LDMX Software
Process.h
Go to the documentation of this file.
1
7#ifndef LDMXSW_FRAMEWORK_PROCESS_H_
8#define LDMXSW_FRAMEWORK_PROCESS_H_
9
10// LDMX
12#include "Framework/Configure/Parameters.h"
13#include "Framework/Exception/Exception.h"
14#include "Framework/Performance/Tracker.h"
15#include "Framework/RunHeader.h"
17
18// STL
19#include <map>
20#include <memory>
21#include <vector>
22
23class TFile;
24class TDirectory;
25
26namespace framework {
27
28class EventProcessor;
29class EventFile;
30class Event;
31
36class Process {
37 public:
42 Process(const framework::config::Parameters &configuration);
43
50 ~Process();
51
56 const std::string &getPassName() const { return passname_; }
57
63 int getRunNumber() const;
64
69
73 const ldmx::RunHeader *getRunHeader() const { return runHeader_; }
74
79
84 int getLogFrequency() const { return logFrequency_; }
85
89 void run();
90
94 void requestFinish() { eventLimit_ = 0; }
95
99 TDirectory *makeHistoDirectory(const std::string &dirName);
100
104 TDirectory *openHistoFile();
105
110
115
126 static Process getDummy() { return std::move(Process()); }
127
128 private:
133 Process() : conditions_{*this} {}
134
147 bool process(int n, int n_tries, Event &event) const;
148
155 void newRun(ldmx::RunHeader &header);
156
160 void onFileOpen(EventFile &file) const;
161
165 void onFileClose(EventFile &file) const;
166
167 private:
170
172 std::string passname_;
173
176
181
184
187
192
195
197 std::vector<EventProcessor *> sequence_;
198
201
204 std::vector<std::string> inputFiles_;
205
207 std::vector<std::string> outputFiles_;
208
217
219 std::vector<std::string> dropKeepRules_;
220
223
225 std::string histoFilename_;
226
229
232
234 TFile *histoTFile_{0};
235
238
240 enableLogging("Process");
241};
242
248typedef std::unique_ptr<Process> ProcessHandle;
249} // namespace framework
250
251#endif
Container and caching class for conditions information.
Definitions related to event storage control from an EventProcessor.
Container and cache for conditions and conditions providers.
Definition Conditions.h:43
This class manages all ROOT file input/output operations.
Definition EventFile.h:26
Implements an event buffer system for storing event data.
Definition Event.h:41
Class which represents the process under execution.
Definition Process.h:36
std::vector< EventProcessor * > sequence_
Ordered list of EventProcessors to execute.
Definition Process.h:197
std::vector< std::string > outputFiles_
List of output file names.
Definition Process.h:207
ldmx::RunHeader * runHeader_
Pointer to the current RunHeader, used for Conditions information.
Definition Process.h:231
void requestFinish()
Request that the processing finish with this event.
Definition Process.h:94
bool skipCorruptedInputFiles_
allow the Process to skip input files that are corrupted
Definition Process.h:191
std::vector< std::string > dropKeepRules_
Set of drop/keep rules.
Definition Process.h:219
void setEventHeader(ldmx::EventHeader *h)
Set the pointer to the current event header, used only for tests.
Definition Process.h:114
void run()
Run the process.
Definition Process.cxx:140
void newRun(ldmx::RunHeader &header)
Run through the processors and let them know that we are starting a new run.
Definition Process.cxx:452
std::string histoFilename_
Filename for histograms and other user products.
Definition Process.h:225
StorageControl storageController_
Storage controller.
Definition Process.h:194
int getLogFrequency() const
Get the frequency with which the event information is printed.
Definition Process.h:84
const ldmx::RunHeader * getRunHeader() const
Get the pointer to the current run header, if defined.
Definition Process.h:73
TDirectory * openHistoFile()
Open a ROOT TFile to write histograms and TTrees.
Definition Process.cxx:431
static Process getDummy()
Get a dummy process.
Definition Process.h:126
int totalEvents_
Number of events we'd like to produce independetly of the number of tries it would take.
Definition Process.h:180
int maxTries_
Maximum number of attempts to make before giving up on an event.
Definition Process.h:186
~Process()
Class Destructor.
Definition Process.cxx:126
void onFileClose(EventFile &file) const
File is begin closed.
Definition Process.cxx:539
std::vector< std::string > inputFiles_
List of input files to process.
Definition Process.h:204
Conditions & getConditions()
Get a reference to the conditions system.
Definition Process.h:78
TDirectory * makeHistoDirectory(const std::string &dirName)
Construct a TDirectory* for the given module.
Definition Process.cxx:424
std::string passname_
Processing pass name.
Definition Process.h:172
const ldmx::EventHeader * getEventHeader() const
Get the pointer to the current event header, if defined.
Definition Process.h:68
performance::Tracker * performance_
class with calls backs to track performance measurements of software
Definition Process.h:237
StorageControl & getStorageController()
Access the storage control unit for this process.
Definition Process.h:109
const ldmx::EventHeader * eventHeader_
Pointer to the current EventHeader, used for Conditions information.
Definition Process.h:228
int compressionSetting_
Compression setting to pass to output files.
Definition Process.h:216
const std::string & getPassName() const
Get the processing pass label.
Definition Process.h:56
enableLogging("Process")
Turn on logging for our process.
bool process(int n, int n_tries, Event &event) const
Process the input event through the sequence of processors.
Definition Process.cxx:484
int logFrequency_
The frequency with which event info is printed.
Definition Process.h:183
int runForGeneration_
Run number to use if generating events.
Definition Process.h:222
Process()
Private dummy constructor We hide it here because it shouldn't be used anywhere else.
Definition Process.h:133
void onFileOpen(EventFile &file) const
File is being opened.
Definition Process.cxx:525
Conditions conditions_
Set of ConditionsProviders.
Definition Process.h:200
int eventLimit_
Limit on events to process.
Definition Process.h:175
int getRunNumber() const
Get the current run number or the run number to be used when initiating new events from the job.
Definition Process.cxx:420
framework::config::Parameters config_
The parameters used to configure this class.
Definition Process.h:169
TFile * histoTFile_
TFile for histograms and other user products.
Definition Process.h:234
Class which encapsulates storage control functionality, used by the Process class.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
Class to interface between framework::Process and various measurements that can eventually be written...
Definition Tracker.h:20
Provides header information an event such as event number and timestamp.
Definition EventHeader.h:44
Run-specific configuration and data stored in its own output TTree alongside the event TTree in the o...
Definition RunHeader.h:54
All classes in the ldmx-sw project use this namespace.
Definition PerfDict.cxx:45
std::unique_ptr< Process > ProcessHandle
A handle to the current process Used to pass a process from ConfigurePython to fire....
Definition Process.h:248