From 21e15161c153f0f9cc8ebeeadd58b77ea1ec6f9e Mon Sep 17 00:00:00 2001 From: Andrea Date: Fri, 15 Oct 2021 12:46:25 +0200 Subject: [PATCH] Clean up and avoid possible misuse of the numOfBins variable --- DQM/CTPPS/plugins/DiamondSampicDQMSource.cc | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/DQM/CTPPS/plugins/DiamondSampicDQMSource.cc b/DQM/CTPPS/plugins/DiamondSampicDQMSource.cc index 0b4e5198029b2..645ccf77e1134 100644 --- a/DQM/CTPPS/plugins/DiamondSampicDQMSource.cc +++ b/DQM/CTPPS/plugins/DiamondSampicDQMSource.cc @@ -8,7 +8,6 @@ * ****************************************************************************/ -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -590,7 +589,7 @@ void DiamondSampicDQMSource::analyze(const edm::Event &event, const edm::EventSe TAxis *hitHistoTmpYAxis = hitHistoTmp->GetYaxis(); int startBin = hitHistoTmpYAxis->FindBin(rechit.x() - horizontalShiftOfDiamond_[detId_pot] - 0.5 * rechit.xWidth()); - int numOfBins = rechit.xWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; + const int numOfBins = rechit.xWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; for (int i = 0; i < numOfBins; ++i) { potPlots_[detId_pot].hitDistribution2d->Fill(detId.plane() + UFSDShift, hitHistoTmpYAxis->GetBinCenter(startBin + i)); @@ -613,11 +612,9 @@ void DiamondSampicDQMSource::analyze(const edm::Event &event, const edm::EventSe // Plane Plots if (planePlots_.find(detId_plane) != planePlots_.end()) { TH1F *hitProfileHistoTmp = planePlots_[detId_plane].hitProfile->getTH1F(); - int numOfBins = rechit.yWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; - int startBin = hitProfileHistoTmp->FindBin(rechit.x() - horizontalShiftOfDiamond_[detId_pot] - + const int startBin = hitProfileHistoTmp->FindBin(rechit.x() - horizontalShiftOfDiamond_[detId_pot] - 0.5 * rechit.xWidth()); - numOfBins = rechit.xWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; - for (int i = 0; i < numOfBins; ++i) + for (int i = 0; i < numOfBins; ++i) hitProfileHistoTmp->Fill(hitProfileHistoTmp->GetBinCenter(startBin + i)); if (channelsPerPlaneWithTime.find(detId_plane) != channelsPerPlaneWithTime.end()) @@ -653,8 +650,8 @@ void DiamondSampicDQMSource::analyze(const edm::Event &event, const edm::EventSe continue; TH1F *trackHistoInTimeTmp = potPlots_[detId_pot].trackDistribution->getTH1F(); - int startBin = trackHistoInTimeTmp->FindBin(track.x0() - horizontalShiftOfDiamond_[detId_pot] - track.x0Sigma()); - int numOfBins = 2 * track.x0Sigma() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; + const int startBin = trackHistoInTimeTmp->FindBin(track.x0() - horizontalShiftOfDiamond_[detId_pot] - track.x0Sigma()); + const int numOfBins = 2 * track.x0Sigma() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; for (int i = 0; i < numOfBins; ++i) { trackHistoInTimeTmp->Fill(trackHistoInTimeTmp->GetBinCenter(startBin + i)); } @@ -674,9 +671,9 @@ void DiamondSampicDQMSource::analyze(const edm::Event &event, const edm::EventSe TH2F *trackHistoTmp = sectorPlots_[detId_far.armId()].trackCorrelation->getTH2F(); TAxis *trackHistoTmpXAxis = trackHistoTmp->GetXaxis(); TAxis *trackHistoTmpYAxis = trackHistoTmp->GetYaxis(); - int startBin_far = + const int startBin_far = trackHistoTmpYAxis->FindBin(track_far.x0() - horizontalShiftOfDiamond_[detId_far] - track_far.x0Sigma()); - int numOfBins_far = 2 * track_far.x0Sigma() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; + const int numOfBins_far = 2 * track_far.x0Sigma() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; for (int i = 0; i < numOfBins; ++i) { for (int y = 0; y < numOfBins_far; ++y) { trackHistoTmp->Fill(trackHistoTmpXAxis->GetBinCenter(startBin + i),