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

#include <TileDQstatusTool.h>

Inheritance diagram for TileDQstatusTool:
Collaboration diagram for TileDQstatusTool:

Public Member Functions

 TileDQstatusTool (const std::string &type, const std::string &name, const IInterface *parent)
 Standard Gaudi tool constructor.
virtual StatusCode initialize () override
 Gaudi initialize method.
virtual StatusCode makeStatus (const EventContext &ctx, const TileRawChannelContainer *rawChannelContainer, const TileDigitsContainer *tileDigitsContainer, const TileBeamElemContainer *tileBeamElemContainer, TileDQstatus &dqstatus) const override
 Make a new TileDQstatus object.

Private Member Functions

StatusCode doBeamElem (const TileBeamElemContainer *tileBeamElemContainer, TileDQstatus &dqstatus) const
 Process BeamElemContainer.

Private Attributes

Gaudi::Property< bool > m_simulateTrips {this, "SimulateTrips", false, "Simulate drawer trips (default=false)"}
ServiceHandle< IAthRNGSvcm_athRNGSvc {this, "AthRNGSvc", "AthRNGSvc", "Random number service"}
SG::ReadCondHandleKey< TileBadChannelsm_badChannelsKey
 Name of TileBadChannels in condition store.
const TileHWIDm_tileHWID = nullptr
 Tile ID helper.

Detailed Description

Definition at line 28 of file TileDQstatusTool.h.

Constructor & Destructor Documentation

◆ TileDQstatusTool()

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

Standard Gaudi tool constructor.

Parameters
typeThe name of the tool type.
nameThe tool name.
parentThe tool's Gaudi parent.

Definition at line 35 of file TileDQstatusTool.cxx.

38 : base_class (type, name, parent)
39{
40}

Member Function Documentation

◆ doBeamElem()

StatusCode TileDQstatusTool::doBeamElem ( const TileBeamElemContainer * tileBeamElemContainer,
TileDQstatus & dqstatus ) const
private

Process BeamElemContainer.

Parameters
tileBeamElemContainerThe TileBeamElemContainer (may be null).
dqstatusTileDQstatus object being filled.

Definition at line 218 of file TileDQstatusTool.cxx.

220{
221 if (!tileBeamElemContainer) {
222 return StatusCode::SUCCESS;
223 }
224
225 uint32_t* cispar = dqstatus.cispar();
226
227 for (const TileBeamElemCollection* coll : *tileBeamElemContainer) {
228 int frag = coll->identify();
229
230 if (dqstatus.trigType() == 0 && coll->getLvl1Type() != 0) {
231 // take it from the ROD header
232 // make negative to distinguish from TileCal internal trig types
233 dqstatus.setTrigType (- coll->getLvl1Type());
234 }
235
236 switch (frag) {
237
238 case LASE_PTN_FRAG: {
239
240 TileBeamElemCollection::const_iterator beamItr = coll->begin();
241 TileBeamElemCollection::const_iterator lastBeam = coll->end();
242
243 if (beamItr != lastBeam) {
244 std::vector < uint32_t > digits = (*beamItr)->get_digits();
245
246 if (digits.size() > 0) {
247 uint32_t laserFlag = digits[0];
248 if (laserFlag & 0xFF00)
249 dqstatus.setTrigType (laserFlag >> 8);
250 }
251 }
252 }
253 break;
254
255 case DIGI_PAR_FRAG: {
256 dqstatus.setRODBCID (coll->getRODBCID());
257
258 for (const TileBeamElem* elem : *coll) {
259 HWIdentifier id = elem->adc_HWID();
260 std::vector < uint32_t > digits = elem->get_digits();
261 int cha = m_tileHWID->channel(id);
262
263 if (cha < 15) {
264 if (digits.size() > 0) {
265 cispar[cha] = digits[0];
266 ATH_MSG_VERBOSE("cispar [" << cha << "] = " << cispar[cha]);
267 }
268 }
269 else if (cha == 15) {
270 int siz = 15 + digits.size();
271 if (siz > 110)
272 siz = 110;
273 for (int i = 15; i < siz; ++i) {
274 cispar[i] = digits[i - 15];
275 ATH_MSG_VERBOSE("cispar [" << i << "] = " << cispar[i]);
276 }
277 switch (cispar[16]) {
278
279 case 0x02: {
280 int aux_ext = cispar[17];
281 cispar[17] = (aux_ext & 0x00ff); // dac
282 cispar[18] = (aux_ext >> 8) & 0x00ff; // 00
283 cispar[19] = (aux_ext >> 16) & 0x00ff; // 00
284 cispar[20] = (aux_ext >> 24) & 0x00ff; // small/large cap
285 }
286 break;
287
288 case 0x07: {
289 bool badpar = ((cispar[16] == cispar[17]) || (cispar[17] == cispar[18]));
290 int aux_ext = cispar[18];
291 cispar[18] = (aux_ext & 0x00ff) - 1; // pmt ext cispar starts from 1
292 cispar[19] = (aux_ext >> 8) & 0x00ff; // tower
293 cispar[20] = (aux_ext >> 16) & 0x00ff; // drawer
294
295 if (badpar || (aux_ext>>24)!=0 || cispar[18]>5 || cispar[19]>15 || cispar[20]>63) {
296 ATH_MSG_WARNING("bad cispar[16,17,18]: " << cispar[16] << " " << cispar[17] << " " << aux_ext
297 << " drawer,tower,pmt: " << cispar[20] << " " << cispar[19] << " " << (int)cispar[18]);
298 cispar[16] += 0x100; // flag bad events
299 cispar[18] = 5;
300 cispar[19] = 0xff;
301 cispar[20] = 0xff;
302 }
303
304 if (cispar[16] != cispar[17]) {
305 const float charge = std::bit_cast<float>(cispar[17]);
306 cispar[17] = static_cast<uint32_t>(charge);
307 }
308 }
309 break;
310 }
311 }
312 }
313 }
314 break;
315
316 case LASER_OBJ_FRAG: {
317
318 dqstatus.setRODBCID (coll->getRODBCID());
319
320 // laspar isn't actually used by anything.
321 // Leave commented out for now.
322#if 0
323 TileBeamElemCollection::const_iterator beamItr = (*collItr)->begin();
324 TileBeamElemCollection::const_iterator lastBeam = (*collItr)->end();
325
326 if (beamItr != lastBeam) { // one channel is expected, check that it's really there
327
328 std::vector < uint32_t > digits = (*beamItr)->get_digits();
329 int cha = std::min(32, (int) digits.size());
330
331 while (--cha >= 0) {
332 m_laspar[cha] = digits[cha];
333 ATH_MSG_VERBOSE("laspar [" << cha << "] = " << m_laspar[cha]);
334 }
335 }
336#endif
337 }
338 break;
339
340 case COIN_TRIG1_FRAG:
341 case COIN_TRIG2_FRAG:
342 case COIN_TRIG3_FRAG:
343 case COIN_TRIG4_FRAG:
344 case COIN_TRIG5_FRAG:
345 case COIN_TRIG6_FRAG:
346 case COIN_TRIG7_FRAG:
347 case COIN_TRIG8_FRAG: {
348 // coincTrig is not actually used by anything now.
349 // Leave commented out.
350#if 0
351 unsigned int board = frag - COIN_TRIG1_FRAG;
352 // make sure that we have enough space
353 if (board >= m_coincTrig.size()) {
354 m_coincTrig.resize(board + 1);
355 }
356
357 TileBeamElemCollection::const_iterator beamItr = (*collItr)->begin();
358 TileBeamElemCollection::const_iterator lastBeam = (*collItr)->end();
359
360 // loop over 4 integer words for one board
361 for (; beamItr != lastBeam; ++beamItr) {
362
363 HWIdentifier id = (*beamItr)->adc_HWID();
364 std::vector < uint32_t > digits = (*beamItr)->get_digits();
365 uint32_t amplitude = (digits.size() > 0) ? digits[0] : 0;
366 int cha = m_tileHWID->channel(id);
367
368 if (cha < 3) {
369 int idx = cha * 32;
370 for (int ibit = 0; ibit < 32; ++ibit) {
371 m_coincTrig[board].trig[idx++] = (amplitude >> ibit) & 1;
372 }
373 } else if (cha == 3) {
374 m_coincTrig[board].amp = amplitude;
375 }
376 }
377#endif
378 }
379 break;
380
381 default:
382 break;
383 }
384 }
385
386 return StatusCode::SUCCESS;
387}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
double charge(const T &p)
Definition AtlasPID.h:997
#define COIN_TRIG4_FRAG
Definition TileTBFrag.h:35
#define COIN_TRIG2_FRAG
Definition TileTBFrag.h:33
#define LASER_OBJ_FRAG
Definition TileTBFrag.h:49
#define COIN_TRIG7_FRAG
Definition TileTBFrag.h:38
#define COIN_TRIG5_FRAG
Definition TileTBFrag.h:36
#define COIN_TRIG8_FRAG
Definition TileTBFrag.h:39
#define COIN_TRIG6_FRAG
Definition TileTBFrag.h:37
#define LASE_PTN_FRAG
Definition TileTBFrag.h:27
#define COIN_TRIG3_FRAG
Definition TileTBFrag.h:34
#define DIGI_PAR_FRAG
Definition TileTBFrag.h:41
#define COIN_TRIG1_FRAG
Definition TileTBFrag.h:32
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
const TileHWID * m_tileHWID
Tile ID helper.
int trigType() const
Trigger type.
void setRODBCID(uint32_t BCID)
sets the ROD BCID stored and used in DQStatus
void setTrigType(int trigType)
const uint32_t * cispar() const
CIS parameters.
setEventNumber uint32_t

◆ initialize()

StatusCode TileDQstatusTool::initialize ( )
overridevirtual

Gaudi initialize method.

Definition at line 46 of file TileDQstatusTool.cxx.

47{
48 ATH_CHECK( detStore()->retrieve(m_tileHWID, "TileHWID") );
49
50 ATH_CHECK( m_badChannelsKey.initialize() );
51
52 if (m_simulateTrips) {
53 ATH_CHECK( m_athRNGSvc.retrieve() );
54 }
55
56 return StatusCode::SUCCESS;
57}
#define ATH_CHECK
Evaluate an expression and check for errors.
SG::ReadCondHandleKey< TileBadChannels > m_badChannelsKey
Name of TileBadChannels in condition store.
Gaudi::Property< bool > m_simulateTrips
ServiceHandle< IAthRNGSvc > m_athRNGSvc

◆ makeStatus()

StatusCode TileDQstatusTool::makeStatus ( const EventContext & ctx,
const TileRawChannelContainer * rawChannelContainer,
const TileDigitsContainer * tileDigitsContainer,
const TileBeamElemContainer * tileBeamElemContainer,
TileDQstatus & dqstatus ) const
overridevirtual

Make a new TileDQstatus object.

Parameters
ctxEvent context.
rawChannelContainerThe TileRawChannelContainer (may be null).
tileDigitsContainerThe TileDigitsContainer (may be null).
tileBeamElemContainerThe TileBeamElemContainer (may be null).
[out]dqstatusTileDQstatus object to fill.

Definition at line 69 of file TileDQstatusTool.cxx.

74{
75 dqstatus.setAllGood();
76 dqstatus.setRODBCID (ctx.eventID().bunch_crossing_id());
77
78 SG::ReadCondHandle<TileBadChannels> badChannels(m_badChannelsKey, ctx);
79 ATH_CHECK( badChannels.isValid() );
80
81 ATH_CHECK( doBeamElem (tileBeamElemContainer, dqstatus) );
82
83 if (rawChannelContainer != nullptr) {
84 if (tileDigitsContainer != nullptr) {
85 bool isCalib = false;
86 bool incomplete = false;
87 for (const TileDigitsCollection* coll : *tileDigitsContainer) {
88 incomplete |= (coll->size() < 48);
89
90 if (coll->size() > 0) {
91 int dsize = (*(coll->begin()))->NtimeSamples();
92 if (4 < dsize && dsize < 15) { // don't use strange fragments
93 isCalib |= coll->isCalibMode();
94 }
95 }
96
97 int frag = coll->identify();
98 int partition = (frag >> 8);
99 int drawer = (frag & 0x3F);
100
101 std::vector < uint32_t > data = coll->getFragChipHeaderWords();
102 unsigned int dataSize = std::min(16u, (unsigned int) data.size());
103 for (unsigned int dmu = 0; dmu < dataSize; ++dmu) {
104 if (data[dmu] == 0xFFFFFFFF)
105 dqstatus.setEmptyEvent(partition, drawer, dmu, 0, 1);
106 }
107
108 data = coll->getFragChipHeaderWordsHigh();
109 dataSize = std::min(16u, (unsigned int) data.size());
110 for (unsigned int dmu = 0; dmu < dataSize; ++dmu) {
111 if (data[dmu] == 0xFFFFFFFF)
112 dqstatus.setEmptyEvent(partition, drawer, dmu, 1, 1);
113 }
114 }
115 dqstatus.setIncompleteDigits (incomplete);
116 dqstatus.setCalibMode (isCalib);
117 dqstatus.setBiGain (isCalib);
118 }
119
120 TileFragHash::TYPE RChType = rawChannelContainer->get_type();
121 if (RChType != TileFragHash::OptFilterDsp
123 {
124 ATH_MSG_DEBUG("RawChannelContainer didn't come from BS - don't check DQ flags");
125 ATH_MSG_DEBUG("RChType = " << RChType);
126 } else {
127 for (const TileRawChannelCollection *coll : *rawChannelContainer) {
128
129 int frag = coll->identify();
130 ATH_MSG_VERBOSE("RCh collection 0x" << MSG::hex << frag << MSG::dec
131 << " size=" << coll->size());
132
133 unsigned short existingDMUs = 0xFFFF;
134 if (frag > 0x2ff) { // do not count non-existing DMUs in EB
135 // do not count non-existing DMUs in EBA15 or EBC18
136 existingDMUs = (frag == 0x30E || frag == 0x411) ? 0x3CFE : 0x3CFF;
137 }
138
139 unsigned short wrongBCID(0);
140 unsigned short fragBCID = coll->getFragBCID();
141 if (fragBCID & existingDMUs) {
142
143 int drawer = (frag & 0x3F); // range 0-63
144 int ros = frag >> 8; // range 1-4
145
146 for (unsigned int channel = 0; channel < TileCalibUtils::MAX_CHAN; ++channel) {
147 HWIdentifier channel_id = m_tileHWID->channel_id(ros, drawer, channel);
148 if (badChannels->getChannelStatus(channel_id).isWrongBCID()) {
149 int dmu = channel / 3;
150 if (dmu == 1) {
151 // If BCID in 2nd DMU is wrong then there is no sence
152 // to check BCID in other DMUs because they are compared with this one.
153 // So it is assumed that BCID in all DMU are wrong.
154 wrongBCID = 0xFFFF & existingDMUs;
155 break;
156 }
157
158 wrongBCID |= (1U << dmu);
159 }
160 }
161
162 fragBCID &= ~wrongBCID;
163 }
164
165 dqstatus.fillArrays(coll, tileDigitsContainer, 0, fragBCID);
166 dqstatus.fillArrays(coll, tileDigitsContainer, 1, fragBCID);
167 }
168 if (dqstatus.nonZeroCounter() == 0) {
169 ATH_MSG_DEBUG("all DQ elements are empty - don't check DQ flags");
170 dqstatus.setAllGood();
171 } else {
172 ATH_MSG_DEBUG("BiGain mode: " << ((dqstatus.isBiGain()) ? "true" : "false"));
173 }
174 }
175 } else if (tileDigitsContainer != nullptr) {
176 bool isCalib = false;
177 bool incomplete = false;
178 for (const TileDigitsCollection* coll : *tileDigitsContainer) {
179 incomplete |= (coll->size() < 48);
180
181 if (coll->size() > 0) {
182 int dsize = (*(coll->begin()))->NtimeSamples();
183 if (4 < dsize && dsize < 15) { // don't use strange fragments
184 isCalib |= coll->isCalibMode();
185 }
186 }
187 }
188 dqstatus.setIncompleteDigits (incomplete);
189 dqstatus.setCalibMode (isCalib);
190 dqstatus.setBiGain (isCalib);
191 }
192
193 if (m_simulateTrips) {
194 ATHRNG::RNGWrapper* wrapper = m_athRNGSvc->getEngine (this, this->name());
195 wrapper->setSeed (this->name(), ctx);
196 CLHEP::HepRandomEngine* engine = wrapper->getEngine (ctx);
197 double rndmVec[TileCalibUtils::MAX_DRAWER];
198 const std::vector<float> defaultTripsProbs(TileCalibUtils::MAX_DRAWER, 0.0F);
199 const std::vector<std::vector<float>>& tripsProbs = badChannels->getTripsProbabilities();
200 for (unsigned int partition = 1; partition < TileCalibUtils::MAX_ROS; ++partition) {
201 CLHEP::RandFlat::shootArray (engine, TileCalibUtils::MAX_DRAWER, rndmVec);
202 const std::vector<float>& trips = tripsProbs.size() ? tripsProbs.at(partition - 1) : defaultTripsProbs;
203 dqstatus.fillTrips(partition, trips, rndmVec, this->msg());
204 }
205 }
206
207 dqstatus.setFilled (true);
208 return StatusCode::SUCCESS;
209}
#define ATH_MSG_DEBUG(x)
bool isCalib()
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition RNGWrapper.h:154
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:108
static const unsigned int MAX_ROS
Number of ROSs.
static const unsigned int MAX_DRAWER
Number of drawers in ROS 1-4.
static const unsigned int MAX_CHAN
Number of channels in drawer.
StatusCode doBeamElem(const TileBeamElemContainer *tileBeamElemContainer, TileDQstatus &dqstatus) const
Process BeamElemContainer.
void fillArrays(const TileRawChannelCollection *coll, const TileDigitsContainer *digitsCnt, int gain, unsigned short fragBCID)
parses DQ fragments and fill error arrays for event
bool nonZeroCounter() const
returns True if there are any errors in event
void setCalibMode(uint32_t calibMode)
void setFilled(bool filled)
sets flag that DQ status instance has been filled for this event
void setBiGain(bool biGain)
sets flag of gain mode of run
void fillTrips(unsigned int partition, const std::vector< float > &trips, double *rndmVec, MsgStream &msg)
void setIncompleteDigits(bool incomplete)
void setEmptyEvent(int partition, int drawer, int dmu, int gain, int isEmpty)
sets flag that DMU sent an empty event (0xFFFFFFFF)
bool isBiGain() const
returns gain mode of run
void setAllGood()
mark all channels/ADC's as DQ good
TYPE
initialize
constexpr size_t dataSize(TDA::PayloadIterator start)
Size in bytes of the buffer that is needed to decode next fragment data content.
MsgStream & msg
Definition testRead.cxx:32

Member Data Documentation

◆ m_athRNGSvc

ServiceHandle<IAthRNGSvc> TileDQstatusTool::m_athRNGSvc {this, "AthRNGSvc", "AthRNGSvc", "Random number service"}
private

Definition at line 78 of file TileDQstatusTool.h.

79{this, "AthRNGSvc", "AthRNGSvc", "Random number service"};

◆ m_badChannelsKey

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

Name of TileBadChannels in condition store.

Definition at line 84 of file TileDQstatusTool.h.

84 {this,
85 "TileBadChannels", "TileBadChannels", "Input Tile bad channel status"};

◆ m_simulateTrips

Gaudi::Property<bool> TileDQstatusTool::m_simulateTrips {this, "SimulateTrips", false, "Simulate drawer trips (default=false)"}
private

Definition at line 75 of file TileDQstatusTool.h.

76{this, "SimulateTrips", false, "Simulate drawer trips (default=false)"};

◆ m_tileHWID

const TileHWID* TileDQstatusTool::m_tileHWID = nullptr
private

Tile ID helper.

Definition at line 88 of file TileDQstatusTool.h.


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