52 using namespace trigger;
68 virtual void endJob()
override ;
80 void checkLumiInfo (
const edm::Event & jEvent);
138 thisiLumiValue =
false;
141 if (debugPrint)
std::cout <<
"Inside Constructor" << std::endl;
145 if (debugPrint)
std::cout <<
"Got plot dirname = " << plotDirectoryName << std::endl;
149 aodTriggerToken_ = consumes<trigger::TriggerEvent>(
InputTag(
"hltTriggerSummaryAOD",
"",
"HLT"));
150 dcsStatusToken_ = consumes<DcsStatusCollection>(
std::string(
"hltScalersRawToDigi"));
151 lumiScalersToken_ = consumes<LumiScalersCollection>(
InputTag(
"hltScalersRawToDigi",
"",
""));
176 if (debugPrint)
std::cout <<
"Inside analyze" << std::endl;
178 if (cntevt % 10000 == 0)
std::cout <<
"[OccupancyPlotter::analyze] Received event " << cntevt << std::endl;
180 bool highVoltageOK = checkDcsInfo ( iEvent );
181 if (!highVoltageOK) {
182 if (debugPrint)
std::cout <<
"Skipping event: DCS problem\n";
186 checkLumiInfo( iEvent);
188 if (debugPrint)
std::cout <<
"instantaneous luminosity=" << _instLumi <<
" ± " << _instLumi_err << std::endl;
191 thisiLumiValue =
false;
192 std::cout <<
"LS = " << lumisection <<
", Lumi = " << _instLumi <<
" ± " << _instLumi_err <<
", pileup = " << _pileup << std::endl;
194 hist_LumivsLS = dbe->get(
"HLT/OccupancyPlots/HLT_LumivsLS")->getTH1F();
195 hist_LumivsLS->SetBinContent(lumisection+1,_instLumi);
196 hist_LumivsLS->SetBinError(lumisection+1,_instLumi_err);
198 hist_PUvsLS = dbe->get(
"HLT/OccupancyPlots/HLT_PUvsLS")->getTH1F();
199 hist_PUvsLS->SetBinContent(lumisection+1,_pileup);
208 if (debugPrint)
std::cout <<
"Trigger results not valid" << std::endl;
211 if (debugPrint)
std::cout <<
"Found triggerResults" << std::endl;
214 iEvent.
getByToken(aodTriggerToken_, aodTriggerEvent);
216 if ( !aodTriggerEvent.isValid() ) {
217 if (debugPrint)
std::cout <<
"No AOD trigger summary found! Returning...";
224 vector<string>
datasetNames = hltConfig_.streamContent(
"A");
226 for (
unsigned int iPD = 0; iPD <
datasetNames.size(); iPD++) {
230 unsigned int keyTracker[1000];
231 for(
unsigned int irreproduceableIterator = 0; irreproduceableIterator < 1000; irreproduceableIterator++) {
232 keyTracker[irreproduceableIterator] = 1001;
235 for (
unsigned int iPath = 0; iPath < PDsVectorPathsVector[iPD].size(); iPath++) {
239 if (debugPrint)
std::cout <<
"Looking at path " << pathName << std::endl;
241 unsigned int index = hltConfig_.triggerIndex(pathName);
243 if (debugPrint)
std::cout <<
"Index = " << index <<
" triggerResults->size() = " <<
triggerResults->size() << std::endl;
245 if (index < triggerResults->
size()) {
248 if (debugPrint)
std::cout <<
"We fired path " << pathName << std::endl;
252 vector<std::string> modulesThisPath = hltConfig_.moduleLabels(pathName);
254 if (debugPrint)
std::cout <<
"Looping over module labels " << std::endl;
257 for (
int iModule = (modulesThisPath.size()-1); iModule >= 0; iModule--) {
259 if (debugPrint)
std::cout <<
"Module name is " << modulesThisPath[iModule] << std::endl;
262 if (hltConfig_.saveTags(modulesThisPath[iModule])) {
264 if (debugPrint)
std::cout <<
"For path " << pathName <<
" this module " << modulesThisPath[iModule] <<
" is a saveTags module of type " << hltConfig_.moduleType(modulesThisPath[iModule]) << std::endl;
266 if (hltConfig_.moduleType(modulesThisPath[iModule]) ==
"HLTLevel1GTSeed")
break;
268 InputTag moduleWhoseResultsWeWant(modulesThisPath[iModule],
"",
"HLT");
270 unsigned int indexOfModuleInAodTriggerEvent = aodTriggerEvent->filterIndex(moduleWhoseResultsWeWant);
272 if ( indexOfModuleInAodTriggerEvent < aodTriggerEvent->sizeFilters() ) {
273 const Keys &
keys = aodTriggerEvent->filterKeys( indexOfModuleInAodTriggerEvent );
274 if (debugPrint)
std::cout <<
"Got Keys for index " << indexOfModuleInAodTriggerEvent <<
", size of keys is " << keys.size() << std::endl;
276 for (
size_t iKey = 0; iKey < keys.size(); iKey++ ) {
278 bool first_count =
false;
280 if(keyTracker[iKey] != iKey) first_count =
true;
282 if (debugPrint || outputPrint)
std::cout <<
"This object has (pt, eta, phi) = "
283 << std::setw(10) << foundObject.
pt()
284 <<
", " << std::setw(10) << foundObject.
eta()
285 <<
", " << std::setw(10) << foundObject.
phi()
286 <<
" for path = " << std::setw(20) << pathName
287 <<
" module " << std::setw(40) << modulesThisPath[iModule]
288 <<
" iKey " << iKey << std::endl;
290 fillHltMatrix(
datasetNames[iPD],pathName,foundObject.
eta(),foundObject.
phi(),first_count);
292 keyTracker[iKey] = iKey;
321 if (debugPrint)
std::cout <<
"Inside begin job" << std::endl;
327 dbe->setCurrentFolder(plotDirectoryName);
344 if (debugPrint)
std::cout <<
"Inside beginRun" << std::endl;
347 if (hltConfig_.init(iRun, iSetup,
"HLT", changed)) {
349 if(debugPrint)
std::cout <<
"HLT config with process name "
350 <<
"HLT" <<
" successfully extracted" << std::endl;
353 if (debugPrint)
std::cout <<
"Warning, didn't find process HLT" << std::endl;
356 vector<string>
datasetNames = hltConfig_.streamContent(
"A");
357 for (
unsigned int i=0;
i<datasetNames.size();
i++) {
359 if (debugPrint)
std::cout <<
"This is dataset " << datasetNames[
i] <<std::endl;
361 vector<string> datasetPaths = hltConfig_.datasetContent(datasetNames[
i]);
363 if (debugPrint)
std::cout <<
"datasetPaths.size() = " << datasetPaths.size() << std::endl;
365 PDsVectorPathsVector.push_back(datasetPaths);
367 if (debugPrint)
std::cout <<
"Found PD: " << datasetNames[
i] << std::endl;
368 setupHltMatrix(datasetNames[i],i);
369 int maxLumisection=1000;
370 dbe->setCurrentFolder(
"HLT/OccupancyPlots/");
371 hist_LumivsLS =
new TH1F(
"HLT_LumivsLS",
"; Lumisection; Instantaneous Luminosity (cm^{-2} s^{-1})",maxLumisection,0,maxLumisection);
372 dbe->book1D(
"HLT_LumivsLS", hist_LumivsLS);
373 hist_PUvsLS =
new TH1F(
"HLT_PUvsLS",
"; Lumisection; Pileup",maxLumisection,0,maxLumisection);
374 dbe->book1D(
"HLT_PUvsLS", hist_PUvsLS);
383 std::cout <<
"[OccupancyPlotter::endRun] Total events received=" << cntevt <<
", events with HV problem=" << cntBadHV << std::endl;
402 PD_Folder = TString(
"HLT/OccupancyPlots");
403 if (label !=
"SingleMu" && label !=
"SingleElectron" && label !=
"Jet") PD_Folder = TString(
"HLT/OccupancyPlots/"+label);
405 dbe->setCurrentFolder(PD_Folder.c_str());
407 h_name =
"HLT_"+label+
"_EtaVsPhi";
408 h_title =
"HLT_"+label+
"_EtaVsPhi; eta; phi";
409 h_name_1dEta =
"HLT_"+label+
"_1dEta";
410 h_name_1dPhi =
"HLT_"+label+
"_1dPhi";
411 h_title_1dEta = label+
" Occupancy Vs Eta";
412 h_title_1dPhi = label+
" Occupancy Vs Phi";
415 Int_t numBinsEta = 30;
416 Int_t numBinsPhi = 34;
417 Int_t numBinsEtaFine = 60;
418 Int_t numBinsPhiFine = 66;
421 Double_t PhiMaxFine = 33.0*
TMath::Pi()/32.0;
427 TH2F * hist_EtaVsPhi =
new TH2F(h_name.c_str(),h_title.c_str(),numBinsEta,-
EtaMax,
EtaMax,numBinsPhi,-PhiMax,PhiMax);
428 TH1F * hist_1dEta =
new TH1F(h_name_1dEta.c_str(),h_title_1dEta.c_str(),numBinsEtaFine,-
EtaMax,
EtaMax);
429 TH1F * hist_1dPhi =
new TH1F(h_name_1dPhi.c_str(),h_title_1dPhi.c_str(),numBinsPhiFine,-PhiMaxFine,PhiMaxFine);
431 hist_EtaVsPhi->SetMinimum(0);
432 hist_1dEta->SetMinimum(0);
433 hist_1dPhi->SetMinimum(0);
435 dbe->book2D(h_name.c_str(),hist_EtaVsPhi);
436 dbe->book1D(h_name_1dEta.c_str(),hist_1dEta);
437 dbe->book1D(h_name_1dPhi.c_str(),hist_1dPhi);
439 for (
unsigned int iPath = 0; iPath < PDsVectorPathsVector[iPD].size(); iPath++) {
440 pathName = PDsVectorPathsVector[iPD][iPath];
441 h_name_1dEtaPath =
"HLT_"+pathName+
"_1dEta";
442 h_name_1dPhiPath =
"HLT_"+pathName+
"_1dPhi";
443 h_title_1dEtaPath = pathName+
" Occupancy Vs Eta";
444 h_title_1dPhiPath = pathName+
"Occupancy Vs Phi";
445 Path_Folder = TString(
"HLT/OccupancyPlots/"+label+
"/Paths");
446 dbe->setCurrentFolder(Path_Folder.c_str());
448 dbe->book1D(h_name_1dEtaPath.c_str(),h_title_1dEtaPath.c_str(),numBinsEtaFine,-
EtaMax,
EtaMax);
449 dbe->book1D(h_name_1dPhiPath.c_str(),h_title_1dPhiPath.c_str(),numBinsPhiFine,-PhiMaxFine,PhiMaxFine);
451 if (debugPrint)
std::cout <<
"book1D for " << pathName << std::endl;
454 if (debugPrint)
std::cout <<
"Success setupHltMatrix( " << label <<
" , " << iPD <<
" )" <<
std::cout;
459 if (debugPrint)
std::cout <<
"Inside fillHltMatrix( " << label <<
" , " << path <<
" ) " << std::endl;
467 fullPathToME =
"HLT/OccupancyPlots/HLT_"+label+
"_EtaVsPhi";
468 fullPathToME1dEta =
"HLT/OccupancyPlots/HLT_"+label+
"_1dEta";
469 fullPathToME1dPhi =
"HLT/OccupancyPlots/HLT_"+label+
"_1dPhi";
471 if (label !=
"SingleMu" && label !=
"SingleElectron" && label !=
"Jet") {
472 fullPathToME =
"HLT/OccupancyPlots/"+label+
"/HLT_"+label+
"_EtaVsPhi";
473 fullPathToME1dEta =
"HLT/OccupancyPlots/"+label+
"/HLT_"+label+
"_1dEta";
474 fullPathToME1dPhi =
"HLT/OccupancyPlots/"+label+
"/HLT_"+label+
"_1dPhi";
477 fullPathToME1dEtaPath =
"HLT/OccupancyPlots/"+label+
"/Paths/HLT_"+path+
"_1dEta";
478 fullPathToME1dPhiPath =
"HLT/OccupancyPlots/"+label+
"/Paths/HLT_"+path+
"_1dPhi";
480 if (debugPrint)
std::cout <<
"fullPathToME = " << std::endl;
488 if (debugPrint)
std::cout <<
"MonitorElement * " << std::endl;
490 TH2F * hist_2d = ME_2d->
getTH2F();
491 TH1F * hist_1dEta = ME_1dEta->
getTH1F();
492 TH1F * hist_1dPhi = ME_1dPhi->
getTH1F();
493 TH1F * hist_1dEtaPath = ME_1dEtaPath->
getTH1F();
494 TH1F * hist_1dPhiPath = ME_1dPhiPath->
getTH1F();
496 if (debugPrint)
std::cout <<
"TH2F *" << std::endl;
504 hist_1dEta->Fill(Eta);
505 hist_1dPhi->Fill(Phi);
506 hist_2d->Fill(Eta,Phi); }
507 hist_1dEtaPath->Fill(Eta);
508 hist_1dPhiPath->Fill(Phi);
510 if (debugPrint)
std::cout <<
"hist->Fill" << std::endl;
521 if (! jEvent.
getByToken(dcsStatusToken_, dcsStatus))
523 std::cout <<
"[OccupancyPlotter::checkDcsInfo] Could not get scalersRawToDigi by label\n" ;
524 for (
int i=0;
i<24;
i++) dcs[
i]=
false;
530 std::cout <<
"[OccupancyPlotter::checkDcsInfo] scalersRawToDigi not valid\n" ;
531 for (
int i=0;
i<24;
i++) dcs[
i]=
false;
536 for (
int i=0;
i<24;
i++) dcs[
i]=
true;
538 for (DcsStatusCollection::const_iterator dcsStatusItr = dcsStatus->begin();
539 dcsStatusItr != dcsStatus->end(); ++dcsStatusItr)
542 if (debugPrint)
std::cout << (*dcsStatusItr) << std::endl;
572 bool decision =
true;
573 for (
int i=0;
i<24;
i++) decision=decision && dcs[
i];
575 std::cout <<
"[OccupancyPlotter::checkDcsInfo] DCS Status:";
577 std::cout <<
"; Decision: " << decision << std::endl;
586 if (debugPrint)
std::cout <<
"Inside method check lumi info" << std::endl;
589 bool lumiHandleOK = jEvent.
getByToken(lumiScalersToken_, lumiScalers);
591 if (!lumiHandleOK || !lumiScalers.
isValid()){
592 if (debugPrint)
std::cout <<
"scalers not valid" << std::endl;
596 if (lumiScalers->size() == 0) {
597 if (debugPrint)
std::cout <<
"scalers has size < 0" << std::endl;
601 LumiScalersCollection::const_iterator it3 = lumiScalers->begin();
604 _instLumi = it3->instantLumi();
605 _instLumi_err = it3->instantLumiErr();
606 _pileup = it3->pileup();
608 if (debugPrint)
std::cout <<
"Instanteous Lumi is " << _instLumi << std::endl;
609 if (debugPrint)
std::cout <<
"Instanteous Lumi Error is " << _instLumi_err << std::endl;
610 if (debugPrint)
std::cout <<
"Lumi Fill is " <<it3->lumiFill() << std::endl;
611 if (debugPrint)
std::cout <<
"Lumi Fill is " <<it3->lumiRun() << std::endl;
612 if (debugPrint)
std::cout <<
"Live Lumi Fill is " <<it3->liveLumiFill() << std::endl;
613 if (debugPrint)
std::cout <<
"Live Lumi Run is " <<it3->liveLumiRun() << std::endl;
614 if (debugPrint)
std::cout <<
"Pileup? = " << _pileup << std::endl;
625 unsigned int thisLumiSection = 0;
627 std::cout <<
"[OccupancyPlotter::beginLuminosityBlock] New luminosity block: " << thisLumiSection << std::endl;
T getUntrackedParameter(std::string const &, T const &) const
virtual void setupHltMatrix(std::string, int)
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
virtual void beginJob() override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< DcsStatusCollection > dcsStatusToken_
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override
edm::LuminosityBlockNumber_t luminosityBlock() const
std::string plotDirectoryName
virtual void endRun(edm::Run const &, edm::EventSetup const &) override
const double EtaMax[kNumberCalorimeter]
DEFINE_FWK_MODULE(HiMixingModule)
bool checkDcsInfo(const edm::Event &jEvent)
edm::EDGetTokenT< trigger::TriggerEvent > aodTriggerToken_
virtual void fillHltMatrix(std::string, std::string, double, double, bool)
triggerResultsToken_(consumes< edm::TriggerResults >(edm::InputTag("TriggerResults")))
LuminosityBlockNumber_t luminosityBlock() const
Single trigger physics object (e.g., an isolated muon)
tuple path
else: Piece not in the list, fine.
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
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
static std::string const triggerResults("TriggerResults")
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
TH1F * getTH1F(void) const
virtual void endJob() override
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
edm::EDGetTokenT< LumiScalersCollection > lumiScalersToken_
TH2F * getTH2F(void) const
HLTConfigProvider hltConfig_
tuple size
Write out results.
void checkLumiInfo(const edm::Event &jEvent)