CMS 3D CMS Logo

IsoTrig.cc
Go to the documentation of this file.
1 // -*- C++ -*-//
2 // Package: IsoTrig
3 // Class: IsoTrig
4 //
12 //
13 // Original Author: Ruchi Gupta
14 // Created: Fri May 25 12:02:48 CDT 2012
15 // $Id$
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // Root objects
23 #include "TROOT.h"
24 #include "TH1.h"
25 #include "TH2.h"
26 #include "TSystem.h"
27 #include "TFile.h"
28 #include "TProfile.h"
29 #include "TDirectory.h"
30 #include "TTree.h"
31 #include "TMath.h"
32 
33 // user include files
39 
41 
53 //Tracks
55 // Vertices
59 //Triggers
65 
76 
84 
88 
91 
94 
96 
97 class IsoTrig : public edm::one::EDAnalyzer<edm::one::WatchRuns,edm::one::SharedResources> {
98 
99 public:
100  explicit IsoTrig(const edm::ParameterSet&);
101  ~IsoTrig() override;
102 
103  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
104 
105 private:
106 
107  void analyze(const edm::Event&, const edm::EventSetup&) override;
108  void beginJob() override ;
109  void endJob() override ;
110  void beginRun(edm::Run const&, edm::EventSetup const&) override;
111  void endRun(edm::Run const&, edm::EventSetup const&) override { }
112 
113  void clearMipCutTreeVectors();
116  math::XYZTLorentzVector &Trkcand,
117  std::vector<double> &PixMaxP, double &TrkMaxP, bool &selTk);
119  math::XYZTLorentzVector &Trkcand,
120  double &EmipNFcand, double &EmipTrkcand,
121  double &mindR, double &mindP1,
122  std::vector<bool> &Flags, double hCone);
124  void studyTiming(const edm::Event& theEvent);
128  std::vector<reco::TrackCollection::const_iterator>&);
130  std::vector<reco::TrackCollection::const_iterator>&);
131  void chgIsolation(double& etaTriggered, double& phiTriggered,
132  edm::Handle<reco::TrackCollection>& trkCollection,
133  const edm::Event& theEvent);
135  void fillHist(int, math::XYZTLorentzVector&);
137  void fillCuts(int, double, double, double, math::XYZTLorentzVector&, int, bool);
138  void fillEnergy(int, int, double, double, math::XYZTLorentzVector&);
145  std::pair<double,double> etaPhiTrigger();
146  std::pair<double,double> GetEtaPhiAtEcal(double etaIP, double phiIP,
147  double pT, int charge, double vtxZ);
148  double getDistInCM(double eta1,double phi1, double eta2,double phi2);
149 
150  // ----------member data ---------------------------
152  const std::vector<std::string> trigNames_;
154  const std::vector<edm::InputTag> pixelTracksSources_;
157  const int verbosity_;
158  const std::vector<double> pixelIsolationConeSizeAtEC_;
163  double rEB_, zEE_, bfVal_;
167  const double cutCharge_, cutNeutral_;
168  const int minRunNo_, maxRunNo_;
186  std::vector<edm::EDGetTokenT<reco::TrackCollection> > tok_pixtks_;
187 
188  std::vector<reco::TrackRef> pixelTrackRefsHB_, pixelTrackRefsHE_;
197 
198  std::map<unsigned int, unsigned int> trigList_;
199  std::map<unsigned int, const std::pair<int, int>> trigPreList_;
200  bool changed_;
201  double pLimits_[6];
204  std::vector<double> *t_timeL2Prod;
205  std::vector<int> *t_nPixCand;
206  std::vector<int> *t_nPixSeed;
207  std::vector<int> *t_nGoodTk;
208 
209  std::vector<double> *t_TrkhCone;
210  std::vector<double> *t_TrkP;
211  std::vector<bool> *t_TrkselTkFlag;
212  std::vector<bool> *t_TrkqltyFlag;
213  std::vector<bool> *t_TrkMissFlag;
214  std::vector<bool> *t_TrkPVFlag;
215  std::vector<bool> *t_TrkNuIsolFlag;
216 
217  std::vector<double> *t_PixcandP;
218  std::vector<double> *t_PixcandPt;
219  std::vector<double> *t_PixcandEta;
220  std::vector<double> *t_PixcandPhi;
221  std::vector<std::vector<double> > *t_PixcandMaxP;
222  std::vector<double> *t_PixTrkcandP;
223  std::vector<double> *t_PixTrkcandPt;
224  std::vector<double> *t_PixTrkcandEta;
225  std::vector<double> *t_PixTrkcandPhi;
226  std::vector<double> *t_PixTrkcandMaxP;
227  std::vector<bool> *t_PixTrkcandselTk;
228 
229  std::vector<double> *t_NFcandP;
230  std::vector<double> *t_NFcandPt;
231  std::vector<double> *t_NFcandEta;
232  std::vector<double> *t_NFcandPhi;
233  std::vector<double> *t_NFcandEmip;
234  std::vector<double> *t_NFTrkcandP;
235  std::vector<double> *t_NFTrkcandPt;
236  std::vector<double> *t_NFTrkcandEta;
237  std::vector<double> *t_NFTrkcandPhi;
238  std::vector<double> *t_NFTrkcandEmip;
239  std::vector<double> *t_NFTrkMinDR;
240  std::vector<double> *t_NFTrkMinDP1;
241  std::vector<bool> *t_NFTrkselTkFlag;
242  std::vector<bool> *t_NFTrkqltyFlag;
243  std::vector<bool> *t_NFTrkMissFlag;
244  std::vector<bool> *t_NFTrkPVFlag;
245  std::vector<bool> *t_NFTrkPropFlag;
246  std::vector<bool> *t_NFTrkChgIsoFlag;
247  std::vector<bool> *t_NFTrkNeuIsoFlag;
248  std::vector<bool> *t_NFTrkMipFlag;
249  std::vector<double> *t_ECone;
250 
251  TH1D *h_EnIn, *h_EnOut;
253  TH1I *h_nHLT, *h_HLT, *h_PreL1, *h_PreHLT;
256  TH1D *h_p[20], *h_pt[20], *h_eta[20], *h_phi[20];
257  TH1D *h_dEtaL1[2], *h_dPhiL1[2], *h_dRL1[2];
258  TH1D *h_dEta[9], *h_dPhi[9], *h_dPt[9], *h_dP[9];
259  TH1D *h_dinvPt[9], *h_mindR[9], *h_eMip[2];
260  TH1D *h_eMaxNearP[2], *h_eNeutIso[2];
261  TH1D *h_etaCalibTracks[5][2][2],*h_etaMipTracks[5][2][2];
262  TH1D *h_eHcal[5][6][48], *h_eCalo[5][6][48];
264  std::vector<math::XYZTLorentzVector> vec_[3];
265 
266 };
267 
269  hltPrescaleProvider_(iConfig, consumesCollector(), *this),
270  trigNames_(iConfig.getUntrackedParameter<std::vector<std::string> >("Triggers")),
271  pixCandTag_(iConfig.getUntrackedParameter<edm::InputTag> ("pixCandTag")),
272  l1CandTag_(iConfig.getUntrackedParameter<edm::InputTag> ("l1CandTag")),
273  l2CandTag_(iConfig.getUntrackedParameter<edm::InputTag> ("l2CandTag")),
274  pixelTracksSources_(iConfig.getUntrackedParameter<std::vector<edm::InputTag> >("pixelTracksSources")),
275  doL2L3_(iConfig.getUntrackedParameter<bool>("doL2L3",true)),
276  doTiming_(iConfig.getUntrackedParameter<bool>("doTimingTree",true)),
277  doMipCutTree_(iConfig.getUntrackedParameter<bool>("doMipCutTree",true)),
278  doTrkResTree_(iConfig.getUntrackedParameter<bool>("doTrkResTree",true)),
279  doChgIsolTree_(iConfig.getUntrackedParameter<bool>("doChgIsolTree",true)),
280  doStudyIsol_(iConfig.getUntrackedParameter<bool>("doStudyIsol",true)),
281  verbosity_(iConfig.getUntrackedParameter<int>("verbosity",0)),
282  pixelIsolationConeSizeAtEC_(iConfig.getUntrackedParameter<std::vector<double> >("pixelIsolationConeSizeAtEC")),
283  minPTrackValue_(iConfig.getUntrackedParameter<double>("minPTrackValue")),
284  vtxCutSeed_(iConfig.getUntrackedParameter<double>("vertexCutSeed")),
285  vtxCutIsol_(iConfig.getUntrackedParameter<double>("vertexCutIsol")),
286  tauUnbiasCone_(iConfig.getUntrackedParameter<double>("tauUnbiasCone")),
287  prelimCone_(iConfig.getUntrackedParameter<double>("prelimCone")),
288  theTrackQuality_(iConfig.getUntrackedParameter<std::string>("trackQuality","highPurity")),
289  processName_(iConfig.getUntrackedParameter<std::string>("processName","HLT")),
290  dr_L1_(iConfig.getUntrackedParameter<double>("isolationL1",1.0)),
291  a_coneR_(iConfig.getUntrackedParameter<double>("coneRadius",34.98)),
293  a_mipR_(iConfig.getUntrackedParameter<double>("coneRadiusMIP",14.0)),
294  a_neutR1_(iConfig.getUntrackedParameter<double>("coneRadiusNeut1",21.0)),
295  a_neutR2_(iConfig.getUntrackedParameter<double>("coneRadiusNeut2",29.0)),
296  cutMip_(iConfig.getUntrackedParameter<double>("cutMIP",1.0)),
297  cutCharge_(iConfig.getUntrackedParameter<double>("chargeIsolation",2.0)),
298  cutNeutral_(iConfig.getUntrackedParameter<double>("neutralIsolation",2.0)),
299  minRunNo_(iConfig.getUntrackedParameter<int>("minRun")),
300  maxRunNo_(iConfig.getUntrackedParameter<int>("maxRun")),
301  changed_(false),
317 
318  usesResource(TFileService::kSharedResource);
319 
320  //now do whatever initialization is needed
322  selectionParameters_.minPt = iConfig.getUntrackedParameter<double>("minTrackPt", 10.0);
323  selectionParameters_.minQuality = trackQuality_;
324  selectionParameters_.maxDxyPV = iConfig.getUntrackedParameter<double>("maxDxyPV", 0.2);
325  selectionParameters_.maxDzPV = iConfig.getUntrackedParameter<double>("maxDzPV", 5.0);
326  selectionParameters_.maxChi2 = iConfig.getUntrackedParameter<double>("maxChi2", 5.0);
327  selectionParameters_.maxDpOverP = iConfig.getUntrackedParameter<double>("maxDpOverP", 0.1);
328  selectionParameters_.minOuterHit = iConfig.getUntrackedParameter<int>("minOuterHit", 4);
329  selectionParameters_.minLayerCrossed = iConfig.getUntrackedParameter<int>("minLayerCrossed", 8);
330  selectionParameters_.maxInMiss = iConfig.getUntrackedParameter<int>("maxInMiss", 0);
331  selectionParameters_.maxOutMiss = iConfig.getUntrackedParameter<int>("maxOutMiss", 0);
332 
333  // define tokens for access
334  tok_lumi_ = consumes<LumiDetails, edm::InLumi>(edm::InputTag("lumiProducer"));
335  edm::InputTag triggerEvent_ ("hltTriggerSummaryAOD","",processName_);
336  tok_trigEvt_ = consumes<trigger::TriggerEvent>(triggerEvent_);
337  edm::InputTag theTriggerResultsLabel ("TriggerResults","",processName_);
338  tok_trigRes_ = consumes<edm::TriggerResults>(theTriggerResultsLabel);
339  tok_genTrack_ = consumes<reco::TrackCollection>(edm::InputTag("generalTracks"));
340  tok_recVtx_ = consumes<reco::VertexCollection>(edm::InputTag("offlinePrimaryVertices"));
341  tok_bs_ = consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"));
342  tok_EB_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit","EcalRecHitsEB"));
343  tok_EE_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit","EcalRecHitsEE"));
344  tok_hbhe_ = consumes<HBHERecHitCollection>(edm::InputTag("hbhereco"));
345  tok_pixtk_ = consumes<reco::IsolatedPixelTrackCandidateCollection>(pixCandTag_);
346  tok_l1cand_ = consumes<trigger::TriggerFilterObjectWithRefs>(l1CandTag_);
347  tok_l2cand_ = consumes<reco::IsolatedPixelTrackCandidateCollection>(l2CandTag_);
348  if (doTiming_) {
349  tok_verthb_ = consumes<reco::VertexCollection>(edm::InputTag("hltHITPixelVerticesHB"));
350  tok_verthe_ = consumes<reco::VertexCollection>(edm::InputTag("hltHITPixelVerticesHB"));
351  tok_hlt_ = consumes<trigger::TriggerFilterObjectWithRefs>(edm::InputTag("hltL1sL1SingleJet68"));
352  tok_SeedingLayerHB_ = consumes<SeedingLayerSetsHits>(edm::InputTag("hltPixelLayerTripletsHITHB"));
353  tok_SeedingLayerHE_ = consumes<SeedingLayerSetsHits>(edm::InputTag("hltPixelLayerTripletsHITHE"));
354  tok_SiPixelRecHits_ = consumes<SiPixelRecHitCollection>(edm::InputTag("hltSiPixelRecHits"));
355  }
356  if(doChgIsolTree_) {
357  for (unsigned int k=0; k<pixelTracksSources_.size(); ++k) {
358  // edm::InputTag pix (pixelTracksSources_[k],"",processName_);
359  // tok_pixtks_.push_back(consumes<reco::TrackCollection>(pix));
360  tok_pixtks_.push_back(consumes<reco::TrackCollection>(pixelTracksSources_[k]));
361  }
362  }
363  if (verbosity_>=0) {
364  edm::LogVerbatim("IsoTrack") <<"Parameters read from config file \n"
365  <<"\t minPt " << selectionParameters_.minPt
366  <<"\t theTrackQuality " << theTrackQuality_
367  <<"\t minQuality " << selectionParameters_.minQuality
368  <<"\t maxDxyPV " <<selectionParameters_.maxDxyPV
369  <<"\t maxDzPV " <<selectionParameters_.maxDzPV
370  <<"\t maxChi2 " <<selectionParameters_.maxChi2
371  <<"\t maxDpOverP "<<selectionParameters_.maxDpOverP
372  <<"\t minOuterHit "<<selectionParameters_.minOuterHit
373  <<"\t minLayerCrossed "<<selectionParameters_.minLayerCrossed
374  <<"\t maxInMiss " <<selectionParameters_.maxInMiss
375  <<"\t maxOutMiss "<<selectionParameters_.maxOutMiss
376  <<"\t a_coneR " << a_coneR_
377  <<"\t a_charIsoR " << a_charIsoR_
378  <<"\t a_neutIsoR " << a_neutIsoR_
379  <<"\t a_mipR " << a_mipR_
380  <<"\t a_neutR " << a_neutR1_ << ":" << a_neutR2_
381  <<"\t cuts (MIP " << cutMip_ << " : Charge "
382  << cutCharge_ <<" : Neutral "<<cutNeutral_ <<")";
383  edm::LogVerbatim("IsoTrack") <<"Charge Isolation parameters:"
384  <<"\t minPTrackValue " << minPTrackValue_
385  <<"\t vtxCutSeed " << vtxCutSeed_
386  <<"\t vtxCutIsol " << vtxCutIsol_
387  <<"\t tauUnbiasCone " << tauUnbiasCone_
388  <<"\t prelimCone " << prelimCone_
389  <<"\t pixelIsolationConeSizeAtEC";
390  for (unsigned int k=0; k<pixelIsolationConeSizeAtEC_.size(); ++k)
391  edm::LogVerbatim("IsoTrack") << "[" << k << "] "
393  }
394  double pl[] = {20,30,40,60,80,120};
395  for (int i=0; i<6; ++i) pLimits_[i] = pl[i];
396  rEB_ = 123.8;
397  zEE_ = 317.0;
398 }
399 
401  // do anything here that needs to be done at desctruction time
402  // (e.g. close files, deallocate resources etc.)
403  if (t_timeL2Prod) delete t_timeL2Prod;
404  if (t_nPixCand) delete t_nPixCand;
405  if (t_nPixSeed) delete t_nPixSeed;
406  if (t_nGoodTk) delete t_nGoodTk;
407  if (t_TrkhCone) delete t_TrkhCone;
408  if (t_TrkP) delete t_TrkP;
409  if (t_TrkselTkFlag) delete t_TrkselTkFlag;
410  if (t_TrkqltyFlag) delete t_TrkqltyFlag;
411  if (t_TrkMissFlag) delete t_TrkMissFlag;
412  if (t_TrkPVFlag) delete t_TrkPVFlag;
413  if (t_TrkNuIsolFlag) delete t_TrkNuIsolFlag;
414  if (t_PixcandP) delete t_PixcandP;
415  if (t_PixcandPt) delete t_PixcandPt;
416  if (t_PixcandEta) delete t_PixcandEta;
417  if (t_PixcandPhi) delete t_PixcandPhi;
418  if (t_PixcandMaxP) delete t_PixcandMaxP;
419  if (t_PixTrkcandP) delete t_PixTrkcandP;
420  if (t_PixTrkcandPt) delete t_PixTrkcandPt;
421  if (t_PixTrkcandEta) delete t_PixTrkcandEta;
422  if (t_PixTrkcandPhi) delete t_PixTrkcandPhi;
425  if (t_NFcandP) delete t_NFcandP;
426  if (t_NFcandPt) delete t_NFcandPt;
427  if (t_NFcandEta) delete t_NFcandEta;
428  if (t_NFcandPhi) delete t_NFcandPhi;
429  if (t_NFcandEmip) delete t_NFcandEmip;
430  if (t_NFTrkcandP) delete t_NFTrkcandP;
431  if (t_NFTrkcandPt) delete t_NFTrkcandPt;
432  if (t_NFTrkcandEta) delete t_NFTrkcandEta;
433  if (t_NFTrkcandPhi) delete t_NFTrkcandPhi;
434  if (t_NFTrkcandEmip) delete t_NFTrkcandEmip;
435  if (t_NFTrkMinDR) delete t_NFTrkMinDR;
436  if (t_NFTrkMinDP1) delete t_NFTrkMinDP1;
438  if (t_NFTrkqltyFlag) delete t_NFTrkqltyFlag;
439  if (t_NFTrkMissFlag) delete t_NFTrkMissFlag;
440  if (t_NFTrkPVFlag) delete t_NFTrkPVFlag;
441  if (t_NFTrkPropFlag) delete t_NFTrkPropFlag;
444  if (t_NFTrkMipFlag) delete t_NFTrkMipFlag;
445  if (t_ECone) delete t_ECone;
446 }
447 
449  std::vector<std::string> triggers = {"HLT_IsoTrackHB"};
450  std::vector<edm::InputTag> tags = {edm::InputTag("hltHITPixelTracksHB"),
451  edm::InputTag("hltHITPixelTracksHE")};
452  std::vector<double> cones = {35.0, 40.0, 45.0, 50.0, 55.0, 60.0, 63.9, 70.0};
454  desc.addUntracked<std::vector<std::string> >("Triggers", triggers);
455  desc.addUntracked<edm::InputTag>("pixCandTag", edm::InputTag(" "));
456  desc.addUntracked<edm::InputTag>("l1CandTag", edm::InputTag("hltL1sV0SingleJet60"));
457  desc.addUntracked<edm::InputTag>("l2CandTag", edm::InputTag("isolEcalPixelTrackProd"));
458  desc.addUntracked<bool>("doL2L3", false);
459  desc.addUntracked<bool>("doTimingTree", false);
460  desc.addUntracked<bool>("doMipCutTree", false);
461  desc.addUntracked<bool>("doTrkResTree", true);
462  desc.addUntracked<bool>("doChgIsolTree", false);
463  desc.addUntracked<bool>("doStudyIsol", false);
464  desc.addUntracked<int>("verbosity", 0);
465  desc.addUntracked<std::string>("processName", "HLT");
466  desc.addUntracked<std::string>("trackQuality", "highPurity");
467  desc.addUntracked<double>("minTrackPt", 10.0);
468  desc.addUntracked<double>("maxDxyPV", 0.02);
469  desc.addUntracked<double>("maxDzPV", 0.02);
470  desc.addUntracked<double>("maxChi2", 5.0);
471  desc.addUntracked<double>("maxDpOverP", 0.1);
472  desc.addUntracked<int>("minOuterHit", 4);
473  desc.addUntracked<int>("minLayerCrossed", 8);
474  desc.addUntracked<int>("maxInMiss", 0);
475  desc.addUntracked<int>("maxOutMiss", 0);
476  desc.addUntracked<double>("isolationL1", 1.0);
477  desc.addUntracked<double>("coneRadius", 34.98);
478  desc.addUntracked<double>("coneRadiusMIP", 14.0);
479  desc.addUntracked<double>("coneRadiusNeut1", 21.0);
480  desc.addUntracked<double>("coneRadiusNeut2", 29.0);
481  desc.addUntracked<double>("cutMIP", 1.0);
482  desc.addUntracked<double>("chargeIsolation", 2.0);
483  desc.addUntracked<double>("neutralIsolation", 2.0);
484  desc.addUntracked<int>("minRun", 190456);
485  desc.addUntracked<int>("maxRun", 203002);
486  desc.addUntracked<std::vector<edm::InputTag> >("pixelTracksSources", tags);
487  desc.addUntracked<std::vector<double> >("pixelIsolationConeSizeAtEC", cones);
488  desc.addUntracked<double>("minPTrackValue", 0.0);
489  desc.addUntracked<double>("vertexCutSeed", 101.0);
490  desc.addUntracked<double>("vertexCutIsol", 101.0);
491  desc.addUntracked<double>("tauUnbiasCone", 1.2);
492  desc.addUntracked<double>("prelimCone", 1.0);
493  descriptions.add("isoTrigHB",desc);
494 }
495 
496 void IsoTrig::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
497 
498  if (verbosity_%10 > 0)
499  edm::LogVerbatim("IsoTrack") << "Event starts====================================";
500 
501  int RunNo = iEvent.id().run();
502 
504 
505  iSetup.get<IdealMagneticFieldRecord>().get(bFieldH_);
506  iSetup.get<CaloGeometryRecord>().get(pG_);
507  const MagneticField *bField = bFieldH_.product();
508  GlobalVector BField=bField->inTesla(GlobalPoint(0,0,0));
509  bfVal_ = BField.mag();
510 
511  trigger::TriggerEvent triggerEvent;
512  edm::Handle<trigger::TriggerEvent> triggerEventHandle;
513  iEvent.getByToken(tok_trigEvt_, triggerEventHandle);
514  if (!triggerEventHandle.isValid()) {
515  edm::LogWarning("IsoTrack") << "Error! Can't get the product hltTriggerSummaryAOD";
516 
517  } else {
518  triggerEvent = *(triggerEventHandle.product());
519  }
520  const trigger::TriggerObjectCollection& TOC(triggerEvent.getObjects());
523  iEvent.getByToken(tok_trigRes_, triggerResults);
524 
526  iEvent.getByToken(tok_genTrack_, trkCollection);
527 
530 
531  iEvent.getByToken(tok_hbhe_, hbhe_);
532 
533  iEvent.getByToken(tok_recVtx_, recVtxs_);
534  iEvent.getByToken(tok_bs_, beamSpotH_);
535  if (!recVtxs_->empty() && !((*recVtxs_)[0].isFake())) {
536  leadPV_ = math::XYZPoint( (*recVtxs_)[0].x(),(*recVtxs_)[0].y(), (*recVtxs_)[0].z() );
537  } else if (beamSpotH_.isValid()) {
539  }
540 
541  if ((verbosity_/100)%10>0) {
542  edm::LogVerbatim("IsoTrack") << "Primary Vertex " << leadPV_;
543  if (beamSpotH_.isValid())
544  edm::LogVerbatim("IsoTrack") << "Beam Spot " << beamSpotH_->position();
545  }
546  pixelTrackRefsHE_.clear(); pixelTrackRefsHB_.clear();
547  for (unsigned int iPix=0; iPix<pixelTracksSources_.size(); iPix++) {
549  iEvent.getByToken(tok_pixtks_[iPix],iPixCol);
550  if(iPixCol.isValid()){
551  for (reco::TrackCollection::const_iterator pit=iPixCol->begin(); pit!=iPixCol->end(); pit++) {
552  if(iPix==0)
553  pixelTrackRefsHB_.push_back(reco::TrackRef(iPixCol,pit-iPixCol->begin()));
554  pixelTrackRefsHE_.push_back(reco::TrackRef(iPixCol,pit-iPixCol->begin()));
555  }
556  }
557  }
558  if (doTiming_) getGoodTracks(iEvent, trkCollection);
559 
560  for (unsigned int ifilter=0; ifilter<triggerEvent.sizeFilters();
561  ++ifilter) {
562  std::string FilterNames[7] = {"hltL1sL1SingleJet68", "hltIsolPixelTrackL2FilterHE", "ecalIsolPixelTrackFilterHE", "hltIsolPixelTrackL3FilterHE",
563  "hltIsolPixelTrackL2FilterHB", "ecalIsolPixelTrackFilterHB", "hltIsolPixelTrackL3FilterHB"};
564  std::string label = triggerEvent.filterTag(ifilter).label();
565  for(int i=0; i<7; i++) {
566  if(label==FilterNames[i]) h_Filters->Fill(i);
567  }
568  }
569  edm::InputTag lumiProducer("LumiProducer", "", "RECO");
571  iEvent.getLuminosityBlock().getByToken(tok_lumi_, Lumid);
572  float mybxlumi=-1;
573  if (Lumid.isValid())
574  mybxlumi=Lumid->lumiValue(LumiDetails::kOCC1,iEvent.bunchCrossing())*6.37;
575  if (verbosity_%10 > 0)
576  edm::LogVerbatim("IsoTrack") << "RunNo " << RunNo << " EvtNo "
577  << iEvent.id().event() << " Lumi "
578  << iEvent.luminosityBlock() << " Bunch "
579  << iEvent.bunchCrossing() << " mybxlumi "
580  << mybxlumi;
581  if (!triggerResults.isValid()) {
582  edm::LogWarning("IsoTrack") << "Error! Can't get the product triggerResults";
583  // boost::shared_ptr<cms::Exception> const & error = triggerResults.whyFailed();
584  // edm::LogWarning(error->category()) << error->what();
585  } else {
586  std::vector<std::string> modules;
587  h_nHLT->Fill(triggerResults->size());
588  const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults);
589 
590  const std::vector<std::string> & triggerNames_ = triggerNames.triggerNames();
591  if (verbosity_%10 > 1)
592  edm::LogVerbatim("IsoTrack") << "number of HLTs " << triggerNames_.size();
593  int hlt(-1), preL1(-1), preHLT(-1), prescale(-1);
594  for (unsigned int i=0; i<triggerResults->size(); i++) {
595  unsigned int triggerindx = hltConfig.triggerIndex(triggerNames_[i]);
596  const std::vector<std::string>& moduleLabels(hltConfig.moduleLabels(triggerindx));
597 
598  for (unsigned int in=0; in<trigNames_.size(); ++in) {
599  // if (triggerNames_[i].find(trigNames_[in].c_str())!=std::string::npos || triggerNames_[i]==" ") {
600  if (triggerNames_[i].find(trigNames_[in])!=std::string::npos) {
601  if (verbosity_%10 > 0)
602  edm::LogVerbatim("IsoTrack") << "trigger that i want "
603  << triggerNames_[i] << " accept "
604  << triggerResults->accept(i);
605  hlt = triggerResults->accept(i);
606  h_HLT -> Fill(hlt);
607  // if (hlt>0 || triggerNames_[i]==" ") {
608  if (hlt>0) {
610  iEvent.getByToken(tok_pixtk_,Pixcands);
612  iEvent.getByToken(tok_l1cand_, L1cands);
613 
614  const std::pair<int,int> prescales(hltPrescaleProvider_.prescaleValues(iEvent,iSetup,triggerNames_[i]));
615  preL1 = prescales.first;
616  preHLT = prescales.second;
617  prescale = preL1*preHLT;
618  if (verbosity_%10 > 0)
619  edm::LogVerbatim("IsoTrack") << triggerNames_[i] << " accept "
620  << hlt << " preL1 " << preL1
621  << " preHLT " << preHLT;
622  for (int iv=0; iv<3; ++iv) vec_[iv].clear();
623  if (trigList_.find(RunNo) != trigList_.end() ) {
624  trigList_[RunNo] += 1;
625  } else {
626  trigList_.insert(std::pair<unsigned int, unsigned int>(RunNo,1));
627  trigPreList_.insert(std::pair<unsigned int, std::pair<int, int>>(RunNo,prescales));
628  }
629  //loop over all trigger filters in event (i.e. filters passed)
630  for (unsigned int ifilter=0; ifilter<triggerEvent.sizeFilters();
631  ++ifilter) {
632  std::vector<int> Keys;
633  std::string label = triggerEvent.filterTag(ifilter).label();
634  //loop over keys to objects passing this filter
635  for (unsigned int imodule=0; imodule<moduleLabels.size();
636  imodule++) {
637  if (label.find(moduleLabels[imodule]) != std::string::npos) {
638  if (verbosity_%10 > 0)
639  edm::LogVerbatim("IsoTrack") << "FILTERNAME " << label;
640  for (unsigned int ifiltrKey=0; ifiltrKey<triggerEvent.filterKeys(ifilter).size(); ++ifiltrKey) {
641  Keys.push_back(triggerEvent.filterKeys(ifilter)[ifiltrKey]);
642  const trigger::TriggerObject& TO(TOC[Keys[ifiltrKey]]);
643  math::XYZTLorentzVector v4(TO.px(), TO.py(), TO.pz(), TO.energy());
644  if (label.find("L2Filter") != std::string::npos) {
645  vec_[1].push_back(v4);
646  } else if (label.find("L3Filter") != std::string::npos) {
647  vec_[2].push_back(v4);
648  } else {
649  vec_[0].push_back(v4);
650  h_L1ObjEnergy->Fill(TO.energy());
651  }
652  if (verbosity_%10 > 0)
653  edm::LogVerbatim("IsoTrack") << "key " << ifiltrKey
654  << " : pt " << TO.pt()
655  << " eta " << TO.eta()
656  << " phi " << TO.phi()
657  << " mass " << TO.mass()
658  << " Id " << TO.id();
659  }
660  }
661  }
662  }
663  std::vector<reco::TrackCollection::const_iterator> goodTks;
664  if (doL2L3_) {
665  h_nL3Objs -> Fill(vec_[2].size());
666  studyTrigger(trkCollection, goodTks);
667  } else {
668  if (trkCollection.isValid()) {
669  reco::TrackCollection::const_iterator trkItr;
670  for (trkItr=trkCollection->begin();
671  trkItr!=trkCollection->end(); trkItr++)
672  goodTks.push_back(trkItr);
673  }
674  }
675  // Now study isolation etc
676  if (doStudyIsol_) studyIsolation(trkCollection, goodTks);
677  if (doTrkResTree_) StudyTrkEbyP(trkCollection);
678 
679  std::pair<double,double> etaphi = etaPhiTrigger();
681  iEvent.getByToken(tok_l2cand_,L2cands);
682  if (!L2cands.isValid()) {
683  if (verbosity_%10 > 0)
684  edm::LogVerbatim("IsoTrack") << " trigCand is not valid ";
685  } else {
686  if(doMipCutTree_) studyMipCut(trkCollection, L2cands);
687  }
688  if (!pixelTracksSources_.empty())
689  if(doChgIsolTree_ && !pixelTrackRefsHE_.empty()) chgIsolation(etaphi.first, etaphi.second, trkCollection, iEvent);
690  }
691  break;
692  }
693  }
694  }
695  h_PreL1 -> Fill(preL1);
696  h_PreHLT -> Fill(preHLT);
697  h_Pre -> Fill(prescale);
698  h_PreL1wt -> Fill(preL1, mybxlumi);
699  h_PreHLTwt -> Fill(preHLT, mybxlumi);
700 
701  // check if trigger names in (new) config
702  // edm::LogVerbatim("IsoTrack") << "changed " << changed_;
703  if (changed_) {
704  changed_ = false;
705  if ((verbosity_/10)%10 > 1) {
706  edm::LogVerbatim("IsoTrack") << "New trigger menu found !!!";
707  const unsigned int n(hltConfig.size());
708  for (unsigned itrig=0; itrig<triggerNames_.size(); itrig++) {
709  unsigned int triggerindx = hltConfig.triggerIndex(triggerNames_[itrig]);
710  if (triggerindx >= n)
711  edm::LogVerbatim("IsoTrack") << triggerNames_[itrig] << " "
712  << triggerindx << " does not exist in"
713  << " the current menu";
714  else
715  edm::LogVerbatim("IsoTrack") << triggerNames_[itrig] << " "
716  << triggerindx << " exists";
717  }
718  }
719  }
720  }
721  if (doTiming_) studyTiming(iEvent);
722 }
723 
725  t_PixcandP ->clear();
726  t_PixcandPt ->clear();
727  t_PixcandEta ->clear();
728  t_PixcandPhi ->clear();
729  for(unsigned int i=0; i< t_PixcandMaxP->size(); i++)
730  t_PixcandMaxP[i].clear();
731  t_PixcandMaxP ->clear();
732  t_PixTrkcandP ->clear();
733  t_PixTrkcandPt ->clear();
734  t_PixTrkcandEta ->clear();
735  t_PixTrkcandPhi ->clear();
736  t_PixTrkcandMaxP ->clear();
737  t_PixTrkcandselTk ->clear();
738 }
739 
741  t_NFcandP ->clear();
742  t_NFcandPt ->clear();
743  t_NFcandEta ->clear();
744  t_NFcandPhi ->clear();
745  t_NFcandEmip ->clear();
746  t_NFTrkcandP ->clear();
747  t_NFTrkcandPt ->clear();
748  t_NFTrkcandEta ->clear();
749  t_NFTrkcandPhi ->clear();
750  t_NFTrkcandEmip ->clear();
751  t_NFTrkMinDR ->clear();
752  t_NFTrkMinDP1 ->clear();
753  t_NFTrkselTkFlag ->clear();
754  t_NFTrkqltyFlag ->clear();
755  t_NFTrkMissFlag ->clear();
756  t_NFTrkPVFlag ->clear();
757  t_NFTrkPropFlag ->clear();
758  t_NFTrkChgIsoFlag->clear();
759  t_NFTrkNeuIsoFlag->clear();
760  t_NFTrkMipFlag ->clear();
761  t_ECone ->clear();
762 }
763 
765  math::XYZTLorentzVector &Trkcand,
766  std::vector<double> &PixMaxP,
767  double &TrkMaxP, bool &selTk) {
768  t_PixcandP ->push_back(Pixcand.r());
769  t_PixcandPt ->push_back(Pixcand.pt());
770  t_PixcandEta ->push_back(Pixcand.eta());
771  t_PixcandPhi ->push_back(Pixcand.phi());
772  t_PixcandMaxP ->push_back(PixMaxP);
773  t_PixTrkcandP ->push_back(Trkcand.r());
774  t_PixTrkcandPt ->push_back(Trkcand.pt());
775  t_PixTrkcandEta ->push_back(Trkcand.eta());
776  t_PixTrkcandPhi ->push_back(Trkcand.phi());
777  t_PixTrkcandMaxP ->push_back(TrkMaxP);
778  t_PixTrkcandselTk ->push_back(selTk);
779 
780 }
781 
783  math::XYZTLorentzVector &Trkcand,
784  double &EmipNFcand, double &EmipTrkcand,
785  double &mindR, double &mindP1,
786  std::vector<bool> &Flags, double hCone) {
787  t_NFcandP ->push_back(NFcand.r());
788  t_NFcandPt ->push_back(NFcand.pt());
789  t_NFcandEta ->push_back(NFcand.eta());
790  t_NFcandPhi ->push_back(NFcand.phi());
791  t_NFcandEmip ->push_back(EmipNFcand);
792  t_NFTrkcandP ->push_back(Trkcand.r());
793  t_NFTrkcandPt ->push_back(Trkcand.pt());
794  t_NFTrkcandEta ->push_back(Trkcand.eta());
795  t_NFTrkcandPhi ->push_back(Trkcand.phi());
796  t_NFTrkcandEmip ->push_back(EmipTrkcand);
797  t_NFTrkMinDR ->push_back(mindR);
798  t_NFTrkMinDP1 ->push_back(mindP1);
799  t_NFTrkselTkFlag ->push_back(Flags[0]);
800  t_NFTrkqltyFlag ->push_back(Flags[1]);
801  t_NFTrkMissFlag ->push_back(Flags[2]);
802  t_NFTrkPVFlag ->push_back(Flags[3]);
803  t_NFTrkPropFlag ->push_back(Flags[4]);
804  t_NFTrkChgIsoFlag->push_back(Flags[5]);
805  t_NFTrkNeuIsoFlag->push_back(Flags[6]);
806  t_NFTrkMipFlag ->push_back(Flags[7]);
807  t_ECone ->push_back(hCone);
808 }
809 
811  char hname[100], htit[100];
812  std::string levels[20] = {"L1", "L2", "L3",
813  "Reco", "RecoMatch", "RecoNoMatch",
814  "L2Match", "L2NoMatch", "L3Match", "L3NoMatch",
815  "HLTTrk", "HLTGoodTrk", "HLTIsoTrk", "HLTMip",
816  "HLTSelect", "nonHLTTrk", "nonHLTGoodTrk",
817  "nonHLTIsoTrk", "nonHLTMip", "nonHLTSelect"};
818  if (doTiming_) {
819  TimingTree_ = fs_->make<TTree>("TimingTree", "TimingTree");
820  t_timeL2Prod = new std::vector<double>();
821  t_nPixCand = new std::vector<int>();
822  t_nPixSeed = new std::vector<int>();
823  t_nGoodTk = new std::vector<int>();
824 
825  TimingTree_->Branch("t_timeL2Prod", "std::vector<double>", &t_timeL2Prod);
826  TimingTree_->Branch("t_nPixCand", "std::vector<int>", &t_nPixCand);
827  TimingTree_->Branch("t_nPixSeed", "std::vector<int>", &t_nPixSeed);
828  TimingTree_->Branch("t_nGoodTk", "std::vector<int>", &t_nGoodTk);
829  }
830  if (doTrkResTree_) {
831  TrkResTree_ = fs_->make<TTree>("TrkRestree", "TrkResTree");
832  t_TrkhCone = new std::vector<double>();
833  t_TrkP = new std::vector<double>();
834  t_TrkselTkFlag = new std::vector<bool>();
835  t_TrkqltyFlag = new std::vector<bool>();
836  t_TrkMissFlag = new std::vector<bool>();
837  t_TrkPVFlag = new std::vector<bool>();
838  t_TrkNuIsolFlag= new std::vector<bool>();
839 
840  TrkResTree_->Branch("t_TrkhCone", "std::vector<double>", &t_TrkhCone);
841  TrkResTree_->Branch("t_TrkP", "std::vector<double>", &t_TrkP);
842  TrkResTree_->Branch("t_TrkselTkFlag", "std::vector<bool>", &t_TrkselTkFlag);
843  TrkResTree_->Branch("t_TrkqltyFlag", "std::vector<bool>", &t_TrkqltyFlag);
844  TrkResTree_->Branch("t_TrkMissFlag", "std::vector<bool>", &t_TrkMissFlag);
845  TrkResTree_->Branch("t_TrkPVFlag", "std::vector<bool>", &t_TrkPVFlag);
846  TrkResTree_->Branch("t_TrkNuIsolFlag","std::vector<bool>", &t_TrkNuIsolFlag);
847  }
848  if (doChgIsolTree_) {
849  ChgIsolnTree_ = fs_->make<TTree>("ChgIsolnTree", "ChgIsolnTree");
850  t_PixcandP = new std::vector<double>();
851  t_PixcandPt = new std::vector<double>();
852  t_PixcandEta = new std::vector<double>();
853  t_PixcandPhi = new std::vector<double>();
854  t_PixcandMaxP = new std::vector<std::vector<double> >();
855  t_PixTrkcandP = new std::vector<double>();
856  t_PixTrkcandPt = new std::vector<double>();
857  t_PixTrkcandEta = new std::vector<double>();
858  t_PixTrkcandPhi = new std::vector<double>();
859  t_PixTrkcandMaxP = new std::vector<double>();
860  t_PixTrkcandselTk = new std::vector<bool>();
861 
862  ChgIsolnTree_->Branch("t_PixcandP", "std::vector<double>", &t_PixcandP);
863  ChgIsolnTree_->Branch("t_PixcandPt", "std::vector<double>", &t_PixcandPt);
864  ChgIsolnTree_->Branch("t_PixcandEta", "std::vector<double>", &t_PixcandEta);
865  ChgIsolnTree_->Branch("t_PixcandPhi", "std::vector<double>", &t_PixcandPhi);
866  ChgIsolnTree_->Branch("t_PixcandMaxP", "std::vector<std::vector<double> >", &t_PixcandMaxP);
867  ChgIsolnTree_->Branch("t_PixTrkcandP", "std::vector<double>", &t_PixTrkcandP);
868  ChgIsolnTree_->Branch("t_PixTrkcandPt", "std::vector<double>", &t_PixTrkcandPt );
869  ChgIsolnTree_->Branch("t_PixTrkcandEta", "std::vector<double>", &t_PixTrkcandEta );
870  ChgIsolnTree_->Branch("t_PixTrkcandPhi", "std::vector<double>", &t_PixTrkcandPhi );
871  ChgIsolnTree_->Branch("t_PixTrkcandMaxP", "std::vector<double>", &t_PixTrkcandMaxP);
872  ChgIsolnTree_->Branch("t_PixTrkcandselTk","std::vector<bool>", &t_PixTrkcandselTk);
873  }
874  if (doMipCutTree_) {
875  MipCutTree_ = fs_->make<TTree>("MipCutTree", "MipCutTree");
876  t_NFcandP = new std::vector<double>();
877  t_NFcandPt = new std::vector<double>();
878  t_NFcandEta = new std::vector<double>();
879  t_NFcandPhi = new std::vector<double>();
880  t_NFcandEmip = new std::vector<double>();
881  t_NFTrkcandP = new std::vector<double>();
882  t_NFTrkcandPt = new std::vector<double>();
883  t_NFTrkcandEta = new std::vector<double>();
884  t_NFTrkcandPhi = new std::vector<double>();
885  t_NFTrkcandEmip = new std::vector<double>();
886  t_NFTrkMinDR = new std::vector<double>();
887  t_NFTrkMinDP1 = new std::vector<double>();
888  t_NFTrkselTkFlag = new std::vector<bool>();
889  t_NFTrkqltyFlag = new std::vector<bool>();
890  t_NFTrkMissFlag = new std::vector<bool>();
891  t_NFTrkPVFlag = new std::vector<bool>();
892  t_NFTrkPropFlag = new std::vector<bool>();
893  t_NFTrkChgIsoFlag= new std::vector<bool>();
894  t_NFTrkNeuIsoFlag= new std::vector<bool>();
895  t_NFTrkMipFlag = new std::vector<bool>();
896  t_ECone = new std::vector<double>();
897 
898  MipCutTree_->Branch("t_NFcandP", "std::vector<double>", &t_NFcandP);
899  MipCutTree_->Branch("t_NFcandPt", "std::vector<double>", &t_NFcandPt);
900  MipCutTree_->Branch("t_NFcandEta", "std::vector<double>", &t_NFcandEta);
901  MipCutTree_->Branch("t_NFcandPhi", "std::vector<double>", &t_NFcandPhi);
902  MipCutTree_->Branch("t_NFcandEmip", "std::vector<double>", &t_NFcandEmip);
903  MipCutTree_->Branch("t_NFTrkcandP", "std::vector<double>", &t_NFTrkcandP);
904  MipCutTree_->Branch("t_NFTrkcandPt", "std::vector<double>", &t_NFTrkcandPt );
905  MipCutTree_->Branch("t_NFTrkcandEta", "std::vector<double>", &t_NFTrkcandEta );
906  MipCutTree_->Branch("t_NFTrkcandPhi", "std::vector<double>", &t_NFTrkcandPhi );
907  MipCutTree_->Branch("t_NFTrkcandEmip", "std::vector<double>", &t_NFTrkcandEmip);
908  MipCutTree_->Branch("t_NFTrkMinDR", "std::vector<double>", &t_NFTrkMinDR);
909  MipCutTree_->Branch("t_NFTrkMinDP1", "std::vector<double>", &t_NFTrkMinDP1);
910  MipCutTree_->Branch("t_NFTrkselTkFlag", "std::vector<bool>", &t_NFTrkselTkFlag);
911  MipCutTree_->Branch("t_NFTrkqltyFlag", "std::vector<bool>", &t_NFTrkqltyFlag);
912  MipCutTree_->Branch("t_NFTrkMissFlag", "std::vector<bool>", &t_NFTrkMissFlag);
913  MipCutTree_->Branch("t_NFTrkPVFlag", "std::vector<bool>", &t_NFTrkPVFlag);
914  MipCutTree_->Branch("t_NFTrkPropFlag", "std::vector<bool>", &t_NFTrkPropFlag);
915  MipCutTree_->Branch("t_NFTrkChgIsoFlag","std::vector<bool>", &t_NFTrkChgIsoFlag);
916  MipCutTree_->Branch("t_NFTrkNeuIsoFlag","std::vector<bool>", &t_NFTrkNeuIsoFlag);
917  MipCutTree_->Branch("t_NFTrkMipFlag", "std::vector<bool>", &t_NFTrkMipFlag);
918  MipCutTree_->Branch("t_ECone", "std::vector<double>", &t_ECone);
919  }
920  h_Filters = fs_->make<TH1I>("h_Filters", "Filter Accepts", 10, 0, 10);
921  std::string FilterNames[7] = {"hltL1sL1SingleJet68", "hltIsolPixelTrackL2FilterHE", "ecalIsolPixelTrackFilterHE", "hltIsolPixelTrackL3FilterHE",
922  "hltIsolPixelTrackL2FilterHB", "ecalIsolPixelTrackFilterHB", "hltIsolPixelTrackL3FilterHB"};
923  for(int i=0; i<7; i++) {
924  h_Filters->GetXaxis()->SetBinLabel(i+1, FilterNames[i].c_str());
925  }
926 
927  h_nHLT = fs_->make<TH1I>("h_nHLT" , "Size of trigger Names", 1000, 1, 1000);
928  h_HLT = fs_->make<TH1I>("h_HLT" , "HLT accept", 3, -1, 2);
929  h_PreL1 = fs_->make<TH1I>("h_PreL1", "L1 Prescale", 500, 0, 500);
930  h_PreHLT = fs_->make<TH1I>("h_PreHLT", "HLT Prescale", 50, 0, 50);
931  h_Pre = fs_->make<TH1I>("h_Pre", "Prescale", 3000, 0, 3000);
932 
933  h_PreL1wt = fs_->make<TH1D>("h_PreL1wt", "Weighted L1 Prescale", 500, 0, 500);
934  h_PreHLTwt = fs_->make<TH1D>("h_PreHLTwt", "Weighted HLT Prescale", 500, 0, 100);
935  h_L1ObjEnergy = fs_->make<TH1D>("h_L1ObjEnergy", "Energy of L1Object", 500, 0.0, 500.0);
936 
937  h_EnIn = fs_->make<TH1D>("h_EnInEcal", "EnergyIn Ecal", 200, 0.0, 20.0);
938  h_EnOut = fs_->make<TH1D>("h_EnOutEcal", "EnergyOut Ecal", 200, 0.0, 20.0);
939  h_MipEnMatch = fs_->make<TH2D>("h_MipEnMatch", "MipEn: HLT level vs Reco Level (Matched)", 200, 0.0, 20.0, 200, 0.0, 20.0);
940  h_MipEnNoMatch = fs_->make<TH2D>("h_MipEnNoMatch", "MipEn: HLT level vs Reco Level (No Match Found)", 200, 0.0, 20.0, 200, 0.0, 20.0);
941 
942  if (doL2L3_) {
943  h_nL3Objs = fs_->make<TH1I>("h_nL3Objs", "Number of L3 objects", 10, 0, 10);
944 
945  std::string pairs[9] = {"L2L3", "L2L3Match", "L2L3NoMatch", "L3Reco", "L3RecoMatch", "L3RecoNoMatch", "NewFilterReco", "NewFilterRecoMatch", "NewFilterRecoNoMatch"};
946  for (int ipair=0; ipair<9; ipair++) {
947  sprintf(hname, "h_dEta%s", pairs[ipair].c_str());
948  sprintf(htit, "#Delta#eta for %s", pairs[ipair].c_str());
949  h_dEta[ipair] = fs_->make<TH1D>(hname, htit, 200, -10.0, 10.0);
950  h_dEta[ipair]->GetXaxis()->SetTitle("d#eta");
951 
952  sprintf(hname, "h_dPhi%s", pairs[ipair].c_str());
953  sprintf(htit, "#Delta#phi for %s", pairs[ipair].c_str());
954  h_dPhi[ipair] = fs_->make<TH1D>(hname, htit, 140, -7.0, 7.0);
955  h_dPhi[ipair]->GetXaxis()->SetTitle("d#phi");
956 
957  sprintf(hname, "h_dPt%s", pairs[ipair].c_str());
958  sprintf(htit, "#Delta dp_{T} for %s objects", pairs[ipair].c_str());
959  h_dPt[ipair] = fs_->make<TH1D>(hname, htit, 400, -200.0, 200.0);
960  h_dPt[ipair]->GetXaxis()->SetTitle("dp_{T} (GeV)");
961 
962  sprintf(hname, "h_dP%s", pairs[ipair].c_str());
963  sprintf(htit, "#Delta p for %s objects", pairs[ipair].c_str());
964  h_dP[ipair] = fs_->make<TH1D>(hname, htit, 400, -200.0, 200.0);
965  h_dP[ipair]->GetXaxis()->SetTitle("dP (GeV)");
966 
967  sprintf(hname, "h_dinvPt%s", pairs[ipair].c_str());
968  sprintf(htit, "#Delta (1/p_{T}) for %s objects", pairs[ipair].c_str());
969  h_dinvPt[ipair] = fs_->make<TH1D>(hname, htit, 500, -0.4, 0.1);
970  h_dinvPt[ipair]->GetXaxis()->SetTitle("d(1/p_{T})");
971  sprintf(hname, "h_mindR%s", pairs[ipair].c_str());
972  sprintf(htit, "min(#Delta R) for %s objects", pairs[ipair].c_str());
973  h_mindR[ipair] = fs_->make<TH1D>(hname, htit, 500, 0.0, 1.0);
974  h_mindR[ipair]->GetXaxis()->SetTitle("dR");
975  }
976 
977  for (int lvl=0; lvl<2; lvl++) {
978  sprintf(hname, "h_dEtaL1%s", levels[lvl+1].c_str());
979  sprintf(htit, "#Delta#eta for L1 and %s objects", levels[lvl+1].c_str());
980  h_dEtaL1[lvl] = fs_->make<TH1D>(hname, htit, 400, -10.0, 10.0);
981 
982  sprintf(hname, "h_dPhiL1%s", levels[lvl+1].c_str());
983  sprintf(htit, "#Delta#phi for L1 and %s objects", levels[lvl+1].c_str());
984  h_dPhiL1[lvl] = fs_->make<TH1D>(hname, htit, 280, -7.0, 7.0);
985 
986  sprintf(hname, "h_dRL1%s", levels[lvl+1].c_str());
987  sprintf(htit, "#Delta R for L1 and %s objects", levels[lvl+1].c_str());
988  h_dRL1[lvl] = fs_->make<TH1D>(hname, htit, 100, 0.0, 10.0);
989  }
990  }
991 
992  int levmin = (doL2L3_ ? 0 : 10);
993  for (int ilevel=levmin; ilevel<20; ilevel++) {
994  sprintf(hname, "h_p%s", levels[ilevel].c_str());
995  sprintf(htit, "p for %s objects", levels[ilevel].c_str());
996  h_p[ilevel] = fs_->make<TH1D>(hname, htit, 100, 0.0, 500.0);
997  h_p[ilevel]->GetXaxis()->SetTitle("p (GeV)");
998 
999  sprintf(hname, "h_pt%s", levels[ilevel].c_str());
1000  sprintf(htit, "p_{T} for %s objects", levels[ilevel].c_str());
1001  h_pt[ilevel] = fs_->make<TH1D>(hname, htit, 100, 0.0, 500.0);
1002  h_pt[ilevel]->GetXaxis()->SetTitle("p_{T} (GeV)");
1003 
1004  sprintf(hname, "h_eta%s", levels[ilevel].c_str());
1005  sprintf(htit, "#eta for %s objects", levels[ilevel].c_str());
1006  h_eta[ilevel] = fs_->make<TH1D>(hname, htit, 100, -5.0, 5.0);
1007  h_eta[ilevel]->GetXaxis()->SetTitle("#eta");
1008 
1009  sprintf(hname, "h_phi%s", levels[ilevel].c_str());
1010  sprintf(htit, "#phi for %s objects", levels[ilevel].c_str());
1011  h_phi[ilevel] = fs_->make<TH1D>(hname, htit, 70, -3.5, 3.50);
1012  h_phi[ilevel]->GetXaxis()->SetTitle("#phi");
1013  }
1014 
1015  std::string cuts[2] = {"HLTMatched", "HLTNotMatched"};
1016  std::string cuts2[2] = {"All", "Away from L1"};
1017  for (int icut=0; icut<2; icut++) {
1018  sprintf(hname, "h_eMip%s", cuts[icut].c_str());
1019  sprintf(htit, "eMip for %s tracks", cuts[icut].c_str());
1020  h_eMip[icut] =fs_->make<TH1D>(hname, htit, 200, 0.0, 10.0);
1021  h_eMip[icut]->GetXaxis()->SetTitle("E_{Mip} (GeV)");
1022 
1023  sprintf(hname, "h_eMaxNearP%s", cuts[icut].c_str());
1024  sprintf(htit, "eMaxNearP for %s tracks", cuts[icut].c_str());
1025  h_eMaxNearP[icut]=fs_->make<TH1D>(hname, htit, 240, -2.0, 10.0);
1026  h_eMaxNearP[icut]->GetXaxis()->SetTitle("E_{MaxNearP} (GeV)");
1027 
1028  sprintf(hname, "h_eNeutIso%s", cuts[icut].c_str());
1029  sprintf(htit, "eNeutIso for %s ", cuts[icut].c_str());
1030  h_eNeutIso[icut] =fs_->make<TH1D>(hname, htit, 200, 0.0, 10.0);
1031  h_eNeutIso[icut]->GetXaxis()->SetTitle("E_{NeutIso} (GeV)");
1032 
1033  for (int kcut=0; kcut<2; ++kcut) {
1034  for (int lim=0; lim<5; ++lim) {
1035  sprintf(hname, "h_etaCalibTracks%sCut%dLim%d", cuts[icut].c_str(), kcut, lim);
1036  sprintf(htit, "#eta for %s isolated MIP tracks (%4.1f < p < %5.1f Gev/c %s)", cuts[icut].c_str(), pLimits_[lim], pLimits_[lim+1], cuts2[kcut].c_str());
1037  h_etaCalibTracks[lim][icut][kcut]=fs_->make<TH1D>(hname, htit, 60, -30.0, 30.0);
1038  h_etaCalibTracks[lim][icut][kcut]->GetXaxis()->SetTitle("i#eta");
1039 
1040  sprintf(hname, "h_etaMipTracks%sCut%dLim%d", cuts[icut].c_str(), kcut, lim);
1041  sprintf(htit, "#eta for %s charge isolated MIP tracks (%4.1f < p < %5.1f Gev/c %s)", cuts[icut].c_str(), pLimits_[lim], pLimits_[lim+1], cuts2[kcut].c_str());
1042  h_etaMipTracks[lim][icut][kcut]=fs_->make<TH1D>(hname, htit, 60, -30.0, 30.0);
1043  h_etaMipTracks[lim][icut][kcut]->GetXaxis()->SetTitle("i#eta");
1044  }
1045  }
1046  }
1047 
1048  std::string ecut1[3] = {"all","HLTMatched","HLTNotMatched"};
1049  std::string ecut2[2] = {"without","with"};
1050  int etac[48] = {-1,-2,-3,-4,-5,-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16,-17,-18,-19,-20,-21,-22,-23,-24,
1051  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
1052  for (int icut=0; icut<6; icut++) {
1053  // int i1 = (icut>3 ? 1 : 0);
1054  int i1 = (icut>2 ? 1 : 0);
1055  int i2 = icut - i1*3;
1056  for (int kcut=0; kcut<48; kcut++) {
1057  for (int lim=0; lim<5; ++lim) {
1058  sprintf(hname, "h_eta%dEnHcal%s%s%d", etac[kcut], ecut1[i2].c_str(), ecut2[i1].c_str(), lim);
1059  sprintf(htit, "HCAL energy for #eta=%d for %s tracks (p=%4.1f:%5.1f Gev) %s neutral isolation", etac[kcut], ecut1[i2].c_str(), pLimits_[lim], pLimits_[lim+1], ecut2[i1].c_str());
1060  h_eHcal[lim][icut][kcut]=fs_->make<TH1D>(hname, htit, 750, 0.0, 150.0);
1061  h_eHcal[lim][icut][kcut]->GetXaxis()->SetTitle("Energy (GeV)");
1062  sprintf(hname, "h_eta%dEnCalo%s%s%d", etac[kcut], ecut1[i2].c_str(), ecut2[i1].c_str(), lim);
1063  sprintf(htit, "Calorimter energy for #eta=%d for %s tracks (p=%4.1f:%5.1f Gev) %s neutral isolation", etac[kcut], ecut1[i2].c_str(), pLimits_[lim], pLimits_[lim+1], ecut2[i1].c_str());
1064  h_eCalo[lim][icut][kcut]=fs_->make<TH1D>(hname, htit, 750, 0.0, 150.0);
1065  h_eCalo[lim][icut][kcut]->GetXaxis()->SetTitle("Energy (GeV)");
1066  }
1067  }
1068  }
1069 }
1070 
1071 // ------------ method called once each job just after ending the event loop ------------
1073  unsigned int preL1, preHLT;
1074  std::map<unsigned int, unsigned int>::iterator itr;
1075  std::map<unsigned int, const std::pair<int, int>>::iterator itrPre;
1076  edm::LogWarning ("IsoTrack") << trigNames_.size() << "Triggers were run. RunNo vs HLT accepts for";
1077  for (unsigned int i=0; i<trigNames_.size(); ++i)
1078  edm::LogWarning("IsoTrack") << "[" << i << "]: " << trigNames_[i];
1079  unsigned int n = maxRunNo_ - minRunNo_ +1;
1080  g_Pre = fs_->make<TH1I>("h_PrevsRN", "PreScale Vs Run Number", n, minRunNo_, maxRunNo_);
1081  g_PreL1 = fs_->make<TH1I>("h_PreL1vsRN", "L1 PreScale Vs Run Number", n, minRunNo_, maxRunNo_);
1082  g_PreHLT = fs_->make<TH1I>("h_PreHLTvsRN", "HLT PreScale Vs Run Number", n, minRunNo_, maxRunNo_);
1083  g_Accepts = fs_->make<TH1I>("h_HLTAcceptsvsRN", "HLT Accepts Vs Run Number", n, minRunNo_, maxRunNo_);
1084 
1085  for (itr=trigList_.begin(), itrPre=trigPreList_.begin(); itr!=trigList_.end(); itr++, itrPre++) {
1086  preL1 = (itrPre->second).first;
1087  preHLT = (itrPre->second).second;
1088  edm::LogVerbatim("IsoTrack") << itr->first << " " << itr->second << " "
1089  << itrPre->first << " " << preL1 << " "
1090  << preHLT;
1091  g_Accepts->Fill(itr->first, itr->second);
1092  g_PreL1->Fill(itr->first, preL1);
1093  g_PreHLT->Fill(itr->first, preHLT);
1094  g_Pre->Fill(itr->first, preL1*preHLT);
1095  }
1096 }
1097 
1098 void IsoTrig::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
1099  edm::LogWarning ("IsoTrack") << "Run " << iRun.run() << " hltconfig.init "
1101 }
1102 
1104 
1105  t_TrkselTkFlag->clear();
1106  t_TrkqltyFlag->clear();
1107  t_TrkMissFlag->clear();
1108  t_TrkPVFlag->clear();
1109  t_TrkNuIsolFlag->clear();
1110  t_TrkhCone->clear();
1111  t_TrkP->clear();
1112 
1113  if (!trkCollection.isValid()) {
1114  edm::LogVerbatim("IsoTrack") << "trkCollection.isValid is false";
1115  } else {
1116  std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
1117  const MagneticField *bField = bFieldH_.product();
1118  const CaloGeometry* geo = pG_.product();
1119  std::vector<spr::propagatedTrackDirection> trkCaloDirections1;
1120  spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_,
1121  trkCaloDirections1, ((verbosity_/100)%10>2));
1122  unsigned int nTracks=0;
1123  int nRH_eMipDR=0, nNearTRKs=0;
1124  std::vector<bool> selFlags;
1125  for (trkDetItr = trkCaloDirections1.begin();
1126  trkDetItr != trkCaloDirections1.end(); trkDetItr++,nTracks++) {
1127  double conehmaxNearP = 0, hCone=0, eMipDR=0.0;
1128  const reco::Track* pTrack = &(*(trkDetItr->trkItr));
1129  if (verbosity_%10>0)
1130  edm::LogVerbatim("IsoTrack") << "track no. " << nTracks << " p(): "
1131  << pTrack->p();
1132  if (pTrack->p() > 20) {
1133  math::XYZTLorentzVector v2(pTrack->px(), pTrack->py(),
1134  pTrack->pz(), pTrack->p());
1135  eMipDR = spr::eCone_ecal(geo, barrelRecHitsHandle_,
1136  endcapRecHitsHandle_, trkDetItr->pointHCAL,
1137  trkDetItr->pointECAL, a_mipR_,
1138  trkDetItr->directionECAL, nRH_eMipDR);
1139  bool selectTk = spr::goodTrack(pTrack, leadPV_, selectionParameters_,
1140  ((verbosity_/100)%10>1));
1142  oneCutParameters.maxDxyPV = 10;
1143  oneCutParameters.maxDzPV = 100;
1144  oneCutParameters.maxInMiss = 2;
1145  oneCutParameters.maxOutMiss= 2;
1146  bool qltyFlag = spr::goodTrack(pTrack, leadPV_, oneCutParameters,
1147  ((verbosity_/100)%10>1));
1148  oneCutParameters = selectionParameters_;
1149  oneCutParameters.maxDxyPV = 10;
1150  oneCutParameters.maxDzPV = 100;
1151  bool qltyMissFlag = spr::goodTrack(pTrack, leadPV_, oneCutParameters,
1152  ((verbosity_/100)%10>1));
1153  oneCutParameters = selectionParameters_;
1154  oneCutParameters.maxInMiss = 2;
1155  oneCutParameters.maxOutMiss= 2;
1156  bool qltyPVFlag = spr::goodTrack(pTrack, leadPV_, oneCutParameters,
1157  ((verbosity_/100)%10>1));
1158  if ((verbosity_/1000)%10>1)
1159  edm::LogVerbatim("IsoTrack") << "sel " << selectTk
1160  << "ntracks " << nTracks
1161  << " a_charIsoR " << a_charIsoR_
1162  << " nNearTRKs " << nNearTRKs;
1163  conehmaxNearP = spr::chargeIsolationCone(nTracks, trkCaloDirections1,
1164  a_charIsoR_, nNearTRKs,
1165  ((verbosity_/100)%10>1));
1166  if ((verbosity_/1000)%10>1)
1167  edm::LogVerbatim("IsoTrack") << "coneh " << conehmaxNearP
1168  << "ok " << trkDetItr->okECAL << " "
1169  << trkDetItr->okHCAL;
1170  double e1 = spr::eCone_ecal(geo, barrelRecHitsHandle_,
1171  endcapRecHitsHandle_, trkDetItr->pointHCAL,
1172  trkDetItr->pointECAL, a_neutR1_,
1173  trkDetItr->directionECAL, nRH_eMipDR);
1174  double e2 = spr::eCone_ecal(geo, barrelRecHitsHandle_,
1175  endcapRecHitsHandle_, trkDetItr->pointHCAL,
1176  trkDetItr->pointECAL, a_neutR2_,
1177  trkDetItr->directionECAL, nRH_eMipDR);
1178  double e_inCone = e2 - e1;
1179  bool chgIsolFlag = (conehmaxNearP < cutCharge_);
1180  bool mipFlag = (eMipDR < cutMip_);
1181  bool neuIsolFlag = (e_inCone < cutNeutral_);
1182  bool trkpropFlag = ((trkDetItr->okECAL) && (trkDetItr->okHCAL));
1183  selFlags.clear();
1184  selFlags.push_back(selectTk); selFlags.push_back(qltyFlag);
1185  selFlags.push_back(qltyMissFlag); selFlags.push_back(qltyPVFlag);
1186  if (verbosity_%10>0)
1187  edm::LogVerbatim("IsoTrack") << "emip: " << eMipDR << "<" << cutMip_
1188  << "(" << mipFlag << ")" << " ; ok: "
1189  << trkDetItr->okECAL << "/"
1190  << trkDetItr->okHCAL << " ; chgiso: "
1191  << conehmaxNearP << "<" << cutCharge_
1192  << "(" << chgIsolFlag << ")";
1193 
1194  if (chgIsolFlag && mipFlag && trkpropFlag) {
1195  double distFromHotCell=-99.0;
1196  int nRecHitsCone=-99, ietaHotCell=-99, iphiHotCell=-99;
1197  GlobalPoint gposHotCell(0.,0.,0.);
1198  std::vector<DetId> coneRecHitDetIds;
1199  hCone = spr::eCone_hcal(geo, hbhe_, trkDetItr->pointHCAL,
1200  trkDetItr->pointECAL,
1201  a_coneR_, trkDetItr->directionHCAL,
1202  nRecHitsCone, coneRecHitDetIds,
1203  distFromHotCell, ietaHotCell, iphiHotCell,
1204  gposHotCell, -1);
1205  // push vectors into the Tree
1206  t_TrkselTkFlag ->push_back(selFlags[0]);
1207  t_TrkqltyFlag ->push_back(selFlags[1]);
1208  t_TrkMissFlag ->push_back(selFlags[2]);
1209  t_TrkPVFlag ->push_back(selFlags[3]);
1210  t_TrkNuIsolFlag->push_back(neuIsolFlag);
1211  t_TrkhCone ->push_back(hCone);
1212  t_TrkP ->push_back(pTrack->p());
1213  }
1214  }
1215  }
1216  if (verbosity_%10>0)
1217  edm::LogVerbatim("IsoTrack") << "Filling " << t_TrkP->size()
1218  << " tracks in TrkRestree out of " <<nTracks;
1219  }
1220  TrkResTree_->Fill();
1221 }
1222 
1223 void IsoTrig::studyTiming(const edm::Event& theEvent) {
1224  t_timeL2Prod->clear(); t_nPixCand->clear(); t_nPixSeed->clear();
1225 
1226  if (verbosity_%10>0) {
1227  edm::Handle<SeedingLayerSetsHits> hblayers, helayers;
1228  theEvent.getByToken(tok_SeedingLayerHB_, hblayers);
1229  theEvent.getByToken(tok_SeedingLayerHE_, helayers);
1230  const SeedingLayerSetsHits* layershb = hblayers.product();
1231  const SeedingLayerSetsHits* layershe = helayers.product();
1232  edm::LogVerbatim("IsoTrack") << "size of Seeding TripletLayers hb/he "
1233  << layershb->size() << "/" << layershe->size();
1235  theEvent.getByToken(tok_SiPixelRecHits_, rchts);
1236  const SiPixelRecHitCollection* rechits = rchts.product();
1237  edm::LogVerbatim("IsoTrack") << "size of SiPixelRechits " <<rechits->size();
1238  }
1239  double tHB=0.0, tHE=0.0;
1240  int nCandHB=pixelTrackRefsHB_.size(), nCandHE=pixelTrackRefsHE_.size();
1241  int nSeedHB=0, nSeedHE=0;
1242 
1243  if (nCandHE>0) {
1244  edm::Handle<reco::VertexCollection> pVertHB, pVertHE;
1245  theEvent.getByToken(tok_verthb_,pVertHB);
1246  theEvent.getByToken(tok_verthe_,pVertHE);
1248  theEvent.getByToken(tok_l1cand_, l1trigobj);
1249 
1250  std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1tauobjref;
1251  std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1jetobjref;
1252  std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1forjetobjref;
1253 
1254  l1trigobj->getObjects(trigger::TriggerL1TauJet, l1tauobjref);
1255  l1trigobj->getObjects(trigger::TriggerL1CenJet, l1jetobjref);
1256  l1trigobj->getObjects(trigger::TriggerL1ForJet, l1forjetobjref);
1257 
1258  double ptTriggered = -10;
1259  double etaTriggered = -100;
1260  double phiTriggered = -100;
1261  for (unsigned int p=0; p<l1tauobjref.size(); p++) {
1262  if (l1tauobjref[p]->pt()>ptTriggered) {
1263  ptTriggered = l1tauobjref[p]->pt();
1264  phiTriggered = l1tauobjref[p]->phi();
1265  etaTriggered = l1tauobjref[p]->eta();
1266  }
1267  }
1268  for (unsigned int p=0; p<l1jetobjref.size(); p++) {
1269  if (l1jetobjref[p]->pt()>ptTriggered) {
1270  ptTriggered = l1jetobjref[p]->pt();
1271  phiTriggered = l1jetobjref[p]->phi();
1272  etaTriggered = l1jetobjref[p]->eta();
1273  }
1274  }
1275  for (unsigned int p=0; p<l1forjetobjref.size(); p++) {
1276  if (l1forjetobjref[p]->pt()>ptTriggered) {
1277  ptTriggered=l1forjetobjref[p]->pt();
1278  phiTriggered=l1forjetobjref[p]->phi();
1279  etaTriggered=l1forjetobjref[p]->eta();
1280  }
1281  }
1282  for(unsigned iS=0; iS<pixelTrackRefsHE_.size(); iS++) {
1283  reco::VertexCollection::const_iterator vitSel;
1284  double minDZ = 100;
1285  bool vtxMatch;
1286  for (reco::VertexCollection::const_iterator vit=pVertHE->begin();
1287  vit!=pVertHE->end(); vit++) {
1288  if (fabs(pixelTrackRefsHE_[iS]->dz(vit->position()))<minDZ) {
1289  minDZ = fabs(pixelTrackRefsHE_[iS]->dz(vit->position()));
1290  vitSel = vit;
1291  }
1292  }
1293  //cut on dYX:
1294  if ((fabs(pixelTrackRefsHE_[iS]->dxy(vitSel->position())) < vtxCutSeed_)||
1295  (minDZ==100)) vtxMatch=true;
1296 
1297  //select tracks not matched to triggered L1 jet
1298  double R = deltaR(etaTriggered, phiTriggered,
1299  pixelTrackRefsHE_[iS]->eta(),
1300  pixelTrackRefsHE_[iS]->phi());
1301  if (R>tauUnbiasCone_ && vtxMatch) nSeedHE++;
1302  }
1303  for (unsigned iS=0; iS<pixelTrackRefsHB_.size(); iS++) {
1304  reco::VertexCollection::const_iterator vitSel;
1305  double minDZ = 100;
1306  bool vtxMatch(false);
1307  for (reco::VertexCollection::const_iterator vit=pVertHB->begin();
1308  vit!=pVertHB->end(); vit++) {
1309  if (fabs(pixelTrackRefsHB_[iS]->dz(vit->position()))<minDZ) {
1310  minDZ = fabs(pixelTrackRefsHB_[iS]->dz(vit->position()));
1311  vitSel = vit;
1312  }
1313  }
1314  //cut on dYX:
1315  if ((fabs(pixelTrackRefsHB_[iS]->dxy(vitSel->position()))<101.0) ||
1316  (minDZ==100)) vtxMatch=true;
1317 
1318  //select tracks not matched to triggered L1 jet
1319  double R = deltaR(etaTriggered, phiTriggered,
1320  pixelTrackRefsHB_[iS]->eta(),
1321  pixelTrackRefsHB_[iS]->phi());
1322  if (R>1.2 && vtxMatch) nSeedHB++;
1323  }
1324 
1326  tHE = ft->queryModuleTimeByLabel(theEvent.streamID(),
1327  "hltIsolPixelTrackProdHE") ;
1328  tHB = ft->queryModuleTimeByLabel(theEvent.streamID(),
1329  "hltIsolPixelTrackProdHB");
1330  if (verbosity_%10>0)
1331  edm::LogVerbatim("IsoTrack") << "(HB/HE) time: " << tHB <<"/" << tHE
1332  << " nCand: " << nCandHB << "/" << nCandHE
1333  << "nSeed: " << nSeedHB << "/" << nSeedHE;
1334  }
1335  t_timeL2Prod->push_back(tHB); t_timeL2Prod->push_back(tHE);
1336  t_nPixSeed->push_back(nSeedHB); t_nPixSeed->push_back(nSeedHE);
1337  t_nPixCand->push_back(nCandHB); t_nPixCand->push_back(nCandHE);
1338 
1339  TimingTree_->Fill();
1340 }
1343 
1345  if (verbosity_%10>0) edm::LogVerbatim("IsoTrack") << "inside studymipcut";
1346  if (!trkCollection.isValid()) {
1347  edm::LogWarning("IsoTrack") << "trkCollection.isValid is false";
1348  } else {
1349  std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
1350  const MagneticField *bField = bFieldH_.product();
1351  const CaloGeometry* geo = pG_.product();
1352  std::vector<spr::propagatedTrackDirection> trkCaloDirections1;
1353  spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, trkCaloDirections1, ((verbosity_/100)%10>2));
1354  if (verbosity_%10>0)
1355  edm::LogVerbatim("IsoTrack") << "Number of L2cands:" << L2cands->size()
1356  << " to be matched to something out of "
1357  << trkCaloDirections1.size()<<" reco tracks";
1358  for (unsigned int i=0; i<L2cands->size(); i++) {
1361  double enIn = candref->energyIn();
1362  h_EnIn->Fill(candref->energyIn());
1363  h_EnOut->Fill(candref->energyOut());
1364  math::XYZTLorentzVector v1(candref->track()->px(),candref->track()->py(),
1365  candref->track()->pz(),candref->track()->p());
1366  if (verbosity_%10>1)
1367  edm::LogVerbatim("IsoTrack") << "HLT Level Candidate eta/phi/pt/enIn:"
1368  << candref->track()->eta() << "/"
1369  << candref->track()->phi() << "/"
1370  << candref->track()->pt() << "/"
1371  << candref->energyIn();
1372  math::XYZTLorentzVector mindRvec;
1373  double mindR=999.9, mindP1=999.9, eMipDR=0.0;
1374  std::vector<bool> selFlags;
1375  unsigned int nTracks=0;
1376  double conehmaxNearP = 0, hCone=0;
1377  for (trkDetItr = trkCaloDirections1.begin();
1378  trkDetItr != trkCaloDirections1.end(); trkDetItr++,nTracks++){
1379  const reco::Track* pTrack = &(*(trkDetItr->trkItr));
1380  math::XYZTLorentzVector v2(pTrack->px(), pTrack->py(),
1381  pTrack->pz(), pTrack->p());
1382  double dr = dR(v1,v2);
1383  double dp1 = std::abs(1./v1.r() - 1./v2.r());
1384  if (verbosity_%1000>0)
1385  edm::LogVerbatim("IsoTrack") << "This recotrack(eta/phi/pt) "
1386  << pTrack->eta() << "/" << pTrack->phi()
1387  << "/" << pTrack->pt() << " has dr/dp= "
1388  << dr << "/" << dp1;
1389  if (dr<mindR) {
1390  mindR = dr;
1391  mindP1= dp1;
1392  mindRvec=v2;
1393  int nRH_eMipDR=0, nNearTRKs=0;
1394  eMipDR = spr::eCone_ecal(geo, barrelRecHitsHandle_,
1395  endcapRecHitsHandle_, trkDetItr->pointHCAL,
1396  trkDetItr->pointECAL, a_mipR_,
1397  trkDetItr->directionECAL, nRH_eMipDR);
1398  bool selectTk = spr::goodTrack(pTrack, leadPV_, selectionParameters_,
1399  ((verbosity_/100)%10>1));
1401  oneCutParameters.maxDxyPV = 10;
1402  oneCutParameters.maxDzPV = 100;
1403  oneCutParameters.maxInMiss = 2;
1404  oneCutParameters.maxOutMiss= 2;
1405  bool qltyFlag = spr::goodTrack(pTrack, leadPV_, oneCutParameters,
1406  ((verbosity_/100)%10>1));
1407  oneCutParameters = selectionParameters_;
1408  oneCutParameters.maxDxyPV = 10;
1409  oneCutParameters.maxDzPV = 100;
1410  bool qltyMissFlag = spr::goodTrack(pTrack, leadPV_, oneCutParameters,
1411  ((verbosity_/100)%10>1));
1412  oneCutParameters = selectionParameters_;
1413  oneCutParameters.maxInMiss = 2;
1414  oneCutParameters.maxOutMiss= 2;
1415  bool qltyPVFlag = spr::goodTrack(pTrack, leadPV_, oneCutParameters,
1416  ((verbosity_/100)%10>1));
1417  conehmaxNearP = spr::chargeIsolationCone(nTracks, trkCaloDirections1,
1418  a_charIsoR_, nNearTRKs,
1419  ((verbosity_/100)%10>1));
1420  double e1 = spr::eCone_ecal(geo, barrelRecHitsHandle_,
1422  trkDetItr->pointHCAL,
1423  trkDetItr->pointECAL,
1424  a_neutR1_, trkDetItr->directionECAL,
1425  nRH_eMipDR);
1426  double e2 = spr::eCone_ecal(geo, barrelRecHitsHandle_,
1428  trkDetItr->pointHCAL,
1429  trkDetItr->pointECAL,
1430  a_neutR2_, trkDetItr->directionECAL,
1431  nRH_eMipDR);
1432  double e_inCone = e2 - e1;
1433  bool chgIsolFlag = (conehmaxNearP < cutCharge_);
1434  bool mipFlag = (eMipDR < cutMip_);
1435  bool neuIsolFlag = (e_inCone < cutNeutral_);
1436  bool trkpropFlag = ((trkDetItr->okECAL) && (trkDetItr->okHCAL));
1437  selFlags.clear();
1438  selFlags.push_back(selectTk); selFlags.push_back(qltyFlag);
1439  selFlags.push_back(qltyMissFlag); selFlags.push_back(qltyPVFlag);
1440  selFlags.push_back(trkpropFlag); selFlags.push_back(chgIsolFlag);
1441  selFlags.push_back(neuIsolFlag); selFlags.push_back(mipFlag);
1442  double distFromHotCell=-99.0;
1443  int nRecHitsCone=-99, ietaHotCell=-99, iphiHotCell=-99;
1444  GlobalPoint gposHotCell(0.,0.,0.);
1445  std::vector<DetId> coneRecHitDetIds;
1446  hCone = spr::eCone_hcal(geo, hbhe_, trkDetItr->pointHCAL,
1447  trkDetItr->pointECAL,
1448  a_coneR_, trkDetItr->directionHCAL,
1449  nRecHitsCone, coneRecHitDetIds,
1450  distFromHotCell, ietaHotCell, iphiHotCell,
1451  gposHotCell, -1);
1452  }
1453  }
1454  pushMipCutTreeVecs(v1, mindRvec, enIn, eMipDR, mindR, mindP1, selFlags,
1455  hCone);
1456  fillDifferences(6, v1, mindRvec, (verbosity_%10 >0));
1457  if (mindR>=0.05) {
1458  fillDifferences(8, v1, mindRvec, (verbosity_%10 >0));
1459  h_MipEnNoMatch->Fill(candref->energyIn(), eMipDR);
1460  } else {
1461  fillDifferences(7, v1, mindRvec, (verbosity_%10 >0));
1462  h_MipEnMatch->Fill(candref->energyIn(), eMipDR);
1463  }
1464  }
1465  }
1466  MipCutTree_->Fill();
1467 }
1468 
1470  std::vector<reco::TrackCollection::const_iterator>& goodTks) {
1471 
1472  if (verbosity_%10 > 0) edm::LogVerbatim("IsoTrack") << "Inside StudyTrigger";
1474  for (int j=0; j<3; j++) {
1475  for (unsigned int k=0; k<vec_[j].size(); k++) {
1476  if (verbosity_%10 > 0)
1477  edm::LogVerbatim("IsoTrack") << "vec[" << j << "][" << k << "] pt "
1478  << vec_[j][k].pt() << " eta "
1479  << vec_[j][k].eta() << " phi "
1480  << vec_[j][k].phi();
1481  fillHist(j, vec_[j][k]);
1482  }
1483  }
1484 
1485  double deta, dphi, dr;
1487  for (int lvl=1; lvl<3; lvl++) {
1488  for (unsigned int i=0; i<vec_[lvl].size(); i++) {
1489  deta = dEta(vec_[0][0],vec_[lvl][i]);
1490  dphi = dPhi(vec_[0][0],vec_[lvl][i]);
1491  dr = dR(vec_[0][0],vec_[lvl][i]);
1492  if (verbosity_%10 > 1)
1493  edm::LogVerbatim("IsoTrack") << "lvl " <<lvl << " i " << i << " deta "
1494  << deta << " dphi " << dphi << " dR " <<dr;
1495  h_dEtaL1[lvl-1] -> Fill(deta);
1496  h_dPhiL1[lvl-1] -> Fill(dphi);
1497  h_dRL1[lvl-1] -> Fill(std::sqrt(dr));
1498  }
1499  }
1500 
1501  math::XYZTLorentzVector mindRvec;
1502  double mindR;
1503  for (unsigned int k=0; k<vec_[2].size(); ++k) {
1505  mindR=999.9;
1506  if (verbosity_%10 > 1)
1507  edm::LogVerbatim("IsoTrack") << "L3obj: pt " << vec_[2][k].pt() << " eta "
1508  << vec_[2][k].eta() << " phi "
1509  << vec_[2][k].phi();
1510  for (unsigned int j=0; j<vec_[1].size(); j++) {
1511  dr = dR(vec_[2][k],vec_[1][j]);
1512  if (dr<mindR) {
1513  mindR=dr;
1514  mindRvec=vec_[1][j];
1515  }
1516  }
1517  fillDifferences(0, vec_[2][k], mindRvec, (verbosity_%10 >0));
1518  if (mindR < 0.03) {
1519  fillDifferences(1, vec_[2][k], mindRvec, (verbosity_%10 >0));
1520  fillHist(6, mindRvec);
1521  fillHist(8, vec_[2][k]);
1522  } else {
1523  fillDifferences(2, vec_[2][k], mindRvec, (verbosity_%10 >0));
1524  fillHist(7, mindRvec);
1525  fillHist(9, vec_[2][k]);
1526  }
1527 
1529  mindR=999.9;
1530  if (verbosity_%10 > 0)
1531  edm::LogVerbatim("IsoTrack") << "Now Matching L3 track with reco: L3 Track (eta, phi) "
1532  << vec_[2][k].eta() << ":" << vec_[2][k].phi()
1533  << " L2 Track " << mindRvec.eta() << ":"
1534  << mindRvec.phi() << " dR " << mindR;
1535  reco::TrackCollection::const_iterator goodTk = trkCollection->end();
1536  if (trkCollection.isValid()) {
1537  double mindP(9999.9);
1538  reco::TrackCollection::const_iterator trkItr;
1539  for (trkItr=trkCollection->begin();
1540  trkItr!=trkCollection->end(); trkItr++) {
1541  math::XYZTLorentzVector v4(trkItr->px(), trkItr->py(),
1542  trkItr->pz(), trkItr->p());
1543  double deltaR = dR(v4, vec_[2][k]);
1544  double dp = std::abs(v4.r()/vec_[2][k].r()-1.0);
1545  if (deltaR<mindR) {
1546  mindR = deltaR;
1547  mindP = dp;
1548  mindRvec = v4;
1549  goodTk = trkItr;
1550  }
1551  if ((verbosity_/10)%10>1 && deltaR<1.0)
1552  edm::LogVerbatim("IsoTrack") << "reco track: pt " << v4.pt()
1553  << " eta " << v4.eta() << " phi "
1554  << v4.phi() << " DR " << deltaR;
1555  }
1556  if (verbosity_%10 > 0)
1557  edm::LogVerbatim("IsoTrack") << "Now Matching at Reco level in step 1 DR: "
1558  << mindR << ":" << mindP << " eta:phi "
1559  << mindRvec.eta() << ":" << mindRvec.phi();
1560  if (mindR < 0.03 && mindP > 0.1) {
1561  for (trkItr=trkCollection->begin();
1562  trkItr!=trkCollection->end(); trkItr++) {
1563  math::XYZTLorentzVector v4(trkItr->px(), trkItr->py(),
1564  trkItr->pz(), trkItr->p());
1565  double deltaR = dR(v4, vec_[2][k]);
1566  double dp = std::abs(v4.r()/vec_[2][k].r()-1.0);
1567  if (dp<mindP && deltaR<0.03) {
1568  mindR = deltaR;
1569  mindP = dp;
1570  mindRvec = v4;
1571  goodTk = trkItr;
1572  }
1573  }
1574  if (verbosity_%10 > 0)
1575  edm::LogVerbatim("IsoTrack") << "Now Matching at Reco level in step 2 DR: "
1576  << mindR << ":" << mindP << " eta:phi "
1577  << mindRvec.eta() << ":"<<mindRvec.phi();
1578  }
1579  fillDifferences(3, vec_[2][k], mindRvec, (verbosity_%10 >0));
1580  fillHist(3, mindRvec);
1581  if(mindR < 0.03) {
1582  fillDifferences(4, vec_[2][k], mindRvec, (verbosity_%10 >0));
1583  fillHist(4, mindRvec);
1584  } else {
1585  fillDifferences(5, vec_[2][k], mindRvec, (verbosity_%10 >0));
1586  fillHist(5, mindRvec);
1587  }
1588  if (goodTk != trkCollection->end()) goodTks.push_back(goodTk);
1589  }
1590  }
1591 }
1592 
1594  std::vector<reco::TrackCollection::const_iterator>& goodTks) {
1595 
1596  if (trkCollection.isValid()) {
1597  // get handles to calogeometry and calotopology
1598  const CaloGeometry* geo = pG_.product();
1599  const MagneticField *bField = bFieldH_.product();
1600  std::vector<spr::propagatedTrackDirection> trkCaloDirections;
1601  spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_,
1602  trkCaloDirections, ((verbosity_/100)%10>2));
1603 
1604  std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
1605  if ((verbosity_/1000)%10 > 1) {
1606  edm::LogVerbatim("IsoTrack") << "n of barrelRecHitsHandle "
1607  << barrelRecHitsHandle_->size();
1609  edm::LogVerbatim("IsoTrack") << "hit : detid(ieta,iphi) "
1610  << (EBDetId)(hit->id()) << " time "
1611  << hit->time() << " energy "
1612  << hit->energy();
1613  }
1614  edm::LogVerbatim("IsoTrack") << "n of endcapRecHitsHandle "
1615  << endcapRecHitsHandle_->size();
1617  edm::LogVerbatim("IsoTrack") << "hit : detid(ieta,iphi) "
1618  << (EEDetId)(hit->id()) << " time "
1619  << hit->time() << " energy "
1620  << hit->energy();
1621  }
1622  edm::LogVerbatim("IsoTrack") << "n of hbhe " << hbhe_->size();
1624  hit != hbhe_->end(); ++hit) {
1625  edm::LogVerbatim("IsoTrack") << "hit : detid(ieta,iphi) " << hit->id()
1626  << " time " << hit->time() << " energy "
1627  << hit->energy();
1628  }
1629  }
1630  unsigned int nTracks=0, ngoodTk=0, nselTk=0;
1631  int ieta=999;
1632  for (trkDetItr = trkCaloDirections.begin(); trkDetItr != trkCaloDirections.end(); trkDetItr++,nTracks++){
1633  bool l3Track = (std::find(goodTks.begin(), goodTks.end(),
1634  trkDetItr->trkItr) != goodTks.end());
1635  const reco::Track* pTrack = &(*(trkDetItr->trkItr));
1636  math::XYZTLorentzVector v4(pTrack->px(), pTrack->py(),
1637  pTrack->pz(), pTrack->p());
1638  bool selectTk = spr::goodTrack(pTrack, leadPV_, selectionParameters_,
1639  ((verbosity_/100)%10>1));
1640  double eMipDR=9999., e_inCone=0, conehmaxNearP=0, mindR=999.9, hCone=0;
1641  if (trkDetItr->okHCAL) {
1642  HcalDetId detId = (HcalDetId)(trkDetItr->detIdHCAL);
1643  ieta = detId.ieta();
1644  }
1645  for (unsigned k=0; k<vec_[0].size(); ++k) {
1646  double deltaR = dR(v4, vec_[0][k]);
1647  if (deltaR<mindR) mindR = deltaR;
1648  }
1649  if ((verbosity_/100)%10 > 1)
1650  edm::LogVerbatim("IsoTrack") << "Track ECAL " << trkDetItr->okECAL
1651  << " HCAL " << trkDetItr->okHCAL
1652  << " Flag " << selectTk;
1653  if (selectTk && trkDetItr->okECAL && trkDetItr->okHCAL) {
1654  ngoodTk++;
1655  int nRH_eMipDR=0, nNearTRKs=0;
1656  double e1 = spr::eCone_ecal(geo, barrelRecHitsHandle_,
1657  endcapRecHitsHandle_, trkDetItr->pointHCAL,
1658  trkDetItr->pointECAL, a_neutR1_,
1659  trkDetItr->directionECAL, nRH_eMipDR);
1660  double e2 = spr::eCone_ecal(geo, barrelRecHitsHandle_,
1661  endcapRecHitsHandle_, trkDetItr->pointHCAL,
1662  trkDetItr->pointECAL, a_neutR2_,
1663  trkDetItr->directionECAL, nRH_eMipDR);
1664  eMipDR = spr::eCone_ecal(geo, barrelRecHitsHandle_,
1665  endcapRecHitsHandle_, trkDetItr->pointHCAL,
1666  trkDetItr->pointECAL, a_mipR_,
1667  trkDetItr->directionECAL, nRH_eMipDR);
1668  conehmaxNearP = spr::chargeIsolationCone(nTracks, trkCaloDirections,
1669  a_charIsoR_, nNearTRKs,
1670  ((verbosity_/100)%10>1));
1671  e_inCone = e2 - e1;
1672  double distFromHotCell=-99.0;
1673  int nRecHitsCone=-99, ietaHotCell=-99, iphiHotCell=-99;
1674  GlobalPoint gposHotCell(0.,0.,0.);
1675  std::vector<DetId> coneRecHitDetIds;
1676  hCone = spr::eCone_hcal(geo, hbhe_, trkDetItr->pointHCAL,
1677  trkDetItr->pointECAL,
1678  a_coneR_, trkDetItr->directionHCAL,
1679  nRecHitsCone, coneRecHitDetIds,
1680  distFromHotCell, ietaHotCell, iphiHotCell,
1681  gposHotCell, -1);
1682  if (eMipDR<1.0) nselTk++;
1683  }
1684  if (l3Track) {
1685  fillHist(10,v4);
1686  if (selectTk) {
1687  fillHist(11,v4);
1688  fillCuts(0, eMipDR, conehmaxNearP, e_inCone, v4, ieta, (mindR>dr_L1_));
1689  if (conehmaxNearP < cutCharge_) {
1690  fillHist(12,v4);
1691  if (eMipDR < cutMip_) {
1692  fillHist(13,v4);
1693  fillEnergy(1, ieta, hCone, eMipDR, v4);
1694  fillEnergy(0, ieta, hCone, eMipDR, v4);
1695  if (e_inCone < cutNeutral_) {
1696  fillHist(14, v4);
1697  fillEnergy(4, ieta, hCone, eMipDR, v4);
1698  fillEnergy(3, ieta, hCone, eMipDR, v4);
1699  }
1700  }
1701  }
1702  }
1703  } else if (doL2L3_) {
1704  fillHist(15,v4);
1705  if (selectTk) {
1706  fillHist(16,v4);
1707  fillCuts(1, eMipDR, conehmaxNearP, e_inCone, v4, ieta, (mindR>dr_L1_));
1708  if (conehmaxNearP < cutCharge_) {
1709  fillHist(17,v4);
1710  if (eMipDR < cutMip_) {
1711  fillHist(18,v4);
1712  fillEnergy(2, ieta, hCone, eMipDR, v4);
1713  fillEnergy(0, ieta, hCone, eMipDR, v4);
1714  if (e_inCone < cutNeutral_) {
1715  fillHist(19, v4);
1716  fillEnergy(5, ieta, hCone, eMipDR, v4);
1717  fillEnergy(3, ieta, hCone, eMipDR, v4);
1718  }
1719  }
1720  }
1721  }
1722  }
1723  }
1724 // edm::LogVerbatim("IsoTrack") << "Number of tracks selected offline " << nselTk;
1725  }
1726 }
1727 
1728 void IsoTrig::chgIsolation(double& etaTriggered, double& phiTriggered,
1729  edm::Handle<reco::TrackCollection>& trkCollection,
1730  const edm::Event& theEvent) {
1732  if (verbosity_%10>0)
1733  edm::LogVerbatim("IsoTrack") << "Inside chgIsolation() with eta/phi Triggered: "
1734  << etaTriggered << "/" << phiTriggered;
1735  std::vector<double> maxP;
1736 
1737  std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
1738  const MagneticField *bField = bFieldH_.product();
1739  const CaloGeometry* geo = pG_.product();
1740  std::vector<spr::propagatedTrackDirection> trkCaloDirections1;
1741  spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_,
1742  trkCaloDirections1, ((verbosity_/100)%10>2));
1743  if (verbosity_%10>0)
1744  edm::LogVerbatim("IsoTrack") << "Propagated TrkCollection";
1745  for (unsigned int k=0; k<pixelIsolationConeSizeAtEC_.size(); ++k)
1746  maxP.push_back(0);
1747  unsigned i = pixelTrackRefsHE_.size();
1748  std::vector<std::pair<unsigned int, std::pair<double, double>>> VecSeedsatEC;
1749  //loop to select isolated tracks
1750  for (unsigned iS=0; iS<pixelTrackRefsHE_.size(); iS++) {
1751  if (pixelTrackRefsHE_[iS]->p() > minPTrackValue_) {
1752  bool vtxMatch = false;
1753  //associate to vertex (in Z)
1754  unsigned int ivSel = recVtxs_->size();
1755  double minDZ = 100;
1756  for (unsigned int iv = 0; iv < recVtxs_->size(); ++iv) {
1757  if (fabs(pixelTrackRefsHE_[iS]->dz((*recVtxs_)[iv].position()))<minDZ) {
1758  minDZ = fabs(pixelTrackRefsHE_[iS]->dz((*recVtxs_)[iv].position()));
1759  ivSel = iv;
1760  }
1761  }
1762  //cut on dYX:
1763  if (ivSel == recVtxs_->size()) {
1764  vtxMatch = true;
1765  } else if (fabs(pixelTrackRefsHE_[iS]->dxy((*recVtxs_)[ivSel].position()))<vtxCutSeed_){
1766  vtxMatch = true;
1767  }
1768  //select tracks not matched to triggered L1 jet
1769  double R = deltaR(etaTriggered, phiTriggered,pixelTrackRefsHE_[iS]->eta(),
1770  pixelTrackRefsHE_[iS]->phi());
1771  if (R > tauUnbiasCone_ && vtxMatch) {
1772  //propagate seed track to ECAL surface:
1773  std::pair<double,double> seedCooAtEC;
1774  // in case vertex is found:
1775  if (minDZ!=100)
1776  seedCooAtEC = GetEtaPhiAtEcal(pixelTrackRefsHE_[iS]->eta(),
1777  pixelTrackRefsHE_[iS]->phi(),
1778  pixelTrackRefsHE_[iS]->pt(),
1779  pixelTrackRefsHE_[iS]->charge(),
1780  (*recVtxs_)[ivSel].z());
1781  //in case vertex is not found:
1782  else
1783  seedCooAtEC = GetEtaPhiAtEcal(pixelTrackRefsHE_[iS]->eta(),
1784  pixelTrackRefsHE_[iS]->phi(),
1785  pixelTrackRefsHE_[iS]->pt(),
1786  pixelTrackRefsHE_[iS]->charge(), 0);
1787  VecSeedsatEC.push_back(std::make_pair(iS, seedCooAtEC));
1788  }
1789  }
1790  }
1791  for (unsigned int l=0; l<VecSeedsatEC.size(); l++) {
1792  unsigned int iSeed = VecSeedsatEC[l].first;
1793  math::XYZTLorentzVector v1(pixelTrackRefsHE_[iSeed]->px(),pixelTrackRefsHE_[iSeed]->py(),
1794  pixelTrackRefsHE_[iSeed]->pz(),pixelTrackRefsHE_[iSeed]->p());
1795 
1796  for (unsigned int j=0; j<VecSeedsatEC.size(); j++) {
1797  unsigned int iSurr = VecSeedsatEC[j].first;
1798  if (iSeed != iSurr) {
1799  //define preliminary cone around seed track impact point from which tracks will be extrapolated:
1800  // edm::Ref<reco::IsolatedPixelTrackCandidateCollection> cand2ref =
1801  // edm::Ref<reco::IsolatedPixelTrackCandidateCollection>(L2cands, iSurr);
1802  if (deltaR(pixelTrackRefsHE_[iSeed]->eta(),
1803  pixelTrackRefsHE_[iSeed]->phi(),
1804  pixelTrackRefsHE_[iSurr]->eta(),
1805  pixelTrackRefsHE_[iSurr]->phi()) < prelimCone_) {
1806  unsigned int ivSel = recVtxs_->size();
1807  double minDZ2=100;
1808  for (unsigned int iv = 0; iv < recVtxs_->size(); ++iv) {
1809  if (fabs(pixelTrackRefsHE_[iSurr]->dz((*recVtxs_)[iv].position()))<minDZ2) {
1810  minDZ2 = fabs(pixelTrackRefsHE_[iSurr]->dz((*recVtxs_)[iv].position()));
1811  ivSel = iv;
1812  }
1813  }
1814  //cut ot dXY:
1815  if (minDZ2==100 || fabs(pixelTrackRefsHE_[iSurr]->dxy((*recVtxs_)[ivSel].position()))<vtxCutIsol_) {
1816  //calculate distance at ECAL surface and update isolation:
1817  double dist = getDistInCM(VecSeedsatEC[i].second.first, VecSeedsatEC[i].second.second, VecSeedsatEC[j].second.first, VecSeedsatEC[j].second.second);
1818  for (unsigned int k=0; k<pixelIsolationConeSizeAtEC_.size(); ++k) {
1819  if (dist<pixelIsolationConeSizeAtEC_[k]) {
1820  if (pixelTrackRefsHE_[iSurr]->p() > maxP[k])
1821  maxP[k] = pixelTrackRefsHE_[iSurr]->p();
1822  }
1823  }
1824  }
1825  }
1826  }
1827  }
1828 
1829  double conehmaxNearP = -1; bool selectTk=false;
1830  double mindR=999.9; int nTracks=0;
1831  math::XYZTLorentzVector mindRvec;
1832  for (trkDetItr = trkCaloDirections1.begin(); trkDetItr != trkCaloDirections1.end(); trkDetItr++, nTracks++){
1833  int nNearTRKs=0;
1834  const reco::Track* pTrack = &(*(trkDetItr->trkItr));
1835  math::XYZTLorentzVector v2(pTrack->px(), pTrack->py(),
1836  pTrack->pz(), pTrack->p());
1837  double dr = dR(v1,v2);
1838  if (dr<mindR) {
1839  selectTk = spr::goodTrack(pTrack, leadPV_, selectionParameters_,
1840  ((verbosity_/100)%10>1));
1841  conehmaxNearP = spr::chargeIsolationCone(nTracks, trkCaloDirections1,
1842  a_charIsoR_, nNearTRKs,
1843  ((verbosity_/100)%10>1));
1844  mindR = dr;
1845  mindRvec = v2;
1846  }
1847  }
1848  pushChgIsolnTreeVecs(v1, mindRvec, maxP, conehmaxNearP, selectTk);
1849  }
1850  ChgIsolnTree_->Fill();
1851 }
1852 
1854  edm::Handle<reco::TrackCollection>& trkCollection){
1855 
1856  t_nGoodTk->clear();
1857  std::vector<int> nGood(4,0);
1858  if (trkCollection.isValid()) {
1859  // get handles to calogeometry and calotopology
1860  const CaloGeometry* geo = pG_.product();
1861  const MagneticField *bField = bFieldH_.product();
1862  std::vector<spr::propagatedTrackDirection> trkCaloDirections;
1863  spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_,
1864  trkCaloDirections, ((verbosity_/100)%10>2));
1865 
1866  // get the trigger jet
1868  iEvent.getByToken(tok_l1cand_, l1trigobj);
1869 
1870  std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1tauobjref;
1871  l1trigobj->getObjects(trigger::TriggerL1TauJet, l1tauobjref);
1872  std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1jetobjref;
1873  l1trigobj->getObjects(trigger::TriggerL1CenJet, l1jetobjref);
1874  std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1forjetobjref;
1875  l1trigobj->getObjects(trigger::TriggerL1ForJet, l1forjetobjref);
1876 
1877  double ptTriggered(-10), etaTriggered(-100), phiTriggered(-100);
1878  for (unsigned int p=0; p<l1tauobjref.size(); p++) {
1879  if (l1tauobjref[p]->pt()>ptTriggered) {
1880  ptTriggered = l1tauobjref[p]->pt();
1881  phiTriggered = l1tauobjref[p]->phi();
1882  etaTriggered = l1tauobjref[p]->eta();
1883  }
1884  }
1885  for (unsigned int p=0; p<l1jetobjref.size(); p++) {
1886  if (l1jetobjref[p]->pt()>ptTriggered) {
1887  ptTriggered = l1jetobjref[p]->pt();
1888  phiTriggered = l1jetobjref[p]->phi();
1889  etaTriggered = l1jetobjref[p]->eta();
1890  }
1891  }
1892  for (unsigned int p=0; p<l1forjetobjref.size(); p++) {
1893  if (l1forjetobjref[p]->pt()>ptTriggered) {
1894  ptTriggered=l1forjetobjref[p]->pt();
1895  phiTriggered=l1forjetobjref[p]->phi();
1896  etaTriggered=l1forjetobjref[p]->eta();
1897  }
1898  }
1899  double pTriggered = ptTriggered*cosh(etaTriggered);
1900  math::XYZTLorentzVector pTrigger(ptTriggered*cos(phiTriggered),
1901  ptTriggered*sin(phiTriggered),
1902  pTriggered*tanh(etaTriggered), pTriggered);
1903 
1904  std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
1905  unsigned int nTracks(0);
1906  for (trkDetItr = trkCaloDirections.begin(); trkDetItr != trkCaloDirections.end(); trkDetItr++,nTracks++) {
1907  const reco::Track* pTrack = &(*(trkDetItr->trkItr));
1908  math::XYZTLorentzVector v4(pTrack->px(), pTrack->py(),
1909  pTrack->pz(), pTrack->p());
1910  bool selectTk = spr::goodTrack(pTrack, leadPV_, selectionParameters_,
1911  ((verbosity_/100)%10>1));
1912  double mindR = dR(v4, pTrigger);
1913  if ((verbosity_/100)%10 > 1)
1914  edm::LogVerbatim("IsoTrack") << "Track ECAL " << trkDetItr->okECAL
1915  << " HCAL " << trkDetItr->okHCAL
1916  << " Flag " << selectTk;
1917  if (selectTk && trkDetItr->okECAL && trkDetItr->okHCAL && mindR > 1.0) {
1918  int nRH_eMipDR(0), nNearTRKs(0);
1919  double eMipDR = spr::eCone_ecal(geo, barrelRecHitsHandle_,
1921  trkDetItr->pointHCAL,
1922  trkDetItr->pointECAL, a_mipR_,
1923  trkDetItr->directionECAL, nRH_eMipDR);
1924  double conehmaxNearP = spr::chargeIsolationCone(nTracks,
1925  trkCaloDirections,
1926  a_charIsoR_, nNearTRKs,
1927  ((verbosity_/100)%10>1));
1928  if (conehmaxNearP < 2.0 && eMipDR<1.0) {
1929  if (pTrack->p() >= 20 && pTrack->p() < 30) {
1930  ++nGood[0];
1931  } else if (pTrack->p() >= 30 && pTrack->p() < 40) {
1932  ++nGood[1];
1933  } else if (pTrack->p() >= 40 && pTrack->p() < 60) {
1934  ++nGood[2];
1935  } else if (pTrack->p() >= 60 && pTrack->p() < 100) {
1936  ++nGood[3];
1937  }
1938  }
1939  }
1940  }
1941  }
1942 
1943  for (unsigned int ii=0; ii<nGood.size(); ++ii)
1944  t_nGoodTk->push_back(nGood[ii]);
1945 }
1946 
1948  h_p[indx]->Fill(vec.r());
1949  h_pt[indx]->Fill(vec.pt());
1950  h_eta[indx]->Fill(vec.eta());
1951  h_phi[indx]->Fill(vec.phi());
1952 }
1953 
1956  double dr = dR(vec1,vec2);
1957  double deta = dEta(vec1, vec2);
1958  double dphi = dPhi(vec1, vec2);
1959  double dpt = dPt(vec1, vec2);
1960  double dp = dP(vec1, vec2);
1961  double dinvpt = dinvPt(vec1, vec2);
1962  h_dEta[indx] ->Fill(deta);
1963  h_dPhi[indx] ->Fill(dphi);
1964  h_dPt[indx] ->Fill(dpt);
1965  h_dP[indx] ->Fill(dp);
1966  h_dinvPt[indx]->Fill(dinvpt);
1967  h_mindR[indx] ->Fill(dr);
1968  if (debug)
1969  edm::LogVerbatim("IsoTrack") << "mindR for index " << indx << " is " << dr
1970  << " deta " << deta << " dphi " << dphi
1971  << " dpt " << dpt << " dinvpt " << dinvpt;
1972 }
1973 
1974 void IsoTrig::fillCuts(int indx, double eMipDR, double conehmaxNearP, double e_inCone, math::XYZTLorentzVector& vec, int ieta, bool cut) {
1975  h_eMip[indx] ->Fill(eMipDR);
1976  h_eMaxNearP[indx]->Fill(conehmaxNearP);
1977  h_eNeutIso[indx] ->Fill(e_inCone);
1978  if ((conehmaxNearP < cutCharge_) && (eMipDR < cutMip_)) {
1979  for (int lim=0; lim<5; ++lim) {
1980  if ((vec.r()>pLimits_[lim]) && (vec.r()<=pLimits_[lim+1])) {
1981  h_etaMipTracks[lim][indx][0]->Fill((double)(ieta));
1982  if (cut) h_etaMipTracks[lim][indx][1]->Fill((double)(ieta));
1983  if (e_inCone < cutNeutral_) {
1984  h_etaCalibTracks[lim][indx][0]->Fill((double)(ieta));
1985  if (cut) h_etaCalibTracks[lim][indx][1]->Fill((double)(ieta));
1986  }
1987  }
1988  }
1989  }
1990 }
1991 
1992 void IsoTrig::fillEnergy(int indx, int ieta, double hCone, double eMipDR, math::XYZTLorentzVector& vec) {
1993  int kk(-1);
1994  if (ieta > 0 && ieta < 25) kk = 23 + ieta;
1995  else if (ieta > -25 && ieta < 0) kk = -(ieta + 1);
1996  if (kk >= 0 && eMipDR > 0.01 && hCone > 1.0) {
1997  for (int lim=0; lim<5; ++lim) {
1998  if ((vec.r()>pLimits_[lim]) && (vec.r()<=pLimits_[lim+1])) {
1999  h_eHcal[lim][indx][kk] ->Fill(hCone);
2000  h_eCalo[lim][indx][kk] ->Fill(hCone+eMipDR);
2001  }
2002  }
2003  }
2004 }
2005 
2007  return (vec1.eta()-vec2.eta());
2008 }
2009 
2011 
2012  double phi1 = vec1.phi();
2013  if (phi1 < 0) phi1 += 2.0*M_PI;
2014  double phi2 = vec2.phi();
2015  if (phi2 < 0) phi2 += 2.0*M_PI;
2016  double dphi = phi1-phi2;
2017  if (dphi > M_PI) dphi -= 2.*M_PI;
2018  else if (dphi < -M_PI) dphi += 2.*M_PI;
2019  return dphi;
2020 }
2021 
2023  double deta = dEta(vec1,vec2);
2024  double dphi = dPhi(vec1,vec2);
2025  return std::sqrt(deta*deta + dphi*dphi);
2026 }
2027 
2029  return (vec1.pt()-vec2.pt());
2030 }
2031 
2033  return (std::abs(vec1.r()-vec2.r()));
2034 }
2035 
2037  return ((1/vec1.pt())-(1/vec2.pt()));
2038 }
2039 
2040 std::pair<double,double> IsoTrig::etaPhiTrigger() {
2041  double eta(0), phi(0), ptmax(0);
2042  for (unsigned int k=0; k<vec_[0].size(); ++k) {
2043  if (k == 0) {
2044  eta = vec_[0][k].eta();
2045  phi = vec_[0][k].phi();
2046  ptmax = vec_[0][k].pt();
2047  } else if (vec_[0][k].pt() > ptmax) {
2048  eta = vec_[0][k].eta();
2049  phi = vec_[0][k].phi();
2050  ptmax = vec_[0][k].pt();
2051  }
2052  }
2053  return std::pair<double,double>(eta,phi);
2054 }
2055 
2056 std::pair<double,double> IsoTrig::GetEtaPhiAtEcal(double etaIP, double phiIP,
2057  double pT, int charge,
2058  double vtxZ) {
2059 
2060  double deltaPhi=0;
2061  double etaEC = 100;
2062  double phiEC = 100;
2063 
2064  double Rcurv = 9999999;
2065  if (bfVal_!=0) Rcurv=pT*33.3*100/(bfVal_*10); //r(m)=pT(GeV)*33.3/B(kG)
2066 
2067  double ecDist = zEE_;
2068  double ecRad = rEB_; //radius of ECAL barrel (cm)
2069  double theta = 2*atan(exp(-etaIP));
2070  double zNew = 0;
2071  if (theta>0.5*M_PI) theta=M_PI-theta;
2072  if (fabs(etaIP)<1.479) {
2073  if ((0.5*ecRad/Rcurv)>1) {
2074  etaEC = 10000;
2075  deltaPhi = 0;
2076  } else {
2077  deltaPhi =-charge*asin(0.5*ecRad/Rcurv);
2078  double alpha1 = 2*asin(0.5*ecRad/Rcurv);
2079  double z = ecRad/tan(theta);
2080  if (etaIP>0) zNew = z*(Rcurv*alpha1)/ecRad+vtxZ; //new z-coordinate of track
2081  else zNew =-z*(Rcurv*alpha1)/ecRad+vtxZ; //new z-coordinate of track
2082  double zAbs=fabs(zNew);
2083  if (zAbs<ecDist) {
2084  etaEC = -log(tan(0.5*atan(ecRad/zAbs)));
2085  deltaPhi = -charge*asin(0.5*ecRad/Rcurv);
2086  }
2087  if (zAbs>ecDist) {
2088  zAbs = (fabs(etaIP)/etaIP)*ecDist;
2089  double Zflight = fabs(zAbs-vtxZ);
2090  double alpha = (Zflight*ecRad)/(z*Rcurv);
2091  double Rec = 2*Rcurv*sin(alpha/2);
2092  deltaPhi =-charge*alpha/2;
2093  etaEC =-log(tan(0.5*atan(Rec/ecDist)));
2094  }
2095  }
2096  } else {
2097  zNew = (fabs(etaIP)/etaIP)*ecDist;
2098  double Zflight = fabs(zNew-vtxZ);
2099  double Rvirt = fabs(Zflight*tan(theta));
2100  double Rec = 2*Rcurv*sin(Rvirt/(2*Rcurv));
2101  deltaPhi =-(charge)*(Rvirt/(2*Rcurv));
2102  etaEC =-log(tan(0.5*atan(Rec/ecDist)));
2103  }
2104 
2105  if (zNew<0) etaEC=-etaEC;
2106  phiEC = phiIP+deltaPhi;
2107 
2108  if (phiEC<-M_PI) phiEC += 2*M_PI;
2109  if (phiEC>M_PI) phiEC -= 2*M_PI;
2110 
2111  std::pair<double,double> retVal(etaEC,phiEC);
2112  return retVal;
2113 }
2114 
2115 double IsoTrig::getDistInCM(double eta1,double phi1, double eta2,double phi2) {
2116  double Rec;
2117  double theta1=2*atan(exp(-eta1));
2118  double theta2=2*atan(exp(-eta2));
2119  if (fabs(eta1)<1.479) Rec=rEB_; //radius of ECAL barrel
2120  else if (fabs(eta1)>1.479&&fabs(eta1)<7.0) Rec=tan(theta1)*zEE_; //distance from IP to ECAL endcap
2121  else return 1000;
2122 
2123  //|vect| times tg of acos(scalar product)
2124  double angle=acos((sin(theta1)*sin(theta2)*(sin(phi1)*sin(phi2)+cos(phi1)*cos(phi2))+cos(theta1)*cos(theta2)));
2125  if (angle<0.5*M_PI) return fabs((Rec/sin(theta1))*tan(angle));
2126  else return 1000;
2127 }
2128 
2129 //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
size
Write out results.
bool changed_
Definition: IsoTrig.cc:200
static const std::string kSharedResource
Definition: TFileService.h:76
double p() const
momentum vector magnitude
Definition: TrackBase.h:615
EventNumber_t event() const
Definition: EventID.h:41
std::vector< bool > * t_NFTrkPVFlag
Definition: IsoTrig.cc:244
std::vector< double > * t_PixTrkcandPhi
Definition: IsoTrig.cc:225
std::vector< double > * t_PixTrkcandP
Definition: IsoTrig.cc:222
const double a_coneR_
Definition: IsoTrig.cc:165
T getUntrackedParameter(std::string const &, T const &) const
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: IsoTrig.cc:111
std::string theTrackQuality_
Definition: IsoTrig.cc:161
edm::EDGetTokenT< reco::IsolatedPixelTrackCandidateCollection > tok_l2cand_
Definition: IsoTrig.cc:185
float alpha
Definition: AMPTWrapper.h:95
const unsigned int nTracks(const reco::Vertex &sv)
edm::Service< TFileService > fs_
Definition: IsoTrig.cc:202
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
const edm::InputTag l2CandTag_
Definition: IsoTrig.cc:153
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, std::string &theTrackQuality, bool debug=false)
edm::Handle< EcalRecHitCollection > endcapRecHitsHandle_
Definition: IsoTrig.cc:193
std::vector< double > * t_NFTrkMinDR
Definition: IsoTrig.cc:239
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: IsoTrig.cc:1098
int id() const
getters
Definition: TriggerObject.h:55
RunNumber_t run() const
Definition: RunBase.h:40
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:135
void chgIsolation(double &etaTriggered, double &phiTriggered, edm::Handle< reco::TrackCollection > &trkCollection, const edm::Event &theEvent)
Definition: IsoTrig.cc:1728
std::vector< bool > * t_NFTrkMissFlag
Definition: IsoTrig.cc:243
~IsoTrig() override
Definition: IsoTrig.cc:400
const bool doChgIsolTree_
Definition: IsoTrig.cc:156
TH1D * h_phi[20]
Definition: IsoTrig.cc:256
edm::EDGetTokenT< LumiDetails > tok_lumi_
Definition: IsoTrig.cc:169
edm::Handle< HBHERecHitCollection > hbhe_
Definition: IsoTrig.cc:191
std::vector< bool > * t_PixTrkcandselTk
Definition: IsoTrig.cc:227
TH1D * h_EnIn
Definition: IsoTrig.cc:251
std::vector< reco::TrackRef > pixelTrackRefsHB_
Definition: IsoTrig.cc:188
const double a_charIsoR_
Definition: IsoTrig.cc:165
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
TH1D * h_dEta[9]
Definition: IsoTrig.cc:258
const double a_neutR2_
Definition: IsoTrig.cc:166
float phi() const
Definition: TriggerObject.h:58
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::ESHandle< MagneticField > bFieldH_
Definition: IsoTrig.cc:189
TrackQuality
track quality
Definition: TrackBase.h:151
void studyIsolation(edm::Handle< reco::TrackCollection > &, std::vector< reco::TrackCollection::const_iterator > &)
Definition: IsoTrig.cc:1593
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< double > * t_NFTrkcandEta
Definition: IsoTrig.cc:236
std::vector< double > * t_NFcandP
Definition: IsoTrig.cc:229
void endJob() override
Definition: IsoTrig.cc:1072
const int verbosity_
Definition: IsoTrig.cc:157
TH1D * h_dEtaL1[2]
Definition: IsoTrig.cc:257
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const int maxRunNo_
Definition: IsoTrig.cc:168
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
Definition: IsoTrig.cc:176
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:111
TH1I * g_PreHLT
Definition: IsoTrig.cc:263
std::map< unsigned int, const std::pair< int, int > > trigPreList_
Definition: IsoTrig.cc:199
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< EcalRecHit >::const_iterator const_iterator
Geom::Theta< T > theta() const
int bunchCrossing() const
Definition: EventBase.h:66
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:63
edm::Handle< EcalRecHitCollection > barrelRecHitsHandle_
Definition: IsoTrig.cc:192
const double a_neutIsoR_
Definition: IsoTrig.cc:165
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:645
std::vector< int > * t_nPixSeed
Definition: IsoTrig.cc:206
std::vector< double > * t_TrkhCone
Definition: IsoTrig.cc:209
double rEB_
Definition: IsoTrig.cc:163
edm::EDGetTokenT< reco::IsolatedPixelTrackCandidateCollection > tok_pixtk_
Definition: IsoTrig.cc:183
std::vector< bool > * t_NFTrkqltyFlag
Definition: IsoTrig.cc:242
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::pair< double, double > GetEtaPhiAtEcal(double etaIP, double phiIP, double pT, int charge, double vtxZ)
Definition: IsoTrig.cc:2056
std::vector< double > * t_PixTrkcandMaxP
Definition: IsoTrig.cc:226
const double minPTrackValue_
Definition: IsoTrig.cc:159
edm::Handle< reco::BeamSpot > beamSpotH_
Definition: IsoTrig.cc:194
float energy() const
Definition: TriggerObject.h:65
std::vector< math::XYZTLorentzVector > vec_[3]
Definition: IsoTrig.cc:264
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:627
std::vector< bool > * t_NFTrkselTkFlag
Definition: IsoTrig.cc:241
#define nullptr
TH1I * h_HLT
Definition: IsoTrig.cc:253
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
double dP(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
Definition: IsoTrig.cc:2032
const double a_mipR_
Definition: IsoTrig.cc:166
std::vector< double > * t_PixcandP
Definition: IsoTrig.cc:217
std::pair< double, double > etaPhiTrigger()
Definition: IsoTrig.cc:2040
Strings const & triggerNames() const
Definition: TriggerNames.cc:24
edm::EDGetTokenT< trigger::TriggerEvent > tok_trigEvt_
Definition: IsoTrig.cc:170
TH1D * h_dP[9]
Definition: IsoTrig.cc:258
float lumiValue(AlgoType algo, unsigned int bx) const
Definition: LumiDetails.cc:92
const double tauUnbiasCone_
Definition: IsoTrig.cc:160
std::vector< bool > * t_NFTrkMipFlag
Definition: IsoTrig.cc:248
const double dr_L1_
Definition: IsoTrig.cc:165
void pushMipCutTreeVecs(math::XYZTLorentzVector &NFcand, math::XYZTLorentzVector &Trkcand, double &EmipNFcand, double &EmipTrkcand, double &mindR, double &mindP1, std::vector< bool > &Flags, double hCone)
Definition: IsoTrig.cc:782
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)
std::vector< double > * t_NFTrkMinDP1
Definition: IsoTrig.cc:240
TH1D * h_EnOut
Definition: IsoTrig.cc:251
edm::ESHandle< CaloGeometry > pG_
Definition: IsoTrig.cc:190
TH1D * h_dPhiL1[2]
Definition: IsoTrig.cc:257
TH1D * h_L1ObjEnergy
Definition: IsoTrig.cc:255
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: IsoTrig.cc:496
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
const std::vector< edm::InputTag > pixelTracksSources_
Definition: IsoTrig.cc:154
void studyMipCut(edm::Handle< reco::TrackCollection > &trkCollection, edm::Handle< reco::IsolatedPixelTrackCandidateCollection > &L2cands)
Definition: IsoTrig.cc:1341
HLTPrescaleProvider hltPrescaleProvider_
Definition: IsoTrig.cc:151
double dinvPt(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
Definition: IsoTrig.cc:2036
const bool doMipCutTree_
Definition: IsoTrig.cc:155
TH1D * h_dPhi[9]
Definition: IsoTrig.cc:258
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes_
Definition: IsoTrig.cc:171
T mag() const
Definition: PV3DBase.h:67
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:651
void studyTrigger(edm::Handle< reco::TrackCollection > &, std::vector< reco::TrackCollection::const_iterator > &)
Definition: IsoTrig.cc:1469
void fillHist(int, math::XYZTLorentzVector &)
Definition: IsoTrig.cc:1947
std::vector< double > * t_NFTrkcandP
Definition: IsoTrig.cc:234
edm::EDGetTokenT< SeedingLayerSetsHits > tok_SeedingLayerHB_
Definition: IsoTrig.cc:180
std::vector< bool > * t_TrkNuIsolFlag
Definition: IsoTrig.cc:215
TH1I * h_nHLT
Definition: IsoTrig.cc:253
std::map< unsigned int, unsigned int > trigList_
Definition: IsoTrig.cc:198
edm::EDGetTokenT< reco::BeamSpot > tok_bs_
Definition: IsoTrig.cc:175
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
const double prelimCone_
Definition: IsoTrig.cc:160
std::vector< bool > * t_TrkPVFlag
Definition: IsoTrig.cc:214
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
std::vector< double > * t_ECone
Definition: IsoTrig.cc:249
std::vector< double > vec1
Definition: HCALResponse.h:15
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
T sqrt(T t)
Definition: SSEVec.h:18
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:167
edm::EDGetTokenT< reco::TrackCollection > tok_genTrack_
Definition: IsoTrig.cc:173
const double a_neutR1_
Definition: IsoTrig.cc:166
double pt() const
track transverse momentum
Definition: TrackBase.h:621
TH1I * h_Pre
Definition: IsoTrig.cc:254
TH1I * h_PreHLT
Definition: IsoTrig.cc:253
TH1D * h_dinvPt[9]
Definition: IsoTrig.cc:259
void fillEnergy(int, int, double, double, math::XYZTLorentzVector &)
Definition: IsoTrig.cc:1992
double zEE_
Definition: IsoTrig.cc:163
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::vector< bool > * t_NFTrkChgIsoFlag
Definition: IsoTrig.cc:246
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
std::vector< edm::EDGetTokenT< reco::TrackCollection > > tok_pixtks_
Definition: IsoTrig.cc:186
std::vector< double > * t_TrkP
Definition: IsoTrig.cc:210
TH1D * h_eta[20]
Definition: IsoTrig.cc:256
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
std::pair< T, T > etaphi(T x, T y, T z)
Definition: FastMath.h:128
TH1I * h_Filters
Definition: IsoTrig.cc:254
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
spr::trackSelectionParameters selectionParameters_
Definition: IsoTrig.cc:164
std::vector< double > * t_NFcandEta
Definition: IsoTrig.cc:231
edm::EDGetTokenT< SeedingLayerSetsHits > tok_SeedingLayerHE_
Definition: IsoTrig.cc:181
std::vector< double > * t_timeL2Prod
Definition: IsoTrig.cc:204
void beginJob() override
Definition: IsoTrig.cc:810
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)
TH1D * h_eHcal[5][6][48]
Definition: IsoTrig.cc:262
LuminosityBlock const & getLuminosityBlock() const
Definition: Event.h:100
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
Definition: IsoTrig.cc:177
static std::string const triggerResults
Definition: EdmProvDump.cc:41
IsoTrig(const edm::ParameterSet &)
Definition: IsoTrig.cc:268
std::vector< double > * t_PixcandPt
Definition: IsoTrig.cc:218
bool isValid() const
Definition: HandleBase.h:74
TH1D * h_PreL1wt
Definition: IsoTrig.cc:255
std::vector< double > * t_NFcandEmip
Definition: IsoTrig.cc:233
TH1D * h_eMaxNearP[2]
Definition: IsoTrig.cc:260
double dPhi(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
Definition: IsoTrig.cc:2010
void studyTiming(const edm::Event &theEvent)
Definition: IsoTrig.cc:1223
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
const bool doTrkResTree_
Definition: IsoTrig.cc:156
void clearChgIsolnTreeVectors()
Definition: IsoTrig.cc:724
ii
Definition: cuy.py:588
#define M_PI
std::vector< bool > * t_NFTrkPropFlag
Definition: IsoTrig.cc:245
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:639
std::vector< reco::TrackRef > pixelTrackRefsHE_
Definition: IsoTrig.cc:188
std::vector< double > * t_NFTrkcandPhi
Definition: IsoTrig.cc:237
int k[5][pyjets_maxn]
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
unsigned int id
TH2D * h_MipEnMatch
Definition: IsoTrig.cc:252
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
TH1D * h_p[20]
Definition: IsoTrig.cc:256
TH1D * h_eNeutIso[2]
Definition: IsoTrig.cc:260
TH1I * h_PreL1
Definition: IsoTrig.cc:253
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
const double cutCharge_
Definition: IsoTrig.cc:167
Float e1
Definition: deltaR.h:20
const edm::InputTag filterTag(trigger::size_type index) const
Definition: TriggerEvent.h:103
std::vector< bool > * t_TrkMissFlag
Definition: IsoTrig.cc:213
double getDistInCM(double eta1, double phi1, double eta2, double phi2)
Definition: IsoTrig.cc:2115
edm::EDGetTokenT< reco::VertexCollection > tok_recVtx_
Definition: IsoTrig.cc:174
TTree * ChgIsolnTree_
Definition: IsoTrig.cc:203
std::vector< int > * t_nPixCand
Definition: IsoTrig.cc:205
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:125
#define debug
Definition: HDRShower.cc:19
void StudyTrkEbyP(edm::Handle< reco::TrackCollection > &trkCollection)
Definition: IsoTrig.cc:1103
std::vector< double > * t_NFTrkcandPt
Definition: IsoTrig.cc:235
TH1D * h_eCalo[5][6][48]
Definition: IsoTrig.cc:262
T const * product() const
Definition: Handle.h:81
TH1I * g_Pre
Definition: IsoTrig.cc:263
const bool doStudyIsol_
Definition: IsoTrig.cc:156
const edm::InputTag pixCandTag_
Definition: IsoTrig.cc:153
auto dp
Definition: deltaR.h:22
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::vector< size_type > Keys
std::vector< double > * t_PixTrkcandPt
Definition: IsoTrig.cc:223
double dEta(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
Definition: IsoTrig.cc:2006
const T & get() const
Definition: EventSetup.h:58
edm::EDGetTokenT< reco::VertexCollection > tok_verthb_
Definition: IsoTrig.cc:179
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< double > * t_NFcandPt
Definition: IsoTrig.cc:230
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: IsoTrig.cc:448
std::pair< int, int > prescaleValues(const edm::Event &iEvent, const edm::EventSetup &iSetup, const std::string &trigger)
Combined L1T (pair.first) and HLT (pair.second) prescales per HLT path.
edm::Handle< reco::VertexCollection > recVtxs_
Definition: IsoTrig.cc:195
const int minRunNo_
Definition: IsoTrig.cc:168
Float e2
Definition: deltaR.h:21
TH1D * h_pt[20]
Definition: IsoTrig.cc:256
std::vector< bool > * t_TrkqltyFlag
Definition: IsoTrig.cc:212
HLTConfigProvider const & hltConfigProvider() const
TH1D * h_etaMipTracks[5][2][2]
Definition: IsoTrig.cc:261
const std::string processName_
Definition: IsoTrig.cc:162
std::string const & label() const
Definition: InputTag.h:36
std::vector< std::vector< double > > * t_PixcandMaxP
Definition: IsoTrig.cc:221
std::vector< double > * t_NFTrkcandEmip
Definition: IsoTrig.cc:238
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_l1cand_
Definition: IsoTrig.cc:184
size_type size() const
edm::EventID id() const
Definition: EventBase.h:60
const double vtxCutIsol_
Definition: IsoTrig.cc:159
HLT enums.
double dR(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
Definition: IsoTrig.cc:2022
TTree * MipCutTree_
Definition: IsoTrig.cc:203
const edm::InputTag l1CandTag_
Definition: IsoTrig.cc:153
TH1D * h_mindR[9]
Definition: IsoTrig.cc:259
void clearMipCutTreeVectors()
Definition: IsoTrig.cc:740
edm::EDGetTokenT< SiPixelRecHitCollection > tok_SiPixelRecHits_
Definition: IsoTrig.cc:182
std::vector< double > * t_PixcandEta
Definition: IsoTrig.cc:219
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
Definition: IsoTrig.cc:178
static int position[264][3]
Definition: ReadPGInfo.cc:509
TTree * TrkResTree_
Definition: IsoTrig.cc:203
reco::TrackBase::TrackQuality minQuality
StreamID streamID() const
Definition: Event.h:95
void fillDifferences(int, math::XYZTLorentzVector &, math::XYZTLorentzVector &, bool)
Definition: IsoTrig.cc:1954
TH1D * h_dPt[9]
Definition: IsoTrig.cc:258
TH2D * h_MipEnNoMatch
Definition: IsoTrig.cc:252
double dPt(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
Definition: IsoTrig.cc:2028
std::vector< bool > * t_NFTrkNeuIsoFlag
Definition: IsoTrig.cc:247
const Point & position() const
position
Definition: BeamSpot.h:62
std::vector< double > * t_PixcandPhi
Definition: IsoTrig.cc:220
const bool doTiming_
Definition: IsoTrig.cc:155
std::vector< double > * t_PixTrkcandEta
Definition: IsoTrig.cc:224
std::vector< int > * t_nGoodTk
Definition: IsoTrig.cc:207
TH1I * g_PreL1
Definition: IsoTrig.cc:263
float mass() const
Definition: TriggerObject.h:59
edm::EDGetTokenT< reco::VertexCollection > tok_verthe_
Definition: IsoTrig.cc:179
double queryModuleTimeByLabel(edm::StreamID, std::string const &module) const
math::XYZPoint leadPV_
Definition: IsoTrig.cc:196
const std::vector< double > pixelIsolationConeSizeAtEC_
Definition: IsoTrig.cc:158
const double cutMip_
Definition: IsoTrig.cc:166
TH1I * h_nL3Objs
Definition: IsoTrig.cc:254
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_hlt_
Definition: IsoTrig.cc:172
void getGoodTracks(const edm::Event &, edm::Handle< reco::TrackCollection > &)
Definition: IsoTrig.cc:1853
std::vector< vec1 > vec2
Definition: HCALResponse.h:16
TH1D * h_dRL1[2]
Definition: IsoTrig.cc:257
const double cutNeutral_
Definition: IsoTrig.cc:167
double pLimits_[6]
Definition: IsoTrig.cc:201
TH1D * h_etaCalibTracks[5][2][2]
Definition: IsoTrig.cc:261
unsigned short size() const
Get the number of SeedingLayerSets.
std::vector< bool > * t_TrkselTkFlag
Definition: IsoTrig.cc:211
T const * product() const
Definition: ESHandle.h:86
const std::vector< std::string > trigNames_
Definition: IsoTrig.cc:152
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:301
const double vtxCutSeed_
Definition: IsoTrig.cc:159
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:633
void fillCuts(int, double, double, double, math::XYZTLorentzVector &, int, bool)
Definition: IsoTrig.cc:1974
Definition: Run.h:43
double bfVal_
Definition: IsoTrig.cc:163
TH1D * h_PreHLTwt
Definition: IsoTrig.cc:255
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)
void pushChgIsolnTreeVecs(math::XYZTLorentzVector &Pixcand, math::XYZTLorentzVector &Trkcand, std::vector< double > &PixMaxP, double &TrkMaxP, bool &selTk)
Definition: IsoTrig.cc:764
TTree * TimingTree_
Definition: IsoTrig.cc:203
TH1I * g_Accepts
Definition: IsoTrig.cc:263
const bool doL2L3_
Definition: IsoTrig.cc:155
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
TH1D * h_eMip[2]
Definition: IsoTrig.cc:259
std::vector< double > * t_NFcandPhi
Definition: IsoTrig.cc:232