33 #include "HepMC/WeightContainer.h"
34 #include "HepMC/GenEvent.h"
50 weightsToken_(consumes<double>(
pset.getParameter<
InputTag>(
"weights"))),
51 nbinsMass_(
pset.getUntrackedParameter<unsigned
int>(
"nbinsMass")),
52 nbinsPt_(
pset.getUntrackedParameter<unsigned
int>(
"nbinsPt")),
53 nbinsAng_(
pset.getUntrackedParameter<unsigned
int>(
"nbinsAng")),
54 massMax_(
pset.getUntrackedParameter<double>(
"massMax")),
55 ptMax_(
pset.getUntrackedParameter<double>(
"ptMax")),
56 angMax_(
pset.getUntrackedParameter<double>(
"angMax")),
57 accPtMin_(
pset.getUntrackedParameter<double>(
"accPtMin")),
58 accMassMin_(
pset.getUntrackedParameter<double>(
"accMassMin")),
59 accMassMax_(
pset.getUntrackedParameter<double>(
"accMassMax")),
60 accEtaMin_(
pset.getUntrackedParameter<double>(
"accEtaMin")),
61 accEtaMax_(
pset.getUntrackedParameter<double>(
"accEtaMax")),
62 isMCatNLO_(
pset.getUntrackedParameter<
bool>(
"isMCatNLO")),
63 filename_(
pset.getUntrackedParameter<
std::
string>(
"outfilename")) {
64 cout <<
">>> Z Histogrammer constructor" << endl;
68 h_nZ_ = ZMCHisto.
make<TH1F>(
"ZNumber",
"number of Z particles", 11, -0.5, 10.5);
89 cout <<
">>> Z Histogrammer analyze" << endl;
98 double weight = (*weights);
102 std::cout <<
"weight = " <<
weight <<
", something strange...." << std::endl;
107 std::vector<GenParticle>
muons;
109 for (
unsigned int i = 0;
i <
gen->size(); ++
i) {
114 cout <<
"I'm getting a muon \n"
116 <<
"muMC.numberOfMothers() " << muMC.
numberOfMothers() <<
"\n the first mother has pdgId "
119 <<
"\n the first grandma has pdgId " << muMC.
mother()->
mother()->
pdgId() << endl;
121 muons.push_back(muMC);
126 cout <<
"finally I selected " <<
muons.size() <<
" muons" << endl;
131 double inv_mass = 0.0;
134 double Ztheta_ = 0.0;
136 double Zrapidity_ = 0.0;
138 if (
muons.size() > 1) {
139 if (
muons[0].mother()->mother()->pdgId() == 23 &&
muons[1].mother()->mother()->pdgId() == 23)
143 tot_momentum += mom2;
144 inv_mass =
sqrt(tot_momentum.mass2());
145 Zpt_ = tot_momentum.pt();
146 Zeta_ = tot_momentum.eta();
147 Ztheta_ = tot_momentum.theta();
148 Zphi_ = tot_momentum.phi();
149 Zrapidity_ = tot_momentum.Rapidity();
153 double weight_sign =
weight;
155 h_mZMC_->Fill(inv_mass, weight_sign);
189 cout <<
" number of events accepted :" <<
nAcc_ << endl;
190 cout <<
" number of events accepted reweigthed :" <<
nAccReW_ << endl;
191 double nev =
h_mZMC_->GetEntries();
193 cout <<
" number of total events :" << nev << endl;
194 cout <<
" number of total weighted events :" << nev_weigthed << endl;
196 double eff = (double)
nAcc_ / (
double)
h_mZMC_->GetEntries();
198 double err =
sqrt(eff * (1. - eff) / (
double)
h_mZMC_->GetEntries());
200 cout <<
" geometric acceptance: " << eff <<
"+/-" <<
err << endl;
201 cout <<
" geometric acceptance reweighted: " << eff_rew <<
"+/-" << err_rew << endl;
204 myfile.open(
filename_.c_str(), std::ios::app);
205 myfile << eff <<
" " << eff_rew <<
" " << nev <<
" " << nev_weigthed << endl;