CMS 3D CMS Logo

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

Public Member Functions

 MCAcceptanceAnalyzer (const ParameterSet &cfg)
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- 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
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const Event &, const EventSetup &) override
 
void endJob () override
 

Private Attributes

long nZToMuMu_
 
long nZToMuMuMC_
 
long nZToMuMuMCDen_
 
long nZToMuMuMCMatched_
 
ZSelector select_
 
ZSelector select_OnlyMassCut_
 
long selZToMuMu_
 
long selZToMuMuMC_
 
long selZToMuMuMCMatched_
 
InputTag zToMuMu_
 
InputTag zToMuMuMatched_
 
EDGetTokenT< GenParticleMatchzToMuMuMatchedToken_
 
InputTag zToMuMuMC_
 
EDGetTokenT< CandidateViewzToMuMuMCToken_
 
EDGetTokenT< CandidateViewzToMuMuToken_
 

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 &)
 
- 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 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 54 of file MCAcceptanceAnalyzer.cc.

Constructor & Destructor Documentation

MCAcceptanceAnalyzer::MCAcceptanceAnalyzer ( const ParameterSet cfg)

Definition at line 68 of file MCAcceptanceAnalyzer.cc.

68  :
69  zToMuMu_(cfg.getParameter<InputTag>("zToMuMu")),
70  zToMuMuMC_(cfg.getParameter<InputTag>("zToMuMuMC")),
71  zToMuMuMatched_(cfg.getParameter<InputTag>("zToMuMuMatched")),
72  zToMuMuToken_(consumes<CandidateView>(zToMuMu_)),
73  zToMuMuMCToken_(consumes<CandidateView>(zToMuMuMC_)),
74  zToMuMuMatchedToken_(consumes<GenParticleMatch> (zToMuMuMatched_)),
75  nZToMuMu_(0), selZToMuMu_(0),
78  select_(cfg.getParameter<double>("ptMin"), cfg.getParameter<double>("etaDau0Min"), cfg.getParameter<double>("etaDau0Max"), cfg.getParameter<double>("etaDau1Min"), cfg.getParameter<double>("etaDau1Max"),cfg.getParameter<double>("massMin"), cfg.getParameter<double>("massMax"), cfg.getParameter<double>("massMinZMC"), cfg.getParameter<double>("massMaxZMC") ),
79  select_OnlyMassCut_(-1, -9999,9999 , -9999, 9999,0, 0, cfg.getParameter<double>("massMinZMC"), cfg.getParameter<double>("massMaxZMC") )
80 {
81 }
T getParameter(std::string const &) const
EDGetTokenT< GenParticleMatch > zToMuMuMatchedToken_
EDGetTokenT< CandidateView > zToMuMuToken_
EDGetTokenT< CandidateView > zToMuMuMCToken_

Member Function Documentation

void MCAcceptanceAnalyzer::analyze ( const Event evt,
const EventSetup  
)
overrideprivate

Definition at line 83 of file MCAcceptanceAnalyzer.cc.

References gather_cfg::cout, allConversions_cfi::d0, reco::Candidate::daughter(), reco::Candidate::eta(), edm::Event::getByToken(), mps_fire::i, edm::Ref< C, T, F >::isNonnull(), funct::m, ResonanceBuilder::mass, reco::Candidate::mass(), mcMuDaughter(), reco::Candidate::numberOfDaughters(), nZToMuMu_, nZToMuMuMC_, nZToMuMuMCDen_, nZToMuMuMCMatched_, reco::Candidate::p4(), reco::Candidate::pt(), edm::View< T >::refAt(), select_, select_OnlyMassCut_, selZToMuMu_, selZToMuMuMC_, selZToMuMuMCMatched_, edm::Association< C >::size(), edm::View< T >::size(), z, zToMuMuMatchedToken_, zToMuMuMCToken_, and zToMuMuToken_.

83  {
84  Handle<CandidateView> zToMuMu;
85  evt.getByToken(zToMuMuToken_, zToMuMu);
86  Handle<CandidateView> zToMuMuMC;
87  evt.getByToken(zToMuMuMCToken_, zToMuMuMC);
88  Handle<GenParticleMatch > zToMuMuMatched;
89  evt.getByToken(zToMuMuMatchedToken_, zToMuMuMatched);
90  // long nZToMuMu = zToMuMu->size();
91  long nZToMuMuMC = zToMuMuMC->size();
92  long nZToMuMuMatched = zToMuMuMatched->size();
93 
94 
95  // cout << ">>> " << zToMuMu_ << " has " << nZToMuMu << " entries" << endl;
96  //cout << ">>> " << zToMuMuMC_ << " has " << nZToMuMuMC << " entries" << endl;
97  //cout << ">>> " << zToMuMuMatched_ << " has " << nZToMuMuMatched << " entries" << endl;
98 
99 
100 
101  nZToMuMuMC_ += nZToMuMuMC;
102  for(long i = 0; i < nZToMuMuMC; ++i) {
103  const Candidate & z = (*zToMuMuMC)[i];
104  if(select_(z)==4) ++selZToMuMuMC_;
106 
107  }
108 
109 
110  for(long i = 0; i < nZToMuMuMatched; ++i) {
111 
112  const Candidate & z = (*zToMuMu)[i];
113  CandidateBaseRef zRef = zToMuMu->refAt(i);
114  GenParticleRef mcRef = (*zToMuMuMatched)[zRef];
115 
116 
117  if(mcRef.isNonnull()) { // z candidate matched to Z MC
118  ++nZToMuMu_;
120 
121  int selectZ = select_(z);
122  if(selectZ==4) ++selZToMuMu_;
123 
124 
125 
126  int selectMC = select_(*mcRef);
127 
128  if(selectMC==4) ++selZToMuMuMCMatched_;
129 
130  if(selectZ != selectMC) {
131  cout << ">>> select reco: " << selectZ << ", select mc: " << selectMC << endl;
132  if ((selectZ * selectMC) ==0 ) break;
133  if (z.numberOfDaughters()> 1){
134  const Candidate * d0 = z.daughter(0), * d1 = z.daughter(1);
135  if (mcRef->numberOfDaughters()>1){
136  const Candidate * mcd0 = mcMuDaughter(mcRef->daughter(0)),
137  * mcd1 = mcMuDaughter(mcRef->daughter(1));
138  double m = z.mass(), mcm = (mcd0->p4()+mcd1->p4()).mass();
139  cout << ">>> reco pt1, eta1: " << d0->pt() <<", " << d0->eta()
140  << ", 2: " << d1->pt() << ", " << d1->eta()
141  << ", mass = " << m << endl;
142  cout << ">>> mc pt1, eta1: " << mcd0->pt() <<", " << mcd0->eta()
143  << ", 2: " << mcd1->pt() << ", " << mcd1->eta()
144  << ", mass = " << mcm << endl;
145  }
146  }
147 
148  }
149  // to avoid double counting
150  if ((selectZ==3) && (selectMC==3)) break;
151  }
152  }
153 
154 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
EDGetTokenT< GenParticleMatch > zToMuMuMatchedToken_
EDGetTokenT< CandidateView > zToMuMuToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
size_type size() const
RefToBase< value_type > refAt(size_type i) const
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
const Candidate * mcMuDaughter(const Candidate *c)
size_t size() const
Definition: Association.h:63
virtual double eta() const =0
momentum pseudorapidity
virtual double pt() const =0
transverse momentum
virtual double mass() const =0
mass
EDGetTokenT< CandidateView > zToMuMuMCToken_
virtual size_type numberOfDaughters() const =0
number of daughters
void MCAcceptanceAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 156 of file MCAcceptanceAnalyzer.cc.

References gather_cfg::cout, DEFINE_FWK_MODULE, nZToMuMu_, nZToMuMuMC_, nZToMuMuMCDen_, nZToMuMuMCMatched_, selZToMuMu_, selZToMuMuMC_, selZToMuMuMCMatched_, mathSSE::sqrt(), zToMuMu_, and zToMuMuMC_.

156  {
157  double effZToMuMu = double(selZToMuMu_)/double(nZToMuMu_);
158  double errZToMuMu = sqrt(effZToMuMu*(1. - effZToMuMu)/nZToMuMu_);
159  double effZToMuMuMC = double(selZToMuMuMC_)/double(nZToMuMuMC_);
160  double errZToMuMuMC = sqrt(effZToMuMuMC*(1. - effZToMuMuMC)/nZToMuMuMC_);
161  double effZToMuMuMCDen = double(selZToMuMuMC_)/double(nZToMuMuMCDen_);
162  double errZToMuMuMCDen = sqrt(effZToMuMuMCDen*(1. - effZToMuMuMCDen)/nZToMuMuMCDen_);
163  double effZToMuMuMCMatched = double(selZToMuMuMCMatched_)/double(nZToMuMuMCMatched_);
164  double errZToMuMuMCMatched = sqrt(effZToMuMuMCMatched*(1. - effZToMuMuMCMatched)/nZToMuMuMCMatched_);
165  cout << ">>> " << zToMuMu_ << ": " << selZToMuMu_ << "/" << nZToMuMu_
166  << " = " << effZToMuMu << " +/- " << errZToMuMu << endl;
167  cout << ">>> " << zToMuMuMC_ << " - matched: " << selZToMuMuMCMatched_ << "/" << nZToMuMuMCMatched_
168  << " = " << effZToMuMuMCMatched << " +/- " << errZToMuMuMCMatched << endl;
169  cout << " if the two numbers above are the same we can neglete resolution effect and quote the acceptance as the number below.... " << endl;
170  cout << "********* acceptance m>sampleMCMassCut (usually 20 or 40) ******** " << endl;
171  cout << ">>> " << zToMuMuMC_ << ": " << selZToMuMuMC_ << "/" << nZToMuMuMC_
172  << " = " << effZToMuMuMC << " +/- " << errZToMuMuMC << endl;
173  cout << "********* acceptance in the given mass range ******** " << endl;
174  cout << ">>> " << zToMuMuMC_ << ": " << selZToMuMuMC_ << "/" << nZToMuMuMCDen_
175  << " = " << effZToMuMuMCDen << " +/- " << errZToMuMuMCDen << endl;
176 
177 }
T sqrt(T t)
Definition: SSEVec.h:18

Member Data Documentation

long MCAcceptanceAnalyzer::nZToMuMu_
private

Definition at line 64 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

long MCAcceptanceAnalyzer::nZToMuMuMC_
private

Definition at line 64 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

long MCAcceptanceAnalyzer::nZToMuMuMCDen_
private

Definition at line 64 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

long MCAcceptanceAnalyzer::nZToMuMuMCMatched_
private

Definition at line 64 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

ZSelector MCAcceptanceAnalyzer::select_
private

Definition at line 65 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

ZSelector MCAcceptanceAnalyzer::select_OnlyMassCut_
private

Definition at line 65 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

long MCAcceptanceAnalyzer::selZToMuMu_
private

Definition at line 64 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

long MCAcceptanceAnalyzer::selZToMuMuMC_
private

Definition at line 64 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

long MCAcceptanceAnalyzer::selZToMuMuMCMatched_
private

Definition at line 64 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

InputTag MCAcceptanceAnalyzer::zToMuMu_
private

Definition at line 60 of file MCAcceptanceAnalyzer.cc.

Referenced by endJob().

InputTag MCAcceptanceAnalyzer::zToMuMuMatched_
private

Definition at line 60 of file MCAcceptanceAnalyzer.cc.

EDGetTokenT<GenParticleMatch > MCAcceptanceAnalyzer::zToMuMuMatchedToken_
private

Definition at line 63 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

InputTag MCAcceptanceAnalyzer::zToMuMuMC_
private

Definition at line 60 of file MCAcceptanceAnalyzer.cc.

Referenced by endJob().

EDGetTokenT<CandidateView> MCAcceptanceAnalyzer::zToMuMuMCToken_
private

Definition at line 62 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

EDGetTokenT<CandidateView> MCAcceptanceAnalyzer::zToMuMuToken_
private

Definition at line 61 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().