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

# User Rev Content
1 ceballos 1.11 // $Id: ElectronCleaningMod.cc,v 1.10 2010/06/28 21:08:19 ceballos Exp $
2 loizides 1.1
3     #include "MitPhysics/Mods/interface/ElectronCleaningMod.h"
4 loizides 1.3 #include "MitCommon/MathTools/interface/MathUtils.h"
5 loizides 1.9 #include "MitAna/DataTree/interface/ElectronCol.h"
6     #include "MitAna/DataTree/interface/MuonCol.h"
7     #include "MitAna/DataTree/interface/Track.h"
8 loizides 1.3 #include "MitPhysics/Init/interface/ModNames.h"
9 loizides 1.1
10     using namespace mithep;
11    
12     ClassImp(mithep::ElectronCleaningMod)
13    
14     //--------------------------------------------------------------------------------------------------
15 loizides 1.4 ElectronCleaningMod::ElectronCleaningMod(const char *name, const char *title) :
16 loizides 1.1 BaseMod(name,title),
17 loizides 1.3 fGoodElectronsName(ModNames::gkGoodElectronsName),
18     fCleanMuonsName(ModNames::gkCleanMuonsName),
19 loizides 1.4 fCleanElectronsName(ModNames::gkCleanElectronsName)
20 loizides 1.1 {
21     // Constructor.
22     }
23    
24     //--------------------------------------------------------------------------------------------------
25     void ElectronCleaningMod::Process()
26     {
27 loizides 1.4 // Process entries of the tree.
28 loizides 1.1
29 loizides 1.4 // get input collection
30 loizides 1.7 const MuonCol *CleanMuons = GetObjThisEvt<MuonCol>(fCleanMuonsName);
31     const ElectronCol *GoodElectrons = GetObjThisEvt<ElectronCol>(fGoodElectronsName);
32 loizides 1.1
33 loizides 1.4 // Go through all electrons and remove electron overlaps with muons and duplicates.
34     std::vector<const Electron*> CleanElTemp;
35 loizides 1.1 for (UInt_t i=0; i<GoodElectrons->GetEntries(); ++i) {
36 loizides 1.4 const Electron *e = GoodElectrons->At(i);
37 loizides 1.1
38 loizides 1.8 FourVectorM mom(e->Mom());
39 loizides 1.4
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 loizides 1.7 UInt_t n = CleanMuons->GetEntries();
44     for (UInt_t j=0; j<n; ++j) {
45 ceballos 1.10 Double_t deltaR = MathUtils::DeltaR(CleanMuons->At(j)->Mom(), mom);
46     if (deltaR < 0.1) {
47     isMuonOverlap = kTRUE;
48     break;
49 loizides 1.1 }
50     }
51 loizides 1.4
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 ceballos 1.5 isElectronOverlap = kTRUE;
71 loizides 1.4 }
72 loizides 1.1
73     if (isElectronOverlap) {
74 loizides 1.4 if (TMath::Abs(CleanElTemp[j]->ESuperClusterOverP() - 1) >
75     TMath::Abs(e->ESuperClusterOverP() - 1)) {
76     CleanElTemp[j] = e;
77 loizides 1.1 }
78     break;
79     }
80     }
81    
82 loizides 1.4 if (isElectronOverlap)
83     continue;
84 loizides 1.1
85 loizides 1.4 // if no overlaps then add to clean electrons
86     CleanElTemp.push_back(GoodElectrons->At(i));
87     }
88 loizides 1.1
89 loizides 1.4 // Fill the electron array with the contents of the vector:
90     ElectronOArr *CleanElectrons = new ElectronOArr;
91     CleanElectrons->SetName(fCleanElectronsName);
92 loizides 1.1
93 loizides 1.4 for (UInt_t j=0; j<CleanElTemp.size(); ++j)
94     CleanElectrons->Add(CleanElTemp[j]);
95 loizides 1.6 CleanElectrons->Sort();
96 loizides 1.4
97     // add to event for other modules to use
98     AddObjThisEvt(CleanElectrons);
99 loizides 1.1 }