ATLAS Offline Software
LArRodBlockPhysicsV2.cxx
Go to the documentation of this file.
1 
2 /*
3  Copyright (C) 2002-2024 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 
13 #include "LArRawEvent/LArDigit.h"
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 
29 namespace {
30 union ShortLong {
31  uint16_t s[2];
32  uint32_t l;
33 };
34 }
35 
37 
39 m_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;
68  m_RawDataFlagsPtr=NULL;
69  m_RawDataPtr=NULL;
70 }
71 
72 // clear temporary block vectors
74 { m_HighEnergyBlock.clear();
75  m_LowEnergyBlock.clear();
76  m_RawDataBlock.clear();
77 }
78 
80 {m_ECounter=0;
82  m_LowEIndex=0;
84  m_HighEIndex=0;
85  m_EIndex=0;
86 }
87 
88 //For reading (to speed up the process)
90 {//Set pointers to data blocks (pesuming, they exist)
92  {
94  {
98  }
99  else
100  {
104  }
106  {
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=(const int16_t*)m_FlagPtr;
114  }
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 
137  if (m_RawDataFlagsPtr)
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 
168  LE_setHeader16(NGainNSamples,(oldword & 0xFF00) | n);
169 }
170 
173  LE_setHeader16(NGainNSamples,(oldword & 0x00FF) | (n<<8));
174 }
175 
176 
177 void 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
195 void 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 
245 void 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
278 void 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()) {
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 
315  resetPointers();
316 }
317 
319 {
320 //Complete non-complete Energy block
321  while (m_EIndex<m_channelsPerFEB)
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();
328  BlockOffset=LE_getVectorHeader16(LowEBlkOffset);
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  }
358  setHeader32(NWTot,m_vFragment->size());
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 */
390  m_pRODblock->resize( m_pRODblock->size()+m_MiddleHeaderSize);
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 
401 int 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 
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
418  {++m_RawDataCounter;
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");
430  LARBSDBG( "index="<<index);
431  ++m_RawDataIndex;
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 /*
459 void 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 /*
567 void 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:
590 template<class RAWDATA>
591 bool 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 
611 void LArRodBlockPhysicsV2::sortDataVector(std::vector<const LArRawChannel*>& vRC)
612 {std::sort(vRC.begin(),vRC.end(),*this);}
613 
614 void 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 
629 {
632  //if(sample&0x1) x=x&0xffff;
633  //else
634  x=x&0xffff;
635  return x;
636 }
637 
639 {
642  x=x>>16;
643  uint16_t ctrl=x;
644  return ctrl;
645 }
646 
648 {
651  x=x&0xffff;
652  uint16_t ctrl=x;
653  return ctrl;
654 }
655 
657 {
660  x=x>>16;
661  uint16_t ctrl=x;
662  return ctrl;
663 }
664 
666 {
668  return x;
669 }
LArRodBlockStructure
Definition: LArRodBlockStructure.h:48
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
LArRodBlockPhysicsV2::NWTot
@ NWTot
Definition: LArRodBlockPhysicsV2.h:56
LArRodBlockPhysicsV2::getStatus
virtual uint32_t getStatus() const
Definition: LArRodBlockPhysicsV2.cxx:665
LArRodBlockStructure::m_vFragment
std::vector< uint32_t > * m_vFragment
Definition: LArRodBlockStructure.h:231
LArRodBlockPhysicsV2::m_ECounter
int m_ECounter
Definition: LArRodBlockPhysicsV2.h:128
febId2
HWIdentifier febId2
Definition: LArRodBlockPhysicsV2.cxx:599
LArRodBlockPhysicsV2::m_onlineHelper
const LArOnlineID * m_onlineHelper
Definition: LArRodBlockPhysicsV2.h:144
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
LArRodBlockPhysicsV2::FebToRodChannel
int FebToRodChannel(int ch) const
Definition: LArRodBlockPhysicsV2.h:156
LArRodBlockPhysicsV2::m_RawDataCounter
int m_RawDataCounter
Definition: LArRodBlockPhysicsV2.h:129
LArRodBlockPhysicsV2::setNumberOfSamples
virtual void setNumberOfSamples(const uint8_t n)
Definition: LArRodBlockPhysicsV2.cxx:166
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
LArRodBlockPhysicsV2::m_RawDataBlock
std::vector< uint32_t > m_RawDataBlock
Definition: LArRodBlockPhysicsV2.h:126
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
LArRodBlockPhysicsV2::clearBlocks
void clearBlocks()
Definition: LArRodBlockPhysicsV2.cxx:73
LArRodBlockPhysicsV2::setRawData
virtual void setRawData(const int channel, const std::vector< short > &samples, const uint32_t gain)
Definition: LArRodBlockPhysicsV2.cxx:245
LArRodBlockPhysicsV2::FEBID
@ FEBID
Definition: LArRodBlockPhysicsV2.h:58
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
LArRodBlockStructure::getNumberOfWords
uint32_t getNumberOfWords() const
Definition: LArRodBlockStructure.h:428
index
Definition: index.py:1
LArRodBlockPhysicsV2::initializeFEB
virtual void initializeFEB(const uint32_t id)
Definition: LArRodBlockPhysicsV2.cxx:306
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
LArRodBlockStructure::m_FebBlockSize
int32_t m_FebBlockSize
Definition: LArRodBlockStructure.h:229
LArRodBlockPhysicsV2::getNextRawData
virtual int getNextRawData(int &channelNumber, std::vector< short > &samples, uint32_t &gain)
Definition: LArRodBlockPhysicsV2.cxx:401
LArRodBlockPhysicsV2::setNextEnergy
virtual void setNextEnergy(const int channel, const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain)
Definition: LArRodBlockPhysicsV2.cxx:177
LArRodBlockStructure::LE_getVectorHeader16
uint16_t LE_getVectorHeader16(const unsigned n) const
Definition: LArRodBlockStructure.h:410
LArRodBlockPhysicsV2::m_RawDataIndex
int m_RawDataIndex
Definition: LArRodBlockPhysicsV2.h:131
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
LArRodBlockPhysicsV2::m_NFlaggingWords
unsigned short m_NFlaggingWords
Definition: LArRodBlockPhysicsV2.h:141
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
LArRodBlockStructure::m_FebBlock
const uint32_t * m_FebBlock
Definition: LArRodBlockStructure.h:227
LArRodBlockPhysicsV2::sortDataVector
virtual void sortDataVector(std::vector< const LArRawChannel * > &)
LArRodBlockPhysicsV2::Status2
@ Status2
Definition: LArRodBlockPhysicsV2.h:66
HWIdentifier
Definition: HWIdentifier.h:13
CaloGain::LARNGAIN
@ LARNGAIN
Definition: CaloGain.h:19
LArRodBlockPhysicsV2.h
x
#define x
xAOD::int16_t
setScaleOne setStatusOne setSaturated int16_t
Definition: gFexGlobalRoI_v1.cxx:55
LArRodBlockStructure::m_pRODblock
std::vector< uint32_t > * m_pRODblock
Definition: LArRodBlockStructure.h:232
LArRodBlockPhysicsV2::getRadd
virtual uint32_t getRadd(uint32_t adc, uint32_t sample) const
Definition: LArRodBlockPhysicsV2.cxx:628
LARBSDBG
#define LARBSDBG(text)
Definition: LArRodBlockPhysicsV2.cxx:26
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
LArRodBlockPhysicsV2::m_logstr
MsgStream m_logstr
Definition: LArRodBlockPhysicsV2.h:151
LArRodBlockPhysicsV2::finalizeFEB
virtual void finalizeFEB()
Definition: LArRodBlockPhysicsV2.cxx:318
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
LArRodBlockStructure::m_iHeadBlockSize
unsigned short m_iHeadBlockSize
Definition: LArRodBlockStructure.h:221
LArRodBlockStructure::m_rearrangeFirstSample
unsigned int m_rearrangeFirstSample
Definition: LArRodBlockStructure.h:241
id2
HWIdentifier id2
Definition: LArRodBlockPhysicsV2.cxx:596
LArRodBlockStructure::getHeader32
uint32_t getHeader32(const unsigned n) const
Definition: LArRodBlockStructure.h:365
LArRodBlockPhysicsV2::m_HighEIndex
int m_HighEIndex
Definition: LArRodBlockPhysicsV2.h:132
LArDigit.h
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:116
lumiFormat.i
int i
Definition: lumiFormat.py:85
Athena
Some weak symbol referencing magic...
Definition: AthLegacySequence.h:21
beamspotman.n
n
Definition: beamspotman.py:731
LArRodBlockPhysicsV2::m_GainPtr
const uint32_t * m_GainPtr
Definition: LArRodBlockPhysicsV2.h:136
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LArRodBlockPhysicsV2::getCtrl2
virtual uint16_t getCtrl2(uint32_t adc) const
Definition: LArRodBlockPhysicsV2.cxx:647
LArRodBlockPhysicsV2::m_LowEnergyBlock
std::vector< uint32_t > m_LowEnergyBlock
Definition: LArRodBlockPhysicsV2.h:124
LArRodBlockPhysicsV2::endtag
@ endtag
Definition: LArRodBlockPhysicsV2.h:70
LArRodBlockPhysicsV2::getCtrl1
virtual uint16_t getCtrl1(uint32_t adc) const
Definition: LArRodBlockPhysicsV2.cxx:638
LArRodBlockPhysicsV2::getNumberOfSamples
virtual uint32_t getNumberOfSamples() const
LArRodBlockStructure::getBit
int getBit(const uint32_t *const p, const unsigned chan) const
Definition: LArRodBlockStructure.h:433
LArRodBlockStructure::LE_setHeader16
void LE_setHeader16(const unsigned n, const uint16_t w)
Definition: LArRodBlockStructure.h:417
LArRodBlockPhysicsV2::LowEBlkOffset
@ LowEBlkOffset
Definition: LArRodBlockPhysicsV2.h:63
LArRawChannel.h
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
LArRodBlockPhysicsV2::m_RawDataPtr
const uint16_t * m_RawDataPtr
Definition: LArRodBlockPhysicsV2.h:134
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
LArRodBlockPhysicsV2::m_DummyBitMap
static const uint32_t m_DummyBitMap[4]
Definition: LArRodBlockPhysicsV2.h:145
LArRodBlockPhysicsV2::setPointers
virtual bool setPointers()
Definition: LArRodBlockPhysicsV2.cxx:89
LArRodBlockPhysicsV2::getNumberOfGains
virtual uint32_t getNumberOfGains() const
LArRodBlockPhysicsV2::setNumberOfGains
virtual void setNumberOfGains(const uint8_t n)
Definition: LArRodBlockPhysicsV2.cxx:171
LArOnlineID
Definition: LArOnlineID.h:20
LArRodBlockPhysicsV2::m_LowEPtr
const int16_t * m_LowEPtr
Definition: LArRodBlockPhysicsV2.h:139
LArRodBlockStructure::LE_getHeader16
uint16_t LE_getHeader16(const unsigned n) const
Definition: LArRodBlockStructure.h:405
ReadOfcFromCool.nsamples
nsamples
Definition: ReadOfcFromCool.py:115
LArRodBlockPhysicsV2::m_EIndex
int m_EIndex
Definition: LArRodBlockPhysicsV2.h:133
LArRodBlockStructure::m_MiddleHeaderSize
int32_t m_MiddleHeaderSize
Definition: LArRodBlockStructure.h:239
LArRodBlockPhysicsV2::concatinateFEBs
virtual void concatinateFEBs()
Definition: LArRodBlockPhysicsV2.cxx:370
LArRodBlockPhysicsV2::RawDataBlkOffset
@ RawDataBlkOffset
Definition: LArRodBlockPhysicsV2.h:65
DeMoScan.index
string index
Definition: DeMoScan.py:364
LArRodBlockPhysicsV2::resetPointers
virtual void resetPointers()
Definition: LArRodBlockPhysicsV2.cxx:79
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
LArRodBlockPhysicsV2::initializeFragment
virtual void initializeFragment(std::vector< uint32_t > &fragment)
Definition: LArRodBlockPhysicsV2.cxx:278
LArRodBlockPhysicsV2::HighEBlkOffset
@ HighEBlkOffset
Definition: LArRodBlockPhysicsV2.h:62
DEBUG
#define DEBUG
Definition: page_access.h:11
LArRodBlockPhysicsV2::m_FlagPtr
const uint32_t * m_FlagPtr
Definition: LArRodBlockPhysicsV2.h:138
LArRodBlockStructure::setBit
void setBit(uint32_t *const p, const unsigned chan)
Definition: LArRodBlockStructure.h:444
LArRodBlockPhysicsV2::m_HighEnergyBlock
std::vector< uint32_t > m_HighEnergyBlock
Definition: LArRodBlockPhysicsV2.h:125
LArRodBlockPhysicsV2::NGainNSamples
@ NGainNSamples
Definition: LArRodBlockPhysicsV2.h:64
LArRodBlockPhysicsV2::m_LowEIndex
int m_LowEIndex
Definition: LArRodBlockPhysicsV2.h:130
LArRodBlockPhysicsV2::getCtrl3
virtual uint16_t getCtrl3(uint32_t adc) const
Definition: LArRodBlockPhysicsV2.cxx:656
febId1
HWIdentifier febId1
Definition: LArRodBlockPhysicsV2.cxx:598
LArRodBlockPhysicsV2::m_RawDataFlagsPtr
const uint32_t * m_RawDataFlagsPtr
Definition: LArRodBlockPhysicsV2.h:135
LArRodBlockPhysicsV2::m_HighEPtr
const int32_t * m_HighEPtr
Definition: LArRodBlockPhysicsV2.h:137
LArRodBlockStructure::m_channelsPerFEB
int m_channelsPerFEB
Definition: LArRodBlockStructure.h:225
LArRodBlockPhysicsV2::LArRodBlockPhysicsV2
LArRodBlockPhysicsV2()
Definition: LArRodBlockPhysicsV2.cxx:38
LArRodBlockStructure::m_mFebBlocks
FEBMAPTYPE m_mFebBlocks
Definition: LArRodBlockStructure.h:234
LArOnlineID.h
LArRodBlockStructure::setHeader32
void setHeader32(const unsigned n, const uint32_t w)
Definition: LArRodBlockStructure.h:394