37 m_scalersSource = consumes<Level1TriggerScalersCollection>(
pset.getParameter<
InputTag>(
"inputTagScalersResults"));
38 m_l1GtDataDaqInputTag = consumes<L1GlobalTriggerReadoutRecord>(
pset.getParameter<
InputTag>(
"inputTagL1GtDataDaq"));
39 m_l1GtEvmSource = consumes<L1GlobalTriggerEvmReadoutRecord>(
pset.getParameter<
InputTag>(
"inputTagtEvmSource"));
40 m_verbose =
pset.getUntrackedParameter<
bool>(
"verbose",
false);
43 m_monitorBits =
pset.getParameter<vector<ParameterSet> >(
"MonitorBits");
45 for (
unsigned i = 0;
i < m_monitorBits.size();
i++) {
47 if (m_monitorBits[
i].getParameter<bool>(
"bitType")) {
48 int bit = m_monitorBits[
i].getParameter<
int>(
"bitNumber");
49 int offset = m_monitorBits[
i].getParameter<
int>(
"bitOffset");
50 m_selAlgoBit.push_back(pair<int, int>(bit,
offset));
54 int bit = m_monitorBits[
i].getParameter<
int>(
"bitNumber");
55 int offset = m_monitorBits[
i].getParameter<
int>(
"bitOffset");
56 m_selTechBit.push_back(pair<int, int>(bit,
offset));
60 m_monitorRates =
pset.getParameter<vector<ParameterSet> >(
"MonitorRates");
72 cout <<
"[L1TBPTX] Called beginRun." << endl;
75 ibooker.setCurrentFolder(
"L1T/L1TBPTX");
91 m_algoBit_Alias[(
algo->second).algoBitNumber()] = (
algo->second).algoAlias();
99 ibooker.setCurrentFolder(
"L1T/L1TBPTX");
100 m_ErrorMonitor = ibooker.book1D(
"ErrorMonitor",
"ErrorMonitor", 7, 0, 7);
101 m_ErrorMonitor->setBinLabel(
UNKNOWN,
"UNKNOWN");
102 m_ErrorMonitor->setBinLabel(WARNING_DB_CONN_FAILED,
"WARNING_DB_CONN_FAILED");
103 m_ErrorMonitor->setBinLabel(WARNING_DB_QUERY_FAILED,
"WARNING_DB_QUERY_FAILED");
104 m_ErrorMonitor->setBinLabel(WARNING_DB_INCORRECT_NBUNCHES,
105 "WARNING_DB_INCORRECT_NBUNCHES");
106 m_ErrorMonitor->setBinLabel(ERROR_UNABLE_RETRIVE_PRODUCT,
"ERROR_UNABLE_RETRIVE_PRODUCT");
107 m_ErrorMonitor->setBinLabel(ERROR_TRIGGERALIAS_NOTVALID,
"ERROR_TRIGGERALIAS_NOTVALID");
108 m_ErrorMonitor->setBinLabel(ERROR_LSBLOCK_NOTVALID,
"ERROR_LSBLOCK_NOTVALID");
110 for (
unsigned i = 0;
i < m_monitorBits.size();
i++) {
111 bool isAlgo = m_monitorBits[
i].getParameter<
bool>(
"bitType");
112 TString
testName = m_monitorBits[
i].getParameter<
string>(
"testName");
113 int bit = m_monitorBits[
i].getParameter<
int>(
"bitNumber");
115 TString meTitle =
"";
116 ibooker.setCurrentFolder(
"L1T/L1TBPTX/Efficiency/");
121 meTitle += m_algoBit_Alias[bit];
122 meTitle +=
" Efficiency";
123 m_meAlgoEfficiency[bit] = ibooker.book1D(
testName, meTitle, maxNbins, -0.5,
double(maxNbins) - 0.5);
124 m_meAlgoEfficiency[bit]->setAxisTitle(
"Lumi Section", 1);
129 meTitle += m_techBit_Alias[bit];
130 meTitle +=
" Efficiency";
131 m_meTechEfficiency[bit] = ibooker.book1D(
testName, meTitle, maxNbins, -0.5,
double(maxNbins) - 0.5);
132 m_meTechEfficiency[bit]->setAxisTitle(
"Lumi Section", 1);
136 ibooker.setCurrentFolder(
"L1T/L1TBPTX/MissFire/");
141 meTitle += m_algoBit_Alias[bit];
142 meTitle +=
"(1 - Miss Fire Rate)";
143 m_meAlgoMissFire[bit] = ibooker.book1D(
testName, meTitle, maxNbins, -0.5,
double(maxNbins) - 0.5);
144 m_meAlgoMissFire[bit]->setAxisTitle(
"Lumi Section", 1);
145 m_meAlgoMissFire[bit]->setAxisTitle(
"1 - Miss Fire Rate", 2);
150 meTitle += m_techBit_Alias[bit];
151 meTitle +=
"(1 - Miss Fire Rate)";
152 m_meTechMissFire[bit] = ibooker.book1D(
testName, meTitle, maxNbins, -0.5,
double(maxNbins) - 0.5);
153 m_meTechMissFire[bit]->setAxisTitle(
"Lumi Section", 1);
154 m_meTechMissFire[bit]->setAxisTitle(
"1 - Miss Fire Rate", 2);
158 for (
unsigned i = 0;
i < m_monitorRates.size();
i++) {
159 TString
testName = m_monitorRates[
i].getParameter<
string>(
"testName");
160 bool isAlgo = m_monitorRates[
i].getParameter<
bool>(
"bitType");
161 int bit = m_monitorRates[
i].getParameter<
int>(
"bitNumber");
163 pair<bool, int> refME = pair<bool, int>(isAlgo, bit);
165 TString meTitle =
"";
166 ibooker.setCurrentFolder(
"L1T/L1TBPTX/Rate/");
168 meTitle =
"Algo " + std::to_string(bit);
170 meTitle += m_algoBit_Alias[bit];
172 m_meRate[refME] = ibooker.book1D(
testName, meTitle, maxNbins, -0.5,
double(maxNbins) - 0.5);
173 m_meRate[refME]->setAxisTitle(
"Lumi Section", 1);
174 m_meRate[refME]->setAxisTitle(
"Rate (unprescaled) [Hz]", 2);
176 meTitle =
"Tech " + std::to_string(bit);
178 meTitle += m_techBit_Alias[bit];
180 m_meRate[refME] = ibooker.book1D(
testName, meTitle, maxNbins, -0.5,
double(maxNbins) - 0.5);
181 m_meRate[refME]->setAxisTitle(
"Lumi Section", 1);
182 m_meRate[refME]->setAxisTitle(
"Rate (unprescaled) [Hz]", 2);
218 cout <<
"[L1TBPTX] Called beginLuminosityBlock." << endl;
225 m_currentLSValid =
true;
227 for (
unsigned i = 0;
i < m_monitorBits.size();
i++) {
229 if (m_monitorBits[
i].getParameter<bool>(
"bitType")) {
230 triggerName =
"algo_" + std::to_string(m_monitorBits[
i].getParameter<int>(
"bitNumber"));
232 triggerName =
"tech_" + std::to_string(m_monitorBits[
i].getParameter<int>(
"bitNumber"));
251 cout <<
"[L1TBPTX] Called endLuminosityBlock." << endl;
255 if (m_currentLSValid && m_beamConfig.isValid()) {
256 for (
unsigned i = 0;
i < m_monitorBits.size();
i++) {
257 bool isAlgo = m_monitorBits[
i].getParameter<
bool>(
"bitType");
258 TString
testName = m_monitorBits[
i].getParameter<
string>(
"testName");
259 int bit = m_monitorBits[
i].getParameter<
int>(
"bitNumber");
282 int bin = m_meAlgoEfficiency[bit]->getTH1()->FindBin(m_currentLS);
283 m_meAlgoEfficiency[bit]->setBinContent(
bin, valEff);
284 m_meAlgoMissFire[bit]->setBinContent(
bin, 1 - valMiss);
286 int bin = m_meTechEfficiency[bit]->getTH1()->FindBin(m_currentLS);
287 m_meTechEfficiency[bit]->setBinContent(
bin, valEff);
288 m_meTechMissFire[bit]->setBinContent(
bin, 1 - valMiss);
300 if (m_currentLSValid) {
301 const vector<int>& currentPFAlgo = (*m_prescaleFactorsAlgoTrig).at(m_currentPrescalesIndex);
302 const vector<int>& currentPFTech = (*m_prescaleFactorsTechTrig).at(m_currentPrescalesIndex);
304 for (
unsigned i = 0;
i < m_monitorRates.size();
i++) {
305 bool isAlgo = m_monitorRates[
i].getParameter<
bool>(
"bitType");
306 int bit = m_monitorRates[
i].getParameter<
int>(
"bitNumber");
308 pair<bool, int> refME = pair<bool, int>(isAlgo, bit);
311 int bin = m_meRate[refME]->getTH1()->FindBin(m_currentGTLS);
312 int trigPS = currentPFAlgo[bit];
313 double trigRate = (double)trigPS * m_l1Rate[refME];
314 m_meRate[refME]->setBinContent(
bin, trigRate);
317 int bin = m_meRate[refME]->getTH1()->FindBin(m_currentGTLS);
318 int trigPS = currentPFTech[bit];
319 double trigRate = (double)trigPS * m_l1Rate[refME];
320 m_meRate[refME]->setBinContent(
bin, trigRate);
329 cout <<
"[L1TBPTX] Called analyze." << endl;
333 if (m_currentLSValid) {
335 cout <<
"[L1TBPTX] -> m_currentLSValid=" << m_currentLSValid << endl;
340 iEvent.getByToken(m_l1GtEvmSource, gtEvmReadoutRecord);
343 if (gtEvmReadoutRecord.
isValid()) {
345 unsigned int lhcBeamMode = gtfeEvmWord.
beamMode();
348 cout <<
"[L1TBPTX] Beam mode: " << lhcBeamMode << endl;
351 if (lhcBeamMode == RAMP || lhcBeamMode == FLATTOP || lhcBeamMode == SQUEEZE || lhcBeamMode == ADJUST ||
352 lhcBeamMode == STABLE) {
353 if (m_lhcFill == 0) {
355 cout <<
"[L1TBPTX] No valid bunch structure yet retrived. Attemptting to retrive..." << endl;
366 if (m_beamConfig.nCollidingBunches <= 0) {
368 m_currentLSValid =
false;
372 m_currentLSValid =
false;
376 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT);
378 m_ErrorMonitor->getTH1()->SetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT, eCount);
385 if (m_currentLSValid && m_beamConfig.isValid()) {
387 cout <<
"Current event in valid LS and beam config" << endl;
392 iEvent.getByToken(m_l1GtDataDaqInputTag, gtReadoutRecordData);
394 if (gtReadoutRecordData.
isValid()) {
395 const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->
gtFdlVector();
399 for (
unsigned int i = 0;
i < gtFdlVectorData.size();
i++) {
400 if (gtFdlVectorData[
i].bxInEvent() == 0) {
406 m_currentPrescalesIndex = gtFdlVectorData[eventFDL].gtPrescaleFactorIndexAlgo();
408 for (
unsigned i = 0;
i < m_monitorBits.size();
i++) {
410 bool isAlgo = m_monitorBits[
i].getParameter<
bool>(
"bitType");
411 int bit = m_monitorBits[
i].getParameter<
int>(
"bitNumber");
412 int offset = m_monitorBits[
i].getParameter<
int>(
"bitOffset");
430 for (
unsigned a = 0;
a < gtFdlVectorData.size();
a++) {
431 int testBx = gtFdlVectorData[
a].localBxNr() -
offset;
432 bool lhcBxFilled = m_beamConfig.beam1[testBx] && m_beamConfig.beam2[testBx];
433 bool algoFired =
false;
436 if (gtFdlVectorData[
a].gtDecisionWord()[bit]) {
441 if (gtFdlVectorData[
a].gtTechnicalTriggerWord()[bit]) {
449 if (lhcBxFilled && algoFired) {
456 if (algoFired && !lhcBxFilled) {
468 iEvent.getByToken(m_scalersSource, triggerScalers);
470 if (triggerScalers.
isValid()) {
471 Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
474 m_currentGTLS = (*itL1TScalers).lumiSegmentNr();
476 for (
unsigned i = 0;
i < m_monitorRates.size();
i++) {
477 bool isAlgo = m_monitorRates[
i].getParameter<
bool>(
"bitType");
478 int bit = m_monitorRates[
i].getParameter<
int>(
"bitNumber");
480 pair<bool, int> refTrig = pair<bool, int>(isAlgo, bit);
483 m_l1Rate[refTrig] = trigRates.gtAlgoCountsRate()[bit];
485 m_l1Rate[refTrig] = trigRates.gtTechCountsRate()[bit];
498 cout <<
"[L1TBPTX] Called getBeamConfOMDS()" << endl;
502 string oracleDB = m_parameters.getParameter<
string>(
"oracleDB");
503 string pathCondDB = m_parameters.getParameter<
string>(
"pathCondDB");
512 cout <<
"[L1TBPTX] Connected to DB with no error." << endl;
516 m_beamConfig = myOMDSHelper.getBeamConfiguration(m_lhcFill, errorRetrive);
520 cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: NO_ERROR" << endl;
521 cout <<
"[L1TSync] -> LHC Bunch Structure valid=" << m_beamConfig.m_valid
522 <<
" nBunches=" << m_beamConfig.nCollidingBunches << endl;
526 cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: WARNING_DB_QUERY_FAILED" << endl;
529 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_QUERY_FAILED);
531 m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_QUERY_FAILED, eCount);
534 cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: WARNING_DB_INCORRECT_NBUNCHES" << endl;
537 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_INCORRECT_NBUNCHES);
539 m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_INCORRECT_NBUNCHES, eCount);
542 cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: UNKNOWN" << endl;
544 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(
UNKNOWN);
546 m_ErrorMonitor->getTH1()->SetBinContent(
UNKNOWN, eCount);
551 cout <<
"[L1TBPTX] Connection to DB: WARNING_DB_CONN_FAILED" << endl;
553 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_CONN_FAILED);
555 m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_CONN_FAILED, eCount);
558 cout <<
"[L1TBPTX] Connection to DB: UNKNOWN" << endl;
560 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(
UNKNOWN);
562 m_ErrorMonitor->getTH1()->SetBinContent(
UNKNOWN, eCount);