32 #include "HepMC/WeightContainer.h"
33 #include "HepMC/GenEvent.h"
48 gen_(pset.getParameter<
InputTag>(
"genParticles")),
49 weights_(pset.getParameter<
InputTag>(
"weights")),
50 nbinsMass_(pset.getUntrackedParameter<unsigned int>(
"nbinsMass")),
51 nbinsPt_(pset.getUntrackedParameter<unsigned int>(
"nbinsPt")),
52 nbinsAng_(pset.getUntrackedParameter<unsigned int>(
"nbinsAng")),
53 massMax_(pset.getUntrackedParameter<double>(
"massMax")),
54 ptMax_(pset.getUntrackedParameter<double>(
"ptMax")),
55 angMax_(pset.getUntrackedParameter<double>(
"angMax")),
56 accPtMin_(pset.getUntrackedParameter<double>(
"accPtMin")),
57 accMassMin_(pset.getUntrackedParameter<double>(
"accMassMin")),
58 accMassMax_(pset.getUntrackedParameter<double>(
"accMassMax")),
59 accEtaMin_(pset.getUntrackedParameter<double>(
"accEtaMin")),
60 accEtaMax_(pset.getUntrackedParameter<double>(
"accEtaMax")),
61 isMCatNLO_(pset.getUntrackedParameter<bool>(
"isMCatNLO")),
62 filename_(pset.getUntrackedParameter<std::
string>(
"outfilename")) {
63 cout <<
">>> Z Histogrammer constructor" << endl;
67 h_nZ_ = ZMCHisto.
make<TH1F>(
"ZNumber",
"number of Z particles", 11, -0.5, 10.5);
90 cout <<
">>> Z Histogrammer analyze" << endl;
95 event.getByLabel(
gen_, gen);
96 event.getByLabel(
weights_, weights );
101 double weight = (*weights);
104 if (weight> 2. || weight < 0.1) {
106 std::cout <<
"weight = " << weight <<
", something strange...." << std::endl;
111 std::vector<GenParticle>
muons;
114 for(
unsigned int i = 0;
i < gen->size(); ++
i){
119 cout <<
"I'm getting a muon \n"
120 <<
"with " <<
"muMC.numberOfMothers() " << muMC.
numberOfMothers() <<
"\n the first mother has pdgId " << muMC.
mother()->
pdgId()
127 cout <<
"finally I selected " << muons.size() <<
" muons" << endl;
141 double inv_mass = 0.0;
144 double Ztheta_ = 0.0;
146 double Zrapidity_ = 0.0;
149 if (muons[0].mother()->mother()->pdgId()==23 && muons[1].mother()->mother()->pdgId()==23)
nBothMuHasZHasGrandMa_ ++;
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();
164 double weight_sign =
weight;
166 h_mZMC_->Fill(inv_mass,weight_sign);
173 double pt1 = muons[0].pt();
174 double pt2 = muons[1].pt();
175 double eta1 = muons[0].eta();
176 double eta2 = muons[1].eta();
181 hardpt->Fill(pt1,weight_sign);
182 softpt->Fill(pt2,weight_sign);
183 hardeta->Fill(eta1,weight_sign);
184 softeta->Fill(eta2,weight_sign);
186 hardpt->Fill(pt2,weight_sign);
187 softpt->Fill(pt1,weight_sign);
188 hardeta->Fill(eta2,weight_sign);
189 softeta->Fill(eta1,weight_sign);
205 cout <<
" number of events accepted :" <<
nAcc_ << endl;
206 cout <<
" number of events accepted reweigthed :" <<
nAccReW_ << endl;
207 double nev =
h_mZMC_->GetEntries();
209 cout <<
" number of total events :" << nev << endl;
210 cout <<
" number of total weighted events :" << nev_weigthed << endl;
212 double eff = (double)
nAcc_ / (
double)
h_mZMC_->GetEntries();
214 double err =
sqrt( eff * (1. - eff) / (
double)
h_mZMC_->GetEntries() );
216 cout <<
" geometric acceptance: " << eff <<
"+/-" << err << endl;
217 cout <<
" geometric acceptance reweighted: " << eff_rew <<
"+/-" << err_rew << endl;
220 myfile.open(
filename_.c_str(), std::ios::app);
221 myfile<< eff <<
" "<< eff_rew <<
" " << nev <<
" " << nev_weigthed << endl ;
double nBothMuHasZHasGrandMa_
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
virtual int pdgId() const GCC11_FINAL
PDG identifier.
#define DEFINE_FWK_MODULE(type)
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
virtual int status() const GCC11_FINAL
status word
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
virtual size_t numberOfMothers() const
number of mothers
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
virtual int pdgId() const =0
PDG identifier.
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
virtual void analyze(const edm::Event &event, const edm::EventSetup &setup)
T * make() const
make new ROOT object
virtual const Candidate * mother(size_type=0) const
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
EWKSystUnc(const edm::ParameterSet &pset)