53 using namespace trigger;
69 virtual void endJob() ;
75 virtual void setupHltMatrix(std::string,
int);
76 virtual void fillHltMatrix(std::string, std::string,
double,
double,
bool);
81 void checkLumiInfo (
const edm::Event & jEvent);
134 thisiLumiValue =
false;
137 if (debugPrint)
std::cout <<
"Inside Constructor" << std::endl;
141 if (debugPrint)
std::cout <<
"Got plot dirname = " << plotDirectoryName << std::endl;
168 if (debugPrint)
std::cout <<
"Inside analyze" << std::endl;
170 if (cntevt % 10000 == 0)
std::cout <<
"[OccupancyPlotter::analyze] Received event " << cntevt << std::endl;
172 bool highVoltageOK = checkDcsInfo ( iEvent );
173 if (!highVoltageOK) {
174 if (debugPrint)
std::cout <<
"Skipping event: DCS problem\n";
178 checkLumiInfo( iEvent);
180 if (debugPrint)
std::cout <<
"instantaneous luminosity=" << _instLumi <<
" ± " << _instLumi_err << std::endl;
183 thisiLumiValue =
false;
184 std::cout <<
"LS = " << lumisection <<
", Lumi = " << _instLumi <<
" ± " << _instLumi_err <<
", pileup = " << _pileup << std::endl;
186 hist_LumivsLS = dbe->get(
"HLT/OccupancyPlots/HLT_LumivsLS")->getTH1F();
187 hist_LumivsLS->SetBinContent(lumisection+1,_instLumi);
188 hist_LumivsLS->SetBinError(lumisection+1,_instLumi_err);
190 hist_PUvsLS = dbe->get(
"HLT/OccupancyPlots/HLT_PUvsLS")->getTH1F();
191 hist_PUvsLS->SetBinContent(lumisection+1,_pileup);
200 if (debugPrint)
std::cout <<
"Trigger results not valid" << std::endl;
203 if (debugPrint)
std::cout <<
"Found triggerResults" << std::endl;
208 if ( !aodTriggerEvent.isValid() ) {
209 if (debugPrint)
std::cout <<
"No AOD trigger summary found! Returning...";
216 vector<string>
datasetNames = hltConfig_.streamContent(
"A");
218 for (
unsigned int iPD = 0; iPD <
datasetNames.size(); iPD++) {
222 unsigned int keyTracker[1000];
223 for(
unsigned int irreproduceableIterator = 0; irreproduceableIterator < 1000; irreproduceableIterator++) {
224 keyTracker[irreproduceableIterator] = 1001;
227 for (
unsigned int iPath = 0; iPath < PDsVectorPathsVector[iPD].size(); iPath++) {
229 std::string
pathName = PDsVectorPathsVector[iPD][iPath];
231 if (debugPrint)
std::cout <<
"Looking at path " << pathName << std::endl;
233 unsigned int index = hltConfig_.triggerIndex(pathName);
235 if (debugPrint)
std::cout <<
"Index = " << index <<
" triggerResults->size() = " <<
triggerResults->size() << std::endl;
237 if (index < triggerResults->
size()) {
240 if (debugPrint)
std::cout <<
"We fired path " << pathName << std::endl;
244 vector<std::string> modulesThisPath = hltConfig_.moduleLabels(pathName);
246 if (debugPrint)
std::cout <<
"Looping over module labels " << std::endl;
249 for (
int iModule = (modulesThisPath.size()-1); iModule >= 0; iModule--) {
251 if (debugPrint)
std::cout <<
"Module name is " << modulesThisPath[iModule] << std::endl;
254 if (hltConfig_.saveTags(modulesThisPath[iModule])) {
256 if (debugPrint)
std::cout <<
"For path " << pathName <<
" this module " << modulesThisPath[iModule] <<
" is a saveTags module of type " << hltConfig_.moduleType(modulesThisPath[iModule]) << std::endl;
258 if (hltConfig_.moduleType(modulesThisPath[iModule]) ==
"HLTLevel1GTSeed")
break;
260 InputTag moduleWhoseResultsWeWant(modulesThisPath[iModule],
"",
"HLT");
262 unsigned int indexOfModuleInAodTriggerEvent = aodTriggerEvent->filterIndex(moduleWhoseResultsWeWant);
264 if ( indexOfModuleInAodTriggerEvent < aodTriggerEvent->sizeFilters() ) {
265 const Keys &
keys = aodTriggerEvent->filterKeys( indexOfModuleInAodTriggerEvent );
266 if (debugPrint)
std::cout <<
"Got Keys for index " << indexOfModuleInAodTriggerEvent <<
", size of keys is " << keys.size() << std::endl;
268 for (
size_t iKey = 0; iKey < keys.size(); iKey++ ) {
270 bool first_count =
false;
272 if(keyTracker[iKey] != iKey) first_count =
true;
274 if (debugPrint || outputPrint)
std::cout <<
"This object has (pt, eta, phi) = "
275 << std::setw(10) << foundObject.
pt()
276 <<
", " << std::setw(10) << foundObject.
eta()
277 <<
", " << std::setw(10) << foundObject.
phi()
278 <<
" for path = " << std::setw(20) << pathName
279 <<
" module " << std::setw(40) << modulesThisPath[iModule]
280 <<
" iKey " << iKey << std::endl;
282 fillHltMatrix(
datasetNames[iPD],pathName,foundObject.
eta(),foundObject.
phi(),first_count);
284 keyTracker[iKey] = iKey;
313 if (debugPrint)
std::cout <<
"Inside begin job" << std::endl;
319 dbe->setCurrentFolder(plotDirectoryName);
336 if (debugPrint)
std::cout <<
"Inside beginRun" << std::endl;
339 if (hltConfig_.init(iRun, iSetup,
"HLT", changed)) {
341 if(debugPrint)
std::cout <<
"HLT config with process name "
342 <<
"HLT" <<
" successfully extracted" << std::endl;
345 if (debugPrint)
std::cout <<
"Warning, didn't find process HLT" << std::endl;
348 vector<string>
datasetNames = hltConfig_.streamContent(
"A");
349 for (
unsigned int i=0;
i<datasetNames.size();
i++) {
351 if (debugPrint)
std::cout <<
"This is dataset " << datasetNames[
i] <<std::endl;
353 vector<string> datasetPaths = hltConfig_.datasetContent(datasetNames[
i]);
355 if (debugPrint)
std::cout <<
"datasetPaths.size() = " << datasetPaths.size() << std::endl;
357 PDsVectorPathsVector.push_back(datasetPaths);
359 if (debugPrint)
std::cout <<
"Found PD: " << datasetNames[
i] << std::endl;
360 setupHltMatrix(datasetNames[i],i);
361 int maxLumisection=1000;
362 dbe->setCurrentFolder(
"HLT/OccupancyPlots/");
363 hist_LumivsLS =
new TH1F(
"HLT_LumivsLS",
"; Lumisection; Instantaneous Luminosity (cm^{-2} s^{-1})",maxLumisection,0,maxLumisection);
364 dbe->book1D(
"HLT_LumivsLS", hist_LumivsLS);
365 hist_PUvsLS =
new TH1F(
"HLT_PUvsLS",
"; Lumisection; Pileup",maxLumisection,0,maxLumisection);
366 dbe->book1D(
"HLT_PUvsLS", hist_PUvsLS);
375 std::cout <<
"[OccupancyPlotter::endRun] Total events received=" << cntevt <<
", events with HV problem=" << cntBadHV << std::endl;
382 std::string h_name_1dEta;
383 std::string h_name_1dPhi;
384 std::string h_title_1dEta;
385 std::string h_title_1dPhi;
386 std::string h_name_1dEtaPath;
387 std::string h_name_1dPhiPath;
388 std::string h_title_1dEtaPath;
389 std::string h_title_1dPhiPath;
391 std::string PD_Folder;
392 std::string Path_Folder;
394 PD_Folder = TString(
"HLT/OccupancyPlots");
395 if (label !=
"SingleMu" && label !=
"SingleElectron" && label !=
"Jet") PD_Folder = TString(
"HLT/OccupancyPlots/"+label);
397 dbe->setCurrentFolder(PD_Folder.c_str());
399 h_name =
"HLT_"+label+
"_EtaVsPhi";
400 h_title =
"HLT_"+label+
"_EtaVsPhi; eta; phi";
401 h_name_1dEta =
"HLT_"+label+
"_1dEta";
402 h_name_1dPhi =
"HLT_"+label+
"_1dPhi";
403 h_title_1dEta = label+
" Occupancy Vs Eta";
404 h_title_1dPhi = label+
" Occupancy Vs Phi";
407 Int_t numBinsEta = 30;
408 Int_t numBinsPhi = 34;
409 Int_t numBinsEtaFine = 60;
410 Int_t numBinsPhiFine = 66;
413 Double_t PhiMaxFine = 33.0*
TMath::Pi()/32.0;
419 TH2F * hist_EtaVsPhi =
new TH2F(h_name.c_str(),h_title.c_str(),numBinsEta,-
EtaMax,
EtaMax,numBinsPhi,-PhiMax,PhiMax);
420 TH1F * hist_1dEta =
new TH1F(h_name_1dEta.c_str(),h_title_1dEta.c_str(),numBinsEtaFine,-
EtaMax,
EtaMax);
421 TH1F * hist_1dPhi =
new TH1F(h_name_1dPhi.c_str(),h_title_1dPhi.c_str(),numBinsPhiFine,-PhiMaxFine,PhiMaxFine);
423 hist_EtaVsPhi->SetMinimum(0);
424 hist_1dEta->SetMinimum(0);
425 hist_1dPhi->SetMinimum(0);
427 dbe->book2D(h_name.c_str(),hist_EtaVsPhi);
428 dbe->book1D(h_name_1dEta.c_str(),hist_1dEta);
429 dbe->book1D(h_name_1dPhi.c_str(),hist_1dPhi);
431 for (
unsigned int iPath = 0; iPath < PDsVectorPathsVector[iPD].size(); iPath++) {
432 pathName = PDsVectorPathsVector[iPD][iPath];
433 h_name_1dEtaPath =
"HLT_"+pathName+
"_1dEta";
434 h_name_1dPhiPath =
"HLT_"+pathName+
"_1dPhi";
435 h_title_1dEtaPath = pathName+
" Occupancy Vs Eta";
436 h_title_1dPhiPath = pathName+
"Occupancy Vs Phi";
437 Path_Folder = TString(
"HLT/OccupancyPlots/"+label+
"/Paths");
438 dbe->setCurrentFolder(Path_Folder.c_str());
440 dbe->book1D(h_name_1dEtaPath.c_str(),h_title_1dEtaPath.c_str(),numBinsEtaFine,-
EtaMax,
EtaMax);
441 dbe->book1D(h_name_1dPhiPath.c_str(),h_title_1dPhiPath.c_str(),numBinsPhiFine,-PhiMaxFine,PhiMaxFine);
443 if (debugPrint)
std::cout <<
"book1D for " << pathName << std::endl;
446 if (debugPrint)
std::cout <<
"Success setupHltMatrix( " << label <<
" , " << iPD <<
" )" <<
std::cout;
451 if (debugPrint)
std::cout <<
"Inside fillHltMatrix( " << label <<
" , " << path <<
" ) " << std::endl;
453 std::string fullPathToME;
454 std::string fullPathToME1dEta;
455 std::string fullPathToME1dPhi;
456 std::string fullPathToME1dEtaPath;
457 std::string fullPathToME1dPhiPath;
459 fullPathToME =
"HLT/OccupancyPlots/HLT_"+label+
"_EtaVsPhi";
460 fullPathToME1dEta =
"HLT/OccupancyPlots/HLT_"+label+
"_1dEta";
461 fullPathToME1dPhi =
"HLT/OccupancyPlots/HLT_"+label+
"_1dPhi";
463 if (label !=
"SingleMu" && label !=
"SingleElectron" && label !=
"Jet") {
464 fullPathToME =
"HLT/OccupancyPlots/"+label+
"/HLT_"+label+
"_EtaVsPhi";
465 fullPathToME1dEta =
"HLT/OccupancyPlots/"+label+
"/HLT_"+label+
"_1dEta";
466 fullPathToME1dPhi =
"HLT/OccupancyPlots/"+label+
"/HLT_"+label+
"_1dPhi";
469 fullPathToME1dEtaPath =
"HLT/OccupancyPlots/"+label+
"/Paths/HLT_"+path+
"_1dEta";
470 fullPathToME1dPhiPath =
"HLT/OccupancyPlots/"+label+
"/Paths/HLT_"+path+
"_1dPhi";
472 if (debugPrint)
std::cout <<
"fullPathToME = " << std::endl;
480 if (debugPrint)
std::cout <<
"MonitorElement * " << std::endl;
482 TH2F * hist_2d = ME_2d->
getTH2F();
483 TH1F * hist_1dEta = ME_1dEta->
getTH1F();
484 TH1F * hist_1dPhi = ME_1dPhi->
getTH1F();
485 TH1F * hist_1dEtaPath = ME_1dEtaPath->
getTH1F();
486 TH1F * hist_1dPhiPath = ME_1dPhiPath->
getTH1F();
488 if (debugPrint)
std::cout <<
"TH2F *" << std::endl;
496 hist_1dEta->Fill(Eta);
497 hist_1dPhi->Fill(Phi);
498 hist_2d->Fill(Eta,Phi); }
499 hist_1dEtaPath->Fill(Eta);
500 hist_1dPhiPath->Fill(Phi);
502 if (debugPrint)
std::cout <<
"hist->Fill" << std::endl;
513 if ( ! jEvent.
getByLabel(
"hltScalersRawToDigi", dcsStatus) )
515 std::cout <<
"[OccupancyPlotter::checkDcsInfo] Could not get scalersRawToDigi by label\n" ;
516 for (
int i=0;
i<24;
i++) dcs[
i]=
false;
522 std::cout <<
"[OccupancyPlotter::checkDcsInfo] scalersRawToDigi not valid\n" ;
523 for (
int i=0;
i<24;
i++) dcs[
i]=
false;
528 for (
int i=0;
i<24;
i++) dcs[
i]=
true;
530 for (DcsStatusCollection::const_iterator dcsStatusItr = dcsStatus->begin();
531 dcsStatusItr != dcsStatus->end(); ++dcsStatusItr)
534 if (debugPrint)
std::cout << (*dcsStatusItr) << std::endl;
564 bool decision =
true;
565 for (
int i=0;
i<24;
i++) decision=decision && dcs[
i];
567 std::cout <<
"[OccupancyPlotter::checkDcsInfo] DCS Status:";
569 std::cout <<
"; Decision: " << decision << std::endl;
578 if (debugPrint)
std::cout <<
"Inside method check lumi info" << std::endl;
581 bool lumiHandleOK = jEvent.
getByLabel(
InputTag(
"hltScalersRawToDigi",
"",
""), lumiScalers);
583 if (!lumiHandleOK || !lumiScalers.
isValid()){
584 if (debugPrint)
std::cout <<
"scalers not valid" << std::endl;
588 if (lumiScalers->size() == 0) {
589 if (debugPrint)
std::cout <<
"scalers has size < 0" << std::endl;
593 LumiScalersCollection::const_iterator it3 = lumiScalers->begin();
596 _instLumi = it3->instantLumi();
597 _instLumi_err = it3->instantLumiErr();
598 _pileup = it3->pileup();
600 if (debugPrint)
std::cout <<
"Instanteous Lumi is " << _instLumi << std::endl;
601 if (debugPrint)
std::cout <<
"Instanteous Lumi Error is " << _instLumi_err << std::endl;
602 if (debugPrint)
std::cout <<
"Lumi Fill is " <<it3->lumiFill() << std::endl;
603 if (debugPrint)
std::cout <<
"Lumi Fill is " <<it3->lumiRun() << std::endl;
604 if (debugPrint)
std::cout <<
"Live Lumi Fill is " <<it3->liveLumiFill() << std::endl;
605 if (debugPrint)
std::cout <<
"Live Lumi Run is " <<it3->liveLumiRun() << std::endl;
606 if (debugPrint)
std::cout <<
"Pileup? = " << _pileup << std::endl;
617 unsigned int thisLumiSection = 0;
619 std::cout <<
"[OccupancyPlotter::beginLuminosityBlock] New luminosity block: " << thisLumiSection << std::endl;
T getUntrackedParameter(std::string const &, T const &) const
virtual void setupHltMatrix(std::string, int)
edm::LuminosityBlockNumber_t luminosityBlock() const
std::string plotDirectoryName
const double EtaMax[kNumberCalorimeter]
DEFINE_FWK_MODULE(HiMixingModule)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
bool checkDcsInfo(const edm::Event &jEvent)
virtual void fillHltMatrix(std::string, std::string, double, double, bool)
LuminosityBlockNumber_t luminosityBlock() const
Single trigger physics object (e.g., an isolated muon)
virtual void endRun(edm::Run const &, edm::EventSetup const &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
vector< vector< string > > PDsVectorPathsVector
OccupancyPlotter(const edm::ParameterSet &)
std::vector< size_type > Keys
TH1F * getTH1F(void) const
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
TH2F * getTH2F(void) const
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
HLTConfigProvider hltConfig_
tuple size
Write out results.
void checkLumiInfo(const edm::Event &jEvent)