34 m_l1GtUtils(ps, consumesCollector(),
false, *this) {
51 m_inputCategories[
"IsoEG"] = Categories.getUntrackedParameter<
bool>(
"IsoEG");
52 m_inputCategories[
"Jet"] = Categories.getUntrackedParameter<
bool>(
"Jet");
53 m_inputCategories[
"CenJet"] = Categories.getUntrackedParameter<
bool>(
"CenJet");
54 m_inputCategories[
"ForJet"] = Categories.getUntrackedParameter<
bool>(
"ForJet");
55 m_inputCategories[
"TauJet"] = Categories.getUntrackedParameter<
bool>(
"TauJet");
56 m_inputCategories[
"ETM"] = Categories.getUntrackedParameter<
bool>(
"ETM");
57 m_inputCategories[
"ETT"] = Categories.getUntrackedParameter<
bool>(
"ETT");
58 m_inputCategories[
"HTT"] = Categories.getUntrackedParameter<
bool>(
"HTT");
59 m_inputCategories[
"HTM"] = Categories.getUntrackedParameter<
bool>(
"HTM");
65 if (!m_outputFile.empty()) {
66 cout <<
"L1T Monitoring histograms will be saved to " << m_outputFile.c_str() << endl;
70 if (disable) {m_outputFile =
"";}
124 TString tCategory = (*i).first;
125 TString tTrigger = (*i).second;
127 TString tErrorMessage =
"";
133 else if(tTrigger ==
"Undefined"){
134 TString tFunc =
"-1";
135 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(
m_maxNbins)-0.5);
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 = ";
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);
184 m_xSecVsInstLumi[tTrigger] ->getTProfile()->GetListOfFunctions()->Add(tTestFunction);
198 if (
m_verbose) {
cout <<
"[L1TRate:] Called beginRun." << endl;}
211 if (
m_verbose) {
cout <<
"[L1TRate:] Called endLuminosityBlock at LS=" << eventLS << endl;}
220 bool isDefRate,isDefLumi,isDefPrescaleIndex;
221 map<TString,double>* rates=
nullptr;
223 int prescalesIndex=0;
227 string tTrigger = (*i).second;
234 unsigned int ls = (*i).first;
235 rates = &(*i).second;
246 isDefPrescaleIndex=
true;
250 if(isDefRate && isDefLumi && isDefPrescaleIndex){
252 const vector<int>& currentPrescaleFactors = (*m_listsPrescaleFactors).at(prescalesIndex);
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);
276 if(
m_verbose){
cout<<
"[L1TRate:] ls="<<ls<<
" Algo="<<tTrigger<<
" XSec="<<AlgoXSec<<
" Test="<<AlgoXSec/TemplateFunctionValue<<endl;}
282 if(
m_verbose){
cout <<
"[L1TRate:] Algo="<< tTrigger<<
" XSec=Failed" << endl;}
302 int EventRun = iEvent.
id().
run();
308 Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
316 if (
m_verbose) {
cout <<
"[L1TRate:] Buffering GT Rates for LS=" << gtLS << endl;}
317 map<TString,double> bufferRate;
322 string tTrigger = (*i).second;
325 if(tTrigger !=
"Undefined"){
327 unsigned int trigBit =
m_algoBit[tTrigger];
330 bufferRate[tTrigger] = trigRate;
338 if(colLScal.
isValid() && !colLScal->empty()){
340 LumiScalersCollection::const_iterator itLScal = colLScal->begin();
341 unsigned int scalLS = itLScal->sectionNumber();
346 if (
m_verbose) {
cout <<
"[L1TRate:] Buffering SCAL-HF Lumi for LS=" << scalLS << endl;}
347 double instLumi = itLScal->instantLumi();
348 double deadTimeNormHF = itLScal->deadTimeNormalization();
355 if(deadTimeNormHF==0){instLumi = 0;}
356 else {instLumi = instLumi/deadTimeNormHF;}
364 if(gtReadoutRecordData.
isValid()){
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();
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);
420 string eName = myOMDSHelper.enumToStringError(conError);
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);
448 minInstantLuminosity,maxInstantLuminosity);
453 }
else{noError =
false;}
476 std::vector<edm::ParameterSet> m_fitParameters = ps.
getParameter< vector<ParameterSet> >(
"fitParameters");
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");
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";
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
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
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
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
void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &, const edm::EventSetup &) override