Public Member Functions | |
EWKSystUnc (const edm::ParameterSet &pset) | |
Private Member Functions | |
virtual void | analyze (const edm::Event &event, const edm::EventSetup &setup) |
virtual void | endJob () |
Private Attributes | |
double | accEtaMax_ |
double | accEtaMin_ |
double | accMassMax_ |
double | accMassMin_ |
double | accPtMin_ |
double | angMax_ |
std::string | filename_ |
edm::InputTag | gen_ |
TH1F * | h_etaZMC_ |
TH1F * | h_mZMC_ |
TH1F * | h_nZ_ |
TH1F * | h_phiZMC_ |
TH1F * | h_ptZMC_ |
TH1F * | h_rapidityZMC_ |
TH1F * | h_thetaZMC_ |
TH1F * | h_weight_histo |
TH1F * | hardeta |
TH1F * | hardpt |
bool | isMCatNLO_ |
double | massMax_ |
double | nAcc_ |
double | nAccReW_ |
unsigned int | nbinsAng_ |
unsigned int | nbinsMass_ |
unsigned int | nbinsPt_ |
double | nBothMuHasZHasGrandMa_ |
double | ptMax_ |
TH1F * | softeta |
TH1F * | softpt |
edm::InputTag | weights_ |
Definition at line 5 of file EWKSystUnc.cc.
EWKSystUnc::EWKSystUnc | ( | const edm::ParameterSet & | pset | ) |
Definition at line 47 of file EWKSystUnc.cc.
References angMax_, gather_cfg::cout, h_etaZMC_, h_mZMC_, h_nZ_, h_phiZMC_, h_ptZMC_, h_rapidityZMC_, h_thetaZMC_, h_weight_histo, hardeta, hardpt, TFileDirectory::make(), massMax_, nAcc_, nAccReW_, nbinsAng_, nbinsMass_, nbinsPt_, nBothMuHasZHasGrandMa_, ptMax_, softeta, and softpt.
: gen_(pset.getParameter<InputTag>("genParticles")), weights_(pset.getParameter<InputTag>("weights")), nbinsMass_(pset.getUntrackedParameter<unsigned int>("nbinsMass")), nbinsPt_(pset.getUntrackedParameter<unsigned int>("nbinsPt")), nbinsAng_(pset.getUntrackedParameter<unsigned int>("nbinsAng")), massMax_(pset.getUntrackedParameter<double>("massMax")), ptMax_(pset.getUntrackedParameter<double>("ptMax")), angMax_(pset.getUntrackedParameter<double>("angMax")), accPtMin_(pset.getUntrackedParameter<double>("accPtMin")), accMassMin_(pset.getUntrackedParameter<double>("accMassMin")), accMassMax_(pset.getUntrackedParameter<double>("accMassMax")), accEtaMin_(pset.getUntrackedParameter<double>("accEtaMin")), accEtaMax_(pset.getUntrackedParameter<double>("accEtaMax")), isMCatNLO_(pset.getUntrackedParameter<bool>("isMCatNLO")), filename_(pset.getUntrackedParameter<std::string>("outfilename")) { cout << ">>> Z Histogrammer constructor" << endl; Service<TFileService> fs; TFileDirectory ZMCHisto = fs->mkdir( "ZMCHisto" ); h_nZ_ = ZMCHisto.make<TH1F>("ZNumber", "number of Z particles", 11, -0.5, 10.5); h_weight_histo = ZMCHisto.make<TH1F>("weight_histo","weight_histo",20,-10,10); h_mZMC_ = ZMCHisto.make<TH1F>("ZMCMass", "Z MC mass (GeV/c^{2})", nbinsMass_, 0, massMax_); h_ptZMC_ = ZMCHisto.make<TH1F>("ZMCPt", "Z MC p_{t} (GeV/c)", nbinsPt_, 0, ptMax_); hardpt = ZMCHisto.make<TH1F>("hardpt", "hard muon p_{t} (GeV/c)", nbinsPt_, 0, ptMax_); softpt = ZMCHisto.make<TH1F>("softpt", "soft muon p_{t} (GeV/c)", nbinsPt_, 0, ptMax_); h_phiZMC_ = ZMCHisto.make<TH1F>("ZMCPhi", "Z MC #phi", nbinsAng_, -angMax_, angMax_); h_thetaZMC_ = ZMCHisto.make<TH1F>("ZMCTheta", "Z MC #theta", nbinsAng_, 0, angMax_); h_etaZMC_ = ZMCHisto.make<TH1F>("ZMCEta", "Z MC #eta", nbinsAng_, -angMax_, angMax_); h_rapidityZMC_ = ZMCHisto.make<TH1F>("ZMCRapidity", "Z MC y", nbinsAng_, -angMax_, angMax_); hardeta = ZMCHisto.make<TH1F>("hard muon eta", "hard muon #eta", nbinsAng_, -angMax_, angMax_); softeta = ZMCHisto.make<TH1F>("soft muon eta", "soft muon #eta", nbinsAng_, -angMax_, angMax_); nAcc_=0.; nAccReW_ =0; nBothMuHasZHasGrandMa_=0; }
void EWKSystUnc::analyze | ( | const edm::Event & | event, |
const edm::EventSetup & | setup | ||
) | [private, virtual] |
Implements edm::EDAnalyzer.
Definition at line 89 of file EWKSystUnc.cc.
References abs, accEtaMax_, accEtaMin_, accMassMax_, accMassMin_, accPtMin_, gather_cfg::cout, HcalObjRepresent::Fill(), relval_steps::gen(), gen_, h_etaZMC_, h_mZMC_, h_phiZMC_, h_ptZMC_, h_rapidityZMC_, h_thetaZMC_, h_weight_histo, hardeta, hardpt, i, reco::Candidate::mother(), reco::CompositeRefCandidateT< D >::mother(), patZpeak::muons, nAcc_, nAccReW_, nBothMuHasZHasGrandMa_, reco::Candidate::numberOfMothers(), reco::CompositeRefCandidateT< D >::numberOfMothers(), p4, reco::LeafCandidate::pdgId(), reco::Candidate::pdgId(), softeta, softpt, mathSSE::sqrt(), reco::LeafCandidate::status(), CommonMethods::weight(), and weights_.
{ cout << ">>> Z Histogrammer analyze" << endl; Handle<GenParticleCollection> gen; Handle<double > weights; event.getByLabel(gen_, gen); event.getByLabel(weights_, weights ); // get weight and fill it to histogram double weight = (*weights); // protection... if (weight> 2. || weight < 0.1) { std::cout << "weight = " << weight << ", something strange...." << std::endl; weight =1; } h_weight_histo->Fill(weight); std::vector<GenParticle> muons; for(unsigned int i = 0; i < gen->size(); ++i){ const GenParticle & muMC = (*gen)[i]; // filling only muons coming form Z if (abs(muMC.pdgId())==13 && muMC.status()==1 && muMC.numberOfMothers()>0) { if (muMC.mother()->numberOfMothers()> 0 ){ cout << "I'm getting a muon \n" << "with " << "muMC.numberOfMothers() " << muMC.numberOfMothers() << "\n the first mother has pdgId " << muMC.mother()->pdgId() << "with " << "muMC.mother()->numberOfMothers() " << muMC.mother()->numberOfMothers()<< "\n the first grandma has pdgId " << muMC.mother()->mother()->pdgId()<<endl; if (muMC.mother()->mother()->pdgId() ==23 ) muons.push_back(muMC); } } } cout << "finally I selected " << muons.size() << " muons" << endl; // if there are at least two muons, // calculate invarant mass of first two and fill it into histogram double inv_mass = 0.0; double Zpt_ = 0.0; double Zeta_ = 0.0; double Ztheta_ = 0.0; double Zphi_ = 0.0; double Zrapidity_ = 0.0; if(muons.size()>1) { if (muons[0].mother()->mother()->pdgId()==23 && muons[1].mother()->mother()->pdgId()==23) nBothMuHasZHasGrandMa_ ++; math::XYZTLorentzVector tot_momentum(muons[0].p4()); math::XYZTLorentzVector mom2(muons[1].p4()); tot_momentum += mom2; inv_mass = sqrt(tot_momentum.mass2()); Zpt_=tot_momentum.pt(); Zeta_ = tot_momentum.eta(); Ztheta_ = tot_momentum.theta(); Zphi_ = tot_momentum.phi(); Zrapidity_ = tot_momentum.Rapidity(); // IMPORTANT: use the weight of the event ... double weight_sign = weight; //double weight_sign = 1. ; h_mZMC_->Fill(inv_mass,weight_sign); h_ptZMC_->Fill(Zpt_,weight_sign); h_etaZMC_->Fill(Zeta_,weight_sign); h_thetaZMC_->Fill(Ztheta_,weight_sign); h_phiZMC_->Fill(Zphi_,weight_sign); h_rapidityZMC_-> Fill (Zrapidity_,weight_sign ); double pt1 = muons[0].pt(); double pt2 = muons[1].pt(); double eta1 = muons[0].eta(); double eta2 = muons[1].eta(); if(pt1>pt2) { hardpt->Fill(pt1,weight_sign); softpt->Fill(pt2,weight_sign); hardeta->Fill(eta1,weight_sign); softeta->Fill(eta2,weight_sign); } else { hardpt->Fill(pt2,weight_sign); softpt->Fill(pt1,weight_sign); hardeta->Fill(eta2,weight_sign); softeta->Fill(eta1,weight_sign); } //evaluating the geometric acceptance if ( pt1 >= accPtMin_ && pt2 >= accPtMin_ && fabs(eta1)>= accEtaMin_ && fabs(eta2) >= accEtaMin_ && fabs(eta1)<= accEtaMax_ && fabs(eta2) <= accEtaMax_ && inv_mass>= accMassMin_ && inv_mass<= accMassMax_) { nAcc_ ++; nAccReW_ +=weight; } } }
void EWKSystUnc::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 204 of file EWKSystUnc.cc.
References gather_cfg::cout, filename_, h_mZMC_, nAcc_, nAccReW_, nbinsMass_, nBothMuHasZHasGrandMa_, and mathSSE::sqrt().
{ cout << " number of events accepted :" << nAcc_ << endl; cout << " number of events accepted reweigthed :" << nAccReW_ << endl; double nev = h_mZMC_->GetEntries(); double nev_weigthed = h_mZMC_->Integral(0,nbinsMass_ +1 ) ; cout << " number of total events :" << nev << endl; cout << " number of total weighted events :" << nev_weigthed << endl; cout << " number of cases in which BothMuHasZHasGrandMa :" << nBothMuHasZHasGrandMa_ << endl; double eff = (double)nAcc_ / (double) h_mZMC_->GetEntries(); double eff_rew = (double)nAccReW_ / (double) h_mZMC_->Integral(0,nbinsMass_ +1 ); double err = sqrt( eff * (1. - eff) / (double) h_mZMC_->GetEntries() ); double err_rew = sqrt( eff_rew * (1. - eff_rew) / (double) h_mZMC_->Integral(0,nbinsMass_ +1 ) ); cout << " geometric acceptance: " << eff << "+/-" << err << endl; cout << " geometric acceptance reweighted: " << eff_rew << "+/-" << err_rew << endl; ofstream myfile; myfile.open(filename_.c_str(), std::ios::app); myfile<< eff << " "<< eff_rew << " " << nev << " " << nev_weigthed << endl ; myfile.close(); }
double EWKSystUnc::accEtaMax_ [private] |
Definition at line 14 of file EWKSystUnc.cc.
Referenced by analyze().
double EWKSystUnc::accEtaMin_ [private] |
Definition at line 14 of file EWKSystUnc.cc.
Referenced by analyze().
double EWKSystUnc::accMassMax_ [private] |
Definition at line 14 of file EWKSystUnc.cc.
Referenced by analyze().
double EWKSystUnc::accMassMin_ [private] |
Definition at line 14 of file EWKSystUnc.cc.
Referenced by analyze().
double EWKSystUnc::accPtMin_ [private] |
Definition at line 14 of file EWKSystUnc.cc.
Referenced by analyze().
double EWKSystUnc::angMax_ [private] |
Definition at line 13 of file EWKSystUnc.cc.
Referenced by EWKSystUnc().
std::string EWKSystUnc::filename_ [private] |
Definition at line 21 of file EWKSystUnc.cc.
Referenced by endJob().
edm::InputTag EWKSystUnc::gen_ [private] |
Definition at line 11 of file EWKSystUnc.cc.
Referenced by analyze().
TH1F * EWKSystUnc::h_etaZMC_ [private] |
Definition at line 16 of file EWKSystUnc.cc.
Referenced by analyze(), and EWKSystUnc().
TH1F* EWKSystUnc::h_mZMC_ [private] |
Definition at line 16 of file EWKSystUnc.cc.
Referenced by analyze(), endJob(), and EWKSystUnc().
TH1F* EWKSystUnc::h_nZ_ [private] |
Definition at line 15 of file EWKSystUnc.cc.
Referenced by EWKSystUnc().
TH1F * EWKSystUnc::h_phiZMC_ [private] |
Definition at line 16 of file EWKSystUnc.cc.
Referenced by analyze(), and EWKSystUnc().
TH1F * EWKSystUnc::h_ptZMC_ [private] |
Definition at line 16 of file EWKSystUnc.cc.
Referenced by analyze(), and EWKSystUnc().
TH1F * EWKSystUnc::h_rapidityZMC_ [private] |
Definition at line 16 of file EWKSystUnc.cc.
Referenced by analyze(), and EWKSystUnc().
TH1F * EWKSystUnc::h_thetaZMC_ [private] |
Definition at line 16 of file EWKSystUnc.cc.
Referenced by analyze(), and EWKSystUnc().
TH1F* EWKSystUnc::h_weight_histo [private] |
Definition at line 18 of file EWKSystUnc.cc.
Referenced by analyze(), and EWKSystUnc().
TH1F * EWKSystUnc::hardeta [private] |
Definition at line 17 of file EWKSystUnc.cc.
Referenced by analyze(), and EWKSystUnc().
TH1F* EWKSystUnc::hardpt [private] |
Definition at line 17 of file EWKSystUnc.cc.
Referenced by analyze(), and EWKSystUnc().
bool EWKSystUnc::isMCatNLO_ [private] |
Definition at line 19 of file EWKSystUnc.cc.
double EWKSystUnc::massMax_ [private] |
Definition at line 13 of file EWKSystUnc.cc.
Referenced by EWKSystUnc().
double EWKSystUnc::nAcc_ [private] |
Definition at line 20 of file EWKSystUnc.cc.
Referenced by analyze(), endJob(), and EWKSystUnc().
double EWKSystUnc::nAccReW_ [private] |
Definition at line 20 of file EWKSystUnc.cc.
Referenced by analyze(), endJob(), and EWKSystUnc().
unsigned int EWKSystUnc::nbinsAng_ [private] |
Definition at line 12 of file EWKSystUnc.cc.
Referenced by EWKSystUnc().
unsigned int EWKSystUnc::nbinsMass_ [private] |
Definition at line 12 of file EWKSystUnc.cc.
Referenced by endJob(), and EWKSystUnc().
unsigned int EWKSystUnc::nbinsPt_ [private] |
Definition at line 12 of file EWKSystUnc.cc.
Referenced by EWKSystUnc().
double EWKSystUnc::nBothMuHasZHasGrandMa_ [private] |
Definition at line 20 of file EWKSystUnc.cc.
Referenced by analyze(), endJob(), and EWKSystUnc().
double EWKSystUnc::ptMax_ [private] |
Definition at line 13 of file EWKSystUnc.cc.
Referenced by EWKSystUnc().
TH1F * EWKSystUnc::softeta [private] |
Definition at line 17 of file EWKSystUnc.cc.
Referenced by analyze(), and EWKSystUnc().
TH1F * EWKSystUnc::softpt [private] |
Definition at line 17 of file EWKSystUnc.cc.
Referenced by analyze(), and EWKSystUnc().
edm::InputTag EWKSystUnc::weights_ [private] |
Definition at line 11 of file EWKSystUnc.cc.
Referenced by analyze().