1 #ifndef RecoLuminosity_LumiProducer_LumiCalculator_h
2 #define RecoLuminosity_LumiProducer_LumiCalculator_h
14 #include <boost/regex.hpp>
49 std::map<std::string, hltPerPathInfo>
hltmap_;
50 std::map<std::string, l1PerBitInfo>
l1map_;
63 consumes<LumiSummary, edm::InLumi>(
edm::InputTag(
"lumiProducer",
""));
64 consumes<LumiSummaryRunHeader, edm::InRun>(
edm::InputTag(
"lumiProducer",
""));
103 *
log_ <<
"======Trigger Configuration Overview======\n";
107 for (
unsigned int t = 0;
t < totaltrg; ++
t) {
111 *
log_ <<
t <<
" HLT path\t" << hltname <<
"\n";
115 hltmap_.insert(std::make_pair(hltname, hlt));
116 std::vector<std::string>::iterator hltpathBeg = numpathmodules.begin();
117 std::vector<std::string>::iterator hltpathEnd = numpathmodules.end();
118 unsigned int mycounter = 0;
119 for (std::vector<std::string>::iterator numpathmodule = hltpathBeg; numpathmodule != hltpathEnd; ++numpathmodule) {
130 *
log_ <<
"\tskip and erase previous seeds : multiple L1SeedsLogicalExpressions per hlt path\n";
136 if (l1pathname.find(
'(') != std::string::npos) {
138 *
log_ <<
" L1SeedsLogicalExpression(Complex)\t" << l1pathname <<
"\n";
139 *
log_ <<
"\tskip:contain complex logic\n";
142 }
else if (l1pathname.find(
"OR") != std::string::npos) {
144 *
log_ <<
" L1SeedsLogicalExpression(ORed)\t" << l1pathname <<
"\n";
147 if (seeds.size() > 2) {
149 *
log_ <<
"\tskip:contain >1 OR\n";
153 for (std::vector<std::string>::iterator
i = seeds.begin();
i != seeds.end(); ++
i) {
155 *
log_ <<
"\t\tseed: " << *
i <<
"\n";
156 if (
i == seeds.begin()) {
161 }
else if (l1pathname.find(
"AND") != std::string::npos) {
163 *
log_ <<
" L1SeedsLogicalExpression(ANDed)\t" << l1pathname <<
"\n";
166 if (seeds.size() > 2) {
168 *
log_ <<
"\tskip:contain >1 AND\n";
172 for (std::vector<std::string>::iterator
i = seeds.begin();
i != seeds.end(); ++
i) {
174 *
log_ <<
"\t\tseed: " << *
i <<
"\n";
175 if (
i == seeds.begin()) {
182 *
log_ <<
" L1SeedsLogicalExpression(ONE)\t" << l1pathname <<
"\n";
186 *
log_ <<
"\tskip:contain NOT\n";
190 trgpathMmap_.insert(std::make_pair(hltname, l1pathname));
195 *
log_ <<
"================\n";
207 lumiBlock.
getByLabel(
"lumiProducer", lumiSummary);
219 l.
intglumi = lumiSummary->avgInsDelLumi() * 93.244;
231 std::map<std::string, hltPerPathInfo>::iterator hltit;
232 std::map<std::string, hltPerPathInfo>::iterator hltitBeg =
hltmap_.begin();
233 std::map<std::string, hltPerPathInfo>::iterator hltitEnd =
hltmap_.end();
235 typedef std::pair<std::multimap<std::string, std::string>::iterator,
236 std::multimap<std::string, std::string>::iterator>
239 for (hltit = hltitBeg; hltit != hltitEnd; ++hltit) {
241 *
log_ << c <<
" HLT path " << hltname <<
" , prescale : " << hltit->second.prescale <<
"\n";
244 if (ppp.first == ppp.second) {
247 for (std::multimap<std::string, std::string>::iterator mit = ppp.first; mit != ppp.second; ++mit) {
249 *
log_ <<
" L1 name : " << l1name;
250 LumiSummary::L1 l1result = lumiSummary->l1info(lumiSummaryRH->getL1Index(l1name));
268 size_t n = lumiSummary->nTriggerLine();
269 for (
size_t i = 0;
i <
n; ++
i) {
270 std::string l1bitname = lumiSummaryRH->getL1Name(lumiSummary->l1info(
i).triggernameidx);
273 t.
prescale = lumiSummary->l1info(
i).prescale;
274 l1map_.insert(std::make_pair(l1bitname, t));
303 std::vector<MyPerLumiInfo>::const_iterator lumiIt;
304 std::vector<MyPerLumiInfo>::const_iterator lumiItBeg =
perrunlumiinfo_.begin();
305 std::vector<MyPerLumiInfo>::const_iterator lumiItEnd =
perrunlumiinfo_.end();
306 float recorded = 0.0;
308 *
log_ <<
"================ Run Summary " << run.
run() <<
"================\n";
309 for (lumiIt = lumiItBeg; lumiIt != lumiItEnd; ++lumiIt) {
310 recorded += lumiIt->intglumi * lumiIt->livefraction;
312 *
log_ <<
" CMS Recorded Lumi (e+27cm^-2) : " << recorded <<
"\n";
313 *
log_ <<
" Effective Lumi (e+27cm^-2) per trigger path: "
315 std::multimap<std::string, std::string>::iterator it;
316 std::multimap<std::string, std::string>::iterator itBeg =
trgpathMmap_.begin();
317 std::multimap<std::string, std::string>::iterator itEnd =
trgpathMmap_.end();
319 for (it = itBeg; it != itEnd; ++it) {
320 *
log_ <<
" " << cc <<
" " << it->first <<
" - " << it->second <<
" : ";
322 std::map<std::string, hltPerPathInfo>::const_iterator hltIt =
hltmap_.find(it->first);
324 std::cout <<
"HLT path " << it->first <<
" not found" << std::endl;
328 std::map<std::string, l1PerBitInfo>::const_iterator l1It =
l1map_.find(it->second);
329 if (l1It ==
l1map_.end()) {
330 std::cout <<
"L1 bit " << it->second <<
" not found" << std::endl;
334 unsigned int hltprescale = hltIt->second.prescale;
335 unsigned int l1prescale = l1It->second.prescale;
336 if (hltprescale != 0 && l1prescale != 0) {
337 float effectiveLumi = recorded / (hltprescale * l1prescale);
338 *
log_ << effectiveLumi <<
"\n";
340 *
log_ <<
"0 prescale exception\n";
351 std::vector<std::string> vecstrResult;
352 boost::regex re(separator);
353 boost::sregex_token_iterator
p(strValue.begin(), strValue.end(), re, -1);
354 boost::sregex_token_iterator
end;
356 vecstrResult.push_back(*
p++);
unsigned int size() const
number of trigger paths in trigger table
LuminosityBlockID id() const
bool getByLabel(std::string const &label, Handle< PROD > &result) const
T getUntrackedParameter(std::string const &, T const &) const
const edm::EventSetup & c
void endLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
const std::string moduleType(const std::string &module) const
C++ class name of module.
const std::string & triggerName(unsigned int triggerIndex) const
std::vector< std::string > splitpathstr(const std::string &strValue, const std::string separator)
unsigned int currentlumi_
#define DEFINE_FWK_MODULE(type)
~LumiCalculator() override
const std::string & tableName() const
HLT ConfDB table name.
const edm::ParameterSet & modulePSet(const std::string &module) const
ParameterSet of module.
std::vector< MyPerLumiInfo > perrunlumiinfo_
bool getByLabel(std::string const &label, Handle< PROD > &result) const
std::map< std::string, l1PerBitInfo > l1map_
void endRun(edm::Run const &, edm::EventSetup const &) override
LumiCalculator(edm::ParameterSet const &pset)
void beginRun(const edm::Run &run, const edm::EventSetup &c) override
unsigned long long deadcount
HLTConfigProvider hltConfig_
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
Log< level::Info, false > LogInfo
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
T getParameter(std::string const &) const
LuminosityBlockNumber_t luminosityBlock() const
std::multimap< std::string, std::string > trgpathMmap_
std::map< std::string, hltPerPathInfo > hltmap_
void analyze(edm::Event const &e, edm::EventSetup const &c) override
static std::string const separator(":")
tuple size
Write out results.
Run const & getRun() const