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 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.

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

◆ ~Ntupliser()

~Ntupliser ( )
overridevirtual
677 {
678  cout << __FILE__ << ':' << __func__ << endl;
679 }

Member Function Documentation

◆ analyze()

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

◆ beginJob()

void beginJob ( )
overridevirtual

Called before looping over the events.

Basically, it set up the branches.

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

◆ endJob()

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

◆ fillMET()

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

Fill the MET flags to the array.

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

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

◆ 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
146 {
147  //for ((typename MyJetCollection)::const_iterator itJet = mygenjets->begin();
148  for (auto itJet = mygenjets->begin();
149  itJet != mygenjets->end(); ++itJet) {
150 
151  // we convert the complicated CMSSW object to our simple DAS object
152  DAS::GenJet genjet = h.GetGenJet(*itJet);
153 
154  // we keep only jet with pt > 20 GeV and in the tracker acceptance
155  //if (genjet.p4.Pt() < 10 /* GeV */ || abs(genjet.p4.Eta()) > 5.0) continue;
158 
159  genJets_->push_back(genjet);
160  }
161 
162  Sort<DAS::GenJet>(genJets_);
163 }

◆ getGenMuons()

void getGenMuons ( )
private

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

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

◆ getGenPhotons()

void getGenPhotons ( )
private

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

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

◆ getHLTjets()

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

Finds HLT jets and simply stores them in a FourVector.

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

◆ getRecJets()

void getRecJets ( )
private

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

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

◆ getRecMuons()

void getRecMuons ( )
private

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

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

◆ getRecPhotons()

void getRecPhotons ( )
private

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

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

◆ getSecVertices()

void getSecVertices ( )
private

◆ initialise()

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

Called at the beginning of each new event.

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

◆ reset()

void reset ( )
private

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

342 {
343  if (p.isMC)
344  genEvent_->clear();
345  recEvent_->clear();
346 
347  if (p.triggers) {
348  jetTrigger_->clear();
349  muonTrigger_->clear();
350  }
351  pileup_->clear();
353  met_->clear();
354 
355  if (p.jets) {
356  if (p.isMC)
357  genJets_->clear();
358  if (p.triggers)
359  HLTjets_->clear();
360  recJets_->clear();
361  }
362 
363  if (p.muons) {
364  recMuons_->clear();
365  if (p.isMC)
366  genMuons_->clear();
367  }
368 
369  if (p.photons) {
370  recPhotons_->clear();
371  if (genPhotons_)
372  genPhotons_->clear();
373  }
374 }

◆ trigger()

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

Finds the bits corresponding to the HLT jet pt triggers.

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

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:59
DAS::Parameters::pileupInfoToken
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupInfoToken
Definition: Parameters.h:94
Ntupliser::zbTrigger_
DAS::Trigger * zbTrigger_
Definition: Ntupliser.h:92
DAS::Parameters::recjetsToken
edm::EDGetTokenT< pat::JetCollection > recjetsToken
Definition: Parameters.h:68
DAS
Definition: applyBTagSF.cc:31
DAS::Parameters::triggerPrescalesl1maxToken
edm::EDGetTokenT< pat::PackedTriggerPrescales > triggerPrescalesl1maxToken
Definition: Parameters.h:87
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:67
Ntupliser::genPhotons_
std::vector< DAS::GenPhoton > * genPhotons_
Definition: Ntupliser.h:91
Ntupliser::getRecPhotons
void getRecPhotons()
Finds the reconstructed photons, and applies some hard cuts on the phase space.
Definition: Ntupliser.cc:186
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:84
DAS::Helper::GetGenMu
DAS::GenMuon GetGenMu(const reco::Candidate &mu)
Helper to get DAS::GenMuon from MiniAOD.
Definition: helper.cc:152
DAS::Parameters::genLeptonsToken
edm::EDGetTokenT< edm::View< reco::Candidate > > genLeptonsToken
Definition: Parameters.h:75
Ntupliser::recmuons
edm::Handle< pat::MuonCollection > recmuons
Definition: Ntupliser.h:62
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)
Helper to get DAS::RecJet from MiniAOD.
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:87
Ntupliser::recEvent_
DAS::RecEvent * recEvent_
Definition: Ntupliser.h:94
Ntupliser::recPhotons_
std::vector< DAS::RecPhoton > * recPhotons_
Definition: Ntupliser.h:90
Ntupliser::met_
DAS::MET * met_
Definition: Ntupliser.h:95
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:88
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:67
DAS::Trigger
Definition: Event.h:71
DAS::Parameters::recphotonsToken
edm::EDGetTokenT< pat::PhotonCollection > recphotonsToken
Definition: Parameters.h:80
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:89
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:167
DAS::Parameters::genParticlesToken
edm::EDGetTokenT< reco::GenParticleCollection > genParticlesToken
Definition: Parameters.h:64
Ntupliser::pileup_
DAS::PileUp * pileup_
Definition: Ntupliser.h:96
DAS::RecEvent
Definition: Event.h:52
Ntupliser::recphotons
edm::Handle< pat::PhotonCollection > recphotons
Definition: Ntupliser.h:63
Ntupliser::pileup_json
boost::property_tree::ptree pileup_json
pileup "latest"
Definition: Ntupliser.h:99
Ntupliser::HLTjets_
std::vector< DAS::FourVector > * HLTjets_
Definition: Ntupliser.h:86
Ntupliser::getHLTjets
void getHLTjets(edm::Event const &iEvent)
Finds HLT jets and simply stores them in a FourVector.
Definition: Ntupliser.cc:544
DAS::RecJet
Definition: Jet.h:37
DAS::MET
Definition: Event.h:84
Ntupliser::primaryvertex_
DAS::PrimaryVertex * primaryvertex_
Definition: Ntupliser.h:97
Ntupliser::triggerPrescalesl1max
edm::Handle< pat::PackedTriggerPrescales > triggerPrescalesl1max
Definition: Ntupliser.h:68
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:74
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:81
Ntupliser::fs_
edm::Service< TFileService > fs_
Definition: Ntupliser.h:80
DAS::Parameters::recmuonsToken
edm::EDGetTokenT< pat::MuonCollection > recmuonsToken
Definition: Parameters.h:76
Ntupliser::met
edm::Handle< pat::METCollection > met
Definition: Ntupliser.h:64
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:92
DAS::Helper::GetRecPhoton
DAS::RecPhoton GetRecPhoton(const pat::Photon &photon)
Helper to get DAS::RecLep from MiniAOD.
Definition: helper.cc:201
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:93
Ntupliser::metainfo
Darwin::Tools::UserInfo metainfo
Definition: Ntupliser.h:82
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:61
Ntupliser::getGenJets
void getGenJets(edm::Handle< MyJetCollection > &mygenjets)
Definition: Ntupliser.cc:145
Ntupliser::theJetFlavourInfos
edm::Handle< reco::JetFlavourInfoMatchingCollection > theJetFlavourInfos
Definition: Ntupliser.h:72
Ntupliser::h
DAS::Helper h
Definition: Ntupliser.h:56
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:87
DAS::Helper::GetGenPhoton
DAS::GenPhoton GetGenPhoton(const reco::GenParticle &photon, bool zAncestor)
Helper to get DAS::GenPhoton from MiniAOD.
Definition: helper.cc:187
DAS::Helper::GetRecMu
DAS::RecMuon GetRecMu(const pat::Muon &mu)
Helper to get DAS::RecMuon from MiniAOD.
Definition: helper.cc:166
Ntupliser::recMuons_
std::vector< DAS::RecMuon > * recMuons_
Definition: Ntupliser.h:88
Ntupliser::triggerResults
edm::Handle< edm::TriggerResults > triggerResults
Definition: Ntupliser.h:67
DAS::Parameters::triggerResultsToken
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken
Definition: Parameters.h:85
Ntupliser::initialise
void initialise(edm::Event const &iEvent)
Called at the beginning of each new event.
Definition: Ntupliser.cc:378
Ntupliser::getGenPhotons
void getGenPhotons()
Finds the generated photons and applies some hard cuts to the phase space.
Definition: Ntupliser.cc:108
DAS::RecEvent::lumi
int lumi
lumi section
Definition: Event.h:56
Ntupliser::rho
edm::Handle< double > rho
Definition: Ntupliser.h:65
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:68
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:83
Ntupliser_cfg.run
int run
Definition: Ntupliser_cfg.py:75
Ntupliser::p
DAS::Parameters p
Definition: Ntupliser.h:55
DAS::PrimaryVertex::z
float z
position on beam axis
Definition: Event.h:121
Ntupliser_cfg.lhe
lhe
Definition: Ntupliser_cfg.py:304
DAS::Parameters::triggerNames_
std::vector< std::string > triggerNames_
Definition: Parameters.h:88
Ntupliser::triggerPrescalesl1min
edm::Handle< pat::PackedTriggerPrescales > triggerPrescalesl1min
Definition: Ntupliser.h:68
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:90
Ntupliser::genEvtInfo
edm::Handle< GenEventInfoProduct > genEvtInfo
Definition: Ntupliser.h:70
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:86
DAS::Parameters::flavour
const bool flavour
Definition: Parameters.h:69
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:526
DAS::Parameters::metResultsToken
edm::EDGetTokenT< edm::TriggerResults > metResultsToken
Definition: Parameters.h:85
Ntupliser::recJets_
std::vector< DAS::RecJet > * recJets_
Definition: Ntupliser.h:85
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:93
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:74
Ntupliser::triggerObjects
edm::Handle< pat::TriggerObjectStandAloneCollection > triggerObjects
Definition: Ntupliser.h:69
Ntupliser::getEventVariables
void getEventVariables(edm::Event const &iEvent)
Definition: Ntupliser.cc:585
DAS::Parameters::photons
const bool photons
Definition: Parameters.h:79
Ntupliser::recjets
edm::Handle< pat::JetCollection > recjets
Definition: Ntupliser.h:60
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:92
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:71
DAS::Parameters::genEvtInfoToken
edm::EDGetTokenT< GenEventInfoProduct > genEvtInfoToken
Definition: Parameters.h:63
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:70
Ntupliser::tree
TTree * tree
Definition: Ntupliser.h:81
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:341
Ntupliser::genJets_
std::vector< DAS::GenJet > * genJets_
Definition: Ntupliser.h:87
DAS::RecPhoton
class RecPhoton
Definition: Photon.h:27
Ntupliser::recVtxs
edm::Handle< reco::VertexCollection > recVtxs
Definition: Ntupliser.h:66
DAS::Parameters::triggerObjectsToken
edm::EDGetTokenT< pat::TriggerObjectStandAloneCollection > triggerObjectsToken
Definition: Parameters.h:89
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:444
DAS::Parameters::jets
const bool jets
Definition: Parameters.h:69
DAS::Helper::JetID
bool JetID(const pat::Jet &jet)
Testing tight ID lepton veto definition for jets (official from JetMET)
Definition: helper.cc:99
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:206