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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
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 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
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>
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)
 
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 79 of file MCAcceptanceAnalyzer.cc.

Constructor & Destructor Documentation

◆ MCAcceptanceAnalyzer()

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")) {}

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 127 of file MCAcceptanceAnalyzer.cc.

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 }

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

◆ endJob()

void MCAcceptanceAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 192 of file MCAcceptanceAnalyzer.cc.

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 }

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

Member Data Documentation

◆ nZToMuMu_

long MCAcceptanceAnalyzer::nZToMuMu_
private

Definition at line 90 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

◆ nZToMuMuMC_

long MCAcceptanceAnalyzer::nZToMuMuMC_
private

Definition at line 90 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

◆ nZToMuMuMCDen_

long MCAcceptanceAnalyzer::nZToMuMuMCDen_
private

Definition at line 90 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

◆ nZToMuMuMCMatched_

long MCAcceptanceAnalyzer::nZToMuMuMCMatched_
private

Definition at line 90 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

◆ select_

ZSelector MCAcceptanceAnalyzer::select_
private

Definition at line 91 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

◆ select_OnlyMassCut_

ZSelector MCAcceptanceAnalyzer::select_OnlyMassCut_
private

Definition at line 91 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

◆ selZToMuMu_

long MCAcceptanceAnalyzer::selZToMuMu_
private

Definition at line 90 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

◆ selZToMuMuMC_

long MCAcceptanceAnalyzer::selZToMuMuMC_
private

Definition at line 90 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

◆ selZToMuMuMCMatched_

long MCAcceptanceAnalyzer::selZToMuMuMCMatched_
private

Definition at line 90 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

◆ zToMuMu_

InputTag MCAcceptanceAnalyzer::zToMuMu_
private

Definition at line 86 of file MCAcceptanceAnalyzer.cc.

Referenced by endJob().

◆ zToMuMuMatched_

InputTag MCAcceptanceAnalyzer::zToMuMuMatched_
private

Definition at line 86 of file MCAcceptanceAnalyzer.cc.

◆ zToMuMuMatchedToken_

EDGetTokenT<GenParticleMatch> MCAcceptanceAnalyzer::zToMuMuMatchedToken_
private

Definition at line 89 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

◆ zToMuMuMC_

InputTag MCAcceptanceAnalyzer::zToMuMuMC_
private

Definition at line 86 of file MCAcceptanceAnalyzer.cc.

Referenced by endJob().

◆ zToMuMuMCToken_

EDGetTokenT<CandidateView> MCAcceptanceAnalyzer::zToMuMuMCToken_
private

Definition at line 88 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

◆ zToMuMuToken_

EDGetTokenT<CandidateView> MCAcceptanceAnalyzer::zToMuMuToken_
private

Definition at line 87 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

mps_fire.i
i
Definition: mps_fire.py:355
MCAcceptanceAnalyzer::selZToMuMuMC_
long selZToMuMuMC_
Definition: MCAcceptanceAnalyzer.cc:90
MCAcceptanceAnalyzer::zToMuMuMatched_
InputTag zToMuMuMatched_
Definition: MCAcceptanceAnalyzer.cc:86
edm::View::refAt
RefToBase< value_type > refAt(size_type i) const
reco::Candidate::eta
virtual double eta() const =0
momentum pseudorapidity
MCAcceptanceAnalyzer::zToMuMu_
InputTag zToMuMu_
Definition: MCAcceptanceAnalyzer.cc:86
MCAcceptanceAnalyzer::zToMuMuMCToken_
EDGetTokenT< CandidateView > zToMuMuMCToken_
Definition: MCAcceptanceAnalyzer.cc:88
gather_cfg.cout
cout
Definition: gather_cfg.py:144
reco::Candidate::pt
virtual double pt() const =0
transverse momentum
MCAcceptanceAnalyzer::nZToMuMu_
long nZToMuMu_
Definition: MCAcceptanceAnalyzer.cc:90
edm::Handle
Definition: AssociativeIterator.h:50
edm::Ref< GenParticleCollection >
MCAcceptanceAnalyzer::selZToMuMu_
long selZToMuMu_
Definition: MCAcceptanceAnalyzer.cc:90
MCAcceptanceAnalyzer::nZToMuMuMC_
long nZToMuMuMC_
Definition: MCAcceptanceAnalyzer.cc:90
mcMuDaughter
const Candidate * mcMuDaughter(const Candidate *c)
Definition: MCAcceptanceAnalyzer.cc:14
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
MCAcceptanceAnalyzer::nZToMuMuMCMatched_
long nZToMuMuMCMatched_
Definition: MCAcceptanceAnalyzer.cc:90
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDAxes::z
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
MCAcceptanceAnalyzer::zToMuMuMatchedToken_
EDGetTokenT< GenParticleMatch > zToMuMuMatchedToken_
Definition: MCAcceptanceAnalyzer.cc:89
edm::View::size
size_type size() const
MCAcceptanceAnalyzer::selZToMuMuMCMatched_
long selZToMuMuMCMatched_
Definition: MCAcceptanceAnalyzer.cc:90
MCAcceptanceAnalyzer::select_
ZSelector select_
Definition: MCAcceptanceAnalyzer.cc:91
MCAcceptanceAnalyzer::nZToMuMuMCDen_
long nZToMuMuMCDen_
Definition: MCAcceptanceAnalyzer.cc:90
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
MCAcceptanceAnalyzer::zToMuMuToken_
EDGetTokenT< CandidateView > zToMuMuToken_
Definition: MCAcceptanceAnalyzer.cc:87
edm::Association::size
size_t size() const
Definition: Association.h:64
looper.cfg
cfg
Definition: looper.py:297
reco::Candidate
Definition: Candidate.h:27
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
edm::RefToBase< Candidate >
reco::Candidate::p4
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
MCAcceptanceAnalyzer::zToMuMuMC_
InputTag zToMuMuMC_
Definition: MCAcceptanceAnalyzer.cc:86
d0
static constexpr float d0
Definition: L1EGammaCrystalsEmulatorProducer.cc:84
MCAcceptanceAnalyzer::select_OnlyMassCut_
ZSelector select_OnlyMassCut_
Definition: MCAcceptanceAnalyzer.cc:91
edm::InputTag
Definition: InputTag.h:15
d1
static constexpr float d1
Definition: L1EGammaCrystalsEmulatorProducer.cc:84