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 
26 
27  return hltConfigProvider_.init(iRun, iSetup, processName, changed);
28 }
29 
31  // return hltPrescaleTable_.set();
33  int errorTech(0);
34  const int psfsiTech(l1GtUtils_.prescaleFactorSetIndex(iEvent,L1GtUtils::TechnicalTrigger,errorTech));
35  int errorPhys(0);
36  const int psfsiPhys(l1GtUtils_.prescaleFactorSetIndex(iEvent,L1GtUtils::AlgorithmTrigger,errorPhys));
37  assert(psfsiTech==psfsiPhys);
38  if ( (errorTech==0) && (errorPhys==0) &&
39  (psfsiTech>=0) && (psfsiPhys>=0) && (psfsiTech==psfsiPhys) ) {
40  return psfsiPhys;
41  } else {
43  edm::LogError("HLTConfigData")
44  << " Error in determining HLT prescale set index from L1 data using L1GtUtils: "
45  << " Tech/Phys error = " << errorTech << "/" << errorPhys
46  << " Tech/Phys psfsi = " << psfsiTech << "/" << psfsiPhys;
47  return -1;
48  }
49 }
50 
52  const edm::EventSetup& iSetup,
53  const std::string& trigger) {
54  const int set(prescaleSet(iEvent,iSetup));
55  if (set<0) {
56  return 1;
57  } else {
58  return hltConfigProvider_.prescaleValue(static_cast<unsigned int>(set),trigger);
59  }
60 }
61 
62 std::pair<int,int>
64  const edm::EventSetup& iSetup,
65  const std::string& trigger) {
66 
67  // start with setting both L1T and HLT prescale values to 0
68  std::pair<int,int> result(std::pair<int,int>(0,0));
69 
70  // get HLT prescale (possible if HLT prescale set index is correctly found)
71  const int set(prescaleSet(iEvent,iSetup));
72  if (set<0) {
73  result.second = -1;
74  } else {
75  result.second = static_cast<int>(hltConfigProvider_.prescaleValue(static_cast<unsigned int>(set),trigger));
76  }
77 
78  // get L1T prescale - works only for those hlt trigger paths with
79  // exactly one L1GT seed module which has exactly one L1T name as seed
80  const unsigned int nL1GTSeedModules(hltConfigProvider_.hltL1GTSeeds(trigger).size());
81  if (nL1GTSeedModules==0) {
82  // no L1 seed module on path hence no L1 seed hence formally no L1 prescale
83  result.first=1;
84  } else if (nL1GTSeedModules==1) {
86  const std::string l1tname(hltConfigProvider_.hltL1GTSeeds(trigger).at(0).second);
87  int l1error(0);
88  result.first = l1GtUtils_.prescaleFactor(iEvent,l1tname,l1error);
89  if (l1error!=0) {
90  edm::LogError("HLTConfigData")
91  << " Error in determining L1T prescale for HLT path: '" << trigger
92  << "' with L1T seed: '" << l1tname
93  << "' using L1GtUtils: error code = " << l1error << "." << std::endl
94  << " Note: for this method ('prescaleValues'), only a single L1T name (and not a bit number) is allowed as seed!"
95  << std::endl
96  << " For seeds being complex logical expressions, try the new method 'prescaleValuesInDetail'."<< std::endl;
97  result.first = -1;
98  }
99  } else {
101  std::string dump("'"+hltConfigProvider_.hltL1GTSeeds(trigger).at(0).second+"'");
102  for (unsigned int i=1; i!=nL1GTSeedModules; ++i) {
103  dump += " * '"+hltConfigProvider_.hltL1GTSeeds(trigger).at(i).second+"'";
104  }
105  edm::LogError("HLTConfigData")
106  << " Error in determining L1T prescale for HLT path: '" << trigger
107  << "' has multiple L1GTSeed modules, " << nL1GTSeedModules
108  << ", with L1 seeds: " << dump
109  << ". (Note: at most one L1GTSeed module is allowed for a proper determination of the L1T prescale!)";
110  result.first = -1;
111  }
112 
113  return result;
114 }
115 
116 std::pair<std::vector<std::pair<std::string,int> >,int>
118  const edm::EventSetup& iSetup,
119  const std::string& trigger) {
120 
121  std::pair<std::vector<std::pair<std::string,int> >,int> result;
122  result.first.clear();
123 
124  // get HLT prescale (possible if HLT prescale set index is correctly found)
125  const int set(prescaleSet(iEvent,iSetup));
126  if (set<0) {
127  result.second = -1;
128  } else {
129  result.second = static_cast<int>(hltConfigProvider_.prescaleValue(static_cast<unsigned int>(set),trigger));
130  }
131 
132  // get L1T prescale - works only for those hlt trigger paths with
133  // exactly one L1GT seed module which has exactly one L1T name as seed
134  const unsigned int nL1GTSeedModules(hltConfigProvider_.hltL1GTSeeds(trigger).size());
135  if (nL1GTSeedModules==0) {
136  // no L1 seed module on path hence no L1 seed hence formally no L1 prescale
137  result.first.clear();
138  } else if (nL1GTSeedModules==1) {
140  const std::string l1tname(hltConfigProvider_.hltL1GTSeeds(trigger).at(0).second);
142  l1Logical.logicalExpressionRunUpdate(iEvent.getRun(),iSetup,l1tname);
143  const std::vector<std::pair<std::string, int> >& errorCodes(l1Logical.errorCodes(iEvent));
144  result.first = l1Logical.prescaleFactors();
145  int l1error(l1Logical.isValid() ? 0 : 1);
146  for (unsigned int i=0; i<errorCodes.size(); ++i) {
147  l1error += std::abs(errorCodes[i].second);
148  }
149  if (l1error!=0) {
150  std::ostringstream message;
151  message
152  << " Error in determining L1T prescales for HLT path: '" << trigger
153  << "' with complex L1T seed: '" << l1tname
154  << "' using L1GtUtils: " << std::endl
155  << " isValid=" << l1Logical.isValid()
156  << " l1tname/error/prescale " << errorCodes.size()
157  << std::endl;
158  for (unsigned int i=0; i< errorCodes.size(); ++i) {
159  message << " " << i << ":" << errorCodes[i].first << "/" << errorCodes[i].second << "/"
160  << result.first[i].second;
161  }
162  message << ".";
163  edm::LogError("HLTConfigData") << message.str();
164  result.first.clear();
165  }
166  } else {
168  std::string dump("'"+hltConfigProvider_.hltL1GTSeeds(trigger).at(0).second+"'");
169  for (unsigned int i=1; i!=nL1GTSeedModules; ++i) {
170  dump += " * '"+hltConfigProvider_.hltL1GTSeeds(trigger).at(i).second+"'";
171  }
172  edm::LogError("HLTConfigData")
173  << " Error in determining L1T prescale for HLT path: '" << trigger
174  << "' has multiple L1GTSeed modules, " << nL1GTSeedModules
175  << ", with L1 seeds: " << dump
176  << ". (Note: at most one L1GTSeed module is allowed for a proper determination of the L1T prescale!)";
177  result.first.clear();
178  }
179 
180  return result;
181 }
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:63
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)
tuple result
Definition: query.py:137
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 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:41
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