ATLAS Offline Software
Loading...
Searching...
No Matches
TileRawChannelNoiseFilter Class Reference

This tool subtracts common-mode noise from all TileRawChannels in one container. More...

#include <TileRawChannelNoiseFilter.h>

Inheritance diagram for TileRawChannelNoiseFilter:
Collaboration diagram for TileRawChannelNoiseFilter:

Public Member Functions

 TileRawChannelNoiseFilter (const std::string &type, const std::string &name, const IInterface *parent)
 AlgTool like constructor.
virtual ~TileRawChannelNoiseFilter ()
 Virtual destructor.
virtual StatusCode initialize () override
 AlgTool initialize method.
virtual StatusCode finalize () override
 AlgTool finalize method.
virtual StatusCode process (TileMutableRawChannelContainer &rchCont, const EventContext &ctx) const override
 process the coherent noise subtruction algorithm and correct TileRawChannel amplitudes

Private Attributes

const TileHWIDm_tileHWID
 Pointer to TileHWID.
SG::ReadCondHandleKey< TileEMScalem_emScaleKey
 Name of TileEMScale in condition store.
SG::ReadCondHandleKey< TileSampleNoisem_sampleNoiseKey
 Name of TileSampleNoise in condition store.
SG::ReadCondHandleKey< TileBadChannelsm_badChannelsKey
 Name of TileBadChannels in condition store.
SG::ReadHandleKey< TileDQstatusm_DQstatusKey
float m_truncationThresholdOnAbsEinSigma
float m_minimumNumberOfTruncatedChannels
bool m_useTwoGaussNoise
bool m_useGapCells
float m_maxNoiseSigma
std::string m_infoName
const TileInfom_tileInfo
float m_ADCmaskValueMinusEps
 indicates channels which were masked in background dataset

Detailed Description

This tool subtracts common-mode noise from all TileRawChannels in one container.

Definition at line 39 of file TileRawChannelNoiseFilter.h.

Constructor & Destructor Documentation

◆ TileRawChannelNoiseFilter()

TileRawChannelNoiseFilter::TileRawChannelNoiseFilter ( const std::string & type,
const std::string & name,
const IInterface * parent )

AlgTool like constructor.

Definition at line 23 of file TileRawChannelNoiseFilter.cxx.

25 : base_class(type, name, parent)
26 , m_tileHWID(0)
27 , m_truncationThresholdOnAbsEinSigma(3.0) // 3 sigma of ADC HF noise by default
28 , m_minimumNumberOfTruncatedChannels(0.6) // at least 60% of channels should be below threshold
29 , m_useTwoGaussNoise(false) // do not use 2G - has no sense for ADC HF noise for the moment
30 , m_useGapCells(false) // use gap cells for noise filter as all normal cells
31 , m_tileInfo(0)
33{
34
35 declareProperty("TruncationThresholdOnAbsEinSigma", m_truncationThresholdOnAbsEinSigma);
36 declareProperty("MinimumNumberOfTruncatedChannels", m_minimumNumberOfTruncatedChannels);
37 declareProperty("UseTwoGaussNoise", m_useTwoGaussNoise);
38 declareProperty("UseGapCells", m_useGapCells);
39 declareProperty("MaxNoiseSigma", m_maxNoiseSigma = 5.0, "Channels with noise more than that value are igonred in calculation of correction");
40 declareProperty("TileInfoName", m_infoName = "TileInfo");
41}
float m_ADCmaskValueMinusEps
indicates channels which were masked in background dataset
const TileHWID * m_tileHWID
Pointer to TileHWID.

◆ ~TileRawChannelNoiseFilter()

virtual TileRawChannelNoiseFilter::~TileRawChannelNoiseFilter ( )
inlinevirtual

Virtual destructor.

Definition at line 48 of file TileRawChannelNoiseFilter.h.

48{};

Member Function Documentation

◆ finalize()

StatusCode TileRawChannelNoiseFilter::finalize ( )
overridevirtual

AlgTool finalize method.

Definition at line 296 of file TileRawChannelNoiseFilter.cxx.

296 {
297 return StatusCode::SUCCESS;
298}

◆ initialize()

StatusCode TileRawChannelNoiseFilter::initialize ( )
overridevirtual

AlgTool initialize method.

Definition at line 45 of file TileRawChannelNoiseFilter.cxx.

45 {
46 ATH_MSG_INFO("Initializing...");
47
48 if (msgLvl(MSG::DEBUG)) {
49 msg(MSG::DEBUG) << "TruncationThresholdOnAbsEinSigma = "
51 msg(MSG::DEBUG) << "MinimumNumberOfTruncatedChannels = "
53 msg(MSG::DEBUG) << "UseTwoGaussNoise = "
54 << ((m_useTwoGaussNoise)?"true":"false") << endmsg;
55 msg(MSG::DEBUG) << "UseGapCells = "
56 << ((m_useGapCells)?"true":"false") << endmsg;
57 }
58
59 ATH_CHECK( detStore()->retrieve(m_tileHWID) );
60
61 ATH_CHECK( m_emScaleKey.initialize() );
62
63 ATH_CHECK( m_sampleNoiseKey.initialize() );
64
65 ATH_CHECK( m_badChannelsKey.initialize() );
66
67 //=== get TileInfo
68 CHECK( detStore()->retrieve(m_tileInfo, m_infoName) );
69 m_ADCmaskValueMinusEps = m_tileInfo->ADCmaskValue() - 0.01; // indicates channels which were masked in background dataset
70
71 ATH_CHECK( m_DQstatusKey.initialize() );
72
73 return StatusCode::SUCCESS;
74}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define CHECK(...)
Evaluate an expression and check for errors.
SG::ReadCondHandleKey< TileBadChannels > m_badChannelsKey
Name of TileBadChannels in condition store.
SG::ReadCondHandleKey< TileEMScale > m_emScaleKey
Name of TileEMScale in condition store.
SG::ReadCondHandleKey< TileSampleNoise > m_sampleNoiseKey
Name of TileSampleNoise in condition store.
SG::ReadHandleKey< TileDQstatus > m_DQstatusKey
MsgStream & msg
Definition testRead.cxx:32

◆ process()

StatusCode TileRawChannelNoiseFilter::process ( TileMutableRawChannelContainer & rchCont,
const EventContext & ctx ) const
overridevirtual

process the coherent noise subtruction algorithm and correct TileRawChannel amplitudes

Definition at line 79 of file TileRawChannelNoiseFilter.cxx.

80{
81 ATH_MSG_DEBUG("in TileRawChannelNoiseFilter::process()");
82
83 TileRawChannelUnit::UNIT rChUnit = rchCont.get_unit();
84 std::string units[8] = { "ADC counts", "pC", "CspC", "MeV",
85 "online ADC counts", "online pC", "online CspC", "online MeV" };
86
89
90 ATH_MSG_ERROR( "Units in container is " << units[rChUnit] );
91 ATH_MSG_ERROR( "Due to non-linear CIS constants noise filter is possible only with ADC counts ");
92 ATH_MSG_ERROR( "Please, disable CIS calibration in optimal filter " );
93
94 return StatusCode::FAILURE;
95 }
96
97 bool undoOnlCalib = (rChUnit > TileRawChannelUnit::OnlineADCcounts);
98 ATH_MSG_VERBOSE( "Units in container is " << units[rChUnit] );
99
100 // Now retrieve the TileDQStatus
101 const TileDQstatus* DQstatus = SG::makeHandle (m_DQstatusKey, ctx).get();
102
103 SG::ReadCondHandle<TileEMScale> emScale(m_emScaleKey, ctx);
104 ATH_CHECK( emScale.isValid() );
105
106 SG::ReadCondHandle<TileBadChannels> badChannels(m_badChannelsKey, ctx);
107 ATH_CHECK( badChannels.isValid() );
108
109 SG::ReadCondHandle<TileSampleNoise> sampleNoise(m_sampleNoiseKey, ctx);
110 ATH_CHECK( sampleNoise.isValid() );
111
112 for (IdentifierHash hash : rchCont.GetAllCurrentHashes()) {
113 TileRawChannelCollection* coll = rchCont.indexFindPtr (hash);
114
115 /* Get drawer ID and build drawer index. */
116 HWIdentifier drawer_id = m_tileHWID->drawer_id(coll->identify());
117 int ros = m_tileHWID->ros(drawer_id);
118 int drawer = m_tileHWID->drawer(drawer_id);
119 unsigned int drawerIdx = TileCalibUtils::getDrawerIdx(ros, drawer);
120 bool eb = (ros > 2);
121 bool ebspD4 = ((ros == 3 && drawer == 14) || (ros == 4 && drawer == 17));
122 bool ebNsp = !ebspD4 && eb;
123 bool ebspC10 = (ebNsp && ((drawer>37 && drawer<42) || (drawer>53 && drawer<58) ) );
124
125 static const int maxChannelDrawer = 48; // number of channels in one drawer
126 static const int maxChannel = 12; // number of channels per motherboard
127 static const int maxMOB = 4; // number of motherboards in one drawer
128
129 float calib[maxChannelDrawer];
130 float commonmode[maxMOB];
131 int nemptychan[maxMOB];
132 int ngoodchan[maxMOB];
133 int chanmap[maxChannelDrawer];
134 memset(calib, 0, sizeof(calib));
135 memset(commonmode, 0, sizeof(commonmode));
136 memset(nemptychan, 0, sizeof(nemptychan));
137 memset(ngoodchan, 0, sizeof(ngoodchan));
138 memset(chanmap, 0, sizeof(chanmap));
139
140 // iterate over all channels in a collection
141 for (const TileRawChannel* rch : *coll) {
142 HWIdentifier adc_id = rch->adc_HWID();
143 //int index,pmt;
144 //Identifier cell_id = rch->cell_ID_index(index,pmt);
145 //if ( index == -1 ) continue; // this is to ignore disconnected channels - just for tests
146 //if ( index < 0 ) continue; // this is to ingnore disconnected channels and MBTS - just for tests
147
148 int chan = m_tileHWID->channel(adc_id);
149 int gain = m_tileHWID->adc(adc_id);
150 int mob = chan / maxChannel;
151 bool empty = (eb && ( (chan > 41) || (chan > 23 && chan < 30) || (ebspD4 && chan < 3) ) );
152
153 // use only good channel
154 float ped=rch->pedestal();
155 if (empty || ped > 59500. || (ped > m_ADCmaskValueMinusEps && ped < 39500.) // all bad patterns, ped=m_tileInfo->ADCmaskValue(), underflow, overflow (see TileRawChannelMaker.cxx for the logic)
156 || badChannels->getAdcStatus(adc_id).isBad()
157 || (!DQstatus->isAdcDQgood(ros, drawer, chan, gain))) continue;
158
159
160 bool usechan = m_useGapCells || // always true if we want to use gap cells
161 ( ! ( ( ebNsp && (chan==0 || chan==1 || chan==12 || chan==13)) ||
162 ( ebspC10 && (chan==4 || chan==5)) ||
163 ( ebspD4 && (chan==18 || chan==19 || chan==12 || chan==13)) ) );
164
165 ++chanmap[chan];
166 // do not count good channels twice
167 if (chanmap[chan] < 2 && usechan) ++ngoodchan[mob];
168 // use only high gain
169 if (gain != TileHWID::HIGHGAIN) continue;
170
171 float amp = rch->amplitude();
172 if (undoOnlCalib) {
173 calib[chan] = emScale->undoOnlineChannelCalibration(drawerIdx, chan, gain, 1.0, rChUnit);
174 amp *= calib[chan];
175 } else {
176 calib[chan] = 1.0;
177 }
178
179
180 if (usechan) {
181
182 float noise_sigma = 1.5; // default value of HFN in high gain channel
183 if (m_useTwoGaussNoise) {
184 //float sigma1 = m_tileToolNoiseSample->getHfn1(drawerIdx, chan, gain, ctx);
185 //float sigma2 = m_tileToolNoiseSample->getHfn2(drawerIdx, chan, gain, ctx);
186 //float norm = m_tileToolNoiseSample->getHfnNorm(drawerIdx, chan, gain, ctx);
187 // still need to define noise_sigma in this case
188 // noise_sigma = ...
189 } else {
190 // take single gauss noise sigma from DB (high frequency noise)
191 noise_sigma = sampleNoise->getHfn(drawerIdx, chan, gain);
192 }
193
194 float significance = 999.999;
195 if ((noise_sigma != 0.0)
196 && (noise_sigma < m_maxNoiseSigma)
197 /* && (!m_tileBadChanTool->getAdcStatus(drawerIdx, chan, gain).isNoisy()) */) {
198
199 significance = fabs(amp / noise_sigma); // caluclate signal/noise ratio
200 } else {
201 --ngoodchan[mob]; // ignore completely channels with zero sigma
202 }
203
204 ATH_MSG_VERBOSE( "HWID " << m_tileHWID->to_string(adc_id)
205 << " calib " << 1. / calib[chan]
206 << " amp " << amp
207 << " noise " << noise_sigma
208 << " significance " << significance );
209
210 if (significance > m_truncationThresholdOnAbsEinSigma) continue;
211
212 commonmode[mob] += amp;
213 ++nemptychan[mob];
214
215 } else {
216
217 ATH_MSG_VERBOSE( "HWID " << m_tileHWID->to_string(adc_id)
218 << " calib " << 1. / calib[chan]
219 << " amp " << amp
220 << " channel is not used" );
221 }
222
223 }
224
225 int ncorr = 0;
227
228 for (int k = 0; k < maxMOB; k++) {
229
231 nchmin = ceil(m_minimumNumberOfTruncatedChannels * ngoodchan[k]);
232 if (nchmin < 2) nchmin = 2;
233 }
234
235 if (nemptychan[k] >= nchmin) {
236 commonmode[k] /= nemptychan[k];
237 ++ncorr;
238
239 ATH_MSG_VERBOSE( "ros " << ros
240 << " drawer " << std::setw(2) << drawer
241 << " mb " << k << " mean " << commonmode[k]
242 << " taken from " << nemptychan[k] << " channels"
243 << " nchgood " << ngoodchan[k]
244 << " nchmin " << nchmin );
245
246 } else {
247 if (msgLvl(MSG::VERBOSE)) {
248 if (commonmode[k] != 0.0) {
249 msg(MSG::VERBOSE) << "ros " << ros
250 << " drawer " << std::setw(2) << drawer
251 << " mb " << k
252 << " mean is zero instead of " << commonmode[k] << " / " << nemptychan[k]
253 << " nchgood " << ngoodchan[k]
254 << " nchmin " << nchmin
255 << endmsg;
256 } else {
257 msg(MSG::VERBOSE) << "ros "
258 << ros << " drawer " << std::setw(2) << drawer
259 << " mb " << k
260 << " mean is zero - nothing to correct"
261 << " nchgood " << ngoodchan[k]
262 << " nchmin " << nchmin
263 << endmsg;
264 }
265 }
266 commonmode[k] = 0.0;
267 }
268 }
269
270 if (ncorr == 0) continue; // nothing to correct
271
272 // iterate over all channels in a collection again
273 for (TileRawChannel* rch : *coll) {
274 int chan = m_tileHWID->channel(rch->adc_HWID());
275 int gain = m_tileHWID->adc(rch->adc_HWID());
276
277 // use only good channel and high gain - for them calib was set to non-zero value above
278 if (calib[chan] > 0.0 && gain == TileHWID::HIGHGAIN) {
279 // correct amplitude directly in channel
280 // (will change this to set() method once it is available in TileRawChannel)
281 int mob = chan/maxChannel;
282 if (undoOnlCalib)
283 rch->setAmplitude (rch->amplitude() - commonmode[mob] / calib[chan]);
284 else
285 rch->setAmplitude (rch->amplitude() - commonmode[mob]);
286 rch->setPedestal (rch->pedestal() + commonmode[mob]);
287 }
288 }
289 }
290
291 return StatusCode::SUCCESS;
292}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
static const Attributes_t empty
virtual std::vector< IdentifierHash > GetAllCurrentHashes() const override final
Returns a collection of all hashes availiable in this IDC.
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
bool isAdcDQgood(int partition, int drawer, int ch, int gain) const
returns status of single ADC returns False if there are any errors
@ HIGHGAIN
Definition TileHWID.h:73
Collection * indexFindPtr(IdentifierHash hash)
Look up a (non-const) collection via hash.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())

Member Data Documentation

◆ m_ADCmaskValueMinusEps

float TileRawChannelNoiseFilter::m_ADCmaskValueMinusEps
private

indicates channels which were masked in background dataset

Definition at line 94 of file TileRawChannelNoiseFilter.h.

◆ m_badChannelsKey

SG::ReadCondHandleKey<TileBadChannels> TileRawChannelNoiseFilter::m_badChannelsKey
private
Initial value:
{this,
"TileBadChannels", "TileBadChannels", "Input Tile bad channel status"}

Name of TileBadChannels in condition store.

Definition at line 78 of file TileRawChannelNoiseFilter.h.

78 {this,
79 "TileBadChannels", "TileBadChannels", "Input Tile bad channel status"};

◆ m_DQstatusKey

SG::ReadHandleKey<TileDQstatus> TileRawChannelNoiseFilter::m_DQstatusKey
private
Initial value:
{this, "TileDQstatus",
"TileDQstatus",
"TileDQstatus key"}

Definition at line 82 of file TileRawChannelNoiseFilter.h.

82 {this, "TileDQstatus",
83 "TileDQstatus",
84 "TileDQstatus key"};

◆ m_emScaleKey

SG::ReadCondHandleKey<TileEMScale> TileRawChannelNoiseFilter::m_emScaleKey
private
Initial value:
{this,
"TileEMScale", "TileEMScale", "Input Tile EMS calibration constants"}

Name of TileEMScale in condition store.

Definition at line 66 of file TileRawChannelNoiseFilter.h.

66 {this,
67 "TileEMScale", "TileEMScale", "Input Tile EMS calibration constants"};

◆ m_infoName

std::string TileRawChannelNoiseFilter::m_infoName
private

Definition at line 92 of file TileRawChannelNoiseFilter.h.

◆ m_maxNoiseSigma

float TileRawChannelNoiseFilter::m_maxNoiseSigma
private

Definition at line 90 of file TileRawChannelNoiseFilter.h.

◆ m_minimumNumberOfTruncatedChannels

float TileRawChannelNoiseFilter::m_minimumNumberOfTruncatedChannels
private

Definition at line 87 of file TileRawChannelNoiseFilter.h.

◆ m_sampleNoiseKey

SG::ReadCondHandleKey<TileSampleNoise> TileRawChannelNoiseFilter::m_sampleNoiseKey
private
Initial value:
{this,
"TileSampleNoise", "TileSampleNoise", "Input Tile sample noise"}

Name of TileSampleNoise in condition store.

Definition at line 72 of file TileRawChannelNoiseFilter.h.

72 {this,
73 "TileSampleNoise", "TileSampleNoise", "Input Tile sample noise"};

◆ m_tileHWID

const TileHWID* TileRawChannelNoiseFilter::m_tileHWID
private

Pointer to TileHWID.

Definition at line 61 of file TileRawChannelNoiseFilter.h.

◆ m_tileInfo

const TileInfo* TileRawChannelNoiseFilter::m_tileInfo
private

Definition at line 93 of file TileRawChannelNoiseFilter.h.

◆ m_truncationThresholdOnAbsEinSigma

float TileRawChannelNoiseFilter::m_truncationThresholdOnAbsEinSigma
private

Definition at line 86 of file TileRawChannelNoiseFilter.h.

◆ m_useGapCells

bool TileRawChannelNoiseFilter::m_useGapCells
private

Definition at line 89 of file TileRawChannelNoiseFilter.h.

◆ m_useTwoGaussNoise

bool TileRawChannelNoiseFilter::m_useTwoGaussNoise
private

Definition at line 88 of file TileRawChannelNoiseFilter.h.


The documentation for this class was generated from the following files: