CMS 3D CMS Logo

HLTMuonIsoDQMSource.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    HLTMuonIsoDQMSource
00004 // Class:      HLTMuonIsoDQMSource
00005 // 
00013 //
00014 // Original Author:  Muriel VANDER DONCKT *:0
00015 //         Created:  Wed Dec 12 09:55:42 CET 2007
00016 // $Id: HLTMuonIsoDQMSource.cc,v 1.1 2008/06/25 10:46:57 muriel Exp $
00017 //
00018 //
00019 
00020 
00021 
00022 #include "DQM/HLTEvF/interface/HLTMuonIsoDQMSource.h"
00023 #include "DQMServices/Core/interface/DQMStore.h"
00024 #include "DataFormats/Common/interface/Handle.h"
00025 #include "FWCore/Framework/interface/Event.h"
00026 #include "FWCore/Framework/interface/EventSetup.h"
00027 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00028 #include "FWCore/ServiceRegistry/interface/Service.h"
00029 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
00030 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
00031 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00032 #include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
00033 #include "DataFormats/RecoCandidate/interface/IsoDepositFwd.h"
00034 
00035 #include "TMath.h" 
00036 
00037 
00038 using namespace std;
00039 using namespace edm;
00040 using namespace reco;
00041 //
00042 // constructors and destructor
00043 //
00044 HLTMuonIsoDQMSource::HLTMuonIsoDQMSource( const edm::ParameterSet& ps ) :counterEvt_(0)
00045 
00046 {
00047   parameters_ = ps;
00048   verbose_ = parameters_.getUntrackedParameter < bool > ("verbose", false);
00049   monitorName_ = parameters_.getUntrackedParameter<string>("monitorName","HLT/HLTMuon");
00050   prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
00051   coneSize_ = parameters_.getUntrackedParameter<double>("coneSize", 0.24);
00052   candCollectionTag_ = parameters_.getUntrackedParameter<InputTag>("CandMuonTag",edm::InputTag("hltL2MuonCandidates"));
00053   isolationTag_ = parameters_.getUntrackedParameter<InputTag>("IsolationTag",edm::InputTag("hltL2MuonIsolations"));
00054   level_ = parameters_.getUntrackedParameter<int>("Level", 2);
00055   dbe_ = 0 ;
00056   if (parameters_.getUntrackedParameter < bool > ("DQMStore", false)) {
00057     dbe_ = Service < DQMStore > ().operator->();
00058     dbe_->setVerbose(0);
00059   }
00060  
00061    outputFile_ =
00062        parameters_.getUntrackedParameter < std::string > ("outputFile", "");
00063    if (outputFile_.size() != 0 && verbose_) {
00064      std::cout << "Muon HLT Monitoring histograms will be saved to " 
00065                << outputFile_ << std::endl;
00066    }
00067    else {
00068      outputFile_ = "HLTMuonDQM.root";
00069    }
00070  
00071    bool disable =
00072      parameters_.getUntrackedParameter < bool > ("disableROOToutput", true);
00073    if (disable) {
00074      outputFile_ = "";
00075    }
00076  
00077    if (dbe_ != NULL) {
00078      dbe_->setCurrentFolder("HLT/HLTMuon");
00079    }
00080 
00081 
00082 }
00083 
00084 
00085 HLTMuonIsoDQMSource::~HLTMuonIsoDQMSource()
00086 {
00087    
00088   // do anything here that needs to be done at desctruction time
00089   // (e.g. close files, deallocate resources etc.)
00090   
00091 }
00092 
00093 
00094 //--------------------------------------------------------
00095 void HLTMuonIsoDQMSource::beginJob(const EventSetup& context){
00096 
00097  
00098    if (dbe_) {
00099      dbe_->setCurrentFolder("monitorName_");
00100      if (monitorName_ != "" ) monitorName_ = monitorName_+"/" ;
00101      if (verbose_)cout << "===>DQM event prescale = " << prescaleEvt_ << " events "<< endl;
00102      
00103      
00105      const int NBINS = 100; XMIN = 0; XMAX = 50;
00106 
00107      // create and cd into new folder
00108      char name[512], title[512];
00109      sprintf(name,"Level%i",level_);
00110      dbe_->setCurrentFolder(monitorName_+name);
00111      sprintf(name,"HLTMuonL%i_iso",level_);
00112      if (level_==2)sprintf(title,"L%i Muon Energy in Isolation cone",level_);         
00113      else if (level_==3)sprintf(title,"L%i Muon SumPt in Isolation cone",level_);               
00114      hiso  = dbe_->book1D(name,title, NBINS, 0., 10./(level_-2));
00115      if ( level_==2)hiso->setAxisTitle("Calo Energy in Iso Cone (GeV)", 1);
00116      else if ( level_==3)hiso->setAxisTitle("Sum Pt in Iso Cone (GeV)", 1);
00117 
00118      if(verbose_)dbe_->showDirStructure();
00119   
00120      // Muon det id is 2 pushed in bits 28:31
00121      const unsigned int detector_id = 2<<28;
00122      dbe_->tagContents(monitorName_, detector_id);
00123    } 
00124 }
00125 
00126 //--------------------------------------------------------
00127 void HLTMuonIsoDQMSource::beginRun(const edm::Run& r, const EventSetup& context) {
00128   // reset all me's
00129   vector<MonitorElement*> AllME=dbe_->getAllContents(monitorName_);
00130   vector<MonitorElement*>::iterator me=AllME.begin();
00131   for ( ; me != AllME.end() ; ++me ){
00132     (*me)->Reset();
00133   }
00134 
00135 }
00136 
00137 //--------------------------------------------------------
00138 void HLTMuonIsoDQMSource::beginLuminosityBlock(const LuminosityBlock& lumiSeg, 
00139                                       const EventSetup& context) {
00140   
00141 }
00142 
00143 // ----------------------------------------------------------
00144 void HLTMuonIsoDQMSource::analyze(const Event& iEvent, 
00145                          const EventSetup& iSetup )
00146 {  
00147   if ( !dbe_) return;
00148   counterEvt_++;
00149   if (prescaleEvt_ > 0 && counterEvt_%prescaleEvt_!=0) return;
00150   if (verbose_)cout << " processing conterEvt_: " << counterEvt_ <<endl;
00151 
00152   Handle<RecoChargedCandidateCollection> mucands;
00153   iEvent.getByLabel (candCollectionTag_,mucands);
00154   RecoChargedCandidateCollection::const_iterator cand; 
00155 
00156   if (!mucands.failedToGet()) {
00157     Handle<reco::IsoDepositMap> depMap;
00158     iEvent.getByLabel (isolationTag_,depMap);
00159     for (cand=mucands->begin(); cand!=mucands->end(); ++cand) {
00160       TrackRef tk = cand->get<TrackRef>();
00161       if (!depMap.failedToGet()) {
00162           if (verbose_)cout << " filling  Iso stuff " << endl;
00163           if ( depMap->contains(tk.id()) ){
00164             reco::IsoDepositMap::value_type calDeposit= (*depMap)[tk];
00165             double dephlt = calDeposit.depositWithin(coneSize_);
00166             hiso->Fill(dephlt);
00167           }
00168       }
00169     }
00170   }
00171 }
00172 
00173 
00174 
00175 
00176 //--------------------------------------------------------
00177 void HLTMuonIsoDQMSource::endLuminosityBlock(const LuminosityBlock& lumiSeg, 
00178                                     const EventSetup& context) {
00179 }
00180 //--------------------------------------------------------
00181 void HLTMuonIsoDQMSource::endRun(const Run& r, const EventSetup& context){
00182 }
00183 //--------------------------------------------------------
00184 void HLTMuonIsoDQMSource::endJob(){
00185    LogInfo("HLTMonMuon") << "analyzed " << counterEvt_ << " events";
00186    if (outputFile_.size() != 0 && dbe_)
00187     dbe_->save(outputFile_);
00188    return;
00189 }

Generated on Tue Jun 9 17:33:08 2009 for CMSSW by  doxygen 1.5.4