CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTTauDQMAutomation.cc
Go to the documentation of this file.
3 #include <boost/regex.hpp>
4 
6 }
7 
8 HLTTauDQMAutomation::HLTTauDQMAutomation( std::string hltProcessName, double L1MatchDr, double HLTMatchDr ) {
9  hltProcessName_ = hltProcessName;
10  L1MatchDr_ = L1MatchDr;
11  HLTMatchDr_ = HLTMatchDr;
12 }
13 
15 }
16 
17 void HLTTauDQMAutomation::AutoCompleteConfig( std::vector<edm::ParameterSet>& config, HLTConfigProvider const& HLTCP ) {
18  //Find tau trigger paths
19  boost::regex reTau(".*Tau.*");
20  std::map<std::string,HLTTauDQMFilter> filters;
21  if ( HLTCP.inited() ) {
22  const std::vector<std::string>& triggerNames = HLTCP.triggerNames();
23  for ( std::vector<std::string>::const_iterator ipath = triggerNames.begin(); ipath != triggerNames.end(); ++ipath ) {
24  if ( boost::regex_match(*ipath, reTau) && HLTCP.prescaleValue(0,*ipath) > 0 ) {
26  selectHLTTauDQMFilter(filters, tmp);
27  }
28  }
29  }
30 
31  //Add PFTau paths
32  boost::regex reMuTau("Mu(.+?)Tau");
33  boost::smatch what;
34  std::map<std::string,HLTTauDQMFilter> pfTauFilters;
35  for ( std::map<std::string,HLTTauDQMFilter>::const_iterator ipath = filters.begin(); ipath != filters.end(); ++ipath ) {
36  std::string::const_iterator start = ipath->first.begin();
37  std::string::const_iterator end = ipath->first.end();
38  if ( boost::regex_match(start, end, what, reMuTau) ) {
39  HLTTauDQMFilter tmp(ipath->second.name(), what[1]+"PFTau", HLTCP.prescaleValue(0,ipath->second.name()), hltProcessName_, L1MatchDr_, HLTMatchDr_, 1, 0, 0);
40  selectHLTTauDQMFilter(pfTauFilters, tmp);
41  }
42  }
43  filters.insert(pfTauFilters.begin(),pfTauFilters.end());
44 
45  //Auto configuration
46  std::vector<edm::ParameterSet>::iterator lpsum = config.end();
47  std::vector<std::map<std::string,HLTTauDQMFilter>::iterator> selectedFilters;
48  for ( std::vector<edm::ParameterSet>::iterator iconfig = config.begin(); iconfig != config.end(); ++iconfig ) {
49  std::string configtype;
50  try {
51  configtype = iconfig->getUntrackedParameter<std::string>("ConfigType");
52  } catch ( cms::Exception &e ) {
53  edm::LogWarning("HLTTauDQMAutomation") << e.what() << std::endl;
54  continue;
55  }
56  if (configtype == "Path") {
57  try {
58  if ( iconfig->getUntrackedParameter<std::vector<edm::ParameterSet> >("Filters",std::vector<edm::ParameterSet>()).size() == 0 ) {
59  std::string triggerName = iconfig->getUntrackedParameter<std::string>("DQMFolder");
60  std::map<std::string,HLTTauDQMFilter>::iterator iter = findFilter(filters,triggerName);
61  if ( iter != filters.end() ) {
62  iconfig->addUntrackedParameter<std::string>("DQMFolder", iter->first);
63  iconfig->addUntrackedParameter<std::vector<edm::ParameterSet> >("Filters", iter->second.getPSets(HLTCP) );
64  iconfig->addUntrackedParameter<edm::ParameterSet >("Reference", iter->second.getRefPSet());
65  selectedFilters.push_back(iter);
66  }
67  }
68  } catch ( cms::Exception &e ) {
69  edm::LogWarning("HLTTauDQMAutomation") << e.what() << std::endl;
70  continue;
71  }
72  }
73  else if (configtype == "LitePath") {
74  try {
75  if ( iconfig->getUntrackedParameter<std::vector<edm::ParameterSet> >("Filters",std::vector<edm::ParameterSet>()).size() == 0 ) {
76  std::string triggerName = iconfig->getUntrackedParameter<std::string>("DQMFolder");
77  if ( triggerName != "Summary" ) {
78  std::map<std::string,HLTTauDQMFilter>::iterator iter = findFilter(filters,triggerName);
79  if ( iter != filters.end() ) {
80  iconfig->addUntrackedParameter<std::string>("DQMFolder", iter->first);
81  iconfig->addUntrackedParameter<std::vector<edm::ParameterSet> >("Filters", iter->second.getPSets(HLTCP) );
82  selectedFilters.push_back(iter);
83  }
84  } else {
85  lpsum = iconfig;
86  }
87  }
88  } catch ( cms::Exception &e ) {
89  edm::LogWarning("HLTTauDQMAutomation") << e.what() << std::endl;
90  continue;
91  }
92  }
93  }
94 
95  //Configure litepath summary
96  if ( lpsum != config.end() ) {
97  std::vector<edm::ParameterSet> filterSet;
98  for ( std::vector<std::map<std::string,HLTTauDQMFilter>::iterator>::iterator ifilter = selectedFilters.begin(); ifilter != selectedFilters.end(); ++ifilter ) {
99  if ( !((*ifilter)->second.getSummaryPSet(HLTCP).empty()) ) {
100  filterSet.push_back((*ifilter)->second.getSummaryPSet(HLTCP));
101  }
102  }
103  lpsum->addUntrackedParameter<std::vector<edm::ParameterSet> >("Filters", filterSet );
104  }
105 }
106 
108  //Find tau trigger paths
109  boost::regex reTau(".*Tau.*");
110  std::map<std::string,HLTTauDQMFilter> filters;
111  if ( HLTCP.inited() ) {
112  const std::vector<std::string>& triggerNames = HLTCP.triggerNames();
113  for ( std::vector<std::string>::const_iterator ipath = triggerNames.begin(); ipath != triggerNames.end(); ++ipath ) {
114  if ( boost::regex_match(*ipath, reTau) && HLTCP.prescaleValue(0,*ipath) > 0 ) {
116  selectHLTTauDQMFilter(filters, tmp);
117  }
118  }
119  }
120 
121  //Auto configuration
122  if ( config.getUntrackedParameter<bool>("doMatching") ) {
123  std::vector<edm::ParameterSet> matchingFilters = config.getUntrackedParameter<std::vector<edm::ParameterSet> >("matchFilters");
124  for ( std::vector<edm::ParameterSet>::iterator imatch = matchingFilters.begin(); imatch != matchingFilters.end(); ++imatch ) {
125  std::string autoFilterName = imatch->getUntrackedParameter<std::string>("AutomaticFilterName","");
126  if ( autoFilterName != "" ) {
127  try {
128  std::map<std::string,HLTTauDQMFilter>::iterator iter = findFilter(filters,autoFilterName);
129  if ( iter != filters.end() ) {
130  std::map<int,std::string> modules = iter->second.interestingModules(HLTCP);
131  boost::regex exprEle(moduleType);
132  std::string selectedModule = "";
133  for ( std::map<int,std::string>::const_iterator imodule = modules.begin(); imodule != modules.end(); ++imodule ) {
134  const std::string& mType = HLTCP.moduleType(imodule->second);
135  std::string::const_iterator start = mType.begin();
136  std::string::const_iterator end = mType.end();
137  if ( boost::regex_match(start, end, exprEle) ) {
138  selectedModule = imodule->second;
139  break;
140  }
141  }
142 
143  imatch->addUntrackedParameter<edm::InputTag>("FilterName", edm::InputTag(selectedModule,"",hltProcessName_) );
144  } else {
145  imatch->addUntrackedParameter<edm::InputTag>("FilterName", edm::InputTag("","",hltProcessName_) );
146  }
147  } catch ( cms::Exception &e ) {
148  edm::LogWarning("HLTTauDQMAutomation") << e.what() << std::endl;
149  continue;
150  }
151  }
152  }
153  config.addUntrackedParameter<std::vector<edm::ParameterSet> >("matchFilters", matchingFilters );
154  }
155 }
156 
157 bool HLTTauDQMAutomation::selectHLTTauDQMFilter(std::map<std::string,HLTTauDQMFilter>& container, HLTTauDQMFilter const& filter) {
158  bool inserted = false;
159  std::map<std::string,HLTTauDQMFilter>::iterator iter = container.find(filter.type());
160  if ( iter == container.end() ) {
161  container.insert(std::make_pair(filter.type(), filter));
162  inserted = true;
163  } else {
164  iter->second = iter->second.select(filter,inserted);
165  }
166  return inserted;
167 }
168 
169 std::map<std::string,HLTTauDQMFilter>::iterator HLTTauDQMAutomation::findFilter(std::map<std::string,HLTTauDQMFilter>& container, std::string const& triggerName) {
170  boost::regex re("[a-zA-Z_]+");
171  std::map<std::string,HLTTauDQMFilter>::iterator iter;
172  if ( boost::regex_match(triggerName, re) ) {
173  iter = container.find(triggerName);
174  return iter;
175  } else {
176  boost::regex tmpRe(triggerName);
177  for ( iter = container.begin(); iter != container.end(); ++iter ) {
178  if ( boost::regex_match(iter->first, tmpRe) ) { //Always take the first matching path
179  return iter;
180  }
181  }
182  }
183  return container.end();
184 }
virtual char const * what() const
Definition: Exception.cc:141
T getUntrackedParameter(std::string const &, T const &) const
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
const std::string moduleType(const std::string &module) const
C++ class name of module.
std::map< std::string, HLTTauDQMFilter >::iterator findFilter(std::map< std::string, HLTTauDQMFilter > &container, std::string const &triggerName)
void AutoCompleteConfig(std::vector< edm::ParameterSet > &config, HLTConfigProvider const &HLTCP)
const std::vector< std::string > & triggerNames() const
names of trigger paths
void AutoCompleteMatching(edm::ParameterSet &config, HLTConfigProvider const &HLTCP, std::string moduleType)
std::vector< TPRegexp > filters
Definition: eve_filter.cc:25
bool inited() const
Accessors (const methods)
unsigned int prescaleValue(unsigned int set, const std::string &trigger) const
HLT prescale value in specific prescale set for a specific trigger path.
#define end
Definition: vmac.h:38
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:209
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
bool selectHLTTauDQMFilter(std::map< std::string, HLTTauDQMFilter > &container, HLTTauDQMFilter const &filter)
std::string type() const