69 {
70 ATH_MSG_DEBUG(
"AFP_ByteStream2RawCnv::fillColelction rob_source_id: in decimal="<<std::dec<<robFrag->rob_source_id()<<
", in hex=0x"<<std::hex<<robFrag->rob_source_id()<<std::dec);
71
72 try {
73 robFrag->check();
74 } catch (...) {
76 return StatusCode::SUCCESS;
77 }
78
79 const uint32_t nStat = robFrag->nstatus();
80 if (nStat) {
82 robFrag->status(it);
83 if (*it) {
85 return StatusCode::SUCCESS;
86 }
87 }
88
89 if (!rawContainer) {
91 return StatusCode::SUCCESS;
92 }
93
94
95
97 robFrag->rod_data(vint);
98
99 if (robFrag->rod_nstatus() <= 0) {
101 return StatusCode::SUCCESS;
102 }
103
104 const eformat::FullEventFragment<const uint32_t*> *
event =
m_robDataProvider->getEvent(Gaudi::Hive::currentContext());
105
106
107
108
109 if (event) {
110
116 }
117
118
119
122
123 std::vector<std::vector<uint16_t>> picoTDC1_channels, picoTDC2_channels;
124 std::vector<bool> picoTDC_hasTrigger;
125 std::vector<int> ToF_links;
126
127 const uint32_t size = robFrag->rod_ndata();
128 for (
unsigned i = 0;
i < size;
i++) {
131
133 AFP_RawCollectionHead* collectionHead = nullptr;
135
137 rawContainer);
138 collectionHead = collectionToF;
139
140
141 picoTDC1_channels.emplace_back();
142 picoTDC2_channels.emplace_back();
143 picoTDC_hasTrigger.push_back(false);
144 ToF_links.push_back(the_link);
145 }
147
149 rawContainer);
150 collectionHead = collectionSi;
151 }
152 else {
153 ATH_MSG_ERROR(
"Unidentified value of link="<<the_link<<
" for header record.");
154 return StatusCode::FAILURE;
155 }
156
157 if (!collectionHead) {
159 << the_link << ", robID = " << robFrag->rob_source_id() <<")");
160 return StatusCode::SUCCESS;
161 }
162
163
165 collectionHead->
setLink(the_link);
168 collectionHead->
setRobId(robFrag->rob_source_id());
169 }
171
173
174
175 if ( !collectionToF ) {
177 return StatusCode::SUCCESS;
178 }
179
181 if(!bit23)
182 {
183
185 if(bits22_21==2)
186 {
187
194
196 }
197 else
198 {
199 ATH_MSG_DEBUG(
"This is not a ToF measurement, bit23 = "<<bit23<<
", bits22_21 "<<bits22_21<<
", ignoring word = "<<the_word);
200 }
201 }
202 else
203 {
204
205
207
208 if(bits19_22==0 || bits19_22==1)
209 {
210
212
213
214 auto ToFData_itr=std::find_if( collectionToF->
begin(), collectionToF->
end(),
215 [&](
const AFP_ToFRawData& entry){return entry.channel()==channel;});
216
217 if(ToFData_itr==collectionToF->
end())
218 {
219
221
228
229 ToFData_itr = std::prev(collectionToF->
end());
230 }
231
232 if(!bits19_22)
233 {
234
235 if(ToFData_itr->time() !=0 )
236 {
237 ATH_MSG_WARNING(
"trying to set time to "<<
m_wordReadout->getBits(the_word, 12, 0)<<
", but it is already set to = "<<ToFData_itr->time()<<
", will not overwrite");
238 }
239 else
240 {
241 ToFData_itr->setTime(
m_wordReadout->getBits(the_word, 12, 0) );
242 picoTDC1_channels.back().push_back(channel);
243 }
244 }
245 else
246 {
247
248 if(ToFData_itr->pulseLength() !=0 )
249 {
250 ATH_MSG_WARNING(
"trying to set pulseLength to "<<
m_wordReadout->getBits(the_word, 12, 0)<<
", but it is already set to = "<<ToFData_itr->pulseLength()<<
", will not overwrite");
251 }
252 else
253 {
254 ToFData_itr->setPulseLength(
m_wordReadout->getBits(the_word, 12, 0) );
255 picoTDC2_channels.back().push_back(channel);
256 }
257 }
258 }
259 else if(bits19_22==4)
260 {
261
262 auto ToFData_itr=std::find_if( collectionToF->
begin(), collectionToF->
end(),
264 if(ToFData_itr!=collectionToF->
end())
265 {
266
267 ATH_MSG_WARNING(
"already found a trigger word with delayedTrigger = "<<ToFData_itr->delayedTrigger()<<
" and triggerPattern = "<<ToFData_itr->triggerPattern()<<
", will ignore new word with delayedTrigger = "<<
m_wordReadout->getBits(the_word, 18,16)<<
" and triggerPattern = "<<
m_wordReadout->getBits(the_word, 15, 0));
268 }
269 else
270 {
271
273
279 picoTDC_hasTrigger.back()=true;
280 }
281 }
282 else
283 {
284 ATH_MSG_WARNING(
"unknown pattern in bits 19-22 = "<<bits19_22<<
", ignoring word = "<<the_word);
285 }
286 }
287 }
289
290
291
292 if ( !collectionSi ) {
293 ATH_MSG_WARNING(
"No silicon detector collection available to fill data.");
294 return StatusCode::SUCCESS;
295 }
296
297
303
305 }
306
307
313
315 }
316 }
317 else {
318 ATH_MSG_ERROR(
"Not recognised value of link="<<the_link<<
" for data record.");
319 return StatusCode::FAILURE;
320 }
321
322 }
323 }
324
325
326 for(
unsigned int i=0;
i<picoTDC1_channels.size();++
i)
327 {
328 if(!picoTDC1_channels.at(i).empty() || !picoTDC2_channels.at(i).empty())
329 {
330 for(auto ch1 : picoTDC1_channels.at(i))
331 {
332 if(std::find(picoTDC2_channels.at(i).begin(),picoTDC2_channels.at(i).end(),ch1) == picoTDC2_channels.at(i).end())
333 {
334 ATH_MSG_WARNING(
"Cannot find channel "<<ch1<<
" from picoTDC #1 in picoTDC #2 in ToF collections with link nr. "<<ToF_links.at(i)<<
", pulseLength is very probably not set");
335 }
336 }
337 for(auto ch2 : picoTDC2_channels.at(i))
338 {
339 if(std::find(picoTDC1_channels.at(i).begin(),picoTDC1_channels.at(i).end(),ch2) == picoTDC1_channels.at(i).end())
340 {
341 ATH_MSG_WARNING(
"Cannot find channel "<<ch2<<
" from picoTDC #2 in picoTDC #1 in ToF collections with link nr. "<<ToF_links.at(i)<<
", time is very probably not set");
342 }
343 }
344
345 if(!picoTDC_hasTrigger.at(i))
346 {
347 ATH_MSG_WARNING(
"Cannot find trigger word in ToF collections with link nr. "<<ToF_links.at(i));
348 }
349 }
350 }
351
352 return StatusCode::SUCCESS;
353}
AFP_RawCollection< AFP_SiRawData > AFP_SiRawCollection
Class representing collection of silicon detector data.
AFP_RawCollection< AFP_ToFRawData > AFP_ToFRawCollection
AFP_ToFRawData_v2 AFP_ToFRawData
#define ATH_MSG_WARNING(x)
AFP_ToFRawCollection * getCollectionToF(AFP_RawContainer *container) const
Adds new time-of-flight collection to AFP_RawContainer.
static const uint32_t s_siNoHitMarker
ToolHandle< AFP_WordReadOut > m_wordReadout
void setDataHeader(uint32_t the_word, AFP_RawDataCommonHead *dataHead) const
Sets data header information for given argument based on m_wordReadout.
bool isLinkSi(const unsigned int link) const
returns true if provided link corresponds to silicon detector information
bool isLinkToF(const unsigned int link) const
returns true if provided link corresponds to time-of-flight information
AFP_SiRawCollection * getCollectionSi(AFP_RawContainer *container) const
Adds new silicon collection to AFP_RawContainer.
void setLvl1Id(const uint16_t lvl1Id)
void setBcId(const uint16_t bcId)
void setLink(const uint16_t link)
void setFrontendFlag(const uint32_t flag)
void setRobId(const uint32_t robId)
std::list< RAWDATA_T >::iterator begin()
Returns iterators to the beginning and end of the list.
RAWDATA_T & newDataRecord()
Creates a new empty data record in the collection and returns reference to it.
std::list< RAWDATA_T >::iterator end()
void setLvl1Id(const uint32_t lvl1ID)
void setTimeStamp(const uint32_t timeStamp)
void setTimeStampNS(const uint32_t timeStampNS)
void setBCId(const uint32_t bcId)
void setLumiBlock(const uint32_t lumiBlock)
void setTimeOverThreshold(const uint16_t timeOverThreshold)
void setColumn(const uint16_t column)
void setRow(const uint32_t row)
void setDelayedTrigger(const uint32_t delayedTrigger)
void setChannel(const uint16_t channel)
void setHeader(const uint16_t header)
void setEdge(const uint16_t edge)
void setPulseLength(const uint32_t pulseLength)
void setTime(const uint32_t time)
void setTriggerPattern(const uint32_t triggerPattern)
const DataType * PointerType