124 {
126 LArDigitContainer* digits=nullptr;
127 LArFebHeaderContainer* febHeaders=nullptr;
128
130 SG::WriteHandle<LArRawChannelContainer> rawChannelsHdl(
m_rawChannelKey,ctx);
131 ATH_CHECK(rawChannelsHdl.record(std::make_unique<LArRawChannelContainer>()));
132 rawChannels=rawChannelsHdl.ptr();
133 rawChannels->reserve(182468);
134 }
135
137 SG::WriteHandle<LArDigitContainer> digitsHdl(
m_digitKey,ctx);
138 ATH_CHECK(digitsHdl.record(std::make_unique<LArDigitContainer>()));
139 digits=digitsHdl.ptr();
141 }
142
144 SG::WriteHandle<LArFebHeaderContainer> febHeadersHdl(
m_febHeaderKey,ctx);
145 ATH_CHECK(febHeadersHdl.record(std::make_unique<LArFebHeaderContainer>()));
146 febHeaders=febHeadersHdl.ptr();
148 }
149
150
152 std::map<eformat::SubDetectorGroup, std::vector<const uint32_t*> > rawEventTOC;
153 eformat::helper::build_toc(*fullEvent, rawEventTOC);
154 auto larRobs=rawEventTOC.find(eformat::LAR);
155 if (larRobs==rawEventTOC.end()) {
156 ATH_MSG_DEBUG(
"No LAr data found in this event. Recording empty LArRawChannelContainer");
157 return StatusCode::SUCCESS;
158 }
159
160
161 std::unique_ptr<LArRodBlockStructure> rodBlock;
164
165
166 for (const uint32_t* robPtr : larRobs->second) {
168 ATH_MSG_VERBOSE(
"Decoding ROB fragment 0x" << std::hex << rob.rob_source_id () <<
" with " << std::dec << rob.rod_fragment_size_word() <<
" ROB words");
169
170 if (rob.rod_fragment_size_word() <3) {
172 ATH_MSG_ERROR(
"Encountered corrupt ROD fragment, less than 3 words!");
173 return StatusCode::FAILURE;
174 }else {
175 continue;
176 }
177 } else if(rob.rob_source_id()& 0x1000 ){
178
179 rodBlock=nullptr;
180 continue;
181 } else if(!(rob.rod_source_id()>>12& 0x0F)
182 && !((rob.rod_source_id()>>20) == 4) ){
183
184 ATH_MSG_WARNING(
"Found not LAr fragment " <<
" event: "<<ctx.eventID().event_number());
186 ATH_MSG_WARNING(
"Rob source id.: 0x"<< std::hex << rob.rob_source_id () <<std::dec <<
" ROD Source id: 0x"<<std::hex<<rob.rod_source_id()<<std::dec<<
" Lvl1ID: "<<eventInfo->extendedLevel1ID());
187 continue;
188 }
189
190
191 eformat::helper::Version
ver(rob.rod_version());
192
193 if (rodBlock==
nullptr || rodMinorVersion !=
ver.minor_version() || rodBlockType!=(rob.rod_detev_type()&0xff)) {
194 rodMinorVersion=
ver.minor_version();
195 rodBlockType=rob.rod_detev_type()&0xff;
196 ATH_MSG_VERBOSE(
"Found version " << rodMinorVersion <<
" of Rod Block Type " << rodBlockType);
197 if (rodBlockType==4) {
198 switch(rodMinorVersion) {
199 case 12:
200 rodBlock.reset(
new LArRodBlockPhysicsV6 (this->
msgSvc().
get()));
201 break;
202 case 11:
203 case 10:
204 rodBlock.reset(
new LArRodBlockPhysicsV5 (this->
msgSvc().
get()));
205 break;
206 default:
208 ATH_MSG_ERROR(
"Found unsupported ROD Block version " << rodMinorVersion
209 << " of ROD block type " << rodBlockType << ". ROD Source id: 0x" <<std::hex<<rob.rod_source_id());
210 return StatusCode::FAILURE;
211 }
212 else {
213 ATH_MSG_WARNING(
"Found unsupported ROD Block version " << rodMinorVersion
214 << " of ROD block type " << rodBlockType << ". ROD Source id: 0x" <<std::hex<<rob.rod_source_id());
215 continue;
216 }
217 }
218 }
219 else if (rodBlockType==2) {
220 switch(rodMinorVersion) {
221 case 4:
222 rodBlock.reset(
new LArRodBlockTransparentV0<LArRodBlockHeaderTransparentV0> (this->
msgSvc().
get()));
223 break;
224 case 12:
225 rodBlock.reset(
new LArRodBlockCalibrationV3 (this->
msgSvc().
get()));
226 break;
227 default:
228 ATH_MSG_WARNING(
"Found unsupported ROD Block version " << rodMinorVersion
229 << " of ROD block type " << rodBlockType);
231 }
232 }
233 }
234
235 const uint32_t* pData=rob.rod_data();
236 const uint32_t nData=rob.rod_ndata();
237 if (nData==0) {
239 ATH_MSG_ERROR(
"ROD 0x"<<std::hex<<rob.rod_source_id() << std::dec <<
" reports data block size 0");
240 return StatusCode::FAILURE;
241 }
242 else {
243 ATH_MSG_WARNING(
"ROD 0x"<<std::hex<<rob.rod_source_id() << std::dec <<
" reports data block size 0");
244 continue;
245 }
246 }
247
248 if (!rodBlock || !rodBlock->setFragment(pData,nData)) {
250 ATH_MSG_ERROR(
"Failed to assign fragment pointer to LArRodBlockStructure");
251 return StatusCode::FAILURE;
252 }
253 else {
254 ATH_MSG_WARNING(
"Failed to assign fragment pointer to LArRodBlockStructure");
255 continue;
256 }
257 }
258
260 const uint32_t onsum = rodBlock->onlineCheckSum();
261 const uint32_t offsum = rodBlock->offlineCheckSum();
262 if(onsum!=offsum) {
266 ATH_MSG_ERROR(
"offline checksum = 0x" << MSG::hex << offsum << MSG::dec);
267 return StatusCode::FAILURE;
268 } else {
269 continue;
270 }
271 }
272 }
273
274
275 do {
276 HWIdentifier fId(Identifier32(rodBlock->getFEBID()));
279 ATH_MSG_ERROR(
"Invalid FEB identifer 0x" << std::hex << fId.get_identifier32().get_compact());
280 return StatusCode::FAILURE;
281 } else {
282 ATH_MSG_WARNING(
"Invalid FEB identifer 0x" << std::hex << fId.get_identifier32().get_compact());
283 continue;
284 }
285 }
286
288 const auto ftId=
m_onlineId->feedthrough_Id(fId);
290 ATH_MSG_DEBUG(
"Feedthrough with id " << MSG::hex << ftId << MSG::dec <<
" not in preselection. Ignored.");
291 continue;
292 } else {
293 ATH_MSG_DEBUG(
"Feedthrough with id " << MSG::hex << ftId << MSG::dec <<
" is preselected.");
294 }
295 }
296
297 const int NthisFebChannel=
m_onlineId->channelInSlotMax(fId);
298
299
303 int32_t quality;
305 int fcNb;
306 while (rodBlock->getNextEnergy(fcNb,energy,time,quality,gain)) {
307 if (fcNb>=NthisFebChannel)
308 continue;
309
310 HWIdentifier cId =
m_onlineId->channel_Id(fId,fcNb);
313 if (quality>0) {
315 iquality = (quality & 0xFFFF);
316 }
317 rawChannels->emplace_back(cId, energy, time, iquality, iprovenance, (
CaloGain::CaloGain)gain);
318 }
319 }
320
321
324 int fcNb;
325 std::vector<short> samples;
326 while (rodBlock->getNextRawData(fcNb,samples,gain)) {
327 if (fcNb>=NthisFebChannel)
328 continue;
329 if (samples.size()==0) continue;
330 HWIdentifier cId =
m_onlineId->channel_Id(fId,fcNb);
332 samples.clear();
333 }
334 }
335
336
338 std::unique_ptr<LArFebHeader> larFebHeader(new LArFebHeader(fId));
340 febHeaders->
push_back(std::move(larFebHeader));
341 }
342
343 }while (rodBlock->nextFEB());
344 }
345 return StatusCode::SUCCESS;
346}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Old LArRawChannelContainer
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
value_type emplace_back(value_type pElem)
Add an element to the end of the collection.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
std::set< HWIdentifier > m_vFinalPreselection
BooleanProperty m_failOnCorruption
SG::WriteHandleKey< LArRawChannelContainer > m_rawChannelKey
const LArOnlineID * m_onlineId
ServiceHandle< IROBDataProviderSvc > m_robDataProviderSvc
SG::WriteHandleKey< LArFebHeaderContainer > m_febHeaderKey
BooleanProperty m_verifyChecksum
SG::WriteHandleKey< LArDigitContainer > m_digitKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
time(flags, cells_name, *args, **kw)
eformat::ROBFragment< PointerType > ROBFragment