34 #include "HepMC/WeightContainer.h"
35 #include "HepMC/GenEvent.h"
51 pdfweightsToken_(consumes<
std::vector<double> >(
pset.getParameter<
InputTag>(
"pdfweights"))),
52 pdfmember_(
pset.getUntrackedParameter<unsigned
int>(
"pdfmember")),
53 nbinsMass_(
pset.getUntrackedParameter<unsigned
int>(
"nbinsMass")),
54 nbinsPt_(
pset.getUntrackedParameter<unsigned
int>(
"nbinsPt")),
55 nbinsAng_(
pset.getUntrackedParameter<unsigned
int>(
"nbinsAng")),
56 massMax_(
pset.getUntrackedParameter<double>(
"massMax")),
57 ptMax_(
pset.getUntrackedParameter<double>(
"ptMax")),
58 angMax_(
pset.getUntrackedParameter<double>(
"angMax")),
59 accPtMin_(
pset.getUntrackedParameter<double>(
"accPtMin")),
60 accMassMin_(
pset.getUntrackedParameter<double>(
"accMassMin")),
61 accMassMax_(
pset.getUntrackedParameter<double>(
"accMassMax")),
62 accEtaMin_(
pset.getUntrackedParameter<double>(
"accEtaMin")),
63 accEtaMax_(
pset.getUntrackedParameter<double>(
"accEtaMax")),
64 accMassMinDenominator_(
pset.getUntrackedParameter<double>(
"accMassMinDenominator")),
65 isMCatNLO_(
pset.getUntrackedParameter<
bool>(
"isMCatNLO")),
66 filename_(
pset.getUntrackedParameter<
std::
string>(
"outfilename")) {
67 cout <<
">>> Z Histogrammer constructor" << endl;
71 h_nZ_ = ZMCHisto.
make<TH1F>(
"ZNumber",
"number of Z particles", 11, -0.5, 10.5);
92 cout <<
">>> Z Histogrammer analyze" << endl;
101 std::vector<double>
weights = (*pdfweights);
103 unsigned int nmembers =
weights.size();
109 cout <<
"found nmember: " << nmembers << endl;
112 std::vector<GenParticle>
muons;
114 for (
unsigned int i = 0;
i <
gen->size(); ++
i) {
119 cout <<
"I'm getting a muon \n"
121 <<
"muMC.numberOfMothers() " << muMC.
numberOfMothers() <<
"\n the first mother has pdgId "
124 <<
"\n the first grandma has pdgId " << muMC.
mother()->
mother()->
pdgId() << endl;
126 muons.push_back(muMC);
131 cout <<
"finally I selected " <<
muons.size() <<
" muons" << endl;
136 double inv_mass = 0.0;
139 double Ztheta_ = 0.0;
141 double Zrapidity_ = 0.0;
143 if (
muons.size() > 1) {
144 if (
muons[0].mother()->mother()->pdgId() == 23 &&
muons[1].mother()->mother()->pdgId() == 23)
148 tot_momentum += mom2;
149 inv_mass =
sqrt(tot_momentum.mass2());
151 Zpt_ = tot_momentum.pt();
152 Zeta_ = tot_momentum.eta();
153 Ztheta_ = tot_momentum.theta();
154 Zphi_ = tot_momentum.phi();
155 Zrapidity_ = tot_momentum.Rapidity();
159 double weight_sign =
weight;
163 h_mZMC_->Fill(inv_mass, weight_sign);
197 cout <<
" number of events accepted :" <<
nAcc_ << endl;
198 cout <<
" number of events accepted reweigthed :" <<
nAccReW_ << endl;
199 double nev =
h_mZMC_->GetEntries();
200 double nev_weigthed =
h_mZMC_->Integral();
201 cout <<
" number of total events :" << nev << endl;
202 cout <<
" number of total weighted events :" << nev_weigthed << endl;
204 double eff = (double)
nAcc_ / (
double)
h_mZMC_->GetEntries();
206 double err =
sqrt(eff * (1. - eff) / (
double)
h_mZMC_->GetEntries());
208 cout <<
" geometric acceptance: " << eff <<
"+/-" <<
err << endl;
209 cout <<
" geometric acceptance reweighted: " << eff_rew <<
"+/-" << err_rew << endl;
212 myfile.open(
filename_.c_str(), std::ios::app);
213 myfile << eff <<
" " << eff_rew <<
" " << nev <<
" " << nev_weigthed << endl;