ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/PhotonIDMod.cc
Revision: 1.15
Committed: Tue Jul 6 08:33:16 2010 UTC (14 years, 10 months ago) by sixie
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d
Changes since 1.14: +10 -7 lines
Log Message:
added null pointer protections

File Contents

# User Rev Content
1 sixie 1.15 // $Id: PhotonIDMod.cc,v 1.14 2010/05/21 05:59:55 ceballos Exp $
2 sixie 1.1
3     #include "MitPhysics/Mods/interface/PhotonIDMod.h"
4 loizides 1.7 #include "MitAna/DataTree/interface/PhotonCol.h"
5 sixie 1.1 #include "MitPhysics/Init/interface/ModNames.h"
6    
7     using namespace mithep;
8    
9     ClassImp(mithep::PhotonIDMod)
10    
11     //--------------------------------------------------------------------------------------------------
12     PhotonIDMod::PhotonIDMod(const char *name, const char *title) :
13     BaseMod(name,title),
14     fPhotonBranchName(Names::gkPhotonBrn),
15     fGoodPhotonsName(ModNames::gkGoodPhotonsName),
16 ceballos 1.5 fPhotonIDType("Custom"),
17 ceballos 1.2 fPhotonIsoType("CombinedIso"),
18 sixie 1.1 fPhotonPtMin(15.0),
19 ceballos 1.10 fHadOverEmMax(0.05),
20 sixie 1.13 fApplySpikeRemoval(kTRUE),
21 ceballos 1.2 fApplyPixelSeed(kTRUE),
22 ceballos 1.10 fPhotonR9Min(0.5),
23 sixie 1.1 fPhIdType(kIdUndef),
24 loizides 1.7 fPhIsoType(kIsoUndef),
25 ceballos 1.10 fFiduciality(kTRUE),
26     fEtaWidthEB(0.013),
27     fEtaWidthEE(0.031),
28 ceballos 1.11 fAbsEtaMax(2.5),
29 loizides 1.7 fPhotons(0)
30 sixie 1.1 {
31     // Constructor.
32     }
33    
34     //--------------------------------------------------------------------------------------------------
35     void PhotonIDMod::Process()
36     {
37     // Process entries of the tree.
38    
39 loizides 1.6 LoadEventObject(fPhotonBranchName, fPhotons);
40 sixie 1.1
41     PhotonOArr *GoodPhotons = new PhotonOArr;
42     GoodPhotons->SetName(fGoodPhotonsName);
43    
44     for (UInt_t i=0; i<fPhotons->GetEntries(); ++i) {
45     const Photon *ph = fPhotons->At(i);
46    
47     if (ph->Pt() <= fPhotonPtMin)
48     continue;
49 sixie 1.13
50    
51 sixie 1.1
52 sixie 1.13 Bool_t passSpikeRemovalFilter = kTRUE;
53 sixie 1.15
54     if (ph->SCluster() && ph->SCluster()->Seed()) {
55     if(ph->SCluster()->Seed()->Energy() > 5.0 &&
56     ph->SCluster()->Seed()->EMax() / ph->SCluster()->Seed()->E3x3() > 0.95
57     ) {
58     passSpikeRemovalFilter = kFALSE;
59     }
60 sixie 1.13 }
61    
62     // For Now Only use the EMax/E3x3 prescription.
63     //if(ph->SCluster()->Seed()->Energy() > 5.0 &&
64     // (1 - (ph->SCluster()->Seed()->E1x3() + ph->SCluster()->Seed()->E3x1() - 2*ph->SCluster()->Seed()->EMax())) > 0.95
65     // ) {
66     // passSpikeRemovalFilter = kFALSE;
67     //}
68     if (fApplySpikeRemoval && !passSpikeRemovalFilter) continue;
69    
70    
71    
72 ceballos 1.2 if (ph->HadOverEm() >= fHadOverEmMax)
73     continue;
74 ceballos 1.14
75 ceballos 1.2 if (fApplyPixelSeed == kTRUE &&
76     ph->HasPixelSeed() == kTRUE)
77     continue;
78 ceballos 1.14
79 sixie 1.1 Bool_t idcut = kFALSE;
80     switch (fPhIdType) {
81     case kTight:
82     idcut = ph->IsTightPhoton();
83     break;
84     case kLoose:
85     idcut = ph->IsLoosePhoton();
86     break;
87     case kLooseEM:
88     idcut = ph->IsLooseEM();
89     break;
90     case kCustomId:
91 ceballos 1.5 idcut = kTRUE;
92 sixie 1.1 default:
93     break;
94     }
95    
96     if (!idcut)
97     continue;
98    
99     Bool_t isocut = kFALSE;
100     switch (fPhIsoType) {
101     case kNoIso:
102     isocut = kTRUE;
103     break;
104 ceballos 1.2 case kCombinedIso:
105 bendavid 1.12 {
106     Double_t totalIso = ph->HollowConeTrkIsoDr04()+
107     ph->EcalRecHitIsoDr04() +
108     ph->HcalTowerSumEtDr04();
109     if (totalIso/ph->Pt() < 0.25)
110     isocut = kTRUE;
111     }
112 ceballos 1.2 break;
113 sixie 1.1 case kCustomIso:
114     default:
115     break;
116     }
117    
118     if (!isocut)
119     continue;
120    
121 ceballos 1.5 if (ph->R9() <= fPhotonR9Min)
122     continue;
123    
124 ceballos 1.10 if (fFiduciality == kTRUE &&
125     ph->IsEB() == kFALSE && ph->IsEE() == kFALSE)
126     continue;
127    
128 sixie 1.15 if ((ph->IsEB() == kTRUE && ph->SCluster() && ph->SCluster()->EtaWidth() >= fEtaWidthEB) ||
129     (ph->IsEE() == kTRUE && ph->SCluster() && ph->SCluster()->EtaWidth() >= fEtaWidthEE))
130 ceballos 1.10 continue;
131    
132 ceballos 1.11 if (ph->AbsEta() >= fAbsEtaMax)
133     continue;
134 ceballos 1.14
135 sixie 1.1 // add good electron
136     GoodPhotons->Add(fPhotons->At(i));
137     }
138    
139 loizides 1.4 // sort according to pt
140     GoodPhotons->Sort();
141    
142 sixie 1.1 // add to event for other modules to use
143     AddObjThisEvt(GoodPhotons);
144     }
145    
146     //--------------------------------------------------------------------------------------------------
147     void PhotonIDMod::SlaveBegin()
148     {
149     // Run startup code on the computer (slave) doing the actual analysis. Here,
150 loizides 1.3 // we just request the photon collection branch.
151 sixie 1.1
152 loizides 1.6 ReqEventObject(fPhotonBranchName, fPhotons, kTRUE);
153 sixie 1.1
154     if (fPhotonIDType.CompareTo("Tight") == 0)
155     fPhIdType = kTight;
156     else if (fPhotonIDType.CompareTo("Loose") == 0)
157     fPhIdType = kLoose;
158     else if (fPhotonIDType.CompareTo("LooseEM") == 0)
159     fPhIdType = kLooseEM;
160     else if (fPhotonIDType.CompareTo("Custom") == 0) {
161     fPhIdType = kCustomId;
162     } else {
163     SendError(kAbortAnalysis, "SlaveBegin",
164 ceballos 1.2 "The specified photon identification %s is not defined.",
165 sixie 1.1 fPhotonIDType.Data());
166     return;
167     }
168    
169     if (fPhotonIsoType.CompareTo("NoIso") == 0 )
170     fPhIsoType = kNoIso;
171 ceballos 1.2 else if (fPhotonIsoType.CompareTo("CombinedIso") == 0 )
172     fPhIsoType = kCombinedIso;
173 sixie 1.1 else if (fPhotonIsoType.CompareTo("Custom") == 0 ) {
174     fPhIsoType = kCustomIso;
175     SendError(kWarning, "SlaveBegin",
176 ceballos 1.2 "Custom photon isolation is not yet implemented.");
177 sixie 1.1 } else {
178     SendError(kAbortAnalysis, "SlaveBegin",
179 ceballos 1.2 "The specified photon isolation %s is not defined.",
180 sixie 1.1 fPhotonIsoType.Data());
181     return;
182     }
183     }