CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/HLTriggerOffline/Higgs/src/HLTHiggsBits.cc

Go to the documentation of this file.
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 /*#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00020 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00021 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00022 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMapRecord.h"
00023 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMap.h"
00024 //#include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerSetup.h"
00025 //#include "DataFormats/L1Trigger/interface/L1ParticleMap.h" */
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 // constructors and destructor
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();   // total paths
00065   
00066  
00067     n_hlt_bits_eg  = hlt_bitnamesEg.size();   // muon paths   
00068     n_hlt_bits_mu  = hlt_bitnamesMu.size();   // electron paths
00069     n_hlt_bits_ph  = hlt_bitnamesPh.size();  // photon paths
00070     n_hlt_bits_tau = hlt_bitnamesTau.size(); // tau paths
00071     
00072    
00073  /* 
00074   std::cout << "Number of bit names : " << n_hlt_bits << std::endl;
00075   if (n_hlt_bits>20) {
00076     std::cout << "TOO MANY BITS REQUESTED - TREATING ONLY FIRST 20" << std::endl;
00077     n_hlt_bits=20;
00078   }*/
00079   
00080   
00081   
00082 
00083 // 1:H->ZZ->4l, 2:H->WW->2l, 3: H->gg, 4:qqh->2tau, 5:H+->taunu, 6:qqh->inv
00084 // The proper channel number has to be set in the cff-file
00085  // std::cout << "Analyzing Higgs channel number " << n_channel_ << std::endl;
00086 
00087   // open the histogram file
00088  // m_file=0; // set to null
00089  // m_file=new TFile((histName+".root").c_str(),"RECREATE");
00090  // m_file->cd();
00091  // outfile.open((histName+".output").c_str());
00092 
00093 
00094   // Initialize the tree
00095   HltTree = 0;
00096   HltTree = new TTree("HltTree","");
00097 
00098  /* for (int i=0;i<n_hlt_bits;i++) {
00099     for (int j=0;j<n_hlt_bits+1;j++) {
00100       hlt_whichbit[0][i][j]=0;
00101       hlt_whichbit[1][i][j]=0;
00102       hlt_whichbit[2][i][j]=0;
00103     }
00104   }*/
00105 
00106 
00107   mct_analysis_.setup(iConfig, HltTree);
00108 
00109  // const int kMaxEvents = 50000;
00110  /* const int kMaxEvents = 5000000;
00111   hlt_nbits = new int[kMaxEvents];
00112   HltTree->Branch("NEventCount",&neventcount,"NEventCount/I");
00113   HltTree->Branch("HLT_nBits",hlt_nbits,"HLT_nBits[NEventCount]/I");*/
00114   
00115 
00116   
00117   //--------------------------------------------
00120   //--------------------------------------------
00121   
00122  
00123         dbe = edm::Service<DQMStore>().operator->();    
00124         dbe->setCurrentFolder(triggerTag_);
00125 
00126      //  dbe->setCurrentFolder("HLT/Higgs");
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){  // only for WW,ZZ, 2tau
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  //  dbe->setCurrentFolder("HLT/Higgs/H2tau");
00171  
00172    if (n_channel_==3){  // only for Hgg
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   // dbe->setCurrentFolder("HLT/Higgs/Htaunu");   
00188   // h_pttau1 = dbe->book1D("Tau1Pt","Tau1Pt",50,0.0,500.0);  
00189   // h_etatau1 = dbe->book1D("Tau1Eta","Tau1Eta",50,-5.0,5.0);
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   //  Histos pt, eta RECO events firing HLT 
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    //  std::string histnamepttau = "Tau1Pt_"+hlt_bitnamesTau[j];
00262    //  std::string histnameetatau = "Tau1Eta_"+hlt_bitnamesTau[j];
00263    //  h_pttau1_trig[j] = dbe->book1D((histnamepttau).c_str(),(hlt_bitnamesTau[j]+"pttau").c_str(),50,0.0,300);
00264    //  h_etatau1_trig[j] = dbe->book1D((histnameetatau).c_str(),(hlt_bitnamesTau[j]+"etatau").c_str(),50,-5.0,5.0);
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  // std::cout << "booking OK " << std::endl;
00272 
00273 }
00274 
00275 HLTHiggsBits::~HLTHiggsBits()
00276 { }
00277 
00278 //
00279 // member functions
00280 //
00281 
00282 
00283 // ------------ method called to produce the data  ------------
00284 void
00285 HLTHiggsBits::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00286 {
00287   // accumulation of statistics for HLT bits used by Higgs analysis 
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  // iEvent.getByLabel("met", caloMet);  // first attempt of adding met variables
00306  iEvent.getByLabel("corMetGlobalMuons", caloMet);
00307 
00308   edm::Handle<reco::TrackCollection> Tracks;
00309   iEvent.getByLabel("generalTracks", Tracks);
00310   
00311 // MC truth part
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   // do the MC-preselection. This depends on the channel under study. with
00320   // wrong n_channel the result would be nonsense
00321   if (n_channel_== 1) {
00322     mct_analysis_.analyzeHZZ4l(*mctruth, *muonHandle, *electronHandle, HltTree);
00323   } else if (n_channel_ == 2) {
00324   //  mct_analysis_.analyzeHWW2l(*mctruth, *muonHandle,*electronHandle, HltTree);
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 // HLT part
00339 
00340   // get hold of HL TriggerResults
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   // initialisation
00348   if (!init_) {
00349     init_=true;
00350     const edm::TriggerNames & triggerNames = iEvent.triggerNames(*HLTR);
00351     hlNames_=triggerNames.triggerNames();
00352   }
00353 
00354  
00355   // define reco objects
00356   reco::Muon muon1, muon2;
00357   reco::GsfElectron electron1, electron2;
00358   reco::Photon photon1, photon2;
00359   
00360   
00361   //------------------------
00362   //  fill pt, eta reco objects
00363   //
00364   //---------------------------------
00365   
00366   
00370   if (mct_analysis_.MuonChannel_recoacc()) {  
00371     // trg_eff_gen_mc_mu -> Fill(4,1);
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    //  trg_eff_gen_mc_elec -> Fill(4,1);
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    //  std::cout<<"iso="<< electron1.dr03TkSumPt()<<std::endl;
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      //  trg_eff_gen_mc_emu -> Fill(4,1);
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   /*   if (mct_analysis_.TauChannel_acc()) {  
00464      h_pttau1->Fill(mct_analysis_.ptTau1());
00465      h_etatau1->Fill(mct_analysis_.etaTau1());
00466  
00467      }
00468   */
00469   
00471   
00472   
00473   // decision for each HL algorithm
00474   const unsigned int n(hlNames_.size());
00475   
00476   // wtrig if set to 1 for paths that have fired
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  //        muons
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           // hlt_bitmu_hist_reco->Fill(j+1);
00548        //h_ptmu2_trig[j]->Fill(mct_analysis_.ptmuon2());
00549           }
00550         }
00551       }
00552       
00553       
00554       
00555  //_------------------------------------
00556  //  electrons
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                 //  hlt_bitel_hist_reco->Fill(j+1); 
00578                   }              
00579               }
00580               }
00581         }
00582         
00583         
00584         
00585 //-------------------------------------------------
00586 //   emu channel
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                //   hlt_bitemu_hist_reco->Fill(j+1); 
00605                   }              
00606               }
00607         }
00608         
00609 
00610 
00611 //--------------------------------
00612 //
00613 //
00614 //------------------------------        
00615     
00616     //photons reco
00617       if (mct_analysis_.PhotonChannel_acc()){
00618               //  h_ph_reco->Fill(1);
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       //taus
00630       if (mct_analysis_.TauChannel_acc()){
00631                //  h_tau->Fill(1);
00632                  
00633                 // ev_clasif->Fill(mct_analysis_.evtype());
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            //   h_pttau1_trig[j]->Fill(mct_analysis_.ptTau1());
00638             //  h_etatau1_trig[j]->Fill(mct_analysis_.etaTau1());
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 /*void
00659 HLTHiggsBits::getL1Names(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00660 {
00661   edm::Handle<L1GlobalTriggerObjectMapRecord> gtObjectMapRecord;
00662   iEvent.getByLabel(l1GTObjectMapTag_.label(), gtObjectMapRecord);
00663 
00664   const std::vector<L1GlobalTriggerObjectMap>& objMapVec =
00665        gtObjectMapRecord->gtObjectMap();
00666 
00667   for (std::vector<L1GlobalTriggerObjectMap>::const_iterator itMap = objMapVec.begin();
00668        itMap != objMapVec.end(); ++itMap) {
00669     int algoBit = (*itMap).algoBitNumber();
00670     std::string algoNameStr = (*itMap).algoName();
00671     algoBitToName[algoBit] = algoNameStr;
00672   }
00673 }*/
00674 
00675 
00676 
00677 
00678 void
00679 HLTHiggsBits::endJob()
00680 {
00681   // final printout of accumulated statistics
00682 
00683  // std::cout << "Job ending " << std::endl;
00684 
00685   using namespace std;
00686 
00687  // std::cout << "Number of events handled:                      " << nEvents_ << std::endl;
00688  // std::cout << "Number of events seen in MC:                   " << n_inmc_ << ", (" << 100.0*n_inmc_/nEvents_ <<"%)" << std::endl;
00689  
00690  
00691 
00692 //  return;
00693 
00694 
00695 
00696  // HltTree->Fill();
00697  // m_file->cd(); 
00698  // HltTree->Write();
00699  // delete HltTree;
00700   
00701  if(outputMEsInRootFile){
00702     dbe->showDirStructure();
00703     dbe->save(outputFileName);
00704   }
00705 
00706   
00707  // HltTree = 0;
00708 
00709 //  if (m_file!=0) { // if there was a tree file...
00710  //   m_file->Write(); // write out the branches
00711  //   delete m_file; // close and delete the file
00712  //   m_file=0; // set to zero to clean up
00713  // }
00714 
00715 
00716   return;
00717 }
00718