GlobalTriggerSimulator.cpp
Go to the documentation of this file.
1 /*
2  * File: GlobalTriggerSimulator.cpp
3  * Author: denis
4  *
5  * Created on February 14, 2012, 6:01 PM
6  */
7 
8 #ifdef NOVACMAKE
12 #else
13 #include "MockDataDAQ/GlobalEventTime.h"
14 #include "MockDataDAQ/GlobalTriggerSimulator.h"
15 #include "MockDataDAQ/Configuration.h"
16 #endif
17 
18 #include <DAQDataFormats/RawTrigger.h>
19 #include <DAQDataFormats/RawTriggerMask.h>
20 #include <DAQDataFormats/RawTriggerTime.h>
21 
22 /// Keyword in the file name for Trigger's file
23 #define TRIGGER_KEYWORD_IN_FILE_NAME "TriggerBlocks"
24 
25 namespace mcdatadaq {
26 
27 //------------------------------------------------------------------------------
29  // Setup the pointer to the Trigger inside the fRawEvent
30  fTrigger.getTriggerHeader()->setSource(daqdataformats::TRIGSRC_SIMULATED);
31 
32  fTrigger.getTriggerTime()->setClockSource(daqdataformats::CLOCKSRC_DUMMY);
33 
34 
35  fTrigger.getTriggerRange()->setTriggerLength(4000); //500 microseconds
36  //fTrigger.getTriggerRange()->setTriggerCont(0); //Not infinity
37 
38  fTrigger.getTriggerMask()->setMonteCarloFlag(1);
39  fTrigger.getTriggerMask()->setTrigMod(0);// who know what this is
40  fTrigger.getTriggerMask()->setPrescale(1); //?
41 
43  const std::string final_file_name_trigger = config->getFullFileName(TRIGGER_KEYWORD_IN_FILE_NAME);
44  fOutputTriggerFile = fopen (final_file_name_trigger.c_str(),"wb");
45 
46  /// Now we need to write DAQ Simulation version in the beginning of the file
48 
49 }
50 
51 //------------------------------------------------------------------------------
53 
54  /// Close output files
55  if(fOutputTriggerFile) {
57  }
58 
59 }
60 
61 //------------------------------------------------------------------------------
63 
64  const GlobalEventTime* global_event_time = GlobalEventTime::getInstance();
65 
66  fTrigger.getTriggerTime()->setTriggerTimeStamp(global_event_time->getGlobalEventTime());
67  fTrigger.getTriggerHeader()->setTriggerNumber(fTrigger.getTriggerHeader()->getTriggerNumber() + 1);
68 
69  /// Write the Trigger into the output triggerblocks file
70  writeTrigger();
71 
72  return getTrigger();
73 }
74 
75 //------------------------------------------------------------------------------
76 /// Gets current trigger
78 
79 //------------------------------------------------------------------------------
82  return config->writeToFile(fOutputTriggerFile, fTrigger);
83 }
84 
85 }// end of namespace
unsigned long long getGlobalEventTime() const
GetGlobal Time.
Definition: config.py:1
Class to hold the data from the global trigger in the correct format.
Definition: RawTrigger.h:40
#define TRIGGER_KEYWORD_IN_FILE_NAME
Keyword in the file name for Trigger&#39;s file.
static Configuration * getInstance()
Method to obtain the class instance.
fclose(fg1)
daqdataformats::RawTrigger fTrigger
Instance of a Trigger.
Something conflicts with RandomNumberGenerator. Keep DAQSimulator.h include below Art Framework inclu...
bool writeToFile(FILE *, const daqdataformats::RawDAQData &) const
Utility method of writing DAQ data into a file.
FILE * fOutputTriggerFile
File for Triggers.
std::string getFullFileName(const std::string addition_to_file_name) const
daqdataformats::RawTrigger * getNewTrigger()
Generates a new trigger.
bool writeDAQSimulatorVersionIntoFile(FILE *) const
Write Global DAQSimulator version into the input file.
daqdataformats::RawTrigger * getTrigger()
Gets the current trigger.
static GlobalEventTime * getInstance()
Method to obtain the class instance.
bool writeTrigger()
Write Trigger Object into output file.
enum BeamMode string