00001
00012 #include "HLTriggerOffline/Higgs/interface/HLTHiggsBits.h"
00013 #include "HLTriggerOffline/Higgs/interface/HLTHiggsTruth.h"
00014
00015
00016 #include "FWCore/Common/interface/TriggerNames.h"
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "DataFormats/MuonReco/interface/Muon.h"
00028
00029 #include "DataFormats/Math/interface/LorentzVector.h"
00030
00031 #include "DataFormats/HLTReco/interface/TriggerEventWithRefs.h"
00032 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
00033
00034 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
00035 #include "DataFormats/HLTReco/interface/TriggerObject.h"
00036 #include <iomanip>
00037 #include <string>
00038 #include <vector>
00039
00040
00041
00042
00043 HLTHiggsBits::HLTHiggsBits(const edm::ParameterSet& iConfig) :
00044 hlTriggerResults_ (iConfig.getParameter<edm::InputTag> ("HLTriggerResults")),
00045 mctruth_ (iConfig.getParameter<edm::InputTag> ("MCTruth")),
00046 n_channel_ (iConfig.getParameter<int>("Nchannel")),
00047 nEvents_(0),
00048 hlNames_(0),
00049 init_(false),
00050 histName(iConfig.getParameter<std::string>("histName")),
00051 hlt_bitnames(iConfig.getParameter<std::vector<std::string> >("hltBitNames")),
00052 hlt_bitnamesMu(iConfig.getParameter<std::vector<std::string> >("hltBitNamesMu")),
00053 hlt_bitnamesEg(iConfig.getParameter<std::vector<std::string> >("hltBitNamesEG")),
00054 hlt_bitnamesPh(iConfig.getParameter<std::vector<std::string> >("hltBitNamesPh")),
00055 hlt_bitnamesTau(iConfig.getParameter<std::vector<std::string> >("hltBitNamesTau")),
00056 triggerTag_(iConfig.getUntrackedParameter<std::string>("DQMFolder","HLT/Higgs")),
00057 outputFileName(iConfig.getParameter<std::string>("OutputFileName")),
00058 outputMEsInRootFile(iConfig.getParameter<bool>("OutputMEsInRootFile"))
00059
00060
00061 {
00062
00063
00064 n_hlt_bits=hlt_bitnames.size();
00065
00066
00067 n_hlt_bits_eg = hlt_bitnamesEg.size();
00068 n_hlt_bits_mu = hlt_bitnamesMu.size();
00069 n_hlt_bits_ph = hlt_bitnamesPh.size();
00070 n_hlt_bits_tau = hlt_bitnamesTau.size();
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 HltTree = 0;
00096 HltTree = new TTree("HltTree","");
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 mct_analysis_.setup(iConfig, HltTree);
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00120
00121
00122
00123 dbe = edm::Service<DQMStore>().operator->();
00124 dbe->setCurrentFolder(triggerTag_);
00125
00126
00127
00128
00129 if (n_channel_==2) {
00130 h_met_hwwdimu = dbe->book1D("caloMET_dimu","caloMET_dimu",50,0.0,150.0);
00131 h_met_hwwdiel = dbe->book1D("caloMET_diel","caloMET_diel",50,0.0,150.0);
00132 h_met_hwwemu = dbe->book1D("caloMET_emu","caloMET_emu",50,0.0,150.0);
00133
00134 }
00135
00136
00137 if (n_channel_==1 || n_channel_==2 || n_channel_==4){
00138
00139 h_ptmu1 = dbe->book1D("Muon1Pt","Muon1Pt",50,0.0,150.0);
00140 h_ptmu2 = dbe->book1D("Muon2Pt","Muon2Pt",50,0.0,150.0);
00141 h_etamu1 = dbe->book1D("Muon1Eta","Muon1Eta",50,-2.5,2.5);
00142 h_etamu2 = dbe->book1D("Muon2Eta","Muon2Eta",50,-2.5,2.5);
00143
00144 h_ptel1 = dbe->book1D("Electron1Pt","Electron1Pt",50,0.0,150.0);
00145 h_ptel2 = dbe->book1D("Electron2Pt","Electron2Pt",50,0.0,150.0);
00146 h_etael1 = dbe->book1D("Electron1Eta","Electron1Eta",50,-2.5,2.5);
00147 h_etael2 = dbe->book1D("Electron2Eta","Electron2Eta",50,-2.5,2.5);
00148
00149 hlt_bitmu_hist_reco = dbe->book1D("muHLT","muHLT",hlt_bitnamesMu.size(),0.5,hlt_bitnamesMu.size()+0.5);
00150 h_mu_reco = dbe->book1D("MuonEvents","MuonEvents",hlt_bitnamesMu.size(),0.5,hlt_bitnamesMu.size()+0.5);
00151
00152 hlt_bitel_hist_reco = dbe->book1D("elHLT","elHLT",hlt_bitnamesEg.size(),0.5,hlt_bitnamesEg.size()+0.5);
00153 h_el_reco = dbe->book1D("ElectronEvents","ElectronEvents",hlt_bitnamesEg.size(),0.5,hlt_bitnamesEg.size()+0.5);
00154
00155
00156 }
00157
00158 if (n_channel_==1 || n_channel_==2){
00159
00160 h_ptmu1_emu = dbe->book1D("Muon1Pt_EM","Muon1Pt_EM",50,0.0,150.0);
00161 h_ptel1_emu = dbe->book1D("Electron1Pt_EM","Electron1Pt_EM",50,0.0,150.0);
00162 h_etamu1_emu = dbe->book1D("Muon1Eta_EM","Muon1Eta_EM",50,-2.5,2.5);
00163 h_etael1_emu = dbe->book1D("Electron1Eta_EM","Electron1Eta_EM",50,-2.5,2.5);
00164
00165 hlt_bitemu_hist_reco = dbe->book1D("emuHLT","emuHLT",hlt_bitnames.size(),0.5,hlt_bitnames.size()+0.5);
00166 h_emu_reco = dbe->book1D("EmuEvents","EmuEvents",hlt_bitnames.size(),0.5,hlt_bitnames.size()+0.5);
00167
00168
00169 }
00170
00171
00172 if (n_channel_==3){
00173
00174 h_ptph1 = dbe->book1D("Photon1Pt","Photon1Pt",50,0.0,200.0);
00175 h_ptph2 = dbe->book1D("Photon2Pt","Photon2Pt",50,0.0,200.0);
00176 h_etaph1 = dbe->book1D("Photon1Eta","Photon1Eta",50,-2.5,2.5);
00177 h_etaph2 = dbe->book1D("Photon2Eta","Photon2Eta",50,-2.5,2.5);
00178
00179 hlt_bitph_hist_reco = dbe->book1D("phHLT","phHLT",hlt_bitnamesPh.size(),0.5,hlt_bitnamesPh.size()+0.5);
00180 h_ph_reco = dbe->book1D("PhotonEvents","PhotonEvents",hlt_bitnamesPh.size(),0.5,hlt_bitnamesPh.size()+0.5);
00181
00182
00183 }
00184
00185 if (n_channel_==5){
00186
00187
00188
00189
00190
00191 hlt_bittau_hist_gen = dbe->book1D("tauHLT","tauHLT",hlt_bitnamesTau.size(),0.5,hlt_bitnamesTau.size()+0.5);
00192 h_tau_gen = dbe->book1D("tauEvents","tauEvents",hlt_bitnamesTau.size(),0.5,hlt_bitnamesTau.size()+0.5);
00193
00194 }
00195
00196
00197
00198
00199
00200
00201
00202 if (n_channel_==1 || n_channel_==2){
00203
00204 for (int j=0;j<n_hlt_bits;j++) {
00205 std::string histnameptmuem = "Muon1Pt_EM_"+hlt_bitnames[j];
00206 std::string histnameetamuem = "Muon1Eta_EM_"+hlt_bitnames[j];
00207 std::string histnameptelem = "Electron1Pt_EM_"+hlt_bitnames[j];
00208 std::string histnameetaelem = "Electron1Eta_EM_"+hlt_bitnames[j];
00209 h_ptmu1_emu_trig[j] = dbe->book1D((histnameptmuem).c_str(),(hlt_bitnames[j]+"ptmuon").c_str(),50,0.0,150.0);
00210 h_etamu1_emu_trig[j] = dbe->book1D((histnameetamuem).c_str(),(hlt_bitnames[j]+"etamuon").c_str(),50,-2.5,2.5);
00211
00212 h_ptel1_emu_trig[j] = dbe->book1D((histnameptelem).c_str(),(hlt_bitnames[j]+"ptelectron").c_str(),50,0.0,150.0);
00213 h_etael1_emu_trig[j] = dbe->book1D((histnameetaelem).c_str(),(hlt_bitnames[j]+"etaelectron").c_str(),50,-2.5,2.5);
00214
00215 hlt_bitemu_hist_reco -> setBinLabel(j+1,hlt_bitnames[j].c_str());
00216 h_emu_reco -> setBinLabel(j+1,hlt_bitnames[j].c_str());
00217
00218 }
00219 }
00220
00221 if (n_channel_==1 || n_channel_==2 || n_channel_==4){
00222 for (int j=0;j<n_hlt_bits_mu;j++) {
00223 std::string histnameptmu = "Muon1Pt_"+hlt_bitnamesMu[j];
00224 std::string histnameetamu = "Muon1Eta_"+hlt_bitnamesMu[j];
00225 h_ptmu1_trig[j] = dbe->book1D((histnameptmu).c_str(),(hlt_bitnamesMu[j]+"ptmuon").c_str(),50,0.0,150.0);
00226 h_etamu1_trig[j] = dbe->book1D((histnameetamu).c_str(),(hlt_bitnamesMu[j]+"etamuon").c_str(),50,-2.5,2.5);
00227 hlt_bitmu_hist_reco -> setBinLabel(j+1,hlt_bitnamesMu[j].c_str());
00228 h_mu_reco -> setBinLabel(j+1,hlt_bitnamesMu[j].c_str());
00229
00230 }
00231 for (int j=0;j<n_hlt_bits_eg;j++) {
00232 std::string histnameptel = "Electron1Pt_"+hlt_bitnamesEg[j];
00233 std::string histnameetael = "Electron1Eta_"+hlt_bitnamesEg[j];
00234 h_ptel1_trig[j] = dbe->book1D((histnameptel).c_str(),(hlt_bitnamesEg[j]+"ptelectron").c_str(),50,0.0,150.0);
00235 h_etael1_trig[j] = dbe->book1D((histnameetael).c_str(),(hlt_bitnamesEg[j]+"etaelectron").c_str(),50,-2.5,2.5);
00236
00237 hlt_bitel_hist_reco -> setBinLabel(j+1,hlt_bitnamesEg[j].c_str());
00238 h_el_reco -> setBinLabel(j+1,hlt_bitnamesEg[j].c_str());
00239
00240
00241 }
00242
00243 }
00244
00245 if (n_channel_==3){
00246 for (int j=0;j<n_hlt_bits_ph;j++) {
00247 std::string histnameptph = "Photon1Pt_"+hlt_bitnamesPh[j];
00248 std::string histnameetaph = "Photon1Eta_"+hlt_bitnamesPh[j];
00249 h_ptph1_trig[j] = dbe->book1D((histnameptph).c_str(),(hlt_bitnamesPh[j]+"ptphoton").c_str(),50,0.0,200);
00250 h_etaph1_trig[j] = dbe->book1D((histnameetaph).c_str(),(hlt_bitnamesPh[j]+"etaphoton").c_str(),50,-2.5,2.5);
00251
00252 hlt_bitph_hist_reco -> setBinLabel(j+1,hlt_bitnamesPh[j].c_str());
00253 h_ph_reco -> setBinLabel(j+1,hlt_bitnamesPh[j].c_str());
00254
00255 }
00256
00257 }
00258
00259 if (n_channel_==5){
00260 for (int j=0;j<n_hlt_bits_tau;j++) {
00261
00262
00263
00264
00265 hlt_bittau_hist_gen -> setBinLabel(j+1,hlt_bitnamesTau[j].c_str());
00266 h_tau_gen -> setBinLabel(j+1,hlt_bitnamesTau[j].c_str());
00267 }
00268 }
00269
00270
00271
00272
00273 }
00274
00275 HLTHiggsBits::~HLTHiggsBits()
00276 { }
00277
00278
00279
00280
00281
00282
00283
00284 void
00285 HLTHiggsBits::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00286 {
00287
00288
00289 using namespace std;
00290 using namespace edm;
00291
00292
00293
00294 edm::Handle<reco::MuonCollection> muonHandle;
00295 iEvent.getByLabel("muons", muonHandle);
00296
00297
00298 edm::Handle<reco::GsfElectronCollection> electronHandle;
00299 iEvent.getByLabel("gsfElectrons",electronHandle);
00300
00301 edm::Handle<reco::PhotonCollection> photonHandle;
00302 iEvent.getByLabel("photons", photonHandle);
00303
00304 edm::Handle<reco::CaloMETCollection> caloMet;
00305
00306 iEvent.getByLabel("corMetGlobalMuons", caloMet);
00307
00308 edm::Handle<reco::TrackCollection> Tracks;
00309 iEvent.getByLabel("generalTracks", Tracks);
00310
00311
00312
00313 std::string errMsg("");
00314 edm::Handle<reco::CandidateView> mctruth;
00315
00316
00317 try {iEvent.getByLabel(mctruth_,mctruth);} catch (...) { errMsg=errMsg + " -- No Gen Particles";}
00318
00319
00320
00321 if (n_channel_== 1) {
00322 mct_analysis_.analyzeHZZ4l(*mctruth, *muonHandle, *electronHandle, HltTree);
00323 } else if (n_channel_ == 2) {
00324
00325 mct_analysis_.analyzeHWW2l(*mctruth, *caloMet, *Tracks, *muonHandle,*electronHandle, HltTree);
00326 } else if (n_channel_ == 3) {
00327 mct_analysis_.analyzeHgg(*mctruth, *photonHandle, HltTree);
00328 } else if (n_channel_ == 4) {
00329 mct_analysis_.analyzeH2tau(*mctruth, HltTree);
00330 } else if (n_channel_ == 5) {
00331 mct_analysis_.analyzeHtaunu(*mctruth, HltTree);
00332 } else if (n_channel_ == 6) {
00333 mct_analysis_.analyzeHinv(*mctruth, HltTree);
00334 }
00335
00336
00337
00338
00339
00340
00341 try {iEvent.getByLabel(hlTriggerResults_,HLTR);} catch (...) {;}
00342 if (!HLTR.isValid()) {
00343 LogDebug("") << "HL TriggerResults with label ["+hlTriggerResults_.encode()+"] not found!";
00344 return;
00345 }
00346
00347
00348 if (!init_) {
00349 init_=true;
00350 const edm::TriggerNames & triggerNames = iEvent.triggerNames(*HLTR);
00351 hlNames_=triggerNames.triggerNames();
00352 }
00353
00354
00355
00356 reco::Muon muon1, muon2;
00357 reco::GsfElectron electron1, electron2;
00358 reco::Photon photon1, photon2;
00359
00360
00361
00362
00363
00364
00365
00366
00370 if (mct_analysis_.MuonChannel_recoacc()) {
00371
00372
00373 if (n_channel_==2) h_met_hwwdimu->Fill(mct_analysis_.met_hwwdimu());
00374
00375 if (n_channel_==4){
00376 h_ptmu1->Fill(mct_analysis_.ptMuon1());
00377 h_etamu1->Fill(mct_analysis_.etaMuon1());
00378
00379 }
00380 else{
00381
00382 muon1 = mct_analysis_.muon1_();
00383 muon2 = mct_analysis_.muon2_();
00384
00385 h_ptmu1->Fill(muon1.pt());
00386 h_ptmu2->Fill(muon2.pt());
00387 h_etamu1->Fill(muon1.eta());
00388 h_etamu2->Fill(muon2.eta());
00389 }
00390
00391
00392
00393 }
00394
00398
00399 if (mct_analysis_.ElecChannel_recoacc()) {
00400
00401
00402 if (n_channel_==2) h_met_hwwdiel->Fill(mct_analysis_.met_hwwdiel());
00403
00404 if (n_channel_==4){
00405 h_ptel1->Fill(mct_analysis_.ptElectron1());
00406 h_etael1->Fill(mct_analysis_.etaElectron1());
00407
00408 }
00409 else{
00410 electron1 = mct_analysis_.electron1_();
00411 electron2 = mct_analysis_.electron2_();
00412
00413
00414
00415
00416 h_ptel1->Fill(electron1.pt());
00417 h_ptel2->Fill(electron2.pt());
00418 h_etael1->Fill(electron1.eta());
00419 h_etael2->Fill(electron2.eta());
00420 }
00421
00422 }
00423
00427
00428 if (mct_analysis_.ElecMuChannel_recoacc()) {
00429
00430
00431 if (n_channel_==2) h_met_hwwemu->Fill(mct_analysis_.met_hwwemu());
00432
00433 if (n_channel_!=4){
00434 muon1 = mct_analysis_.muon1_();
00435 electron1 = mct_analysis_.electron1_();
00436
00437 h_ptmu1_emu->Fill(muon1.pt());
00438 h_ptel1_emu->Fill(electron1.pt());
00439 h_etamu1_emu->Fill(muon1.eta());
00440 h_etael1_emu->Fill(electron1.eta());
00441 }
00442
00443 }
00444
00448
00449 if (mct_analysis_.PhotonChannel_acc()) {
00450
00451
00452 photon1 = mct_analysis_.photon1_();
00453 photon2 = mct_analysis_.photon2_();
00454
00455 h_ptph1->Fill(photon1.pt());
00456 h_ptph2->Fill(photon2.pt());
00457 h_etaph1->Fill(photon1.eta());
00458 h_etaph2->Fill(photon2.eta());
00459
00460 }
00461
00462
00463
00464
00465
00466
00467
00468
00469
00471
00472
00473
00474 const unsigned int n(hlNames_.size());
00475
00476
00477 int wtrig_m[100]={0};
00478 int wtrig_eg[100]={0};
00479 int wtrig_ph[100]={0};
00480 int wtrig_tau[100]={0};
00481 int wtrig_[100]={0};
00482
00483 for (unsigned int i=0; i!=n; ++i) {
00484 if (HLTR->accept(i)) {
00485 for (int j=0;j<n_hlt_bits_mu;j++) {
00486 if (hlNames_[i] == hlt_bitnamesMu[j]) {
00487 wtrig_m[j]=1;
00488 }
00489 }
00490 for(int jj=0;jj<n_hlt_bits_eg;jj++) {
00491 if (hlNames_[i] == hlt_bitnamesEg[jj]) {
00492 wtrig_eg[jj]=1;
00493 }
00494 }
00495
00496 for (int j=0;j<n_hlt_bits;j++) {
00497 if (hlNames_[i] == hlt_bitnames[j]) {
00498 wtrig_[j]=1;
00499 }
00500 }
00501
00502
00503 for(int k=0;k<n_hlt_bits_ph;k++) {
00504 if (hlNames_[i] == hlt_bitnamesPh[k]) {
00505 wtrig_ph[k]=1;
00506 }
00507 }
00508 for(int k=0;k<n_hlt_bits_tau;k++) {
00509 if (hlNames_[i] == hlt_bitnamesTau[k]) {
00510 wtrig_tau[k]=1;
00511 }
00512 }
00513
00514
00515 }
00516 }
00517
00518
00519
00521
00522
00523
00524
00525
00526
00527
00528 if (mct_analysis_.MuonChannel_recoacc()){
00529
00530 for (int j=0;j<n_hlt_bits_mu;j++) {
00531 h_mu_reco->Fill(j+1);
00532
00533 if (wtrig_m[j]==1) {
00534 hlt_bitmu_hist_reco->Fill(j+1);
00535
00536 if (n_channel_==4){
00537 h_ptmu1_trig[j]->Fill(mct_analysis_.ptMuon1());
00538 h_etamu1_trig[j]->Fill(mct_analysis_.etaMuon1());
00539
00540 }
00541 else{
00542
00543 h_ptmu1_trig[j]->Fill(muon1.pt());
00544 h_etamu1_trig[j]->Fill(muon1.eta());
00545
00546 }
00547
00548
00549 }
00550 }
00551 }
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561 if (mct_analysis_.ElecChannel_recoacc()){
00562
00563
00564 for (int j=0;j<n_hlt_bits_eg;j++) {
00565 h_el_reco->Fill(j+1);
00566 if (wtrig_eg[j]==1) {
00567 hlt_bitel_hist_reco->Fill(j+1);
00568
00569 if (n_channel_==4){
00570 h_ptel1_trig[j]->Fill(mct_analysis_.ptElectron1());
00571 h_etael1_trig[j]->Fill(mct_analysis_.etaElectron1());
00572
00573 }
00574 else {
00575 h_ptel1_trig[j]->Fill(electron1.pt());
00576 h_etael1_trig[j]->Fill(electron1.eta());
00577
00578 }
00579 }
00580 }
00581 }
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591 if (mct_analysis_.ElecMuChannel_recoacc()){
00592
00593 for (int j=0;j<n_hlt_bits;j++) {
00594 h_emu_reco->Fill(j+1);
00595 if (wtrig_[j]==1) {
00596 hlt_bitemu_hist_reco->Fill(j+1);
00597
00598 if (n_channel_!=4){
00599 h_ptel1_emu_trig[j]->Fill(electron1.pt());
00600 h_etael1_emu_trig[j]->Fill(electron1.eta());
00601 h_ptmu1_emu_trig[j]->Fill(muon1.pt());
00602 h_etamu1_emu_trig[j]->Fill(muon1.eta());
00603 }
00604
00605 }
00606 }
00607 }
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617 if (mct_analysis_.PhotonChannel_acc()){
00618
00619 for (int j=0;j<n_hlt_bits_ph;j++) {
00620 h_ph_reco->Fill(j+1);
00621 if (wtrig_ph[j]==1) {
00622 h_ptph1_trig[j]->Fill(photon1.pt());
00623 h_etaph1_trig[j]->Fill(photon1.eta());
00624 hlt_bitph_hist_reco->Fill(j+1);
00625 }
00626 }
00627 }
00628
00629
00630 if (mct_analysis_.TauChannel_acc()){
00631
00632
00633
00634 for (int j=0;j<n_hlt_bits_tau;j++) {
00635 h_tau_gen->Fill(j+1);
00636 if (wtrig_tau[j]==1) {
00637
00638
00639 hlt_bittau_hist_gen->Fill(j+1);
00640 }
00641 }
00642 }
00643
00644
00646
00647
00648
00649
00650
00651 neventcount=nEvents_;
00652
00653 return;
00654
00655 }
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678 void
00679 HLTHiggsBits::endJob()
00680 {
00681
00682
00683
00684
00685 using namespace std;
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701 if(outputMEsInRootFile){
00702 dbe->showDirStructure();
00703 dbe->save(outputFileName);
00704 }
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716 return;
00717 }
00718