28 m_scalersSource_LSCollection = consumes<LumiScalersCollection> (m_parameters.getParameter<
InputTag>(
"inputTagScalersResults"));
29 m_scalersSource_L1TSCollection = consumes<Level1TriggerScalersCollection>(m_parameters.getParameter<
InputTag>(
"inputTagScalersResults"));
30 m_l1GtDataDaqInputTag = consumes<L1GlobalTriggerReadoutRecord> (m_parameters.getParameter<
InputTag>(
"inputTagL1GtDataDaq"));
31 m_verbose = m_parameters.getUntrackedParameter<
bool>(
"verbose",
false);
32 m_refPrescaleSet = m_parameters.getParameter <
int> (
"refPrescaleSet");
33 m_lsShiftGTRates = m_parameters.getUntrackedParameter<
int> (
"lsShiftGTRates",0);
39 m_inputCategories[
"IsoEG"] = Categories.getUntrackedParameter<
bool>(
"IsoEG");
40 m_inputCategories[
"Jet"] = Categories.getUntrackedParameter<
bool>(
"Jet");
41 m_inputCategories[
"CenJet"] = Categories.getUntrackedParameter<
bool>(
"CenJet");
42 m_inputCategories[
"ForJet"] = Categories.getUntrackedParameter<
bool>(
"ForJet");
43 m_inputCategories[
"TauJet"] = Categories.getUntrackedParameter<
bool>(
"TauJet");
44 m_inputCategories[
"ETM"] = Categories.getUntrackedParameter<
bool>(
"ETM");
45 m_inputCategories[
"ETT"] = Categories.getUntrackedParameter<
bool>(
"ETT");
46 m_inputCategories[
"HTT"] = Categories.getUntrackedParameter<
bool>(
"HTT");
47 m_inputCategories[
"HTM"] = Categories.getUntrackedParameter<
bool>(
"HTM");
51 cout <<
"[L1TRate_Offline:] ____________ Storage initialization ____________ " << endl;
52 cout <<
"[L1TRate_Offline:] Setting up dbe folder: L1T/L1TRate" << endl;
57 dbe->setCurrentFolder(
"L1T/L1TRate");
60 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Pointer for DQM Store: " << dbe << endl;}
69 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called beginJob." << endl;}
77 dbe->
rmdir(
"L1T/L1TRate");
85 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called endJob." << endl;}
87 if (m_outputFile.size() != 0 && dbe)
88 dbe->save(m_outputFile);
99 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called beginRun." << endl;}
111 dbe->setCurrentFolder(
"L1T/L1TRate");
112 m_ErrorMonitor = dbe->book1D(
"ErrorMonitor",
"ErrorMonitor",2,0,2);
113 m_ErrorMonitor->setBinLabel(
UNKNOWN ,
"UNKNOWN");
114 m_ErrorMonitor->setBinLabel(WARNING_PY_MISSING_FIT,
"WARNING_PY_MISSING_FIT");
116 cout <<
"[L1TRate_Offline:] m_ErrorMonitor: " << m_ErrorMonitor << endl;
123 m_selectedTriggers = myMenuHelper.
getLUSOTrigger(m_inputCategories,m_refPrescaleSet);
126 getXSexFitsPython(m_parameters);
129 m_algoBit[(algo->second).algoAlias()] = (algo->second).algoBitNumber();
132 double minInstantLuminosity = m_parameters.getParameter<
double>(
"minInstantLuminosity");
133 double maxInstantLuminosity = m_parameters.getParameter<
double>(
"maxInstantLuminosity");
136 for(map<string,string>::const_iterator
i=m_selectedTriggers.begin() ;
i!=m_selectedTriggers.end() ;
i++){
138 TString tCategory = (*i).first;
139 TString tTrigger = (*i).second;
141 TString tErrorMessage =
"";
144 if(tTrigger !=
"Undefined" && m_templateFunctions.find(tTrigger) != m_templateFunctions.end()){
145 tTestFunction = m_templateFunctions[tTrigger];
147 else if(tTrigger ==
"Undefined"){
148 TString tFunc =
"-1";
149 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(m_maxNbins)-0.5);
151 else if(m_templateFunctions.find(tTrigger) == m_templateFunctions.end()){
152 TString tFunc =
"-1";
153 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(m_maxNbins)-0.5);
154 tErrorMessage =
" (Undefined Test Function)";
157 TString tFunc =
"-1";
158 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(m_maxNbins)-0.5);
161 if(tTrigger !=
"Undefined"){
164 tErrorMessage +=
" WARNING: Default Prescale = ";
168 if (tCategory ==
"Mu" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 4294967295){
169 tErrorMessage +=
" WARNING: Eta Range = ";
172 else if(tCategory ==
"EG" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 32639){
173 tErrorMessage +=
" WARNING: Eta Range = ";
176 else if(tCategory ==
"IsoEG" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 32639){
177 tErrorMessage +=
" WARNING: Eta Range = ";
181 if(tCategory ==
"Mu" && myMenuHelper.
getQualityAlias(tCategory,tTrigger) != 240){
182 tErrorMessage +=
" WARNING: Quality = ";
188 dbe->setCurrentFolder(
"L1T/L1TRate/xSecDelivLumi");
189 m_xSecObservedVsDelivLumi[tTrigger] = dbe->bookProfile(tCategory,
190 "Cross Sec. vs Deliv. Lumi: "+tTrigger+tErrorMessage,
192 minInstantLuminosity,
193 maxInstantLuminosity,0,500);
194 m_xSecObservedVsDelivLumi[tTrigger] ->setAxisTitle(
"Delivered Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
195 m_xSecObservedVsDelivLumi[tTrigger] ->setAxisTitle(
"Algorithm #sigma [#mu b]" ,2);
197 dbe->setCurrentFolder(
"L1T/L1TRate/xSecRecorLumi");
198 m_xSecObservedVsRecorLumi[tTrigger] = dbe->bookProfile(tCategory,
199 "Cross Sec. vs Recor. Lumi: "+tTrigger+tErrorMessage,
201 minInstantLuminosity,
202 maxInstantLuminosity,0,500);
203 m_xSecObservedVsRecorLumi[tTrigger] ->setAxisTitle(
"Recorded Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
204 m_xSecObservedVsRecorLumi[tTrigger] ->setAxisTitle(
"Algorithm #sigma [#mu b]" ,2);
206 dbe->setCurrentFolder(
"L1T/L1TRate/TriggerCounts");
207 m_CountsVsLS[tTrigger] = dbe->bookProfile(tCategory,
208 "Cross Sec. vs Inst. Lumi Algo: "+tTrigger+tErrorMessage,
210 minInstantLuminosity,
211 maxInstantLuminosity,0,500);
212 m_CountsVsLS[tTrigger] ->setAxisTitle(
"Instantaneous Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
213 m_CountsVsLS[tTrigger] ->setAxisTitle(
"Algorithm #sigma [#mu b]" ,2);
214 m_CountsVsLS[tTrigger] ->getTProfile()->GetListOfFunctions()->Add(tTestFunction);
215 m_CountsVsLS[tTrigger] ->getTProfile()->SetMarkerStyle(23);
217 m_algoFit[tTrigger] = (TF1*) tTestFunction->Clone(
"Fit_"+tTrigger);
219 dbe->setCurrentFolder(
"L1T/L1TRate/xSecObs");
220 m_xSecObservedVsLS[tTrigger] = dbe->book1D(tCategory,
"Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,
double(m_maxNbins)-0.5);
221 m_xSecObservedVsLS[tTrigger] ->setAxisTitle(
"Lumi Section" ,1);
222 m_xSecObservedVsLS[tTrigger] ->setAxisTitle(
"#sigma_{obs}" ,2);
224 dbe->setCurrentFolder(
"L1T/L1TRate/Delivered");
225 m_DelivLumiVsLS[tTrigger] = dbe->book1D(tCategory,
"Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,
double(m_maxNbins)-0.5);
226 m_DelivLumiVsLS[tTrigger] ->setAxisTitle(
"Lumi Section" ,1);
227 m_DelivLumiVsLS[tTrigger] ->setAxisTitle(
"Deliv. Lumi" ,2);
229 dbe->setCurrentFolder(
"L1T/L1TRate/Recorded");
230 m_RecorLumiVsLS[tTrigger] = dbe->book1D(tCategory,
"Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,
double(m_maxNbins)-0.5);
231 m_RecorLumiVsLS[tTrigger] ->setAxisTitle(
"Lumi Section" ,1);
232 m_RecorLumiVsLS[tTrigger] ->setAxisTitle(
"Recor. Lumi" ,2);
234 dbe->setCurrentFolder(
"L1T/L1TRate/Ratio");
235 m_xSecObservedToExpected[tTrigger] = dbe->book1D(tCategory,
"Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,
double(m_maxNbins)-0.5);
236 m_xSecObservedToExpected[tTrigger] ->setAxisTitle(
"Lumi Section" ,1);
237 m_xSecObservedToExpected[tTrigger] ->setAxisTitle(
"#sigma_{obs} / #sigma_{exp}" ,2);
251 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called endRun." << endl;}
257 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called beginLuminosityBlock at LS=" << lumiBlock.
id().
luminosityBlock() << endl;}
265 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called endLuminosityBlock at LS=" << eventLS << endl;}
275 bool isDefLumi,isDefPrescaleIndex;
279 int prescalesIndex=0;
282 map<TString,double>* counts=0;
285 for(map<string,string>::const_iterator
i=m_selectedTriggers.begin() ;
i!=m_selectedTriggers.end() ;
i++){
286 string tTrigger = (*i).second;
288 m_CountsVsLS [tTrigger]->getTH1()->Reset(
"ICE");
289 m_xSecObservedToExpected[tTrigger]->getTH1()->Reset(
"ICE");
291 m_xSecObservedVsLS [tTrigger]->getTH1()->Reset(
"ICE");
292 m_DelivLumiVsLS [tTrigger]->getTH1()->Reset(
"ICE");
293 m_RecorLumiVsLS [tTrigger]->getTH1()->Reset(
"ICE");
295 m_xSecObservedVsDelivLumi[tTrigger]->getTH1()->Reset(
"ICE");
296 m_xSecObservedVsRecorLumi[tTrigger]->getTH1()->Reset(
"ICE");
301 for(
map<
int,map<TString,double> >::iterator
j=m_lsRates.begin() ;
j!=m_lsRates.end() ;
j++){
303 unsigned int lsOffline = (*j).first;
304 counts = &(*j).second;
307 unsigned int lsPreInd;
309 if(m_lsLuminosity.find(lsOffline)==m_lsLuminosity.end()){isDefLumi=
false;}
312 lumi=m_lsLuminosity[lsOffline];
313 deadtime=m_lsDeadTime[lsOffline];
316 lsPreInd = lsOffline + 1;
318 if(m_lsPrescaleIndex.find(lsPreInd)==m_lsPrescaleIndex.end()){isDefPrescaleIndex=
false;}
320 isDefPrescaleIndex=
true;
321 prescalesIndex=m_lsPrescaleIndex[lsPreInd];
324 if(isDefCount && isDefLumi && isDefPrescaleIndex){
326 const vector<int>& currentPrescaleFactors = (*m_listsPrescaleFactors).at(prescalesIndex);
328 for(map<string,string>::const_iterator
j=m_selectedTriggers.begin() ;
j!=m_selectedTriggers.end() ;
j++){
330 string tTrigger = (*j).second;
331 double trigCount = (*counts)[tTrigger];
334 TF1* tTestFunction = m_algoFit[tTrigger];
338 if(tTrigger !=
"Undefined"){
340 unsigned int trigBit = m_algoBit[tTrigger];
341 double trigPrescale = currentPrescaleFactors[trigBit];
343 if(lumi!=0 && trigCount!=0 && trigPrescale!=0){
345 double RecLumi = lumi*(1. - deadtime/100.);
347 double AlgoXSec = (trigPrescale*trigCount)/RecLumi;
348 double TemplateFunctionValue = tTestFunction->Eval(lumi);
355 m_xSecObservedVsRecorLumi[tTrigger]->Fill(RecLumi,AlgoXSec);
357 m_CountsVsLS [tTrigger]->Fill(lumi,AlgoXSec);
359 int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(lsOffline);
360 m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,AlgoXSec/TemplateFunctionValue);
362 m_DelivLumiVsLS[tTrigger]->setBinContent(ibin,lumi);
363 m_RecorLumiVsLS[tTrigger]->setBinContent(ibin,RecLumi);
365 m_xSecObservedVsLS[tTrigger]->setBinContent(ibin,AlgoXSec);
371 m_xSecObservedVsRecorLumi[tTrigger]->Fill(0.000001,0.000001);
373 m_CountsVsLS [tTrigger]->Fill(0.000001,0.000001);
375 int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(lsOffline);
376 m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,0.000001);
378 m_DelivLumiVsLS[tTrigger]->setBinContent(ibin,0.000001);
379 m_RecorLumiVsLS[tTrigger]->setBinContent(ibin,0.000001);
381 m_xSecObservedVsLS[tTrigger]->setBinContent(ibin,0.000001);
397 iEvent.
getByToken(m_l1GtDataDaqInputTag , gtReadoutRecordData);
398 iEvent.
getByToken(m_scalersSource_LSCollection , colLScal);
399 iEvent.
getByToken(m_scalersSource_L1TSCollection , triggerScalers);
402 int EventRun = iEvent.
id().
run();
406 if(triggerScalers.
isValid() && triggerScalers->size()){
408 Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
417 const std::vector<unsigned int> gtAlgoCounts = itL1TScalers->gtAlgoCounts();
424 int gtLS = (*itL1TScalers).lumiSegmentNr()+m_lsShiftGTRates;
427 if(m_lsRates.find(gtLS)==m_lsRates.end()){
429 map<TString,double> bufferCount;
432 for(map<string,string>::const_iterator
i=m_selectedTriggers.begin();
i!=m_selectedTriggers.end() ;
i++){
434 string tTrigger = (*i).second;
437 if(tTrigger !=
"Undefined"){
439 unsigned int trigBit = m_algoBit[tTrigger];
440 double trigCount = gtAlgoCounts[trigBit];
442 bufferCount[tTrigger] = trigCount;
446 m_lsRates[gtLS] = bufferCount;
447 m_lsDeadTime[gtLS] = deadtime;
453 if(colLScal.
isValid() && colLScal->size()){
455 LumiScalersCollection::const_iterator itLScal = colLScal->begin();
456 unsigned int scalLS = itLScal->sectionNumber();
459 if(m_lsLuminosity.find(scalLS)==m_lsLuminosity.end()){
461 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Buffering SCAL-HF Lumi for LS=" << scalLS << endl;}
462 double instLumi = itLScal->instantLumi();
463 double deadTimeNormHF = itLScal->deadTimeNormalization();
483 if(m_parameters.getUntrackedParameter<
bool>(
"useHFDeadTimeNormalization",
false)){
486 if(deadTimeNormHF==0){instLumi = 0;}
487 else {instLumi = instLumi/deadTimeNormHF;}
490 m_lsLuminosity[scalLS]=instLumi;
495 if(gtReadoutRecordData.
isValid()){
498 if(m_lsPrescaleIndex.find(eventLS)==m_lsPrescaleIndex.end()){
500 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Buffering Prescale Index for LS=" << eventLS << endl;}
503 const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
507 for(
unsigned int i=0;
i<gtFdlVectorData.size();
i++){
508 if(gtFdlVectorData[
i].bxInEvent()==0){indexFDL=
i;
break;}
511 int CurrentPrescalesIndex = gtFdlVectorData[indexFDL].gtPrescaleFactorIndexAlgo();
512 m_lsPrescaleIndex[eventLS] = CurrentPrescalesIndex;
536 std::vector<edm::ParameterSet> m_fitParameters = ps.
getParameter< vector<ParameterSet> >(
"fitParameters");
538 double minInstantLuminosity = m_parameters.getParameter<
double>(
"minInstantLuminosity");
539 double maxInstantLuminosity = m_parameters.getParameter<
double>(
"maxInstantLuminosity");
542 for(map<string,string>::const_iterator
a=m_selectedTriggers.begin() ;
a!=m_selectedTriggers.end() ;
a++){
544 string tTrigger = (*a).second;
547 if(tTrigger !=
"Undefined"){
549 bool foundFit =
false;
551 for(
unsigned int b=0 ;
b<m_fitParameters.size() ;
b++){
553 if(tTrigger == m_fitParameters[
b].getParameter<string>(
"AlgoName")){
555 TString tAlgoName = m_fitParameters[
b].getParameter<
string > (
"AlgoName");
556 TString tTemplateFunction = m_fitParameters[
b].getParameter<
string > (
"TemplateFunction");
557 vector<double> tParameters = m_fitParameters[
b].getParameter< vector<double> >(
"Parameters");
560 m_templateFunctions[tTrigger] =
new TF1(
"FitParametrization_"+tAlgoName,tTemplateFunction,
561 minInstantLuminosity,maxInstantLuminosity);
562 m_templateFunctions[tTrigger] ->SetParameters(&tParameters[0]);
563 m_templateFunctions[tTrigger] ->SetLineWidth(1);
564 m_templateFunctions[tTrigger] ->SetLineColor(kRed);
574 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_PY_MISSING_FIT);
576 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
void rmdir(const std::string &fullpath)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
0: Unidentified isolated particle
virtual void endLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
DEFINE_FWK_MODULE(HiMixingModule)
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
void setCurrentFolder(const std::string &fullpath)