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 "MitAna/DataTree/interface/PFMet.h"
|
7 |
#include "MitPhysics/Init/interface/ModNames.h"
|
8 |
#include "MitPhysics/Utils/interface/IsolationTools.h"
|
9 |
#include "MitPhysics/Utils/interface/PhotonTools.h"
|
10 |
#include "MitPhysics/Utils/interface/VertexTools.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 |
fMCParticleName (Names::gkMCPartBrn),
|
39 |
fPileUpName (Names::gkPileupInfoBrn),
|
40 |
fSuperClusterName ("PFSuperClusters"),
|
41 |
fPFMetName ("PFMet"),
|
42 |
fPFJetName (Names::gkPFJetBrn),
|
43 |
|
44 |
|
45 |
fIsData (false),
|
46 |
fPhotonsFromBranch (true),
|
47 |
fPVFromBranch (true),
|
48 |
fGoodElectronsFromBranch (kTRUE),
|
49 |
fPFJetsFromBranch (kTRUE),
|
50 |
|
51 |
// ----------------------------------------
|
52 |
// collections....
|
53 |
fPhotons (0),
|
54 |
fElectrons (0),
|
55 |
fConversions (0),
|
56 |
fTracks (0),
|
57 |
fPileUpDen (0),
|
58 |
fPV (0),
|
59 |
fBeamspot (0),
|
60 |
fPFCands (0),
|
61 |
fMCParticles (0),
|
62 |
fPileUp (0),
|
63 |
fSuperClusters (0),
|
64 |
fPFJets (0),
|
65 |
|
66 |
fLoopOnGoodElectrons(kFALSE),
|
67 |
fApplyElectronVeto(kTRUE),
|
68 |
|
69 |
fWriteDiphotonTree(kTRUE),
|
70 |
fWriteSingleTree(kTRUE),
|
71 |
fExcludeSinglePrompt(kFALSE),
|
72 |
fExcludeDoublePrompt(kFALSE),
|
73 |
fEnableJets(kFALSE),
|
74 |
fPhFixDataFile(gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/PhotonFixSTART42V13.dat")),
|
75 |
fTupleName ("hPhotonTree")
|
76 |
|
77 |
|
78 |
{
|
79 |
// Constructor.
|
80 |
}
|
81 |
|
82 |
PhotonTreeWriter::~PhotonTreeWriter(){
|
83 |
;
|
84 |
}
|
85 |
|
86 |
//--------------------------------------------------------------------------------------------------
|
87 |
void PhotonTreeWriter::Process()
|
88 |
{
|
89 |
// ------------------------------------------------------------
|
90 |
// Process entries of the tree.
|
91 |
|
92 |
LoadEventObject(fPhotonBranchName, fPhotons);
|
93 |
LoadEventObject(fGoodElectronName, fGoodElectrons);
|
94 |
|
95 |
const BaseCollection *egcol = 0;
|
96 |
if (fLoopOnGoodElectrons) {
|
97 |
egcol = fGoodElectrons;
|
98 |
}
|
99 |
else {
|
100 |
egcol = fPhotons;
|
101 |
}
|
102 |
|
103 |
if (egcol->GetEntries()<1) return;
|
104 |
|
105 |
LoadEventObject(fElectronName, fElectrons);
|
106 |
LoadEventObject(fConversionName, fConversions);
|
107 |
LoadEventObject(fTrackBranchName, fTracks);
|
108 |
LoadEventObject(fPileUpDenName, fPileUpDen);
|
109 |
LoadEventObject(fPVName, fPV);
|
110 |
LoadEventObject(fBeamspotName, fBeamspot);
|
111 |
LoadEventObject(fPFCandName, fPFCands);
|
112 |
LoadEventObject(fSuperClusterName, fSuperClusters);
|
113 |
LoadEventObject(fPFMetName, fPFMet);
|
114 |
if (fEnableJets) LoadEventObject(fPFJetName, fPFJets);
|
115 |
|
116 |
// ------------------------------------------------------------
|
117 |
// load event based information
|
118 |
Int_t _numPU = -1.; // some sensible default values....
|
119 |
Int_t _numPUminus = -1.; // some sensible default values....
|
120 |
Int_t _numPUplus = -1.; // some sensible default values....
|
121 |
|
122 |
Float_t _tRho = -99.;
|
123 |
if( fPileUpDen->GetEntries() > 0 )
|
124 |
_tRho = (Double_t) fPileUpDen->At(0)->RhoRandomLowEta();
|
125 |
|
126 |
const BaseVertex *bsp = dynamic_cast<const BaseVertex*>(fBeamspot->At(0));
|
127 |
|
128 |
if( !fIsData ) {
|
129 |
LoadBranch(fMCParticleName);
|
130 |
LoadBranch(fPileUpName);
|
131 |
}
|
132 |
|
133 |
if( !fIsData ) {
|
134 |
for (UInt_t i=0; i<fPileUp->GetEntries(); ++i) {
|
135 |
const PileupInfo *puinfo = fPileUp->At(i);
|
136 |
if (puinfo->GetBunchCrossing()==0) _numPU = puinfo->GetPU_NumInteractions();
|
137 |
else if (puinfo->GetBunchCrossing() == -1) _numPUminus = puinfo->GetPU_NumInteractions();
|
138 |
else if (puinfo->GetBunchCrossing() == 1) _numPUplus = puinfo->GetPU_NumInteractions();
|
139 |
}
|
140 |
}
|
141 |
|
142 |
// in case of a MC event, try to find Higgs and Higgs decay Z poisition
|
143 |
Float_t _pth = -100.;
|
144 |
Float_t _decayZ = -100.;
|
145 |
Float_t _genmass = -100.;
|
146 |
if( !fIsData ) FindHiggsPtAndZ(_pth, _decayZ, _genmass);
|
147 |
|
148 |
fDiphotonEvent->rho = _tRho;
|
149 |
fDiphotonEvent->genHiggspt = _pth;
|
150 |
fDiphotonEvent->genHiggsZ = _decayZ;
|
151 |
fDiphotonEvent->genmass = _genmass;
|
152 |
fDiphotonEvent->gencostheta = -99.;
|
153 |
fDiphotonEvent->nVtx = fPV->GetEntries();
|
154 |
fDiphotonEvent->bsX = fBeamspot->At(0)->X();
|
155 |
fDiphotonEvent->bsY = fBeamspot->At(0)->Y();
|
156 |
fDiphotonEvent->bsZ = fBeamspot->At(0)->Z();
|
157 |
fDiphotonEvent->bsSigmaZ = fBeamspot->At(0)->SigmaZ();
|
158 |
fDiphotonEvent->vtxX = (fDiphotonEvent->nVtx>0) ? fPV->At(0)->X() : -99.;
|
159 |
fDiphotonEvent->vtxY = (fDiphotonEvent->nVtx>0) ? fPV->At(0)->Y() : -99.;
|
160 |
fDiphotonEvent->vtxZ = (fDiphotonEvent->nVtx>0) ? fPV->At(0)->Z() : -99.;
|
161 |
fDiphotonEvent->numPU = _numPU;
|
162 |
fDiphotonEvent->numPUminus = _numPUminus;
|
163 |
fDiphotonEvent->numPUplus = _numPUplus;
|
164 |
fDiphotonEvent->mass = -99.;
|
165 |
fDiphotonEvent->ptgg = -99.;
|
166 |
fDiphotonEvent->costheta = -99.;
|
167 |
fDiphotonEvent->mt = -99.;
|
168 |
fDiphotonEvent->cosphimet = -99.;
|
169 |
fDiphotonEvent->mtele = -99.;
|
170 |
fDiphotonEvent->cosphimetele = -99.;
|
171 |
fDiphotonEvent->evt = GetEventHeader()->EvtNum();
|
172 |
fDiphotonEvent->run = GetEventHeader()->RunNum();
|
173 |
fDiphotonEvent->lumi = GetEventHeader()->LumiSec();
|
174 |
fDiphotonEvent->evtcat = -99;
|
175 |
fDiphotonEvent->nobj = fPhotons->GetEntries();
|
176 |
fDiphotonEvent->pfmet = fPFMet->At(0)->Pt();
|
177 |
fDiphotonEvent->pfmetphi = fPFMet->At(0)->Phi();
|
178 |
fDiphotonEvent->pfmetx = fPFMet->At(0)->Px();
|
179 |
fDiphotonEvent->pfmety = fPFMet->At(0)->Py();
|
180 |
fDiphotonEvent->masscor = -99.;
|
181 |
fDiphotonEvent->masscorerr = -99.;
|
182 |
fDiphotonEvent->masscorele = -99.;
|
183 |
fDiphotonEvent->masscoreleerr = -99.;
|
184 |
fDiphotonEvent->ismc = GetEventHeader()->IsMC();
|
185 |
|
186 |
//jets
|
187 |
const Jet *jet1 = 0;
|
188 |
const Jet *jet2 = 0;
|
189 |
const Jet *jetcentral = 0;
|
190 |
|
191 |
fDiphotonEvent->jet1pt = -99.;
|
192 |
fDiphotonEvent->jet1eta = -99.;
|
193 |
fDiphotonEvent->jet1phi = -99.;
|
194 |
fDiphotonEvent->jet1mass = -99.;
|
195 |
fDiphotonEvent->jet2pt = -99.;
|
196 |
fDiphotonEvent->jet2eta = -99.;
|
197 |
fDiphotonEvent->jet2phi = -99.;
|
198 |
fDiphotonEvent->jet2mass = -99.;
|
199 |
fDiphotonEvent->jetcentralpt = -99.;
|
200 |
fDiphotonEvent->jetcentraleta = -99.;
|
201 |
fDiphotonEvent->jetcentralphi = -99.;
|
202 |
fDiphotonEvent->jetcentralmass = -99.;
|
203 |
fDiphotonEvent->dijetpt = -99.;
|
204 |
fDiphotonEvent->dijeteta = -99.;
|
205 |
fDiphotonEvent->dijetphi = -99.;
|
206 |
fDiphotonEvent->dijetmass = -99.;
|
207 |
fDiphotonEvent->jetetaplus = -99.;
|
208 |
fDiphotonEvent->jetetaminus = -99.;
|
209 |
fDiphotonEvent->zeppenfeld = -99.;
|
210 |
fDiphotonEvent->dphidijetgg = -99.;
|
211 |
|
212 |
Int_t nhitsbeforevtxmax = 1;
|
213 |
if (!fApplyElectronVeto) nhitsbeforevtxmax = 999;
|
214 |
|
215 |
if (egcol->GetEntries()>=2) {
|
216 |
|
217 |
const Particle *p1 = 0;
|
218 |
const Particle *p2 = 0;
|
219 |
const Photon *phHard = 0;
|
220 |
const Photon *phSoft = 0;
|
221 |
const Electron *ele1 = 0;
|
222 |
const Electron *ele2 = 0;
|
223 |
const SuperCluster *sc1 = 0;
|
224 |
const SuperCluster *sc2 = 0;
|
225 |
|
226 |
if (fLoopOnGoodElectrons) {
|
227 |
ele1 = fGoodElectrons->At(0);
|
228 |
ele2 = fGoodElectrons->At(1);
|
229 |
p1 = ele1;
|
230 |
p2 = ele2;
|
231 |
sc1 = ele1->SCluster();
|
232 |
sc2 = ele2->SCluster();
|
233 |
phHard = PhotonTools::MatchedPhoton(ele1,fPhotons);
|
234 |
phSoft = PhotonTools::MatchedPhoton(ele2,fPhotons);
|
235 |
}
|
236 |
else {
|
237 |
phHard = fPhotons->At(0);
|
238 |
phSoft = fPhotons->At(1);
|
239 |
p1 = phHard;
|
240 |
p2 = phSoft;
|
241 |
sc1 = phHard->SCluster();
|
242 |
sc2 = phSoft->SCluster();
|
243 |
ele1 = PhotonTools::MatchedElectron(phHard,fGoodElectrons);
|
244 |
ele2 = PhotonTools::MatchedElectron(phSoft,fGoodElectrons);
|
245 |
}
|
246 |
|
247 |
const DecayParticle *conv1 = PhotonTools::MatchedConversion(sc1,fConversions,bsp,nhitsbeforevtxmax);
|
248 |
const DecayParticle *conv2 = PhotonTools::MatchedConversion(sc2,fConversions,bsp,nhitsbeforevtxmax);
|
249 |
|
250 |
const SuperCluster *pfsc1 = PhotonTools::MatchedSC(sc1,fSuperClusters);
|
251 |
const SuperCluster *pfsc2 = PhotonTools::MatchedSC(sc2,fSuperClusters);
|
252 |
|
253 |
const MCParticle *phgen1 = 0;
|
254 |
const MCParticle *phgen2 = 0;
|
255 |
if( !fIsData ) {
|
256 |
phgen1 = PhotonTools::MatchMC(p1,fMCParticles,!fApplyElectronVeto);
|
257 |
phgen2 = PhotonTools::MatchMC(p2,fMCParticles,!fApplyElectronVeto);
|
258 |
}
|
259 |
|
260 |
/* if (phgen1 && phgen2) {
|
261 |
printf("p1 pt = %5f, eta = %5f, phi = %5f\n",p1->Pt(),p1->Eta(),p1->Phi());
|
262 |
printf("p2 pt = %5f, eta = %5f, phi = %5f\n",p2->Pt(),p2->Eta(),p2->Phi());
|
263 |
printf("phgen1 pt = %5f, eta = %5f, phi = %5f, pdg = %i, motherpdg = %i, distinctmotherpdg = %i, distinctmotherstatus = %i\n",phgen1->Pt(),phgen1->Eta(),phgen1->Phi(),phgen1->PdgId(),phgen1->Mother()->PdgId(),phgen1->DistinctMother()->PdgId(),phgen1->DistinctMother()->Status());
|
264 |
printf("phgen2 pt = %5f, eta = %5f, phi = %5f, pdg = %i, motherpdg = %i, distinctmotherpdg = %i, distinctmotherstatus = %i\n",phgen2->Pt(),phgen2->Eta(),phgen2->Phi(),phgen2->PdgId(),phgen2->Mother()->PdgId(),phgen2->DistinctMother()->PdgId(),phgen2->DistinctMother()->Status());
|
265 |
} */
|
266 |
|
267 |
|
268 |
if (fExcludeSinglePrompt && (phgen1 || phgen2) ) return;
|
269 |
if (fExcludeDoublePrompt && (phgen1 && phgen2) ) return;
|
270 |
|
271 |
if (!fLoopOnGoodElectrons && phHard->HasPV()) {
|
272 |
fDiphotonEvent->vtxX = phHard->PV()->X();
|
273 |
fDiphotonEvent->vtxY = phHard->PV()->Y();
|
274 |
fDiphotonEvent->vtxZ = phHard->PV()->Z();
|
275 |
fDiphotonEvent->vtxprob = phHard->VtxProb();
|
276 |
}
|
277 |
|
278 |
//fill jet variables
|
279 |
if (fEnableJets) {
|
280 |
for (UInt_t ijet=0; ijet<fPFJets->GetEntries();++ijet) {
|
281 |
const Jet *jet = fPFJets->At(ijet);
|
282 |
if (jet->AbsEta()<4.7 && MathUtils::DeltaR(jet,p1)>0.3 && MathUtils::DeltaR(jet,p2)>0.3) {
|
283 |
if (!jet1) jet1 = jet;
|
284 |
else if (!jet2) jet2 = jet;
|
285 |
else if (!jetcentral && 0) jetcentral = jet;
|
286 |
}
|
287 |
if (jet1&&jet2&&jetcentral) break;
|
288 |
}
|
289 |
}
|
290 |
|
291 |
if (jet1) {
|
292 |
fDiphotonEvent->jet1pt = jet1->Pt();
|
293 |
fDiphotonEvent->jet1eta = jet1->Eta();
|
294 |
fDiphotonEvent->jet1phi = jet1->Phi();
|
295 |
fDiphotonEvent->jet1mass = jet1->Mass();
|
296 |
}
|
297 |
|
298 |
if (jet2) {
|
299 |
fDiphotonEvent->jet2pt = jet2->Pt();
|
300 |
fDiphotonEvent->jet2eta = jet2->Eta();
|
301 |
fDiphotonEvent->jet2phi = jet2->Phi();
|
302 |
fDiphotonEvent->jet2mass = jet2->Mass();
|
303 |
}
|
304 |
|
305 |
if (jetcentral) {
|
306 |
fDiphotonEvent->jetcentralpt = jetcentral->Pt();
|
307 |
fDiphotonEvent->jetcentraleta = jetcentral->Eta();
|
308 |
fDiphotonEvent->jetcentralphi = jetcentral->Phi();
|
309 |
fDiphotonEvent->jetcentralmass = jetcentral->Mass();
|
310 |
}
|
311 |
|
312 |
if (jet1&&jet2){
|
313 |
FourVectorM momjj = (jet1->Mom() + jet2->Mom());
|
314 |
|
315 |
fDiphotonEvent->dijetpt = momjj.Pt();
|
316 |
fDiphotonEvent->dijeteta = momjj.Eta();
|
317 |
fDiphotonEvent->dijetphi = momjj.Phi();
|
318 |
fDiphotonEvent->dijetmass = momjj.M();
|
319 |
|
320 |
if (jet1->Eta()>jet2->Eta()) {
|
321 |
fDiphotonEvent->jetetaplus = jet1->Eta();
|
322 |
fDiphotonEvent->jetetaminus = jet2->Eta();
|
323 |
}
|
324 |
else {
|
325 |
fDiphotonEvent->jetetaplus = jet2->Eta();
|
326 |
fDiphotonEvent->jetetaminus = jet1->Eta();
|
327 |
}
|
328 |
|
329 |
}
|
330 |
|
331 |
|
332 |
|
333 |
Double_t _mass = -99.;
|
334 |
Double_t _masserr = -99.;
|
335 |
Double_t _masserrsmeared = -99.;
|
336 |
Double_t _masserrwrongvtx = -99.;
|
337 |
Double_t _masserrsmearedwrongvtx = -99.;
|
338 |
Double_t _ptgg = -99.;
|
339 |
Double_t _etagg = -99.;
|
340 |
Double_t _phigg = -99.;
|
341 |
Double_t _costheta = -99.;
|
342 |
PhotonTools::DiphotonR9EtaPtCats _evtcat = PhotonTools::kOctCat0;
|
343 |
if (phHard && phSoft) {
|
344 |
_mass = (phHard->Mom()+phSoft->Mom()).M();
|
345 |
_masserr = 0.5*_mass*TMath::Sqrt(phHard->EnergyErr()*phHard->EnergyErr()/phHard->E()/phHard->E() + phSoft->EnergyErr()*phSoft->EnergyErr()/phSoft->E()/phSoft->E());
|
346 |
_masserrsmeared = 0.5*_mass*TMath::Sqrt(phHard->EnergyErrSmeared()*phHard->EnergyErrSmeared()/phHard->E()/phHard->E() + phSoft->EnergyErrSmeared()*phSoft->EnergyErrSmeared()/phSoft->E()/phSoft->E());
|
347 |
_ptgg = (phHard->Mom()+phSoft->Mom()).Pt();
|
348 |
_etagg = (phHard->Mom()+phSoft->Mom()).Eta();
|
349 |
_phigg = (phHard->Mom()+phSoft->Mom()).Phi();
|
350 |
_costheta = ThreeVector(phHard->Mom()).Unit().Dot(ThreeVector(phSoft->Mom()).Unit());
|
351 |
_evtcat = PhotonTools::DiphotonR9EtaPtCat(phHard,phSoft);
|
352 |
|
353 |
const Double_t dz = sqrt(2.0)*5.8;
|
354 |
Double_t deltamvtx = _mass*VertexTools::DeltaMassVtx(phHard->CaloPos().X(), phHard->CaloPos().Y(), phHard->CaloPos().Z(),
|
355 |
phSoft->CaloPos().X(), phSoft->CaloPos().Y(), phSoft->CaloPos().Z(),
|
356 |
dz);
|
357 |
|
358 |
fDiphotonEvent->deltamvtx = deltamvtx;
|
359 |
|
360 |
_masserrwrongvtx = TMath::Sqrt(_masserr*_masserr + deltamvtx*deltamvtx);
|
361 |
_masserrsmearedwrongvtx = TMath::Sqrt(_masserrsmeared*_masserrsmeared + deltamvtx*deltamvtx);
|
362 |
|
363 |
if (jet1 && jet2) {
|
364 |
fDiphotonEvent->zeppenfeld = TMath::Abs(_etagg - 0.5*(jet1->Eta()+jet2->Eta()));
|
365 |
fDiphotonEvent->dphidijetgg = MathUtils::DeltaPhi( (jet1->Mom()+jet2->Mom()).Phi(), _phigg );
|
366 |
}
|
367 |
|
368 |
}
|
369 |
|
370 |
|
371 |
Float_t _massele = -99.;
|
372 |
Float_t _ptee = -99.;
|
373 |
Float_t _costhetaele = -99.;
|
374 |
if (ele1 && ele2) {
|
375 |
_massele = (ele1->Mom()+ele2->Mom()).M();
|
376 |
_ptee = (ele1->Mom()+ele2->Mom()).Pt();
|
377 |
_costhetaele = ThreeVector(ele1->Mom()).Unit().Dot(ThreeVector(ele2->Mom()).Unit());
|
378 |
}
|
379 |
|
380 |
Float_t _gencostheta = -99.;
|
381 |
if (phgen1 && phgen2) {
|
382 |
_gencostheta = ThreeVector(phgen1->Mom()).Unit().Dot(ThreeVector(phgen2->Mom()).Unit());
|
383 |
}
|
384 |
|
385 |
fDiphotonEvent->gencostheta = _gencostheta;
|
386 |
fDiphotonEvent->mass = _mass;
|
387 |
fDiphotonEvent->masserr = _masserr;
|
388 |
fDiphotonEvent->masserrsmeared = _masserrsmeared;
|
389 |
fDiphotonEvent->masserrwrongvtx = _masserrwrongvtx;
|
390 |
fDiphotonEvent->masserrsmearedwrongvtx = _masserrsmearedwrongvtx;
|
391 |
fDiphotonEvent->ptgg = _ptgg;
|
392 |
fDiphotonEvent->etagg = _etagg;
|
393 |
fDiphotonEvent->phigg = _phigg;
|
394 |
fDiphotonEvent->costheta = _costheta;;
|
395 |
fDiphotonEvent->massele = _massele;
|
396 |
fDiphotonEvent->ptee = _ptee;
|
397 |
fDiphotonEvent->costhetaele = _costhetaele;
|
398 |
fDiphotonEvent->evtcat = _evtcat;
|
399 |
|
400 |
fDiphotonEvent->photons[0].SetVars(phHard,conv1,ele1,pfsc1,phgen1,fPhfixph,fPhfixele);
|
401 |
fDiphotonEvent->photons[1].SetVars(phSoft,conv2,ele2,pfsc2,phgen2,fPhfixph,fPhfixele);
|
402 |
|
403 |
Float_t ph1ecor = fDiphotonEvent->photons[0].Ecor();
|
404 |
Float_t ph1ecorerr = fDiphotonEvent->photons[0].Ecorerr();
|
405 |
Float_t ph2ecor = fDiphotonEvent->photons[1].Ecor();
|
406 |
Float_t ph2ecorerr = fDiphotonEvent->photons[1].Ecorerr();
|
407 |
|
408 |
Float_t ph1ecorele = fDiphotonEvent->photons[0].Ecorele();
|
409 |
Float_t ph1ecoreleerr = fDiphotonEvent->photons[0].Ecoreleerr();
|
410 |
Float_t ph2ecorele = fDiphotonEvent->photons[1].Ecorele();
|
411 |
Float_t ph2ecoreleerr = fDiphotonEvent->photons[1].Ecoreleerr();
|
412 |
|
413 |
|
414 |
fDiphotonEvent->masscor = TMath::Sqrt(2.0*ph1ecor*ph2ecor*(1.0-fDiphotonEvent->costheta));
|
415 |
fDiphotonEvent->masscorerr = 0.5*fDiphotonEvent->masscor*TMath::Sqrt(ph1ecorerr*ph1ecorerr/ph1ecor/ph1ecor + ph2ecorerr*ph2ecorerr/ph2ecor/ph2ecor);
|
416 |
|
417 |
fDiphotonEvent->masscorele = TMath::Sqrt(2.0*ph1ecorele*ph2ecorele*(1.0-fDiphotonEvent->costheta));
|
418 |
fDiphotonEvent->masscoreleerr = 0.5*fDiphotonEvent->masscorele*TMath::Sqrt(ph1ecoreleerr*ph1ecoreleerr/ph1ecorele/ph1ecorele + ph2ecoreleerr*ph2ecoreleerr/ph2ecorele/ph2ecorele);
|
419 |
|
420 |
//printf("r9 = %5f, photon sigieie = %5f, seed sigieie = %5f\n",phHard->R9(),phHard->CoviEtaiEta(),sqrt(phHard->SCluster()->Seed()->CoviEtaiEta()));
|
421 |
|
422 |
if (fWriteDiphotonTree) hCiCTuple->Fill();
|
423 |
|
424 |
}
|
425 |
|
426 |
if (!fWriteSingleTree) return;
|
427 |
|
428 |
|
429 |
for (UInt_t iph = 0; iph<egcol->GetEntries(); ++iph) {
|
430 |
|
431 |
const Particle *p = 0;
|
432 |
const Photon *ph = 0;
|
433 |
const Electron *ele = 0;
|
434 |
const SuperCluster *sc = 0;
|
435 |
if (fLoopOnGoodElectrons) {
|
436 |
ele = fGoodElectrons->At(iph);
|
437 |
p = ele;
|
438 |
sc = ele->SCluster();
|
439 |
ph = PhotonTools::MatchedPhoton(ele,fPhotons);
|
440 |
}
|
441 |
else {
|
442 |
ph = fPhotons->At(iph);
|
443 |
p = ph;
|
444 |
sc = ph->SCluster();
|
445 |
ele = PhotonTools::MatchedElectron(ph,fGoodElectrons);
|
446 |
}
|
447 |
|
448 |
const DecayParticle *conv = PhotonTools::MatchedConversion(sc,fConversions,bsp,nhitsbeforevtxmax);
|
449 |
const SuperCluster *pfsc = PhotonTools::MatchedSC(sc,fSuperClusters);
|
450 |
|
451 |
|
452 |
|
453 |
if (!fLoopOnGoodElectrons && ph->HasPV()) {
|
454 |
fDiphotonEvent->vtxZ = ph->PV()->Z();
|
455 |
}
|
456 |
|
457 |
const MCParticle *phgen = 0;
|
458 |
if( !fIsData ) {
|
459 |
phgen = PhotonTools::MatchMC(p,fMCParticles,!fApplyElectronVeto);
|
460 |
}
|
461 |
|
462 |
if (fExcludeSinglePrompt && phgen) return;
|
463 |
|
464 |
fDiphotonEvent->mt = -99.;
|
465 |
fDiphotonEvent->cosphimet = -99.;
|
466 |
fDiphotonEvent->mtele = -99.;
|
467 |
fDiphotonEvent->cosphimetele = -99.;
|
468 |
|
469 |
if (ph) {
|
470 |
fDiphotonEvent->cosphimet = TMath::Cos(ph->Phi()-fPFMet->At(0)->Phi());
|
471 |
fDiphotonEvent->mt = TMath::Sqrt(2.0*fPFMet->At(0)->Pt()*ph->Pt()*(1.0-fDiphotonEvent->cosphimet));
|
472 |
}
|
473 |
|
474 |
if (ele) {
|
475 |
fDiphotonEvent->cosphimetele = TMath::Cos(ele->Phi()-fPFMet->At(0)->Phi());
|
476 |
fDiphotonEvent->mtele = TMath::Sqrt(2.0*fPFMet->At(0)->Pt()*ele->Pt()*(1.0-fDiphotonEvent->cosphimetele));
|
477 |
}
|
478 |
|
479 |
fSinglePhoton->SetVars(ph,conv,ele,pfsc,phgen,fPhfixph,fPhfixele);
|
480 |
hCiCTupleSingle->Fill();
|
481 |
|
482 |
}
|
483 |
|
484 |
|
485 |
return;
|
486 |
|
487 |
}
|
488 |
|
489 |
//--------------------------------------------------------------------------------------------------
|
490 |
void PhotonTreeWriter::SlaveBegin()
|
491 |
{
|
492 |
// Run startup code on the computer (slave) doing the actual analysis. Here,
|
493 |
// we just request the photon collection branch.
|
494 |
|
495 |
ReqEventObject(fPhotonBranchName, fPhotons, fPhotonsFromBranch);
|
496 |
ReqEventObject(fTrackBranchName, fTracks, true);
|
497 |
ReqEventObject(fElectronName, fElectrons, true);
|
498 |
ReqEventObject(fGoodElectronName, fGoodElectrons, fGoodElectronsFromBranch);
|
499 |
ReqEventObject(fPileUpDenName, fPileUpDen, true);
|
500 |
ReqEventObject(fPVName, fPV, fPVFromBranch);
|
501 |
ReqEventObject(fConversionName, fConversions,true);
|
502 |
ReqEventObject(fBeamspotName, fBeamspot, true);
|
503 |
ReqEventObject(fPFCandName, fPFCands, true);
|
504 |
ReqEventObject(fSuperClusterName, fSuperClusters, true);
|
505 |
ReqEventObject(fPFMetName, fPFMet, true);
|
506 |
if (fEnableJets) ReqEventObject(fPFJetName, fPFJets, fPFJetsFromBranch);
|
507 |
|
508 |
if (!fIsData) {
|
509 |
ReqBranch(fPileUpName, fPileUp);
|
510 |
ReqBranch(fMCParticleName, fMCParticles);
|
511 |
}
|
512 |
|
513 |
|
514 |
if (fIsData) {
|
515 |
fPhFixDataFile = gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/PhotonFixGRPV22.dat");
|
516 |
}
|
517 |
else {
|
518 |
fPhFixDataFile = gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/PhotonFixSTART42V13.dat");
|
519 |
}
|
520 |
|
521 |
//initialize photon energy corrections
|
522 |
//PhotonFix::initialise("4_2",std::string((gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/PhotonFix.dat")).Data()));
|
523 |
|
524 |
fPhfixph.initialise("4_2",std::string(fPhFixDataFile));
|
525 |
fPhfixele.initialise("4_2e",std::string(fPhFixDataFile));
|
526 |
|
527 |
fDiphotonEvent = new PhotonTreeWriterDiphotonEvent;
|
528 |
fSinglePhoton = new PhotonTreeWriterPhoton;
|
529 |
|
530 |
|
531 |
if (fWriteDiphotonTree) hCiCTuple = new TTree(fTupleName.Data(),fTupleName.Data());
|
532 |
TString singlename = fTupleName + TString("Single");
|
533 |
if (fWriteSingleTree) hCiCTupleSingle = new TTree(singlename,singlename);
|
534 |
|
535 |
//make flattish tree from classes so we don't have to rely on dictionaries for reading later
|
536 |
TClass *eclass = TClass::GetClass("mithep::PhotonTreeWriterDiphotonEvent");
|
537 |
TClass *pclass = TClass::GetClass("mithep::PhotonTreeWriterPhoton");
|
538 |
TList *elist = eclass->GetListOfDataMembers();
|
539 |
TList *plist = pclass->GetListOfDataMembers();
|
540 |
|
541 |
for (int i=0; i<elist->GetEntries(); ++i) {
|
542 |
const TDataMember *tdm = static_cast<const TDataMember*>(elist->At(i));
|
543 |
if (!(tdm->IsBasic() && tdm->IsPersistent())) continue;
|
544 |
TString typestring;
|
545 |
if (TString(tdm->GetTypeName())=="Char_t") typestring = "B";
|
546 |
else if (TString(tdm->GetTypeName())=="UChar_t") typestring = "b";
|
547 |
else if (TString(tdm->GetTypeName())=="Short_t") typestring = "S";
|
548 |
else if (TString(tdm->GetTypeName())=="UShort_t") typestring = "s";
|
549 |
else if (TString(tdm->GetTypeName())=="Int_t") typestring = "I";
|
550 |
else if (TString(tdm->GetTypeName())=="UInt_t") typestring = "i";
|
551 |
else if (TString(tdm->GetTypeName())=="Float_t") typestring = "F";
|
552 |
else if (TString(tdm->GetTypeName())=="Double_t") typestring = "D";
|
553 |
else if (TString(tdm->GetTypeName())=="Long64_t") typestring = "L";
|
554 |
else if (TString(tdm->GetTypeName())=="ULong64_t") typestring = "l";
|
555 |
else if (TString(tdm->GetTypeName())=="Bool_t") typestring = "O";
|
556 |
else continue;
|
557 |
//printf("%s %s: %i\n",tdm->GetTypeName(),tdm->GetName(),int(tdm->GetOffset()));
|
558 |
Char_t *addr = (Char_t*)fDiphotonEvent;
|
559 |
assert(sizeof(Char_t)==1);
|
560 |
if (fWriteDiphotonTree) hCiCTuple->Branch(tdm->GetName(),addr + tdm->GetOffset(),TString::Format("%s/%s",tdm->GetName(),typestring.Data()));
|
561 |
if (fWriteSingleTree) hCiCTupleSingle->Branch(tdm->GetName(),addr + tdm->GetOffset(),TString::Format("%s/%s",tdm->GetName(),typestring.Data()));
|
562 |
}
|
563 |
|
564 |
for (int iph=0; iph<2; ++iph) {
|
565 |
for (int i=0; i<plist->GetEntries(); ++i) {
|
566 |
const TDataMember *tdm = static_cast<const TDataMember*>(plist->At(i));
|
567 |
if (!(tdm->IsBasic() && tdm->IsPersistent())) continue;
|
568 |
TString typestring;
|
569 |
if (TString(tdm->GetTypeName())=="Char_t") typestring = "B";
|
570 |
else if (TString(tdm->GetTypeName())=="UChar_t") typestring = "b";
|
571 |
else if (TString(tdm->GetTypeName())=="Short_t") typestring = "S";
|
572 |
else if (TString(tdm->GetTypeName())=="UShort_t") typestring = "s";
|
573 |
else if (TString(tdm->GetTypeName())=="Int_t") typestring = "I";
|
574 |
else if (TString(tdm->GetTypeName())=="UInt_t") typestring = "i";
|
575 |
else if (TString(tdm->GetTypeName())=="Float_t") typestring = "F";
|
576 |
else if (TString(tdm->GetTypeName())=="Double_t") typestring = "D";
|
577 |
else if (TString(tdm->GetTypeName())=="Long64_t") typestring = "L";
|
578 |
else if (TString(tdm->GetTypeName())=="ULong64_t") typestring = "l";
|
579 |
else if (TString(tdm->GetTypeName())=="Bool_t") typestring = "O";
|
580 |
else continue;
|
581 |
//printf("%s\n",tdm->GetTypeName());
|
582 |
TString varname = TString::Format("ph%d.%s",iph+1,tdm->GetName());
|
583 |
|
584 |
Char_t *addr = (Char_t*)&fDiphotonEvent->photons[iph];
|
585 |
assert(sizeof(Char_t)==1);
|
586 |
if (fWriteDiphotonTree) hCiCTuple->Branch(varname,addr+tdm->GetOffset(),TString::Format("%s/%s",varname.Data(),typestring.Data()));
|
587 |
|
588 |
if (iph==0) {
|
589 |
TString singlename = TString::Format("ph.%s",tdm->GetName());
|
590 |
Char_t *addrsingle = (Char_t*)fSinglePhoton;
|
591 |
if (fWriteSingleTree) hCiCTupleSingle->Branch(singlename,addrsingle+tdm->GetOffset(),TString::Format("%s/%s",singlename.Data(),typestring.Data()));
|
592 |
}
|
593 |
}
|
594 |
}
|
595 |
|
596 |
|
597 |
if (fWriteDiphotonTree) AddOutput(hCiCTuple);
|
598 |
if (fWriteSingleTree) AddOutput(hCiCTupleSingle);
|
599 |
|
600 |
|
601 |
}
|
602 |
|
603 |
// ----------------------------------------------------------------------------------------
|
604 |
// some helpfer functions....
|
605 |
void PhotonTreeWriter::FindHiggsPtAndZ(Float_t& pt, Float_t& decayZ, Float_t& mass) {
|
606 |
|
607 |
pt = -999.;
|
608 |
decayZ = -999.;
|
609 |
mass = -999.;
|
610 |
|
611 |
// loop over all GEN particles and look for status 1 photons
|
612 |
for(UInt_t i=0; i<fMCParticles->GetEntries(); ++i) {
|
613 |
const MCParticle* p = fMCParticles->At(i);
|
614 |
if( p->Is(MCParticle::kH) || (!fApplyElectronVeto && (p->AbsPdgId()==23||p->AbsPdgId()==24) ) ) {
|
615 |
pt=p->Pt();
|
616 |
decayZ = p->DecayVertex().Z();
|
617 |
mass = p->Mass();
|
618 |
break;
|
619 |
}
|
620 |
}
|
621 |
|
622 |
return;
|
623 |
}
|
624 |
|
625 |
|
626 |
Float_t PhotonTreeWriter::GetEventCat(PhotonTools::CiCBaseLineCats cat1, PhotonTools::CiCBaseLineCats cat2) {
|
627 |
|
628 |
bool ph1IsEB = (cat1 == PhotonTools::kCiCCat1 || cat1 == PhotonTools::kCiCCat2);
|
629 |
bool ph2IsEB = (cat2 == PhotonTools::kCiCCat1 || cat2 == PhotonTools::kCiCCat2);
|
630 |
|
631 |
bool ph1IsHR9 = (cat1 == PhotonTools::kCiCCat1 || cat1 == PhotonTools::kCiCCat3);
|
632 |
bool ph2IsHR9 = (cat2 == PhotonTools::kCiCCat1 || cat2 == PhotonTools::kCiCCat3);
|
633 |
|
634 |
if( ph1IsEB && ph2IsEB )
|
635 |
return ( ph1IsHR9 && ph2IsHR9 ? 0. : 1.);
|
636 |
|
637 |
return ( ph1IsHR9 && ph2IsHR9 ? 2. : 3.);
|
638 |
}
|
639 |
|
640 |
void PhotonTreeWriterPhoton::SetVars(const Photon *p, const DecayParticle *c, const Electron *ele, const SuperCluster *pfsc, const MCParticle *m, PhotonFix &phfixph, PhotonFix &phfixele) {
|
641 |
|
642 |
const SuperCluster *s = 0;
|
643 |
if (p) {
|
644 |
s = p->SCluster();
|
645 |
}
|
646 |
else {
|
647 |
s = ele->SCluster();
|
648 |
}
|
649 |
const BasicCluster *b = s->Seed();
|
650 |
const BasicCluster *b2 = 0;
|
651 |
Double_t ebcmax = -99.;
|
652 |
for (UInt_t i=0; i<s->ClusterSize(); ++i) {
|
653 |
const BasicCluster *bc = s->Cluster(i);
|
654 |
if (bc->Energy() > ebcmax && bc !=b) {
|
655 |
b2 = bc;
|
656 |
ebcmax = bc->Energy();
|
657 |
}
|
658 |
}
|
659 |
|
660 |
const BasicCluster *bclast = 0;
|
661 |
Double_t ebcmin = 1e6;
|
662 |
for (UInt_t i=0; i<s->ClusterSize(); ++i) {
|
663 |
const BasicCluster *bc = s->Cluster(i);
|
664 |
if (bc->Energy() < ebcmin && bc !=b) {
|
665 |
bclast = bc;
|
666 |
ebcmin = bc->Energy();
|
667 |
}
|
668 |
}
|
669 |
|
670 |
const BasicCluster *bclast2 = 0;
|
671 |
ebcmin = 1e6;
|
672 |
for (UInt_t i=0; i<s->ClusterSize(); ++i) {
|
673 |
const BasicCluster *bc = s->Cluster(i);
|
674 |
if (bc->Energy() < ebcmin && bc !=b && bc!=bclast) {
|
675 |
bclast2 = bc;
|
676 |
ebcmin = bc->Energy();
|
677 |
}
|
678 |
}
|
679 |
|
680 |
|
681 |
if (p) {
|
682 |
hasphoton = kTRUE;
|
683 |
e = p->E();
|
684 |
pt = p->Pt();
|
685 |
eta = p->Eta();
|
686 |
phi = p->Phi();
|
687 |
r9 = p->R9();
|
688 |
e3x3 = p->E33();
|
689 |
e5x5 = p->E55();
|
690 |
hovere = p->HadOverEm();
|
691 |
sigietaieta = p->CoviEtaiEta();
|
692 |
phcat = PhotonTools::CiCBaseLineCat(p);
|
693 |
eerr = p->EnergyErr();
|
694 |
eerrsmeared = p->EnergyErrSmeared();
|
695 |
esmearing = p->EnergySmearing();
|
696 |
idmva = p->IdMva();
|
697 |
hcalisodr03 = p->HcalTowerSumEtDr03();
|
698 |
ecalisodr03 = p->EcalRecHitIsoDr03();
|
699 |
trkisohollowdr03 = p->HollowConeTrkIsoDr03();
|
700 |
}
|
701 |
else {
|
702 |
hasphoton = kFALSE;
|
703 |
e = -99.;
|
704 |
pt = -99.;
|
705 |
eta = -99.;
|
706 |
phi = -99.;
|
707 |
r9 = b->E3x3()/s->RawEnergy();
|
708 |
e3x3 = b->E3x3();
|
709 |
e5x5 = b->E5x5();
|
710 |
hovere = ele->HadronicOverEm();
|
711 |
sigietaieta = ele->CoviEtaiEta();
|
712 |
phcat = -99;
|
713 |
eerr = -99.;
|
714 |
eerrsmeared = -99.;
|
715 |
esmearing = 0.;
|
716 |
idmva = -99.;
|
717 |
}
|
718 |
|
719 |
|
720 |
sce = s->Energy();
|
721 |
scrawe = s->RawEnergy();
|
722 |
scpse = s->PreshowerEnergy();
|
723 |
sceta = s->Eta();
|
724 |
scphi = s->Phi();
|
725 |
scnclusters = s->ClusterSize();
|
726 |
scnhits = s->NHits();
|
727 |
scetawidth = s->EtaWidth();
|
728 |
scphiwidth = s->PhiWidth();
|
729 |
isbarrel = (s->AbsEta()<1.5);
|
730 |
isr9reco = (isbarrel && r9>0.94) || (!isbarrel && r9>0.95);
|
731 |
isr9cat = (r9>0.94);
|
732 |
|
733 |
eseed = b->Energy();
|
734 |
etaseed = b->Eta();
|
735 |
phiseed = b->Phi();
|
736 |
ietaseed = b->IEta();
|
737 |
iphiseed = b->IPhi();
|
738 |
ixseed = b->IX();
|
739 |
iyseed = b->IY();
|
740 |
etacryseed = b->EtaCry();
|
741 |
phicryseed = b->PhiCry();
|
742 |
xcryseed = b->XCry();
|
743 |
ycryseed = b->YCry();
|
744 |
thetaaxisseed = b->ThetaAxis();
|
745 |
phiaxisseed = b->PhiAxis();
|
746 |
sigietaietaseed = TMath::Sqrt(b->CoviEtaiEta());
|
747 |
sigiphiphiseed = TMath::Sqrt(b->CoviPhiiPhi());
|
748 |
if (isnan(sigiphiphiseed)) sigiphiphiseed = -99.;
|
749 |
covietaiphiseed = b->CoviEtaiPhi();
|
750 |
if (isnan(covietaiphiseed)) covietaiphiseed = -99.;
|
751 |
e3x3seed = b->E3x3();
|
752 |
e5x5seed = b->E5x5();
|
753 |
emaxseed = b->EMax();
|
754 |
e2ndseed = b->E2nd();
|
755 |
etopseed = b->ETop();
|
756 |
ebottomseed = b->EBottom();
|
757 |
eleftseed = b->ELeft();
|
758 |
erightseed = b->ERight();
|
759 |
e1x3seed = b->E1x3();
|
760 |
e3x1seed = b->E3x1();
|
761 |
e1x5seed = b->E1x5();
|
762 |
e2x2seed = b->E2x2();
|
763 |
e4x4seed = b->E4x4();
|
764 |
e2x5maxseed = b->E2x5Max();
|
765 |
e2x5topseed = b->E2x5Top();
|
766 |
e2x5bottomseed = b->E2x5Bottom();
|
767 |
e2x5leftseed = b->E2x5Left();
|
768 |
e2x5rightseed = b->E2x5Right();
|
769 |
xseedseed = b->Pos().X();
|
770 |
yseedseed = b->Pos().Y();
|
771 |
zseedseed = b->Pos().Z();
|
772 |
nhitsseed = b->NHits();
|
773 |
|
774 |
|
775 |
if (b2) {
|
776 |
ebc2 = b2->Energy();
|
777 |
etabc2 = b2->Eta();
|
778 |
phibc2 = b2->Phi();
|
779 |
ietabc2 = b2->IEta();
|
780 |
iphibc2 = b2->IPhi();
|
781 |
ixbc2 = b2->IX();
|
782 |
iybc2 = b2->IY();
|
783 |
etacrybc2 = b2->EtaCry();
|
784 |
phicrybc2 = b2->PhiCry();
|
785 |
xcrybc2 = b2->XCry();
|
786 |
ycrybc2 = b2->YCry();
|
787 |
thetaaxisbc2 = b2->ThetaAxis();
|
788 |
phiaxisbc2 = b2->PhiAxis();
|
789 |
sigietaietabc2 = TMath::Sqrt(b2->CoviEtaiEta());
|
790 |
sigiphiphibc2 = TMath::Sqrt(b2->CoviPhiiPhi());
|
791 |
if (isnan(sigiphiphibc2)) sigiphiphibc2 = -99.;
|
792 |
covietaiphibc2 = b2->CoviEtaiPhi();
|
793 |
if (isnan(covietaiphibc2)) covietaiphibc2 = -99.;
|
794 |
e3x3bc2 = b2->E3x3();
|
795 |
e5x5bc2 = b2->E5x5();
|
796 |
emaxbc2 = b2->EMax();
|
797 |
e2ndbc2 = b2->E2nd();
|
798 |
etopbc2 = b2->ETop();
|
799 |
ebottombc2 = b2->EBottom();
|
800 |
eleftbc2 = b2->ELeft();
|
801 |
erightbc2 = b2->ERight();
|
802 |
e1x3bc2 = b2->E1x3();
|
803 |
e3x1bc2 = b2->E3x1();
|
804 |
e1x5bc2 = b2->E1x5();
|
805 |
e2x2bc2 = b2->E2x2();
|
806 |
e4x4bc2 = b2->E4x4();
|
807 |
e2x5maxbc2 = b2->E2x5Max();
|
808 |
e2x5topbc2 = b2->E2x5Top();
|
809 |
e2x5bottombc2 = b2->E2x5Bottom();
|
810 |
e2x5leftbc2 = b2->E2x5Left();
|
811 |
e2x5rightbc2 = b2->E2x5Right();
|
812 |
xbc2bc2 = b2->Pos().X();
|
813 |
ybc2bc2 = b2->Pos().Y();
|
814 |
zbc2bc2 = b2->Pos().Z();
|
815 |
nhitsbc2= b2->NHits();
|
816 |
}
|
817 |
else {
|
818 |
ebc2 = 0;
|
819 |
etabc2 = 0;
|
820 |
phibc2 = 0;
|
821 |
ietabc2 = 0;
|
822 |
iphibc2 = 0;
|
823 |
ixbc2 = 0;
|
824 |
iybc2 = 0;
|
825 |
etacrybc2 = 0;
|
826 |
phicrybc2 = 0;
|
827 |
xcrybc2 = 0;
|
828 |
ycrybc2 = 0;
|
829 |
thetaaxisbc2 = 0;
|
830 |
phiaxisbc2 = 0;
|
831 |
sigietaietabc2 = 0;
|
832 |
sigiphiphibc2 = 0;
|
833 |
covietaiphibc2 = 0;
|
834 |
e3x3bc2 = 0;
|
835 |
e5x5bc2 = 0;
|
836 |
emaxbc2 = 0;
|
837 |
e2ndbc2 = 0;
|
838 |
etopbc2 = 0;
|
839 |
ebottombc2 = 0;
|
840 |
eleftbc2 = 0;
|
841 |
erightbc2 = 0;
|
842 |
e1x3bc2 = 0;
|
843 |
e3x1bc2 = 0;
|
844 |
e1x5bc2 = 0;
|
845 |
e2x2bc2 = 0;
|
846 |
e4x4bc2 = 0;
|
847 |
e2x5maxbc2 = 0;
|
848 |
e2x5topbc2 = 0;
|
849 |
e2x5bottombc2 = 0;
|
850 |
e2x5leftbc2 = 0;
|
851 |
e2x5rightbc2 = 0;
|
852 |
xbc2bc2 = 0;
|
853 |
ybc2bc2 = 0;
|
854 |
zbc2bc2 = 0;
|
855 |
nhitsbc2 = 0;
|
856 |
}
|
857 |
|
858 |
if (bclast) {
|
859 |
ebclast = bclast->Energy();
|
860 |
etabclast = bclast->Eta();
|
861 |
phibclast = bclast->Phi();
|
862 |
ietabclast = bclast->IEta();
|
863 |
iphibclast = bclast->IPhi();
|
864 |
ixbclast = bclast->IX();
|
865 |
iybclast = bclast->IY();
|
866 |
etacrybclast = bclast->EtaCry();
|
867 |
phicrybclast = bclast->PhiCry();
|
868 |
xcrybclast = bclast->XCry();
|
869 |
ycrybclast = bclast->YCry();
|
870 |
thetaaxisbclast = bclast->ThetaAxis();
|
871 |
phiaxisbclast = bclast->PhiAxis();
|
872 |
sigietaietabclast = TMath::Sqrt(bclast->CoviEtaiEta());
|
873 |
sigiphiphibclast = TMath::Sqrt(bclast->CoviPhiiPhi());
|
874 |
if (isnan(sigiphiphibclast)) sigiphiphibclast = -99.;
|
875 |
covietaiphibclast = bclast->CoviEtaiPhi();
|
876 |
if (isnan(covietaiphibclast)) covietaiphibclast = -99.;
|
877 |
e3x3bclast = bclast->E3x3();
|
878 |
nhitsbclast = bclast->NHits();
|
879 |
}
|
880 |
else {
|
881 |
ebclast = 0;
|
882 |
etabclast = 0;
|
883 |
phibclast = 0;
|
884 |
ietabclast = 0;
|
885 |
iphibclast = 0;
|
886 |
ixbclast = 0;
|
887 |
iybclast = 0;
|
888 |
etacrybclast = 0;
|
889 |
phicrybclast = 0;
|
890 |
xcrybclast = 0;
|
891 |
ycrybclast = 0;
|
892 |
thetaaxisbclast = 0;
|
893 |
phiaxisbclast = 0;
|
894 |
sigietaietabclast = 0;
|
895 |
sigiphiphibclast = 0;
|
896 |
covietaiphibclast = 0;
|
897 |
e3x3bclast = 0;
|
898 |
nhitsbclast = 0;
|
899 |
}
|
900 |
|
901 |
if (bclast2) {
|
902 |
ebclast2 = bclast2->Energy();
|
903 |
etabclast2 = bclast2->Eta();
|
904 |
phibclast2 = bclast2->Phi();
|
905 |
ietabclast2 = bclast2->IEta();
|
906 |
iphibclast2 = bclast2->IPhi();
|
907 |
ixbclast2 = bclast2->IX();
|
908 |
iybclast2 = bclast2->IY();
|
909 |
etacrybclast2 = bclast2->EtaCry();
|
910 |
phicrybclast2 = bclast2->PhiCry();
|
911 |
xcrybclast2 = bclast2->XCry();
|
912 |
ycrybclast2 = bclast2->YCry();
|
913 |
thetaaxisbclast2 = bclast2->ThetaAxis();
|
914 |
phiaxisbclast2 = bclast2->PhiAxis();
|
915 |
sigietaietabclast2 = TMath::Sqrt(bclast2->CoviEtaiEta());
|
916 |
sigiphiphibclast2 = TMath::Sqrt(bclast2->CoviPhiiPhi());
|
917 |
if (isnan(sigiphiphibclast2)) sigiphiphibclast2 = -99.;
|
918 |
covietaiphibclast2 = bclast2->CoviEtaiPhi();
|
919 |
if (isnan(covietaiphibclast2)) covietaiphibclast2 = -99.;
|
920 |
e3x3bclast2 = bclast2->E3x3();
|
921 |
nhitsbclast2 = bclast2->NHits();
|
922 |
}
|
923 |
else {
|
924 |
ebclast2 = 0;
|
925 |
etabclast2 = 0;
|
926 |
phibclast2 = 0;
|
927 |
ietabclast2 = 0;
|
928 |
iphibclast2 = 0;
|
929 |
ixbclast2 = 0;
|
930 |
iybclast2 = 0;
|
931 |
etacrybclast2 = 0;
|
932 |
phicrybclast2 = 0;
|
933 |
xcrybclast2 = 0;
|
934 |
ycrybclast2 = 0;
|
935 |
thetaaxisbclast2 = 0;
|
936 |
phiaxisbclast2 = 0;
|
937 |
sigietaietabclast2 = 0;
|
938 |
sigiphiphibclast2 = 0;
|
939 |
covietaiphibclast2 = 0;
|
940 |
e3x3bclast2 = 0;
|
941 |
nhitsbclast2 = 0;
|
942 |
}
|
943 |
|
944 |
|
945 |
//initialize photon energy corrections if needed
|
946 |
/*if (!PhotonFix::initialised()) {
|
947 |
PhotonFix::initialise("4_2",std::string((gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/PhotonFix.dat")).Data()));
|
948 |
}*/
|
949 |
|
950 |
|
951 |
phfixph.setup(e,sceta,scphi,r9);
|
952 |
phfixele.setup(e,sceta,scphi,r9);
|
953 |
|
954 |
const Float_t dval = -99.;
|
955 |
ecor = phfixph.fixedEnergy();
|
956 |
ecorerr = phfixph.sigmaEnergy();
|
957 |
ecorele = phfixele.fixedEnergy();
|
958 |
ecoreleerr = phfixele.sigmaEnergy();
|
959 |
if (phfixph.isbarrel()) {
|
960 |
etac = phfixph.etaC();
|
961 |
etas = phfixph.etaS();
|
962 |
etam = phfixph.etaM();
|
963 |
phic = phfixph.phiC();
|
964 |
phis = phfixph.phiS();
|
965 |
phim = phfixph.phiM();
|
966 |
xz = dval;
|
967 |
xc = dval;
|
968 |
xs = dval;
|
969 |
xm = dval;
|
970 |
yz = dval;
|
971 |
yc = dval;
|
972 |
ys = dval;
|
973 |
ym = dval;
|
974 |
}
|
975 |
else {
|
976 |
etac = dval;
|
977 |
etas = dval;
|
978 |
etam = dval;
|
979 |
phic = dval;
|
980 |
phis = dval;
|
981 |
phim = dval;
|
982 |
xz = phfixph.xZ();
|
983 |
xc = phfixph.xC();
|
984 |
xs = phfixph.xS();
|
985 |
xm = phfixph.xM();
|
986 |
yz = phfixph.yZ();
|
987 |
yc = phfixph.yC();
|
988 |
ys = phfixph.yS();
|
989 |
ym = phfixph.yM();
|
990 |
}
|
991 |
|
992 |
if (c) {
|
993 |
hasconversion = kTRUE;
|
994 |
convp = c->P();
|
995 |
convpt = c->Pt();
|
996 |
conveta = c->Eta();
|
997 |
convphi = c->Phi();
|
998 |
ThreeVector dirconvsc = ThreeVector(s->Point()) - c->Position();
|
999 |
convdeta = c->Eta() - dirconvsc.Eta();
|
1000 |
convdphi = MathUtils::DeltaPhi(c->Phi(),dirconvsc.Phi());
|
1001 |
convvtxrho = c->Position().Rho();
|
1002 |
convvtxz = c->Position().Z();
|
1003 |
convvtxphi = c->Position().Phi();
|
1004 |
|
1005 |
const StableData *leadsd = dynamic_cast<const StableData*>(c->DaughterDat(0));
|
1006 |
const StableData *trailsd = dynamic_cast<const StableData*>(c->DaughterDat(1));
|
1007 |
if (leadsd->Pt()<trailsd->Pt()) {
|
1008 |
const StableData *sdtmp = leadsd;
|
1009 |
leadsd = trailsd;
|
1010 |
trailsd = sdtmp;
|
1011 |
}
|
1012 |
|
1013 |
const Track *leadtrack = dynamic_cast<const StableParticle*>(leadsd->Original())->Trk();
|
1014 |
const Track *trailtrack = dynamic_cast<const StableParticle*>(trailsd->Original())->Trk();
|
1015 |
|
1016 |
convleadpt = leadsd->Pt();
|
1017 |
convtrailpt = trailsd->Pt();
|
1018 |
convleadtrackpt = leadtrack->Pt();
|
1019 |
convleadtrackalgo = leadtrack->Algo();
|
1020 |
if (convleadtrackalgo==29) convleadtrackalgos=2; //gsf track
|
1021 |
else if (convleadtrackalgo==15 ||convleadtrackalgo==16) convleadtrackalgos=1; //ecal-seeded track
|
1022 |
else convleadtrackalgos = 0; //std iterative track
|
1023 |
convleadtrackcharge = leadtrack->Charge();
|
1024 |
convtrailtrackpt = trailtrack->Pt();
|
1025 |
convtrailtrackalgo = trailtrack->Algo();
|
1026 |
if (convtrailtrackalgo==29) convtrailtrackalgos=2; //gsf track
|
1027 |
else if (convtrailtrackalgo==15 ||convtrailtrackalgo==16) convtrailtrackalgos=1; //ecal-seeded track
|
1028 |
else convtrailtrackalgos = 0; //std iterative track
|
1029 |
trailtrackcharge = trailtrack->Charge();
|
1030 |
}
|
1031 |
else {
|
1032 |
hasconversion = kFALSE;
|
1033 |
convp = -99.;
|
1034 |
convpt = -99.;
|
1035 |
conveta = -99.;
|
1036 |
convphi = -99.;
|
1037 |
convdeta = -99.;
|
1038 |
convdphi = -99.;
|
1039 |
convvtxrho = -99.;
|
1040 |
convvtxz = -999.;
|
1041 |
convvtxphi = -99.;
|
1042 |
convleadpt = -99.;
|
1043 |
convtrailpt = -99.;
|
1044 |
convleadtrackpt = -99.;
|
1045 |
convleadtrackalgo = -99;
|
1046 |
convleadtrackalgos = -99;
|
1047 |
convleadtrackcharge = 0;
|
1048 |
convtrailtrackpt = -99.;
|
1049 |
convtrailtrackalgo = -99;
|
1050 |
convtrailtrackalgos = -99;
|
1051 |
trailtrackcharge = 0;
|
1052 |
}
|
1053 |
|
1054 |
//electron quantities
|
1055 |
if (ele) {
|
1056 |
haselectron = kTRUE;
|
1057 |
eleisecaldriven = ele->IsEcalDriven();
|
1058 |
eleistrackerdriven = ele->IsTrackerDriven();
|
1059 |
elee = ele->E();
|
1060 |
elept = ele->Pt();
|
1061 |
eleeta = ele->Eta();
|
1062 |
elephi = ele->Phi();
|
1063 |
elecharge = ele->Charge();
|
1064 |
elefbrem = ele->FBrem();
|
1065 |
eledeta = ele->DeltaEtaSuperClusterTrackAtVtx();
|
1066 |
eledphi = ele->DeltaPhiSuperClusterTrackAtVtx();
|
1067 |
elep = s->Energy()/ele->ESuperClusterOverP();
|
1068 |
elepin = ele->PIn();
|
1069 |
elepout = ele->POut();
|
1070 |
}
|
1071 |
else {
|
1072 |
haselectron = kFALSE;
|
1073 |
eleisecaldriven = kFALSE;
|
1074 |
eleistrackerdriven = kFALSE;
|
1075 |
elee = -99.;
|
1076 |
elept = -99.;
|
1077 |
eleeta = -99.;
|
1078 |
elephi = -99.;
|
1079 |
elecharge = -99;
|
1080 |
elefbrem = -99.;
|
1081 |
eledeta = -99.;
|
1082 |
eledphi = -99.;
|
1083 |
elep = -99.;
|
1084 |
elepin = -99.;
|
1085 |
elepout = -99.;
|
1086 |
}
|
1087 |
|
1088 |
//pf supercluster quantities
|
1089 |
if (pfsc) {
|
1090 |
haspfsc = kTRUE;
|
1091 |
pfsce = pfsc->Energy();
|
1092 |
pfscrawe = pfsc->RawEnergy();
|
1093 |
pfsceta = pfsc->Eta();
|
1094 |
pfscphi = pfsc->Phi();
|
1095 |
}
|
1096 |
else {
|
1097 |
haspfsc = kFALSE;
|
1098 |
pfsce = -99.;
|
1099 |
pfscrawe = -99.;
|
1100 |
pfsceta = -99.;
|
1101 |
pfscphi = -99.;
|
1102 |
}
|
1103 |
|
1104 |
genz = -99.;
|
1105 |
if (m) {
|
1106 |
ispromptgen = kTRUE;
|
1107 |
gene = m->E();
|
1108 |
genpt = m->Pt();
|
1109 |
geneta = m->Eta();
|
1110 |
genphi = m->Phi();
|
1111 |
const MCParticle *mm = m->DistinctMother();
|
1112 |
if (mm) genz = mm->DecayVertex().Z();
|
1113 |
pdgid = m->PdgId();
|
1114 |
if (mm) motherpdgid = mm->PdgId();
|
1115 |
else motherpdgid = -99;
|
1116 |
}
|
1117 |
else {
|
1118 |
ispromptgen = kFALSE;
|
1119 |
gene = -99.;
|
1120 |
genpt = -99.;
|
1121 |
geneta = -99.;
|
1122 |
genphi = -99.;
|
1123 |
pdgid = -99;
|
1124 |
motherpdgid = -99;
|
1125 |
}
|
1126 |
|
1127 |
}
|
1128 |
|