SPU number for this RDO there 10 SPU - Sparsifier Processing Units, one for each gas layer, except for the non-precision strips where all the layers map to one SPU
find the online address - one per plane for the non-precision strips, the 4 planes all go into one RPU
there 10 SPU - Sparsifier Processing Units, one for each gas layer, except for the non-precision strips where all the layers map to one SPU note that the "-50" is because stationName = 50 (CSS) or 51 (CSL)
74 {
76
77
78
79
80 ATHRNG::RNGWrapper* rngWrapper =
m_rndmSvc->getEngine(
this);
81 rngWrapper->
setSeed(
name(), Gaudi::Hive::currentContext());
82 CLHEP::HepRandomEngine* rndmEngine = *rngWrapper;
83
85
86
87
89 rodReadOut.setChamberBitVaue(1);
90
92 ATH_CHECK(rdoContainer.record(std::make_unique<CscRawDataContainer>()));
93
96
98 typedef CscDigitContainer::const_iterator collection_iterator;
100
103
105 collection_iterator it_coll = container->begin();
106 collection_iterator it_coll_e = container->end();
107
108 for (; it_coll != it_coll_e; ++it_coll) {
109 const CscDigitCollection* cscCollection = *it_coll;
110
112 int oldLayer = 0;
113
116
119
121 std::vector<uint16_t> samples;
122 samples.clear();
123
125 IdentifierHash cscRawDataOfflineHashId;
126
131
133 digit_iterator it_dig = cscCollection->
begin();
134 digit_iterator it_dig_e = cscCollection->
end();
135
137 int oldStrip = -1;
138 unsigned int count = 0;
139 unsigned int size = cscCollection->
size();
140
141 for (; it_dig != it_dig_e; ++it_dig) {
142 const CscDigit* cscDigit = *it_dig;
143
145
147
148
149
150 Identifier offlineChannelId = cscDigit->
identify();
151 IdentifierHash cscOfflineChannelHashId;
152 IdContext cscContext =
m_idHelperSvc->cscIdHelper().channel_context();
153 if (!
m_idHelperSvc->cscIdHelper().get_hash(offlineChannelId, cscOfflineChannelHashId, &cscContext)) {
155 << cscOfflineChannelHashId << " for "
156 <<
m_idHelperSvc->cscIdHelper().show_to_string(offlineChannelId, &cscContext));
157 }
158
159 int currentStrip =
m_idHelperSvc->cscIdHelper().strip(offlineChannelId);
160
162 int currentLayer =
m_idHelperSvc->cscIdHelper().wireLayer(offlineChannelId);
163 int measuresPhi =
m_idHelperSvc->cscIdHelper().measuresPhi(offlineChannelId);
166 int stationId =
m_idHelperSvc->cscIdHelper().stationName(offlineChannelId);
167 uint16_t subDetectorId = (
eta == -1) ? 0x6A : 0x69;
170 if (stationId == 0x32) rodId = (0x10 | (
phi - 1));
171 if (stationId == 0x33) rodId = (0x18 | (
phi - 1));
172 } else {
174 }
176
177 if (IsNewEDM) {
181 }
182 } else {
183 double flat = CLHEP::RandFlat::shoot(rndmEngine, 0.0, 1.0);
185 }
186
189 bool sparsified = true;
192 bool enableCal = false;
193
195 ((
neutron & 1) << 23) | ((calAmplitude & 0x3f) << 24) | ((enableCal & 1) << 30) |
197
199
202
205
206
207
208
209 if (currentStrip != (oldStrip + 1) || currentLayer != oldLayer) {
210 if (currentLayer != oldLayer) oldLayer = currentLayer;
211
214 int mphi = ((address & 0x00000100) >> 8);
215 int zEta = (((address & 0x00001000) >> 12) == 0x0) ? -1 : 1;
216
217 if (zEta > 0 && mphi == 1) {
218 int istat = ((address & 0x00010000) >> 16) + 50;
219 int phisector = ((address & 0x0000E000) >> 13) + 1;
220 int chamLayer = ((address & 0x00000800) >> 11) + 1;
221 int wlayer = ((address & 0x00000600) >> 9) + 1;
222
223 int beforestrip = (address & 0x000000FF) + 1;
224 int afterstrip = beforestrip -
width + 1;
225
226 Identifier newOnlineChannelId =
227 m_idHelperSvc->cscIdHelper().channelID(istat, zEta, phisector, chamLayer, wlayer, mphi, afterstrip);
228 address = rodReadOut.address(newOnlineChannelId, zEta, phisector);
229 }
230
231 ATH_MSG_DEBUG(
"At Creation of CscRawData, SPU ID = " << spuID);
236 }
237
243 if (measuresPhi == 0)
245 else
248
249
250
251
252 Identifier onlineChannelId = offlineChannelId;
253 if (
eta > 0 && measuresPhi == 1) {
254 int chamberLayer =
m_idHelperSvc->cscIdHelper().chamberLayer(offlineChannelId);
255 int strip = 49 - currentStrip;
256
257 onlineChannelId =
259 }
260
262 address = rodReadOut.address(onlineChannelId,
eta,
phi);
263
265 IdContext cscContext =
m_idHelperSvc->cscIdHelper().channel_context();
266 if (!
m_idHelperSvc->cscIdHelper().get_hash(offlineChannelId, cscRawDataOfflineHashId, &cscContext)) {
267 ATH_MSG_DEBUG(
"HashId off CscRawData (still offline hashId) is "
268 << cscRawDataOfflineHashId << " for "
269 <<
m_idHelperSvc->cscIdHelper().show_to_string(offlineChannelId, &cscContext));
270 }
271
274 samples.clear();
275 }
276
280
281 int zsec =
m_idHelperSvc->cscIdHelper().stationEta(offlineChannelId);
282 int phisec =
m_idHelperSvc->cscIdHelper().stationPhi(offlineChannelId);
283 int istation =
m_idHelperSvc->cscIdHelper().stationName(offlineChannelId) - 49;
284 int sector = zsec * (2 * phisec - istation + 1);
285 int wlay =
m_idHelperSvc->cscIdHelper().wireLayer(offlineChannelId);
286 int measphi =
m_idHelperSvc->cscIdHelper().measuresPhi(offlineChannelId);
287 int istrip =
m_idHelperSvc->cscIdHelper().strip(offlineChannelId);
288
289
290
291 double noiseADC =
m_cscCalibTool->stripNoise(cscOfflineChannelHashId,
false);
292
293 double pedestalADC =
m_cscCalibTool->stripPedestal(cscOfflineChannelHashId,
false);
294 double phaseOffset = (cscRdoCollection->
samplingPhase()) ? 25 : 0;
295
296 if (IsNewEDM) {
297 std::vector<float> cscDigitSamples = cscDigit->
sampleCharges();
298
300
301 double theNoise = (
m_addNoise) ? CLHEP::RandGaussZiggurat::shoot(rndmEngine, 0.0, noiseADC) : 0.0;
302 double rawAmpl = cscDigitSamples[
i];
303 double ampl = rawAmpl;
304 double charge_to_adcCount =
305 m_cscCalibTool->numberOfElectronsToADCCount(cscOfflineChannelHashId, ampl) + theNoise + pedestalADC;
306
308 if (charge_to_adcCount < 0) charge_to_adcCount = 0;
309
311
312 samples.push_back(adcCount);
313
315
316 << " charge to ADC = "
317 << charge_to_adcCount
318
319 << " raw amplitude (double) = " << rawAmpl << " theNoise (ADC) = " << theNoise);
320 }
321 } else {
322 double charge_to_adcCount =
m_cscCalibTool->numberOfElectronsToADCCount(cscOfflineChannelHashId, cscDigit->
charge());
323
324
326
329 double theNoise = (
m_addNoise) ? CLHEP::RandGaussZiggurat::shoot(rndmEngine, 0.0, noiseADC) : 0.0;
330 double rawAmpl = rodReadOut.signal_amplitude(samplingTime);
331 double ampl = charge_to_adcCount * rawAmpl + theNoise + pedestalADC;
332
334
336
337 samples.push_back(adcCount);
338
339 ATH_MSG_DEBUG(
"amplitude :: index = " << (i + 1) <<
" sampling time (ns) = " << samplingTime
340 << " charge to ADC (double) = " << charge_to_adcCount
341 << " amplitude (double) = " << ampl << " raw amplitude (double) = " << rawAmpl
342 << " theNoise (double) = " << theNoise);
343 }
344
345 }
346
347 ATH_MSG_DEBUG(
"CSC Digit zsec:phisec:station:sector:measphi:wlay:istrip:charge "
348 << zsec << " " << phisec << " " << istation << " " << sector << " " << measphi << " " << wlay << " " << istrip
349 << " " << samples[0] << " " << samples[1] << " " << samples[2] << " " << samples[3] << " ");
350
353 oldStrip = currentStrip;
354
356
358 ATH_MSG_DEBUG(
"End of DigitCollection : SPU ID = " << spuID);
360 if (spuID <= 4)
361 rpuID = 5;
362 else if (spuID > 4 && spuID <= 9)
363 rpuID = 11;
364 else
366 cscRdoCollection->
addRPU(rpuID);
369
370 int mphi = ((address & 0x00000100) >> 8);
371 int zEta = (((address & 0x00001000) >> 12) == 0x0) ? -1 : 1;
372
373 if (zEta > 0 && mphi == 1) {
374 int istat = ((address & 0x00010000) >> 16) + 50;
375 int phisector = ((address & 0x0000E000) >> 13) + 1;
376 int chamLayer = ((address & 0x00000800) >> 11) + 1;
377 int wlayer = ((address & 0x00000600) >> 9) + 1;
378
379 int beforestrip = (address & 0x000000FF) + 1;
380 int afterstrip = beforestrip -
width + 1;
381
382 Identifier newOnlineChannelId =
383 m_idHelperSvc->cscIdHelper().channelID(istat, zEta, phisector, chamLayer, wlayer, mphi, afterstrip);
384 address = rodReadOut.address(newOnlineChannelId, zEta, phisector);
385 }
386
392 }
393
394 }
395 }
396
399 std::map<uint16_t, CscRawDataCollection*>::iterator itM =
m_cscRdoMap.begin();
400 std::map<uint16_t, CscRawDataCollection*>::iterator itM_e =
m_cscRdoMap.end();
401 for (; itM != itM_e; ++itM) {
403 uint16_t clusterCounts[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
406 for (; itD != itD_e; ++itD) {
408 clusterCounts[spuID] += 1;
409 }
410 for (
unsigned int i = 0;
i < 10; ++
i) (itM->second)->set_spuCount(i, clusterCounts[i]);
411
413 ATH_CHECK(rdoContainer->addCollection(itM->second, itM->first));
414 }
416
417 return StatusCode::SUCCESS;
418}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
bool samplingPhase() const
int charge() const
Return the charge.
const std::vector< float > & sampleCharges() const
float time() const
return the time
bool samplingPhase() const
void set_eventType(const uint32_t eventType)
void addDataType(const uint8_t dataType)
uint16_t identify() const
access methods
void addRPU(const uint16_t rpuID)
void setHashID(uint32_t hash)
DataModel_detail::const_iterator< DataVector > const_iterator
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
Identifier identify() const
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
@ neutron
for Fatras usage