|
DAS
3.0
Das Analysis System
|
#include <Ntupliser.h>
|
| 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 |
|
◆ LorentzVector
◆ Ntupliser()
Constructor, only initialising the members.
40 p(cfg, consumesCollector()),
h(
p),
41 tree(
fs_->make<TTree>(
"events",
"events")),
63 cout << __FILE__ <<
':' << __func__ << endl;
68 for (TString
source: RecPhoton::uncs) {
73 catch (boost::exception& e) {
74 throw cms::Exception(
"Ntupliser") << boost::diagnostic_information(e);
◆ ~Ntupliser()
◆ analyze()
void analyze |
( |
edm::Event const & |
iEvent, |
|
|
edm::EventSetup const & |
iSetup |
|
) |
| |
|
overridevirtual |
309 bool passTrigger =
trigger(iEvent);
310 if (!
p.
isMC && !passTrigger)
return;
◆ beginJob()
Called before looping over the events.
Basically, it set up the branches.
232 cout << __FILE__ <<
':' << __func__ << endl;
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;
241 throw cms::Exception(
"Ntupliser") <<
pileup <<
" could not be found";
244 else cout <<
"\x1B[33mNo input pileup normalisation\x1B[0m" << endl;
◆ beginRun()
void beginRun |
( |
edm::Run const & |
iRun, |
|
|
edm::EventSetup const & |
iSetup |
|
) |
| |
|
overridevirtual |
293 cout << __FILE__ <<
':' << __func__ << endl;
◆ endJob()
289 cout << __FILE__ <<
':' << __func__ << endl;
◆ endRun()
void endRun |
( |
edm::Run const & |
iRun, |
|
|
edm::EventSetup const & |
iSetup |
|
) |
| |
|
overridevirtual |
297 cout << __FILE__ <<
':' << __func__ << endl;
◆ fillMET()
void fillMET |
( |
edm::Event const & |
iEvent | ) |
|
|
private |
Fill the MET flags to the array.
529 const edm::TriggerNames &namesMet = iEvent.triggerNames(*
metResults);
530 for(
unsigned int k=0; k <
p.
metNames_.size(); ++k) {
532 for(
unsigned int itrig=0; itrig<
metResults->size(); ++itrig) {
533 string met_name = string(namesMet.triggerName(itrig));
◆ 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()
599 #error "Generator weights haven't been tested yet! Implementation may not be ready"
603 cout <<
"Weight " <<
w.id <<
" " <<
w.wgt <<
'\n';
619 if (PUI->getBunchCrossing() != 0)
continue;
629 auto &ptHatVec = PUI->getPU_pT_hats();
632 const vector<edm::EventID>& evtIDs = PUI->getPU_EventID();
633 for (
const auto& evtID: evtIDs)
637 auto runNo = to_string(iEvent.id().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();
643 auto LSno = it->second.get_value<
unsigned int>();
644 if (LSno != iEvent.id().luminosityBlock())
continue;
647 ++it;
auto avXsec = it->second.get_value<
float>();
654 const auto& PV = (*recVtxs)[0];
661 const auto& rv = PV.position();
662 const auto& gv = (*genParticles)[0].daughter(0)->vertex();
664 hypot( rv.y() - gv.y(),
669 met_->
Et = (*met)[0].et();
671 met_->
Pt = (*met)[0].pt();
◆ 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 for (
auto itJet = mygenjets->begin();
147 itJet != mygenjets->end(); ++itJet) {
◆ getGenMuons()
Finds the generated muons, and applies some hard cuts on the phase space.
81 for (
const reco::Candidate &lepton: *
genLeptons) {
82 if (abs(lepton.pdgId()) != 13)
continue;
89 if (genmu.
p4.Pt() < 10 || abs(genmu.
p4.Eta()) > 3.0)
continue;
◆ getGenPhotons()
Finds the generated photons and applies some hard cuts to the phase space.
109 vector<const reco::GenParticle *> charged_leptons;
111 auto id = abs(gp.pdgId());
112 if (gp.status() == 1 && (
id == 11 ||
id == 13))
113 charged_leptons.push_back(&gp);
118 if (gp.status() != 1 || gp.pdgId() != 22)
continue;
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;
127 if (any_of(charged_leptons.begin(), charged_leptons.end(),
128 [gp](
auto lep) { return reco::deltaR(lep->p4(), gp.p4()) < 0.1; }))
◆ getHLTjets()
void getHLTjets |
( |
edm::Event const & |
iEvent | ) |
|
|
private |
Finds HLT jets and simply stores them in a FourVector
.
552 obj.unpackPathNames(names);
554 vector<string> pathNamesLast = obj.pathNames(
true);
557 bool isHLTjet =
false;
559 for (
auto s: pathNamesLast) {
572 if(v == P4) {isIn =
true;
break;}
◆ getRecJets()
Finds the reconstructed jets, and applies some hard cuts on the phase space.
- Todo:
- externalize option for phase space cut
206 for(pat::JetCollection::const_iterator itJet =
recjets->begin();
207 itJet !=
recjets->end(); ++itJet) {
◆ getRecMuons()
Finds the reconstructed muons, and applies some hard cuts on the phase space.
167 for(pat::MuonCollection::const_iterator itMu =
recmuons->begin();
174 if (recmu.
p4.Pt() < 10 || abs(recmu.
p4.Eta()) > 2.4)
continue;
◆ getRecPhotons()
Finds the reconstructed photons, and applies some hard cuts on the phase space.
186 for (pat::PhotonCollection::const_iterator it =
recphotons->begin();
◆ getSecVertices()
◆ initialise()
void initialise |
( |
edm::Event const & |
iEvent | ) |
|
|
private |
Called at the beginning of each new event.
391 iEvent.getByToken(
p.lheToken);
◆ reset()
Just a common method to reset all branches at each new event.
◆ trigger()
bool trigger |
( |
edm::Event const & |
iEvent | ) |
|
|
private |
Finds the bits corresponding to the HLT jet pt triggers.
456 bool passTrigger(
false);
459 int preHLT(1), preL1min(1), preL1max(1);
462 for (
unsigned int itrig = 0; itrig <
triggerResults->size(); ++itrig) {
463 name = names.triggerName(itrig);
479 regex jetTriggerpattern(
"HLT_(AK4|AK8|HI|HIAK4|HIAK8|Di)?PFJet");
480 regex muonTriggerpattern(
"HLT_(Mu|IsoMu)");
481 regex zbTriggerpattern(
"HLT_ZeroBias");
494 if (regex_search(
name, jetTriggerpattern)) {
508 else if (regex_search(
name, muonTriggerpattern)) {
514 else if (regex_search(
name, zbTriggerpattern)) {
520 else throw cms::Exception(
"Ntupliser") <<
"No dedicated collection exists for " <<
name;
◆ fs_
edm::Service<TFileService> fs_ |
|
private |
◆ genEvent_
◆ genEvtInfo
edm::Handle<GenEventInfoProduct> genEvtInfo |
|
private |
◆ genjets
edm::Handle<reco::GenJetCollection> genjets |
|
private |
◆ genJets_
◆ genLeptons
edm::Handle<edm::View<reco::Candidate> > genLeptons |
|
private |
◆ genMuons_
◆ genParticles
edm::Handle<reco::GenParticleCollection> genParticles |
|
private |
◆ genPhotons_
◆ HLTjets_
◆ jetTrigger_
◆ met
edm::Handle<pat::METCollection> met |
|
private |
◆ met_
◆ metainfo
◆ metResults
edm::Handle<edm::TriggerResults> metResults |
|
private |
◆ muonTrigger_
◆ pileup_
◆ pileup_json
boost::property_tree::ptree pileup_json |
|
private |
◆ pileupInfo
edm::Handle<std::vector<PileupSummaryInfo> > pileupInfo |
|
private |
◆ primaryvertex_
◆ recEvent_
◆ recjets
edm::Handle<pat::JetCollection> recjets |
|
private |
◆ recJets_
◆ recmuons
edm::Handle<pat::MuonCollection> recmuons |
|
private |
◆ recMuons_
◆ recphotons
edm::Handle<pat::PhotonCollection> recphotons |
|
private |
◆ recPhotons_
◆ recVtxs
edm::Handle<reco::VertexCollection> recVtxs |
|
private |
◆ rho
◆ SVs
edm::Handle<std::vector<reco::VertexCompositePtrCandidate> > SVs |
|
private |
◆ theJetFlavourInfos
edm::Handle<reco::JetFlavourInfoMatchingCollection> theJetFlavourInfos |
|
private |
◆ tree
◆ 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_
The documentation for this class was generated from the following files:
- /builds/cms-analysis/general/DasAnalysisSystem/Core/Installer/Core/Ntupliser/plugins/Ntupliser.h
- /builds/cms-analysis/general/DasAnalysisSystem/Core/Installer/Core/Ntupliser/plugins/Ntupliser.cc
name
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:48
edm::Handle< reco::GenJetCollection > genjets
Definition: Ntupliser.h:62
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupInfoToken
Definition: Parameters.h:93
DAS::Trigger * zbTrigger_
Definition: Ntupliser.h:95
edm::EDGetTokenT< pat::JetCollection > recjetsToken
Definition: Parameters.h:67
Definition: applyBTagSF.cc:31
edm::EDGetTokenT< pat::PackedTriggerPrescales > triggerPrescalesl1maxToken
Definition: Parameters.h:86
DAS::GenJet GetGenJet(const reco::JetFlavourInfoMatching &ijet)
Helper to get DAS::GenJet from MiniAOD with flavour.
Definition: helper.cc:30
edm::Handle< edm::TriggerResults > metResults
Definition: Ntupliser.h:70
std::vector< DAS::GenPhoton > * genPhotons_
Definition: Ntupliser.h:94
void getRecPhotons()
Finds the reconstructed photons, and applies some hard cuts on the phase space.
Definition: Ntupliser.cc:184
FourVector p4
raw four-momentum directly after reconstruction
Definition: PhysicsObject.h:50
float trpu
true pile-up
Definition: Event.h:104
edm::EDGetTokenT< pat::METCollection > metToken
Definition: Parameters.h:83
DAS::GenMuon GetGenMu(const reco::Candidate &mu)
Helper to get DAS::GenMuon from MiniAOD.
Definition: helper.cc:243
edm::EDGetTokenT< edm::View< reco::Candidate > > genLeptonsToken
Definition: Parameters.h:74
edm::Handle< pat::MuonCollection > recmuons
Definition: Ntupliser.h:65
const std::string SysUp
Suffix used for "up" uncertainties. Follows the Combine convention.
Definition: Format.h:8
void clear()
to clear for each new event in n-tupliser
Definition: Event.cc:15
DAS::RecJet GetRecJet(const pat::Jet &ijet)
Definition: helper.cc:52
float chi2
figure of merit of the vertex fit
Definition: Event.h:122
edm::EDGetTokenT< pat::PackedTriggerPrescales > triggerPrescalesToken
Definition: Parameters.h:86
DAS::RecEvent * recEvent_
Definition: Ntupliser.h:97
std::vector< DAS::RecPhoton > * recPhotons_
Definition: Ntupliser.h:93
string DelLastDigits(string n)
Definition: Ntupliser.cc:442
DAS::MET * met_
Definition: Ntupliser.h:98
source
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:39
std::vector< std::string > metNames_
Definition: Parameters.h:87
const bool sandbox
flag for CRAB sandbox
Definition: Parameters.h:58
edm::EDGetTokenT< reco::GenJetCollection > genjetsToken
Definition: Parameters.h:66
edm::EDGetTokenT< pat::PhotonCollection > recphotonsToken
Definition: Parameters.h:79
int nVtx
number of vertices in the event
Definition: Event.h:103
std::vector< DAS::GenMuon > * genMuons_
Definition: Ntupliser.h:92
std::vector< bool > Bit
indicates which trigger has fired
Definition: Event.h:72
void getRecMuons()
Finds the reconstructed muons, and applies some hard cuts on the phase space.
Definition: Ntupliser.cc:165
edm::EDGetTokenT< reco::GenParticleCollection > genParticlesToken
Definition: Parameters.h:63
DAS::PileUp * pileup_
Definition: Ntupliser.h:99
edm::Handle< pat::PhotonCollection > recphotons
Definition: Ntupliser.h:66
boost::property_tree::ptree pileup_json
pileup "latest"
Definition: Ntupliser.h:102
std::vector< DAS::FourVector > * HLTjets_
Definition: Ntupliser.h:89
void getHLTjets(edm::Event const &iEvent)
Finds HLT jets and simply stores them in a FourVector.
Definition: Ntupliser.cc:545
DAS::PrimaryVertex * primaryvertex_
Definition: Ntupliser.h:100
edm::Handle< pat::PackedTriggerPrescales > triggerPrescalesl1max
Definition: Ntupliser.h:71
Weights weights
e.g. cross section normalisation
Definition: Event.h:23
static const float w
Definition: common.h:51
float ndof
number of degrees of freedom in vertex fit
Definition: Event.h:123
const bool muons
Definition: Parameters.h:73
float Et
transverse energy
Definition: Event.h:85
void getGenMuons()
Finds the generated muons, and applies some hard cuts on the phase space.
Definition: Ntupliser.cc:79
edm::Service< TFileService > fs_
Definition: Ntupliser.h:83
bool TightLepVetoID(const pat::Jet &jet)
Definition: helper.cc:185
edm::EDGetTokenT< pat::MuonCollection > recmuonsToken
Definition: Parameters.h:75
edm::Handle< pat::METCollection > met
Definition: Ntupliser.h:67
class RecMuon
Definition: Lepton.h:25
int runNo
6-digit run number
Definition: Event.h:55
void clear()
to clear for each new event in n-tupliser
Definition: Event.cc:82
DAS::Trigger * muonTrigger_
Definition: Ntupliser.h:95
DAS::RecPhoton GetRecPhoton(const pat::Photon &photon)
Helper to get DAS::RecLep from MiniAOD.
Definition: helper.cc:292
std::vector< int > PreL1max
L1 max pre-scale.
Definition: Event.h:75
edm::EDGetTokenT< double > rhoToken
Definition: Parameters.h:92
Darwin::Tools::UserInfo metainfo
Definition: Ntupliser.h:85
unsigned long long evtNo
event number
Definition: Event.h:57
class GenMuon
Definition: Lepton.h:9
boost::property_tree::ptree config
input JSON config
Definition: Parameters.h:60
class GenJet
Definition: Jet.h:9
DAS::RecJet recjet
Definition: classes.h:15
edm::Handle< edm::View< reco::Candidate > > genLeptons
Definition: Ntupliser.h:64
void getGenJets(edm::Handle< MyJetCollection > &mygenjets)
Definition: Ntupliser.cc:143
edm::Handle< reco::JetFlavourInfoMatchingCollection > theJetFlavourInfos
Definition: Ntupliser.h:75
DAS::Helper h
Definition: Ntupliser.h:59
float rho
soft activity (see formula 7.15 in Patrick's thesis)
Definition: Event.h:102
edm::EDGetTokenT< pat::PackedTriggerPrescales > triggerPrescalesl1minToken
Definition: Parameters.h:86
DAS::GenPhoton GetGenPhoton(const reco::GenParticle &photon, bool zAncestor)
Helper to get DAS::GenPhoton from MiniAOD.
Definition: helper.cc:278
DAS::RecMuon GetRecMu(const pat::Muon &mu)
Helper to get DAS::RecMuon from MiniAOD.
Definition: helper.cc:257
std::vector< DAS::RecMuon > * recMuons_
Definition: Ntupliser.h:91
edm::Handle< edm::TriggerResults > triggerResults
Definition: Ntupliser.h:70
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken
Definition: Parameters.h:84
void initialise(edm::Event const &iEvent)
Called at the beginning of each new event.
Definition: Ntupliser.cc:386
void getGenPhotons()
Finds the generated photons and applies some hard cuts to the phase space.
Definition: Ntupliser.cc:106
int lumi
lumi section
Definition: Event.h:56
edm::Handle< double > rho
Definition: Ntupliser.h:68
std::vector< bool > Bit
flags for application of MET filters (see n-tupliser config file)
Definition: Event.h:89
edm::Handle< pat::PackedTriggerPrescales > triggerPrescales
Definition: Ntupliser.h:71
std::vector< int > PreL1min
L1 min pre-scale.
Definition: Event.h:74
float distGen
distance to gen (only relevant in MC)
Definition: Event.h:126
const bool triggers
Definition: Parameters.h:82
DAS::Parameters p
Definition: Ntupliser.h:58
float z
position on beam axis
Definition: Event.h:121
lhe
Definition: Ntupliser_cfg.py:271
std::vector< std::string > triggerNames_
Definition: Parameters.h:87
edm::Handle< pat::PackedTriggerPrescales > triggerPrescalesl1min
Definition: Ntupliser.h:71
float Rho
transverse distance to beam axis
Definition: Event.h:120
std::set< std::string > HLTjet_triggerNames
Definition: Parameters.h:89
edm::Handle< GenEventInfoProduct > genEvtInfo
Definition: Ntupliser.h:73
DAS::RecPhoton recphoton
Definition: classes.h:21
void clear()
to clear for each new event in n-tupliser
Definition: Event.cc:9
bool fake
flag for fake vertices
Definition: Event.h:124
DAS::PileUp pileup
Definition: classes.h:27
edm::EDGetTokenT< reco::VertexCollection > recVtxsToken
Definition: Parameters.h:85
const bool flavour
Definition: Parameters.h:68
const std::string SysDown
Suffix used for "down" uncertainties. Follows the Combine convention.
Definition: Format.h:10
void fillMET(edm::Event const &iEvent)
Fill the MET flags to the array.
Definition: Ntupliser.cc:527
edm::EDGetTokenT< edm::TriggerResults > metResultsToken
Definition: Parameters.h:84
std::vector< DAS::RecJet > * recJets_
Definition: Ntupliser.h:88
Weights weights
object weights
Definition: PhysicsObject.h:52
DAS::GenJet genjet
Definition: classes.h:14
DAS::GenEvent * genEvent_
Definition: Ntupliser.h:96
void clear()
to clear for each new event in n-tupliser
Definition: Event.cc:74
static float MBxsec
Definition: Event.h:100
std::vector< float > pthats
all hard scales found in PU
Definition: Event.h:106
edm::Handle< std::vector< PileupSummaryInfo > > pileupInfo
Definition: Ntupliser.h:77
edm::Handle< pat::TriggerObjectStandAloneCollection > triggerObjects
Definition: Ntupliser.h:72
void getEventVariables(edm::Event const &iEvent)
Definition: Ntupliser.cc:586
const bool photons
Definition: Parameters.h:78
run
Definition: generate_html.py:86
edm::Handle< pat::JetCollection > recjets
Definition: Ntupliser.h:63
float Phi
direction of the total transverse momentum
Definition: Event.h:88
std::vector< int > PreHLT
HLT prescale.
Definition: Event.h:73
DAS::Trigger * jetTrigger_
Definition: Ntupliser.h:95
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< float > > FourVector
Definition: PhysicsObject.h:15
float hard_scale
hard scale, corresponding to pthat in Pythia 8
Definition: Event.h:41
edm::Handle< reco::GenParticleCollection > genParticles
Definition: Ntupliser.h:74
edm::EDGetTokenT< GenEventInfoProduct > genEvtInfoToken
Definition: Parameters.h:62
int intpu
in-time pile-up (i.e. from the same bunch crossing)
Definition: Event.h:105
void clear()
to clear for each new event in n-tupliser
Definition: Event.cc:29
DAS::Weights weights
Definition: classes.h:12
void clear()
to clear for each new event in n-tupliser
Definition: Event.cc:21
edm::EDGetTokenT< reco::JetFlavourInfoMatchingCollection > jetFlavourInfosToken
Definition: Parameters.h:69
TTree * tree
Definition: Ntupliser.h:84
float SumEt
sum of the transverse energies of all the components (jet, leptons, etc.) present in the event
Definition: Event.h:86
std::vector< unsigned long long > MBevents
event IDs in MB sample
Definition: Event.h:107
void reset()
Just a common method to reset all branches at each new event.
Definition: Ntupliser.cc:349
std::vector< DAS::GenJet > * genJets_
Definition: Ntupliser.h:90
class RecPhoton
Definition: Photon.h:27
edm::Handle< reco::VertexCollection > recVtxs
Definition: Ntupliser.h:69
edm::EDGetTokenT< pat::TriggerObjectStandAloneCollection > triggerObjectsToken
Definition: Parameters.h:88
const bool isMC
flag
Definition: Parameters.h:56
bool trigger(edm::Event const &iEvent)
Finds the bits corresponding to the HLT jet pt triggers.
Definition: Ntupliser.cc:452
const bool jets
Definition: Parameters.h:68
float Pt
exactly the same as Et
Definition: Event.h:87
void getRecJets()
Finds the reconstructed jets, and applies some hard cuts on the phase space.
Definition: Ntupliser.cc:204