CMS 3D CMS Logo

HLTMonElectron Class Reference

Description: This is a DQM source meant to be an example for general development of HLT DQM code. More...

#include <DQM/HLTMonElectron/src/HLTMonElectron.cc>

Inheritance diagram for HLTMonElectron:

edm::EDAnalyzer

List of all members.

Public Member Functions

 HLTMonElectron (const edm::ParameterSet &)
 ~HLTMonElectron ()

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob (const edm::EventSetup &)
virtual void endJob ()
template<class T>
void fillHistos (edm::Handle< trigger::TriggerEventWithRefs > &, const edm::Event &, unsigned int)

Private Attributes

DQMStoredbe
std::string dirname_
std::vector< MonitorElement * > etahist
std::vector< MonitorElement * > etahistiso
std::vector< MonitorElement * > ethist
std::vector< MonitorElement * > ethistiso
std::vector< std::vector
< edm::InputTag > > 
isoNames
ofstream logFile_
bool monitorDaemon_
int nev_
std::string outputFile_
std::vector< MonitorElement * > phihist
std::vector< MonitorElement * > phihistiso
std::vector< std::pair< double,
double > > 
plotBounds
std::vector< boolplotiso
unsigned int reqNum
std::vector< edm::InputTagtheHLTCollectionLabels
int theHLTOutputType
std::vector< inttheHLTOutputTypes
unsigned int theNbins
double thePtMax
double thePtMin
MonitorElementtotal


Detailed Description

Description: This is a DQM source meant to be an example for general development of HLT DQM code.

Based on the general structure used for L1TMonitor DQM sources.

Implementation: <Notes on="" implementation>="">

Definition at line 51 of file HLTMonElectron.h.


Constructor & Destructor Documentation

HLTMonElectron::HLTMonElectron ( const edm::ParameterSet iConfig  )  [explicit]

Definition at line 26 of file HLTMonElectron.cc.

References dbe, dirname_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), isoNames, LogDebug, logFile_, NULL, outputFile_, plotBounds, plotiso, reqNum, DQMStore::setCurrentFolder(), DQMStore::setVerbose(), theHLTCollectionLabels, theHLTOutputTypes, theNbins, thePtMax, and thePtMin.

00027 {
00028   
00029   LogDebug("HLTMonElectron") << "constructor...." ;
00030   
00031   logFile_.open("HLTMonElectron.log");
00032   
00033   dbe = NULL;
00034   if (iConfig.getUntrackedParameter < bool > ("DQMStore", false)) {
00035     dbe = Service < DQMStore > ().operator->();
00036     dbe->setVerbose(0);
00037   }
00038   
00039   outputFile_ =
00040     iConfig.getUntrackedParameter < std::string > ("outputFile", "");
00041   if (outputFile_.size() != 0) {
00042     LogInfo("HLTMonElectron") << "L1T Monitoring histograms will be saved to " 
00043                               << outputFile_ ;
00044   }
00045   else {
00046     outputFile_ = "L1TDQM.root";
00047   }
00048   
00049   bool disable =
00050     iConfig.getUntrackedParameter < bool > ("disableROOToutput", false);
00051   if (disable) {
00052     outputFile_ = "";
00053   }
00054   
00055   dirname_="HLT/HLTMonElectron/"+iConfig.getParameter<std::string>("@module_label");
00056   
00057   if (dbe != NULL) {
00058     dbe->setCurrentFolder(dirname_);
00059   }
00060   
00061   
00062   //plotting paramters
00063   thePtMin = iConfig.getUntrackedParameter<double>("PtMin",0.);
00064   thePtMax = iConfig.getUntrackedParameter<double>("PtMax",1000.);
00065   theNbins = iConfig.getUntrackedParameter<unsigned int>("Nbins",40);
00066   
00067   //info for each filter-step
00068   reqNum = iConfig.getParameter<unsigned int>("reqNum");
00069   std::vector<edm::ParameterSet> filters = iConfig.getParameter<std::vector<edm::ParameterSet> >("filters");
00070   
00071   for(std::vector<edm::ParameterSet>::iterator filterconf = filters.begin() ; filterconf != filters.end() ; filterconf++){
00072     theHLTCollectionLabels.push_back(filterconf->getParameter<edm::InputTag>("HLTCollectionLabels"));
00073     theHLTOutputTypes.push_back(filterconf->getParameter<unsigned int>("theHLTOutputTypes"));
00074     std::vector<double> bounds = filterconf->getParameter<std::vector<double> >("PlotBounds");
00075     assert(bounds.size() == 2);
00076     plotBounds.push_back(std::pair<double,double>(bounds[0],bounds[1]));
00077     isoNames.push_back(filterconf->getParameter<std::vector<edm::InputTag> >("IsoCollections"));
00078     assert(isoNames.back().size()>0);
00079     if (isoNames.back().at(0).label()=="none")
00080       plotiso.push_back(false);
00081     else{
00082       plotiso.push_back(true);
00083     }
00084   }
00085   
00086 }

HLTMonElectron::~HLTMonElectron (  ) 

Definition at line 89 of file HLTMonElectron.cc.

00090 {
00091  
00092    // do anything here that needs to be done at desctruction time
00093    // (e.g. close files, deallocate resources etc.)
00094 
00095 }


Member Function Documentation

void HLTMonElectron::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 104 of file HLTMonElectron.cc.

References MonitorElement::Fill(), edm::Event::getByLabel(), edm::Handle< T >::isValid(), LogDebug, n, nev_, theHLTCollectionLabels, theHLTOutputTypes, and total.

00105 {
00106    using namespace edm;
00107    using namespace trigger;
00108    nev_++;
00109    LogDebug("HLTMonElectron")<< "HLTMonElectron: analyze...." ;
00110    
00111 
00112   edm::Handle<trigger::TriggerEventWithRefs> triggerObj;
00113   iEvent.getByLabel("hltTriggerSummaryRAW",triggerObj); 
00114   if(!triggerObj.isValid()) { 
00115     edm::LogWarning("HLTMonElectron") << "RAW-type HLT results not found, skipping event";
00116     return;
00117   }
00118 
00119   // total event number
00120   total->Fill(theHLTCollectionLabels.size()+0.5);
00121     
00122 
00123   for(unsigned int n=0; n < theHLTCollectionLabels.size() ; n++) { //loop over filter modules
00124     switch(theHLTOutputTypes[n]){
00125     case 82: // non-iso L1
00126       fillHistos<l1extra::L1EmParticleCollection>(triggerObj,iEvent,n);break;
00127     case 83: // iso L1
00128       fillHistos<l1extra::L1EmParticleCollection>(triggerObj,iEvent,n);break;
00129     case 91: //photon 
00130       fillHistos<reco::RecoEcalCandidateCollection>(triggerObj,iEvent,n);break;
00131     case 92: //electron 
00132       fillHistos<reco::ElectronCollection>(triggerObj,iEvent,n);break;
00133     case 100: // TriggerCluster
00134       fillHistos<reco::RecoEcalCandidateCollection>(triggerObj,iEvent,n);break;
00135     default: throw(cms::Exception("Release Validation Error")<< "HLT output type not implemented: theHLTOutputTypes[n]" );
00136     }
00137   }
00138 }

void HLTMonElectron::beginJob ( const edm::EventSetup  )  [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 191 of file HLTMonElectron.cc.

References DQMStore::book1D(), DQMStore::book2D(), dbe, dirname_, etahist, etahistiso, ethist, ethistiso, i, label, nev_, NULL, phihist, phihistiso, plotBounds, plotiso, DQMStore::rmdir(), MonitorElement::setBinLabel(), DQMStore::setCurrentFolder(), theHLTCollectionLabels, theNbins, thePtMax, thePtMin, and total.

00192 {
00193   nev_ = 0;
00194   DQMStore *dbe = 0;
00195   dbe = Service < DQMStore > ().operator->();
00196   
00197   if (dbe) {
00198     dbe->setCurrentFolder(dirname_);
00199     dbe->rmdir(dirname_);
00200   }
00201   
00202   
00203   if (dbe) {
00204     dbe->setCurrentFolder(dirname_);
00205 
00206     std::string histoname="total eff";
00207     MonitorElement* tmphisto;
00208 
00209      
00210     total = dbe->book1D(histoname.c_str(),histoname.c_str(),theHLTCollectionLabels.size()+1,0,theHLTCollectionLabels.size()+1);
00211     total->setBinLabel(theHLTCollectionLabels.size()+1,"Total",1);
00212     for (unsigned int u=0; u<theHLTCollectionLabels.size(); u++){total->setBinLabel(u+1,theHLTCollectionLabels[u].label().c_str());}
00213     
00214     
00215     for(unsigned int i = 0; i< theHLTCollectionLabels.size() ; i++){
00216       histoname = theHLTCollectionLabels[i].label()+"et";
00217       tmphisto =  dbe->book1D(histoname.c_str(),histoname.c_str(),theNbins,thePtMin,thePtMax);
00218       ethist.push_back(tmphisto);
00219       
00220       histoname = theHLTCollectionLabels[i].label()+"eta";
00221       tmphisto =  dbe->book1D(histoname.c_str(),histoname.c_str(),theNbins,-2.7,2.7);
00222       etahist.push_back(tmphisto);          
00223  
00224       histoname = theHLTCollectionLabels[i].label()+"phi";
00225       tmphisto =  dbe->book1D(histoname.c_str(),histoname.c_str(),theNbins,-3.2,3.2);
00226       phihist.push_back(tmphisto);          
00227  
00228       if(plotiso[i]){
00229         histoname = theHLTCollectionLabels[i].label()+"eta isolation";
00230         tmphisto = dbe->book2D(histoname.c_str(),histoname.c_str(),theNbins,-2.7,2.7,theNbins,plotBounds[i].first,plotBounds[i].second);
00231       }
00232       else{
00233         tmphisto = NULL;
00234       }
00235       etahistiso.push_back(tmphisto);
00236       
00237       if(plotiso[i]){
00238         histoname = theHLTCollectionLabels[i].label()+"phi isolation";
00239         tmphisto = dbe->book2D(histoname.c_str(),histoname.c_str(),theNbins,-3.2,3.2,theNbins,plotBounds[i].first,plotBounds[i].second);
00240       }
00241       else{
00242         tmphisto = NULL;
00243       }
00244       phihistiso.push_back(tmphisto);
00245       
00246       if(plotiso[i]){
00247         histoname = theHLTCollectionLabels[i].label()+"et isolation";
00248         tmphisto = dbe->book2D(histoname.c_str(),histoname.c_str(),theNbins,thePtMin,thePtMax,theNbins,plotBounds[i].first,plotBounds[i].second);
00249       }
00250       else{
00251         tmphisto = NULL;
00252       }
00253       ethistiso.push_back(tmphisto);
00254       
00255 
00256     } 
00257   } // end "if(dbe)"
00258 }

void HLTMonElectron::endJob ( void   )  [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 262 of file HLTMonElectron.cc.

References dbe, nev_, outputFile_, and DQMStore::save().

00262                        {
00263 
00264 //     std::cout << "HLTMonElectron: end job...." << std::endl;
00265    LogInfo("HLTMonElectron") << "analyzed " << nev_ << " events";
00266  
00267    if (outputFile_.size() != 0 && dbe)
00268      dbe->save(outputFile_);
00269  
00270    return;
00271 }

template<class T>
void HLTMonElectron::fillHistos ( edm::Handle< trigger::TriggerEventWithRefs > &  triggerObj,
const edm::Event iEvent,
unsigned int  n 
) [inline, private]

Definition at line 140 of file HLTMonElectron.cc.

References asciidump::at, eta, etahist, etahistiso, ethist, ethistiso, MonitorElement::Fill(), edm::Event::getByLabel(), i, isoNames, j, label, phi, phihist, phihistiso, plotiso, reqNum, theHLTCollectionLabels, theHLTOutputTypes, and total.

00140                                                                                                                                             {
00141   
00142   std::vector<edm::Ref<T> > recoecalcands;
00143   if (!( triggerObj->filterIndex(theHLTCollectionLabels[n])>=triggerObj->size() )){ // only process if availabel
00144   
00145     // retrieve saved filter objects
00146     triggerObj->getObjects(triggerObj->filterIndex(theHLTCollectionLabels[n]),theHLTOutputTypes[n],recoecalcands);
00147     //Danger: special case, L1 non-isolated
00148     // needs to be merged with L1 iso
00149     if(theHLTOutputTypes[n]==82){
00150       std::vector<edm::Ref<T> > isocands;
00151       triggerObj->getObjects(triggerObj->filterIndex(theHLTCollectionLabels[n]),83,isocands);
00152       if(isocands.size()>0)
00153         for(unsigned int i=0; i < isocands.size(); i++)
00154           recoecalcands.push_back(isocands[i]);
00155     }
00156 
00157 
00158     //fill filter objects into histos
00159     if (recoecalcands.size()!=0){
00160       if(recoecalcands.size() >= reqNum ) 
00161         total->Fill(n+0.5);
00162       for (unsigned int i=0; i<recoecalcands.size(); i++) {
00163         //unmatched
00164         ethist[n]->Fill(recoecalcands[i]->et() );
00165         phihist[n]->Fill(recoecalcands[i]->phi() );
00166         etahist[n]->Fill(recoecalcands[i]->eta() );
00167 
00168 
00169         //plot isolation variables (show not yet cut  iso, i.e. associated to next filter)
00170         if(n+1 < theHLTCollectionLabels.size()){ // can't plot beyond last
00171           if(plotiso[n+1]){
00172             for(unsigned int j =  0 ; j < isoNames[n+1].size() ;j++  ){
00173               edm::Handle<edm::AssociationMap<edm::OneToValue< T , float > > > depMap; 
00174               iEvent.getByLabel(isoNames[n+1].at(j).label(),depMap);
00175               typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(recoecalcands[i]);
00176               if(mapi!=depMap->end()){  // found candidate in isolation map! 
00177                 etahistiso[n+1]->Fill(recoecalcands[i]->eta(),mapi->val);
00178                 phihistiso[n+1]->Fill(recoecalcands[i]->phi(),mapi->val);
00179                 ethistiso[n+1]->Fill(recoecalcands[i]->et(),mapi->val);
00180                 break; // to avoid multiple filling we only look until we found the candidate once.
00181               }
00182             }
00183           }               
00184         }
00185       }
00186     }
00187   }
00188 }


Member Data Documentation

DQMStore* HLTMonElectron::dbe [private]

Definition at line 65 of file HLTMonElectron.h.

Referenced by beginJob(), endJob(), and HLTMonElectron().

std::string HLTMonElectron::dirname_ [private]

Definition at line 84 of file HLTMonElectron.h.

Referenced by beginJob(), and HLTMonElectron().

std::vector<MonitorElement *> HLTMonElectron::etahist [private]

Definition at line 66 of file HLTMonElectron.h.

Referenced by beginJob(), and fillHistos().

std::vector<MonitorElement *> HLTMonElectron::etahistiso [private]

Definition at line 69 of file HLTMonElectron.h.

Referenced by beginJob(), and fillHistos().

std::vector<MonitorElement *> HLTMonElectron::ethist [private]

Definition at line 68 of file HLTMonElectron.h.

Referenced by beginJob(), and fillHistos().

std::vector<MonitorElement *> HLTMonElectron::ethistiso [private]

Definition at line 71 of file HLTMonElectron.h.

Referenced by beginJob(), and fillHistos().

std::vector<std::vector<edm::InputTag> > HLTMonElectron::isoNames [private]

Definition at line 76 of file HLTMonElectron.h.

Referenced by fillHistos(), and HLTMonElectron().

ofstream HLTMonElectron::logFile_ [private]

Definition at line 86 of file HLTMonElectron.h.

Referenced by HLTMonElectron().

bool HLTMonElectron::monitorDaemon_ [private]

Definition at line 85 of file HLTMonElectron.h.

int HLTMonElectron::nev_ [private]

Definition at line 64 of file HLTMonElectron.h.

Referenced by analyze(), beginJob(), and endJob().

std::string HLTMonElectron::outputFile_ [private]

Definition at line 88 of file HLTMonElectron.h.

Referenced by endJob(), and HLTMonElectron().

std::vector<MonitorElement *> HLTMonElectron::phihist [private]

Definition at line 67 of file HLTMonElectron.h.

Referenced by beginJob(), and fillHistos().

std::vector<MonitorElement *> HLTMonElectron::phihistiso [private]

Definition at line 70 of file HLTMonElectron.h.

Referenced by beginJob(), and fillHistos().

std::vector<std::pair<double,double> > HLTMonElectron::plotBounds [private]

Definition at line 77 of file HLTMonElectron.h.

Referenced by beginJob(), and HLTMonElectron().

std::vector<bool> HLTMonElectron::plotiso [private]

Definition at line 75 of file HLTMonElectron.h.

Referenced by beginJob(), fillHistos(), and HLTMonElectron().

unsigned int HLTMonElectron::reqNum [private]

Definition at line 78 of file HLTMonElectron.h.

Referenced by fillHistos(), and HLTMonElectron().

std::vector<edm::InputTag> HLTMonElectron::theHLTCollectionLabels [private]

Definition at line 73 of file HLTMonElectron.h.

Referenced by analyze(), beginJob(), fillHistos(), and HLTMonElectron().

int HLTMonElectron::theHLTOutputType [private]

Definition at line 87 of file HLTMonElectron.h.

std::vector<int> HLTMonElectron::theHLTOutputTypes [private]

Definition at line 74 of file HLTMonElectron.h.

Referenced by analyze(), fillHistos(), and HLTMonElectron().

unsigned int HLTMonElectron::theNbins [private]

Definition at line 82 of file HLTMonElectron.h.

Referenced by beginJob(), and HLTMonElectron().

double HLTMonElectron::thePtMax [private]

Definition at line 81 of file HLTMonElectron.h.

Referenced by beginJob(), and HLTMonElectron().

double HLTMonElectron::thePtMin [private]

Definition at line 80 of file HLTMonElectron.h.

Referenced by beginJob(), and HLTMonElectron().

MonitorElement* HLTMonElectron::total [private]

Definition at line 72 of file HLTMonElectron.h.

Referenced by analyze(), beginJob(), and fillHistos().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:24:32 2009 for CMSSW by  doxygen 1.5.4