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

PMT channel data element for photomultiplier tube readout. More...

#include <QwPMT_Channel.h>

+ Inheritance diagram for QwPMT_Channel:
+ Collaboration diagram for QwPMT_Channel:

Public Member Functions

 QwPMT_Channel ()
 Default constructor.
 
 QwPMT_Channel (const QwPMT_Channel &source)
 Copy constructor.
 
 QwPMT_Channel (TString name)
 Constructor with name.
 
 ~QwPMT_Channel () override
 Virtual destructor.
 
void InitializeChannel (TString name)
 
void ClearEventData () override
 Clear the event-scoped ADC word value.
 
void RandomizeEventData (int helicity, int SlotNum, int ChanNum)
 Generate a mock ADC word for testing.
 
void EncodeEventData (std::vector< UInt_t > &TrigBuffer)
 Encode this channel's word into the trigger buffer.
 
Int_t ProcessEvBuffer (UInt_t *buffer, UInt_t num_words_left, UInt_t subelement=0) override
 Process the CODA event buffer for this element.
 
void SetValue (Double_t data)
 
Double_t GetValue () const
 
void SetSubbankID (const Int_t bank_index)
 
void SetModule (const Int_t slot_num)
 
Int_t GetSubbankID () const
 
Int_t GetModule () const
 
void ProcessEvent ()
 Process the event (no-op for simple PMT channel).
 
QwPMT_Channeloperator= (const QwPMT_Channel &value)
 Copy-assign from another PMT channel (event-scoped data).
 
QwPMT_Channeloperator+= (const QwPMT_Channel &value)
 
QwPMT_Channeloperator-= (const QwPMT_Channel &value)
 
void Sum (const QwPMT_Channel &value1, const QwPMT_Channel &value2)
 
void Difference (const QwPMT_Channel &value1, const QwPMT_Channel &value2)
 
void ConstructHistograms (TDirectory *folder, TString &prefix) override
 Create histograms for this channel within an optional folder.
 
void FillHistograms () override
 Fill histograms for this channel if present.
 
void ConstructBranchAndVector (TTree *tree, TString &prefix, QwRootTreeBranchVector &values)
 Construct a ROOT branch and append a value slot to the vector.
 
void FillTreeVector (QwRootTreeBranchVector &values) const
 Write this channel's value into the tree vector slot.
 
void PrintValue () const override
 Print a compact value summary for this PMT channel.
 
void PrintInfo () const override
 Print a placeholder info line for this PMT channel.
 
void PrintErrorCounters () const override
 report number of events failed due to HW and event cut failure
 
- 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.
 
virtual void LoadChannelParameters (QwParameterFile &)
 
virtual void LoadMockDataParameters (QwParameterFile &)
 
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 UInt_t GetEventcutErrorFlag ()
 return the error flag on this channel/device
 
virtual UInt_t UpdateErrorFlag ()
 Update the error flag based on the error flags of internally contained objects Return parameter is the "Eventcut Error Flag".
 
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.
 

Private Attributes

size_t fTreeArrayIndex
 
size_t fTreeArrayNumEntries
 
Double_t fValue
 
Int_t fCrate
 ROC number.
 
Int_t fModule
 slot number
 

Static Private Attributes

static const Bool_t kDEBUG = kFALSE
 
static const Double_t kPMT_VoltsPerBit = (20./(1<<18))
 

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.
 
- 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.
 

Detailed Description

PMT channel data element for photomultiplier tube readout.

Handles data from photomultiplier tube channels including raw values, calibration, and basic data element operations for PMT-based detectors in the tracking system.

Definition at line 29 of file QwPMT_Channel.h.

Constructor & Destructor Documentation

◆ QwPMT_Channel() [1/3]

QwPMT_Channel::QwPMT_Channel ( )
inline

Default constructor.

Definition at line 36 of file QwPMT_Channel.h.

36 {
37 // Prepare the random number generator.
38 gRandom->SetSeed();
39 };

Referenced by Difference(), operator+=(), operator-=(), operator=(), QwPMT_Channel(), and Sum().

+ Here is the caller graph for this function:

◆ QwPMT_Channel() [2/3]

QwPMT_Channel::QwPMT_Channel ( const QwPMT_Channel & source)
inline

Copy constructor.

Definition at line 41 of file QwPMT_Channel.h.

42 : VQwDataElement(source)
43 { };
VQwDataElement()
Default constructor.

References QwPMT_Channel(), and VQwDataElement::VQwDataElement().

+ Here is the call graph for this function:

◆ QwPMT_Channel() [3/3]

QwPMT_Channel::QwPMT_Channel ( TString name)
inline

Constructor with name.

Definition at line 45 of file QwPMT_Channel.h.

45 {
47 };
void InitializeChannel(TString name)

References InitializeChannel().

+ Here is the call graph for this function:

◆ ~QwPMT_Channel()

QwPMT_Channel::~QwPMT_Channel ( )
inlineoverride

Virtual destructor.

Definition at line 49 of file QwPMT_Channel.h.

49{ };

Member Function Documentation

◆ ClearEventData()

void QwPMT_Channel::ClearEventData ( )
overridevirtual

Clear the event-scoped ADC word value.

Reimplemented from VQwDataElement.

Definition at line 28 of file QwPMT_Channel.cc.

28 {
29 fValue = 0;
30}

References fValue.

Referenced by InitializeChannel().

+ Here is the caller graph for this function:

◆ ConstructBranchAndVector()

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

Construct a ROOT branch and append a value slot to the vector.

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

Definition at line 120 of file QwPMT_Channel.cc.

121{
122 if (GetElementName() == "") {
123 // This channel is not used, so skip setting up the tree.
124 } else {
125 TString basename = prefix + GetElementName();
126 fTreeArrayIndex = values.size();
127
128 values.push_back(basename.Data(), 'D');
129
131 tree->Branch(basename, &(values[fTreeArrayIndex]), values.LeafList(fTreeArrayIndex).c_str());
132 }
133}
size_t fTreeArrayNumEntries
size_t fTreeArrayIndex
size_type size() const noexcept
Definition QwRootFile.h:81
std::string LeafList(size_type start_index=0) const
Definition QwRootFile.h:228
void push_back(const std::string &name, const char type='D')
Definition QwRootFile.h:195
virtual const TString & GetElementName() const
Get the name of this element.

References fTreeArrayIndex, fTreeArrayNumEntries, VQwDataElement::GetElementName(), QwRootTreeBranchVector::LeafList(), QwRootTreeBranchVector::push_back(), and QwRootTreeBranchVector::size().

+ Here is the call graph for this function:

◆ ConstructHistograms()

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

Create histograms for this channel within an optional folder.

Parameters
folderOptional ROOT folder to cd() into.
prefixHistogram name prefix.

Implements VQwDataElement.

Definition at line 82 of file QwPMT_Channel.cc.

83{
84 // If we have defined a subdirectory in the ROOT file, then change into it.
85 if (folder != NULL) folder->cd();
86
87 if (GetElementName() == "") {
88 // This channel is not used, so skip filling the histograms.
89 } else {
90 // Now create the histograms.
91 TString basename, fullname;
92 basename = prefix + GetElementName();
93
94 fHistograms.resize(1, NULL);
95 size_t index = 0;
96 fHistograms[index] = gQwHists.Construct1DHist(basename);
97 index++;
98 }
99}
QwHistogramHelper gQwHists
Globally defined instance of the QwHistogramHelper class.
std::vector< TH1_ptr > fHistograms
Histograms associated with this data element.
TH1F * Construct1DHist(const TString &inputfile, const TString &name_title)

References MQwHistograms::fHistograms, VQwDataElement::GetElementName(), and gQwHists.

+ Here is the call graph for this function:

◆ Difference()

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

Definition at line 187 of file QwPMT_Channel.cc.

187 {
188 *this = value1;
189 *this -= value2;
190}

References QwPMT_Channel().

+ Here is the call graph for this function:

◆ EncodeEventData()

void QwPMT_Channel::EncodeEventData ( std::vector< UInt_t > & TrigBuffer)

Encode this channel's word into the trigger buffer.

Definition at line 54 of file QwPMT_Channel.cc.

55{
56// std::cout<<"QwPMT_Channel::EncodeEventData() not fully implemented yet."<<std::endl;
57
58 Long_t localbuf;
59
60 if (IsNameEmpty()) {
61 // This channel is not used, but is present in the data stream.
62 // Skip over this data.
63 } else {
64 localbuf = (Long_t) (this->fValue);
65 TrigBuffer.push_back(localbuf);
66 }
67
68}
Bool_t IsNameEmpty() const
Is the name of this element empty?

References fValue, and VQwDataElement::IsNameEmpty().

+ Here is the call graph for this function:

◆ FillHistograms()

void QwPMT_Channel::FillHistograms ( )
overridevirtual

Fill histograms for this channel if present.

Implements VQwDataElement.

Definition at line 102 of file QwPMT_Channel.cc.

103{
104 size_t index = 0;
105 if (GetElementName() == "") {
106 // This channel is not used, so skip creating the histograms.
107 } else {
108 if (fHistograms[index] != NULL)
109 fHistograms[index]->Fill(fValue);
110 index++;
111 }
112}

References MQwHistograms::fHistograms, fValue, and VQwDataElement::GetElementName().

+ Here is the call graph for this function:

◆ FillTreeVector()

void QwPMT_Channel::FillTreeVector ( QwRootTreeBranchVector & values) const

Write this channel's value into the tree vector slot.

Definition at line 136 of file QwPMT_Channel.cc.

137{
138 if (GetElementName()==""){
139 // This channel is not used, so skip filling the tree vector.
140 } else if (fTreeArrayNumEntries<=0){
141 std::cerr << "QwPMT_Channel::FillTreeVector: fTreeArrayNumEntries=="
142 << fTreeArrayNumEntries << std::endl;
143 } else if (values.size() < fTreeArrayIndex+fTreeArrayNumEntries){
144 std::cerr << "QwPMT_Channel::FillTreeVector: values.size()=="
145 << values.size()
146 << "; fTreeArrayIndex+fTreeArrayNumEntries=="
148 << std::endl;
149 } else {
150 size_t index=fTreeArrayIndex;
151 values.SetValue(index++, this->fValue);
152 }
153}
void SetValue(size_type index, Double_t val)
Definition QwRootFile.h:108

References fTreeArrayIndex, fTreeArrayNumEntries, fValue, VQwDataElement::GetElementName(), QwRootTreeBranchVector::SetValue(), and QwRootTreeBranchVector::size().

+ Here is the call graph for this function:

◆ GetModule()

Int_t QwPMT_Channel::GetModule ( ) const
inline

Definition at line 66 of file QwPMT_Channel.h.

66{ return fModule; };
Int_t fModule
slot number

References fModule.

◆ GetSubbankID()

Int_t QwPMT_Channel::GetSubbankID ( ) const
inline

Definition at line 65 of file QwPMT_Channel.h.

65{ return fCrate; };
Int_t fCrate
ROC number.

References fCrate.

◆ GetValue()

Double_t QwPMT_Channel::GetValue ( ) const
inline

Definition at line 62 of file QwPMT_Channel.h.

62{ return fValue; };

References fValue.

Referenced by PrintValue().

+ Here is the caller graph for this function:

◆ InitializeChannel()

void QwPMT_Channel::InitializeChannel ( TString name)
inline

Definition at line 51 of file QwPMT_Channel.h.

51 {
52 SetElementName(name);
54 };
void ClearEventData() override
Clear the event-scoped ADC word value.
void SetElementName(const TString &name)
Set the name of this element.

References ClearEventData(), and VQwDataElement::SetElementName().

Referenced by QwPMT_Channel().

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

◆ operator+=()

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

Definition at line 168 of file QwPMT_Channel.cc.

168 {
169 if (GetElementName()!=""){
170 this->fValue += value.fValue;
171 }
172 return *this;
173}

References fValue, VQwDataElement::GetElementName(), and QwPMT_Channel().

+ Here is the call graph for this function:

◆ operator-=()

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

Definition at line 175 of file QwPMT_Channel.cc.

175 {
176 if (GetElementName()!=""){
177 this->fValue -= value.fValue;
178 }
179 return *this;
180}

References fValue, VQwDataElement::GetElementName(), and QwPMT_Channel().

+ Here is the call graph for this function:

◆ operator=()

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

Copy-assign from another PMT channel (event-scoped data).

Definition at line 158 of file QwPMT_Channel.cc.

158 {
159 if (this != &value) {
160 if (GetElementName()!=""){
162 this->fValue = value.fValue;
163 }
164 }
165 return *this;
166}
VQwDataElement & operator=(const VQwDataElement &value)
Arithmetic assignment operator: Should only copy event-based data.

References fValue, VQwDataElement::GetElementName(), VQwDataElement::operator=(), and QwPMT_Channel().

+ Here is the call graph for this function:

◆ PrintErrorCounters()

void QwPMT_Channel::PrintErrorCounters ( ) const
inlineoverridevirtual

report number of events failed due to HW and event cut failure

Reimplemented from VQwDataElement.

Definition at line 84 of file QwPMT_Channel.h.

84{};

◆ PrintInfo()

void QwPMT_Channel::PrintInfo ( ) const
overridevirtual

Print a placeholder info line for this PMT channel.

Reimplemented from VQwDataElement.

Definition at line 202 of file QwPMT_Channel.cc.

203{
204 std::cout << "QwPMT_Channel::Print() not implemented yet." << std::endl;
205}

◆ PrintValue()

void QwPMT_Channel::PrintValue ( ) const
overridevirtual

Print a compact value summary for this PMT channel.

Reimplemented from VQwDataElement.

Definition at line 193 of file QwPMT_Channel.cc.

194{
195 QwMessage << std::setprecision(4)
196 << std::setw(18) << std::left << GetElementName() << ", "
197 << std::setw(15) << std::left << GetValue()
198 << QwLog::endl;
199}
#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
Double_t GetValue() const

References QwLog::endl(), VQwDataElement::GetElementName(), GetValue(), and QwMessage.

+ Here is the call graph for this function:

◆ ProcessEvBuffer()

Int_t QwPMT_Channel::ProcessEvBuffer ( UInt_t * buffer,
UInt_t num_words_left,
UInt_t subelement = 0 )
inlineoverridevirtual

Process the CODA event buffer for this element.

Implements VQwDataElement.

Definition at line 59 of file QwPMT_Channel.h.

59{return 0;};

References QwBPMStripline< T >::subelement.

◆ ProcessEvent()

void QwPMT_Channel::ProcessEvent ( )

Process the event (no-op for simple PMT channel).

Definition at line 71 of file QwPMT_Channel.cc.

72{
73
74}

◆ RandomizeEventData()

void QwPMT_Channel::RandomizeEventData ( int helicity,
int SlotNum,
int ChanNum )

Generate a mock ADC word for testing.

Parameters
helicityHelicity state indicator (unused).
SlotNumV775 slot number to encode in the word.
ChanNumV775 channel number to encode in the word.

Definition at line 38 of file QwPMT_Channel.cc.

38 {
39
40 Double_t mean = 1500.0;
41 Double_t sigma = 300.0;
42 UInt_t fV775Dataword = abs( (Int_t)gRandom->Gaus(mean,sigma) );
43
44 UInt_t fV775SlotNumber = SlotNum;
45 UInt_t fV775ChannelNumber = ChanNum;
46 const UInt_t fV775DataValidBit = 0x00004000;
47
48 UInt_t word = fV775Dataword | (fV775SlotNumber<<27);
49 word = word | (fV775ChannelNumber<<16) | fV775DataValidBit;
50 fValue = word;
51}

References fValue.

◆ SetModule()

void QwPMT_Channel::SetModule ( const Int_t slot_num)
inline

Definition at line 64 of file QwPMT_Channel.h.

64{ fModule = slot_num; };

References fModule.

◆ SetSubbankID()

void QwPMT_Channel::SetSubbankID ( const Int_t bank_index)
inline

Definition at line 63 of file QwPMT_Channel.h.

63{ fCrate = bank_index; };

References fCrate.

◆ SetValue()

void QwPMT_Channel::SetValue ( Double_t data)
inline

Definition at line 61 of file QwPMT_Channel.h.

61{ fValue = data; };

References fValue.

◆ Sum()

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

Definition at line 182 of file QwPMT_Channel.cc.

182 {
183 *this = value1;
184 *this += value2;
185}

References QwPMT_Channel().

+ Here is the call graph for this function:

Field Documentation

◆ fCrate

Int_t QwPMT_Channel::fCrate
private

ROC number.

Definition at line 106 of file QwPMT_Channel.h.

Referenced by GetSubbankID(), and SetSubbankID().

◆ fModule

Int_t QwPMT_Channel::fModule
private

slot number

Definition at line 107 of file QwPMT_Channel.h.

Referenced by GetModule(), and SetModule().

◆ fTreeArrayIndex

size_t QwPMT_Channel::fTreeArrayIndex
private

Definition at line 100 of file QwPMT_Channel.h.

Referenced by ConstructBranchAndVector(), and FillTreeVector().

◆ fTreeArrayNumEntries

size_t QwPMT_Channel::fTreeArrayNumEntries
private

Definition at line 101 of file QwPMT_Channel.h.

Referenced by ConstructBranchAndVector(), and FillTreeVector().

◆ fValue

Double_t QwPMT_Channel::fValue
private

◆ kDEBUG

const Bool_t QwPMT_Channel::kDEBUG = kFALSE
staticprivate

Definition at line 91 of file QwPMT_Channel.h.

◆ kPMT_VoltsPerBit

const Double_t QwPMT_Channel::kPMT_VoltsPerBit = (20./(1<<18))
staticprivate

Conversion factor to translate the average bit count in an ADC channel into average voltage. The base factor is roughly 76 uV per count, and zero counts corresponds to zero voltage. Store as the exact value for 20 V range, 18 bit ADC.

Definition at line 94 of file QwPMT_Channel.h.


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