Public Member Functions | Private Member Functions | Private Attributes | List of all members
mcdatadaq::DCMSimulator Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-05-06/MockDataDAQ/include/DCMSimulator.h"

Public Member Functions

 DCMSimulator (const daqchannelmap::diblock_t, const daqchannelmap::dcm_id_t)
 Constructor. More...
 
 ~DCMSimulator ()
 Destructor. More...
 
bool generateNanoSlice (const daqchannelmap::dchan, const uint32_t time_stamp, const uint32_t pulse_height)
 Generate NanoSlice with a given pixel, TimeStamp and PulseHeight. More...
 
bool generateNanoSlice (const daqchannelmap::dchan, const uint32_t time_stamp, const std::vector< uint32_t > &data)
 
bool writeMicroSlices ()
 Write all MicroSlices into the output file. More...
 
bool writeMilliSlices ()
 Write MilliSlice into the output file. More...
 
daqdataformats::RawMilliSlicefillMilliSlice ()
 Fill MilliSlices out. More...
 
bool nextEvent ()
 Advance to next event. Advancing MilliSlice. Clearing MicroSlice vector. More...
 

Private Member Functions

daqdataformats::FEBSimulatorgetFEBSimulator (const daqchannelmap::feb_t)
 Get the instance of the FEB Simulator for a given link ID on this DCM. More...
 
bool fillMicroSlice (const uint32_t microslice_number, daqdataformats::RawNanoSlice *)
 Fill MicroSlice with a given NanoSlice. More...
 
daqdataformats::RawMicroSlicecreateMicroSlice (const uint32_t microslice_number)
 Create a MicroSlice and put it in the vector. More...
 

Private Attributes

uint32_t fDiblockNumber
 Diblock number. More...
 
uint32_t fDCMNumber
 DCM number in the diblock. More...
 
std::vector< daqdataformats::FEBSimulator * > fFrontEndBoards
 All 64 FEBs on the DCM. More...
 
std::vector< RawMicroSlice_shrptrfMicroSlice
 Vector of all Microslices in the event. More...
 
daqdataformats::RawMilliSlice fMilliSlice
 There is going to be 1 Millislice per event. More...
 
FILE * fOutputMicroslicesFile
 Output file with hte microslices from this DCM. More...
 
FILE * fOutputMillislicesFile
 

Detailed Description

Definition at line 28 of file DCMSimulator.h.

Constructor & Destructor Documentation

mcdatadaq::DCMSimulator::DCMSimulator ( const daqchannelmap::diblock_t  diblock,
const daqchannelmap::dcm_id_t  dcm 
)

Constructor.

Construct 64 front-end-boards

Setup the milliclice

Figure out the output file name for the MicroSlices for the DCM

Open the file

Now we need to write DAQ Simulation version in the beginning of the file

Figure out the output file name for the MilliSlices for the DCM

Open the file

Now we need to write DAQ Simulation version in the beginning of the file

Definition at line 28 of file DCMSimulator.cpp.

References fDCMNumber, fDiblockNumber, fFrontEndBoards, fMilliSlice, fOutputMicroslicesFile, fOutputMillislicesFile, mcdatadaq::Configuration::getDetector(), mcdatadaq::Configuration::getFullFileName(), mcdatadaq::Configuration::getInstance(), mcdatadaq::Configuration::getNanoSliceVersion(), mcdatadaq::Configuration::isProducingMilliSlices(), mcdatadaq::Configuration::openFile(), daqdataformats::RawMilliSlice::setComplete(), daqdataformats::RawMilliSlice::setDCMId(), daqdataformats::RawMilliSlice::setDestBuffID(), daqdataformats::RawMilliSlice::setDetId(), daqdataformats::RawMilliSlice::setDiblockId(), daqdataformats::RawMilliSlice::setMonteCarloFlag(), string, and mcdatadaq::Configuration::writeDAQSimulatorVersionIntoFile().

28  :
30  , fDCMNumber(dcm)
31  //, fMilliSlice(10000)
34 {
36 
37  const daqdataformats::version_t nanoslice_version = config->getNanoSliceVersion();
38  /// Construct 64 front-end-boards
39  for(daqdataformats::link_id_t ifeb = 0; ifeb < 64; ifeb++){
40  fFrontEndBoards.push_back(new daqdataformats::FEBSimulator(ifeb, nanoslice_version));
41  }// end of loop over FEBs
42 
43  /// Setup the milliclice
44  fMilliSlice.setDetId(config->getDetector());
50 
51  /// Figure out the output file name for the MicroSlices for the DCM
52  std::stringstream final_file_name_microslices_addition;
53  final_file_name_microslices_addition<<"MicroSlices_Diblock"<<fDiblockNumber<<"_Dcmnum"<<fDCMNumber;
54  const std::string final_file_name_microslices = config->getFullFileName(final_file_name_microslices_addition.str());
55 
56  /// Open the file
57  fOutputMicroslicesFile = config->openFile(final_file_name_microslices);
58  /// Now we need to write DAQ Simulation version in the beginning of the file
59  config->writeDAQSimulatorVersionIntoFile(fOutputMicroslicesFile);
60 
61  if(config->isProducingMilliSlices()){
62 
63  /// Figure out the output file name for the MilliSlices for the DCM
64  std::stringstream final_file_name_millislices_addition;
65  final_file_name_millislices_addition<<"MilliSlices_Diblock"<<fDiblockNumber<<"_Dcmnum"<<fDCMNumber;
66  const std::string final_file_name_millislices = config->getFullFileName(final_file_name_millislices_addition.str());
67 
68  /// Open the file
69  fOutputMillislicesFile = config->openFile(final_file_name_millislices);
70  /// Now we need to write DAQ Simulation version in the beginning of the file
71  config->writeDAQSimulatorVersionIntoFile(fOutputMillislicesFile);
72  }
73 
74 }// end of constructor
diblock
print "ROW IS " print row
Definition: geo2elec.py:31
bool setDCMId(const uint32_t a)
Definition: RawMilliSlice.h:81
bool setDestBuffID(const uint32_t a)
Definition: RawMilliSlice.h:84
Definition: config.py:1
bool setDiblockId(const uint32_t a)
Definition: RawMilliSlice.h:80
uint32_t link_id_t
Definition: FEBSimulator.h:8
uint32_t fDiblockNumber
Diblock number.
Definition: DCMSimulator.h:60
static Configuration * getInstance()
Method to obtain the class instance.
bool setComplete(const bool a)
Definition: RawMilliSlice.h:90
bool setMonteCarloFlag(const bool a)
Definition: RawMilliSlice.h:98
FILE * fOutputMicroslicesFile
Output file with hte microslices from this DCM.
Definition: DCMSimulator.h:69
std::vector< daqdataformats::FEBSimulator * > fFrontEndBoards
All 64 FEBs on the DCM.
Definition: DCMSimulator.h:63
int32_t version_t
Definition: RawDAQData.h:72
uint32_t fDCMNumber
DCM number in the diblock.
Definition: DCMSimulator.h:61
daqdataformats::RawMilliSlice fMilliSlice
There is going to be 1 Millislice per event.
Definition: DCMSimulator.h:66
bool setDetId(const uint32_t a)
Definition: RawMilliSlice.h:82
enum BeamMode string
mcdatadaq::DCMSimulator::~DCMSimulator ( )

Destructor.

Delete 64 front-end-boards

Close the MicroSlices file

Close the Millislice file

Definition at line 78 of file DCMSimulator.cpp.

References fclose(), fFrontEndBoards, fOutputMicroslicesFile, and fOutputMillislicesFile.

78  {
79 
80  /// Delete 64 front-end-boards
81  for(uint32_t ifeb = 0; ifeb < fFrontEndBoards.size(); ifeb++){
82  delete fFrontEndBoards[ifeb];
83  }// end of loop over FEBs
84 
85  /// Close the MicroSlices file
87 
88  /// Close the Millislice file
90 }// end of destructor
fclose(fg1)
FILE * fOutputMicroslicesFile
Output file with hte microslices from this DCM.
Definition: DCMSimulator.h:69
std::vector< daqdataformats::FEBSimulator * > fFrontEndBoards
All 64 FEBs on the DCM.
Definition: DCMSimulator.h:63

Member Function Documentation

daqdataformats::RawMicroSlice * mcdatadaq::DCMSimulator::createMicroSlice ( const uint32_t  microslice_number)
private

Create a MicroSlice and put it in the vector.

Definition at line 163 of file DCMSimulator.cpp.

References mcdatadaq::GlobalEventTime::getGlobalEventTime(), mcdatadaq::Configuration::getInstance(), mcdatadaq::GlobalEventTime::getInstance(), mcdatadaq::Configuration::getMicrosliceDT(), daqdataformats::RawMicroSlice::setMonteCarloFlag(), and daqdataformats::RawMicroSlice::setTime().

Referenced by fillMicroSlice().

163  {
164 
166 
168  const GlobalEventTime* global_event_time = GlobalEventTime::getInstance();
169  const unsigned long long microslice_time_in_event = config->getMicrosliceDT()*microslice_number + global_event_time->getGlobalEventTime();
170 
171  microslice->setMonteCarloFlag(true);
172  microslice->setTime(microslice_time_in_event);
173 
174  return microslice;
175 }// end of createMicroSlice
Definition: config.py:1
static Configuration * getInstance()
Method to obtain the class instance.
bool setTime(const uint64_t)
Set method for upper half of timing word.
Class to hold the MicroSlice data.
Definition: RawMicroSlice.h:48
static GlobalEventTime * getInstance()
Method to obtain the class instance.
bool setMonteCarloFlag(const bool)
Get number of NanoSlices in the MicroSlice.
bool mcdatadaq::DCMSimulator::fillMicroSlice ( const uint32_t  microslice_number,
daqdataformats::RawNanoSlice nanoslice 
)
private

Fill MicroSlice with a given NanoSlice.

Number of microslices created so far

Create new microslices if needed

Definition at line 143 of file DCMSimulator.cpp.

References daqdataformats::RawMicroSlice::addNanoSlice(), createMicroSlice(), and fMicroSlice.

Referenced by generateNanoSlice().

143  {
144 
145  /// Number of microslices created so far
146  const uint32_t number_of_created_microslices_in_event = fMicroSlice.size();
147 
148  /// Create new microslices if needed
149  for(uint32_t i_microslice = number_of_created_microslices_in_event; i_microslice <=microslice_number; i_microslice++){
150  RawMicroSlice_shrptr microslice(createMicroSlice(i_microslice));
151  fMicroSlice.push_back(microslice);
152 
153  }// end of creating new microslices if needed
154 
155  daqdataformats::RawMicroSlice* microslice = fMicroSlice[microslice_number].get();
156 
157  microslice->addNanoSlice(nanoslice->getBuffer());
158 
159  return true;
160 }// end of fillMicroSlice
boost::shared_ptr< daqdataformats::RawMicroSlice > RawMicroSlice_shrptr
Shared pointer.
Definition: DCMSimulator.h:26
daqdataformats::RawMicroSlice * createMicroSlice(const uint32_t microslice_number)
Create a MicroSlice and put it in the vector.
Class to hold the MicroSlice data.
Definition: RawMicroSlice.h:48
void addNanoSlice(const void *nanoslice_buffer, const bool check_mc_flag=true)
std::vector< RawMicroSlice_shrptr > fMicroSlice
Vector of all Microslices in the event.
Definition: DCMSimulator.h:65
daqdataformats::RawMilliSlice * mcdatadaq::DCMSimulator::fillMilliSlice ( )

Fill MilliSlices out.

Add all microslices for the DCM into the millislice

end of adding microslices

Close MilliSlice

Definition at line 179 of file DCMSimulator.cpp.

References daqdataformats::RawMilliSlice::addMicroSlice(), daqdataformats::RawMilliSlice::close(), fMicroSlice, fMilliSlice, mcdatadaq::GlobalEventTime::getGlobalEventTime(), mcdatadaq::GlobalEventTime::getInstance(), and daqdataformats::RawMilliSlice::setTimeStart().

Referenced by mcdatadaq::DAQSimulator::fillMilliSlices().

179  {
180 
181  const GlobalEventTime* global_event_time = GlobalEventTime::getInstance();
182  fMilliSlice.setTimeStart(global_event_time->getGlobalEventTime());
183 
184  /// Add all microslices for the DCM into the millislice
185  for(uint32_t imicro = 0; imicro < fMicroSlice.size(); imicro++){
186  fMilliSlice.addMicroSlice(fMicroSlice[imicro]->getBuffer());
187  }/// end of adding microslices
188  /// Close MilliSlice
189  fMilliSlice.close();
190 
191  return &fMilliSlice;
192 }// end of fillMilliSlice
bool close(const bool produce_crc=false)
bool setTimeStart(const uint64_t a)
Definition: RawMilliSlice.h:86
static GlobalEventTime * getInstance()
Method to obtain the class instance.
bool addMicroSlice(const void *microslice_buffer, const bool indexate=false, const bool check_mc_flag=false)
std::vector< RawMicroSlice_shrptr > fMicroSlice
Vector of all Microslices in the event.
Definition: DCMSimulator.h:65
daqdataformats::RawMilliSlice fMilliSlice
There is going to be 1 Millislice per event.
Definition: DCMSimulator.h:66
bool mcdatadaq::DCMSimulator::generateNanoSlice ( const daqchannelmap::dchan  daqchannel,
const uint32_t  time_stamp,
const uint32_t  pulse_height 
)

Generate NanoSlice with a given pixel, TimeStamp and PulseHeight.

Definition at line 93 of file DCMSimulator.cpp.

Referenced by mcdatadaq::DAQSimulator::fillMicroSlices().

95  {
96 
97  std::vector <uint32_t> data;
98  data.push_back(pulse_height);
99 
100  return generateNanoSlice(daqchannel, simulated_time_stamp, data);
101 
102 }// end of generateNanoSlice
bool generateNanoSlice(const daqchannelmap::dchan, const uint32_t time_stamp, const uint32_t pulse_height)
Generate NanoSlice with a given pixel, TimeStamp and PulseHeight.
const XML_Char const XML_Char * data
Definition: expat.h:268
bool mcdatadaq::DCMSimulator::generateNanoSlice ( const daqchannelmap::dchan  daqchannel,
const uint32_t  time_stamp,
const std::vector< uint32_t > &  data 
)

Front End Board number

Pixel Number on the APD

Need to advance by the time of the event

Get the right FEB simulator for the FEB

Generate a nanoslice in that FEB

Get that nanoslice

The MicroSlice number corresponding to the nanoslice

Fill that MicroSlice with the nanoslice that we have just generated

Definition at line 105 of file DCMSimulator.cpp.

References visualisationForPaperMasterPlot::cmap, APDHVSetting::feb, fillMicroSlice(), daqchannelmap::DAQChannelMap::getFEB(), getFEBSimulator(), mcdatadaq::GlobalEventTime::getGlobalEventTime(), mcdatadaq::Configuration::getInstance(), mcdatadaq::GlobalEventTime::getInstance(), mcdatadaq::Configuration::getMicrosliceDT(), daqchannelmap::DAQChannelMap::getPixel(), and cmap::dataprov::CMap::Map().

107  {
108 
111 
112  /// Front End Board number
113  const daqchannelmap::feb_t feb = cmap->Map()->getFEB(daqchannel);
114 
115  /// Pixel Number on the APD
116  const daqchannelmap::pixel_t pixel = cmap->Map()->getPixel(daqchannel);
117 
118  /// Need to advance by the time of the event
119  const GlobalEventTime* global_event_time = GlobalEventTime::getInstance();
120  const uint32_t simulated_hit_time_in_event = simulated_time_stamp + uint32_t(global_event_time->getGlobalEventTime());
121 
122  /// Get the right FEB simulator for the FEB
123  daqdataformats::FEBSimulator* feb_simulator = getFEBSimulator(feb);
124  /// Generate a nanoslice in that FEB
125  feb_simulator->generateNanoSlice(pixel, simulated_hit_time_in_event, data);
126 
127  /// Get that nanoslice
128  daqdataformats::RawNanoSlice* last_nanoslice_pointer = feb_simulator->getLastNanoSlice();
129 
130  /// The MicroSlice number corresponding to the nanoslice
131  const uint32_t microslice_number = simulated_time_stamp / config->getMicrosliceDT();
132 
133  /// Fill that MicroSlice with the nanoslice that we have just generated
134  fillMicroSlice(microslice_number, last_nanoslice_pointer);
135 
136  return true;
137 }
uint32_t pixel_t
Type for physical pixel on APD.
const daqchannelmap::DAQChannelMap * Map() const
Definition: CMap.h:57
Definition: config.py:1
const XML_Char const XML_Char * data
Definition: expat.h:268
static Configuration * getInstance()
Method to obtain the class instance.
bool fillMicroSlice(const uint32_t microslice_number, daqdataformats::RawNanoSlice *)
Fill MicroSlice with a given NanoSlice.
uint32_t feb_t
Type for DCM link port. Counts from 0.
pixel_t getPixel(dchan daqchan) const
Decode the pixel id from a dchan.
daqdataformats::FEBSimulator * getFEBSimulator(const daqchannelmap::feb_t)
Get the instance of the FEB Simulator for a given link ID on this DCM.
static GlobalEventTime * getInstance()
Method to obtain the class instance.
feb_t getFEB(dchan daqchan) const
Decode the feb id from a dchan.
daqdataformats::FEBSimulator * mcdatadaq::DCMSimulator::getFEBSimulator ( const daqchannelmap::feb_t  feb)
private

Get the instance of the FEB Simulator for a given link ID on this DCM.

Definition at line 140 of file DCMSimulator.cpp.

References APDHVSetting::feb, and fFrontEndBoards.

Referenced by generateNanoSlice().

140 {return fFrontEndBoards[feb];}
std::vector< daqdataformats::FEBSimulator * > fFrontEndBoards
All 64 FEBs on the DCM.
Definition: DCMSimulator.h:63
bool mcdatadaq::DCMSimulator::nextEvent ( )

Advance to next event. Advancing MilliSlice. Clearing MicroSlice vector.

Definition at line 219 of file DCMSimulator.cpp.

References daqdataformats::RawMilliSliceHeader::advanceMilliSliceSEQ(), fMicroSlice, fMilliSlice, daqdataformats::RawMilliSlice::getDestBuffID(), daqdataformats::RawMilliSlice::getHeader(), daqdataformats::RawMilliSlice::setDestBuffID(), and daqdataformats::RawMilliSliceHeader::sizeofdata().

Referenced by mcdatadaq::DAQSimulator::nextEvent().

219  {
220 
221  // Next MilliSlice
222  fMilliSlice.getHeader()->setSliceSize(fMilliSlice.getHeader()->sizeofdata());
223  fMilliSlice.getHeader()->setMicrosliceNumber(0);
226 
227  fMicroSlice.clear();
228 
229  return true;
230 }// end of nextEvent
bool setDestBuffID(const uint32_t a)
Definition: RawMilliSlice.h:84
daqdataformats::RawMilliSliceHeader * getHeader() const
Definition: RawMilliSlice.h:47
uint32_t getDestBuffID() const
Definition: RawMilliSlice.h:53
std::vector< RawMicroSlice_shrptr > fMicroSlice
Vector of all Microslices in the event.
Definition: DCMSimulator.h:65
daqdataformats::RawMilliSlice fMilliSlice
There is going to be 1 Millislice per event.
Definition: DCMSimulator.h:66
bool mcdatadaq::DCMSimulator::writeMicroSlices ( )

Write all MicroSlices into the output file.

Loop over Microslices and write them out

end of adding microslices

Definition at line 195 of file DCMSimulator.cpp.

References fMicroSlice, fOutputMicroslicesFile, mcdatadaq::Configuration::getInstance(), and mcdatadaq::Configuration::writeToFile().

Referenced by mcdatadaq::DAQSimulator::fillMicroSlices().

195  {
196 
198 
199  /// Loop over Microslices and write them out
200  for(uint32_t imicro = 0; imicro < fMicroSlice.size(); imicro++){
201  config->writeToFile(fOutputMicroslicesFile, *(fMicroSlice[imicro]));
202  }/// end of adding microslices
203 
204  return true;
205 
206 }// end of writeMicroSlices
Definition: config.py:1
static Configuration * getInstance()
Method to obtain the class instance.
FILE * fOutputMicroslicesFile
Output file with hte microslices from this DCM.
Definition: DCMSimulator.h:69
std::vector< RawMicroSlice_shrptr > fMicroSlice
Vector of all Microslices in the event.
Definition: DCMSimulator.h:65
bool mcdatadaq::DCMSimulator::writeMilliSlices ( )

Write MilliSlice into the output file.

Definition at line 209 of file DCMSimulator.cpp.

References fMilliSlice, fOutputMillislicesFile, mcdatadaq::Configuration::getInstance(), mcdatadaq::Configuration::isProducingMilliSlices(), and mcdatadaq::Configuration::writeToFile().

Referenced by mcdatadaq::DAQSimulator::fillMilliSlices().

209  {
210 
212 
213  if(!config->isProducingMilliSlices()) return true;
214 
215  return config->writeToFile(fOutputMillislicesFile, fMilliSlice);
216 }// end of writeMicroSlices
Definition: config.py:1
static Configuration * getInstance()
Method to obtain the class instance.
daqdataformats::RawMilliSlice fMilliSlice
There is going to be 1 Millislice per event.
Definition: DCMSimulator.h:66

Member Data Documentation

uint32_t mcdatadaq::DCMSimulator::fDCMNumber
private

DCM number in the diblock.

Definition at line 61 of file DCMSimulator.h.

Referenced by DCMSimulator().

uint32_t mcdatadaq::DCMSimulator::fDiblockNumber
private

Diblock number.

Definition at line 60 of file DCMSimulator.h.

Referenced by DCMSimulator().

std::vector<daqdataformats::FEBSimulator*> mcdatadaq::DCMSimulator::fFrontEndBoards
private

All 64 FEBs on the DCM.

Definition at line 63 of file DCMSimulator.h.

Referenced by DCMSimulator(), getFEBSimulator(), and ~DCMSimulator().

std::vector<RawMicroSlice_shrptr > mcdatadaq::DCMSimulator::fMicroSlice
private

Vector of all Microslices in the event.

Definition at line 65 of file DCMSimulator.h.

Referenced by fillMicroSlice(), fillMilliSlice(), nextEvent(), and writeMicroSlices().

daqdataformats::RawMilliSlice mcdatadaq::DCMSimulator::fMilliSlice
private

There is going to be 1 Millislice per event.

Definition at line 66 of file DCMSimulator.h.

Referenced by DCMSimulator(), fillMilliSlice(), nextEvent(), and writeMilliSlices().

FILE* mcdatadaq::DCMSimulator::fOutputMicroslicesFile
private

Output file with hte microslices from this DCM.

Definition at line 69 of file DCMSimulator.h.

Referenced by DCMSimulator(), writeMicroSlices(), and ~DCMSimulator().

FILE* mcdatadaq::DCMSimulator::fOutputMillislicesFile
private

Definition at line 70 of file DCMSimulator.h.

Referenced by DCMSimulator(), writeMilliSlices(), and ~DCMSimulator().


The documentation for this class was generated from the following files: