CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

HLTMonElectron Class Reference

#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 ()
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< bool > plotiso
unsigned int reqNum
std::vector< edm::InputTagtheHLTCollectionLabels
int theHLTOutputType
std::vector< int > theHLTOutputTypes
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 filters, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), LogDebug, NULL, and cmsCodeRules::cppFunctionSkipper::operator.

{
  
  LogDebug("HLTMonElectron") << "constructor...." ;
  
  logFile_.open("HLTMonElectron.log");
  
  dbe = NULL;
  if (iConfig.getUntrackedParameter < bool > ("DQMStore", false)) {
    dbe = Service < DQMStore > ().operator->();
    dbe->setVerbose(0);
  }
  
  outputFile_ =
    iConfig.getUntrackedParameter < std::string > ("outputFile", "");
  if (outputFile_.size() != 0) {
    LogInfo("HLTMonElectron") << "L1T Monitoring histograms will be saved to " 
                              << outputFile_ ;
  }
  else {
    outputFile_ = "L1TDQM.root";
  }
  
  bool disable =
    iConfig.getUntrackedParameter < bool > ("disableROOToutput", false);
  if (disable) {
    outputFile_ = "";
  }
  
  dirname_="HLT/HLTMonElectron/"+iConfig.getParameter<std::string>("@module_label");
  
  if (dbe != NULL) {
    dbe->setCurrentFolder(dirname_);
  }
  
  
  //plotting paramters
  thePtMin = iConfig.getUntrackedParameter<double>("PtMin",0.);
  thePtMax = iConfig.getUntrackedParameter<double>("PtMax",1000.);
  theNbins = iConfig.getUntrackedParameter<unsigned int>("Nbins",40);
  
  //info for each filter-step
  reqNum = iConfig.getParameter<unsigned int>("reqNum");
  std::vector<edm::ParameterSet> filters = iConfig.getParameter<std::vector<edm::ParameterSet> >("filters");
  
  for(std::vector<edm::ParameterSet>::iterator filterconf = filters.begin() ; filterconf != filters.end() ; filterconf++){
    theHLTCollectionLabels.push_back(filterconf->getParameter<edm::InputTag>("HLTCollectionLabels"));
    theHLTOutputTypes.push_back(filterconf->getParameter<unsigned int>("theHLTOutputTypes"));
    std::vector<double> bounds = filterconf->getParameter<std::vector<double> >("PlotBounds");
    assert(bounds.size() == 2);
    plotBounds.push_back(std::pair<double,double>(bounds[0],bounds[1]));
    isoNames.push_back(filterconf->getParameter<std::vector<edm::InputTag> >("IsoCollections"));
    assert(isoNames.back().size()>0);
    if (isoNames.back().at(0).label()=="none")
      plotiso.push_back(false);
    else{
      plotiso.push_back(true);
    }
  }
  
}
HLTMonElectron::~HLTMonElectron ( )

Definition at line 89 of file HLTMonElectron.cc.

{
 
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)

}

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 edm::Event::getByLabel(), iEvent, LogDebug, n, and pileupDistInMC::total.

{
   using namespace edm;
   using namespace trigger;
   nev_++;
   LogDebug("HLTMonElectron")<< "HLTMonElectron: analyze...." ;
   

  edm::Handle<trigger::TriggerEventWithRefs> triggerObj;
  iEvent.getByLabel("hltTriggerSummaryRAW",triggerObj); 
  if(!triggerObj.isValid()) { 
    edm::LogWarning("HLTMonElectron") << "RAW-type HLT results not found, skipping event";
    return;
  }

  // total event number
  total->Fill(theHLTCollectionLabels.size()+0.5);
    

  for(unsigned int n=0; n < theHLTCollectionLabels.size() ; n++) { //loop over filter modules
    switch(theHLTOutputTypes[n]){
    case 82: // non-iso L1
      fillHistos<l1extra::L1EmParticleCollection>(triggerObj,iEvent,n);break;
    case 83: // iso L1
      fillHistos<l1extra::L1EmParticleCollection>(triggerObj,iEvent,n);break;
    case 91: //photon 
      fillHistos<reco::RecoEcalCandidateCollection>(triggerObj,iEvent,n);break;
    case 92: //electron 
      fillHistos<reco::ElectronCollection>(triggerObj,iEvent,n);break;
    case 100: // TriggerCluster
      fillHistos<reco::RecoEcalCandidateCollection>(triggerObj,iEvent,n);break;
    default: throw(cms::Exception("Release Validation Error")<< "HLT output type not implemented: theHLTOutputTypes[n]" );
    }
  }
}
void HLTMonElectron::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 191 of file HLTMonElectron.cc.

References DQMStore::book1D(), DQMStore::book2D(), i, label, NULL, cmsCodeRules::cppFunctionSkipper::operator, DQMStore::rmdir(), DQMStore::setCurrentFolder(), and pileupDistInMC::total.

{
  nev_ = 0;
  DQMStore *dbe = 0;
  dbe = Service < DQMStore > ().operator->();
  
  if (dbe) {
    dbe->setCurrentFolder(dirname_);
    dbe->rmdir(dirname_);
  }
  
  
  if (dbe) {
    dbe->setCurrentFolder(dirname_);

    std::string histoname="total eff";
    MonitorElement* tmphisto;

     
    total = dbe->book1D(histoname.c_str(),histoname.c_str(),theHLTCollectionLabels.size()+1,0,theHLTCollectionLabels.size()+1);
    total->setBinLabel(theHLTCollectionLabels.size()+1,"Total",1);
    for (unsigned int u=0; u<theHLTCollectionLabels.size(); u++){total->setBinLabel(u+1,theHLTCollectionLabels[u].label().c_str());}
    
    
    for(unsigned int i = 0; i< theHLTCollectionLabels.size() ; i++){
      histoname = theHLTCollectionLabels[i].label()+"et";
      tmphisto =  dbe->book1D(histoname.c_str(),histoname.c_str(),theNbins,thePtMin,thePtMax);
      ethist.push_back(tmphisto);
      
      histoname = theHLTCollectionLabels[i].label()+"eta";
      tmphisto =  dbe->book1D(histoname.c_str(),histoname.c_str(),theNbins,-2.7,2.7);
      etahist.push_back(tmphisto);          
 
      histoname = theHLTCollectionLabels[i].label()+"phi";
      tmphisto =  dbe->book1D(histoname.c_str(),histoname.c_str(),theNbins,-3.2,3.2);
      phihist.push_back(tmphisto);          
 
      if(plotiso[i]){
        histoname = theHLTCollectionLabels[i].label()+"eta isolation";
        tmphisto = dbe->book2D(histoname.c_str(),histoname.c_str(),theNbins,-2.7,2.7,theNbins,plotBounds[i].first,plotBounds[i].second);
      }
      else{
        tmphisto = NULL;
      }
      etahistiso.push_back(tmphisto);
      
      if(plotiso[i]){
        histoname = theHLTCollectionLabels[i].label()+"phi isolation";
        tmphisto = dbe->book2D(histoname.c_str(),histoname.c_str(),theNbins,-3.2,3.2,theNbins,plotBounds[i].first,plotBounds[i].second);
      }
      else{
        tmphisto = NULL;
      }
      phihistiso.push_back(tmphisto);
      
      if(plotiso[i]){
        histoname = theHLTCollectionLabels[i].label()+"et isolation";
        tmphisto = dbe->book2D(histoname.c_str(),histoname.c_str(),theNbins,thePtMin,thePtMax,theNbins,plotBounds[i].first,plotBounds[i].second);
      }
      else{
        tmphisto = NULL;
      }
      ethistiso.push_back(tmphisto);
      

    } 
  } // end "if(dbe)"
}
void HLTMonElectron::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 262 of file HLTMonElectron.cc.

                       {

//     std::cout << "HLTMonElectron: end job...." << std::endl;
   LogInfo("HLTMonElectron") << "analyzed " << nev_ << " events";
 
   if (outputFile_.size() != 0 && dbe)
     dbe->save(outputFile_);
 
   return;
}
template<class T >
void HLTMonElectron::fillHistos ( edm::Handle< trigger::TriggerEventWithRefs > &  triggerObj,
const edm::Event iEvent,
unsigned int  n 
) [private]

Definition at line 140 of file HLTMonElectron.cc.

References asciidump::at, eta(), edm::Event::getByLabel(), i, j, label, n, phi, and pileupDistInMC::total.

                                                                                                                                            {
  
  std::vector<edm::Ref<T> > recoecalcands;
  if (!( triggerObj->filterIndex(theHLTCollectionLabels[n])>=triggerObj->size() )){ // only process if availabel
  
    // retrieve saved filter objects
    triggerObj->getObjects(triggerObj->filterIndex(theHLTCollectionLabels[n]),theHLTOutputTypes[n],recoecalcands);
    //Danger: special case, L1 non-isolated
    // needs to be merged with L1 iso
    if(theHLTOutputTypes[n]==82){
      std::vector<edm::Ref<T> > isocands;
      triggerObj->getObjects(triggerObj->filterIndex(theHLTCollectionLabels[n]),83,isocands);
      if(isocands.size()>0)
        for(unsigned int i=0; i < isocands.size(); i++)
          recoecalcands.push_back(isocands[i]);
    }


    //fill filter objects into histos
    if (recoecalcands.size()!=0){
      if(recoecalcands.size() >= reqNum ) 
        total->Fill(n+0.5);
      for (unsigned int i=0; i<recoecalcands.size(); i++) {
        //unmatched
        ethist[n]->Fill(recoecalcands[i]->et() );
        phihist[n]->Fill(recoecalcands[i]->phi() );
        etahist[n]->Fill(recoecalcands[i]->eta() );


        //plot isolation variables (show not yet cut  iso, i.e. associated to next filter)
        if(n+1 < theHLTCollectionLabels.size()){ // can't plot beyond last
          if(plotiso[n+1]){
            for(unsigned int j =  0 ; j < isoNames[n+1].size() ;j++  ){
              edm::Handle<edm::AssociationMap<edm::OneToValue< T , float > > > depMap; 
              iEvent.getByLabel(isoNames[n+1].at(j).label(),depMap);
              typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(recoecalcands[i]);
              if(mapi!=depMap->end()){  // found candidate in isolation map! 
                etahistiso[n+1]->Fill(recoecalcands[i]->eta(),mapi->val);
                phihistiso[n+1]->Fill(recoecalcands[i]->phi(),mapi->val);
                ethistiso[n+1]->Fill(recoecalcands[i]->et(),mapi->val);
                break; // to avoid multiple filling we only look until we found the candidate once.
              }
            }
          }               
        }
      }
    }
  }
}

Member Data Documentation

Definition at line 65 of file HLTMonElectron.h.

std::string HLTMonElectron::dirname_ [private]

Definition at line 84 of file HLTMonElectron.h.

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

Definition at line 66 of file HLTMonElectron.h.

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

Definition at line 69 of file HLTMonElectron.h.

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

Definition at line 68 of file HLTMonElectron.h.

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

Definition at line 71 of file HLTMonElectron.h.

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

Definition at line 76 of file HLTMonElectron.h.

ofstream HLTMonElectron::logFile_ [private]

Definition at line 86 of file HLTMonElectron.h.

Definition at line 85 of file HLTMonElectron.h.

int HLTMonElectron::nev_ [private]

Definition at line 64 of file HLTMonElectron.h.

std::string HLTMonElectron::outputFile_ [private]

Definition at line 88 of file HLTMonElectron.h.

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

Definition at line 67 of file HLTMonElectron.h.

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

Definition at line 70 of file HLTMonElectron.h.

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

Definition at line 77 of file HLTMonElectron.h.

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

Definition at line 75 of file HLTMonElectron.h.

unsigned int HLTMonElectron::reqNum [private]

Definition at line 78 of file HLTMonElectron.h.

Definition at line 73 of file HLTMonElectron.h.

Definition at line 87 of file HLTMonElectron.h.

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

Definition at line 74 of file HLTMonElectron.h.

unsigned int HLTMonElectron::theNbins [private]

Definition at line 82 of file HLTMonElectron.h.

double HLTMonElectron::thePtMax [private]

Definition at line 81 of file HLTMonElectron.h.

double HLTMonElectron::thePtMin [private]

Definition at line 80 of file HLTMonElectron.h.

Definition at line 72 of file HLTMonElectron.h.