ATLAS Offline Software
Loading...
Searching...
No Matches
LArRodBlockPhysicsV2.cxx
Go to the documentation of this file.
1
2/*
3 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4*/
5
6// Implementation of the LArRODBlockStructure_3 class
7// This version contains LArRawChannels (=E,t,Q)
8// and LArDigits (=5 time samples)
9// See .h file for more details.
10
15#include "GaudiKernel/Bootstrap.h"
16#include "GaudiKernel/ISvcLocator.h"
17#include "GaudiKernel/IToolSvc.h"
18#include <stdlib.h>
19#include <cstdio>
20#include <iostream>
21
22//#define LARBSDBGOUTPUT
23#ifdef LARBSDBGOUTPUT
24#define LARBSDBG(text) m_logstr<<MSG::DEBUG<<text<<endmsg
25#else
26#define LARBSDBG(text)
27#endif
28
29namespace {
30union ShortLong {
31 uint16_t s[2];
32 uint32_t l;
33};
34}
35
37
39m_logstr(Athena::getMessageSvc(), BlockType())
40{
41 // retrieve onlineHelper
42 const LArOnlineID* online_id;
43 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service("DetectorStore")};
44 if (!detStore) {
45 m_logstr << MSG::ERROR << "Unable to locate DetectorStore" << endmsg;
46 std::abort();
47 }
48 StatusCode sc = detStore->retrieve(online_id, "LArOnlineID");
49 if (sc.isFailure()) {
50 m_logstr << MSG::FATAL << "Could not get LArOnlineID helper !" << endmsg;
51 std::abort();
52 }
53 else {
54 m_onlineHelper=online_id;
55 m_logstr << MSG::DEBUG << " Found the LArOnlineID helper. " << endmsg;
56 }
57
58 m_iHeadBlockSize=endtag/2; // The implicit cast rounds down to the right size
61 m_vFragment=NULL;
62 m_FebBlock=NULL;
63 m_pRODblock=NULL;
64 m_FlagPtr=NULL;
65 m_GainPtr=NULL;
66 m_HighEPtr=NULL;
67 m_LowEPtr=NULL;
69 m_RawDataPtr=NULL;
70}
71
72// clear temporary block vectors
78
87
88//For reading (to speed up the process)
90{//Set pointers to data blocks (pesuming, they exist)
92 {
94 {
96 m_RawDataPtr=reinterpret_cast<const uint16_t*>(m_RawDataFlagsPtr+m_NFlaggingWords);
97 m_GainPtr=reinterpret_cast<const uint32_t*>(m_RawDataFlagsPtr-2*m_NFlaggingWords);
98 }
99 else
100 {
102 m_RawDataPtr=reinterpret_cast<const uint16_t*>(m_RawDataFlagsPtr);
103 m_GainPtr=reinterpret_cast<const uint32_t*>(m_DummyBitMap);
104 }
106 {
108 m_LowEPtr=reinterpret_cast<const int16_t*>(m_FlagPtr+m_NFlaggingWords);
109 }
110 else
111 { //Bugfix, 9.8.2004, WL: Set pointer to dummy map to read FEB with only high energy block
113 m_LowEPtr=reinterpret_cast<const int16_t*>(m_FlagPtr);
114 }
116 m_HighEPtr=reinterpret_cast<const int32_t*>(m_FebBlock)+LE_getHeader16(HighEBlkOffset);
117 else
118 m_HighEPtr=NULL;
119 }
120 else
121 {
122 m_RawDataPtr=NULL;
123 m_RawDataFlagsPtr=NULL;
124 m_GainPtr=NULL;
125 m_FlagPtr=NULL;
126 m_LowEPtr=NULL;
127 m_HighEPtr=NULL;
128 }
129#ifdef LARBSDBGOUTPUT
130 std::cout << "Fragment offsets: (m_NFlaggingWords=" << m_NFlaggingWords << ")" << std::endl;
131
132 if (m_GainPtr)
133 std::cout << "Gains: " << LE_getHeader16(RawDataBlkOffset)-2*m_NFlaggingWords<< std::endl;
134 else
135 std::cout << "Gains: not present" << std::endl;
136
138 std::cout << "Raw Data Flags: " << LE_getHeader16(RawDataBlkOffset)<< std::endl;
139 else
140 std::cout << "Raw Data Flags: not present" << std::endl;
141
142 if (m_RawDataPtr)
143 std::cout << "Raw Data: " << LE_getHeader16(RawDataBlkOffset)+m_NFlaggingWords<< std::endl;
144 else
145 std::cout << "Raw Data: not present" << std::endl;
146
147 if (m_FlagPtr)
148 std::cout << "Flags: " << LE_getHeader16(LowEBlkOffset)<< std::endl;
149 else
150 std::cout << "Flags: not present" << std::endl;
151
152 if (m_LowEPtr)
153 std::cout << "Low Energy: " << LE_getHeader16(LowEBlkOffset)+m_NFlaggingWords << std::endl;
154 else
155 std::cout << "Low Energy: not present" << std::endl;
156
157 if (m_HighEPtr)
158 std::cout << "High Energy: " << LE_getHeader16(HighEBlkOffset)<< std::endl;
159 else
160 std::cout << "High Energy: not present" << std::endl;
161#endif
162 return true;
163}
164
165
167{ uint16_t oldword=LE_getVectorHeader16(NGainNSamples);
168 LE_setHeader16(NGainNSamples,(oldword & 0xFF00) | n);
169}
170
172{ uint16_t oldword=LE_getVectorHeader16(NGainNSamples);
173 LE_setHeader16(NGainNSamples,(oldword & 0x00FF) | (n<<8));
174}
175
176
177void LArRodBlockPhysicsV2::setNextEnergy(const int channel, const int32_t energy,
178 const int32_t time, const int32_t quality, const uint32_t gain) {
179 int rcNb=FebToRodChannel(channel);
180 //rcNb ist supposed to equal or bigger than m_EIndex.
181 //In the latter case, we fill up the missing channels with zero
182 if (rcNb<m_EIndex) {
183 m_logstr << MSG::ERROR << "LArRODBlockStructure Error: Internal error. Channels not ordered correctly. rcNb=" << rcNb
184 << " m_EIndex=" << m_EIndex << endmsg;
185 return;
186 }
187 //Fill up missing channels with zeros:
188 while (m_EIndex<rcNb)
189 setNextEnergy(0,0,-1,0);
190 //Add data...
191 setNextEnergy(energy,time,quality,gain);
192 return;
193}
194//Private function, expects channel number is rod-style ordering
195void LArRodBlockPhysicsV2::setNextEnergy(const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain)
196{
197 if (m_EIndex>=m_channelsPerFEB) //Use m_EIndex to count total number of channels
198 {m_logstr << MSG::ERROR << "LArRodBlockStructure Error: Attempt to write Energy for channel "
199 << m_EIndex << " channels into a FEB!" <<endmsg;
200 return;
201 }
202 LARBSDBG("LArRodBlockStructure: Setting Energy for channel " << m_EIndex << ". E=" << energy);
203 if (quality<0 && energy<0x7FFE && gain==0) { //Write into Low Energy block
204 m_LowEIndex++; //Use m_LowEIndex to count the channels in the Low Energy block
205 ShortLong twoValues{};
206 twoValues.s[0]=0;
207 twoValues.s[1]=0;
208 if (m_LowEIndex%2==1) { //This is an odd number, simply add data at the bottom of the block
209 twoValues.s[0]=(int16_t)energy;
210 }
211 else { //Even number: Merging with previous block
212 uint32_t oneValue=m_LowEnergyBlock[m_LowEnergyBlock.size()-1]; //Take last element of vector
213 m_LowEnergyBlock.pop_back();
214 int16_t* valptr=reinterpret_cast<int16_t*>(&oneValue);
215 twoValues.s[0]=valptr[0];
216 twoValues.s[1]=(int16_t)energy;
217 }
218 LARBSDBG("Writing words: val0= " << twoValues.s[0] << " val1= " << twoValues.s[1]);
219 m_LowEnergyBlock.push_back(twoValues.l);
220 LARBSDBG("Writing Raw data to Low E block. E=" << energy);
221 }
222 else //Write into High Energy block
224 m_HighEnergyBlock.push_back(energy);
225 uint32_t t_sign;
226 uint32_t abs_time;
227 if (time<0)
228 t_sign=1;
229 else
230 t_sign=0;
231 abs_time=abs(time);
232 if (abs_time>0x1fff)
233 abs_time=0x1fff;
234 //uint32_t gtQ = (gain << 30) | ((time & 0x3fff)<<16) | (0xffff & quality);
235 uint32_t gtQ = (gain << 30) | (t_sign<<29) | ((abs_time & 0x1fff)<<16) | (0xffff & quality);
236 m_HighEnergyBlock.push_back(gtQ);
237 LARBSDBG("Writing Raw data to High E block. E=" << energy << " Q=" << quality);
238 }
239 m_EIndex++;
240 // if (energy>0)
241 //m_ECounter++;
242}
243
244
245void LArRodBlockPhysicsV2::setRawData(const int channel, const std::vector<short>& samples, const uint32_t gain) {
246 //Convert Feb to Rod Channel Number:
247 //int rcNb=(channel>>3) + ((channel&0x7)<<4);
248 int rcNb=FebToRodChannel(channel);
249 if (rcNb>=m_channelsPerFEB)
250 {m_logstr << MSG::ERROR << "Attempt to write Energy for channel " << rcNb << " channels into a FEB!" << endmsg;
251 return;
252 }
253 unsigned int nsamples = LE_getVectorHeader16(NGainNSamples) & 0x00FF;
254 if(samples.size() != nsamples) {
255 m_logstr << MSG::ERROR << "Number of samples mismatch!\n";
256 m_logstr << " nsamples =" << nsamples;
257 m_logstr << " samples.size() =" << samples.size() << endmsg;
258 std::abort();
259 }
260
261 setBit(&m_RawDataBlock[0],rcNb);
262 //Samples have 12 bit and are shifted to the left by 2 bits.
263 // odd samples in high bits, even samples in low bits
264 if((nsamples/2)*2!=nsamples) { //odd number of samples - gain is alone
265 m_RawDataBlock.push_back((gain<<30) | samples[0]<<2);
266 for (unsigned int i=1;i<nsamples;i+=2)
267 m_RawDataBlock.push_back((samples[i+1]<<18) | samples[i]<<2);
268 }
269 else { //even number of samples - gain is packed with sample 0
270 m_RawDataBlock.push_back((gain<<30) | (samples[1]<<18) | samples[0]<<2);
271 for (unsigned int i=2;i<nsamples;i+=2)
272 m_RawDataBlock.push_back((samples[i+1]<<18) | samples[i]<<2);
273 }
274}
275
276
277//For writing: takes existing Fragment and splits it into Feb-Blocks
278void LArRodBlockPhysicsV2::initializeFragment(std::vector<uint32_t>& fragment)
279{
280 m_pRODblock=&fragment; //remember pointer to fragment
281 if (fragment.size()>m_iHeadBlockSize) { //Got filled fragment
282 unsigned int sizeRead=0;
283 //Store existing data in the FEB-Map
284 while (sizeRead<fragment.size()) {
285 std::vector<uint32_t>::iterator FebIter;
286 FebIter=fragment.begin()+sizeRead; //Store pointer to current Feb-Header
287 m_FebBlock=&(*FebIter); //Set m_FebBlock in order to use getHeader-functions.
288 uint32_t currFEBid=getHeader32(FEBID); //Get this FEB-ID
289 uint16_t currFebSize=getNumberOfWords(); //Size of this FEB-Block
290 //std::cout << "FebID=" << currFEBid << " FEBSize=" << currFebSize << " Vector size=" << fragment.size() << std::endl;
291 if (FebIter+currFebSize>fragment.end()) {
292 fragment.clear(); //Clear existing vector
293 m_logstr << MSG::ERROR << "Got inconsistent ROD-Fragment!" << endmsg;
294 return;
295 }
296 m_mFebBlocks[currFEBid].assign(FebIter,FebIter+currFebSize); //Copy data from ROD-fragment into FEB-Block
297 sizeRead+=currFebSize+m_MiddleHeaderSize;//6 is the middle header size
298 LARBSDBG("Found FEB-id " << currFEBid << " in existing ROD-Fragment");
299 } // end while
300 }
301 fragment.clear(); //Clear existing vector
302 return;
303}
304
305//For writing: Initalizes a single FEB-Block
308 if (m_vFragment->size()<m_iHeadBlockSize) //Got empty or spoiled fragment
309 {m_vFragment->resize(m_iHeadBlockSize,0); //Initialize FEB-Header
310 setHeader32(FEBID,id); //Set Feb ID
311 }
312
316}
317
319{
320//Complete non-complete Energy block
322 setNextEnergy(0,0,-1,0);//E=0,t=0,q=-1,G=0
323 // Energies
324 unsigned int n;
325 uint16_t BlockOffset;
326 //Low energy block....
327 n = m_LowEnergyBlock.size();
329 //Check if Low Energy Block exists and is not yet part of the fragment
330 LARBSDBG("Checking Low Energy Block n=" << n << "BlockOffset=" << BlockOffset);
331 if (n>m_NFlaggingWords && !BlockOffset)
333 for (unsigned i=0;i<n;i++)
334 m_vFragment->push_back(m_LowEnergyBlock[i]);
335 }
336 //High energy block...
337 n = m_HighEnergyBlock.size();
339 LARBSDBG("Checking High Energy Block n=" << n << "BlockOffset=" << BlockOffset);
340 //Check if High Energy-Block exists and is not yet part of the fragment
341 if (n && !BlockOffset)
343 for(unsigned int i=0;i<n;i++)
344 m_vFragment->push_back(m_HighEnergyBlock[i]);
345 }
346
347 // Raw data
348 LARBSDBG("Checking Raw Data Block");
349 n = m_RawDataBlock.size();
351 LARBSDBG("Checking Raw Data Block. n=" << n << "BlockOffset=" << BlockOffset);
352 //Check if Raw Data block exists and is not yet part of the fragment
353 if (n>m_NFlaggingWords && !BlockOffset)
355 for(unsigned int i=0;i<n;i++)
356 m_vFragment->push_back(m_RawDataBlock[i]);
357 }
359 LARBSDBG("Offsets:" << std::endl
360 << "Raw Data: " << LE_getVectorHeader16(RawDataBlkOffset) << std::endl
361 <<"Low Energy: " << LE_getVectorHeader16(LowEBlkOffset)<< std::endl
362 << "High Energy: " << LE_getVectorHeader16(HighEBlkOffset)<< std::endl
363 << "Energy-index:" << m_EIndex << std::endl
364 << "Filled channels: " << m_ECounter << std::endl);
365 clearBlocks();
366 return;
367}
368
369
371{
372 //std::cout << "Concatinating FEBs. Have "<< m_mFebBlocks.size() <<" febs." << std::endl;
373 FEBMAPTYPE::const_iterator feb_it_b=m_mFebBlocks.begin();
374 FEBMAPTYPE::const_iterator feb_it_e=m_mFebBlocks.end();
375 FEBMAPTYPE::const_iterator feb_it;
376 for (feb_it=feb_it_b;feb_it!=feb_it_e;++feb_it) {
377 if (feb_it!=feb_it_b) //Not first Feb
378/*
379 if (fullHeader) {//Add middle header
380 m_pRODblock->push_back(fullHeader->version().full());//Format Version number
381 m_pRODblock->push_back(fullHeader->source_id()); //Source identifer
382 m_pRODblock->push_back(fullHeader->run_no());
383 m_pRODblock->push_back(fullHeader->lvl1_id()); //Level 1 identifer
384 m_pRODblock->push_back(fullHeader->bc_id()); //Bunch Crossing identifer
385 m_pRODblock->push_back(fullHeader->lvl1_type()); //Level 1 trigger type
386 m_pRODblock->push_back(fullHeader->detev_type()); //Detector event type
387 }
388 else //No ROD-Header
389*/
391
392 //Add feb data to rod data block
393 m_pRODblock->insert (m_pRODblock->end(),
394 feb_it->second.begin(), feb_it->second.end());
395 } //end for feb_it
396
397 m_mFebBlocks.clear();
398 return;
399}
400
401int LArRodBlockPhysicsV2::getNextRawData(int& channelNumber, std::vector<short>& samples, uint32_t& gain)
402{
403 LARBSDBG("in LArRodBlockPhysicsV2::getNextRawData.");
404 LARBSDBG("m_RawDataCounter=" << m_RawDataCounter << " m_RawDataIndex="<< m_RawDataIndex);
405 LARBSDBG("m_channelsPerFEB=" << m_channelsPerFEB);
406 if(m_FebBlockSize<=m_iHeadBlockSize) return 0;
408
409 const int flags=(int) LE_getHeader16(RawDataBlkOffset);
410 if (!flags)
411 return 0; //Block not existing
412 if (m_RawDataCounter>=m_channelsPerFEB) //Already beyond maximal number of channels
413 return 0;
414
415 LARBSDBG("Flags="<<flags);
416
417 while (!getBit(m_RawDataFlagsPtr,m_RawDataCounter)) //Look for next filled channel
419 LARBSDBG("RawDataCounter ist now " << m_RawDataCounter);
420 if (m_RawDataCounter>=m_channelsPerFEB) //No more channel available
421 return 0;
422 }
423 LARBSDBG("Found filled channel at positon " << m_RawDataCounter);
424 //Found next filled channel
425 channelNumber=m_RawDataCounter;
426 //channelNumber=(m_RawDataCounter>>4) + ((m_RawDataCounter&0xf)<<3); //Convert ROD to FEB channel ordering
427 unsigned int nsamples = LE_getHeader16(NGainNSamples) & 0x00FF;
428 LARBSDBG("This run has " << nsamples << " samples");
429 int index = m_RawDataIndex*nsamples;
430 LARBSDBG( "index="<<index);
432 LARBSDBG("In getnextRawData(). index= " << index);
433 gain=3-((m_GainPtr[channelNumber/16] >> (channelNumber%16)*2) & 0x3);
434 if(gain>=CaloGain::LARNGAIN) return 0;
435 for(unsigned int i=0;i<nsamples;i++) {
436 uint16_t x;
437 if((index+i)%2==0)
438 x=m_RawDataPtr[index+i+1];
439 else
440 x=m_RawDataPtr[index+i-1];
441 samples.push_back((short) (x & 0xfff));
442 }
444
445 if (m_rearrangeFirstSample && m_rearrangeFirstSample<samples.size()) //FIXME: Very ugly hack! See explanation in LArRodDecoder.h file
446 {//Change e.g. 3 0 1 2 4 to 0 1 2 3 4
447 short movedSample=samples[0];
448 for (unsigned i=1;i<=m_rearrangeFirstSample;i++)
449 samples[i-1]=samples[i];
450 samples[m_rearrangeFirstSample]=movedSample;
451 }
452
453 return 1;
454}
455
456
457
458/*
459void LArRodBlockPhysicsV2::dumpFragment()
460{
461 if (m_pRODblock)
462 std::cout << "Dump of LArRodFragment. Block Type=3. Size of vector=" << m_pRODblock->size() <<std::endl;
463 else
464 std::cout << "Dumping FEB block" << std::endl;
465 int size_read=0;
466 int size_tot=0;
467 if (m_pRODblock)
468 size_tot=m_pRODblock->size();
469 do {
470 std::cout <<"Begin of do-while loop:" << std::endl;
471 if (m_pRODblock)
472 m_FebBlock=&m_pRODblock->at(size_read);
473 char s[33];
474 int i;
475 int FlagPosition;
476 int CurrentPosition = 0;
477
478 std::cout << " Head Block size = " << m_iHeadBlockSize << std::endl;
479 for (i=0;i<m_iHeadBlockSize;i++) {
480 sprintf(s,"%8.8x",m_FebBlock[CurrentPosition]);
481 std::cout << " " << CurrentPosition << " " << s
482 << " = " << (m_FebBlock[CurrentPosition]>>16)
483 << " " << (m_FebBlock[CurrentPosition] &0xffff) << std::endl;
484 CurrentPosition++;
485 }
486 std::cout << "Energy Block offset: " << LE_getHeader16(EBlkOffset) << std::endl;
487 std::cout << "tQ Block offset: " << LE_getHeader16(tQBlkOffset) << std::endl;
488 std::cout << "Raw Data Block offset " << LE_getHeader16(RawDataBlkOffset) << std::endl;
489
490 while (CurrentPosition<getNumberOfWords())
491 {FlagPosition=CurrentPosition;
492 if (CurrentPosition==LE_getHeader16(EBlkOffset))
493 {std::cout << " Found Energy Block at offset = " << LE_getHeader16(EBlkOffset) << std::endl;
494 for (i=0; i<m_NFlaggingWords; i++) {
495 sprintf(s,"%8.8x",m_FebBlock[CurrentPosition]);
496 std::cout << " " << CurrentPosition << " " << s
497 << " Flag word" << std::endl;
498 CurrentPosition++;
499 }
500 for (i=0; i<m_NFlaggingWords*32; i++) {
501 if(getBit(&m_FebBlock[FlagPosition],i)) {
502 sprintf(s,"%8.8x",m_FebBlock[CurrentPosition]);
503 std::cout << " " << CurrentPosition << " " << s
504 << " ROD Channel " << i << " FEB Channel " << RodToFebChannel(i)
505 << " = " << m_FebBlock[CurrentPosition] << std::endl;
506 CurrentPosition++;
507 }
508 }
509 } // end if energy block
510 else if (CurrentPosition==LE_getHeader16(tQBlkOffset))
511 {std::cout << " Found tQ Block at position = " << LE_getHeader16(tQBlkOffset) << std::endl;
512 FlagPosition = CurrentPosition;
513 for (i=0; i<m_NFlaggingWords; i++) {
514 sprintf(s,"%8.8x",m_FebBlock[CurrentPosition]);
515 std::cout << " " << CurrentPosition << " " << s
516 << " Flag word" << std::endl;
517 CurrentPosition++;
518 }
519 for (i=0; i<m_NFlaggingWords*32; i++) {
520 if(getBit(&m_FebBlock[FlagPosition],i)) {
521 sprintf(s,"%8.8x",m_FebBlock[CurrentPosition]);
522 std::cout << " " << CurrentPosition << " " << s
523 << " ROD Channel " << i << " FEB Channel " << RodToFebChannel(i)
524 << " = " << (m_FebBlock[CurrentPosition]>>16)
525 << " " << (m_FebBlock[CurrentPosition] &0xffff) << std::endl;
526 CurrentPosition++;
527 }
528 }
529 }// end if tQ block
530 else if (CurrentPosition==LE_getHeader16(RawDataBlkOffset))
531 {std::cout << "Found Raw Data Block at position = " <<LE_getHeader16(RawDataBlkOffset) << std::endl;
532 FlagPosition = CurrentPosition;
533 for (i=0; i<m_NFlaggingWords; i++) {
534 sprintf(s,"%8.8x",m_FebBlock[CurrentPosition]);
535 std::cout << " " << CurrentPosition << " " << s
536 << " Flag word" << std::endl;
537 CurrentPosition++;
538 }
539 for (i=0; i<m_NFlaggingWords*32; i++) {
540 if(getBit(&m_FebBlock[FlagPosition],i)) {
541 int nsamples = LE_getHeader16(NSamples);
542 for(int j=0;j<nsamples;j+=2) {
543 sprintf(s,"%8.8x",m_FebBlock[CurrentPosition]);
544 std::cout << " " << CurrentPosition << " " << s
545 << " ROD Channel " << i << " FEB Channel " << RodToFebChannel(i)
546 << " samples " << j << " and " << j+1 << " = "
547 << ((m_FebBlock[CurrentPosition]>>16) & 0x3fff) << " " //Mask gain!
548 << (m_FebBlock[CurrentPosition] & 0xffff) << std::endl;
549 CurrentPosition++;
550 }
551 }
552 }
553 }// end if Raw Data block
554 else
555 {std::cout << "UNKNOWN block found at position" << CurrentPosition << std::endl;
556 return;
557 }
558 }// end while
559 size_read+=CurrentPosition+6;
560 std::cout << " ------- End of FEB-Block (size_read=" <<size_read << ", size_tot=" << size_tot << ") -------" << std::endl;
561 } while(size_read<size_tot);
562 std::cout << " ------------------ End Of ROD-Framgent -----------------" << std::endl;
563}
564*/
565
566/*
567void LArRodBlockPhysicsV2::dumpFragment(const std::vector<uint32_t>& v)
568{
569 uint32_t size_tot = v.size();
570 uint32_t size_read = 0;
571 std::cout << "LAr ROD vector size = " << size_tot << std::endl;
572
573 int ifeb=0;
574 while(size_read<size_tot)
575 {
576 m_FebBlock = &(v[0]);
577 m_FebBlock+= size_read;
578 std::cout << "LAr ROD - FEB " << ifeb << std::endl;
579 dumpFragment();
580 // next FEB
581 size_read += getNumberOfWords()+6;
582 ifeb++;
583 }
584 std::cout << "End of ROD-Fragment" << std::endl;
585}
586*/
587
588
589//Sort functions & ordering relation:
590template<class RAWDATA>
591bool LArRodBlockPhysicsV2::operator ()
592 //(const LArRawChannel* ch1, const LArRawChannel* ch2) const
593 (const RAWDATA* ch1, const RAWDATA* ch2) const
594{
595 HWIdentifier id1 = ch1->channelID();
596 HWIdentifier id2 = ch2->channelID();
597
598 HWIdentifier febId1= m_onlineHelper->feb_Id(id1);
599 HWIdentifier febId2= m_onlineHelper->feb_Id(id2);
600
601 if(febId1 == febId2 ){
602 int cId1 = m_onlineHelper->channel(id1);
603 int cId2 = m_onlineHelper->channel(id2);
604 return FebToRodChannel(cId1) < FebToRodChannel(cId2);
605 }
606
607 return febId1 < febId2 ;
608}
609
610
611void LArRodBlockPhysicsV2::sortDataVector(std::vector<const LArRawChannel*>& vRC)
612{std::sort(vRC.begin(),vRC.end(),*this);}
613
614void LArRodBlockPhysicsV2::sortDataVector( std::vector<const LArDigit*>& vDigit)
615{std::sort(vDigit.begin(),vDigit.end(),*this);
616}
617
619{
620 return LE_getHeader16(NGainNSamples)&0xff;
621}
622
624{
625 return LE_getHeader16(NGainNSamples)>>8;
626}
627
628uint32_t LArRodBlockPhysicsV2::getRadd(uint32_t /*adc*/, uint32_t sample) const
629{
630 int index=LE_getHeader16(RawDataBlkOffset)-3+(sample+1)/2;
631 uint32_t x=m_FebBlock[index];
632 //if(sample&0x1) x=x&0xffff;
633 //else
634 x=x&0xffff;
635 return x;
636}
637
638uint16_t LArRodBlockPhysicsV2::getCtrl1(uint32_t /*adc*/) const
639{
641 uint32_t x=m_FebBlock[index];
642 x=x>>16;
643 uint16_t ctrl=x;
644 return ctrl;
645}
646
647uint16_t LArRodBlockPhysicsV2::getCtrl2(uint32_t /*adc*/) const
648{
650 uint32_t x=m_FebBlock[index];
651 x=x&0xffff;
652 uint16_t ctrl=x;
653 return ctrl;
654}
655
656uint16_t LArRodBlockPhysicsV2::getCtrl3(uint32_t /*adc*/) const
657{
659 uint32_t x=m_FebBlock[index];
660 x=x>>16;
661 uint16_t ctrl=x;
662 return ctrl;
663}
664
666{
667 uint32_t x=getHeader32(Status2);
668 return x;
669}
#define endmsg
static Double_t sc
HWIdentifier febId1
HWIdentifier febId2
HWIdentifier id2
#define LARBSDBG(text)
This class provides decoding/encoding from/to ROD format.
#define x
std::vector< uint32_t > m_LowEnergyBlock
std::vector< uint32_t > m_HighEnergyBlock
std::vector< uint32_t > m_RawDataBlock
virtual uint32_t getNumberOfSamples() const
virtual int getNextRawData(int &channelNumber, std::vector< short > &samples, uint32_t &gain)
virtual void setNumberOfSamples(const uint8_t n)
virtual void sortDataVector(std::vector< const LArRawChannel * > &)
virtual void setNumberOfGains(const uint8_t n)
virtual uint32_t getStatus() const
virtual uint16_t getCtrl2(uint32_t adc) const
const uint16_t * m_RawDataPtr
virtual void initializeFragment(std::vector< uint32_t > &fragment)
virtual void setNextEnergy(const int channel, const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain)
virtual void setRawData(const int channel, const std::vector< short > &samples, const uint32_t gain)
virtual uint16_t getCtrl1(uint32_t adc) const
const uint32_t * m_RawDataFlagsPtr
virtual uint32_t getRadd(uint32_t adc, uint32_t sample) const
virtual uint32_t getNumberOfGains() const
static const uint32_t m_DummyBitMap[4]
virtual uint16_t getCtrl3(uint32_t adc) const
int FebToRodChannel(int ch) const
virtual void initializeFEB(const uint32_t id)
int getBit(const uint32_t *const p, const unsigned chan) const
void setHeader32(const unsigned n, const uint32_t w)
uint16_t LE_getVectorHeader16(const unsigned n) const
void LE_setHeader16(const unsigned n, const uint16_t w)
uint32_t getHeader32(const unsigned n) const
void setBit(uint32_t *const p, const unsigned chan)
std::vector< uint32_t > * m_pRODblock
std::vector< uint32_t > * m_vFragment
uint16_t LE_getHeader16(const unsigned n) const
uint32_t getNumberOfWords() const
Some weak symbol referencing magic... These are declared in AthenaKernel/getMessageSvc....
@ LARNGAIN
Definition CaloGain.h:19
Definition index.py:1
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
setEventNumber uint32_t