19#ifdef HAS_RNTUPLE_SUPPORT
20#include "ROOT/RNTuple.hxx"
21#include "ROOT/RNTupleModel.hxx"
22#include "ROOT/RField.hxx"
30#ifdef __USE_DATABASE__
55#if __has_include(<valgrind/callgrind.h>)
56#include <valgrind/callgrind.h>
59Int_t
main(Int_t argc, Char_t* argv[])
62 ROOT::EnableImplicitMT();
69 gQwOptions.AddOptions()(
"single-output-file", po::value<bool>()->default_bool_value(
false),
"Write a single output file");
70 gQwOptions.AddOptions()(
"print-errorcounters", po::value<bool>()->default_bool_value(
true),
"Print summary of error counters");
71 gQwOptions.AddOptions()(
"write-promptsummary", po::value<bool>()->default_bool_value(
false),
"Write PromptSummary");
72 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)");
73 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)");
105 #ifdef __USE_DATABASE__
112 Int_t run_number = 0;
174 #ifdef __USE_DATABASE__
175 database.SetupOneRun(eventbuffer);
184 if (
gQwOptions.GetValue<
bool>(
"single-output-file")) {
187 burstrootfile = historootfile = treerootfile;
193 treerootfile =
new QwRootFile(run_label +
".trees");
194 burstrootfile =
new QwRootFile(run_label +
".bursts");
195 historootfile =
new QwRootFile(run_label +
".histos");
203 #ifdef __USE_DATABASE__
204 if (database.AllowsWriteAccess()) {
205 database.FillParameterFiles(detectors);
220 burstrootfile->
ConstructTreeBranches(
"burst",
"Burst level data tree", patternsum_per_burst,
"|stat");
223#ifdef HAS_RNTUPLE_SUPPORT
224 treerootfile->ConstructNTupleFields(
"evt",
"MPS event data RNTuple", ringoutput);
225 treerootfile->ConstructNTupleFields(
"mul",
"Helicity event data RNTuple", helicitypattern);
226 burstrootfile->ConstructNTupleFields(
"pr_yield",
"Pair yield RNTuple", helicitypattern.
GetPairYield(),
"yield_");
227 burstrootfile->ConstructNTupleFields(
"pr_asym",
"Pair asymmetry RNTuple", helicitypattern.
GetPairAsymmetry(),
"asym_");
228 treerootfile->ConstructNTupleFields(
"slow",
"EPICS and slow control RNTuple", epicsevent);
229 burstrootfile->ConstructNTupleFields(
"burst",
"Burst level data RNTuple", patternsum_per_burst,
"|stat");
241#ifdef HAS_RNTUPLE_SUPPORT
252#ifdef HAS_RNTUPLE_SUPPORT
253 treerootfile->ConstructNTupleFields(
"evts",
"Running sum RNTuple", eventsum,
"|stat");
254 treerootfile->ConstructNTupleFields(
"muls",
"Running sum RNTuple", patternsum,
"|stat");
255 burstrootfile->ConstructNTupleFields(
"bursts",
"Burst running sum RNTuple", burstsum,
"|stat");
278#ifdef __USE_DATABASE__
305#ifdef CALLGRIND_START_INSTRUMENTATION
306 if (
gQwOptions.GetValue<
bool>(
"callgrind-instr-start-event-loop")) {
308 CALLGRIND_START_INSTRUMENTATION;
334#ifdef HAS_RNTUPLE_SUPPORT
335 treerootfile->FillNTupleFields(epicsevent);
336 treerootfile->FillNTuple(
"slow");
357 eventring.
push(detectors);
361 ringoutput = eventring.
pop();
376#ifdef HAS_RNTUPLE_SUPPORT
377 treerootfile->FillNTupleFields(ringoutput);
378 treerootfile->FillNTuple(
"evt");
391#ifdef HAS_RNTUPLE_SUPPORT
408#ifdef HAS_RNTUPLE_SUPPORT
409 burstrootfile->FillNTupleFields(
"pr_yield", helicitypattern.
GetPairYield());
410 burstrootfile->FillNTupleFields(
"pr_asym", helicitypattern.
GetPairAsymmetry());
411 burstrootfile->FillNTuple(
"pr_yield");
412 burstrootfile->FillNTuple(
"pr_asym");
431#ifdef HAS_RNTUPLE_SUPPORT
432 treerootfile->FillNTupleFields(helicitypattern);
433 treerootfile->FillNTuple(
"mul");
447#ifdef HAS_RNTUPLE_SUPPORT
466 if (
gQwOptions.GetValue<
bool>(
"print-burstsum")) {
480#ifdef HAS_RNTUPLE_SUPPORT
481 burstrootfile->FillNTupleFields(patternsum_per_burst);
482 burstrootfile->FillNTuple(
"burst");
495#ifdef HAS_RNTUPLE_SUPPORT
523#ifdef CALLGRIND_START_INSTRUMENTATION
524 if (
gQwOptions.GetValue<
bool>(
"callgrind-instr-stop-event-loop")) {
525 CALLGRIND_STOP_INSTRUMENTATION;
540 if (
gQwOptions.GetValue<
bool>(
"print-burstsum")) {
554#ifdef HAS_RNTUPLE_SUPPORT
555 burstrootfile->FillNTupleFields(patternsum_per_burst);
556 burstrootfile->FillNTuple(
"burst");
569#ifdef HAS_RNTUPLE_SUPPORT
580 QwMessage <<
"Number of events processed at end of run: "
593 if (
gQwOptions.GetValue<
bool>(
"print-runningsum")) {
602#ifdef HAS_RNTUPLE_SUPPORT
603 treerootfile->FillNTupleFields(eventsum);
604 treerootfile->FillNTuple(
"evts");
607 if (
gQwOptions.GetValue<
bool>(
"print-patternsum")) {
616#ifdef HAS_RNTUPLE_SUPPORT
617 treerootfile->FillNTupleFields(patternsum);
618 treerootfile->FillNTuple(
"muls");
621 if (
gQwOptions.GetValue<
bool>(
"print-burstsum")) {
630#ifdef HAS_RNTUPLE_SUPPORT
631 burstrootfile->FillNTupleFields(burstsum);
632 burstrootfile->FillNTuple(
"bursts");
647 if (treerootfile == historootfile) {
649#ifdef HAS_RNTUPLE_SUPPORT
650 if (
gQwOptions.GetValue<
bool>(
"enable-rntuples") &&
gQwOptions.GetValue<
bool>(
"disable-trees")) {
652 treerootfile->
Close();
656 treerootfile->
Write(0, TObject::kOverwrite);
657 treerootfile->
Close();
658#ifdef HAS_RNTUPLE_SUPPORT
661 delete treerootfile; treerootfile = 0; burstrootfile = 0; historootfile = 0;
664#ifdef HAS_RNTUPLE_SUPPORT
665 if (
gQwOptions.GetValue<
bool>(
"enable-rntuples") &&
gQwOptions.GetValue<
bool>(
"disable-trees")) {
667 treerootfile->
Close();
668 burstrootfile->
Close();
669 historootfile->
Close();
673 treerootfile->
Write(0, TObject::kOverwrite);
674 burstrootfile->
Write(0, TObject::kOverwrite);
675 historootfile->
Write(0, TObject::kOverwrite);
676 treerootfile->
Close();
677 burstrootfile->
Close();
678 historootfile->
Close();
679#ifdef HAS_RNTUPLE_SUPPORT
682 delete treerootfile; treerootfile = 0;
683 delete burstrootfile; burstrootfile = 0;
684 delete historootfile; historootfile = 0;
688 if (
gQwOptions.GetValue<
bool>(
"print-errorcounters")) {
693 if (
gQwOptions.GetValue<
bool>(
"write-promptsummary")) {
702 #ifdef __USE_DATABASE__
703 database.SetupOneRun(eventbuffer);
706 if (database.AllowsWriteAccess()) {
707 patternsum.FillDB(&database);
708 patternsum.FillErrDB(&database);
709 epicsevent.
FillDB(&database);
Helper functions and utilities for ROOT histogram management.
QwHistogramHelper gQwHists
Globally defined instance of the QwHistogramHelper class.
const std::string getenv_safe_string(const char *name)
A logfile class, based on an identical class in the Hermes analyzer.
#define QwMessage
Predefined log drain for regular messages.
ROOT file and tree management wrapper classes.
EPICS data event handling and storage.
Prompt summary data management.
Event buffer management for reading and processing CODA data.
Helicity state management and pattern recognition.
Subsystem array container for parity analysis with asymmetry calculations.
Event ring buffer for burp detection and stability monitoring.
Beam modulation subsystem for parity analysis.
Correlator data handler using LinRegBlue algorithms.
Integrated raster subsystem for beam position tracking.
Combiner subsystem for parity analysis data handling.
Data extraction handler for output processing.
Linear regression blue corrector data handler class.
Data combiner handler for channel operations.
Beamline subsystem containing BPMs, BCMs, and other beam monitoring devices.
Fake helicity generator using pregenerated random seeds.
Array container for managing multiple data handlers.
Load the options for the parity subsystems.
void DefineOptionsParity(QwOptions &options)
Helicity pattern analysis and management.
Int_t main(Int_t argc, Char_t *argv[])
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.