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