47 m_monitorBits = pset.
getParameter< vector<ParameterSet> >(
"MonitorBits");
49 for(
unsigned i=0;
i<m_monitorBits.size();
i++){
52 if(m_monitorBits[
i].getParameter<bool>(
"bitType")){
54 int bit = m_monitorBits[
i].getParameter<
int>(
"bitNumber");
55 int offset = m_monitorBits[
i].getParameter<
int>(
"bitOffset");
56 m_selAlgoBit.push_back( pair<int,int>(bit,offset) );
60 int bit = m_monitorBits[
i].getParameter<
int>(
"bitNumber");
61 int offset = m_monitorBits[
i].getParameter<
int>(
"bitOffset");
62 m_selTechBit.push_back( pair<int,int>(bit,offset) );
66 m_monitorRates = pset.
getParameter< vector<ParameterSet> >(
"MonitorRates");
83 if (m_verbose){
cout <<
"[L1TBPTX] Called beginJob." << endl;}
91 dbe->
rmdir(
"L1T/L1TBPTX");
100 if (m_verbose){
cout <<
"[L1TBPTX] Called endJob." << endl;}
102 if (m_outputFile.size() != 0 && dbe)
103 dbe->save(m_outputFile);
114 if (m_verbose){
cout <<
"[L1TBPTX] Called beginRun." << endl;}
130 m_algoBit_Alias[(algo->second).algoBitNumber()] = (algo->second).algoAlias();
134 m_techBit_Alias[(algo->second).algoBitNumber()] = (algo->second).algoName();
138 dbe->setCurrentFolder(
"L1T/L1TBPTX");
139 m_ErrorMonitor = dbe->book1D(
"ErrorMonitor",
"ErrorMonitor",7,0,7);
140 m_ErrorMonitor->setBinLabel(
UNKNOWN ,
"UNKNOWN");
141 m_ErrorMonitor->setBinLabel(WARNING_DB_CONN_FAILED ,
"WARNING_DB_CONN_FAILED");
142 m_ErrorMonitor->setBinLabel(WARNING_DB_QUERY_FAILED ,
"WARNING_DB_QUERY_FAILED");
143 m_ErrorMonitor->setBinLabel(WARNING_DB_INCORRECT_NBUNCHES,
"WARNING_DB_INCORRECT_NBUNCHES");
144 m_ErrorMonitor->setBinLabel(ERROR_UNABLE_RETRIVE_PRODUCT ,
"ERROR_UNABLE_RETRIVE_PRODUCT");
145 m_ErrorMonitor->setBinLabel(ERROR_TRIGGERALIAS_NOTVALID ,
"ERROR_TRIGGERALIAS_NOTVALID");
146 m_ErrorMonitor->setBinLabel(ERROR_LSBLOCK_NOTVALID ,
"ERROR_LSBLOCK_NOTVALID");
148 for(
unsigned i=0;
i<m_monitorBits.size();
i++){
150 bool isAlgo = m_monitorBits[
i].getParameter<
bool> (
"bitType");
151 TString testName = m_monitorBits[
i].getParameter<
string>(
"testName");
152 int bit = m_monitorBits[
i].getParameter<
int> (
"bitNumber");
154 TString meTitle =
"";
155 dbe->setCurrentFolder(
"L1T/L1TBPTX/Efficiency/");
157 meTitle=
"Algo ";meTitle+=bit; meTitle+=
" - "; meTitle+=m_algoBit_Alias[bit]; meTitle+=
" Efficiency";
158 m_meAlgoEfficiency[bit] = dbe->book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
159 m_meAlgoEfficiency[bit]->setAxisTitle(
"Lumi Section" ,1);
162 meTitle=
"Tech "; meTitle+=bit; meTitle+=
" - "; meTitle+=m_techBit_Alias[bit]; meTitle+=
" Efficiency";
163 m_meTechEfficiency[bit] = dbe->book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
164 m_meTechEfficiency[bit]->setAxisTitle(
"Lumi Section" ,1);
168 dbe->setCurrentFolder(
"L1T/L1TBPTX/MissFire/");
170 meTitle=
"Algo "; meTitle+=bit; meTitle+=
" - "; meTitle+=m_algoBit_Alias[bit]; meTitle+=
"(1 - Miss Fire Rate)";
171 m_meAlgoMissFire[bit] = dbe->book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
172 m_meAlgoMissFire[bit]->setAxisTitle(
"Lumi Section" ,1);
173 m_meAlgoMissFire[bit]->setAxisTitle(
"1 - Miss Fire Rate",2);
176 meTitle=
"Tech "; meTitle+=bit; meTitle+=
" - "; meTitle+=m_techBit_Alias[bit]; meTitle+=
"(1 - Miss Fire Rate)";
177 m_meTechMissFire[bit] = dbe->book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
178 m_meTechMissFire[bit]->setAxisTitle(
"Lumi Section" ,1);
179 m_meTechMissFire[bit]->setAxisTitle(
"1 - Miss Fire Rate",2);
183 for(
unsigned i=0;
i<m_monitorRates.size();
i++){
185 TString testName = m_monitorRates[
i].getParameter<
string>(
"testName");
186 bool isAlgo = m_monitorRates[
i].getParameter<
bool> (
"bitType");
187 int bit = m_monitorRates[
i].getParameter<
int> (
"bitNumber");
189 pair<bool,int> refME = pair<bool,int>(isAlgo,bit);
191 TString meTitle =
"";
192 dbe->setCurrentFolder(
"L1T/L1TBPTX/Rate/");
194 meTitle=
"Algo "+bit; meTitle+=
" - "; meTitle+=m_algoBit_Alias[bit]; meTitle+=
" Rate";
195 m_meRate[refME] = dbe->book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
196 m_meRate[refME]->setAxisTitle(
"Lumi Section" ,1);
197 m_meRate[refME]->setAxisTitle(
"Rate (unprescaled) [Hz]",2);
200 meTitle=
"Tech "+bit; meTitle+=
" - "; meTitle+=m_techBit_Alias[bit]; meTitle+=
" Rate";
201 m_meRate[refME] = dbe->book1D(testName,meTitle,maxNbins,-0.5,
double(maxNbins)-0.5);
202 m_meRate[refME]->setAxisTitle(
"Lumi Section" ,1);
203 m_meRate[refME]->setAxisTitle(
"Rate (unprescaled) [Hz]",2);
238 if (m_verbose){
cout <<
"[L1TBPTX] Called beginLuminosityBlock." << endl;}
244 m_currentLSValid =
true;
246 for(
unsigned i=0;
i<m_monitorBits.size();
i++){
248 TString triggerName =
"";
249 if(m_monitorBits[
i].getParameter<bool>(
"bitType")){
250 triggerName =
"algo_"+m_monitorBits[
i].getParameter<
int>(
"bitNumber");
252 triggerName =
"tech_"+m_monitorBits[
i].getParameter<
int>(
"bitNumber");
255 m_effNumerator [triggerName] = 0;
256 m_effDenominator [triggerName] = 0;
257 m_missFireNumerator [triggerName] = 0;
258 m_missFireDenominator[triggerName] = 0;
273 if(m_verbose){
cout <<
"[L1TBPTX] Called endLuminosityBlock." << endl;}
276 if(m_currentLSValid && m_beamConfig.isValid()){
278 for(
unsigned i=0;
i<m_monitorBits.size();
i++){
280 bool isAlgo = m_monitorBits[
i].getParameter<
bool> (
"bitType");
281 TString testName = m_monitorBits[
i].getParameter<
string>(
"testName");
282 int bit = m_monitorBits[
i].getParameter<
int> (
"bitNumber");
285 if(isAlgo){triggerName =
"algo_"+bit;}
286 else {triggerName =
"tech_"+bit;}
290 if(m_effDenominator[triggerName]!=0) {valEff = (double)m_effNumerator[triggerName]/m_effDenominator[triggerName];}
292 if(m_missFireDenominator[triggerName]!=0){valMiss = (double)m_missFireNumerator[triggerName]/m_missFireDenominator[triggerName];}
296 int bin = m_meAlgoEfficiency[bit]->getTH1()->FindBin(m_currentLS);
297 m_meAlgoEfficiency[bit]->setBinContent(bin,valEff);
298 m_meAlgoMissFire[bit] ->setBinContent(bin,1-valMiss);
301 int bin = m_meTechEfficiency[bit]->getTH1()->FindBin(m_currentLS);
302 m_meTechEfficiency[bit]->setBinContent(bin,valEff);
303 m_meTechMissFire[bit] ->setBinContent(bin,1-valMiss);
315 if(m_currentLSValid){
317 const vector<int>& currentPFAlgo = (*m_prescaleFactorsAlgoTrig).at(m_currentPrescalesIndex);
318 const vector<int>& currentPFTech = (*m_prescaleFactorsTechTrig).at(m_currentPrescalesIndex);
320 for(
unsigned i=0;
i<m_monitorRates.size();
i++){
322 bool isAlgo = m_monitorRates[
i].getParameter<
bool> (
"bitType");
323 int bit = m_monitorRates[
i].getParameter<
int> (
"bitNumber");
325 pair<bool,int> refME = pair<bool,int>(isAlgo,bit);
328 int bin = m_meRate[refME]->getTH1()->FindBin(m_currentGTLS);
329 int trigPS = currentPFAlgo[bit];
330 double trigRate = (double) trigPS*m_l1Rate[refME];
331 m_meRate[refME]->setBinContent(bin,trigRate);
334 int bin = m_meRate[refME]->getTH1()->FindBin(m_currentGTLS);
335 int trigPS = currentPFTech[bit];
336 double trigRate = (double) trigPS*m_l1Rate[refME];
337 m_meRate[refME]->setBinContent(bin,trigRate);
346 if(m_verbose){
cout <<
"[L1TBPTX] Called endRun." << endl;}
354 if(m_verbose){
cout <<
"[L1TBPTX] Called analyze." << endl;}
357 if(m_currentLSValid){
359 if(m_verbose){
cout <<
"[L1TBPTX] -> m_currentLSValid=" << m_currentLSValid << endl;}
363 iEvent.
getByLabel(m_l1GtEvmSource, gtEvmReadoutRecord);
366 if(gtEvmReadoutRecord.
isValid()){
368 const L1GtfeExtWord& gtfeEvmWord = gtEvmReadoutRecord->gtfeWord();
369 unsigned int lhcBeamMode = gtfeEvmWord.
beamMode();
371 if(m_verbose){
cout <<
"[L1TBPTX] Beam mode: "<< lhcBeamMode << endl;}
373 if(lhcBeamMode==RAMP || lhcBeamMode==FLATTOP || lhcBeamMode==SQUEEZE || lhcBeamMode==ADJUST || lhcBeamMode==STABLE){
377 if(m_verbose){
cout <<
"[L1TBPTX] No valid bunch structure yet retrived. Attemptting to retrive..." << endl;}
387 if(m_beamConfig.nCollidingBunches<=0){
389 m_currentLSValid=
false;
393 else{m_currentLSValid=
false;}
396 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT);
398 m_ErrorMonitor->getTH1()->SetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT,eCount);
405 if(m_currentLSValid && m_beamConfig.isValid()){
407 if(m_verbose){
cout <<
"Current event in valid LS and beam config" << endl;}
411 iEvent.
getByLabel(m_l1GtDataDaqInputTag, gtReadoutRecordData);
413 if(gtReadoutRecordData.
isValid()){
415 const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
419 for(
unsigned int i=0;
i<gtFdlVectorData.size();
i++){
420 if(gtFdlVectorData[
i].bxInEvent()==0){eventFDL=
i;
break;}
423 m_currentPrescalesIndex = gtFdlVectorData[eventFDL].gtPrescaleFactorIndexAlgo();
425 for(
unsigned i=0;
i<m_monitorBits.size();
i++){
427 TString triggerName =
"";
428 bool isAlgo = m_monitorBits[
i].getParameter<
bool>(
"bitType");
429 int bit = m_monitorBits[
i].getParameter<
int> (
"bitNumber");
430 int offset = m_monitorBits[
i].getParameter<
int> (
"bitOffset");
432 if(isAlgo){triggerName =
"algo_"+bit;}
433 else {triggerName =
"tech_"+bit;}
438 if(offset<0){evBxStart+=-1*
offset;}
439 if(offset>0){evBxEnd +=-1*
offset;}
441 for(
unsigned a=0;
a<gtFdlVectorData.size();
a++){
443 int testBx = gtFdlVectorData[
a].localBxNr()-
offset;
444 bool lhcBxFilled = m_beamConfig.beam1[testBx] && m_beamConfig.beam2[testBx];
445 bool algoFired =
false;
448 if(gtFdlVectorData[
a].gtDecisionWord()[bit]){algoFired=
true;}
452 if(gtFdlVectorData[
a].gtTechnicalTriggerWord()[bit]){algoFired=
true;}
455 if(lhcBxFilled) {m_effDenominator[triggerName]++;}
456 if(lhcBxFilled && algoFired){m_effNumerator [triggerName]++;}
458 if(algoFired) {m_missFireNumerator[triggerName]++;}
459 if(algoFired && !lhcBxFilled){m_missFireNumerator[triggerName]++;}
470 iEvent.
getByLabel(m_scalersSource,triggerScalers);
474 Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
477 m_currentGTLS= (*itL1TScalers).lumiSegmentNr();
479 for(
unsigned i=0;
i<m_monitorRates.size();
i++){
481 bool isAlgo = m_monitorRates[
i].getParameter<
bool>(
"bitType");
482 int bit = m_monitorRates[
i].getParameter<
int> (
"bitNumber");
484 pair<bool,int> refTrig = pair<bool,int>(isAlgo,bit);
487 else {m_l1Rate[refTrig] = trigRates.gtTechCountsRate()[bit];}
500 if(m_verbose){
cout <<
"[L1TBPTX] Called getBeamConfOMDS()" << endl;}
503 string oracleDB = m_parameters.getParameter<
string>(
"oracleDB");
504 string pathCondDB = m_parameters.getParameter<
string>(
"pathCondDB");
509 myOMDSHelper.connect(oracleDB,pathCondDB,conError);
513 if(m_verbose){
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 <<
" nBunches=" << m_beamConfig.nCollidingBunches << endl;
525 if(m_verbose){
cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: WARNING_DB_QUERY_FAILED" << endl;}
527 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_QUERY_FAILED);
529 m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_QUERY_FAILED,eCount);
532 if(m_verbose){
cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: WARNING_DB_INCORRECT_NBUNCHES" << endl;}
534 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_INCORRECT_NBUNCHES);
536 m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_INCORRECT_NBUNCHES,eCount);
539 if(m_verbose){
cout <<
"[L1TBPTX] Retriving LHC Bunch Structure: UNKNOWN" << endl;}
540 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(
UNKNOWN);
542 m_ErrorMonitor->getTH1()->SetBinContent(
UNKNOWN,eCount);
547 if(m_verbose){
cout <<
"[L1TBPTX] Connection to DB: WARNING_DB_CONN_FAILED" << endl;}
548 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_CONN_FAILED);
550 m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_CONN_FAILED,eCount);
553 if(m_verbose){
cout <<
"[L1TBPTX] Connection to DB: UNKNOWN" << endl;}
554 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(
UNKNOWN);
556 m_ErrorMonitor->getTH1()->SetBinContent(
UNKNOWN,eCount);
LuminosityBlockID id() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void analyze(const edm::Event &e, const edm::EventSetup &c)
void doFractionInSync(bool iForce=false, bool iBad=false)
virtual void endLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
void rmdir(const std::string &fullpath)
virtual void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
0: Unidentified isolated particle
L1TBPTX(const edm::ParameterSet &ps)
DEFINE_FWK_MODULE(HiMixingModule)
std::vector< double > gtAlgoCountsRate() const
unsigned int offset(bool)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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
void endRun(const edm::Run &run, const edm::EventSetup &iSetup)
const cms_uint32_t lhcFillNumber() const
T const * product() const
LuminosityBlockNumber_t luminosityBlock() const
void beginRun(const edm::Run &run, const edm::EventSetup &iSetup)
BeginRun.
const cms_uint16_t beamMode() const
void setCurrentFolder(const std::string &fullpath)