CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IsoTrackCalib.cc
Go to the documentation of this file.
1 #include "IsoTrackCalib.h"
5 
7  changed(false), nRun(0), t_trackP(0), t_trackPx(0), t_trackPy(0),
8  t_trackPz(0), t_trackEta(0), t_trackPhi(0), t_trackPt(0), t_neu_iso(0),
9  t_charge_iso(0), t_emip(0), t_ehcal(0), t_trkL3mindr(0), t_ieta(0),
10  t_disthotcell(0), t_ietahotcell(0), t_eventweight(0), t_l1pt(0), t_l1eta(0),
11  t_l1phi(0), t_l3pt(0), t_l3eta(0), t_l3phi(0), t_leadingpt(0),
12  t_leadingeta(0), t_leadingphi(0) {
13  //now do whatever initialization is needed
14  verbosity = iConfig.getUntrackedParameter<int>("Verbosity",0);
15  trigNames = iConfig.getUntrackedParameter<std::vector<std::string> >("Triggers");
16  theTrackQuality = iConfig.getUntrackedParameter<std::string>("TrackQuality","highPurity");
18  selectionParameters.minPt = iConfig.getUntrackedParameter<double>("MinTrackPt", 10.0);
19  selectionParameters.minQuality = trackQuality_;
20  selectionParameters.maxDxyPV = iConfig.getUntrackedParameter<double>("MaxDxyPV", 0.2);
21  selectionParameters.maxDzPV = iConfig.getUntrackedParameter<double>("MaxDzPV", 5.0);
22  selectionParameters.maxChi2 = iConfig.getUntrackedParameter<double>("MaxChi2", 5.0);
23  selectionParameters.maxDpOverP = iConfig.getUntrackedParameter<double>("MaxDpOverP", 0.1);
24  selectionParameters.minOuterHit = iConfig.getUntrackedParameter<int>("MinOuterHit", 4);
25  selectionParameters.minLayerCrossed = iConfig.getUntrackedParameter<int>("MinLayerCrossed", 8);
26  selectionParameters.maxInMiss = iConfig.getUntrackedParameter<int>("MaxInMiss", 0);
27  selectionParameters.maxOutMiss = iConfig.getUntrackedParameter<int>("MaxOutMiss", 0);
28  dr_L1 = iConfig.getUntrackedParameter<double>("IsolationL1",1.0);
29  a_coneR = iConfig.getUntrackedParameter<double>("ConeRadius",34.98);
30  a_charIsoR = a_coneR + 28.9;
31  a_neutIsoR = a_charIsoR*0.726;
32  a_mipR = iConfig.getUntrackedParameter<double>("ConeRadiusMIP",14.0);
33  a_neutR1 = iConfig.getUntrackedParameter<double>("ConeRadiusNeut1",21.0);
34  a_neutR2 = iConfig.getUntrackedParameter<double>("ConeRadiusNeut2",29.0);
35  cutMip = iConfig.getUntrackedParameter<double>("MIPCut", 1.0);
36  cutCharge = iConfig.getUntrackedParameter<double>("ChargeIsolation", 2.0);
37  cutNeutral = iConfig.getUntrackedParameter<double>("NeutralIsolation", 2.0);
38  minRunNo = iConfig.getUntrackedParameter<int>("minRun");
39  maxRunNo = iConfig.getUntrackedParameter<int>("maxRun");
40  drCuts = iConfig.getUntrackedParameter<std::vector<double> >("DRCuts");
41  bool isItAOD = iConfig.getUntrackedParameter<bool>("IsItAOD", true);
42  triggerEvent_ = edm::InputTag("hltTriggerSummaryAOD","","HLT");
43  theTriggerResultsLabel = edm::InputTag("TriggerResults","","HLT");
44 
45  // define tokens for access
46  tok_lumi = consumes<LumiDetails, edm::InLumi>(edm::InputTag("lumiProducer"));
47  tok_trigEvt = consumes<trigger::TriggerEvent>(triggerEvent_);
48  tok_trigRes = consumes<edm::TriggerResults>(theTriggerResultsLabel);
49  tok_genTrack_ = consumes<reco::TrackCollection>(edm::InputTag("generalTracks"));
50  tok_recVtx_ = consumes<reco::VertexCollection>(edm::InputTag("offlinePrimaryVertices"));
51  tok_bs_ = consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"));
52  tok_ew_ = consumes<GenEventInfoProduct>(edm::InputTag("generator"));
53  tok_pf_ = consumes<reco::PFJetCollection>(edm::InputTag("ak5PFJets"));
54 
55  if (isItAOD) {
56  tok_EB_ = consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEB"));
57  tok_EE_ = consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEE"));
58  tok_hbhe_ = consumes<HBHERecHitCollection>(edm::InputTag("reducedHcalRecHits", "hbhereco"));
59  } else {
60  tok_EB_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit","EcalRecHitsEB"));
61  tok_EE_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit","EcalRecHitsEE"));
62  tok_hbhe_ = consumes<HBHERecHitCollection>(edm::InputTag("hbhereco"));
63  }
64 
65  if (verbosity>=0) {
66  edm::LogInfo("IsoTrack") <<"Parameters read from config file \n"
67  <<"\t minPt " << selectionParameters.minPt
68  <<"\t theTrackQuality " << theTrackQuality
69  <<"\t minQuality " << selectionParameters.minQuality
70  <<"\t maxDxyPV " << selectionParameters.maxDxyPV
71  <<"\t maxDzPV " << selectionParameters.maxDzPV
72  <<"\t maxChi2 " << selectionParameters.maxChi2
73  <<"\t maxDpOverP " << selectionParameters.maxDpOverP
74  <<"\t minOuterHit " << selectionParameters.minOuterHit
75  <<"\t minLayerCrossed " << selectionParameters.minLayerCrossed
76  <<"\t maxInMiss " << selectionParameters.maxInMiss
77  <<"\t maxOutMiss " << selectionParameters.maxOutMiss
78  <<"\t a_coneR " << a_coneR
79  <<"\t a_charIsoR " << a_charIsoR
80  <<"\t a_neutIsoR " << a_neutIsoR
81  <<"\t a_mipR " << a_mipR
82  <<"\t a_neutR " << a_neutR1 << ":" << a_neutR2
83  <<"\t cuts (MIP " << cutMip << " : Charge " << cutCharge
84  <<" : Neutral " << cutNeutral << ")";
85  edm::LogInfo("IsoTrack") << trigNames.size() << " triggers to be studied";
86  for (unsigned int k=0; k<trigNames.size(); ++k)
87  edm::LogInfo("IsoTrack") << "Trigger[" << k << "] : " << trigNames[k];
88  edm::LogInfo("IsoTrack") << drCuts.size() << " Delta R zones wrt trigger objects";
89  for (unsigned int k=0; k<drCuts.size(); ++k)
90  edm::LogInfo("IsoTrack") << "Cut[" << k << "]: " << drCuts[k];
91  }
92 }
93 
95  // do anything here that needs to be done at desctruction time
96  // (e.g. close files, deallocate resources etc.)
97 
98  if (t_trackP) delete t_trackP;
99  if (t_trackPx) delete t_trackPx;
100  if (t_trackPy) delete t_trackPy;
101  if (t_trackPz) delete t_trackPz;
102  if (t_trackEta) delete t_trackEta;
103  if (t_trackPhi) delete t_trackPhi;
104  if (t_trackPt) delete t_trackPt;
105  if (t_neu_iso) delete t_neu_iso;
106  if (t_charge_iso) delete t_charge_iso;
107  if (t_emip) delete t_emip;
108  if (t_ehcal) delete t_ehcal;
109  if (t_trkL3mindr) delete t_trkL3mindr;
110  if (t_ieta) delete t_ieta;
111  if (t_disthotcell)delete t_disthotcell;
112  if (t_ietahotcell)delete t_ietahotcell;
113  if (t_eventweight)delete t_eventweight;
114  if (t_l1pt) delete t_l1pt;
115  if (t_l1eta) delete t_l1eta;
116  if (t_l1phi) delete t_l1phi;
117  if (t_l3pt) delete t_l3pt;
118  if (t_l3eta) delete t_l3eta;
119  if (t_l3phi) delete t_l3phi;
120  if (t_leadingpt) delete t_leadingpt;
121  if (t_leadingeta) delete t_leadingeta;
122  if (t_leadingphi) delete t_leadingphi;
123  }
124 
126 
127  Run = iEvent.id().run();
128  Event = iEvent.id().event();
129  if (verbosity%10 > 0)
130  edm::LogInfo("IsoTrack") << "Run " << Run << " Event " << Event
131  << " Luminosity " << iEvent.luminosityBlock()
132  << " Bunch " << iEvent.bunchCrossing() << " start";
134 
135  //Get magnetic field and ECAL channel status
137  iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
138  const MagneticField *bField = bFieldH.product();
139 
141  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
142 
143  // get handles to calogeometry and calotopology
145  iSetup.get<CaloGeometryRecord>().get(pG);
146  const CaloGeometry* geo = pG.product();
147 
148  //Get track collection
150  iEvent.getByToken(tok_genTrack_, trkCollection);
151  reco::TrackCollection::const_iterator trkItr;
152 
153  double flatPtWeight = 0.0;
154  //event weight for FLAT sample
156  iEvent.getByToken(tok_ew_, genEventInfo);
157  flatPtWeight = genEventInfo->weight();
158 
159  //jets info
161  iEvent.getByToken(tok_pf_, pfJetsHandle);
162  reco::PFJetCollection::const_iterator pfItr;
163 
164  //Define the best vertex and the beamspot
166  iEvent.getByToken(tok_recVtx_, recVtxs);
167  edm::Handle<reco::BeamSpot> beamSpotH;
168  iEvent.getByToken(tok_bs_, beamSpotH);
169  math::XYZPoint leadPV(0,0,0);
170  if (recVtxs->size()>0 && !((*recVtxs)[0].isFake())) {
171  leadPV = math::XYZPoint( (*recVtxs)[0].x(),(*recVtxs)[0].y(), (*recVtxs)[0].z() );
172  } else if (beamSpotH.isValid()) {
173  leadPV = beamSpotH->position();
174  }
175  if ((verbosity/100)%10>0) {
176  edm::LogInfo("IsoTrack") << "Primary Vertex " << leadPV;
177  if (beamSpotH.isValid()) edm::LogInfo("IsoTrack") << "Beam Spot "
178  << beamSpotH->position();
179  }
180 
181  // RecHits
182  edm::Handle<EcalRecHitCollection> barrelRecHitsHandle;
183  edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
184  iEvent.getByToken(tok_EB_, barrelRecHitsHandle);
185  iEvent.getByToken(tok_EE_, endcapRecHitsHandle);
187  iEvent.getByToken(tok_hbhe_, hbhe);
188 
190  iEvent.getLuminosityBlock().getByToken(tok_lumi, Lumid);
191  float mybxlumi=-1;
192  if (Lumid.isValid())
193  mybxlumi=Lumid->lumiValue(LumiDetails::kOCC1,iEvent.bunchCrossing())*6.37;
194  if (verbosity%10 > 0) edm::LogInfo("IsoTrack") << "Luminosity " << mybxlumi;
195 
196  trigger::TriggerEvent triggerEvent;
197  edm::Handle<trigger::TriggerEvent> triggerEventHandle;
198  iEvent.getByToken(tok_trigEvt, triggerEventHandle);
199  if (!triggerEventHandle.isValid()) {
200  edm::LogWarning("IsoTrack") << "Error! Can't get the product "
201  << triggerEvent_.label();
202  } else {
203  triggerEvent = *(triggerEventHandle.product());
204 
205  const trigger::TriggerObjectCollection& TOC(triggerEvent.getObjects());
208  iEvent.getByToken(tok_trigRes, triggerResults);
209  if (triggerResults.isValid()) {
210  std::vector<std::string> modules;
211  h_nHLT->Fill(triggerResults->size());
212  const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults);
213 
214  const std::vector<std::string> & triggerNames_ = triggerNames.triggerNames();
215  for (unsigned int iHLT=0; iHLT<triggerResults->size(); iHLT++) {
216  bool ok(false);
217  unsigned int triggerindx = hltConfig_.triggerIndex(triggerNames_[iHLT]);
218  const std::vector<std::string>& moduleLabels(hltConfig_.moduleLabels(triggerindx));
219  edm::LogInfo("IsoTrack") << iHLT << " " <<triggerNames_[iHLT];
220  int ipos = -1;
221  for (unsigned int i=0; i<HLTNames.size(); ++i) {
222  if (triggerNames_[iHLT] == HLTNames[i]) {
223  ipos = i;
224  break;
225  }
226  }
227  if (ipos < 0) {
228  ipos = (int)(HLTNames.size()+1);
229  HLTNames.push_back(triggerNames_[iHLT]);
230  h_HLTAccept->GetXaxis()->SetBinLabel(ipos+1,triggerNames_[iHLT].c_str());
231  }
232  if (firstEvent) h_HLTAccepts[nRun]->GetXaxis()->SetBinLabel(iHLT+1, triggerNames_[iHLT].c_str());
233  int hlt = triggerResults->accept(iHLT);
234  if (hlt) {
235  h_HLTAccepts[nRun]->Fill(iHLT+1);
236  h_HLTAccept->Fill(ipos+1);
237  }
238  if (iHLT >= 645) edm::LogInfo("IsoTrack") << "Wrong trigger " << Run
239  << " Event " << Event
240  << " Hlt " << iHLT;
241  for (unsigned int i=0; i<trigNames.size(); ++i) {
242  if (triggerNames_[iHLT].find(trigNames[i].c_str())!=std::string::npos) {
243  if (verbosity)
244  edm::LogInfo("IsoTrack") << "This is the trigger we are looking for " << triggerNames_[iHLT];
245  if (hlt > 0) ok = true;
246  }
247  }
248  if (verbosity%10 > 2)
249  edm::LogInfo("IsoTrack") << "Trigger fired? : " << ok;
250  if (ok) {
251  std::vector<math::XYZTLorentzVector> vec[3];
252  const std::pair<int,int> prescales(hltConfig_.prescaleValues(iEvent,iSetup,triggerNames_[iHLT]));
253  int preL1 = prescales.first;
254  int preHLT = prescales.second;
255  int prescale = preL1*preHLT;
256  if (verbosity%10 > 0)
257  edm::LogInfo("IsoTrack") << triggerNames_[iHLT] << " accept "
258  << hlt << " preL1 " << preL1 << " preHLT "
259  << preHLT << " preScale " << prescale;
260  std::pair<unsigned int, std::string> iRunTrig =
261  std::pair<unsigned int, std::string>(Run,triggerNames_[iHLT]);
262  if (TrigList.find(iRunTrig) != TrigList.end() ) {
263  TrigList[iRunTrig] += 1;
264  } else {
265  TrigList.insert(std::pair<std::pair<unsigned int, std::string>, unsigned int>(iRunTrig,1));
266  TrigPreList.insert(std::pair<std::pair<unsigned int, std::string>, std::pair<int, int>>(iRunTrig,prescales));
267  }
268  //loop over all trigger filters in event (i.e. filters passed)
269  for (unsigned int ifilter=0; ifilter<triggerEvent.sizeFilters(); ++ifilter) {
270  std::vector<int> Keys;
271  std::string label = triggerEvent.filterTag(ifilter).label();
272  //loop over keys to objects passing this filter
273  for (unsigned int imodule=0; imodule<moduleLabels.size(); imodule++) {
274  if (label.find(moduleLabels[imodule]) != std::string::npos) {
275  if (verbosity%10 > 0)
276  edm::LogInfo("IsoTrack") << "FilterName " << label;
277  for (unsigned int ifiltrKey=0; ifiltrKey<triggerEvent.filterKeys(ifilter).size(); ++ifiltrKey) {
278  Keys.push_back(triggerEvent.filterKeys(ifilter)[ifiltrKey]);
279  const trigger::TriggerObject& TO(TOC[Keys[ifiltrKey]]);
280  math::XYZTLorentzVector v4(TO.px(), TO.py(), TO.pz(), TO.energy());
281  if(label.find("hltSingleJet") != std::string::npos) {
282  vec[1].push_back(v4);
283  } else if (label.find("hlt1PFJet") != std::string::npos) {
284  vec[2].push_back(v4);
285  } else {
286  vec[0].push_back(v4);
287  }
288  if (verbosity%10 > 2)
289  edm::LogInfo("IsoTrack") << "key " << ifiltrKey << " : pt "
290  << TO.pt() << " eta " << TO.eta()
291  << " phi " << TO.phi() << " mass "
292  << TO.mass() << " Id " << TO.id();
293  }
294  }
295  }
296  }
298  if (verbosity%10 > 0) {
299  for (int j=0; j<3; j++) {
300  for (unsigned int k=0; k<vec[j].size(); k++) {
301  edm::LogInfo("IsoTrack") << "vec[" << j << "][" << k << "] pt "
302  << vec[j][k].pt() << " eta "
303  << vec[j][k].eta() << " phi "
304  << vec[j][k].phi();
305  }
306  }
307  }
308  double deta, dphi, dr;
310  math::XYZTLorentzVector mindRvec1;
311  double mindR1(999);
312  for (int lvl=1; lvl<3; lvl++) {
313  for (unsigned int i=0; i<vec[lvl].size(); i++) {
314  deta = dEta(vec[0][0],vec[lvl][i]);
315  dphi = dPhi(vec[0][0],vec[lvl][i]);
316  dr = dR(vec[0][0],vec[lvl][i]);
317  if (verbosity%10 > 2)
318  edm::LogInfo("IsoTrack") << "lvl " << lvl << " i " << i
319  << " deta " << deta << " dphi "
320  << dphi << " dR " << dr;
321  if (dr<mindR1) {
322  mindR1 = dr;
323  mindRvec1 = vec[lvl][i];
324  }
325  }
326  }
327  //leading jet loop
328  for(pfItr=pfJetsHandle->begin();pfItr!=pfJetsHandle->end(); pfItr++){
329  t_leadingpt->push_back(pfItr->pt());
330  t_leadingeta->push_back(pfItr->eta());
331  t_leadingphi->push_back(pfItr->phi());
332  if (verbosity%10 > 0)
333  edm::LogInfo("IsoTrack") << "Leading jet : pt/eta/phi "
334  << pfItr->pt() << "/" << pfItr->eta()
335  << "/" << pfItr->phi();
336  break;
337  }
338  //tracks loop
339  std::vector<spr::propagatedTrackDirection> trkCaloDirections;
340  spr::propagateCALO(trkCollection, geo, bField, theTrackQuality, trkCaloDirections, ((verbosity/100)%10>2));
341  std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
342  unsigned int nTracks=0,nselTracks=0;
343  for (trkDetItr = trkCaloDirections.begin(),nTracks=0;
344  trkDetItr != trkCaloDirections.end(); trkDetItr++,nTracks++) {
345  const reco::Track* pTrack = &(*(trkDetItr->trkItr));
346  math::XYZTLorentzVector v4(pTrack->px(), pTrack->py(), pTrack->pz(), pTrack->p());
347  TLorentzVector trackinfo;
348  trackinfo.SetPxPyPzE(pTrack->px(), pTrack->py(), pTrack->pz(), pTrack->p());
349  if (verbosity%10 > 0)
350  edm::LogInfo("IsoTrack") << "This track : " << nTracks
351  << " (pt/eta/phi/p) :" << pTrack->pt()
352  << "/" << pTrack->eta() << "/"
353  << pTrack->phi() << "/" << pTrack->p();
354  math::XYZTLorentzVector mindRvec2;
355  double mindR2(999);
356  if(pTrack->pt()>10){
357  for (unsigned int k=0; k<vec[2].size(); ++k) {
358  dr = dR(vec[2][k],v4); //changed 1 to 2
359  if (dr<mindR2) {
360  mindR2 = dr;
361  mindRvec2 = vec[2][k];
362  }
363  }
364  if (verbosity%10 > 2)
365  edm::LogInfo("IsoTrack") << "Closest L3 object at mindr :"
366  << mindR2 << " is " << mindRvec2;
367  double mindR = dR(mindRvec1,v4);
368 
369  unsigned int i1 = drCuts.size();
370  for (unsigned int ik=0; ik<drCuts.size(); ++ik) {
371  if (mindR < drCuts[ik]) {
372  i1 = ik; break;
373  }
374  }
375  unsigned int i2 = drCuts.size();
376  for (unsigned int ik=0; ik<drCuts.size(); ++ik) {
377  if (mindR2 < drCuts[ik]) {
378  i2 = ik; break;
379  }
380  }
381 
382  //Selection of good track
383  bool selectTk = spr::goodTrack(pTrack,leadPV,selectionParameters,((verbosity/100)%10>2));
384  int ieta(0);
385  if (trkDetItr->okHCAL) {
386  HcalDetId detId = (HcalDetId)(trkDetItr->detIdHCAL);
387  ieta = detId.ieta();
388  }
389  if (verbosity%10 > 0)
390  edm::LogInfo("IsoTrack") << "seltlk/okECAL/okHCAL : "<< selectTk
391  << "/" << trkDetItr->okECAL << "/"
392  << trkDetItr->okHCAL << " iEta "
393  << ieta << " Classify " << i1 << ":"
394  << i2;
395  if (selectTk && trkDetItr->okECAL && trkDetItr->okHCAL) {
396  nselTracks++;
397  int nRH_eMipDR=0, nNearTRKs=0;
398  double e1 = spr::eCone_ecal(geo, barrelRecHitsHandle, endcapRecHitsHandle,
399  trkDetItr->pointHCAL, trkDetItr->pointECAL,
400  a_neutR1, trkDetItr->directionECAL, nRH_eMipDR);
401  double e2 = spr::eCone_ecal(geo, barrelRecHitsHandle, endcapRecHitsHandle,
402  trkDetItr->pointHCAL, trkDetItr->pointECAL,
403  a_neutR2, trkDetItr->directionECAL, nRH_eMipDR);
404  double eMipDR = spr::eCone_ecal(geo, barrelRecHitsHandle, endcapRecHitsHandle,
405  trkDetItr->pointHCAL, trkDetItr->pointECAL,
406  a_mipR, trkDetItr->directionECAL, nRH_eMipDR);
407  int ietaHotCell(-99), iphiHotCell(-99), nRecHitsCone(-999);
408  double distFromHotCell(-99.0);
409  std::vector<DetId> coneRecHitDetIds;
410  GlobalPoint gposHotCell(0.,0.,0.);
411  double eHcal = spr::eCone_hcal(geo, hbhe, trkDetItr->pointHCAL, trkDetItr->pointECAL,
412  a_coneR, trkDetItr->directionHCAL, nRecHitsCone,
413  coneRecHitDetIds, distFromHotCell,
414  ietaHotCell, iphiHotCell, gposHotCell);
415 
416  double conehmaxNearP = spr::chargeIsolationCone(nTracks, trkCaloDirections, a_charIsoR, nNearTRKs, ((verbosity/100)%10>2));
417  double e_inCone = e2 - e1;
418 
419  if (verbosity%10 > 0) {
420  edm::LogInfo("IsoTrack") << "This track : " << nTracks
421  <<" (pt/eta/phi/p) :" << pTrack->pt()
422  << "/" << pTrack->eta() << "/"
423  << pTrack->phi() << "/"
424  << pTrack->p() << "\n"
425  << " (MIP/neu_isol/charge_iso/HCAL_energy/iEta/distfromHcell/iEtaHcell) = "
426  << eMipDR << "/"<< e_inCone << "/"
427  << conehmaxNearP << "/" << eHcal
428  << "/" << ieta << "/" << distFromHotCell
429  << "/" <<ietaHotCell;
430  }
431  t_trackP->push_back(pTrack->p());
432  t_trackPx->push_back(pTrack->px());
433  t_trackPy->push_back(pTrack->py());
434  t_trackPz->push_back(pTrack->pz());
435  t_trackPt->push_back(pTrack->pt());;
436  t_trackEta->push_back(pTrack->eta());
437  t_trackPhi->push_back(pTrack->phi());
438  t_emip->push_back(eMipDR);
439  t_neu_iso->push_back(e_inCone);;
440  t_charge_iso->push_back(conehmaxNearP);
441  t_ehcal->push_back(eHcal);
442  t_trkL3mindr->push_back(mindR2);
443  t_ieta->push_back(ieta);
444  t_disthotcell->push_back(distFromHotCell);
445  t_ietahotcell->push_back(ietaHotCell);
446  }
447  }
448  }
449  if (verbosity%10 > 0) {
450  edm::LogInfo("IsoTrack") << "selected tracks = " << nselTracks
451  << "\nevent weight is = " << flatPtWeight
452  << "\n L1 trigger object : pt/eta/phi "
453  << vec[0][0].pt() << "/" << vec[0][0].eta()
454  << "/" << vec[0][0].phi()
455  << "\n L3 trigger object : pt/eta/phi "
456  << vec[2][0].pt() << "/" << vec[2][0].eta()
457  << "/"<< vec[2][0].phi();
458  }
459  t_l1pt->push_back(vec[0][0].pt());
460  t_l1eta->push_back(vec[0][0].eta());
461  t_l1phi->push_back(vec[0][0].phi());
462  t_l3pt->push_back(vec[2][0].pt());
463  t_l3eta->push_back(vec[2][0].eta());
464  t_l3phi->push_back(vec[2][0].phi());
465  t_eventweight->push_back(flatPtWeight);
466  // break;
467  }
468  }
469  // check if trigger names in (new) config
470  if (changed) {
471  changed = false;
472  if ((verbosity/10)%10 > 1) {
473  edm::LogInfo("IsoTrack") <<"New trigger menu found !!!";
474  const unsigned int n(hltConfig_.size());
475  for (unsigned itrig=0; itrig<triggerNames_.size(); itrig++) {
476  unsigned int triggerindx = hltConfig_.triggerIndex(triggerNames_[itrig]);
477  if (triggerindx >= n)
478  edm::LogInfo("IsoTrack") << triggerNames_[itrig] << " "
479  << triggerindx << " does not exist";
480  else
481  edm::LogInfo("IsoTrack") << triggerNames_[itrig] << " "
482  << triggerindx << " exists";
483  }
484  }
485  }
486  }
487  }
488  tree->Fill();
489 }
490 
492  h_nHLT = fs->make<TH1I>("h_nHLT" , "size of trigger Names", 1000, 0, 1000);
493  h_HLTAccept = fs->make<TH1I>("h_HLTAccept", "HLT Accepts for all runs", 1000, 0, 1000);
494  tree = fs->make<TTree>("tree", "tree");
495 
496  tree->Branch("Run",&Run,"Run/I");
497  tree->Branch("Event",&Event,"Event/I");
498  t_trackP = new std::vector<double>();
499  t_trackPx = new std::vector<double>();
500  t_trackPy = new std::vector<double>();
501  t_trackPz = new std::vector<double>();
502  t_trackEta = new std::vector<double>();
503  t_trackPhi = new std::vector<double>();
504  t_trackPt = new std::vector<double>();
505  t_neu_iso = new std::vector<double>();
506  t_charge_iso = new std::vector<double>();
507  t_emip = new std::vector<double>();
508  t_ehcal = new std::vector<double>();
509  t_trkL3mindr = new std::vector<double>();
510  t_ieta = new std::vector<int>();
511  t_disthotcell = new std::vector<double>();
512  t_ietahotcell = new std::vector<double>();
513  t_eventweight = new std::vector<double>();
514  t_l1pt = new std::vector<double>();
515  t_l1eta = new std::vector<double>();
516  t_l1phi = new std::vector<double>();
517  t_l3pt = new std::vector<double>();
518  t_l3eta = new std::vector<double>();
519  t_l3phi = new std::vector<double>();
520  t_leadingpt = new std::vector<double>();
521  t_leadingeta = new std::vector<double>();
522  t_leadingphi = new std::vector<double>();
523 
524  tree->Branch("t_trackP","std::vector<double>",&t_trackP);
525  tree->Branch("t_trackPx","std::vector<double>",&t_trackPx);
526  tree->Branch("t_trackPy","std::vector<double>",&t_trackPy);
527  tree->Branch("t_trackPz","std::vector<double>",&t_trackPz);
528  tree->Branch("t_trackEta","std::vector<double>",&t_trackEta);
529  tree->Branch("t_trackPhi","vector<double>",&t_trackPhi);
530  tree->Branch("t_trackPt","std::vector<double>",&t_trackPt);
531  tree->Branch("t_neu_iso","std::vector<double>",&t_neu_iso);
532  tree->Branch("t_charge_iso","std::vector<double>",&t_charge_iso);
533  tree->Branch("t_emip","std::vector<double>",&t_emip);
534  tree->Branch("t_ehcal","std::vector<double>",&t_ehcal);
535  tree->Branch("t_trkL3mindr","std::vector<double>",&t_trkL3mindr);
536  tree->Branch("t_ieta","std::vector<int>",&t_ieta);
537  tree->Branch("t_disthotcell","std::vector<double>",&t_disthotcell);
538  tree->Branch("t_ietahotcell","std::vector<double>",&t_ietahotcell);
539  tree->Branch("t_eventweight","std::vector<double>",&t_eventweight);
540  tree->Branch("t_l1pt","std::vector<double>",&t_l1pt);
541  tree->Branch("t_l1eta","std::vector<double>",&t_l1eta);
542  tree->Branch("t_l1phi","std::vector<double>",&t_l1phi);
543  tree->Branch("t_l3pt","std::vector<double>",&t_l3pt);
544  tree->Branch("t_l3eta","std::vector<double>",&t_l3eta);
545  tree->Branch("t_l3phi","std::vector<double>",&t_l3phi);
546  tree->Branch("t_leadingpt","std::vector<double>",&t_leadingpt);
547  tree->Branch("t_leadingeta","std::vector<double>",&t_leadingeta);
548  tree->Branch("t_leadingphi","std::vector<double>",&t_leadingphi);
549 }
550 
551 // ------------ method called once each job just after ending the event loop ------------
553  unsigned int preL1, preHLT;
554  std::map<std::pair<unsigned int, std::string>, unsigned int>::iterator itr;
555  std::map<std::pair<unsigned int, std::string>, const std::pair<int, int>>::iterator itrPre;
556  edm::LogInfo("IsoTrack") << "RunNo vs HLT accepts";
557  unsigned int n = maxRunNo - minRunNo +1;
558  g_Pre = fs->make<TH1I>("h_PrevsRN", "PreScale Vs Run Number", n, minRunNo, maxRunNo);
559  g_PreL1 = fs->make<TH1I>("h_PreL1vsRN", "L1 PreScale Vs Run Number", n, minRunNo, maxRunNo);
560  g_PreHLT = fs->make<TH1I>("h_PreHLTvsRN", "HLT PreScale Vs Run Number", n, minRunNo, maxRunNo);
561  g_Accepts = fs->make<TH1I>("h_HLTAcceptsvsRN", "HLT Accepts Vs Run Number", n, minRunNo, maxRunNo);
562 
563  for (itr=TrigList.begin(), itrPre=TrigPreList.begin(); itr!=TrigList.end(); itr++, itrPre++) {
564  preL1 = (itrPre->second).first;
565  preHLT = (itrPre->second).second;
566  g_Accepts->Fill((itr->first).first, itr->second);
567  g_PreL1->Fill((itr->first).first, preL1);
568  g_PreHLT->Fill((itr->first).first, preHLT);
569  g_Pre->Fill((itr->first).first, preL1*preHLT);
570  }
571 }
572 
573 // ------------ method called when starting to processes a run ------------
574 void IsoTrackCalib::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
575  edm::LogInfo("IsoTrack") << "Run[" << nRun <<"] " << iRun.run()
576  << " hltconfig.init " << hltConfig_.init(iRun,iSetup,"HLT",changed);
577  char hname[100], htit[100];
578  sprintf(hname, "h_HLTAccepts_%i", iRun.run());
579  sprintf(htit, "HLT Accepts for Run No %i", iRun.run());
580  TH1I *hnew = fs->make<TH1I>(hname, htit, 1000, 0, 1000);
581  h_HLTAccepts.push_back(hnew);
582  firstEvent = true;
583 }
584 
585 // ------------ method called when ending the processing of a run ------------
586 void IsoTrackCalib::endRun(edm::Run const& iRun, edm::EventSetup const&) {
587  nRun++;
588  edm::LogInfo("IsoTrack") << "endRun[" << nRun << "] " << iRun.run();
589 }
590 
591 // ------------ method called when starting to processes a luminosity block ------------
593 // ------------ method called when ending the processing of a luminosity block ------------
595 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
597  //The following says we do not know what parameters are allowed so do no validation
598  // Please change this to state exactly what you do use, even if it is no parameters
600  desc.setUnknown();
601  descriptions.addDefault(desc);
602 }
603 
605  return (vec1.eta()-vec2.eta());
606 }
607 
609  return reco::deltaPhi(vec1.phi(),vec2.phi());
610 }
611 
613  return reco::deltaR(vec1.eta(),vec1.phi(),vec2.eta(),vec2.phi());
614 }
615 
617  return (vec1.pt()-vec2.pt());
618 }
619 
621  return (std::abs(vec1.r()-vec2.r()));
622 }
623 
625  return ((1/vec1.pt())-(1/vec2.pt()));
626 }
627 
629  t_trackP->clear();
630  t_trackPx->clear();
631  t_trackPy->clear();
632  t_trackPz->clear();
633  t_trackPt->clear();
634  t_trackEta->clear();
635  t_trackPhi->clear();
636  t_emip->clear();
637  t_neu_iso->clear();;
638  t_charge_iso->clear();
639  t_ehcal->clear();
640  t_trkL3mindr->clear();
641  t_ieta->clear();
642  t_disthotcell->clear();
643  t_ietahotcell->clear();
644  t_eventweight->clear();
645  t_l1pt->clear();
646  t_l1eta->clear();
647  t_l1phi->clear();
648  t_l3pt->clear();
649  t_l3eta->clear();
650  t_l3phi->clear();
651  t_leadingpt->clear();
652  t_leadingeta->clear();
653  t_leadingphi->clear();
654 }
655 
656 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:39
unsigned int size() const
number of trigger paths in trigger table
double p() const
momentum vector magnitude
Definition: TrackBase.h:568
EventNumber_t event() const
Definition: EventID.h:41
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:208
std::vector< double > * t_trackP
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, std::string &theTrackQuality, bool debug=false)
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
int id() const
getters
Definition: TriggerObject.h:55
RunNumber_t run() const
Definition: RunBase.h:42
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:135
std::vector< double > * t_trackEta
HLTConfigProvider hltConfig_
Definition: IsoTrackCalib.h:98
std::vector< double > * t_l3pt
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
float phi() const
Definition: TriggerObject.h:58
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual void endRun(edm::Run const &, edm::EventSetup const &)
edm::InputTag triggerEvent_
TrackQuality
track quality
Definition: TrackBase.h:139
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:111
edm::EDGetTokenT< reco::VertexCollection > tok_recVtx_
int bunchCrossing() const
Definition: EventBase.h:66
std::vector< double > * t_eventweight
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:63
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:598
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
float energy() const
Definition: TriggerObject.h:65
std::vector< double > * t_trackPhi
edm::EDGetTokenT< reco::TrackCollection > tok_genTrack_
double chargeIsolationCone(unsigned int trkIndex, std::vector< spr::propagatedTrackDirection > &trkDirs, double dR, int &nNearTRKs, bool debug=false)
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
float eta() const
Definition: TriggerObject.h:57
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:580
std::vector< double > * t_leadingeta
std::vector< double > * t_disthotcell
T eta() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes
Strings const & triggerNames() const
Definition: TriggerNames.cc:24
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
std::vector< double > * t_leadingphi
float float float z
std::vector< TH1I * > h_HLTAccepts
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
std::vector< int > * t_ieta
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:22
U second(std::pair< T, U > const &p)
std::string theTrackQuality
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
std::vector< double > * t_l1pt
edm::EDGetTokenT< trigger::TriggerEvent > tok_trigEvt
std::vector< double > * t_trackPt
std::vector< double > * t_trackPy
double dR(double eta1, double eta2, double phi1, double phi2)
std::vector< double > drCuts
std::vector< std::string > HLTNames
Definition: IsoTrackCalib.h:99
std::vector< double > * t_ehcal
double dinvPt(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
std::vector< double > * t_trackPx
int iEvent
Definition: GenABIO.cc:230
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:604
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< double > * t_ietahotcell
edm::Service< TFileService > fs
Definition: IsoTrackCalib.h:97
edm::EDGetTokenT< reco::BeamSpot > tok_bs_
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
std::vector< double > vec1
Definition: HCALResponse.h:15
double pt() const
track transverse momentum
Definition: TrackBase.h:574
int ieta() const
get the cell ieta
Definition: HcalDetId.h:36
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< reco::PFJetCollection > tok_pf_
double eCone_ecal(const CaloGeometry *geo, edm::Handle< T > &barrelhits, edm::Handle< T > &endcaphits, const GlobalPoint &hpoint1, const GlobalPoint &point1, double dR, const GlobalVector &trackMom, int &nRecHits, double ebThr=-100, double eeThr=-100, double tMin=-500, double tMax=500, bool debug=false)
edm::EDGetTokenT< LumiDetails > tok_lumi
LuminosityBlock const & getLuminosityBlock() const
Definition: Event.h:77
static std::string const triggerResults
Definition: EdmProvDump.cc:40
bool isValid() const
Definition: HandleBase.h:75
std::vector< double > * t_l1phi
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:592
std::vector< double > * t_emip
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
double dP(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:12
const edm::InputTag filterTag(trigger::size_type index) const
Definition: TriggerEvent.h:103
std::vector< double > * t_charge_iso
double dEta(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
std::vector< double > * t_l3phi
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:114
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
T const * product() const
Definition: Handle.h:81
double eCone_hcal(const CaloGeometry *geo, edm::Handle< T > &hits, const GlobalPoint &hpoint1, const GlobalPoint &point1, double dR, const GlobalVector &trackMom, int &nRecHits, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, int detOnly=-1, bool debug=false)
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
TH1I * h_HLTAccept
std::vector< size_type > Keys
virtual void beginJob()
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
edm::EDGetTokenT< GenEventInfoProduct > tok_ew_
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
std::pair< int, int > prescaleValues(const edm::Event &iEvent, const edm::EventSetup &iSetup, const std::string &trigger) const
Combined L1T (pair.first) and HLT (pair.second) prescales per HLT path.
std::vector< double > * t_trackPz
std::map< std::pair< unsigned int, std::string >, unsigned int > TrigList
std::string const & label() const
Definition: InputTag.h:42
edm::EventID id() const
Definition: EventBase.h:60
spr::trackSelectionParameters selectionParameters
std::vector< double > * t_l3eta
reco::TrackBase::TrackQuality minQuality
edm::InputTag theTriggerResultsLabel
double dPhi(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
volatile std::atomic< bool > shutdown_flag false
Definition: DDAxes.h:10
float mass() const
Definition: TriggerObject.h:59
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< vec1 > vec2
Definition: HCALResponse.h:16
double dPt(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
std::vector< double > * t_l1eta
std::map< std::pair< unsigned int, std::string >, const std::pair< int, int > > TrigPreList
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
std::vector< double > * t_leadingpt
virtual void endJob()
std::vector< double > * t_trkL3mindr
std::vector< double > * t_neu_iso
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:586
Definition: Run.h:41
std::vector< std::string > trigNames
Definition: IsoTrackCalib.h:99
void clearTreeVectors()
IsoTrackCalib(const edm::ParameterSet &)
Definition: IsoTrackCalib.cc:6
Definition: DDAxes.h:10