20 m_l1GtUtils(ps, consumesCollector(),
false, *this) {
37 m_inputCategories[
"IsoEG"] = Categories.getUntrackedParameter<
bool>(
"IsoEG");
38 m_inputCategories[
"Jet"] = Categories.getUntrackedParameter<
bool>(
"Jet");
39 m_inputCategories[
"CenJet"] = Categories.getUntrackedParameter<
bool>(
"CenJet");
40 m_inputCategories[
"ForJet"] = Categories.getUntrackedParameter<
bool>(
"ForJet");
41 m_inputCategories[
"TauJet"] = Categories.getUntrackedParameter<
bool>(
"TauJet");
42 m_inputCategories[
"ETM"] = Categories.getUntrackedParameter<
bool>(
"ETM");
43 m_inputCategories[
"ETT"] = Categories.getUntrackedParameter<
bool>(
"ETT");
44 m_inputCategories[
"HTT"] = Categories.getUntrackedParameter<
bool>(
"HTT");
45 m_inputCategories[
"HTM"] = Categories.getUntrackedParameter<
bool>(
"HTM");
49 cout <<
"[L1TRate_Offline:] ____________ Storage initialization ____________ " << endl;
50 cout <<
"[L1TRate_Offline:] Setting up dbe folder: L1T/L1TRate" << endl;
62 if (
m_verbose) {
cout <<
"[L1TRate_Offline:] Called beginRun." << endl;}
102 TString tCategory = (*i).first;
103 TString tTrigger = (*i).second;
105 TString tErrorMessage =
"";
111 else if(tTrigger ==
"Undefined"){
112 TString tFunc =
"-1";
113 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(
m_maxNbins)-0.5);
116 TString tFunc =
"-1";
117 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(
m_maxNbins)-0.5);
118 tErrorMessage =
" (Undefined Test Function)";
121 TString tFunc =
"-1";
122 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(
m_maxNbins)-0.5);
125 if(tTrigger !=
"Undefined"){
128 tErrorMessage +=
" WARNING: Default Prescale = ";
132 if (tCategory ==
"Mu" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 4294967295){
133 tErrorMessage +=
" WARNING: Eta Range = ";
136 else if(tCategory ==
"EG" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 32639){
137 tErrorMessage +=
" WARNING: Eta Range = ";
140 else if(tCategory ==
"IsoEG" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 32639){
141 tErrorMessage +=
" WARNING: Eta Range = ";
145 if(tCategory ==
"Mu" && myMenuHelper.
getQualityAlias(tCategory,tTrigger) != 240){
146 tErrorMessage +=
" WARNING: Quality = ";
154 "Cross Sec. vs Deliv. Lumi: "+tTrigger+tErrorMessage,
156 minInstantLuminosity,
157 maxInstantLuminosity,0,500);
163 "Cross Sec. vs Recor. Lumi: "+tTrigger+tErrorMessage,
165 minInstantLuminosity,
166 maxInstantLuminosity,0,500);
172 "Cross Sec. vs Inst. Lumi Algo: "+tTrigger+tErrorMessage,
174 minInstantLuminosity,
175 maxInstantLuminosity,0,500);
176 m_CountsVsLS[tTrigger] ->setAxisTitle(
"Instantaneous Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
177 m_CountsVsLS[tTrigger] ->setAxisTitle(
"Algorithm #sigma [#mu b]" ,2);
178 m_CountsVsLS[tTrigger] ->getTProfile()->GetListOfFunctions()->Add(tTestFunction);
179 m_CountsVsLS[tTrigger] ->getTProfile()->SetMarkerStyle(23);
181 m_algoFit[tTrigger] = (TF1*) tTestFunction->Clone(
"Fit_"+tTrigger);
221 if (
m_verbose) {
cout <<
"[L1TRate_Offline:] Called endLuminosityBlock at LS=" << eventLS << endl;}
231 bool isDefLumi,isDefPrescaleIndex;
235 unsigned int prescalesIndex=0;
238 map<TString,double>* counts=
nullptr;
242 string tTrigger = (*i).second;
259 unsigned int lsOffline = (*j).first;
260 counts = &(*j).second;
263 unsigned int lsPreInd;
272 lsPreInd = lsOffline + 1;
276 isDefPrescaleIndex=
true;
280 if(isDefCount && isDefLumi && isDefPrescaleIndex && (prescalesIndex < m_listsPrescaleFactors->
size())){
282 const vector<int>& currentPrescaleFactors = (*m_listsPrescaleFactors).at(prescalesIndex);
286 string tTrigger = (*j).second;
287 double trigCount = (*counts)[tTrigger];
290 TF1* tTestFunction =
m_algoFit[tTrigger];
294 if(tTrigger !=
"Undefined"){
296 unsigned int trigBit =
m_algoBit[tTrigger];
297 double trigPrescale = currentPrescaleFactors[trigBit];
299 if(lumi!=0 && trigCount!=0 && trigPrescale!=0){
301 double RecLumi = lumi*(1. - deadtime/100.);
303 double AlgoXSec = (trigPrescale*trigCount)/RecLumi;
304 double TemplateFunctionValue = tTestFunction->Eval(lumi);
358 int EventRun = iEvent.
id().
run();
362 if(triggerScalers.
isValid() && !triggerScalers->empty()){
364 Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
373 const std::vector<unsigned int> gtAlgoCounts = itL1TScalers->gtAlgoCounts();
385 map<TString,double> bufferCount;
390 string tTrigger = (*i).second;
393 if(tTrigger !=
"Undefined"){
395 unsigned int trigBit =
m_algoBit[tTrigger];
396 double trigCount = gtAlgoCounts[trigBit];
398 bufferCount[tTrigger] = trigCount;
409 if(colLScal.
isValid() && !colLScal->empty()){
411 LumiScalersCollection::const_iterator itLScal = colLScal->begin();
412 unsigned int scalLS = itLScal->sectionNumber();
417 if (
m_verbose) {
cout <<
"[L1TRate_Offline:] Buffering SCAL-HF Lumi for LS=" << scalLS << endl;}
418 double instLumi = itLScal->instantLumi();
419 double deadTimeNormHF = itLScal->deadTimeNormalization();
442 if(deadTimeNormHF==0){instLumi = 0;}
443 else {instLumi = instLumi/deadTimeNormHF;}
451 if(gtReadoutRecordData.
isValid()){
456 if (
m_verbose) {
cout <<
"[L1TRate_Offline:] Buffering Prescale Index for LS=" << eventLS << endl;}
459 const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->
gtFdlVector();
463 for(
unsigned int i=0;
i<gtFdlVectorData.size();
i++){
464 if(gtFdlVectorData[
i].bxInEvent()==0){indexFDL=
i;
break;}
467 if(!gtFdlVectorData.empty())
469 int CurrentPrescalesIndex = gtFdlVectorData[indexFDL].gtPrescaleFactorIndexAlgo();
493 std::vector<edm::ParameterSet> m_fitParameters = ps.
getParameter< vector<ParameterSet> >(
"fitParameters");
501 string tTrigger = (*a).second;
504 if(tTrigger !=
"Undefined"){
506 bool foundFit =
false;
508 for(
unsigned int b=0 ;
b<m_fitParameters.size() ;
b++){
510 if(tTrigger == m_fitParameters[
b].getParameter<string>(
"AlgoName")){
512 TString tAlgoName = m_fitParameters[
b].getParameter<
string > (
"AlgoName");
513 TString tTemplateFunction = m_fitParameters[
b].getParameter<
string > (
"TemplateFunction");
514 vector<double> tParameters = m_fitParameters[
b].getParameter< vector<double> >(
"Parameters");
518 minInstantLuminosity,maxInstantLuminosity);
519 m_templateFunctions[tTrigger] ->SetParameters(&tParameters[0]);
520 m_templateFunctions[tTrigger] ->SetLineWidth(1);
521 m_templateFunctions[tTrigger] ->SetLineColor(kRed);
LuminosityBlockID id() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
edm::EDGetTokenT< Level1TriggerScalersCollection > m_scalersSource_L1TSCollection
MonitorElement * m_ErrorMonitor
MonitorElement * bookProfile(Args &&...args)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::map< std::string, std::string > m_selectedTriggers
#define DEFINE_FWK_MODULE(type)
const std::vector< L1GtFdlWord > gtFdlVector() const
get the vector of L1GtFdlWord
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, MonitorElement * > m_RecorLumiVsLS
std::map< TString, TF1 * > m_templateFunctions
LuminosityBlockNumber_t luminosityBlock() const
bool getXSexFitsPython(const edm::ParameterSet &ps)
void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
void endLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtDataDaqInputTag
std::map< int, double > m_lsLuminosity
edm::ParameterSet m_parameters
void setCurrentFolder(std::string const &fullpath)
L1TRate_Offline(const edm::ParameterSet &ps)
~L1TRate_Offline() override
MonitorElement * book1D(Args &&...args)
std::map< TString, MonitorElement * > m_xSecObservedVsDelivLumi
void retrieveL1EventSetup(const edm::EventSetup &)
retrieve all the relevant L1 trigger event setup records and cache them to improve the speed ...
std::map< TString, MonitorElement * > m_xSecObservedVsLS
std::map< TString, MonitorElement * > m_xSecObservedToExpected
void analyze(const edm::Event &e, const edm::EventSetup &c) override
std::map< int, int > m_lsPrescaleIndex
const std::vector< std::vector< int > > & gtPrescaleFactors() const
get the prescale factors by reference
std::map< std::string, bool > m_inputCategories
LuminosityBlockNumber_t luminosityBlock() const
std::map< int, double > m_lsDeadTime
double deadtimePercent() const
std::map< TString, MonitorElement * > m_CountsVsLS
void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &iSetup) override
const std::vector< std::vector< int > > * m_listsPrescaleFactors
edm::EDGetTokenT< LumiScalersCollection > m_scalersSource_LSCollection
std::map< int, std::map< TString, double > > m_lsRates
std::map< TString, int > m_algoBit
std::map< TString, MonitorElement * > m_DelivLumiVsLS
std::map< TString, MonitorElement * > m_xSecObservedVsRecorLumi
T const * product() const
std::map< TString, TF1 * > m_algoFit