32 #include "HepMC/WeightContainer.h" 33 #include "HepMC/GenEvent.h" 48 nbinsMass_(pset.getUntrackedParameter<unsigned
int>(
"nbinsMass")),
49 nbinsPt_(pset.getUntrackedParameter<unsigned
int>(
"nbinsPt")),
50 nbinsAng_(pset.getUntrackedParameter<unsigned
int>(
"nbinsAng")),
51 massMax_(pset.getUntrackedParameter<double>(
"massMax")),
52 ptMax_(pset.getUntrackedParameter<double>(
"ptMax")),
53 angMax_(pset.getUntrackedParameter<double>(
"angMax")),
54 accPtMin_(pset.getUntrackedParameter<double>(
"accPtMin")),
55 accMassMin_(pset.getUntrackedParameter<double>(
"accMassMin")),
56 accMassMax_(pset.getUntrackedParameter<double>(
"accMassMax")),
57 accMassMinDen_(pset.getUntrackedParameter<double>(
"accMassMinDen")),
58 accMassMaxDen_(pset.getUntrackedParameter<double>(
"accMassMaxDen")),
59 accEtaMin_(pset.getUntrackedParameter<double>(
"accEtaMin")),
60 accEtaMax_(pset.getUntrackedParameter<double>(
"accEtaMax")),
61 ptScale_(pset.getUntrackedParameter<double>(
"ptScale")),
63 cout <<
">>> Z Histogrammer constructor" << endl;
88 cout <<
">>> Z HistogrammerZLONLOHistogrammer.cc analyze" << endl;
97 std::vector<GenParticle>
muons;
101 for (
unsigned int i = 0;
i < gen->size(); ++
i) {
105 cout <<
"I'm getting a muon \n" 107 <<
"muMC.numberOfMothers() " << muMC.
numberOfMothers() <<
"\n the first mother has pdgId " 110 <<
"\n the first grandma has pdgId " << muMC.
mother()->
mother()->
pdgId() << endl;
111 cout <<
"with muMC.eta() " << muMC.
eta() << endl;
112 muons.push_back(muMC);
129 cout <<
"I'm selecting a Z MC with mass " << mZGen << endl;
135 cout <<
"finally I selected " << muons.size() <<
" muons" << endl;
140 double inv_mass = 0.0;
143 double Ztheta_ = 0.0;
145 double Zrapidity_ = 0.0;
147 if (muons.size() > 1) {
148 if (muons[0].mother()->mother()->pdgId() == 23 && muons[1].mother()->mother()->pdgId() == 23)
152 tot_momentum += mom2;
153 inv_mass =
sqrt(tot_momentum.mass2());
154 Zpt_ = tot_momentum.pt();
155 Zeta_ = tot_momentum.eta();
156 Ztheta_ = tot_momentum.theta();
157 Zphi_ = tot_momentum.phi();
158 Zrapidity_ = tot_momentum.Rapidity();
160 double weight_sign = 1.;
169 double pt1 = muons[0].pt();
170 double pt2 = muons[1].pt();
171 double eta1 = muons[0].eta();
172 double eta2 = muons[1].eta();
175 hardpt->Fill(pt1, weight_sign);
176 softpt->Fill(pt2, weight_sign);
177 hardeta->Fill(eta1, weight_sign);
178 softeta->Fill(eta2, weight_sign);
180 hardpt->Fill(pt2, weight_sign);
181 softpt->Fill(pt1, weight_sign);
182 hardeta->Fill(eta2, weight_sign);
183 softeta->Fill(eta1, weight_sign);
191 cout <<
"pt1" << pt1 << endl;
194 double pt1ScaledP = pt1 * (1. +
ptScale_);
196 cout <<
"pt1ScaledP" << pt1ScaledP << endl;
198 double pt2ScaledP = pt2 * (1. +
ptScale_);
206 double pt1ScaledN = pt1 * (1. -
ptScale_);
207 double pt2ScaledN = pt2 * (1. -
ptScale_);
216 f.SetSeed(123456789);
217 double pt1SmearedFlat = pt1 * (1. +
ptScale_ * f.Uniform());
218 double pt2SmearedFlat = pt2 * (1. +
ptScale_ * f.Uniform());
228 ff.SetSeed(123456789);
229 double pt1SmearedGaus = pt1 * (1. +
ptScale_ * f.Gaus());
230 double pt2SmearedGaus = pt2 * (1. +
ptScale_ * f.Gaus());
241 cout <<
" number of events accepted :" <<
nAcc_ << endl;
242 cout <<
" number of total events :" <<
h_mZMC_->GetEntries() << endl;
244 cout <<
" number of events pt scaled positively accepted :" <<
nAccPtScaleP_ << endl;
246 cout <<
" number of events pt scaled negatively accepted :" <<
nAccPtScaleN_ << endl;
252 double eff = (double)
nAcc_ / (
double)
h_mZMC_->GetEntries();
253 double err =
sqrt(eff * (1. - eff) / (
double)
h_mZMC_->GetEntries());
254 cout <<
" geometric acceptance: " << eff <<
"+/-" << err << endl;
257 double errScaledP =
sqrt(effScaledP * (1. - effScaledP) / (
double)
h_mZMC_->GetEntries());
258 cout <<
" geometric acceptance when pt muon is positively scaled: " << effScaledP <<
"+/-" << errScaledP << endl;
261 double errScaledN =
sqrt(effScaledN * (1. - effScaledN) / (
double)
h_mZMC_->GetEntries());
262 cout <<
" geometric acceptance when pt muon is negatively scaled: " << effScaledN <<
"+/-" << errScaledN << endl;
265 double errSmearedFlat =
sqrt(effSmearedFlat * (1. - effSmearedFlat) / (
double)
h_mZMC_->GetEntries());
266 cout <<
" geometric acceptance when pt muon is scaled with a flat smaering: " << effSmearedFlat <<
"+/-" 267 << errSmearedFlat << endl;
270 double errSmearedGaus =
sqrt(effSmearedGaus * (1. - effSmearedGaus) / (
double)
h_mZMC_->GetEntries());
271 cout <<
" geometric acceptance when pt muon is scaled with a gaussian smearing: " << effSmearedGaus <<
"+/-" 272 << errSmearedGaus << endl;
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
int pdgId() const final
PDG identifier.
ZMuPtScaleAnalyzer(const edm::ParameterSet &pset)
double eta() const final
momentum pseudorapidity
unsigned int nAccPtScaleP_
size_t numberOfMothers() const override
number of mothers
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
edm::EDGetTokenT< reco::GenParticleCollection > genToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
unsigned int nBothMuHasZHasGrandMa_
#define DEFINE_FWK_MODULE(type)
unsigned int nAccPtScaleN_
virtual int pdgId() const =0
PDG identifier.
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
Abs< T >::type abs(const T &t)
T * make(const Args &...args) const
make new ROOT object
def gen(fragment, howMuch)
Production test section ####.
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
size_t numberOfDaughters() const override
number of daughters
unsigned int nAccPtScaleSmearedFlat_
int status() const final
status word
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
unsigned int nAccPtScaleSmearedGaus_
const Candidate * mother(size_type=0) const override
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
double mass() const final
mass