DAS  3.0
Das Analysis System
Ntupliser

#include <Ntupliser.h>

+ Inheritance diagram for Ntupliser:
+ Collaboration diagram for Ntupliser:

Public Types

typedef reco::Particle::LorentzVector LorentzVector
 

Public Member Functions

 Ntupliser (edm::ParameterSet const &cfg)
 
virtual void beginJob () override
 
virtual void beginRun (edm::Run const &iRun, edm::EventSetup const &iSetup) override
 
virtual void endRun (edm::Run const &iRun, edm::EventSetup const &iSetup) override
 
virtual void analyze (edm::Event const &iEvent, edm::EventSetup const &iSetup) override
 
virtual void endJob () override
 
virtual ~Ntupliser () override
 

Private Member Functions

void reset ()
 
void initialise (edm::Event const &iEvent)
 
bool trigger (edm::Event const &iEvent)
 
void fillMET (edm::Event const &iEvent)
 
void getHLTjets (edm::Event const &iEvent)
 
template<typename MyJetCollection >
void getGenJets (edm::Handle< MyJetCollection > &mygenjets)
 
void getRecJets ()
 
void getGenMuons ()
 
void getRecMuons ()
 
void getGenPhotons ()
 
void getRecPhotons ()
 
void getSecVertices ()
 
void getEventVariables (edm::Event const &iEvent)
 

Private Attributes

DAS::Parameters p
 
DAS::Helper h
 
edm::Handle< reco::GenJetCollection > genjets
 
edm::Handle< pat::JetCollection > recjets
 
edm::Handle< edm::View< reco::Candidate > > genLeptons
 
edm::Handle< pat::MuonCollection > recmuons
 
edm::Handle< pat::PhotonCollection > recphotons
 
edm::Handle< pat::METCollection > met
 
edm::Handle< double > rho
 
edm::Handle< reco::VertexCollection > recVtxs
 
edm::Handle< edm::TriggerResults > triggerResults
 
edm::Handle< edm::TriggerResults > metResults
 
edm::Handle< pat::PackedTriggerPrescales > triggerPrescales
 
edm::Handle< pat::PackedTriggerPrescales > triggerPrescalesl1min
 
edm::Handle< pat::PackedTriggerPrescales > triggerPrescalesl1max
 
edm::Handle< pat::TriggerObjectStandAloneCollection > triggerObjects
 
edm::Handle< GenEventInfoProduct > genEvtInfo
 
edm::Handle< reco::GenParticleCollection > genParticles
 
edm::Handle< reco::JetFlavourInfoMatchingCollection > theJetFlavourInfos
 
edm::Handle< std::vector< reco::VertexCompositePtrCandidate > > SVs
 
edm::Handle< std::vector< PileupSummaryInfo > > pileupInfo
 
edm::Service< TFileService > fs_
 
TTree * tree
 
Darwin::Tools::UserInfo metainfo
 
std::vector< DAS::RecJet > * recJets_
 
std::vector< DAS::FourVector > * HLTjets_
 
std::vector< DAS::GenJet > * genJets_
 
std::vector< DAS::RecMuon > * recMuons_
 
std::vector< DAS::GenMuon > * genMuons_
 
std::vector< DAS::RecPhoton > * recPhotons_
 
std::vector< DAS::GenPhoton > * genPhotons_
 
DAS::TriggerjetTrigger_
 
DAS::TriggermuonTrigger_
 
DAS::TriggerzbTrigger_
 
DAS::GenEventgenEvent_
 
DAS::RecEventrecEvent_
 
DAS::METmet_
 
DAS::PileUppileup_
 
DAS::PrimaryVertexprimaryvertex_
 
boost::property_tree::ptree pileup_json
 

Member Typedef Documentation

◆ LorentzVector

typedef reco::Particle::LorentzVector LorentzVector

Constructor & Destructor Documentation

◆ Ntupliser()

Ntupliser ( edm::ParameterSet const &  cfg)
explicit

Constructor, only initialising the members.

39  :
40  p(cfg, consumesCollector()), h(p),
41  tree(fs_->make<TTree>("events","events")),
43  // jets
44  recJets_(p.jets ? new vector<DAS::RecJet> : nullptr),
45  HLTjets_(p.jets && p.triggers ? new vector<DAS::FourVector> : nullptr),
46  genJets_(p.jets && p.isMC ? new vector<DAS::GenJet> : nullptr),
47  // muons
48  recMuons_( p.muons ? new vector<DAS::RecMuon> : nullptr),
49  genMuons_(p.isMC && p.muons ? new vector<DAS::GenMuon> : nullptr),
50  // photons
51  recPhotons_( p.photons ? new vector<DAS::RecPhoton> : nullptr),
52  genPhotons_(p.isMC && p.photons ? new vector<DAS::GenPhoton> : nullptr),
53  // event variables
54  jetTrigger_ (p.triggers ? new DAS::Trigger : nullptr),
55  muonTrigger_ (p.triggers ? new DAS::Trigger : nullptr),
56  zbTrigger_ (p.triggers ? new DAS::Trigger : nullptr),
57  genEvent_ (p.isMC ? new DAS::GenEvent : nullptr),
58  recEvent_ ( new DAS::RecEvent ),
59  met_ (new DAS::MET ),
60  pileup_ (new DAS::PileUp ),
62 {
63  cout << __FILE__ << ':' << __func__ << endl;
64 
65  using namespace DAS;
66 
67  if (p.photons) // photon variations
68  for (TString source: RecPhoton::uncs) {
69  metainfo.Set<TString>("variations", RecPhoton::ScaleVar, source + SysDown);
70  metainfo.Set<TString>("variations", RecPhoton::ScaleVar, source + SysUp);
71  }
72 }
73 catch (boost::exception& e) {
74  throw cms::Exception("Ntupliser") << boost::diagnostic_information(e);
75 }

◆ ~Ntupliser()

~Ntupliser ( )
overridevirtual
679 {
680 }

Member Function Documentation

◆ analyze()

void analyze ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup 
)
overridevirtual
302 {
303  // reset and initialise member variables (filled to the tree)
304  reset();
305  initialise(iEvent);
306 
307  // check trigger
308  if (p.triggers) {
309  bool passTrigger = trigger(iEvent);
310  if (!p.isMC && !passTrigger) return;
311  if (p.jets)
312  getHLTjets(iEvent); //Fill High-Level-Trigger jets
313  }
314  fillMET(iEvent);
315 
316  // event variables
317  getEventVariables(iEvent);
318 
319  // jet variables
320  if (p.jets) {
321  getRecJets();
322  if (p.isMC) {
323  if (p.flavour)
325  else
327  }
328  }
329 
330  // muon variables
331  if (p.muons) {
332  getRecMuons();
333  if (p.isMC)
334  getGenMuons();
335  }
336 
337  // photon variables
338  if (p.photons) {
339  getRecPhotons();
340  if (p.isMC)
341  getGenPhotons();
342  }
343 
344  tree->Fill();
345 }

◆ beginJob()

void beginJob ( )
overridevirtual

Called before looping over the events.

Basically, it set up the branches.

231 {
232  cout << __FILE__ << ':' << __func__ << endl;
233 
234  if (!p.isMC) {
235  const auto luminosity = p.config.get_child_optional("luminosity");
236  if (luminosity && luminosity->count("pileup")) {
237  auto pileup = luminosity->get<fs::path>("pileup");
238  cout << "Extracting pileup normalisation from " << pileup << endl;
239  if (p.sandbox) pileup = pileup.filename();
240  if (!fs::exists(pileup))
241  throw cms::Exception("Ntupliser") << pileup << " could not be found";
242  pt::read_json(pileup.string(), pileup_json);
243  }
244  else cout << "\x1B[33mNo input pileup normalisation\x1B[0m" << endl;
245  }
246 
247  // event
248  if (p.isMC)
249  tree->Branch("genEvent",&genEvent_);
250  tree->Branch("recEvent",&recEvent_);
251  if (p.triggers) {
252  tree->Branch("jetTrigger",&jetTrigger_);
253  tree->Branch("muonTrigger",&muonTrigger_);
254  tree->Branch("zbTrigger",&zbTrigger_);
255  }
256 
257  tree->Branch("pileup",&pileup_);
258  tree->Branch("primaryvertex",&primaryvertex_);
259  tree->Branch("met",&met_);
260 
261  // jets
262  if (p.jets) {
263  tree->Branch("recJets",&recJets_);
264  if (p.triggers)
265  tree->Branch("hltJets", &HLTjets_);
266  if (p.isMC)
267  tree->Branch("genJets", &genJets_);
268  }
269 
270  // muons
271  if (p.muons) {
272  tree->Branch("recMuons",&recMuons_);
273  if (p.isMC)
274  tree->Branch("genMuons", &genMuons_);
275  }
276 
277  // photons
278  if (p.photons) {
279  tree->Branch("recPhotons", &recPhotons_);
280  if (p.isMC)
281  tree->Branch("genPhotons", &genPhotons_);
282  }
283 }

◆ beginRun()

void beginRun ( edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
overridevirtual
292 {
293  cout << __FILE__ << ':' << __func__ << endl;
294 }

◆ endJob()

void endJob ( )
overridevirtual
287 {
288  metainfo.Set<bool>("git", "complete", true);
289  cout << __FILE__ << ':' << __func__ << endl;
290 }

◆ endRun()

void endRun ( edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
overridevirtual
296 {
297  cout << __FILE__ << ':' << __func__ << endl;
298 }

◆ fillMET()

void fillMET ( edm::Event const &  iEvent)
private

Fill the MET flags to the array.

528 {
529  const edm::TriggerNames &namesMet = iEvent.triggerNames(*metResults);
530  for(unsigned int k=0; k < p.metNames_.size(); ++k) {
531  bool bit(false);
532  for(unsigned int itrig=0; itrig<metResults->size(); ++itrig) {
533  string met_name = string(namesMet.triggerName(itrig));
534  if (met_name == p.metNames_[k]) {
535  bit = metResults->accept(itrig);
536  break;
537  }
538  }
539  met_->Bit.push_back(bit);
540  }
541 }

◆ getEventVariables()

void getEventVariables ( edm::Event const &  iEvent)
private

Gets information about the event (run number, etc.), the pile-up, the MET and the primary vertex.

https://cmsdoxygen.web.cern.ch/cmsdoxygen/CMSSW_10_6_19/doc/html/d9/d53/classPileupSummaryInfo.html

Todo:
check out-of-time pileup
Todo:
compare to (*met)[0].pt() to (*met)[0].uncorPt()
587 {
588  // event
589  recEvent_->runNo = iEvent.id().run(); // note: always 1 for MC
590  recEvent_->evtNo = iEvent.id().event();
591  recEvent_->lumi = iEvent.id().luminosityBlock();
592 
593  recEvent_->weights.resize(1);
594  recEvent_->weights.front() = 1;
595 
596  if (p.isMC) {
597  genEvent_->hard_scale = genEvtInfo->qScale();
598 #ifdef PS_WEIGHTS
599 #error "Generator weights haven't been tested yet! Implementation may not be ready"
600  // model variations
601  auto& weights = lhe->weights();
602  for (auto& w: weights) {
603  cout << "Weight " << w.id << " " << w.wgt << '\n';
604  genEvent_->weights.push_back(w.wgt);
605  }
606  cout << flush;
607 #else
608  genEvent_->weights.resize(1);
609  genEvent_->weights.front() = genEvtInfo->weight();
610 #endif
611  }
612 
613  // pile-up
614  // https://cmsdoxygen.web.cern.ch/cmsdoxygen/CMSSW_12_4_0/doc/html/d9/d53/classPileupSummaryInfo.html
615  pileup_->rho = *rho;
616  pileup_->nVtx = recVtxs->size();
617  if (p.isMC)
618  for(auto PUI = pileupInfo->begin(); PUI != pileupInfo->end(); ++PUI) {
619  if (PUI->getBunchCrossing() != 0) continue;
620 
621  // for pile-up profile correction
622  // Adapted from [TWiki](https://twiki.cern.ch/twiki/bin/viewauth/CMS/PileupJSONFileforData):
623  // In order to do reasonable comparisons between data and MC, it is necessary to understand exactly what the histogram produced by pileupCalc.py means so that it can be compared with the correct quantity in MC.
624  // The way that pileup events are generated in MC, given an input pileup distribution, is as follows:
625  pileup_->trpu = PUI->getTrueNumInteractions(); // average pileup conditions under which the event is generated
626  pileup_->intpu = PUI->getPU_NumInteractions(); // the number of pileup events for the in-time bunch crossing is selected from a Poisson distribution with a mean equal to the "true" pileup
627 
628  // for pile-up staub cleaning
629  auto &ptHatVec = PUI->getPU_pT_hats();
630  pileup_->pthats = ptHatVec;
631 
632  const vector<edm::EventID>& evtIDs = PUI->getPU_EventID();
633  for (const auto& evtID: evtIDs)
634  pileup_->MBevents.push_back(evtID.event());
635  }
636  else if (pileup_json.size() > 0) {
637  auto runNo = to_string(iEvent.id().run());
638  auto run = pileup_json.get_child_optional(runNo);
639  if (!run)
640  throw cms::Exception("Ntupliser") << runNo << " could not be found in the pileup latest file";
641  for (auto& LS: *run) {
642  auto it = LS.second.begin(); // ["LS", "inst lumi", "xsec RMS", "av xsec"]
643  auto LSno = it->second.get_value<unsigned int>(); // LS
644  if (LSno != iEvent.id().luminosityBlock()) continue;
645  ++it; //auto instLumi = it->second.get_value<float>(); // inst lumi
646  ++it; //auto xsecRMS = it->second.get_value<float>(); // xsec RMS
647  ++it; auto avXsec = it->second.get_value<float>(); // av xsec
648  pileup_->trpu = avXsec * DAS::PileUp::MBxsec;
649  break;
650  }
651  }
652 
653  // primary vertex
654  const auto& PV = (*recVtxs)[0];
655  primaryvertex_->Rho = PV.position().Rho();
656  primaryvertex_->z = PV.z();
657  primaryvertex_->ndof = PV.ndof();
658  primaryvertex_->chi2 = PV.chi2();
659  primaryvertex_->fake = PV.isFake();
660  if (p.isMC) {
661  const auto& rv = PV.position();
662  const auto& gv = (*genParticles)[0].daughter(0)->vertex();
663  primaryvertex_->distGen = hypot( rv.x() - gv.x(),
664  hypot( rv.y() - gv.y(),
665  rv.z() - gv.z()) );
666  }
667 
668  // MET
669  met_->Et = (*met)[0].et();
670  met_->SumEt = (*met)[0].sumEt();
671  met_->Pt = (*met)[0].pt();
672  met_->Phi = (*met)[0].phi();
673  // https://twiki.cern.ch/twiki/bin/viewauth/CMS/MissingETRun2Corrections#Type_I_Correction_Propagation_of
674  // https://twiki.cern.ch/twiki/bin/view/CMS/MissingETUncertaintyPrescription
675 }

◆ getGenJets()

void getGenJets ( edm::Handle< MyJetCollection > &  mygenjets)
private

Finds the reconstructed jets, and applies some hard cuts on the phase space.

MyJetCollection is expected to be either JetCollection or JetFlavourInfoMatchingCollection (according to the flavour flag)

Todo:
externalize option for phase space cut
Note
slimmedJets are only defined from 10 GeV
144 {
145  //for ((typename MyJetCollection)::const_iterator itJet = mygenjets->begin();
146  for (auto itJet = mygenjets->begin();
147  itJet != mygenjets->end(); ++itJet) {
148 
149  // we convert the complicated CMSSW object to our simple DAS object
150  DAS::GenJet genjet = h.GetGenJet(*itJet);
151 
152  // we keep only jet with pt > 20 GeV and in the tracker acceptance
153  //if (genjet.p4.Pt() < 10 /* GeV */ || abs(genjet.p4.Eta()) > 5.0) continue;
156 
157  genJets_->push_back(genjet);
158  }
159 
160  Sort<DAS::GenJet>(genJets_);
161 }

◆ getGenMuons()

void getGenMuons ( )
private

Finds the generated muons, and applies some hard cuts on the phase space.

80 {
81  for (const reco::Candidate &lepton: *genLeptons) {
82  if (abs(lepton.pdgId()) != 13) continue;
83 
84  // we convert the complicated CMSSW object to our simple DAS object
85  DAS::GenMuon genmu = h.GetGenMu(lepton);
86 
87  // we keep only get with pt > 15 GeV and |eta| < 3.0 (to have a margin
88  // w.r.t. tracker acceptance and treat migrations)
89  if (genmu.p4.Pt() < 10 /* GeV */ || abs(genmu.p4.Eta()) > 3.0) continue;
90 
91  genMuons_->push_back(genmu);
92  }
93 
94  Sort<DAS::GenMuon>(genMuons_);
95 }

◆ getGenPhotons()

void getGenPhotons ( )
private

Finds the generated photons and applies some hard cuts to the phase space.

107 {
108  // Collect charged leptons that would be dressed
109  vector<const reco::GenParticle *> charged_leptons;
110  for (const reco::GenParticle &gp: *genParticles) {
111  auto id = abs(gp.pdgId());
112  if (gp.status() == 1 && (id == 11 || id == 13))
113  charged_leptons.push_back(&gp);
114  }
115 
116  for (const reco::GenParticle &gp: *genParticles) {
117  // Consider stable (status 1) photons
118  if (gp.status() != 1 || gp.pdgId() != 22) continue;
119 
120  // Phase space cuts
121  const bool zAncestor = hasZAncestor(gp);
122  if (zAncestor && gp.pt() < 1) continue;
123  if (!zAncestor && (gp.pt() < 10 || abs(gp.eta()) > 3.0)) continue;
124 
125  // We store dressed leptons. Remove any photon falling within the
126  // dressing cones, since we'd have no way of removing them afterwards.
127  if (any_of(charged_leptons.begin(), charged_leptons.end(),
128  [gp](auto lep) { return reco::deltaR(lep->p4(), gp.p4()) < 0.1; }))
129  continue;
130 
131  genPhotons_->push_back(h.GetGenPhoton(gp, zAncestor));
132  }
133 
134  Sort<DAS::GenPhoton>(genPhotons_);
135 }

◆ getHLTjets()

void getHLTjets ( edm::Event const &  iEvent)
private

Finds HLT jets and simply stores them in a FourVector.

546 {
547  const auto &names = iEvent.triggerNames(*triggerResults);
548 
549  // loop over all possible triggers and only keep object from the PFJet
550  // triggers
551  for (pat::TriggerObjectStandAlone obj: *triggerObjects){
552  obj.unpackPathNames(names);
553  //vector<string> pathNamesAll = obj.pathNames(false);
554  vector<string> pathNamesLast = obj.pathNames(true);
555 
556  // first, look if the HLT object is a HLT jet
557  bool isHLTjet = false;
558  string sNow;
559  for (auto s: pathNamesLast) {
560  s = DelLastDigits(s); // remove the version of the trigger (i.e. HLT_PFJetXX_v*)
561  if (p.HLTjet_triggerNames.count(s) == 0) continue; // typically ignore mu triggers
562  isHLTjet = true;
563  sNow = s;
564  break;
565  }
566 
567  // then add it unless it has already been added
568  if(isHLTjet) {
569  DAS::FourVector P4(obj.pt(), obj.eta(), obj.phi(), obj.mass());
570  bool isIn = false;
571  for(const auto &v : *HLTjets_)
572  if(v == P4) {isIn = true; break;}
573  if(!isIn)
574  HLTjets_->push_back(P4);
575  }
576  }
577 
578  Sort<DAS::FourVector>(HLTjets_);
579 }

◆ getRecJets()

void getRecJets ( )
private

Finds the reconstructed jets, and applies some hard cuts on the phase space.

Todo:
externalize option for phase space cut
205 {
206  for(pat::JetCollection::const_iterator itJet = recjets->begin();
207  itJet != recjets->end(); ++itJet) {
208 
209  // we convert the complicated CMSSW object to our simple DAS object
210  DAS::RecJet recjet = h.GetRecJet(*itJet);
211 
212  // we keep all jets and give set the weight to 0 for jets not fullfiling the quality criterion
213  if (!h.TightLepVetoID(*itJet)) recjet.weights.front() = 0.;
214 
215  // we keep only jet with pt > 20 GeV and in the tracker acceptance
216  //if (recjet.p4.Pt() < 10 /* GeV */ || abs(recjet.p4.Eta()) > 5.0) continue;
218  // (note: slimmedJets are only defined from 10 GeV)
219 
220  recJets_->push_back(recjet);
221  }
222 
223  Sort<DAS::RecJet>(recJets_);
224 }

◆ getRecMuons()

void getRecMuons ( )
private

Finds the reconstructed muons, and applies some hard cuts on the phase space.

166 {
167  for(pat::MuonCollection::const_iterator itMu = recmuons->begin();
168  itMu != recmuons->end(); ++itMu) {
169 
170  // we convert the complicated CMSSW object to our simple DAS object
171  DAS::RecMuon recmu = h.GetRecMu(*itMu);
172 
173  // we keep only muons with pt > 10 GeV and in the muon chamber acceptance
174  if (recmu.p4.Pt() < 10 /* GeV */ || abs(recmu.p4.Eta()) > 2.4) continue;
175 
176  recMuons_->push_back(recmu);
177  }
178 
179  Sort<DAS::RecMuon>(recMuons_);
180 }

◆ getRecPhotons()

void getRecPhotons ( )
private

Finds the reconstructed photons, and applies some hard cuts on the phase space.

185 {
186  for (pat::PhotonCollection::const_iterator it = recphotons->begin();
187  it != recphotons->end(); ++it) {
188 
189  // we convert the complicated CMSSW object to our simple DAS object
191 
192  // we keep only photons with pt > 5 GeV
193  if (recphoton.p4.Pt() < 5 /* GeV */) continue;
194 
195  recPhotons_->push_back(recphoton);
196  }
197 
198  Sort<DAS::RecPhoton>(recPhotons_);
199 }

◆ getSecVertices()

void getSecVertices ( )
private

◆ initialise()

void initialise ( edm::Event const &  iEvent)
private

Called at the beginning of each new event.

387 {
388  // jets
389  if (p.isMC) {
390 #ifdef PS_WEIGHTS
391  iEvent.getByToken(p.lheToken);
392 #endif
393  iEvent.getByToken(p.genEvtInfoToken, genEvtInfo);
394  if (p.jets) {
395  iEvent.getByToken(p.genjetsToken, genjets);
396  if (p.flavour)
397  iEvent.getByToken(p.jetFlavourInfosToken, theJetFlavourInfos );
398  }
399  iEvent.getByToken(p.genParticlesToken, genParticles);
400  }
401  if (p.jets)
402  iEvent.getByToken(p.recjetsToken, recjets);
403 
404  // muons
405  if (p.muons) {
406  if (p.isMC)
407  iEvent.getByToken(p.genLeptonsToken, genLeptons);
408  iEvent.getByToken(p.recmuonsToken, recmuons);
409  }
410 
411  // photons
412  if (p.photons)
413  iEvent.getByToken(p.recphotonsToken, recphotons);
414 
415  // pile-up
416  if (p.isMC)
417  iEvent.getByToken(p.pileupInfoToken, pileupInfo);
418  iEvent.getByToken(p.rhoToken,rho);
419 
420  // vertex
421  iEvent.getByToken(p.recVtxsToken,recVtxs);
422 
423  // trigger
424  if (p.triggers) {
425  iEvent.getByToken(p.triggerResultsToken, triggerResults);
426  iEvent.getByToken(p.triggerObjectsToken, triggerObjects);
427 
428  // HLT
429  iEvent.getByToken(p.triggerPrescalesToken,triggerPrescales);
430 
431  // L1
434  }
435 
436  // MET
437  iEvent.getByToken(p.metToken,met);
438  iEvent.getByToken(p.metResultsToken, metResults);
439 }

◆ reset()

void reset ( )
private

Just a common method to reset all branches at each new event.

350 {
351  if (p.isMC)
352  genEvent_->clear();
353  recEvent_->clear();
354 
355  if (p.triggers) {
356  jetTrigger_->clear();
357  muonTrigger_->clear();
358  }
359  pileup_->clear();
361  met_->clear();
362 
363  if (p.jets) {
364  if (p.isMC)
365  genJets_->clear();
366  if (p.triggers)
367  HLTjets_->clear();
368  recJets_->clear();
369  }
370 
371  if (p.muons) {
372  recMuons_->clear();
373  if (p.isMC)
374  genMuons_->clear();
375  }
376 
377  if (p.photons) {
378  recPhotons_->clear();
379  if (genPhotons_)
380  genPhotons_->clear();
381  }
382 }

◆ trigger()

bool trigger ( edm::Event const &  iEvent)
private

Finds the bits corresponding to the HLT jet pt triggers.

453 {
454  const auto &names = iEvent.triggerNames(*triggerResults);
455 
456  bool passTrigger(false);
457  for (unsigned int k = 0; k < p.triggerNames_.size(); ++k) {
458  bool bit(false);
459  int preHLT(1), preL1min(1), preL1max(1);
460  string name;
461 
462  for (unsigned int itrig = 0; itrig < triggerResults->size(); ++itrig) {
463  name = names.triggerName(itrig);
464 
465  //--- erase the the version number----
467  if (name != p.triggerNames_[k]) continue;
468 
469  bit = triggerResults->accept(itrig);
470  preHLT = triggerPrescales->getPrescaleForIndex(itrig);
471  preL1min = triggerPrescalesl1min->getPrescaleForIndex(itrig);
472  preL1max = triggerPrescalesl1max->getPrescaleForIndex(itrig);
473  break;
474  }
475  //--- if at least one monitored trigger has fired passTrigger becomes true
476  passTrigger += bit;
477 
478  // Identify trigger collection
479  regex jetTriggerpattern("HLT_(AK4|AK8|HI|HIAK4|HIAK8|Di)?PFJet");
480  regex muonTriggerpattern("HLT_(Mu|IsoMu)");
481  regex zbTriggerpattern("HLT_ZeroBias");
482  // example for Run18A (both low & high pt jets)
483  // HLT_PFJet40_v 153 153
484  // HLT_PFJet60_v 154 154
485  // HLT_PFJet80_v 155 155
486  // HLT_PFJet140_v 156 156
487  // HLT_PFJet200_v 157 157
488  // HLT_PFJet260_v 158 158
489  // HLT_PFJet320_v 159 159
490  // HLT_PFJet400_v 160 160
491  // HLT_PFJet450_v 161 161
492  // HLT_PFJet500_v 162 162
493  // HLT_PFJet550_v 163 163
494  if (regex_search(name, jetTriggerpattern)) {
495  jetTrigger_->Bit.push_back(bit);
496  jetTrigger_->PreHLT.push_back(preHLT);
497  jetTrigger_->PreL1min.push_back(preL1min);
498  jetTrigger_->PreL1max.push_back(preL1max);
499  }
500  // HLT_IsoMu24_eta2p1_v
501  // HLT_IsoMu24_v
502  // HLT_IsoMu27_v
503  // HLT_IsoMu30_v
504  // HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_v
505  // HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_v
506  // HLT_Mu19_TrkIsoVVL_Mu9_TrkIsoVVL_DZ_v
507  // HLT_Mu19_TrkIsoVVL_Mu9_TrkIsoVVL_v
508  else if (regex_search(name, muonTriggerpattern)) {
509  muonTrigger_->Bit.push_back(bit);
510  muonTrigger_->PreHLT.push_back(preHLT);
511  muonTrigger_->PreL1min.push_back(preL1min);
512  muonTrigger_->PreL1max.push_back(preL1max);
513  }
514  else if (regex_search(name, zbTriggerpattern)) {
515  zbTrigger_->Bit.push_back(bit);
516  zbTrigger_->PreHLT.push_back(preHLT);
517  zbTrigger_->PreL1min.push_back(preL1min);
518  zbTrigger_->PreL1max.push_back(preL1max);
519  }
520  else throw cms::Exception("Ntupliser") << "No dedicated collection exists for " << name;
521  }
522  return passTrigger;
523 }

Member Data Documentation

◆ fs_

edm::Service<TFileService> fs_
private

◆ genEvent_

DAS::GenEvent* genEvent_
private

◆ genEvtInfo

edm::Handle<GenEventInfoProduct> genEvtInfo
private

◆ genjets

edm::Handle<reco::GenJetCollection> genjets
private

◆ genJets_

std::vector<DAS::GenJet>* genJets_
private

◆ genLeptons

edm::Handle<edm::View<reco::Candidate> > genLeptons
private

◆ genMuons_

std::vector<DAS::GenMuon>* genMuons_
private

◆ genParticles

edm::Handle<reco::GenParticleCollection> genParticles
private

◆ genPhotons_

std::vector<DAS::GenPhoton>* genPhotons_
private

◆ h

DAS::Helper h
private

◆ HLTjets_

std::vector<DAS::FourVector>* HLTjets_
private

◆ jetTrigger_

DAS::Trigger* jetTrigger_
private

◆ met

edm::Handle<pat::METCollection> met
private

◆ met_

DAS::MET* met_
private

◆ metainfo

Darwin::Tools::UserInfo metainfo
private

◆ metResults

edm::Handle<edm::TriggerResults> metResults
private

◆ muonTrigger_

DAS::Trigger * muonTrigger_
private

◆ p

DAS::Parameters p
private

◆ pileup_

DAS::PileUp* pileup_
private

◆ pileup_json

boost::property_tree::ptree pileup_json
private

pileup "latest"

◆ pileupInfo

edm::Handle<std::vector<PileupSummaryInfo> > pileupInfo
private

◆ primaryvertex_

DAS::PrimaryVertex* primaryvertex_
private

◆ recEvent_

DAS::RecEvent* recEvent_
private

◆ recjets

edm::Handle<pat::JetCollection> recjets
private

◆ recJets_

std::vector<DAS::RecJet>* recJets_
private

◆ recmuons

edm::Handle<pat::MuonCollection> recmuons
private

◆ recMuons_

std::vector<DAS::RecMuon>* recMuons_
private

◆ recphotons

edm::Handle<pat::PhotonCollection> recphotons
private

◆ recPhotons_

std::vector<DAS::RecPhoton>* recPhotons_
private

◆ recVtxs

edm::Handle<reco::VertexCollection> recVtxs
private

◆ rho

edm::Handle<double> rho
private

◆ SVs

edm::Handle<std::vector<reco::VertexCompositePtrCandidate> > SVs
private

◆ theJetFlavourInfos

edm::Handle<reco::JetFlavourInfoMatchingCollection> theJetFlavourInfos
private

◆ tree

TTree* tree
private

◆ triggerObjects

edm::Handle<pat::TriggerObjectStandAloneCollection> triggerObjects
private

◆ triggerPrescales

edm::Handle<pat::PackedTriggerPrescales> triggerPrescales
private

◆ triggerPrescalesl1max

edm::Handle<pat::PackedTriggerPrescales> triggerPrescalesl1max
private

◆ triggerPrescalesl1min

edm::Handle<pat::PackedTriggerPrescales> triggerPrescalesl1min
private

◆ triggerResults

edm::Handle<edm::TriggerResults> triggerResults
private

◆ zbTrigger_

DAS::Trigger * zbTrigger_
private

The documentation for this class was generated from the following files:
DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.name
name
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:48
Ntupliser::genjets
edm::Handle< reco::GenJetCollection > genjets
Definition: Ntupliser.h:62
DAS::Parameters::pileupInfoToken
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupInfoToken
Definition: Parameters.h:93
Ntupliser::zbTrigger_
DAS::Trigger * zbTrigger_
Definition: Ntupliser.h:95
DAS::Parameters::recjetsToken
edm::EDGetTokenT< pat::JetCollection > recjetsToken
Definition: Parameters.h:67
DAS
Definition: applyBTagSF.cc:31
DAS::Parameters::triggerPrescalesl1maxToken
edm::EDGetTokenT< pat::PackedTriggerPrescales > triggerPrescalesl1maxToken
Definition: Parameters.h:86
DAS::Helper::GetGenJet
DAS::GenJet GetGenJet(const reco::JetFlavourInfoMatching &ijet)
Helper to get DAS::GenJet from MiniAOD with flavour.
Definition: helper.cc:30
Ntupliser::metResults
edm::Handle< edm::TriggerResults > metResults
Definition: Ntupliser.h:70
Ntupliser::genPhotons_
std::vector< DAS::GenPhoton > * genPhotons_
Definition: Ntupliser.h:94
Ntupliser::getRecPhotons
void getRecPhotons()
Finds the reconstructed photons, and applies some hard cuts on the phase space.
Definition: Ntupliser.cc:184
DAS::PhysicsObject::p4
FourVector p4
raw four-momentum directly after reconstruction
Definition: PhysicsObject.h:50
DAS::PileUp::trpu
float trpu
true pile-up
Definition: Event.h:104
DAS::Parameters::metToken
edm::EDGetTokenT< pat::METCollection > metToken
Definition: Parameters.h:83
DAS::Helper::GetGenMu
DAS::GenMuon GetGenMu(const reco::Candidate &mu)
Helper to get DAS::GenMuon from MiniAOD.
Definition: helper.cc:243
DAS::Parameters::genLeptonsToken
edm::EDGetTokenT< edm::View< reco::Candidate > > genLeptonsToken
Definition: Parameters.h:74
Ntupliser::recmuons
edm::Handle< pat::MuonCollection > recmuons
Definition: Ntupliser.h:65
DAS::SysUp
const std::string SysUp
Suffix used for "up" uncertainties. Follows the Combine convention.
Definition: Format.h:8
DAS::RecEvent::clear
void clear()
to clear for each new event in n-tupliser
Definition: Event.cc:15
DAS::Helper::GetRecJet
DAS::RecJet GetRecJet(const pat::Jet &ijet)
Definition: helper.cc:52
DAS::PrimaryVertex::chi2
float chi2
figure of merit of the vertex fit
Definition: Event.h:122
DAS::Parameters::triggerPrescalesToken
edm::EDGetTokenT< pat::PackedTriggerPrescales > triggerPrescalesToken
Definition: Parameters.h:86
Ntupliser::recEvent_
DAS::RecEvent * recEvent_
Definition: Ntupliser.h:97
Ntupliser::recPhotons_
std::vector< DAS::RecPhoton > * recPhotons_
Definition: Ntupliser.h:93
DelLastDigits
string DelLastDigits(string n)
Definition: Ntupliser.cc:442
Ntupliser::met_
DAS::MET * met_
Definition: Ntupliser.h:98
DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.source
source
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:39
DAS::Parameters::metNames_
std::vector< std::string > metNames_
Definition: Parameters.h:87
DAS::Parameters::sandbox
const bool sandbox
flag for CRAB sandbox
Definition: Parameters.h:58
DAS::Parameters::genjetsToken
edm::EDGetTokenT< reco::GenJetCollection > genjetsToken
Definition: Parameters.h:66
DAS::Trigger
Definition: Event.h:71
DAS::Parameters::recphotonsToken
edm::EDGetTokenT< pat::PhotonCollection > recphotonsToken
Definition: Parameters.h:79
DAS::PileUp::nVtx
int nVtx
number of vertices in the event
Definition: Event.h:103
Ntupliser::genMuons_
std::vector< DAS::GenMuon > * genMuons_
Definition: Ntupliser.h:92
DAS::Trigger::Bit
std::vector< bool > Bit
indicates which trigger has fired
Definition: Event.h:72
Ntupliser::getRecMuons
void getRecMuons()
Finds the reconstructed muons, and applies some hard cuts on the phase space.
Definition: Ntupliser.cc:165
DAS::Parameters::genParticlesToken
edm::EDGetTokenT< reco::GenParticleCollection > genParticlesToken
Definition: Parameters.h:63
Ntupliser::pileup_
DAS::PileUp * pileup_
Definition: Ntupliser.h:99
DAS::RecEvent
Definition: Event.h:52
Ntupliser::recphotons
edm::Handle< pat::PhotonCollection > recphotons
Definition: Ntupliser.h:66
Ntupliser::pileup_json
boost::property_tree::ptree pileup_json
pileup "latest"
Definition: Ntupliser.h:102
Ntupliser::HLTjets_
std::vector< DAS::FourVector > * HLTjets_
Definition: Ntupliser.h:89
Ntupliser::getHLTjets
void getHLTjets(edm::Event const &iEvent)
Finds HLT jets and simply stores them in a FourVector.
Definition: Ntupliser.cc:545
DAS::RecJet
Definition: Jet.h:37
DAS::MET
Definition: Event.h:84
Ntupliser::primaryvertex_
DAS::PrimaryVertex * primaryvertex_
Definition: Ntupliser.h:100
Ntupliser::triggerPrescalesl1max
edm::Handle< pat::PackedTriggerPrescales > triggerPrescalesl1max
Definition: Ntupliser.h:71
DAS::AbstractEvent::weights
Weights weights
e.g. cross section normalisation
Definition: Event.h:23
DAS::JetEnergy::w
static const float w
Definition: common.h:51
DAS::PrimaryVertex::ndof
float ndof
number of degrees of freedom in vertex fit
Definition: Event.h:123
DAS::Parameters::muons
const bool muons
Definition: Parameters.h:73
DAS::MET::Et
float Et
transverse energy
Definition: Event.h:85
Ntupliser::getGenMuons
void getGenMuons()
Finds the generated muons, and applies some hard cuts on the phase space.
Definition: Ntupliser.cc:79
Ntupliser::fs_
edm::Service< TFileService > fs_
Definition: Ntupliser.h:83
DAS::Helper::TightLepVetoID
bool TightLepVetoID(const pat::Jet &jet)
Definition: helper.cc:185
DAS::Parameters::recmuonsToken
edm::EDGetTokenT< pat::MuonCollection > recmuonsToken
Definition: Parameters.h:75
Ntupliser::met
edm::Handle< pat::METCollection > met
Definition: Ntupliser.h:67
DAS::RecMuon
class RecMuon
Definition: Lepton.h:25
DAS::RecEvent::runNo
int runNo
6-digit run number
Definition: Event.h:55
DAS::PrimaryVertex::clear
void clear()
to clear for each new event in n-tupliser
Definition: Event.cc:82
Ntupliser::muonTrigger_
DAS::Trigger * muonTrigger_
Definition: Ntupliser.h:95
DAS::Helper::GetRecPhoton
DAS::RecPhoton GetRecPhoton(const pat::Photon &photon)
Helper to get DAS::RecLep from MiniAOD.
Definition: helper.cc:292
DAS::Trigger::PreL1max
std::vector< int > PreL1max
L1 max pre-scale.
Definition: Event.h:75
DAS::PileUp
Definition: Event.h:98
DAS::Parameters::rhoToken
edm::EDGetTokenT< double > rhoToken
Definition: Parameters.h:92
Ntupliser::metainfo
Darwin::Tools::UserInfo metainfo
Definition: Ntupliser.h:85
DAS::RecEvent::evtNo
unsigned long long evtNo
event number
Definition: Event.h:57
DAS::GenMuon
class GenMuon
Definition: Lepton.h:9
DAS::Parameters::config
boost::property_tree::ptree config
input JSON config
Definition: Parameters.h:60
DAS::GenJet
class GenJet
Definition: Jet.h:9
recjet
DAS::RecJet recjet
Definition: classes.h:15
Ntupliser::genLeptons
edm::Handle< edm::View< reco::Candidate > > genLeptons
Definition: Ntupliser.h:64
Ntupliser::getGenJets
void getGenJets(edm::Handle< MyJetCollection > &mygenjets)
Definition: Ntupliser.cc:143
Ntupliser::theJetFlavourInfos
edm::Handle< reco::JetFlavourInfoMatchingCollection > theJetFlavourInfos
Definition: Ntupliser.h:75
Ntupliser::h
DAS::Helper h
Definition: Ntupliser.h:59
DAS::PileUp::rho
float rho
soft activity (see formula 7.15 in Patrick's thesis)
Definition: Event.h:102
DAS::Parameters::triggerPrescalesl1minToken
edm::EDGetTokenT< pat::PackedTriggerPrescales > triggerPrescalesl1minToken
Definition: Parameters.h:86
DAS::Helper::GetGenPhoton
DAS::GenPhoton GetGenPhoton(const reco::GenParticle &photon, bool zAncestor)
Helper to get DAS::GenPhoton from MiniAOD.
Definition: helper.cc:278
DAS::Helper::GetRecMu
DAS::RecMuon GetRecMu(const pat::Muon &mu)
Helper to get DAS::RecMuon from MiniAOD.
Definition: helper.cc:257
Ntupliser::recMuons_
std::vector< DAS::RecMuon > * recMuons_
Definition: Ntupliser.h:91
Ntupliser::triggerResults
edm::Handle< edm::TriggerResults > triggerResults
Definition: Ntupliser.h:70
DAS::Parameters::triggerResultsToken
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken
Definition: Parameters.h:84
Ntupliser::initialise
void initialise(edm::Event const &iEvent)
Called at the beginning of each new event.
Definition: Ntupliser.cc:386
Ntupliser::getGenPhotons
void getGenPhotons()
Finds the generated photons and applies some hard cuts to the phase space.
Definition: Ntupliser.cc:106
DAS::RecEvent::lumi
int lumi
lumi section
Definition: Event.h:56
Ntupliser::rho
edm::Handle< double > rho
Definition: Ntupliser.h:68
DAS::MET::Bit
std::vector< bool > Bit
flags for application of MET filters (see n-tupliser config file)
Definition: Event.h:89
Ntupliser::triggerPrescales
edm::Handle< pat::PackedTriggerPrescales > triggerPrescales
Definition: Ntupliser.h:71
DAS::Trigger::PreL1min
std::vector< int > PreL1min
L1 min pre-scale.
Definition: Event.h:74
DAS::PrimaryVertex::distGen
float distGen
distance to gen (only relevant in MC)
Definition: Event.h:126
DAS::Parameters::triggers
const bool triggers
Definition: Parameters.h:82
Ntupliser::p
DAS::Parameters p
Definition: Ntupliser.h:58
DAS::PrimaryVertex::z
float z
position on beam axis
Definition: Event.h:121
Ntupliser_cfg.lhe
lhe
Definition: Ntupliser_cfg.py:271
DAS::Parameters::triggerNames_
std::vector< std::string > triggerNames_
Definition: Parameters.h:87
Ntupliser::triggerPrescalesl1min
edm::Handle< pat::PackedTriggerPrescales > triggerPrescalesl1min
Definition: Ntupliser.h:71
DAS::PrimaryVertex::Rho
float Rho
transverse distance to beam axis
Definition: Event.h:120
DAS::Parameters::HLTjet_triggerNames
std::set< std::string > HLTjet_triggerNames
Definition: Parameters.h:89
Ntupliser::genEvtInfo
edm::Handle< GenEventInfoProduct > genEvtInfo
Definition: Ntupliser.h:73
recphoton
DAS::RecPhoton recphoton
Definition: classes.h:21
Darwin::Tools::UserInfo::Set
void Set(TList *mother, const char *key, T value) const
Definition: UserInfo.h:129
DAS::GenEvent::clear
void clear()
to clear for each new event in n-tupliser
Definition: Event.cc:9
DAS::PrimaryVertex::fake
bool fake
flag for fake vertices
Definition: Event.h:124
pileup
DAS::PileUp pileup
Definition: classes.h:27
DAS::Parameters::recVtxsToken
edm::EDGetTokenT< reco::VertexCollection > recVtxsToken
Definition: Parameters.h:85
DAS::Parameters::flavour
const bool flavour
Definition: Parameters.h:68
DAS::SysDown
const std::string SysDown
Suffix used for "down" uncertainties. Follows the Combine convention.
Definition: Format.h:10
Ntupliser::fillMET
void fillMET(edm::Event const &iEvent)
Fill the MET flags to the array.
Definition: Ntupliser.cc:527
DAS::Parameters::metResultsToken
edm::EDGetTokenT< edm::TriggerResults > metResultsToken
Definition: Parameters.h:84
Ntupliser::recJets_
std::vector< DAS::RecJet > * recJets_
Definition: Ntupliser.h:88
DAS::PhysicsObject::weights
Weights weights
object weights
Definition: PhysicsObject.h:52
genjet
DAS::GenJet genjet
Definition: classes.h:14
Ntupliser::genEvent_
DAS::GenEvent * genEvent_
Definition: Ntupliser.h:96
DAS::PileUp::clear
void clear()
to clear for each new event in n-tupliser
Definition: Event.cc:74
DAS::PileUp::MBxsec
static float MBxsec
Definition: Event.h:100
DAS::PileUp::pthats
std::vector< float > pthats
all hard scales found in PU
Definition: Event.h:106
Ntupliser::pileupInfo
edm::Handle< std::vector< PileupSummaryInfo > > pileupInfo
Definition: Ntupliser.h:77
Ntupliser::triggerObjects
edm::Handle< pat::TriggerObjectStandAloneCollection > triggerObjects
Definition: Ntupliser.h:72
Ntupliser::getEventVariables
void getEventVariables(edm::Event const &iEvent)
Definition: Ntupliser.cc:586
DAS::Parameters::photons
const bool photons
Definition: Parameters.h:78
generate_html.run
run
Definition: generate_html.py:86
Ntupliser::recjets
edm::Handle< pat::JetCollection > recjets
Definition: Ntupliser.h:63
DAS::MET::Phi
float Phi
direction of the total transverse momentum
Definition: Event.h:88
DAS::Trigger::PreHLT
std::vector< int > PreHLT
HLT prescale.
Definition: Event.h:73
Ntupliser::jetTrigger_
DAS::Trigger * jetTrigger_
Definition: Ntupliser.h:95
DAS::FourVector
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< float > > FourVector
Definition: PhysicsObject.h:15
DAS::GenEvent::hard_scale
float hard_scale
hard scale, corresponding to pthat in Pythia 8
Definition: Event.h:41
Ntupliser::genParticles
edm::Handle< reco::GenParticleCollection > genParticles
Definition: Ntupliser.h:74
DAS::Parameters::genEvtInfoToken
edm::EDGetTokenT< GenEventInfoProduct > genEvtInfoToken
Definition: Parameters.h:62
DAS::PileUp::intpu
int intpu
in-time pile-up (i.e. from the same bunch crossing)
Definition: Event.h:105
DAS::MET::clear
void clear()
to clear for each new event in n-tupliser
Definition: Event.cc:29
weights
DAS::Weights weights
Definition: classes.h:12
DAS::Trigger::clear
void clear()
to clear for each new event in n-tupliser
Definition: Event.cc:21
DAS::Parameters::jetFlavourInfosToken
edm::EDGetTokenT< reco::JetFlavourInfoMatchingCollection > jetFlavourInfosToken
Definition: Parameters.h:69
Ntupliser::tree
TTree * tree
Definition: Ntupliser.h:84
DAS::MET::SumEt
float SumEt
sum of the transverse energies of all the components (jet, leptons, etc.) present in the event
Definition: Event.h:86
DAS::PileUp::MBevents
std::vector< unsigned long long > MBevents
event IDs in MB sample
Definition: Event.h:107
Ntupliser::reset
void reset()
Just a common method to reset all branches at each new event.
Definition: Ntupliser.cc:349
Ntupliser::genJets_
std::vector< DAS::GenJet > * genJets_
Definition: Ntupliser.h:90
DAS::RecPhoton
class RecPhoton
Definition: Photon.h:27
Ntupliser::recVtxs
edm::Handle< reco::VertexCollection > recVtxs
Definition: Ntupliser.h:69
DAS::Parameters::triggerObjectsToken
edm::EDGetTokenT< pat::TriggerObjectStandAloneCollection > triggerObjectsToken
Definition: Parameters.h:88
DAS::Parameters::isMC
const bool isMC
flag
Definition: Parameters.h:56
Ntupliser::trigger
bool trigger(edm::Event const &iEvent)
Finds the bits corresponding to the HLT jet pt triggers.
Definition: Ntupliser.cc:452
DAS::Parameters::jets
const bool jets
Definition: Parameters.h:68
DAS::MET::Pt
float Pt
exactly the same as Et
Definition: Event.h:87
DAS::PrimaryVertex
Definition: Event.h:119
DAS::GenEvent
Definition: Event.h:38
Ntupliser::getRecJets
void getRecJets()
Finds the reconstructed jets, and applies some hard cuts on the phase space.
Definition: Ntupliser.cc:204