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

Constructor & Destructor Documentation

MCAcceptanceAnalyzer::MCAcceptanceAnalyzer ( const ParameterSet cfg)

Definition at line 94 of file MCAcceptanceAnalyzer.cc.

95  : zToMuMu_(cfg.getParameter<InputTag>("zToMuMu")),
96  zToMuMuMC_(cfg.getParameter<InputTag>("zToMuMuMC")),
97  zToMuMuMatched_(cfg.getParameter<InputTag>("zToMuMuMatched")),
98  zToMuMuToken_(consumes<CandidateView>(zToMuMu_)),
99  zToMuMuMCToken_(consumes<CandidateView>(zToMuMuMC_)),
100  zToMuMuMatchedToken_(consumes<GenParticleMatch>(zToMuMuMatched_)),
101  nZToMuMu_(0),
102  selZToMuMu_(0),
103  nZToMuMuMC_(0),
104  selZToMuMuMC_(0),
107  nZToMuMuMCDen_(0),
108  select_(cfg.getParameter<double>("ptMin"),
109  cfg.getParameter<double>("etaDau0Min"),
110  cfg.getParameter<double>("etaDau0Max"),
111  cfg.getParameter<double>("etaDau1Min"),
112  cfg.getParameter<double>("etaDau1Max"),
113  cfg.getParameter<double>("massMin"),
114  cfg.getParameter<double>("massMax"),
115  cfg.getParameter<double>("massMinZMC"),
116  cfg.getParameter<double>("massMaxZMC")),
118  -9999,
119  9999,
120  -9999,
121  9999,
122  0,
123  0,
124  cfg.getParameter<double>("massMinZMC"),
125  cfg.getParameter<double>("massMaxZMC")) {}
T getParameter(std::string const &) const
EDGetTokenT< CandidateView > zToMuMuToken_
EDGetTokenT< GenParticleMatch > zToMuMuMatchedToken_
EDGetTokenT< CandidateView > zToMuMuMCToken_

Member Function Documentation

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

Definition at line 127 of file MCAcceptanceAnalyzer.cc.

References gather_cfg::cout, HLTMuonOfflineAnalyzer_cfi::d0, reco::Candidate::daughter(), reco::Candidate::eta(), edm::Event::getByToken(), mps_fire::i, edm::Ref< C, T, F >::isNonnull(), visualization-live-secondInstance_cfg::m, EgHLTOffHistBins_cfi::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_.

127  {
128  Handle<CandidateView> zToMuMu;
129  evt.getByToken(zToMuMuToken_, zToMuMu);
130  Handle<CandidateView> zToMuMuMC;
131  evt.getByToken(zToMuMuMCToken_, zToMuMuMC);
132  Handle<GenParticleMatch> zToMuMuMatched;
133  evt.getByToken(zToMuMuMatchedToken_, zToMuMuMatched);
134  // long nZToMuMu = zToMuMu->size();
135  long nZToMuMuMC = zToMuMuMC->size();
136  long nZToMuMuMatched = zToMuMuMatched->size();
137 
138  // cout << ">>> " << zToMuMu_ << " has " << nZToMuMu << " entries" << endl;
139  //cout << ">>> " << zToMuMuMC_ << " has " << nZToMuMuMC << " entries" << endl;
140  //cout << ">>> " << zToMuMuMatched_ << " has " << nZToMuMuMatched << " entries" << endl;
141 
142  nZToMuMuMC_ += nZToMuMuMC;
143  for (long i = 0; i < nZToMuMuMC; ++i) {
144  const Candidate& z = (*zToMuMuMC)[i];
145  if (select_(z) == 4)
146  ++selZToMuMuMC_;
147  if (select_OnlyMassCut_(z) == 4)
148  ++nZToMuMuMCDen_;
149  }
150 
151  for (long i = 0; i < nZToMuMuMatched; ++i) {
152  const Candidate& z = (*zToMuMu)[i];
153  CandidateBaseRef zRef = zToMuMu->refAt(i);
154  GenParticleRef mcRef = (*zToMuMuMatched)[zRef];
155 
156  if (mcRef.isNonnull()) { // z candidate matched to Z MC
157  ++nZToMuMu_;
159 
160  int selectZ = select_(z);
161  if (selectZ == 4)
162  ++selZToMuMu_;
163 
164  int selectMC = select_(*mcRef);
165 
166  if (selectMC == 4)
168 
169  if (selectZ != selectMC) {
170  cout << ">>> select reco: " << selectZ << ", select mc: " << selectMC << endl;
171  if ((selectZ * selectMC) == 0)
172  break;
173  if (z.numberOfDaughters() > 1) {
174  const Candidate *d0 = z.daughter(0), *d1 = z.daughter(1);
175  if (mcRef->numberOfDaughters() > 1) {
176  const Candidate *mcd0 = mcMuDaughter(mcRef->daughter(0)), *mcd1 = mcMuDaughter(mcRef->daughter(1));
177  double m = z.mass(), mcm = (mcd0->p4() + mcd1->p4()).mass();
178  cout << ">>> reco pt1, eta1: " << d0->pt() << ", " << d0->eta() << ", 2: " << d1->pt() << ", " << d1->eta()
179  << ", mass = " << m << endl;
180  cout << ">>> mc pt1, eta1: " << mcd0->pt() << ", " << mcd0->eta() << ", 2: " << mcd1->pt() << ", "
181  << mcd1->eta() << ", mass = " << mcm << endl;
182  }
183  }
184  }
185  // to avoid double counting
186  if ((selectZ == 3) && (selectMC == 3))
187  break;
188  }
189  }
190 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
EDGetTokenT< CandidateView > zToMuMuToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
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:64
EDGetTokenT< GenParticleMatch > zToMuMuMatchedToken_
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 192 of file MCAcceptanceAnalyzer.cc.

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

192  {
193  double effZToMuMu = double(selZToMuMu_) / double(nZToMuMu_);
194  double errZToMuMu = sqrt(effZToMuMu * (1. - effZToMuMu) / nZToMuMu_);
195  double effZToMuMuMC = double(selZToMuMuMC_) / double(nZToMuMuMC_);
196  double errZToMuMuMC = sqrt(effZToMuMuMC * (1. - effZToMuMuMC) / nZToMuMuMC_);
197  double effZToMuMuMCDen = double(selZToMuMuMC_) / double(nZToMuMuMCDen_);
198  double errZToMuMuMCDen = sqrt(effZToMuMuMCDen * (1. - effZToMuMuMCDen) / nZToMuMuMCDen_);
199  double effZToMuMuMCMatched = double(selZToMuMuMCMatched_) / double(nZToMuMuMCMatched_);
200  double errZToMuMuMCMatched = sqrt(effZToMuMuMCMatched * (1. - effZToMuMuMCMatched) / nZToMuMuMCMatched_);
201  cout << ">>> " << zToMuMu_ << ": " << selZToMuMu_ << "/" << nZToMuMu_ << " = " << effZToMuMu << " +/- " << errZToMuMu
202  << endl;
203  cout << ">>> " << zToMuMuMC_ << " - matched: " << selZToMuMuMCMatched_ << "/" << nZToMuMuMCMatched_ << " = "
204  << effZToMuMuMCMatched << " +/- " << errZToMuMuMCMatched << endl;
205  cout << " if the two numbers above are the same we can neglete resolution effect and quote the acceptance as the "
206  "number below.... "
207  << endl;
208  cout << "********* acceptance m>sampleMCMassCut (usually 20 or 40) ******** " << endl;
209  cout << ">>> " << zToMuMuMC_ << ": " << selZToMuMuMC_ << "/" << nZToMuMuMC_ << " = " << effZToMuMuMC << " +/- "
210  << errZToMuMuMC << endl;
211  cout << "********* acceptance in the given mass range ******** " << endl;
212  cout << ">>> " << zToMuMuMC_ << ": " << selZToMuMuMC_ << "/" << nZToMuMuMCDen_ << " = " << effZToMuMuMCDen << " +/- "
213  << errZToMuMuMCDen << endl;
214 }
T sqrt(T t)
Definition: SSEVec.h:19

Member Data Documentation

long MCAcceptanceAnalyzer::nZToMuMu_
private

Definition at line 90 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

long MCAcceptanceAnalyzer::nZToMuMuMC_
private

Definition at line 90 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

long MCAcceptanceAnalyzer::nZToMuMuMCDen_
private

Definition at line 90 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

long MCAcceptanceAnalyzer::nZToMuMuMCMatched_
private

Definition at line 90 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

ZSelector MCAcceptanceAnalyzer::select_
private

Definition at line 91 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

ZSelector MCAcceptanceAnalyzer::select_OnlyMassCut_
private

Definition at line 91 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

long MCAcceptanceAnalyzer::selZToMuMu_
private

Definition at line 90 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

long MCAcceptanceAnalyzer::selZToMuMuMC_
private

Definition at line 90 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

long MCAcceptanceAnalyzer::selZToMuMuMCMatched_
private

Definition at line 90 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

InputTag MCAcceptanceAnalyzer::zToMuMu_
private

Definition at line 86 of file MCAcceptanceAnalyzer.cc.

Referenced by endJob().

InputTag MCAcceptanceAnalyzer::zToMuMuMatched_
private

Definition at line 86 of file MCAcceptanceAnalyzer.cc.

EDGetTokenT<GenParticleMatch> MCAcceptanceAnalyzer::zToMuMuMatchedToken_
private

Definition at line 89 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

InputTag MCAcceptanceAnalyzer::zToMuMuMC_
private

Definition at line 86 of file MCAcceptanceAnalyzer.cc.

Referenced by endJob().

EDGetTokenT<CandidateView> MCAcceptanceAnalyzer::zToMuMuMCToken_
private

Definition at line 88 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

EDGetTokenT<CandidateView> MCAcceptanceAnalyzer::zToMuMuToken_
private

Definition at line 87 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().