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"));
43 m_monitorBits = pset.
getParameter< vector<ParameterSet> >(
"MonitorBits");
45 for(
unsigned i=0;
i<m_monitorBits.size();
i++){
48 if(m_monitorBits[
i].getParameter<bool>(
"bitType")){
50 int bit = m_monitorBits[
i].getParameter<
int>(
"bitNumber");
51 int offset = m_monitorBits[
i].getParameter<
int>(
"bitOffset");
52 m_selAlgoBit.push_back( pair<int,int>(bit,offset) );
56 int bit = m_monitorBits[
i].getParameter<
int>(
"bitNumber");
57 int offset = m_monitorBits[
i].getParameter<
int>(
"bitOffset");
58 m_selTechBit.push_back( pair<int,int>(bit,offset) );
62 m_monitorRates = pset.
getParameter< vector<ParameterSet> >(
"MonitorRates");
75 if (m_verbose){
cout <<
"[L1TBPTX] Called beginRun." << endl;}
93 m_algoBit_Alias[(
algo->second).algoBitNumber()] = (
algo->second).algoAlias();
102 m_ErrorMonitor = ibooker.
book1D(
"ErrorMonitor",
"ErrorMonitor",7,0,7);
104 m_ErrorMonitor->setBinLabel(WARNING_DB_CONN_FAILED ,
"WARNING_DB_CONN_FAILED");
105 m_ErrorMonitor->setBinLabel(WARNING_DB_QUERY_FAILED ,
"WARNING_DB_QUERY_FAILED");
106 m_ErrorMonitor->setBinLabel(WARNING_DB_INCORRECT_NBUNCHES,
"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++){
113 bool isAlgo = m_monitorBits[
i].getParameter<
bool> (
"bitType");
114 TString testName = m_monitorBits[
i].getParameter<
string>(
"testName");
115 int bit = m_monitorBits[
i].getParameter<
int> (
"bitNumber");
117 TString meTitle =
"";
120 meTitle=
"Algo ";meTitle+=bit; meTitle+=
" - "; meTitle+=m_algoBit_Alias[bit]; meTitle+=
" Efficiency";
121 m_meAlgoEfficiency[bit] = ibooker.
book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
122 m_meAlgoEfficiency[bit]->
setAxisTitle(
"Lumi Section" ,1);
125 meTitle=
"Tech "; meTitle+=bit; meTitle+=
" - "; meTitle+=m_techBit_Alias[bit]; meTitle+=
" Efficiency";
126 m_meTechEfficiency[bit] = ibooker.
book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
127 m_meTechEfficiency[bit]->
setAxisTitle(
"Lumi Section" ,1);
133 meTitle=
"Algo "; meTitle+=bit; meTitle+=
" - "; meTitle+=m_algoBit_Alias[bit]; meTitle+=
"(1 - Miss Fire Rate)";
134 m_meAlgoMissFire[bit] = ibooker.
book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
136 m_meAlgoMissFire[bit]->setAxisTitle(
"1 - Miss Fire Rate",2);
139 meTitle=
"Tech "; meTitle+=bit; meTitle+=
" - "; meTitle+=m_techBit_Alias[bit]; meTitle+=
"(1 - Miss Fire Rate)";
140 m_meTechMissFire[bit] = ibooker.
book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
142 m_meTechMissFire[bit]->setAxisTitle(
"1 - Miss Fire Rate",2);
146 for(
unsigned i=0;
i<m_monitorRates.size();
i++){
148 TString testName = m_monitorRates[
i].getParameter<
string>(
"testName");
149 bool isAlgo = m_monitorRates[
i].getParameter<
bool> (
"bitType");
150 int bit = m_monitorRates[
i].getParameter<
int> (
"bitNumber");
152 pair<bool,int> refME = pair<bool,int>(isAlgo,bit);
154 TString meTitle =
"";
157 meTitle=
"Algo "+bit; meTitle+=
" - "; meTitle+=m_algoBit_Alias[bit]; meTitle+=
" Rate";
158 m_meRate[refME] = ibooker.
book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
160 m_meRate[refME]->setAxisTitle(
"Rate (unprescaled) [Hz]",2);
163 meTitle=
"Tech "+bit; meTitle+=
" - "; meTitle+=m_techBit_Alias[bit]; meTitle+=
" Rate";
164 m_meRate[refME] = ibooker.
book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
166 m_meRate[refME]->setAxisTitle(
"Rate (unprescaled) [Hz]",2);
205 if (m_verbose){
cout <<
"[L1TBPTX] Called beginLuminosityBlock." << endl;}
211 m_currentLSValid =
true;
213 for(
unsigned i=0;
i<m_monitorBits.size();
i++){
215 TString triggerName =
"";
216 if(m_monitorBits[
i].getParameter<bool>(
"bitType")){
217 triggerName =
"algo_"+m_monitorBits[
i].getParameter<
int>(
"bitNumber");
219 triggerName =
"tech_"+m_monitorBits[
i].getParameter<
int>(
"bitNumber");
222 m_effNumerator [triggerName] = 0;
223 m_effDenominator [triggerName] = 0;
224 m_missFireNumerator [triggerName] = 0;
225 m_missFireDenominator[triggerName] = 0;
240 if(m_verbose){
cout <<
"[L1TBPTX] Called endLuminosityBlock." << endl;}
243 if(m_currentLSValid && m_beamConfig.isValid()){
245 for(
unsigned i=0;
i<m_monitorBits.size();
i++){
247 bool isAlgo = m_monitorBits[
i].getParameter<
bool> (
"bitType");
248 TString testName = m_monitorBits[
i].getParameter<
string>(
"testName");
249 int bit = m_monitorBits[
i].getParameter<
int> (
"bitNumber");
252 if(isAlgo){triggerName =
"algo_"+bit;}
253 else {triggerName =
"tech_"+bit;}
257 if(m_effDenominator[triggerName]!=0) {valEff = (double)m_effNumerator[triggerName]/m_effDenominator[triggerName];}
259 if(m_missFireDenominator[triggerName]!=0){valMiss = (double)m_missFireNumerator[triggerName]/m_missFireDenominator[triggerName];}
263 int bin = m_meAlgoEfficiency[bit]->getTH1()->FindBin(m_currentLS);
264 m_meAlgoEfficiency[bit]->setBinContent(bin,valEff);
265 m_meAlgoMissFire[bit] ->setBinContent(bin,1-valMiss);
268 int bin = m_meTechEfficiency[bit]->getTH1()->FindBin(m_currentLS);
269 m_meTechEfficiency[bit]->setBinContent(bin,valEff);
270 m_meTechMissFire[bit] ->setBinContent(bin,1-valMiss);
282 if(m_currentLSValid){
284 const vector<int>& currentPFAlgo = (*m_prescaleFactorsAlgoTrig).at(m_currentPrescalesIndex);
285 const vector<int>& currentPFTech = (*m_prescaleFactorsTechTrig).at(m_currentPrescalesIndex);
287 for(
unsigned i=0;
i<m_monitorRates.size();
i++){
289 bool isAlgo = m_monitorRates[
i].getParameter<
bool> (
"bitType");
290 int bit = m_monitorRates[
i].getParameter<
int> (
"bitNumber");
292 pair<bool,int> refME = pair<bool,int>(isAlgo,bit);
295 int bin = m_meRate[refME]->getTH1()->FindBin(m_currentGTLS);
296 int trigPS = currentPFAlgo[bit];
297 double trigRate = (double) trigPS*m_l1Rate[refME];
298 m_meRate[refME]->setBinContent(bin,trigRate);
301 int bin = m_meRate[refME]->getTH1()->FindBin(m_currentGTLS);
302 int trigPS = currentPFTech[bit];
303 double trigRate = (double) trigPS*m_l1Rate[refME];
304 m_meRate[refME]->setBinContent(bin,trigRate);
314 if(m_verbose){
cout <<
"[L1TBPTX] Called analyze." << endl;}
317 if(m_currentLSValid){
319 if(m_verbose){
cout <<
"[L1TBPTX] -> m_currentLSValid=" << m_currentLSValid << endl;}
323 iEvent.
getByToken(m_l1GtEvmSource, gtEvmReadoutRecord);
326 if(gtEvmReadoutRecord.
isValid()){
329 unsigned int lhcBeamMode = gtfeEvmWord.
beamMode();
331 if(m_verbose){
cout <<
"[L1TBPTX] Beam mode: "<< lhcBeamMode << endl;}
333 if(lhcBeamMode==RAMP || lhcBeamMode==FLATTOP || lhcBeamMode==SQUEEZE || lhcBeamMode==ADJUST || lhcBeamMode==STABLE){
337 if(m_verbose){
cout <<
"[L1TBPTX] No valid bunch structure yet retrived. Attemptting to retrive..." << endl;}
347 if(m_beamConfig.nCollidingBunches<=0){
349 m_currentLSValid=
false;
353 else{m_currentLSValid=
false;}
356 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT);
358 m_ErrorMonitor->getTH1()->SetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT,eCount);
365 if(m_currentLSValid && m_beamConfig.isValid()){
367 if(m_verbose){
cout <<
"Current event in valid LS and beam config" << endl;}
371 iEvent.
getByToken(m_l1GtDataDaqInputTag, gtReadoutRecordData);
373 if(gtReadoutRecordData.
isValid()){
375 const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->
gtFdlVector();
379 for(
unsigned int i=0;
i<gtFdlVectorData.size();
i++){
380 if(gtFdlVectorData[
i].bxInEvent()==0){eventFDL=
i;
break;}
383 m_currentPrescalesIndex = gtFdlVectorData[eventFDL].gtPrescaleFactorIndexAlgo();
385 for(
unsigned i=0;
i<m_monitorBits.size();
i++){
387 TString triggerName =
"";
388 bool isAlgo = m_monitorBits[
i].getParameter<
bool>(
"bitType");
389 int bit = m_monitorBits[
i].getParameter<
int> (
"bitNumber");
390 int offset = m_monitorBits[
i].getParameter<
int> (
"bitOffset");
392 if(isAlgo){triggerName =
"algo_"+bit;}
393 else {triggerName =
"tech_"+bit;}
398 if(offset<0){evBxStart+=-1*
offset;}
399 if(offset>0){evBxEnd +=-1*
offset;}
401 for(
unsigned a=0;
a<gtFdlVectorData.size();
a++){
403 int testBx = gtFdlVectorData[
a].localBxNr()-
offset;
404 bool lhcBxFilled = m_beamConfig.beam1[testBx] && m_beamConfig.beam2[testBx];
405 bool algoFired =
false;
408 if(gtFdlVectorData[
a].gtDecisionWord()[bit]){algoFired=
true;}
412 if(gtFdlVectorData[
a].gtTechnicalTriggerWord()[bit]){algoFired=
true;}
415 if(lhcBxFilled) {m_effDenominator[triggerName]++;}
416 if(lhcBxFilled && algoFired){m_effNumerator [triggerName]++;}
418 if(algoFired) {m_missFireNumerator[triggerName]++;}
419 if(algoFired && !lhcBxFilled){m_missFireNumerator[triggerName]++;}
430 iEvent.
getByToken(m_scalersSource,triggerScalers);
434 Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
437 m_currentGTLS= (*itL1TScalers).lumiSegmentNr();
439 for(
unsigned i=0;
i<m_monitorRates.size();
i++){
441 bool isAlgo = m_monitorRates[
i].getParameter<
bool>(
"bitType");
442 int bit = m_monitorRates[
i].getParameter<
int> (
"bitNumber");
444 pair<bool,int> refTrig = pair<bool,int>(isAlgo,bit);
447 else {m_l1Rate[refTrig] = trigRates.gtTechCountsRate()[bit];}
459 if(m_verbose){
cout <<
"[L1TBPTX] Called getBeamConfOMDS()" << endl;}
462 string oracleDB = m_parameters.getParameter<
string>(
"oracleDB");
463 string pathCondDB = m_parameters.getParameter<
string>(
"pathCondDB");
468 myOMDSHelper.connect(oracleDB,pathCondDB,conError);
472 if(m_verbose){
cout <<
"[L1TBPTX] Connected to DB with no error." << endl;}
475 m_beamConfig = myOMDSHelper.getBeamConfiguration(m_lhcFill,errorRetrive);
479 cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: NO_ERROR" << endl;
480 cout <<
"[L1TSync] -> LHC Bunch Structure valid=" << m_beamConfig.m_valid <<
" nBunches=" << m_beamConfig.nCollidingBunches << endl;
484 if(m_verbose){
cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: WARNING_DB_QUERY_FAILED" << endl;}
486 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_QUERY_FAILED);
488 m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_QUERY_FAILED,eCount);
491 if(m_verbose){
cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: WARNING_DB_INCORRECT_NBUNCHES" << endl;}
493 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_INCORRECT_NBUNCHES);
495 m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_INCORRECT_NBUNCHES,eCount);
498 if(m_verbose){
cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: UNKNOWN" << endl;}
499 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(
UNKNOWN);
501 m_ErrorMonitor->getTH1()->SetBinContent(
UNKNOWN,eCount);
506 if(m_verbose){
cout <<
"[L1TBPTX] Connection to DB: WARNING_DB_CONN_FAILED" << endl;}
507 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_CONN_FAILED);
509 m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_CONN_FAILED,eCount);
512 if(m_verbose){
cout <<
"[L1TBPTX] Connection to DB: UNKNOWN" << endl;}
513 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(
UNKNOWN);
515 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 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.
void setCurrentFolder(const std::string &fullpath)
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