DAQChannelMapBaseOLD.h
Go to the documentation of this file.
1 /*
2  * File: DAQChannelMapBaseOLD.h
3  * Author: denis
4  *
5  * This is the base class for DAQChannelMap.
6  * It is an abstract class.
7  * Here we precalculate some stuff, which are going to be use in the derived class
8  *
9  * Created on February 10, 2012, 10:17 AM
10  */
11 
12 #ifndef _DAQCHANNELMAPBASEOLD_H
13 #define _DAQCHANNELMAPBASEOLD_H
14 
15 #include "DAQChannelMap/DAQChannelMapErrorsOLD.h"
16 #include "DAQChannelMap/DAQChannelMapConstantsOLD.h"
17 #include "DAQChannelMap/DAQChannelMapConstants.h"
18 
19 #include <string>
20 #include <vector>
21 
22 typedef unsigned int uint;
23 
24 namespace daqchannelmap { //!< DAQ Channel Map Package
25 
26 #ifndef EVEN
27 #define EVEN(x) (0 == ((x) % 2)) ? 1 : 0
28 #endif
29 
30 #ifndef ODD
31 #define ODD(x) (1 == ((x) % 2)) ? 1 : 0
32 #endif
33 
34 
35 //#define BOUNDS_CHECK_ALL /* Define this macro to enable bounds checking */
36 
37 /// This thing has to have a comma at the end or it could be entirely empty
38 #define CHAN_IDX_0_1 0x0,
39 
41 
42  /// Some type defs
43  typedef std::vector< uint32_t > numberOfPlanesInBlock_t;
44  typedef std::vector< uint32_t > numberOfPlanesInDiblock_t;
45  typedef std::vector< numberOfPlanesInBlock_t > numberOfTypePlanesInBlock_t;
46  typedef std::vector< numberOfPlanesInDiblock_t > numberOfTypePlanesInDiblock_t;
47  typedef std::vector< std::vector <uint32_t> > numberOfPlanesInBlockDetector_t;
48  typedef std::vector< std::vector <uint32_t> > numberOfDCMsInDiblockDetector_t;
49 
50 
51 
52  public:
54  virtual ~DAQChannelMapBaseOLD();
55 
56  /// Print all detectors info
57  bool print() const;
58  bool print(const int detId, const offline_plane_t) const;
59 
60 
61  /// Pixel number from APDPixel
63  /// APDPixel number from Pixel
65 
66  /// Diblock type given detectorID and diblock number
68 
69  /// Number of planes in the block given detectorID and block number
70  uint32_t getNumberOfPlanesInBlock (int detId, block_t) const;
71  /// Number of planes in the diblock given detectorID and diblock number
72  uint32_t getNumberOfPlanesInDiblock(int detId, diblock_t) const;
73 
74  /// Number of planes before block or diblock
75  uint32_t getNumberOfPlanesBeforeBlock(int detId, block_t) const;
76  uint32_t getNumberOfPlanesBeforeDiblock(int detId, diblock_t) const;
77 
78  /// Number of planes in the block given block type
79  uint32_t getNumberOfPlanesInBlock (DetBlock_TYPE) const;
80  /// Number of planes in the diblock given diblock type
82 
83  /// Number of planes (X or Y) in the block given block type and type of plane(X or Y)
85  /// Number of planes (X or Y) in the diblock given diblock type and type of plane(X or Y)
87 
88  /// Block type given diblock type an local block in diblock
89  DetBlock_TYPE getBlockType(DiBlock_TYPE, uint32_t local_block_number_in_diblock) const;
90  /// Starting plane in the block given its type
92 
93  /// get Plane type
94  DetPlane_TYPE getPlaneType(const int detId, const offline_plane_t) const;
95  //DetPlane_TYPE getPlaneType(const int detId, const offline_plane_t, const DetBlock_TYPE block_type) const;
96 
97  /// Get minimum detector ID
98  int getDetectorIDMinimum() const;
99  /// Get maximum detector ID
100  int getDetectorIDMaximum() const;
101 
102  /// The block number given the detectorID and offline plane number
103  uint32_t getBlockNumber (int detId, offline_plane_t) const;
104  /// The diblock number given the detectorID and offline plane number
105  uint32_t getDiblockNumber (int detId, offline_plane_t) const;
106  uint32_t getDiblockNumber (const block_t) const;
107  uint32_t getLocalBlockInDiblock (const block_t) const;
108 
109  /// Local plane in block number given the detectorID and offline plane number
111  /// Local plane in diblock number given the detectorID and offline plane number
113 
114 
115  /// opposite plane view from the input. For instance Y = getOtherView(X)
117  /// opposite plane view from the input. For instance Y = getOtherView(X)
119  /// Conversion from DetPlane_TYPE to DetView_TYPE
121  /// Conversion from DetView_TYPE to DetPlane_TYPE
123 
124  /// Number of DCMs for horizontal planes in the diblock given detectorID and Diblock type
125  uint32_t getNumberOfXDCM(int detId, DiBlock_TYPE) const;
126  /// Number of DCMs for vertical planes in the diblock given detectorID and Diblock type
127  uint32_t getNumberOfYDCM(int detId, DiBlock_TYPE) const;
128  /// Total number of DCMs in the diblock given detectorID and Diblock type
129  uint32_t getNumberOfDCM(int detId, DiBlock_TYPE) const;
130 
131  /// Number of channels in X plane for a given detectorID
132  uint32_t getNumberOfChannelsInXPlane(int detId) const;
133  /// Number of channels in Y plane for a given detectorID
134  uint32_t getNumberOfChannelsInYPlane(int detId) const;
135 
136  /// Get Number of channels in plane
137  uint32_t getNumberOfChannelsInPlane(const int detId, const DetPlane_TYPE) const;
138  uint32_t getNumberOfChannelsInPlane(const int detId, const offline_plane_t) const;
139 
140  /// Number of cells per DCM for a given diblock type
141  uint32_t getNumberOfCellsPerDCM(DiBlock_TYPE) const;
142 
143  /// Total number of blocks for a given detector
144  uint32_t getTotalNumberOfBlocks(int detId) const; ///< Total number of diblocks in the detector
145  /// Total number of diblocks for a given detector
146  uint32_t getTotalNumberOfDiblocks(int detId) const; ///< Total number of diblocks in the detector
147 
148  /// Total number of Planes in the detector
149  uint32_t getTotalNumberOfPlanes(const int detId) const;
150 
151  // Error Message Related
152  const char* errorString(DAQChanMapErrorCodes err_code) const;
153 
154  private:
155 
156  uint32_t getBlockOrDiblock (int detId
158  ,const numberOfPlanesInBlockDetector_t&
159  ,const BlockNumerationOffset
160  ) const;
161  uint32_t getBlockOrDiblock (int detId
163  ,const uint32_t max_number_of_blocks_or_diblocks
164  ,const uint**
165  ,const BlockNumerationOffset
166  ) const;
167 
170  ,const numberOfPlanesInBlockDetector_t&
171  ,const BlockNumerationOffset
172  ) const;
173 
175  ,const offline_plane_t
176  ,const uint32_t max_number_of_blocks_or_diblocks
177  ,const uint**
178  ,const BlockNumerationOffset
179  ) const;
180 
181  /// Initialization methods
184  bool initPlanesInBlockID();
186  bool initPlanesInDiblockID();
192 
193 
194  /// Checks for Initialization methods
197  bool isinitPlanesInBlockID();
204 
205  bool initApdPixel2PixelMap();
206 
207  bool allocateArray(uint32_t**&, const std::vector< std::vector<uint32_t> >&);
208  bool allocateSize (uint32_t*& , const std::vector< std::vector<uint32_t> >&);
209  private:
210  static const char* DetectorLabels[];
211  const static unsigned int NUM_XCHAN_PLANE[];
212  const static unsigned int NUM_YCHAN_PLANE[];
213  const static unsigned int NUM_DIBLOCK_DET[];
214  const static unsigned int NUM_DCMS_DIBLOCK[];
215  const static unsigned int NUM_X_DCMS[];
216  const static unsigned int NUM_Y_DCMS[];
217  const static unsigned int apd_pixel2cell_v0[],apd_cell2pixel_v0[];
218 
219  const static unsigned int DetectorDiBlockConfig_IPND[];
220  const static unsigned int DetectorDiBlockConfig_NDOS[];
221  const static unsigned int DetectorDiBlockConfig_NEARDET[];
222  const static unsigned int DetectorDiBlockConfig_FARDET[];
223  const static unsigned int DetectorDiBlockConfig_TESTBEAM_2Block_1x1[];
224  const static unsigned int DetectorDiBlockConfig_TESTBEAM_3Block_1x1[];
225  const static unsigned int DetectorDiBlockConfig_TESTBEAM_2Block_2x2[];
226  const static unsigned int DetectorDiBlockConfig_TESTBEAM_3Block_2x2[];
227  std::vector< std::vector <uint32_t> > DetectorDiBlockConfigVector;
229 
230  std::vector<uint32_t> getVector(const unsigned int*, const unsigned int maxsize=1000000);
232 
233 
234  std::vector<uint32_t> _planesInDiblockType; //Number of planes in diblock type
235  std::vector<uint32_t> _planesInBlockType; //Number of planes in diblock type
238 
239  numberOfPlanesInBlockDetector_t _planesInDiblockDetector; // array depends on detector and diblock number
240  numberOfPlanesInBlockDetector_t _planesInBlockDetector; // array depends on detector and diblock number
245 
246 
247  numberOfPlanesInBlockDetector_t _planesBeforeDiblockDetector; // array depends on detector and diblock number
248  numberOfPlanesInBlockDetector_t _planesBeforeBlockDetector; // array depends on detector and diblock number
251 
252  numberOfPlanesInBlockDetector_t _BlockOrderInDiblock; // The order of blocks in the diblock
254 
255 
256  std::vector<DetPlane_TYPE> _startPlaneTypeInBlock; ///< Does the block start with X or Y plane. Keyed by block
258 
259  numberOfTypePlanesInBlock_t _numberOfTypePlanesInBlock; /// Keyed bu the DetPlane_TYPE and
260  numberOfTypePlanesInDiblock_t _numberOfTypePlanesInDiBlock; /// Keyed bu the DetPlane_TYPE and
261  uint32_t** _numberOfTypePlanesInBlockArray; /// Keyed bu the DetPlane_TYPE and
262  uint32_t** _numberOfTypePlanesInDiBlockArray; /// Keyed bu the DetPlane_TYPE and
263 
264  std::vector<uint32_t> _numberOfCellsPerDCMInDiblock; /// Number of cells that each DCM caries for each diblock type
266 
267  numberOfDCMsInDiblockDetector_t _numberOfXDCMsInDiblockDetector;// holds how many DCMs we make in a diblock of particular type and of particular detector
268  numberOfDCMsInDiblockDetector_t _numberOfYDCMsInDiblockDetector;// holds how many DCMs we make in a diblock of particular type and of particular detector
271 
272  std::vector <pixel_t> _apdPixel2CellMap;
273  std::vector <apd_pixel_t> _cell2ApdPixelMap;
276 
277 
278  std::vector < std::vector <uint32_t> > _planeType_planeNumber; /// Plane type as a function of offline plane number and DetectorID
280 
281  std::vector <uint32_t> _totalNumberOfPlanes;
282 
283 
284  };
285 }// end of namespace daqchannelmap
286 
287 #endif /* _DAQCHANNELMAPBASE_H */
288 
uint32_t ** _numberOfTypePlanesInDiBlockArray
Keyed bu the DetPlane_TYPE and.
static const unsigned int apd_pixel2cell_v0[]
static const unsigned int NUM_YCHAN_PLANE[]
uint32_t getLocalBlockInDiblock(const block_t) const
uint32_t getNumberOfPlanesBeforeDiblock(int detId, diblock_t) const
static const unsigned int DetectorDiBlockConfig_FARDET[]
bool initNumberOfCellsPerDCMInDiblock()
Initialization methods.
DetBlock_TYPE
Types of Block.
uint32_t getNumberOfChannelsInPlane(const int detId, const DetPlane_TYPE) const
Get Number of channels in plane.
std::vector< uint32_t > _totalNumberOfPlanes
uint32_t pixel_t
Type for physical pixel on APD.
uint32_t getTotalNumberOfPlanes(const int detId) const
Total number of Planes in the detector.
numberOfPlanesInBlockDetector_t _planesBeforeBlockDetector
std::vector< numberOfPlanesInBlock_t > numberOfTypePlanesInBlock_t
uint32_t offline_plane_t
Type for offline plane. Offline counts from 0.
uint32_t getNumberOfCellsPerDCM(DiBlock_TYPE) const
Number of cells per DCM for a given diblock type.
std::vector< std::vector< uint32_t > > numberOfDCMsInDiblockDetector_t
uint32_t getNumberOfChannelsInYPlane(int detId) const
Number of channels in Y plane for a given detectorID.
DetPlane_TYPE getOtherPlaneType(DetPlane_TYPE) const
opposite plane view from the input. For instance Y = getOtherView(X)
std::vector< uint32_t > _planesInBlockType
DiBlock_TYPE getDiBlockType(int detId, diblock_t) const
Diblock type given detectorID and diblock number.
uint32_t getNumberOfPlanesInBlock(int detId, block_t) const
Number of planes in the block given detectorID and block number.
static const unsigned int apd_cell2pixel_v0[]
static const unsigned int DetectorDiBlockConfig_NEARDET[]
uint32_t getNumberOfXDCM(int detId, DiBlock_TYPE) const
Number of DCMs for horizontal planes in the diblock given detectorID and Diblock type.
uint32_t getNumberOfDCM(int detId, DiBlock_TYPE) const
Total number of DCMs in the diblock given detectorID and Diblock type.
std::vector< apd_pixel_t > _cell2ApdPixelMap
uint32_t getNumberOfYDCM(int detId, DiBlock_TYPE) const
Number of DCMs for vertical planes in the diblock given detectorID and Diblock type.
const char * errorString(DAQChanMapErrorCodes err_code) const
DetPlane_TYPE detViewToDetPlane(DetView_TYPE) const
Conversion from DetView_TYPE to DetPlane_TYPE.
numberOfPlanesInBlockDetector_t _planesInBlockDetector
numberOfDCMsInDiblockDetector_t _numberOfXDCMsInDiblockDetector
std::vector< DetPlane_TYPE > _startPlaneTypeInBlock
Does the block start with X or Y plane. Keyed by block.
uint32_t getBlockOrDiblock(int detId, offline_plane_t, const numberOfPlanesInBlockDetector_t &, const BlockNumerationOffset) const
std::vector< uint32_t > _planesInDiblockType
std::vector< numberOfPlanesInDiblock_t > numberOfTypePlanesInDiblock_t
offline_plane_t getLocalPlaneInBlockOrDiblock(int detId, offline_plane_t, const numberOfPlanesInBlockDetector_t &, const BlockNumerationOffset) const
DetBlock_TYPE getBlockType(DiBlock_TYPE, uint32_t local_block_number_in_diblock) const
Block type given diblock type an local block in diblock.
static const unsigned int NUM_X_DCMS[]
bool print() const
Print all detectors info.
numberOfTypePlanesInDiblock_t _numberOfTypePlanesInDiBlock
Keyed bu the DetPlane_TYPE and.
DetView_TYPE detPlaneToDetView(DetPlane_TYPE) const
Conversion from DetPlane_TYPE to DetView_TYPE.
std::vector< std::vector< uint32_t > > DetectorDiBlockConfigVector
std::vector< uint32_t > _numberOfCellsPerDCMInDiblock
Keyed bu the DetPlane_TYPE and.
std::vector< uint32_t > getVector(const unsigned int *, const unsigned int maxsize=1000000)
static const unsigned int DetectorDiBlockConfig_IPND[]
bool allocateArray(uint32_t **&, const std::vector< std::vector< uint32_t > > &)
static const unsigned int DetectorDiBlockConfig_NDOS[]
DetView_TYPE getOtherView(DetView_TYPE) const
opposite plane view from the input. For instance Y = getOtherView(X)
std::vector< std::vector< uint32_t > > numberOfPlanesInBlockDetector_t
pixel_t APDPixel2Pixel(apd_pixel_t) const
Pixel number from APDPixel.
uint32_t ** _planeType_planeNumberArray
Plane type as a function of offline plane number and DetectorID.
uint32_t getBlockNumber(int detId, offline_plane_t) const
The block number given the detectorID and offline plane number.
static const unsigned int DetectorDiBlockConfig_TESTBEAM_2Block_1x1[]
std::vector< std::vector< uint32_t > > _planeType_planeNumber
static const unsigned int NUM_Y_DCMS[]
static const unsigned int NUM_DIBLOCK_DET[]
bool allocateSize(uint32_t *&, const std::vector< std::vector< uint32_t > > &)
offline_plane_t getLocalPlaneInBlock(int detId, offline_plane_t) const
Local plane in block number given the detectorID and offline plane number.
uint32_t getTotalNumberOfDiblocks(int detId) const
Total number of diblocks for a given detector.
int getDetectorIDMinimum() const
Get minimum detector ID.
int getDetectorIDMaximum() const
Get maximum detector ID.
bool isinitNumberOfCellsPerDCMInDiblock()
Checks for Initialization methods.
numberOfPlanesInBlockDetector_t _planesInDiblockDetector
static const unsigned int DetectorDiBlockConfig_TESTBEAM_3Block_1x1[]
uint32_t ** _numberOfTypePlanesInBlockArray
Keyed bu the DetPlane_TYPE and.
uint32_t getTotalNumberOfBlocks(int detId) const
Total number of blocks for a given detector.
static const unsigned int DetectorDiBlockConfig_TESTBEAM_2Block_2x2[]
numberOfDCMsInDiblockDetector_t _numberOfYDCMsInDiblockDetector
static const unsigned int NUM_XCHAN_PLANE[]
DetView_TYPE
Types of Detector View.
static const unsigned int NUM_DCMS_DIBLOCK[]
uint32_t getNumberOfPlaneTypeInDiblock(DiBlock_TYPE, DetPlane_TYPE) const
Number of planes (X or Y) in the diblock given diblock type and type of plane(X or Y) ...
uint32_t diblock_t
Type for diblocks and blocks.
std::vector< uint32_t > numberOfPlanesInBlock_t
Some type defs.
DetPlane_TYPE
Types of Detector Plane.
uint32_t getNumberOfPlanesInDiblock(int detId, diblock_t) const
Number of planes in the diblock given detectorID and diblock number.
offline_plane_t getLocalPlaneInDiblock(int detId, offline_plane_t) const
Local plane in diblock number given the detectorID and offline plane number.
uint32_t * _numberOfCellsPerDCMInDiblockArray
Number of cells that each DCM caries for each diblock type.
DetPlane_TYPE getPlaneType(const int detId, const offline_plane_t) const
get Plane type
DiBlock_TYPE
Types of Diblock.
uint32_t getNumberOfChannelsInXPlane(int detId) const
Number of channels in X plane for a given detectorID.
numberOfTypePlanesInBlock_t _numberOfTypePlanesInBlock
uint32_t getDiblockNumber(int detId, offline_plane_t) const
The diblock number given the detectorID and offline plane number.
DetPlane_TYPE getStartPlaneTypeInBlock(DetBlock_TYPE) const
Starting plane in the block given its type.
bool initApdPixel2PixelMap()
Initialization methods.
std::vector< uint32_t > numberOfPlanesInDiblock_t
numberOfPlanesInBlockDetector_t _BlockOrderInDiblock
uint32_t getNumberOfPlaneTypeInBlock(DetBlock_TYPE, DetPlane_TYPE) const
Number of planes (X or Y) in the block given block type and type of plane(X or Y) ...
numberOfPlanesInBlockDetector_t _planesBeforeDiblockDetector
static const unsigned int DetectorDiBlockConfig_TESTBEAM_3Block_2x2[]
uint32_t getNumberOfPlanesBeforeBlock(int detId, block_t) const
Number of planes before block or diblock.
apd_pixel_t pixel2APDPixel(pixel_t) const
APDPixel number from Pixel.
unsigned int uint