1 |
bendavid |
1.1 |
#include "MitPhysics/Mods/interface/PhotonTreeWriter.h"
|
2 |
|
|
#include "MitAna/DataTree/interface/PhotonCol.h"
|
3 |
|
|
#include "MitAna/DataTree/interface/PFCandidateCol.h"
|
4 |
|
|
#include "MitAna/DataTree/interface/StableData.h"
|
5 |
|
|
#include "MitAna/DataTree/interface/StableParticle.h"
|
6 |
|
|
#include "MitPhysics/Init/interface/ModNames.h"
|
7 |
|
|
#include "MitPhysics/Utils/interface/IsolationTools.h"
|
8 |
|
|
#include "MitPhysics/Utils/interface/PhotonTools.h"
|
9 |
|
|
#include "MitPhysics/Utils/interface/VertexTools.h"
|
10 |
|
|
#include "MitPhysics/Utils/interface/PhotonFix.h"
|
11 |
|
|
#include "TDataMember.h"
|
12 |
|
|
#include <TNtuple.h>
|
13 |
|
|
#include <TRandom3.h>
|
14 |
|
|
#include <TSystem.h>
|
15 |
|
|
|
16 |
|
|
using namespace mithep;
|
17 |
|
|
|
18 |
|
|
ClassImp(mithep::PhotonTreeWriter)
|
19 |
|
|
ClassImp(mithep::PhotonTreeWriterPhoton)
|
20 |
|
|
ClassImp(mithep::PhotonTreeWriterDiphotonEvent)
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
//--------------------------------------------------------------------------------------------------
|
24 |
|
|
PhotonTreeWriter::PhotonTreeWriter(const char *name, const char *title) :
|
25 |
|
|
// Base Module...
|
26 |
|
|
BaseMod (name,title),
|
27 |
|
|
|
28 |
|
|
// define all the Branches to load
|
29 |
|
|
fPhotonBranchName (Names::gkPhotonBrn),
|
30 |
|
|
fElectronName (Names::gkElectronBrn),
|
31 |
|
|
fGoodElectronName (Names::gkElectronBrn),
|
32 |
|
|
fConversionName (Names::gkMvfConversionBrn),
|
33 |
|
|
fTrackBranchName (Names::gkTrackBrn),
|
34 |
|
|
fPileUpDenName (Names::gkPileupEnergyDensityBrn),
|
35 |
|
|
fPVName (Names::gkPVBeamSpotBrn),
|
36 |
|
|
fBeamspotName (Names::gkBeamSpotBrn),
|
37 |
|
|
fPFCandName (Names::gkPFCandidatesBrn),
|
38 |
|
|
// MC specific stuff...
|
39 |
|
|
fMCParticleName (Names::gkMCPartBrn),
|
40 |
|
|
fPileUpName (Names::gkPileupInfoBrn),
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
fIsData (false),
|
44 |
|
|
fPhotonsFromBranch (true),
|
45 |
|
|
fPVFromBranch (true),
|
46 |
|
|
fGoodElectronsFromBranch (kTRUE),
|
47 |
|
|
|
48 |
|
|
// ----------------------------------------
|
49 |
|
|
// collections....
|
50 |
|
|
fPhotons (0),
|
51 |
|
|
fElectrons (0),
|
52 |
|
|
fConversions (0),
|
53 |
|
|
fTracks (0),
|
54 |
|
|
fPileUpDen (0),
|
55 |
|
|
fPV (0),
|
56 |
|
|
fBeamspot (0),
|
57 |
|
|
fPFCands (0),
|
58 |
|
|
fMCParticles (0),
|
59 |
|
|
fPileUp (0),
|
60 |
|
|
|
61 |
|
|
fInvertElectronVeto(kFALSE),
|
62 |
|
|
|
63 |
|
|
fWriteDiphotonTree(kTRUE),
|
64 |
|
|
fWriteSingleTree(kTRUE),
|
65 |
|
|
fTupleName ("hPhotonTree")
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
{
|
69 |
|
|
// Constructor.
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
PhotonTreeWriter::~PhotonTreeWriter(){
|
73 |
|
|
;
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
//--------------------------------------------------------------------------------------------------
|
77 |
|
|
void PhotonTreeWriter::Process()
|
78 |
|
|
{
|
79 |
|
|
// ------------------------------------------------------------
|
80 |
|
|
// Process entries of the tree.
|
81 |
|
|
LoadEventObject(fPhotonBranchName, fPhotons);
|
82 |
|
|
|
83 |
|
|
if (fPhotons->GetEntries()<1) return;
|
84 |
|
|
|
85 |
|
|
LoadEventObject(fElectronName, fElectrons);
|
86 |
|
|
LoadEventObject(fGoodElectronName, fGoodElectrons);
|
87 |
|
|
LoadEventObject(fConversionName, fConversions);
|
88 |
|
|
LoadEventObject(fTrackBranchName, fTracks);
|
89 |
|
|
LoadEventObject(fPileUpDenName, fPileUpDen);
|
90 |
|
|
LoadEventObject(fPVName, fPV);
|
91 |
|
|
LoadEventObject(fBeamspotName, fBeamspot);
|
92 |
|
|
LoadEventObject(fPFCandName, fPFCands);
|
93 |
|
|
|
94 |
|
|
// ------------------------------------------------------------
|
95 |
|
|
// load event based information
|
96 |
|
|
Int_t _numPU = -1.; // some sensible default values....
|
97 |
|
|
Int_t _numPUminus = -1.; // some sensible default values....
|
98 |
|
|
Int_t _numPUplus = -1.; // some sensible default values....
|
99 |
|
|
|
100 |
|
|
Float_t _tRho = -99.;
|
101 |
|
|
if( fPileUpDen->GetEntries() > 0 )
|
102 |
|
|
_tRho = (Double_t) fPileUpDen->At(0)->RhoRandomLowEta();
|
103 |
|
|
|
104 |
|
|
const BaseVertex *bsp = dynamic_cast<const BaseVertex*>(fBeamspot->At(0));
|
105 |
|
|
|
106 |
|
|
if( !fIsData ) {
|
107 |
|
|
LoadBranch(fMCParticleName);
|
108 |
|
|
LoadBranch(fPileUpName);
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
if( !fIsData ) {
|
112 |
|
|
for (UInt_t i=0; i<fPileUp->GetEntries(); ++i) {
|
113 |
|
|
const PileupInfo *puinfo = fPileUp->At(i);
|
114 |
|
|
if (puinfo->GetBunchCrossing()==0) _numPU = puinfo->GetPU_NumInteractions();
|
115 |
|
|
else if (puinfo->GetBunchCrossing() == -1) _numPUminus = puinfo->GetPU_NumInteractions();
|
116 |
|
|
else if (puinfo->GetBunchCrossing() == 1) _numPUplus = puinfo->GetPU_NumInteractions();
|
117 |
|
|
}
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
// in case of a MC event, try to find Higgs and Higgs decay Z poisition
|
121 |
|
|
Float_t _pth = -100.;
|
122 |
|
|
Float_t _decayZ = -100.;
|
123 |
|
|
Float_t _genmass = -100.;
|
124 |
|
|
if( !fIsData ) FindHiggsPtAndZ(_pth, _decayZ, _genmass);
|
125 |
|
|
|
126 |
|
|
fDiphotonEvent->rho = _tRho;
|
127 |
|
|
fDiphotonEvent->genHiggspt = _pth;
|
128 |
|
|
fDiphotonEvent->genHiggsZ = _decayZ;
|
129 |
|
|
fDiphotonEvent->genmass = _genmass;
|
130 |
|
|
fDiphotonEvent->gencostheta = -99.;
|
131 |
|
|
fDiphotonEvent->nVtx = fPV->GetEntries();
|
132 |
|
|
fDiphotonEvent->vtxZ = (fDiphotonEvent->nVtx>0) ? fPV->At(0)->Z() : -99.;
|
133 |
|
|
fDiphotonEvent->numPU = _numPU;
|
134 |
|
|
fDiphotonEvent->numPUminus = _numPUminus;
|
135 |
|
|
fDiphotonEvent->numPUplus = _numPUplus;
|
136 |
|
|
fDiphotonEvent->mass = -99.;
|
137 |
|
|
fDiphotonEvent->ptgg = -99.;
|
138 |
|
|
fDiphotonEvent->costheta = -99.;
|
139 |
|
|
fDiphotonEvent->evt = GetEventHeader()->EvtNum();
|
140 |
|
|
fDiphotonEvent->run = GetEventHeader()->RunNum();
|
141 |
|
|
fDiphotonEvent->lumi = GetEventHeader()->LumiSec();
|
142 |
|
|
fDiphotonEvent->evtcat = -99;
|
143 |
|
|
fDiphotonEvent->masscor = -99.;
|
144 |
|
|
fDiphotonEvent->masscorerr = -99.;
|
145 |
|
|
|
146 |
|
|
Int_t nhitsbeforevtxmax = 1;
|
147 |
|
|
if (fInvertElectronVeto) nhitsbeforevtxmax = 999;
|
148 |
|
|
|
149 |
|
|
if (fPhotons->GetEntries()>=2) {
|
150 |
|
|
Bool_t doFill = kTRUE;
|
151 |
|
|
|
152 |
|
|
const Photon *phHard = fPhotons->At(0);
|
153 |
|
|
const Photon *phSoft = fPhotons->At(1);
|
154 |
|
|
|
155 |
|
|
if (phHard->HasPV()) {
|
156 |
|
|
fDiphotonEvent->vtxZ = phHard->PV()->Z();
|
157 |
|
|
}
|
158 |
|
|
|
159 |
|
|
Float_t _mass = ( doFill ? (phHard->Mom()+phSoft->Mom()).M() : -100.);
|
160 |
|
|
Float_t _ptgg = ( doFill ? (phHard->Mom()+phSoft->Mom()).Pt() : -100.);
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
const DecayParticle *conv1 = PhotonTools::MatchedConversion(phHard,fConversions,bsp,nhitsbeforevtxmax);
|
164 |
|
|
const DecayParticle *conv2 = PhotonTools::MatchedConversion(phSoft,fConversions,bsp,nhitsbeforevtxmax);
|
165 |
|
|
|
166 |
|
|
const MCParticle *phgen1 = 0;
|
167 |
|
|
const MCParticle *phgen2 = 0;
|
168 |
|
|
if( !fIsData ) {
|
169 |
|
|
phgen1 = PhotonTools::MatchMC(phHard,fMCParticles,!fInvertElectronVeto);
|
170 |
|
|
phgen2 = PhotonTools::MatchMC(phSoft,fMCParticles,!fInvertElectronVeto);
|
171 |
|
|
}
|
172 |
|
|
|
173 |
|
|
Float_t _gencostheta = -99.;
|
174 |
|
|
if (phgen1 && phgen2) {
|
175 |
|
|
_gencostheta = ThreeVector(phgen1->Mom()).Unit().Dot(ThreeVector(phgen2->Mom()).Unit());
|
176 |
|
|
}
|
177 |
|
|
|
178 |
|
|
fDiphotonEvent->gencostheta = _gencostheta;
|
179 |
|
|
fDiphotonEvent->mass = _mass;
|
180 |
|
|
fDiphotonEvent->ptgg = _ptgg;
|
181 |
|
|
fDiphotonEvent->costheta = ThreeVector(phHard->Mom()).Unit().Dot(ThreeVector(phSoft->Mom()).Unit());
|
182 |
|
|
fDiphotonEvent->evtcat = PhotonTools::DiphotonR9EtaPtCat(phHard,phSoft);
|
183 |
|
|
|
184 |
|
|
fDiphotonEvent->photons[0].SetVars(phHard,conv1,phgen1);
|
185 |
|
|
fDiphotonEvent->photons[1].SetVars(phSoft,conv2,phgen2);
|
186 |
|
|
|
187 |
|
|
Float_t ph1ecor = fDiphotonEvent->photons[0].Ecor();
|
188 |
|
|
Float_t ph1ecorerr = fDiphotonEvent->photons[0].Ecorerr();
|
189 |
|
|
Float_t ph2ecor = fDiphotonEvent->photons[1].Ecor();
|
190 |
|
|
Float_t ph2ecorerr = fDiphotonEvent->photons[1].Ecorerr();
|
191 |
|
|
|
192 |
|
|
fDiphotonEvent->masscor = TMath::Sqrt(2.0*ph1ecor*ph2ecor*(1.0-fDiphotonEvent->costheta));
|
193 |
|
|
fDiphotonEvent->masscorerr = 0.5*fDiphotonEvent->masscor*TMath::Sqrt(ph1ecorerr*ph1ecorerr/ph1ecor/ph1ecor + ph2ecorerr*ph2ecorerr/ph2ecor/ph2ecor);
|
194 |
|
|
|
195 |
|
|
//printf("r9 = %5f, photon sigieie = %5f, seed sigieie = %5f\n",phHard->R9(),phHard->CoviEtaiEta(),sqrt(phHard->SCluster()->Seed()->CoviEtaiEta()));
|
196 |
|
|
|
197 |
|
|
if (fWriteDiphotonTree) hCiCTuple->Fill();
|
198 |
|
|
|
199 |
|
|
}
|
200 |
|
|
|
201 |
|
|
if (!fWriteSingleTree) return;
|
202 |
|
|
|
203 |
|
|
|
204 |
|
|
for (UInt_t iph = 0; iph<fPhotons->GetEntries(); ++iph) {
|
205 |
|
|
const Photon *ph = fPhotons->At(iph);
|
206 |
|
|
|
207 |
|
|
if (ph->HasPV()) {
|
208 |
|
|
fDiphotonEvent->vtxZ = ph->PV()->Z();
|
209 |
|
|
}
|
210 |
|
|
|
211 |
|
|
const MCParticle *phgen = 0;
|
212 |
|
|
if( !fIsData ) {
|
213 |
|
|
phgen = PhotonTools::MatchMC(ph,fMCParticles,!fInvertElectronVeto);
|
214 |
|
|
}
|
215 |
|
|
|
216 |
|
|
const DecayParticle *conv = PhotonTools::MatchedConversion(ph,fConversions,bsp,nhitsbeforevtxmax);
|
217 |
|
|
|
218 |
|
|
fSinglePhoton->SetVars(ph,conv,phgen);
|
219 |
|
|
hCiCTupleSingle->Fill();
|
220 |
|
|
|
221 |
|
|
}
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
return;
|
225 |
|
|
|
226 |
|
|
}
|
227 |
|
|
|
228 |
|
|
//--------------------------------------------------------------------------------------------------
|
229 |
|
|
void PhotonTreeWriter::SlaveBegin()
|
230 |
|
|
{
|
231 |
|
|
// Run startup code on the computer (slave) doing the actual analysis. Here,
|
232 |
|
|
// we just request the photon collection branch.
|
233 |
|
|
|
234 |
|
|
ReqEventObject(fPhotonBranchName, fPhotons, fPhotonsFromBranch);
|
235 |
|
|
ReqEventObject(fTrackBranchName, fTracks, true);
|
236 |
|
|
ReqEventObject(fElectronName, fElectrons, true);
|
237 |
|
|
ReqEventObject(fGoodElectronName, fGoodElectrons, fGoodElectronsFromBranch);
|
238 |
|
|
ReqEventObject(fPileUpDenName, fPileUpDen, true);
|
239 |
|
|
ReqEventObject(fPVName, fPV, fPVFromBranch);
|
240 |
|
|
ReqEventObject(fConversionName, fConversions,true);
|
241 |
|
|
ReqEventObject(fBeamspotName, fBeamspot, true);
|
242 |
|
|
ReqEventObject(fPFCandName, fPFCands, true);
|
243 |
|
|
|
244 |
|
|
if (!fIsData) {
|
245 |
|
|
ReqBranch(fPileUpName, fPileUp);
|
246 |
|
|
ReqBranch(fMCParticleName, fMCParticles);
|
247 |
|
|
}
|
248 |
|
|
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
//initialize photon energy corrections
|
252 |
|
|
//PhotonFix::initialise("4_2",std::string((gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/PhotonFix.dat")).Data()));
|
253 |
|
|
|
254 |
|
|
fDiphotonEvent = new PhotonTreeWriterDiphotonEvent;
|
255 |
|
|
fSinglePhoton = new PhotonTreeWriterPhoton;
|
256 |
|
|
|
257 |
|
|
|
258 |
|
|
if (fWriteDiphotonTree) hCiCTuple = new TTree(fTupleName.Data(),fTupleName.Data());
|
259 |
|
|
TString singlename = fTupleName + TString("Single");
|
260 |
|
|
if (fWriteSingleTree) hCiCTupleSingle = new TTree(singlename,singlename);
|
261 |
|
|
|
262 |
|
|
//make flattish tree from classes so we don't have to rely on dictionaries for reading later
|
263 |
|
|
TClass *eclass = TClass::GetClass("mithep::PhotonTreeWriterDiphotonEvent");
|
264 |
|
|
TClass *pclass = TClass::GetClass("mithep::PhotonTreeWriterPhoton");
|
265 |
|
|
TList *elist = eclass->GetListOfDataMembers();
|
266 |
|
|
TList *plist = pclass->GetListOfDataMembers();
|
267 |
|
|
|
268 |
|
|
for (int i=0; i<elist->GetEntries(); ++i) {
|
269 |
|
|
const TDataMember *tdm = static_cast<const TDataMember*>(elist->At(i));
|
270 |
|
|
if (!(tdm->IsBasic() && tdm->IsPersistent())) continue;
|
271 |
|
|
TString typestring;
|
272 |
|
|
if (TString(tdm->GetTypeName())=="Char_t") typestring = "B";
|
273 |
|
|
else if (TString(tdm->GetTypeName())=="UChar_t") typestring = "b";
|
274 |
|
|
else if (TString(tdm->GetTypeName())=="Short_t") typestring = "S";
|
275 |
|
|
else if (TString(tdm->GetTypeName())=="UShort_t") typestring = "s";
|
276 |
|
|
else if (TString(tdm->GetTypeName())=="Int_t") typestring = "I";
|
277 |
|
|
else if (TString(tdm->GetTypeName())=="UInt_t") typestring = "i";
|
278 |
|
|
else if (TString(tdm->GetTypeName())=="Float_t") typestring = "F";
|
279 |
|
|
else if (TString(tdm->GetTypeName())=="Double_t") typestring = "D";
|
280 |
|
|
else if (TString(tdm->GetTypeName())=="Long64_t") typestring = "L";
|
281 |
|
|
else if (TString(tdm->GetTypeName())=="ULong64_t") typestring = "l";
|
282 |
|
|
else if (TString(tdm->GetTypeName())=="Bool_t") typestring = "O";
|
283 |
|
|
else continue;
|
284 |
|
|
//printf("%s %s: %i\n",tdm->GetTypeName(),tdm->GetName(),int(tdm->GetOffset()));
|
285 |
|
|
Char_t *addr = (Char_t*)fDiphotonEvent;
|
286 |
|
|
assert(sizeof(Char_t)==1);
|
287 |
|
|
if (fWriteDiphotonTree) hCiCTuple->Branch(tdm->GetName(),addr + tdm->GetOffset(),TString::Format("%s/%s",tdm->GetName(),typestring.Data()));
|
288 |
|
|
if (fWriteSingleTree) hCiCTupleSingle->Branch(tdm->GetName(),addr + tdm->GetOffset(),TString::Format("%s/%s",tdm->GetName(),typestring.Data()));
|
289 |
|
|
}
|
290 |
|
|
|
291 |
|
|
for (int iph=0; iph<2; ++iph) {
|
292 |
|
|
for (int i=0; i<plist->GetEntries(); ++i) {
|
293 |
|
|
const TDataMember *tdm = static_cast<const TDataMember*>(plist->At(i));
|
294 |
|
|
if (!(tdm->IsBasic() && tdm->IsPersistent())) continue;
|
295 |
|
|
TString typestring;
|
296 |
|
|
if (TString(tdm->GetTypeName())=="Char_t") typestring = "B";
|
297 |
|
|
else if (TString(tdm->GetTypeName())=="UChar_t") typestring = "b";
|
298 |
|
|
else if (TString(tdm->GetTypeName())=="Short_t") typestring = "S";
|
299 |
|
|
else if (TString(tdm->GetTypeName())=="UShort_t") typestring = "s";
|
300 |
|
|
else if (TString(tdm->GetTypeName())=="Int_t") typestring = "I";
|
301 |
|
|
else if (TString(tdm->GetTypeName())=="UInt_t") typestring = "i";
|
302 |
|
|
else if (TString(tdm->GetTypeName())=="Float_t") typestring = "F";
|
303 |
|
|
else if (TString(tdm->GetTypeName())=="Double_t") typestring = "D";
|
304 |
|
|
else if (TString(tdm->GetTypeName())=="Long64_t") typestring = "L";
|
305 |
|
|
else if (TString(tdm->GetTypeName())=="ULong64_t") typestring = "l";
|
306 |
|
|
else if (TString(tdm->GetTypeName())=="Bool_t") typestring = "O";
|
307 |
|
|
else continue;
|
308 |
|
|
//printf("%s\n",tdm->GetTypeName());
|
309 |
|
|
TString varname = TString::Format("ph%d.%s",iph+1,tdm->GetName());
|
310 |
|
|
|
311 |
|
|
Char_t *addr = (Char_t*)&fDiphotonEvent->photons[iph];
|
312 |
|
|
assert(sizeof(Char_t)==1);
|
313 |
|
|
if (fWriteDiphotonTree) hCiCTuple->Branch(varname,addr+tdm->GetOffset(),TString::Format("%s/%s",varname.Data(),typestring.Data()));
|
314 |
|
|
|
315 |
|
|
if (iph==0) {
|
316 |
|
|
TString singlename = TString::Format("ph.%s",tdm->GetName());
|
317 |
|
|
Char_t *addrsingle = (Char_t*)fSinglePhoton;
|
318 |
|
|
if (fWriteSingleTree) hCiCTupleSingle->Branch(singlename,addrsingle+tdm->GetOffset(),TString::Format("%s/%s",singlename.Data(),typestring.Data()));
|
319 |
|
|
}
|
320 |
|
|
}
|
321 |
|
|
}
|
322 |
|
|
|
323 |
|
|
|
324 |
|
|
if (fWriteDiphotonTree) AddOutput(hCiCTuple);
|
325 |
|
|
if (fWriteSingleTree) AddOutput(hCiCTupleSingle);
|
326 |
|
|
|
327 |
|
|
|
328 |
|
|
}
|
329 |
|
|
|
330 |
|
|
// ----------------------------------------------------------------------------------------
|
331 |
|
|
// some helpfer functions....
|
332 |
|
|
void PhotonTreeWriter::FindHiggsPtAndZ(Float_t& pt, Float_t& decayZ, Float_t& mass) {
|
333 |
|
|
|
334 |
|
|
pt = -999.;
|
335 |
|
|
decayZ = -999.;
|
336 |
|
|
mass = -999.;
|
337 |
|
|
|
338 |
|
|
// loop over all GEN particles and look for status 1 photons
|
339 |
|
|
for(UInt_t i=0; i<fMCParticles->GetEntries(); ++i) {
|
340 |
|
|
const MCParticle* p = fMCParticles->At(i);
|
341 |
|
|
if( p->Is(MCParticle::kH) || (!fInvertElectronVeto && p->AbsPdgId()==23) ) {
|
342 |
|
|
pt=p->Pt();
|
343 |
|
|
decayZ = p->DecayVertex().Z();
|
344 |
|
|
mass = p->Mass();
|
345 |
|
|
break;
|
346 |
|
|
}
|
347 |
|
|
}
|
348 |
|
|
|
349 |
|
|
return;
|
350 |
|
|
}
|
351 |
|
|
|
352 |
|
|
|
353 |
|
|
Float_t PhotonTreeWriter::GetEventCat(PhotonTools::CiCBaseLineCats cat1, PhotonTools::CiCBaseLineCats cat2) {
|
354 |
|
|
|
355 |
|
|
bool ph1IsEB = (cat1 == PhotonTools::kCiCCat1 || cat1 == PhotonTools::kCiCCat2);
|
356 |
|
|
bool ph2IsEB = (cat2 == PhotonTools::kCiCCat1 || cat2 == PhotonTools::kCiCCat2);
|
357 |
|
|
|
358 |
|
|
bool ph1IsHR9 = (cat1 == PhotonTools::kCiCCat1 || cat1 == PhotonTools::kCiCCat3);
|
359 |
|
|
bool ph2IsHR9 = (cat2 == PhotonTools::kCiCCat1 || cat2 == PhotonTools::kCiCCat3);
|
360 |
|
|
|
361 |
|
|
if( ph1IsEB && ph2IsEB )
|
362 |
|
|
return ( ph1IsHR9 && ph2IsHR9 ? 0. : 1.);
|
363 |
|
|
|
364 |
|
|
return ( ph1IsHR9 && ph2IsHR9 ? 2. : 3.);
|
365 |
|
|
}
|
366 |
|
|
|
367 |
|
|
void PhotonTreeWriterPhoton::SetVars(const Photon *p, const DecayParticle *c, const MCParticle *m) {
|
368 |
|
|
e = p->E();
|
369 |
|
|
pt = p->Pt();
|
370 |
|
|
eta = p->Eta();
|
371 |
|
|
phi = p->Phi();
|
372 |
|
|
r9 = p->R9();
|
373 |
|
|
e3x3 = p->E33();
|
374 |
|
|
e5x5 = p->E55();
|
375 |
|
|
const SuperCluster *s = p->SCluster();
|
376 |
|
|
sce = s->Energy();
|
377 |
|
|
scrawe = s->RawEnergy();
|
378 |
|
|
scpse = s->PreshowerEnergy();
|
379 |
|
|
sceta = s->Eta();
|
380 |
|
|
scphi = s->Phi();
|
381 |
|
|
scnclusters = s->ClusterSize();
|
382 |
|
|
scnhits = s->NHits();
|
383 |
|
|
hovere = p->HadOverEm();
|
384 |
|
|
sigietaieta = p->CoviEtaiEta();
|
385 |
|
|
isbarrel = (s->AbsEta()<1.5);
|
386 |
|
|
isr9reco = (isbarrel && r9>0.94) || (!isbarrel && r9>0.95);
|
387 |
|
|
isr9cat = (r9>0.94);
|
388 |
|
|
|
389 |
|
|
phcat = PhotonTools::CiCBaseLineCat(p);
|
390 |
|
|
|
391 |
|
|
/* if (isbarrel) {
|
392 |
|
|
if (isr9cat) phcat = 1;
|
393 |
|
|
else phcat = 2;
|
394 |
|
|
}
|
395 |
|
|
else {
|
396 |
|
|
if (isr9cat) phcat = 3;
|
397 |
|
|
else phcat = 4;
|
398 |
|
|
}*/
|
399 |
|
|
|
400 |
|
|
const BasicCluster *b = s->Seed();
|
401 |
|
|
sigiphiphi = TMath::Sqrt(b->CoviPhiiPhi());
|
402 |
|
|
if (isnan(sigiphiphi)) sigiphiphi = -99.;
|
403 |
|
|
covietaiphi = b->CoviEtaiPhi();
|
404 |
|
|
if (isnan(covietaiphi)) covietaiphi = -99.;
|
405 |
|
|
emax = b->EMax();
|
406 |
|
|
e2nd = b->E2nd();
|
407 |
|
|
etop = b->ETop();
|
408 |
|
|
ebottom = b->EBottom();
|
409 |
|
|
eleft = b->ELeft();
|
410 |
|
|
eright = b->ERight();
|
411 |
|
|
e1x3 = b->E1x3();
|
412 |
|
|
e3x1 = b->E3x1();
|
413 |
|
|
e1x5 = b->E1x5();
|
414 |
|
|
e2x2 = b->E2x2();
|
415 |
|
|
e4x4 = b->E4x4();
|
416 |
|
|
e2x5max = b->E2x5Max();
|
417 |
|
|
e2x5top = b->E2x5Top();
|
418 |
|
|
e2x5bottom = b->E2x5Bottom();
|
419 |
|
|
e2x5left = b->E2x5Left();
|
420 |
|
|
e2x5right = b->E2x5Right();
|
421 |
|
|
|
422 |
|
|
//initialize photon energy corrections if needed
|
423 |
|
|
if (!PhotonFix::initialised()) {
|
424 |
|
|
PhotonFix::initialise("4_2",std::string((gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/PhotonFix.dat")).Data()));
|
425 |
|
|
}
|
426 |
|
|
|
427 |
|
|
PhotonFix fix(e,sceta,scphi,r9);
|
428 |
|
|
const Float_t dval = -99.;
|
429 |
|
|
ecor = fix.fixedEnergy();
|
430 |
|
|
ecorerr = fix.sigmaEnergy();
|
431 |
|
|
if (isbarrel) {
|
432 |
|
|
etac = fix.etaC();
|
433 |
|
|
etas = fix.etaS();
|
434 |
|
|
etam = fix.etaM();
|
435 |
|
|
phic = fix.phiC();
|
436 |
|
|
phis = fix.phiS();
|
437 |
|
|
phim = fix.phiM();
|
438 |
|
|
xz = dval;
|
439 |
|
|
xc = dval;
|
440 |
|
|
xs = dval;
|
441 |
|
|
xm = dval;
|
442 |
|
|
yz = dval;
|
443 |
|
|
yc = dval;
|
444 |
|
|
ys = dval;
|
445 |
|
|
ym = dval;
|
446 |
|
|
}
|
447 |
|
|
else {
|
448 |
|
|
etac = dval;
|
449 |
|
|
etas = dval;
|
450 |
|
|
etam = dval;
|
451 |
|
|
phic = dval;
|
452 |
|
|
phis = dval;
|
453 |
|
|
phim = dval;
|
454 |
|
|
xz = fix.xZ();
|
455 |
|
|
xc = fix.xC();
|
456 |
|
|
xs = fix.xS();
|
457 |
|
|
xm = fix.xM();
|
458 |
|
|
yz = fix.yZ();
|
459 |
|
|
yc = fix.yC();
|
460 |
|
|
ys = fix.yS();
|
461 |
|
|
ym = fix.yM();
|
462 |
|
|
}
|
463 |
|
|
|
464 |
|
|
if (c) {
|
465 |
|
|
hasconversion = kTRUE;
|
466 |
|
|
convp = c->P();
|
467 |
|
|
convpt = c->Pt();
|
468 |
|
|
conveta = c->Eta();
|
469 |
|
|
convphi = c->Phi();
|
470 |
|
|
ThreeVector dirconvsc = ThreeVector(p->SCluster()->Point()) - c->Position();
|
471 |
|
|
convdeta = c->Eta() - dirconvsc.Eta();
|
472 |
|
|
convdphi = MathUtils::DeltaPhi(c->Phi(),dirconvsc.Phi());
|
473 |
|
|
convvtxrho = c->Position().Rho();
|
474 |
|
|
convvtxz = c->Position().Z();
|
475 |
|
|
convvtxphi = c->Position().Phi();
|
476 |
|
|
|
477 |
|
|
const StableData *leadsd = dynamic_cast<const StableData*>(c->DaughterDat(0));
|
478 |
|
|
const StableData *trailsd = dynamic_cast<const StableData*>(c->DaughterDat(1));
|
479 |
|
|
if (leadsd->Pt()<trailsd->Pt()) {
|
480 |
|
|
const StableData *sdtmp = leadsd;
|
481 |
|
|
leadsd = trailsd;
|
482 |
|
|
trailsd = sdtmp;
|
483 |
|
|
}
|
484 |
|
|
|
485 |
|
|
const Track *leadtrack = dynamic_cast<const StableParticle*>(leadsd->Original())->Trk();
|
486 |
|
|
const Track *trailtrack = dynamic_cast<const StableParticle*>(trailsd->Original())->Trk();
|
487 |
|
|
|
488 |
|
|
convleadpt = leadsd->Pt();
|
489 |
|
|
convtrailpt = trailsd->Pt();
|
490 |
|
|
convleadtrackpt = leadtrack->Pt();
|
491 |
|
|
convleadtrackalgo = leadtrack->Algo();
|
492 |
|
|
if (convleadtrackalgo==29) convleadtrackalgos=2; //gsf track
|
493 |
|
|
else if (convleadtrackalgo==15 ||convleadtrackalgo==16) convleadtrackalgos=1; //ecal-seeded track
|
494 |
|
|
else convleadtrackalgos = 0; //std iterative track
|
495 |
|
|
convleadtrackcharge = leadtrack->Charge();
|
496 |
|
|
convtrailtrackpt = trailtrack->Pt();
|
497 |
|
|
convtrailtrackalgo = trailtrack->Algo();
|
498 |
|
|
if (convtrailtrackalgo==29) convtrailtrackalgos=2; //gsf track
|
499 |
|
|
else if (convtrailtrackalgo==15 ||convtrailtrackalgo==16) convtrailtrackalgos=1; //ecal-seeded track
|
500 |
|
|
else convtrailtrackalgos = 0; //std iterative track
|
501 |
|
|
trailtrackcharge = trailtrack->Charge();
|
502 |
|
|
}
|
503 |
|
|
else {
|
504 |
|
|
hasconversion = kFALSE;
|
505 |
|
|
convp = -99.;
|
506 |
|
|
convpt = -99.;
|
507 |
|
|
conveta = -99.;
|
508 |
|
|
convphi = -99.;
|
509 |
|
|
convdeta = -99.;
|
510 |
|
|
convdphi = -99.;
|
511 |
|
|
convvtxrho = -99.;
|
512 |
|
|
convvtxz = -999.;
|
513 |
|
|
convvtxphi = -99.;
|
514 |
|
|
convleadpt = -99.;
|
515 |
|
|
convtrailpt = -99.;
|
516 |
|
|
convleadtrackpt = -99.;
|
517 |
|
|
convleadtrackalgo = -99;
|
518 |
|
|
convleadtrackalgos = -99;
|
519 |
|
|
convleadtrackcharge = 0;
|
520 |
|
|
convtrailtrackpt = -99.;
|
521 |
|
|
convtrailtrackalgo = -99;
|
522 |
|
|
convtrailtrackalgos = -99;
|
523 |
|
|
trailtrackcharge = 0;
|
524 |
|
|
}
|
525 |
|
|
|
526 |
|
|
genz = -99.;
|
527 |
|
|
if (m) {
|
528 |
|
|
ispromptgen = kTRUE;
|
529 |
|
|
gene = m->E();
|
530 |
|
|
genpt = m->Pt();
|
531 |
|
|
geneta = m->Eta();
|
532 |
|
|
genphi = m->Phi();
|
533 |
|
|
const MCParticle *mm = m->DistinctMother();
|
534 |
|
|
if (mm) genz = mm->DecayVertex().Z();
|
535 |
|
|
}
|
536 |
|
|
else {
|
537 |
|
|
ispromptgen = kFALSE;
|
538 |
|
|
gene = -99.;
|
539 |
|
|
genpt = -99.;
|
540 |
|
|
geneta = -99.;
|
541 |
|
|
genphi = -99.;
|
542 |
|
|
}
|
543 |
|
|
|
544 |
|
|
}
|