CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
StudyHLT.cc
Go to the documentation of this file.
1 #include "StudyHLT.h"
2 
3 //Triggers
8 
13 
19 
26 
33 
34 StudyHLT::StudyHLT(const edm::ParameterSet& iConfig) : nRun(0) {
35  verbosity = iConfig.getUntrackedParameter<int>("Verbosity",0);
36  trigNames = iConfig.getUntrackedParameter<std::vector<std::string> >("Triggers");
37  theTrackQuality = iConfig.getUntrackedParameter<std::string>("TrackQuality","highPurity");
39  selectionParameters.minPt = iConfig.getUntrackedParameter<double>("MinTrackPt", 10.0);
40  selectionParameters.minQuality = trackQuality_;
41  selectionParameters.maxDxyPV = iConfig.getUntrackedParameter<double>("MaxDxyPV", 0.2);
42  selectionParameters.maxDzPV = iConfig.getUntrackedParameter<double>("MaxDzPV", 5.0);
43  selectionParameters.maxChi2 = iConfig.getUntrackedParameter<double>("MaxChi2", 5.0);
44  selectionParameters.maxDpOverP = iConfig.getUntrackedParameter<double>("MaxDpOverP", 0.1);
45  selectionParameters.minOuterHit = iConfig.getUntrackedParameter<int>("MinOuterHit", 4);
46  selectionParameters.minLayerCrossed = iConfig.getUntrackedParameter<int>("MinLayerCrossed", 8);
47  selectionParameters.maxInMiss = iConfig.getUntrackedParameter<int>("MaxInMiss", 0);
48  selectionParameters.maxOutMiss = iConfig.getUntrackedParameter<int>("MaxOutMiss", 0);
49  minTrackP = iConfig.getUntrackedParameter<double>("MinTrackP", 1.0);
50  maxTrackEta = iConfig.getUntrackedParameter<double>("MaxTrackEta", 2.5);
51  tMinE_ = iConfig.getUntrackedParameter<double>("TimeMinCutECAL", -500.);
52  tMaxE_ = iConfig.getUntrackedParameter<double>("TimeMaxCutECAL", 500.);
53  tMinH_ = iConfig.getUntrackedParameter<double>("TimeMinCutHCAL", -500.);
54  tMaxH_ = iConfig.getUntrackedParameter<double>("TimeMaxCutHCAL", 500.);
55  isItAOD = iConfig.getUntrackedParameter<bool>("IsItAOD", false);
56  triggerEvent_ = edm::InputTag("hltTriggerSummaryAOD","","HLT");
57  theTriggerResultsLabel = edm::InputTag("TriggerResults","","HLT");
58 
59  // define tokens for access
60  tok_lumi = consumes<LumiDetails, edm::InLumi>(edm::InputTag("lumiProducer"));
61  tok_trigEvt = consumes<trigger::TriggerEvent>(triggerEvent_);
62  tok_trigRes = consumes<edm::TriggerResults>(theTriggerResultsLabel);
63  tok_genTrack_ = consumes<reco::TrackCollection>(edm::InputTag("generalTracks"));
64  tok_recVtx_ = consumes<reco::VertexCollection>(edm::InputTag("offlinePrimaryVertices"));
65  if (isItAOD) {
66  tok_EB_ = consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEB"));
67  tok_EE_ = consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEE"));
68  tok_hbhe_ = consumes<HBHERecHitCollection>(edm::InputTag("reducedHcalRecHits", "hbhereco"));
69  } else {
70  tok_EB_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit","EcalRecHitsEB"));
71  tok_EE_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit","EcalRecHitsEE"));
72  tok_hbhe_ = consumes<HBHERecHitCollection>(edm::InputTag("hbhereco"));
73  }
74 
75  edm::LogInfo("IsoTrack") << "Verbosity " << verbosity << " with "
76  << trigNames.size() << " triggers:";
77  for (unsigned int k=0; k<trigNames.size(); ++k)
78  edm::LogInfo("IsoTrack") << " [" << k << "] " << trigNames[k];
79  edm::LogInfo("IsoTrack") << "TrackQuality " << theTrackQuality << " Minpt "
80  << selectionParameters.minPt << " maxDxy "
81  << selectionParameters.maxDxyPV << " maxDz "
82  << selectionParameters.maxDzPV << " maxChi2 "
83  << selectionParameters.maxChi2 << " maxDp/p "
84  << selectionParameters.maxDpOverP << " minOuterHit "
85  << selectionParameters.minOuterHit << " minLayerCrossed "
86  << selectionParameters.minLayerCrossed << " maxInMiss "
87  << selectionParameters.maxInMiss << " maxOutMiss "
88  << selectionParameters.maxOutMiss << " minTrackP "
89  << minTrackP << " maxTrackEta " << maxTrackEta
90  << " tMinE_ " << tMinE_ << " tMaxE " << tMaxE_
91  << " tMinH_ " << tMinH_ << " tMaxH_ " << tMaxH_
92  << " isItAOD " << isItAOD;
93 
94  double pBins[nPBin+1] = {1.0,2.0,3.0,4.0,5.0,6.0,7.0,9.0,11.0,15.0,20.0};
95  int etaBins[nEtaBin+1] = {1, 7, 13, 17, 23};
96  int pvBins[nPVBin+1] = {1, 2, 3, 5, 100};
97  for (int i=0; i<=nPBin; ++i) pBin[i] = pBins[i];
98  for (int i=0; i<=nEtaBin; ++i) etaBin[i] = etaBins[i];
99  for (int i=0; i<=nPVBin; ++i) pvBin[i] = pvBins[i];
100 }
101 
103 
104 void StudyHLT::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
105 if (verbosity > 0)
106  edm::LogInfo("IsoTrack") << "Event starts====================================";
107  int RunNo = iEvent.id().run();
108  int EvtNo = iEvent.id().event();
109  int Lumi = iEvent.luminosityBlock();
110  int Bunch = iEvent.bunchCrossing();
111 
113  iEvent.getLuminosityBlock().getByToken(tok_lumi,Lumid);
114 
115  std::string newNames[5]={"HLT","PixelTracks_Multiplicity","HLT_Physics_","HLT_JetE","HLT_ZeroBias"};
116  int newAccept[5];
117  for (int i=0; i<5; ++i) newAccept[i] = 0;
118  float mybxlumi=-1;
119  if (Lumid.isValid())
120  mybxlumi=Lumid->lumiValue(LumiDetails::kOCC1,iEvent.bunchCrossing())*6.37;
121 
122  if (verbosity > 0)
123  edm::LogInfo("IsoTrack") << "RunNo " << RunNo << " EvtNo " << EvtNo
124  << " Lumi " << Lumi << " Bunch " << Bunch
125  << " mybxlumi " << mybxlumi;
126 
127  trigger::TriggerEvent triggerEvent;
128  edm::Handle<trigger::TriggerEvent> triggerEventHandle;
129  iEvent.getByToken(tok_trigEvt,triggerEventHandle);
130 
131  bool ok(false);
132  if (trigNames.size() < 1) {
133  ok = true;
134  } else if (!triggerEventHandle.isValid()) {
135  edm::LogWarning("IsoTrack") << "Error! Can't get the product "
136  << triggerEvent_.label();
137  } else {
138  triggerEvent = *(triggerEventHandle.product());
139 
142  iEvent.getByToken(tok_trigRes, triggerResults);
143 
144  if (triggerResults.isValid()) {
145  h_nHLT->Fill(triggerResults->size());
146  h_nHLTvsRN->Fill(RunNo, triggerResults->size());
147 
148  const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults);
149  const std::vector<std::string> & triggerNames_ = triggerNames.triggerNames();
150  for (unsigned int iHLT=0; iHLT<triggerResults->size(); iHLT++) {
151  // unsigned int triggerindx = hltConfig_.triggerIndex(triggerNames_[iHLT]);
152  // const std::vector<std::string>& moduleLabels(hltConfig_.moduleLabels(triggerindx));
153  int ipos=-1;
154  std::string newtriggerName = truncate_str(triggerNames_[iHLT]);
155  for (unsigned int i=0; i<HLTNames.size(); ++i) {
156  if (newtriggerName == HLTNames[i]) {
157  ipos = i+1;
158  break;
159  }
160  }
161  if (ipos < 0) {
162  HLTNames.push_back(newtriggerName);
163  ipos = (int)(HLTNames.size());
164  if (ipos <= h_HLTAccept->GetNbinsX())
165  h_HLTAccept->GetXaxis()->SetBinLabel(ipos,newtriggerName.c_str());
166  }
167  if ((int)(iHLT+1) > h_HLTAccepts[nRun]->GetNbinsX()) {
168  edm::LogInfo("IsoTrack") << "Wrong trigger " << RunNo << " Event "
169  << EvtNo << " Hlt " << iHLT;
170  } else {
171  if (firstEvent) h_HLTAccepts[nRun]->GetXaxis()->SetBinLabel(iHLT+1, newtriggerName.c_str());
172  }
173  int hlt = triggerResults->accept(iHLT);
174  if (hlt) {
175  h_HLTAccepts[nRun]->Fill(iHLT+1);
176  h_HLTAccept->Fill(ipos);
177  }
178  for (unsigned int i=0; i<trigNames.size(); ++i) {
179  if (newtriggerName.find(trigNames[i].c_str())!=std::string::npos) {
180  if (verbosity%10 > 0)
181  edm::LogInfo("IsoTrack") << newtriggerName;
182  if (hlt > 0) ok = true;
183  }
184  }
185  for (int i=0; i<5; ++i) {
186  if (newtriggerName.find(newNames[i].c_str())!=std::string::npos) {
187  if (verbosity%10 > 0)
188  edm::LogInfo("IsoTrack") << "[" << i << "] " << newNames[i]
189  << " : " << newtriggerName;
190  if (hlt > 0) newAccept[i] = 1;
191  }
192  }
193  }
194  int iflg(0), indx(1);
195  for (int i=0; i<5; ++i) {
196  iflg += (indx*newAccept[i]); indx *= 2;
197  }
198  h_HLTCorr->Fill(iflg);
199  }
200  }
201 
202  //Look at the tracks
203  if (ok) {
204  h_goodRun->Fill(RunNo);
205  // get handles to calogeometry and calotopology
207  iSetup.get<CaloGeometryRecord>().get(pG);
208  const CaloGeometry* geo = pG.product();
209 
210  edm::ESHandle<CaloTopology> theCaloTopology;
211  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
212  const CaloTopology *caloTopology = theCaloTopology.product();
213 
215  iSetup.get<HcalRecNumberingRecord>().get(htopo);
216  const HcalTopology* theHBHETopology = htopo.product();
217 
219  iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
220  const MagneticField *bField = bFieldH.product();
221 
223  iSetup.get<EcalChannelStatusRcd>().get(ecalChStatus);
224  const EcalChannelStatus* theEcalChStatus = ecalChStatus.product();
225 
227  iEvent.getByToken(tok_recVtx_,recVtxs);
228  int ntrk(0), ngoodPV(0), nPV(-1);
229  for (unsigned int ind=0; ind<recVtxs->size(); ind++) {
230  if (!((*recVtxs)[ind].isFake()) && (*recVtxs)[ind].ndof() > 4) ngoodPV++;
231  }
232  for (int i=0; i<nPVBin; ++i) {
233  if (ngoodPV >= pvBin[i] && ngoodPV < pvBin[i+1]) {
234  nPV = i; break;
235  }
236  }
237  if ((verbosity/10)%10 > 0)
238  edm::LogInfo("IsoTrack") << "Number of vertices: " << recVtxs->size()
239  << " Good " << ngoodPV << " Bin " << nPV;
240  h_numberPV->Fill((int)(recVtxs->size()));
241  h_goodPV->Fill(ngoodPV);
242 
243 
245  iEvent.getByToken(tok_genTrack_, trkCollection);
246  reco::TrackCollection::const_iterator trkItr;
247  for (trkItr=trkCollection->begin(); trkItr != trkCollection->end(); ++trkItr,++ntrk) {
248  const reco::Track* pTrack = &(*trkItr);
249  double pt1 = pTrack->pt();
250  double p1 = pTrack->p();
251  double eta1 = pTrack->momentum().eta();
252  double phi1 = pTrack->momentum().phi();
254  fillTrack(0, pt1,p1,eta1,phi1);
255  if (quality) fillTrack(1, pt1,p1,eta1,phi1);
256  }
257  h_ntrk[0]->Fill(ntrk);
258 
259  std::vector<spr::propagatedTrackID> trkCaloDets;
260  spr::propagateCALO(trkCollection, geo, bField, theTrackQuality, trkCaloDets, ((verbosity/100)%10 > 0));
261  std::vector<spr::propagatedTrackID>::const_iterator trkDetItr;
262  for (trkDetItr = trkCaloDets.begin(),ntrk=0; trkDetItr != trkCaloDets.end(); trkDetItr++,ntrk++) {
263  const reco::Track* pTrack = &(*(trkDetItr->trkItr));
264  double pt1 = pTrack->pt();
265  double p1 = pTrack->p();
266  double eta1 = pTrack->momentum().eta();
267  double phi1 = pTrack->momentum().phi();
268  if ((verbosity/10)%10 > 0)
269  edm::LogInfo("IsoTrack") << "track: p " << p1 << " pt " << pt1
270  << " eta " << eta1 << " phi " << phi1
271  << " okEcal " << trkDetItr->okECAL;
272  fillTrack(2, pt1,p1,eta1,phi1);
273  if (pt1>minTrackP && std::abs(eta1)<maxTrackEta && trkDetItr->okECAL) {
274  fillTrack(3, pt1,p1,eta1,phi1);
275  double maxNearP31x31 = spr::chargeIsolationEcal(ntrk, trkCaloDets, geo, caloTopology, 15, 15, ((verbosity/1000)%10 > 0));
276 
278  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
279 
280  edm::Handle<EcalRecHitCollection> barrelRecHitsHandle;
281  edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
282  iEvent.getByToken(tok_EB_,barrelRecHitsHandle);
283  iEvent.getByToken(tok_EE_,endcapRecHitsHandle);
284  // get ECal Tranverse Profile
285  std::pair<double, bool> e7x7P, e11x11P, e15x15P;
286  const DetId isoCell = trkDetItr->detIdECAL;
287  e7x7P = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),3,3, 0.030, 0.150, tMinE_,tMaxE_, ((verbosity/10000)%10 > 0));
288  e11x11P = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),5,5, 0.030, 0.150, tMinE_,tMaxE_, ((verbosity/10000)%10 > 0));
289  e15x15P = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),7,7, 0.030, 0.150, tMinE_,tMaxE_, ((verbosity/10000)%10 > 0));
290 
291  double maxNearHcalP7x7 = spr::chargeIsolationHcal(ntrk, trkCaloDets, theHBHETopology, 3,3, ((verbosity/1000)%10 > 0));
292  int ieta(0);
293  double h3x3(0), h5x5(0), h7x7(0);
294  fillIsolation(0, maxNearP31x31,e11x11P.first,e15x15P.first);
295  if ((verbosity/10)%10 > 0)
296  edm::LogInfo("IsoTrack") << "Accepted Tracks reaching Ecal maxNearP31x31 "
297  << maxNearP31x31 << " e11x11P "
298  << e11x11P.first << " e15x15P "
299  << e15x15P.first << " okHCAL "
300  << trkDetItr->okHCAL;
301 
302  if (trkDetItr->okHCAL) {
304  iEvent.getByToken(tok_hbhe_, hbhe);
305  const DetId ClosestCell(trkDetItr->detIdHCAL);
306  ieta = ((HcalDetId)(ClosestCell)).ietaAbs();
307  h3x3 = spr::eHCALmatrix(theHBHETopology, ClosestCell, hbhe,1,1, false, true, 0.7, 0.8, -100.0, -100.0, tMinH_,tMaxH_, ((verbosity/10000)%10 > 0));
308  h5x5 = spr::eHCALmatrix(theHBHETopology, ClosestCell, hbhe,2,2, false, true, 0.7, 0.8, -100.0, -100.0, tMinH_,tMaxH_, ((verbosity/10000)%10 > 0) );
309  h7x7 = spr::eHCALmatrix(theHBHETopology, ClosestCell, hbhe,3,3, false, true, 0.7, 0.8, -100.0, -100.0, tMinH_,tMaxH_, ((verbosity/10000)%10 > 0) );
310  fillIsolation(1, maxNearHcalP7x7,h5x5,h7x7);
311  if ((verbosity/10)%10 > 0)
312  edm::LogInfo("IsoTrack") << "Tracks Reaching Hcal maxNearHcalP7x7/h5x5/h7x7 "
313  << maxNearHcalP7x7 << "/" << h5x5 << "/" << h7x7;
314  }
315  if (maxNearP31x31 < 0) {
316  fillTrack(4, pt1,p1,eta1,phi1);
317  fillEnergy(0,ieta,p1,e7x7P.first,h3x3,e11x11P.first,h5x5);
318  if (maxNearHcalP7x7 < 0) {
319  fillTrack(5, pt1,p1,eta1,phi1);
320  fillEnergy(1,ieta,p1,e7x7P.first,h3x3,e11x11P.first,h5x5);
321  if (e11x11P.second && e15x15P.second && (e15x15P.first-e11x11P.first)<2.0) {
322  fillTrack(6, pt1,p1,eta1,phi1);
323  fillEnergy(2,ieta,p1,e7x7P.first,h3x3,e11x11P.first,h5x5);
324  if (h7x7-h5x5 < 2.0) {
325  fillTrack(7, pt1,p1,eta1,phi1);
326  fillEnergy(3,ieta,p1,e7x7P.first,h3x3,e11x11P.first,h5x5);
327  if (nPV >= 0) {
328  fillTrack(nPV+8, pt1,p1,eta1,phi1);
329  fillEnergy(nPV+4,ieta,p1,e7x7P.first,h3x3,e11x11P.first,h5x5);
330  }
331  }
332  }
333  }
334  }
335  }
336  }
337  h_ntrk[1]->Fill(ntrk);
338  }
339  firstEvent = false;
340 }
341 
343  h_nHLT = fs->make<TH1I>("h_nHLT" , "size of trigger Names", 1000, 0, 1000);
344  h_HLTAccept = fs->make<TH1I>("h_HLTAccept", "HLT Accepts for all runs", 500, 0, 500);
345  for (int i=1; i<=500; ++i) h_HLTAccept->GetXaxis()->SetBinLabel(i," ");
346  h_nHLTvsRN = fs->make<TH2I>("h_nHLTvsRN" , "size of trigger Names vs RunNo", 2168, 190949, 193116, 100, 400, 500);
347  h_HLTCorr = fs->make<TH1I>("h_HLTCorr", "Correlation among different paths", 100, 0, 100);
348  h_numberPV = fs->make<TH1I>("h_numberPV", "Number of Primary Vertex", 100, 0, 100);
349  h_goodPV = fs->make<TH1I>("h_goodPV", "Number of good Primary Vertex", 100, 0, 100);
350  h_goodRun = fs->make<TH1I>("h_goodRun","Number of accepted events for Run", 4000, 190000, 1940000);
351  char hname[50], htit[400];
352  std::string CollectionNames[2] = {"Reco", "Propagated"};
353  for (unsigned int i=0; i<2; i++) {
354  sprintf(hname, "h_nTrk_%s", CollectionNames[i].c_str());
355  sprintf(htit, "Number of %s tracks", CollectionNames[i].c_str());
356  h_ntrk[i] = fs->make<TH1I>(hname, htit, 500, 0, 500);
357  }
358  std::string TrkNames[8] = {"All", "Quality", "NoIso", "okEcal", "EcalCharIso", "HcalCharIso", "EcalNeutIso", "HcalNeutIso"};
359  for (unsigned int i=0; i<8+nPVBin; i++) {
360  if (i < 8) {
361  sprintf(hname, "h_pt_%s", TrkNames[i].c_str());
362  sprintf(htit, "p_{T} of %s tracks", TrkNames[i].c_str());
363  } else {
364  sprintf(hname, "h_pt_%s_%d", TrkNames[7].c_str(), i-8);
365  sprintf(htit, "p_{T} of %s tracks (PV=%d:%d)", TrkNames[7].c_str(), pvBin[i-8], pvBin[i-7]-1);
366  }
367  h_pt[i] = fs->make<TH1D>(hname, htit, 400, 0, 200.0);
368  h_pt[i]->Sumw2();
369 
370  if (i < 8) {
371  sprintf(hname, "h_p_%s", TrkNames[i].c_str());
372  sprintf(htit, "Momentum of %s tracks", TrkNames[i].c_str());
373  } else {
374  sprintf(hname, "h_p_%s_%d", TrkNames[7].c_str(), i-8);
375  sprintf(htit, "Momentum of %s tracks (PV=%d:%d)", TrkNames[7].c_str(), pvBin[i-8], pvBin[i-7]-1);
376  }
377  h_p[i] = fs->make<TH1D>(hname, htit, 400, 0, 200.0);
378  h_p[i]->Sumw2();
379 
380  if (i < 8) {
381  sprintf(hname, "h_eta_%s", TrkNames[i].c_str());
382  sprintf(htit, "Eta of %s tracks", TrkNames[i].c_str());
383  } else {
384  sprintf(hname, "h_eta_%s_%d", TrkNames[7].c_str(), i-8);
385  sprintf(htit, "Eta of %s tracks (PV=%d:%d)", TrkNames[7].c_str(), pvBin[i-8], pvBin[i-7]-1);
386  }
387  h_eta[i] = fs->make<TH1D>(hname, htit, 60, -3.0, 3.0);
388  h_eta[i]->Sumw2();
389 
390  if (i < 8) {
391  sprintf(hname, "h_phi_%s", TrkNames[i].c_str());
392  sprintf(htit, "Phi of %s tracks", TrkNames[i].c_str());
393  } else {
394  sprintf(hname, "h_phi_%s_%d", TrkNames[7].c_str(), i-8);
395  sprintf(htit, "Phi of %s tracks (PV=%d:%d)", TrkNames[7].c_str(), pvBin[i-8], pvBin[i-7]-1);
396  }
397  h_phi[i] = fs->make<TH1D>(hname, htit, 100, -3.15, 3.15);
398  h_phi[i]->Sumw2();
399  }
400  std::string IsolationNames[2] = {"Ecal", "Hcal"};
401  for (unsigned int i=0; i<2; i++) {
402  sprintf(hname, "h_maxNearP_%s", IsolationNames[i].c_str());
403  sprintf(htit, "Energy in ChargeIso region for %s", IsolationNames[i].c_str());
404  h_maxNearP[i] = fs->make<TH1D>(hname, htit, 120, -1.5, 10.5);
405  h_maxNearP[i]->Sumw2();
406 
407  sprintf(hname, "h_ene1_%s", IsolationNames[i].c_str());
408  sprintf(htit, "Energy in smaller cone for %s", IsolationNames[i].c_str());
409  h_ene1[i] = fs->make<TH1D>(hname, htit, 400, 0.0, 200.0);
410  h_ene1[i]->Sumw2();
411 
412  sprintf(hname, "h_ene2_%s", IsolationNames[i].c_str());
413  sprintf(htit, "Energy in bigger cone for %s", IsolationNames[i].c_str());
414  h_ene2[i] = fs->make<TH1D>(hname, htit, 400, 0.0, 200.0);
415  h_ene2[i]->Sumw2();
416 
417  sprintf(hname, "h_ediff_%s", IsolationNames[i].c_str());
418  sprintf(htit, "Energy in NeutralIso region for %s", IsolationNames[i].c_str());
419  h_ediff[i] = fs->make<TH1D>(hname, htit, 100, -0.5, 19.5);
420  h_ediff[i]->Sumw2();
421  }
422  std::string energyNames[6]={"E_{7x7}", "H_{3x3}", "(E_{7x7}+H_{3x3})",
423  "E_{11x11}", "H_{5x5}", "{E_{11x11}+H_{5x5})"};
424  for (int i=0; i<4+nPVBin; ++i) {
425  for (int ip=0; ip<nPBin; ++ip) {
426  for (int ie=0; ie<nEtaBin; ++ie) {
427  for (int j=0; j<6; ++j) {
428  sprintf(hname, "h_energy_%d_%d_%d_%d", i, ip, ie, j);
429  if (i < 4) {
430  sprintf(htit,"%s/p (p=%4.1f:%4.1f; i#eta=%d:%d) for tracks with %s",
431  energyNames[j].c_str(),pBin[ip],pBin[ip+1],etaBin[ie],
432  (etaBin[ie+1]-1), TrkNames[i+4].c_str());
433  } else {
434  sprintf(htit,"%s/p (p=%4.1f:%4.1f; i#eta=%d:%d, PV=%d:%d) for tracks with %s",
435  energyNames[j].c_str(),pBin[ip],pBin[ip+1],etaBin[ie],
436  (etaBin[ie+1]-1), pvBin[i-4], pvBin[i-3],
437  TrkNames[7].c_str());
438  }
439  h_energy[i][ip][ie][j] = fs->make<TH1D>(hname, htit, 500, -0.1, 4.9);
440  h_energy[i][ip][ie][j]->Sumw2();
441  }
442  }
443  }
444  }
445 }
446 
448 
449 // ------------ method called when starting to processes a run ------------
450 void StudyHLT::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
451  char hname[100], htit[400];
452  edm::LogInfo("IsoTrack") << "Run[" << nRun << "] " << iRun.run() << " hltconfig.init "
453  << hltConfig_.init(iRun,iSetup,"HLT",changed);
454  sprintf(hname, "h_HLTAccepts_%i", iRun.run());
455  sprintf(htit, "HLT Accepts for Run No %i", iRun.run());
456  TH1I *hnew = fs->make<TH1I>(hname, htit, 500, 0, 500);
457  for (int i=1; i<=500; ++i) hnew->GetXaxis()->SetBinLabel(i," ");
458  h_HLTAccepts.push_back(hnew);
459  edm::LogInfo("IsoTrack") << "beginrun " << iRun.run();
460  firstEvent = true;
461 }
462 
463 // ------------ method called when ending the processing of a run ------------
464 void StudyHLT::endRun(edm::Run const& iRun, edm::EventSetup const&) {
465  nRun++;
466  edm::LogInfo("IsoTrack") << "endrun[" << nRun << "] " << iRun.run();
467 }
468 
469 // ------------ method called when starting to processes a luminosity block ------------
471 // ------------ method called when ending the processing of a luminosity block ------------
473 
474 void StudyHLT::fillTrack(int i, double pt, double p, double eta, double phi){
475  h_pt[i]->Fill(pt);
476  h_p[i]->Fill(p);
477  h_eta[i]->Fill(eta);
478  h_phi[i]->Fill(phi);
479 }
480 
481 void StudyHLT::fillIsolation(int i, double emaxnearP, double eneutIso1, double eneutIso2){
482  h_maxNearP[i]->Fill(emaxnearP);
483  h_ene1[i]->Fill(eneutIso1);
484  h_ene2[i]->Fill(eneutIso2);
485  h_ediff[i]->Fill(eneutIso2-eneutIso1);
486 }
487 
488 void StudyHLT::fillEnergy(int flag, int ieta, double p, double enEcal1,
489  double enHcal1, double enEcal2, double enHcal2) {
490  int ip(-1), ie(-1);
491  for (int i=0; i<nPBin; ++i) {
492  if (p >= pBin[i] && p < pBin[i+1]) { ip = i; break; }
493  }
494  for (int i=0; i<nEtaBin; ++i) {
495  if (ieta >= etaBin[i] && ieta < etaBin[i+1]) { ie = i; break; }
496  }
497  if (ip >= 0 && ie >= 0 && enEcal1 > 0.02 && enHcal1 > 0.1) {
498  h_energy[flag][ip][ie][0]->Fill(enEcal1/p);
499  h_energy[flag][ip][ie][1]->Fill(enHcal1/p);
500  h_energy[flag][ip][ie][2]->Fill((enEcal1+enHcal1)/p);
501  h_energy[flag][ip][ie][3]->Fill(enEcal2/p);
502  h_energy[flag][ip][ie][4]->Fill(enHcal2/p);
503  h_energy[flag][ip][ie][5]->Fill((enEcal2+enHcal2)/p);
504  }
505 }
506 
508  std::string truncated_str(str);
509  int length = str.length();
510  for (int i=0; i<length-2; i++){
511  if (str[i]=='_' && str[i+1]=='v' && isdigit(str.at(i+2))) {
512  int z = i+1;
513  truncated_str = str.substr(0,z);
514  }
515  }
516  return(truncated_str);
517 }
518 
520 
RunNumber_t run() const
Definition: EventID.h:39
void fillEnergy(int, int, double, double, double, double, double)
Definition: StudyHLT.cc:488
double p() const
momentum vector magnitude
Definition: TrackBase.h:602
EventNumber_t event() const
Definition: EventID.h:41
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
Definition: StudyHLT.h:77
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:220
TH1I * h_HLTCorr
Definition: StudyHLT.h:80
edm::InputTag triggerEvent_
Definition: StudyHLT.h:69
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, std::string &theTrackQuality, bool debug=false)
TH1I * h_numberPV
Definition: StudyHLT.h:80
TH1I * h_nHLT
Definition: StudyHLT.h:80
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
Definition: StudyHLT.cc:450
RunNumber_t run() const
Definition: RunBase.h:42
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: StudyHLT.cc:472
edm::Service< TFileService > fs
Definition: StudyHLT.h:61
TH1I * h_ntrk[2]
Definition: StudyHLT.h:85
virtual void beginJob()
Definition: StudyHLT.cc:342
double maxTrackEta
Definition: StudyHLT.h:66
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TrackQuality
track quality
Definition: TrackBase.h:149
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< TH1I * > h_HLTAccepts
Definition: StudyHLT.h:83
TH1D * h_phi[nPVBin+8]
Definition: StudyHLT.h:84
std::vector< std::string > trigNames
Definition: StudyHLT.h:64
TH1D * h_pt[nPVBin+8]
Definition: StudyHLT.h:84
int bunchCrossing() const
Definition: EventBase.h:66
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:63
static const int nPVBin
Definition: StudyHLT.h:59
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
double tMaxH_
Definition: StudyHLT.h:66
TH1I * h_HLTAccept
Definition: StudyHLT.h:80
double minTrackP
Definition: StudyHLT.h:66
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:662
int pvBin[nPVBin+1]
Definition: StudyHLT.h:88
Strings const & triggerNames() const
Definition: TriggerNames.cc:24
virtual void endJob()
Definition: StudyHLT.cc:447
edm::EDGetTokenT< reco::TrackCollection > tok_genTrack_
Definition: StudyHLT.h:74
TH1I * h_goodRun
Definition: StudyHLT.h:81
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: StudyHLT.cc:104
std::string theTrackQuality
Definition: StudyHLT.h:65
spr::trackSelectionParameters selectionParameters
Definition: StudyHLT.h:63
TH1D * h_ene2[2]
Definition: StudyHLT.h:86
void fillIsolation(int, double, double, double)
Definition: StudyHLT.cc:481
double eHCALmatrix(const HcalTopology *topology, const DetId &det, edm::Handle< T > &hits, int ieta, int iphi, bool includeHO=false, bool algoNew=true, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, bool debug=false)
bool firstEvent
Definition: StudyHLT.h:67
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
Definition: StudyHLT.h:78
edm::InputTag theTriggerResultsLabel
Definition: StudyHLT.h:69
bool isItAOD
Definition: StudyHLT.h:67
double chargeIsolationEcal(unsigned int trkIndex, std::vector< spr::propagatedTrackID > &vdetIds, const CaloGeometry *geo, const CaloTopology *caloTopology, int ieta, int iphi, bool debug=false)
double pBin[nPBin+1]
Definition: StudyHLT.h:89
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< reco::VertexCollection > tok_recVtx_
Definition: StudyHLT.h:75
void fillTrack(int, double, double, double, double)
Definition: StudyHLT.cc:474
static const int nEtaBin
Definition: StudyHLT.h:59
~StudyHLT()
Definition: StudyHLT.cc:102
std::string truncate_str(const std::string &)
Definition: StudyHLT.cc:507
int nRun
Definition: StudyHLT.h:88
TH1D * h_ene1[2]
Definition: StudyHLT.h:86
double pt() const
track transverse momentum
Definition: TrackBase.h:608
virtual void endRun(edm::Run const &, edm::EventSetup const &)
Definition: StudyHLT.cc:464
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
LuminosityBlock const & getLuminosityBlock() const
Definition: Event.h:84
HLTConfigProvider hltConfig_
Definition: StudyHLT.h:60
static std::string const triggerResults
Definition: EdmProvDump.cc:40
bool isValid() const
Definition: HandleBase.h:75
TH1D * h_ediff[2]
Definition: StudyHLT.h:86
Definition: DetId.h:18
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:123
TH1D * h_maxNearP[2]
Definition: StudyHLT.h:86
T const * product() const
Definition: Handle.h:81
TH2I * h_nHLTvsRN
Definition: StudyHLT.h:82
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
Definition: StudyHLT.h:76
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
TH1D * h_eta[nPVBin+8]
Definition: StudyHLT.h:84
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
bool changed
Definition: StudyHLT.h:67
TH1I * h_goodPV
Definition: StudyHLT.h:81
edm::EDGetTokenT< LumiDetails > tok_lumi
Definition: StudyHLT.h:70
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:497
Geom::Phi< T > phi() const
std::string const & label() const
Definition: InputTag.h:43
int verbosity
Definition: StudyHLT.h:62
edm::EventID id() const
Definition: EventBase.h:60
double p1[4]
Definition: TauolaWrapper.h:89
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes
Definition: StudyHLT.h:72
reco::TrackBase::TrackQuality minQuality
std::vector< std::string > HLTNames
Definition: StudyHLT.h:64
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: StudyHLT.cc:470
int etaBin[nEtaBin+1]
Definition: StudyHLT.h:88
StudyHLT(const edm::ParameterSet &)
Definition: StudyHLT.cc:34
static const int nPBin
Definition: StudyHLT.h:59
double tMinE_
Definition: StudyHLT.h:66
TH1D * h_p[nPVBin+8]
Definition: StudyHLT.h:84
double chargeIsolationHcal(unsigned int trkIndex, std::vector< spr::propagatedTrackID > &vdetIds, const HcalTopology *topology, int ieta, int iphi, bool debug=false)
TH1D * h_energy[nPVBin+4][nPBin][nEtaBin][6]
Definition: StudyHLT.h:87
Definition: Run.h:43
double tMinH_
Definition: StudyHLT.h:66
double tMaxE_
Definition: StudyHLT.h:66
edm::EDGetTokenT< trigger::TriggerEvent > tok_trigEvt
Definition: StudyHLT.h:71
double eECALmatrix(const DetId &detId, edm::Handle< T > &hitsEB, edm::Handle< T > &hitsEE, const CaloGeometry *geo, const CaloTopology *caloTopology, int ieta, int iphi, double ebThr=-100, double eeThr=-100, double tMin=-500, double tMax=500, bool debug=false)