00001 #include "DQM/Physics/src/EwkMuDQM.h"
00002
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 #include "DataFormats/Common/interface/Handle.h"
00006
00007 #include "FWCore/ServiceRegistry/interface/Service.h"
00008 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00009
00010 #include "DQMServices/Core/interface/DQMStore.h"
00011 #include "DQMServices/Core/interface/MonitorElement.h"
00012
00013 #include "DataFormats/TrackReco/interface/Track.h"
00014 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00015 #include "DataFormats/VertexReco/interface/Vertex.h"
00016
00017 #include "DataFormats/MuonReco/interface/Muon.h"
00018 #include "DataFormats/MuonReco/interface/MuonSelectors.h"
00019 #include "DataFormats/METReco/interface/MET.h"
00020 #include "DataFormats/JetReco/interface/Jet.h"
00021 #include "DataFormats/EgammaCandidates/interface/Photon.h"
00022
00023 #include "DataFormats/GeometryVector/interface/Phi.h"
00024
00025 #include "FWCore/Common/interface/TriggerNames.h"
00026 #include "FWCore/Framework/interface/Event.h"
00027 #include "DataFormats/Common/interface/TriggerResults.h"
00028
00029 #include "DataFormats/Common/interface/View.h"
00030
00031 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
00032
00033 using namespace edm;
00034 using namespace std;
00035 using namespace reco;
00036
00037 EwkMuDQM::EwkMuDQM( const ParameterSet & cfg ) :
00038
00039 trigTag_ (cfg.getUntrackedParameter<edm::InputTag> ("TrigTag", edm::InputTag("TriggerResults::HLT"))),
00040 muonTag_ (cfg.getUntrackedParameter<edm::InputTag> ("MuonTag", edm::InputTag("muons"))),
00041 metTag_ (cfg.getUntrackedParameter<edm::InputTag> ("METTag", edm::InputTag("pfmet"))),
00042 jetTag_ (cfg.getUntrackedParameter<edm::InputTag> ("JetTag", edm::InputTag("ak5PFJets"))),
00043 phoTag_ (cfg.getUntrackedParameter<edm::InputTag> ("phoTag", edm::InputTag("photons"))),
00044 pfPhoTag_ (cfg.getUntrackedParameter<edm::InputTag> ("pfPhoTag", edm::InputTag("pfPhotonTranslator","pfPhot"))),
00045 vertexTag_ (cfg.getUntrackedParameter<edm::InputTag> ("VertexTag", edm::InputTag("offlinePrimaryVertices"))),
00046 trigPathNames_(cfg.getUntrackedParameter<std::vector <std::string> >("TrigPathNames")),
00047
00048
00049 isAlsoTrackerMuon_(cfg.getUntrackedParameter<bool>("IsAlsoTrackerMuon", true)),
00050 dxyCut_ (cfg.getUntrackedParameter<double>("DxyCut", 0.2)),
00051 normalizedChi2Cut_(cfg.getUntrackedParameter<double>("NormalizedChi2Cut", 10.)),
00052 trackerHitsCut_ (cfg.getUntrackedParameter<int>("TrackerHitsCut", 11)),
00053 pixelHitsCut_ (cfg.getUntrackedParameter<int>("PixelHitsCut", 1)),
00054 muonHitsCut_ (cfg.getUntrackedParameter<int>("MuonHitsCut", 1)),
00055 nMatchesCut_ (cfg.getUntrackedParameter<int>("NMatchesCut", 2)),
00056
00057
00058 isRelativeIso_(cfg.getUntrackedParameter<bool>("IsRelativeIso", true)),
00059 isCombinedIso_(cfg.getUntrackedParameter<bool>("IsCombinedIso", false)),
00060 isoCut03_ (cfg.getUntrackedParameter<double>("IsoCut03", 0.1)),
00061 acopCut_ (cfg.getUntrackedParameter<double>("AcopCut", 999.)),
00062 metMin_ (cfg.getUntrackedParameter<double>("MetMin", -999999.)),
00063 metMax_ (cfg.getUntrackedParameter<double>("MetMax", 999999.)),
00064 mtMin_ (cfg.getUntrackedParameter<double>("MtMin", 50.)),
00065 mtMax_ (cfg.getUntrackedParameter<double>("MtMax", 200.)),
00066 ptCut_ (cfg.getUntrackedParameter<double>("PtCut", 20.)),
00067 etaCut_ (cfg.getUntrackedParameter<double>("EtaCut", 2.4)),
00068
00069
00070 ptThrForZ1_ (cfg.getUntrackedParameter<double>("PtThrForZ1", 20.)),
00071 ptThrForZ2_ (cfg.getUntrackedParameter<double>("PtThrForZ2", 10.)),
00072
00073
00074 dimuonMassMin_(cfg.getUntrackedParameter<double>("dimuonMassMin", 80.)),
00075 dimuonMassMax_(cfg.getUntrackedParameter<double>("dimuonMassMax", 120.)),
00076
00077
00078 eJetMin_ (cfg.getUntrackedParameter<double>("EJetMin", 999999.)),
00079 nJetMax_ (cfg.getUntrackedParameter<int>("NJetMax", 999999)),
00080
00081
00082 ptThrForPhoton_(cfg.getUntrackedParameter<double>("ptThrForPhoton",5.)),
00083 nPhoMax_(cfg.getUntrackedParameter<int>("nPhoMax", 999999))
00084 {
00085 isValidHltConfig_ = false;
00086
00087 theDbe = Service<DQMStore>().operator->();
00088 theDbe->setCurrentFolder("Physics/EwkMuDQM");
00089 init_histograms();
00090
00091 }
00092
00093 void EwkMuDQM::beginRun(const Run& iRun, const EventSetup& iSet) {
00094 nall = 0;
00095 nsel = 0;
00096 nz = 0;
00097
00098 nrec = 0;
00099 niso = 0;
00100 nhlt = 0;
00101 nmet = 0;
00102
00103
00104 bool isConfigChanged = false;
00105
00106 isValidHltConfig_ = hltConfigProvider_.init( iRun, iSet, "HLT", isConfigChanged );
00107
00108 }
00109
00110 void EwkMuDQM::beginJob() {
00111
00112 }
00113
00114 void EwkMuDQM::init_histograms() {
00115
00116 char chtitle[256] = "";
00117
00118 pt_before_ = theDbe->book1D("PT_BEFORECUTS","Muon transverse momentum (global muon) [GeV]",100,0.,100.);
00119 pt_after_ = theDbe->book1D("PT_AFTERWCUTS","Muon transverse momentum (global muon) [GeV]",100,0.,100.);
00120
00121 eta_before_ = theDbe->book1D("ETA_BEFORECUTS","Muon pseudo-rapidity",50,-2.5,2.5);
00122 eta_after_ = theDbe->book1D("ETA_AFTERWCUTS","Muon pseudo-rapidity",50,-2.5,2.5);
00123
00124 dxy_before_ = theDbe->book1D("DXY_BEFORECUTS","Muon transverse distance to beam spot [cm]",1000,-0.5,0.5);
00125 dxy_after_ = theDbe->book1D("DXY_AFTERWCUTS","Muon transverse distance to beam spot [cm]",1000,-0.5,0.5);
00126
00127 goodewkmuon_before_ = theDbe->book1D("GOODEWKMUON_BEFORECUTS","Quality-muon flag",2,-0.5,1.5);
00128 goodewkmuon_after_ = theDbe->book1D("GOODEWKMUON_AFTERWCUTS","Quality-muon flag",2,-0.5,1.5);
00129
00130 if (isRelativeIso_) {
00131 if (isCombinedIso_) {
00132 iso_before_ = theDbe->book1D("ISO_BEFORECUTS","Relative (combined) isolation variable",100, 0., 1.);
00133 iso_after_ = theDbe->book1D("ISO_AFTERWCUTS","Relative (combined) isolation variable",100, 0., 1.);
00134 } else {
00135 iso_before_ = theDbe->book1D("ISO_BEFORECUTS","Relative (tracker) isolation variable",100, 0., 1.);
00136 iso_after_ = theDbe->book1D("ISO_AFTERWCUTS","Relative (tracker) isolation variable",100, 0., 1.);
00137 }
00138 } else {
00139 if (isCombinedIso_) {
00140 iso_before_ = theDbe->book1D("ISO_BEFORECUTS","Absolute (combined) isolation variable [GeV]",100, 0., 20.);
00141 iso_after_ = theDbe->book1D("ISO_AFTERWCUTS","Absolute (combined) isolation variable [GeV]",100, 0., 20.);
00142 } else {
00143 iso_before_ = theDbe->book1D("ISO_BEFORECUTS","Absolute (tracker) isolation variable [GeV]",100, 0., 20.);
00144 iso_after_ = theDbe->book1D("ISO_AFTERWCUTS","Absolute (tracker) isolation variable [GeV]",100, 0., 20.);
00145 }
00146 }
00147
00148 trig_before_ = theDbe->book1D("TRIG_BEFORECUTS","Trigger response (boolean of muon triggers)",2,-0.5,1.5);
00149 trig_after_ = theDbe->book1D("TRIG_AFTERWCUTS","Trigger response (boolean of muon triggers)",2,-0.5,1.5);
00150
00151 snprintf(chtitle, 255, "Transverse mass (%s) [GeV]", metTag_.label().data());
00152 mt_before_ = theDbe->book1D("MT_BEFORECUTS",chtitle,150,0.,300.);
00153 mt_after_ = theDbe->book1D("MT_AFTERWCUTS",chtitle,150,0.,300.);
00154
00155 snprintf(chtitle, 255, "Missing transverse energy (%s) [GeV]", metTag_.label().data());
00156 met_before_ = theDbe->book1D("MET_BEFORECUTS",chtitle,100,0.,200.);
00157 met_after_ = theDbe->book1D("MET_AFTERWCUTS",chtitle,100,0.,200.);
00158 met_afterZ_ = theDbe->book1D("MET_AFTERZCUTS",chtitle,100,0.,200.);
00159
00160 snprintf(chtitle, 255, "MU-MET (%s) acoplanarity", metTag_.label().data());
00161 acop_before_ = theDbe->book1D("ACOP_BEFORECUTS",chtitle,50,0.,M_PI);
00162 acop_after_ = theDbe->book1D("ACOP_AFTERWCUTS",chtitle,50,0.,M_PI);
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 snprintf(chtitle, 255, "Number of jets (%s) above %.2f GeV", jetTag_.label().data(), eJetMin_);
00175 njets_before_ = theDbe->book1D("NJETS_BEFORECUTS",chtitle,16,-0.5,15.5);
00176 njets_after_ = theDbe->book1D("NJETS_AFTERWCUTS",chtitle,16,-0.5,15.5);
00177 njets_afterZ_ = theDbe->book1D("NJETS_AFTERZCUTS",chtitle,16,-0.5,15.5);
00178
00179 leadingjet_pt_before_ = theDbe->book1D("LEADINGJET_PT_BEFORECUTS","Leading Jet transverse momentum",300,0.,300.);
00180 leadingjet_pt_after_ = theDbe->book1D("LEADINGJET_PT_AFTERWCUTS","Leading Jet transverse momentum",300,0.,300.);
00181 leadingjet_pt_afterZ_ = theDbe->book1D("LEADINGJET_PT_AFTERZCUTS","Leading Jet transverse momentum",300,0.,300.);
00182
00183 leadingjet_eta_before_ = theDbe->book1D("LEADINGJET_ETA_BEFORECUTS","Leading Jet pseudo-rapidity",50,-2.5,2.5);
00184 leadingjet_eta_after_ = theDbe->book1D("LEADINGJET_ETA_AFTERWCUTS","Leading Jet pseudo-rapidity",50,-2.5,2.5);
00185 leadingjet_eta_afterZ_ = theDbe->book1D("LEADINGJET_ETA_AFTERZCUTS","Leading Jet pseudo-rapidity",50,-2.5,2.5);
00186
00187
00190 pt1_afterZ_ = theDbe->book1D("PT1_AFTERZCUTS","Muon transverse momentum (global muon) [GeV]",100,0.,100.);
00191 eta1_afterZ_ = theDbe->book1D("ETA1_AFTERZCUTS","Muon pseudo-rapidity",50,-2.5,2.5);
00192 dxy1_afterZ_ = theDbe->book1D("DXY1_AFTERZCUTS","Muon transverse distance to beam spot [cm]",1000,-0.5,0.5);
00193 goodewkmuon1_afterZ_ = theDbe->book1D("GOODEWKMUON1_AFTERZCUTS","Quality-muon flag",2,-0.5,1.5);
00194
00195 if (isRelativeIso_) {
00196 if (isCombinedIso_) {
00197 iso1_afterZ_ = theDbe->book1D("ISO1_AFTERZCUTS","Relative (combined) isolation variable",100, 0., 1.);
00198 iso2_afterZ_ = theDbe->book1D("ISO2_AFTERZCUTS","Relative (combined) isolation variable",100, 0., 1.);
00199 } else {
00200 iso1_afterZ_ = theDbe->book1D("ISO1_AFTERZCUTS","Relative (tracker) isolation variable",100, 0., 1.);
00201 iso2_afterZ_ = theDbe->book1D("ISO2_AFTERZCUTS","Relative (tracker) isolation variable",100, 0., 1.);
00202 }
00203 } else {
00204 if (isCombinedIso_) {
00205 iso1_afterZ_ = theDbe->book1D("ISO1_AFTERZCUTS","Absolute (combined) isolation variable [GeV]",100, 0., 20.);
00206 iso2_afterZ_ = theDbe->book1D("ISO2_AFTERZCUTS","Absolute (combined) isolation variable [GeV]",100, 0., 20.);
00207 } else {
00208 iso1_afterZ_ = theDbe->book1D("ISO1_AFTERZCUTS","Absolute (tracker) isolation variable [GeV]",100, 0., 20.);
00209 iso2_afterZ_ = theDbe->book1D("ISO2_AFTERZCUTS","Absolute (tracker) isolation variable [GeV]",100, 0., 20.);
00210 }
00211 }
00212
00213 pt2_afterZ_ = theDbe->book1D("PT2_AFTERZCUTS","Muon transverse momentum (global muon) [GeV]",100,0.,100.);
00214 eta2_afterZ_ = theDbe->book1D("ETA2_AFTERZCUTS","Muon pseudo-rapidity",50,-2.5,2.5);
00215 dxy2_afterZ_ = theDbe->book1D("DXY2_AFTERZCUTS","Muon transverse distance to beam spot [cm]",1000,-0.5,0.5);
00216 goodewkmuon2_afterZ_ = theDbe->book1D("GOODEWKMUON2_AFTERZCUTS","Quality-muon flag",2,-0.5,1.5);
00217 ztrig_afterZ_ = theDbe->book1D("ZTRIG_AFTERZCUTS","Trigger response (boolean of muon triggers)",2,-0.5,1.5);
00218 dimuonmass_before_= theDbe->book1D("DIMUONMASS_BEFORECUTS","DiMuonMass (2 globals)",100,0,200);
00219 dimuonmass_afterZ_= theDbe->book1D("DIMUONMASS_AFTERZCUTS","DiMuonMass (2 globals)",100,0,200);
00220 npvs_before_ = theDbe->book1D("NPVs_BEFORECUTS","Number of Valid Primary Vertices",51,-0.5,50.5);
00221 npvs_after_ = theDbe->book1D("NPVs_AFTERWCUTS","Number of Valid Primary Vertices",51,-0.5,50.5);
00222 npvs_afterZ_ = theDbe->book1D("NPVs_AFTERZCUTS","Number of Valid Primary Vertices",51,-0.5,50.5);
00223 muoncharge_before_ = theDbe->book1D("MUONCHARGE_BEFORECUTS","Muon Charge",3,-1.5,1.5);
00224 muoncharge_after_ = theDbe->book1D("MUONCHARGE_AFTERWCUTS","Muon Charge",3,-1.5,1.5);
00225 muoncharge_afterZ_ = theDbe->book1D("MUONCHARGE_AFTERZCUTS","Muon Charge",3,-1.5,1.5);
00226
00227
00228 nmuons_ = theDbe->book1D("NMuons","Number of muons in the event",10,-0.5,9.5);
00229 ngoodmuons_ = theDbe->book1D("NGoodMuons","Number of muons passing the quality criteria",10,-0.5,9.5);
00230
00231 nph_ = theDbe->book1D("nph","Number of photons in the event",20,0.,20.);
00232
00233 phPt_ = theDbe->book1D("phPt","Photon transverse momentum [GeV]",1000,0.,1000.);
00234
00235 snprintf(chtitle, 255, "Photon pseudorapidity (pT>%4.1f)",ptThrForPhoton_);
00236 phEta_ = theDbe->book1D("phEta",chtitle,100,-2.5,2.5);
00237
00238
00239 }
00240
00241
00242 void EwkMuDQM::endJob() {
00243 }
00244
00245 void EwkMuDQM::endRun(const Run& r, const EventSetup& iSet) {
00246
00247 }
00248
00249 void EwkMuDQM::analyze (const Event & ev, const EventSetup & iSet) {
00250
00251
00252 Handle<View<Muon> > muonCollection;
00253 if (!ev.getByLabel(muonTag_, muonCollection)) {
00254
00255 return;
00256 }
00257 unsigned int muonCollectionSize = muonCollection->size();
00258
00259
00260 Handle<reco::BeamSpot> beamSpotHandle;
00261 if (!ev.getByLabel(InputTag("offlineBeamSpot"), beamSpotHandle)) {
00262
00263 return;
00264 }
00265
00266
00267
00268 unsigned int nmuonsForZ1 = 0;
00269 unsigned int nmuonsForZ2 = 0;
00270 bool cosmic = false;
00271 for (unsigned int i=0; i<muonCollectionSize; i++) {
00272 const Muon& mu = muonCollection->at(i);
00273 if (!mu.isGlobalMuon()) continue;
00274 double pt = mu.pt();
00275 double dxy = mu.innerTrack()->dxy(beamSpotHandle->position());
00276
00277 if (fabs(dxy)>1) { cosmic=true; break;}
00278
00279 if (pt>ptThrForZ1_) nmuonsForZ1++;
00280 if (pt>ptThrForZ2_) nmuonsForZ2++;
00281
00282 for (unsigned int j=i+1; j<muonCollectionSize; j++) {
00283 const Muon& mu2 = muonCollection->at(j);
00284 if (mu2.isGlobalMuon() && (mu.charge()*mu2.charge()==-1) ){
00285 const math::XYZTLorentzVector ZRecoGlb (mu.px()+mu2.px(), mu.py()+mu2.py() , mu.pz()+mu2.pz(), mu.p()+mu2.p());
00286 dimuonmass_before_->Fill(ZRecoGlb.mass());
00287 }
00288 }
00289 }
00290 if(cosmic) return;
00291
00292 LogTrace("") << "> Z rejection: muons above " << ptThrForZ1_ << " [GeV]: " << nmuonsForZ1;
00293 LogTrace("") << "> Z rejection: muons above " << ptThrForZ2_ << " [GeV]: " << nmuonsForZ2;
00294
00295
00296
00297
00298
00299 Handle<View<MET> > metCollection;
00300 if (!ev.getByLabel(metTag_, metCollection)) {
00301
00302 return;
00303 }
00304 const MET& met = metCollection->at(0);
00305 double met_et = met.pt();
00306 LogTrace("") << ">>> MET, MET_px, MET_py: " << met_et << ", " << met.px() << ", " << met.py() << " [GeV]";
00307 met_before_->Fill(met_et);
00308
00309
00310 Handle<View<reco::Vertex> > vertexCollection;
00311 if (!ev.getByLabel(vertexTag_, vertexCollection)) {
00312 LogError("") << ">>> Vertex collection does not exist !!!";
00313 return;
00314 }
00315 unsigned int vertexCollectionSize = vertexCollection->size();
00316
00317
00318
00319 int nvvertex = 0;
00320 for (unsigned int i=0; i<vertexCollectionSize; i++) {
00321 const Vertex& vertex = vertexCollection->at(i);
00322 if (vertex.isValid()) nvvertex++;
00323 }
00324
00325 npvs_before_->Fill(nvvertex);
00326
00327 bool trigger_fired = false;
00328 Handle<TriggerResults> triggerResults;
00329 if (!ev.getByLabel(trigTag_, triggerResults)) {
00330
00331 return;
00332 }
00333 const edm::TriggerNames & trigNames = ev.triggerNames(*triggerResults);
00334
00335
00336
00337 for (unsigned int i=0; i<triggerResults->size(); i++)
00338 {
00339 const std::string trigName = trigNames.triggerName(i);
00340
00341 bool found=false;
00342 for(unsigned int index=0; index<trigPathNames_.size() && found==false; index++) {
00343 size_t trigPath = trigName.find(trigPathNames_[index]);
00344 if (trigPath==0) found=true;
00345 }
00346 if(!found) {continue;}
00347
00348 bool prescaled=false;
00349 for (unsigned int ps= 0; ps< hltConfigProvider_.prescaleSize(); ps++){
00350 const unsigned int prescaleValue = hltConfigProvider_.prescaleValue(ps, trigName) ;
00351 if (prescaleValue != 1) prescaled =true;
00352 }
00353
00354 if( triggerResults->accept(i) && !prescaled){ trigger_fired=true;}
00355
00356 }
00357 trig_before_->Fill(trigger_fired);
00358
00359
00360 Handle<View<Jet> > jetCollection;
00361 if (!ev.getByLabel(jetTag_, jetCollection)) {
00362
00363 return;
00364 }
00365 unsigned int jetCollectionSize = jetCollection->size();
00366 int njets = 0; int LEADJET=-1; double max_pt=0;
00367 for (unsigned int i=0; i<jetCollectionSize; i++) {
00368 const Jet& jet = jetCollection->at(i);
00369 double minDistance=99999;
00370 for (unsigned int j=0; j<muonCollectionSize; j++) {
00371 const Muon& mu = muonCollection->at(j);
00372 double distance = sqrt( (mu.eta()-jet.eta())*(mu.eta()-jet.eta()) +(mu.phi()-jet.phi())*(mu.phi()-jet.phi()) );
00373 if (minDistance>distance) minDistance=distance;
00374 }
00375 if (minDistance<0.3) continue;
00376 if(jet.et()>max_pt) { LEADJET=i; max_pt=jet.et();}
00377 if (jet.et()>eJetMin_) {njets++;}
00378 }
00379
00380
00381 LogTrace("") << ">>> Total number of jets: " << jetCollectionSize;
00382 LogTrace("") << ">>> Number of jets above " << eJetMin_ << " [GeV]: " << njets;
00383 njets_before_->Fill(njets);
00384 double lead_jet_pt=-1;
00385 double lead_jet_eta=-100;
00386 if(LEADJET!=-1){
00387 const Jet& leadJet = jetCollection->at(LEADJET);
00388 leadingjet_pt_before_->Fill(leadJet.pt());
00389 leadingjet_eta_before_->Fill(leadJet.eta());
00390 lead_jet_pt=leadJet.pt();
00391 lead_jet_eta=leadJet.eta();
00392 }
00393
00394 Handle<View<Photon> > photonCollection;
00395 if(!ev.getByLabel(phoTag_,photonCollection)){
00396
00397 return;
00398 }
00399 unsigned int ngam=0;
00400
00401 for (unsigned int i=0; i<photonCollection->size(); i++){
00402 const Photon &ph = photonCollection->at(i);
00403 double photonPt = ph.pt();
00404 if (photonPt> ptThrForPhoton_) {
00405 ngam++;
00406 phEta_->Fill(ph.eta());
00407 }
00408 phPt_->Fill(photonPt);
00409 }
00410 nph_->Fill(ngam);
00411 LogTrace("") << " >>> N photons " << ngam << std::endl;
00412
00413 nmuons_->Fill(muonCollectionSize);
00414
00416
00418
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434 nall++;
00435
00436
00437 bool hlt_hist_done = false;
00438 bool zhlt_hist_done = false;
00439 bool zjets_hist_done = false;
00440 bool zfullsel_hist_done = false;
00441 bool met_hist_done = false;
00442
00443
00444 bool njets_hist_done = false;
00445 bool wfullsel_hist_done = false;
00446
00447
00448 const int NFLAGS = 11;
00449 bool muon_sel[NFLAGS];
00450 const int NFLAGSZ = 13;
00451 bool zmuon_sel[NFLAGSZ];
00452 bool muon4Z=false;
00453
00454 double number_of_muons=0;
00455 double number_of_goodMuons=0;
00456
00457
00458 for (unsigned int i=0; i<muonCollectionSize; i++) {
00459 for (int j=0; j<NFLAGS; ++j) {
00460 muon_sel[j] = false;
00461 }
00462
00463 number_of_muons++;
00464
00465 const Muon& mu = muonCollection->at(i);
00466 if (!mu.isGlobalMuon()) continue;
00467 if (mu.globalTrack().isNull()) continue;
00468 if (mu.innerTrack().isNull()) continue;
00469
00470 LogTrace("") << "> Wsel: processing muon number " << i << "...";
00471 reco::TrackRef gm = mu.globalTrack();
00472 reco::TrackRef tk = mu.innerTrack();
00473
00474
00475 double pt = mu.pt();
00476 double eta = mu.eta();
00477 LogTrace("") << "\t... pt, eta: " << pt << " [GeV], " << eta;;
00478 if (pt>ptCut_) muon_sel[0] = true;
00479 if (fabs(eta)<etaCut_) muon_sel[1] = true;
00480
00481 double charge=mu.charge();
00482
00483
00484 double dxy = gm->dxy(beamSpotHandle->position());
00485 double normalizedChi2 = gm->normalizedChi2();
00486 double trackerHits = tk->hitPattern().numberOfValidTrackerHits();
00487 int pixelHits = tk->hitPattern().numberOfValidPixelHits();
00488 int muonHits = gm->hitPattern().numberOfValidMuonHits();
00489 int nMatches = mu.numberOfMatches();
00490
00491 LogTrace("") << "\t... dxy, normalizedChi2, trackerHits, isTrackerMuon?: " << dxy << " [cm], " << normalizedChi2 << ", " << trackerHits << ", " << mu.isTrackerMuon();
00492 if (fabs(dxy)<dxyCut_) muon_sel[2] = true;
00493
00494 bool quality=true;
00495
00496 if (normalizedChi2>normalizedChi2Cut_) quality =false;
00497 if (trackerHits<trackerHitsCut_) quality =false;
00498 if (pixelHits<pixelHitsCut_) quality =false;
00499 if (muonHits<muonHitsCut_) quality=false;;
00500 if (!mu.isTrackerMuon()) quality=false;
00501 if (nMatches<nMatchesCut_) quality=false;
00502 muon_sel[3]=quality;
00503 if(quality) number_of_goodMuons++;
00504
00505 pt_before_->Fill(pt);
00506 eta_before_->Fill(eta);
00507 dxy_before_->Fill(dxy);
00508 muoncharge_before_->Fill(charge);
00509 goodewkmuon_before_->Fill(quality);
00510
00511
00512 double isovar = mu.isolationR03().sumPt;
00513 if (isCombinedIso_) {
00514 isovar += mu.isolationR03().emEt;
00515 isovar += mu.isolationR03().hadEt;
00516 }
00517 if (isRelativeIso_) isovar /= pt;
00518 if (isovar<isoCut03_) muon_sel[4] = true;
00519
00520 LogTrace("") << "\t... isolation value" << isovar <<", isolated? " << muon_sel[6];
00521 iso_before_->Fill(isovar);
00522
00523
00524
00525 if (trigger_fired) muon_sel[5] = true;
00526
00527
00528 if (pt>ptThrForZ1_ && fabs(eta)<etaCut_ && fabs(dxy)<dxyCut_ && quality && trigger_fired && isovar<isoCut03_) { muon4Z = true;}
00529
00530
00531
00532 double w_et = met_et+mu.pt();
00533 double w_px = met.px()+mu.px();
00534 double w_py = met.py()+mu.py();
00535
00536 double massT = w_et*w_et - w_px*w_px - w_py*w_py;
00537 massT = (massT>0) ? sqrt(massT) : 0;
00538
00539 LogTrace("") << "\t... W mass, W_et, W_px, W_py: " << massT << ", " << w_et << ", " << w_px << ", " << w_py << " [GeV]";
00540 if (massT>mtMin_ && massT<mtMax_) muon_sel[6] = true;
00541 mt_before_->Fill(massT);
00542 if (met_et>metMin_ && met_et<metMax_) muon_sel[7] = true;
00543
00544
00545 Geom::Phi<double> deltaphi(mu.phi()-atan2(met.py(),met.px()));
00546 double acop = deltaphi.value();
00547 if (acop<0) acop = - acop;
00548 acop = M_PI - acop;
00549 LogTrace("") << "\t... acoplanarity: " << acop;
00550 if (acop<acopCut_) muon_sel[8] = true;
00551 acop_before_->Fill(acop);
00552
00553
00554 if (nmuonsForZ1<1 || nmuonsForZ2<2) muon_sel[9] = true;
00555 if (njets<=nJetMax_) muon_sel[10] = true;
00556
00557
00558 int flags_passed = 0;
00559 for (int j=0; j<NFLAGS; ++j) {
00560 if (muon_sel[j]) flags_passed += 1;
00561 }
00562
00563
00564 if (flags_passed >= (NFLAGS-1)) {
00565 if (!muon_sel[0] || flags_passed==NFLAGS)
00566 pt_after_->Fill(pt);
00567 if (!muon_sel[1] || flags_passed==NFLAGS)
00568 eta_after_->Fill(eta);
00569 if (!muon_sel[2] || flags_passed==NFLAGS)
00570 dxy_after_->Fill(dxy);
00571 if (!muon_sel[3] || flags_passed==NFLAGS)
00572 goodewkmuon_after_->Fill(quality);
00573 if (!muon_sel[4] || flags_passed==NFLAGS)
00574 iso_after_->Fill(isovar);
00575 if (!muon_sel[5] || flags_passed==NFLAGS)
00576 if (!hlt_hist_done) trig_after_->Fill(trigger_fired);
00577 hlt_hist_done = true;
00578 if (!muon_sel[6] || flags_passed==NFLAGS)
00579 mt_after_->Fill(massT);
00580 if (!muon_sel[7] || flags_passed==NFLAGS)
00581 if (!met_hist_done) met_after_->Fill(met_et);
00582 met_hist_done = true;
00583 if (!muon_sel[8] || flags_passed==NFLAGS)
00584 acop_after_->Fill(acop);
00585
00586
00587
00588
00589
00590
00591
00592
00593 if (!muon_sel[10] || flags_passed==NFLAGS) {
00594 if (!njets_hist_done) {
00595 njets_after_->Fill(njets);
00596 leadingjet_pt_after_->Fill(lead_jet_pt);
00597 leadingjet_eta_after_->Fill(lead_jet_eta);
00598 }
00599 njets_hist_done = true;
00600 if( flags_passed==NFLAGS ) {
00601 if (!wfullsel_hist_done){
00602 npvs_after_->Fill(nvvertex);
00603 muoncharge_after_->Fill(charge);
00604 }
00605 wfullsel_hist_done=true;
00606 }
00607
00608 }
00609
00610
00611
00612 if ( muon4Z && !muon_sel[9]){
00613
00614
00615 for (unsigned int j=i+1; j<muonCollectionSize; j++) {
00616
00617 for (int ij=0; ij<NFLAGSZ; ++ij) {
00618 zmuon_sel[ij] = false;
00619 }
00620
00621 for (int ji=0; ji<5; ++ji ) {
00622 zmuon_sel[ji] = muon_sel[ji];
00623 }
00624
00625 const Muon& mu2 = muonCollection->at(j);
00626 if (!mu2.isGlobalMuon()) continue;
00627 if (mu2.charge() * charge != -1 ) continue;
00628 reco::TrackRef gm2 = mu2.globalTrack();
00629 reco::TrackRef tk2 = mu2.innerTrack();
00630 double pt2 = mu2.pt(); if (pt2>ptThrForZ1_) zmuon_sel[5] = true;
00631 double eta2=mu2.eta(); if (fabs(eta2)<etaCut_) zmuon_sel[6] = true;
00632 double dxy2 = gm2->dxy(beamSpotHandle->position()); if (fabs(dxy2)<dxyCut_) zmuon_sel[7] = true;
00633 double normalizedChi22 = gm2->normalizedChi2();
00634 double trackerHits2 = tk2->hitPattern().numberOfValidTrackerHits();
00635 int pixelHits2 = tk2->hitPattern().numberOfValidPixelHits();
00636 int muonHits2 = gm2->hitPattern().numberOfValidMuonHits();
00637 int nMatches2 = mu2.numberOfMatches();
00638 bool quality2=true;
00639 if (normalizedChi22>normalizedChi2Cut_) quality2 = false;
00640 if (trackerHits2<trackerHitsCut_) quality2 = false;
00641 if (pixelHits2<pixelHitsCut_) quality2 = false;
00642 if (muonHits2<muonHitsCut_) quality2 = false;
00643 if (!mu2.isTrackerMuon()) quality2 = false;
00644 if (nMatches2<nMatchesCut_) quality2 = false;
00645 zmuon_sel[8]=quality2;
00646 double isovar2 = mu2.isolationR03().sumPt;
00647 if (isCombinedIso_) {
00648 isovar2 += mu2.isolationR03().emEt;
00649 isovar2 += mu2.isolationR03().hadEt;
00650 }
00651 if (isRelativeIso_) isovar2 /= pt2;
00652 if (isovar2<isoCut03_) zmuon_sel[9] = true;
00653 if (trigger_fired) zmuon_sel[10] = true;
00654 const math::XYZTLorentzVector ZRecoGlb (mu.px()+mu2.px(), mu.py()+mu2.py() , mu.pz()+mu2.pz(), mu.p()+mu2.p());
00655 if (ZRecoGlb.mass()>dimuonMassMin_ && ZRecoGlb.mass()<dimuonMassMax_) zmuon_sel[11] = true;
00656
00657
00658 if (njets <=nJetMax_) zmuon_sel[12] = true;
00659
00660
00661 int flags_passed_z = 0;
00662
00663 for (int jj=0; jj<NFLAGSZ; ++jj) {
00664 if (zmuon_sel[jj]) ++flags_passed_z ;
00665 }
00666
00667 if (flags_passed_z >= (NFLAGSZ-1)) {
00668 if (!zmuon_sel[0] || flags_passed_z==NFLAGSZ) {pt1_afterZ_->Fill(pt); }
00669 if (!zmuon_sel[1] || flags_passed_z==NFLAGSZ) {eta1_afterZ_->Fill(eta); }
00670 if (!zmuon_sel[2] || flags_passed_z==NFLAGSZ) {dxy1_afterZ_->Fill(dxy); }
00671 if (!zmuon_sel[3] || flags_passed_z==NFLAGSZ) {goodewkmuon1_afterZ_->Fill(quality); }
00672 if (!zmuon_sel[4] || flags_passed_z==NFLAGSZ) {iso1_afterZ_->Fill(isovar); }
00673 if (!zmuon_sel[5] || flags_passed_z==NFLAGSZ) { pt2_afterZ_->Fill(pt2); }
00674 if (!zmuon_sel[6] || flags_passed_z==NFLAGSZ) { eta2_afterZ_->Fill(eta2); }
00675 if (!zmuon_sel[7] || flags_passed_z==NFLAGSZ) {dxy2_afterZ_->Fill(dxy2); }
00676 if (!zmuon_sel[8] || flags_passed_z==NFLAGSZ) {goodewkmuon2_afterZ_->Fill(quality2); }
00677 if (!zmuon_sel[9] || flags_passed_z==NFLAGSZ) {iso2_afterZ_->Fill(isovar2); }
00678 if (!zmuon_sel[10] || flags_passed_z==NFLAGSZ) {
00679 if (!zhlt_hist_done) ztrig_afterZ_->Fill(trigger_fired);
00680 zhlt_hist_done = true;
00681 }
00682 if (!zmuon_sel[11] || flags_passed_z==NFLAGSZ) {dimuonmass_afterZ_->Fill(ZRecoGlb.mass()); }
00683 if (!zmuon_sel[12] || flags_passed_z==NFLAGSZ ){
00684 if(!zjets_hist_done){
00685 njets_afterZ_->Fill(njets);
00686 leadingjet_pt_afterZ_->Fill(lead_jet_pt);
00687 leadingjet_eta_afterZ_->Fill(lead_jet_eta);
00688 }
00689 zjets_hist_done=true;
00690 }
00691 if(flags_passed_z==NFLAGSZ) {met_afterZ_->Fill(met_et);
00692 if(!zfullsel_hist_done){
00693 npvs_afterZ_->Fill(nvvertex);
00694 muoncharge_afterZ_->Fill(charge);
00695 }
00696 zfullsel_hist_done=true;
00697 }
00698 }
00699
00700 }
00701
00702 }
00703 }
00704
00705 }
00706
00707
00708
00709 ngoodmuons_->Fill(number_of_goodMuons);
00710
00711 return;
00712
00713 }
00714