CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

GeneralHLTOffline Class Reference

Inheritance diagram for GeneralHLTOffline:
edm::EDAnalyzer

List of all members.

Public Member Functions

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

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob ()
virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
virtual void beginRun (edm::Run const &, edm::EventSetup const &)
virtual void endJob ()
virtual void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
virtual void endRun (edm::Run const &, edm::EventSetup const &)
virtual void fillHltMatrix (std::string, std::string, double, double, bool)
virtual void setupHltMatrix (std::string, int)

Private Attributes

DQMStoredbe
bool debugPrint
HLTConfigProvider hltConfig_
bool outputPrint
vector< vector< string > > PDsVectorPathsVector
std::string plotDirectoryName

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 57 of file GeneralHLTOffline.cc.


Constructor & Destructor Documentation

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

Definition at line 104 of file GeneralHLTOffline.cc.

References gather_cfg::cout, and edm::ParameterSet::getUntrackedParameter().

{
   //now do what ever initialization is needed

  debugPrint = false;
  outputPrint = false;

  if (debugPrint) std::cout << "Inside Constructor" << std::endl;

  plotDirectoryName = iConfig.getUntrackedParameter<std::string>("dirname", "HLT/General");

  if (debugPrint) std::cout << "Got plot dirname = " << plotDirectoryName << std::endl;


}
GeneralHLTOffline::~GeneralHLTOffline ( )

Definition at line 122 of file GeneralHLTOffline.cc.

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

}

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 137 of file GeneralHLTOffline.cc.

References gather_cfg::cout, makeLayoutFileForGui::datasetNames, trigger::TriggerObject::eta(), edm::Event::getByLabel(), i, trigger::TriggerObject::id(), getHLTprescales::index, relativeConstraints::keys, EgammaValidation_cff::pathName, trigger::TriggerObject::phi(), trigger::TriggerObject::pt(), findQualityFiles::size, and patRefSel_triggerSelection_cff::triggerResults.

{
   using namespace edm;
   using std::string;

   if (debugPrint) std::cout << "Inside analyze" << std::endl;

    // Access Trigger Results
   edm::Handle<edm::TriggerResults> triggerResults;
   iEvent.getByLabel(InputTag("TriggerResults","", "HLT"), triggerResults);
   
   if (!triggerResults.isValid()) {
     if (debugPrint) std::cout << "Trigger results not valid" << std::endl;
     return; }

    if (debugPrint) std::cout << "Found triggerResults" << std::endl;

   edm::Handle<trigger::TriggerEvent>         aodTriggerEvent;   
   iEvent.getByLabel(InputTag("hltTriggerSummaryAOD", "", "HLT"), aodTriggerEvent);
   
   if ( !aodTriggerEvent.isValid() ) { 
     if (debugPrint) std::cout << "No AOD trigger summary found! Returning..."; 
     return; 
   }

  std::vector<std::string> nameStreams = hltConfig_.streamNames();

  const TriggerObjectCollection objects = aodTriggerEvent->getObjects();

  bool streamAfound = false;
  int i = 0;

  for (vector<string>::iterator streamName = nameStreams.begin(); 
       streamName != nameStreams.end(); ++streamName) {
    
    if  (hltConfig_.streamName(i) == "A") {
      if (debugPrint) std::cout << " Stream A not found " << std::endl;
      streamAfound = true;
    }
    else
      if (debugPrint) std::cout << " Stream A found " << std::endl;
    i++;
  }

   if (streamAfound) {
     vector<string> datasetNames =  hltConfig_.streamContent("A");
     // Loop over PDs
     for (unsigned int iPD = 0; iPD < datasetNames.size(); iPD++) { 
       
       //     if (datasetNames[iPD] != "SingleMu" && datasetNames[iPD] != "SingleElectron" && datasetNames[iPD] != "Jet") continue;  
       
       unsigned int keyTracker[1000]; // Array to eliminate double counts by tracking what Keys have already been fired
       for(unsigned int irreproduceableIterator = 0; irreproduceableIterator < 1000; irreproduceableIterator++) {
         keyTracker[irreproduceableIterator] = 1001;
       }
       // Loop over Paths in each PD
       for (unsigned int iPath = 0; iPath < PDsVectorPathsVector[iPD].size(); iPath++) { //Andrew - where does PDsVectorPathsVector get defined?
         
         std::string pathName = PDsVectorPathsVector[iPD][iPath];
         
         if (debugPrint) std::cout << "Looking at path " << pathName << std::endl;
         
         unsigned int index = hltConfig_.triggerIndex(pathName);
         
         if (debugPrint) std::cout << "Index = " << index << " triggerResults->size() = " << triggerResults->size() << std::endl;
         
         if (index < triggerResults->size()) {
           if(triggerResults->accept(index)) {
             
             if (debugPrint) std::cout << "We fired path " << pathName << std::endl;
             
             // look up module labels for this path
             
             vector<std::string> modulesThisPath = hltConfig_.moduleLabels(pathName);
             
             if (debugPrint) std::cout << "Looping over module labels " << std::endl;
             
             // Loop backward through module names
             for ( int iModule = (modulesThisPath.size()-1); iModule >= 0; iModule--) {
               
               if (debugPrint) std::cout << "Module name is " << modulesThisPath[iModule] << std::endl;
               
               // check to see if you have savetags information
               if (hltConfig_.saveTags(modulesThisPath[iModule])) {
                 
                 if (debugPrint) std::cout << "For path " << pathName << " this module " << modulesThisPath[iModule] <<" is a saveTags module of type " << hltConfig_.moduleType(modulesThisPath[iModule]) << std::endl;
                 
                 if (hltConfig_.moduleType(modulesThisPath[iModule]) == "HLTLevel1GTSeed") break;
                 
                 InputTag moduleWhoseResultsWeWant(modulesThisPath[iModule], "", "HLT");
                 
                 unsigned int indexOfModuleInAodTriggerEvent = aodTriggerEvent->filterIndex(moduleWhoseResultsWeWant);
                 
                 if ( indexOfModuleInAodTriggerEvent < aodTriggerEvent->sizeFilters() ) {
                   const Keys &keys = aodTriggerEvent->filterKeys( indexOfModuleInAodTriggerEvent );
                   if (debugPrint) std::cout << "Got Keys for index " << indexOfModuleInAodTriggerEvent <<", size of keys is " << keys.size() << std::endl;
                   
                   for ( size_t iKey = 0; iKey < keys.size(); iKey++ ) {
                     TriggerObject foundObject = objects[keys[iKey]];
                     bool first_count = false;
                     
                     if(keyTracker[iKey] != iKey) first_count = true;
                     
                     if (debugPrint || outputPrint) std::cout << "This object has id (pt, eta, phi) = "
                                                              << " " << foundObject.id() << " " 
                                                              << std::setw(10) << foundObject.pt()
                                                              << ", " << std::setw(10) << foundObject.eta() 
                                                              << ", " << std::setw(10) << foundObject.phi()
                                                              << "    for path = " << std::setw(20) << pathName
                                                              << " module " << std::setw(40) << modulesThisPath[iModule]
                                                              << " iKey " << iKey << std::endl;
                     
                     fillHltMatrix(datasetNames[iPD],pathName,foundObject.eta(),foundObject.phi(),first_count);
                     
                     keyTracker[iKey] = iKey;
                     
                   }// end for each key               
                 }// end if filter in aodTriggerEvent
                 
                 
                 // OK, we found the last module. No need to look at the others.
                 // get out of the loop
                 
                 break;
               }// end if saveTags
             }//end Loop backward through module names   
           }// end if(triggerResults->accept(index))
         }// end if (index < triggerResults->size())
       }// end Loop over Paths in each PD
     }//end Loop over PDs
   }

   

}
void GeneralHLTOffline::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 276 of file GeneralHLTOffline.cc.

References gather_cfg::cout, and cmsCodeRules::cppFunctionSkipper::operator.

{

  if (debugPrint) std::cout << "Inside begin job" << std::endl; 

  dbe = Service<DQMStore>().operator->();

  if (dbe) {

    dbe->setCurrentFolder(plotDirectoryName);

  }

}
void GeneralHLTOffline::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 498 of file GeneralHLTOffline.cc.

{
}
void GeneralHLTOffline::beginRun ( edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 299 of file GeneralHLTOffline.cc.

References gather_cfg::cout, makeLayoutFileForGui::datasetNames, and i.

{

  if (debugPrint) std::cout << "Inside beginRun" << std::endl;


  bool changed = true;
  if (hltConfig_.init(iRun, iSetup, "HLT", changed)) {
    if(debugPrint)
      if(debugPrint) std::cout << "HLT config with process name " 
                << "HLT" << " successfully extracted" << std::endl;
  } else {
    if (debugPrint)
      if (debugPrint) std::cout << "Warning, didn't find process HLT" << std::endl;
  }

  if (debugPrint) std::cout << " About to access stream A content " << std::endl;

  std::vector<std::string> nameStreams = hltConfig_.streamNames();

  bool streamAfound = false;
  int i = 0;
  for (vector<string>::iterator streamName = nameStreams.begin(); 
       streamName != nameStreams.end(); ++streamName) {
    
    if  (hltConfig_.streamName(i) == "A") {
      if (debugPrint) std::cout << " Stream A found " << std::endl;
      streamAfound = true;
    }
    else
      if (debugPrint) std::cout << " Stream A not found " << std::endl;
    i++;
  }


  if (streamAfound) {
    vector<string> datasetNames =  hltConfig_.streamContent("A");
  
    if (debugPrint) std::cout << " Size of Stream A dataset " << datasetNames.size() << std::endl;

    for (unsigned int i=0;i<datasetNames.size();i++) {
      
      if (debugPrint) std::cout << "This is dataset " << datasetNames[i] <<std::endl;
      
      vector<string> datasetPaths = hltConfig_.datasetContent(datasetNames[i]);

      if (debugPrint) std::cout << "datasetPaths.size() = " << datasetPaths.size() << std::endl;
      
      PDsVectorPathsVector.push_back(datasetPaths);
      
      if (debugPrint) std::cout <<"Found PD: " << datasetNames[i]  << std::endl;     
      setupHltMatrix(datasetNames[i],i);   
      
    }// end of loop over dataset names
  }

}// end of beginRun
void GeneralHLTOffline::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 293 of file GeneralHLTOffline.cc.

{
}
void GeneralHLTOffline::endLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 504 of file GeneralHLTOffline.cc.

{
}
void GeneralHLTOffline::endRun ( edm::Run const &  ,
edm::EventSetup const &   
) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 358 of file GeneralHLTOffline.cc.

{
}
void GeneralHLTOffline::fillHltMatrix ( std::string  label,
std::string  path,
double  Eta,
double  Phi,
bool  first_count 
) [private, virtual]

Definition at line 440 of file GeneralHLTOffline.cc.

References gather_cfg::cout, MonitorElement::getTH1F(), and MonitorElement::getTH2F().

                                                                                                              {

  if (debugPrint) std::cout << "Inside fillHltMatrix( " << label << " , " << path << " ) " << std::endl;

  std::string fullPathToME;
  std::string fullPathToME1dEta;
  std::string fullPathToME1dPhi;
  std::string fullPathToME1dEtaPath;
  std::string fullPathToME1dPhiPath;

 fullPathToME = "HLT/GeneralHLTOffline/HLT_"+label+"_EtaVsPhi"; 
 fullPathToME1dEta = "HLT/GeneralHLTOffline/HLT_"+label+"_1dEta";
 fullPathToME1dPhi = "HLT/GeneralHLTOffline/HLT_"+label+"_1dPhi";

if (label != "SingleMu" && label != "SingleElectron" && label != "Jet") {
 fullPathToME = "HLT/GeneralHLTOffline/"+label+"/HLT_"+label+"_EtaVsPhi"; 
 fullPathToME1dEta = "HLT/GeneralHLTOffline/"+label+"/HLT_"+label+"_1dEta";
 fullPathToME1dPhi = "HLT/GeneralHLTOffline/"+label+"/HLT_"+label+"_1dPhi";
 }
 
 fullPathToME1dEtaPath = "HLT/GeneralHLTOffline/"+label+"/Paths/HLT_"+path+"_1dEta";
 fullPathToME1dPhiPath = "HLT/GeneralHLTOffline/"+label+"/Paths/HLT_"+path+"_1dPhi";

  if (debugPrint) std::cout << "fullPathToME = " << std::endl;

  MonitorElement * ME_2d = dbe->get(fullPathToME);
  MonitorElement * ME_1dEta = dbe->get(fullPathToME1dEta);
  MonitorElement * ME_1dPhi = dbe->get(fullPathToME1dPhi);  
  MonitorElement * ME_1dEtaPath = dbe->get(fullPathToME1dEtaPath);
  MonitorElement * ME_1dPhiPath = dbe->get(fullPathToME1dPhiPath);

  if (debugPrint) std::cout << "MonitorElement * " << std::endl;

  TH2F * hist_2d = ME_2d->getTH2F();
  TH1F * hist_1dEta = ME_1dEta->getTH1F();
  TH1F * hist_1dPhi = ME_1dPhi->getTH1F();
  TH1F * hist_1dEtaPath = ME_1dEtaPath->getTH1F();
  TH1F * hist_1dPhiPath = ME_1dPhiPath->getTH1F();

  if (debugPrint) std::cout << "TH2F *" << std::endl;

  //int i=2;
  //if (Eta>1.305 && Eta<1.872) i=0;
  //if (Eta<-1.305 && Eta>-1.872) i=0;
  //for (int ii=i; ii<3; ++ii) hist_2d->Fill(Eta,Phi); //Scales narrow bins in Barrel/Endcap border region

  if(first_count) {
    hist_1dEta->Fill(Eta);
    hist_1dPhi->Fill(Phi); 
    hist_2d->Fill(Eta,Phi); }
    hist_1dEtaPath->Fill(Eta); 
    hist_1dPhiPath->Fill(Phi);

 if (debugPrint) std::cout << "hist->Fill" << std::endl;

} //End fillHltMatrix
void GeneralHLTOffline::setupHltMatrix ( std::string  label,
int  iPD 
) [private, virtual]

Definition at line 1025 of file TrigResRateMon.cc.

References DQMStore::book1D(), DQMStore::bookProfile(), TrigResRateMon::dbe_, MonitorElement::getTH1F(), MonitorElement::getTProfile(), i, TrigResRateMon::pathsSummaryFolder_, and DQMStore::setCurrentFolder().

                                                                                    {

    //string groupLabelAny = "HLT_"+label+"_Any";
    //paths.push_back(groupLabelAny.c_str());
    //paths.push_back("HLT_"+label+"_L1_Any");
    paths.push_back("");
    paths.push_back("Total "+label);
    //paths.push_back("HLT_Any");

    string h_name; 
    string h_title; 

    dbe_->setCurrentFolder(pathsSummaryFolder_.c_str());

// //     h_name= "HLT_"+label+"_PassPass";
// //     h_title = "HLT_"+label+"_PassPass (x=Pass, y=Pass);;; ";
// //     MonitorElement* ME = dbe_->book2D(h_name.c_str(), h_title.c_str(),
// //                            paths.size(), -0.5, paths.size()-0.5, paths.size(), -0.5, paths.size()-0.5);

    // This is counts per path per for a specific PD
    // it will be corrected for prescales
    h_name= "HLT_"+label+"_Pass_Any";
    h_title = "HLT_"+label+"_Pass -- Prescale*Counts Per Path;Path;PS*Counts";
    MonitorElement* ME_Any = dbe_->book1D(h_name.c_str(), h_title.c_str(),
                           paths.size(), -0.5, paths.size()-0.5);

    // This is RAW counts per path per for a specific PD
    // it will be corrected for
    h_name= "HLT_"+label+"_RawCounts";
    h_title = "HLT_"+label+"_Pass (x=Pass, An) normalized to HLT_Any Pass;;Counts";
    MonitorElement* ME_RawCounts = dbe_->book1D(h_name.c_str(), h_title.c_str(),
                           paths.size(), -0.5, paths.size()-0.5);


    // Make a similar histogram that is xsec per path for a specific PD
    // this is actually a profile of the average xsec per path 
    h_name= "HLT_"+label+"_Xsec";
    h_title = "HLT_"+label+"_Xsec -- Profile shows Average Xsec per path;;#sigma (#mu b)";

    TProfile tempProfile(h_name.c_str(), h_title.c_str(),
                         paths.size(), -0.5, paths.size()-0.5);
    MonitorElement* ME_Xsec = dbe_->bookProfile(h_name.c_str(), &tempProfile);


    // Make a similar histogram that is xsec per path for a specific PD
    // this is actually a profile of the average xsec per path
    // this histogram is scaled to the cross section of a reference path
    h_name= "HLT_"+label+"_XsecScaled";
    h_title = "HLT_"+label+"_Xsec -- Profile shows Average Xsec per path Scaled to Reference;;Ratio (#sigma/#sigma_{ref}";

    TProfile tempProfileScaled(h_name.c_str(), h_title.c_str(),
                         paths.size(), -0.5, paths.size()-0.5);
    MonitorElement* ME_XsecScaled = dbe_->bookProfile(h_name.c_str(), &tempProfileScaled);

    h_name= "HLT_"+label+"_Rate";
    h_title = "HLT_"+label+"_Rate -- histogram shows Average Rate per LS;LS;Rate [Hz]";

    // MonitorElement* ME_Rate = dbe_->book1D(h_name.c_str(), h_title.c_str(),nLS_, 0, nLS_);


//     dbe_->setCurrentFolder(pathsSummaryHLTCorrelationsFolder_.c_str());
//     h_name= "HLT_"+label+"_PassPass_Normalized";
//     h_title = "HLT_"+label+"_PassPass (x=Pass, y=Pass) normalized to xBin=Pass";
//     MonitorElement* ME_Normalized = dbe_->book2D(h_name.c_str(), h_title.c_str(),
//                            paths.size(), -0.5, paths.size()-0.5, paths.size(), -0.5, paths.size()-0.5);
//     h_name= "HLT_"+label+"_Pass_Normalized_Any";
//     h_title = "HLT_"+label+"_Pass (x=Pass, Any=Pass) normalized to HLT_Any Pass";
//     MonitorElement* ME_Normalized_Any = dbe_->book1D(h_name.c_str(), h_title.c_str(),
//                            paths.size(), -0.5, paths.size()-0.5);

//     dbe_->setCurrentFolder(pathsSummaryHLTPathsPerLSFolder_.c_str());
//     h_name= "HLT_"+label+"_Total_LS";
//     h_title = label+" HLT paths total combined rate [Hz]";
//     MonitorElement* ME_Total_LS = dbe_->book1D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_);
//     ME_Total_LS->setAxisTitle("LS");

//     h_name= "HLT_"+label+"_LS";
//     h_title = label+" HLT paths rate [Hz]";
//     MonitorElement* ME_Group_LS = dbe_->book2D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_, paths.size(), -0.5, paths.size()-0.5);
//     ME_Group_LS->setAxisTitle("LS");
//     /// add this path to the vector of 2D LS paths
//     v_ME_HLTAll_LS.push_back(ME_Group_LS);

    /*
    h_name= "HLT_"+label+"_L1_Total_LS";
    h_title = label+" HLT paths total combined rate [Hz]";
    MonitorElement* ME_Total_L1_LS = dbe_->book1D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_);
    ME_Total_L1_LS->setAxisTitle("LS");

    h_name= "HLT_"+label+"_L1_LS";
    h_title = label+" HLT L1s rate [Hz]";
    MonitorElement* ME_Group_L1_LS = dbe_->book2D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_, paths.size(), -0.5, paths.size()-0.5);
    ME_Group_L1_LS->setAxisTitle("LS");

    dbe_->setCurrentFolder(pathsSummaryHLTPathsPerBXFolder_.c_str());
    h_name= "HLT_"+label+"_BX_LS";
    h_title = label+" HLT paths total count combined per BX ";
    MonitorElement* ME_Total_BX = dbe_->book2D(h_name.c_str(), h_title.c_str(),  nLS_, 0, nLS_, 5, -2.5, 2.5);
    ME_Total_BX->setAxisTitle("LS",1);
    v_ME_Total_BX.push_back(ME_Total_BX);

    h_name= "HLT_"+label+"_BX_LS_Norm";
    h_title = label+" HLT paths total count combined per BX Normalized to LS";
    MonitorElement* ME_Total_BX_Norm = dbe_->book2D(h_name.c_str(), h_title.c_str(),  nLS_, 0, nLS_, 5, -2.5, 2.5);
    ME_Total_BX_Norm->setAxisTitle("LS",1);
    v_ME_Total_BX_Norm.push_back(ME_Total_BX_Norm);
    */

    for(unsigned int i = 0; i < paths.size(); i++){

// //       ME->getTH2F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
// //       ME->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
//       ME_Group_LS->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());

//       ME_Normalized->getTH2F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
//       ME_Normalized->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
//       ME_Normalized_Any->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
      ME_Any->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
      ME_Xsec->getTProfile()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
      ME_XsecScaled->getTProfile()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
      ME_RawCounts->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
    }
    
}

Member Data Documentation

Definition at line 85 of file GeneralHLTOffline.cc.

Definition at line 80 of file GeneralHLTOffline.cc.

Definition at line 87 of file GeneralHLTOffline.cc.

Definition at line 81 of file GeneralHLTOffline.cc.

vector< vector<string> > GeneralHLTOffline::PDsVectorPathsVector [private]

Definition at line 89 of file GeneralHLTOffline.cc.

std::string GeneralHLTOffline::plotDirectoryName [private]

Definition at line 83 of file GeneralHLTOffline.cc.