00001 #include "DQM/Physics/src/EwkElecDQM.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
00018 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00019
00020 #include "DataFormats/METReco/interface/MET.h"
00021 #include "DataFormats/JetReco/interface/Jet.h"
00022
00023
00024
00025
00026
00027 #include "DataFormats/GeometryVector/interface/Phi.h"
00028
00029 #include "FWCore/Common/interface/TriggerNames.h"
00030 #include "FWCore/Framework/interface/Event.h"
00031 #include "DataFormats/Common/interface/TriggerResults.h"
00032
00033 #include "DataFormats/Common/interface/View.h"
00034
00035 using namespace edm;
00036 using namespace std;
00037 using namespace reco;
00038
00039 EwkElecDQM::EwkElecDQM( const ParameterSet & cfg ) :
00040
00041 trigTag_(cfg.getUntrackedParameter<edm::InputTag> ("TrigTag", edm::InputTag("TriggerResults::HLT"))),
00042
00043 elecTag_(cfg.getUntrackedParameter<edm::InputTag> ("ElecTag", edm::InputTag("gsfElectrons"))),
00044 metTag_(cfg.getUntrackedParameter<edm::InputTag> ("METTag", edm::InputTag("met"))),
00045
00046 jetTag_(cfg.getUntrackedParameter<edm::InputTag> ("JetTag", edm::InputTag("sisCone5CaloJets"))),
00047 vertexTag_ (cfg.getUntrackedParameter<edm::InputTag> ("VertexTag", edm::InputTag("offlinePrimaryVertices"))),
00048
00049
00050
00051
00052 elecTrig_(cfg.getUntrackedParameter<std::vector< std::string > >("ElecTrig")),
00053
00054 ptCut_(cfg.getUntrackedParameter<double>("PtCut", 10.)),
00055
00056 etaCut_(cfg.getUntrackedParameter<double>("EtaCut", 2.4)),
00057 sieieCutBarrel_(cfg.getUntrackedParameter<double>("SieieBarrel", 0.01)),
00058 sieieCutEndcap_(cfg.getUntrackedParameter<double>("SieieEndcap", 0.028)),
00059 detainCutBarrel_(cfg.getUntrackedParameter<double>("DetainBarrel", 0.0071)),
00060 detainCutEndcap_(cfg.getUntrackedParameter<double>("DetainEndcap", 0.0066)),
00061
00062
00063
00064 ecalIsoCutBarrel_(cfg.getUntrackedParameter<double>("EcalIsoCutBarrel", 5.7)),
00065 ecalIsoCutEndcap_(cfg.getUntrackedParameter<double>("EcalIsoCutEndcap", 5.0)),
00066 hcalIsoCutBarrel_(cfg.getUntrackedParameter<double>("HcalIsoCutBarrel", 8.1)),
00067 hcalIsoCutEndcap_(cfg.getUntrackedParameter<double>("HcalIsoCutEndcap", 3.4)),
00068 trkIsoCutBarrel_(cfg.getUntrackedParameter<double>("TrkIsoCutBarrel", 7.2)),
00069 trkIsoCutEndcap_(cfg.getUntrackedParameter<double>("TrkIsoCutEndcap", 5.1)),
00070 mtMin_(cfg.getUntrackedParameter<double>("MtMin", -999999)),
00071 mtMax_(cfg.getUntrackedParameter<double>("MtMax", 999999.)),
00072 metMin_(cfg.getUntrackedParameter<double>("MetMin", -999999.)),
00073 metMax_(cfg.getUntrackedParameter<double>("MetMax", 999999.)),
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 eJetMin_(cfg.getUntrackedParameter<double>("EJetMin", 999999.)),
00088 nJetMax_(cfg.getUntrackedParameter<int>("NJetMax", 999999)),
00089 PUMax_(cfg.getUntrackedParameter<unsigned int>("PUMax", 60)),
00090 PUBinCount_(cfg.getUntrackedParameter<unsigned int>("PUBinCount", 12))
00091
00092
00093
00094
00095
00096 {
00097 isValidHltConfig_ = false;
00098
00099
00100 theDbe = Service<DQMStore>().operator->();
00101 theDbe->setCurrentFolder("Physics/EwkElecDQM");
00102 init_histograms();
00103
00104 }
00105
00106 void EwkElecDQM::beginRun(const Run& iRun, const EventSetup& iSet) {
00107 nall = 0;
00108 nsel = 0;
00109
00110 nrec = 0;
00111 neid = 0;
00112 niso = 0;
00113
00114
00115
00116
00117 bool isConfigChanged = false;
00118
00119 isValidHltConfig_ = hltConfigProvider_.init( iRun, iSet, "HLT", isConfigChanged );
00120
00121 LogTrace("") << "isValidHltConfig_=" << isValidHltConfig_ << "\n";
00122 }
00123
00124
00125 void EwkElecDQM::beginJob() {
00126
00127 }
00128
00129 void EwkElecDQM::init_histograms() {
00130
00131 char chtitle[256] = "";
00132 for (int i=0; i<2; ++i) {
00133
00134
00135
00136
00137 pt_before_ = theDbe->book1D("PT_BEFORECUTS","Electron transverse momentum [GeV]",100,0.,100.);
00138 pt_after_ = theDbe->book1D("PT_LASTCUT","Electron transverse momentum [GeV]",100,0.,100.);
00139
00140 eta_before_ = theDbe->book1D("ETA_BEFORECUTS","Electron pseudo-rapidity",50,-2.5,2.5);
00141 eta_after_ = theDbe->book1D("ETA_LASTCUT","Electron pseudo-rapidity",50,-2.5,2.5);
00142
00143 sieiebarrel_before_ = theDbe->book1D("SIEIEBARREL_BEFORECUTS","Electron #sigma_{i#etai#eta} (barrel)",70,0.,0.07);
00144 sieiebarrel_after_ = theDbe->book1D("SIEIEBARREL_LASTCUT","Electron #sigma_{i#etai#eta} (barrel)",70,0.,0.07);
00145
00146 sieieendcap_before_ = theDbe->book1D("SIEIEENDCAP_BEFORECUTS","Electron #sigma_{i#etai#eta} (endcap)",70,0.,0.07);
00147 sieieendcap_after_ = theDbe->book1D("SIEIEENDCAP_LASTCUT","Electron #sigma_{i#etai#eta} (endcap)",70,0.,0.07);
00148
00149 detainbarrel_before_ = theDbe->book1D("DETAINBARREL_BEFORECUTS","Electron #Delta#eta_{in} (barrel)",40,-0.02,0.02);
00150 detainbarrel_after_ = theDbe->book1D("DETAINBARREL_LASTCUT","Electron #Delta#eta_{in} (barrel)",40,-0.02,0.02);
00151
00152 detainendcap_before_ = theDbe->book1D("DETAINENDCAP_BEFORECUTS","Electron #Delta#eta_{in} (endcap)",40,-0.02,0.02);
00153 detainendcap_after_ = theDbe->book1D("DETAINENDCAP_LASTCUT","Electron #Delta#eta_{in} (endcap)",40,-0.02,0.02);
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187 ecalisobarrel_before_ = theDbe->book1D("ECALISOBARREL_BEFORECUTS","Absolute electron ECAL isolation variable (barrel) [GeV]",50,0.,50.);
00188 ecalisobarrel_after_ = theDbe->book1D("ECALISOBARREL_LASTCUT","Absolute electron ECAL isolation variable (barrel) [GeV]",50,0.,50.);
00189
00190 ecalisoendcap_before_ = theDbe->book1D("ECALISOENDCAP_BEFORECUTS","Absolute electron ECAL isolation variable (endcap) [GeV]",50,0.,50.);
00191 ecalisoendcap_after_ = theDbe->book1D("ECALISOENDCAP_LASTCUT","Absolute electron ECAL isolation variable (endcap) [GeV]",50,0.,50.);
00192
00193 hcalisobarrel_before_ = theDbe->book1D("HCALISOBARREL_BEFORECUTS","Absolute electron HCAL isolation variable (barrel) [GeV]",50,0.,50.);
00194 hcalisobarrel_after_ = theDbe->book1D("HCALISOBARREL_LASTCUT","Absolute electron HCAL isolation variable (barrel) [GeV]",50,0.,50.);
00195
00196 hcalisoendcap_before_ = theDbe->book1D("HCALISOENDCAP_BEFORECUTS","Absolute electron HCAL isolation variable (endcap) [GeV]",50,0.,50.);
00197 hcalisoendcap_after_ = theDbe->book1D("HCALISOENDCAP_LASTCUT","Absolute electron HCAL isolation variable (endcap) [GeV]",50,0.,50.);
00198
00199 trkisobarrel_before_ = theDbe->book1D("TRKISOBARREL_BEFORECUTS","Absolute electron track isolation variable (barrel) [GeV]",50,0.,50.);
00200 trkisobarrel_after_ = theDbe->book1D("TRKISOBARREL_LASTCUT","Absolute electron track isolation variable (barrel) [GeV]",50,0.,50.);
00201
00202 trkisoendcap_before_ = theDbe->book1D("TRKISOENDCAP_BEFORECUTS","Absolute electron track isolation variable (endcap) [GeV]",50,0.,50.);
00203 trkisoendcap_after_ = theDbe->book1D("TRKISOENDCAP_LASTCUT","Absolute electron track isolation variable (endcap) [GeV]",50,0.,50.);
00204
00205
00206
00207
00208
00209
00210 trig_before_ = theDbe->book1D("TRIG_BEFORECUTS","Trigger response",2,-0.5,1.5);
00211 trig_after_ = theDbe->book1D("TRIG_LASTCUT","Trigger response",2,-0.5,1.5);
00212
00213 invmass_before_ = theDbe->book1D("INVMASS_BEFORECUTS","Di-electron invariant mass [GeV]",100,0.,200.);
00214 invmass_after_ = theDbe->book1D("INVMASS_AFTERCUTS","Di-electron invariant mass [GeV]",100,0.,200.);
00215
00216 invmassPU_before_ = theDbe->book2D("INVMASS_PU_BEFORECUTS","Di-electron invariant mass [GeV] vs PU; mass [GeV]; PU count",100,0.,200., PUBinCount_, -0.5, PUMax_+0.5);
00217 invmassPU_afterZ_ = theDbe->book2D("INVMASS_PU_AFTERZCUTS","Di-electron invariant mass [GeV] vs PU; mass [GeV]; PU count",100,0.,200., PUBinCount_, -0.5, PUMax_+0.5);
00218
00219 npvs_before_ = theDbe->book1D("NPVs_BEFORECUTS","Number of Valid Primary Vertices; nGoodPVs",PUMax_+1,-0.5,PUMax_+0.5);
00220
00221 npvs_afterZ_ = theDbe->book1D("NPVs_AFTERZCUTS","Number of Valid Primary Vertices; nGoodPVs",PUMax_+1,-0.5,PUMax_+0.5);
00222
00223
00224 nelectrons_before_ = theDbe->book1D("NELECTRONS_BEFORECUTS","Number of electrons in event",10,-0.5,9.5);
00225 nelectrons_after_ = theDbe->book1D("NELECTRONS_AFTERCUTS","Number of electrons in event",10,-0.5,9.5);
00226
00227 snprintf(chtitle, 255, "Transverse mass (%s) [GeV]", metTag_.label().data());
00228 mt_before_ = theDbe->book1D("MT_BEFORECUTS",chtitle,150,0.,300.);
00229 mt_after_ = theDbe->book1D("MT_LASTCUT",chtitle,150,0.,300.);
00230
00231
00232
00233
00234
00235 snprintf(chtitle, 255, "Missing transverse energy (%s) [GeV]", metTag_.label().data());
00236 met_before_ = theDbe->book1D("MET_BEFORECUTS",chtitle,100,0.,200.);
00237 met_after_ = theDbe->book1D("MET_LASTCUT",chtitle,100,0.,200.);
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251 snprintf(chtitle, 255, "Number of jets (%s) above %.2f GeV", jetTag_.label().data(), eJetMin_);
00252 njets_before_ = theDbe->book1D("NJETS_BEFORECUTS",chtitle,10,-0.5,9.5);
00253 njets_after_ = theDbe->book1D("NJETS_LASTCUT",chtitle,10,-0.5,9.5);
00254
00255 snprintf(chtitle, 255, "Jet with highest E_{T} (%s)", jetTag_.label().data());
00256 jet_et_before_ = theDbe->book1D("JETET1_BEFORECUTS",chtitle, 20, 0., 200.0);
00257 jet_et_after_ = theDbe->book1D("JETET1_AFTERCUTS",chtitle, 20, 0., 200.0);
00258
00259 snprintf(chtitle, 255, "Eta of Jet with highest E_{T} (%s)", jetTag_.label().data());
00260 jet_eta_before_ = theDbe->book1D("JETETA1_BEFORECUTS",chtitle, 20, -5, 5);
00261 jet_eta_after_ = theDbe->book1D("JETETA1_AFTERCUTS",chtitle, 20, -5, 5);
00262
00263
00264
00265
00266
00267
00268
00269 }
00270 }
00271
00272
00273 void EwkElecDQM::endJob() {
00274 }
00275
00276 void EwkElecDQM::endRun(const Run& r, const EventSetup&) {
00277
00278
00279 double all = nall;
00280 double esel = nsel/all;
00281 LogVerbatim("") << "\n>>>>>> SELECTION SUMMARY BEGIN >>>>>>>>>>>>>>>";
00282 LogVerbatim("") << "Total number of events analyzed: " << nall << " [events]";
00283 LogVerbatim("") << "Total number of events selected: " << nsel << " [events]";
00284 LogVerbatim("") << "Overall efficiency: " << "(" << setprecision(4) << esel*100. <<" +/- "<< setprecision(2) << sqrt(esel*(1-esel)/all)*100. << ")%";
00285
00286 double erec = nrec/all;
00287 double eeid = neid/all;
00288 double eiso = niso/all;
00289
00290
00291
00292
00293 double num = nrec;
00294 double eff = erec;
00295 double err = sqrt(eff*(1-eff)/all);
00296 LogVerbatim("") << "Passing Pt/Eta/Quality cuts: " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%";
00297
00298
00299 num = neid;
00300 eff = eeid;
00301 err = sqrt(eff*(1-eff)/all);
00302 double effstep = 0.;
00303 double errstep = 0.;
00304 if (nrec>0) effstep = eeid/erec;
00305 if (nrec>0) errstep = sqrt(effstep*(1-effstep)/nrec);
00306 LogVerbatim("") << "Passing eID cuts: " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" << setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
00307
00308
00309 num = niso;
00310 eff = eiso;
00311 err = sqrt(eff*(1-eff)/all);
00312 effstep = 0.;
00313 errstep = 0.;
00314 if (neid>0) effstep = eiso/eeid;
00315 if (neid>0) errstep = sqrt(effstep*(1-effstep)/neid);
00316 LogVerbatim("") << "Passing isolation cuts: " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" << setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329 num = nsel;
00330 eff = esel;
00331 err = sqrt(eff*(1-eff)/all);
00332 effstep = 0.;
00333 errstep = 0.;
00334 if (niso>0) effstep = esel/eiso;
00335 if (niso>0) errstep = sqrt(effstep*(1-effstep)/niso);
00336 LogVerbatim("") << "Passing HLT criteria: " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" << setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358 LogVerbatim("") << ">>>>>> SELECTION SUMMARY END >>>>>>>>>>>>>>>\n";
00359 }
00360
00361 void EwkElecDQM::analyze (const Event & ev, const EventSetup &) {
00362
00363
00364 bool rec_sel = false;
00365 bool eid_sel = false;
00366 bool iso_sel = false;
00367
00368 bool all_sel = false;
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379 Handle<View<GsfElectron> > electronCollection;
00380 if (!ev.getByLabel(elecTag_, electronCollection)) {
00381
00382 return;
00383 }
00384 unsigned int electronCollectionSize = electronCollection->size();
00385
00386
00387 Handle<reco::BeamSpot> beamSpotHandle;
00388 if (!ev.getByLabel(InputTag("offlineBeamSpot"), beamSpotHandle)) {
00389
00390 return;
00391 }
00392
00393 double met_px = 0.;
00394 double met_py = 0.;
00395 Handle<View<MET> > metCollection;
00396 if (!ev.getByLabel(metTag_, metCollection)) {
00397
00398 return;
00399 }
00400 const MET& met = metCollection->at(0);
00401 met_px = met.px();
00402 met_py = met.py();
00403
00404
00405
00406
00407
00408
00409
00410
00411 double met_et = sqrt(met_px*met_px+met_py*met_py);
00412 LogTrace("") << ">>> MET, MET_px, MET_py: " << met_et << ", " << met_px << ", " << met_py << " [GeV]";
00413 met_before_->Fill(met_et);
00414
00415
00416
00417 int npvCount = 0;
00418 Handle<View<reco::Vertex> > vertexCollection;
00419 if (!ev.getByLabel(vertexTag_, vertexCollection)) {
00420 LogError("") << ">>> Vertex collection does not exist !!!";
00421 return;
00422 }
00423 for (unsigned int i=0; i<vertexCollection->size(); i++) {
00424 const Vertex& vertex = vertexCollection->at(i);
00425 if (vertex.isValid()) npvCount++;
00426 }
00427 npvs_before_->Fill(npvCount);
00428
00429
00430
00431 Handle<TriggerResults> triggerResults;
00432 if (!ev.getByLabel(trigTag_, triggerResults)) {
00433
00434 return;
00435 }
00436 const edm::TriggerNames & trigNames = ev.triggerNames(*triggerResults);
00437 bool trigger_fired = false;
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452 for (unsigned int i=0; i<triggerResults->size(); i++)
00453 {
00454 std::string trigName = trigNames.triggerName(i);
00455 bool found=false;
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466 for(unsigned int index=0; index<elecTrig_.size() && found==false; index++) {
00467 size_t trigPath = trigName.find(elecTrig_.at(index));
00468 if (trigPath==0) found=true;
00469 }
00470 if(!found) continue;
00471
00472 bool prescaled=false;
00473 for (unsigned int ps= 0; ps< hltConfigProvider_.prescaleSize(); ps++){
00474 const unsigned int prescaleValue = hltConfigProvider_.prescaleValue(ps, trigName) ;
00475 if (prescaleValue != 1) prescaled =true;
00476 }
00477
00478 if(triggerResults->accept(i) && !prescaled) trigger_fired=true;
00479
00480 }
00481
00482
00483 LogTrace("") << ">>> Trigger bit: " << trigger_fired << " for one of ( " ;
00484 for (unsigned int k = 0; k < elecTrig_.size(); k++)
00485 {
00486 LogTrace("") << elecTrig_.at(k) << " ";
00487 }
00488 LogTrace("") << ")";
00489 trig_before_->Fill(trigger_fired);
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507 Handle<View<Jet> > jetCollection;
00508 if (!ev.getByLabel(jetTag_, jetCollection)) {
00509
00510 return;
00511 }
00512 float electron_et = -8.0;
00513 float electron_eta = -8.0;
00514 float electron_phi = -8.0;
00515 float electron2_et = -9.0;
00516 float electron2_eta = -9.0;
00517 float electron2_phi = -9.0;
00518
00519 for (unsigned int i=0; i<electronCollectionSize; i++)
00520 {
00521 const GsfElectron& elec = electronCollection->at(i);
00522
00523 if (i < 1)
00524 {
00525 electron_et = elec.pt();
00526 electron_eta = elec.eta();
00527 electron_phi = elec.phi();
00528 }
00529 if (i == 2)
00530 {
00531 electron2_et = elec.pt();
00532 electron2_eta = elec.eta();
00533 electron2_phi = elec.phi();
00534 }
00535 }
00536
00537 float jet_et = -8.0;
00538 float jet_eta = -8.0;
00539 int jet_count = 0;
00540 float jet2_et = -9.0;
00541 unsigned int jetCollectionSize = jetCollection->size();
00542 int njets = 0;
00543 for (unsigned int i=0; i<jetCollectionSize; i++) {
00544 const Jet& jet = jetCollection->at(i);
00545
00546 float jet_current_et = jet.et();
00547
00548
00549 if ( electron_et>0.0 && fabs(jet.eta()-electron_eta ) < 0.2
00550 && calcDeltaPhi(jet.phi(), electron_phi ) < 0.2)
00551 continue;
00552 if ( electron2_et>0.0&& fabs(jet.eta()-electron2_eta) < 0.2
00553 && calcDeltaPhi(jet.phi(), electron2_phi) < 0.2)
00554 continue;
00555
00556
00557
00558
00559 if (jet.et()>eJetMin_)
00560 {
00561 njets++;
00562 jet_count++;
00563 }
00564 if (jet_current_et > jet_et)
00565 {
00566 jet2_et = jet_et;
00567 jet_et = jet.et();
00568 jet_eta = jet.eta();
00569 }
00570 else if (jet_current_et > jet2_et)
00571 {
00572 jet2_et = jet.et();
00573 }
00574 }
00575
00576
00577 if (jet_et>10)
00578 {
00579 jet_et_before_ ->Fill(jet_et);
00580
00581 jet_eta_before_ ->Fill(jet_eta);
00582 }
00583
00584
00585 LogTrace("") << ">>> Total number of jets: " << jetCollectionSize;
00586 LogTrace("") << ">>> Number of jets above " << eJetMin_ << " [GeV]: " << njets;
00587 njets_before_->Fill(njets);
00588
00589
00590
00591 nall++;
00592
00593
00594 bool hlt_hist_done = false;
00595
00596 bool met_hist_done = false;
00597
00598
00599 bool njets_hist_done = false;
00600
00601
00602
00603 const int NFLAGS = 11;
00604
00605
00606
00607
00608
00609
00610
00611
00612 bool electron_sel[NFLAGS];
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626 double electron[2][6];
00627 double goodElectron[2][6];
00628 nGoodElectrons = 0;
00629 for (unsigned int i = 0; i < 2; i++)
00630 {
00631 for (unsigned int j = 0; j < 6; j++)
00632 {
00633 electron[i][j] = 0.;
00634 goodElectron[i][j] = 0.;
00635 }
00636 }
00637
00638 for (unsigned int i=0; i<electronCollectionSize; i++)
00639 {
00640 for (int j=0; j<NFLAGS; ++j)
00641 {
00642 electron_sel[j] = false;
00643 }
00644
00645 const GsfElectron& elec = electronCollection->at(i);
00646
00647
00648
00649
00650 LogTrace("") << "> elec: processing electron number " << i << "...";
00651
00652
00653
00654
00655 if (i < 2)
00656 {
00657 electron[i][0] = 1.;
00658 electron[i][1] = elec.massSqr();
00659 electron[i][2] = elec.energy();
00660 electron[i][3] = elec.px();
00661 electron[i][4] = elec.py();
00662 electron[i][5] = elec.pz();
00663 }
00664
00665
00666 double pt = elec.pt();
00667 double px = elec.px();
00668 double py = elec.py();
00669 double eta = elec.eta();
00670 LogTrace("") << "\t... pt, eta: " << pt << " [GeV], " << eta;;
00671 if (pt>ptCut_) electron_sel[0] = true;
00672 if (fabs(eta)<etaCut_) electron_sel[1] = true;
00673
00674 bool isBarrel = false;
00675 bool isEndcap = false;
00676 if (eta < 1.4442 && eta > -1.4442)
00677 {
00678 isBarrel = true;
00679 }
00680 else if ((eta > 1.56 && eta < 2.4) || (eta < -1.56 && eta > -2.4))
00681 {
00682 isEndcap = true;
00683 }
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695 pt_before_->Fill(pt);
00696 eta_before_->Fill(eta);
00697
00698
00699
00700
00701
00702
00703
00704 double sieie = (double) elec.sigmaIetaIeta();
00705 double detain = (double) elec.deltaEtaSuperClusterTrackAtVtx();
00706 if (sieie < sieieCutBarrel_ && isBarrel) electron_sel[2] = true;
00707 if (sieie < sieieCutEndcap_ && isEndcap) electron_sel[2] = true;
00708 if (detain < detainCutBarrel_ && isBarrel) electron_sel[3] = true;
00709 if (detain < detainCutEndcap_ && isEndcap) electron_sel[3] = true;
00710 if (isBarrel)
00711 {
00712 LogTrace("") << "\t... sieie value " << sieie << " (barrel), pass? " << electron_sel[2];
00713 LogTrace("") << "\t... detain value " << detain << " (barrel), pass? " << electron_sel[3];
00714 }
00715 else if (isEndcap)
00716 {
00717 LogTrace("") << "\t... sieie value " << sieie << " (endcap), pass? " << electron_sel[2];
00718 LogTrace("") << "\t... detain value " << detain << " (endcap), pass? " << electron_sel[2];
00719 }
00720
00721 if (isBarrel)
00722 {
00723 sieiebarrel_before_->Fill(sieie);
00724 detainbarrel_before_->Fill(detain);
00725 }
00726 else if (isEndcap)
00727 {
00728 sieieendcap_before_->Fill(sieie);
00729 detainendcap_before_->Fill(detain);
00730 }
00731
00732
00733
00734
00735
00736 double ecalisovar = elec.dr03EcalRecHitSumEt();
00737 double hcalisovar = elec.dr03HcalTowerSumEt();
00738 double trkisovar = elec.dr04TkSumPt();
00739
00740
00741
00742
00743
00744 if (ecalisovar<ecalIsoCutBarrel_ && isBarrel) electron_sel[4] = true;
00745 if (ecalisovar<ecalIsoCutEndcap_ && isEndcap) electron_sel[4] = true;
00746 if (hcalisovar<hcalIsoCutBarrel_ && isBarrel) electron_sel[5] = true;
00747 if (hcalisovar<hcalIsoCutEndcap_ && isEndcap) electron_sel[5] = true;
00748 if (trkisovar<trkIsoCutBarrel_ && isBarrel) electron_sel[6] = true;
00749 if (trkisovar<trkIsoCutEndcap_ && isEndcap) electron_sel[6] = true;
00750 if (isBarrel)
00751 {
00752 LogTrace("") << "\t... ecal isolation value " << ecalisovar << " (barrel), pass? " << electron_sel[4];
00753 LogTrace("") << "\t... hcal isolation value " << hcalisovar << " (barrel), pass? " << electron_sel[5];
00754 LogTrace("") << "\t... trk isolation value " << trkisovar << " (barrel), pass? " << electron_sel[6];
00755 }
00756 else if (isEndcap)
00757 {
00758 LogTrace("") << "\t... ecal isolation value " << ecalisovar << " (endcap), pass? " << electron_sel[4];
00759 LogTrace("") << "\t... hcal isolation value " << hcalisovar << " (endcap), pass? " << electron_sel[5];
00760 LogTrace("") << "\t... trk isolation value " << trkisovar << " (endcap), pass? " << electron_sel[6];
00761 }
00762
00763
00764 if (isBarrel)
00765 {
00766 ecalisobarrel_before_->Fill(ecalisovar);
00767 hcalisobarrel_before_->Fill(hcalisovar);
00768 trkisobarrel_before_->Fill(trkisovar);
00769 }
00770 else if (isEndcap)
00771 {
00772 ecalisoendcap_before_->Fill(ecalisovar);
00773 hcalisoendcap_before_->Fill(hcalisovar);
00774 trkisoendcap_before_->Fill(trkisovar);
00775 }
00776
00777
00778
00779 if (trigger_fired) electron_sel[7] = true;
00780
00781
00782
00783 double w_et = met_et+pt;
00784 double w_px = met_px+px;
00785 double w_py = met_py+py;
00786
00787 double massT = w_et*w_et - w_px*w_px - w_py*w_py;
00788 massT = (massT>0) ? sqrt(massT) : 0;
00789
00790 LogTrace("") << "\t... W mass, W_et, W_px, W_py: " << massT << ", " << w_et << ", " << w_px << ", " << w_py << " [GeV]";
00791 if (massT>mtMin_ && massT<mtMax_) electron_sel[8] = true;
00792 mt_before_->Fill(massT);
00793 if (met_et>metMin_ && met_et<metMax_) electron_sel[9] = true;
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806 if (njets<=nJetMax_) electron_sel[10] = true;
00807
00808
00809 int flags_passed = 0;
00810 bool rec_sel_this = true;
00811 bool eid_sel_this = true;
00812 bool iso_sel_this = true;
00813 bool all_sel_this = true;
00814 for (int j=0; j<NFLAGS; ++j)
00815 {
00816 if (electron_sel[j]) flags_passed += 1;
00817 if (j<2 && !electron_sel[j]) rec_sel_this = false;
00818 if (j<4 && !electron_sel[j]) eid_sel_this = false;
00819 if (j<7 && !electron_sel[j]) iso_sel_this = false;
00820 if (!electron_sel[j]) all_sel_this = false;
00821 }
00822
00823 if (all_sel_this)
00824 {
00825 if (nGoodElectrons < 2)
00826 {
00827 goodElectron[nGoodElectrons][0] = 1.;
00828 goodElectron[nGoodElectrons][1] = elec.massSqr();
00829 goodElectron[nGoodElectrons][2] = elec.energy();
00830 goodElectron[nGoodElectrons][3] = elec.px();
00831 goodElectron[nGoodElectrons][4] = elec.py();
00832 goodElectron[nGoodElectrons][5] = elec.pz();
00833 }
00834 nGoodElectrons++;
00835 }
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847 if (rec_sel_this) rec_sel = true;
00848
00849 if (eid_sel_this) iso_sel = true;
00850
00851 if (iso_sel_this) iso_sel = true;
00852
00853
00854 if (all_sel_this) all_sel = true;
00855
00856
00857 if (flags_passed >= (NFLAGS-1))
00858 {
00859 if (!electron_sel[0] || flags_passed==NFLAGS)
00860 {
00861 pt_after_->Fill(pt);
00862 }
00863 if (!electron_sel[1] || flags_passed==NFLAGS)
00864 {
00865 eta_after_->Fill(eta);
00866 }
00867 if (!electron_sel[2] || flags_passed==NFLAGS)
00868 {
00869 if (isBarrel)
00870 {
00871 sieiebarrel_after_->Fill(sieie);
00872 }
00873 else if (isEndcap)
00874 {
00875 sieieendcap_after_->Fill(sieie);
00876 }
00877 }
00878 if (!electron_sel[3] || flags_passed==NFLAGS)
00879 {
00880 if (isBarrel)
00881 {
00882 detainbarrel_after_->Fill(detain);
00883 }
00884 else if (isEndcap)
00885 {
00886 detainendcap_after_->Fill(detain);
00887 }
00888 }
00889 if (!electron_sel[4] || flags_passed==NFLAGS)
00890 {
00891 if (isBarrel)
00892 {
00893 ecalisobarrel_after_->Fill(ecalisovar);
00894 }
00895 else if (isEndcap)
00896 {
00897 ecalisoendcap_after_->Fill(ecalisovar);
00898 }
00899 }
00900 if (!electron_sel[5] || flags_passed==NFLAGS)
00901 {
00902 if (isBarrel)
00903 {
00904 hcalisobarrel_after_->Fill(hcalisovar);
00905 }
00906 else if (isEndcap)
00907 {
00908 hcalisoendcap_after_->Fill(hcalisovar);
00909 }
00910 }
00911 if (!electron_sel[6] || flags_passed==NFLAGS)
00912 {
00913 if (isBarrel)
00914 {
00915 trkisobarrel_after_->Fill(trkisovar);
00916 }
00917 else if (isEndcap)
00918 {
00919 trkisoendcap_after_->Fill(trkisovar);
00920 }
00921 }
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938 if (!electron_sel[7] || flags_passed==NFLAGS)
00939 {
00940 if (!hlt_hist_done)
00941 {
00942 trig_after_->Fill(trigger_fired);
00943 }
00944 }
00945 hlt_hist_done = true;
00946 if (!electron_sel[8] || flags_passed==NFLAGS)
00947 {
00948 mt_after_->Fill(massT);
00949 }
00950 if (!electron_sel[9] || flags_passed==NFLAGS)
00951 {
00952 if (!met_hist_done) {
00953 met_after_->Fill(met_et);
00954 }
00955 }
00956 met_hist_done = true;
00957
00958
00959
00960
00961
00962
00963
00964
00965 if (!electron_sel[10] || flags_passed==NFLAGS) {
00966 if (!njets_hist_done)
00967 {
00968 njets_after_->Fill(njets);
00969 if (jet_et>10)
00970 {
00971 jet_et_after_ ->Fill(jet_et);
00972 jet_eta_after_ ->Fill(jet_eta);
00973 }
00974 }
00975 }
00976 njets_hist_done = true;
00977
00978 }
00979
00980 }
00981
00982
00983 double invMass=0;
00984
00985 nelectrons_before_->Fill(electronCollectionSize);
00986 if (electronCollectionSize > 1)
00987 {
00988 invMass = sqrt(electron[0][1] + electron[1][1] + 2*(electron[0][2]*electron[1][2] - (electron[0][3]*electron[1][3] + electron[0][4]*electron[1][4] + electron[0][5]*electron[1][5]) ) );
00989 invmass_before_->Fill(invMass);
00990 invmassPU_before_->Fill(invMass,npvCount);
00991 }
00992
00993 nelectrons_after_->Fill(nGoodElectrons);
00994 if (nGoodElectrons > 1)
00995 {
00996 invMass = sqrt(goodElectron[0][1] + goodElectron[1][1] + 2*(goodElectron[0][2]*goodElectron[1][2] - (goodElectron[0][3]*goodElectron[1][3] + goodElectron[0][4]*goodElectron[1][4] + goodElectron[0][5]*goodElectron[1][5]) ) );
00997 invmass_after_->Fill(invMass);
00998 invmassPU_afterZ_->Fill(invMass,npvCount);
00999 npvs_afterZ_->Fill(npvCount);
01000 }
01001
01002
01003 if (rec_sel) nrec++;
01004 if (eid_sel) neid++;
01005 if (iso_sel) niso++;
01006
01007
01008
01009 if (all_sel) {
01010 nsel++;
01011 LogTrace("") << ">>>> Event ACCEPTED";
01012 } else {
01013 LogTrace("") << ">>>> Event REJECTED";
01014 }
01015
01016
01017
01018 return;
01019
01020 }
01021
01022
01023 double EwkElecDQM::calcDeltaPhi(double phi1, double phi2) {
01024
01025 double deltaPhi = phi1 - phi2;
01026
01027 if (deltaPhi < 0) deltaPhi = -deltaPhi;
01028
01029 if (deltaPhi > 3.1415926) {
01030 deltaPhi = 2 * 3.1415926 - deltaPhi;
01031 }
01032
01033 return deltaPhi;
01034 }
01035