JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwEnergyCalculator Class Reference

Computes beam energy change from BPM information. More...

#include <QwEnergyCalculator.h>

+ Inheritance diagram for QwEnergyCalculator:
+ Collaboration diagram for QwEnergyCalculator:

Public Member Functions

 QwEnergyCalculator ()
 
 QwEnergyCalculator (TString name)
 
 QwEnergyCalculator (TString subsystem, TString name)
 
 QwEnergyCalculator (const QwEnergyCalculator &source)
 
 ~QwEnergyCalculator () override
 
void InitializeChannel (TString name, TString datatosave)
 Initialize this energy calculator with a name and data-saving mode.
 
void InitializeChannel (TString subsystem, TString name, TString datatosave)
 Initialize this energy calculator with subsystem and name.
 
void LoadChannelParameters (QwParameterFile &paramfile) override
 
void SetRandomEventParameters (Double_t mean, Double_t sigma)
 Configure Gaussian mock data parameters for the underlying channel.
 
void RandomizeEventData (int helicity=0, double time=0.0)
 Generate mock event data for testing.
 
void GetProjectedPosition (VQwBPM *device)
 Back-project a BPM position from the current dp/p estimate.
 
size_t GetNumberOfElements ()
 
TString GetSubElementName (Int_t index)
 
void LoadMockDataParameters (QwParameterFile &paramfile) override
 Load mock-data configuration for the underlying channel from a file.
 
void ClearEventData () override
 Clear event-scoped data of this calculator and underlying channel.
 
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 ProcessEvent ()
 Compute per-event energy change by summing configured device terms.
 
void PrintValue () const override
 Print a compact value summary for this calculator.
 
void PrintInfo () const override
 Print detailed information for this calculator.
 
void SetRootSaveStatus (TString &prefix)
 Determine whether to save full ROOT output based on the prefix.
 
Bool_t ApplyHWChecks ()
 Apply hardware checks (delegated to contributing channels if any).
 
Bool_t ApplySingleEventCuts ()
 Apply single-event cuts to the energy channel and contributing devices.
 
Int_t SetSingleEventCuts (Double_t mean, Double_t sigma)
 Set single-event cut limits on the underlying energy channel.
 
void SetSingleEventCuts (UInt_t errorflag, Double_t min, Double_t max, Double_t stability, Double_t burplevel)
 Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel.
 
void SetEventCutMode (Int_t bcuts)
 
Bool_t CheckForBurpFail (const VQwDataElement *ev_error)
 Check for burp failures by delegating to the energy channel.
 
void IncrementErrorCounters ()
 Increment error counters in the underlying energy channel.
 
void PrintErrorCounters () const override
 Print accumulated error counters for diagnostic purposes.
 
UInt_t GetEventcutErrorFlag () override
 return the error flag on this channel/device
 
UInt_t UpdateErrorFlag () override
 Update and return the composite event-cut error flag.
 
void UpdateErrorFlag (const QwEnergyCalculator *ev_error)
 Propagate error flags from a reference calculator into this one.
 
void Set (const VQwBPM *device, TString type, TString property, Double_t tmatrix_ratio)
 Register a BPM-based device contributing to the energy calculation.
 
void Ratio (QwEnergyCalculator &numer, QwEnergyCalculator &denom)
 Define the ratio for asymmetry formation (here acts as pass-through).
 
void Scale (Double_t factor)
 Scale the underlying energy channel by a constant factor.
 
QwEnergyCalculatoroperator= (const QwEnergyCalculator &value)
 Copy-assign from another calculator (event-scoped data).
 
QwEnergyCalculatoroperator+= (const QwEnergyCalculator &value)
 Add-assign from another calculator (sum energy change).
 
QwEnergyCalculatoroperator-= (const QwEnergyCalculator &value)
 Subtract-assign from another calculator (difference energy change).
 
void Sum (const QwEnergyCalculator &value1, const QwEnergyCalculator &value2)
 
void Difference (const QwEnergyCalculator &value1, const QwEnergyCalculator &value2)
 
void AccumulateRunningSum (const QwEnergyCalculator &value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF)
 Accumulate running sums from another calculator into this one.
 
void DeaccumulateRunningSum (QwEnergyCalculator &value, Int_t ErrorMask=0xFFFFFFF)
 Remove a single entry from the running sums using a source value.
 
void CalculateRunningAverage ()
 Update running averages for the underlying energy channel.
 
void ConstructHistograms (TDirectory *folder, TString &prefix) override
 Define histograms for this calculator (delegated to energy channel).
 
void FillHistograms () override
 Fill histograms for this calculator if enabled.
 
void ConstructBranchAndVector (TTree *tree, TString &prefix, QwRootTreeBranchVector &values)
 Construct ROOT branches and value vector entries.
 
void ConstructBranch (TTree *tree, TString &prefix)
 Construct ROOT branches for this calculator (if enabled).
 
void ConstructBranch (TTree *tree, TString &prefix, QwParameterFile &trim_file)
 
void FillTreeVector (QwRootTreeBranchVector &values) const
 
VQwHardwareChannelGetEnergy ()
 
const VQwHardwareChannelGetEnergy () const
 
- Public Member Functions inherited from VQwDataElement
 VQwDataElement ()
 Default constructor.
 
 VQwDataElement (const VQwDataElement &value)
 Copy constructor.
 
 ~VQwDataElement () override
 Virtual destructor.
 
void CopyFrom (const VQwDataElement &value)
 
Bool_t IsNameEmpty () const
 Is the name of this element empty?
 
void SetElementName (const TString &name)
 Set the name of this element.
 
virtual const TString & GetElementName () const
 Get the name of this element.
 
size_t GetNumberOfDataWords ()
 Get the number of data words in this data element.
 
UInt_t GetGoodEventCount () const
 
virtual void AssignValueFrom (const VQwDataElement *)
 
VQwDataElementoperator+= (const VQwDataElement &)
 Addition-assignment operator.
 
VQwDataElementoperator-= (const VQwDataElement &)
 Subtraction-assignment operator.
 
void Sum (const VQwDataElement &, const VQwDataElement &)
 Sum operator (base class fallback throws runtime error)
 
void Difference (const VQwDataElement &, const VQwDataElement &)
 Difference operator (base class fallback throws runtime error)
 
void Ratio (const VQwDataElement &, const VQwDataElement &)
 Ratio operator (base class fallback throws runtime error)
 
void SetSingleEventCuts (UInt_t, Double_t, Double_t, Double_t)
 set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel
 
Bool_t CheckForBurpFail (const VQwDataElement *)
 
virtual void SetNeedsExternalClock (Bool_t)
 
virtual Bool_t NeedsExternalClock ()
 
virtual std::string GetExternalClockName ()
 
virtual void SetExternalClockPtr (const VQwHardwareChannel *)
 
virtual void SetExternalClockName (const std::string)
 
virtual Double_t GetNormClockValue ()
 
TString GetSubsystemName () const
 Return the name of the inheriting subsystem name.
 
void SetSubsystemName (TString sysname)
 Set the name of the inheriting subsystem name.
 
TString GetModuleType () const
 Return the type of the beam instrument.
 
void SetModuleType (TString ModuleType)
 set the type of the beam instrument
 
- Public Member Functions inherited from MQwHistograms
void ShareHistograms (const MQwHistograms *source)
 Share histogram pointers between objects.
 

Protected Attributes

QwMollerADC_Channel fEnergyChange
 
- Protected Attributes inherited from VQwDataElement
TString fElementName
 Name of this data element.
 
UInt_t fNumberOfDataWords
 Number of raw data words in this data element.
 
UInt_t fGoodEventCount
 Number of good events accumulated in this element.
 
TString fSubsystemName
 
TString fModuleType
 
UInt_t fErrorFlag
 This the standard error code generated for the channel that contains the global/local/stability flags and the Device error code (Unique error code for HW failures)
 
UInt_t fErrorConfigFlag
 contains the global/local/stability flags
 
- Protected Attributes inherited from MQwHistograms
std::vector< TH1_ptrfHistograms
 Histograms associated with this data element.
 

Private Attributes

std::vector< const VQwBPM * > fDevice
 
std::vector< Double_t > fTMatrixRatio
 
std::vector< TString > fProperty
 
std::vector< TString > fType
 
Int_t fDeviceErrorCode
 
Bool_t bEVENTCUTMODE
 
Bool_t bFullSave
 

Additional Inherited Members

- Public Types inherited from VQwDataElement
enum  EDataToSave { kRaw = 0 , kDerived , kMoments }
 
- Protected Member Functions inherited from VQwDataElement
void SetNumberOfDataWords (const UInt_t &numwords)
 Set the number of data words in this data element.
 
VQwDataElementoperator= (const VQwDataElement &value)
 Arithmetic assignment operator: Should only copy event-based data.
 
void UpdateErrorFlag (const UInt_t &error)
 
- Protected Member Functions inherited from MQwHistograms
 MQwHistograms ()
 Default constructor.
 
 MQwHistograms (const MQwHistograms &source)
 Copy constructor.
 
virtual ~MQwHistograms ()
 Virtual destructor.
 
MQwHistogramsoperator= (const MQwHistograms &value)
 
void Fill_Pointer (TH1_ptr hist_ptr, Double_t value)
 
void AddHistogram (TH1 *h)
 Register a histogram.
 

Detailed Description

Computes beam energy change from BPM information.

Uses measured angles and dispersive positions to estimate relative beam energy variations; exposes a single hardware-like channel.

Definition at line 43 of file QwEnergyCalculator.h.

Constructor & Destructor Documentation

◆ QwEnergyCalculator() [1/4]

QwEnergyCalculator::QwEnergyCalculator ( )
inline

Definition at line 55 of file QwEnergyCalculator.h.

55{ };

Referenced by AccumulateRunningSum(), CheckForBurpFail(), DeaccumulateRunningSum(), Difference(), GetEnergy(), operator+=(), operator-=(), operator=(), QwEnergyCalculator(), Ratio(), Sum(), and UpdateErrorFlag().

+ Here is the caller graph for this function:

◆ QwEnergyCalculator() [2/4]

QwEnergyCalculator::QwEnergyCalculator ( TString name)
inline

Definition at line 56 of file QwEnergyCalculator.h.

56 {
57 InitializeChannel(name,"derived");
58 };
void InitializeChannel(TString name, TString datatosave)
Initialize this energy calculator with a name and data-saving mode.

References InitializeChannel().

+ Here is the call graph for this function:

◆ QwEnergyCalculator() [3/4]

QwEnergyCalculator::QwEnergyCalculator ( TString subsystem,
TString name )
inline

Definition at line 59 of file QwEnergyCalculator.h.

59 {
60 InitializeChannel(subsystem, name,"derived");
61 };

References InitializeChannel().

+ Here is the call graph for this function:

◆ QwEnergyCalculator() [4/4]

QwEnergyCalculator::QwEnergyCalculator ( const QwEnergyCalculator & source)
inline

Definition at line 62 of file QwEnergyCalculator.h.

64 { }
VQwDataElement()
Default constructor.
QwMollerADC_Channel fEnergyChange

References fEnergyChange, QwEnergyCalculator(), and VQwDataElement::VQwDataElement().

+ Here is the call graph for this function:

◆ ~QwEnergyCalculator()

QwEnergyCalculator::~QwEnergyCalculator ( )
inlineoverride

Definition at line 65 of file QwEnergyCalculator.h.

65{ };

Member Function Documentation

◆ AccumulateRunningSum()

void QwEnergyCalculator::AccumulateRunningSum ( const QwEnergyCalculator & value,
Int_t count = 0,
Int_t ErrorMask = 0xFFFFFFF )

Accumulate running sums from another calculator into this one.

Parameters
valueSource calculator to accumulate from.
countWeight/count for accumulation; 0 implies use source count.
ErrorMaskMask to control error propagation behavior.

Definition at line 359 of file QwEnergyCalculator.cc.

359 {
360 fEnergyChange.AccumulateRunningSum(value.fEnergyChange, count, ErrorMask);
361}

References fEnergyChange, and QwEnergyCalculator().

+ Here is the call graph for this function:

◆ ApplyHWChecks()

Bool_t QwEnergyCalculator::ApplyHWChecks ( )

Apply hardware checks (delegated to contributing channels if any).

Returns
Always kTRUE; no direct hardware channels in this calculator.

Definition at line 461 of file QwEnergyCalculator.cc.

461 {
462 // For the energy calculator there are no physical channels that we can relate to because it is being
463 // derived from combinations of physical channels. Therefore, this is not exactly a "HW Check"
464 // but just a check of the HW checks of the used channels.
465
466 Bool_t eventokay=kTRUE;
467 return eventokay;
468}

◆ ApplySingleEventCuts()

Bool_t QwEnergyCalculator::ApplySingleEventCuts ( )

Apply single-event cuts to the energy channel and contributing devices.

Returns
kTRUE if the event passes cuts; otherwise kFALSE.

Definition at line 273 of file QwEnergyCalculator.cc.

273 {
274 Bool_t status=kTRUE;
275
276 UInt_t error_code = 0;
277 for(UInt_t i = 0; i<fProperty.size(); i++){
278 if(fProperty[i].Contains("targetbeamangle")){
279 error_code |= ((QwCombinedBPM<QwMollerADC_Channel>*)fDevice[i])->fSlope[0].GetErrorCode();
280 } else {
281 error_code |= fDevice[i]->GetPosition(VQwBPM::kXAxis)->GetErrorCode();
282 }
283 }
284 //fEnergyChange.UpdateErrorFlag(error_code);//No need to do this. error codes are ORed when energy is calculated
285
286 if (fEnergyChange.ApplySingleEventCuts()){
287 status=kTRUE;
288 }
289 else{
290 status&=kFALSE;
291 }
292 return status;
293}
std::vector< const VQwBPM * > fDevice
std::vector< TString > fProperty
@ kXAxis
Definition VQwBPM.h:72

References fDevice, fEnergyChange, fProperty, and VQwBPM::kXAxis.

◆ CalculateRunningAverage()

void QwEnergyCalculator::CalculateRunningAverage ( )

Update running averages for the underlying energy channel.

Definition at line 347 of file QwEnergyCalculator.cc.

347 {
348 fEnergyChange.CalculateRunningAverage();
349}

References fEnergyChange.

◆ CheckForBurpFail()

Bool_t QwEnergyCalculator::CheckForBurpFail ( const VQwDataElement * ev_error)

Check for burp failures by delegating to the energy channel.

Parameters
ev_errorReference energy calculator to compare against.
Returns
kTRUE if a burp failure was detected; otherwise kFALSE.

Definition at line 502 of file QwEnergyCalculator.cc.

502 {
503 Bool_t burpstatus = kFALSE;
504 try {
505 if(typeid(*ev_error)==typeid(*this)) {
506 //std::cout<<" Here in QwEnergyCalculator::CheckForBurpFail \n";
507 if (this->GetElementName()!="") {
508 const QwEnergyCalculator* value_halo = dynamic_cast<const QwEnergyCalculator* >(ev_error);
509 burpstatus |= fEnergyChange.CheckForBurpFail(&(value_halo->fEnergyChange));
510 }
511 } else {
512 TString loc="Standard exception from QwEnergyCalculator::CheckForBurpFail :"+
513 ev_error->GetElementName()+" "+this->GetElementName()+" are not of the "
514 +"same type";
515 throw std::invalid_argument(loc.Data());
516 }
517 } catch (std::exception& e) {
518 std::cerr<< e.what()<<std::endl;
519 }
520 return burpstatus;
521}
virtual const TString & GetElementName() const
Get the name of this element.

References fEnergyChange, VQwDataElement::GetElementName(), QwEnergyCalculator(), and VQwDataElement::VQwDataElement().

+ Here is the call graph for this function:

◆ ClearEventData()

void QwEnergyCalculator::ClearEventData ( )
overridevirtual

Clear event-scoped data of this calculator and underlying channel.

Reimplemented from VQwDataElement.

Definition at line 93 of file QwEnergyCalculator.cc.

93 {
94 fEnergyChange.ClearEventData();
95 return;
96}

References fEnergyChange.

Referenced by ProcessEvent().

+ Here is the caller graph for this function:

◆ ConstructBranch() [1/2]

void QwEnergyCalculator::ConstructBranch ( TTree * tree,
TString & prefix )

Construct ROOT branches for this calculator (if enabled).

Parameters
treeOutput tree.
prefixBranch name prefix.

Definition at line 583 of file QwEnergyCalculator.cc.

583 {
584 if (GetElementName()==""){
585 // This channel is not used, so skip filling the histograms.
586 }
587 else{
588 TString thisprefix=prefix;
589 if(prefix.Contains("asym_"))
590 thisprefix.ReplaceAll("asym_","diff_");
591
592 SetRootSaveStatus(thisprefix);
593 fEnergyChange.ConstructBranch(tree,thisprefix);
594 }
595 return;
596}
void SetRootSaveStatus(TString &prefix)
Determine whether to save full ROOT output based on the prefix.

References fEnergyChange, VQwDataElement::GetElementName(), and SetRootSaveStatus().

+ Here is the call graph for this function:

◆ ConstructBranch() [2/2]

void QwEnergyCalculator::ConstructBranch ( TTree * tree,
TString & prefix,
QwParameterFile & trim_file )

Definition at line 598 of file QwEnergyCalculator.cc.

598 {
599
600 TString devicename;
601 devicename=GetElementName();
602 devicename.ToLower();
603 if (GetElementName()==""){
604 // This channel is not used, so skip filling the histograms.
605 }
606 else
607 if (modulelist.HasValue(devicename)){
608 TString thisprefix=prefix;
609 if(prefix.Contains("asym_"))
610 thisprefix.ReplaceAll("asym_","diff_");
611 SetRootSaveStatus(thisprefix);
612 fEnergyChange.ConstructBranch(tree,thisprefix);
613 QwMessage <<" Tree leave added to "<<devicename<<QwLog::endl;
614 }
615 return;
616}
#define QwMessage
Predefined log drain for regular messages.
Definition QwLog.h:49
static std::ostream & endl(std::ostream &)
End of the line.
Definition QwLog.cc:297

References QwLog::endl(), fEnergyChange, VQwDataElement::GetElementName(), QwParameterFile::HasValue(), QwMessage, and SetRootSaveStatus().

+ Here is the call graph for this function:

◆ ConstructBranchAndVector()

void QwEnergyCalculator::ConstructBranchAndVector ( TTree * tree,
TString & prefix,
QwRootTreeBranchVector & values )

Construct ROOT branches and value vector entries.

Parameters
treeOutput tree.
prefixBranch name prefix.
valuesOutput value vector to be appended.

Definition at line 559 of file QwEnergyCalculator.cc.

560 {
561 if (GetElementName()==""){
562 // This channel is not used, so skip filling the histograms.
563 }
564 else{
565 TString thisprefix=prefix;
566 if(prefix.Contains("asym_"))
567 thisprefix.ReplaceAll("asym_","diff_");
568
569 SetRootSaveStatus(thisprefix);
570
571 fEnergyChange.ConstructBranchAndVector(tree,thisprefix,values);
572 }
573 return;
574}

References fEnergyChange, VQwDataElement::GetElementName(), and SetRootSaveStatus().

+ Here is the call graph for this function:

◆ ConstructHistograms()

void QwEnergyCalculator::ConstructHistograms ( TDirectory * folder,
TString & prefix )
overridevirtual

Define histograms for this calculator (delegated to energy channel).

Parameters
folderROOT folder to contain histograms.
prefixHistogram name prefix.

Implements VQwDataElement.

Definition at line 528 of file QwEnergyCalculator.cc.

528 {
529 if (GetElementName()==""){
530 // This channel is not used, so skip filling the histograms.
531 }
532 else{
533 TString thisprefix=prefix;
534 if(prefix.Contains("asym_"))
535 thisprefix.ReplaceAll("asym_","diff_");
536 SetRootSaveStatus(thisprefix);
537 fEnergyChange.ConstructHistograms(folder, thisprefix);
538 }
539 return;
540}

References fEnergyChange, VQwDataElement::GetElementName(), and SetRootSaveStatus().

+ Here is the call graph for this function:

◆ DeaccumulateRunningSum()

void QwEnergyCalculator::DeaccumulateRunningSum ( QwEnergyCalculator & value,
Int_t ErrorMask = 0xFFFFFFF )

Remove a single entry from the running sums using a source value.

Parameters
valueSource calculator to subtract.
ErrorMaskMask to control error propagation behavior.

Definition at line 368 of file QwEnergyCalculator.cc.

368 {
369 fEnergyChange.DeaccumulateRunningSum(value.fEnergyChange, ErrorMask);
370}

References fEnergyChange, and QwEnergyCalculator().

+ Here is the call graph for this function:

◆ Difference()

void QwEnergyCalculator::Difference ( const QwEnergyCalculator & value1,
const QwEnergyCalculator & value2 )

Definition at line 414 of file QwEnergyCalculator.cc.

414 {
415 *this = value1;
416 *this -= value2;
417}

References QwEnergyCalculator().

+ Here is the call graph for this function:

◆ FillHistograms()

void QwEnergyCalculator::FillHistograms ( )
overridevirtual

Fill histograms for this calculator if enabled.

Implements VQwDataElement.

Definition at line 543 of file QwEnergyCalculator.cc.

543 {
544 if (GetElementName()==""){
545 // This channel is not used, so skip filling the histograms.
546 }
547 else
548 fEnergyChange.FillHistograms();
549
550 return;
551}

References fEnergyChange, and VQwDataElement::GetElementName().

+ Here is the call graph for this function:

◆ FillTreeVector()

void QwEnergyCalculator::FillTreeVector ( QwRootTreeBranchVector & values) const

Definition at line 618 of file QwEnergyCalculator.cc.

619{
620 if (GetElementName()==""){
621 // This channel is not used, so skip filling the histograms.
622 }
623 else
624 fEnergyChange.FillTreeVector(values);
625 return;
626}

References fEnergyChange, and VQwDataElement::GetElementName().

+ Here is the call graph for this function:

◆ GetEnergy() [1/2]

VQwHardwareChannel * QwEnergyCalculator::GetEnergy ( )
inline

Definition at line 138 of file QwEnergyCalculator.h.

138 {
139 return &fEnergyChange;
140 };

References fEnergyChange.

Referenced by GetEnergy().

+ Here is the caller graph for this function:

◆ GetEnergy() [2/2]

const VQwHardwareChannel * QwEnergyCalculator::GetEnergy ( ) const
inline

Definition at line 142 of file QwEnergyCalculator.h.

142 {
143 return const_cast<QwEnergyCalculator*>(this)->GetEnergy();
144 };
VQwHardwareChannel * GetEnergy()

References GetEnergy(), and QwEnergyCalculator().

+ Here is the call graph for this function:

◆ GetEventcutErrorFlag()

UInt_t QwEnergyCalculator::GetEventcutErrorFlag ( )
inlineoverridevirtual

return the error flag on this channel/device

Reimplemented from VQwDataElement.

Definition at line 103 of file QwEnergyCalculator.h.

103 {//return the error flag
104 return fEnergyChange.GetEventcutErrorFlag();
105 }

References fEnergyChange.

◆ GetNumberOfElements()

size_t QwEnergyCalculator::GetNumberOfElements ( )
inline

Definition at line 77 of file QwEnergyCalculator.h.

77{return fDevice.size();};

References fDevice.

◆ GetProjectedPosition()

void QwEnergyCalculator::GetProjectedPosition ( VQwBPM * device)

Back-project a BPM position from the current dp/p estimate.

Parameters
deviceBPM device whose X position is solved from energy and other terms.

fProperty.size()=3, idevice=4

fDevice[i] = qwk_1c12 = device

i=0=idevice

idevice=0, fProperty.size()=3

qwk_1c12X changes only

idevice=0

Definition at line 174 of file QwEnergyCalculator.cc.

175{
176 UInt_t idevice = fProperty.size()+1; /** fProperty.size()=3, idevice=4 **/
177
178 for(UInt_t i=0; i<fProperty.size(); i++) {
179 if (fDevice[i]->GetElementName()==device->GetElementName()) { /** fDevice[i] = qwk_1c12 = device **/
180 idevice = i; /** i=0=idevice **/
181 break;
182 }
183 } /** idevice=0, fProperty.size()=3 **/
184
185 if (idevice>fProperty.size()) return; // Return without trying to find a new position if "device" doesn't contribute to the energy calculator
186
187 static QwMollerADC_Channel tmp;
188 tmp.InitializeChannel("tmp","derived");
189 tmp.ClearEventData();
190 // Set the device position value to be equal to the energy change
191 (device->GetPosition(VQwBPM::kXAxis))->AssignValueFrom(&fEnergyChange);
192 /** qwk_1c12X changes only **/
193
194 /** idevice=0 **/
195 for(UInt_t i = 0; i<fProperty.size(); i++) {
196 if (i==idevice) {
197 // Do nothing for this device!
198 continue;
199 } else {
200 // Calculate contribution to fEnergyChange from the other devices
201 if(fProperty[i].Contains("targetbeamangle")) {
202 tmp.ArcTan((((QwCombinedBPM<QwMollerADC_Channel>*)fDevice[i])->fSlope[VQwBPM::kXAxis]));
203 } else {
204 tmp.AssignValueFrom(fDevice[i]->GetPosition(VQwBPM::kXAxis));
205 }
206 tmp.Scale(fTMatrixRatio[i]);
207 // And subtract it from the device we are trying to get the position of.
208 (device->GetPosition(VQwBPM::kXAxis))->operator-=(tmp);
209 }
210 } // end of for(UInt_t i = 0; i<fProperty.size(); i++)
211
212 // At this point, device position is (Energy - ( M_x*x + M_xp*arctan(xp) ) )
213 // Now divide by matrixratio for 1c12 to get: (Energy - ( M_x*x + M_xp*arctan(xp) ) )/M_1c12 === x_1c12
214
215 (device->GetPosition(VQwBPM::kXAxis))->Scale(1.0/fTMatrixRatio[idevice]);
217 device->FillRawEventData();
218
219/*
220/// Reclaculate energy and see what we get
221 static QwVQWK_Channel tmp_e;
222 tmp_e.InitializeChannel("tmp_e","derived");
223 tmp_e.ClearEventData();
224
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]));
228 } else {
229 tmp.AssignValueFrom(fDevice[i]->GetPosition(VQwBPM::kXAxis));
230 }
231 tmp.Scale(fTMatrixRatio[i]);
232 tmp_e += tmp;
233 }
234 // std::cout << "GetProjectedPosition()::fEnergyChange = " << fEnergyChange.GetValue(0) << "\t ProcessEvent()::fEnergyChange = " << tmp_e.GetValue(0) << std::endl;
235*/
236
237 return;
238}
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.
std::vector< Double_t > fTMatrixRatio
virtual void ApplyResolutionSmearing()
Definition VQwBPM.h:273
virtual void FillRawEventData()
Definition VQwBPM.h:98
virtual const VQwHardwareChannel * GetPosition(EBeamPositionMonitorAxis axis) const
Definition VQwBPM.h:140

References VQwBPM::ApplyResolutionSmearing(), QwMollerADC_Channel::ArcTan(), QwMollerADC_Channel::AssignValueFrom(), QwMollerADC_Channel::ClearEventData(), fDevice, fEnergyChange, VQwBPM::FillRawEventData(), fProperty, fTMatrixRatio, VQwDataElement::GetElementName(), VQwBPM::GetPosition(), QwMollerADC_Channel::InitializeChannel(), VQwBPM::kXAxis, and QwMollerADC_Channel::Scale().

+ Here is the call graph for this function:

◆ GetSubElementName()

TString QwEnergyCalculator::GetSubElementName ( Int_t index)
inline

Definition at line 78 of file QwEnergyCalculator.h.

78{return fDevice.at(index)->GetElementName();};

References fDevice.

◆ IncrementErrorCounters()

void QwEnergyCalculator::IncrementErrorCounters ( )

Increment error counters in the underlying energy channel.

Definition at line 298 of file QwEnergyCalculator.cc.

299{
300 fEnergyChange.IncrementErrorCounters();
301}

References fEnergyChange.

◆ InitializeChannel() [1/2]

void QwEnergyCalculator::InitializeChannel ( TString name,
TString datatosave )

Initialize this energy calculator with a name and data-saving mode.

Parameters
nameElement name used for histogram and branch prefixes.
datatosaveStorage mode (e.g., "raw" or "derived").

Definition at line 34 of file QwEnergyCalculator.cc.

35{
36 SetElementName(name);
37 fEnergyChange.InitializeChannel(name,datatosave);
38 // beamx.InitializeChannel("beamx","derived");
39 return;
40}
void SetElementName(const TString &name)
Set the name of this element.

References fEnergyChange, and VQwDataElement::SetElementName().

Referenced by QwEnergyCalculator(), and QwEnergyCalculator().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InitializeChannel() [2/2]

void QwEnergyCalculator::InitializeChannel ( TString subsystem,
TString name,
TString datatosave )

Initialize this energy calculator with subsystem and name.

Parameters
subsystemSubsystem identifier for tree/hist foldering.
nameElement name used for histogram and branch prefixes.
datatosaveStorage mode (e.g., "raw" or "derived").

Definition at line 48 of file QwEnergyCalculator.cc.

49{
50 SetElementName(name);
51 fEnergyChange.InitializeChannel(subsystem, "QwEnergyCalculator", name,datatosave);
52 // beamx.InitializeChannel("beamx","derived");
53 return;
54}

References fEnergyChange, and VQwDataElement::SetElementName().

+ Here is the call graph for this function:

◆ LoadChannelParameters()

void QwEnergyCalculator::LoadChannelParameters ( QwParameterFile & paramfile)
inlineoverridevirtual

Reimplemented from VQwDataElement.

Definition at line 71 of file QwEnergyCalculator.h.

71{};

◆ LoadMockDataParameters()

void QwEnergyCalculator::LoadMockDataParameters ( QwParameterFile & paramfile)
overridevirtual

Load mock-data configuration for the underlying channel from a file.

Parameters
paramfileParameter file reader positioned at channel section.

Reimplemented from VQwDataElement.

Definition at line 245 of file QwEnergyCalculator.cc.

245 {
246
247 //std::cout << "In QwEnergyCalculator: ChannelName = " << GetElementName() << std::endl;
248 fEnergyChange.SetMockDataAsDiff(); // Sets this channel to use the difference mode in the RandomizeMockData
249 fEnergyChange.LoadMockDataParameters(paramfile);
250
251/* Bool_t ldebug=kFALSE;
252 Double_t mean=0.0, sigma=0.0;
253
254 mean = paramfile.GetTypedNextToken<Double_t>();
255 sigma = paramfile.GetTypedNextToken<Double_t>();
256
257 if (ldebug==1) {
258 std::cout << "#################### \n";
259 std::cout << "! mean, sigma \n" << std::endl;
260 std::cout << mean << " / "
261 << sigma << " / "
262 << std::endl;
263 }
264 this->SetRandomEventParameters(mean, sigma);
265*/
266}

References fEnergyChange.

◆ operator+=()

QwEnergyCalculator & QwEnergyCalculator::operator+= ( const QwEnergyCalculator & value)

Add-assign from another calculator (sum energy change).

Definition at line 393 of file QwEnergyCalculator.cc.

393 {
394
395 if (GetElementName()!="")
396 this->fEnergyChange+=value.fEnergyChange;
397
398 return *this;
399}

References fEnergyChange, VQwDataElement::GetElementName(), and QwEnergyCalculator().

+ Here is the call graph for this function:

◆ operator-=()

QwEnergyCalculator & QwEnergyCalculator::operator-= ( const QwEnergyCalculator & value)

Subtract-assign from another calculator (difference energy change).

Definition at line 402 of file QwEnergyCalculator.cc.

402 {
403 if (GetElementName()!="")
404 this->fEnergyChange-=value.fEnergyChange;
405
406 return *this;
407}

References fEnergyChange, VQwDataElement::GetElementName(), and QwEnergyCalculator().

+ Here is the call graph for this function:

◆ operator=()

QwEnergyCalculator & QwEnergyCalculator::operator= ( const QwEnergyCalculator & value)

Copy-assign from another calculator (event-scoped data).

Definition at line 384 of file QwEnergyCalculator.cc.

384 {
385 if (this != &value) {
386 if (GetElementName()!="")
387 this->fEnergyChange=value.fEnergyChange;
388 }
389 return *this;
390}

References fEnergyChange, VQwDataElement::GetElementName(), and QwEnergyCalculator().

+ Here is the call graph for this function:

◆ PrintErrorCounters()

void QwEnergyCalculator::PrintErrorCounters ( ) const
overridevirtual

Print accumulated error counters for diagnostic purposes.

Reimplemented from VQwDataElement.

Definition at line 307 of file QwEnergyCalculator.cc.

307 {
308 // report number of events failed due to HW and event cut failure
309 fEnergyChange.PrintErrorCounters();
310}

References fEnergyChange.

◆ PrintInfo()

void QwEnergyCalculator::PrintInfo ( ) const
overridevirtual

Print detailed information for this calculator.

Reimplemented from VQwDataElement.

Definition at line 445 of file QwEnergyCalculator.cc.

445 {
446 fEnergyChange.PrintInfo();
447 return;
448}

References fEnergyChange.

◆ PrintValue()

void QwEnergyCalculator::PrintValue ( ) const
overridevirtual

Print a compact value summary for this calculator.

Reimplemented from VQwDataElement.

Definition at line 452 of file QwEnergyCalculator.cc.

452 {
453 fEnergyChange.PrintValue();
454 return;
455}

References fEnergyChange.

◆ ProcessEvBuffer()

Int_t QwEnergyCalculator::ProcessEvBuffer ( UInt_t * buffer,
UInt_t word_position_in_buffer,
UInt_t subelement )
overridevirtual

Process a configuration/event buffer (no-op for this calculator).

Returns
The updated buffer word position (unchanged here).

Implements VQwDataElement.

Definition at line 378 of file QwEnergyCalculator.cc.

378 {
379 return 0;
380}

References QwBPMStripline< T >::subelement.

◆ ProcessEvent()

void QwEnergyCalculator::ProcessEvent ( )

Compute per-event energy change by summing configured device terms.

Definition at line 103 of file QwEnergyCalculator.cc.

104{
105 //Bool_t ldebug = kFALSE;
106 //Double_t targetbeamangle = 0.0;
107 static QwMollerADC_Channel tmp;
108 tmp.InitializeChannel("tmp","derived");
109 tmp.ClearEventData();
110
111 this->ClearEventData();
112
113 for(UInt_t i = 0; i<fProperty.size(); i++){
114 if(fProperty[i].Contains("targetbeamangle")){
115 tmp.ArcTan((((QwCombinedBPM<QwMollerADC_Channel>*)fDevice[i])->fSlope[VQwBPM::kXAxis]));
116 } else {
117 tmp.AssignValueFrom(fDevice[i]->GetPosition(VQwBPM::kXAxis));
118 }
119 tmp.Scale(fTMatrixRatio[i]);
120 fEnergyChange += tmp;
121 }
122/*
123 if(fProperty[i].Contains("targetbeamangle")){
124 tmp.ArcTan((((QwCombinedBPM<QwVQWK_Channel>*)fDevice[i])->fSlope[VQwBPM::kXAxis]));
125 tmp.Scale(fTMatrixRatio[i]);
126 // targetbeamangle = atan((((QwCombinedBPM<QwVQWK_Channel>*)fDevice[i])->fSlope[VQwBPM::kXAxis]).GetValue());
127 // targetbeamangle *= fTMatrixRatio[i];
128 //if(ldebug) std::cout<<"QwEnegyCalculator::ProcessEvent() :: Beam angle in X at target = "<<targetbeamangle<<std::endl;
129 // fEnergyChange.AddChannelOffset(targetbeamangle);
130 fEnergyChange += tmp;
131 //if(ldebug) std::cout<<"QwEnegyCalculator::ProcessEvent() :: dp/p += (M12/M16)*X angle = "<<fEnergyChange.GetValue()<<std::endl;
132 } else {
133 tmp.AssignValueFrom(fDevice[i]->GetPosition(VQwBPM::kXAxis));
134 if(ldebug) std::cout<<"QwEnegyCalculator::ProcessEvent() :: X position from "<<fDevice[i]->GetElementName()<<" = "<<tmp.GetValue()<<std::endl;
135 tmp.Scale(fTMatrixRatio[i]);
136 if(ldebug) std::cout<<"QwEnegyCalculator::ProcessEvent() :: (M11/M16)*X position = "<<tmp.GetValue()<<std::endl;
137 fEnergyChange += tmp;
138 }
139*/
140 //if(ldebug) std::cout<<"QwEnegyCalculator::ProcessEvent() :: dp/p = "<<fEnergyChange.GetValue()<<std::endl;
141 return;
142}
void ClearEventData() override
Clear event-scoped data of this calculator and underlying channel.

References QwMollerADC_Channel::ArcTan(), QwMollerADC_Channel::AssignValueFrom(), ClearEventData(), QwMollerADC_Channel::ClearEventData(), fDevice, fEnergyChange, fProperty, fTMatrixRatio, QwMollerADC_Channel::InitializeChannel(), VQwBPM::kXAxis, and QwMollerADC_Channel::Scale().

+ Here is the call graph for this function:

◆ RandomizeEventData()

void QwEnergyCalculator::RandomizeEventData ( int helicity = 0,
double time = 0.0 )

Generate mock event data for testing.

Parameters
helicityHelicity state indicator.
timeEvent time or timestamp proxy.

Definition at line 151 of file QwEnergyCalculator.cc.

152{
153 fEnergyChange.RandomizeEventData(helicity, time);
154 return;
155}

References fEnergyChange.

◆ Ratio()

void QwEnergyCalculator::Ratio ( QwEnergyCalculator & numer,
QwEnergyCalculator & denom )

Define the ratio for asymmetry formation (here acts as pass-through).

Parameters
numerNumerator calculator.
denomDenominator calculator.

Definition at line 425 of file QwEnergyCalculator.cc.

425 {
426 // this function is called when forming asymmetries. In this case what we actually want for the
427 // qwk_energy/(dp/p) is the difference only not the asymmetries
428
429 *this=numer;
430 return;
431}

References QwEnergyCalculator().

+ Here is the call graph for this function:

◆ Scale()

void QwEnergyCalculator::Scale ( Double_t factor)

Scale the underlying energy channel by a constant factor.

Parameters
factorMultiplicative scale factor.

Definition at line 438 of file QwEnergyCalculator.cc.

438 {
439 fEnergyChange.Scale(factor);
440 return;
441}

References fEnergyChange.

◆ Set()

void QwEnergyCalculator::Set ( const VQwBPM * device,
TString type,
TString property,
Double_t tmatrix_ratio )

Register a BPM-based device contributing to the energy calculation.

Parameters
devicePointer to contributing BPM object.
typeDevice type string (e.g., BPM, ComboBPM).
propertyProperty descriptor (e.g., targetbeamangle).
tmatrix_ratioTransport matrix ratio coefficient for contribution.

Definition at line 63 of file QwEnergyCalculator.cc.

64{
65 Bool_t ldebug = kFALSE;
66
67 fDevice.push_back(device);
68 fProperty.push_back(property);
69 fType.push_back(type);
70 fTMatrixRatio.push_back(tmatrix_ratio);
71
72 if(ldebug)
73 std::cout<<"QwEnergyCalculator:: Using "<<device->GetElementName()<<" with ratio "<< tmatrix_ratio <<" for "<<property<<std::endl;
74
75 return;
76}
std::vector< TString > fType

References fDevice, fProperty, fTMatrixRatio, fType, and VQwDataElement::GetElementName().

+ Here is the call graph for this function:

◆ SetEventCutMode()

void QwEnergyCalculator::SetEventCutMode ( Int_t bcuts)
inline

Definition at line 95 of file QwEnergyCalculator.h.

95 {
96 bEVENTCUTMODE=bcuts;
97 fEnergyChange.SetEventCutMode(bcuts);
98 }

References bEVENTCUTMODE, and fEnergyChange.

◆ SetRandomEventParameters()

void QwEnergyCalculator::SetRandomEventParameters ( Double_t mean,
Double_t sigma )

Configure Gaussian mock data parameters for the underlying channel.

Parameters
meanMean value for the distribution.
sigmaStandard deviation for the distribution.

Definition at line 163 of file QwEnergyCalculator.cc.

164{
165 fEnergyChange.SetRandomEventParameters(mean, sigma);
166 return;
167}

References fEnergyChange.

◆ SetRootSaveStatus()

void QwEnergyCalculator::SetRootSaveStatus ( TString & prefix)

Determine whether to save full ROOT output based on the prefix.

Parameters
prefixBranch/histogram prefix (may toggle full save for asym/diff).

Definition at line 82 of file QwEnergyCalculator.cc.

83{
84 if(prefix.Contains("diff_")||prefix.Contains("yield_")|| prefix.Contains("asym_"))
85 bFullSave=kFALSE;
86
87 return;
88}

References bFullSave.

Referenced by ConstructBranch(), ConstructBranch(), ConstructBranchAndVector(), and ConstructHistograms().

+ Here is the caller graph for this function:

◆ SetSingleEventCuts() [1/2]

Int_t QwEnergyCalculator::SetSingleEventCuts ( Double_t minX,
Double_t maxX )

Set single-event cut limits on the underlying energy channel.

Parameters
minXLower limit.
maxXUpper limit.
Returns
1 on success.

Definition at line 477 of file QwEnergyCalculator.cc.

477 {
478 fEnergyChange.SetSingleEventCuts(minX,maxX);
479 return 1;
480}

References fEnergyChange.

◆ SetSingleEventCuts() [2/2]

void QwEnergyCalculator::SetSingleEventCuts ( UInt_t errorflag,
Double_t LL = 0,
Double_t UL = 0,
Double_t stability = 0,
Double_t burplevel = 0 )

Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel.

Configure detailed single-event cuts for the underlying channel.

Parameters
errorflagDevice-specific error flag mask to set.
LLLower limit.
ULUpper limit.
stabilityStability threshold.
burplevelBurp detection threshold.

Definition at line 490 of file QwEnergyCalculator.cc.

490 {
491 //set the unique tag to identify device type (bcm,bpm & etc)
492 errorflag|=kBCMErrorFlag;//currently I use the same flag for bcm
493 QwMessage<<"QwEnergyCalculator Error Code passing to QwMollerADC_Ch "<<errorflag<<QwLog::endl;
494 fEnergyChange.SetSingleEventCuts(errorflag,LL,UL,stability,burplevel);
495}
static const UInt_t kBCMErrorFlag
Definition QwTypes.h:168

References QwLog::endl(), fEnergyChange, kBCMErrorFlag, and QwMessage.

+ Here is the call graph for this function:

◆ Sum()

void QwEnergyCalculator::Sum ( const QwEnergyCalculator & value1,
const QwEnergyCalculator & value2 )

Definition at line 409 of file QwEnergyCalculator.cc.

409 {
410 *this = value1;
411 *this += value2;
412}

References QwEnergyCalculator().

+ Here is the call graph for this function:

◆ UpdateErrorFlag() [1/2]

UInt_t QwEnergyCalculator::UpdateErrorFlag ( )
overridevirtual

Update and return the composite event-cut error flag.

Returns
The updated event-cut error flag for this calculator.

Reimplemented from VQwDataElement.

Definition at line 320 of file QwEnergyCalculator.cc.

321{
322 UInt_t error_code = 0;
323 for(UInt_t i = 0; i<fProperty.size(); i++){
324 if(fProperty[i].Contains("targetbeamangle")){
325 error_code |= ((QwCombinedBPM<QwMollerADC_Channel>*)fDevice[i])->fSlope[0].GetErrorCode();
326 } else {
327 error_code |= fDevice[i]->GetPosition(VQwBPM::kXAxis)->GetErrorCode();
328 }
329 }
330 fEnergyChange.UpdateErrorFlag(error_code);
331 return fEnergyChange.GetEventcutErrorFlag();
332}

References fDevice, fEnergyChange, fProperty, and VQwBPM::kXAxis.

◆ UpdateErrorFlag() [2/2]

void QwEnergyCalculator::UpdateErrorFlag ( const QwEnergyCalculator * ev_error)

Propagate error flags from a reference calculator into this one.

Parameters
ev_errorReference energy calculator containing error flags to merge.

Definition at line 339 of file QwEnergyCalculator.cc.

339 {
340 fEnergyChange.UpdateErrorFlag(ev_error->fEnergyChange);
341};

References fEnergyChange, and QwEnergyCalculator().

+ Here is the call graph for this function:

Field Documentation

◆ bEVENTCUTMODE

Bool_t QwEnergyCalculator::bEVENTCUTMODE
private

Definition at line 161 of file QwEnergyCalculator.h.

Referenced by SetEventCutMode().

◆ bFullSave

Bool_t QwEnergyCalculator::bFullSave
private

Definition at line 162 of file QwEnergyCalculator.h.

Referenced by SetRootSaveStatus().

◆ fDevice

std::vector<const VQwBPM*> QwEnergyCalculator::fDevice
private

◆ fDeviceErrorCode

Int_t QwEnergyCalculator::fDeviceErrorCode
private

Definition at line 160 of file QwEnergyCalculator.h.

◆ fEnergyChange

◆ fProperty

std::vector<TString> QwEnergyCalculator::fProperty
private

◆ fTMatrixRatio

std::vector<Double_t> QwEnergyCalculator::fTMatrixRatio
private

Definition at line 157 of file QwEnergyCalculator.h.

Referenced by GetProjectedPosition(), ProcessEvent(), and Set().

◆ fType

std::vector<TString> QwEnergyCalculator::fType
private

Definition at line 159 of file QwEnergyCalculator.h.

Referenced by Set().


The documentation for this class was generated from the following files: