19#ifdef HAS_RNTUPLE_SUPPORT
20#include "ROOT/RNTuple.hxx"
21#include "ROOT/RNTupleModel.hxx"
22#include "ROOT/RField.hxx"
30#ifdef __USE_DATABASE__
56#if __has_include(<valgrind/callgrind.h>)
57#include <valgrind/callgrind.h>
60Int_t
main(Int_t argc, Char_t* argv[])
63 ROOT::EnableImplicitMT();
70 gQwOptions.AddOptions()(
"single-output-file", po::value<bool>()->default_bool_value(
false),
"Write a single output file");
71 gQwOptions.AddOptions()(
"print-errorcounters", po::value<bool>()->default_bool_value(
true),
"Print summary of error counters");
72 gQwOptions.AddOptions()(
"write-promptsummary", po::value<bool>()->default_bool_value(
false),
"Write PromptSummary");
73 gQwOptions.AddOptions()(
"callgrind-instr-start-event-loop", po::value<bool>()->default_bool_value(
false),
"Start callgrind instrumentation with main event loop (with --instr-atstart=no)");
74 gQwOptions.AddOptions()(
"callgrind-instr-stop-event-loop", po::value<bool>()->default_bool_value(
false),
"Stop callgrind instrumentation with main event loop (with --instr-atstart=no)");
106 #ifdef __USE_DATABASE__
113 Int_t run_number = 0;
175 #ifdef __USE_DATABASE__
176 database.SetupOneRun(eventbuffer);
185 if (
gQwOptions.GetValue<
bool>(
"single-output-file")) {
188 burstrootfile = historootfile = treerootfile;
194 treerootfile =
new QwRootFile(run_label +
".trees");
195 burstrootfile =
new QwRootFile(run_label +
".bursts");
196 historootfile =
new QwRootFile(run_label +
".histos");
204 #ifdef __USE_DATABASE__
205 if (database.AllowsWriteAccess()) {
206 database.FillParameterFiles(detectors);
221 burstrootfile->
ConstructTreeBranches(
"burst",
"Burst level data tree", patternsum_per_burst,
"|stat");
224#ifdef HAS_RNTUPLE_SUPPORT
225 treerootfile->ConstructNTupleFields(
"evt",
"MPS event data RNTuple", ringoutput);
226 treerootfile->ConstructNTupleFields(
"mul",
"Helicity event data RNTuple", helicitypattern);
227 burstrootfile->ConstructNTupleFields(
"pr_yield",
"Pair yield RNTuple", helicitypattern.
GetPairYield(),
"yield_");
228 burstrootfile->ConstructNTupleFields(
"pr_asym",
"Pair asymmetry RNTuple", helicitypattern.
GetPairAsymmetry(),
"asym_");
229 treerootfile->ConstructNTupleFields(
"slow",
"EPICS and slow control RNTuple", epicsevent);
230 burstrootfile->ConstructNTupleFields(
"burst",
"Burst level data RNTuple", patternsum_per_burst,
"|stat");
242#ifdef HAS_RNTUPLE_SUPPORT
253#ifdef HAS_RNTUPLE_SUPPORT
254 treerootfile->ConstructNTupleFields(
"evts",
"Running sum RNTuple", eventsum,
"|stat");
255 treerootfile->ConstructNTupleFields(
"muls",
"Running sum RNTuple", patternsum,
"|stat");
256 burstrootfile->ConstructNTupleFields(
"bursts",
"Burst running sum RNTuple", burstsum,
"|stat");
279#ifdef __USE_DATABASE__
306#ifdef CALLGRIND_START_INSTRUMENTATION
307 if (
gQwOptions.GetValue<
bool>(
"callgrind-instr-start-event-loop")) {
309 CALLGRIND_START_INSTRUMENTATION;
335#ifdef HAS_RNTUPLE_SUPPORT
336 treerootfile->FillNTupleFields(epicsevent);
337 treerootfile->FillNTuple(
"slow");
358 eventring.
push(detectors);
362 ringoutput = eventring.
pop();
377#ifdef HAS_RNTUPLE_SUPPORT
378 treerootfile->FillNTupleFields(ringoutput);
379 treerootfile->FillNTuple(
"evt");
392#ifdef HAS_RNTUPLE_SUPPORT
409#ifdef HAS_RNTUPLE_SUPPORT
410 burstrootfile->FillNTupleFields(
"pr_yield", helicitypattern.
GetPairYield());
411 burstrootfile->FillNTupleFields(
"pr_asym", helicitypattern.
GetPairAsymmetry());
412 burstrootfile->FillNTuple(
"pr_yield");
413 burstrootfile->FillNTuple(
"pr_asym");
432#ifdef HAS_RNTUPLE_SUPPORT
433 treerootfile->FillNTupleFields(helicitypattern);
434 treerootfile->FillNTuple(
"mul");
448#ifdef HAS_RNTUPLE_SUPPORT
467 if (
gQwOptions.GetValue<
bool>(
"print-burstsum")) {
481#ifdef HAS_RNTUPLE_SUPPORT
482 burstrootfile->FillNTupleFields(patternsum_per_burst);
483 burstrootfile->FillNTuple(
"burst");
496#ifdef HAS_RNTUPLE_SUPPORT
524#ifdef CALLGRIND_START_INSTRUMENTATION
525 if (
gQwOptions.GetValue<
bool>(
"callgrind-instr-stop-event-loop")) {
526 CALLGRIND_STOP_INSTRUMENTATION;
541 if (
gQwOptions.GetValue<
bool>(
"print-burstsum")) {
555#ifdef HAS_RNTUPLE_SUPPORT
556 burstrootfile->FillNTupleFields(patternsum_per_burst);
557 burstrootfile->FillNTuple(
"burst");
570#ifdef HAS_RNTUPLE_SUPPORT
581 QwMessage <<
"Number of events processed at end of run: "
594 if (
gQwOptions.GetValue<
bool>(
"print-runningsum")) {
603#ifdef HAS_RNTUPLE_SUPPORT
604 treerootfile->FillNTupleFields(eventsum);
605 treerootfile->FillNTuple(
"evts");
608 if (
gQwOptions.GetValue<
bool>(
"print-patternsum")) {
617#ifdef HAS_RNTUPLE_SUPPORT
618 treerootfile->FillNTupleFields(patternsum);
619 treerootfile->FillNTuple(
"muls");
622 if (
gQwOptions.GetValue<
bool>(
"print-burstsum")) {
631#ifdef HAS_RNTUPLE_SUPPORT
632 burstrootfile->FillNTupleFields(burstsum);
633 burstrootfile->FillNTuple(
"bursts");
648 if (treerootfile == historootfile) {
650#ifdef HAS_RNTUPLE_SUPPORT
651 if (
gQwOptions.GetValue<
bool>(
"enable-rntuples") &&
gQwOptions.GetValue<
bool>(
"disable-trees")) {
653 treerootfile->
Close();
657 treerootfile->
Write(0, TObject::kOverwrite);
658 treerootfile->
Close();
659#ifdef HAS_RNTUPLE_SUPPORT
662 delete treerootfile; treerootfile = 0; burstrootfile = 0; historootfile = 0;
665#ifdef HAS_RNTUPLE_SUPPORT
666 if (
gQwOptions.GetValue<
bool>(
"enable-rntuples") &&
gQwOptions.GetValue<
bool>(
"disable-trees")) {
668 treerootfile->
Close();
669 burstrootfile->
Close();
670 historootfile->
Close();
674 treerootfile->
Write(0, TObject::kOverwrite);
675 burstrootfile->
Write(0, TObject::kOverwrite);
676 historootfile->
Write(0, TObject::kOverwrite);
677 treerootfile->
Close();
678 burstrootfile->
Close();
679 historootfile->
Close();
680#ifdef HAS_RNTUPLE_SUPPORT
683 delete treerootfile; treerootfile = 0;
684 delete burstrootfile; burstrootfile = 0;
685 delete historootfile; historootfile = 0;
689 if (
gQwOptions.GetValue<
bool>(
"print-errorcounters")) {
694 if (
gQwOptions.GetValue<
bool>(
"write-promptsummary")) {
703 #ifdef __USE_DATABASE__
704 database.SetupOneRun(eventbuffer);
707 if (database.AllowsWriteAccess()) {
708 patternsum.FillDB(&database);
709 patternsum.FillErrDB(&database);
710 epicsevent.
FillDB(&database);
A logfile class, based on an identical class in the Hermes analyzer.
#define QwMessage
Predefined log drain for regular messages.
Event buffer management for reading and processing CODA data.
EPICS data event handling and storage.
Prompt summary data management.
Helper functions and utilities for ROOT histogram management.
QwHistogramHelper gQwHists
Globally defined instance of the QwHistogramHelper class.
ROOT file and tree management wrapper classes.
const std::string getenv_safe_string(const char *name)
Int_t main(Int_t argc, Char_t *argv[])
Event ring buffer for burp detection and stability monitoring.
Helicity state management and pattern recognition.
Subsystem array container for parity analysis with asymmetry calculations.
Correlator data handler using LinRegBlue algorithms.
Beamline subsystem containing BPMs, BCMs, and other beam monitoring devices.
Helicity pattern analysis and management.
Load the options for the parity subsystems.
void DefineOptionsParity(QwOptions &options)
Fake helicity generator using pregenerated random seeds.
Beam modulation subsystem for parity analysis.
Linear regression blue corrector data handler class.
Array container for managing multiple data handlers.
Data combiner handler for channel operations.
Combiner subsystem for parity analysis data handling.
Data extraction handler for output processing.
void ListPublishedValues() const
List all published variables with descriptions Prints a summary of all currently published variables ...
EPICS slow controls data management.
Bool_t HasDataLoaded() const
void ProcessOptions(QwOptions &options)
Process the configuration options.
Int_t LoadChannelMap(TString mapfile)
void CalculateRunningValues()
void FillDB(QwParityDB *db)
Event buffer management for reading and processing CODA data.
TString GetRunLabel() const
Returns a string like <run#> or <run#>.<file#>
Int_t CloseStream()
Closes a currently open event stream.
Int_t OpenNextStream()
Opens the event stream (file or ET) based on the internal flags.
void ProcessOptions(QwOptions &options)
Sets internal flags based on the QwOptions.
Bool_t FillSubsystemData(QwSubsystemArray &subsystems)
Int_t GetSegmentNumber() const
Return CODA file segment number.
TString GetStartSQLTime()
Int_t GetRunNumber() const
Return CODA file run number.
Bool_t IsROCConfigurationEvent()
Int_t GetPhysicsEventNumber()
Bool_t FillEPICSData(QwEPICSEvent &epics)
Bool_t FillSubsystemConfigurationData(QwSubsystemArray &subsystems)
static std::ostream & endl(std::ostream &)
End of the line.
static void AppendToSearchPath(const TString &searchdir)
Add a directory to the search path.
static void SetCurrentRunNumber(const UInt_t runnumber)
Set the current run number for looking up the appropriate parameter file.
void PrintCSV(Int_t nEvents, TString start_time, TString end_time)
A wrapper class for a ROOT file or memory mapped file.
Int_t FillTree(const std::string &name)
Fill the tree with name.
Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
void ConstructTreeBranches(const std::string &name, const std::string &desc, T &object, const std::string &prefix="")
Construct the tree branches of a generic object.
void FillHistograms(T &object)
Fill histograms of the subsystem array.
void FillTreeBranches(const std::string &name, const T &object)
Fill the tree branches of a generic object by tree name.
Int_t WriteParamFileList(const TString &name, T &object)
void ConstructHistograms(const std::string &name, T &object)
Construct the histograms of a generic object.
void ConstructObjects(const std::string &name, T &object)
Construct the histograms of a generic object.
void ProcessEvent()
Process the decoded data in this event.
void PrintParamFileList() const
Print list of parameter files.
void ShareHistograms(const QwSubsystemArray &source)
Share the histograms with another subsystem.
void ProcessOptions(QwOptions &options)
Process configuration options (default behavior)
void AtEndOfEventLoop()
Perform actions at the end of the event loop.
Virtual base class for the parity handlers.
void UpdateBurstCounter(Short_t burstcounter)
void FillNTupleFields(QwRootFile *treerootfile)
void ProcessDataHandlerEntry()
void FillTreeBranches(QwRootFile *treerootfile)
void ConstructTreeBranches(QwRootFile *treerootfile, const std::string &treeprefix="", const std::string &branchprefix="")
void WritePromptSummary(QwPromptSummary *ps, TString type)
void ConstructNTupleFields(QwRootFile *treerootfile, const std::string &treeprefix="", const std::string &branchprefix="")
RNTuple methods.
Ring buffer of subsystem snapshots for burp/stability handling.
QwSubsystemArrayParity & pop()
Return the last subsystem in the ring.
void push(QwSubsystemArrayParity &event)
Add the subsystem to the ring.
Bool_t IsReady()
Return the read status of the ring.
void Unwind()
Unwind the ring until empty.
Manages yields/differences/asymmetries for helicity patterns.
QwSubsystemArrayParity & GetPairYield()
void DisablePairs()
Disable storing pair differences.
void UpdateBlinder()
Update the blinder status using a random number generator.
void ProcessOptions(QwOptions &options)
Process the configuration options.
void AccumulatePairRunningSum(QwHelicityPattern &entry)
QwSubsystemArrayParity & GetPairAsymmetry()
Short_t GetBurstCounter() const
QwSubsystemArrayParity & GetPairDifference()
void WritePromptSummary(QwPromptSummary *ps)
void PrintIndexMapFile(Int_t runNum)
void LoadEventData(QwSubsystemArrayParity &event)
void IncrementBurstCounter()
void AccumulateRunningSum(QwHelicityPattern &entry, Int_t count=0, Int_t ErrorMask=0xFFFFFFF)
Bool_t PairAsymmetryIsGood()
void CalculateRunningAverage()
Subsystem array container specialized for parity analysis with asymmetry calculations.
void PrintErrorCounters() const
Report the number of events failed due to HW and event cut failures.
void PrintValue() const
Print value of all channels.
void IncrementErrorCounters()
Update the data elements' error counters based on their internal error flags.
void AccumulateRunningSum(const QwSubsystemArrayParity &value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF)
Update the running sums for devices accumulated for the global error non-zero events/patterns.
void CalculateRunningAverage()
Calculate the average for all good events.
void FillDB_MPS(QwParityDB *db, TString type)
Fill the database with MPS-based variables Note that most subsystems don't need to do this.
Bool_t ApplySingleEventCuts()
Apply the single event cuts.