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 24 of file TileRawChannelNoiseFilter.cxx.

26 : base_class(type, name, parent)
27 , m_tileHWID(0)
28 , m_truncationThresholdOnAbsEinSigma(3.0) // 3 sigma of ADC HF noise by default
29 , m_minimumNumberOfTruncatedChannels(0.6) // at least 60% of channels should be below threshold
30 , m_useTwoGaussNoise(false) // do not use 2G - has no sense for ADC HF noise for the moment
31 , m_useGapCells(false) // use gap cells for noise filter as all normal cells
32 , m_tileInfo(0)
34{
35
36 declareProperty("TruncationThresholdOnAbsEinSigma", m_truncationThresholdOnAbsEinSigma);
37 declareProperty("MinimumNumberOfTruncatedChannels", m_minimumNumberOfTruncatedChannels);
38 declareProperty("UseTwoGaussNoise", m_useTwoGaussNoise);
39 declareProperty("UseGapCells", m_useGapCells);
40 declareProperty("MaxNoiseSigma", m_maxNoiseSigma = 5.0, "Channels with noise more than that value are igonred in calculation of correction");
41 declareProperty("TileInfoName", m_infoName = "TileInfo");
42}
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 297 of file TileRawChannelNoiseFilter.cxx.

297 {
298 return StatusCode::SUCCESS;
299}

◆ initialize()

StatusCode TileRawChannelNoiseFilter::initialize ( )
overridevirtual

AlgTool initialize method.

Definition at line 46 of file TileRawChannelNoiseFilter.cxx.

46 {
47 ATH_MSG_INFO("Initializing...");
48
49 if (msgLvl(MSG::DEBUG)) {
50 msg(MSG::DEBUG) << "TruncationThresholdOnAbsEinSigma = "
52 msg(MSG::DEBUG) << "MinimumNumberOfTruncatedChannels = "
54 msg(MSG::DEBUG) << "UseTwoGaussNoise = "
55 << ((m_useTwoGaussNoise)?"true":"false") << endmsg;
56 msg(MSG::DEBUG) << "UseGapCells = "
57 << ((m_useGapCells)?"true":"false") << endmsg;
58 }
59
61
62 ATH_CHECK( m_emScaleKey.initialize() );
63
64 ATH_CHECK( m_sampleNoiseKey.initialize() );
65
66 ATH_CHECK( m_badChannelsKey.initialize() );
67
68 //=== get TileInfo
70 m_ADCmaskValueMinusEps = m_tileInfo->ADCmaskValue() - 0.01; // indicates channels which were masked in background dataset
71
72 ATH_CHECK( m_DQstatusKey.initialize() );
73
74 return StatusCode::SUCCESS;
75}
#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
retrieve(aClass, aKey=None)
Definition PyKernel.py:110
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 80 of file TileRawChannelNoiseFilter.cxx.

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