ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/ElectronCleaningMod.cc
Revision: 1.11
Committed: Sun Mar 27 17:05:55 2011 UTC (14 years, 1 month ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b
Changes since 1.10: +1 -2 lines
Log Message:
small fix

File Contents

# Content
1 // $Id: ElectronCleaningMod.cc,v 1.10 2010/06/28 21:08:19 ceballos Exp $
2
3 #include "MitPhysics/Mods/interface/ElectronCleaningMod.h"
4 #include "MitCommon/MathTools/interface/MathUtils.h"
5 #include "MitAna/DataTree/interface/ElectronCol.h"
6 #include "MitAna/DataTree/interface/MuonCol.h"
7 #include "MitAna/DataTree/interface/Track.h"
8 #include "MitPhysics/Init/interface/ModNames.h"
9
10 using namespace mithep;
11
12 ClassImp(mithep::ElectronCleaningMod)
13
14 //--------------------------------------------------------------------------------------------------
15 ElectronCleaningMod::ElectronCleaningMod(const char *name, const char *title) :
16 BaseMod(name,title),
17 fGoodElectronsName(ModNames::gkGoodElectronsName),
18 fCleanMuonsName(ModNames::gkCleanMuonsName),
19 fCleanElectronsName(ModNames::gkCleanElectronsName)
20 {
21 // Constructor.
22 }
23
24 //--------------------------------------------------------------------------------------------------
25 void ElectronCleaningMod::Process()
26 {
27 // Process entries of the tree.
28
29 // get input collection
30 const MuonCol *CleanMuons = GetObjThisEvt<MuonCol>(fCleanMuonsName);
31 const ElectronCol *GoodElectrons = GetObjThisEvt<ElectronCol>(fGoodElectronsName);
32
33 // Go through all electrons and remove electron overlaps with muons and duplicates.
34 std::vector<const Electron*> CleanElTemp;
35 for (UInt_t i=0; i<GoodElectrons->GetEntries(); ++i) {
36 const Electron *e = GoodElectrons->At(i);
37
38 FourVectorM mom(e->Mom());
39
40 // Check whether it overlaps with a good muon: If the muon and electron both have
41 // tracker tracks then compare the tracks, otherwise
42 Bool_t isMuonOverlap = kFALSE;
43 UInt_t n = CleanMuons->GetEntries();
44 for (UInt_t j=0; j<n; ++j) {
45 Double_t deltaR = MathUtils::DeltaR(CleanMuons->At(j)->Mom(), mom);
46 if (deltaR < 0.1) {
47 isMuonOverlap = kTRUE;
48 break;
49 }
50 }
51
52 if (isMuonOverlap)
53 continue;
54
55 // Check whether it overlaps with another electron candidate:
56 // Here I check whether we have two electron candidates with the same super cluster
57 // or two electron candidates with the same track. At the end we also check deltaR
58 // to be sure. If there is a duplicate we swap the old one with the new one if the new
59 // one has E/P closer to 1.0.
60 bool isElectronOverlap = kFALSE;
61 for (UInt_t j=0; j<CleanElTemp.size(); ++j) {
62
63 if (e->SCluster() == CleanElTemp[j]->SCluster() ||
64 e->Trk() == CleanElTemp[j]->Trk())
65 isElectronOverlap = kTRUE;
66
67 if (!isElectronOverlap) {
68 Double_t deltaR = MathUtils::DeltaR(CleanElTemp[j]->Mom(), mom);
69 if (deltaR < 0.1)
70 isElectronOverlap = kTRUE;
71 }
72
73 if (isElectronOverlap) {
74 if (TMath::Abs(CleanElTemp[j]->ESuperClusterOverP() - 1) >
75 TMath::Abs(e->ESuperClusterOverP() - 1)) {
76 CleanElTemp[j] = e;
77 }
78 break;
79 }
80 }
81
82 if (isElectronOverlap)
83 continue;
84
85 // if no overlaps then add to clean electrons
86 CleanElTemp.push_back(GoodElectrons->At(i));
87 }
88
89 // Fill the electron array with the contents of the vector:
90 ElectronOArr *CleanElectrons = new ElectronOArr;
91 CleanElectrons->SetName(fCleanElectronsName);
92
93 for (UInt_t j=0; j<CleanElTemp.size(); ++j)
94 CleanElectrons->Add(CleanElTemp[j]);
95 CleanElectrons->Sort();
96
97 // add to event for other modules to use
98 AddObjThisEvt(CleanElectrons);
99 }