00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "DataFormats/Common/interface/AssociationVector.h"
00011 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00012 #include "DataFormats/Candidate/interface/CandMatchMap.h"
00013 #include "FWCore/Framework/interface/EDAnalyzer.h"
00014 #include "DataFormats/Candidate/interface/Particle.h"
00015 #include "DataFormats/Candidate/interface/Candidate.h"
00016 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00017 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00018 #include "DataFormats/MuonReco/interface/Muon.h"
00019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00020 #include "FWCore/Framework/interface/Event.h"
00021 #include "FWCore/Framework/interface/EventSetup.h"
00022 #include "FWCore/Utilities/interface/InputTag.h"
00023 #include "DataFormats/Candidate/interface/OverlapChecker.h"
00024 #include "DataFormats/Math/interface/deltaR.h"
00025 #include "DataFormats/PatCandidates/interface/Muon.h"
00026 #include "DataFormats/PatCandidates/interface/GenericParticle.h"
00027 #include "DataFormats/PatCandidates/interface/TriggerObjectStandAlone.h"
00028 #include "DataFormats/Common/interface/AssociationVector.h"
00029 #include "DataFormats/PatCandidates/interface/PATObject.h"
00030 #include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
00031 #include "DataFormats/RecoCandidate/interface/IsoDepositFwd.h"
00032 #include "DataFormats/PatCandidates/interface/Isolation.h"
00033 #include "DataFormats/Common/interface/ValueMap.h"
00034 #include "DataFormats/RecoCandidate/interface/IsoDepositVetos.h"
00035 #include "DataFormats/RecoCandidate/interface/IsoDepositDirection.h"
00036
00037
00038
00039
00040 #include "TH1.h"
00041 #include "TH2.h"
00042 #include "TH3.h"
00043 #include <vector>
00044 using namespace edm;
00045 using namespace std;
00046 using namespace reco;
00047 using namespace reco;
00048 using namespace isodeposit;
00049
00050
00051 class ZMuMu_MCanalyzer : public edm::EDAnalyzer {
00052 public:
00053 ZMuMu_MCanalyzer(const edm::ParameterSet& pset);
00054 private:
00055 virtual void analyze(const edm::Event& event, const edm::EventSetup& setup);
00056 bool check_ifZmumu(const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2);
00057 float getParticlePt(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2);
00058 float getParticleEta(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2);
00059 float getParticlePhi(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2);
00060 Particle::LorentzVector getParticleP4(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2);
00061 virtual void endJob();
00062
00063 edm::InputTag zMuMu_, zMuMuMatchMap_;
00064 edm::InputTag zMuStandAlone_, zMuStandAloneMatchMap_;
00065 edm::InputTag zMuTrack_, zMuTrackMatchMap_;
00066 edm::InputTag muons_, muonMatchMap_, muonIso_;
00067 edm::InputTag tracks_, trackIso_;
00068 edm::InputTag genParticles_;
00069
00070 bool bothMuons_;
00071
00072 double etamin_, etamax_, ptmin_, massMin_, massMax_, isoMax_;
00073
00074 double ptThreshold_, etEcalThreshold_, etHcalThreshold_ ,dRVetoTrk_, dRTrk_, dREcal_ , dRHcal_, alpha_, beta_;
00075
00076 bool relativeIsolation_;
00077 string hltPath_;
00078 reco::CandidateBaseRef globalMuonCandRef_, trackMuonCandRef_, standAloneMuonCandRef_;
00079 OverlapChecker overlap_;
00080
00081
00082 TH1D *h_trackProbe_eta, *h_trackProbe_pt, *h_staProbe_eta, *h_staProbe_pt, *h_ProbeOk_eta, *h_ProbeOk_pt;
00083
00084
00085 int nGlobalMuonsMatched_passed;
00086 int nGlobalMuonsMatched_passedIso;
00087 int n2GlobalMuonsMatched_passedIso;
00088 int nStaMuonsMatched_passedIso;
00089 int nTracksMuonsMatched_passedIso;
00090 int n2GlobalMuonsMatched_passedIso2Trg;
00091 int nMu0onlyTriggered;
00092 int nMu1onlyTriggered;
00093
00094 int nZMuMu_matched;
00095 int nZMuSta_matched;
00096 int nZMuTrk_matched;
00097 };
00098
00099
00100 template<typename T>
00101 double isolation(const T * t, double ptThreshold, double etEcalThreshold, double etHcalThreshold , double dRVetoTrk, double dRTrk, double dREcal , double dRHcal, double alpha, double beta, bool relativeIsolation) {
00102
00103 const pat::IsoDeposit * trkIso = t->isoDeposit(pat::TrackIso);
00104
00105
00106 const pat::IsoDeposit * ecalIso = t->isoDeposit(pat::EcalIso);
00107
00108
00109 const pat::IsoDeposit * hcalIso = t->isoDeposit(pat::HcalIso);
00110
00111
00112 Direction dir = Direction(t->eta(), t->phi());
00113
00114 pat::IsoDeposit::AbsVetos vetosTrk;
00115 vetosTrk.push_back(new ConeVeto( dir, dRVetoTrk ));
00116 vetosTrk.push_back(new ThresholdVeto( ptThreshold ));
00117
00118 pat::IsoDeposit::AbsVetos vetosEcal;
00119 vetosEcal.push_back(new ConeVeto( dir, 0.));
00120 vetosEcal.push_back(new ThresholdVeto( etEcalThreshold ));
00121
00122 pat::IsoDeposit::AbsVetos vetosHcal;
00123 vetosHcal.push_back(new ConeVeto( dir, 0. ));
00124 vetosHcal.push_back(new ThresholdVeto( etHcalThreshold ));
00125
00126 double isovalueTrk = (trkIso->sumWithin(dRTrk,vetosTrk));
00127 double isovalueEcal = (ecalIso->sumWithin(dREcal,vetosEcal));
00128 double isovalueHcal = (hcalIso->sumWithin(dRHcal,vetosHcal));
00129
00130
00131 double iso = alpha*( ((1+beta)/2*isovalueEcal) + ((1-beta)/2*isovalueHcal) ) + ((1-alpha)*isovalueTrk) ;
00132 if(relativeIsolation) iso /= t->pt();
00133 return iso;
00134 }
00135
00136
00137 double candidateIsolation( const reco::Candidate* c, double ptThreshold, double etEcalThreshold, double etHcalThreshold , double dRVetoTrk, double dRTrk, double dREcal , double dRHcal, double alpha, double beta, bool relativeIsolation) {
00138 const pat::Muon * mu = dynamic_cast<const pat::Muon *>(&*c->masterClone());
00139 if(mu != 0) return isolation(mu, ptThreshold, etEcalThreshold, etHcalThreshold ,dRVetoTrk, dRTrk, dREcal , dRHcal, alpha, beta, relativeIsolation);
00140 const pat::GenericParticle * trk = dynamic_cast<const pat::GenericParticle*>(&*c->masterClone());
00141 if(trk != 0) return isolation(trk, ptThreshold, etEcalThreshold, etHcalThreshold ,dRVetoTrk, dRTrk, dREcal ,
00142 dRHcal, alpha, beta, relativeIsolation);
00143 throw edm::Exception(edm::errors::InvalidReference)
00144 << "Candidate daughter #0 is neither pat::Muons nor pat::GenericParticle\n";
00145 return -1;
00146 }
00147
00148
00149
00150
00151 #include "FWCore/ServiceRegistry/interface/Service.h"
00152 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00153 #include "DataFormats/Common/interface/Handle.h"
00154 #include "DataFormats/Candidate/interface/Particle.h"
00155 #include "DataFormats/Candidate/interface/Candidate.h"
00156 #include "DataFormats/Common/interface/ValueMap.h"
00157 #include "DataFormats/Candidate/interface/CandAssociation.h"
00158 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00159 #include "DataFormats/Math/interface/LorentzVector.h"
00160 #include "DataFormats/TrackReco/interface/Track.h"
00161 #include <iostream>
00162 #include <iterator>
00163 #include <cmath>
00164 using namespace std;
00165 using namespace reco;
00166 using namespace edm;
00167
00168
00169 typedef edm::ValueMap<float> IsolationCollection;
00170
00171 ZMuMu_MCanalyzer::ZMuMu_MCanalyzer(const ParameterSet& pset) :
00172 zMuMu_(pset.getParameter<InputTag>("zMuMu")),
00173 zMuMuMatchMap_(pset.getParameter<InputTag>("zMuMuMatchMap")),
00174 zMuStandAlone_(pset.getParameter<InputTag>("zMuStandAlone")),
00175 zMuStandAloneMatchMap_(pset.getParameter<InputTag>("zMuStandAloneMatchMap")),
00176 zMuTrack_(pset.getParameter<InputTag>("zMuTrack")),
00177 zMuTrackMatchMap_(pset.getParameter<InputTag>("zMuTrackMatchMap")),
00178 muons_(pset.getParameter<InputTag>("muons")),
00179 tracks_(pset.getParameter<InputTag>("tracks")),
00180 genParticles_(pset.getParameter<InputTag>( "genParticles" ) ),
00181
00182 bothMuons_(pset.getParameter<bool>("bothMuons")),
00183 etamin_(pset.getUntrackedParameter<double>("etamin")),
00184 etamax_(pset.getUntrackedParameter<double>("etamax")),
00185 ptmin_(pset.getUntrackedParameter<double>("ptmin")),
00186 massMin_(pset.getUntrackedParameter<double>("zMassMin")),
00187 massMax_(pset.getUntrackedParameter<double>("zMassMax")),
00188 isoMax_(pset.getUntrackedParameter<double>("isomax")),
00189 ptThreshold_(pset.getUntrackedParameter<double>("ptThreshold")),
00190 etEcalThreshold_(pset.getUntrackedParameter<double>("etEcalThreshold")),
00191 etHcalThreshold_(pset.getUntrackedParameter<double>("etHcalThreshold")),
00192 dRVetoTrk_(pset.getUntrackedParameter<double>("deltaRVetoTrk")),
00193 dRTrk_(pset.getUntrackedParameter<double>("deltaRTrk")),
00194 dREcal_(pset.getUntrackedParameter<double>("deltaREcal")),
00195 dRHcal_(pset.getUntrackedParameter<double>("deltaRHcal")),
00196 alpha_(pset.getUntrackedParameter<double>("alpha")),
00197 beta_(pset.getUntrackedParameter<double>("beta")),
00198 relativeIsolation_(pset.getUntrackedParameter<bool>("relativeIsolation")),
00199 hltPath_(pset.getUntrackedParameter<std::string >("hltPath")) {
00200 Service<TFileService> fs;
00201
00202
00203 double etaRange[8] = {-2.5,-2.,-1.2,-0.8,0.8,1.2,2.,2.5};
00204 double ptRange[4] = {20.,40.,60.,100.};
00205
00206
00207 h_trackProbe_eta = fs->make<TH1D>("trackProbeEta","Eta of tracks",7,etaRange);
00208 h_trackProbe_pt = fs->make<TH1D>("trackProbePt","Pt of tracks",3,ptRange);
00209 h_staProbe_eta = fs->make<TH1D>("standAloneProbeEta","Eta of standAlone",7,etaRange);
00210 h_staProbe_pt = fs->make<TH1D>("standAloneProbePt","Pt of standAlone",3,ptRange);
00211 h_ProbeOk_eta = fs->make<TH1D>("probeOkEta","Eta of probe Ok",7,etaRange);
00212 h_ProbeOk_pt = fs->make<TH1D>("probeOkPt","Pt of probe ok",3,ptRange);
00213
00214
00215 nGlobalMuonsMatched_passed = 0;
00216 nGlobalMuonsMatched_passedIso = 0;
00217 n2GlobalMuonsMatched_passedIso = 0;
00218 nStaMuonsMatched_passedIso = 0;
00219 nTracksMuonsMatched_passedIso = 0;
00220 n2GlobalMuonsMatched_passedIso2Trg = 0;
00221 nMu0onlyTriggered = 0;
00222 nMu1onlyTriggered = 0;
00223 nZMuMu_matched = 0;
00224 nZMuSta_matched = 0;
00225 nZMuTrk_matched = 0;
00226 }
00227
00228 void ZMuMu_MCanalyzer::analyze(const Event& event, const EventSetup& setup) {
00229 Handle<CandidateView> zMuMu;
00230 Handle<GenParticleMatch> zMuMuMatchMap;
00231 Handle<CandidateView> zMuStandAlone;
00232 Handle<GenParticleMatch> zMuStandAloneMatchMap;
00233 Handle<CandidateView> zMuTrack;
00234 Handle<GenParticleMatch> zMuTrackMatchMap;
00235 Handle<CandidateView> muons;
00236 Handle<CandidateView> tracks;
00237
00238 Handle<GenParticleCollection> genParticles;
00239
00240 event.getByLabel(zMuMu_, zMuMu);
00241 event.getByLabel(zMuStandAlone_, zMuStandAlone);
00242 event.getByLabel(zMuTrack_, zMuTrack);
00243 event.getByLabel(genParticles_, genParticles);
00244 event.getByLabel(muons_, muons);
00245 event.getByLabel(tracks_, tracks);
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258 bool zMuMu_found = false;
00259
00260
00261 if (zMuMu->size() > 0 ) {
00262 event.getByLabel(zMuMuMatchMap_, zMuMuMatchMap);
00263 for(unsigned int i = 0; i < zMuMu->size(); ++i) {
00264 const Candidate & zMuMuCand = (*zMuMu)[i];
00265 CandidateBaseRef zMuMuCandRef = zMuMu->refAt(i);
00266
00267 const Candidate * lep0 = zMuMuCand.daughter( 0 );
00268 const Candidate * lep1 = zMuMuCand.daughter( 1 );
00269 const pat::Muon & muonDau0 = dynamic_cast<const pat::Muon &>(*lep0->masterClone());
00270
00271 const pat::Muon & muonDau1 = dynamic_cast<const pat::Muon &>(*lep1->masterClone());
00272
00273
00274 double iso0 = candidateIsolation(lep0,ptThreshold_, etEcalThreshold_, etHcalThreshold_,dRVetoTrk_, dRTrk_, dREcal_ , dRHcal_, alpha_, beta_, relativeIsolation_);
00275 double iso1 = candidateIsolation(lep1,ptThreshold_, etEcalThreshold_, etHcalThreshold_,dRVetoTrk_, dRTrk_, dREcal_ , dRHcal_, alpha_, beta_, relativeIsolation_);
00276
00277 double pt0 = zMuMuCand.daughter(0)->pt();
00278 double pt1 = zMuMuCand.daughter(1)->pt();
00279 double eta0 = zMuMuCand.daughter(0)->eta();
00280 double eta1 = zMuMuCand.daughter(1)->eta();
00281 double mass = zMuMuCand.mass();
00282
00283
00284 const pat::TriggerObjectStandAloneCollection mu0HLTMatches =
00285 muonDau0.triggerObjectMatchesByPath( hltPath_ );
00286 const pat::TriggerObjectStandAloneCollection mu1HLTMatches =
00287 muonDau1.triggerObjectMatchesByPath( hltPath_ );
00288
00289 bool trig0found = false;
00290 bool trig1found = false;
00291 if( mu0HLTMatches.size()>0 )
00292 trig0found = true;
00293 if( mu1HLTMatches.size()>0 )
00294 trig1found = true;
00295
00296 GenParticleRef zMuMuMatch = (*zMuMuMatchMap)[zMuMuCandRef];
00297 if(zMuMuMatch.isNonnull()) {
00298 zMuMu_found = true;
00299 nZMuMu_matched++;
00300 if (pt0>ptmin_ && pt1>ptmin_ && abs(eta0)>etamin_ && abs(eta1) >etamin_ && abs(eta0)<etamax_ && abs(eta1) <etamax_ && mass >massMin_ && mass < massMax_ && (trig0found || trig1found)) {
00301 nGlobalMuonsMatched_passed++;
00302 nGlobalMuonsMatched_passed++;
00303 if (iso0<isoMax_) nGlobalMuonsMatched_passedIso++;
00304 if (iso1<isoMax_) nGlobalMuonsMatched_passedIso++;
00305 if (iso0<isoMax_ && iso1<isoMax_) {
00306 n2GlobalMuonsMatched_passedIso++;
00307 if (trig0found && trig1found) n2GlobalMuonsMatched_passedIso2Trg++;
00308 if (trig0found && !trig1found) nMu0onlyTriggered++;
00309 if (trig1found && !trig0found) nMu1onlyTriggered++;
00310
00311 if (trig1found) {
00312 h_trackProbe_eta->Fill(eta0);
00313 h_trackProbe_pt->Fill(pt0);
00314 h_staProbe_eta->Fill(eta0);
00315 h_staProbe_pt->Fill(pt0);
00316 h_ProbeOk_eta->Fill(eta0);
00317 h_ProbeOk_pt->Fill(pt0);
00318 }
00319 if (trig0found) {
00320 h_trackProbe_eta->Fill(eta1);
00321 h_staProbe_eta->Fill(eta1);
00322 h_trackProbe_pt->Fill(pt1);
00323 h_staProbe_pt->Fill(pt1);
00324 h_ProbeOk_eta->Fill(eta1);
00325 h_ProbeOk_pt->Fill(pt1);
00326 }
00327 }
00328 }
00329 }
00330
00331 }
00332 }
00333
00334
00335 bool zMuSta_found = false;
00336 if (!zMuMu_found && zMuStandAlone->size() > 0 ) {
00337 event.getByLabel(zMuStandAloneMatchMap_, zMuStandAloneMatchMap);
00338 for(unsigned int i = 0; i < zMuStandAlone->size(); ++i) {
00339 const Candidate & zMuStandAloneCand = (*zMuStandAlone)[i];
00340 CandidateBaseRef zMuStandAloneCandRef = zMuStandAlone->refAt(i);
00341 GenParticleRef zMuStandAloneMatch = (*zMuStandAloneMatchMap)[zMuStandAloneCandRef];
00342
00343 const Candidate * lep0 = zMuStandAloneCand.daughter( 0 );
00344 const Candidate * lep1 = zMuStandAloneCand.daughter( 1 );
00345 const pat::Muon & muonDau0 = dynamic_cast<const pat::Muon &>(*lep0->masterClone());
00346
00347
00348
00349
00350 double iso0 = candidateIsolation(lep0,ptThreshold_, etEcalThreshold_, etHcalThreshold_,dRVetoTrk_, dRTrk_, dREcal_ , dRHcal_, alpha_, beta_, relativeIsolation_);
00351 double iso1 = candidateIsolation(lep1,ptThreshold_, etEcalThreshold_, etHcalThreshold_,dRVetoTrk_, dRTrk_, dREcal_ , dRHcal_, alpha_, beta_, relativeIsolation_);
00352
00353 double pt0 = zMuStandAloneCand.daughter(0)->pt();
00354 double pt1 = zMuStandAloneCand.daughter(1)->pt();
00355 double eta0 = zMuStandAloneCand.daughter(0)->eta();
00356 double eta1 = zMuStandAloneCand.daughter(1)->eta();
00357 double mass = zMuStandAloneCand.mass();
00358
00359
00360 const pat::TriggerObjectStandAloneCollection mu0HLTMatches =
00361 muonDau0.triggerObjectMatchesByPath( hltPath_ );
00362
00363 bool trig0found = false;
00364 if( mu0HLTMatches.size()>0 )
00365 trig0found = true;
00366
00367 if(zMuStandAloneMatch.isNonnull()) {
00368 zMuSta_found = true;
00369 nZMuSta_matched++;
00370 if (pt0>ptmin_ && pt1>ptmin_ && abs(eta0)>etamin_ && abs(eta1)>etamin_ && abs(eta0)<etamax_ && abs(eta1) <etamax_ && mass >massMin_ &&
00371 mass < massMax_ && iso0<isoMax_ && iso1 < isoMax_ && trig0found) {
00372 nStaMuonsMatched_passedIso++;
00373
00374 h_staProbe_eta->Fill(eta1);
00375 h_staProbe_pt->Fill(pt1);
00376 }
00377 }
00378 }
00379 }
00380
00381
00382
00383 if (!zMuMu_found && !zMuSta_found && zMuTrack->size() > 0 ) {
00384 event.getByLabel(zMuTrackMatchMap_, zMuTrackMatchMap);
00385 for(unsigned int i = 0; i < zMuTrack->size(); ++i) {
00386 const Candidate & zMuTrackCand = (*zMuTrack)[i];
00387 CandidateBaseRef zMuTrackCandRef = zMuTrack->refAt(i);
00388 const Candidate * lep0 = zMuTrackCand.daughter( 0 );
00389 const Candidate * lep1 = zMuTrackCand.daughter( 1 );
00390 const pat::Muon & muonDau0 = dynamic_cast<const pat::Muon &>(*lep0->masterClone());
00391
00392
00393
00394 double iso0 = candidateIsolation(lep0,ptThreshold_, etEcalThreshold_, etHcalThreshold_,dRVetoTrk_, dRTrk_, dREcal_ , dRHcal_, alpha_, beta_, relativeIsolation_);
00395 double iso1 = candidateIsolation(lep1,ptThreshold_, etEcalThreshold_, etHcalThreshold_,dRVetoTrk_, dRTrk_, dREcal_ , dRHcal_, alpha_, beta_, relativeIsolation_);
00396
00397
00398 double pt0 = zMuTrackCand.daughter(0)->pt();
00399 double pt1 = zMuTrackCand.daughter(1)->pt();
00400 double eta0 = zMuTrackCand.daughter(0)->eta();
00401 double eta1 = zMuTrackCand.daughter(1)->eta();
00402 double mass = zMuTrackCand.mass();
00403
00404
00405 const pat::TriggerObjectStandAloneCollection mu0HLTMatches =
00406 muonDau0.triggerObjectMatchesByPath( hltPath_ );
00407
00408 bool trig0found = false;
00409 if( mu0HLTMatches.size()>0 )
00410 trig0found = true;
00411
00412 GenParticleRef zMuTrackMatch = (*zMuTrackMatchMap)[zMuTrackCandRef];
00413 if(zMuTrackMatch.isNonnull()) {
00414 nZMuTrk_matched++;
00415 if (pt0>ptmin_ && pt1>ptmin_ && abs(eta0)>etamin_ && abs(eta1)>etamin_ && abs(eta0)<etamax_ && abs(eta1) <etamax_ && mass >massMin_ &&
00416 mass < massMax_ && iso0<isoMax_ && iso1 < isoMax_ && trig0found) {
00417 nTracksMuonsMatched_passedIso++;
00418
00419 h_trackProbe_eta->Fill(eta1);
00420 h_trackProbe_pt->Fill(pt1);
00421 }
00422 }
00423 }
00424 }
00425
00426 }
00427
00428 bool ZMuMu_MCanalyzer::check_ifZmumu(const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
00429 {
00430 int partId0 = dauGen0->pdgId();
00431 int partId1 = dauGen1->pdgId();
00432 int partId2 = dauGen2->pdgId();
00433 bool muplusFound=false;
00434 bool muminusFound=false;
00435 bool ZFound=false;
00436 if (partId0==13 || partId1==13 || partId2==13) muminusFound=true;
00437 if (partId0==-13 || partId1==-13 || partId2==-13) muplusFound=true;
00438 if (partId0==23 || partId1==23 || partId2==23) ZFound=true;
00439 return muplusFound*muminusFound*ZFound;
00440 }
00441
00442 float ZMuMu_MCanalyzer::getParticlePt(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
00443 {
00444 int partId0 = dauGen0->pdgId();
00445 int partId1 = dauGen1->pdgId();
00446 int partId2 = dauGen2->pdgId();
00447 float ptpart=0.;
00448 if (partId0 == ipart) {
00449 for(unsigned int k = 0; k < dauGen0->numberOfDaughters(); ++k) {
00450 const Candidate * dauMuGen = dauGen0->daughter(k);
00451 if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
00452 ptpart = dauMuGen->pt();
00453 }
00454 }
00455 }
00456 if (partId1 == ipart) {
00457 for(unsigned int k = 0; k < dauGen1->numberOfDaughters(); ++k) {
00458 const Candidate * dauMuGen = dauGen1->daughter(k);
00459 if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
00460 ptpart = dauMuGen->pt();
00461 }
00462 }
00463 }
00464 if (partId2 == ipart) {
00465 for(unsigned int k = 0; k < dauGen2->numberOfDaughters(); ++k) {
00466 const Candidate * dauMuGen = dauGen2->daughter(k);
00467 if(abs(dauMuGen->pdgId()) == ipart && dauMuGen->status() ==1) {
00468 ptpart = dauMuGen->pt();
00469 }
00470 }
00471 }
00472 return ptpart;
00473 }
00474
00475 float ZMuMu_MCanalyzer::getParticleEta(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
00476 {
00477 int partId0 = dauGen0->pdgId();
00478 int partId1 = dauGen1->pdgId();
00479 int partId2 = dauGen2->pdgId();
00480 float etapart=0.;
00481 if (partId0 == ipart) {
00482 for(unsigned int k = 0; k < dauGen0->numberOfDaughters(); ++k) {
00483 const Candidate * dauMuGen = dauGen0->daughter(k);
00484 if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
00485 etapart = dauMuGen->eta();
00486 }
00487 }
00488 }
00489 if (partId1 == ipart) {
00490 for(unsigned int k = 0; k < dauGen1->numberOfDaughters(); ++k) {
00491 const Candidate * dauMuGen = dauGen1->daughter(k);
00492 if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
00493 etapart = dauMuGen->eta();
00494 }
00495 }
00496 }
00497 if (partId2 == ipart) {
00498 for(unsigned int k = 0; k < dauGen2->numberOfDaughters(); ++k) {
00499 const Candidate * dauMuGen = dauGen2->daughter(k);
00500 if(abs(dauMuGen->pdgId()) == ipart && dauMuGen->status() ==1) {
00501 etapart = dauMuGen->eta();
00502 }
00503 }
00504 }
00505 return etapart;
00506 }
00507
00508 float ZMuMu_MCanalyzer::getParticlePhi(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
00509 {
00510 int partId0 = dauGen0->pdgId();
00511 int partId1 = dauGen1->pdgId();
00512 int partId2 = dauGen2->pdgId();
00513 float phipart=0.;
00514 if (partId0 == ipart) {
00515 for(unsigned int k = 0; k < dauGen0->numberOfDaughters(); ++k) {
00516 const Candidate * dauMuGen = dauGen0->daughter(k);
00517 if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
00518 phipart = dauMuGen->phi();
00519 }
00520 }
00521 }
00522 if (partId1 == ipart) {
00523 for(unsigned int k = 0; k < dauGen1->numberOfDaughters(); ++k) {
00524 const Candidate * dauMuGen = dauGen1->daughter(k);
00525 if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
00526 phipart = dauMuGen->phi();
00527 }
00528 }
00529 }
00530 if (partId2 == ipart) {
00531 for(unsigned int k = 0; k < dauGen2->numberOfDaughters(); ++k) {
00532 const Candidate * dauMuGen = dauGen2->daughter(k);
00533 if(abs(dauMuGen->pdgId()) == ipart && dauMuGen->status() ==1) {
00534 phipart = dauMuGen->phi();
00535 }
00536 }
00537 }
00538 return phipart;
00539 }
00540
00541 Particle::LorentzVector ZMuMu_MCanalyzer::getParticleP4(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
00542 {
00543 int partId0 = dauGen0->pdgId();
00544 int partId1 = dauGen1->pdgId();
00545 int partId2 = dauGen2->pdgId();
00546 Particle::LorentzVector p4part(0.,0.,0.,0.);
00547 if (partId0 == ipart) {
00548 for(unsigned int k = 0; k < dauGen0->numberOfDaughters(); ++k) {
00549 const Candidate * dauMuGen = dauGen0->daughter(k);
00550 if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
00551 p4part = dauMuGen->p4();
00552 }
00553 }
00554 }
00555 if (partId1 == ipart) {
00556 for(unsigned int k = 0; k < dauGen1->numberOfDaughters(); ++k) {
00557 const Candidate * dauMuGen = dauGen1->daughter(k);
00558 if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
00559 p4part = dauMuGen->p4();
00560 }
00561 }
00562 }
00563 if (partId2 == ipart) {
00564 for(unsigned int k = 0; k < dauGen2->numberOfDaughters(); ++k) {
00565 const Candidate * dauMuGen = dauGen2->daughter(k);
00566 if(abs(dauMuGen->pdgId()) == ipart && dauMuGen->status() ==1) {
00567 p4part = dauMuGen->p4();
00568 }
00569 }
00570 }
00571 return p4part;
00572 }
00573
00574
00575
00576 void ZMuMu_MCanalyzer::endJob() {
00577
00578
00579 double eff_Iso = double(nGlobalMuonsMatched_passedIso)/nGlobalMuonsMatched_passed;
00580 double err_effIso = sqrt(eff_Iso*(1-eff_Iso)/nGlobalMuonsMatched_passed);
00581
00582 double n1_afterIso = 2*n2GlobalMuonsMatched_passedIso2Trg+nMu0onlyTriggered+nMu1onlyTriggered+nTracksMuonsMatched_passedIso;
00583 double n2_afterIso = 2*n2GlobalMuonsMatched_passedIso2Trg+nMu0onlyTriggered+nMu1onlyTriggered+nStaMuonsMatched_passedIso;
00584 double nGLB_afterIso = 2*n2GlobalMuonsMatched_passedIso2Trg+nMu0onlyTriggered+nMu1onlyTriggered;
00585 double effSta_afterIso = (2*n2GlobalMuonsMatched_passedIso2Trg+nMu0onlyTriggered+nMu1onlyTriggered)/n1_afterIso;
00586 double effTrk_afterIso = (2*n2GlobalMuonsMatched_passedIso2Trg+nMu0onlyTriggered+nMu1onlyTriggered)/n2_afterIso;
00587 double effHLT_afterIso = (2.* n2GlobalMuonsMatched_passedIso2Trg)/(2.* n2GlobalMuonsMatched_passedIso2Trg + nMu0onlyTriggered + nMu1onlyTriggered);
00588 double err_effHLT_afterIso= sqrt( effHLT_afterIso * (1 - effHLT_afterIso)/nGLB_afterIso);
00589 double err_effsta_afterIso = sqrt(effSta_afterIso*(1-effSta_afterIso)/n1_afterIso);
00590 double err_efftrk_afterIso = sqrt(effTrk_afterIso*(1-effTrk_afterIso)/n2_afterIso);
00591
00592
00593 cout << "------------------------------------ Counters --------------------------------" << endl;
00594
00595 cout << "number of events zMuMu matched " << nZMuMu_matched << endl;
00596 cout << "number of events zMuSta matched " << nZMuSta_matched << endl;
00597 cout << "number of events zMuTk matched " << nZMuTrk_matched << endl;
00598 cout << "number of events zMuMu with mu0 only triggered " << nMu0onlyTriggered << endl;
00599 cout << "number of events zMuMu with mu1 only triggered " << nMu1onlyTriggered << endl;
00600 cout << "=========================================" << endl;
00601 cout << "n. of global muons MC matched and passing cuts: " << nGlobalMuonsMatched_passed << endl;
00602 cout << "n. of global muons MC matched and passing also Iso cut: " << nGlobalMuonsMatched_passedIso << endl;
00603 cout << "n. of Z -> 2 global muons MC matched and passing ALL cuts: " << n2GlobalMuonsMatched_passedIso << endl;
00604 cout << "n. of ZMuSta MC matched and passing ALL cuts: " << nStaMuonsMatched_passedIso << endl;
00605 cout << "n. of ZmuTrck MC matched and passing ALL cuts: " << nTracksMuonsMatched_passedIso << endl;
00606 cout << "n. of Z -> 2 global muons MC matched and passing ALL cuts and both triggered: " << n2GlobalMuonsMatched_passedIso2Trg << endl;
00607 cout << "=================================================================================" << endl;
00608 cout << "Iso efficiency: " << eff_Iso << " +/- " << err_effIso << endl;
00609 cout << "HLT efficiency: " << effHLT_afterIso << " +/- " << err_effHLT_afterIso << endl;
00610 cout << "eff StandAlone (after Isocut) : " << effSta_afterIso << "+/-" << err_effsta_afterIso << endl;
00611 cout << "eff Tracker (after Isocut) : " << effTrk_afterIso << "+/-" << err_efftrk_afterIso << endl;
00612
00613 }
00614
00615 #include "FWCore/Framework/interface/MakerMacros.h"
00616
00617 DEFINE_FWK_MODULE(ZMuMu_MCanalyzer);
00618