ATLAS Offline Software
TBByteStreamCnvTool.h
Go to the documentation of this file.
1 //Dear emacs, this is -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef TESTBEAM_BYTESTREAMTOOL_H
8 #define TESTBEAM_BYTESTREAMTOOL_H
9 
10 #include <stdint.h>
11 #include <string>
12 
14 #include "ByteStreamData/RawEvent.h"
15 #include "EventInfo/EventInfo.h"
16 #include "EventInfo/EventID.h"
19 #include "TBEvent/TBTDC.h"
20 #include "TBEvent/TBBeamDetector.h"
21 #include "TBEvent/TBBPCRawCont.h"
22 #include "TBEvent/TBMWPCRawCont.h"
26 #include "TBEvent/TBADCRawCont.h"
27 #include "TBEvent/TBTDCRawCont.h"
28 #include "TBEvent/TBEventInfo.h"
32 
34 
35 #include "eformat/SourceIdentifier.h"
36 
38 class LArOnlineID;
39 
48 public:
49 
52  TBByteStreamCnvTool( const std::string& type, const std::string& name,
53  const IInterface* parent ) ;
54 
55  static const InterfaceID& interfaceID( ) ;
56 
57  virtual StatusCode initialize();
58  virtual StatusCode finalize();
59 
60 
61 
63  StatusCode ReadFragment(int unrec_code);
64  StatusCode ReadFragment(TBTDC*& tdc,const std::string& key);
65  StatusCode ReadFragment(TBTDCRawCont*& tdcrawCont,const std::string& key);
66  StatusCode ReadFragment(TBADCRawCont*& adcrawCont,const std::string& key);
67  StatusCode ReadFragment(TBBPCRawCont*& bpcrawCont,const std::string& key);
68  StatusCode ReadFragment(TBMWPCRawCont*& mwpcrawCont,const std::string& key);
69  StatusCode ReadFragment(TBTriggerPatternUnit*& trigpat,const std::string& key);
70  StatusCode ReadFragment(TBScintillatorRawCont*& scintrawCont,const std::string& key);
71  StatusCode ReadFragment(TBTailCatcherRaw*& tailcatchraw,const std::string& key);
72  StatusCode ReadFragment(TBEventInfo*& tbeventinfo,const std::string& key);
73  StatusCode ReadFragment(TBLArDigitContainer*& tblardigitcont,const std::string& key);
74  StatusCode ReadFragment(TBLArCalibDigitContainer*& tblarcalibdigitcont,const std::string& key);
75 
76  StatusCode BuildRODBlock(std::vector<uint32_t>* theRODBlock);
77  StatusCode GetRODBlock(eformat::SubDetector subdet_id,
78  eformat::SubDetector subdet_rod_id=m_DontCheckRodSubDetID);
79 
80  StatusCode H6BuildObjects(int unrec_code);
81  StatusCode H6RecordObjects(int unrec_code);
82  StatusCode H8BuildObjects(int unrec_code);
83 
84 
85 
86 
87 private:
88 
89  static const eformat::SubDetector m_DontCheckRodSubDetID; //==0xff
90 
94  eformat::SubDetector m_subdet_id{};
95  std::vector<uint32_t> m_rodBlock; //For reading only : data fragment
97 
98  // event fragments for writing
99  std::vector<uint32_t> * m_theRodBlock{};
101 
102  bool m_H6run{};
103  bool m_H8run{};
105  bool m_dump{};
106  std::vector<std::string> m_keys;
108 
109  // H6 SubFragment navigation :
113 
114  bool NextSubFrag(){
116  if(m_subfrag_firstdata<int(m_rodBlock.size())){
119  return true;
120  }else return false;
121  }
122 
124  {this, "CalibLineKey", "LArCalibLineMap", "SG calib line key"};
125 
126  // pointers to raw objects :
138 
139 
140  // MiniROD members
141  std::vector<int> m_boards;
142  std::vector<int> m_samples;
143  std::vector<int> m_gains;
144  std::vector<int> m_febgain;
145  std::vector<int> m_firstsamples;
146  std::vector<short> m_arrayofsample[128][4]; // 128 channels, 4 possible gain mode
147  CaloGain::CaloGain m_arrayofgain[128][4]{}; // 128 channels.
148 
149 
151  switch(gain){
152  case 0:
153  return CaloGain::LARLOWGAIN;
154  case 1:
156  case 2:
157  return CaloGain::LARHIGHGAIN;
158  default:
159  return CaloGain::UNKNOWNGAIN;
160  }
161  }
162 
163 
164 
165  // Calibration runs :
166  bool m_isCalib{};
167  unsigned char m_calib_pattern[16]{};
170  bool m_calib_error{}; //m_calib_isPulsed{};
171 
172 
173  // Run - Event Info :
174 
175  int m_ev_number{};
176  unsigned int m_run_num{};
177  float m_beam_moment{};
178  std::string m_beam_part;
179  float m_cryoX{};
180  float m_cryoAngle{};
181  float m_tableY{};
182  std::string m_summary_path;
183 
184 
185 
186  // H8 trigger word
187  unsigned int m_h8_triggword{};
188 
189  // Word manipulation :
190  unsigned short firstword(unsigned int w){
191  return 65535 & w;
192  }
193  unsigned short secondword(unsigned int w){
194  return w >> 16;
195  }
196 
197  unsigned short firstnbit(int n,unsigned short w){
198  unsigned short tmp=0;
199  for(unsigned short i=0;i<n;i++) tmp = tmp | (1<<i);
200  return (w & tmp);
201  }
202 
203  bool testbit(int n,unsigned short w){
204  return (w & (1<<n));
205  }
206 
207 };
208 
209 #endif
210 
211 
212 
213 
214 
215 
TBByteStreamCnvTool::m_tableY
float m_tableY
Definition: TBByteStreamCnvTool.h:181
TBByteStreamCnvTool::m_h8_triggword
unsigned int m_h8_triggword
Definition: TBByteStreamCnvTool.h:187
TBByteStreamCnvTool::m_boards
std::vector< int > m_boards
Definition: TBByteStreamCnvTool.h:141
TBByteStreamCnvTool::m_tailcatchraw
TBTailCatcherRaw * m_tailcatchraw
Definition: TBByteStreamCnvTool.h:134
TBBeamDetector.h
TBMWPCRawCont.h
TBByteStreamCnvTool::m_cryoX
float m_cryoX
Definition: TBByteStreamCnvTool.h:179
TBTDC.h
TBByteStreamCnvTool::m_summary_path
std::string m_summary_path
Definition: TBByteStreamCnvTool.h:182
TBByteStreamCnvTool::m_H8run
bool m_H8run
Definition: TBByteStreamCnvTool.h:103
TBByteStreamCnvTool::m_firstsamples
std::vector< int > m_firstsamples
Definition: TBByteStreamCnvTool.h:145
TBByteStreamCnvTool::m_calib_error
bool m_calib_error
Definition: TBByteStreamCnvTool.h:170
TBByteStreamCnvTool::m_tbtdc
TBTDC * m_tbtdc
Definition: TBByteStreamCnvTool.h:127
CaloGain::UNKNOWNGAIN
@ UNKNOWNGAIN
Definition: CaloGain.h:20
TBByteStreamCnvTool::m_ByteStreamEventAccess
ServiceHandle< IByteStreamEventAccess > m_ByteStreamEventAccess
Definition: TBByteStreamCnvTool.h:91
TBADCRawCont.h
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
TBMWPCRawCont
Definition: TBMWPCRawCont.h:18
TBByteStreamCnvTool::m_keys
std::vector< std::string > m_keys
Definition: TBByteStreamCnvTool.h:106
TBByteStreamCnvTool::m_lastEventID
EventID m_lastEventID
Definition: TBByteStreamCnvTool.h:93
TBByteStreamCnvTool::m_H6run
bool m_H6run
Definition: TBByteStreamCnvTool.h:102
TBByteStreamCnvTool::m_arrayofgain
CaloGain::CaloGain m_arrayofgain[128][4]
Definition: TBByteStreamCnvTool.h:147
TBByteStreamCnvTool::getCaloGain
CaloGain::CaloGain getCaloGain(int gain)
Definition: TBByteStreamCnvTool.h:150
IByteStreamEventAccess.h
TBScintillatorRawCont.h
TBTriggerPatternUnit.h
TBByteStreamCnvTool::interfaceID
static const InterfaceID & interfaceID()
Definition: TBByteStreamCnvTool.cxx:30
TBByteStreamCnvTool::m_theROB
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * m_theROB
Definition: TBByteStreamCnvTool.h:100
TBLArDigitContainer.h
TBByteStreamCnvTool::m_CLKey
SG::ReadCondHandleKey< LArCalibLineMapping > m_CLKey
Definition: TBByteStreamCnvTool.h:124
TBByteStreamCnvTool::m_beam_moment
float m_beam_moment
Definition: TBByteStreamCnvTool.h:177
TBByteStreamCnvTool::m_rodBlock
std::vector< uint32_t > m_rodBlock
Definition: TBByteStreamCnvTool.h:95
TBByteStreamCnvTool::m_theRodBlock
std::vector< uint32_t > * m_theRodBlock
Definition: TBByteStreamCnvTool.h:99
TBByteStreamCnvTool::m_febgain
std::vector< int > m_febgain
Definition: TBByteStreamCnvTool.h:144
TBByteStreamCnvTool::m_eventinfo
TBEventInfo * m_eventinfo
Definition: TBByteStreamCnvTool.h:135
TBByteStreamCnvTool::m_calib_pattern
unsigned char m_calib_pattern[16]
Definition: TBByteStreamCnvTool.h:167
TBTDCRawCont.h
IROBDataProviderSvc
Interface class for managing ROB for both online and offline.
Definition: IROBDataProviderSvc.h:23
TBLArCalibDigitContainer
Liquid Argon Calibration Digit Container
Definition: TBLArCalibDigitContainer.h:26
TBByteStreamCnvTool::GetRODBlock
StatusCode GetRODBlock(eformat::SubDetector subdet_id, eformat::SubDetector subdet_rod_id=m_DontCheckRodSubDetID)
Definition: TBByteStreamCnvTool.cxx:395
EventID.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
TBByteStreamCnvTool::firstnbit
unsigned short firstnbit(int n, unsigned short w)
Definition: TBByteStreamCnvTool.h:197
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
TBByteStreamCnvTool::H6RecordObjects
StatusCode H6RecordObjects(int unrec_code)
Definition: TBByteStreamCnvTool.cxx:1912
TBByteStreamCnvTool::m_gains
std::vector< int > m_gains
Definition: TBByteStreamCnvTool.h:143
lumiFormat.i
int i
Definition: lumiFormat.py:85
TBByteStreamCnvTool::m_samples
std::vector< int > m_samples
Definition: TBByteStreamCnvTool.h:142
beamspotman.n
n
Definition: beamspotman.py:731
RawEvent.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TBLArCalibDigitContainer.h
TBByteStreamCnvTool::m_mwpcrawCont
TBMWPCRawCont * m_mwpcrawCont
Definition: TBByteStreamCnvTool.h:131
AthAlgTool.h
TBByteStreamCnvTool::m_tdcrawCont
TBTDCRawCont * m_tdcrawCont
Definition: TBByteStreamCnvTool.h:128
TBByteStreamCnvTool::WriteFragment
StatusCode WriteFragment()
Definition: TBByteStreamCnvTool.cxx:133
TBByteStreamCnvTool::m_isCalib
bool m_isCalib
Definition: TBByteStreamCnvTool.h:166
test_pyathena.parent
parent
Definition: test_pyathena.py:15
TBByteStreamCnvTool::secondword
unsigned short secondword(unsigned int w)
Definition: TBByteStreamCnvTool.h:193
TBByteStreamCnvTool::m_subdet_key
int m_subdet_key
Definition: TBByteStreamCnvTool.h:107
TBBPCRawCont.h
TBTDCRawCont
Definition: TBTDCRawCont.h:21
TBByteStreamCnvTool::m_ev_number
int m_ev_number
Definition: TBByteStreamCnvTool.h:175
ByteStreamAddress.h
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
TBByteStreamCnvTool::ReadFragment
StatusCode ReadFragment(int unrec_code)
Definition: TBByteStreamCnvTool.cxx:262
TBTDC
Definition: TBTDC.h:17
TBByteStreamCnvTool::NextSubFrag
bool NextSubFrag()
Definition: TBByteStreamCnvTool.h:114
TBByteStreamCnvTool::m_subfrag_firstdata
int m_subfrag_firstdata
Definition: TBByteStreamCnvTool.h:112
TBByteStreamCnvTool::H6BuildObjects
StatusCode H6BuildObjects(int unrec_code)
Definition: TBByteStreamCnvTool.cxx:502
TBByteStreamCnvTool
An AlgTool class to provide conversion ByteStream <-> TestBeam Instrumentation Data created Feb 2004 ...
Definition: TBByteStreamCnvTool.h:47
TBByteStreamCnvTool::initialize
virtual StatusCode initialize()
Definition: TBByteStreamCnvTool.cxx:59
TBByteStreamCnvTool::m_subfrag_id
int m_subfrag_id
Definition: TBByteStreamCnvTool.h:110
TBByteStreamCnvTool::m_trigpat
TBTriggerPatternUnit * m_trigpat
Definition: TBByteStreamCnvTool.h:132
TBByteStreamCnvTool::m_beam_part
std::string m_beam_part
Definition: TBByteStreamCnvTool.h:178
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TBByteStreamCnvTool::m_rdpSvc
ServiceHandle< IROBDataProviderSvc > m_rdpSvc
Definition: TBByteStreamCnvTool.h:92
TBByteStreamCnvTool::m_run_num
unsigned int m_run_num
Definition: TBByteStreamCnvTool.h:176
LArOnlineID
Definition: LArOnlineID.h:20
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
TBByteStreamCnvTool::m_force_Hchoice
bool m_force_Hchoice
Definition: TBByteStreamCnvTool.h:104
TBByteStreamCnvTool::BuildRODBlock
StatusCode BuildRODBlock(std::vector< uint32_t > *theRODBlock)
Definition: TBByteStreamCnvTool.cxx:191
TBByteStreamCnvTool::TBByteStreamCnvTool
TBByteStreamCnvTool(const std::string &type, const std::string &name, const IInterface *parent)
constructor
Definition: TBByteStreamCnvTool.cxx:40
TBByteStreamCnvTool::m_cryoAngle
float m_cryoAngle
Definition: TBByteStreamCnvTool.h:180
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
TBByteStreamCnvTool::m_onlineHelper
const LArOnlineID * m_onlineHelper
Definition: TBByteStreamCnvTool.h:96
SG::ReadCondHandleKey< LArCalibLineMapping >
TBByteStreamCnvTool::m_tblarcalibdigitcont
TBLArCalibDigitContainer * m_tblarcalibdigitcont[4]
Definition: TBByteStreamCnvTool.h:137
CaloGain::LARMEDIUMGAIN
@ LARMEDIUMGAIN
Definition: CaloGain.h:18
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment
eformat::write::ROBFragment ROBFragment
Definition: RawEvent.h:33
TBEventInfo
Definition: TBEventInfo.h:27
TBByteStreamCnvTool::m_calib_dac
uint16_t m_calib_dac
Definition: TBByteStreamCnvTool.h:168
TBByteStreamCnvTool::m_scintrawCont
TBScintillatorRawCont * m_scintrawCont
Definition: TBByteStreamCnvTool.h:133
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TBByteStreamCnvTool::m_bpcrawCont
TBBPCRawCont * m_bpcrawCont
Definition: TBByteStreamCnvTool.h:130
TBByteStreamCnvTool::m_calib_delay
uint16_t m_calib_delay
Definition: TBByteStreamCnvTool.h:169
EventID
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventID.h:35
TBTailCatcherRaw.h
TBByteStreamCnvTool::H8BuildObjects
StatusCode H8BuildObjects(int unrec_code)
Definition: TBByteStreamCnvTool.cxx:1279
TBByteStreamCnvTool::m_DontCheckRodSubDetID
static const eformat::SubDetector m_DontCheckRodSubDetID
Definition: TBByteStreamCnvTool.h:89
TBByteStreamCnvTool::finalize
virtual StatusCode finalize()
Definition: TBByteStreamCnvTool.cxx:122
TBEventInfo.h
TBTriggerPatternUnit
Definition: TBTriggerPatternUnit.h:27
TBByteStreamCnvTool::testbit
bool testbit(int n, unsigned short w)
Definition: TBByteStreamCnvTool.h:203
TBLArDigitContainer
Gaudi Class ID.
Definition: TBLArDigitContainer.h:40
TBByteStreamCnvTool::firstword
unsigned short firstword(unsigned int w)
Definition: TBByteStreamCnvTool.h:190
AthAlgTool
Definition: AthAlgTool.h:26
TBTailCatcherRaw
Definition: TBTailCatcherRaw.h:25
CaloGain::LARLOWGAIN
@ LARLOWGAIN
Definition: CaloGain.h:18
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
TBByteStreamCnvTool::m_subfrag_size
int m_subfrag_size
Definition: TBByteStreamCnvTool.h:111
CaloGain.h
TBByteStreamCnvTool::m_subdet_id
eformat::SubDetector m_subdet_id
Definition: TBByteStreamCnvTool.h:94
LArCalibLineMapping.h
TBADCRawCont
Definition: TBADCRawCont.h:20
TBScintillatorRawCont
Definition: TBScintillatorRawCont.h:18
TBByteStreamCnvTool::m_tblardigitcont
TBLArDigitContainer * m_tblardigitcont[4]
Definition: TBByteStreamCnvTool.h:136
TBByteStreamCnvTool::m_arrayofsample
std::vector< short > m_arrayofsample[128][4]
Definition: TBByteStreamCnvTool.h:146
TBBPCRawCont
Definition: TBBPCRawCont.h:17
TBByteStreamCnvTool::m_dump
bool m_dump
Definition: TBByteStreamCnvTool.h:105
TBByteStreamCnvTool::m_adcrawCont
TBADCRawCont * m_adcrawCont
Definition: TBByteStreamCnvTool.h:129
ServiceHandle< IByteStreamEventAccess >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37