41 m_scalersSource_colLScal = consumes<LumiScalersCollection> (m_parameters.getParameter<
InputTag>(
"inputTagScalersResults"));
42 m_scalersSource_triggerScalers = consumes<Level1TriggerScalersCollection> (m_parameters.getParameter<
InputTag>(
"inputTagScalersResults"));
43 m_l1GtDataDaqInputTag = consumes<L1GlobalTriggerReadoutRecord> (m_parameters.getParameter<
InputTag>(
"inputTagL1GtDataDaq"));
44 m_verbose = m_parameters.getUntrackedParameter<
bool> (
"verbose",
false);
45 m_refPrescaleSet = m_parameters.getParameter <
int> (
"refPrescaleSet");
46 m_lsShiftGTRates = m_parameters.getUntrackedParameter<
int> (
"lsShiftGTRates",0);
52 m_inputCategories[
"IsoEG"] = Categories.getUntrackedParameter<
bool>(
"IsoEG");
53 m_inputCategories[
"Jet"] = Categories.getUntrackedParameter<
bool>(
"Jet");
54 m_inputCategories[
"CenJet"] = Categories.getUntrackedParameter<
bool>(
"CenJet");
55 m_inputCategories[
"ForJet"] = Categories.getUntrackedParameter<
bool>(
"ForJet");
56 m_inputCategories[
"TauJet"] = Categories.getUntrackedParameter<
bool>(
"TauJet");
57 m_inputCategories[
"ETM"] = Categories.getUntrackedParameter<
bool>(
"ETM");
58 m_inputCategories[
"ETT"] = Categories.getUntrackedParameter<
bool>(
"ETT");
59 m_inputCategories[
"HTT"] = Categories.getUntrackedParameter<
bool>(
"HTT");
60 m_inputCategories[
"HTM"] = Categories.getUntrackedParameter<
bool>(
"HTM");
66 if (m_outputFile.size() != 0) {
67 cout <<
"L1T Monitoring histograms will be saved to " << m_outputFile.c_str() << endl;
71 if (disable) {m_outputFile =
"";}
95 m_ErrorMonitor = ibooker.
book1D(
"ErrorMonitor",
"ErrorMonitor",5,0,5);
96 m_ErrorMonitor->
setBinLabel(1,
"WARNING_DB_CONN_FAILED");
97 m_ErrorMonitor->setBinLabel(2,
"WARNING_DB_QUERY_FAILED");
98 m_ErrorMonitor->setBinLabel(3,
"WARNING_DB_INCORRECT_NBUNCHES");
99 m_ErrorMonitor->setBinLabel(4,
"WARNING_PY_MISSING_FIT");
100 m_ErrorMonitor->setBinLabel(5,
"UNKNOWN");
107 m_selectedTriggers = myMenuHelper.
getLUSOTrigger(m_inputCategories,m_refPrescaleSet);
110 int srcAlgoXSecFit = m_parameters.getParameter<
int>(
"srcAlgoXSecFit");
111 if (srcAlgoXSecFit == 0){getXSexFitsOMDS (m_parameters);}
112 else if(srcAlgoXSecFit == 1){getXSexFitsPython(m_parameters);}
115 m_algoBit[(
algo->second).algoAlias()] = (
algo->second).algoBitNumber();
118 double minInstantLuminosity = m_parameters.getParameter<
double>(
"minInstantLuminosity");
119 double maxInstantLuminosity = m_parameters.getParameter<
double>(
"maxInstantLuminosity");
122 for(map<string,string>::const_iterator
i=m_selectedTriggers.begin() ;
i!=m_selectedTriggers.end() ;
i++){
124 TString tCategory = (*i).first;
125 TString tTrigger = (*i).second;
127 TString tErrorMessage =
"";
130 if(tTrigger !=
"Undefined" && m_templateFunctions.find(tTrigger) != m_templateFunctions.end()){
131 tTestFunction = m_templateFunctions[tTrigger];
133 else if(tTrigger ==
"Undefined"){
134 TString tFunc =
"-1";
135 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(m_maxNbins)-0.5);
137 else if(m_templateFunctions.find(tTrigger) == m_templateFunctions.end()){
138 TString tFunc =
"-1";
139 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(m_maxNbins)-0.5);
140 tErrorMessage =
" (Undefined Test Function)";
143 TString tFunc =
"-1";
144 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(m_maxNbins)-0.5);
147 if(tTrigger !=
"Undefined"){
150 tErrorMessage +=
" WARNING: Default Prescale = ";
154 if (tCategory ==
"Mu" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 4294967295){
155 tErrorMessage +=
" WARNING: Eta Range = ";
158 else if(tCategory ==
"EG" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 32639){
159 tErrorMessage +=
" WARNING: Eta Range = ";
162 else if(tCategory ==
"IsoEG" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 32639){
163 tErrorMessage +=
" WARNING: Eta Range = ";
167 if(tCategory ==
"Mu" && myMenuHelper.
getQualityAlias(tCategory,tTrigger) != 240){
168 tErrorMessage +=
" WARNING: Quality = ";
177 m_xSecVsInstLumi[tTrigger] = ibooker.
bookProfile(tCategory,
178 "Cross Sec. vs Inst. Lumi Algo: "+tTrigger+tErrorMessage,
180 minInstantLuminosity,
181 maxInstantLuminosity,0,500);
182 m_xSecVsInstLumi[tTrigger] ->
setAxisTitle(
"Instantaneous Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
183 m_xSecVsInstLumi[tTrigger] ->setAxisTitle(
"Algorithm #sigma [#mu b]" ,2);
184 m_xSecVsInstLumi[tTrigger] ->getTProfile()->GetListOfFunctions()->Add(tTestFunction);
185 m_xSecVsInstLumi[tTrigger] ->getTProfile()->SetMarkerStyle(23);
188 m_xSecObservedToExpected[tTrigger] = ibooker.
book1D(tCategory,
"Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,
double(m_maxNbins)-0.5);
189 m_xSecObservedToExpected[tTrigger] ->
setAxisTitle(
"Lumi Section" ,1);
190 m_xSecObservedToExpected[tTrigger] ->setAxisTitle(
"#sigma_{obs} / #sigma_{exp}" ,2);
198 if (m_verbose) {
cout <<
"[L1TRate:] Called beginRun." << endl;}
203 if (m_verbose) {
cout <<
"[L1TRate:] Called beginLuminosityBlock at LS=" << lumiBlock.
id().
luminosityBlock() << endl;}
211 if (m_verbose) {
cout <<
"[L1TRate:] Called endLuminosityBlock at LS=" << eventLS << endl;}
220 bool isDefRate,isDefLumi,isDefPrescaleIndex;
221 map<TString,double>* rates=0;
223 int prescalesIndex=0;
226 for(map<string,string>::const_iterator
i=m_selectedTriggers.begin() ;
i!=m_selectedTriggers.end() ;
i++){
227 string tTrigger = (*i).second;
228 m_xSecObservedToExpected[tTrigger]->getTH1()->Reset(
"ICE");
229 m_xSecVsInstLumi [tTrigger]->getTH1()->Reset(
"ICE");
232 for(
map<
int,map<TString,double> >::iterator
i=m_lsRates.begin() ;
i!=m_lsRates.end() ;
i++){
234 unsigned int ls = (*i).first;
235 rates = &(*i).second;
238 if(m_lsLuminosity.find(ls)==m_lsLuminosity.end()){isDefLumi=
false;}
241 lumi=m_lsLuminosity[
ls];
244 if(m_lsPrescaleIndex.find(ls)==m_lsPrescaleIndex.end()){isDefPrescaleIndex=
false;}
246 isDefPrescaleIndex=
true;
247 prescalesIndex=m_lsPrescaleIndex[
ls];
250 if(isDefRate && isDefLumi && isDefPrescaleIndex){
252 const vector<int>& currentPrescaleFactors = (*m_listsPrescaleFactors).at(prescalesIndex);
254 for(map<string,string>::const_iterator
i=m_selectedTriggers.begin() ;
i!=m_selectedTriggers.end() ;
i++){
256 string tTrigger = (*i).second;
257 TF1* tTestFunction = (TF1*) m_xSecVsInstLumi[tTrigger]->
getTProfile()->GetListOfFunctions()->First();
260 if(tTrigger !=
"Undefined"){
262 unsigned int trigBit = m_algoBit[tTrigger];
263 double trigPrescale = currentPrescaleFactors[trigBit];
264 double trigRate = (*rates)[tTrigger];
266 if(lumi!=0 && trigPrescale!=0 && trigRate!=0){
268 double AlgoXSec = (trigPrescale*trigRate)/lumi;
269 double TemplateFunctionValue = tTestFunction->Eval(lumi);
272 int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(ls);
273 m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,AlgoXSec/TemplateFunctionValue);
274 m_xSecVsInstLumi [tTrigger]->Fill(lumi,AlgoXSec);
276 if(m_verbose){
cout<<
"[L1TRate:] ls="<<ls<<
" Algo="<<tTrigger<<
" XSec="<<AlgoXSec<<
" Test="<<AlgoXSec/TemplateFunctionValue<<endl;}
280 int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(ls);
281 m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,0.000001);
282 if(m_verbose){
cout <<
"[L1TRate:] Algo="<< tTrigger<<
" XSec=Failed" << endl;}
297 iEvent.
getByToken(m_l1GtDataDaqInputTag, gtReadoutRecordData);
298 iEvent.
getByToken(m_scalersSource_colLScal, colLScal);
299 iEvent.
getByToken(m_scalersSource_triggerScalers, triggerScalers);
302 int EventRun = iEvent.
id().
run();
308 Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
311 int gtLS = (*itL1TScalers).lumiSegmentNr()+m_lsShiftGTRates;
314 if(m_lsRates.find(gtLS)==m_lsRates.end()){
316 if (m_verbose) {
cout <<
"[L1TRate:] Buffering GT Rates for LS=" << gtLS << endl;}
317 map<TString,double> bufferRate;
320 for(map<string,string>::const_iterator
i=m_selectedTriggers.begin() ;
i!=m_selectedTriggers.end() ;
i++){
322 string tTrigger = (*i).second;
325 if(tTrigger !=
"Undefined"){
327 unsigned int trigBit = m_algoBit[tTrigger];
330 bufferRate[tTrigger] = trigRate;
333 m_lsRates[gtLS] = bufferRate;
338 if(colLScal.
isValid() && colLScal->size()){
340 LumiScalersCollection::const_iterator itLScal = colLScal->begin();
341 unsigned int scalLS = itLScal->sectionNumber();
344 if(m_lsLuminosity.find(scalLS)==m_lsLuminosity.end()){
346 if (m_verbose) {
cout <<
"[L1TRate:] Buffering SCAL-HF Lumi for LS=" << scalLS << endl;}
347 double instLumi = itLScal->instantLumi();
348 double deadTimeNormHF = itLScal->deadTimeNormalization();
352 if(m_parameters.getUntrackedParameter<
bool>(
"useHFDeadTimeNormalization",
false)){
355 if(deadTimeNormHF==0){instLumi = 0;}
356 else {instLumi = instLumi/deadTimeNormHF;}
359 m_lsLuminosity[scalLS]=instLumi;
364 if(gtReadoutRecordData.
isValid()){
367 if(m_lsPrescaleIndex.find(eventLS)==m_lsPrescaleIndex.end()){
369 if (m_verbose) {
cout <<
"[L1TRate:] Buffering Prescale Index for LS=" << eventLS << endl;}
372 const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
376 for(
unsigned int i=0;
i<gtFdlVectorData.size();
i++){
377 if(gtFdlVectorData[
i].bxInEvent()==0){indexFDL=
i;
break;}
380 int CurrentPrescalesIndex = gtFdlVectorData[indexFDL].gtPrescaleFactorIndexAlgo();
381 m_lsPrescaleIndex[eventLS] = CurrentPrescalesIndex;
400 string pathCondDB = ps.
getParameter<
string>(
"pathCondDB");
404 myOMDSHelper.
connect(oracleDB,pathCondDB,conError);
406 map<string,WbMTriggerXSecFit> wbmFits;
410 wbmFits = myOMDSHelper.getWbMAlgoXsecFits(errorRetrive);
415 string eName = myOMDSHelper.enumToStringError(errorRetrive);
416 m_ErrorMonitor->Fill(eName);
420 string eName = myOMDSHelper.enumToStringError(conError);
421 m_ErrorMonitor->Fill(eName);
424 double minInstantLuminosity = m_parameters.getParameter<
double>(
"minInstantLuminosity");
425 double maxInstantLuminosity = m_parameters.getParameter<
double>(
"maxInstantLuminosity");
428 for(map<string,string>::const_iterator
a=m_selectedTriggers.begin() ;
a!=m_selectedTriggers.end() ;
a++){
430 string tTrigger = (*a).second;
433 if(tTrigger !=
"Undefined"){
435 if(wbmFits.find(tTrigger) != wbmFits.end()){
439 vector<double> tParameters;
440 tParameters.push_back(tWbMParameters.
pm1);
441 tParameters.push_back(tWbMParameters.
p0);
442 tParameters.push_back(tWbMParameters.
p1);
443 tParameters.push_back(tWbMParameters.
p2);
446 m_templateFunctions[tTrigger] =
new TF1(
"FitParametrization_"+tWbMParameters.
bitName,
448 minInstantLuminosity,maxInstantLuminosity);
449 m_templateFunctions[tTrigger] ->SetParameters(&tParameters[0]);
450 m_templateFunctions[tTrigger] ->SetLineWidth(1);
451 m_templateFunctions[tTrigger] ->SetLineColor(kRed);
453 }
else{noError =
false;}
476 std::vector<edm::ParameterSet> m_fitParameters = ps.
getParameter< vector<ParameterSet> >(
"fitParameters");
478 double minInstantLuminosity = m_parameters.getParameter<
double>(
"minInstantLuminosity");
479 double maxInstantLuminosity = m_parameters.getParameter<
double>(
"maxInstantLuminosity");
482 for(map<string,string>::const_iterator
a=m_selectedTriggers.begin() ;
a!=m_selectedTriggers.end() ;
a++){
484 string tTrigger = (*a).second;
487 if(tTrigger !=
"Undefined"){
489 bool foundFit =
false;
491 for(
unsigned int b=0 ;
b<m_fitParameters.size() ;
b++){
493 if(tTrigger == m_fitParameters[
b].getParameter<string>(
"AlgoName")){
495 TString tAlgoName = m_fitParameters[
b].getParameter<
string > (
"AlgoName");
496 TString tTemplateFunction = m_fitParameters[
b].getParameter<
string > (
"TemplateFunction");
497 vector<double> tParameters = m_fitParameters[
b].getParameter< vector<double> >(
"Parameters");
500 m_templateFunctions[tTrigger] =
new TF1(
"FitParametrization_"+tAlgoName,tTemplateFunction,
501 minInstantLuminosity,maxInstantLuminosity);
502 m_templateFunctions[tTrigger] ->SetParameters(&tParameters[0]);
503 m_templateFunctions[tTrigger] ->SetLineWidth(1);
504 m_templateFunctions[tTrigger] ->SetLineColor(kRed);
512 string eName =
"WARNING_PY_MISSING_FIT";
513 m_ErrorMonitor->Fill(eName);
LuminosityBlockID id() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
TProfile * getTProfile(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
bool connect(std::string iOracleDB, std::string iPathCondDB, int &error)
MonitorElement * bookProfile(Args &&...args)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
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)
LuminosityBlockNumber_t luminosityBlock() const
virtual void dqmBeginRun(edm::Run const &, edm::EventSetup const &)
std::vector< double > gtAlgoCountsRate() const
bool getXSexFitsPython(const edm::ParameterSet &ps)
MonitorElement * book1D(Args &&...args)
L1TRate(const edm::ParameterSet &ps)
bool getXSexFitsOMDS(const edm::ParameterSet &ps)
void setCurrentFolder(const std::string &fullpath)
const std::vector< std::vector< int > > & gtPrescaleFactors() const
get the prescale factors by reference
T const * product() const
LuminosityBlockNumber_t luminosityBlock() const
virtual void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
virtual void endLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
virtual void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &, const edm::EventSetup &) override
void analyze(const edm::Event &e, const edm::EventSetup &c)