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