34 #include "HepMC/WeightContainer.h" 35 #include "HepMC/GenEvent.h" 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")),
67 cout <<
">>> Z Histogrammer constructor" << endl;
71 h_nZ_ = ZMCHisto.
make<TH1F>(
"ZNumber",
"number of Z particles", 11, -0.5, 10.5);
94 cout <<
">>> Z Histogrammer analyze" << endl;
105 std::vector<double>
weights = (*pdfweights);
107 unsigned int nmembers = weights.size();
114 cout <<
"found nmember: " << nmembers << endl;
115 cout <<
"taken the member n " <<
pdfmember_ <<
" weight= " << weight << endl;
119 std::vector<GenParticle>
muons;
122 for(
unsigned int i = 0;
i < gen->size(); ++
i){
127 cout <<
"I'm getting a muon \n" 128 <<
"with " <<
"muMC.numberOfMothers() " << muMC.
numberOfMothers() <<
"\n the first mother has pdgId " << muMC.
mother()->
pdgId()
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;
148 if (muons[0].mother()->mother()->pdgId()==23 && muons[1].mother()->mother()->pdgId()==23)
nBothMuHasZHasGrandMa_ ++;
151 tot_momentum += mom2;
152 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();
164 double weight_sign =
weight;
168 h_mZMC_->Fill(inv_mass,weight_sign);
175 double pt1 = muons[0].pt();
176 double pt2 = muons[1].pt();
177 double eta1 = muons[0].eta();
178 double eta2 = muons[1].eta();
180 hardpt->Fill(pt1,weight_sign);
181 softpt->Fill(pt2,weight_sign);
182 hardeta->Fill(eta1,weight_sign);
183 softeta->Fill(eta2,weight_sign);
185 hardpt->Fill(pt2,weight_sign);
186 softpt->Fill(pt1,weight_sign);
187 hardeta->Fill(eta2,weight_sign);
188 softeta->Fill(eta1,weight_sign);
202 cout <<
" number of events accepted :" <<
nAcc_ << endl;
203 cout <<
" number of events accepted reweigthed :" <<
nAccReW_ << endl;
204 double nev =
h_mZMC_->GetEntries();
205 double nev_weigthed =
h_mZMC_->Integral( ) ;
206 cout <<
" number of total events :" << nev << endl;
207 cout <<
" number of total weighted events :" << nev_weigthed << endl;
209 double eff = (double)
nAcc_ / (
double)
h_mZMC_->GetEntries();
211 double err =
sqrt( eff * (1. - eff) / (
double)
h_mZMC_->GetEntries() );
213 cout <<
" geometric acceptance: " << eff <<
"+/-" << err << endl;
214 cout <<
" geometric acceptance reweighted: " << eff_rew <<
"+/-" << err_rew << endl;
217 myfile.open(
filename_.c_str(), std::ios::app);
218 myfile<< eff <<
" "<< eff_rew <<
" " << nev <<
" " << nev_weigthed << endl ;
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
int pdgId() const final
PDG identifier.
double nBothMuHasZHasGrandMa_
double accMassMinDenominator_
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
size_t numberOfMothers() const override
number of mothers
def setup(process, global_tag, zero_tesla=False)
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
zPdfUnc(const edm::ParameterSet &pset)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
edm::EDGetTokenT< std::vector< double > > pdfweightsToken_
#define DEFINE_FWK_MODULE(type)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
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 ####.
edm::EDGetTokenT< reco::GenParticleCollection > genToken_
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
int status() const final
status word
const Candidate * mother(size_type=0) const override
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...