diff --git a/CaloFuture/CaloFutureMoniDst/src/CaloFutureDigitMonitor.cpp b/CaloFuture/CaloFutureMoniDst/src/CaloFutureDigitMonitor.cpp index adf9a92042cd1dcde99ccf2c375f7437a10cc276..a260a44a40abcd46355237ee3a9a1d9216f3c415 100644 --- a/CaloFuture/CaloFutureMoniDst/src/CaloFutureDigitMonitor.cpp +++ b/CaloFuture/CaloFutureMoniDst/src/CaloFutureDigitMonitor.cpp @@ -14,7 +14,10 @@ #include "CaloFutureUtils/CaloFutureAlgUtils.h" #include "DetDesc/GenericConditionAccessorHolder.h" #include "Event/CaloDigits_v2.h" +#include "GaudiAlg/Consumer.h" #include "LHCbAlgs/Consumer.h" +#include <Gaudi/Accumulators/Histogram.h> +#include <mutex> // ============================================================================= @@ -53,6 +56,16 @@ public: private: Gaudi::Property<bool> m_spectrum{this, "Spectrum", false, "activate spectrum per channel histogramming"}; + //Define thread safe histograms + + mutable Gaudi::Accumulators::Histogram<1> histoDigitX{this, "DigitX", "Digit X", {m_xBin, m_xMin, m_xMax}}; + mutable Gaudi::Accumulators::Histogram<1> histoDigitY{this, "DigitY", "Digit Y", {m_yBin, m_yMin, m_yMax}}; + mutable Gaudi::Accumulators::Histogram<2> histoDigitXY{this, "DigitXY", "Digit position x vs y",{{m_xBin, m_xMin, m_xMax}, {m_yBin, m_yMin, m_yMax}}}; + mutable Gaudi::Accumulators::WeightedHistogram<2> histoweightedE{this, "Energy2D", "energy weight",{{m_xBin, m_xMin, m_xMax}, {m_yBin, m_yMin, m_yMax}}}; + mutable Gaudi::Accumulators::WeightedHistogram<2> histoDigit2D{this, "Digits2D", detData() + " digits position 2D view",{{m_xBin, m_xMin, m_xMax}, {m_yBin, m_yMin, m_yMax}}}; + mutable Gaudi::Accumulators::WeightedHistogram<2> histoweightedADC{this, "ADC2D", detData() + " ADC 2D view",{{m_xBin, m_xMin, m_xMax}, {m_yBin, m_yMin, m_yMax}}}; + mutable Gaudi::Accumulators::Histogram<1> histoET{this, "ET", "ET", {m_etBin, m_etMin, m_etMax}}; + mutable Gaudi::Accumulators::Histogram<1> histoADC{this, "ADC", "ADC", {m_adcBin, m_adcMin, m_adcMax}}; }; // ============================================================================= @@ -73,12 +86,7 @@ CaloFutureDigitMonitor::CaloFutureDigitMonitor( const std::string& name, ISvcLoc StatusCode CaloFutureDigitMonitor::initialize() { StatusCode sc = Consumer::initialize(); if ( sc.isFailure() ) return sc; - - hBook1( "1", detData() + " : # of Digits", m_multMin, m_multMax, m_multBin ); - hBook1( "4", "Hypo X " + inputLocation(), m_xMin, m_xMax, m_xBin ); - hBook1( "5", "Hypo Y " + inputLocation(), m_yMin, m_yMax, m_yBin ); - hBook2( "6", "Digit position x vs y " + inputLocation(), m_xMin, m_xMax, m_xBin, m_yMin, m_yMax, m_yBin ); - info() << detData() << " digits from " << inputLocation() << endmsg; + info() << detData() << " digits from " << inputLocation() << endmsg; return StatusCode::SUCCESS; } @@ -111,15 +119,18 @@ void CaloFutureDigitMonitor::operator()( const Input& digits, const DeCalorimete if ( et < m_etFilter ) continue; if ( adc < m_adcFilter ) continue; count( id ); - hFill1( id, "2", e ); - const double x = calo.cellCenter( id ).X(); - const double y = calo.cellCenter( id ).Y(); - hFill1( id, "4", x ); - hFill1( id, "5", y ); - hFill2( id, "6", x, y ); - if ( doHisto( "7" ) ) fillCaloFuture2D( "7", id, e, detData() + " energy weighted" ); - if ( doHisto( "8" ) ) fillCaloFuture2D( "8", id, 1., detData() + " digits position 2D view" ); - if ( doHisto( "9" ) ) fillCaloFuture2D( "9", id, adc, detData() + " ADC 2D view" ); + const double x = m_calo->cellCenter( id ).X(); + const double y = m_calo->cellCenter( id ).Y(); + // fill thread safe histograms + + ++histoDigitX[x]; + ++histoDigitY[y]; + ++histoDigitXY[{x,y}]; + + histoweightedE[{x,y}] += e; + histoweightedADC[{x,y}] += adc; + histoDigit2D[{x,y}] += 1.; + if ( m_spectrum ) { if ( msgLevel( MSG::DEBUG ) ) debug() << "Filling cell by cell histograms" << endmsg; @@ -135,11 +146,10 @@ void CaloFutureDigitMonitor::operator()( const Input& digits, const DeCalorimete verbose() << " et " << et << " cell " << unit_et << endmsg; verbose() << " adc " << adc << " cell " << unit_adc << endmsg; } else { - plot1D( et, unit_et, tit.str(), m_etMin, m_etMax, m_etBin ); - plot1D( adc, unit_adc, tit.str(), m_adcMin, m_adcMax, m_adcBin ); + ++histoET[et]; + ++histoADC[adc]; } } } - fillFutureCounters( "1" ); return; // StatusCode::SUCCESS; } diff --git a/CaloFuture/CaloFutureMoniDst/src/CaloFutureMoniAlg.h b/CaloFuture/CaloFutureMoniDst/src/CaloFutureMoniAlg.h index 225503e38ebf11278e85b2ffbf648827dd1e7450..2f1a4d99c361b295249888e8d5025ff2dedfd28a 100644 --- a/CaloFuture/CaloFutureMoniDst/src/CaloFutureMoniAlg.h +++ b/CaloFuture/CaloFutureMoniDst/src/CaloFutureMoniAlg.h @@ -108,8 +108,8 @@ protected: Gaudi::Property<int> m_multBin{this, "HistoMultiplicityBin", 100}; Gaudi::Property<int> m_sizeBin{this, "HistoSizeBin", 25}; - Gaudi::Property<float> m_eFilter{this, "EnergyFilter", -100.}; - Gaudi::Property<float> m_etFilter{this, "EtFilter", -100.}; + Gaudi::Property<float> m_eFilter{this, "EnergyFilter", -9999999.}; + Gaudi::Property<float> m_etFilter{this, "EtFilter", -9999999.}; Gaudi::Property<float> m_adcFilter{this, "ADCFilter", -100.}; Gaudi::Property<float> m_massFilterMin{this, "MassWindowMin", -9999999.}; Gaudi::Property<float> m_massFilterMax{this, "MassWindowMax", +9999999.}; diff --git a/CaloFuture/CaloFutureMoniDst/src/CaloFutureTimeAlignment.cpp b/CaloFuture/CaloFutureMoniDst/src/CaloFutureTimeAlignment.cpp index 316c638e3427cfeb8fad53ba303a25abb44947a7..736bd7776c4599e96c2f576dffee0fba8593322e 100644 --- a/CaloFuture/CaloFutureMoniDst/src/CaloFutureTimeAlignment.cpp +++ b/CaloFuture/CaloFutureMoniDst/src/CaloFutureTimeAlignment.cpp @@ -15,7 +15,10 @@ #include "DetDesc/GenericConditionAccessorHolder.h" #include "Event/CaloDigits_v2.h" #include "Event/ODIN.h" +#include "GaudiAlg/Consumer.h" #include "LHCbAlgs/Consumer.h" +#include <Gaudi/Accumulators/Histogram.h> +#include <mutex> // ============================================================================= @@ -53,15 +56,21 @@ class CaloFutureTimeAlignment final public: StatusCode initialize() override; void operator()( const Input&, const LHCb::ODIN&, const DeCalorimeter& ) const override; - CaloFutureTimeAlignment( const std::string& name, ISvcLocator* pSvcLocator ); - + private: Gaudi::Property<bool> m_spectrum{this, "Spectrum", false, "activate spectrum per channel histogramming"}; Gaudi::Property<bool> m_perCrate{this, "PerCrate", true, "activate spectrum per crate"}; Gaudi::Property<std::vector<int>> m_TAE_BXIDs{this, "TAE_BXIDs"}; + + mutable Gaudi::Accumulators::Histogram<2> histoTA_E{this, "TA_E", "Energy per BX " + inputLocation(),{{3600, 0, 3600}, {m_yBinTA, m_energyMin, m_energyMax}}}; + mutable Gaudi::Accumulators::Histogram<2> histoTA_ADC{this, "TA_ADC", "ADC per BX " + inputLocation(),{{3600, 0, 3600}, {m_yBinTA, m_adcMin, m_adcMax}}}; + mutable Gaudi::Accumulators::Histogram<2> histoTA_ADC_perCrate{this, "TA_ADC", "ADC per BX " + inputLocation(),{{3600, 0, 3600}, {m_yBinTA, m_adcMin, m_adcMax}}}; + mutable Gaudi::Accumulators::Histogram<1> histoTAEbx{this, "TAEbx", "TAEbx", {4000, 0, 4000}}; + mutable Gaudi::Accumulators::Histogram<1> histoTA_w{this, "TAEw", "TAEw", {11, -5, 6}}; }; + // ============================================================================= DECLARE_COMPONENT( CaloFutureTimeAlignment ) @@ -87,9 +96,6 @@ StatusCode CaloFutureTimeAlignment::initialize() { m_xMax = 3600; m_xBin = m_xMax - m_xMin; - hBook2( "TA_E", "Energy per BX " + inputLocation(), m_xMin, m_xMax, m_xBin, m_energyMin, m_energyMax, m_yBinTA ); - hBook2( "TA_ADC", "ADC per BX " + inputLocation(), m_xMin, m_xMax, m_xBin, m_adcMin, m_adcMax, m_yBinTA ); - info() << "Using digits from " << inputLocation() << endmsg; return StatusCode::SUCCESS; @@ -113,13 +119,13 @@ void CaloFutureTimeAlignment::operator()( const Input& digits, const LHCb::ODIN& for ( const auto& digit : digits ) { if ( digit.adc() < m_adcFilter ) continue; - hFill2( "TA_E", bcID, digit.energy() ); - hFill2( "TA_ADC", bcID, digit.adc() ); - // Fill per crate histograms (TAE mode) + ++histoTA_E[{bcID,digit.energy() }]; + ++histoTA_ADC[{bcID,digit.adc() }]; + if ( m_perCrate.value() ) { const auto crate = calo.cardCrate( calo.cardNumber( digit.cellID() ) ); - plot2D( bcID, digit.adc(), fmt::format( "TAE_crate{}", crate ), 0, 3600, m_adcMin, m_adcMax, 3600, m_yBinTA ); + ++histoTA_ADC_perCrate[{bcID,digit.adc() }]; } // Fill cell by cell histograms (TAE mode) if ( m_spectrum.value() ) { @@ -127,14 +133,12 @@ void CaloFutureTimeAlignment::operator()( const Input& digits, const LHCb::ODIN& int TAEwindow = -9999; for ( auto TAEbx : m_TAE_BXIDs ) { if ( ( bcID < TAEbx + 5 ) & ( bcID > TAEbx - 5 ) ) { TAEwindow = bcID - TAEbx; } - plot1D( TAEbx, "TAE BXIDs", "TAE BXIDs", 0, 4000, 4000, 1. ); // safety check on which BX we read on + ++histoTAEbx[TAEbx]; } if ( TAEwindow > -9999 ) { - std::string tit = fmt::format( "{} channel : {}", detData(), Gaudi::Utils::toString( id ) ); - std::string name_tae = fmt::format( "{}Cells/{}/{}_{}_tae", detData(), id.areaName(), id.row(), id.col() ); - plot1D( TAEwindow, name_tae, tit, -5, 6, 11, digit.adc() ); - } - } + std::string tit = fmt::format( "{} channel : {}", detData(), Gaudi::Utils::toString( id ) ); + std::string name_tae = fmt::format( "{}Cells/{}/{}_{}_tae", detData(), id.areaName(), id.row(), id.col() ); + ++histoTAE_w[TAEwindow]; } return; // StatusCode::SUCCESS;