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

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-10-28/MockDataDAQ/include/Configuration.h"

Public Member Functions

 ~Configuration ()
 
bool init ()
 initialize detector More...
 
bool print () const
 Print Configuration. More...
 
int getDetector () const
 Get Detector ID. More...
 
bool isDetectorUnknown () const
 Check Detector if it's unknown ID. More...
 
uint32_t getMicrosliceDT () const
 MicroSlice DT. More...
 
uint32_t getNumberOfMicroslicesInMilliSlice () const
 NumberOfMicroslicesInMilliSlice. More...
 
uint32_t getNumberOfBufferNodes () const
 Number of buffer nodes. More...
 
uint32_t getEventTimeDifference () const
 Event time difference in NOvA clock ticks (15.626 ns) More...
 
bool isProducingJustMicroSlices () const
 Do we produce just microslices? More...
 
bool isProducingRunObject () const
 Do we produce Run object? More...
 
bool isProducingMilliSlices () const
 
uint32_t getDAQSimulatorVersion () const
 Get Global DAQSimulator version. More...
 
bool writeDAQSimulatorVersionIntoFile (FILE *) const
 Write Global DAQSimulator version into the input file. More...
 
daqdataformats::version_t getNanoSliceVersion () const
 Get NanoSlice version. More...
 
daqdataformats::version_t getMicroBlockVersion () const
 Get MicroBlock version. More...
 
std::string getFullFileName (const std::string addition_to_file_name) const
 
bool writeToFile (FILE *, const daqdataformats::RawDAQData &) const
 Utility method of writing DAQ data into a file. More...
 
FILE * openFile (const std::string file_name) const
 Open file for binary write access. More...
 

Static Public Member Functions

static bool setInstance (fhicl::ParameterSet const &pset)
 Method to set the class instance with parameters from fhicl. More...
 
static ConfigurationgetInstance ()
 Method to obtain the class instance. More...
 

Private Member Functions

 Configuration ()
 default constructor More...
 
 Configuration (fhicl::ParameterSet const &pset)
 Constructor using fcl parameters. More...
 
std::string getOutputDir () const
 GetOutput Directory. More...
 
std::string getFileName () const
 Get File name. More...
 

Private Attributes

int fDetector
 !< Instance pointer for singleton class More...
 
uint32_t fNumberOfMicroslicesInMilliSlice
 !< ipnd, near, far More...
 
uint32_t fMicrosliceDT
 MicroSlice length in NOvA clock ticks (15.626 ns) More...
 
uint32_t fNumberOfBufferNodes
 Number of buffer nodes. More...
 
std::string fOutputDir
 Directory for the output files. More...
 
std::string fFileName
 Output file names. More...
 
uint32_t fEventTimeDifference
 Event time difference in NOvA clock ticks (15.626 ns) More...
 
bool fIsProducingJustMicroSlices
 
bool fIsProducingRunObject
 !< Are we producing just microslices? More...
 
bool fIsProducingMilliSlices
 !< Are we producing Run Object? More...
 
daqdataformats::version_t fNanoSliceVersion
 !< Are me going to produce MilliSlices? More...
 
daqdataformats::version_t fMicroBlockVersion
 

Static Private Attributes

static ConfigurationfinstanceID = NULL
 

Detailed Description

Definition at line 26 of file Configuration.h.

Constructor & Destructor Documentation

mcdatadaq::Configuration::~Configuration ( )

Definition at line 95 of file Configuration.cpp.

95 { }
mcdatadaq::Configuration::Configuration ( )
private

default constructor

Definition at line 57 of file Configuration.cpp.

References print().

Referenced by getInstance(), and setInstance().

57  :
62  ,fOutputDir(".")
63  ,fFileName("muon")
66  ,fIsProducingRunObject(false)
70 {
71  print();
72 }
bool print() const
Print Configuration.
uint32_t fNumberOfMicroslicesInMilliSlice
!< ipnd, near, far
Definition: Configuration.h:80
static const uint32_t DEFAULT_NUMBER_MICROSLICES_IN_MILLISLICE
Definition: Configuration.h:20
static const uint32_t DEFAULT_DCM_MICROSLICE_DT
Definition: Configuration.h:21
daqdataformats::version_t fNanoSliceVersion
!< Are me going to produce MilliSlices?
Definition: Configuration.h:94
std::string fOutputDir
Directory for the output files.
Definition: Configuration.h:85
uint32_t fNumberOfBufferNodes
Number of buffer nodes.
Definition: Configuration.h:83
bool fIsProducingMilliSlices
!< Are we producing Run Object?
Definition: Configuration.h:92
std::string fFileName
Output file names.
Definition: Configuration.h:86
bool fIsProducingRunObject
!< Are we producing just microslices?
Definition: Configuration.h:91
static const uint32_t DEFAULT_NUMBER_OF_BUFFERNODES
Definition: Configuration.h:22
daqdataformats::version_t fMicroBlockVersion
Definition: Configuration.h:95
uint32_t fMicrosliceDT
MicroSlice length in NOvA clock ticks (15.626 ns)
Definition: Configuration.h:81
static const uint32_t DEFAULT_TIME_DIFF
int fDetector
!< Instance pointer for singleton class
Definition: Configuration.h:77
uint32_t fEventTimeDifference
Event time difference in NOvA clock ticks (15.626 ns)
Definition: Configuration.h:88
static const daqdataformats::version_t DEFAULT_NANOSLICE_VERSION
Definition: Configuration.h:23
mcdatadaq::Configuration::Configuration ( fhicl::ParameterSet const &  pset)
private

Constructor using fcl parameters.

Definition at line 75 of file Configuration.cpp.

References ana::assert(), fOutputDir, and print().

75  :
77  ,fNumberOfMicroslicesInMilliSlice(parameters.get< uint32_t >("NumberOfMicroslicesInMilliSlice"))
78  ,fMicrosliceDT(parameters.get< uint32_t >("MicrosliceDT"))
79  ,fNumberOfBufferNodes(parameters.get< uint32_t >("NumberOfBufferNodes"))
80  ,fOutputDir(parameters.get< std::string >("OutputDir"))
81  ,fFileName(parameters.get< std::string >("FileName"))
82  ,fEventTimeDifference(parameters.get< uint32_t >("EventTimeDifference"))
83  ,fIsProducingJustMicroSlices(parameters.get< bool >("ProduceJustMicroSlices"))
84  ,fIsProducingRunObject(parameters.get< bool >("FillRunObject"))
85  ,fIsProducingMilliSlices(parameters.get< bool >("FillMilliSlices"))
86  ,fNanoSliceVersion(parameters.get< daqdataformats::version_t >("NanoSliceVersion"))
87  ,fMicroBlockVersion(parameters.get< daqdataformats::version_t >("MicroBlockVersion"))
88 {
89  print();
90  struct stat sb;
91  assert((stat(fOutputDir.c_str(), &sb) == 0 && S_ISDIR(sb.st_mode)) && "Output directory doesn't exist or we don't have permissions to it, fail.");
92 }
bool print() const
Print Configuration.
uint32_t fNumberOfMicroslicesInMilliSlice
!< ipnd, near, far
Definition: Configuration.h:80
daqdataformats::version_t fNanoSliceVersion
!< Are me going to produce MilliSlices?
Definition: Configuration.h:94
std::string fOutputDir
Directory for the output files.
Definition: Configuration.h:85
uint32_t fNumberOfBufferNodes
Number of buffer nodes.
Definition: Configuration.h:83
bool fIsProducingMilliSlices
!< Are we producing Run Object?
Definition: Configuration.h:92
std::string fFileName
Output file names.
Definition: Configuration.h:86
bool fIsProducingRunObject
!< Are we producing just microslices?
Definition: Configuration.h:91
daqdataformats::version_t fMicroBlockVersion
Definition: Configuration.h:95
uint32_t fMicrosliceDT
MicroSlice length in NOvA clock ticks (15.626 ns)
Definition: Configuration.h:81
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
int fDetector
!< Instance pointer for singleton class
Definition: Configuration.h:77
int32_t version_t
Definition: RawDAQData.h:72
uint32_t fEventTimeDifference
Event time difference in NOvA clock ticks (15.626 ns)
Definition: Configuration.h:88
assert(nhit_max >=nhit_nbins)

Member Function Documentation

uint32_t mcdatadaq::Configuration::getDAQSimulatorVersion ( ) const

Get Global DAQSimulator version.

Definition at line 185 of file Configuration.cpp.

References mcdatadaq::DAQSIMULATION_VERSION.

Referenced by writeDAQSimulatorVersionIntoFile().

185 { return DAQSIMULATION_VERSION;}
static const uint32_t DAQSIMULATION_VERSION
Version of the DAQ simulation.
Definition: DAQSimulator.h:39
int mcdatadaq::Configuration::getDetector ( ) const

Get Detector ID.

Definition at line 115 of file Configuration.cpp.

References fDetector.

Referenced by mcdatadaq::DCMSimulator::DCMSimulator(), and mcdatadaq::DAQSimulator::init().

115 { return fDetector;}
int fDetector
!< Instance pointer for singleton class
Definition: Configuration.h:77
uint32_t mcdatadaq::Configuration::getEventTimeDifference ( ) const

Event time difference in NOvA clock ticks (15.626 ns)

Definition at line 121 of file Configuration.cpp.

References fEventTimeDifference.

Referenced by mcdatadaq::GlobalEventTime::getInstance().

121 { return fEventTimeDifference;}
uint32_t fEventTimeDifference
Event time difference in NOvA clock ticks (15.626 ns)
Definition: Configuration.h:88
std::string mcdatadaq::Configuration::getFileName ( ) const
private

Get File name.

Definition at line 120 of file Configuration.cpp.

References fFileName.

Referenced by getFullFileName().

120 { return fFileName;}
std::string fFileName
Output file names.
Definition: Configuration.h:86
std::string mcdatadaq::Configuration::getFullFileName ( const std::string  addition_to_file_name) const

Get full file name with a given additional name to specify what kind of file it is, like "MicroSlices", "Events" or "Run"

Definition at line 130 of file Configuration.cpp.

References getFileName(), and getOutputDir().

Referenced by mcdatadaq::DataLoggerSimulator::DataLoggerSimulator(), mcdatadaq::DCMSimulator::DCMSimulator(), and mcdatadaq::GlobalTriggerSimulator::GlobalTriggerSimulator().

130  {
131 
132  const std::string file_extention = ".raw";
133  const std::string full_file_name = getOutputDir()
134  + "/"
135  + getFileName()
136  + "_"
137  + addition_to_file_name
138  + file_extention;
139  return full_file_name;
140 }
std::string getOutputDir() const
GetOutput Directory.
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::string getFileName() const
Get File name.
Configuration * mcdatadaq::Configuration::getInstance ( )
static
daqdataformats::version_t mcdatadaq::Configuration::getMicroBlockVersion ( ) const

Get MicroBlock version.

Definition at line 127 of file Configuration.cpp.

References fMicroBlockVersion.

Referenced by mcdatadaq::BufferNodeSimulator::addMilliSlice().

127 { return fMicroBlockVersion;}
daqdataformats::version_t fMicroBlockVersion
Definition: Configuration.h:95
uint32_t mcdatadaq::Configuration::getMicrosliceDT ( ) const

MicroSlice DT.

Definition at line 117 of file Configuration.cpp.

References fMicrosliceDT.

Referenced by mcdatadaq::DCMSimulator::createMicroSlice(), and mcdatadaq::DCMSimulator::generateNanoSlice().

117 { return fMicrosliceDT;}
uint32_t fMicrosliceDT
MicroSlice length in NOvA clock ticks (15.626 ns)
Definition: Configuration.h:81
daqdataformats::version_t mcdatadaq::Configuration::getNanoSliceVersion ( ) const

Get NanoSlice version.

Definition at line 126 of file Configuration.cpp.

References fNanoSliceVersion.

Referenced by mcdatadaq::DCMSimulator::DCMSimulator(), and mcdatadaq::DAQSimulator::fillMicroSlices().

126 { return fNanoSliceVersion;}
daqdataformats::version_t fNanoSliceVersion
!< Are me going to produce MilliSlices?
Definition: Configuration.h:94
uint32_t mcdatadaq::Configuration::getNumberOfBufferNodes ( ) const

Number of buffer nodes.

Definition at line 118 of file Configuration.cpp.

References fNumberOfBufferNodes.

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

118 { return fNumberOfBufferNodes;}
uint32_t fNumberOfBufferNodes
Number of buffer nodes.
Definition: Configuration.h:83
uint32_t mcdatadaq::Configuration::getNumberOfMicroslicesInMilliSlice ( ) const

NumberOfMicroslicesInMilliSlice.

std::string mcdatadaq::Configuration::getOutputDir ( ) const
private

GetOutput Directory.

Definition at line 119 of file Configuration.cpp.

References fOutputDir.

Referenced by getFullFileName().

119 { return fOutputDir;}
std::string fOutputDir
Directory for the output files.
Definition: Configuration.h:85
bool mcdatadaq::Configuration::init ( )

initialize detector

Checking if detectorID is invalid. If so, return false.

Definition at line 98 of file Configuration.cpp.

References om::cout, geo::GeometryBase::DetId(), fDetector, novadaq::cnv::DetInfo::GetName(), novadaq::cnv::kNDetector, and novadaq::cnv::kUNKNOWN_DET.

Referenced by demo.App::__init__(), testem0.App::__init__(), Lesson1.App::__init__(), ExN03.App::__init__(), and mcdatadaq::MockDataDAQAna::init().

98  {
99 
101  fDetector = geo->DetId();
102 
103  /// Checking if detectorID is invalid. If so, return false.
105  fDetector >= novadaq::cnv::kNDetector) return false;
106 
107 
108  std::cout<<"Setting detector to "<<novadaq::cnv::DetInfo::GetName(fDetector)<<"\n";
109 
110  return true;
111 
112 }// end of init
static std::string GetName(int id)
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
OStream cout
Definition: OStream.cxx:6
int fDetector
!< Instance pointer for singleton class
Definition: Configuration.h:77
Helper for AttenCurve.
Definition: Path.h:10
bool mcdatadaq::Configuration::isDetectorUnknown ( ) const

Check Detector if it's unknown ID.

Definition at line 116 of file Configuration.cpp.

References fDetector, and novadaq::cnv::kUNKNOWN_DET.

Referenced by mcdatadaq::MockDataDAQAna::analyze().

116 { return (fDetector == novadaq::cnv::kUNKNOWN_DET);}// end of isDetectorUnknown
int fDetector
!< Instance pointer for singleton class
Definition: Configuration.h:77
bool mcdatadaq::Configuration::isProducingJustMicroSlices ( ) const
bool mcdatadaq::Configuration::isProducingMilliSlices ( ) const
inline
bool mcdatadaq::Configuration::isProducingRunObject ( ) const

Do we produce Run object?

Definition at line 123 of file Configuration.cpp.

References fIsProducingRunObject.

Referenced by mcdatadaq::DataLoggerSimulator::DataLoggerSimulator(), and mcdatadaq::DataLoggerSimulator::produceEvent().

123 { return fIsProducingRunObject;}
bool fIsProducingRunObject
!< Are we producing just microslices?
Definition: Configuration.h:91
FILE * mcdatadaq::Configuration::openFile ( const std::string  file_name) const

Open file for binary write access.

Definition at line 180 of file Configuration.cpp.

Referenced by mcdatadaq::DCMSimulator::DCMSimulator().

180  {
181  return fopen (file_name.c_str(), "wb");
182 }
bool mcdatadaq::Configuration::print ( ) const

Print Configuration.

Definition at line 144 of file Configuration.cpp.

References om::cout, allTimeWatchdog::endl, fDetector, fEventTimeDifference, fFileName, fIsProducingJustMicroSlices, fIsProducingMilliSlices, fMicrosliceDT, fNanoSliceVersion, fNumberOfBufferNodes, fNumberOfMicroslicesInMilliSlice, and fOutputDir.

Referenced by Configuration().

144  {
145 
146  std::cout<<"MockDataDAQ Configuration: ";
147 
148  std::cout<<" Detector="<<fDetector<<std::endl;;
149  std::cout<<" Produce Just MicroSlices="<<fIsProducingJustMicroSlices<<std::endl;
150  std::cout<<" Producing MilliSlices="<<fIsProducingMilliSlices<<std::endl;
151  std::cout<<" Number Of Microslices In MilliSlice="<<fNumberOfMicroslicesInMilliSlice<<std::endl;;
152  std::cout<<" Microslice DT="<<fMicrosliceDT<<std::endl;;
153  std::cout<<" Number Of Buffer Nodes="<<fNumberOfBufferNodes<<std::endl;
154  std::cout<<" Event Time Difference="<<fEventTimeDifference<<std::endl;
155 
156  std::cout<<" Output Directory:"<<fOutputDir<<std::endl;
157  std::cout<<" FileName:"<<fFileName<<std::endl;
158  std::cout<<" NanoSliceVersion:"<<fNanoSliceVersion<<std::endl;
159 
160  return true;
161 }
uint32_t fNumberOfMicroslicesInMilliSlice
!< ipnd, near, far
Definition: Configuration.h:80
daqdataformats::version_t fNanoSliceVersion
!< Are me going to produce MilliSlices?
Definition: Configuration.h:94
std::string fOutputDir
Directory for the output files.
Definition: Configuration.h:85
uint32_t fNumberOfBufferNodes
Number of buffer nodes.
Definition: Configuration.h:83
bool fIsProducingMilliSlices
!< Are we producing Run Object?
Definition: Configuration.h:92
std::string fFileName
Output file names.
Definition: Configuration.h:86
uint32_t fMicrosliceDT
MicroSlice length in NOvA clock ticks (15.626 ns)
Definition: Configuration.h:81
OStream cout
Definition: OStream.cxx:6
int fDetector
!< Instance pointer for singleton class
Definition: Configuration.h:77
uint32_t fEventTimeDifference
Event time difference in NOvA clock ticks (15.626 ns)
Definition: Configuration.h:88
bool mcdatadaq::Configuration::setInstance ( fhicl::ParameterSet const &  pset)
static

Method to set the class instance with parameters from fhicl.

If the configuration already exists, then we delete it

Issue a brand new Configuration

Definition at line 45 of file Configuration.cpp.

References Configuration(), and finstanceID.

Referenced by mcdatadaq::MockDataDAQAna::MockDataDAQAna().

45  {
46 
47  /// If the configuration already exists, then we delete it
48  if(!finstanceID) delete finstanceID;
49 
50  /// Issue a brand new Configuration
51  finstanceID = new Configuration(parameters);
52 
53  return true;
54 }
Configuration()
default constructor
static Configuration * finstanceID
Definition: Configuration.h:75
bool mcdatadaq::Configuration::writeDAQSimulatorVersionIntoFile ( FILE *  file) const

Write Global DAQSimulator version into the input file.

Definition at line 188 of file Configuration.cpp.

References getDAQSimulatorVersion().

Referenced by mcdatadaq::DCMSimulator::DCMSimulator(), and mcdatadaq::GlobalTriggerSimulator::GlobalTriggerSimulator().

188  {
189 
190  const uint32_t daq_sim_version = getDAQSimulatorVersion();
191  fwrite (&daq_sim_version, 4 , 1, file);
192 
193  return true;
194 }
uint32_t getDAQSimulatorVersion() const
Get Global DAQSimulator version.
TFile * file
Definition: cellShifts.C:17
bool mcdatadaq::Configuration::writeToFile ( FILE *  file,
const daqdataformats::RawDAQData daq_data 
) const

Utility method of writing DAQ data into a file.

Write data into a file.

If empty file, exit

Definition at line 165 of file Configuration.cpp.

References file, daqdataformats::RawDAQData::getBuffer(), and daqdataformats::RawDAQData::sizeofdata().

Referenced by mcdatadaq::DataLoggerSimulator::writeEvent(), mcdatadaq::DCMSimulator::writeMicroSlices(), mcdatadaq::DCMSimulator::writeMilliSlices(), mcdatadaq::DataLoggerSimulator::writeRun(), and mcdatadaq::GlobalTriggerSimulator::writeTrigger().

165  {
166 
167  /// If empty file, exit
168  if(!file) return true;
169 
170  const size_t size_of_data_in_words = daq_data.sizeofdata();
171 
172  if(size_of_data_in_words == 0) return true;
173 
174  fwrite (daq_data.getBuffer(), 4, size_of_data_in_words, file);
175  return true;
176 }
void * getBuffer() const
Definition: RawDAQData.h:131
TFile * file
Definition: cellShifts.C:17
uint32_t sizeofdata() const
Sizeof method for the current data block. Returns the size of the data block in 32bit words...
Definition: RawDAQData.cpp:990

Member Data Documentation

int mcdatadaq::Configuration::fDetector
private

!< Instance pointer for singleton class

Definition at line 77 of file Configuration.h.

Referenced by getDetector(), init(), isDetectorUnknown(), and print().

uint32_t mcdatadaq::Configuration::fEventTimeDifference
private

Event time difference in NOvA clock ticks (15.626 ns)

Definition at line 88 of file Configuration.h.

Referenced by getEventTimeDifference(), and print().

std::string mcdatadaq::Configuration::fFileName
private

Output file names.

Definition at line 86 of file Configuration.h.

Referenced by getFileName(), and print().

Configuration * mcdatadaq::Configuration::finstanceID = NULL
staticprivate

Definition at line 75 of file Configuration.h.

Referenced by getInstance(), and setInstance().

bool mcdatadaq::Configuration::fIsProducingJustMicroSlices
private

Definition at line 90 of file Configuration.h.

Referenced by isProducingJustMicroSlices(), and print().

bool mcdatadaq::Configuration::fIsProducingMilliSlices
private

!< Are we producing Run Object?

Definition at line 92 of file Configuration.h.

Referenced by print().

bool mcdatadaq::Configuration::fIsProducingRunObject
private

!< Are we producing just microslices?

Definition at line 91 of file Configuration.h.

Referenced by isProducingRunObject().

daqdataformats::version_t mcdatadaq::Configuration::fMicroBlockVersion
private

Definition at line 95 of file Configuration.h.

Referenced by getMicroBlockVersion().

uint32_t mcdatadaq::Configuration::fMicrosliceDT
private

MicroSlice length in NOvA clock ticks (15.626 ns)

Definition at line 81 of file Configuration.h.

Referenced by getMicrosliceDT(), and print().

daqdataformats::version_t mcdatadaq::Configuration::fNanoSliceVersion
private

!< Are me going to produce MilliSlices?

Definition at line 94 of file Configuration.h.

Referenced by getNanoSliceVersion(), and print().

uint32_t mcdatadaq::Configuration::fNumberOfBufferNodes
private

Number of buffer nodes.

Definition at line 83 of file Configuration.h.

Referenced by getNumberOfBufferNodes(), and print().

uint32_t mcdatadaq::Configuration::fNumberOfMicroslicesInMilliSlice
private

!< ipnd, near, far

Number of Microslices in the MilliSlice

Definition at line 80 of file Configuration.h.

Referenced by print().

std::string mcdatadaq::Configuration::fOutputDir
private

Directory for the output files.

Definition at line 85 of file Configuration.h.

Referenced by Configuration(), getOutputDir(), and print().


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