MicroSliceConstructor.cpp
Go to the documentation of this file.
1 /*
2  * File: MicroSliceConstructor.cpp
3  * Author: denis
4  *
5  * Created on September 20, 2012, 2:18 PM
6  */
7 #include <DAQDataFormats/RawNanoSlice.h>
8 #include <DAQDataFormats/RawMicroSlice.h>
9 
12 
13 
14 namespace daqdataformats {
15 
16 //------------------------------------------------------------------------------
17 MicroSliceConstructor::MicroSliceConstructor():_currentNanoSliceVersion(0){ }
18 
19 //------------------------------------------------------------------------------
21 
22 //------------------------------------------------------------------------------
25  fillDataFormat(out);
26  return out;
27 }
28 
29 //------------------------------------------------------------------------------
31  return new daqdataformats::RawMicroSlice();
32 }
33 
34 //------------------------------------------------------------------------------
37 
38  microslice->setVersion(0);
39  setFieldToTestValue_Time(microslice);
40  setFieldToTestValue_MonteCarloFlag(microslice);
41 
42  rawnano::NanoSliceConstructor nano_constructor;
43 
44  RawNanoSlice* nano1 = (RawNanoSlice*)nano_constructor.getFilledDataFormat(_currentNanoSliceVersion);
45 
46  RawNanoSlice* nano2 = (RawNanoSlice*)nano_constructor.getFilledDataFormat(_currentNanoSliceVersion);
47 
48  if(_currentNanoSliceVersion == 0){
49  nano2->setPulseHeight(nano2->getPulseHeight() + 1);
50  }
51  if(_currentNanoSliceVersion == 1){
52  nano2->setValue1(nano2->getValue1() + 1);
53  }
54 
55  microslice->addNanoSlice(nano1->getBuffer());
56  microslice->addNanoSlice(nano2->getBuffer());
57 
58  delete nano1;
59  delete nano2;
60 
61  return true;
62 }
63 
64 //------------------------------------------------------------------------------
65 /// Gets the NanoSlices version in the MicroSlice
67 
69 
70  /// right now it's unknown
72 
73  /// loop over nanoslices
74  for(uint32_t inano = 0; inano < micro->getNumNanoSlices(); ++inano){
75  micro->setFloatingNanoSlice(inano);
76 
77  const version_t nano_ver_current = _nanosliceConstructor.getVersion(micro->getFloatingNanoSlice());
78 
80  LOG_ERROR("UNITTEST")<<"Failure in "<<__PRETTY_FUNCTION__<<" at "<<__LINE__<<"\n"
81  <<" Output nanoslice version is rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION\n";
83  }
84 
86  nano_ver = nano_ver_current;
87  }
88  else{
89  if(nano_ver != nano_ver_current){
90  LOG_ERROR("UNITTEST")<<"Failure in "<<__PRETTY_FUNCTION__<<" at "<<__LINE__<<"\n"
91  <<" versions are inconsistent: at nanoslice "<<inano<<"\n"
92  <<"ver0="<<nano_ver<<" ver1="<<nano_ver_current<<"\n";
94  }
95  }
96  }// end of loop over nanoslices
97 
98  return nano_ver;
99 }
100 
101 }// end of namespaces
version_t getNanoSlicesVersion(const RawMicroSlice *) const
Gets the NanoSlices version in the MicroSlice.
daqdataformats::RawDAQData * getFilledDataFormat(const version_t) const
bool setVersion(const version_t)
uint32_t getNumNanoSlices() const
Get current Hit Probability (for a microslice generation)
daqdataformats::RawDAQData * getEmptyDataFormat(const version_t) const
method to create an empty dataformat with a given version
rawnano::NanoSliceConstructor _nanosliceConstructor
bool setFloatingNanoSlice(const uint32_t inano) const
Set the SIM flag.
Class to hold the MicroSlice data.
Definition: RawMicroSlice.h:48
int32_t version_t
Definition: RawDAQData.h:72
void addNanoSlice(const void *nanoslice_buffer, const bool check_mc_flag=true)
bool fillDataFormat(daqdataformats::RawDAQData *) const
method to Fill the input dataformat
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81
Class to hold the data from the FEBs in correct formats.
#define LOG_ERROR(stream)
Definition: Messenger.h:129
daqdataformats::RawNanoSlice * getFloatingNanoSlice() const
Get the MicroSlice Timing Marker.