38 m_scalersSource = consumes<Level1TriggerScalersCollection>(pset.
getParameter <
InputTag>(
"inputTagScalersResults"));
39 m_l1GtDataDaqInputTag = consumes<L1GlobalTriggerReadoutRecord>(pset.
getParameter <
InputTag>(
"inputTagL1GtDataDaq"));
40 m_l1GtEvmSource = consumes<L1GlobalTriggerEvmReadoutRecord>(pset.
getParameter <
InputTag>(
"inputTagtEvmSource"));
44 m_monitorBits = pset.
getParameter< vector<ParameterSet> >(
"MonitorBits");
46 for(
unsigned i=0;
i<m_monitorBits.size();
i++){
49 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");
76 if (m_verbose){
cout <<
"[L1TBPTX] Called beginRun." << endl;}
94 m_algoBit_Alias[(
algo->second).algoBitNumber()] = (
algo->second).algoAlias();
103 m_ErrorMonitor = ibooker.
book1D(
"ErrorMonitor",
"ErrorMonitor",7,0,7);
105 m_ErrorMonitor->setBinLabel(WARNING_DB_CONN_FAILED ,
"WARNING_DB_CONN_FAILED");
106 m_ErrorMonitor->setBinLabel(WARNING_DB_QUERY_FAILED ,
"WARNING_DB_QUERY_FAILED");
107 m_ErrorMonitor->setBinLabel(WARNING_DB_INCORRECT_NBUNCHES,
"WARNING_DB_INCORRECT_NBUNCHES");
108 m_ErrorMonitor->setBinLabel(ERROR_UNABLE_RETRIVE_PRODUCT ,
"ERROR_UNABLE_RETRIVE_PRODUCT");
109 m_ErrorMonitor->setBinLabel(ERROR_TRIGGERALIAS_NOTVALID ,
"ERROR_TRIGGERALIAS_NOTVALID");
110 m_ErrorMonitor->setBinLabel(ERROR_LSBLOCK_NOTVALID ,
"ERROR_LSBLOCK_NOTVALID");
112 for(
unsigned i=0;
i<m_monitorBits.size();
i++){
114 bool isAlgo = m_monitorBits[
i].getParameter<
bool> (
"bitType");
115 TString testName = m_monitorBits[
i].getParameter<
string>(
"testName");
116 int bit = m_monitorBits[
i].getParameter<
int> (
"bitNumber");
118 TString meTitle =
"";
121 meTitle=
"Algo ";meTitle+=bit; meTitle+=
" - "; meTitle+=m_algoBit_Alias[bit]; meTitle+=
" Efficiency";
122 m_meAlgoEfficiency[bit] = ibooker.
book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
123 m_meAlgoEfficiency[bit]->
setAxisTitle(
"Lumi Section" ,1);
126 meTitle=
"Tech "; meTitle+=bit; meTitle+=
" - "; meTitle+=m_techBit_Alias[bit]; meTitle+=
" Efficiency";
127 m_meTechEfficiency[bit] = ibooker.
book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
128 m_meTechEfficiency[bit]->
setAxisTitle(
"Lumi Section" ,1);
134 meTitle=
"Algo "; meTitle+=bit; meTitle+=
" - "; meTitle+=m_algoBit_Alias[bit]; meTitle+=
"(1 - Miss Fire Rate)";
135 m_meAlgoMissFire[bit] = ibooker.
book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
137 m_meAlgoMissFire[bit]->setAxisTitle(
"1 - Miss Fire Rate",2);
140 meTitle=
"Tech "; meTitle+=bit; meTitle+=
" - "; meTitle+=m_techBit_Alias[bit]; meTitle+=
"(1 - Miss Fire Rate)";
141 m_meTechMissFire[bit] = ibooker.
book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
143 m_meTechMissFire[bit]->setAxisTitle(
"1 - Miss Fire Rate",2);
147 for(
unsigned i=0;
i<m_monitorRates.size();
i++){
149 TString testName = m_monitorRates[
i].getParameter<
string>(
"testName");
150 bool isAlgo = m_monitorRates[
i].getParameter<
bool> (
"bitType");
151 int bit = m_monitorRates[
i].getParameter<
int> (
"bitNumber");
153 pair<bool,int> refME = pair<bool,int>(isAlgo,bit);
155 TString meTitle =
"";
158 meTitle=
"Algo "+std::to_string(bit); meTitle+=
" - "; meTitle+=m_algoBit_Alias[bit]; meTitle+=
" Rate";
159 m_meRate[refME] = ibooker.
book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
161 m_meRate[refME]->setAxisTitle(
"Rate (unprescaled) [Hz]",2);
164 meTitle=
"Tech "+std::to_string(bit); meTitle+=
" - "; meTitle+=m_techBit_Alias[bit]; meTitle+=
" Rate";
165 m_meRate[refME] = ibooker.
book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
167 m_meRate[refME]->setAxisTitle(
"Rate (unprescaled) [Hz]",2);
206 if (m_verbose){
cout <<
"[L1TBPTX] Called beginLuminosityBlock." << endl;}
212 m_currentLSValid =
true;
214 for(
unsigned i=0;
i<m_monitorBits.size();
i++){
216 TString triggerName =
"";
217 if(m_monitorBits[
i].getParameter<bool>(
"bitType")){
218 triggerName =
"algo_"+std::to_string(m_monitorBits[
i].getParameter<int>(
"bitNumber"));
220 triggerName =
"tech_"+std::to_string(m_monitorBits[
i].getParameter<int>(
"bitNumber"));
223 m_effNumerator [triggerName] = 0;
224 m_effDenominator [triggerName] = 0;
225 m_missFireNumerator [triggerName] = 0;
226 m_missFireDenominator[triggerName] = 0;
241 if(m_verbose){
cout <<
"[L1TBPTX] Called endLuminosityBlock." << endl;}
244 if(m_currentLSValid && m_beamConfig.isValid()){
246 for(
unsigned i=0;
i<m_monitorBits.size();
i++){
248 bool isAlgo = m_monitorBits[
i].getParameter<
bool> (
"bitType");
249 TString testName = m_monitorBits[
i].getParameter<
string>(
"testName");
250 int bit = m_monitorBits[
i].getParameter<
int> (
"bitNumber");
253 if(isAlgo){triggerName =
"algo_"+std::to_string(bit);}
254 else {triggerName =
"tech_"+std::to_string(bit);}
258 if(m_effDenominator[triggerName]!=0) {valEff = (double)m_effNumerator[triggerName]/m_effDenominator[triggerName];}
260 if(m_missFireDenominator[triggerName]!=0){valMiss = (double)m_missFireNumerator[triggerName]/m_missFireDenominator[triggerName];}
264 int bin = m_meAlgoEfficiency[bit]->getTH1()->FindBin(m_currentLS);
265 m_meAlgoEfficiency[bit]->setBinContent(bin,valEff);
266 m_meAlgoMissFire[bit] ->setBinContent(bin,1-valMiss);
269 int bin = m_meTechEfficiency[bit]->getTH1()->FindBin(m_currentLS);
270 m_meTechEfficiency[bit]->setBinContent(bin,valEff);
271 m_meTechMissFire[bit] ->setBinContent(bin,1-valMiss);
283 if(m_currentLSValid){
285 const vector<int>& currentPFAlgo = (*m_prescaleFactorsAlgoTrig).at(m_currentPrescalesIndex);
286 const vector<int>& currentPFTech = (*m_prescaleFactorsTechTrig).at(m_currentPrescalesIndex);
288 for(
unsigned i=0;
i<m_monitorRates.size();
i++){
290 bool isAlgo = m_monitorRates[
i].getParameter<
bool> (
"bitType");
291 int bit = m_monitorRates[
i].getParameter<
int> (
"bitNumber");
293 pair<bool,int> refME = pair<bool,int>(isAlgo,bit);
296 int bin = m_meRate[refME]->getTH1()->FindBin(m_currentGTLS);
297 int trigPS = currentPFAlgo[bit];
298 double trigRate = (double) trigPS*m_l1Rate[refME];
299 m_meRate[refME]->setBinContent(bin,trigRate);
302 int bin = m_meRate[refME]->getTH1()->FindBin(m_currentGTLS);
303 int trigPS = currentPFTech[bit];
304 double trigRate = (double) trigPS*m_l1Rate[refME];
305 m_meRate[refME]->setBinContent(bin,trigRate);
315 if(m_verbose){
cout <<
"[L1TBPTX] Called analyze." << endl;}
318 if(m_currentLSValid){
320 if(m_verbose){
cout <<
"[L1TBPTX] -> m_currentLSValid=" << m_currentLSValid << endl;}
324 iEvent.
getByToken(m_l1GtEvmSource, gtEvmReadoutRecord);
327 if(gtEvmReadoutRecord.
isValid()){
330 unsigned int lhcBeamMode = gtfeEvmWord.
beamMode();
332 if(m_verbose){
cout <<
"[L1TBPTX] Beam mode: "<< lhcBeamMode << endl;}
334 if(lhcBeamMode==RAMP || lhcBeamMode==FLATTOP || lhcBeamMode==SQUEEZE || lhcBeamMode==ADJUST || lhcBeamMode==STABLE){
338 if(m_verbose){
cout <<
"[L1TBPTX] No valid bunch structure yet retrived. Attemptting to retrive..." << endl;}
348 if(m_beamConfig.nCollidingBunches<=0){
350 m_currentLSValid=
false;
354 else{m_currentLSValid=
false;}
357 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT);
359 m_ErrorMonitor->getTH1()->SetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT,eCount);
366 if(m_currentLSValid && m_beamConfig.isValid()){
368 if(m_verbose){
cout <<
"Current event in valid LS and beam config" << endl;}
372 iEvent.
getByToken(m_l1GtDataDaqInputTag, gtReadoutRecordData);
374 if(gtReadoutRecordData.
isValid()){
376 const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->
gtFdlVector();
380 for(
unsigned int i=0;
i<gtFdlVectorData.size();
i++){
381 if(gtFdlVectorData[
i].bxInEvent()==0){eventFDL=
i;
break;}
384 m_currentPrescalesIndex = gtFdlVectorData[eventFDL].gtPrescaleFactorIndexAlgo();
386 for(
unsigned i=0;
i<m_monitorBits.size();
i++){
388 TString triggerName =
"";
389 bool isAlgo = m_monitorBits[
i].getParameter<
bool>(
"bitType");
390 int bit = m_monitorBits[
i].getParameter<
int> (
"bitNumber");
391 int offset = m_monitorBits[
i].getParameter<
int> (
"bitOffset");
393 if(isAlgo){triggerName =
"algo_"+std::to_string(bit);}
394 else {triggerName =
"tech_"+std::to_string(bit);}
399 if(offset<0){evBxStart+=-1*
offset;}
400 if(offset>0){evBxEnd +=-1*
offset;}
402 for(
unsigned a=0;
a<gtFdlVectorData.size();
a++){
404 int testBx = gtFdlVectorData[
a].localBxNr()-
offset;
405 bool lhcBxFilled = m_beamConfig.beam1[testBx] && m_beamConfig.beam2[testBx];
406 bool algoFired =
false;
409 if(gtFdlVectorData[
a].gtDecisionWord()[bit]){algoFired=
true;}
413 if(gtFdlVectorData[
a].gtTechnicalTriggerWord()[bit]){algoFired=
true;}
416 if(lhcBxFilled) {m_effDenominator[triggerName]++;}
417 if(lhcBxFilled && algoFired){m_effNumerator [triggerName]++;}
419 if(algoFired) {m_missFireNumerator[triggerName]++;}
420 if(algoFired && !lhcBxFilled){m_missFireNumerator[triggerName]++;}
431 iEvent.
getByToken(m_scalersSource,triggerScalers);
435 Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
438 m_currentGTLS= (*itL1TScalers).lumiSegmentNr();
440 for(
unsigned i=0;
i<m_monitorRates.size();
i++){
442 bool isAlgo = m_monitorRates[
i].getParameter<
bool>(
"bitType");
443 int bit = m_monitorRates[
i].getParameter<
int> (
"bitNumber");
445 pair<bool,int> refTrig = pair<bool,int>(isAlgo,bit);
448 else {m_l1Rate[refTrig] = trigRates.gtTechCountsRate()[bit];}
460 if(m_verbose){
cout <<
"[L1TBPTX] Called getBeamConfOMDS()" << endl;}
463 string oracleDB = m_parameters.getParameter<
string>(
"oracleDB");
464 string pathCondDB = m_parameters.getParameter<
string>(
"pathCondDB");
469 myOMDSHelper.connect(oracleDB,pathCondDB,conError);
473 if(m_verbose){
cout <<
"[L1TBPTX] Connected to DB with no error." << endl;}
476 m_beamConfig = myOMDSHelper.getBeamConfiguration(m_lhcFill,errorRetrive);
480 cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: NO_ERROR" << endl;
481 cout <<
"[L1TSync] -> LHC Bunch Structure valid=" << m_beamConfig.m_valid <<
" nBunches=" << m_beamConfig.nCollidingBunches << endl;
485 if(m_verbose){
cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: WARNING_DB_QUERY_FAILED" << endl;}
487 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_QUERY_FAILED);
489 m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_QUERY_FAILED,eCount);
492 if(m_verbose){
cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: WARNING_DB_INCORRECT_NBUNCHES" << endl;}
494 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_INCORRECT_NBUNCHES);
496 m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_INCORRECT_NBUNCHES,eCount);
499 if(m_verbose){
cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: UNKNOWN" << endl;}
500 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(
UNKNOWN);
502 m_ErrorMonitor->getTH1()->SetBinContent(
UNKNOWN,eCount);
507 if(m_verbose){
cout <<
"[L1TBPTX] Connection to DB: WARNING_DB_CONN_FAILED" << endl;}
508 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_CONN_FAILED);
510 m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_CONN_FAILED,eCount);
513 if(m_verbose){
cout <<
"[L1TBPTX] Connection to DB: UNKNOWN" << endl;}
514 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(
UNKNOWN);
516 m_ErrorMonitor->getTH1()->SetBinContent(
UNKNOWN,eCount);
LuminosityBlockID id() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void doFractionInSync(bool iForce=false, bool iBad=false)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const L1GtfeExtWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
0: Unidentified isolated particle
const std::vector< L1GtFdlWord > gtFdlVector() const
get the vector of L1GtFdlWord
void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
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)
L1TBPTX(const edm::ParameterSet &ps)
std::vector< double > gtAlgoCountsRate() const
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
void setCurrentFolder(std::string const &fullpath)
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
MonitorElement * book1D(Args &&...args)
void certifyLSBlock(std::string iTrigger, int iInitLs, int iEndLs, float iValue)
bin
set the eta bin as selection string.
const std::vector< std::vector< int > > & gtPrescaleFactors() const
get the prescale factors by reference
const cms_uint32_t lhcFillNumber() const
LuminosityBlockNumber_t luminosityBlock() const
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
const cms_uint16_t beamMode() const
T const * product() const