12 virtual void endJob()
override;
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);
91 cout <<
">>> Z Histogrammer analyze" << endl;
102 double weight = (*weights);
105 if (weight> 2. || weight < 0.1) {
107 std::cout <<
"weight = " << weight <<
", something strange...." << std::endl;
112 std::vector<GenParticle>
muons;
115 for(
unsigned int i = 0;
i < gen->size(); ++
i){
120 cout <<
"I'm getting a muon \n"
121 <<
"with " <<
"muMC.numberOfMothers() " << muMC.
numberOfMothers() <<
"\n the first mother has pdgId " << muMC.
mother()->
pdgId()
128 cout <<
"finally I selected " << muons.size() <<
" muons" << endl;
142 double inv_mass = 0.0;
145 double Ztheta_ = 0.0;
147 double Zrapidity_ = 0.0;
150 if (muons[0].mother()->mother()->pdgId()==23 && muons[1].mother()->mother()->pdgId()==23)
nBothMuHasZHasGrandMa_ ++;
153 tot_momentum += mom2;
154 inv_mass =
sqrt(tot_momentum.mass2());
155 Zpt_=tot_momentum.pt();
156 Zeta_ = tot_momentum.eta();
157 Ztheta_ = tot_momentum.theta();
158 Zphi_ = tot_momentum.phi();
159 Zrapidity_ = tot_momentum.Rapidity();
165 double weight_sign =
weight;
167 h_mZMC_->Fill(inv_mass,weight_sign);
174 double pt1 = muons[0].pt();
175 double pt2 = muons[1].pt();
176 double eta1 = muons[0].eta();
177 double eta2 = muons[1].eta();
182 hardpt->Fill(pt1,weight_sign);
183 softpt->Fill(pt2,weight_sign);
184 hardeta->Fill(eta1,weight_sign);
185 softeta->Fill(eta2,weight_sign);
187 hardpt->Fill(pt2,weight_sign);
188 softpt->Fill(pt1,weight_sign);
189 hardeta->Fill(eta2,weight_sign);
190 softeta->Fill(eta1,weight_sign);
206 cout <<
" number of events accepted :" <<
nAcc_ << endl;
207 cout <<
" number of events accepted reweigthed :" <<
nAccReW_ << endl;
208 double nev =
h_mZMC_->GetEntries();
210 cout <<
" number of total events :" << nev << endl;
211 cout <<
" number of total weighted events :" << nev_weigthed << endl;
213 double eff = (double)
nAcc_ / (
double)
h_mZMC_->GetEntries();
215 double err =
sqrt( eff * (1. - eff) / (
double)
h_mZMC_->GetEntries() );
217 cout <<
" geometric acceptance: " << eff <<
"+/-" << err << endl;
218 cout <<
" geometric acceptance reweighted: " << eff_rew <<
"+/-" << err_rew << endl;
221 myfile.open(
filename_.c_str(), std::ios::app);
222 myfile<< eff <<
" "<< eff_rew <<
" " << nev <<
" " << nev_weigthed << endl ;
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
edm::EDGetTokenT< double > weightsToken_
virtual int pdgId() const
PDG identifier.
double nBothMuHasZHasGrandMa_
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
#define DEFINE_FWK_MODULE(type)
virtual int status() const
status word
edm::EDGetTokenT< reco::GenParticleCollection > genToken_
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.
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
virtual size_t numberOfMothers() const
number of mothers
virtual void endJob() override
Abs< T >::type abs(const T &t)
T * make(const Args &...args) const
make new ROOT object
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) override
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)