48 m_l1GtDataDaqInputTag = m_parameters.getParameter <
InputTag>(
"inputTagL1GtDataDaq");
49 m_verbose = m_parameters.getUntrackedParameter<
bool> (
"verbose",
false);
50 m_refPrescaleSet = m_parameters.getParameter <
int> (
"refPrescaleSet");
51 m_lsShiftGTRates = m_parameters.getUntrackedParameter<
int> (
"lsShiftGTRates",0);
57 m_inputCategories[
"IsoEG"] = Categories.getUntrackedParameter<
bool>(
"IsoEG");
58 m_inputCategories[
"Jet"] = Categories.getUntrackedParameter<
bool>(
"Jet");
59 m_inputCategories[
"CenJet"] = Categories.getUntrackedParameter<
bool>(
"CenJet");
60 m_inputCategories[
"ForJet"] = Categories.getUntrackedParameter<
bool>(
"ForJet");
61 m_inputCategories[
"TauJet"] = Categories.getUntrackedParameter<
bool>(
"TauJet");
62 m_inputCategories[
"ETM"] = Categories.getUntrackedParameter<
bool>(
"ETM");
63 m_inputCategories[
"ETT"] = Categories.getUntrackedParameter<
bool>(
"ETT");
64 m_inputCategories[
"HTT"] = Categories.getUntrackedParameter<
bool>(
"HTT");
65 m_inputCategories[
"HTM"] = Categories.getUntrackedParameter<
bool>(
"HTM");
69 cout <<
"[L1TRate_Offline:] ____________ Storage inicialization ____________ " << endl;
70 cout <<
"[L1TRate_Offline:] Setting up dbe folder: L1T/L1TRate_Offline" << endl;
75 dbe->setCurrentFolder(
"L1T/L1TRate_Offline");
78 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Pointer for DQM Store: " << dbe << endl;}
87 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called beginJob." << endl;}
95 dbe->
rmdir(
"L1T/L1TRate_Offline");
103 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called endJob." << endl;}
105 if (m_outputFile.size() != 0 && dbe)
106 dbe->save(m_outputFile);
117 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called beginRun." << endl;}
129 dbe->setCurrentFolder(
"L1T/L1TRate_Offline");
130 m_ErrorMonitor = dbe->book1D(
"ErrorMonitor",
"ErrorMonitor",2,0,2);
131 m_ErrorMonitor->setBinLabel(
UNKNOWN ,
"UNKNOWN");
132 m_ErrorMonitor->setBinLabel(WARNING_PY_MISSING_FIT,
"WARNING_PY_MISSING_FIT");
134 cout <<
"[L1TRate_Offline:] m_ErrorMonitor: " << m_ErrorMonitor << endl;
141 m_selectedTriggers = myMenuHelper.
getLUSOTrigger(m_inputCategories,m_refPrescaleSet);
144 getXSexFitsPython(m_parameters);
147 m_algoBit[(algo->second).algoAlias()] = (algo->second).algoBitNumber();
150 double minInstantLuminosity = m_parameters.getParameter<
double>(
"minInstantLuminosity");
151 double maxInstantLuminosity = m_parameters.getParameter<
double>(
"maxInstantLuminosity");
154 for(map<string,string>::const_iterator
i=m_selectedTriggers.begin() ;
i!=m_selectedTriggers.end() ;
i++){
156 TString tCategory = (*i).first;
157 TString tTrigger = (*i).second;
159 TString tErrorMessage =
"";
162 if(tTrigger !=
"Undefined" && m_templateFunctions.find(tTrigger) != m_templateFunctions.end()){
163 tTestFunction = m_templateFunctions[tTrigger];
165 else if(tTrigger ==
"Undefined"){
166 TString tFunc =
"-1";
167 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(m_maxNbins)-0.5);
169 else if(m_templateFunctions.find(tTrigger) == m_templateFunctions.end()){
170 TString tFunc =
"-1";
171 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(m_maxNbins)-0.5);
172 tErrorMessage =
" (Undefined Test Function)";
175 TString tFunc =
"-1";
176 tTestFunction =
new TF1(
"FitParametrization_"+tTrigger,tFunc,0,
double(m_maxNbins)-0.5);
179 if(tTrigger !=
"Undefined"){
182 tErrorMessage +=
" WARNING: Default Prescale = ";
186 if (tCategory ==
"Mu" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 4294967295){
187 tErrorMessage +=
" WARNING: Eta Range = ";
190 else if(tCategory ==
"EG" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 32639){
191 tErrorMessage +=
" WARNING: Eta Range = ";
194 else if(tCategory ==
"IsoEG" && myMenuHelper.
getEtaRangeByAlias(tCategory,tTrigger) != 32639){
195 tErrorMessage +=
" WARNING: Eta Range = ";
199 if(tCategory ==
"Mu" && myMenuHelper.
getQualityAlias(tCategory,tTrigger) != 240){
200 tErrorMessage +=
" WARNING: Quality = ";
206 dbe->setCurrentFolder(
"L1T/L1TRate_Offline/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_Offline/Ratio");
220 m_xSecObservedToExpected[tTrigger] = dbe->book1D(tCategory,
"Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,
double(m_maxNbins)-0.5);
221 m_xSecObservedToExpected[tTrigger] ->setAxisTitle(
"Lumi Section" ,1);
222 m_xSecObservedToExpected[tTrigger] ->setAxisTitle(
"#sigma_{obs} / #sigma_{exp}" ,2);
232 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called endRun." << endl;}
238 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called beginLuminosityBlock at LS=" << lumiBlock.
id().
luminosityBlock() << endl;}
246 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Called endLuminosityBlock at LS=" << eventLS << endl;}
256 bool isDefLumi,isDefPrescaleIndex;
259 int prescalesIndex=0;
262 map<TString,double>* counts=0;
265 for(map<string,string>::const_iterator
i=m_selectedTriggers.begin() ;
i!=m_selectedTriggers.end() ;
i++){
266 string tTrigger = (*i).second;
267 m_CountsVsLS [tTrigger]->getTH1()->Reset(
"ICE");
268 m_xSecObservedToExpected[tTrigger]->getTH1()->Reset(
"ICE");
273 for(
map<
int,map<TString,double> >::iterator
j=m_lsRates.begin() ;
j!=m_lsRates.end() ;
j++){
275 unsigned int lsOffline = (*j).first;
276 counts = &(*j).second;
279 unsigned int lsPreInd;
281 if(m_lsLuminosity.find(lsOffline)==m_lsLuminosity.end()){isDefLumi=
false;}
284 lumi=m_lsLuminosity[lsOffline];
287 lsPreInd = lsOffline + 1;
289 if(m_lsPrescaleIndex.find(lsPreInd)==m_lsPrescaleIndex.end()){isDefPrescaleIndex=
false;}
291 isDefPrescaleIndex=
true;
292 prescalesIndex=m_lsPrescaleIndex[lsPreInd];
295 if(isDefCount && isDefLumi && isDefPrescaleIndex){
299 for(map<string,string>::const_iterator
j=m_selectedTriggers.begin() ;
j!=m_selectedTriggers.end() ;
j++){
301 string tTrigger = (*j).second;
302 double trigCount = (*counts)[tTrigger];
305 TF1* tTestFunction = m_algoFit[tTrigger];
309 if(tTrigger !=
"Undefined"){
312 if(lumi!=0 && trigCount!=0 && prescalesIndex!=0){
314 double AlgoXSec = (prescalesIndex*trigCount)/lumi;
315 double TemplateFunctionValue = tTestFunction->Eval(lumi);
318 m_CountsVsLS [tTrigger]->Fill(lumi,AlgoXSec);
320 int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(lsOffline);
321 m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,AlgoXSec/TemplateFunctionValue);
326 m_CountsVsLS [tTrigger]->Fill(0.000001,0.000001);
328 int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(lsOffline);
329 m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,0.000001);
345 iEvent.
getByLabel(m_l1GtDataDaqInputTag, gtReadoutRecordData);
346 iEvent.
getByLabel(m_scalersSource , colLScal);
347 iEvent.
getByLabel(m_scalersSource , triggerScalers);
354 if(triggerScalers.
isValid() && triggerScalers->size()){
356 Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
360 const std::vector<unsigned int> gtAlgoCounts = itL1TScalers->gtAlgoCounts();
362 int gtLS = (*itL1TScalers).lumiSegmentNr()+m_lsShiftGTRates;
365 if(m_lsRates.find(gtLS)==m_lsRates.end()){
367 map<TString,double> bufferCount;
370 for(map<string,string>::const_iterator
i=m_selectedTriggers.begin();
i!=m_selectedTriggers.end() ;
i++){
372 string tTrigger = (*i).second;
375 if(tTrigger !=
"Undefined"){
377 unsigned int trigBit = m_algoBit[tTrigger];
378 double trigCount = gtAlgoCounts[trigBit];
380 bufferCount[tTrigger] = trigCount;
384 m_lsRates[gtLS] = bufferCount;
390 if(colLScal.
isValid() && colLScal->size()){
392 LumiScalersCollection::const_iterator itLScal = colLScal->begin();
393 unsigned int scalLS = itLScal->sectionNumber();
396 if(m_lsLuminosity.find(scalLS)==m_lsLuminosity.end()){
398 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Buffering SCAL-HF Lumi for LS=" << scalLS << endl;}
399 double instLumi = itLScal->instantLumi();
400 double deadTimeNormHF = itLScal->deadTimeNormalization();
404 if(m_parameters.getUntrackedParameter<
bool>(
"useHFDeadTimeNormalization",
false)){
407 if(deadTimeNormHF==0){instLumi = 0;}
408 else {instLumi = instLumi/deadTimeNormHF;}
411 m_lsLuminosity[scalLS]=instLumi;
416 if(gtReadoutRecordData.
isValid()){
419 if(m_lsPrescaleIndex.find(eventLS)==m_lsPrescaleIndex.end()){
421 if (m_verbose) {
cout <<
"[L1TRate_Offline:] Buffering Prescale Index for LS=" << eventLS << endl;}
424 const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
428 for(
unsigned int i=0;
i<gtFdlVectorData.size();
i++){
429 if(gtFdlVectorData[
i].bxInEvent()==0){indexFDL=
i;
break;}
432 int CurrentPrescalesIndex = gtFdlVectorData[indexFDL].gtPrescaleFactorIndexAlgo();
433 m_lsPrescaleIndex[eventLS] = CurrentPrescalesIndex;
457 std::vector<edm::ParameterSet> m_fitParameters = ps.
getParameter< vector<ParameterSet> >(
"fitParameters");
459 double minInstantLuminosity = m_parameters.getParameter<
double>(
"minInstantLuminosity");
460 double maxInstantLuminosity = m_parameters.getParameter<
double>(
"maxInstantLuminosity");
463 for(map<string,string>::const_iterator
a=m_selectedTriggers.begin() ;
a!=m_selectedTriggers.end() ;
a++){
465 string tTrigger = (*a).second;
468 if(tTrigger !=
"Undefined"){
470 bool foundFit =
false;
472 for(
unsigned int b=0 ;
b<m_fitParameters.size() ;
b++){
474 if(tTrigger == m_fitParameters[
b].getParameter<string>(
"AlgoName")){
476 TString tAlgoName = m_fitParameters[
b].getParameter<
string > (
"AlgoName");
477 TString tTemplateFunction = m_fitParameters[
b].getParameter<
string > (
"TemplateFunction");
478 vector<double> tParameters = m_fitParameters[
b].getParameter< vector<double> >(
"Parameters");
481 m_templateFunctions[tTrigger] =
new TF1(
"FitParametrization_"+tAlgoName,tTemplateFunction,
482 minInstantLuminosity,maxInstantLuminosity);
483 m_templateFunctions[tTrigger] ->SetParameters(&tParameters[0]);
484 m_templateFunctions[tTrigger] ->SetLineWidth(1);
485 m_templateFunctions[tTrigger] ->SetLineColor(kRed);
495 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_PY_MISSING_FIT);
497 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)
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)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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)
void setCurrentFolder(const std::string &fullpath)