Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to pixel phase 1 summary class #18993

Merged
merged 4 commits into from Jun 1, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions DQM/SiPixelPhase1Summary/interface/SiPixelPhase1Summary.h
Expand Up @@ -32,6 +32,7 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/LuminosityBlock.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand Down Expand Up @@ -69,10 +70,20 @@

std::map<std::string,std::string> summaryPlotName_;

//The dead and innefficient roc trend plot
std::map<std::string,MonitorElement*> deadROCTrends_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @leggat - please change these to be std::map<enum,MonitorElement*> to avoid all the string lookups below. (where you should define a set of enums to meet your needs) [best to do this also with the key to summaryPlotName_] Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @davidlange6 - I've changed the deadROCTrends_ and ineffROCTrends_ as you suggest, but I don't immediately see how this would work for summaryPlotName_ since both the key and value are configurable strings passed from the SiPixelPhase1Summary_cfi.py config file. I don't know where I'd start in changing that...

std::map<std::string,MonitorElement*> ineffROCTrends_;

//book the summary plots
void bookSummaries(DQMStore::IBooker & iBooker);

//Book trend plots
void bookTrendPlots(DQMStore::IBooker & iBooker);

void fillSummaries(DQMStore::IBooker & iBooker, DQMStore::IGetter & iGetter);

void fillTrendPlots(DQMStore::IBooker & iBooker, DQMStore::IGetter & iGetter, int lumiSeg = 0);

};

#endif
144 changes: 131 additions & 13 deletions DQM/SiPixelPhase1Summary/src/SiPixelPhase1Summary.cc
Expand Up @@ -75,13 +75,18 @@ SiPixelPhase1Summary::~SiPixelPhase1Summary()
void SiPixelPhase1Summary::beginRun(edm::Run const& run, edm::EventSetup const& eSetup){
}

void SiPixelPhase1Summary::dqmEndLuminosityBlock(DQMStore::IBooker & iBooker, DQMStore::IGetter & iGetter, edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& c){
void SiPixelPhase1Summary::dqmEndLuminosityBlock(DQMStore::IBooker & iBooker, DQMStore::IGetter & iGetter, const edm::LuminosityBlock & lumiSeg, edm::EventSetup const& c){
if (firstLumi){
bookSummaries(iBooker);
bookTrendPlots(iBooker);
firstLumi = false;
}

if (runOnEndLumi_) fillSummaries(iBooker,iGetter);
if (runOnEndLumi_){
fillSummaries(iBooker,iGetter);
int lumiSec = lumiSeg.id().luminosityBlock();
fillTrendPlots(iBooker,iGetter,lumiSec);
}

// iBooker.cd();

Expand All @@ -92,21 +97,32 @@ void SiPixelPhase1Summary::dqmEndLuminosityBlock(DQMStore::IBooker & iBooker, DQ
//------------------------------------------------------------------
void SiPixelPhase1Summary::dqmEndJob(DQMStore::IBooker & iBooker, DQMStore::IGetter & iGetter)
{
if (runOnEndJob_) fillSummaries(iBooker,iGetter);
if (firstLumi){ //Book the plots in the (maybe possible?) case that they aren't booked in the dqmEndLuminosityBlock method
bookSummaries(iBooker);
bookTrendPlots(iBooker);
firstLumi = false;
}
if (runOnEndJob_){
fillSummaries(iBooker,iGetter);
if (!runOnEndLumi_) fillTrendPlots(iBooker,iGetter); //If we're filling these plots at the end lumi step, it doesn't really make sense to also do them at the end job
}

}

//------------------------------------------------------------------
// Used to book the summary plots
//------------------------------------------------------------------
void SiPixelPhase1Summary::bookSummaries(DQMStore::IBooker & iBooker){
iBooker.setCurrentFolder("PixelPhase1/Summary");

iBooker.cd();

std::vector<std::string> xAxisLabels_ = {"BMO","BMI","BPO ","BPI","HCMO_1","HCMO_2","HCMI_1","HCMI_2","HCPO_1","HCPO_2","HCPI_1","HCPI_2"}; // why not having a global variable !?!?!?!
std::vector<std::string> yAxisLabels_ = {"1","2","3","4"}; // why not having a global variable ?!?!?!!?
std::vector<std::string> yAxisLabels_ = {"1","2","3","4"}; // why not having a global variable ?!?!?!!? - I originally did, but was told not to by David Lange!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first link on google might be informative - google can tell you more about why to avoid using globals in c++ (let alone a multiply threaded c++)
http://www.cplusplus.com/forum/general/76476/


for (auto mapInfo: summaryPlotName_){
auto name = mapInfo.first;
if (name == "Grand") iBooker.setCurrentFolder("PixelPhase1/EventInfo");
else iBooker.setCurrentFolder("PixelPhase1/Summary");
summaryMap_[name] = iBooker.book2D("pixel"+name+"Summary","Pixel "+name+" Summary",12,0,12,4,0,4);
for (unsigned int i = 0; i < xAxisLabels_.size(); i++){
summaryMap_[name]->setBinLabel(i+1, xAxisLabels_[i],1);
Expand All @@ -124,6 +140,35 @@ void SiPixelPhase1Summary::bookSummaries(DQMStore::IBooker & iBooker){
}
}

//------------------------------------------------------------------
// Used to book the trend plots
//------------------------------------------------------------------
void SiPixelPhase1Summary::bookTrendPlots(DQMStore::IBooker & iBooker){
//We need different plots depending on if we're online (runOnEndLumi) or offline (!runOnEndLumi)
if (runOnEndLumi_){
deadROCTrends_["bpix"] = iBooker.book1D("deadRocTrendBPix","BPIX dead ROC trend",500,0.,5000);
deadROCTrends_["bpix"]->setAxisTitle("Lumisection",1);
deadROCTrends_["fpix"] = iBooker.book1D("deadRocTrendFPix","FPIX dead ROC trend",500,0.,5000);
deadROCTrends_["fpix"]->setAxisTitle("Lumisection",1);
ineffROCTrends_["bpix"] = iBooker.book1D("ineffRocTrendBPix","BPIX inefficient ROC trend",500,0.,5000);
ineffROCTrends_["bpix"]->setAxisTitle("Lumisection",1);
ineffROCTrends_["fpix"] = iBooker.book1D("ineffRocTrendFPix","FPIX inefficient ROC trend",500,0.,5000);
ineffROCTrends_["fpix"]->setAxisTitle("Lumisection",1);
}
else {
deadROCTrends_["offline"] = iBooker.book1D("deadRocTotal","N dead ROCs",2,0,2);
deadROCTrends_["offline"]->setBinLabel(1,"Barrel");
deadROCTrends_["offline"]->setBinLabel(2,"Endcap");
deadROCTrends_["offline"]->setAxisTitle("Subdetector",1);
ineffROCTrends_["offline"] = iBooker.book1D("ineffRocTotal","N inefficient ROCs",2,0,2);
ineffROCTrends_["offline"]->setBinLabel(1,"Barrel");
ineffROCTrends_["offline"]->setBinLabel(2,"Endcap");
ineffROCTrends_["offline"]->setAxisTitle("Subdetector",1);

}

}

//------------------------------------------------------------------
// Fill the summary histograms
//------------------------------------------------------------------
Expand Down Expand Up @@ -152,30 +197,103 @@ void SiPixelPhase1Summary::fillSummaries(DQMStore::IBooker & iBooker, DQMStore::
continue; // Ignore non-existing MEs, as this can cause the whole thing to crash
}

if (me->hasError()) {
//If there is an error, fill with 0
summaryMap_[name]->setBinContent(i+1,j+1,0);
} //Do we want to include warnings here?
else if (me->hasWarning()){
summaryMap_[name]->setBinContent(i+1,j+1,0.5);
if (!summaryMap_[name]){
edm::LogWarning("SiPixelPhase1Summary") << "Summary map " << name << " is not available !!";
continue; // Based on reported errors it seems possible that we're trying to access a non-existant summary map, so if the map doesn't exist but we're trying to access it here we'll skip it instead.
}
else summaryMap_[name]->setBinContent(i+1,j+1,1);
if ((me->getQReports()).size()!=0) summaryMap_[name]->setBinContent(i+1,j+1,(me->getQReports())[0]->getQTresult());
else summaryMap_[name]->setBinContent(i+1,j+1,-1);
}
}
}
//Now we will use the other summary maps to create the overall map.
for (int i = 0; i < 12; i++){ // !??!?!? xAxisLabels_.size() ?!?!
if (!summaryMap_["Grand"]){
edm::LogWarning("SiPixelPhase1Summary") << "Grand summary does not exist!";
break;
}
for (int j = 0; j < 4; j++){ // !??!?!? yAxisLabels_.size() ?!?!?!
summaryMap_["Grand"]->setBinContent(i+1,j+1,1); // This resets the map to be good. We only then set it to 0 if there has been a problem in one of the other summaries.
for (auto const mapInfo: summaryPlotName_){ //Check summary maps
auto name = mapInfo.first;
if (name == "Grand") continue;
if (summaryMap_[name]->getBinContent(i+1,j+1) < 0.9 && summaryMap_["Grand"]->getBinContent(i+1,j+1) > summaryMap_[name]->getBinContent(i+1,j+1)) summaryMap_["Grand"]->setBinContent(i+1,j+1,summaryMap_[name]->getBinContent(i+1,j+1)); // This could be changed to include warnings if we want?
if (!summaryMap_[name]){
edm::LogWarning("SiPixelPhase1Summary") << "Summary " << name << " does not exist!";
continue;
}
if (summaryMap_["Grand"]->getBinContent(i+1,j+1) > summaryMap_[name]->getBinContent(i+1,j+1)) summaryMap_["Grand"]->setBinContent(i+1,j+1,summaryMap_[name]->getBinContent(i+1,j+1));
}
}
}

}

//------------------------------------------------------------------
// Fill the trend plots
//------------------------------------------------------------------
void SiPixelPhase1Summary::fillTrendPlots(DQMStore::IBooker & iBooker, DQMStore::IGetter & iGetter, int lumiSec){

// If we're running in online mode and the lumi section is not modulo 10, return. Offline running always uses lumiSec=0, so it will pass this test.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand this comment. why is lumiSec=0 always? (lumiSec seems to be defined as lumiSeg.id().luminosityBlock();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah - the magic is in if (runOnEndJob_)... got it.

if (lumiSec%10 != 0) return;

std::ostringstream histNameStream;
std::string histName;


//Find the total number of filled bins and hi efficiency bins
int nFilledROCsFPix = 0, nFilledROCsBPix = 0;
int hiEffROCsFPix = 0, hiEffROCsBPix = 0;
std::vector<int> nRocsPerLayer = {1536,3584,5632,8192};
std::vector<int> nRocsPerRing = {4224,6528};
//Loop over layers. This will also do the rings, but we'll skip the ring calculation for
for (auto it : {1,2,3,4}){

iGetter.cd();
histNameStream.str("");
histNameStream << "PixelPhase1/Phase1_MechanicalView/PXBarrel/digi_occupancy_per_SignedModuleCoord_per_SignedLadderCoord_PXLayer_" << it;
histName = histNameStream.str();
MonitorElement * tempLayerME = iGetter.get(histName);
if (!tempLayerME) continue;
float lowEffValue = 0.25 * tempLayerME->getTH1()->Integral() / nRocsPerLayer[it-1];
for (int i=1; i<=tempLayerME->getTH1()->GetXaxis()->GetNbins(); i++){
for (int j=1; j<=tempLayerME->getTH1()->GetYaxis()->GetNbins(); j++){
if (tempLayerME->getBinContent(i,j) > 0.) nFilledROCsBPix++;
if (tempLayerME->getBinContent(i,j) > lowEffValue) hiEffROCsBPix++;
}
}
if (runOnEndLumi_) tempLayerME->Reset(); //If we're doing online monitoring, reset the digi maps.
if (it > 2) continue;
//And now do the fpix if we're in the first 2 layers
histNameStream.str("");
histNameStream << "PixelPhase1/Phase1_MechanicalView/PXForward/digi_occupancy_per_SignedDiskCoord_per_SignedBladePanelCoord_PXRing_" << it;
histName = histNameStream.str();
MonitorElement * tempDiskME = iGetter.get(histName);
lowEffValue = 0.25 * tempDiskME->getTH1()->Integral()/ nRocsPerRing[it-1];
for (int i=1; i<=tempDiskME->getTH1()->GetXaxis()->GetNbins(); i++){
for (int j=1; j<=tempDiskME->getTH1()->GetYaxis()->GetNbins(); j++){
if (tempDiskME->getBinContent(i,j) > 0.) nFilledROCsFPix++;
if (tempDiskME->getBinContent(i,j) > lowEffValue) hiEffROCsFPix++;
}
}
if (runOnEndLumi_) tempLayerME->Reset();


} // Close layers/ring loop

if (!runOnEndLumi_) { //offline
deadROCTrends_["offline"]->setBinContent(1,18944-nFilledROCsBPix);
deadROCTrends_["offline"]->setBinContent(2,10752-nFilledROCsFPix);
ineffROCTrends_["offline"]->setBinContent(1,nFilledROCsBPix-hiEffROCsBPix);
ineffROCTrends_["offline"]->setBinContent(2,nFilledROCsFPix-hiEffROCsFPix);
}
else { //online
deadROCTrends_["fpix"]->setBinContent(lumiSec/10,10752-nFilledROCsFPix);
deadROCTrends_["bpix"]->setBinContent(lumiSec/10,18944-nFilledROCsBPix);
ineffROCTrends_["fpix"]->setBinContent(lumiSec/10,nFilledROCsFPix-hiEffROCsFPix);
ineffROCTrends_["bpix"]->setBinContent(lumiSec/10,nFilledROCsBPix-hiEffROCsBPix);
}

}

//define this as a plug-in
DEFINE_FWK_MODULE(SiPixelPhase1Summary);