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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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 wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
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<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 29 of file MC_Efficiency_Analyzer.cc.

Constructor & Destructor Documentation

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  }
T getParameter(std::string const &) const
EDGetTokenT< CandidateCollection > TracksToken_
EDGetTokenT< CandidateCollection > zMuMuToken_
EDGetTokenT< CandidateCollection > StandAloneToken_
EDGetTokenT< CandMatchMap > TracksMapToken_
EDGetTokenT< CandMatchMap > StandAloneMapToken_
EDGetTokenT< CandMatchMap > MuonsMapToken_
EDGetTokenT< GenParticleCollection > genParticlesToken_
EDGetTokenT< CandidateCollection > MuonsToken_

Member Function Documentation

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

Definition at line 52 of file MC_Efficiency_Analyzer.cc.

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, edm::helpers::KeyVal< K, V >::key, 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, edm::helpers::KeyVal< K, V >::val, and ZMuMuAnalysisNtupler_cff::zMuMu.

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  }
EDGetTokenT< CandidateCollection > TracksToken_
const_iterator end() const
last iterator over the map (read only)
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
EDGetTokenT< CandidateCollection > zMuMuToken_
EDGetTokenT< CandidateCollection > StandAloneToken_
virtual int status() const =0
status word
EDGetTokenT< CandMatchMap > TracksMapToken_
virtual int pdgId() const =0
PDG identifier.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
d
Definition: ztail.py:151
zMuMu
zMuMu vector of PSet is common to all categories except zMuTrk category
virtual double eta() const =0
momentum pseudorapidity
virtual double pt() const =0
transverse momentum
EDGetTokenT< CandMatchMap > StandAloneMapToken_
EDGetTokenT< CandMatchMap > MuonsMapToken_
EDGetTokenT< GenParticleCollection > genParticlesToken_
const_iterator begin() const
first iterator over the map (read only)
EDGetTokenT< CandidateCollection > MuonsToken_
virtual size_type numberOfDaughters() const =0
number of daughters
void MCEfficiencyAnalyzer::endJob ( void  )
inlineoverridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 157 of file MC_Efficiency_Analyzer.cc.

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

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  }

Member Data Documentation

double MCEfficiencyAnalyzer::deltaRStacut_
private

Definition at line 183 of file MC_Efficiency_Analyzer.cc.

double MCEfficiencyAnalyzer::etacut_
private

Definition at line 183 of file MC_Efficiency_Analyzer.cc.

EDGetTokenT<GenParticleCollection> MCEfficiencyAnalyzer::genParticlesToken_
private

Definition at line 180 of file MC_Efficiency_Analyzer.cc.

EDGetTokenT<CandMatchMap> MCEfficiencyAnalyzer::MuonsMapToken_
private

Definition at line 177 of file MC_Efficiency_Analyzer.cc.

EDGetTokenT<CandidateCollection> MCEfficiencyAnalyzer::MuonsToken_
private

Definition at line 176 of file MC_Efficiency_Analyzer.cc.

int MCEfficiencyAnalyzer::nMuMC
private

Definition at line 184 of file MC_Efficiency_Analyzer.cc.

int MCEfficiencyAnalyzer::nMureco
private

Definition at line 184 of file MC_Efficiency_Analyzer.cc.

int MCEfficiencyAnalyzer::nNotMuMatching
private

Definition at line 184 of file MC_Efficiency_Analyzer.cc.

int MCEfficiencyAnalyzer::nSta
private

Definition at line 184 of file MC_Efficiency_Analyzer.cc.

int MCEfficiencyAnalyzer::nTrk
private

Definition at line 184 of file MC_Efficiency_Analyzer.cc.

double MCEfficiencyAnalyzer::ptcut_
private

Definition at line 183 of file MC_Efficiency_Analyzer.cc.

EDGetTokenT<CandMatchMap> MCEfficiencyAnalyzer::StandAloneMapToken_
private

Definition at line 182 of file MC_Efficiency_Analyzer.cc.

EDGetTokenT<CandidateCollection> MCEfficiencyAnalyzer::StandAloneToken_
private

Definition at line 181 of file MC_Efficiency_Analyzer.cc.

EDGetTokenT<CandMatchMap> MCEfficiencyAnalyzer::TracksMapToken_
private

Definition at line 179 of file MC_Efficiency_Analyzer.cc.

EDGetTokenT<CandidateCollection> MCEfficiencyAnalyzer::TracksToken_
private

Definition at line 178 of file MC_Efficiency_Analyzer.cc.

vector<double> MCEfficiencyAnalyzer::v_
private

Definition at line 185 of file MC_Efficiency_Analyzer.cc.

EDGetTokenT<CandidateCollection> MCEfficiencyAnalyzer::zMuMuToken_
private

Definition at line 175 of file MC_Efficiency_Analyzer.cc.