36 m_l1GtUtils(ps, consumesCollector(),
false, *this) {
55 m_inputCategories[
"IsoEG"] = Categories.getUntrackedParameter<
bool>(
"IsoEG");
56 m_inputCategories[
"Jet"] = Categories.getUntrackedParameter<
bool>(
"Jet");
57 m_inputCategories[
"CenJet"] = Categories.getUntrackedParameter<
bool>(
"CenJet");
58 m_inputCategories[
"ForJet"] = Categories.getUntrackedParameter<
bool>(
"ForJet");
59 m_inputCategories[
"TauJet"] = Categories.getUntrackedParameter<
bool>(
"TauJet");
60 m_inputCategories[
"ETM"] = Categories.getUntrackedParameter<
bool>(
"ETM");
61 m_inputCategories[
"ETT"] = Categories.getUntrackedParameter<
bool>(
"ETT");
62 m_inputCategories[
"HTT"] = Categories.getUntrackedParameter<
bool>(
"HTT");
63 m_inputCategories[
"HTM"] = Categories.getUntrackedParameter<
bool>(
"HTM");
68 if (!m_outputFile.empty()) {
69 cout <<
"L1T Monitoring histograms will be saved to " << m_outputFile.c_str() << endl;
107 if (srcAlgoXSecFit == 0) {
109 }
else if (srcAlgoXSecFit == 1) {
122 TString tCategory = (*i).first;
123 TString tTrigger = (*i).second;
125 TString tErrorMessage =
"";
130 }
else if (tTrigger ==
"Undefined") {
131 TString tFunc =
"-1";
132 tTestFunction =
new TF1(
"FitParametrization_" + tTrigger, tFunc, 0,
double(
m_maxNbins) - 0.5);
134 TString tFunc =
"-1";
135 tTestFunction =
new TF1(
"FitParametrization_" + tTrigger, tFunc, 0,
double(
m_maxNbins) - 0.5);
136 tErrorMessage =
" (Undefined Test Function)";
138 TString tFunc =
"-1";
139 tTestFunction =
new TF1(
"FitParametrization_" + tTrigger, tFunc, 0,
double(
m_maxNbins) - 0.5);
142 if (tTrigger !=
"Undefined") {
144 tErrorMessage +=
" WARNING: Default Prescale = ";
148 if (tCategory ==
"Mu" && myMenuHelper.
getEtaRangeByAlias(tCategory, tTrigger) != 4294967295) {
149 tErrorMessage +=
" WARNING: Eta Range = ";
151 }
else if (tCategory ==
"EG" && myMenuHelper.
getEtaRangeByAlias(tCategory, tTrigger) != 32639) {
152 tErrorMessage +=
" WARNING: Eta Range = ";
154 }
else if (tCategory ==
"IsoEG" && myMenuHelper.
getEtaRangeByAlias(tCategory, tTrigger) != 32639) {
155 tErrorMessage +=
" WARNING: Eta Range = ";
159 if (tCategory ==
"Mu" && myMenuHelper.
getQualityAlias(tCategory, tTrigger) != 240) {
160 tErrorMessage +=
" WARNING: Quality = ";
167 "Cross Sec. vs Inst. Lumi Algo: " + tTrigger + tErrorMessage,
169 minInstantLuminosity,
170 maxInstantLuminosity,
173 m_xSecVsInstLumi[tTrigger]->setAxisTitle(
"Instantaneous Luminosity [10^{30}cm^{-2}s^{-1}]", 1);
175 m_xSecVsInstLumi[tTrigger]->getTProfile()->GetListOfFunctions()->Add(tTestFunction);
189 cout <<
"[L1TRate:] Called beginRun." << endl;
203 cout <<
"[L1TRate:] Called endLuminosityBlock at LS=" << eventLS << endl;
213 bool isDefRate, isDefLumi, isDefPrescaleIndex;
214 map<TString, double>* rates =
nullptr;
216 int prescalesIndex = 0;
220 string tTrigger = (*i).second;
226 unsigned int ls = (*i).first;
227 rates = &(*i).second;
238 isDefPrescaleIndex =
false;
240 isDefPrescaleIndex =
true;
244 if (isDefRate && isDefLumi && isDefPrescaleIndex) {
245 const vector<int>& currentPrescaleFactors = (*m_listsPrescaleFactors).at(prescalesIndex);
248 string tTrigger = (*i).second;
249 TF1* tTestFunction = (TF1*)
m_xSecVsInstLumi[tTrigger]->getTProfile()->GetListOfFunctions()->First();
252 if (tTrigger !=
"Undefined") {
253 unsigned int trigBit =
m_algoBit[tTrigger];
254 double trigPrescale = currentPrescaleFactors[trigBit];
255 double trigRate = (*rates)[tTrigger];
257 if (lumi != 0 && trigPrescale != 0 && trigRate != 0) {
258 double AlgoXSec = (trigPrescale * trigRate) / lumi;
259 double TemplateFunctionValue = tTestFunction->Eval(lumi);
267 cout <<
"[L1TRate:] ls=" << ls <<
" Algo=" << tTrigger <<
" XSec=" << AlgoXSec
268 <<
" Test=" << AlgoXSec / TemplateFunctionValue << endl;
275 cout <<
"[L1TRate:] Algo=" << tTrigger <<
" XSec=Failed" << endl;
295 int EventRun = iEvent.
id().
run();
299 if (triggerScalers.
isValid()) {
300 Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
308 cout <<
"[L1TRate:] Buffering GT Rates for LS=" << gtLS << endl;
310 map<TString, double> bufferRate;
314 string tTrigger = (*i).second;
317 if (tTrigger !=
"Undefined") {
318 unsigned int trigBit =
m_algoBit[tTrigger];
321 bufferRate[tTrigger] = trigRate;
329 if (colLScal.
isValid() && !colLScal->empty()) {
330 LumiScalersCollection::const_iterator itLScal = colLScal->begin();
331 unsigned int scalLS = itLScal->sectionNumber();
336 cout <<
"[L1TRate:] Buffering SCAL-HF Lumi for LS=" << scalLS << endl;
338 double instLumi = itLScal->instantLumi();
339 double deadTimeNormHF = itLScal->deadTimeNormalization();
345 if (deadTimeNormHF == 0) {
348 instLumi = instLumi / deadTimeNormHF;
357 if (gtReadoutRecordData.
isValid()) {
361 cout <<
"[L1TRate:] Buffering Prescale Index for LS=" << eventLS << endl;
365 const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
369 for (
unsigned int i = 0;
i < gtFdlVectorData.size();
i++) {
370 if (gtFdlVectorData[
i].bxInEvent() == 0) {
376 int CurrentPrescalesIndex = gtFdlVectorData[indexFDL].gtPrescaleFactorIndexAlgo();
395 string pathCondDB = ps.
getParameter<
string>(
"pathCondDB");
399 myOMDSHelper.
connect(oracleDB, pathCondDB, conError);
401 map<string, WbMTriggerXSecFit> wbmFits;
405 wbmFits = myOMDSHelper.getWbMAlgoXsecFits(errorRetrive);
410 string eName = myOMDSHelper.enumToStringError(errorRetrive);
415 string eName = myOMDSHelper.enumToStringError(conError);
424 string tTrigger = (*a).second;
427 if (tTrigger !=
"Undefined") {
428 if (wbmFits.find(tTrigger) != wbmFits.end()) {
431 vector<double> tParameters;
432 tParameters.push_back(tWbMParameters.
pm1);
433 tParameters.push_back(tWbMParameters.
p0);
434 tParameters.push_back(tWbMParameters.
p1);
435 tParameters.push_back(tWbMParameters.
p2);
440 minInstantLuminosity,
441 maxInstantLuminosity);
469 std::vector<edm::ParameterSet> m_fitParameters = ps.
getParameter<vector<ParameterSet> >(
"fitParameters");
476 string tTrigger = (*a).second;
479 if (tTrigger !=
"Undefined") {
480 bool foundFit =
false;
482 for (
unsigned int b = 0;
b < m_fitParameters.size();
b++) {
483 if (tTrigger == m_fitParameters[
b].getParameter<string>(
"AlgoName")) {
484 TString tAlgoName = m_fitParameters[
b].getParameter<
string>(
"AlgoName");
485 TString tTemplateFunction = m_fitParameters[
b].getParameter<
string>(
"TemplateFunction");
486 vector<double> tParameters = m_fitParameters[
b].getParameter<vector<double> >(
"Parameters");
490 new TF1(
"FitParametrization_" + tAlgoName, tTemplateFunction, minInstantLuminosity, maxInstantLuminosity);
491 m_templateFunctions[tTrigger]->SetParameters(&tParameters[0]);
492 m_templateFunctions[tTrigger]->SetLineWidth(1);
493 m_templateFunctions[tTrigger]->SetLineColor(kRed);
501 string eName =
"WARNING_PY_MISSING_FIT";
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
std::map< TString, TF1 * > m_templateFunctions
std::map< int, std::map< TString, double > > m_lsRates
void retrieveL1EventSetup(const edm::EventSetup &, bool isRun=true)
retrieve all the relevant L1 trigger event setup records and cache them to improve the speed ...
const edm::EventSetup & c
edm::EDGetTokenT< LumiScalersCollection > m_scalersSource_colLScal
edm::EDGetTokenT< Level1TriggerScalersCollection > m_scalersSource_triggerScalers
void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
bool connect(std::string iOracleDB, std::string iPathCondDB, int &error)
virtual void setCurrentFolder(std::string const &fullpath)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtDataDaqInputTag
std::map< std::string, bool > m_inputCategories
edm::ParameterSet m_parameters
LuminosityBlockNumber_t luminosityBlock() const
const edm::ESGetToken< L1GtPrescaleFactors, L1GtPrescaleFactorsAlgoTrigRcd > m_l1GtPfAlgoToken
void endLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
std::vector< double > gtAlgoCountsRate() const
bool getData(T &iHolder) const
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
bool getXSexFitsPython(const edm::ParameterSet &ps)
const std::vector< std::vector< int > > * m_listsPrescaleFactors
std::map< TString, int > m_algoBit
L1TRate(const edm::ParameterSet &ps)
bool getXSexFitsOMDS(const edm::ParameterSet &ps)
void analyze(const edm::Event &e, const edm::EventSetup &c) override
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
std::map< TString, MonitorElement * > m_xSecVsInstLumi
std::map< TString, MonitorElement * > m_xSecObservedToExpected
L1TMenuHelper::Tokens m_helperTokens
std::map< std::string, std::string > m_selectedTriggers
const std::vector< std::vector< int > > & gtPrescaleFactors() const
get the prescale factors by reference
T getParameter(std::string const &) const
LuminosityBlockNumber_t luminosityBlock() const
MonitorElement * m_ErrorMonitor
const edm::ESGetToken< L1GtTriggerMenu, L1GtTriggerMenuRcd > m_menuToken
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
std::map< int, double > m_lsLuminosity
void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &, const edm::EventSetup &) override
std::map< int, int > m_lsPrescaleIndex