16 for(
unsigned int i = 0;
i <
n; ++
i) {
18 if(fabs(d->
pdgId())==13)
return d;
24 ZSelector(
double ptMin,
double etaDau0Min,
double etaDau0Max,
double etaDau1Min,
double etaDau1Max,
double massMin,
double massMax,
double massMinZMC,
double massMaxZMC) :
25 ptMin_(ptMin), etaDau0Min_(etaDau0Min),etaDau0Max_(etaDau0Max), etaDau1Min_(etaDau1Min),etaDau1Max_(etaDau1Max),
26 massMin_(massMin), massMax_(massMax), massMinZMC_(massMinZMC), massMaxZMC_(massMaxZMC) { }
39 if( ( fabs(d0->
eta()) > etaDau0Min_ && fabs(d1->
eta())>etaDau1Min_ && fabs(d0->
eta()) < etaDau0Max_ && fabs(d1->
eta()) <etaDau1Max_ ) || ( fabs(d0->
eta()) > etaDau1Min_ && fabs(d1->
eta())>etaDau0Min_ && fabs(d0->
eta()) < etaDau1Max_ && fabs(d1->
eta()) <etaDau0Max_ ) ) {
41 if(d0->
pt() > ptMin_ && d1->
pt() > ptMin_) {
43 double m = (d0->
p4() + d1->
p4()).mass();
44 if(m > massMin_ && m < massMax_) temp_cut=3;
45 if (c.
mass()> massMinZMC_ && c.
mass() < massMaxZMC_) temp_cut =4;
51 double ptMin_, etaDau0Min_, etaDau0Max_, etaDau1Min_, etaDau1Max_, massMin_, massMax_, massMinZMC_, massMaxZMC_;
59 void endJob()
override;
64 long nZToMuMu_, selZToMuMu_, nZToMuMuMC_, selZToMuMuMC_, nZToMuMuMCMatched_,
selZToMuMuMCMatched_, nZToMuMuMCDen_;
69 zToMuMu_(cfg.getParameter<
InputTag>(
"zToMuMu")),
70 zToMuMuMC_(cfg.getParameter<
InputTag>(
"zToMuMuMC")),
71 zToMuMuMatched_(cfg.getParameter<
InputTag>(
"zToMuMuMatched")),
75 nZToMuMu_(0), selZToMuMu_(0),
76 nZToMuMuMC_(0), selZToMuMuMC_(0),
77 nZToMuMuMCMatched_(0), selZToMuMuMCMatched_(0), nZToMuMuMCDen_(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") )
91 long nZToMuMuMC = zToMuMuMC->size();
92 long nZToMuMuMatched = zToMuMuMatched->size();
102 for(
long i = 0;
i < nZToMuMuMC; ++
i) {
110 for(
long i = 0;
i < nZToMuMuMatched; ++
i) {
126 int selectMC =
select_(*mcRef);
130 if(selectZ != selectMC) {
131 cout <<
">>> select reco: " << selectZ <<
", select mc: " << selectMC << endl;
132 if ((selectZ * selectMC) ==0 )
break;
135 if (mcRef->numberOfDaughters()>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;
150 if ((selectZ==3) && (selectMC==3))
break;
158 double errZToMuMu =
sqrt(effZToMuMu*(1. - effZToMuMu)/
nZToMuMu_);
160 double errZToMuMuMC =
sqrt(effZToMuMuMC*(1. - effZToMuMuMC)/
nZToMuMuMC_);
166 <<
" = " << effZToMuMu <<
" +/- " << errZToMuMu << endl;
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;
172 <<
" = " << effZToMuMuMC <<
" +/- " << errZToMuMuMC << endl;
173 cout <<
"********* acceptance in the given mass range ******** " << endl;
175 <<
" = " << effZToMuMuMCDen <<
" +/- " << errZToMuMuMCDen << endl;
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
long selZToMuMuMCMatched_
EDGetTokenT< GenParticleMatch > zToMuMuMatchedToken_
EDGetTokenT< CandidateView > zToMuMuToken_
virtual float mass() const =0
mass
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual float eta() const =0
momentum pseudorapidity
#define DEFINE_FWK_MODULE(type)
ZSelector select_OnlyMassCut_
bool isNonnull() const
Checks for non-null.
virtual size_type numberOfDaughters() const =0
number of daughters
virtual float pt() const =0
transverse momentum
const Candidate * mcMuDaughter(const Candidate *c)
virtual int pdgId() const =0
PDG identifier.
void analyze(const Event &, const EventSetup &) override
int operator()(const Candidate &c) const
EDGetTokenT< CandidateView > zToMuMuMCToken_
MCAcceptanceAnalyzer(const ParameterSet &cfg)
ZSelector(double ptMin, double etaDau0Min, double etaDau0Max, double etaDau1Min, double etaDau1Max, double massMin, double massMax, double massMinZMC, double massMaxZMC)
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector