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