From 1ea882d208c06eac94ee02ac99b344b83774f328 Mon Sep 17 00:00:00 2001 From: Sandro Wenzel Date: Wed, 13 Apr 2022 16:02:05 +0200 Subject: [PATCH] TPC: reduce use of static keyword static keyword has been used unnecessarily which led to construction of TPC objects at library load time (such as mapper) ... even when TPC algorithms are not run. The static keyword is not necessary here, since the mapper object is in any case a singleton. --- Detectors/TPC/base/include/TPCBase/CalArray.h | 4 ++-- Detectors/TPC/base/include/TPCBase/CalDet.h | 4 ++-- Detectors/TPC/base/src/Painter.cxx | 14 +++++++------- .../include/TPCCalibration/CalibPadGainTracks.h | 3 +-- .../TPC/calibration/src/CalibPadGainTracks.cxx | 6 +++--- Detectors/TPC/calibration/src/IDCAverageGroup.cxx | 2 +- Detectors/TPC/qc/src/Helpers.cxx | 4 ++-- .../include/TPCSimulation/DigitGlobalPad.h | 4 ++-- .../simulation/include/TPCSimulation/DigitTime.h | 4 ++-- Detectors/TPC/simulation/src/Digitizer.cxx | 6 +++--- .../TPC/spacecharge/macro/createSCHistosFromHits.C | 8 ++++---- 11 files changed, 29 insertions(+), 30 deletions(-) diff --git a/Detectors/TPC/base/include/TPCBase/CalArray.h b/Detectors/TPC/base/include/TPCBase/CalArray.h index 88adb61c75d2a..985ee6d1223da 100644 --- a/Detectors/TPC/base/include/TPCBase/CalArray.h +++ b/Detectors/TPC/base/include/TPCBase/CalArray.h @@ -194,7 +194,7 @@ template inline void CalArray::setValue(const size_t row, const size_t pad, const T& value) { /// \todo might need check for row, pad or position limits - static const auto& mapper = Mapper::instance(); + const auto& mapper = Mapper::instance(); size_t position = mapper.getPadNumber(mPadSubset, mPadSubsetNumber, row, pad); setValue(position, value); } @@ -204,7 +204,7 @@ template inline const T CalArray::getValue(const size_t row, const size_t pad) const { /// \todo might need check for row, pad or position limits - static const auto& mapper = Mapper::instance(); + const auto& mapper = Mapper::instance(); size_t position = mapper.getPadNumber(mPadSubset, mPadSubsetNumber, row, pad); return getValue(position); } diff --git a/Detectors/TPC/base/include/TPCBase/CalDet.h b/Detectors/TPC/base/include/TPCBase/CalDet.h index 522b5ad775dda..72a57204686f1 100644 --- a/Detectors/TPC/base/include/TPCBase/CalDet.h +++ b/Detectors/TPC/base/include/TPCBase/CalDet.h @@ -131,7 +131,7 @@ template inline const T CalDet::getValue(const ROC roc, const size_t row, const size_t pad) const { // TODO: might need speedup and beautification - static const Mapper& mapper = Mapper::instance(); + const Mapper& mapper = Mapper::instance(); // bind row and pad to the maximum rows and pads in the requested region const size_t nRows = mapper.getNumberOfRowsROC(roc); @@ -163,7 +163,7 @@ template inline const T CalDet::getValue(const CRU cru, const size_t row, const size_t pad) const { // TODO: might need speedup and beautification - static const Mapper& mapper = Mapper::instance(); + const Mapper& mapper = Mapper::instance(); const auto& info = mapper.getPadRegionInfo(cru.region()); // bind row and pad to the maximum rows and pads in the requested region diff --git a/Detectors/TPC/base/src/Painter.cxx b/Detectors/TPC/base/src/Painter.cxx index d6bda66a69617..488f6a267373f 100644 --- a/Detectors/TPC/base/src/Painter.cxx +++ b/Detectors/TPC/base/src/Painter.cxx @@ -92,7 +92,7 @@ TCanvas* painter::draw(const CalDet& calDet, int nbins1D, float xMin1D, float using DetType = CalDet; using CalType = CalArray; - static const Mapper& mapper = Mapper::instance(); + const Mapper& mapper = Mapper::instance(); // ===| name and title |====================================================== std::string title = calDet.getName(); @@ -216,7 +216,7 @@ TCanvas* painter::draw(const CalArray& calArray) template void painter::fillHistogram2D(TH2& h2D, const CalDet& calDet, Side side) { - static const Mapper& mapper = Mapper::instance(); + const Mapper& mapper = Mapper::instance(); for (ROC roc; !roc.looped(); ++roc) { if (roc.side() != side) { @@ -242,7 +242,7 @@ void painter::fillHistogram2D(TH2& h2D, const CalDet& calDet, Side side) template void painter::fillHistogram2D(TH2& h2D, const CalArray& calArray) { - static const Mapper& mapper = Mapper::instance(); + const Mapper& mapper = Mapper::instance(); const size_t position = calArray.getPadSubsetNumber(); const PadSubset padSubset = calArray.getPadSubset(); @@ -283,7 +283,7 @@ TH2* painter::getHistogram2D(const CalDet& calDet, Side side) template TH2* painter::getHistogram2D(const CalArray& calArray) { - static const Mapper& mapper = Mapper::instance(); + const Mapper& mapper = Mapper::instance(); const size_t position = calArray.getPadSubsetNumber(); const PadSubset padSubset = calArray.getPadSubset(); @@ -472,7 +472,7 @@ TH2Poly* painter::makeSideHist(Side side) template void painter::fillPoly2D(TH2Poly& h2D, const CalDet& calDet, Side side) { - static const Mapper& mapper = Mapper::instance(); + const Mapper& mapper = Mapper::instance(); int bin = 1; for (const auto& calROC : calDet.getData()) { @@ -595,7 +595,7 @@ void painter::drawSectorsXY(Side side, int sectorLineColor, int sectorTextColor) void painter::drawSectorLocalPadNumberPoly(short padTextColor, float lineScalePS) { - static const Mapper& mapper = Mapper::instance(); + const Mapper& mapper = Mapper::instance(); const auto coords = getPadCoordinatesSector(); TLatex lat; lat.SetTextAlign(12); @@ -619,7 +619,7 @@ void painter::drawSectorLocalPadNumberPoly(short padTextColor, float lineScalePS void painter::drawSectorInformationPoly(short regionLineColor, short rowTextColor) { - static const Mapper& mapper = Mapper::instance(); + const Mapper& mapper = Mapper::instance(); TLatex lat; lat.SetTextColor(rowTextColor); diff --git a/Detectors/TPC/calibration/include/TPCCalibration/CalibPadGainTracks.h b/Detectors/TPC/calibration/include/TPCCalibration/CalibPadGainTracks.h index c8168aed34503..b14835b8a09f1 100644 --- a/Detectors/TPC/calibration/include/TPCCalibration/CalibPadGainTracks.h +++ b/Detectors/TPC/calibration/include/TPCCalibration/CalibPadGainTracks.h @@ -157,7 +157,6 @@ class CalibPadGainTracks : public CalibPadGainTracksBase const o2::tpc::ClusterNativeAccess* mClusterIndex{nullptr}; /// CalibPadGainTracks::getTruncMean(std::vector::drawGrouping(const std::string filename) template void o2::tpc::IDCAverageGroup::drawGroupingInformations(const int region, const int grPads, const int grRows, const int groupLastRowsThreshold, const int groupLastPadsThreshold, const int overlapRows, const int overlapPads, const int nIDCs, const int groupPadsSectorEdges) const { - static const o2::tpc::Mapper& mapper = Mapper::instance(); + const o2::tpc::Mapper& mapper = Mapper::instance(); TLatex lat; lat.SetTextColor(kBlack); diff --git a/Detectors/TPC/qc/src/Helpers.cxx b/Detectors/TPC/qc/src/Helpers.cxx index df2c68e4a54e5..d18d6a596a10a 100644 --- a/Detectors/TPC/qc/src/Helpers.cxx +++ b/Detectors/TPC/qc/src/Helpers.cxx @@ -76,7 +76,7 @@ void helpers::setStyleHistogram2D(std::vector& histos) //______________________________________________________________________________ bool helpers::newZSCalib(const o2::tpc::CalDet& refPedestal, const o2::tpc::CalDet& refNoise, const o2::tpc::CalDet& pedestal) { - static const o2::tpc::Mapper& mapper = o2::tpc::Mapper::instance(); + const o2::tpc::Mapper& mapper = o2::tpc::Mapper::instance(); o2::tpc::CalDet diffCalDet = refPedestal - pedestal; @@ -94,4 +94,4 @@ bool helpers::newZSCalib(const o2::tpc::CalDet& refPedestal, const o2::tp } return false; -} \ No newline at end of file +} diff --git a/Detectors/TPC/simulation/include/TPCSimulation/DigitGlobalPad.h b/Detectors/TPC/simulation/include/TPCSimulation/DigitGlobalPad.h index e1c5759386813..62ad2968760f2 100644 --- a/Detectors/TPC/simulation/include/TPCSimulation/DigitGlobalPad.h +++ b/Detectors/TPC/simulation/include/TPCSimulation/DigitGlobalPad.h @@ -133,8 +133,8 @@ inline void DigitGlobalPad::fillOutputContainer(std::vector& output, o2::dataformats::LabelContainer, false>& labels, float commonMode) { - const static Mapper& mapper = Mapper::instance(); - static SAMPAProcessing& sampaProcessing = SAMPAProcessing::instance(); + const Mapper& mapper = Mapper::instance(); + SAMPAProcessing& sampaProcessing = SAMPAProcessing::instance(); const PadPos pad = mapper.padPos(globalPad); static std::vector> labelCollector; // static workspace container for sorting diff --git a/Detectors/TPC/simulation/include/TPCSimulation/DigitTime.h b/Detectors/TPC/simulation/include/TPCSimulation/DigitTime.h index 46edd8add8bee..9723b4bbe6cb4 100644 --- a/Detectors/TPC/simulation/include/TPCSimulation/DigitTime.h +++ b/Detectors/TPC/simulation/include/TPCSimulation/DigitTime.h @@ -113,7 +113,7 @@ inline void DigitTime::reset() inline float DigitTime::getCommonMode(const GEMstack& gemstack) const { /// simple case when there is no external capacitance on the ROC - static const Mapper& mapper = Mapper::instance(); + const Mapper& mapper = Mapper::instance(); const auto nPads = mapper.getNumberOfPads(gemstack); return mCommonMode[gemstack] / static_cast(nPads); } @@ -123,7 +123,7 @@ inline void DigitTime::fillOutputContainer(std::vector& output, dataforma std::vector& commonModeOutput, const Sector& sector, TimeBin timeBin, float commonMode) { - static Mapper& mapper = Mapper::instance(); + Mapper& mapper = Mapper::instance(); GlobalPadNumber globalPad = 0; for (size_t i = 0; i < mCommonMode.size(); ++i) { const float cm = getCommonMode(GEMstack(i)); diff --git a/Detectors/TPC/simulation/src/Digitizer.cxx b/Detectors/TPC/simulation/src/Digitizer.cxx index 9cbee01324247..2f82bca748d34 100644 --- a/Detectors/TPC/simulation/src/Digitizer.cxx +++ b/Detectors/TPC/simulation/src/Digitizer.cxx @@ -51,7 +51,7 @@ void Digitizer::init() void Digitizer::process(const std::vector& hits, const int eventID, const int sourceID) { - const static Mapper& mapper = Mapper::instance(); + const Mapper& mapper = Mapper::instance(); auto& detParam = ParameterDetector::Instance(); auto& eleParam = ParameterElectronics::Instance(); auto& gemParam = ParameterGEM::Instance(); @@ -161,7 +161,7 @@ void Digitizer::flush(std::vector& digits, std::vector& commonModeOutput, bool finalFlush) { - static SAMPAProcessing& sampaProcessing = SAMPAProcessing::instance(); + SAMPAProcessing& sampaProcessing = SAMPAProcessing::instance(); mDigitContainer.fillOutputContainer(digits, labels, commonModeOutput, mSector, sampaProcessing.getTimeBinFromTime(mEventTime - mOutputDigitTimeOffset), mIsContinuous, finalFlush); } @@ -198,7 +198,7 @@ void Digitizer::setUseSCDistortions(TFile& finp) void Digitizer::setStartTime(double time) { - static SAMPAProcessing& sampaProcessing = SAMPAProcessing::instance(); + SAMPAProcessing& sampaProcessing = SAMPAProcessing::instance(); sampaProcessing.updateParameters(); mDigitContainer.setStartTime(sampaProcessing.getTimeBinFromTime(time - mOutputDigitTimeOffset)); } diff --git a/Detectors/TPC/spacecharge/macro/createSCHistosFromHits.C b/Detectors/TPC/spacecharge/macro/createSCHistosFromHits.C index 944514b51f56c..f459364177e68 100644 --- a/Detectors/TPC/spacecharge/macro/createSCHistosFromHits.C +++ b/Detectors/TPC/spacecharge/macro/createSCHistosFromHits.C @@ -197,16 +197,16 @@ void createSCHistosFromHits(const int ionDriftTime = 200, const int nEvIon = 1, auto& cdb = CDBInterface::instance(); cdb.setUseDefaults(); - const static Mapper& mapper = Mapper::instance(); + const Mapper& mapper = Mapper::instance(); - static GEMAmplification& gemAmplification = GEMAmplification::instance(); + GEMAmplification& gemAmplification = GEMAmplification::instance(); gemAmplification.updateParameters(); - static ElectronTransport& electronTransport = ElectronTransport::instance(); + ElectronTransport& electronTransport = ElectronTransport::instance(); electronTransport.updateParameters(); auto& eleParam = ParameterElectronics::Instance(); - static SAMPAProcessing& sampaProcessing = SAMPAProcessing::instance(); + SAMPAProcessing& sampaProcessing = SAMPAProcessing::instance(); sampaProcessing.updateParameters(); const int nShapedPoints = eleParam.NShapedPoints;