JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
VQwSubsystemParity.h
Go to the documentation of this file.
1/*!
2 * \file VQwSubsystemParity.h
3 * \brief Virtual base class for parity analysis subsystems
4 * \author P. M. King, Rakitha Beminiwattha
5 * \date 2007-05-08
6 */
7
8#pragma once
9
10// ROOT headers
11#include <TTree.h>
12
13// Qweak headers
14#include "VQwSubsystem.h"
15#include "QwParameterFile.h"
16
17// Forward declarations
18class QwBlinder;
19class QwParityDB;
20class QwPromptSummary;
21
22
23/**
24 * \class VQwSubsystemParity
25 * \ingroup QwAnalysis
26 * \brief Abstract base class for subsystems participating in parity analysis
27 *
28 * Extends VQwSubsystem with parity-specific capabilities including asymmetry
29 * formation, blinding support, database output, running sum accumulation,
30 * and event cuts. Provides the contract for subsystems that contribute to
31 * parity violation measurements and helicity-based analyses.
32 */
33class VQwSubsystemParity: virtual public VQwSubsystem {
34
35 private:
36 /// Private default constructor (not implemented, will throw linker error on use)
38
39 public:
40 /// Constructor with name
41 VQwSubsystemParity(const TString& name): VQwSubsystem(name) {
42 SetEventTypeMask(0x1); // only accept 0x1
43 };
44 /// Copy constructor
46 : VQwSubsystem(source)
47 { }
48 /// Default destructor
49 ~VQwSubsystemParity() override { };
50
51 /// \brief Fill the database with MPS-based variables
52 /// Note that most subsystems don't need to do this.
53 virtual void FillDB_MPS(QwParityDB * /*db*/, TString /*type*/) {};
54 /// \brief Fill the database
55 virtual void FillDB(QwParityDB * /*db*/, TString /*type*/) { };
56 virtual void FillErrDB(QwParityDB * /*db*/, TString /*type*/) { };
57
58 // VQwSubsystem routine is overridden. Call it at the beginning by VQwSubsystem::operator=(value)
59 VQwSubsystem& operator= (VQwSubsystem *value) override = 0;
62 virtual void Sum(VQwSubsystem *value1, VQwSubsystem *value2)
63 {
64 if(Compare(value1)&&Compare(value2)){
65 *this = value1;
66 *this += value2;
67 }
68 };
69 virtual void Difference(VQwSubsystem *value1, VQwSubsystem *value2)
70 {
71 if(Compare(value1)&&Compare(value2)){
72 *this = value1;
73 *this -= value2;
74 }
75 };
76 virtual void Ratio(VQwSubsystem *numer, VQwSubsystem *denom) = 0;
77 virtual void Scale(Double_t factor) = 0;
78
79 /// \brief Update the running sums for devices
80 virtual void AccumulateRunningSum(VQwSubsystem* value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) = 0;
81 /// \brief remove one entry from the running sums for devices
82 virtual void DeaccumulateRunningSum(VQwSubsystem* value, Int_t ErrorMask=0xFFFFFFF) = 0;
83
84 /// \brief Calculate the average for all good events
85 virtual void CalculateRunningAverage() = 0;
86
87 /// \brief Load the event cuts file
88 Int_t LoadEventCuts(TString filename) override{
89 Int_t eventcut_flag = 1;
90
91 // Open the file
92 QwParameterFile mapstr(filename.Data());
94 this->LoadEventCuts_Init();
95
96 while (mapstr.ReadNextLine()){
97 mapstr.TrimComment('!'); // Remove everything after a '!' character.
98 mapstr.TrimWhitespace(); // Get rid of leading and trailing spaces.
99 if (mapstr.LineIsEmpty())
100 continue;
101 TString varname, varvalue;
102 if (mapstr.HasVariablePair("=",varname,varvalue)){
103 if (varname == "EVENTCUTS"){
104 eventcut_flag = QwParameterFile::GetUInt(varvalue);
105 }
106 } else {
107 this->LoadEventCuts_Line(mapstr, varvalue, eventcut_flag);
108 }
109 }
110
111 this->LoadEventCuts_Fin(eventcut_flag);
112 mapstr.Close();
113 return 0;
114 };
115 virtual void LoadEventCuts_Init() {};
116 virtual void LoadEventCuts_Line(QwParameterFile & /*mapstr*/, TString & /*varvalue*/, Int_t & /*eventcut_flag*/) {};
117 virtual void LoadEventCuts_Fin(Int_t & /*eventcut_flag*/) {};
118 /// \brief Apply the single event cuts
119 virtual Bool_t ApplySingleEventCuts() = 0;
120 /// \brief Report the number of events failed due to HW and event cut failures
121
122 virtual Bool_t CheckForBurpFail(const VQwSubsystem *subsys)=0;
123
124 virtual void PrintErrorCounters() const = 0;
125 /// \brief Increment the error counters
126 virtual void IncrementErrorCounters() = 0;
127
128 /// \brief Return the error flag to the top level routines related to stability checks and ErrorFlag updates
129 virtual UInt_t GetEventcutErrorFlag() = 0;
130 /// \brief Uses the error flags of contained data elements to update
131 /// Returns the error flag to the top level routines related
132 /// to stability checks and ErrorFlag updates
133 virtual UInt_t UpdateErrorFlag(){return GetEventcutErrorFlag();};
134
135 /// \brief update the error flag in the subsystem level from the top level routines related to stability checks. This will uniquely update the errorflag at each channel based on the error flag in the corresponding channel in the ev_error subsystem
136 virtual void UpdateErrorFlag(const VQwSubsystem *ev_error) = 0;
137
138
139 /// \brief Blind the asymmetry of this subsystem
140 virtual void Blind(const QwBlinder * /*blinder*/) { return; };
141 /// \brief Blind the difference of this subsystem
142 virtual void Blind(const QwBlinder * /*blinder*/, const VQwSubsystemParity* /*subsys*/) { return; };
143
144 /// \brief Print values of all channels
145 virtual void PrintValue() const { };
146
147 virtual void WritePromptSummary(QwPromptSummary * /*ps*/, TString /*type*/) {};
148
149
150 virtual Bool_t CheckForEndOfBurst() const {return kFALSE;};
151
152 virtual void LoadMockDataParameters(TString /*mapfile*/) {};
153
154}; // class VQwSubsystemParity
Definition of the pure virtual base class of all subsystems.
Parameter file parsing and management.
Configuration file parser with flexible tokenization and search capabilities.
void TrimWhitespace(TString::EStripType head_tail=TString::kBoth)
Bool_t HasVariablePair(const std::string &separatorchars, std::string &varname, std::string &varvalue)
void TrimComment(const char commentchar)
static UInt_t GetUInt(const TString &varvalue)
const std::pair< TString, TString > GetParamFileNameContents()
void SetEventTypeMask(const UInt_t mask)
Set event type mask.
Bool_t Compare(VQwSubsystem *source)
std::map< TString, TString > fDetectorMaps
Map of file name to full path or content.
VQwSubsystem(const TString &name)
Constructor with name.
Data blinding utilities for parity violation analysis.
Definition QwBlinder.h:57
virtual VQwSubsystem & operator-=(VQwSubsystem *value)=0
VQwSubsystemParity(const VQwSubsystemParity &source)
Copy constructor.
virtual void Difference(VQwSubsystem *value1, VQwSubsystem *value2)
virtual void LoadEventCuts_Init()
virtual void Ratio(VQwSubsystem *numer, VQwSubsystem *denom)=0
~VQwSubsystemParity() override
Default destructor.
VQwSubsystemParity()
Private default constructor (not implemented, will throw linker error on use)
virtual Bool_t CheckForBurpFail(const VQwSubsystem *subsys)=0
Report the number of events failed due to HW and event cut failures.
virtual void LoadEventCuts_Fin(Int_t &)
virtual UInt_t GetEventcutErrorFlag()=0
Return the error flag to the top level routines related to stability checks and ErrorFlag updates.
virtual void PrintValue() const
Print values of all channels.
virtual void Blind(const QwBlinder *, const VQwSubsystemParity *)
Blind the difference of this subsystem.
virtual void FillDB_MPS(QwParityDB *, TString)
Fill the database with MPS-based variables Note that most subsystems don't need to do this.
virtual Bool_t ApplySingleEventCuts()=0
Apply the single event cuts.
virtual void FillDB(QwParityDB *, TString)
Fill the database.
virtual void Blind(const QwBlinder *)
Blind the asymmetry of this subsystem.
virtual void WritePromptSummary(QwPromptSummary *, TString)
virtual void IncrementErrorCounters()=0
Increment the error counters.
virtual void PrintErrorCounters() const =0
virtual UInt_t UpdateErrorFlag()
Uses the error flags of contained data elements to update Returns the error flag to the top level rou...
virtual void UpdateErrorFlag(const VQwSubsystem *ev_error)=0
update the error flag in the subsystem level from the top level routines related to stability checks....
virtual void LoadMockDataParameters(TString)
Int_t LoadEventCuts(TString filename) override
Load the event cuts file.
virtual void AccumulateRunningSum(VQwSubsystem *value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF)=0
Update the running sums for devices.
virtual void LoadEventCuts_Line(QwParameterFile &, TString &, Int_t &)
virtual void CalculateRunningAverage()=0
Calculate the average for all good events.
VQwSubsystem & operator=(VQwSubsystem *value) override=0
Assignment Note: Must be called at the beginning of all subsystems routine call to operator=(VQwSubsy...
virtual Bool_t CheckForEndOfBurst() const
virtual void Sum(VQwSubsystem *value1, VQwSubsystem *value2)
virtual void FillErrDB(QwParityDB *, TString)
virtual void DeaccumulateRunningSum(VQwSubsystem *value, Int_t ErrorMask=0xFFFFFFF)=0
remove one entry from the running sums for devices
virtual void Scale(Double_t factor)=0
VQwSubsystemParity(const TString &name)
Constructor with name.
virtual VQwSubsystem & operator+=(VQwSubsystem *value)=0