ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/ElectronCleaningMod.cc
Revision: 1.10
Committed: Mon Jun 28 21:08:19 2010 UTC (14 years, 10 months ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c
Changes since 1.9: +5 -13 lines
Log Message:
change electron cleaning

File Contents

# Content
1 // $Id: ElectronCleaningMod.cc,v 1.9 2009/06/15 15:00:21 loizides 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 const Track *trtrack = e->TrackerTrk();
40
41 // Check whether it overlaps with a good muon: If the muon and electron both have
42 // tracker tracks then compare the tracks, otherwise
43 Bool_t isMuonOverlap = kFALSE;
44 UInt_t n = CleanMuons->GetEntries();
45 for (UInt_t j=0; j<n; ++j) {
46 Double_t deltaR = MathUtils::DeltaR(CleanMuons->At(j)->Mom(), mom);
47 if (deltaR < 0.1) {
48 isMuonOverlap = kTRUE;
49 break;
50 }
51 }
52
53 if (isMuonOverlap)
54 continue;
55
56 // Check whether it overlaps with another electron candidate:
57 // Here I check whether we have two electron candidates with the same super cluster
58 // or two electron candidates with the same track. At the end we also check deltaR
59 // to be sure. If there is a duplicate we swap the old one with the new one if the new
60 // one has E/P closer to 1.0.
61 bool isElectronOverlap = kFALSE;
62 for (UInt_t j=0; j<CleanElTemp.size(); ++j) {
63
64 if (e->SCluster() == CleanElTemp[j]->SCluster() ||
65 e->Trk() == CleanElTemp[j]->Trk())
66 isElectronOverlap = kTRUE;
67
68 if (!isElectronOverlap) {
69 Double_t deltaR = MathUtils::DeltaR(CleanElTemp[j]->Mom(), mom);
70 if (deltaR < 0.1)
71 isElectronOverlap = kTRUE;
72 }
73
74 if (isElectronOverlap) {
75 if (TMath::Abs(CleanElTemp[j]->ESuperClusterOverP() - 1) >
76 TMath::Abs(e->ESuperClusterOverP() - 1)) {
77 CleanElTemp[j] = e;
78 }
79 break;
80 }
81 }
82
83 if (isElectronOverlap)
84 continue;
85
86 // if no overlaps then add to clean electrons
87 CleanElTemp.push_back(GoodElectrons->At(i));
88 }
89
90 // Fill the electron array with the contents of the vector:
91 ElectronOArr *CleanElectrons = new ElectronOArr;
92 CleanElectrons->SetName(fCleanElectronsName);
93
94 for (UInt_t j=0; j<CleanElTemp.size(); ++j)
95 CleanElectrons->Add(CleanElTemp[j]);
96 CleanElectrons->Sort();
97
98 // add to event for other modules to use
99 AddObjThisEvt(CleanElectrons);
100 }