19#ifdef HAS_RNTUPLE_SUPPORT
20#include "ROOT/RNTuple.hxx"
21#include "ROOT/RNTupleModel.hxx"
22#include "ROOT/RField.hxx"
30#ifdef __USE_DATABASE__
54#if __has_include(<valgrind/callgrind.h>)
55#include <valgrind/callgrind.h>
58Int_t
main(Int_t argc, Char_t* argv[])
61 ROOT::EnableImplicitMT();
68 gQwOptions.AddOptions()(
"single-output-file", po::value<bool>()->default_bool_value(
false),
"Write a single output file");
69 gQwOptions.AddOptions()(
"print-errorcounters", po::value<bool>()->default_bool_value(
true),
"Print summary of error counters");
70 gQwOptions.AddOptions()(
"write-promptsummary", po::value<bool>()->default_bool_value(
false),
"Write PromptSummary");
71 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)");
72 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)");
104 #ifdef __USE_DATABASE__
111 Int_t run_number = 0;
173 #ifdef __USE_DATABASE__
174 database.SetupOneRun(eventbuffer);
183 if (
gQwOptions.GetValue<
bool>(
"single-output-file")) {
186 burstrootfile = historootfile = treerootfile;
192 treerootfile =
new QwRootFile(run_label +
".trees");
193 burstrootfile =
new QwRootFile(run_label +
".bursts");
194 historootfile =
new QwRootFile(run_label +
".histos");
202 #ifdef __USE_DATABASE__
203 if (database.AllowsWriteAccess()) {
204 database.FillParameterFiles(detectors);
219 burstrootfile->
ConstructTreeBranches(
"burst",
"Burst level data tree", patternsum_per_burst,
"|stat");
222#ifdef HAS_RNTUPLE_SUPPORT
223 treerootfile->ConstructNTupleFields(
"evt",
"MPS event data RNTuple", ringoutput);
224 treerootfile->ConstructNTupleFields(
"mul",
"Helicity event data RNTuple", helicitypattern);
225 burstrootfile->ConstructNTupleFields(
"pr_yield",
"Pair yield RNTuple", helicitypattern.
GetPairYield(),
"yield_");
226 burstrootfile->ConstructNTupleFields(
"pr_asym",
"Pair asymmetry RNTuple", helicitypattern.
GetPairAsymmetry(),
"asym_");
227 treerootfile->ConstructNTupleFields(
"slow",
"EPICS and slow control RNTuple", epicsevent);
228 burstrootfile->ConstructNTupleFields(
"burst",
"Burst level data RNTuple", patternsum_per_burst,
"|stat");
240#ifdef HAS_RNTUPLE_SUPPORT
251#ifdef HAS_RNTUPLE_SUPPORT
252 treerootfile->ConstructNTupleFields(
"evts",
"Running sum RNTuple", eventsum,
"|stat");
253 treerootfile->ConstructNTupleFields(
"muls",
"Running sum RNTuple", patternsum,
"|stat");
254 burstrootfile->ConstructNTupleFields(
"bursts",
"Burst running sum RNTuple", burstsum,
"|stat");
277#ifdef __USE_DATABASE__
304#ifdef CALLGRIND_START_INSTRUMENTATION
305 if (
gQwOptions.GetValue<
bool>(
"callgrind-instr-start-event-loop")) {
307 CALLGRIND_START_INSTRUMENTATION;
333#ifdef HAS_RNTUPLE_SUPPORT
334 treerootfile->FillNTupleFields(epicsevent);
335 treerootfile->FillNTuple(
"slow");
356 eventring.
push(detectors);
360 ringoutput = eventring.
pop();
375#ifdef HAS_RNTUPLE_SUPPORT
376 treerootfile->FillNTupleFields(ringoutput);
377 treerootfile->FillNTuple(
"evt");
390#ifdef HAS_RNTUPLE_SUPPORT
407#ifdef HAS_RNTUPLE_SUPPORT
408 burstrootfile->FillNTupleFields(
"pr_yield", helicitypattern.
GetPairYield());
409 burstrootfile->FillNTupleFields(
"pr_asym", helicitypattern.
GetPairAsymmetry());
410 burstrootfile->FillNTuple(
"pr_yield");
411 burstrootfile->FillNTuple(
"pr_asym");
430#ifdef HAS_RNTUPLE_SUPPORT
431 treerootfile->FillNTupleFields(helicitypattern);
432 treerootfile->FillNTuple(
"mul");
446#ifdef HAS_RNTUPLE_SUPPORT
465 if (
gQwOptions.GetValue<
bool>(
"print-burstsum")) {
479#ifdef HAS_RNTUPLE_SUPPORT
480 burstrootfile->FillNTupleFields(patternsum_per_burst);
481 burstrootfile->FillNTuple(
"burst");
494#ifdef HAS_RNTUPLE_SUPPORT
522#ifdef CALLGRIND_START_INSTRUMENTATION
523 if (
gQwOptions.GetValue<
bool>(
"callgrind-instr-stop-event-loop")) {
524 CALLGRIND_STOP_INSTRUMENTATION;
539 if (
gQwOptions.GetValue<
bool>(
"print-burstsum")) {
553#ifdef HAS_RNTUPLE_SUPPORT
554 burstrootfile->FillNTupleFields(patternsum_per_burst);
555 burstrootfile->FillNTuple(
"burst");
568#ifdef HAS_RNTUPLE_SUPPORT
579 QwMessage <<
"Number of events processed at end of run: "
592 if (
gQwOptions.GetValue<
bool>(
"print-runningsum")) {
601#ifdef HAS_RNTUPLE_SUPPORT
602 treerootfile->FillNTupleFields(eventsum);
603 treerootfile->FillNTuple(
"evts");
606 if (
gQwOptions.GetValue<
bool>(
"print-patternsum")) {
615#ifdef HAS_RNTUPLE_SUPPORT
616 treerootfile->FillNTupleFields(patternsum);
617 treerootfile->FillNTuple(
"muls");
620 if (
gQwOptions.GetValue<
bool>(
"print-burstsum")) {
629#ifdef HAS_RNTUPLE_SUPPORT
630 burstrootfile->FillNTupleFields(burstsum);
631 burstrootfile->FillNTuple(
"bursts");
646 if (treerootfile == historootfile) {
648#ifdef HAS_RNTUPLE_SUPPORT
649 if (
gQwOptions.GetValue<
bool>(
"enable-rntuples") &&
gQwOptions.GetValue<
bool>(
"disable-trees")) {
651 treerootfile->
Close();
655 treerootfile->
Write(0, TObject::kOverwrite);
656 treerootfile->
Close();
657#ifdef HAS_RNTUPLE_SUPPORT
660 delete treerootfile; treerootfile = 0; burstrootfile = 0; historootfile = 0;
663#ifdef HAS_RNTUPLE_SUPPORT
664 if (
gQwOptions.GetValue<
bool>(
"enable-rntuples") &&
gQwOptions.GetValue<
bool>(
"disable-trees")) {
666 treerootfile->
Close();
667 burstrootfile->
Close();
668 historootfile->
Close();
672 treerootfile->
Write(0, TObject::kOverwrite);
673 burstrootfile->
Write(0, TObject::kOverwrite);
674 historootfile->
Write(0, TObject::kOverwrite);
675 treerootfile->
Close();
676 burstrootfile->
Close();
677 historootfile->
Close();
678#ifdef HAS_RNTUPLE_SUPPORT
681 delete treerootfile; treerootfile = 0;
682 delete burstrootfile; burstrootfile = 0;
683 delete historootfile; historootfile = 0;
687 if (
gQwOptions.GetValue<
bool>(
"print-errorcounters")) {
692 if (
gQwOptions.GetValue<
bool>(
"write-promptsummary")) {
701 #ifdef __USE_DATABASE__
702 database.SetupOneRun(eventbuffer);
705 if (database.AllowsWriteAccess()) {
706 patternsum.FillDB(&database);
707 patternsum.FillErrDB(&database);
708 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.
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.