ATLAS Offline Software
Loading...
Searching...
No Matches
LArABBADecoder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8static const InterfaceID IID_ILArABBADecoder("LArABBADecoder", 1, 0);
9
10
11using namespace OFFLINE_FRAGMENTS_NAMESPACE;
12
13LArABBADecoder::LArABBADecoder(const std::string& type, const std::string& name,
14 const IInterface* parent )
15 : AthAlgTool(type,name,parent)
16{
17 declareInterface< LArABBADecoder >( this );
18}
19
20const InterfaceID& LArABBADecoder::interfaceID( )
21{ return IID_ILArABBADecoder; }
22
23
24
26
27
29 return StatusCode::SUCCESS;
30}
31
33 return StatusCode::SUCCESS;
34}
35
37{
38 bool ret=false;
39 // Check fragment validity:
40 try {
41 ret=re->check();
42 }
43 catch (eformat::Issue& ex) {
44 ATH_MSG_WARNING( "Exception while checking eformat fragment validity: " << ex.what() );
45 ret=false;
46 }
47 if (!ret) {
48 ATH_MSG_ERROR( "Got invalid RawEvent fragment" );
49 return StatusCode::FAILURE;
50 }
51
52 //Build TOC
53 std::map<eformat::SubDetectorGroup, std::vector<const uint32_t*> > robIndex;
54 eformat::helper::build_toc(*re, robIndex );
55 std::map<eformat::SubDetectorGroup, std::vector<const uint32_t*> >::const_iterator robIt = robIndex.find(eformat::LAR);
56 if (robIt!=robIndex.end()) {
57 const std::vector<const uint32_t*>& robs = robIt->second;
58 for (const uint32_t* pRob :robs) {
59 try {
60 ROBFragment robFrag(pRob);
61 fillCollection(&robFrag,coll);
62 }
63 catch (eformat::Issue& ex) {
64 ATH_MSG_WARNING ( " exception thrown by ROBFragment, badly corrupted event. Abort decoding " );
65 coll->clear();
66 break;
67 }
68 }//end loop over robs
69 }//end if got LAr-RODs
70 return StatusCode::SUCCESS;
71}
72
73
75{
77 LArDigit * scDigit=0 ;
78
79 //FIXME: Check validity
80 uint32_t nData = robFrag->rod_ndata();
81 const uint32_t* p=robFrag->rod_data();
82 if (nData < 3) {
83 ATH_MSG_WARNING ( "Error reading bytestream event: "
84 << "Empty ROD block (less than 3 words) for source ID " << robFrag->rod_source_id() );
85 return;
86 }
87 else
88 robFrag->rod_source_id();
89
90 unsigned int n = robFrag->payload_size_word();
91
92 std::vector<std::string> string;
93 int x=0x0;
94 int nsamples = p[0];
95 for(unsigned int s=1;s<n-13;s+=6) {
96 std::string ss;
97 for (unsigned int k=0;k<6;++k){
98 x = p[s+k];
99 std::ostringstream oss;
100 oss << std::hex << x;
101 if (oss.str().size() == 7){
102 ss.append("0");
103 }
104 ss += oss.str();
105 }
106 string.push_back(std::move(ss));
107 }
108
109 constexpr int nFibers = 20;
110 constexpr int nchannels = 8;
111 constexpr int Nabbachannels = nFibers * nchannels;
112
113 constexpr int fiberSeq[16] = {0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1};
114 constexpr int adcSeq[16] = {1,0,1,0,3,2,3,2,5,4,5,4,7,6,7,6};
115
116 std::vector< std::vector< std::vector<int> > > abbasamples;
117 abbasamples.resize(nFibers);
118
119 std::vector<std::vector<short>> abba_channel_samples;
120 abba_channel_samples.resize(Nabbachannels);
121
122 for (int fib=0;fib < nFibers; ++fib){
123 abbasamples[fib].resize(nchannels);
124 for (int ch = 0; ch < nchannels; ++ch){
125 abbasamples[fib][ch].resize(nsamples);
126 int Nchannel = fib*8 + ch;
127 abba_channel_samples[Nchannel].resize(nsamples);
128 }
129 }
130
131 for (int fib=0;fib < nFibers; fib+=2){
132 for (int sam=0; sam < nsamples; sam++){
133 int zx = sam + (fib/2)*nsamples;
134 const std::string &wx = string[zx];
135 int k = 0;
136 for (int m = 0; m < 16; ++m){ //16 size of fiberSeq array
137 int fiber_number = fiberSeq[m];
138 int adc_number = adcSeq[m];
139 int idx = k*3;
140 std::stringstream ss;
141 char mysample[3];
142 for (int j = idx; j < idx+3; ++j){
143 int i = j%3;
144 mysample[i] = wx[j];
145 }
146 ss << mysample;
147 short mysample_int;
148 ss >> std::hex >> mysample_int;
149 int fb = fiber_number+fib;
150 int ch = adc_number;
151 int abbachannel = fb*8+ch;
152 k++;
153 abbasamples[fb][ch][sam] = mysample_int;
154 abba_channel_samples[abbachannel][sam] = mysample_int;
155 }
156 }
157 }
158
159 std::map<int, HWIdentifier> abba_mapping;
160
161
162 int iphi = 0;
163 switch (robFrag->rod_source_id())
164 {
165 case 0x410511:
166 iphi=19;
167 break;
169 case 0x410512:
170 iphi=18;
171 break;
172 case 0x410521:
173 iphi=20;
174 break;
175 case 0x410522:
176 iphi=21;
177 break;
178
179 default:
180 ATH_MSG_ERROR("ROD_source_id not found");
181 }
182
183
184 ABBAMapping::fill(&abba_mapping, iphi, msg());
185
186
187 for (std::size_t index_abba_channel_samples = 0; index_abba_channel_samples < abba_channel_samples.size(); ++index_abba_channel_samples) {
188 auto abba_mapping_search = abba_mapping.find(index_abba_channel_samples);
189 if (abba_mapping_search == abba_mapping.end()) {
190 ATH_MSG_WARNING("No mapping for index_abba_channel_samples: "<<std::dec<<index_abba_channel_samples);
191 continue;
192 }
193
194 HWIdentifier channelID = (*abba_mapping_search).second;
195 std::vector<short> adcValues = abba_channel_samples[index_abba_channel_samples];
196 scDigit=new LArDigit(channelID,dummyGain,std::move(adcValues));
197
198 coll->push_back(scDigit);
199 }
200
201 abbasamples.clear();
202}
const boost::regex re(r_e)
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
static const InterfaceID IID_ILArABBADecoder("LArABBADecoder", 1, 0)
static Double_t ss
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition RawEvent.h:37
#define x
static void fill(std::map< int, HWIdentifier > *toFill, int iphi, MsgStream &log)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
MsgStream & msg() const
value_type push_back(value_type pElem)
Add an element to the end of the collection.
void clear()
Erase all the elements in the collection.
static const InterfaceID & interfaceID()
virtual StatusCode initialize() override
LArABBADecoder(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode finalize() override
virtual ~LArABBADecoder()
Destructor.
StatusCode convert(const RawEvent *re, LArDigitContainer *coll) const
void fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *pROB, LArDigitContainer *coll) const
Container class for LArDigit.
Liquid Argon digit base class.
Definition LArDigit.h:25
STL class.
@ LARHIGHGAIN
Definition CaloGain.h:18
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27