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 l1gtMenuToken_ = esConsumes<edm::Transition::BeginRun>();
41 l1GtPfAlgoToken_ = esConsumes<edm::Transition::BeginRun>();
42 l1GtPfTechToken_ = esConsumes<edm::Transition::BeginRun>();
46 m_monitorBits = pset.
getParameter<vector<ParameterSet> >(
"MonitorBits");
48 for (
unsigned i = 0;
i < m_monitorBits.size();
i++) {
50 if (m_monitorBits[
i].getParameter<bool>(
"bitType")) {
51 int bit = m_monitorBits[
i].getParameter<
int>(
"bitNumber");
52 int offset = m_monitorBits[
i].getParameter<
int>(
"bitOffset");
53 m_selAlgoBit.push_back(pair<int, int>(bit, offset));
57 int bit = m_monitorBits[
i].getParameter<
int>(
"bitNumber");
58 int offset = m_monitorBits[
i].getParameter<
int>(
"bitOffset");
59 m_selTechBit.push_back(pair<int, int>(bit, offset));
63 m_monitorRates = pset.
getParameter<vector<ParameterSet> >(
"MonitorRates");
75 cout <<
"[L1TBPTX] Called beginRun." << endl;
92 m_algoBit_Alias[(
algo->second).algoBitNumber()] = (
algo->second).algoAlias();
96 m_techBit_Alias[(
algo->second).algoBitNumber()] = (
algo->second).algoName();
101 m_ErrorMonitor = ibooker.
book1D(
"ErrorMonitor",
"ErrorMonitor", 7, 0, 7);
103 m_ErrorMonitor->setBinLabel(WARNING_DB_CONN_FAILED,
"WARNING_DB_CONN_FAILED");
104 m_ErrorMonitor->setBinLabel(WARNING_DB_QUERY_FAILED,
"WARNING_DB_QUERY_FAILED");
105 m_ErrorMonitor->setBinLabel(WARNING_DB_INCORRECT_NBUNCHES,
106 "WARNING_DB_INCORRECT_NBUNCHES");
107 m_ErrorMonitor->setBinLabel(ERROR_UNABLE_RETRIVE_PRODUCT,
"ERROR_UNABLE_RETRIVE_PRODUCT");
108 m_ErrorMonitor->setBinLabel(ERROR_TRIGGERALIAS_NOTVALID,
"ERROR_TRIGGERALIAS_NOTVALID");
109 m_ErrorMonitor->setBinLabel(ERROR_LSBLOCK_NOTVALID,
"ERROR_LSBLOCK_NOTVALID");
111 for (
unsigned i = 0;
i < m_monitorBits.size();
i++) {
112 bool isAlgo = m_monitorBits[
i].getParameter<
bool>(
"bitType");
113 TString testName = m_monitorBits[
i].getParameter<
string>(
"testName");
114 int bit = m_monitorBits[
i].getParameter<
int>(
"bitNumber");
116 TString meTitle =
"";
122 meTitle += m_algoBit_Alias[bit];
123 meTitle +=
" Efficiency";
124 m_meAlgoEfficiency[bit] = ibooker.
book1D(testName, meTitle, maxNbins, -0.5,
double(maxNbins) - 0.5);
125 m_meAlgoEfficiency[bit]->
setAxisTitle(
"Lumi Section", 1);
130 meTitle += m_techBit_Alias[bit];
131 meTitle +=
" Efficiency";
132 m_meTechEfficiency[bit] = ibooker.
book1D(testName, meTitle, maxNbins, -0.5,
double(maxNbins) - 0.5);
133 m_meTechEfficiency[bit]->
setAxisTitle(
"Lumi Section", 1);
142 meTitle += m_algoBit_Alias[bit];
143 meTitle +=
"(1 - Miss Fire Rate)";
144 m_meAlgoMissFire[bit] = ibooker.
book1D(testName, meTitle, maxNbins, -0.5,
double(maxNbins) - 0.5);
146 m_meAlgoMissFire[bit]->setAxisTitle(
"1 - Miss Fire Rate", 2);
151 meTitle += m_techBit_Alias[bit];
152 meTitle +=
"(1 - Miss Fire Rate)";
153 m_meTechMissFire[bit] = ibooker.
book1D(testName, meTitle, maxNbins, -0.5,
double(maxNbins) - 0.5);
155 m_meTechMissFire[bit]->setAxisTitle(
"1 - Miss Fire Rate", 2);
159 for (
unsigned i = 0;
i < m_monitorRates.size();
i++) {
160 TString testName = m_monitorRates[
i].getParameter<
string>(
"testName");
161 bool isAlgo = m_monitorRates[
i].getParameter<
bool>(
"bitType");
162 int bit = m_monitorRates[
i].getParameter<
int>(
"bitNumber");
164 pair<bool, int> refME = pair<bool, int>(isAlgo, bit);
166 TString meTitle =
"";
171 meTitle += m_algoBit_Alias[bit];
173 m_meRate[refME] = ibooker.
book1D(testName, meTitle, maxNbins, -0.5,
double(maxNbins) - 0.5);
175 m_meRate[refME]->setAxisTitle(
"Rate (unprescaled) [Hz]", 2);
179 meTitle += m_techBit_Alias[bit];
181 m_meRate[refME] = ibooker.
book1D(testName, meTitle, maxNbins, -0.5,
double(maxNbins) - 0.5);
183 m_meRate[refME]->setAxisTitle(
"Rate (unprescaled) [Hz]", 2);
189 const auto& l1GtPfAlgo = iSetup.
getHandle(l1GtPfAlgoToken_);
190 const auto& l1GtPfTech = iSetup.
getHandle(l1GtPfTechToken_);
192 if (l1GtPfAlgo.isValid()) {
199 if (l1GtPfAlgo.isValid()) {
216 cout <<
"[L1TBPTX] Called beginLuminosityBlock." << endl;
223 m_currentLSValid =
true;
225 for (
unsigned i = 0;
i < m_monitorBits.size();
i++) {
226 TString triggerName =
"";
227 if (m_monitorBits[
i].getParameter<bool>(
"bitType")) {
228 triggerName =
"algo_" +
std::to_string(m_monitorBits[
i].getParameter<int>(
"bitNumber"));
230 triggerName =
"tech_" +
std::to_string(m_monitorBits[
i].getParameter<int>(
"bitNumber"));
233 m_effNumerator[triggerName] = 0;
234 m_effDenominator[triggerName] = 0;
235 m_missFireNumerator[triggerName] = 0;
236 m_missFireDenominator[triggerName] = 0;
249 cout <<
"[L1TBPTX] Called endLuminosityBlock." << endl;
253 if (m_currentLSValid && m_beamConfig.isValid()) {
254 for (
unsigned i = 0;
i < m_monitorBits.size();
i++) {
255 bool isAlgo = m_monitorBits[
i].getParameter<
bool>(
"bitType");
256 TString testName = m_monitorBits[
i].getParameter<
string>(
"testName");
257 int bit = m_monitorBits[
i].getParameter<
int>(
"bitNumber");
268 if (m_effDenominator[triggerName] != 0) {
269 valEff = (double)m_effNumerator[triggerName] / m_effDenominator[triggerName];
273 if (m_missFireDenominator[triggerName] != 0) {
274 valMiss = (double)m_missFireNumerator[triggerName] / m_missFireDenominator[triggerName];
280 int bin = m_meAlgoEfficiency[bit]->getTH1()->FindBin(m_currentLS);
281 m_meAlgoEfficiency[bit]->setBinContent(bin, valEff);
282 m_meAlgoMissFire[bit]->setBinContent(bin, 1 - valMiss);
284 int bin = m_meTechEfficiency[bit]->getTH1()->FindBin(m_currentLS);
285 m_meTechEfficiency[bit]->setBinContent(bin, valEff);
286 m_meTechMissFire[bit]->setBinContent(bin, 1 - valMiss);
298 if (m_currentLSValid) {
299 const vector<int>& currentPFAlgo = (*m_prescaleFactorsAlgoTrig).at(m_currentPrescalesIndex);
300 const vector<int>& currentPFTech = (*m_prescaleFactorsTechTrig).at(m_currentPrescalesIndex);
302 for (
unsigned i = 0;
i < m_monitorRates.size();
i++) {
303 bool isAlgo = m_monitorRates[
i].getParameter<
bool>(
"bitType");
304 int bit = m_monitorRates[
i].getParameter<
int>(
"bitNumber");
306 pair<bool, int> refME = pair<bool, int>(isAlgo, bit);
309 int bin = m_meRate[refME]->getTH1()->FindBin(m_currentGTLS);
310 int trigPS = currentPFAlgo[bit];
311 double trigRate = (double)trigPS * m_l1Rate[refME];
312 m_meRate[refME]->setBinContent(bin, trigRate);
315 int bin = m_meRate[refME]->getTH1()->FindBin(m_currentGTLS);
316 int trigPS = currentPFTech[bit];
317 double trigRate = (double)trigPS * m_l1Rate[refME];
318 m_meRate[refME]->setBinContent(bin, trigRate);
327 cout <<
"[L1TBPTX] Called analyze." << endl;
331 if (m_currentLSValid) {
333 cout <<
"[L1TBPTX] -> m_currentLSValid=" << m_currentLSValid << endl;
338 iEvent.
getByToken(m_l1GtEvmSource, gtEvmReadoutRecord);
341 if (gtEvmReadoutRecord.
isValid()) {
342 const L1GtfeExtWord& gtfeEvmWord = gtEvmReadoutRecord->gtfeWord();
343 unsigned int lhcBeamMode = gtfeEvmWord.
beamMode();
346 cout <<
"[L1TBPTX] Beam mode: " << lhcBeamMode << endl;
349 if (lhcBeamMode == RAMP || lhcBeamMode == FLATTOP || lhcBeamMode == SQUEEZE || lhcBeamMode == ADJUST ||
350 lhcBeamMode == STABLE) {
351 if (m_lhcFill == 0) {
353 cout <<
"[L1TBPTX] No valid bunch structure yet retrived. Attemptting to retrive..." << endl;
364 if (m_beamConfig.nCollidingBunches <= 0) {
366 m_currentLSValid =
false;
370 m_currentLSValid =
false;
374 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT);
376 m_ErrorMonitor->getTH1()->SetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT, eCount);
383 if (m_currentLSValid && m_beamConfig.isValid()) {
385 cout <<
"Current event in valid LS and beam config" << endl;
390 iEvent.
getByToken(m_l1GtDataDaqInputTag, gtReadoutRecordData);
392 if (gtReadoutRecordData.
isValid()) {
393 const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
397 for (
unsigned int i = 0;
i < gtFdlVectorData.size();
i++) {
398 if (gtFdlVectorData[
i].bxInEvent() == 0) {
404 m_currentPrescalesIndex = gtFdlVectorData[eventFDL].gtPrescaleFactorIndexAlgo();
406 for (
unsigned i = 0;
i < m_monitorBits.size();
i++) {
407 TString triggerName =
"";
408 bool isAlgo = m_monitorBits[
i].getParameter<
bool>(
"bitType");
409 int bit = m_monitorBits[
i].getParameter<
int>(
"bitNumber");
410 int offset = m_monitorBits[
i].getParameter<
int>(
"bitOffset");
418 for (
unsigned a = 0;
a < gtFdlVectorData.size();
a++) {
419 int testBx = gtFdlVectorData[
a].localBxNr() -
offset;
420 bool lhcBxFilled = m_beamConfig.beam1[testBx] && m_beamConfig.beam2[testBx];
421 bool algoFired =
false;
424 if (gtFdlVectorData[
a].gtDecisionWord()[bit])
428 if (gtFdlVectorData[
a].gtTechnicalTriggerWord()[bit])
433 m_effDenominator[triggerName]++;
435 m_effNumerator[triggerName]++;
438 m_missFireDenominator[triggerName]++;
440 m_missFireNumerator[triggerName]++;
451 iEvent.
getByToken(m_scalersSource, triggerScalers);
453 if (triggerScalers.
isValid()) {
454 Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
457 m_currentGTLS = (*itL1TScalers).lumiSegmentNr();
459 for (
unsigned i = 0;
i < m_monitorRates.size();
i++) {
460 bool isAlgo = m_monitorRates[
i].getParameter<
bool>(
"bitType");
461 int bit = m_monitorRates[
i].getParameter<
int>(
"bitNumber");
463 pair<bool, int> refTrig = pair<bool, int>(isAlgo, bit);
468 m_l1Rate[refTrig] = trigRates.gtTechCountsRate()[bit];
481 cout <<
"[L1TBPTX] Called getBeamConfOMDS()" << endl;
485 string oracleDB = m_parameters.getParameter<
string>(
"oracleDB");
486 string pathCondDB = m_parameters.getParameter<
string>(
"pathCondDB");
491 myOMDSHelper.connect(oracleDB, pathCondDB, conError);
495 cout <<
"[L1TBPTX] Connected to DB with no error." << endl;
499 m_beamConfig = myOMDSHelper.getBeamConfiguration(m_lhcFill, errorRetrive);
503 cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: NO_ERROR" << endl;
504 cout <<
"[L1TSync] -> LHC Bunch Structure valid=" << m_beamConfig.m_valid
505 <<
" nBunches=" << m_beamConfig.nCollidingBunches << endl;
509 cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: WARNING_DB_QUERY_FAILED" << endl;
512 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_QUERY_FAILED);
514 m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_QUERY_FAILED, eCount);
517 cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: WARNING_DB_INCORRECT_NBUNCHES" << endl;
520 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_INCORRECT_NBUNCHES);
522 m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_INCORRECT_NBUNCHES, eCount);
525 cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: UNKNOWN" << endl;
527 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(
UNKNOWN);
529 m_ErrorMonitor->getTH1()->SetBinContent(
UNKNOWN, eCount);
534 cout <<
"[L1TBPTX] Connection to DB: WARNING_DB_CONN_FAILED" << endl;
536 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_CONN_FAILED);
538 m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_CONN_FAILED, eCount);
541 cout <<
"[L1TBPTX] Connection to DB: UNKNOWN" << endl;
543 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(
UNKNOWN);
545 m_ErrorMonitor->getTH1()->SetBinContent(
UNKNOWN, eCount);
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
const edm::EventSetup & c
void doFractionInSync(bool iForce=false, bool iBad=false)
virtual void setCurrentFolder(std::string const &fullpath)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
m_verbose(ps.getUntrackedParameter< bool >("verbose"))
void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
std::string to_string(const V &value)
L1TBPTX(const edm::ParameterSet &ps)
std::vector< double > gtAlgoCountsRate() const
bool getData(T &iHolder) const
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &, const edm::EventSetup &) override
BeginRun.
void analyze(const edm::Event &e, const edm::EventSetup &c) override
void endLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &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)
void certifyLSBlock(std::string iTrigger, int iInitLs, int iEndLs, float iValue)
const std::vector< std::vector< int > > & gtPrescaleFactors() const
get the prescale factors by reference
const cms_uint32_t lhcFillNumber() const
T getParameter(std::string const &) const
LuminosityBlockNumber_t luminosityBlock() const
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
const cms_uint16_t beamMode() const
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)