CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTPrescaleProvider.cc
Go to the documentation of this file.
1 
12 
13 #include <cassert>
14 #include <sstream>
15 
16 static const bool useL1EventSetup(true);
17 static const bool useL1GtTriggerMenuLite(false);
18 
20  const edm::EventSetup& iSetup,
21  const std::string& processName,
22  bool& changed) {
23 
24  count_[0]=0;
25  count_[1]=0;
26  count_[2]=0;
27  count_[3]=0;
28  count_[4]=0;
29 
32 
33  return hltConfigProvider_.init(iRun, iSetup, processName, changed);
34 }
35 
37  // return hltPrescaleTable_.set();
39  int errorTech(0);
40  const int psfsiTech(l1GtUtils_.prescaleFactorSetIndex(iEvent,L1GtUtils::TechnicalTrigger,errorTech));
41  int errorPhys(0);
42  const int psfsiPhys(l1GtUtils_.prescaleFactorSetIndex(iEvent,L1GtUtils::AlgorithmTrigger,errorPhys));
43  assert(psfsiTech==psfsiPhys);
44  if ( (errorTech==0) && (errorPhys==0) &&
45  (psfsiTech>=0) && (psfsiPhys>=0) && (psfsiTech==psfsiPhys) ) {
46  return psfsiPhys;
47  } else {
49  if (count_[0]<2) {
50  count_[0] += 1;
51  edm::LogError("HLTConfigData")
52  << " Error in determining HLT prescale set index from L1 data using L1GtUtils: "
53  << " Tech/Phys error = " << errorTech << "/" << errorPhys
54  << " Tech/Phys psfsi = " << psfsiTech << "/" << psfsiPhys;
55  }
56  return -1;
57  }
58 }
59 
61  const edm::EventSetup& iSetup,
62  const std::string& trigger) {
63  const int set(prescaleSet(iEvent,iSetup));
64  if (set<0) {
65  return 1;
66  } else {
67  return hltConfigProvider_.prescaleValue(static_cast<unsigned int>(set),trigger);
68  }
69 }
70 
71 std::pair<int,int>
73  const edm::EventSetup& iSetup,
74  const std::string& trigger) {
75 
76  // start with setting both L1T and HLT prescale values to 0
77  std::pair<int,int> result(std::pair<int,int>(0,0));
78 
79  // get HLT prescale (possible if HLT prescale set index is correctly found)
80  const int set(prescaleSet(iEvent,iSetup));
81  if (set<0) {
82  result.second = -1;
83  } else {
84  result.second = static_cast<int>(hltConfigProvider_.prescaleValue(static_cast<unsigned int>(set),trigger));
85  }
86 
87  // get L1T prescale - works only for those hlt trigger paths with
88  // exactly one L1GT seed module which has exactly one L1T name as seed
89  const unsigned int nL1GTSeedModules(hltConfigProvider_.hltL1GTSeeds(trigger).size());
90  if (nL1GTSeedModules==0) {
91  // no L1 seed module on path hence no L1 seed hence formally no L1 prescale
92  result.first=1;
93  } else if (nL1GTSeedModules==1) {
95  const std::string l1tname(hltConfigProvider_.hltL1GTSeeds(trigger).at(0).second);
96  int l1error(0);
97  result.first = l1GtUtils_.prescaleFactor(iEvent,l1tname,l1error);
98  if (l1error!=0) {
99  if (count_[1]<2) {
100  count_[1] += 1;
101  edm::LogError("HLTConfigData")
102  << " Error in determining L1T prescale for HLT path: '" << trigger
103  << "' with L1T seed: '" << l1tname
104  << "' using L1GtUtils: error code = " << l1error << "." << std::endl
105  << " Note: for this method ('prescaleValues'), only a single L1T name (and not a bit number) is allowed as seed!"
106  << std::endl
107  << " For seeds being complex logical expressions, try the new method 'prescaleValuesInDetail'."<< std::endl;
108  }
109  result.first = -1;
110  }
111  } else {
113  if (count_[2]<2) {
114  count_[2] += 1;
115  std::string dump("'"+hltConfigProvider_.hltL1GTSeeds(trigger).at(0).second+"'");
116  for (unsigned int i=1; i!=nL1GTSeedModules; ++i) {
117  dump += " * '"+hltConfigProvider_.hltL1GTSeeds(trigger).at(i).second+"'";
118  }
119  edm::LogError("HLTConfigData")
120  << " Error in determining L1T prescale for HLT path: '" << trigger
121  << "' has multiple L1GTSeed modules, " << nL1GTSeedModules
122  << ", with L1 seeds: " << dump
123  << ". (Note: at most one L1GTSeed module is allowed for a proper determination of the L1T prescale!)";
124  }
125  result.first = -1;
126  }
127 
128  return result;
129 }
130 
131 std::pair<std::vector<std::pair<std::string,int> >,int>
133  const edm::EventSetup& iSetup,
134  const std::string& trigger) {
135 
136  std::pair<std::vector<std::pair<std::string,int> >,int> result;
137  result.first.clear();
138 
139  // get HLT prescale (possible if HLT prescale set index is correctly found)
140  const int set(prescaleSet(iEvent,iSetup));
141  if (set<0) {
142  result.second = -1;
143  } else {
144  result.second = static_cast<int>(hltConfigProvider_.prescaleValue(static_cast<unsigned int>(set),trigger));
145  }
146 
147  // get L1T prescale - works only for those hlt trigger paths with
148  // exactly one L1GT seed module which has exactly one L1T name as seed
149  const unsigned int nL1GTSeedModules(hltConfigProvider_.hltL1GTSeeds(trigger).size());
150  if (nL1GTSeedModules==0) {
151  // no L1 seed module on path hence no L1 seed hence formally no L1 prescale
152  result.first.clear();
153  } else if (nL1GTSeedModules==1) {
155  const std::string l1tname(hltConfigProvider_.hltL1GTSeeds(trigger).at(0).second);
157  l1Logical.logicalExpressionRunUpdate(iEvent.getRun(),iSetup,l1tname);
158  const std::vector<std::pair<std::string, int> >& errorCodes(l1Logical.errorCodes(iEvent));
159  result.first = l1Logical.prescaleFactors();
160  int l1error(l1Logical.isValid() ? 0 : 1);
161  for (unsigned int i=0; i<errorCodes.size(); ++i) {
162  l1error += std::abs(errorCodes[i].second);
163  }
164  if (l1error!=0) {
165  if (count_[3]<2) {
166  count_[3] += 1;
167  std::ostringstream message;
168  message
169  << " Error in determining L1T prescales for HLT path: '" << trigger
170  << "' with complex L1T seed: '" << l1tname
171  << "' using L1GtUtils: " << std::endl
172  << " isValid=" << l1Logical.isValid()
173  << " l1tname/error/prescale " << errorCodes.size()
174  << std::endl;
175  for (unsigned int i=0; i< errorCodes.size(); ++i) {
176  message << " " << i << ":" << errorCodes[i].first << "/" << errorCodes[i].second << "/"
177  << result.first[i].second;
178  }
179  message << ".";
180  edm::LogError("HLTConfigData") << message.str();
181  }
182  result.first.clear();
183  }
184  } else {
186  if (count_[4]<2) {
187  count_[4] += 1;
188  std::string dump("'"+hltConfigProvider_.hltL1GTSeeds(trigger).at(0).second+"'");
189  for (unsigned int i=1; i!=nL1GTSeedModules; ++i) {
190  dump += " * '"+hltConfigProvider_.hltL1GTSeeds(trigger).at(i).second+"'";
191  }
192  edm::LogError("HLTConfigData")
193  << " Error in determining L1T prescale for HLT path: '" << trigger
194  << "' has multiple L1GTSeed modules, " << nL1GTSeedModules
195  << ", with L1 seeds: " << dump
196  << ". (Note: at most one L1GTSeed module is allowed for a proper determination of the L1T prescale!)";
197  }
198  result.first.clear();
199  }
200 
201  return result;
202 }
HLTConfigProvider hltConfigProvider_
int i
Definition: DBlmapReader.cc:9
std::pair< std::vector< std::pair< std::string, int > >, int > prescaleValuesInDetail(const edm::Event &iEvent, const edm::EventSetup &iSetup, const std::string &trigger)
const int prescaleFactorSetIndex(const edm::Event &iEvent, const TriggerCategory &trigCategory, int &errorCode) const
Definition: L1GtUtils.cc:1458
const std::vector< std::vector< std::pair< bool, std::string > > > & hltL1GTSeeds() const
assert(m_qm.get())
Run const & getRun() const
Definition: Event.cc:65
tuple result
Definition: mps_fire.py:95
U second(std::pair< T, U > const &p)
unsigned int prescaleValue(unsigned int set, const std::string &trigger) const
HLT prescale value in specific prescale set for a specific trigger path.
int iEvent
Definition: GenABIO.cc:230
static const bool useL1GtTriggerMenuLite(false)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int prescaleSet(const edm::Event &iEvent, const edm::EventSetup &iSetup)
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
std::pair< int, int > prescaleValues(const edm::Event &iEvent, const edm::EventSetup &iSetup, const std::string &trigger)
Combined L1T (pair.first) and HLT (pair.second) prescales per HLT path.
void getL1GtRunCache(const edm::Run &, const edm::EventSetup &, const bool, const bool)
get all the run-constant quantities for L1 trigger and cache them
Definition: L1GtUtils.cc:319
unsigned char count_[5]
unsigned int prescaleValue(const edm::Event &iEvent, const edm::EventSetup &iSetup, const std::string &trigger)
combining the two methods above
static const bool useL1EventSetup(true)
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
Definition: Run.h:43
const int prescaleFactor(const edm::Event &iEvent, const std::string &nameAlgoTechTrig, int &errorCode) const
return prescale factor for a given algorithm or technical trigger
Definition: L1GtUtils.cc:1223