36 m_l1GtUtils(ps, consumesCollector(),
false, *this) {
53 m_inputCategories[
"IsoEG"] = Categories.getUntrackedParameter<
bool>(
"IsoEG");
54 m_inputCategories[
"Jet"] = Categories.getUntrackedParameter<
bool>(
"Jet");
55 m_inputCategories[
"CenJet"] = Categories.getUntrackedParameter<
bool>(
"CenJet");
56 m_inputCategories[
"ForJet"] = Categories.getUntrackedParameter<
bool>(
"ForJet");
57 m_inputCategories[
"TauJet"] = Categories.getUntrackedParameter<
bool>(
"TauJet");
58 m_inputCategories[
"ETM"] = Categories.getUntrackedParameter<
bool>(
"ETM");
59 m_inputCategories[
"ETT"] = Categories.getUntrackedParameter<
bool>(
"ETT");
60 m_inputCategories[
"HTT"] = Categories.getUntrackedParameter<
bool>(
"HTT");
61 m_inputCategories[
"HTM"] = Categories.getUntrackedParameter<
bool>(
"HTM");
67 if (m_outputFile.size() != 0) {
68 cout <<
"L1T Monitoring histograms will be saved to " << m_outputFile.c_str() << endl;
72 if (disable) {m_outputFile =
"";}
126 TString tCategory = (*i).first;
127 TString tTrigger = (*i).second;
129 TString tErrorMessage =
"";
135 else if(tTrigger ==
"Undefined"){
136 TString tFunc =
"-1";
137 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(
m_maxNbins)-0.5);
140 TString tFunc =
"-1";
141 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(
m_maxNbins)-0.5);
142 tErrorMessage =
" (Undefined Test Function)";
145 TString tFunc =
"-1";
146 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(
m_maxNbins)-0.5);
149 if(tTrigger !=
"Undefined"){
152 tErrorMessage +=
" WARNING: Default Prescale = ";
156 if (tCategory ==
"Mu" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 4294967295){
157 tErrorMessage +=
" WARNING: Eta Range = ";
160 else if(tCategory ==
"EG" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 32639){
161 tErrorMessage +=
" WARNING: Eta Range = ";
164 else if(tCategory ==
"IsoEG" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 32639){
165 tErrorMessage +=
" WARNING: Eta Range = ";
169 if(tCategory ==
"Mu" && myMenuHelper.
getQualityAlias(tCategory,tTrigger) != 240){
170 tErrorMessage +=
" WARNING: Quality = ";
180 "Cross Sec. vs Inst. Lumi Algo: "+tTrigger+tErrorMessage,
182 minInstantLuminosity,
183 maxInstantLuminosity,0,500);
184 m_xSecVsInstLumi[tTrigger] ->setAxisTitle(
"Instantaneous Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
186 m_xSecVsInstLumi[tTrigger] ->getTProfile()->GetListOfFunctions()->Add(tTestFunction);
200 if (
m_verbose) {
cout <<
"[L1TRate:] Called beginRun." << endl;}
213 if (
m_verbose) {
cout <<
"[L1TRate:] Called endLuminosityBlock at LS=" << eventLS << endl;}
222 bool isDefRate,isDefLumi,isDefPrescaleIndex;
223 map<TString,double>* rates=0;
225 int prescalesIndex=0;
229 string tTrigger = (*i).second;
236 unsigned int ls = (*i).first;
237 rates = &(*i).second;
248 isDefPrescaleIndex=
true;
252 if(isDefRate && isDefLumi && isDefPrescaleIndex){
254 const vector<int>& currentPrescaleFactors = (*m_listsPrescaleFactors).at(prescalesIndex);
258 string tTrigger = (*i).second;
259 TF1* tTestFunction = (TF1*)
m_xSecVsInstLumi[tTrigger]->getTProfile()->GetListOfFunctions()->First();
262 if(tTrigger !=
"Undefined"){
264 unsigned int trigBit =
m_algoBit[tTrigger];
265 double trigPrescale = currentPrescaleFactors[trigBit];
266 double trigRate = (*rates)[tTrigger];
268 if(lumi!=0 && trigPrescale!=0 && trigRate!=0){
270 double AlgoXSec = (trigPrescale*trigRate)/lumi;
271 double TemplateFunctionValue = tTestFunction->Eval(lumi);
278 if(
m_verbose){
cout<<
"[L1TRate:] ls="<<ls<<
" Algo="<<tTrigger<<
" XSec="<<AlgoXSec<<
" Test="<<AlgoXSec/TemplateFunctionValue<<endl;}
284 if(
m_verbose){
cout <<
"[L1TRate:] Algo="<< tTrigger<<
" XSec=Failed" << endl;}
304 int EventRun = iEvent.
id().
run();
310 Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
318 if (
m_verbose) {
cout <<
"[L1TRate:] Buffering GT Rates for LS=" << gtLS << endl;}
319 map<TString,double> bufferRate;
324 string tTrigger = (*i).second;
327 if(tTrigger !=
"Undefined"){
329 unsigned int trigBit =
m_algoBit[tTrigger];
332 bufferRate[tTrigger] = trigRate;
340 if(colLScal.
isValid() && colLScal->size()){
342 LumiScalersCollection::const_iterator itLScal = colLScal->begin();
343 unsigned int scalLS = itLScal->sectionNumber();
348 if (
m_verbose) {
cout <<
"[L1TRate:] Buffering SCAL-HF Lumi for LS=" << scalLS << endl;}
349 double instLumi = itLScal->instantLumi();
350 double deadTimeNormHF = itLScal->deadTimeNormalization();
357 if(deadTimeNormHF==0){instLumi = 0;}
358 else {instLumi = instLumi/deadTimeNormHF;}
366 if(gtReadoutRecordData.
isValid()){
371 if (
m_verbose) {
cout <<
"[L1TRate:] Buffering Prescale Index for LS=" << eventLS << endl;}
374 const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->
gtFdlVector();
378 for(
unsigned int i=0;
i<gtFdlVectorData.size();
i++){
379 if(gtFdlVectorData[
i].bxInEvent()==0){indexFDL=
i;
break;}
382 int CurrentPrescalesIndex = gtFdlVectorData[indexFDL].gtPrescaleFactorIndexAlgo();
402 string pathCondDB = ps.
getParameter<
string>(
"pathCondDB");
406 myOMDSHelper.
connect(oracleDB,pathCondDB,conError);
408 map<string,WbMTriggerXSecFit> wbmFits;
412 wbmFits = myOMDSHelper.getWbMAlgoXsecFits(errorRetrive);
417 string eName = myOMDSHelper.enumToStringError(errorRetrive);
422 string eName = myOMDSHelper.enumToStringError(conError);
432 string tTrigger = (*a).second;
435 if(tTrigger !=
"Undefined"){
437 if(wbmFits.find(tTrigger) != wbmFits.end()){
441 vector<double> tParameters;
442 tParameters.push_back(tWbMParameters.
pm1);
443 tParameters.push_back(tWbMParameters.
p0);
444 tParameters.push_back(tWbMParameters.
p1);
445 tParameters.push_back(tWbMParameters.
p2);
450 minInstantLuminosity,maxInstantLuminosity);
455 }
else{noError =
false;}
478 std::vector<edm::ParameterSet> m_fitParameters = ps.
getParameter< vector<ParameterSet> >(
"fitParameters");
486 string tTrigger = (*a).second;
489 if(tTrigger !=
"Undefined"){
491 bool foundFit =
false;
493 for(
unsigned int b=0 ;
b<m_fitParameters.size() ;
b++){
495 if(tTrigger == m_fitParameters[
b].getParameter<string>(
"AlgoName")){
497 TString tAlgoName = m_fitParameters[
b].getParameter<
string > (
"AlgoName");
498 TString tTemplateFunction = m_fitParameters[
b].getParameter<
string > (
"TemplateFunction");
499 vector<double> tParameters = m_fitParameters[
b].getParameter< vector<double> >(
"Parameters");
503 minInstantLuminosity,maxInstantLuminosity);
504 m_templateFunctions[tTrigger] ->SetParameters(&tParameters[0]);
505 m_templateFunctions[tTrigger] ->SetLineWidth(1);
506 m_templateFunctions[tTrigger] ->SetLineColor(kRed);
514 string eName =
"WARNING_PY_MISSING_FIT";
LuminosityBlockID id() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< LumiScalersCollection > m_scalersSource_colLScal
edm::EDGetTokenT< Level1TriggerScalersCollection > m_scalersSource_triggerScalers
virtual void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
std::map< int, std::map< TString, double > > m_lsRates
bool connect(std::string iOracleDB, std::string iPathCondDB, int &error)
MonitorElement * bookProfile(Args &&...args)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::map< TString, MonitorElement * > m_xSecObservedToExpected
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtDataDaqInputTag
const std::vector< L1GtFdlWord > gtFdlVector() const
get the vector of L1GtFdlWord
edm::ParameterSet m_parameters
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)
std::map< TString, TF1 * > m_templateFunctions
LuminosityBlockNumber_t luminosityBlock() const
virtual void endLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
std::vector< double > gtAlgoCountsRate() const
bool getXSexFitsPython(const edm::ParameterSet &ps)
std::map< int, double > m_lsLuminosity
MonitorElement * book1D(Args &&...args)
std::map< TString, int > m_algoBit
void retrieveL1EventSetup(const edm::EventSetup &)
retrieve all the relevant L1 trigger event setup records and cache them to improve the speed ...
L1TRate(const edm::ParameterSet &ps)
bool getXSexFitsOMDS(const edm::ParameterSet &ps)
void analyze(const edm::Event &e, const edm::EventSetup &c) override
void setCurrentFolder(const std::string &fullpath)
const std::vector< std::vector< int > > & gtPrescaleFactors() const
get the prescale factors by reference
const std::vector< std::vector< int > > * m_listsPrescaleFactors
LuminosityBlockNumber_t luminosityBlock() const
std::map< TString, MonitorElement * > m_xSecVsInstLumi
std::map< std::string, bool > m_inputCategories
MonitorElement * m_ErrorMonitor
virtual void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
T const * product() const
std::map< int, int > m_lsPrescaleIndex
std::map< std::string, std::string > m_selectedTriggers
virtual void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &, const edm::EventSetup &) override