test
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 // system include files
2 #include <memory>
3 
4 // Root objects
5 #include "TROOT.h"
6 #include "TSystem.h"
7 #include "TFile.h"
8 #include "TProfile.h"
9 #include "TDirectory.h"
10 #include "TTree.h"
11 #include "TLorentzVector.h"
12 #include "TInterpreter.h"
13 
14 //Tracks
19 // Vertices
23 // Jets
26 
27 //Triggers
34 
37 
47 
48  //L1 trigger Menus etc
57 
63 
78 
80 
81 public:
82  explicit IsoTrackCalib(const edm::ParameterSet&);
84 
85  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
86  double dR(double eta1, double eta2, double phi1, double phi2);
87 
88 private:
89  virtual void beginJob() ;
90  virtual void analyze(const edm::Event&, const edm::EventSetup&);
91  virtual void endJob() ;
92  virtual void beginRun(edm::Run const&, edm::EventSetup const&);
93  virtual void endRun(edm::Run const&, edm::EventSetup const&);
94  virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
95  virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
96 
100  double deltaR(double eta1,double eta2,double phi1,double phi2);
101 
105  bool initL1;
106  std::vector<std::string> trigNames, HLTNames,l1Names;
112  std::vector<bool> *t_l1bits;
116 
129 
130 
131  TTree *tree;
136 
138  std::vector<unsigned int> *t_DetIds;
139  std::vector<double> *t_HitEnergies, pbin;
141  TH1I *h_iEta, *h_tkEta0[5], *h_tkEta1[5], *h_tkEta2[5];
142  TH1I *h_tkEta3[5], *h_tkEta4[5], *h_tkEta5[5];
144  TH1F *h_jetpt[4];
145  TH1I *h_tketa0[6], *h_tketa1[6], *h_tketa2[6], *h_tketa3[6], *h_tketa4[6],*h_tketa5[6];
146  std::vector<std::string> trgnames;
147  std::map< std::pair<unsigned int,std::string>, int> l1AlgoMap;
148 };
149 
150  static const bool useL1GtTriggerMenuLite(true);
152  m_l1GtUtils(iConfig, consumesCollector(), useL1GtTriggerMenuLite, *this){
153  //now do whatever initialization is needed
154  verbosity = iConfig.getUntrackedParameter<int>("Verbosity",0);
155  l1Names = iConfig.getUntrackedParameter<std::vector<std::string> >("L1Seed");
156  theTrackQuality = iConfig.getUntrackedParameter<std::string>("TrackQuality","highPurity");
157  reco::TrackBase::TrackQuality trackQuality_=reco::TrackBase::qualityByName(theTrackQuality);
158  selectionParameters.minPt = iConfig.getUntrackedParameter<double>("MinTrackPt", 10.0);
159  selectionParameters.minQuality = trackQuality_;
160  selectionParameters.maxDxyPV = iConfig.getUntrackedParameter<double>("MaxDxyPV", 0.2);
161  selectionParameters.maxDzPV = iConfig.getUntrackedParameter<double>("MaxDzPV", 5.0);
162  selectionParameters.maxChi2 = iConfig.getUntrackedParameter<double>("MaxChi2", 5.0);
163  selectionParameters.maxDpOverP = iConfig.getUntrackedParameter<double>("MaxDpOverP", 0.1);
164  selectionParameters.minOuterHit = iConfig.getUntrackedParameter<int>("MinOuterHit", 4);
165  selectionParameters.minLayerCrossed = iConfig.getUntrackedParameter<int>("MinLayerCrossed", 8);
166  selectionParameters.maxInMiss = iConfig.getUntrackedParameter<int>("MaxInMiss", 0);
167  selectionParameters.maxOutMiss = iConfig.getUntrackedParameter<int>("MaxOutMiss", 0);
168  a_coneR = iConfig.getUntrackedParameter<double>("ConeRadius",34.98);
169  a_charIsoR = a_coneR + 28.9;
170  a_mipR = iConfig.getUntrackedParameter<double>("ConeRadiusMIP",14.0);
171  bool isItAOD = iConfig.getUntrackedParameter<bool>("IsItAOD", false);
172  triggerEvent_ = edm::InputTag("hltTriggerSummaryAOD","","HLT");
173  theTriggerResultsLabel = edm::InputTag("TriggerResults","","HLT");
174  edm::InputTag L1extraTauJetSource_ = iConfig.getParameter<edm::InputTag> ("L1extraTauJetSource" );
175  edm::InputTag L1extraCenJetSource_ = iConfig.getParameter<edm::InputTag> ("L1extraCenJetSource" );
176  edm::InputTag L1extraFwdJetSource_ = iConfig.getParameter<edm::InputTag> ("L1extraFwdJetSource" );
177 
178  // define tokens for access
179  tok_trigEvt = consumes<trigger::TriggerEvent>(triggerEvent_);
180  tok_trigRes = consumes<edm::TriggerResults>(theTriggerResultsLabel);
181  tok_genTrack_ = consumes<reco::TrackCollection>(edm::InputTag("generalTracks"));
182  tok_recVtx_ = consumes<reco::VertexCollection>(edm::InputTag("offlinePrimaryVertices"));
183  tok_bs_ = consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"));
184  tok_ew_ = consumes<GenEventInfoProduct>(edm::InputTag("generatorSmeared"));
185  tok_L1extTauJet_ = consumes<l1extra::L1JetParticleCollection>(L1extraTauJetSource_);
186  tok_L1extCenJet_ = consumes<l1extra::L1JetParticleCollection>(L1extraCenJetSource_);
187  tok_L1extFwdJet_ = consumes<l1extra::L1JetParticleCollection>(L1extraFwdJetSource_);
188  if (isItAOD) {
189  tok_EB_ = consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEB"));
190  tok_EE_ = consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEE"));
191  tok_hbhe_ = consumes<HBHERecHitCollection>(edm::InputTag("reducedHcalRecHits", "hbhereco"));
192  } else {
193  tok_EB_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit","EcalRecHitsEB"));
194  tok_EE_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit","EcalRecHitsEE"));
195  tok_hbhe_ = consumes<HBHERecHitCollection>(edm::InputTag("hbhereco"));
196  }
197  tok_jets_ = consumes<reco::GenJetCollection>(iConfig.getParameter<edm::InputTag>("JetSource"));
198  tok_pfjets_ = consumes<reco::PFJetCollection>(edm::InputTag("ak5PFJets"));
199  if (verbosity>=0) {
200  edm::LogInfo("IsoTrack")
201  <<"Parameters read from config file \n"
202  <<"\t minPt " << selectionParameters.minPt
203  <<"\t theTrackQuality " << theTrackQuality
204  <<"\t minQuality " << selectionParameters.minQuality
205  <<"\t maxDxyPV " << selectionParameters.maxDxyPV
206  <<"\t maxDzPV " << selectionParameters.maxDzPV
207  <<"\t maxChi2 " << selectionParameters.maxChi2
208  <<"\t maxDpOverP " << selectionParameters.maxDpOverP
209  <<"\t minOuterHit " << selectionParameters.minOuterHit
210  <<"\t minLayerCrossed " << selectionParameters.minLayerCrossed
211  <<"\t maxInMiss " << selectionParameters.maxInMiss
212  <<"\t maxOutMiss " << selectionParameters.maxOutMiss
213  <<"\t a_coneR " << a_coneR
214  <<"\t a_charIsoR " << a_charIsoR
215  <<"\t a_mipR " << a_mipR
216  <<"\t isItAOD " << isItAOD;
217  edm::LogInfo("IsoTrack") << trigNames.size() << " triggers to be studied";
218  for (unsigned int k=0; k<trigNames.size(); ++k)
219  edm::LogInfo("IsoTrack") << "[" << k << "]: " << trigNames[k];
220  }
221 
222 }
223 
225  // do anything here that needs to be done at desctruction time
226  // (e.g. close files, deallocate resources etc.)
227 
228 }
229 
231  const edm::EventSetup& iSetup) {
232 
233  t_Run = iEvent.id().run();
234  t_Event = iEvent.id().event();
235  if (verbosity%10 > 0)
236  edm::LogInfo("IsoTrack")
237  << "Run " << t_Run << " Event " << t_Event << " Luminosity "
238  << iEvent.luminosityBlock() << " Bunch " << iEvent.bunchCrossing()
239  << " starts ==========";
240 
241  //Get magnetic field and ECAL channel status
243  iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
244  const MagneticField *bField = bFieldH.product();
245 
247  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
248 
249  // get handles to calogeometry and calotopology
251  iSetup.get<CaloGeometryRecord>().get(pG);
252  const CaloGeometry* geo = pG.product();
253 
254  //Get track collection
256  iEvent.getByToken(tok_genTrack_, trkCollection);
257  reco::TrackCollection::const_iterator trkItr;
258 
259  //event weight for FLAT sample
260  t_EventWeight = 1.0;
262  iEvent.getByToken(tok_ew_, genEventInfo);
263  if (genEventInfo.isValid()) t_EventWeight = genEventInfo->weight();
264 
265  // genJet information
267  iEvent.getByToken(tok_jets_, genJets);
268  if (genJets.isValid()) {
269  for (unsigned iGenJet = 0; iGenJet < genJets->size(); ++iGenJet) {
270  const reco::GenJet& genJet = (*genJets) [iGenJet];
271  double genJetPt = genJet.pt();
272  double genJetEta = genJet.eta();
273  h_jetpt[0]->Fill(genJetPt);
274  h_jetpt[1]->Fill(genJetPt,t_EventWeight);
275  if (genJetEta>-2.5 && genJetEta<2.5) {
276  h_jetpt[2]->Fill(genJetPt);
277  h_jetpt[3]->Fill(genJetPt,t_EventWeight);
278  }
279  break;
280  }
281  }
282 
283  //pf jets
285  iEvent.getByToken(tok_pfjets_, pfJets);
286  reco::PFJetCollection::const_iterator pfItr;
287 
288  //Define the best vertex and the beamspot
290  iEvent.getByToken(tok_recVtx_, recVtxs);
291  edm::Handle<reco::BeamSpot> beamSpotH;
292  iEvent.getByToken(tok_bs_, beamSpotH);
293  math::XYZPoint leadPV(0,0,0);
294  if (recVtxs->size()>0 && !((*recVtxs)[0].isFake())) {
295  leadPV = math::XYZPoint( (*recVtxs)[0].x(),(*recVtxs)[0].y(), (*recVtxs)[0].z() );
296  } else if (beamSpotH.isValid()) {
297  leadPV = beamSpotH->position();
298  }
299  if (verbosity>10) {
300  if ((verbosity%100)/10>2)
301  edm::LogInfo("IsoTrack") << "Primary Vertex " << leadPV;
302  if (beamSpotH.isValid()) edm::LogInfo("IsoTrack") << " Beam Spot "
303  << beamSpotH->position();
304  }
305 
306  // RecHits
307  edm::Handle<EcalRecHitCollection> barrelRecHitsHandle;
308  edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
309  iEvent.getByToken(tok_EB_, barrelRecHitsHandle);
310  iEvent.getByToken(tok_EE_, endcapRecHitsHandle);
312  iEvent.getByToken(tok_hbhe_, hbhe);
314 
315  for (rhitItr=hbhe->begin();rhitItr!=hbhe->end();rhitItr++) {
316  double rec_energy = rhitItr->energy();
317  int rec_ieta = rhitItr->id().ieta();
318  int rec_depth = rhitItr->id().depth();
319  int rec_zside = rhitItr->id().zside();
320  double num1_1 = rec_zside*(rec_ieta+0.2*(rec_depth-1));
321  if (verbosity%10>0)
322  edm::LogInfo("IsoTrack") << "detid/rechit/ieta/zside/depth/num " << " = "
323  << rhitItr->id() << "/" << rec_energy << "/"
324  << rec_ieta << "/" << rec_zside << "/"
325  << rec_depth << "/" << num1_1;
326  h_iEta->Fill(rec_ieta);
327  h_Rechit_E->Fill(rec_energy);
328  h_RecHit_iEta->Fill(rec_ieta,rec_energy);
329  h_RecHit_num->Fill(num1_1,rec_energy);
330  }
331 
332  //Propagate tracks to calorimeter surface)
333  std::vector<spr::propagatedTrackDirection> trkCaloDirections;
334  spr::propagateCALO(trkCollection, geo, bField, theTrackQuality,
335  trkCaloDirections, ((verbosity/100)%10>2));
336  std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
337  for (trkDetItr = trkCaloDirections.begin();
338  trkDetItr != trkCaloDirections.end(); trkDetItr++) {
339  if (trkDetItr->okHCAL) {
340  HcalDetId detId = (HcalDetId)(trkDetItr->detIdHCAL);
341  int tk_ieta = detId.ieta();
342  const reco::Track* pTrack = &(*(trkDetItr->trkItr));
343  double tk_p = pTrack->p();
344  h_tketa0[0]->Fill(tk_ieta);
345  for (unsigned int k=1; k<pbin.size(); ++k) {
346  if (tk_p >= pbin[k-1] && tk_p < pbin[k]) {
347  h_tketa0[k]->Fill(tk_ieta);
348  break;
349  }
350  }
351  }
352  }
354  t_l1bits->clear();
355  for (unsigned int i=0; i<l1Names.size(); ++i) t_l1bits->push_back(false);
356  bool useL1EventSetup = true;
357  bool useL1GtTriggerMenuLite = true;
358 
359  m_l1GtUtils.getL1GtRunCache(iEvent, iSetup, useL1EventSetup, useL1GtTriggerMenuLite);
360  int iErrorCode = -1;
361  int l1ConfCode = -1;
362  const bool l1Conf = m_l1GtUtils.availableL1Configuration(iErrorCode, l1ConfCode);
363  if( !l1Conf) {
364  edm::LogInfo("IsoTrack") << "\nL1 configuration code:" << l1ConfCode
365  << "\nNo valid L1 trigger configuration available."
366  << "\nSee text above for error code interpretation"
367  << "\nNo return here, in order to test each method"
368  << ", protected against configuration error.";
369  }
370 
371  const AlgorithmMap& algorithmMap = m_l1GtMenu->gtAlgorithmMap();
372  const std::string& menuName = m_l1GtMenu->gtTriggerMenuName();
373  std::cout << "menuName " << menuName << std::endl;
374 
375  std::vector<int> algbits;
376  for (CItAlgo itAlgo = algorithmMap.begin(); itAlgo != algorithmMap.end();
377  itAlgo++) {
378  std::string algName = itAlgo->first;
379  int algBitNumber = ( itAlgo->second ).algoBitNumber();
380  bool decision = m_l1GtUtils.decision(iEvent, itAlgo->first, iErrorCode);
381 
382  bool l1ok(false);
383  if (verbosity%10>0)
384  edm::LogInfo("IsoTrack") << algName <<" "<< algBitNumber << " "
385  << decision;
386  for (unsigned int i=0; i<l1Names.size(); ++i) {
387  if (algName.find(l1Names[i])!=std::string::npos){
388  if (verbosity%10>0)
389  edm::LogInfo("IsoTrack") << "match found" << " " << algName << " "
390  << decision;
391  t_l1bits->at(i) = (decision>0);
392  if (decision > 0) l1ok = true;
393  }
394  }
395  if (verbosity%10>0) edm::LogInfo("IsoTrack") << "l1 ok =" << l1ok;
396 
397  if(l1ok){
399  iEvent.getByToken(tok_L1extTauJet_,l1TauHandle);
400  l1extra::L1JetParticleCollection::const_iterator itr;
401  double ptTriggered = -10;
402  double etaTriggered = -100;
403  double phiTriggered = -100;
404 
405  for(itr = l1TauHandle->begin(); itr != l1TauHandle->end(); ++itr) {
406  if(itr->pt()>ptTriggered){
407  ptTriggered = itr->pt();
408  etaTriggered = itr->eta();
409  phiTriggered = itr->phi() ;
410  }
411  if (verbosity%10>0)
412  edm::LogInfo("IsoTrack") << "tauJ pt " << itr->pt() << " eta/phi "
413  << itr->eta() << " " << itr->phi();
414  }
416  iEvent.getByToken(tok_L1extCenJet_,l1CenJetHandle);
417  for (itr = l1CenJetHandle->begin(); itr != l1CenJetHandle->end(); ++itr){
418  if (itr->pt()>ptTriggered) {
419  ptTriggered = itr->pt();
420  etaTriggered = itr->eta();
421  phiTriggered = itr->phi() ;
422  }
423  if (verbosity%10>0)
424  edm::LogInfo("IsoTrack") << "cenJ pt " << itr->pt()
425  << " eta/phi " << itr->eta() << " "
426  << itr->phi();
427  }
429  iEvent.getByToken(tok_L1extFwdJet_,l1FwdJetHandle);
430  for (itr = l1FwdJetHandle->begin(); itr != l1FwdJetHandle->end(); ++itr) {
431  if (itr->pt()>ptTriggered) {
432  ptTriggered = itr->pt();
433  etaTriggered = itr->eta();
434  phiTriggered = itr->phi() ;
435  }
436  if (verbosity%10>0)
437  edm::LogInfo("IsoTrack") << "forJ pt " << itr->pt() << " eta/phi "
438  << itr->eta() << " " << itr->phi();
439  }
440  if (verbosity%10>0)
441  edm::LogInfo("IsoTrack") << "jets pt/eta/phi = " << ptTriggered << "/"
442  << etaTriggered << "/" <<phiTriggered;
444  unsigned int nTracks(0),nselTracks(0);
445  for (trkDetItr = trkCaloDirections.begin(),nTracks=0;
446  trkDetItr != trkCaloDirections.end(); trkDetItr++,nTracks++) {
447  const reco::Track* pTrack = &(*(trkDetItr->trkItr));
448  math::XYZTLorentzVector v4(pTrack->px(), pTrack->py(),
449  pTrack->pz(), pTrack->p());
450 
451  t_mindR1 = deltaR(etaTriggered,v4.eta(),phiTriggered,v4.phi());
452  t_mindR2 = -999;
453  if (verbosity%10>0)
454  edm::LogInfo("IsoTrack") << "This track : " << nTracks << " (pt/eta/phi/p) :"
455  << pTrack->pt() << "/" << pTrack->eta() << "/"
456  << pTrack->phi() << "/" << pTrack->p();
457 
458  if (verbosity%10>0) edm::LogInfo("IsoTrack") << "dr values are = " << t_mindR1;
459 
460  t_l1pt = ptTriggered;
461  t_l1eta = etaTriggered;
462  t_l1phi = phiTriggered;
463  t_l3pt = -999;
464  t_l3eta = -999;
465  t_l3phi = -999;
466 
467  //Selection of good track
468  t_selectTk = spr::goodTrack(pTrack,leadPV,selectionParameters,((verbosity/100)%10>2));
470  oneCutParameters.maxDxyPV = 10;
471  oneCutParameters.maxDzPV = 100;
472  oneCutParameters.maxInMiss = 2;
473  oneCutParameters.maxOutMiss= 2;
474  bool qltyFlag = spr::goodTrack(pTrack,leadPV,oneCutParameters,((verbosity/100)%10>2));
475  oneCutParameters = selectionParameters;
476  oneCutParameters.maxDxyPV = 10;
477  oneCutParameters.maxDzPV = 100;
478  t_qltyMissFlag = spr::goodTrack(pTrack,leadPV,oneCutParameters,((verbosity/100)%10>2));
479  oneCutParameters = selectionParameters;
480  oneCutParameters.maxInMiss = 2;
481  oneCutParameters.maxOutMiss= 2;
482  t_qltyPVFlag = spr::goodTrack(pTrack,leadPV,oneCutParameters,((verbosity/100)%10>2));
483  t_ieta = 0;
484  if (trkDetItr->okHCAL) {
485  HcalDetId detId = (HcalDetId)(trkDetItr->detIdHCAL);
486  t_ieta = detId.ieta();
487  }
488  if (verbosity%10 > 0)
489  edm::LogInfo("IsoTrack") << "qltyFlag|okECAL|okHCAL : " << qltyFlag << "|"
490  << trkDetItr->okECAL << "/" << trkDetItr->okHCAL;
491  t_qltyFlag = (qltyFlag && trkDetItr->okECAL && trkDetItr->okHCAL);
492  t_p = pTrack->p();
493  h_tketa1[0]->Fill(t_ieta);
494  for (unsigned int k=1; k<pbin.size(); ++k) {
495  if (t_p >= pbin[k-1] && t_p < pbin[k]) {
496  h_tketa1[k]->Fill(t_ieta);
497  break;
498  }
499  }
500  if (t_qltyFlag) {
501  nselTracks++;
502  h_tketa2[0]->Fill(t_ieta);
503  for (unsigned int k=1; k<pbin.size(); ++k) {
504  if (t_p >= pbin[k-1] && t_p < pbin[k]) {
505  h_tketa2[k]->Fill(t_ieta);
506  break;
507  }
508  }
509  int nRH_eMipDR(0), nNearTRKs(0), nRecHits(-999);
510  t_eMipDR = spr::eCone_ecal(geo, barrelRecHitsHandle,
511  endcapRecHitsHandle,
512  trkDetItr->pointHCAL,
513  trkDetItr->pointECAL,
514  a_mipR, trkDetItr->directionECAL,
515  nRH_eMipDR);
516  t_DetIds->clear(); t_HitEnergies->clear();
517  std::vector<DetId> ids;
518  t_eHcal = spr::eCone_hcal(geo, hbhe, trkDetItr->pointHCAL,
519  trkDetItr->pointECAL, a_coneR,
520  trkDetItr->directionHCAL,nRecHits,
521  ids, *t_HitEnergies);
522  for (unsigned int k=0; k<ids.size(); ++k) {
523  t_DetIds->push_back(ids[k].rawId());
524  }
525  t_hmaxNearP = spr::chargeIsolationCone(nTracks,trkCaloDirections,
526  a_charIsoR, nNearTRKs,
527  ((verbosity/100)%10>2));
528  if (t_hmaxNearP < 2) {
529  h_tketa3[0]->Fill(t_ieta);
530  for (unsigned int k=1; k<pbin.size(); ++k) {
531  if (t_p >= pbin[k-1] && t_p < pbin[k]) {
532  h_tketa3[k]->Fill(t_ieta);
533  break;
534  }
535  }
536  if (t_eMipDR < 1) {
537  h_tketa4[0]->Fill(t_ieta);
538  for (unsigned int k=1; k<pbin.size(); ++k) {
539  if (t_p >= pbin[k-1] && t_p < pbin[k]) {
540  h_tketa4[k]->Fill(t_ieta);
541  break;
542  }
543  }
544  if (t_mindR1 > 1) {
545  h_tketa5[0]->Fill(t_ieta);
546  for (unsigned int k=1; k<pbin.size(); ++k) {
547  if (t_p >= pbin[k-1] && t_p < pbin[k]) {
548  h_tketa5[k]->Fill(t_ieta);
549  break;
550  }
551  }
552  }
553  }
554  }
555  if (verbosity%10 > 0) {
556  edm::LogInfo("IsoTrack") << "This track : " << nTracks << " (pt/eta/phi/p) :"
557  << pTrack->pt() << "/" << pTrack->eta() << "/"
558  << pTrack->phi() << "/" << t_p;
559  edm::LogInfo("IsoTrack") << "e_MIP " << t_eMipDR << " Chg Isolation "
560  << t_hmaxNearP << " eHcal" << t_eHcal << " ieta "
561  << t_ieta << " Quality " << t_qltyMissFlag
562  << ":" << t_qltyPVFlag << ":" << t_selectTk;
563  for (unsigned int lll=0;lll<t_DetIds->size();lll++) {
564  edm::LogInfo("IsoTrack") << "det id is = " << t_DetIds->at(lll) << " "
565  << " hit enery is = " << t_HitEnergies->at(lll);
566  }
567  }
568  if (t_p>20.0 && t_eMipDR<2.0 && t_hmaxNearP<2.0) {
569  tree->Fill();
570  }
571  }
572  }
573  }
574  }
575 }
576 
578  h_RecHit_iEta = fs->make<TProfile>("rechit_ieta","Rec hit vs. ieta",60,-30,30,0,1000);
579  h_RecHit_num = fs->make<TProfile>("rechit_num","Rec hit vs. num",100,0,20,0,1000);
580  h_iEta = fs->make<TH1I>("iEta","iEta",60,-30,30);
581  h_Rechit_E = fs->make<TH1F>("Rechit_E","Rechit_E",100,0,1000);
582 
583  double prange[5] = {20,30,40,60,100};
584  for (int k=0; k<5; ++k) pbin.push_back(prange[k]);
585  std::string type[6] = {"All", "Trigger OK", "Tree Selected",
586  "Charge Isolation", "MIP Cut", "L1 Cut"};
587  for (unsigned int k=0; k<pbin.size(); ++k) {
588  char name[20], namp[20], title[100];
589  if (k == 0) sprintf (namp, "all momentum");
590  else sprintf (namp, "p = %4.0f:%4.0f GeV", pbin[k-1], pbin[k]);
591  sprintf (name, "TrackEta0%d", k);
592  sprintf (title, "Track #eta for tracks with %s (%s)",namp,type[0].c_str());
593  h_tketa0[k] = fs->make<TH1I>(name, title, 60, -30, 30);
594  sprintf (name, "TrackEta1%d", k);
595  sprintf (title, "Track #eta for tracks with %s (%s)",namp,type[1].c_str());
596  h_tketa1[k] = fs->make<TH1I>(name, title, 60, -30, 30);
597  sprintf (name, "TrackEta2%d", k);
598  sprintf (title, "Track #eta for tracks with %s (%s)",namp,type[2].c_str());
599  h_tketa2[k] = fs->make<TH1I>(name, title, 60, -30, 30);
600  sprintf (name, "TrackEta3%d", k);
601  sprintf (title, "Track #eta for tracks with %s (%s)",namp,type[3].c_str());
602  h_tketa3[k] = fs->make<TH1I>(name, title, 60, -30, 30);
603  sprintf (name, "TrackEta4%d", k);
604  sprintf (title, "Track #eta for tracks with %s (%s)",namp,type[4].c_str());
605  h_tketa4[k] = fs->make<TH1I>(name, title, 60, -30, 30);
606  sprintf (name, "TrackEta5%d", k);
607  sprintf (title, "Track #eta for tracks with %s (%s)",namp,type[5].c_str());
608  h_tketa5[k] = fs->make<TH1I>(name, title, 60, -30, 30);
609  }
610  h_jetpt[0] = fs->make<TH1F>("Jetpt0","Jet p_T (All)", 500,0.,2500.);
611  h_jetpt[1] = fs->make<TH1F>("Jetpt1","Jet p_T (All Weighted)", 500,0.,2500.);
612  h_jetpt[2] = fs->make<TH1F>("Jetpt2","Jet p_T (|#eta| < 2.5)", 500,0.,2500.);
613  h_jetpt[3] = fs->make<TH1F>("Jetpt3","Jet p_T (|#eta| < 2.5 Weighted)", 500,0.,2500.);
614 
615  tree = fs->make<TTree>("CalibTree", "CalibTree");
616 
617  tree->Branch("t_Run", &t_Run, "t_Run/I");
618  tree->Branch("t_Event", &t_Event, "t_Event/I");
619  tree->Branch("t_ieta", &t_ieta, "t_ieta/I");
620  tree->Branch("t_EventWeight", &t_EventWeight, "t_EventWeight/D");
621  tree->Branch("t_l1pt", &t_l1pt, "t_l1pt/D");
622  tree->Branch("t_l1eta", &t_l1eta, "t_l1eta/D");
623  tree->Branch("t_l1phi", &t_l1phi, "t_l1phi/D");
624  tree->Branch("t_l3pt", &t_l3pt, "t_l3pt/D");
625  tree->Branch("t_l3eta", &t_l3eta, "t_l3eta/D");
626  tree->Branch("t_l3phi", &t_l3phi, "t_l3phi/D");
627  tree->Branch("t_p", &t_p, "t_p/D");
628  tree->Branch("t_mindR1", &t_mindR1, "t_mindR1/D");
629  tree->Branch("t_mindR2", &t_mindR2, "t_mindR2/D");
630  tree->Branch("t_eMipDR", &t_eMipDR, "t_eMipDR/D");
631  tree->Branch("t_eHcal", &t_eHcal, "t_eHcal/D");
632  tree->Branch("t_hmaxNearP", &t_hmaxNearP, "t_hmaxNearP/D");
633  tree->Branch("t_selectTk", &t_selectTk, "t_selectTk/O");
634  tree->Branch("t_qltyFlag", &t_qltyFlag, "t_qltyFlag/O");
635  tree->Branch("t_qltyMissFlag",&t_qltyMissFlag,"t_qltyMissFlag/O");
636  tree->Branch("t_qltyPVFlag", &t_qltyPVFlag, "t_qltyPVFlag/O)");
637 
638  t_DetIds = new std::vector<unsigned int>();
639  t_HitEnergies = new std::vector<double>();
640  t_l1bits = new std::vector<bool>();
641  tree->Branch("t_DetIds", "std::vector<unsigned int>", &t_DetIds);
642  tree->Branch("t_HitEnergies", "std::vector<double>", &t_HitEnergies);
643  tree->Branch("t_l1bits","std::vector<bool>", &t_l1bits);
644 }
645 
646 // ------------ method called once each job just after ending the event loop ------------
648 }
649 
650 int iErrorCode = -1;
651 // ------------ method called when starting to processes a run ------------
652 void IsoTrackCalib::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
653  bool changed = false;
654  bool ok = hltConfig_.init(iRun,iSetup,"HLT",changed);
655  edm::LogInfo("IsoTrack") << "Run " << iRun.run() << " hltconfig.init " << ok;
656 
658  const AlgorithmMap& algorithmMap = m_l1GtMenu->gtAlgorithmMap();
659  const std::string& menuName = m_l1GtMenu->gtTriggerMenuName();
660 
661  // if (verbosity%10>0) edm::LogInfo("IsoTrack") << "menuName " << menuName;
662  std::cout << "menuName " << menuName << std::endl;;
663  for (CItAlgo itAlgo = algorithmMap.begin(); itAlgo != algorithmMap.end();
664  itAlgo++) {
665  std::string algName = itAlgo->first;
666  int algBitNumber = ( itAlgo->second ).algoBitNumber();
667  l1AlgoMap.insert( std::pair<std::pair<unsigned int,std::string>,int>( std::pair<unsigned int,std::string>(algBitNumber, algName) , 0) ) ;
668  }
669  std::map< std::pair<unsigned int,std::string>, int>::iterator itr;
670  for (itr=l1AlgoMap.begin(); itr!=l1AlgoMap.end(); itr++) {
671  if (verbosity%10>0)
672  edm::LogInfo("IsoTrack") << " ********** " << (itr->first).first << " "
673  << (itr->first).second <<" "<<itr->second;
674  }
675 }
676 
677 // ------------ method called when ending the processing of a run ------------
678 void IsoTrackCalib::endRun(edm::Run const& iRun, edm::EventSetup const&) {
679  edm::LogInfo("IsoTrack") << "endRun " << iRun.run() << std::endl;
680 }
681 
682 // ------------ method called when starting to processes a luminosity block ------------
684 // ------------ method called when ending the processing of a luminosity block ------------
686 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
688  //The following says we do not know what parameters are allowed so do no validation
689  // Please change this to state exactly what you do use, even if it is no parameters
691  desc.setUnknown();
692  descriptions.addDefault(desc);
693 }
694 
696  return (vec1.eta()-vec2.eta());
697 }
698 
700 
701  double phi1 = vec1.phi();
702  if (phi1 < 0) phi1 += 2.0*M_PI;
703  double phi2 = vec2.phi();
704  if (phi2 < 0) phi2 += 2.0*M_PI;
705  double dphi = phi1-phi2;
706  if (dphi > M_PI) dphi -= 2.*M_PI;
707  else if (dphi < -M_PI) dphi += 2.*M_PI;
708  return dphi;
709 }
710 
712  double deta = dEta(vec1,vec2);
713  double dphi = dPhi(vec1,vec2);
714  return std::sqrt(deta*deta + dphi*dphi);
715 }
716 
717 double IsoTrackCalib::deltaR(double eta1,double eta2,double phi1,double phi2){
718  double deta = eta1-eta2;
719  if (phi1 < 0) phi1 += 2.0*M_PI;
720  if (phi2 < 0) phi2 += 2.0*M_PI;
721  double dphi = phi1-phi2;
722  if (dphi > M_PI) dphi -= 2.*M_PI;
723  else if (dphi < -M_PI) dphi += 2.*M_PI;
724  return std::sqrt(deta*deta + dphi*dphi);
725 }
726 
727 
728 
729 //define this as a plug-in
731 
RunNumber_t run() const
Definition: EventID.h:39
double p() const
momentum vector magnitude
Definition: TrackBase.h:610
type
Definition: HCALResponse.h:21
const std::string & gtTriggerMenuName() const
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
std::vector< double > * t_HitEnergies
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
TH1I * h_tkEta0[5]
const unsigned int nTracks(const reco::Vertex &sv)
const L1GtTriggerMenu * m_l1GtMenu
std::vector< unsigned int > * t_DetIds
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, std::string &theTrackQuality, bool debug=false)
RunNumber_t run() const
Definition: RunBase.h:40
TProfile * h_RecHit_num
HLTConfigProvider hltConfig_
edm::EDGetTokenT< l1extra::L1JetParticleCollection > tok_L1extCenJet_
edm::EDGetTokenT< reco::GenJetCollection > tok_jets_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
virtual void endRun(edm::Run const &, edm::EventSetup const &)
edm::InputTag triggerEvent_
TrackQuality
track quality
Definition: TrackBase.h:151
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< std::string > l1Names
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
const bool availableL1Configuration(int &errorCode, int &l1ConfCode) const
Definition: L1GtUtils.cc:1948
TH1I * h_tketa0[6]
TH1I * h_tketa3[6]
std::vector< HBHERecHit >::const_iterator const_iterator
int bunchCrossing() const
Definition: EventBase.h:65
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:62
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:640
const bool decision(const edm::Event &iEvent, const std::string &nameAlgoTechTrig, int &errorCode) const
Definition: L1GtUtils.cc:1208
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
edm::EDGetTokenT< reco::PFJetCollection > tok_pfjets_
double chargeIsolationCone(unsigned int trkIndex, std::vector< spr::propagatedTrackDirection > &trkDirs, double dR, int &nNearTRKs, bool debug=false)
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:622
edm::EDGetTokenT< l1extra::L1JetParticleCollection > tok_L1extTauJet_
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
TH1I * h_tketa5[6]
edm::EDGetTokenT< reco::TrackCollection > tok_genTrack_
std::vector< std::string > trgnames
TH1I * h_tketa1[6]
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
std::string theTrackQuality
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
double dR(double eta1, double eta2, double phi1, double phi2)
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes
TH1I * h_tketa4[6]
int iEvent
Definition: GenABIO.cc:230
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:646
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< double > pbin
TH1I * h_tkEta2[5]
TH1I * h_tkEta4[5]
static const bool useL1GtTriggerMenuLite(true)
edm::Service< TFileService > fs
double deltaR(double eta1, double eta2, double phi1, double phi2)
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
std::vector< bool > * t_l1bits
std::vector< double > vec1
Definition: HCALResponse.h:15
T sqrt(T t)
Definition: SSEVec.h:18
double pt() const
track transverse momentum
Definition: TrackBase.h:616
std::map< std::pair< unsigned int, std::string >, int > l1AlgoMap
TH1I * h_tketa2[6]
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
Jets made from MC generator particles.
Definition: GenJet.h:24
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)
std::vector< std::string > HLTNames
edm::EDGetTokenT< l1extra::L1JetParticleCollection > tok_L1extFwdJet_
bool isValid() const
Definition: HandleBase.h:75
#define M_PI
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:634
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
double t_EventWeight
double dEta(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:125
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
L1GtUtils m_l1GtUtils
TH1I * h_tkEta3[5]
TProfile * h_RecHit_iEta
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
virtual void beginJob()
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:56
T const * product() const
Definition: ESHandle.h:86
TH1I * h_tkEta5[5]
TH1I * h_tkEta1[5]
edm::EDGetTokenT< GenEventInfoProduct > tok_ew_
edm::EventID id() const
Definition: EventBase.h:59
spr::trackSelectionParameters selectionParameters
int iErrorCode
void getL1GtRunCache(const edm::Run &, const edm::EventSetup &, const bool, const bool)
get all the run-constant quantities for L1 trigger and cache them
Definition: L1GtUtils.cc:319
reco::TrackBase::TrackQuality minQuality
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
const AlgorithmMap & gtAlgorithmMap() const
get / set the algorithm map (by name)
edm::InputTag theTriggerResultsLabel
edm::EDGetTokenT< reco::BeamSpot > tok_bs_
tuple cout
Definition: gather_cfg.py:145
edm::EDGetTokenT< trigger::TriggerEvent > tok_trigEvt
virtual double eta() const final
momentum pseudorapidity
double dPhi(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const L1GtTriggerMenu * ptrL1TriggerMenuEventSetup(int &errorCode)
return a pointer to the L1 trigger menu from event setup
Definition: L1GtUtils.cc:1883
std::vector< vec1 > vec2
Definition: HCALResponse.h:16
TH1F * h_jetpt[4]
tuple pfJets
Definition: pfJets_cff.py:8
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
virtual void endJob()
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:628
static const bool useL1EventSetup(true)
Definition: Run.h:43
std::vector< std::string > trigNames
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 useRaw=false, bool debug=false)
edm::EDGetTokenT< reco::VertexCollection > tok_recVtx_
virtual double pt() const final
transverse momentum
IsoTrackCalib(const edm::ParameterSet &)