14#ifdef HAS_RNTUPLE_SUPPORT
15#include <ROOT/RNTupleModel.hxx>
16#include <ROOT/RNTupleWriter.hxx>
20#ifdef __USE_DATABASE__
51 fEnergyChange.InitializeChannel(subsystem,
"QwEnergyCalculator", name,datatosave);
65 Bool_t ldebug = kFALSE;
69 fType.push_back(type);
73 std::cout<<
"QwEnergyCalculator:: Using "<<device->
GetElementName()<<
" with ratio "<< tmatrix_ratio <<
" for "<<
property<<std::endl;
84 if(prefix.Contains(
"diff_")||prefix.Contains(
"yield_")|| prefix.Contains(
"asym_"))
113 for(UInt_t i = 0; i<
fProperty.size(); i++){
114 if(
fProperty[i].Contains(
"targetbeamangle")){
178 for(UInt_t i=0; i<
fProperty.size(); i++) {
195 for(UInt_t i = 0; i<
fProperty.size(); i++) {
201 if(
fProperty[i].Contains(
"targetbeamangle")) {
221 static QwVQWK_Channel tmp_e;
222 tmp_e.InitializeChannel("tmp_e","derived");
223 tmp_e.ClearEventData();
225 for(UInt_t i = 0; i<fProperty.size(); i++){
226 if(fProperty[i].Contains("targetbeamangle")){
227 tmp.ArcTan((((QwCombinedBPM<QwVQWK_Channel>*)fDevice[i])->fSlope[VQwBPM::kXAxis]));
229 tmp.AssignValueFrom(fDevice[i]->GetPosition(VQwBPM::kXAxis));
231 tmp.Scale(fTMatrixRatio[i]);
234 // std::cout << "GetProjectedPosition()::fEnergyChange = " << fEnergyChange.GetValue(0) << "\t ProcessEvent()::fEnergyChange = " << tmp_e.GetValue(0) << std::endl;
276 UInt_t error_code = 0;
277 for(UInt_t i = 0; i<
fProperty.size(); i++){
278 if(
fProperty[i].Contains(
"targetbeamangle")){
322 UInt_t error_code = 0;
323 for(UInt_t i = 0; i<
fProperty.size(); i++){
324 if(
fProperty[i].Contains(
"targetbeamangle")){
385 if (
this != &value) {
466 Bool_t eventokay=kTRUE;
494 fEnergyChange.SetSingleEventCuts(errorflag,LL,UL,stability,burplevel);
503 Bool_t burpstatus = kFALSE;
505 if(
typeid(*ev_error)==
typeid(*
this)) {
512 TString loc=
"Standard exception from QwEnergyCalculator::CheckForBurpFail :"+
515 throw std::invalid_argument(loc.Data());
517 }
catch (std::exception& e) {
518 std::cerr<< e.what()<<std::endl;
533 TString thisprefix=prefix;
534 if(prefix.Contains(
"asym_"))
535 thisprefix.ReplaceAll(
"asym_",
"diff_");
565 TString thisprefix=prefix;
566 if(prefix.Contains(
"asym_"))
567 thisprefix.ReplaceAll(
"asym_",
"diff_");
571 fEnergyChange.ConstructBranchAndVector(tree,thisprefix,values);
588 TString thisprefix=prefix;
589 if(prefix.Contains(
"asym_"))
590 thisprefix.ReplaceAll(
"asym_",
"diff_");
602 devicename.ToLower();
607 if (modulelist.
HasValue(devicename)){
608 TString thisprefix=prefix;
609 if(prefix.Contains(
"asym_"))
610 thisprefix.ReplaceAll(
"asym_",
"diff_");
628#ifdef HAS_RNTUPLE_SUPPORT
629void QwEnergyCalculator::ConstructNTupleAndVector(std::unique_ptr<ROOT::RNTupleModel>& model, TString& prefix, std::vector<Double_t>& values, std::vector<std::shared_ptr<Double_t>>& fieldPtrs)
635 TString thisprefix=prefix;
636 if(prefix.Contains(
"asym_"))
637 thisprefix.ReplaceAll(
"asym_",
"diff_");
639 fEnergyChange.ConstructNTupleAndVector(model, thisprefix, values, fieldPtrs);
644void QwEnergyCalculator::FillNTupleVector(std::vector<Double_t>& values)
const
655#ifdef __USE_DATABASE__
656std::vector<QwDBInterface> QwEnergyCalculator::GetDBEntry()
658 std::vector <QwDBInterface> row_list;
665std::vector<QwErrDBInterface> QwEnergyCalculator::GetErrDBEntry()
667 std::vector <QwErrDBInterface> row_list;
#define QwMessage
Predefined log drain for regular messages.
static const UInt_t kBCMErrorFlag
Database interface for QwIntegrationPMT and subsystems.
Beam energy calculation from BPM position measurements.
const TString QwBPMStripline< T >::subelement[4]
static std::ostream & endl(std::ostream &)
End of the line.
Concrete hardware channel for Moller ADC modules (6x32-bit words)
void AssignValueFrom(const VQwDataElement *valueptr) override
void InitializeChannel(TString name, TString datatosave) override
Initialize the fields in this object.
void ArcTan(const QwMollerADC_Channel &value)
void Scale(Double_t Offset) override
void ClearEventData() override
Clear the event data in this element.
Configuration file parser with flexible tokenization and search capabilities.
Bool_t HasValue(TString &vname)
A helper class to manage a vector of branch entries for ROOT trees.
VQwDataElement()
Default constructor.
virtual const TString & GetElementName() const
Get the name of this element.
void SetElementName(const TString &name)
Set the name of this element.
Template for combined beam position monitor using multiple BPMs.
void ClearEventData() override
Clear event-scoped data of this calculator and underlying channel.
void RandomizeEventData(int helicity=0, double time=0.0)
Generate mock event data for testing.
std::vector< const VQwBPM * > fDevice
void PrintInfo() const override
Print detailed information for this calculator.
void Difference(const QwEnergyCalculator &value1, const QwEnergyCalculator &value2)
QwEnergyCalculator & operator-=(const QwEnergyCalculator &value)
Subtract-assign from another calculator (difference energy change).
void ConstructBranch(TTree *tree, TString &prefix)
Construct ROOT branches for this calculator (if enabled).
void CalculateRunningAverage()
Update running averages for the underlying energy channel.
std::vector< TString > fType
void PrintValue() const override
Print a compact value summary for this calculator.
void FillHistograms() override
Fill histograms for this calculator if enabled.
void Scale(Double_t factor)
Scale the underlying energy channel by a constant factor.
void SetRootSaveStatus(TString &prefix)
Determine whether to save full ROOT output based on the prefix.
QwEnergyCalculator & operator+=(const QwEnergyCalculator &value)
Add-assign from another calculator (sum energy change).
void FillTreeVector(QwRootTreeBranchVector &values) const
Int_t SetSingleEventCuts(Double_t mean, Double_t sigma)
Set single-event cut limits on the underlying energy channel.
std::vector< Double_t > fTMatrixRatio
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values)
Construct ROOT branches and value vector entries.
void LoadMockDataParameters(QwParameterFile ¶mfile) override
Load mock-data configuration for the underlying channel from a file.
void PrintErrorCounters() const override
Print accumulated error counters for diagnostic purposes.
void Set(const VQwBPM *device, TString type, TString property, Double_t tmatrix_ratio)
Register a BPM-based device contributing to the energy calculation.
UInt_t UpdateErrorFlag() override
Update and return the composite event-cut error flag.
void GetProjectedPosition(VQwBPM *device)
Back-project a BPM position from the current dp/p estimate.
void ProcessEvent()
Compute per-event energy change by summing configured device terms.
Bool_t ApplySingleEventCuts()
Apply single-event cuts to the energy channel and contributing devices.
void AccumulateRunningSum(const QwEnergyCalculator &value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF)
Accumulate running sums from another calculator into this one.
QwMollerADC_Channel fEnergyChange
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t word_position_in_buffer, UInt_t indexnumber) override
Process a configuration/event buffer (no-op for this calculator).
void SetRandomEventParameters(Double_t mean, Double_t sigma)
Configure Gaussian mock data parameters for the underlying channel.
std::vector< TString > fProperty
void DeaccumulateRunningSum(QwEnergyCalculator &value, Int_t ErrorMask=0xFFFFFFF)
Remove a single entry from the running sums using a source value.
void Ratio(QwEnergyCalculator &numer, QwEnergyCalculator &denom)
Define the ratio for asymmetry formation (here acts as pass-through).
Bool_t CheckForBurpFail(const VQwDataElement *ev_error)
Check for burp failures by delegating to the energy channel.
void InitializeChannel(TString name, TString datatosave)
Initialize this energy calculator with a name and data-saving mode.
void Sum(const QwEnergyCalculator &value1, const QwEnergyCalculator &value2)
QwEnergyCalculator & operator=(const QwEnergyCalculator &value)
Copy-assign from another calculator (event-scoped data).
Bool_t ApplyHWChecks()
Apply hardware checks (delegated to contributing channels if any).
void IncrementErrorCounters()
Increment error counters in the underlying energy channel.
void ConstructHistograms(TDirectory *folder, TString &prefix) override
Define histograms for this calculator (delegated to energy channel).
Abstract base for beam position monitors (BPMs)
virtual void ApplyResolutionSmearing()
virtual void FillRawEventData()
virtual const VQwHardwareChannel * GetPosition(EBeamPositionMonitorAxis axis) const