ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/CosmicCleaningMod.cc
Revision: 1.3
Committed: Wed Oct 9 22:16:27 2013 UTC (11 years, 7 months ago) by dimatteo
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +18 -2 lines
Log Message:
new cleaning

File Contents

# Content
1 // $Id: CosmicCleaningMod.cc,v 1.0
2
3 #include "MitPhysics/Mods/interface/CosmicCleaningMod.h"
4 #include "MitCommon/MathTools/interface/MathUtils.h"
5 #include "MitAna/DataTree/interface/Track.h"
6 #include "MitPhysics/Init/interface/ModNames.h"
7
8 using namespace mithep;
9
10 ClassImp(mithep::CosmicCleaningMod)
11
12 //--------------------------------------------------------------------------------------------------
13 CosmicCleaningMod::CosmicCleaningMod(const char *name, const char *title) :
14 BaseMod(name,title),
15 fCosmicsName("random"),
16 fCleanMuonsName(ModNames::gkCleanMuonsName),
17 fCleanCosmicsName(ModNames::gkCleanCosmicsName),
18 fDeltaR(0.1),
19 fCosmics(0)
20 {
21 // Constructor.
22 }
23
24 //--------------------------------------------------------------------------------------------------
25 void CosmicCleaningMod::Process()
26 {
27 // Process entries of the tree.
28
29 // get input collection
30 const MuonCol *CleanMuons = GetObjThisEvt<MuonCol>(fCleanMuonsName);
31 LoadEventObject(fCosmicsName, fCosmics);
32
33 // Go through all cosmics and remove cosmic overlaps with collision muons and duplicates.
34 std::vector<const Muon*> CleanCosTemp;
35
36 if (fCosmics) {
37 for (UInt_t i=0; i<fCosmics->GetEntries(); ++i) {
38 const Muon *u = fCosmics->At(i);
39
40 FourVectorM mom(u->Mom());
41 // Invert the cosmic momentum for fake cosmic cleaning
42 FourVectorM momInv(mom.Pt(),-mom.Eta(),mom.Phi()+TMath::Pi(),mom.M());
43
44 // Check whether it overlaps with a good muon: If the muon and cosmic both have
45 // tracker tracks then compare the tracks, otherwise
46 Bool_t isMuonOverlap = kFALSE;
47 if (CleanMuons) {
48 UInt_t n = CleanMuons->GetEntries();
49 for (UInt_t j=0; j<n; ++j) {
50 Double_t deltaR = MathUtils::DeltaR(CleanMuons->At(j)->Mom(), mom);
51 Double_t deltaRInv = MathUtils::DeltaR(CleanMuons->At(j)->Mom(), momInv);
52 if (deltaR < fDeltaR || deltaRInv < fDeltaR) {
53 isMuonOverlap = kTRUE;
54 break;
55 }
56 }
57 } else {
58 cout << "Warning: GoodMuons collection " << fCleanMuonsName << " was not found.\n";
59 }
60
61 if (isMuonOverlap)
62 continue;
63
64 // Check whether it overlaps with another cosmic candidate:
65 bool isCosmicOverlap = kFALSE;
66 for (UInt_t j=0; j<CleanCosTemp.size(); ++j) {
67 Double_t deltaR = MathUtils::DeltaR(CleanCosTemp[j]->Mom(), mom);
68 if (deltaR < 0.1) {
69 isCosmicOverlap = kTRUE;
70 break;
71 }
72 }
73
74 if (isCosmicOverlap)
75 continue;
76
77 // if no overlaps then add to clean cosmics
78 CleanCosTemp.push_back(fCosmics->At(i));
79 }
80 } else {
81 cout << "Warning: fCosmics collection " << fCosmicsName << " was not found.\n";
82 }
83
84 // Fill the muon array with the contents of the vector:
85 MuonOArr *CleanCosmics = new MuonOArr;
86 CleanCosmics->SetName(fCleanCosmicsName);
87
88 for (UInt_t j=0; j<CleanCosTemp.size(); ++j) CleanCosmics->Add(CleanCosTemp[j]);
89 CleanCosmics->Sort();
90
91 // add to event for other modules to use
92 AddObjThisEvt(CleanCosmics);
93 }
94
95 //--------------------------------------------------------------------------------------------------
96 void CosmicCleaningMod::SlaveBegin()
97 {
98 ReqEventObject(fCosmicsName, fCosmics, kTRUE);
99
100 }