diff --git a/TileCalorimeter/TileRecUtils/TileRecUtils/ATLAS_CHECK_THREAD_SAFETY b/TileCalorimeter/TileRecUtils/TileRecUtils/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 0000000000000000000000000000000000000000..a463031defd26167b405dae149d73c80bb29c28f --- /dev/null +++ b/TileCalorimeter/TileRecUtils/TileRecUtils/ATLAS_CHECK_THREAD_SAFETY @@ -0,0 +1 @@ +TileCalorimeter/TileRecUtils diff --git a/TileCalorimeter/TileRecUtils/TileRecUtils/TileCorrelation.h b/TileCalorimeter/TileRecUtils/TileRecUtils/TileCorrelation.h index aaeb3367dca339b5fe4be36bbf5812eb0f1947a3..5882129a45bef12f9b52fa448451c4f5da6f2b6e 100644 --- a/TileCalorimeter/TileRecUtils/TileRecUtils/TileCorrelation.h +++ b/TileCalorimeter/TileRecUtils/TileRecUtils/TileCorrelation.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ //************************************************************************************* @@ -15,7 +15,8 @@ // ************************************************************************************ -#include "AthenaKernel/MsgStreamMember.h" +#include "AthenaBaseComps/AthMessaging.h" +#include "AthenaKernel/getMessageSvc.h" class TileHWID; @@ -24,8 +25,9 @@ class TileHWID; #include <fstream> -class TileCorrelation { - +class TileCorrelation + : public AthMessaging +{ public: TileCorrelation(); ~TileCorrelation(); @@ -54,10 +56,6 @@ class TileCorrelation { void buildPulseShape(std::vector<double> &pulseShape, std::vector<double> &pulseShapeY, std::vector<double> &pulseShapeT, int dignum); - /// Log a message using the Athena controlled logging system - MsgStream& msg( MSG::Level lvl ) const { return m_msg << lvl; } - /// Check whether the logging system is active at the provided verbosity level - bool msgLvl( MSG::Level lvl ) const { return m_msg.get().level() <= lvl; } private: //double SS(9,9); @@ -80,11 +78,6 @@ class TileCorrelation { double m_S11[4][64][48][2][9]; double m_S12[4][64][48][2][9]; double m_S22[4][64][48][2][9]; - - // const TileInfo *m_tileInfo; - - /// Private message stream member - mutable Athena::MsgStreamMember m_msg; }; diff --git a/TileCalorimeter/TileRecUtils/TileRecUtils/TileRawChannelBuilder.h b/TileCalorimeter/TileRecUtils/TileRecUtils/TileRawChannelBuilder.h index bf972da9f9980a0d95306cce1ba22ea7cddb6104..880ae1c3401900e2500b14eebf0ea9bd44bc00e9 100644 --- a/TileCalorimeter/TileRecUtils/TileRecUtils/TileRawChannelBuilder.h +++ b/TileCalorimeter/TileRecUtils/TileRecUtils/TileRawChannelBuilder.h @@ -132,7 +132,7 @@ class TileRawChannelBuilder: public AthAlgTool { static const char* BadPatternName(float ped); - static void resetDrawer(); + void resetDrawer(); void resetOverflows(void); Overflows_t& getOverflowedChannels(void); std::string getTileRawChannelContainerID(void); @@ -226,10 +226,9 @@ class TileRawChannelBuilder: public AthAlgTool { static const int MAX_CHANNELS = 48; static const int MAX_DMUS = 16; - static int s_error[MAX_CHANNELS]; - static int s_dmuerr[MAX_DMUS]; - static int s_lastDrawer; - static bool s_badDrawer; + int m_error[MAX_CHANNELS]; + int m_lastDrawer = -1; + bool m_badDrawer = false; bool m_notUpgradeCabling; diff --git a/TileCalorimeter/TileRecUtils/TileRecUtils/TileRawChannelBuilderOpt2FilterLookup.h b/TileCalorimeter/TileRecUtils/TileRecUtils/TileRawChannelBuilderOpt2FilterLookup.h index a13806556266f04be2300b864b0d644deabfcb73..10d58794dcb0cb31c088bc37fb6f67539553f5d9 100644 --- a/TileCalorimeter/TileRecUtils/TileRecUtils/TileRawChannelBuilderOpt2FilterLookup.h +++ b/TileCalorimeter/TileRecUtils/TileRecUtils/TileRawChannelBuilderOpt2FilterLookup.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef TILERECUTILS_TILERAWCHANNELBUILDEROPT2FILTERLOOKUP_H @@ -15,6 +15,9 @@ // 25-jul-2007 ////////////////////////////////////////////////////////////////////// +namespace TileRawChannelBuilderOpt2 { + +const unsigned short lookup[2401]={ 0x000e, 0x8000, 0x4000, 0x2aab, 0x2000, 0x199a, 0x1555, 0x1249, 0x1000, 0x0e39, 0x0ccd, @@ -256,6 +259,9 @@ unsigned short lookup[2401]={ 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, -0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e }; +0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e }; + +} // namespace TileRawChannelBuilderOpt2 + #endif diff --git a/TileCalorimeter/TileRecUtils/src/TileCorrelation.cxx b/TileCalorimeter/TileRecUtils/src/TileCorrelation.cxx index d190eb56099788dd5c76a78180b7e511d995cee2..19216632e484477eb750db7ade8d832a0dcc1195 100644 --- a/TileCalorimeter/TileRecUtils/src/TileCorrelation.cxx +++ b/TileCalorimeter/TileRecUtils/src/TileCorrelation.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ //////////////////////////////////////// @@ -35,7 +35,8 @@ //////////////////////////////////////// TileCorrelation::TileCorrelation() - : m_SS() + : AthMessaging (Athena::getMessageSvc(), "TileCorrelation") + , m_SS() , m_S() , m_R() , m_corr() @@ -52,7 +53,6 @@ TileCorrelation::TileCorrelation() , m_S11() , m_S12() , m_S22() - , m_msg("TileCorrelation") { } diff --git a/TileCalorimeter/TileRecUtils/src/TileRawChannelBuilder.cxx b/TileCalorimeter/TileRecUtils/src/TileRawChannelBuilder.cxx index 76f01e7108f2ba52dd33891104fd49ce99873d37..e97efe737f7131dda65dc78e0c04162d4af79a7f 100644 --- a/TileCalorimeter/TileRecUtils/src/TileRawChannelBuilder.cxx +++ b/TileCalorimeter/TileRecUtils/src/TileRawChannelBuilder.cxx @@ -25,15 +25,10 @@ const InterfaceID& TileRawChannelBuilder::interfaceID() { return IID_ITileRawChannelBuilder; } -int TileRawChannelBuilder::s_error[MAX_CHANNELS] = {0}; -int TileRawChannelBuilder::s_dmuerr[MAX_DMUS] = {0}; -int TileRawChannelBuilder::s_lastDrawer = -1; -bool TileRawChannelBuilder::s_badDrawer = false; - void TileRawChannelBuilder::resetDrawer() { - s_lastDrawer = -1; - s_badDrawer = false; + m_lastDrawer = -1; + m_badDrawer = false; } void TileRawChannelBuilder::resetOverflows() { @@ -76,8 +71,7 @@ TileRawChannelBuilder::TileRawChannelBuilder(const std::string& type , m_tileInfo(nullptr) { resetDrawer(); - memset(s_error, 0, sizeof(s_error)); - memset(s_dmuerr, 0, sizeof(s_dmuerr)); + memset(m_error, 0, sizeof(m_error)); declareProperty("calibrateEnergy", m_calibrateEnergy = false); declareProperty("correctTime", m_correctTime = false); @@ -291,28 +285,28 @@ void TileRawChannelBuilder::fill_drawer_errors(const EventContext& ctx, int ros = (frag >> 8); int drawer = (frag & 0xff); - s_lastDrawer = frag; + m_lastDrawer = frag; - memset(s_error, 0, sizeof(s_error)); - memset(s_dmuerr, 0, sizeof(s_dmuerr)); + memset(m_error, 0, sizeof(m_error)); + int dmuerr[MAX_DMUS] = {0}; int nch = 0; bool bigain = DQstatus->isBiGain(); if (!bigain) { // in bigain runs we don't have DQ status fragment for (int ch = 0; ch < MAX_CHANNELS; ch += 3) { if (!DQstatus->isAdcDQgood(ros, drawer, ch, 0)) { - s_error[ch + 2] = s_error[ch + 1] = s_error[ch] = -3; - s_dmuerr[ch / 3] = 3; + m_error[ch + 2] = m_error[ch + 1] = m_error[ch] = -3; + dmuerr[ch / 3] = 3; nch += 3; } } } if (nch == MAX_CHANNELS) { // all bad - nothing to do - s_badDrawer = true; + m_badDrawer = true; ATH_MSG_VERBOSE( "Drawer 0x" << MSG::hex << frag << MSG::dec << " is bad - skipping bad patterns check " ); return; } else { - s_badDrawer = false; + m_badDrawer = false; ATH_MSG_VERBOSE( "Drawer 0x" << MSG::hex << frag << MSG::dec << " looking for bad patterns in digits" ); } @@ -330,7 +324,7 @@ void TileRawChannelBuilder::fill_drawer_errors(const EventContext& ctx, int channel = m_tileHWID->channel(adcId); int gain = m_tileHWID->adc(adcId); - if (s_error[channel]) { + if (m_error[channel]) { ATH_MSG_VERBOSE( "BadCh " << ros << "/" << drawer << "/" << channel @@ -342,9 +336,9 @@ void TileRawChannelBuilder::fill_drawer_errors(const EventContext& ctx, if (err) { - s_error[channel] = err; + m_error[channel] = err; if (err > -5) { - ++s_dmuerr[channel / 3]; + ++dmuerr[channel / 3]; ++nchbad[channel / 24]; } @@ -374,7 +368,7 @@ void TileRawChannelBuilder::fill_drawer_errors(const EventContext& ctx, } else { if (mindig < 0.01) err += 1; if (maxdig > m_ADCmaxMinusEps) err += 2; - if (err) s_error[channel] = err - 10; + if (err) m_error[channel] = err - 10; } } } @@ -385,11 +379,11 @@ void TileRawChannelBuilder::fill_drawer_errors(const EventContext& ctx, int ndmubad[2] = { 0, 0 }; int dmu = 0; for (; dmu < MAX_DMUS / 2; ++dmu) { // first half - if (s_dmuerr[dmu] > 1) + if (dmuerr[dmu] > 1) ++ndmubad[0]; // count DMUs with at least two bad channels } for (; dmu < MAX_DMUS; ++dmu) { // second half - if (s_dmuerr[dmu] > 1) + if (dmuerr[dmu] > 1) ++ndmubad[1]; // count DMUs with at least two bad channels } @@ -412,16 +406,16 @@ void TileRawChannelBuilder::fill_drawer_errors(const EventContext& ctx, if (printall) { msg(MSG::VERBOSE) << "nDMuErr "; for (int d = 0; d < MAX_DMUS; ++d) { - msg(MSG::VERBOSE) << " " << s_dmuerr[d]; + msg(MSG::VERBOSE) << " " << dmuerr[d]; } msg(MSG::VERBOSE) << " total " << ndmubad[p] << " errors" << endmsg; msg(MSG::VERBOSE) << "ChErr "; int ch = 0; while (ch < MAX_CHANNELS) { - msg(MSG::VERBOSE) << " " << s_error[ch++]; - msg(MSG::VERBOSE) << " " << s_error[ch++]; - msg(MSG::VERBOSE) << " " << s_error[ch++]; + msg(MSG::VERBOSE) << " " << m_error[ch++]; + msg(MSG::VERBOSE) << " " << m_error[ch++]; + msg(MSG::VERBOSE) << " " << m_error[ch++]; msg(MSG::VERBOSE) << " "; } @@ -433,8 +427,8 @@ void TileRawChannelBuilder::fill_drawer_errors(const EventContext& ctx, int ch = (p) ? MAX_CHANNELS / 2 : 0; int chmax = (p) ? MAX_CHANNELS : MAX_CHANNELS / 2; for (; ch < chmax; ++ch) { - if (s_error[ch] == 0 || s_error[ch] < -5) { // channel was good before - s_error[ch] = -4; + if (m_error[ch] == 0 || m_error[ch] < -5) { // channel was good before + m_error[ch] = -4; } } } @@ -443,7 +437,7 @@ void TileRawChannelBuilder::fill_drawer_errors(const EventContext& ctx, } const char * TileRawChannelBuilder::BadPatternName(float ped) { - static const char * errname[25] = { + static const char * const errname[25] = { "-10 - good signal", "-9 - underflow", "-8 - overflow", @@ -482,7 +476,7 @@ StatusCode TileRawChannelBuilder::build(const TileDigitsCollection* coll) int frag = coll->identify(); // make sure that error array is up-to-date - if (frag != s_lastDrawer && m_notUpgradeCabling) { + if (frag != m_lastDrawer && m_notUpgradeCabling) { fill_drawer_errors(ctx, coll); } @@ -496,13 +490,13 @@ StatusCode TileRawChannelBuilder::build(const TileDigitsCollection* coll) if (m_notUpgradeCabling) { - int err = s_error[m_tileHWID->channel(rch->adc_HWID())]; + int err = m_error[m_tileHWID->channel(rch->adc_HWID())]; if (err) { if (err == -8 || err == -7) m_overflows.push_back(std::make_pair(rch, (*digitItr))); float ped = rch->pedestal() + 100000 + 10000 * err; rch->setPedestal(ped); - if (msgLvl(MSG::VERBOSE) && !s_badDrawer) { + if (msgLvl(MSG::VERBOSE) && !m_badDrawer) { if (err < -5) { msg(MSG::VERBOSE) << "BadCh " << m_tileHWID->to_string(rch->adc_HWID()) << " warning = " << BadPatternName(ped) << endmsg; diff --git a/TileCalorimeter/TileRecUtils/src/TileRawChannelBuilderOpt2Filter.cxx b/TileCalorimeter/TileRecUtils/src/TileRawChannelBuilderOpt2Filter.cxx index 5ef745a88fac3868e0220a6825dc3ede91b3384f..de60aaa50c6b9e4711a514fc884088e64317534b 100644 --- a/TileCalorimeter/TileRecUtils/src/TileRawChannelBuilderOpt2Filter.cxx +++ b/TileCalorimeter/TileRecUtils/src/TileRawChannelBuilderOpt2Filter.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ @@ -636,6 +636,7 @@ double TileRawChannelBuilderOpt2Filter::compute(int ros, int drawer, int channel } if (m_emulateDsp) { + using TileRawChannelBuilderOpt2::lookup; round = 1 << (ascale - 2); short e2Dsp = (unsigned short) ((dspEnergy + round) >> (ascale - 1)); size_t OptInd = abs(e2Dsp); diff --git a/TileCalorimeter/TileRecUtils/src/TileRawChannelMaker.cxx b/TileCalorimeter/TileRecUtils/src/TileRawChannelMaker.cxx index 192a4114af832829c6ae66f2bce846a621e0042d..6a88ab6f4d30c4e9fb417c3c02b472dd2b1ef218 100644 --- a/TileCalorimeter/TileRecUtils/src/TileRawChannelMaker.cxx +++ b/TileCalorimeter/TileRecUtils/src/TileRawChannelMaker.cxx @@ -94,11 +94,9 @@ StatusCode TileRawChannelMaker::execute() { // create RawChannel Containers for all sub-algs for (ToolHandle<TileRawChannelBuilder>& rawChannelBuilder : m_tileRawChannelBuilderList) { ATH_CHECK( rawChannelBuilder->createContainer() ); + rawChannelBuilder->resetDrawer(); } - //make sure that we clean memory about errors in a drawer - TileRawChannelBuilder::resetDrawer(); - // clean memory about overflows if (m_fitOverflow) { for (ToolHandle<TileRawChannelBuilder>& rawChannelBuilder : m_tileRawChannelBuilderList) { diff --git a/TileCalorimeter/TileRecUtils/src/TileRawCorrelatedNoise.cxx b/TileCalorimeter/TileRecUtils/src/TileRawCorrelatedNoise.cxx index 9ebe87b255ecf45feceace26bbf0168859eda252..e051276bb1683a37aa3addf3561aea7bdade6de8 100644 --- a/TileCalorimeter/TileRecUtils/src/TileRawCorrelatedNoise.cxx +++ b/TileCalorimeter/TileRecUtils/src/TileRawCorrelatedNoise.cxx @@ -101,6 +101,7 @@ StatusCode TileRawCorrelatedNoise::initialize() { const char* TOKENS = { " \t\n" }; // read Matrix int dima = 48; + char* saveptr = nullptr; for (int line = 0; line < dima; line++) { if (fgets(buff, sizeof(buff), alpha_file) != NULL) { ATH_MSG_DEBUG( "line " << line << " is " << buff ); @@ -110,9 +111,9 @@ StatusCode TileRawCorrelatedNoise::initialize() { // read value int error = 0; if (column == 0) { - if ((word = strtok(buff, TOKENS)) == NULL) error = 1; + if ((word = strtok_r(buff, TOKENS, &saveptr)) == NULL) error = 1; } else { - if ((word = strtok(NULL, TOKENS)) == NULL) error = 1; + if ((word = strtok_r(NULL, TOKENS, &saveptr)) == NULL) error = 1; } double pippo; @@ -181,6 +182,7 @@ StatusCode TileRawCorrelatedNoise::initialize() { const char* TOKENS = { " \t\n" }; // read Vector int dima = 48; + char* saveptr = nullptr; for (int line = 0; line < dima; line++) { if (fgets(buff, sizeof(buff), mean_file) != NULL) { ATH_MSG_DEBUG( "line " << line << " is " << buff ); @@ -190,9 +192,9 @@ StatusCode TileRawCorrelatedNoise::initialize() { // read value int error = 0; if (Sample == 0) { - if ((word = strtok(buff, TOKENS)) == NULL) error = 1; + if ((word = strtok_r(buff, TOKENS, &saveptr)) == NULL) error = 1; } else { - if ((word = strtok(NULL, TOKENS)) == NULL) error = 1; + if ((word = strtok_r(NULL, TOKENS, &saveptr)) == NULL) error = 1; } double pippo; if (error) @@ -271,7 +273,8 @@ StatusCode TileRawCorrelatedNoise::initialize() { if (*buff == '!' || *buff == '*') continue; // read value double pippo; - if ((word = strtok(buff, TOKENS)) == NULL) pippo = 0; + char* saveptr = nullptr; + if ((word = strtok_r(buff, TOKENS, &saveptr)) == NULL) pippo = 0; else pippo = atof(word); // read value ATH_MSG_VERBOSE ( "elem is " << pippo );