43 {
45 LArDigitContainer* digits=nullptr;
46 LArFebHeaderContainer* febHeaders=nullptr;
47
49 SG::WriteHandle<LArRawChannelContainer> rawChannelsHdl(
m_rawChannelKey,ctx);
50 ATH_CHECK(rawChannelsHdl.record(std::make_unique<LArRawChannelContainer>()));
51 rawChannels=rawChannelsHdl.ptr();
52 rawChannels->reserve(182468);
53 }
54
56 SG::WriteHandle<LArDigitContainer> digitsHdl(
m_digitKey,ctx);
57 ATH_CHECK(digitsHdl.record(std::make_unique<LArDigitContainer>()));
58 digits=digitsHdl.ptr();
60 }
61
63 SG::WriteHandle<LArFebHeaderContainer> febHeadersHdl(
m_febHeaderKey,ctx);
64 ATH_CHECK(febHeadersHdl.record(std::make_unique<LArFebHeaderContainer>()));
65 febHeaders=febHeadersHdl.ptr();
67 }
68
69
71 std::map<eformat::SubDetectorGroup, std::vector<const uint32_t*> > rawEventTOC;
72 eformat::helper::build_toc(*fullEvent, rawEventTOC);
73 auto larRobs=rawEventTOC.find(eformat::LAR);
74 if (larRobs==rawEventTOC.end()) {
75 ATH_MSG_DEBUG(
"No LAr data found in this event. Recording empty LArRawChannelContainer");
76 return StatusCode::SUCCESS;
77 }
78
79
80 std::unique_ptr<LArRodBlockStructure> rodBlock;
83
84
85 for (const uint32_t* robPtr : larRobs->second) {
87 ATH_MSG_VERBOSE(
"Decoding ROB fragment 0x" << std::hex << rob.rob_source_id () <<
" with " << std::dec << rob.rod_fragment_size_word() <<
" ROB words");
88
89 if (rob.rod_fragment_size_word() <3) {
91 ATH_MSG_ERROR(
"Encountered corrupt ROD fragment, less than 3 words!");
92 return StatusCode::FAILURE;
93 }else {
94 continue;
95 }
96 } else if(rob.rob_source_id()& 0x1000 ){
97
98 rodBlock=nullptr;
99 continue;
100 } else if(!(rob.rod_source_id()>>12& 0x0F)
101 && !((rob.rod_source_id()>>20) == 4) ){
102
103 ATH_MSG_WARNING(
"Found not LAr fragment " <<
" event: "<<ctx.eventID().event_number());
105 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());
106 continue;
107 }
108
109
110 eformat::helper::Version
ver(rob.rod_version());
111
112 if (rodBlock==
nullptr || rodMinorVersion !=
ver.minor_version() || rodBlockType!=(rob.rod_detev_type()&0xff)) {
113 rodMinorVersion=
ver.minor_version();
114 rodBlockType=rob.rod_detev_type()&0xff;
115 ATH_MSG_VERBOSE(
"Found version " << rodMinorVersion <<
" of Rod Block Type " << rodBlockType);
116 if (rodBlockType==4) {
117 switch(rodMinorVersion) {
118 case 12:
119 rodBlock.reset(new LArRodBlockPhysicsV6);
120 break;
121 case 11:
122 case 10:
123 rodBlock.reset(new LArRodBlockPhysicsV5);
124 break;
125 default:
127 ATH_MSG_ERROR(
"Found unsupported ROD Block version " << rodMinorVersion
128 << " of ROD block type " << rodBlockType << ". ROD Source id: 0x" <<std::hex<<rob.rod_source_id());
129 return StatusCode::FAILURE;
130 }
131 else {
132 ATH_MSG_WARNING(
"Found unsupported ROD Block version " << rodMinorVersion
133 << " of ROD block type " << rodBlockType << ". ROD Source id: 0x" <<std::hex<<rob.rod_source_id());
134 continue;
135 }
136 }
137 }
138 else if (rodBlockType==2) {
139 switch(rodMinorVersion) {
140 case 4:
141 rodBlock.reset(new LArRodBlockTransparentV0<LArRodBlockHeaderTransparentV0>);
142 break;
143 case 12:
144 rodBlock.reset(new LArRodBlockCalibrationV3);
145 break;
146 default:
147 ATH_MSG_WARNING(
"Found unsupported ROD Block version " << rodMinorVersion
148 << " of ROD block type " << rodBlockType);
150 }
151 }
152 }
153
154 const uint32_t* pData=rob.rod_data();
155 const uint32_t nData=rob.rod_ndata();
156 if (nData==0) {
158 ATH_MSG_ERROR(
"ROD 0x"<<std::hex<<rob.rod_source_id() << std::dec <<
" reports data block size 0");
159 return StatusCode::FAILURE;
160 }
161 else {
162 ATH_MSG_WARNING(
"ROD 0x"<<std::hex<<rob.rod_source_id() << std::dec <<
" reports data block size 0");
163 continue;
164 }
165 }
166
167 if (!rodBlock || !rodBlock->setFragment(pData,nData)) {
169 ATH_MSG_ERROR(
"Failed to assign fragment pointer to LArRodBlockStructure");
170 return StatusCode::FAILURE;
171 }
172 else {
173 ATH_MSG_WARNING(
"Failed to assign fragment pointer to LArRodBlockStructure");
174 continue;
175 }
176 }
177
179 const uint32_t onsum = rodBlock->onlineCheckSum();
180 const uint32_t offsum = rodBlock->offlineCheckSum();
181 if(onsum!=offsum) {
185 ATH_MSG_ERROR(
"offline checksum = 0x" << MSG::hex << offsum << MSG::dec);
186 return StatusCode::FAILURE;
187 } else {
188 continue;
189 }
190 }
191 }
192
193
194 do {
195 HWIdentifier fId(Identifier32(rodBlock->getFEBID()));
198 ATH_MSG_ERROR(
"Invalid FEB identifer 0x" << std::hex << fId.get_identifier32().get_compact());
199 return StatusCode::FAILURE;
200 } else {
201 ATH_MSG_WARNING(
"Invalid FEB identifer 0x" << std::hex << fId.get_identifier32().get_compact());
202 continue;
203 }
204 }
205 const int NthisFebChannel=
m_onlineId->channelInSlotMax(fId);
206
207
211 int32_t quality;
213 int fcNb;
214 while (rodBlock->getNextEnergy(fcNb,energy,time,quality,gain)) {
215 if (fcNb>=NthisFebChannel)
216 continue;
217
218 HWIdentifier cId =
m_onlineId->channel_Id(fId,fcNb);
221 if (quality>0) {
223 iquality = (quality & 0xFFFF);
224 }
225 rawChannels->emplace_back(cId, energy, time, iquality, iprovenance, (
CaloGain::CaloGain)gain);
226 }
227 }
228
229
232 int fcNb;
233 std::vector<short> samples;
234 while (rodBlock->getNextRawData(fcNb,samples,gain)) {
235 if (fcNb>=NthisFebChannel)
236 continue;
237 if (samples.size()==0) continue;
238 HWIdentifier cId =
m_onlineId->channel_Id(fId,fcNb);
240 samples.clear();
241 }
242 }
243
244
246 std::unique_ptr<LArFebHeader> larFebHeader(new LArFebHeader(fId));
248 febHeaders->
push_back(std::move(larFebHeader));
249 }
250
251 }while (rodBlock->nextFEB());
252 }
253 return StatusCode::SUCCESS;
254}
#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.
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
time(flags, cells_name, *args, **kw)
eformat::ROBFragment< PointerType > ROBFragment