Public Member Functions | |
ZMuPtScaleAnalyzer (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 | accMassMaxDen_ |
double | accMassMin_ |
double | accMassMinDen_ |
double | accPtMin_ |
double | angMax_ |
edm::InputTag | gen_ |
TH1F * | h_etaZ_ |
TH1F * | h_etaZMC_ |
TH1F * | h_mZ_ |
TH1F * | h_mZMC_ |
TH1F * | h_nZ_ |
TH1F * | h_phiZ_ |
TH1F * | h_phiZMC_ |
TH1F * | h_ptZ_ |
TH1F * | h_ptZMC_ |
TH1F * | h_rapidityZ_ |
TH1F * | h_rapidityZMC_ |
TH1F * | h_thetaZ_ |
TH1F * | h_thetaZMC_ |
TH1F * | hardeta |
TH1F * | hardpt |
double | massMax_ |
int | muPdgStatus_ |
unsigned int | nAcc_ |
unsigned int | nAccPtScaleN_ |
unsigned int | nAccPtScaleP_ |
unsigned int | nAccPtScaleSmearedFlat_ |
unsigned int | nAccPtScaleSmearedGaus_ |
unsigned int | nbinsAng_ |
unsigned int | nbinsMass_ |
unsigned int | nbinsPt_ |
unsigned int | nBothMuHasZHasGrandMa_ |
double | ptMax_ |
double | ptScale_ |
TH1F * | softeta |
TH1F * | softpt |
Definition at line 7 of file ZMuPtScaleAnalyzer.cc.
ZMuPtScaleAnalyzer::ZMuPtScaleAnalyzer | ( | const edm::ParameterSet & | pset | ) |
Definition at line 45 of file ZMuPtScaleAnalyzer.cc.
References angMax_, gather_cfg::cout, h_etaZMC_, h_mZMC_, h_phiZMC_, h_ptZMC_, h_rapidityZMC_, h_thetaZMC_, hardeta, hardpt, TFileDirectory::make(), massMax_, nAcc_, nAccPtScaleN_, nAccPtScaleP_, nAccPtScaleSmearedFlat_, nAccPtScaleSmearedGaus_, nbinsAng_, nbinsMass_, nbinsPt_, nBothMuHasZHasGrandMa_, ptMax_, softeta, and softpt.
: gen_(pset.getParameter<InputTag>("genParticles")), 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")), accMassMinDen_(pset.getUntrackedParameter<double>("accMassMinDen")), accMassMaxDen_(pset.getUntrackedParameter<double>("accMassMaxDen")), accEtaMin_(pset.getUntrackedParameter<double>("accEtaMin")), accEtaMax_(pset.getUntrackedParameter<double>("accEtaMax")), ptScale_(pset.getUntrackedParameter<double>("ptScale")), muPdgStatus_(pset.getUntrackedParameter<int>("muPdgStatus")){ cout << ">>> Z Histogrammer constructor" << endl; Service<TFileService> fs; TFileDirectory ZMCHisto = fs->mkdir( "ZMCHisto" ); 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; nAccPtScaleP_=0; nAccPtScaleN_=0; nAccPtScaleSmearedFlat_=0; nAccPtScaleSmearedGaus_=0; nBothMuHasZHasGrandMa_=0;}
void ZMuPtScaleAnalyzer::analyze | ( | const edm::Event & | event, |
const edm::EventSetup & | setup | ||
) | [private, virtual] |
Implements edm::EDAnalyzer.
Definition at line 89 of file ZMuPtScaleAnalyzer.cc.
References abs, accEtaMax_, accEtaMin_, accMassMax_, accMassMaxDen_, accMassMin_, accMassMinDen_, accPtMin_, gather_cfg::cout, reco::LeafCandidate::eta(), f, createTree::ff, HcalObjRepresent::Fill(), gen_, h_etaZMC_, h_mZMC_, h_phiZMC_, h_ptZMC_, h_rapidityZMC_, h_thetaZMC_, hardeta, hardpt, i, reco::LeafCandidate::mass(), reco::Candidate::mother(), reco::CompositeRefCandidateT< D >::mother(), patZpeak::muons, muPdgStatus_, nAcc_, nAccPtScaleN_, nAccPtScaleP_, nAccPtScaleSmearedFlat_, nAccPtScaleSmearedGaus_, nBothMuHasZHasGrandMa_, reco::CompositeRefCandidateT< D >::numberOfDaughters(), reco::Candidate::numberOfMothers(), reco::CompositeRefCandidateT< D >::numberOfMothers(), p4, reco::LeafCandidate::pdgId(), reco::Candidate::pdgId(), ptScale_, softeta, softpt, mathSSE::sqrt(), and reco::LeafCandidate::status().
{ cout << ">>> Z HistogrammerZLONLOHistogrammer.cc analyze" << endl; Handle<GenParticleCollection> gen; Handle<double> weights; event.getByLabel(gen_, gen); // get weight and fill it to histogram std::vector<GenParticle> muons; double mZGen = -100; for(unsigned int i = 0; i < gen->size(); ++i){ const GenParticle & muMC = (*gen)[i]; // filliScaledPng only muons coming form Z if (abs(muMC.pdgId())==13 && muMC.status()==muPdgStatus_ && muMC.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; cout << "with muMC.eta() " << muMC.eta()<<endl; muons.push_back(muMC); } // introducing here the gen mass cut...................... /* if (muPdgStatus_ ==1) { mZGen = muMC.mother()->mother()->mass(); if (muMC.mother()->mother()->pdgId() ==23 && mZGen>accMassMinDen_ && mZGen<accMassMaxDen_ ) muons.push_back(muMC);} } if (muPdgStatus_ ==3) { mZGen = muMC.mother()->mass(); if (muMC.mother()->pdgId() ==23 && mZGen>accMassMinDen_ && mZGen<accMassMaxDen_ ) muons.push_back(muMC);} } */ const GenParticle & zMC = (*gen)[i]; if (zMC.pdgId()==23 && zMC.status()==3 &&zMC.numberOfDaughters()>1 ) { mZGen = zMC.mass(); cout << "I'm selecting a Z MC with mass " << mZGen << endl; if(mZGen>accMassMinDen_ && mZGen<accMassMaxDen_ ) h_mZMC_->Fill(mZGen); } } 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(); double weight_sign = 1. ; //h_mZMC_->Fill(inv_mass); 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_++; cout << "pt1" << pt1 << endl; // scaling the muon pt double pt1ScaledP = pt1* ( 1. + ptScale_); cout << "pt1 ScaledP of " << ( 1. + ptScale_) << endl; cout << "pt1ScaledP" << pt1ScaledP << endl; double pt2ScaledP = pt2 * ( 1. + ptScale_); //evaluating the geometric acceptance if ( pt1ScaledP >= accPtMin_ && pt2ScaledP >= accPtMin_ && fabs(eta1)>= accEtaMin_ && fabs(eta2) >= accEtaMin_ && fabs(eta1)<= accEtaMax_ && fabs(eta2) <= accEtaMax_ && inv_mass>= accMassMin_ && inv_mass<= accMassMax_) nAccPtScaleP_++; // scaling the muon pt double pt1ScaledN = pt1* ( 1. - ptScale_); double pt2ScaledN = pt2 * ( 1. - ptScale_); //evaluating the geometric acceptance if ( pt1ScaledN >= accPtMin_ && pt2ScaledN >= accPtMin_ && fabs(eta1)>= accEtaMin_ && fabs(eta2) >= accEtaMin_ && fabs(eta1)<= accEtaMax_ && fabs(eta2) <= accEtaMax_ && inv_mass>= accMassMin_ && inv_mass<= accMassMax_) nAccPtScaleN_++; // scaling the muon pt TRandom3 f; f.SetSeed(123456789); double pt1SmearedFlat = pt1* ( 1. + ptScale_ * f.Uniform() ); double pt2SmearedFlat = pt2 * ( 1. + ptScale_ * f.Uniform() ) ; //evaluating the geometric acceptance if ( pt1SmearedFlat >= accPtMin_ && pt2SmearedFlat >= accPtMin_ && fabs(eta1)>= accEtaMin_ && fabs(eta2) >= accEtaMin_ && fabs(eta1)<= accEtaMax_ && fabs(eta2) <= accEtaMax_ && inv_mass>= accMassMin_ && inv_mass<= accMassMax_) nAccPtScaleSmearedFlat_++; // scaling the muon pt TRandom3 ff; ff.SetSeed(123456789); double pt1SmearedGaus = pt1* ( 1. + ptScale_ * f.Gaus() ); double pt2SmearedGaus = pt2 * ( 1. + ptScale_ * f.Gaus() ) ; //evaluating the geometric acceptance if ( pt1SmearedGaus >= accPtMin_ && pt2SmearedGaus >= accPtMin_ && fabs(eta1)>= accEtaMin_ && fabs(eta2) >= accEtaMin_ && fabs(eta1)<= accEtaMax_ && fabs(eta2) <= accEtaMax_ && inv_mass>= accMassMin_ && inv_mass<= accMassMax_) nAccPtScaleSmearedGaus_++; }}
void ZMuPtScaleAnalyzer::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 272 of file ZMuPtScaleAnalyzer.cc.
References gather_cfg::cout, h_mZMC_, nAcc_, nAccPtScaleN_, nAccPtScaleP_, nAccPtScaleSmearedFlat_, nAccPtScaleSmearedGaus_, nBothMuHasZHasGrandMa_, and mathSSE::sqrt().
{ cout << " number of events accepted :" << nAcc_ << endl; cout << " number of total events :" << h_mZMC_->GetEntries() << endl; cout << " number of cases in which BothMuHasZHasGrandMa :" << nBothMuHasZHasGrandMa_ << endl; cout << " number of events pt scaled positively accepted :" << nAccPtScaleP_ << endl; cout << " number of events pt scaled negatively accepted :" << nAccPtScaleN_ << endl; cout << " number of events pt scaled smeared flattely accepted :" << nAccPtScaleSmearedFlat_ << endl; cout << " number of events pt scaled smeared gaussianely accepted :" << nAccPtScaleSmearedGaus_ << endl; double eff = (double)nAcc_ / (double) h_mZMC_->GetEntries(); double err = sqrt( eff * (1. - eff) / (double) h_mZMC_->GetEntries() ); cout << " geometric acceptance: " << eff << "+/-" << err << endl; double effScaledP = (double)nAccPtScaleP_ / (double) h_mZMC_->GetEntries(); double errScaledP = sqrt( effScaledP * (1. - effScaledP) / (double) h_mZMC_->GetEntries() ); cout << " geometric acceptance when pt muon is positively scaled: " << effScaledP << "+/-" << errScaledP << endl; double effScaledN = (double)nAccPtScaleN_ / (double) h_mZMC_->GetEntries(); double errScaledN = sqrt( effScaledN * (1. - effScaledN) / (double) h_mZMC_->GetEntries() ); cout << " geometric acceptance when pt muon is negatively scaled: " << effScaledN << "+/-" << errScaledN << endl; double effSmearedFlat = (double) nAccPtScaleSmearedFlat_ / (double) h_mZMC_->GetEntries(); double errSmearedFlat = sqrt( effSmearedFlat * (1. - effSmearedFlat) / (double) h_mZMC_->GetEntries() ); cout << " geometric acceptance when pt muon is scaled with a flat smaering: " << effSmearedFlat << "+/-" << errSmearedFlat << endl; double effSmearedGaus = (double) nAccPtScaleSmearedGaus_ / (double) h_mZMC_->GetEntries(); double errSmearedGaus = sqrt( effSmearedGaus * (1. - effSmearedGaus) / (double) h_mZMC_->GetEntries() ); cout << " geometric acceptance when pt muon is scaled with a gaussian smearing: " << effSmearedGaus << "+/-" << errSmearedGaus << endl; }
double ZMuPtScaleAnalyzer::accEtaMax_ [private] |
Definition at line 16 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze().
double ZMuPtScaleAnalyzer::accEtaMin_ [private] |
Definition at line 16 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze().
double ZMuPtScaleAnalyzer::accMassMax_ [private] |
Definition at line 16 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze().
double ZMuPtScaleAnalyzer::accMassMaxDen_ [private] |
Definition at line 16 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze().
double ZMuPtScaleAnalyzer::accMassMin_ [private] |
Definition at line 16 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze().
double ZMuPtScaleAnalyzer::accMassMinDen_ [private] |
Definition at line 16 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze().
double ZMuPtScaleAnalyzer::accPtMin_ [private] |
Definition at line 16 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze().
double ZMuPtScaleAnalyzer::angMax_ [private] |
Definition at line 15 of file ZMuPtScaleAnalyzer.cc.
Referenced by ZMuPtScaleAnalyzer().
edm::InputTag ZMuPtScaleAnalyzer::gen_ [private] |
Definition at line 13 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze().
TH1F * ZMuPtScaleAnalyzer::h_etaZ_ [private] |
Definition at line 17 of file ZMuPtScaleAnalyzer.cc.
TH1F * ZMuPtScaleAnalyzer::h_etaZMC_ [private] |
Definition at line 18 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze(), and ZMuPtScaleAnalyzer().
TH1F * ZMuPtScaleAnalyzer::h_mZ_ [private] |
Definition at line 17 of file ZMuPtScaleAnalyzer.cc.
TH1F* ZMuPtScaleAnalyzer::h_mZMC_ [private] |
Definition at line 18 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze(), endJob(), and ZMuPtScaleAnalyzer().
TH1F* ZMuPtScaleAnalyzer::h_nZ_ [private] |
Definition at line 17 of file ZMuPtScaleAnalyzer.cc.
TH1F * ZMuPtScaleAnalyzer::h_phiZ_ [private] |
Definition at line 17 of file ZMuPtScaleAnalyzer.cc.
TH1F * ZMuPtScaleAnalyzer::h_phiZMC_ [private] |
Definition at line 18 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze(), and ZMuPtScaleAnalyzer().
TH1F * ZMuPtScaleAnalyzer::h_ptZ_ [private] |
Definition at line 17 of file ZMuPtScaleAnalyzer.cc.
TH1F * ZMuPtScaleAnalyzer::h_ptZMC_ [private] |
Definition at line 18 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze(), and ZMuPtScaleAnalyzer().
TH1F * ZMuPtScaleAnalyzer::h_rapidityZ_ [private] |
Definition at line 17 of file ZMuPtScaleAnalyzer.cc.
TH1F * ZMuPtScaleAnalyzer::h_rapidityZMC_ [private] |
Definition at line 18 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze(), and ZMuPtScaleAnalyzer().
TH1F * ZMuPtScaleAnalyzer::h_thetaZ_ [private] |
Definition at line 17 of file ZMuPtScaleAnalyzer.cc.
TH1F * ZMuPtScaleAnalyzer::h_thetaZMC_ [private] |
Definition at line 18 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze(), and ZMuPtScaleAnalyzer().
TH1F * ZMuPtScaleAnalyzer::hardeta [private] |
Definition at line 19 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze(), and ZMuPtScaleAnalyzer().
TH1F* ZMuPtScaleAnalyzer::hardpt [private] |
Definition at line 19 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze(), and ZMuPtScaleAnalyzer().
double ZMuPtScaleAnalyzer::massMax_ [private] |
Definition at line 15 of file ZMuPtScaleAnalyzer.cc.
Referenced by ZMuPtScaleAnalyzer().
int ZMuPtScaleAnalyzer::muPdgStatus_ [private] |
Definition at line 21 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze().
unsigned int ZMuPtScaleAnalyzer::nAcc_ [private] |
Definition at line 20 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze(), endJob(), and ZMuPtScaleAnalyzer().
unsigned int ZMuPtScaleAnalyzer::nAccPtScaleN_ [private] |
Definition at line 20 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze(), endJob(), and ZMuPtScaleAnalyzer().
unsigned int ZMuPtScaleAnalyzer::nAccPtScaleP_ [private] |
Definition at line 20 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze(), endJob(), and ZMuPtScaleAnalyzer().
unsigned int ZMuPtScaleAnalyzer::nAccPtScaleSmearedFlat_ [private] |
Definition at line 20 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze(), endJob(), and ZMuPtScaleAnalyzer().
unsigned int ZMuPtScaleAnalyzer::nAccPtScaleSmearedGaus_ [private] |
Definition at line 20 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze(), endJob(), and ZMuPtScaleAnalyzer().
unsigned int ZMuPtScaleAnalyzer::nbinsAng_ [private] |
Definition at line 14 of file ZMuPtScaleAnalyzer.cc.
Referenced by ZMuPtScaleAnalyzer().
unsigned int ZMuPtScaleAnalyzer::nbinsMass_ [private] |
Definition at line 14 of file ZMuPtScaleAnalyzer.cc.
Referenced by ZMuPtScaleAnalyzer().
unsigned int ZMuPtScaleAnalyzer::nbinsPt_ [private] |
Definition at line 14 of file ZMuPtScaleAnalyzer.cc.
Referenced by ZMuPtScaleAnalyzer().
unsigned int ZMuPtScaleAnalyzer::nBothMuHasZHasGrandMa_ [private] |
Definition at line 20 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze(), endJob(), and ZMuPtScaleAnalyzer().
double ZMuPtScaleAnalyzer::ptMax_ [private] |
Definition at line 15 of file ZMuPtScaleAnalyzer.cc.
Referenced by ZMuPtScaleAnalyzer().
double ZMuPtScaleAnalyzer::ptScale_ [private] |
Definition at line 16 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze().
TH1F * ZMuPtScaleAnalyzer::softeta [private] |
Definition at line 19 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze(), and ZMuPtScaleAnalyzer().
TH1F * ZMuPtScaleAnalyzer::softpt [private] |
Definition at line 19 of file ZMuPtScaleAnalyzer.cc.
Referenced by analyze(), and ZMuPtScaleAnalyzer().