CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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_
 
InputTag zToMuMuMC_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- 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 65 of file MCAcceptanceAnalyzer.cc.

65  :
66  zToMuMu_(cfg.getParameter<InputTag>("zToMuMu")),
67  zToMuMuMC_(cfg.getParameter<InputTag>("zToMuMuMC")),
68  zToMuMuMatched_(cfg.getParameter<InputTag>("zToMuMuMatched")),
69  nZToMuMu_(0), selZToMuMu_(0),
72  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") ),
73  select_OnlyMassCut_(-1, -9999,9999 , -9999, 9999,0, 0, cfg.getParameter<double>("massMinZMC"), cfg.getParameter<double>("massMaxZMC") )
74 {
75 }
T getParameter(std::string const &) const

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 77 of file MCAcceptanceAnalyzer.cc.

References gather_cfg::cout, reco::Candidate::daughter(), reco::Candidate::eta(), edm::Event::getByLabel(), i, edm::Ref< C, T, F >::isNonnull(), m, reco::Candidate::mass(), mcMuDaughter(), reco::Candidate::numberOfDaughters(), nZToMuMu_, nZToMuMuMC_, nZToMuMuMCDen_, nZToMuMuMCMatched_, reco::Candidate::p4(), reco::Candidate::pt(), select_, select_OnlyMassCut_, selZToMuMu_, selZToMuMuMC_, selZToMuMuMCMatched_, detailsBasic3DVector::z, zToMuMu_, zToMuMuMatched_, and zToMuMuMC_.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 150 of file MCAcceptanceAnalyzer.cc.

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

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

Member Data Documentation

long MCAcceptanceAnalyzer::nZToMuMu_
private

Definition at line 61 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

long MCAcceptanceAnalyzer::nZToMuMuMC_
private

Definition at line 61 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

long MCAcceptanceAnalyzer::nZToMuMuMCDen_
private

Definition at line 61 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

long MCAcceptanceAnalyzer::nZToMuMuMCMatched_
private

Definition at line 61 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

ZSelector MCAcceptanceAnalyzer::select_
private

Definition at line 62 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

ZSelector MCAcceptanceAnalyzer::select_OnlyMassCut_
private

Definition at line 62 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

long MCAcceptanceAnalyzer::selZToMuMu_
private

Definition at line 61 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

long MCAcceptanceAnalyzer::selZToMuMuMC_
private

Definition at line 61 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

long MCAcceptanceAnalyzer::selZToMuMuMCMatched_
private

Definition at line 61 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

InputTag MCAcceptanceAnalyzer::zToMuMu_
private

Definition at line 60 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

InputTag MCAcceptanceAnalyzer::zToMuMuMatched_
private

Definition at line 60 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

InputTag MCAcceptanceAnalyzer::zToMuMuMC_
private

Definition at line 60 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().