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