CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IsoTrig.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: IsoTrig
4 // Class: IsoTrig
5 //
13 //
14 // Original Author: Ruchi Gupta
15 // Created: Fri May 25 12:02:48 CDT 2012
16 // $Id$
17 //
18 //
19 #include "IsoTrig.h"
20 
21 //Tracks
26 // Vertices
30 
31 //Triggers
37 
39 
44 
57 
58 IsoTrig::IsoTrig(const edm::ParameterSet& iConfig) : changed(false) {
59  //now do whatever initialization is needed
60  Det = iConfig.getParameter<std::string>("Det");
61  verbosity = iConfig.getUntrackedParameter<int>("Verbosity",0);
62  theTrackQuality = iConfig.getUntrackedParameter<std::string>("TrackQuality","highPurity");
64  selectionParameters.minPt = iConfig.getUntrackedParameter<double>("MinTrackPt", 10.0);
65  selectionParameters.minQuality = trackQuality_;
66  selectionParameters.maxDxyPV = iConfig.getUntrackedParameter<double>("MaxDxyPV", 0.2);
67  selectionParameters.maxDzPV = iConfig.getUntrackedParameter<double>("MaxDzPV", 5.0);
68  selectionParameters.maxChi2 = iConfig.getUntrackedParameter<double>("MaxChi2", 5.0);
69  selectionParameters.maxDpOverP = iConfig.getUntrackedParameter<double>("MaxDpOverP", 0.1);
70  selectionParameters.minOuterHit = iConfig.getUntrackedParameter<int>("MinOuterHit", 4);
71  selectionParameters.minLayerCrossed = iConfig.getUntrackedParameter<int>("MinLayerCrossed", 8);
72  selectionParameters.maxInMiss = iConfig.getUntrackedParameter<int>("MaxInMiss", 0);
73  selectionParameters.maxOutMiss = iConfig.getUntrackedParameter<int>("MaxOutMiss", 0);
74  dr_L1 = iConfig.getUntrackedParameter<double>("IsolationL1",1.0);
75  a_coneR = iConfig.getUntrackedParameter<double>("ConeRadius",34.98);
76  a_charIsoR = a_coneR + 28.9;
77  a_neutIsoR = a_charIsoR*0.726;
78  a_mipR = iConfig.getUntrackedParameter<double>("ConeRadiusMIP",14.0);
79  a_neutR1 = iConfig.getUntrackedParameter<double>("ConeRadiusNeut1",21.0);
80  a_neutR2 = iConfig.getUntrackedParameter<double>("ConeRadiusNeut2",29.0);
81  cutMip = iConfig.getUntrackedParameter<double>("MIPCut", 1.0);
82  cutCharge = iConfig.getUntrackedParameter<double>("ChargeIsolation", 2.0);
83  cutNeutral = iConfig.getUntrackedParameter<double>("NeutralIsolation", 2.0);
84  minRunNo = iConfig.getUntrackedParameter<int>("minRun");
85  maxRunNo = iConfig.getUntrackedParameter<int>("maxRun");
86  if (verbosity>=0) {
87  std::cout <<"Parameters read from config file \n"
88  <<"\t minPt " << selectionParameters.minPt
89  <<"\t theTrackQuality " << theTrackQuality
90  <<"\t minQuality " << selectionParameters.minQuality
91  <<"\t maxDxyPV " << selectionParameters.maxDxyPV
92  <<"\t maxDzPV " << selectionParameters.maxDzPV
93  <<"\t maxChi2 " << selectionParameters.maxChi2
94  <<"\t maxDpOverP " << selectionParameters.maxDpOverP
95  <<"\t minOuterHit " << selectionParameters.minOuterHit
96  <<"\t minLayerCrossed " << selectionParameters.minLayerCrossed
97  <<"\t maxInMiss " << selectionParameters.maxInMiss
98  <<"\t maxOutMiss " << selectionParameters.maxOutMiss
99  <<"\t a_coneR " << a_coneR
100  <<"\t a_charIsoR " << a_charIsoR
101  <<"\t a_neutIsoR " << a_neutIsoR
102  <<"\t a_mipR " << a_mipR
103  <<"\t a_neutR " << a_neutR1 << ":" << a_neutR2
104  <<"\t cuts (MIP " << cutMip << " : Charge " << cutCharge
105  <<" : Neutral " << cutNeutral << ")"
106  << std::endl;
107  }
108 }
109 
111  // do anything here that needs to be done at desctruction time
112  // (e.g. close files, deallocate resources etc.)
113 
114 }
115 
116 void IsoTrig::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
117 
118  if (verbosity%10 > 0) std::cout << "Event starts====================================" << std::endl;
119  int RunNo = iEvent.id().run();
120  int EvtNo = iEvent.id().event();
121  int Lumi = iEvent.luminosityBlock();
122  int Bunch = iEvent.bunchCrossing();
123 
125  iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
126  const MagneticField *bField = bFieldH.product();
127 
128  // get handles to calogeometry and calotopology
130  iSetup.get<CaloGeometryRecord>().get(pG);
131  const CaloGeometry* geo = pG.product();
132 
134  iEvent.getByLabel("generalTracks", trkCollection);
135  reco::TrackCollection::const_iterator trkItr;
136 
137  edm::InputTag lumiProducer("LumiProducer", "", "RECO");
139  iEvent.getLuminosityBlock().getByLabel("lumiProducer",Lumid);
140  float mybxlumi=-1;
141  if (Lumid.isValid())
142  mybxlumi=Lumid->lumiValue(LumiDetails::kOCC1,iEvent.bunchCrossing())*6.37;
143  if (verbosity%10 > 0)
144  std::cout << "RunNo " << RunNo << " EvtNo " << EvtNo << " Lumi " << Lumi
145  << " Bunch " << Bunch << " mybxlumi " << mybxlumi << std::endl;
146 
147  edm::InputTag triggerEvent_ ("hltTriggerSummaryAOD","","HLT");
148  trigger::TriggerEvent triggerEvent;
149  edm::Handle<trigger::TriggerEvent> triggerEventHandle;
150  iEvent.getByLabel(triggerEvent_,triggerEventHandle);
151  if (!triggerEventHandle.isValid())
152  std::cout << "Error! Can't get the product "<< triggerEvent_.label() << std::endl;
153  else {
154  triggerEvent = *(triggerEventHandle.product());
155 
156  const trigger::TriggerObjectCollection& TOC(triggerEvent.getObjects());
158  edm::InputTag theTriggerResultsLabel ("TriggerResults","","HLT");
160  iEvent.getByLabel( theTriggerResultsLabel, triggerResults);
161  char TrigName[50];
162  sprintf(TrigName, "HLT_IsoTrack%s", Det.c_str());
163  if (triggerResults.isValid()) {
164  std::vector<std::string> modules;
165  h_nHLT->Fill(triggerResults->size());
166  const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults);
167 
168  const std::vector<std::string> & triggerNames_ = triggerNames.triggerNames();
169  int hlt(-1), preL1(-1), preHLT(-1), prescale(-1);
170  for (unsigned int i=0; i<triggerResults->size(); i++) {
171  unsigned int triggerindx = hltConfig_.triggerIndex(triggerNames_[i]);
172  const std::vector<std::string>& moduleLabels(hltConfig_.moduleLabels(triggerindx));
173  if (triggerNames_[i].find(TrigName)!=std::string::npos) {
174  const std::pair<int,int> prescales(hltConfig_.prescaleValues(iEvent,iSetup,triggerNames_[i]));
175  hlt = triggerResults->accept(i);
176  preL1 = prescales.first;
177  preHLT = prescales.second;
178  prescale = preL1*preHLT;
179  if (verbosity%10 > 0)
180  std::cout << triggerNames_[i] << " accept " << hlt << " preL1 "
181  << preL1 << " preHLT " << preHLT << std::endl;
182  if (hlt>0) {
183  std::vector<math::XYZTLorentzVector> vec[3];
184  if (TrigList.find(RunNo) != TrigList.end() ) {
185  TrigList[RunNo] += 1;
186  } else {
187  TrigList.insert(std::pair<unsigned int, unsigned int>(RunNo,1));
188  TrigPreList.insert(std::pair<unsigned int, std::pair<int, int>>(RunNo,prescales));
189  }
190  //loop over all trigger filters in event (i.e. filters passed)
191  for (unsigned int ifilter=0; ifilter<triggerEvent.sizeFilters(); ++ifilter) {
192  std::vector<int> Keys;
193  std::string label = triggerEvent.filterTag(ifilter).label();
194  //loop over keys to objects passing this filter
195  for (unsigned int imodule=0; imodule<moduleLabels.size(); imodule++) {
196  if (label.find(moduleLabels[imodule]) != std::string::npos) {
197  if (verbosity%10 > 0) std::cout << "FILTERNAME " << label << std::endl;
198  for (unsigned int ifiltrKey=0; ifiltrKey<triggerEvent.filterKeys(ifilter).size(); ++ifiltrKey) {
199  Keys.push_back(triggerEvent.filterKeys(ifilter)[ifiltrKey]);
200  const trigger::TriggerObject& TO(TOC[Keys[ifiltrKey]]);
201  math::XYZTLorentzVector v4(TO.px(), TO.py(), TO.pz(), TO.energy());
202  if(label.find("L2Filter") != std::string::npos) {
203  vec[1].push_back(v4);
204  } else if (label.find("L3Filter") != std::string::npos) {
205  vec[2].push_back(v4);
206  } else {
207  vec[0].push_back(v4);
208  h_L1ObjEnergy->Fill(TO.energy());
209  }
210  if (verbosity%10 > 0)
211  std::cout << "key " << ifiltrKey << " : pt " << TO.pt() << " eta " << TO.eta() << " phi " << TO.phi() << " mass " << TO.mass() << " Id " << TO.id() << std::endl;
212  }
213  }
214  }
215  }
216  h_nL3Objs -> Fill(vec[2].size());
217 
219  for (int j=0; j<3; j++) {
220  for (unsigned int k=0; k<vec[j].size(); k++) {
221  if (verbosity%10 > 0) std::cout << "vec[" << j << "][" << k << "] pt " << vec[j][k].pt() << " eta " << vec[j][k].eta() << " phi " << vec[j][k].phi() << std::endl;
222  fillHist(j, vec[j][k]);
223  }
224  }
225 
226  double deta, dphi, dr;
228  for (int lvl=1; lvl<3; lvl++) {
229  for (unsigned int i=0; i<vec[lvl].size(); i++) {
230  deta = dEta(vec[0][0],vec[lvl][i]);
231  dphi = dPhi(vec[0][0],vec[lvl][i]);
232  dr = dR(vec[0][0],vec[lvl][i]);
233  if (verbosity%10 > 0) std::cout << "lvl " <<lvl << " i " << i << " deta " << deta << " dphi " << dphi << " dR " << dr << std::endl;
234  h_dEtaL1[lvl-1] -> Fill(deta);
235  h_dPhiL1[lvl-1] -> Fill(dphi);
236  h_dRL1[lvl-1] -> Fill(std::sqrt(dr));
237  }
238  }
239 
240  math::XYZTLorentzVector mindRvec;
241  double mindR;
242  for (unsigned int k=0; k<vec[2].size(); ++k) {
244  mindR=999.9;
245  if (verbosity%10 > 0) std::cout << "L3obj: pt " << vec[2][i].pt() << " eta " << vec[2][i].eta() << " phi " << vec[2][i].phi() << std::endl;
246  for (unsigned int j=0; j<vec[1].size(); j++) {
247  dr = dR(vec[2][k],vec[1][j]);
248  if(dr<mindR) {
249  mindR=dr;
250  mindRvec=vec[1][j];
251  }
252  }
253  fillDifferences(0, vec[2][k], mindRvec, (verbosity%10 >0));
254  if(mindR < 0.03) {
255  fillDifferences(1, vec[2][k], mindRvec, (verbosity%10 >0));
256  fillHist(6, mindRvec);
257  fillHist(8, vec[2][k]);
258  } else {
259  fillDifferences(2, vec[2][k], mindRvec, (verbosity%10 >0));
260  fillHist(7, mindRvec);
261  fillHist(9, vec[2][k]);
262  }
263 
265  mindR=999.9;
266  if (verbosity%10 > 0) std::cout << "vec[2][k].eta() " << vec[2][k].eta() << " vec[k][0].phi " << vec[2][k].phi() << std::endl;
267  reco::TrackCollection::const_iterator goodTk = trkCollection->end();
268  if (trkCollection.isValid()) {
269  double mindP = 9999.9;
270  for (trkItr=trkCollection->begin();
271  trkItr!=trkCollection->end(); trkItr++) {
272  math::XYZTLorentzVector v4(trkItr->px(), trkItr->py(),
273  trkItr->pz(), trkItr->p());
274  double deltaR = dR(v4, vec[2][k]);
275  double dp = std::abs(v4.r()/vec[2][k].r()-1.0);
276  if (deltaR<mindR) {
277  mindR = deltaR;
278  mindP = dp;
279  mindRvec = v4;
280  goodTk = trkItr;
281  }
282  if ((verbosity/10)%10>1 && deltaR<1.0) {
283  std::cout << "track: pt " << v4.pt() << " eta " << v4.eta()
284  << " phi " << v4.phi() << " DR " << deltaR
285  << std::endl;
286  }
287  }
288  if (mindR < 0.03 && mindP > 0.1) {
289  for (trkItr=trkCollection->begin();
290  trkItr!=trkCollection->end(); trkItr++) {
291  math::XYZTLorentzVector v4(trkItr->px(), trkItr->py(),
292  trkItr->pz(), trkItr->p());
293  double deltaR = dR(v4, vec[2][k]);
294  double dp = std::abs(v4.r()/vec[2][k].r()-1.0);
295  if (dp<mindP && deltaR<0.03) {
296  mindR = deltaR;
297  mindP = dp;
298  mindRvec = v4;
299  goodTk = trkItr;
300  }
301  }
302  }
303  fillDifferences(3, vec[2][k], mindRvec, (verbosity%10 >0));
304  fillHist(3, mindRvec);
305  if(mindR < 0.03) {
306  fillDifferences(4, vec[2][k], mindRvec, (verbosity%10 >0));
307  fillHist(4, mindRvec);
308  } else {
309  fillDifferences(5, vec[2][k], mindRvec, (verbosity%10 >0));
310  fillHist(5, mindRvec);
311  }
312 
313  //Define the best vertex
315  iEvent.getByLabel("offlinePrimaryVertices",recVtxs);
316  // Get the beamspot
317  edm::Handle<reco::BeamSpot> beamSpotH;
318  iEvent.getByLabel("offlineBeamSpot", beamSpotH);
319  math::XYZPoint leadPV(0,0,0);
320  if (recVtxs->size()>0 && !((*recVtxs)[0].isFake())) {
321  leadPV = math::XYZPoint( (*recVtxs)[0].x(),(*recVtxs)[0].y(), (*recVtxs)[0].z() );
322  } else if (beamSpotH.isValid()) {
323  leadPV = beamSpotH->position();
324  }
325  if ((verbosity/100)%10>0) {
326  std::cout << "Primary Vertex " << leadPV;
327  if (beamSpotH.isValid()) std::cout << " Beam Spot "
328  << beamSpotH->position();
329  std::cout << std::endl;
330  }
331 
332  std::vector<spr::propagatedTrackDirection> trkCaloDirections;
333  spr::propagateCALO(trkCollection, geo, bField, theTrackQuality, trkCaloDirections, ((verbosity/100)%10>2));
334  std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
335 
336  edm::Handle<EcalRecHitCollection> barrelRecHitsHandle;
337  edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
338  iEvent.getByLabel("ecalRecHit","EcalRecHitsEB",barrelRecHitsHandle);
339  iEvent.getByLabel("ecalRecHit","EcalRecHitsEE",endcapRecHitsHandle);
340 
341  unsigned int nTracks=0, ngoodTk=0, nselTk=0;
342  int ieta=999;
343  for (trkDetItr = trkCaloDirections.begin(); trkDetItr != trkCaloDirections.end(); trkDetItr++,nTracks++){
344  bool l3Track = (trkDetItr->trkItr == goodTk);
345  const reco::Track* pTrack = &(*(trkDetItr->trkItr));
346  math::XYZTLorentzVector v4(pTrack->px(), pTrack->py(),
347  pTrack->pz(), pTrack->p());
348  bool selectTk = spr::goodTrack(pTrack,leadPV,selectionParameters,((verbosity/100)%10>2));
349  double eMipDR=9999., e_inCone=0, conehmaxNearP=0, mindR=999.9;
350  if (trkDetItr->okHCAL) {
351  HcalDetId detId = (HcalDetId)(trkDetItr->detIdHCAL);
352  ieta = detId.ieta();
353  }
354  for (unsigned k=0; k<vec[0].size(); ++k) {
355  double deltaR = dR(v4, vec[0][k]);
356  if (deltaR<mindR) mindR = deltaR;
357  }
358  if (selectTk && trkDetItr->okECAL && trkDetItr->okHCAL) {
359  ngoodTk++;
360  int nRH_eMipDR=0, nNearTRKs=0;
361  double e1 = spr::eCone_ecal(geo, barrelRecHitsHandle, endcapRecHitsHandle,
362  trkDetItr->pointHCAL, trkDetItr->pointECAL,
363  a_neutR1, trkDetItr->directionECAL, nRH_eMipDR);
364  double e2 = spr::eCone_ecal(geo, barrelRecHitsHandle, endcapRecHitsHandle,
365  trkDetItr->pointHCAL, trkDetItr->pointECAL,
366  a_neutR2, trkDetItr->directionECAL, nRH_eMipDR);
367  eMipDR = spr::eCone_ecal(geo, barrelRecHitsHandle, endcapRecHitsHandle,
368  trkDetItr->pointHCAL, trkDetItr->pointECAL,
369  a_mipR, trkDetItr->directionECAL, nRH_eMipDR);
370  conehmaxNearP = spr::chargeIsolationCone(nTracks, trkCaloDirections, a_charIsoR, nNearTRKs, ((verbosity/100)%10>2));
371  e_inCone = e2 - e1;
372  if (eMipDR<1.0) nselTk++;
373  }
374  if (l3Track) {
375  fillHist(10,v4);
376  if (selectTk) {
377  fillHist(11,v4);
378  fillCuts(0, eMipDR, conehmaxNearP, e_inCone, v4, ieta, (mindR>dr_L1));
379  if (conehmaxNearP < cutCharge) {
380  fillHist(12,v4);
381  if (eMipDR < cutMip) {
382  fillHist(13,v4);
383  if (e_inCone < cutNeutral) fillHist(14, v4);
384  }
385  }
386  }
387  } else {
388  fillHist(15,v4);
389  if (selectTk) {
390  fillHist(16,v4);
391  fillCuts(1, eMipDR, conehmaxNearP, e_inCone, v4, ieta, (mindR>dr_L1));
392  if (conehmaxNearP < cutCharge) {
393  fillHist(17,v4);
394  if (eMipDR < cutMip) {
395  fillHist(18,v4);
396  if (e_inCone < cutNeutral) fillHist(19, v4);
397  }
398  }
399  }
400  }
401  }
402  }
403  }
404  }
405  break;
406  }
407  }
408 
409  h_HLT -> Fill(hlt);
410  h_PreL1 -> Fill(preL1);
411  h_PreHLT -> Fill(preHLT);
412  h_Pre -> Fill(prescale);
413  h_PreL1wt -> Fill(preL1, mybxlumi);
414  h_PreHLTwt -> Fill(preHLT, mybxlumi);
415 
416  // check if trigger names in (new) config
417  if (changed) {
418  changed = false;
419  if ((verbosity/10)%10 > 1) {
420  std::cout<<"New trigger menu found !!!" << std::endl;
421  const unsigned int n(hltConfig_.size());
422  for (unsigned itrig=0; itrig<triggerNames_.size(); itrig++) {
423  unsigned int triggerindx = hltConfig_.triggerIndex(triggerNames_[itrig]);
424  std::cout << triggerNames_[itrig] << " " << triggerindx << " ";
425  if (triggerindx >= n)
426  std::cout << "does not exist in the current menu" << std::endl;
427  else
428  std::cout << "exists" << std::endl;
429  }
430  }
431  }
432  }
433  }
434 }
435 
437  char hname[100], htit[100];
438  std::string levels[20] = {"L1", "L2", "L3",
439  "Reco", "RecoMatch", "RecoNoMatch",
440  "L2Match", "L2NoMatch", "L3Match", "L3NoMatch",
441  "HLTTrk", "HLTGoodTrk", "HLTIsoTrk", "HLTMip", "HLTSelect",
442  "nonHLTTrk", "nonHLTGoodTrk", "nonHLTIsoTrk", "nonHLTMip", "nonHLTSelect"};
443  std::string pairs[6] = {"L2L3", "L2L3Match", "L2L3NoMatch", "L3Reco", "L3RecoMatch", "L3RecoNoMatch"};
444 
445  std::string cuts[2] = {"HLTMatched", "HLTNotMatched"};
446  std::string cuts2[2] = {"All", "Away from L1"};
447  h_nHLT = fs->make<TH1I>("h_nHLT" , "size of rigger Names", 1000, 1, 1000);
448  h_HLT = fs->make<TH1I>("h_HLT" , "HLT accept", 3, -1, 2);
449  h_PreL1 = fs->make<TH1I>("h_PreL1", "L1 Prescale", 500, 0, 500);
450  h_PreHLT = fs->make<TH1I>("h_PreHLT", "HLT Prescale", 50, 0, 50);
451  h_Pre = fs->make<TH1I>("h_Pre", "Prescale", 3000, 0, 3000);
452  h_nL3Objs = fs->make<TH1I>("h_nL3Objs", "Number of L3 objects", 10, 0, 10);
453 
454  h_PreL1wt = fs->make<TH1D>("h_PreL1wt", "Weighted L1 Prescale", 500, 0, 500);
455  h_PreHLTwt = fs->make<TH1D>("h_PreHLTwt", "Weighted HLT Prescale", 500, 0, 100);
456  h_L1ObjEnergy = fs->make<TH1D>("h_L1ObjEnergy", "Energy of L1Object", 500, 0.0, 500.0);
457 
458  for(int ipair=0; ipair<6; ipair++) {
459  sprintf(hname, "h_dEta%s", pairs[ipair].c_str());
460  sprintf(htit, "dEta for %s", pairs[ipair].c_str());
461  h_dEta[ipair] = fs->make<TH1D>(hname, htit, 200, -10.0, 10.0);
462  h_dEta[ipair]->GetXaxis()->SetTitle("d#eta");
463 
464  sprintf(hname, "h_dPhi%s", pairs[ipair].c_str());
465  sprintf(htit, "dPhi for %s", pairs[ipair].c_str());
466  h_dPhi[ipair] = fs->make<TH1D>(hname, htit, 140, -7.0, 7.0);
467  h_dPhi[ipair]->GetXaxis()->SetTitle("d#phi");
468 
469  sprintf(hname, "h_dPt%s", pairs[ipair].c_str());
470  sprintf(htit, "dPt for %s objects", pairs[ipair].c_str());
471  h_dPt[ipair] = fs->make<TH1D>(hname, htit, 400, -200.0, 200.0);
472  h_dPt[ipair]->GetXaxis()->SetTitle("dp_{T} (GeV)");
473 
474  sprintf(hname, "h_dP%s", pairs[ipair].c_str());
475  sprintf(htit, "dP for %s objects", pairs[ipair].c_str());
476  h_dP[ipair] = fs->make<TH1D>(hname, htit, 400, -200.0, 200.0);
477  h_dP[ipair]->GetXaxis()->SetTitle("dP (GeV)");
478 
479  sprintf(hname, "h_dinvPt%s", pairs[ipair].c_str());
480  sprintf(htit, "dinvPt for %s objects", pairs[ipair].c_str());
481  h_dinvPt[ipair] = fs->make<TH1D>(hname, htit, 500, -0.4, 0.1);
482  h_dinvPt[ipair]->GetXaxis()->SetTitle("d(1/p_{T})");
483 
484  sprintf(hname, "h_mindR%s", pairs[ipair].c_str());
485  sprintf(htit, "mindR for %s objects", pairs[ipair].c_str());
486  h_mindR[ipair] = fs->make<TH1D>(hname, htit, 500, 0.0, 1.0);
487  h_mindR[ipair]->GetXaxis()->SetTitle("dR");
488  }
489 
490  for(int ilevel=0; ilevel<20; ilevel++) {
491  sprintf(hname, "h_p%s", levels[ilevel].c_str());
492  sprintf(htit, "p for %s objects", levels[ilevel].c_str());
493  h_p[ilevel] = fs->make<TH1D>(hname, htit, 100, 0.0, 500.0);
494  h_p[ilevel]->GetXaxis()->SetTitle("p (GeV)");
495 
496  sprintf(hname, "h_pt%s", levels[ilevel].c_str());
497  sprintf(htit, "pt for %s objects", levels[ilevel].c_str());
498  h_pt[ilevel] = fs->make<TH1D>(hname, htit, 100, 0.0, 500.0);
499  h_pt[ilevel]->GetXaxis()->SetTitle("p_{T} (GeV)");
500 
501  sprintf(hname, "h_eta%s", levels[ilevel].c_str());
502  sprintf(htit, "eta for %s objects", levels[ilevel].c_str());
503  h_eta[ilevel] = fs->make<TH1D>(hname, htit, 100, -5.0, 5.0);
504  h_eta[ilevel]->GetXaxis()->SetTitle("#eta");
505 
506  sprintf(hname, "h_phi%s", levels[ilevel].c_str());
507  sprintf(htit, "phi for %s objects", levels[ilevel].c_str());
508  h_phi[ilevel] = fs->make<TH1D>(hname, htit, 70, -3.5, 3.50);
509  h_phi[ilevel]->GetXaxis()->SetTitle("#phi");
510  }
511  for(int lvl=0; lvl<2; lvl++) {
512  sprintf(hname, "h_dEtaL1%s", levels[lvl+1].c_str());
513  sprintf(htit, "dEta for L1 and %s objects", levels[lvl+1].c_str());
514  h_dEtaL1[lvl] = fs->make<TH1D>(hname, htit, 400, -10.0, 10.0);
515 
516  sprintf(hname, "h_dPhiL1%s", levels[lvl+1].c_str());
517  sprintf(htit, "dPhi for L1 and %s objects", levels[lvl+1].c_str());
518  h_dPhiL1[lvl] = fs->make<TH1D>(hname, htit, 280, -7.0, 7.0);
519 
520  sprintf(hname, "h_dRL1%s", levels[lvl+1].c_str());
521  sprintf(htit, "dR for L1 and %s objects", levels[lvl+1].c_str());
522  h_dRL1[lvl] = fs->make<TH1D>(hname, htit, 100, 0.0, 10.0);
523  }
524 
525  for(int icut=0; icut<2; icut++) {
526  sprintf(hname, "h_eMip%s", cuts[icut].c_str());
527  sprintf(htit, "eMip for %s tracks", cuts[icut].c_str());
528  h_eMip[icut] =fs->make<TH1D>(hname, htit, 200, 0.0, 10.0);
529  h_eMip[icut]->GetXaxis()->SetTitle("E_{Mip} (GeV)");
530 
531  sprintf(hname, "h_eMaxNearP%s", cuts[icut].c_str());
532  sprintf(htit, "eMaxNearP for %s tracks", cuts[icut].c_str());
533  h_eMaxNearP[icut]=fs->make<TH1D>(hname, htit, 240, -2.0, 10.0);
534  h_eMaxNearP[icut]->GetXaxis()->SetTitle("E_{MaxNearP} (GeV)");
535 
536  sprintf(hname, "h_eNeutIso%s", cuts[icut].c_str());
537  sprintf(htit, "eNeutIso for %s ", cuts[icut].c_str());
538  h_eNeutIso[icut] =fs->make<TH1D>(hname, htit, 200, 0.0, 10.0);
539  h_eNeutIso[icut]->GetXaxis()->SetTitle("E_{NeutIso} (GeV)");
540 
541  for (int kcut=0; kcut<2; ++kcut) {
542  sprintf(hname, "h_etaCalibTracks%s%d", cuts[icut].c_str(), kcut);
543  sprintf(htit, "etaCalibTracks for %s (%s)", cuts[icut].c_str(), cuts2[kcut].c_str());
544  h_etaCalibTracks[icut][kcut]=fs->make<TH1D>(hname, htit, 60, -30.0, 30.0);
545  h_etaCalibTracks[icut][kcut]->GetXaxis()->SetTitle("i#eta");
546 
547  sprintf(hname, "h_etaMipTracks%s%d", cuts[icut].c_str(), kcut);
548  sprintf(htit, "etaMipTracks for %s (%s)", cuts[icut].c_str(), cuts2[kcut].c_str());
549  h_etaMipTracks[icut][kcut]=fs->make<TH1D>(hname, htit, 60, -30.0, 30.0);
550  h_etaMipTracks[icut][kcut]->GetXaxis()->SetTitle("i#eta");
551  }
552  }
553 }
554 // ------------ method called once each job just after ending the event loop ------------
556  unsigned int preL1, preHLT;
557  std::map<unsigned int, unsigned int>::iterator itr;
558  std::map<unsigned int, const std::pair<int, int>>::iterator itrPre;
559  std::cout << "RunNo vs HLT accepts for " << Det << std::endl;
560  unsigned int n = maxRunNo - minRunNo +1;
561  g_Pre = fs->make<TH1I>("h_PrevsRN", "PreScale Vs Run Number", n, minRunNo, maxRunNo);
562  g_PreL1 = fs->make<TH1I>("h_PreL1vsRN", "L1 PreScale Vs Run Number", n, minRunNo, maxRunNo);
563  g_PreHLT = fs->make<TH1I>("h_PreHLTvsRN", "HLT PreScale Vs Run Number", n, minRunNo, maxRunNo);
564  g_Accepts = fs->make<TH1I>("h_HLTAcceptsvsRN", "HLT Accepts Vs Run Number", n, minRunNo, maxRunNo);
565 
566  for (itr=TrigList.begin(), itrPre=TrigPreList.begin(); itr!=TrigList.end(); itr++, itrPre++) {
567  preL1 = (itrPre->second).first;
568  preHLT = (itrPre->second).second;
569  std::cout << itr->first << " " << itr->second << " " << itrPre->first << " " << preL1 << " " << preHLT << std::endl;
570  g_Accepts->Fill(itr->first, itr->second);
571  g_PreL1->Fill(itr->first, preL1);
572  g_PreHLT->Fill(itr->first, preHLT);
573  g_Pre->Fill(itr->first, preL1*preHLT);
574  }
575 }
576 
577 // ------------ method called when starting to processes a run ------------
578 void IsoTrig::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
579  std::cout << "Run " << iRun.run() << " hltconfig.init "
580  << hltConfig_.init(iRun,iSetup,"HLT",changed) << std::endl;;
581 }
582 
583 // ------------ method called when ending the processing of a run ------------
584 void IsoTrig::endRun(edm::Run const&, edm::EventSetup const&) {}
585 
586 // ------------ method called when starting to processes a luminosity block ------------
588 // ------------ method called when ending the processing of a luminosity block ------------
590 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
592  //The following says we do not know what parameters are allowed so do no validation
593  // Please change this to state exactly what you do use, even if it is no parameters
595  desc.setUnknown();
596  descriptions.addDefault(desc);
597 }
598 
600  h_p[indx]->Fill(vec.r());
601  h_pt[indx]->Fill(vec.pt());
602  h_eta[indx]->Fill(vec.eta());
603  h_phi[indx]->Fill(vec.phi());
604 }
605 
608  double dr = dR(vec1,vec2);
609  double deta = dEta(vec1, vec2);
610  double dphi = dPhi(vec1, vec2);
611  double dpt = dPt(vec1, vec2);
612  double dp = dP(vec1, vec2);
613  double dinvpt = dinvPt(vec1, vec2);
614  h_dEta[indx] ->Fill(deta);
615  h_dPhi[indx] ->Fill(dphi);
616  h_dPt[indx] ->Fill(dpt);
617  h_dP[indx] ->Fill(dp);
618  h_dinvPt[indx]->Fill(dinvpt);
619  h_mindR[indx] ->Fill(dr);
620  if (debug) std::cout << "mindR for index " << indx << " is " << dr << " deta " << deta
621  << " dphi " << dphi << " dpt " << dpt << " dinvpt " << dinvpt <<std::endl;
622 }
623 
624 void IsoTrig::fillCuts(int indx, double eMipDR, double conehmaxNearP, double e_inCone, math::XYZTLorentzVector& vec, int ieta, bool cut) {
625  h_eMip[indx] ->Fill(eMipDR);
626  h_eMaxNearP[indx]->Fill(conehmaxNearP);
627  h_eNeutIso[indx] ->Fill(e_inCone);
628  if (conehmaxNearP < cutCharge && eMipDR < cutMip && vec.r()<60 && vec.r()>40) {
629  h_etaMipTracks[indx][0]->Fill((double)(ieta));
630  if (cut) h_etaMipTracks[indx][1]->Fill((double)(ieta));
631  if (e_inCone < cutNeutral) {
632  h_etaCalibTracks[indx][0]->Fill((double)(ieta));
633  if (cut) h_etaCalibTracks[indx][1]->Fill((double)(ieta));
634  }
635  }
636 }
637 
639  return (vec1.eta()-vec2.eta());
640 }
641 
643 
644  double phi1 = vec1.phi();
645  if (phi1 < 0) phi1 += 2.0*M_PI;
646  double phi2 = vec2.phi();
647  if (phi2 < 0) phi2 += 2.0*M_PI;
648  double dphi = phi1-phi2;
649  if (dphi > M_PI) dphi -= 2.*M_PI;
650  else if (dphi < -M_PI) dphi += 2.*M_PI;
651  return dphi;
652 }
653 
655  double deta = dEta(vec1,vec2);
656  double dphi = dPhi(vec1,vec2);
657  return std::sqrt(deta*deta + dphi*dphi);
658 }
659 
661  return (vec1.pt()-vec2.pt());
662 }
663 
665  return (std::abs(vec1.r()-vec2.r()));
666 }
667 
669  return ((1/vec1.pt())-(1/vec2.pt()));
670 }
671 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:42
unsigned int size() const
number of trigger paths in trigger table
double p() const
momentum vector magnitude
Definition: TrackBase.h:127
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
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:204
double a_coneR
Definition: IsoTrig.h:60
TH1D * h_dPt[6]
Definition: IsoTrig.h:71
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, std::string &theTrackQuality, bool debug=false)
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
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: IsoTrig.cc:589
double dr_L1
Definition: IsoTrig.h:60
TH1D * h_phi[20]
Definition: IsoTrig.h:69
float phi() const
Definition: TriggerObject.h:58
TH1D * h_dP[6]
Definition: IsoTrig.h:71
TrackQuality
track quality
Definition: TrackBase.h:93
TH1D * h_dEta[6]
Definition: IsoTrig.h:71
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
TH1I * h_Pre
Definition: IsoTrig.h:67
TH1D * h_dEtaL1[2]
Definition: IsoTrig.h:70
std::string theTrackQuality
Definition: IsoTrig.h:59
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:111
TH1I * g_PreHLT
Definition: IsoTrig.h:73
int bunchCrossing() const
Definition: EventBase.h:62
bool changed
Definition: IsoTrig.h:65
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
float energy() const
Definition: TriggerObject.h:65
TH1D * h_eMaxNearP[2]
Definition: IsoTrig.h:72
double chargeIsolationCone(unsigned int trkIndex, std::vector< spr::propagatedTrackDirection > &trkDirs, double dR, int &nNearTRKs, bool debug=false)
float eta() const
Definition: TriggerObject.h:57
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:131
TH1I * h_HLT
Definition: IsoTrig.h:67
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
double dP(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
Definition: IsoTrig.cc:664
bool getByLabel(std::string const &label, Handle< PROD > &result) const
Strings const & triggerNames() const
Definition: TriggerNames.cc:24
TH1D * h_etaMipTracks[2][2]
Definition: IsoTrig.h:70
float float float z
virtual void beginJob()
Definition: IsoTrig.cc:436
TH1D * h_dPhi[6]
Definition: IsoTrig.h:71
HLTConfigProvider hltConfig_
Definition: IsoTrig.h:55
double a_neutIsoR
Definition: IsoTrig.h:60
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:22
U second(std::pair< T, U > const &p)
TH1D * h_dPhiL1[2]
Definition: IsoTrig.h:70
TH1D * h_L1ObjEnergy
Definition: IsoTrig.h:68
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
TH1D * h_etaCalibTracks[2][2]
Definition: IsoTrig.h:72
double dinvPt(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
Definition: IsoTrig.cc:668
int maxRunNo
Definition: IsoTrig.h:62
int verbosity
Definition: IsoTrig.h:57
int iEvent
Definition: GenABIO.cc:243
void fillHist(int, math::XYZTLorentzVector &)
Definition: IsoTrig.cc:599
void addDefault(ParameterSetDescription const &psetDescription)
TH1I * h_nHLT
Definition: IsoTrig.h:67
double a_mipR
Definition: IsoTrig.h:60
TH1D * h_dinvPt[6]
Definition: IsoTrig.h:71
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
std::vector< double > vec1
Definition: HCALResponse.h:15
T sqrt(T t)
Definition: SSEVec.h:48
double cutNeutral
Definition: IsoTrig.h:61
TH1I * h_PreHLT
Definition: IsoTrig.h:67
double a_charIsoR
Definition: IsoTrig.h:60
int ieta() const
get the cell ieta
Definition: HcalDetId.h:36
TH1D * h_eMip[2]
Definition: IsoTrig.h:72
TH1D * h_eta[20]
Definition: IsoTrig.h:69
double cutCharge
Definition: IsoTrig.h:61
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: IsoTrig.cc:116
LuminosityBlock const & getLuminosityBlock() const
Definition: Event.h:80
static std::string const triggerResults
Definition: EdmProvDump.cc:41
IsoTrig(const edm::ParameterSet &)
Definition: IsoTrig.cc:58
virtual void endJob()
Definition: IsoTrig.cc:555
bool first
Definition: L1TdeRCT.cc:79
bool isValid() const
Definition: HandleBase.h:76
double a_neutR2
Definition: IsoTrig.h:61
TH1D * h_PreL1wt
Definition: IsoTrig.h:68
std::map< unsigned int, const std::pair< int, int > > TrigPreList
Definition: IsoTrig.h:64
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
double dPhi(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
Definition: IsoTrig.cc:642
double dR(double eta1, double eta2, double phi1, double phi2)
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:135
int k[5][pyjets_maxn]
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
TH1D * h_p[20]
Definition: IsoTrig.h:69
TH1D * h_eNeutIso[2]
Definition: IsoTrig.h:72
TH1I * h_PreL1
Definition: IsoTrig.h:67
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
Float e1
Definition: deltaR.h:22
const edm::InputTag filterTag(trigger::size_type index) const
Definition: TriggerEvent.h:103
int minRunNo
Definition: IsoTrig.h:62
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:46
#define M_PI
Definition: BFit3D.cc:3
#define debug
Definition: HDRShower.cc:19
TH1I * g_Pre
Definition: IsoTrig.h:73
virtual void endRun(edm::Run const &, edm::EventSetup const &)
Definition: IsoTrig.cc:584
auto dp
Definition: deltaR.h:24
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::vector< size_type > Keys
double dEta(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
Definition: IsoTrig.cc:638
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
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.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: IsoTrig.cc:591
T const * product() const
Definition: Handle.h:81
spr::trackSelectionParameters selectionParameters
Definition: IsoTrig.h:58
Float e2
Definition: deltaR.h:23
TH1D * h_pt[20]
Definition: IsoTrig.h:69
std::map< unsigned int, unsigned int > TrigList
Definition: IsoTrig.h:63
std::string const & label() const
Definition: InputTag.h:42
edm::EventID id() const
Definition: EventBase.h:56
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)
double a_neutR1
Definition: IsoTrig.h:61
reco::TrackBase::TrackQuality minQuality
void fillDifferences(int, math::XYZTLorentzVector &, math::XYZTLorentzVector &, bool)
Definition: IsoTrig.cc:606
double dPt(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
Definition: IsoTrig.cc:660
tuple cout
Definition: gather_cfg.py:121
edm::Service< TFileService > fs
Definition: IsoTrig.h:66
volatile std::atomic< bool > shutdown_flag false
TH1I * g_PreL1
Definition: IsoTrig.h:73
Definition: DDAxes.h:10
float mass() const
Definition: TriggerObject.h:59
TH1I * h_nL3Objs
Definition: IsoTrig.h:67
~IsoTrig()
Definition: IsoTrig.cc:110
std::vector< vec1 > vec2
Definition: HCALResponse.h:16
TH1D * h_dRL1[2]
Definition: IsoTrig.h:70
double cutMip
Definition: IsoTrig.h:61
tuple size
Write out results.
TH1D * h_mindR[6]
Definition: IsoTrig.h:71
void fillCuts(int, double, double, double, math::XYZTLorentzVector &, int, bool)
Definition: IsoTrig.cc:624
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:133
Definition: Run.h:41
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: IsoTrig.cc:587
TH1D * h_PreHLTwt
Definition: IsoTrig.h:68
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
Definition: IsoTrig.cc:578
TH1I * g_Accepts
Definition: IsoTrig.h:73