CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TSync_Offline.cc
Go to the documentation of this file.
1 
2 /*
3  * \class L1TSync_Offline
4  *
5  *
6  * Description: offline DQM module for L1Trigger/bunchStructure synchronization
7  *
8  * Implementation:
9  * <TODO: enter implementation details>
10  *
11  * \author: Pietro Vischia - LIP Lisbon pietro.vischia@gmail.com
12  *
13  * Changelog:
14  * 2012/08/10 11:01:01: First creation. Dummy module with actual code commented.
15  *
16  * Todo:
17  * - implement the module in offline
18  * - check if there are user includes specific for offline/online that should be changed
19  *
20  * $Date: 2012/12/11 10:36:34 $
21  * $Revision: 1.2 $
22  *
23  */
24 
25 //
26 
27 // This class header
29 
30 // System include files
31 // --
32 
33 // User include files
35 
39 
42 
43 #include "DataFormats/Common/interface/ConditionsInEdm.h" // Parameters associated to Run, LS and Event
44 
52 // Luminosity Information
53 //#include "DataFormats/Luminosity/interface/LumiDetails.h"
54 //#include "DataFormats/Luminosity/interface/LumiSummary.h"
55 
56 // L1TMonitor includes
59 
60 #include "TList.h"
61 
62 using namespace edm;
63 using namespace std;
64 
65 //-------------------------------------------------------------------------------------
66 //-------------------------------------------------------------------------------------
68 
69  m_parameters = pset;
70 
71  // Mapping parameter input variables
72  m_scalersSource = pset.getParameter <InputTag>("inputTagScalersResults");
73  m_l1GtDataDaqInputTag = pset.getParameter <InputTag>("inputTagL1GtDataDaq");
74  m_l1GtEvmSource = pset.getParameter <InputTag>("inputTagtEvmSource");
75  m_verbose = pset.getUntrackedParameter<bool> ("verbose",false);
76  m_refPrescaleSet = pset.getParameter <int> ("refPrescaleSet");
77 
78  // Getting which categories to monitor
79  ParameterSet Categories = pset.getParameter< ParameterSet >("Categories");
80 
81  bool forceGlobalParameters = Categories.getParameter<bool>("forceGlobalParameters");
82  bool doGlobalAutoSelection = Categories.getParameter<bool>("doGlobalAutoSelection");
83 
84  ParameterSet CatBPTX = Categories.getParameter<ParameterSet>("BPTX");
85  ParameterSet CatMu = Categories.getParameter<ParameterSet>("Mu");
86  ParameterSet CatEG = Categories.getParameter<ParameterSet>("EG");
87  ParameterSet CatIsoEG = Categories.getParameter<ParameterSet>("IsoEG");
88  ParameterSet CatJet = Categories.getParameter<ParameterSet>("Jet");
89  ParameterSet CatCenJet = Categories.getParameter<ParameterSet>("CenJet");
90  ParameterSet CatForJet = Categories.getParameter<ParameterSet>("ForJet");
91  ParameterSet CatTauJet = Categories.getParameter<ParameterSet>("TauJet");
92  ParameterSet CatETM = Categories.getParameter<ParameterSet>("ETT");
93  ParameterSet CatETT = Categories.getParameter<ParameterSet>("ETM");
94  ParameterSet CatHTT = Categories.getParameter<ParameterSet>("HTT");
95  ParameterSet CatHTM = Categories.getParameter<ParameterSet>("HTM");
96 
97  // --> Setting parameters related to which algos to monitor
98  // If global parameters are forced they take precedence over algo-by-algo parameters
99  if(forceGlobalParameters){
100 
101  // If global automatic selection if enable all categories set to be monitored will have
102  // their algos auto selected (the lowest prescale algo will be selected)
103  if(doGlobalAutoSelection){
104 
105  if(CatMu .getParameter<bool>("monitor")){m_algoAutoSelect["Mu"] = true;}else{m_algoAutoSelect["Mu"] = false;}
106  if(CatEG .getParameter<bool>("monitor")){m_algoAutoSelect["EG"] = true;}else{m_algoAutoSelect["EG"] = false;}
107  if(CatIsoEG .getParameter<bool>("monitor")){m_algoAutoSelect["IsoEG"] = true;}else{m_algoAutoSelect["IsoEG"] = false;}
108  if(CatJet .getParameter<bool>("monitor")){m_algoAutoSelect["Jet"] = true;}else{m_algoAutoSelect["Jet"] = false;}
109  if(CatCenJet.getParameter<bool>("monitor")){m_algoAutoSelect["CenJet"] = true;}else{m_algoAutoSelect["CenJet"] = false;}
110  if(CatForJet.getParameter<bool>("monitor")){m_algoAutoSelect["ForJet"] = true;}else{m_algoAutoSelect["ForJet"] = false;}
111  if(CatTauJet.getParameter<bool>("monitor")){m_algoAutoSelect["TauJet"] = true;}else{m_algoAutoSelect["TauJet"] = false;}
112  if(CatETM .getParameter<bool>("monitor")){m_algoAutoSelect["ETM"] = true;}else{m_algoAutoSelect["ETM"] = false;}
113  if(CatETT .getParameter<bool>("monitor")){m_algoAutoSelect["ETT"] = true;}else{m_algoAutoSelect["ETT"] = false;}
114  if(CatHTM .getParameter<bool>("monitor")){m_algoAutoSelect["HTM"] = true;}else{m_algoAutoSelect["HTM"] = false;}
115  if(CatHTT .getParameter<bool>("monitor")){m_algoAutoSelect["HTT"] = true;}else{m_algoAutoSelect["HTT"] = false;}
116 
117  // If global non-automatic selection is enable all categories set to be monitored will use
118  // user defined algos
119  }else{
120 
121  m_algoAutoSelect["Mu"] = false;
122  m_algoAutoSelect["EG"] = false;
123  m_algoAutoSelect["IsoEG"] = false;
124  m_algoAutoSelect["Jet"] = false;
125  m_algoAutoSelect["CenJet"] = false;
126  m_algoAutoSelect["ForJet"] = false;
127  m_algoAutoSelect["TauJet"] = false;
128  m_algoAutoSelect["ETM"] = false;
129  m_algoAutoSelect["ETT"] = false;
130  m_algoAutoSelect["HTM"] = false;
131  m_algoAutoSelect["HTT"] = false;
132 
133  if(CatMu .getParameter<bool>("monitor")){m_selectedTriggers["Mu"] = CatMu .getParameter<string>("algo");}
134  if(CatEG .getParameter<bool>("monitor")){m_selectedTriggers["EG"] = CatEG .getParameter<string>("algo");}
135  if(CatIsoEG .getParameter<bool>("monitor")){m_selectedTriggers["IsoEG"] = CatIsoEG .getParameter<string>("algo");}
136  if(CatJet .getParameter<bool>("monitor")){m_selectedTriggers["Jet"] = CatJet .getParameter<string>("algo");}
137  if(CatCenJet.getParameter<bool>("monitor")){m_selectedTriggers["CenJet"] = CatCenJet.getParameter<string>("algo");}
138  if(CatForJet.getParameter<bool>("monitor")){m_selectedTriggers["CatForJet"] = CatForJet.getParameter<string>("algo");}
139  if(CatTauJet.getParameter<bool>("monitor")){m_selectedTriggers["TauJet"] = CatTauJet.getParameter<string>("algo");}
140  if(CatETM .getParameter<bool>("monitor")){m_selectedTriggers["ETM"] = CatETM .getParameter<string>("algo");}
141  if(CatETT .getParameter<bool>("monitor")){m_selectedTriggers["ETT"] = CatETT .getParameter<string>("algo");}
142  if(CatHTM .getParameter<bool>("monitor")){m_selectedTriggers["HTM"] = CatHTM .getParameter<string>("algo");}
143  if(CatHTT .getParameter<bool>("monitor")){m_selectedTriggers["HTT"] = CatHTT .getParameter<string>("algo");}
144 
145  }
146 
147  // If we are using algo-by-algo parametes we get them and set what is needed
148  }else{
149 
150  if(CatBPTX.getParameter<bool>("monitor")){
151  m_selectedTriggers["BPTX"] = CatBPTX.getParameter<string>("algo");
152  }
153 
154  if(CatMu.getParameter<bool>("monitor")){
155  m_algoAutoSelect["Mu"] = CatMu.getParameter<bool>("doAutoSelection");
156  if(!m_algoAutoSelect["Mu"]){m_selectedTriggers["Mu"] = CatMu.getParameter<string>("algo");}
157  }else{m_algoAutoSelect["Mu"] = false;}
158 
159  if(CatEG.getParameter<bool>("monitor")){
160  m_algoAutoSelect["EG"] = CatEG.getParameter<bool>("doAutoSelection");
161  if(!m_algoAutoSelect["EG"]){m_selectedTriggers["EG"] = CatEG.getParameter<string>("algo");}
162  }else{m_algoAutoSelect["EG"] = false;}
163 
164  if(CatIsoEG.getParameter<bool>("monitor")){
165  m_algoAutoSelect["IsoEG"] = CatIsoEG.getParameter<bool>("doAutoSelection");
166  if(!m_algoAutoSelect["IsoEG"]){m_selectedTriggers["IsoEG"] = CatIsoEG.getParameter<string>("algo");}
167  }else{m_algoAutoSelect["IsoEG"] = false;}
168 
169  if(CatJet.getParameter<bool>("monitor")){
170  m_algoAutoSelect["Jet"] = CatJet.getParameter<bool>("doAutoSelection");
171  if(!m_algoAutoSelect["Jet"]){m_selectedTriggers["Jet"] = CatJet.getParameter<string>("algo");}
172  }else{m_algoAutoSelect["Jet"] = false;}
173 
174  if(CatCenJet.getParameter<bool>("monitor")){
175  m_algoAutoSelect["CenJet"] = CatCenJet.getParameter<bool>("doAutoSelection");
176  if(!m_algoAutoSelect["CenJet"]){m_selectedTriggers["CenJet"] = CatCenJet.getParameter<string>("algo");}
177  }else{m_algoAutoSelect["CenJet"] = false;}
178 
179  if(CatForJet.getParameter<bool>("monitor")){
180  m_algoAutoSelect["CatForJet"] = CatForJet.getParameter<bool>("doAutoSelection");
181  if(!m_algoAutoSelect["CatForJet"]){m_selectedTriggers["CatForJet"] = CatForJet.getParameter<string>("algo");}
182  }else{m_algoAutoSelect["CatForJet"] = false;}
183 
184  if(CatTauJet.getParameter<bool>("monitor")){
185  m_algoAutoSelect["TauJet"] = CatTauJet.getParameter<bool>("doAutoSelection");
186  if(!m_algoAutoSelect["TauJet"]){m_selectedTriggers["TauJet"] = CatTauJet.getParameter<string>("algo");}
187  }else{m_algoAutoSelect["TauJet"] = false;}
188 
189  if(CatETM.getParameter<bool>("monitor")){
190  m_algoAutoSelect["ETM"] = CatETM.getParameter<bool>("doAutoSelection");
191  if(!m_algoAutoSelect["ETM"]){m_selectedTriggers["ETM"] = CatETM.getParameter<string>("algo");}
192  }else{m_algoAutoSelect["ETM"] = false;}
193 
194  if(CatETT.getParameter<bool>("monitor")){
195  m_algoAutoSelect["ETT"] = CatETT.getParameter<bool>("doAutoSelection");
196  if(!m_algoAutoSelect["ETT"]){m_selectedTriggers["ETT"] = CatETT.getParameter<string>("algo");}
197  }else{m_algoAutoSelect["ETT"] = false;}
198 
199  if(CatHTM.getParameter<bool>("monitor")){
200  m_algoAutoSelect["HTM"] = CatHTM.getParameter<bool>("doAutoSelection");
201  if(!m_algoAutoSelect["HTM"]){m_selectedTriggers["HTM"] = CatHTM.getParameter<string>("algo");}
202  }else{m_algoAutoSelect["HTM"] = false;}
203 
204  if(CatHTT.getParameter<bool>("monitor")){
205  m_algoAutoSelect["HTT"] = CatHTT.getParameter<bool>("doAutoSelection");
206  if(!m_algoAutoSelect["HTT"]){m_selectedTriggers["HTT"] = CatHTT.getParameter<string>("algo");}
207  }else{m_algoAutoSelect["HTT"] = false;}
208 
209  }
210 
211 
212  if (pset.getUntrackedParameter < bool > ("dqmStore", false)) {
213  dbe = Service < DQMStore > ().operator->();
214  dbe->setVerbose(0);
215  }
216 
217  m_outputFile = pset.getUntrackedParameter < std::string > ("outputFile","");
218 
219  if (m_outputFile.size() != 0) {
220  std::cout << "L1T Monitoring histograms will be saved to " << m_outputFile.c_str() << std::endl;
221  }
222 
223  bool disable = pset.getUntrackedParameter < bool > ("disableROOToutput", false);
224  if (disable) {m_outputFile = "";}
225 
226  if (dbe != NULL) {dbe->setCurrentFolder("L1T/L1TSync");}
227 
228 }
229 
230 //-------------------------------------------------------------------------------------
231 //-------------------------------------------------------------------------------------
233 
234 //-------------------------------------------------------------------------------------
235 //-------------------------------------------------------------------------------------
237 
238  if (m_verbose){cout << "[L1TSync_Offline] Called beginJob." << endl;}
239 
240  // get hold of back-end interface
241  DQMStore *dbe = 0;
242  dbe = Service < DQMStore > ().operator->();
243 
244  if (dbe) {
245  dbe->setCurrentFolder("L1T/L1TSync");
246  dbe->rmdir("L1T/L1TSync");
247  }
248 
249 }
250 
251 //-------------------------------------------------------------------------------------
252 //-------------------------------------------------------------------------------------
254 
255  if (m_verbose){cout << "[L1TSync_Offline] Called endJob." << endl;}
256 
257  if (m_outputFile.size() != 0 && dbe)
258  dbe->save(m_outputFile);
259 
260  return;
261 
262 }
263 
264 //-------------------------------------------------------------------------------------
266 //-------------------------------------------------------------------------------------
267 void L1TSync_Offline::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup){
268 
269  if (m_verbose){cout << "[L1TSync_Offline] Called beginRun." << endl;}
270 
271  // Initializing variables
272  int maxNbins = 2501;
273 
274  // Reseting run dependent variables
275  m_lhcFill = 0;
276  m_currentLS = 0;
277  m_certFirstLS.clear();
278  m_certLastLS .clear();
279 
280  // Getting Trigger menu from GT
282  iSetup.get<L1GtTriggerMenuRcd>().get(menuRcd);
283  const L1GtTriggerMenu* menu = menuRcd.product();
284 
285  // Filling Alias-Bit Map
286  for (CItAlgo algo = menu->gtAlgorithmAliasMap().begin(); algo!=menu->gtAlgorithmAliasMap().end(); ++algo){
287  m_algoBit[(algo->second).algoAlias()] = (algo->second).algoBitNumber();
288  }
289 
290  // Getting fill number for this run
291  //Handle<ConditionsInRunBlock> runConditions;
292  //iRun.getByType(runConditions);
293  //int lhcFillNumber = runConditions->lhcFillNumber;
294  //
295  //ESHandle<L1GtPrescaleFactors> l1GtPfAlgo;
296  //iSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().get(l1GtPfAlgo);
297  //const L1GtPrescaleFactors* m_l1GtPfAlgo = l1GtPfAlgo.product();
298 
299  L1TMenuHelper myMenuHelper = L1TMenuHelper(iSetup);
300 
301  m_selectedTriggers = myMenuHelper.testAlgos(m_selectedTriggers);
302 
303  map<string,string> tAutoSelTrig = myMenuHelper.getLUSOTrigger(m_algoAutoSelect,m_refPrescaleSet);
304  m_selectedTriggers.insert(tAutoSelTrig.begin(),tAutoSelTrig.end());
305 
306  // Initializing DQM Monitor Elements
307  dbe->setCurrentFolder("L1T/L1TSync");
308  m_ErrorMonitor = dbe->book1D("ErrorMonitor","ErrorMonitor",7,0,7);
309  m_ErrorMonitor->setBinLabel(UNKNOWN ,"UNKNOWN");
310  m_ErrorMonitor->setBinLabel(WARNING_DB_CONN_FAILED ,"WARNING_DB_CONN_FAILED"); // Errors from L1TOMDSHelper
311  m_ErrorMonitor->setBinLabel(WARNING_DB_QUERY_FAILED ,"WARNING_DB_QUERY_FAILED"); // Errors from L1TOMDSHelper
312  m_ErrorMonitor->setBinLabel(WARNING_DB_INCORRECT_NBUNCHES,"WARNING_DB_INCORRECT_NBUNCHES"); // Errors from L1TOMDSHelper
313  m_ErrorMonitor->setBinLabel(ERROR_UNABLE_RETRIVE_PRODUCT ,"ERROR_UNABLE_RETRIVE_PRODUCT");
314  m_ErrorMonitor->setBinLabel(ERROR_TRIGGERALIAS_NOTVALID ,"ERROR_TRIGGERALIAS_NOTVALID");
315  m_ErrorMonitor->setBinLabel(ERROR_LSBLOCK_NOTVALID ,"ERROR_LSBLOCK_NOTVALID");
316 
317  // Looping over selected triggers
318  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
319 
320  string tCategory = (*i).first;
321  string tTrigger = (*i).second;
322 
323  // Initializing LS blocks for certification
324  m_certFirstLS[(*i).second] = 0;
325  m_certLastLS [(*i).second] = 0;
326 
327  // Initializing DQM Monitors
328  dbe->setCurrentFolder("L1T/L1TSync/AlgoVsBunchStructure/");
329  m_algoVsBunchStructure[tTrigger] = dbe->book2D(tCategory,"min #Delta("+tTrigger+",Bunch)",maxNbins,-0.5,double(maxNbins)-0.5,5,-2.5,2.5);
330  m_algoVsBunchStructure[tTrigger] ->setAxisTitle("Lumi Section" ,1);
331 
332  dbe->setCurrentFolder("L1T/L1TSync/Certification/");
333  m_algoCertification[tTrigger] = dbe->book1D(tCategory, "fraction of in sync: "+tTrigger,maxNbins,-0.5,double(maxNbins)-0.5);
334  m_algoCertification[tTrigger] ->setAxisTitle("Lumi Section" ,1);
335 
336  }
337 
338 }
339 
340  //_____________________________________________________________________
341  // Function: beginLuminosityBlock
342  //_____________________________________________________________________
344 
345  if (m_verbose){cout << "[L1TSync_Offline] Called beginLuminosityBlock." << endl;}
346 
347  m_currentLSValid = true;
348 
349  }
350 
351 
352 //_____________________________________________________________________
354 
355  if(m_verbose){cout << "[L1TSync_Offline] Called endRun." << endl;}
356 
357  // When the run end for closing of the LS certification blocks and evaluation
358  // of synchronization for that block
359 
360  // This will be for Harvesting
361  // doFractionInSync(true,false);
362 
363 }
364 
365 //_____________________________________________________________________
366 void L1TSync_Offline::analyze(const Event & iEvent, const EventSetup & eventSetup){
367 
368 
369  if(m_verbose){cout << "[L1TSync_Offline] Called analyze." << endl;}
370 
371  // We only start analyzing if current LS is still valid
372  if(m_currentLSValid){
373 
374  if(m_verbose){cout << "[L1TSync_Offline] -> m_currentLSValid=" << m_currentLSValid << endl;}
375 
376  // Retriving information from GT
378  iEvent.getByLabel(m_l1GtEvmSource, gtEvmReadoutRecord);
379 
380  // Determining beam mode and fill number
381  if(gtEvmReadoutRecord.isValid()){
382 
383  const L1GtfeExtWord& gtfeEvmWord = gtEvmReadoutRecord->gtfeWord();
384  unsigned int lhcBeamMode = gtfeEvmWord.beamMode(); // Updating beam mode
385 
386  if(m_lhcFill == 0){
387  m_lhcFill = gtfeEvmWord.lhcFillNumber(); // Getting LHC Fill Number from GT
388 
389  //I AM HERE
390  getBeamConfOffline(iEvent); // Getting Beam Configuration from OMDS
391  // no OMDS //
392  /* (Savannah ticket https://savannah.cern.ch/task/?31857 )
393  Purged the OMDS helper from the module, since apparently we don't have access to that information from Offline.
394  The comparison with the closest BPTX trigger will be performed via conditions objects which are being implemented by Joao Pela.
395  In the meantime, for being able to test the module, he suggested to pass the correct bunch structure by hand for the specific run which is run during the test.
396  The idea of the temporary fix is setting the vector variable that stores the bunch structure either by hand or filling it with the BPTX fires (that is check for the event the BX's where tech0 fired and set those as true in the vector.
397  */
398  // no OMDS // m_beamConfig = myOMDSHelper.getBeamConfiguration(m_lhcFill,errorRetrieve); Yuhuuu!!!OB asked Joao Pela how to fetch that
399 
400 
401 
402 
403  }
404 
405  if(lhcBeamMode != STABLE){m_currentLSValid = false;
406  if(m_verbose){cout << "[L1TSync_Offline] -> m_currentLSValid=" << m_currentLSValid << "because beams mode not stable, being " << lhcBeamMode << endl;}
407  } // If Beams are not stable we invalidate this LS
408  }else{
409  int eCount = m_ErrorMonitor->getTH1()->GetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT);
410  eCount++;
411  m_ErrorMonitor->getTH1()->SetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT,eCount);
412  }
413  }else{
414  if(m_verbose){cout << "[L1TSync_Offline] -> m_currentLSValid=" << m_currentLSValid << endl;}
415  }
416 
417  // Commenting out un-necessary print outs (S.Dutta)
418  /* for(size_t l=0; l<m_beamConfig.beam1.size(); l++){
419  cout << "Beam 1: element " << l << " is in state " << m_beamConfig.beam1[l] << " --- Beam 2: element " << l << " is in state " << m_beamConfig.beam2[l] << endl;
420  }*/
421  //------------------------------------------------------------------------------
422  // If current LS is valid and Beam Configuration is Valid we analyse this event
423  //------------------------------------------------------------------------------
424  if(m_currentLSValid && m_beamConfig.isValid()){
425 
426  // Getting Final Decision Logic (FDL) Data from GT
427  edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecordData;
428  iEvent.getByLabel(m_l1GtDataDaqInputTag, gtReadoutRecordData);
429 
430  if(gtReadoutRecordData.isValid()){
431 
432  const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
433 
434  // Running over selected triggers
435  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
436 
437  string tTrigger = (*i).second;
438 
439  // Analyse only defined triggers
440  if(tTrigger != "Undefined" && tTrigger != "Undefined (Wrong Name)"){
441 
442  bool beamSingleConfig = false; // Single beam configured for this event
443  bool firedAlgo = false; // Algo fired in this event
444  unsigned int eventBx = ~0;
445 
446  // Running over FDL results to get which bits fired
447  for(unsigned int a=0 ; a<gtFdlVectorData.size() ; a++){
448 
449  // Selecting the FDL that triggered
450  if(gtFdlVectorData[a].bxInEvent() == 0){
451  eventBx = gtFdlVectorData[a].localBxNr();
452  if(gtFdlVectorData[a].gtDecisionWord()[ m_algoBit[tTrigger] ]){firedAlgo = true;}
453  }
454  }
455 
456  // Checking beam configuration
457  if ( m_beamConfig.beam1.size() > eventBx && m_beamConfig.beam2.size() > eventBx) {
458  if( m_beamConfig.beam1[eventBx] && !m_beamConfig.beam2[eventBx]){beamSingleConfig = true;}
459  if(!m_beamConfig.beam1[eventBx] && m_beamConfig.beam2[eventBx]){beamSingleConfig = true;}
460  }
461  // Analyse only if this trigger fired in this event
462  // NOTE: Veto cases where a single beam is configured since
463  // for this cases this could be a real-satelite bunch collision
464  // -> Calculate the minimum bx diference between this event and a configured bx
465  if(firedAlgo && !beamSingleConfig){
466 
467  int DifAlgoVsBunchStructure = 9999; // Majorated
468 
469  for(unsigned int a=0 ; a<gtFdlVectorData.size() ; a++){
470 
471  int bxFDL = gtFdlVectorData[a].localBxNr();
472  int bxInEvent = gtFdlVectorData[a].bxInEvent();
473 
474  if(m_beamConfig.bxConfig(bxFDL) && abs(bxInEvent)<abs(DifAlgoVsBunchStructure)){
475  DifAlgoVsBunchStructure = -1*bxInEvent;
476  }
477  }
478 
479  m_algoVsBunchStructure[tTrigger]->Fill(m_currentLS,DifAlgoVsBunchStructure);
480 
481  }
482  }
483  }
484  }
485  else{
486  int eCount = m_ErrorMonitor->getTH1()->GetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT);
487  eCount++;
488  m_ErrorMonitor->getTH1()->SetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT,eCount);
489  }
490 
491  }
492 }
493 
494 //_____________________________________________________________________
495 // Method: getBunchStructureOffline
496 // Description: Attempt to retrive Beam Configuration from Offline and if
497 // we find error handle it
498 //_____________________________________________________________________
500 
501  //Getting connection parameters
502  // [11:21:35] Pietro Vischia: pathCondDB and oracleDB are available in offline?
503  // [11:21:51] Joao Pela: no
504  // [11:21:56] Pietro Vischia: cool
505  // [11:21:58] Pietro Vischia: tks
506  // [11:22:00] Joao Pela: well
507  // [11:22:02] Joao Pela: maybe
508  // [11:22:05] Joao Pela: but assume no
509  // [11:22:22] Joao Pela: definitely assume no
510  // *** UPDATE: now we have a DB for Rate parameters, it would be useful to have s.th also for L1TSync
511 
512  // string oracleDB = m_parameters.getParameter<string>("oracleDB");
513  // string pathCondDB = m_parameters.getParameter<string>("pathCondDB");
514 
515  // m_beamConfig = myOMDSHelper.getBeamConfiguration(m_lhcFill,errorRetrieve);
516  // m_lhcFill -> lhcFillNumber
517  // errorRetrieve -> error
518  // m_beamConfig -> bConfig
519 
520 
521  // No error codes at the moment. Taking info from BPTX fires
522  // int errorRetrieve = 0; // NO_ERROR;
523  m_beamConfig.m_valid = true;
524 
525 
526 
527  // bool beamSingleConfig = false; // Single beam configured for this event
528  bool firedAlgo = false; // Algo fired in this event
529  // int eventBx = -1;
530 
531  // Running over FDL results to get which bits fired for BPTX (temporary fix Savannah ticket https://savannah.cern.ch/task/?31857 )
532  // Getting Final Decision Logic (FDL) Data from GT
533  edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecordData;
534  iEvent.getByLabel(m_l1GtDataDaqInputTag, gtReadoutRecordData);
535 
536  if(gtReadoutRecordData.isValid()){
537 
538  const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
539 
540  for(unsigned int a=0 ; a<gtFdlVectorData.size() ; a++){
541  // Selecting the FDL that triggered
542  if(gtFdlVectorData[a].bxInEvent() == 0){
543  //eventBx = gtFdlVectorData[a].localBxNr();
544  if(gtFdlVectorData[a].gtDecisionWord()[ m_algoBit[ m_selectedTriggers["BPTX"] ] ]){firedAlgo = true;}
545  }
546 
547  // Fill beam status with BPTX fires
548  if(firedAlgo){
549  m_beamConfig.beam1.push_back(true);
550  m_beamConfig.beam2.push_back(true);
551  }
552  else {
553  m_beamConfig.beam1.push_back(false);
554  m_beamConfig.beam2.push_back(false);
555  }
556  // End fill beam status with BPTX fires
557  } // End loop on FDL
558  } // End if readout is valid
559 
560 }
561 
562 
563 
564 //_____________________________________________________________________
565 // Method: doFractionInSync
566 // Description: Produce plot with the fraction of in sync trigger for
567 // LS blocks with enough statistics.
568 // Variable: iForce - Forces closing of all blocks and calculation of
569 // the respective fractions
570 // Variable: iBad - (Only works with iForce=true) Forces the current
571 // all current blocks to be marked as bad
572 //_____________________________________________________________________
573 //void L1TSync_Offline::doFractionInSync(bool iForce,bool iBad){
574 //
673 //}
674 
675 
676 //_____________________________________________________________________
677 // Method: certifyLSBlock
678 // Description: Fill the trigger certification plot by blocks
679 // Variable: iTrigger - Which trigger to certify
680 // Variable: iInitLs - Blocks initial LS
681 // Variable: iEndLs - Blocks end LS
682 // Variable: iValue - Value to be used to fill
683 //_____________________________________________________________________
684 //void L1TSync_Offline::certifyLSBlock(string iTrigger, int iInitLs, int iEndLs ,float iValue){
685 //
693 //
694 //}
695 
696 //define this as a plug-in
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
int i
Definition: DBlmapReader.cc:9
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2535
L1TSync_Offline(const edm::ParameterSet &ps)
0: Unidentified isolated particle
Definition: ParticleCode.h:19
std::map< std::string, std::string > testAlgos(std::map< std::string, std::string >)
#define abs(x)
Definition: mlp_lapack.h:159
#define NULL
Definition: scimark2.h:8
DEFINE_FWK_MODULE(HiMixingModule)
virtual void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
int iEvent
Definition: GenABIO.cc:243
std::map< std::string, std::string > getLUSOTrigger(std::map< std::string, bool > iCategories, int IndexRefPrescaleFactors)
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
const cms_uint32_t lhcFillNumber() const
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
virtual ~L1TSync_Offline()
void analyze(const edm::Event &e, const edm::EventSetup &c)
double a
Definition: hdecay.h:121
tuple cout
Definition: gather_cfg.py:121
const AlgorithmMap & gtAlgorithmAliasMap() const
get / set the algorithm map (by alias)
const cms_uint16_t beamMode() const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
Definition: Run.h:36
void endRun(const edm::Run &run, const edm::EventSetup &iSetup)