66 m_l1GtDataDaqInputTag = consumes<L1GlobalTriggerReadoutRecord>(pset.
getParameter <
InputTag>(
"inputTagL1GtDataDaq"));
67 m_l1GtEvmSource = consumes<L1GlobalTriggerEvmReadoutRecord>(pset.
getParameter <
InputTag>(
"inputTagtEvmSource"));
69 m_refPrescaleSet = pset.
getParameter <
int> (
"refPrescaleSet");
74 bool forceGlobalParameters = Categories.
getParameter<
bool>(
"forceGlobalParameters");
75 bool doGlobalAutoSelection = Categories.getParameter<
bool>(
"doGlobalAutoSelection");
92 if(forceGlobalParameters){
96 if(doGlobalAutoSelection){
98 if(CatMu .getParameter<bool>(
"monitor")){m_algoAutoSelect[
"Mu"] =
true;}
else{m_algoAutoSelect[
"Mu"] =
false;}
99 if(CatEG .getParameter<bool>(
"monitor")){m_algoAutoSelect[
"EG"] =
true;}
else{m_algoAutoSelect[
"EG"] =
false;}
100 if(CatIsoEG .getParameter<bool>(
"monitor")){m_algoAutoSelect[
"IsoEG"] =
true;}
else{m_algoAutoSelect[
"IsoEG"] =
false;}
101 if(CatJet .getParameter<bool>(
"monitor")){m_algoAutoSelect[
"Jet"] =
true;}
else{m_algoAutoSelect[
"Jet"] =
false;}
102 if(CatCenJet.getParameter<
bool>(
"monitor")){m_algoAutoSelect[
"CenJet"] =
true;}
else{m_algoAutoSelect[
"CenJet"] =
false;}
103 if(CatForJet.getParameter<
bool>(
"monitor")){m_algoAutoSelect[
"ForJet"] =
true;}
else{m_algoAutoSelect[
"ForJet"] =
false;}
104 if(CatTauJet.getParameter<
bool>(
"monitor")){m_algoAutoSelect[
"TauJet"] =
true;}
else{m_algoAutoSelect[
"TauJet"] =
false;}
105 if(CatETM .getParameter<bool>(
"monitor")){m_algoAutoSelect[
"ETM"] =
true;}
else{m_algoAutoSelect[
"ETM"] =
false;}
106 if(CatETT .getParameter<bool>(
"monitor")){m_algoAutoSelect[
"ETT"] =
true;}
else{m_algoAutoSelect[
"ETT"] =
false;}
107 if(CatHTM .getParameter<bool>(
"monitor")){m_algoAutoSelect[
"HTM"] =
true;}
else{m_algoAutoSelect[
"HTM"] =
false;}
108 if(CatHTT .getParameter<bool>(
"monitor")){m_algoAutoSelect[
"HTT"] =
true;}
else{m_algoAutoSelect[
"HTT"] =
false;}
114 m_algoAutoSelect[
"Mu"] =
false;
115 m_algoAutoSelect[
"EG"] =
false;
116 m_algoAutoSelect[
"IsoEG"] =
false;
117 m_algoAutoSelect[
"Jet"] =
false;
118 m_algoAutoSelect[
"CenJet"] =
false;
119 m_algoAutoSelect[
"ForJet"] =
false;
120 m_algoAutoSelect[
"TauJet"] =
false;
121 m_algoAutoSelect[
"ETM"] =
false;
122 m_algoAutoSelect[
"ETT"] =
false;
123 m_algoAutoSelect[
"HTM"] =
false;
124 m_algoAutoSelect[
"HTT"] =
false;
126 if(CatMu .getParameter<bool>(
"monitor")){m_selectedTriggers[
"Mu"] = CatMu .
getParameter<
string>(
"algo");}
127 if(CatEG .getParameter<bool>(
"monitor")){m_selectedTriggers[
"EG"] = CatEG .getParameter<
string>(
"algo");}
128 if(CatIsoEG .getParameter<bool>(
"monitor")){m_selectedTriggers[
"IsoEG"] = CatIsoEG .getParameter<
string>(
"algo");}
129 if(CatJet .getParameter<bool>(
"monitor")){m_selectedTriggers[
"Jet"] = CatJet .getParameter<
string>(
"algo");}
130 if(CatCenJet.getParameter<
bool>(
"monitor")){m_selectedTriggers[
"CenJet"] = CatCenJet.getParameter<
string>(
"algo");}
131 if(CatForJet.getParameter<
bool>(
"monitor")){m_selectedTriggers[
"CatForJet"] = CatForJet.getParameter<
string>(
"algo");}
132 if(CatTauJet.getParameter<
bool>(
"monitor")){m_selectedTriggers[
"TauJet"] = CatTauJet.getParameter<
string>(
"algo");}
133 if(CatETM .getParameter<bool>(
"monitor")){m_selectedTriggers[
"ETM"] = CatETM .getParameter<
string>(
"algo");}
134 if(CatETT .getParameter<bool>(
"monitor")){m_selectedTriggers[
"ETT"] = CatETT .getParameter<
string>(
"algo");}
135 if(CatHTM .getParameter<bool>(
"monitor")){m_selectedTriggers[
"HTM"] = CatHTM .getParameter<
string>(
"algo");}
136 if(CatHTT .getParameter<bool>(
"monitor")){m_selectedTriggers[
"HTT"] = CatHTT .getParameter<
string>(
"algo");}
143 if(CatBPTX.getParameter<
bool>(
"monitor")){
144 m_selectedTriggers[
"BPTX"] = CatBPTX.getParameter<
string>(
"algo");
147 if(CatMu.getParameter<
bool>(
"monitor")){
148 m_algoAutoSelect[
"Mu"] = CatMu.getParameter<
bool>(
"doAutoSelection");
149 if(!m_algoAutoSelect[
"Mu"]){m_selectedTriggers[
"Mu"] = CatMu.getParameter<
string>(
"algo");}
150 }
else{m_algoAutoSelect[
"Mu"] =
false;}
152 if(CatEG.getParameter<
bool>(
"monitor")){
153 m_algoAutoSelect[
"EG"] = CatEG.getParameter<
bool>(
"doAutoSelection");
154 if(!m_algoAutoSelect[
"EG"]){m_selectedTriggers[
"EG"] = CatEG.getParameter<
string>(
"algo");}
155 }
else{m_algoAutoSelect[
"EG"] =
false;}
157 if(CatIsoEG.getParameter<
bool>(
"monitor")){
158 m_algoAutoSelect[
"IsoEG"] = CatIsoEG.getParameter<
bool>(
"doAutoSelection");
159 if(!m_algoAutoSelect[
"IsoEG"]){m_selectedTriggers[
"IsoEG"] = CatIsoEG.getParameter<
string>(
"algo");}
160 }
else{m_algoAutoSelect[
"IsoEG"] =
false;}
162 if(CatJet.getParameter<
bool>(
"monitor")){
163 m_algoAutoSelect[
"Jet"] = CatJet.getParameter<
bool>(
"doAutoSelection");
164 if(!m_algoAutoSelect[
"Jet"]){m_selectedTriggers[
"Jet"] = CatJet.getParameter<
string>(
"algo");}
165 }
else{m_algoAutoSelect[
"Jet"] =
false;}
167 if(CatCenJet.getParameter<
bool>(
"monitor")){
168 m_algoAutoSelect[
"CenJet"] = CatCenJet.getParameter<
bool>(
"doAutoSelection");
169 if(!m_algoAutoSelect[
"CenJet"]){m_selectedTriggers[
"CenJet"] = CatCenJet.getParameter<
string>(
"algo");}
170 }
else{m_algoAutoSelect[
"CenJet"] =
false;}
172 if(CatForJet.getParameter<
bool>(
"monitor")){
173 m_algoAutoSelect[
"CatForJet"] = CatForJet.getParameter<
bool>(
"doAutoSelection");
174 if(!m_algoAutoSelect[
"CatForJet"]){m_selectedTriggers[
"CatForJet"] = CatForJet.getParameter<
string>(
"algo");}
175 }
else{m_algoAutoSelect[
"CatForJet"] =
false;}
177 if(CatTauJet.getParameter<
bool>(
"monitor")){
178 m_algoAutoSelect[
"TauJet"] = CatTauJet.getParameter<
bool>(
"doAutoSelection");
179 if(!m_algoAutoSelect[
"TauJet"]){m_selectedTriggers[
"TauJet"] = CatTauJet.getParameter<
string>(
"algo");}
180 }
else{m_algoAutoSelect[
"TauJet"] =
false;}
182 if(CatETM.getParameter<
bool>(
"monitor")){
183 m_algoAutoSelect[
"ETM"] = CatETM.getParameter<
bool>(
"doAutoSelection");
184 if(!m_algoAutoSelect[
"ETM"]){m_selectedTriggers[
"ETM"] = CatETM.getParameter<
string>(
"algo");}
185 }
else{m_algoAutoSelect[
"ETM"] =
false;}
187 if(CatETT.getParameter<
bool>(
"monitor")){
188 m_algoAutoSelect[
"ETT"] = CatETT.getParameter<
bool>(
"doAutoSelection");
189 if(!m_algoAutoSelect[
"ETT"]){m_selectedTriggers[
"ETT"] = CatETT.getParameter<
string>(
"algo");}
190 }
else{m_algoAutoSelect[
"ETT"] =
false;}
192 if(CatHTM.getParameter<
bool>(
"monitor")){
193 m_algoAutoSelect[
"HTM"] = CatHTM.getParameter<
bool>(
"doAutoSelection");
194 if(!m_algoAutoSelect[
"HTM"]){m_selectedTriggers[
"HTM"] = CatHTM.getParameter<
string>(
"algo");}
195 }
else{m_algoAutoSelect[
"HTM"] =
false;}
197 if(CatHTT.getParameter<
bool>(
"monitor")){
198 m_algoAutoSelect[
"HTT"] = CatHTT.getParameter<
bool>(
"doAutoSelection");
199 if(!m_algoAutoSelect[
"HTT"]){m_selectedTriggers[
"HTT"] = CatHTT.getParameter<
string>(
"algo");}
200 }
else{m_algoAutoSelect[
"HTT"] =
false;}
212 if (m_outputFile.size() != 0) {
213 std::cout <<
"L1T Monitoring histograms will be saved to " << m_outputFile.c_str() << std::endl;
217 if (disable) {m_outputFile =
"";}
219 if (dbe !=
NULL) {dbe->setCurrentFolder(
"L1T/L1TSync");}
231 if (m_verbose){
cout <<
"[L1TSync_Offline] Called beginJob." << endl;}
238 dbe->setCurrentFolder(
"L1T/L1TSync");
239 dbe->rmdir(
"L1T/L1TSync");
248 if (m_verbose){
cout <<
"[L1TSync_Offline] Called endJob." << endl;}
250 if (m_outputFile.size() != 0 && dbe)
251 dbe->save(m_outputFile);
262 if (m_verbose){
cout <<
"[L1TSync_Offline] Called beginRun." << endl;}
270 m_certFirstLS.clear();
271 m_certLastLS .clear();
280 m_algoBit[(algo->second).algoAlias()] = (algo->second).algoBitNumber();
294 m_selectedTriggers = myMenuHelper.
testAlgos(m_selectedTriggers);
296 map<string,string> tAutoSelTrig = myMenuHelper.
getLUSOTrigger(m_algoAutoSelect,m_refPrescaleSet);
297 m_selectedTriggers.insert(tAutoSelTrig.begin(),tAutoSelTrig.end());
300 dbe->setCurrentFolder(
"L1T/L1TSync");
301 m_ErrorMonitor = dbe->book1D(
"ErrorMonitor",
"ErrorMonitor",7,0,7);
302 m_ErrorMonitor->setBinLabel(
UNKNOWN ,
"UNKNOWN");
303 m_ErrorMonitor->setBinLabel(WARNING_DB_CONN_FAILED ,
"WARNING_DB_CONN_FAILED");
304 m_ErrorMonitor->setBinLabel(WARNING_DB_QUERY_FAILED ,
"WARNING_DB_QUERY_FAILED");
305 m_ErrorMonitor->setBinLabel(WARNING_DB_INCORRECT_NBUNCHES,
"WARNING_DB_INCORRECT_NBUNCHES");
306 m_ErrorMonitor->setBinLabel(ERROR_UNABLE_RETRIVE_PRODUCT ,
"ERROR_UNABLE_RETRIVE_PRODUCT");
307 m_ErrorMonitor->setBinLabel(ERROR_TRIGGERALIAS_NOTVALID ,
"ERROR_TRIGGERALIAS_NOTVALID");
308 m_ErrorMonitor->setBinLabel(ERROR_LSBLOCK_NOTVALID ,
"ERROR_LSBLOCK_NOTVALID");
311 for(map<string,string>::const_iterator
i=m_selectedTriggers.begin() ;
i!=m_selectedTriggers.end() ;
i++){
313 string tCategory = (*i).first;
314 string tTrigger = (*i).second;
317 m_certFirstLS[(*i).second] = 0;
318 m_certLastLS [(*i).second] = 0;
321 dbe->setCurrentFolder(
"L1T/L1TSync/AlgoVsBunchStructure/");
322 m_algoVsBunchStructure[tTrigger] = dbe->book2D(tCategory,
"min #Delta("+tTrigger+
",Bunch)",maxNbins,-0.5,
double(maxNbins)-0.5,5,-2.5,2.5);
323 m_algoVsBunchStructure[tTrigger] ->setAxisTitle(
"Lumi Section" ,1);
325 dbe->setCurrentFolder(
"L1T/L1TSync/Certification/");
326 m_algoCertification[tTrigger] = dbe->book1D(tCategory,
"fraction of in sync: "+tTrigger,maxNbins,-0.5,
double(maxNbins)-0.5);
327 m_algoCertification[tTrigger] ->setAxisTitle(
"Lumi Section" ,1);
338 if (m_verbose){
cout <<
"[L1TSync_Offline] Called beginLuminosityBlock." << endl;}
340 m_currentLSValid =
true;
348 if(m_verbose){
cout <<
"[L1TSync_Offline] Called endRun." << endl;}
362 if(m_verbose){
cout <<
"[L1TSync_Offline] Called analyze." << endl;}
365 if(m_currentLSValid){
367 if(m_verbose){
cout <<
"[L1TSync_Offline] -> m_currentLSValid=" << m_currentLSValid << endl;}
371 iEvent.
getByToken(m_l1GtEvmSource, gtEvmReadoutRecord);
374 if(gtEvmReadoutRecord.
isValid()){
376 const L1GtfeExtWord& gtfeEvmWord = gtEvmReadoutRecord->gtfeWord();
377 unsigned int lhcBeamMode = gtfeEvmWord.
beamMode();
383 getBeamConfOffline(iEvent);
398 if(lhcBeamMode != STABLE){m_currentLSValid =
false;
399 if(m_verbose){
cout <<
"[L1TSync_Offline] -> m_currentLSValid=" << m_currentLSValid <<
"because beams mode not stable, being " << lhcBeamMode << endl;}
402 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT);
404 m_ErrorMonitor->getTH1()->SetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT,eCount);
407 if(m_verbose){
cout <<
"[L1TSync_Offline] -> m_currentLSValid=" << m_currentLSValid << endl;}
417 if(m_currentLSValid && m_beamConfig.isValid()){
421 iEvent.
getByToken(m_l1GtDataDaqInputTag, gtReadoutRecordData);
423 if(gtReadoutRecordData.
isValid()){
425 const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
428 for(map<string,string>::const_iterator
i=m_selectedTriggers.begin() ;
i!=m_selectedTriggers.end() ;
i++){
430 string tTrigger = (*i).second;
433 if(tTrigger !=
"Undefined" && tTrigger !=
"Undefined (Wrong Name)"){
435 bool beamSingleConfig =
false;
436 bool firedAlgo =
false;
437 unsigned int eventBx = ~0;
440 for(
unsigned int a=0 ;
a<gtFdlVectorData.size() ;
a++){
443 if(gtFdlVectorData[
a].bxInEvent() == 0){
444 eventBx = gtFdlVectorData[
a].localBxNr();
445 if(gtFdlVectorData[
a].gtDecisionWord()[ m_algoBit[tTrigger] ]){firedAlgo =
true;}
450 if ( m_beamConfig.beam1.size() > eventBx && m_beamConfig.beam2.size() > eventBx) {
451 if( m_beamConfig.beam1[eventBx] && !m_beamConfig.beam2[eventBx]){beamSingleConfig =
true;}
452 if(!m_beamConfig.beam1[eventBx] && m_beamConfig.beam2[eventBx]){beamSingleConfig =
true;}
458 if(firedAlgo && !beamSingleConfig){
460 int DifAlgoVsBunchStructure = 9999;
462 for(
unsigned int a=0 ;
a<gtFdlVectorData.size() ;
a++){
464 int bxFDL = gtFdlVectorData[
a].localBxNr();
465 int bxInEvent = gtFdlVectorData[
a].bxInEvent();
467 if(m_beamConfig.bxConfig(bxFDL) &&
abs(bxInEvent)<
abs(DifAlgoVsBunchStructure)){
468 DifAlgoVsBunchStructure = -1*bxInEvent;
472 m_algoVsBunchStructure[tTrigger]->Fill(m_currentLS,DifAlgoVsBunchStructure);
479 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT);
481 m_ErrorMonitor->getTH1()->SetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT,eCount);
516 m_beamConfig.m_valid =
true;
521 bool firedAlgo =
false;
527 iEvent.
getByToken(m_l1GtDataDaqInputTag, gtReadoutRecordData);
529 if(gtReadoutRecordData.
isValid()){
531 const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
533 for(
unsigned int a=0 ;
a<gtFdlVectorData.size() ;
a++){
535 if(gtFdlVectorData[
a].bxInEvent() == 0){
537 if(gtFdlVectorData[
a].gtDecisionWord()[ m_algoBit[ m_selectedTriggers[
"BPTX"] ] ]){firedAlgo =
true;}
542 m_beamConfig.beam1.push_back(
true);
543 m_beamConfig.beam2.push_back(
true);
546 m_beamConfig.beam1.push_back(
false);
547 m_beamConfig.beam2.push_back(
false);
T getParameter(std::string const &) const
void getBeamConfOffline(const edm::Event &)
void beginRun(const edm::Run &run, const edm::EventSetup &iSetup)
BeginRun.
T getUntrackedParameter(std::string const &, T const &) const
L1TSync_Offline(const edm::ParameterSet &ps)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
0: Unidentified isolated particle
virtual void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
Abs< T >::type abs(const T &t)
const cms_uint32_t lhcFillNumber() const
T const * product() const
virtual ~L1TSync_Offline()
void analyze(const edm::Event &e, const edm::EventSetup &c)
const cms_uint16_t beamMode() const
void endRun(const edm::Run &run, const edm::EventSetup &iSetup)