RawMicroSlice.h
Go to the documentation of this file.
1 #ifndef RAWMICROSLICE_H
2 #define RAWMICROSLICE_H
3 #include "DAQDataFormats/FEBSimulator.h"
4 #include "DAQDataFormats/RawMicroSliceHeader.h"
5 #include "DAQDataFormats/RawTimingMarker.h"
6 #include "DAQDataFormats/RawNanoSlice.h"
7 #include "DAQDataFormats/Macros.h"
8 #include "DAQDataFormats/FunctionBind.h"
9 
10 #include <vector> /* Use the Vector STL */
11 
12 
13 
14  //! Class to hold the data from the FEBs in correct formats
15  /*!
16  The RawMicroSlice class is designed to mimic the format of the data
17  * produced in the DCM by the DCM firmware
18  *
19  *
20  * CAUTION!!!!!!!!!!! Right now the MicroSlice Header size is considered to be equal to 1
21  * always! If you plan on changing it, could be a hassle.
22  * RawMicroSlice::setBufferSource uses 1 explisitly
23  *
24  */
25 
26 
27 
28 namespace daqdataformats {
29 
30 /*
31 // FLAG Setting for Initialization and Resets
32 #define MICROSLICE_RESET_MEM 0x1
33 #define MICROSLICE_RESET_FEB 0x2
34 #define MICROSLICE_DELETE_FEB 0x4
35 #define MICROSLICE_INIT_FEB 0x8
36 */
37  namespace rawmicro{
38  static const uint32_t DEFAULT_MICROSLICE_SIZE = 16384; /* Maximum Microslice Buffer Size 64k/4 */
39  static const uint32_t MAXIMUM_FRONTEND_BOARDS = 64; /* Maximum number of front end boards we support */
41  }
42 
43  //! Class to hold the MicroSlice data
44  /*!
45  Currently, MicroSlice does not have versioning
46  */
47 
48  class RawMicroSlice : public RawDAQData {
49 
50 
51  public:
52 
53  // Constructors
54  /// If resize_buffer=true, then we resize the whole internal Buffer with zeros on the construction
55  RawMicroSlice(const uint32_t buffersize = rawmicro::DEFAULT_MICROSLICE_SIZE
56  ,const bool resize_buffer = false
57  ,const version_t microsliceheader_version = rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION
58  );
59  RawMicroSlice(const RawMicroSlice& copy_in);//! Deep copy constructor
60  RawMicroSlice(const void* microslice_buffer
61  ,const uint32_t buffersize = rawmicro::DEFAULT_MICROSLICE_SIZE
62  ,const version_t microsliceheader_version = rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION
63  ); //! Shallow copy constructor
64  /// Destructor
65  ~RawMicroSlice();
66 
67  version_t getVersion() const {return _microSliceHeaderVersion;}
68  bool setVersion(const version_t);
69 
70  /// Add a NanoSlice to the MicroSlice changing the MicroSlice Header appropriately
71  /// If check_mc_flag = true, the method checks whether the nanoslice is MC generated
72  /// and adds an appropriate flag to the MicroSlice Header.
73  void addNanoSlice(const void* nanoslice_buffer, const bool check_mc_flag=true);
74  /// Add a Some nwords of data to the internal buffer changing the MicroSlice Header appropriately
75  /// If check_mc_flag = true, the method checks whether the nanoslice is MC generated
76  /// and adds an appropriate flag to the MicroSlice Header.
77  void addData(const void* buffer, const uint32_t nwords, const bool check_mc_flag=true);
78 
79  /// Generate a MicroSlice
80  /// Need to provide the version of NanoSlices to generate
81  void generate(const version_t version_nanoslice=nanosliceheader::RAWNANOSLICE_DEFAULT_VERSION);
82 
83  // Getters
84  daqdataformats::RawMicroSliceHeader* getHeader() const; //! Get the MicroSlice Header
85  daqdataformats::RawTimingMarker* getTimingMarker() const; //! Get the MicroSlice Timing Marker
86  daqdataformats::RawNanoSlice* getFloatingNanoSlice() const; //! Get Floating NanoSlice
87  bool getDataPresent() const; //! Get the Data Present bit of the Header
88  bool getMonteCarloFlag() const; //! Get the Data Present bit of the Header
89  uint32_t getByteCount() const; //! Get the byte count value of the header
90  uint32_t getLowWord() const; //! Get method for lower half of timing word
91  uint32_t getHighWord() const; //! Get method for upper half of timing word
92  uint64_t getTime() const; //! Get the time-stamp as a single 64-bit value
93  float getHitProbability() const; //! Get current Hit Probability (for a microslice generation)
94  uint32_t getNumNanoSlices() const; //! Get number of NanoSlices in the MicroSlice
95 
96  //Setters
97  bool setMonteCarloFlag (const bool); //! Set the SIM flag
98  bool setFloatingNanoSlice (const uint32_t inano) const; //! Set Floating NanoSlice to point to the "inano"-th NanoSlice
99  /// We are allowed to change the floating nanoslice, thus it's const
100  bool setLowWord (const uint32_t); //! Set method for lower half of timing word
101  bool setHighWord (const uint32_t); //! Set method for upper half of timing word
102  bool setTime (const uint64_t); /**< Set the time-stamp as a single 64-bit value */
103  /// Set Hit probability of a pixel.
104  /// Used when generating MicroSlices - method generate.
105  bool setHitProbability (const float hit_prob);
106 
107  /// Getting a nanoslice size. It could be different for different versions
108  uint32_t getNanoSliceSize() const;
109 
110  using RawDAQData::readData;
111  /// Read Data From File Descriptor
112  readDataStatus readData(const int file_descriptor);
113 
114  void init ();
115  uint32_t sizeofdata () const;
116  bool setBufferSource (const void* pointer);
117 
118  protected:
119 
120  // These have to have a different name from readData and print.
121  // Otherwise, we can't bind them to their respactive DELEGATEs.
122  void* readDataFromBuffer(const void*);
123  void printStandard (std::ostream& os=std::cout) const;
124 
125  /// Sometimes we don't know the NanoSlice size yet,
126  /// But we need to know if there are NanoSlices at all
127  bool areThereNanoSlices() const;
128 
129  /// Read the NanoSlice version from the buffer
130  version_t figureOutTheVersion(const void*) const{return 0;}
131 
133  bool setFunctionPointers(){return true;};
134 
135  private:
136 
137  daqdataformats::RawMicroSliceHeader* _Header; ///< MicroSlice Header
138  daqdataformats::RawTimingMarker* _TimingMarker; ///< MicroSlice Timing Marker
139  mutable daqdataformats::RawNanoSlice* _FloatingNanoSlice;///< Floating NanoSlice.
140  ///< Allowed to be changed anywhere, even in const routines
141  ///< One can set the pointer of the
142  ///< nanoslice to any one within the MicroSlice
143  float _HitProbability; ///< Pixel Hit probability. Used when generating a MicroSlice
146  };// end of class RawMicroSlice
147 
148 } // END NAMESPCE daqdataformats
149 #endif /* RAWMICROSLICEHEADER_H */
static const uint32_t RAWTIMINGMARKER_SIZE
static const uint32_t PREDETERMINED_MICROSLICE_SIZE
Definition: RawMicroSlice.h:40
version_t getVersion() const
Definition: RawMicroSlice.h:67
static const uint32_t MAXIMUM_FRONTEND_BOARDS
Definition: RawMicroSlice.h:39
static const uint32_t DEFAULT_MICROSLICE_SIZE
Definition: RawMicroSlice.h:38
::xsd::cxx::tree::buffer< char > buffer
Definition: Database.h:179
uint32_t getPredeterminedSize() const
daqdataformats::RawTimingMarker * _TimingMarker
MicroSlice Timing Marker.
float _HitProbability
Pixel Hit probability. Used when generating a MicroSlice.
daqdataformats::RawNanoSlice * _FloatingNanoSlice
OStream cout
Definition: OStream.cxx:6
Class to hold the MicroSlice data.
Definition: RawMicroSlice.h:48
Class to hold the timing markers used in the construction of Microslices in the DCMs.
void * readData(const void *buffer)
Shallow copy constructor.
Definition: RawDAQData.cpp:181
int32_t version_t
Definition: RawDAQData.h:72
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81
Class to hold the data from the FEBs in correct formats.
version_t figureOutTheVersion(const void *) const
Read the NanoSlice version from the buffer.
static const uint32_t RAWMICROSLICEHEADER_SIZE