19 static const InterfaceID IID_IAFP_ByteStream2RawCnv(
"AFP_ByteStream2RawCnv", 1, 0);
20 return IID_IAFP_ByteStream2RawCnv;
24 const std::string &
name,
27 m_robDataProvider(
"ROBDataProviderSvc",
name)
29 declareInterface<AFP_ByteStream2RawCnv>(
this);
41 return StatusCode::SUCCESS;
47 return StatusCode::SUCCESS;
55 return StatusCode::SUCCESS;
60 return StatusCode::SUCCESS;
66 return StatusCode::SUCCESS;
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);
76 return StatusCode::SUCCESS;
79 const uint32_t nStat = robFrag->nstatus();
85 return StatusCode::SUCCESS;
91 return StatusCode::SUCCESS;
97 robFrag->rod_data(vint);
99 if (robFrag->rod_nstatus() <= 0) {
101 return StatusCode::SUCCESS;
104 const eformat::FullEventFragment<const uint32_t*> *
event =
m_robDataProvider->getEvent(Gaudi::Hive::currentContext());
123 std::vector<std::vector<uint16_t>> picoTDC1_channels, picoTDC2_channels;
124 std::vector<bool> picoTDC_hasTrigger;
125 std::vector<int> ToF_links;
128 for (
unsigned i = 0;
i <
size;
i++) {
138 collectionHead = collectionToF;
140 std::vector<uint16_t>
helper;
141 picoTDC1_channels.push_back(
helper);
142 picoTDC2_channels.push_back(
helper);
143 picoTDC_hasTrigger.push_back(
false);
144 ToF_links.push_back(the_link);
150 collectionHead = collectionSi;
153 ATH_MSG_ERROR(
"Unidentified value of link="<<the_link<<
" for header record.");
154 return StatusCode::FAILURE;
157 if (!collectionHead) {
159 << the_link <<
", robID = " << robFrag->rob_source_id() <<
")");
160 return StatusCode::SUCCESS;
165 collectionHead->
setLink(the_link);
168 collectionHead->
setRobId(robFrag->rob_source_id());
175 if ( !collectionToF ) {
177 return StatusCode::SUCCESS;
199 ATH_MSG_DEBUG(
"This is not a ToF measurement, bit23 = "<<bit23<<
", bits22_21 "<<bits22_21<<
", ignoring word = "<<the_word);
208 if(bits19_22==0 || bits19_22==1)
214 auto ToFData_itr=std::find_if( collectionToF->
begin(), collectionToF->
end(),
217 if(ToFData_itr==collectionToF->
end())
222 ToFData.setHeader( bit23 );
223 ToFData.setEdge( 0 );
224 ToFData.setChannel(
m_wordReadout->getBits(the_word, 18, 13) );
225 ToFData.setPulseLength( 0 );
226 ToFData.setTime( 0 );
229 ToFData_itr = std::prev(collectionToF->
end());
235 if(ToFData_itr->time() !=0 )
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");
241 ToFData_itr->setTime(
m_wordReadout->getBits(the_word, 12, 0) );
242 picoTDC1_channels.back().push_back(
channel);
248 if(ToFData_itr->pulseLength() !=0 )
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");
254 ToFData_itr->setPulseLength(
m_wordReadout->getBits(the_word, 12, 0) );
255 picoTDC2_channels.back().push_back(
channel);
259 else if(bits19_22==4)
262 auto ToFData_itr=std::find_if( collectionToF->
begin(), collectionToF->
end(),
264 if(ToFData_itr!=collectionToF->
end())
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));
274 ToFData.setHeader( bit23 );
275 ToFData.setEdge( 0 );
276 ToFData.setTrigger();
277 ToFData.setDelayedTrigger(
m_wordReadout->getBits(the_word, 18,16) );
278 ToFData.setTriggerPattern(
m_wordReadout->getBits(the_word, 15, 0) );
279 picoTDC_hasTrigger.back()=
true;
284 ATH_MSG_WARNING(
"unknown pattern in bits 19-22 = "<<bits19_22<<
", ignoring word = "<<the_word);
292 if ( !collectionSi ) {
293 ATH_MSG_WARNING(
"No silicon detector collection available to fill data.");
294 return StatusCode::SUCCESS;
318 ATH_MSG_ERROR(
"Not recognised value of link="<<the_link<<
" for data record.");
319 return StatusCode::FAILURE;
326 for(
unsigned int i=0;
i<picoTDC1_channels.size();++
i)
328 if(!picoTDC1_channels.at(
i).empty() || !picoTDC2_channels.at(
i).empty())
330 for(
auto ch1 : picoTDC1_channels.at(
i))
332 if(
std::find(picoTDC2_channels.at(
i).begin(),picoTDC2_channels.at(
i).end(),ch1) == picoTDC2_channels.at(
i).end())
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");
337 for(
auto ch2 : picoTDC2_channels.at(
i))
339 if(
std::find(picoTDC1_channels.at(
i).begin(),picoTDC1_channels.at(
i).end(),ch2) == picoTDC1_channels.at(
i).end())
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");
345 if(!picoTDC_hasTrigger.at(
i))
347 ATH_MSG_WARNING(
"Cannot find trigger word in ToF collections with link nr. "<<ToF_links.at(
i));
352 return StatusCode::SUCCESS;
360 ATH_MSG_WARNING(
"NULL pointer passed in argument: container. NULL pointer returned.");
376 return &newCollection;
384 ATH_MSG_WARNING(
"NULL pointer passed in argument: container. NULL pointer returned.");
400 return &newCollection;