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 32 of file MC_Efficiency_Analyzer.cc.

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

References funct::abs(), edm::AssociationMap< Tag >::begin(), gather_cfg::cout, edmIntegrityCheck::d, reco::Candidate::daughter(), boostedElectronIsolation_cff::deltaR, MillePedeFileConverter_cfg::e, edm::AssociationMap< Tag >::end(), reco::Candidate::eta(), GenHFHadronMatcher_cfi::genParticles, mps_fire::i, gen::k, crabWrapper::key, checklumidiff::l, CaloTowersParam_cfi::mc, Reconstruction_hiPF_cff::Muons, gen::n, reco::Candidate::numberOfDaughters(), reco::Candidate::pdgId(), reco::Candidate::pt(), mps_update::status, reco::Candidate::status(), gather_cfg::Tracks, and heppy_batch::val.

50  {
51 
53  event.getByToken(zMuMuToken_, zMuMu);
54 
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  {
80  const Candidate & ZCand = (*genParticles)[ k ];
81  int status = ZCand.status();
82 
83  if (ZCand.pdgId()==23&& status==3 )
84  {
85  // positive muons
86  const Candidate * muCand1 = ZCand.daughter(0);
87  if (muCand1->status()==3)
88  {
89  for (unsigned int d =0 ; d< muCand1->numberOfDaughters(); d++)
90  {
91  const Candidate * muCandidate = muCand1->daughter(d);
92  if (muCandidate->pdgId() == muCand1->pdgId() )
93  {
94  muCand1 = muCand1->daughter(d);
95  }
96  }
97  }
98  // negative muons
99  const Candidate * muCand2 = ZCand.daughter(1);
100  if (muCand2->status()==3)
101  {
102  for (unsigned int e =0 ; e< muCand2->numberOfDaughters(); e++)
103  {
104  const Candidate * muCandidate = muCand2->daughter(e);
105  if (muCandidate->pdgId() == muCand2->pdgId() )
106  {
107  muCand2 = muCand2->daughter(e);
108  }
109  }
110  }
111 
112  double deltaR_Mu_Sta =0;
113  int nMurecoTemp = nMureco;
114  // getting mu matched
116  for(i = MuonsMap->begin(); i != MuonsMap->end(); i++ )
117  {
118  const Candidate/* & reco = * i -> key,*/ & mc = * i -> val;
119  if ((muCand1 == &mc) && (mc.pt()>ptcut_) && (std::abs(mc.eta())<etacut_))
120  {
121  nMuMC++;
122  nMureco++;
123  break;
124  }
125  }
126  if (nMureco == nMurecoTemp ) // I.E. MU RECO NOT FOUND!!!!
127  {
128  int nTrkTemp = nTrk;
129  int nStaTemp = nSta;
130 
131  // getting tracks matched and doing the same, CONTROLLING IF MU IS RECONSTRUCTED AS A TRACK AND NOT AS A MU
133  for(l = TracksMap->begin(); l != TracksMap->end(); l++ )
134  {
135  const Candidate /* & Trkreco = * l -> key, */ & Trkmc = * l -> val;
136  if (( muCand1 == & Trkmc) && (Trkmc.pt()>ptcut_) && (std::abs(Trkmc.eta())<etacut_))
137  {
138  nMuMC++;
139  nTrk++;
140  break;
141  }
142  }
143  // the same for standalone
145  for(n = StandAloneMap->begin(); n != StandAloneMap->end(); n++ )
146  {
147  const Candidate & Stareco = * n -> key, & Stamc = * n -> val;
148  if ((muCand1 == &Stamc ) && (Stamc.pt()>ptcut_) && (std::abs(Stamc.eta())<etacut_))
149  {
150  nMuMC++;
151  nSta++;
152  deltaR_Mu_Sta = deltaR(Stareco, *muCand1);
153 
154  // cout<<"Ho trovato un sta reco "<<endl;
155  break;
156  }
157  }
158  // 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
159  if ((nSta == nStaTemp + 1) && (nTrk == nTrkTemp + 1 ) )
160  {
161  nNotMuMatching ++;
162  if ((deltaR_Mu_Sta< deltaRStacut_))
163  {
164  v_.push_back(deltaR_Mu_Sta) ;
165  cout << "Not matching from trk and sta matched to MC mu, to reconstruct a recoMU" << endl;
166  }
167  }
168  }
169  }
170  }
171  }
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
int k[5][pyjets_maxn]
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 174 of file MC_Efficiency_Analyzer.cc.

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

175  {
176 
177 
178  cout <<"--- nMuMC == "<<nMuMC<<endl;
179  cout <<"--- nMureco == "<<nMureco<<endl;
180  cout <<"--- nSta == "<<nSta<<endl;
181  cout <<"--- nTrk == "<<nTrk<<endl;
182  cout <<"--- nNotMuMatching from a trk and sta matched to a Mu MC == "<<nNotMuMatching<<endl;
183  if (nMuMC!=0 )
184  {
185  cout<<" effMu == "<<(double) nMureco/nMuMC<<endl;
186  cout<<" effTrk == "<< (double)(nTrk + nMureco) /nMuMC<<endl;
187  cout<<" effSta == "<< (double)(nSta + nMureco) / nMuMC<<endl;
188  }
189 
190  for (unsigned int i =0 ; i < v_.size(); ++i )
191  {
192  cout<<" delta R Mu Sta == "<< v_[i]<<endl;
193  }
194  }

Member Data Documentation

double MCEfficiencyAnalyzer::deltaRStacut_
private

Definition at line 210 of file MC_Efficiency_Analyzer.cc.

double MCEfficiencyAnalyzer::etacut_
private

Definition at line 210 of file MC_Efficiency_Analyzer.cc.

EDGetTokenT<GenParticleCollection> MCEfficiencyAnalyzer::genParticlesToken_
private

Definition at line 207 of file MC_Efficiency_Analyzer.cc.

EDGetTokenT<CandMatchMap> MCEfficiencyAnalyzer::MuonsMapToken_
private

Definition at line 204 of file MC_Efficiency_Analyzer.cc.

EDGetTokenT<CandidateCollection> MCEfficiencyAnalyzer::MuonsToken_
private

Definition at line 203 of file MC_Efficiency_Analyzer.cc.

int MCEfficiencyAnalyzer::nMuMC
private

Definition at line 211 of file MC_Efficiency_Analyzer.cc.

int MCEfficiencyAnalyzer::nMureco
private

Definition at line 211 of file MC_Efficiency_Analyzer.cc.

int MCEfficiencyAnalyzer::nNotMuMatching
private

Definition at line 211 of file MC_Efficiency_Analyzer.cc.

int MCEfficiencyAnalyzer::nSta
private

Definition at line 211 of file MC_Efficiency_Analyzer.cc.

int MCEfficiencyAnalyzer::nTrk
private

Definition at line 211 of file MC_Efficiency_Analyzer.cc.

double MCEfficiencyAnalyzer::ptcut_
private

Definition at line 210 of file MC_Efficiency_Analyzer.cc.

EDGetTokenT<CandMatchMap> MCEfficiencyAnalyzer::StandAloneMapToken_
private

Definition at line 209 of file MC_Efficiency_Analyzer.cc.

EDGetTokenT<CandidateCollection> MCEfficiencyAnalyzer::StandAloneToken_
private

Definition at line 208 of file MC_Efficiency_Analyzer.cc.

EDGetTokenT<CandMatchMap> MCEfficiencyAnalyzer::TracksMapToken_
private

Definition at line 206 of file MC_Efficiency_Analyzer.cc.

EDGetTokenT<CandidateCollection> MCEfficiencyAnalyzer::TracksToken_
private

Definition at line 205 of file MC_Efficiency_Analyzer.cc.

vector<double> MCEfficiencyAnalyzer::v_
private

Definition at line 212 of file MC_Efficiency_Analyzer.cc.

EDGetTokenT<CandidateCollection> MCEfficiencyAnalyzer::zMuMuToken_
private

Definition at line 202 of file MC_Efficiency_Analyzer.cc.