CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
MCEfficiencyAnalyzer Class Reference
Inheritance diagram for MCEfficiencyAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &setup) override
 
void endJob () override
 
 MCEfficiencyAnalyzer (const edm::ParameterSet &pset)
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

double deltaRStacut_
 
double etacut_
 
EDGetTokenT< GenParticleCollectiongenParticlesToken_
 
EDGetTokenT< CandMatchMapMuonsMapToken_
 
EDGetTokenT< CandidateCollectionMuonsToken_
 
int nMuMC
 
int nMureco
 
int nNotMuMatching
 
int nSta
 
int nTrk
 
double ptcut_
 
EDGetTokenT< CandMatchMapStandAloneMapToken_
 
EDGetTokenT< CandidateCollectionStandAloneToken_
 
EDGetTokenT< CandMatchMapTracksMapToken_
 
EDGetTokenT< CandidateCollectionTracksToken_
 
vector< double > v_
 
EDGetTokenT< CandidateCollectionzMuMuToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 29 of file MC_Efficiency_Analyzer.cc.

Constructor & Destructor Documentation

◆ MCEfficiencyAnalyzer()

MCEfficiencyAnalyzer::MCEfficiencyAnalyzer ( const edm::ParameterSet pset)
inline

Definition at line 31 of file MC_Efficiency_Analyzer.cc.

32  : zMuMuToken_(consumes<CandidateCollection>(pset.getParameter<InputTag>("zMuMu"))),
33  MuonsToken_(consumes<CandidateCollection>(pset.getParameter<InputTag>("Muons"))),
34  MuonsMapToken_(consumes<CandMatchMap>(pset.getParameter<InputTag>("MuonsMap"))),
35  TracksToken_(consumes<CandidateCollection>(pset.getParameter<InputTag>("Tracks"))),
36  TracksMapToken_(consumes<CandMatchMap>(pset.getParameter<InputTag>("TracksMap"))),
37  genParticlesToken_(consumes<GenParticleCollection>(pset.getParameter<InputTag>("genParticles"))),
38  StandAloneToken_(consumes<CandidateCollection>(pset.getParameter<InputTag>("StandAlone"))),
39  StandAloneMapToken_(consumes<CandMatchMap>(pset.getParameter<InputTag>("StandAloneMap"))),
40  etacut_(pset.getParameter<double>("etacut")),
41  ptcut_(pset.getParameter<double>("ptcut")),
42  deltaRStacut_(pset.getParameter<double>("deltaRStacut"))
43 
44  {
45  nMuMC = 0;
46  nMureco = 0;
47  nTrk = 0;
48  nSta = 0;
49  nNotMuMatching = 0;
50  }

Member Function Documentation

◆ analyze()

void MCEfficiencyAnalyzer::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
inlineoverridevirtual

Implements edm::EDAnalyzer.

Definition at line 52 of file MC_Efficiency_Analyzer.cc.

52  {
54  event.getByToken(zMuMuToken_, zMuMu);
55 
57  event.getByToken(MuonsToken_, Muons);
58 
60  event.getByToken(TracksToken_, Tracks);
61 
62  Handle<CandidateCollection> StandAlone;
63  event.getByToken(StandAloneToken_, StandAlone);
64 
65  Handle<CandMatchMap> MuonsMap;
66  event.getByToken(MuonsMapToken_, MuonsMap);
67 
68  Handle<CandMatchMap> TracksMap;
69  event.getByToken(TracksMapToken_, TracksMap);
70 
71  Handle<CandMatchMap> StandAloneMap;
72  event.getByToken(StandAloneMapToken_, StandAloneMap);
73 
75  event.getByToken(genParticlesToken_, genParticles);
76 
77  //Getting muons from Z MC
78  for (unsigned int k = 0; k < genParticles->size(); k++) {
79  const Candidate& ZCand = (*genParticles)[k];
80  int status = ZCand.status();
81 
82  if (ZCand.pdgId() == 23 && status == 3) {
83  // positive muons
84  const Candidate* muCand1 = ZCand.daughter(0);
85  if (muCand1->status() == 3) {
86  for (unsigned int d = 0; d < muCand1->numberOfDaughters(); d++) {
87  const Candidate* muCandidate = muCand1->daughter(d);
88  if (muCandidate->pdgId() == muCand1->pdgId()) {
89  muCand1 = muCand1->daughter(d);
90  }
91  }
92  }
93  // negative muons
94  const Candidate* muCand2 = ZCand.daughter(1);
95  if (muCand2->status() == 3) {
96  for (unsigned int e = 0; e < muCand2->numberOfDaughters(); e++) {
97  const Candidate* muCandidate = muCand2->daughter(e);
98  if (muCandidate->pdgId() == muCand2->pdgId()) {
99  muCand2 = muCand2->daughter(e);
100  }
101  }
102  }
103 
104  double deltaR_Mu_Sta = 0;
105  int nMurecoTemp = nMureco;
106  // getting mu matched
108  for (i = MuonsMap->begin(); i != MuonsMap->end(); i++) {
109  const Candidate /* & reco = * i -> key,*/& mc = *i->val;
110  if ((muCand1 == &mc) && (mc.pt() > ptcut_) && (std::abs(mc.eta()) < etacut_)) {
111  nMuMC++;
112  nMureco++;
113  break;
114  }
115  }
116  if (nMureco == nMurecoTemp) // I.E. MU RECO NOT FOUND!!!!
117  {
118  int nTrkTemp = nTrk;
119  int nStaTemp = nSta;
120 
121  // getting tracks matched and doing the same, CONTROLLING IF MU IS RECONSTRUCTED AS A TRACK AND NOT AS A MU
123  for (l = TracksMap->begin(); l != TracksMap->end(); l++) {
124  const Candidate /* & Trkreco = * l -> key, */& Trkmc = *l->val;
125  if ((muCand1 == &Trkmc) && (Trkmc.pt() > ptcut_) && (std::abs(Trkmc.eta()) < etacut_)) {
126  nMuMC++;
127  nTrk++;
128  break;
129  }
130  }
131  // the same for standalone
133  for (n = StandAloneMap->begin(); n != StandAloneMap->end(); n++) {
134  const Candidate &Stareco = *n->key, &Stamc = *n->val;
135  if ((muCand1 == &Stamc) && (Stamc.pt() > ptcut_) && (std::abs(Stamc.eta()) < etacut_)) {
136  nMuMC++;
137  nSta++;
138  deltaR_Mu_Sta = deltaR(Stareco, *muCand1);
139 
140  // cout<<"Ho trovato un sta reco "<<endl;
141  break;
142  }
143  }
144  // controlling if sta and trk are reconstrucetd both, and if so the get the deltaR beetween muon MC and reco sta, to controll correlation to this happening
145  if ((nSta == nStaTemp + 1) && (nTrk == nTrkTemp + 1)) {
146  nNotMuMatching++;
147  if ((deltaR_Mu_Sta < deltaRStacut_)) {
148  v_.push_back(deltaR_Mu_Sta);
149  cout << "Not matching from trk and sta matched to MC mu, to reconstruct a recoMU" << endl;
150  }
151  }
152  }
153  }
154  }
155  }

References funct::abs(), edm::AssociationMap< Tag >::begin(), gather_cfg::cout, ztail::d, reco::Candidate::daughter(), PbPb_ZMuSkimMuonDPG_cff::deltaR, MillePedeFileConverter_cfg::e, edm::AssociationMap< Tag >::end(), reco::Candidate::eta(), genParticles2HepMC_cfi::genParticles, mps_fire::i, dqmdumpme::k, cmsLHEtoEOSManager::l, CaloTowersParam_cfi::mc, HLTTauDQMOffline_cfi::Muons, dqmiodumpmetadata::n, reco::Candidate::numberOfDaughters(), reco::Candidate::pdgId(), reco::Candidate::pt(), mps_update::status, reco::Candidate::status(), gather_cfg::Tracks, and ZMuMuAnalysisNtupler_cff::zMuMu.

◆ endJob()

void MCEfficiencyAnalyzer::endJob ( void  )
inlineoverridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 157 of file MC_Efficiency_Analyzer.cc.

157  {
158  cout << "--- nMuMC == " << nMuMC << endl;
159  cout << "--- nMureco == " << nMureco << endl;
160  cout << "--- nSta == " << nSta << endl;
161  cout << "--- nTrk == " << nTrk << endl;
162  cout << "--- nNotMuMatching from a trk and sta matched to a Mu MC == " << nNotMuMatching << endl;
163  if (nMuMC != 0) {
164  cout << " effMu == " << (double)nMureco / nMuMC << endl;
165  cout << " effTrk == " << (double)(nTrk + nMureco) / nMuMC << endl;
166  cout << " effSta == " << (double)(nSta + nMureco) / nMuMC << endl;
167  }
168 
169  for (unsigned int i = 0; i < v_.size(); ++i) {
170  cout << " delta R Mu Sta == " << v_[i] << endl;
171  }
172  }

References gather_cfg::cout, and mps_fire::i.

Member Data Documentation

◆ deltaRStacut_

double MCEfficiencyAnalyzer::deltaRStacut_
private

Definition at line 183 of file MC_Efficiency_Analyzer.cc.

◆ etacut_

double MCEfficiencyAnalyzer::etacut_
private

Definition at line 183 of file MC_Efficiency_Analyzer.cc.

◆ genParticlesToken_

EDGetTokenT<GenParticleCollection> MCEfficiencyAnalyzer::genParticlesToken_
private

Definition at line 180 of file MC_Efficiency_Analyzer.cc.

◆ MuonsMapToken_

EDGetTokenT<CandMatchMap> MCEfficiencyAnalyzer::MuonsMapToken_
private

Definition at line 177 of file MC_Efficiency_Analyzer.cc.

◆ MuonsToken_

EDGetTokenT<CandidateCollection> MCEfficiencyAnalyzer::MuonsToken_
private

Definition at line 176 of file MC_Efficiency_Analyzer.cc.

◆ nMuMC

int MCEfficiencyAnalyzer::nMuMC
private

Definition at line 184 of file MC_Efficiency_Analyzer.cc.

◆ nMureco

int MCEfficiencyAnalyzer::nMureco
private

Definition at line 184 of file MC_Efficiency_Analyzer.cc.

◆ nNotMuMatching

int MCEfficiencyAnalyzer::nNotMuMatching
private

Definition at line 184 of file MC_Efficiency_Analyzer.cc.

◆ nSta

int MCEfficiencyAnalyzer::nSta
private

Definition at line 184 of file MC_Efficiency_Analyzer.cc.

◆ nTrk

int MCEfficiencyAnalyzer::nTrk
private

Definition at line 184 of file MC_Efficiency_Analyzer.cc.

◆ ptcut_

double MCEfficiencyAnalyzer::ptcut_
private

Definition at line 183 of file MC_Efficiency_Analyzer.cc.

◆ StandAloneMapToken_

EDGetTokenT<CandMatchMap> MCEfficiencyAnalyzer::StandAloneMapToken_
private

Definition at line 182 of file MC_Efficiency_Analyzer.cc.

◆ StandAloneToken_

EDGetTokenT<CandidateCollection> MCEfficiencyAnalyzer::StandAloneToken_
private

Definition at line 181 of file MC_Efficiency_Analyzer.cc.

◆ TracksMapToken_

EDGetTokenT<CandMatchMap> MCEfficiencyAnalyzer::TracksMapToken_
private

Definition at line 179 of file MC_Efficiency_Analyzer.cc.

◆ TracksToken_

EDGetTokenT<CandidateCollection> MCEfficiencyAnalyzer::TracksToken_
private

Definition at line 178 of file MC_Efficiency_Analyzer.cc.

◆ v_

vector<double> MCEfficiencyAnalyzer::v_
private

Definition at line 185 of file MC_Efficiency_Analyzer.cc.

◆ zMuMuToken_

EDGetTokenT<CandidateCollection> MCEfficiencyAnalyzer::zMuMuToken_
private

Definition at line 175 of file MC_Efficiency_Analyzer.cc.

reco::Candidate::daughter
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode)
mps_fire.i
i
Definition: mps_fire.py:428
genParticles2HepMC_cfi.genParticles
genParticles
Definition: genParticles2HepMC_cfi.py:4
MCEfficiencyAnalyzer::TracksToken_
EDGetTokenT< CandidateCollection > TracksToken_
Definition: MC_Efficiency_Analyzer.cc:178
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
ZMuMuAnalysisNtupler_cff.zMuMu
zMuMu
zMuMu vector of PSet is common to all categories except zMuTrk category
Definition: ZMuMuAnalysisNtupler_cff.py:340
CaloTowersParam_cfi.mc
mc
Definition: CaloTowersParam_cfi.py:8
mps_update.status
status
Definition: mps_update.py:69
reco::Candidate::eta
virtual double eta() const =0
momentum pseudorapidity
gather_cfg.cout
cout
Definition: gather_cfg.py:144
MCEfficiencyAnalyzer::zMuMuToken_
EDGetTokenT< CandidateCollection > zMuMuToken_
Definition: MC_Efficiency_Analyzer.cc:175
MCEfficiencyAnalyzer::v_
vector< double > v_
Definition: MC_Efficiency_Analyzer.cc:185
reco::Candidate::pt
virtual double pt() const =0
transverse momentum
reco::Candidate::status
virtual int status() const =0
status word
MCEfficiencyAnalyzer::StandAloneToken_
EDGetTokenT< CandidateCollection > StandAloneToken_
Definition: MC_Efficiency_Analyzer.cc:181
edm::Handle
Definition: AssociativeIterator.h:50
edm::AssociationMap::end
const_iterator end() const
last iterator over the map (read only)
Definition: AssociationMap.h:171
MCEfficiencyAnalyzer::nMuMC
int nMuMC
Definition: MC_Efficiency_Analyzer.cc:184
MCEfficiencyAnalyzer::nMureco
int nMureco
Definition: MC_Efficiency_Analyzer.cc:184
MCEfficiencyAnalyzer::MuonsMapToken_
EDGetTokenT< CandMatchMap > MuonsMapToken_
Definition: MC_Efficiency_Analyzer.cc:177
reco::Candidate::numberOfDaughters
virtual size_type numberOfDaughters() const =0
number of daughters
MCEfficiencyAnalyzer::StandAloneMapToken_
EDGetTokenT< CandMatchMap > StandAloneMapToken_
Definition: MC_Efficiency_Analyzer.cc:182
dqmdumpme.k
k
Definition: dqmdumpme.py:60
MCEfficiencyAnalyzer::MuonsToken_
EDGetTokenT< CandidateCollection > MuonsToken_
Definition: MC_Efficiency_Analyzer.cc:176
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
HLTTauDQMOffline_cfi.Muons
Muons
Definition: HLTTauDQMOffline_cfi.py:51
MCEfficiencyAnalyzer::nNotMuMatching
int nNotMuMatching
Definition: MC_Efficiency_Analyzer.cc:184
MCEfficiencyAnalyzer::deltaRStacut_
double deltaRStacut_
Definition: MC_Efficiency_Analyzer.cc:183
gather_cfg.Tracks
Tracks
Definition: gather_cfg.py:251
reco::Candidate::pdgId
virtual int pdgId() const =0
PDG identifier.
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
MCEfficiencyAnalyzer::TracksMapToken_
EDGetTokenT< CandMatchMap > TracksMapToken_
Definition: MC_Efficiency_Analyzer.cc:179
reco::Candidate
Definition: Candidate.h:27
MCEfficiencyAnalyzer::etacut_
double etacut_
Definition: MC_Efficiency_Analyzer.cc:183
MCEfficiencyAnalyzer::nTrk
int nTrk
Definition: MC_Efficiency_Analyzer.cc:184
edm::AssociationMap::begin
const_iterator begin() const
first iterator over the map (read only)
Definition: AssociationMap.h:169
MCEfficiencyAnalyzer::ptcut_
double ptcut_
Definition: MC_Efficiency_Analyzer.cc:183
ztail.d
d
Definition: ztail.py:151
MCEfficiencyAnalyzer::nSta
int nSta
Definition: MC_Efficiency_Analyzer.cc:184
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::AssociationMap::const_iterator
const iterator
Definition: AssociationMap.h:76
edm::InputTag
Definition: InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
MCEfficiencyAnalyzer::genParticlesToken_
EDGetTokenT< GenParticleCollection > genParticlesToken_
Definition: MC_Efficiency_Analyzer.cc:180
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37