31 #include "HepMC/WeightContainer.h" 32 #include "HepMC/GenEvent.h" 48 nbinsMass_(pset.getUntrackedParameter<unsigned
int>(
"nbinsMass")),
49 nbinsPt_(pset.getUntrackedParameter<unsigned
int>(
"nbinsPt")),
50 nbinsAng_(pset.getUntrackedParameter<unsigned
int>(
"nbinsAng")),
51 massMax_(pset.getUntrackedParameter<double>(
"massMax")),
52 ptMax_(pset.getUntrackedParameter<double>(
"ptMax")),
53 angMax_(pset.getUntrackedParameter<double>(
"angMax")),
54 accPtMin_(pset.getUntrackedParameter<double>(
"accPtMin")),
55 accMassMin_(pset.getUntrackedParameter<double>(
"accMassMin")),
56 accMassMax_(pset.getUntrackedParameter<double>(
"accMassMax")),
57 accEtaMin_(pset.getUntrackedParameter<double>(
"accEtaMin")),
58 accEtaMax_(pset.getUntrackedParameter<double>(
"accEtaMax")),
60 cout <<
">>> Z Histogrammer constructor" << endl;
64 h_nZ_ = ZHisto.
make<TH1F>(
"ZNumber",
"number of Z particles", 11, -0.5, 10.5);
92 cout <<
">>> Z Histogrammer analyze" << endl;
105 if(!weight) weight=1.;
109 weight > 0 ? weight=1. : weight=-1.;
114 std::vector<GenParticle>
muons;
117 for(
unsigned int i = 0;
i < gen->size(); ++
i){
122 cout <<
"I'm getting a muon \n" 123 <<
"with " <<
"muMC.numberOfMothers() " << muMC.
numberOfMothers() <<
"\n the first mother has pdgId " << muMC.
mother()->
pdgId()
131 for(
unsigned int i = 0;
i < gen->size(); ++
i){
134 cout <<
"I'm getting a muon \n" 135 <<
"with " <<
"muMC.numberOfMothers() " << muMC.
numberOfMothers() <<
"\n the first mother has pdgId " << muMC.
mother()->
pdgId()
138 muons.push_back(muMC);
144 cout <<
"finally I selected " << muons.size() <<
" muons" << endl;
158 double inv_mass = 0.0;
161 double Ztheta_ = 0.0;
163 double Zrapidity_ = 0.0;
166 if (muons[0].mother()->mother()->pdgId()==23 && muons[1].mother()->mother()->pdgId()==23)
nBothMuHasZHasGrandMa_ ++;
169 tot_momentum += mom2;
170 inv_mass =
sqrt(tot_momentum.mass2());
171 Zpt_=tot_momentum.pt();
172 Zeta_ = tot_momentum.eta();
173 Ztheta_ = tot_momentum.theta();
174 Zphi_ = tot_momentum.phi();
175 Zrapidity_ = tot_momentum.Rapidity();
181 double weight_sign = (weight > 0) ? 1. : -1.;
183 h_mZMC_->Fill(inv_mass,weight_sign);
190 double pt1 = muons[0].pt();
191 double pt2 = muons[1].pt();
192 double eta1 = muons[0].eta();
193 double eta2 = muons[1].eta();
198 hardpt->Fill(pt1,weight_sign);
199 softpt->Fill(pt2,weight_sign);
200 hardeta->Fill(eta1,weight_sign);
201 softeta->Fill(eta2,weight_sign);
203 hardpt->Fill(pt2,weight_sign);
204 softpt->Fill(pt1,weight_sign);
205 hardeta->Fill(eta2,weight_sign);
206 softeta->Fill(eta1,weight_sign);
220 cout <<
" number of events accepted :" <<
nAcc_ << endl;
221 cout <<
" number of total events :" <<
h_mZMC_->GetEntries() << endl;
223 double eff = (double)
nAcc_ / (
double)
h_mZMC_->GetEntries();
224 double err =
sqrt( eff * (1. - eff) / (
double)
h_mZMC_->GetEntries() );
225 cout <<
" geometric acceptance: " << eff <<
"+/-" << err << endl;
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
int pdgId() const final
PDG identifier.
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
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< double > weightsToken_
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)
ZLONLOHistogrammer(const edm::ParameterSet &pset)
T * make(const Args &...args) const
make new ROOT object
unsigned int nBothMuHasZHasGrandMa_
def gen(fragment, howMuch)
Production test section ####.
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
edm::EDGetTokenT< reco::GenParticleCollection > genToken_
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) ...