22 m_l1GtUtils(ps, consumesCollector(),
false, *this) {
41 m_inputCategories[
"IsoEG"] = Categories.getUntrackedParameter<
bool>(
"IsoEG");
42 m_inputCategories[
"Jet"] = Categories.getUntrackedParameter<
bool>(
"Jet");
43 m_inputCategories[
"CenJet"] = Categories.getUntrackedParameter<
bool>(
"CenJet");
44 m_inputCategories[
"ForJet"] = Categories.getUntrackedParameter<
bool>(
"ForJet");
45 m_inputCategories[
"TauJet"] = Categories.getUntrackedParameter<
bool>(
"TauJet");
46 m_inputCategories[
"ETM"] = Categories.getUntrackedParameter<
bool>(
"ETM");
47 m_inputCategories[
"ETT"] = Categories.getUntrackedParameter<
bool>(
"ETT");
48 m_inputCategories[
"HTT"] = Categories.getUntrackedParameter<
bool>(
"HTT");
49 m_inputCategories[
"HTM"] = Categories.getUntrackedParameter<
bool>(
"HTM");
53 cout <<
"[L1TRate_Offline:] ____________ Storage initialization ____________ " << endl;
54 cout <<
"[L1TRate_Offline:] Setting up dbe folder: L1T/L1TRate" << endl;
66 cout <<
"[L1TRate_Offline:] Called beginRun." << endl;
102 TString tCategory = (*i).first;
103 TString tTrigger = (*i).second;
105 TString tErrorMessage =
"";
110 }
else if (tTrigger ==
"Undefined") {
111 TString tFunc =
"-1";
112 tTestFunction =
new TF1(
"FitParametrization_" + tTrigger, tFunc, 0,
double(
m_maxNbins) - 0.5);
114 TString tFunc =
"-1";
115 tTestFunction =
new TF1(
"FitParametrization_" + tTrigger, tFunc, 0,
double(
m_maxNbins) - 0.5);
116 tErrorMessage =
" (Undefined Test Function)";
118 TString tFunc =
"-1";
119 tTestFunction =
new TF1(
"FitParametrization_" + tTrigger, tFunc, 0,
double(
m_maxNbins) - 0.5);
122 if (tTrigger !=
"Undefined") {
124 tErrorMessage +=
" WARNING: Default Prescale = ";
128 if (tCategory ==
"Mu" &&
130 tErrorMessage +=
" WARNING: Eta Range = ";
132 }
else if (tCategory ==
"EG" && myMenuHelper.
getEtaRangeByAlias(tCategory, tTrigger) != 32639) {
133 tErrorMessage +=
" WARNING: Eta Range = ";
135 }
else if (tCategory ==
"IsoEG" && myMenuHelper.
getEtaRangeByAlias(tCategory, tTrigger) != 32639) {
136 tErrorMessage +=
" WARNING: Eta Range = ";
140 if (tCategory ==
"Mu" && myMenuHelper.
getQualityAlias(tCategory, tTrigger) != 240) {
141 tErrorMessage +=
" WARNING: Quality = ";
148 "Cross Sec. vs Deliv. Lumi: " + tTrigger + tErrorMessage,
150 minInstantLuminosity,
151 maxInstantLuminosity,
159 "Cross Sec. vs Recor. Lumi: " + tTrigger + tErrorMessage,
161 minInstantLuminosity,
162 maxInstantLuminosity,
170 "Cross Sec. vs Inst. Lumi Algo: " + tTrigger + tErrorMessage,
172 minInstantLuminosity,
173 maxInstantLuminosity,
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);
212 cout <<
"[L1TRate_Offline:] Called beginLuminosityBlock at LS=" << lumiBlock.
id().
luminosityBlock() << endl;
220 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;
257 unsigned int lsOffline = (*j).first;
258 counts = &(*j).second;
261 unsigned int lsPreInd;
271 lsPreInd = lsOffline + 1;
274 isDefPrescaleIndex =
false;
276 isDefPrescaleIndex =
true;
280 if (isDefCount && isDefLumi && isDefPrescaleIndex && (prescalesIndex < m_listsPrescaleFactors->
size())) {
281 const vector<int>& currentPrescaleFactors = (*m_listsPrescaleFactors).at(prescalesIndex);
284 string tTrigger = (*j).second;
285 double trigCount = (*counts)[tTrigger];
288 TF1* tTestFunction =
m_algoFit[tTrigger];
291 if (tTrigger !=
"Undefined") {
292 unsigned int trigBit =
m_algoBit[tTrigger];
293 double trigPrescale = currentPrescaleFactors[trigBit];
295 if (lumi != 0 && trigCount != 0 && trigPrescale != 0) {
296 double RecLumi = lumi * (1. - deadtime / 100.);
298 double AlgoXSec = (trigPrescale * trigCount) / RecLumi;
299 double TemplateFunctionValue = tTestFunction->Eval(lumi);
348 int EventRun = iEvent.
id().
run();
352 if (triggerScalers.
isValid() && !triggerScalers->empty()) {
353 Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
362 const std::vector<unsigned int> gtAlgoCounts = itL1TScalers->gtAlgoCounts();
373 map<TString, double> bufferCount;
377 string tTrigger = (*i).second;
380 if (tTrigger !=
"Undefined") {
381 unsigned int trigBit =
m_algoBit[tTrigger];
382 double trigCount = gtAlgoCounts[trigBit];
384 bufferCount[tTrigger] = trigCount;
393 if (colLScal.
isValid() && !colLScal->empty()) {
394 LumiScalersCollection::const_iterator itLScal = colLScal->begin();
395 unsigned int scalLS = itLScal->sectionNumber();
400 cout <<
"[L1TRate_Offline:] Buffering SCAL-HF Lumi for LS=" << scalLS << endl;
403 itLScal->instantLumi();
404 double deadTimeNormHF = itLScal->deadTimeNormalization();
425 if (deadTimeNormHF == 0) {
428 instLumi = instLumi / deadTimeNormHF;
437 if (gtReadoutRecordData.
isValid()) {
441 cout <<
"[L1TRate_Offline:] Buffering Prescale Index for LS=" << eventLS << endl;
445 const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
449 for (
unsigned int i = 0;
i < gtFdlVectorData.size();
i++) {
450 if (gtFdlVectorData[
i].bxInEvent() == 0) {
456 if (!gtFdlVectorData.empty()) {
457 int CurrentPrescalesIndex =
458 gtFdlVectorData[indexFDL].gtPrescaleFactorIndexAlgo();
479 std::vector<edm::ParameterSet> m_fitParameters = ps.
getParameter<vector<ParameterSet> >(
"fitParameters");
486 string tTrigger = (*a).second;
489 if (tTrigger !=
"Undefined") {
490 bool foundFit =
false;
492 for (
unsigned int b = 0;
b < m_fitParameters.size();
b++) {
493 if (tTrigger == m_fitParameters[
b].getParameter<string>(
"AlgoName")) {
494 TString tAlgoName = m_fitParameters[
b].getParameter<
string>(
"AlgoName");
495 TString tTemplateFunction = m_fitParameters[
b].getParameter<
string>(
"TemplateFunction");
496 vector<double> tParameters = m_fitParameters[
b].getParameter<vector<double> >(
"Parameters");
500 new TF1(
"FitParametrization_" + tAlgoName, tTemplateFunction, minInstantLuminosity, maxInstantLuminosity);
501 m_templateFunctions[tTrigger]->SetParameters(&tParameters[0]);
502 m_templateFunctions[tTrigger]->SetLineWidth(1);
503 m_templateFunctions[tTrigger]->SetLineColor(kRed);
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
void retrieveL1EventSetup(const edm::EventSetup &, bool isRun=true)
retrieve all the relevant L1 trigger event setup records and cache them to improve the speed ...
const edm::EventSetup & c
edm::EDGetTokenT< Level1TriggerScalersCollection > m_scalersSource_L1TSCollection
MonitorElement * m_ErrorMonitor
std::map< int, double > m_lsDeadTime
virtual void setCurrentFolder(std::string const &fullpath)
std::map< TString, MonitorElement * > m_xSecObservedToExpected
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
std::map< int, int > m_lsPrescaleIndex
std::map< std::string, bool > m_inputCategories
std::map< std::string, std::string > m_selectedTriggers
LuminosityBlockNumber_t luminosityBlock() const
std::map< int, std::map< TString, double > > m_lsRates
bool getXSexFitsPython(const edm::ParameterSet &ps)
const edm::ESGetToken< L1GtPrescaleFactors, L1GtPrescaleFactorsAlgoTrigRcd > m_l1GtPfAlgoToken
std::map< TString, MonitorElement * > m_xSecObservedVsLS
void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
bool getData(T &iHolder) const
void endLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
std::map< TString, MonitorElement * > m_xSecObservedVsDelivLumi
std::map< int, double > m_lsLuminosity
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtDataDaqInputTag
edm::ParameterSet m_parameters
L1TMenuHelper::Tokens m_helperTokens
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
std::map< TString, MonitorElement * > m_RecorLumiVsLS
std::map< TString, TF1 * > m_templateFunctions
L1TRate_Offline(const edm::ParameterSet &ps)
~L1TRate_Offline() override
std::map< TString, MonitorElement * > m_DelivLumiVsLS
virtual 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, int > m_algoBit
std::map< TString, TF1 * > m_algoFit
const std::vector< std::vector< int > > * m_listsPrescaleFactors
void analyze(const edm::Event &e, const edm::EventSetup &c) override
const std::vector< std::vector< int > > & gtPrescaleFactors() const
get the prescale factors by reference
T getParameter(std::string const &) const
LuminosityBlockNumber_t luminosityBlock() const
double deadtimePercent() const
void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &iSetup) override
std::map< TString, MonitorElement * > m_CountsVsLS
edm::EDGetTokenT< LumiScalersCollection > m_scalersSource_LSCollection
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
std::map< TString, MonitorElement * > m_xSecObservedVsRecorLumi
const edm::ESGetToken< L1GtTriggerMenu, L1GtTriggerMenuRcd > m_menuToken
tuple size
Write out results.