27 m_scalersSource_LSCollection = consumes<LumiScalersCollection> (m_parameters.getParameter<
InputTag>(
"inputTagScalersResults"));
28 m_scalersSource_L1TSCollection = consumes<Level1TriggerScalersCollection>(m_parameters.getParameter<
InputTag>(
"inputTagScalersResults"));
29 m_l1GtDataDaqInputTag = consumes<L1GlobalTriggerReadoutRecord> (m_parameters.getParameter<
InputTag>(
"inputTagL1GtDataDaq"));
30 m_verbose = m_parameters.getUntrackedParameter<
bool>(
"verbose",
false);
31 m_refPrescaleSet = m_parameters.getParameter <
int> (
"refPrescaleSet");
32 m_lsShiftGTRates = m_parameters.getUntrackedParameter<
int> (
"lsShiftGTRates",0);
38 m_inputCategories[
"IsoEG"] = Categories.getUntrackedParameter<
bool>(
"IsoEG");
39 m_inputCategories[
"Jet"] = Categories.getUntrackedParameter<
bool>(
"Jet");
40 m_inputCategories[
"CenJet"] = Categories.getUntrackedParameter<
bool>(
"CenJet");
41 m_inputCategories[
"ForJet"] = Categories.getUntrackedParameter<
bool>(
"ForJet");
42 m_inputCategories[
"TauJet"] = Categories.getUntrackedParameter<
bool>(
"TauJet");
43 m_inputCategories[
"ETM"] = Categories.getUntrackedParameter<
bool>(
"ETM");
44 m_inputCategories[
"ETT"] = Categories.getUntrackedParameter<
bool>(
"ETT");
45 m_inputCategories[
"HTT"] = Categories.getUntrackedParameter<
bool>(
"HTT");
46 m_inputCategories[
"HTM"] = Categories.getUntrackedParameter<
bool>(
"HTM");
50 cout <<
"[L1TRate_Offline:] ____________ Storage initialization ____________ " << endl;
51 cout <<
"[L1TRate_Offline:] Setting up dbe folder: L1T/L1TRate" << endl;
56 dbe->setCurrentFolder(
"L1T/L1TRate");
59 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Pointer for DQM Store: " << dbe << endl;}
68 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called beginJob." << endl;}
75 dbe->setCurrentFolder(
"L1T/L1TRate");
76 dbe->rmdir(
"L1T/L1TRate");
84 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called endJob." << endl;}
86 if (m_outputFile.size() != 0 && dbe)
87 dbe->save(m_outputFile);
98 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called beginRun." << endl;}
110 dbe->setCurrentFolder(
"L1T/L1TRate");
111 m_ErrorMonitor = dbe->book1D(
"ErrorMonitor",
"ErrorMonitor",2,0,2);
112 m_ErrorMonitor->setBinLabel(
UNKNOWN ,
"UNKNOWN");
113 m_ErrorMonitor->setBinLabel(WARNING_PY_MISSING_FIT,
"WARNING_PY_MISSING_FIT");
115 if (m_verbose) {
cout <<
"[L1TRate_Offline:] m_ErrorMonitor: " << m_ErrorMonitor << endl;}
122 m_selectedTriggers = myMenuHelper.
getLUSOTrigger(m_inputCategories,m_refPrescaleSet);
125 getXSexFitsPython(m_parameters);
128 m_algoBit[(algo->second).algoAlias()] = (algo->second).algoBitNumber();
131 double minInstantLuminosity = m_parameters.getParameter<
double>(
"minInstantLuminosity");
132 double maxInstantLuminosity = m_parameters.getParameter<
double>(
"maxInstantLuminosity");
135 for(map<string,string>::const_iterator
i=m_selectedTriggers.begin() ;
i!=m_selectedTriggers.end() ;
i++){
137 TString tCategory = (*i).first;
138 TString tTrigger = (*i).second;
140 TString tErrorMessage =
"";
143 if(tTrigger !=
"Undefined" && m_templateFunctions.find(tTrigger) != m_templateFunctions.end()){
144 tTestFunction = m_templateFunctions[tTrigger];
146 else if(tTrigger ==
"Undefined"){
147 TString tFunc =
"-1";
148 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(m_maxNbins)-0.5);
150 else if(m_templateFunctions.find(tTrigger) == m_templateFunctions.end()){
151 TString tFunc =
"-1";
152 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(m_maxNbins)-0.5);
153 tErrorMessage =
" (Undefined Test Function)";
156 TString tFunc =
"-1";
157 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(m_maxNbins)-0.5);
160 if(tTrigger !=
"Undefined"){
163 tErrorMessage +=
" WARNING: Default Prescale = ";
167 if (tCategory ==
"Mu" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 4294967295){
168 tErrorMessage +=
" WARNING: Eta Range = ";
171 else if(tCategory ==
"EG" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 32639){
172 tErrorMessage +=
" WARNING: Eta Range = ";
175 else if(tCategory ==
"IsoEG" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 32639){
176 tErrorMessage +=
" WARNING: Eta Range = ";
180 if(tCategory ==
"Mu" && myMenuHelper.
getQualityAlias(tCategory,tTrigger) != 240){
181 tErrorMessage +=
" WARNING: Quality = ";
187 dbe->setCurrentFolder(
"L1T/L1TRate/xSecDelivLumi");
188 m_xSecObservedVsDelivLumi[tTrigger] = dbe->bookProfile(tCategory,
189 "Cross Sec. vs Deliv. Lumi: "+tTrigger+tErrorMessage,
191 minInstantLuminosity,
192 maxInstantLuminosity,0,500);
193 m_xSecObservedVsDelivLumi[tTrigger] ->setAxisTitle(
"Delivered Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
194 m_xSecObservedVsDelivLumi[tTrigger] ->setAxisTitle(
"Algorithm #sigma [#mu b]" ,2);
196 dbe->setCurrentFolder(
"L1T/L1TRate/xSecRecorLumi");
197 m_xSecObservedVsRecorLumi[tTrigger] = dbe->bookProfile(tCategory,
198 "Cross Sec. vs Recor. Lumi: "+tTrigger+tErrorMessage,
200 minInstantLuminosity,
201 maxInstantLuminosity,0,500);
202 m_xSecObservedVsRecorLumi[tTrigger] ->setAxisTitle(
"Recorded Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
203 m_xSecObservedVsRecorLumi[tTrigger] ->setAxisTitle(
"Algorithm #sigma [#mu b]" ,2);
205 dbe->setCurrentFolder(
"L1T/L1TRate/TriggerCounts");
206 m_CountsVsLS[tTrigger] = dbe->bookProfile(tCategory,
207 "Cross Sec. vs Inst. Lumi Algo: "+tTrigger+tErrorMessage,
209 minInstantLuminosity,
210 maxInstantLuminosity,0,500);
211 m_CountsVsLS[tTrigger] ->setAxisTitle(
"Instantaneous Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
212 m_CountsVsLS[tTrigger] ->setAxisTitle(
"Algorithm #sigma [#mu b]" ,2);
213 m_CountsVsLS[tTrigger] ->getTProfile()->GetListOfFunctions()->Add(tTestFunction);
214 m_CountsVsLS[tTrigger] ->getTProfile()->SetMarkerStyle(23);
216 m_algoFit[tTrigger] = (TF1*) tTestFunction->Clone(
"Fit_"+tTrigger);
218 dbe->setCurrentFolder(
"L1T/L1TRate/xSecObs");
219 m_xSecObservedVsLS[tTrigger] = dbe->book1D(tCategory,
"Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,
double(m_maxNbins)-0.5);
220 m_xSecObservedVsLS[tTrigger] ->setAxisTitle(
"Lumi Section" ,1);
221 m_xSecObservedVsLS[tTrigger] ->setAxisTitle(
"#sigma_{obs}" ,2);
223 dbe->setCurrentFolder(
"L1T/L1TRate/Delivered");
224 m_DelivLumiVsLS[tTrigger] = dbe->book1D(tCategory,
"Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,
double(m_maxNbins)-0.5);
225 m_DelivLumiVsLS[tTrigger] ->setAxisTitle(
"Lumi Section" ,1);
226 m_DelivLumiVsLS[tTrigger] ->setAxisTitle(
"Deliv. Lumi" ,2);
228 dbe->setCurrentFolder(
"L1T/L1TRate/Recorded");
229 m_RecorLumiVsLS[tTrigger] = dbe->book1D(tCategory,
"Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,
double(m_maxNbins)-0.5);
230 m_RecorLumiVsLS[tTrigger] ->setAxisTitle(
"Lumi Section" ,1);
231 m_RecorLumiVsLS[tTrigger] ->setAxisTitle(
"Recor. Lumi" ,2);
233 dbe->setCurrentFolder(
"L1T/L1TRate/Ratio");
234 m_xSecObservedToExpected[tTrigger] = dbe->book1D(tCategory,
"Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,
double(m_maxNbins)-0.5);
235 m_xSecObservedToExpected[tTrigger] ->setAxisTitle(
"Lumi Section" ,1);
236 m_xSecObservedToExpected[tTrigger] ->setAxisTitle(
"#sigma_{obs} / #sigma_{exp}" ,2);
250 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called endRun." << endl;}
256 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called beginLuminosityBlock at LS=" << lumiBlock.
id().
luminosityBlock() << endl;}
264 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called endLuminosityBlock at LS=" << eventLS << endl;}
274 bool isDefLumi,isDefPrescaleIndex;
278 int prescalesIndex=0;
281 map<TString,double>* counts=0;
284 for(map<string,string>::const_iterator
i=m_selectedTriggers.begin() ;
i!=m_selectedTriggers.end() ;
i++){
285 string tTrigger = (*i).second;
287 m_CountsVsLS [tTrigger]->getTH1()->Reset(
"ICE");
288 m_xSecObservedToExpected[tTrigger]->getTH1()->Reset(
"ICE");
290 m_xSecObservedVsLS [tTrigger]->getTH1()->Reset(
"ICE");
291 m_DelivLumiVsLS [tTrigger]->getTH1()->Reset(
"ICE");
292 m_RecorLumiVsLS [tTrigger]->getTH1()->Reset(
"ICE");
294 m_xSecObservedVsDelivLumi[tTrigger]->getTH1()->Reset(
"ICE");
295 m_xSecObservedVsRecorLumi[tTrigger]->getTH1()->Reset(
"ICE");
300 for(
map<
int,map<TString,double> >::iterator
j=m_lsRates.begin() ;
j!=m_lsRates.end() ;
j++){
302 unsigned int lsOffline = (*j).first;
303 counts = &(*j).second;
306 unsigned int lsPreInd;
308 if(m_lsLuminosity.find(lsOffline)==m_lsLuminosity.end()){isDefLumi=
false;}
311 lumi=m_lsLuminosity[lsOffline];
312 deadtime=m_lsDeadTime[lsOffline];
315 lsPreInd = lsOffline + 1;
317 if(m_lsPrescaleIndex.find(lsPreInd)==m_lsPrescaleIndex.end()){isDefPrescaleIndex=
false;}
319 isDefPrescaleIndex=
true;
320 prescalesIndex=m_lsPrescaleIndex[lsPreInd];
323 if(isDefCount && isDefLumi && isDefPrescaleIndex){
325 const vector<int>& currentPrescaleFactors = (*m_listsPrescaleFactors).at(prescalesIndex);
327 for(map<string,string>::const_iterator
j=m_selectedTriggers.begin() ;
j!=m_selectedTriggers.end() ;
j++){
329 string tTrigger = (*j).second;
330 double trigCount = (*counts)[tTrigger];
333 TF1* tTestFunction = m_algoFit[tTrigger];
337 if(tTrigger !=
"Undefined"){
339 unsigned int trigBit = m_algoBit[tTrigger];
340 double trigPrescale = currentPrescaleFactors[trigBit];
342 if(lumi!=0 && trigCount!=0 && trigPrescale!=0){
344 double RecLumi = lumi*(1. - deadtime/100.);
346 double AlgoXSec = (trigPrescale*trigCount)/RecLumi;
347 double TemplateFunctionValue = tTestFunction->Eval(lumi);
354 m_xSecObservedVsRecorLumi[tTrigger]->Fill(RecLumi,AlgoXSec);
356 m_CountsVsLS [tTrigger]->Fill(lumi,AlgoXSec);
358 int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(lsOffline);
359 m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,AlgoXSec/TemplateFunctionValue);
361 m_DelivLumiVsLS[tTrigger]->setBinContent(ibin,lumi);
362 m_RecorLumiVsLS[tTrigger]->setBinContent(ibin,RecLumi);
364 m_xSecObservedVsLS[tTrigger]->setBinContent(ibin,AlgoXSec);
370 m_xSecObservedVsRecorLumi[tTrigger]->Fill(0.000001,0.000001);
372 m_CountsVsLS [tTrigger]->Fill(0.000001,0.000001);
374 int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(lsOffline);
375 m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,0.000001);
377 m_DelivLumiVsLS[tTrigger]->setBinContent(ibin,0.000001);
378 m_RecorLumiVsLS[tTrigger]->setBinContent(ibin,0.000001);
380 m_xSecObservedVsLS[tTrigger]->setBinContent(ibin,0.000001);
396 iEvent.
getByToken(m_l1GtDataDaqInputTag , gtReadoutRecordData);
397 iEvent.
getByToken(m_scalersSource_LSCollection , colLScal);
398 iEvent.
getByToken(m_scalersSource_L1TSCollection , triggerScalers);
401 int EventRun = iEvent.
id().
run();
405 if(triggerScalers.
isValid() && triggerScalers->size()){
407 Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
416 const std::vector<unsigned int> gtAlgoCounts = itL1TScalers->gtAlgoCounts();
423 int gtLS = (*itL1TScalers).lumiSegmentNr()+m_lsShiftGTRates;
426 if(m_lsRates.find(gtLS)==m_lsRates.end()){
428 map<TString,double> bufferCount;
431 for(map<string,string>::const_iterator
i=m_selectedTriggers.begin();
i!=m_selectedTriggers.end() ;
i++){
433 string tTrigger = (*i).second;
436 if(tTrigger !=
"Undefined"){
438 unsigned int trigBit = m_algoBit[tTrigger];
439 double trigCount = gtAlgoCounts[trigBit];
441 bufferCount[tTrigger] = trigCount;
445 m_lsRates[gtLS] = bufferCount;
446 m_lsDeadTime[gtLS] = deadtime;
452 if(colLScal.
isValid() && colLScal->size()){
454 LumiScalersCollection::const_iterator itLScal = colLScal->begin();
455 unsigned int scalLS = itLScal->sectionNumber();
458 if(m_lsLuminosity.find(scalLS)==m_lsLuminosity.end()){
460 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Buffering SCAL-HF Lumi for LS=" << scalLS << endl;}
461 double instLumi = itLScal->instantLumi();
462 double deadTimeNormHF = itLScal->deadTimeNormalization();
482 if(m_parameters.getUntrackedParameter<
bool>(
"useHFDeadTimeNormalization",
false)){
485 if(deadTimeNormHF==0){instLumi = 0;}
486 else {instLumi = instLumi/deadTimeNormHF;}
489 m_lsLuminosity[scalLS]=instLumi;
494 if(gtReadoutRecordData.
isValid()){
497 if(m_lsPrescaleIndex.find(eventLS)==m_lsPrescaleIndex.end()){
499 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Buffering Prescale Index for LS=" << eventLS << endl;}
502 const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
506 for(
unsigned int i=0;
i<gtFdlVectorData.size();
i++){
507 if(gtFdlVectorData[
i].bxInEvent()==0){indexFDL=
i;
break;}
510 if(gtFdlVectorData.size() != 0)
512 int CurrentPrescalesIndex = gtFdlVectorData[indexFDL].gtPrescaleFactorIndexAlgo();
513 m_lsPrescaleIndex[eventLS] = CurrentPrescalesIndex;
538 std::vector<edm::ParameterSet> m_fitParameters = ps.
getParameter< vector<ParameterSet> >(
"fitParameters");
540 double minInstantLuminosity = m_parameters.getParameter<
double>(
"minInstantLuminosity");
541 double maxInstantLuminosity = m_parameters.getParameter<
double>(
"maxInstantLuminosity");
544 for(map<string,string>::const_iterator
a=m_selectedTriggers.begin() ;
a!=m_selectedTriggers.end() ;
a++){
546 string tTrigger = (*a).second;
549 if(tTrigger !=
"Undefined"){
551 bool foundFit =
false;
553 for(
unsigned int b=0 ;
b<m_fitParameters.size() ;
b++){
555 if(tTrigger == m_fitParameters[
b].getParameter<string>(
"AlgoName")){
557 TString tAlgoName = m_fitParameters[
b].getParameter<
string > (
"AlgoName");
558 TString tTemplateFunction = m_fitParameters[
b].getParameter<
string > (
"TemplateFunction");
559 vector<double> tParameters = m_fitParameters[
b].getParameter< vector<double> >(
"Parameters");
562 m_templateFunctions[tTrigger] =
new TF1(
"FitParametrization_"+tAlgoName,tTemplateFunction,
563 minInstantLuminosity,maxInstantLuminosity);
564 m_templateFunctions[tTrigger] ->SetParameters(&tParameters[0]);
565 m_templateFunctions[tTrigger] ->SetLineWidth(1);
566 m_templateFunctions[tTrigger] ->SetLineColor(kRed);
576 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_PY_MISSING_FIT);
578 m_ErrorMonitor->getTH1()->SetBinContent(WARNING_PY_MISSING_FIT,eCount);
virtual void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
LuminosityBlockID id() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
0: Unidentified isolated particle
virtual void endLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
LuminosityBlockNumber_t luminosityBlock() const
bool getXSexFitsPython(const edm::ParameterSet &ps)
virtual ~L1TRate_Offline()
L1TRate_Offline(const edm::ParameterSet &ps)
void analyze(const edm::Event &e, const edm::EventSetup &c)
void beginRun(const edm::Run &run, const edm::EventSetup &iSetup)
const std::vector< std::vector< int > > & gtPrescaleFactors() const
get the prescale factors by reference
T const * product() const
LuminosityBlockNumber_t luminosityBlock() const
void endRun(const edm::Run &run, const edm::EventSetup &iSetup)
double deadtimePercent() const