Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:41

0001 #include "Validation/HLTrigger/interface/HLTGenValHistCollPath.h"
0002 
0003 // constructor
0004 HLTGenValHistCollPath::HLTGenValHistCollPath(edm::ParameterSet pathCollConfig, HLTConfigProvider& hltConfig)
0005     : hltConfig_(hltConfig) {
0006   triggerPath_ = pathCollConfig.getParameter<std::string>("triggerPath");
0007   doOnlyLastFilter_ = pathCollConfig.getParameter<bool>("doOnlyLastFilter");
0008 
0009   // before creating the collections for each filter, we'll store the needed configurations in a pset
0010   // we'll copy this basis multiple times and add the respective path later
0011   edm::ParameterSet filterCollConfig;
0012   filterCollConfig.addParameter<std::string>("objType", pathCollConfig.getParameter<std::string>("objType"));
0013   filterCollConfig.addParameter<std::string>("hltProcessName",
0014                                              pathCollConfig.getParameter<std::string>("hltProcessName"));
0015   filterCollConfig.addParameter<double>("dR2limit", pathCollConfig.getParameter<double>("dR2limit"));
0016   filterCollConfig.addParameter<std::string>("pathName", triggerPath_);
0017 
0018   pathStringName_ = triggerPath_ + "-" + pathCollConfig.getParameter<std::string>("objType");
0019 
0020   // this filter will be the denominator
0021   edm::ParameterSet filterCollConfigStepBeforeAny = filterCollConfig;
0022   filterCollConfigStepBeforeAny.addParameter<std::string>("filterName", "beforeAnyFilter");
0023   collectionFilter_.emplace_back(HLTGenValHistCollFilter(filterCollConfigStepBeforeAny));
0024 
0025   // we'll use this to construct the string to find which filters belong to which histogram later
0026   pathString_ = "";
0027 
0028   // getting all filters from path
0029   filters_ = hltConfig_.saveTagsModules(triggerPath_);
0030   if (doOnlyLastFilter_) {
0031     edm::ParameterSet filterCollConfigOnlyLastFilter = filterCollConfig;
0032     filterCollConfigOnlyLastFilter.addParameter<std::string>("filterName", filters_.back());
0033     collectionFilter_.emplace_back(HLTGenValHistCollFilter(filterCollConfigOnlyLastFilter));
0034 
0035     // remove potential leading "-" for printing
0036     std::string filterName = filters_.back();
0037     if (filterName.rfind('-', 0) == 0)
0038       filterName.erase(0, 1);
0039 
0040     pathString_ += filterName;
0041   } else {
0042     for (auto& filter : filters_) {
0043       edm::ParameterSet filterCollConfigStep = filterCollConfig;
0044       filterCollConfigStep.addParameter<std::string>("filterName", filter);
0045       collectionFilter_.emplace_back(HLTGenValHistCollFilter(filterCollConfigStep));
0046 
0047       // remove potential leading "-" for printing
0048       std::string filterName = filter;
0049       if (filterName.rfind('-', 0) == 0)
0050         filterName.erase(0, 1);
0051 
0052       pathString_ += filterName;
0053       if (filter != filters_.back())
0054         pathString_ += ";";
0055     }
0056   }
0057 }
0058 
0059 edm::ParameterSetDescription HLTGenValHistCollPath::makePSetDescription() {
0060   edm::ParameterSetDescription desc;
0061   desc.add<std::string>("objType", "");
0062   desc.add<double>("dR2limit", 0.1);
0063   desc.add<bool>("doOnlyLastFilter", false);
0064   desc.add<std::string>("hltProcessName", "HLT");
0065   desc.add<std::string>("triggerPath", "");
0066   return desc;
0067 }
0068 
0069 // hist booking function
0070 // this just calls the booking for each object in the the filter collection
0071 void HLTGenValHistCollPath::bookHists(DQMStore::IBooker& iBooker,
0072                                       std::vector<edm::ParameterSet>& histConfigs,
0073                                       std::vector<edm::ParameterSet>& histConfigs2D) {
0074   if (!pathString_.empty())
0075     iBooker.bookString("path-" + pathStringName_, pathString_);
0076 
0077   for (auto& collectionFilter : collectionFilter_)
0078     collectionFilter.bookHists(iBooker, histConfigs, histConfigs2D);
0079 }
0080 
0081 // hist filling function
0082 // this just calls the filling for each object in the filter collection
0083 void HLTGenValHistCollPath::fillHists(const HLTGenValObject& obj, edm::Handle<trigger::TriggerEvent>& triggerEvent) {
0084   for (auto& collectionFilter : collectionFilter_)
0085     collectionFilter.fillHists(obj, triggerEvent);
0086 }