QwAnalysis
QwPMT_Channel Class Reference

#include <QwPMT_Channel.h>

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

Public Member Functions

 QwPMT_Channel ()
 Default constructor. More...
 
 QwPMT_Channel (const QwPMT_Channel &source)
 Copy constructor. More...
 
 QwPMT_Channel (TString name)
 Constructor with name. More...
 
virtual ~QwPMT_Channel ()
 Virtual destructor. More...
 
void InitializeChannel (TString name)
 
void ClearEventData ()
 Clear the event data in this element. More...
 
void RandomizeEventData (int helicity, int SlotNum, int ChanNum)
 
void EncodeEventData (std::vector< UInt_t > &TrigBuffer)
 
Int_t ProcessEvBuffer (UInt_t *buffer, UInt_t num_words_left, UInt_t subelement=0)
 Process the CODA event buffer for this element. More...
 
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 ()
 
QwPMT_Channeloperator= (const QwPMT_Channel &value)
 
void ConstructHistograms (TDirectory *folder, TString &prefix)
 Construct the histograms for this data element. More...
 
void FillHistograms ()
 Fill the histograms for this data element. More...
 
void ConstructBranchAndVector (TTree *tree, TString &prefix, std::vector< Double_t > &values)
 
void FillTreeVector (std::vector< Double_t > &values) const
 
void PrintValue () const
 Print single line of value and error of this data element. More...
 
void PrintInfo () const
 Print multiple lines of information about this data element. More...
 
void PrintErrorCounters () const
 report number of events failed due to HW and event cut failure More...
 
- Public Member Functions inherited from VQwDataElement
 VQwDataElement ()
 Default constructor. More...
 
 VQwDataElement (const VQwDataElement &value)
 Copy constructor. More...
 
virtual ~VQwDataElement ()
 Virtual destructor. More...
 
Bool_t IsNameEmpty () const
 Is the name of this element empty? More...
 
void SetElementName (const TString &name)
 Set the name of this element. More...
 
virtual const TString & GetElementName () const
 Get the name of this element. More...
 
virtual void LoadChannelParameters (QwParameterFile &paramfile)
 
size_t GetNumberOfDataWords ()
 Get the number of data words in this data element. More...
 
UInt_t GetGoodEventCount () const
 
virtual void AssignValueFrom (const VQwDataElement *valueptr)
 
virtual VQwDataElementoperator+= (const VQwDataElement &value)
 Addition-assignment operator. More...
 
virtual VQwDataElementoperator-= (const VQwDataElement &value)
 Subtraction-assignment operator. More...
 
virtual void Sum (const VQwDataElement &value1, const VQwDataElement &value2)
 Sum operator. More...
 
virtual void Difference (const VQwDataElement &value1, const VQwDataElement &value2)
 Difference operator. More...
 
virtual void Ratio (const VQwDataElement &numer, const VQwDataElement &denom)
 Ratio operator. More...
 
virtual void SetSingleEventCuts (UInt_t errorflag, Double_t min, Double_t max, Double_t stability)
 set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel More...
 
virtual UInt_t GetEventcutErrorFlag ()
 return the error flag on this channel/device More...
 
virtual UInt_t UpdateErrorFlag ()
 Update the error flag based on the error flags of internally contained objects Return paramter is the "Eventcut Error Flag". More...
 
virtual void SetNeedsExternalClock (Bool_t needed)
 
virtual Bool_t NeedsExternalClock ()
 
virtual std::string GetExternalClockName ()
 
virtual void SetExternalClockPtr (const VQwHardwareChannel *clock)
 
virtual void SetExternalClockName (const std::string name)
 
virtual Double_t GetNormClockValue ()
 
TString GetSubsystemName () const
 Return the name of the inheriting subsystem name. More...
 
void SetSubsystemName (TString sysname)
 Set the name of the inheriting subsystem name. More...
 
TString GetModuleType () const
 Return the type of the beam instrument. More...
 
void SetModuleType (TString ModuleType)
 set the type of the beam instrument More...
 
- Public Member Functions inherited from MQwHistograms
void ShareHistograms (const MQwHistograms *source)
 Share histogram pointers between objects. More...
 

Private Attributes

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

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 }
 
- Protected Member Functions inherited from VQwDataElement
void SetNumberOfDataWords (const UInt_t &numwords)
 Set the number of data words in this data element. More...
 
virtual VQwDataElementoperator= (const VQwDataElement &value)
 Arithmetic assignment operator: Should only copy event-based data. More...
 
virtual void UpdateErrorFlag (const UInt_t &error)
 
- Protected Member Functions inherited from MQwHistograms
 MQwHistograms ()
 Default constructor. More...
 
 MQwHistograms (const MQwHistograms &source)
 Copy constructor. More...
 
virtual ~MQwHistograms ()
 Virtual destructor. More...
 
virtual MQwHistogramsoperator= (const MQwHistograms &value)
 
void Fill_Pointer (TH1_ptr hist_ptr, Double_t value)
 
void AddHistogram (TH1 *h)
 Register a histogram. More...
 
- Protected Attributes inherited from VQwDataElement
TString fElementName
 Name of this data element. More...
 
UInt_t fNumberOfDataWords
 Number of raw data words in this data element. More...
 
Int_t fGoodEventCount
 Number of good events accumulated in this element. More...
 
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) More...
 
UInt_t fErrorConfigFlag
 contains the global/local/stability flags More...
 
- Protected Attributes inherited from MQwHistograms
std::vector< TH1_ptrfHistograms
 Histograms associated with this data element. More...
 

Detailed Description

Definition at line 24 of file QwPMT_Channel.h.

Constructor & Destructor Documentation

QwPMT_Channel::QwPMT_Channel ( )
inline

Default constructor.

Definition at line 31 of file QwPMT_Channel.h.

31  {
32  // Prepare the random number generator.
33  gRandom->SetSeed();
34  };
QwPMT_Channel::QwPMT_Channel ( const QwPMT_Channel source)
inline

Copy constructor.

Definition at line 36 of file QwPMT_Channel.h.

37  : VQwDataElement(source)
38  { };
VQwDataElement()
Default constructor.
QwPMT_Channel::QwPMT_Channel ( TString  name)
inline

Constructor with name.

Definition at line 40 of file QwPMT_Channel.h.

References InitializeChannel().

40  {
41  InitializeChannel(name);
42  };
void InitializeChannel(TString name)
Definition: QwPMT_Channel.h:46

+ Here is the call graph for this function:

virtual QwPMT_Channel::~QwPMT_Channel ( )
inlinevirtual

Virtual destructor.

Definition at line 44 of file QwPMT_Channel.h.

44 { };

Member Function Documentation

void QwPMT_Channel::ClearEventData ( )
virtual

Clear the event data in this element.

Reimplemented from VQwDataElement.

Definition at line 26 of file QwPMT_Channel.cc.

References fValue.

Referenced by InitializeChannel().

26  {
27  fValue = 0;
28 }
Double_t fValue
Definition: QwPMT_Channel.h:95

+ Here is the caller graph for this function:

void QwPMT_Channel::ConstructBranchAndVector ( TTree *  tree,
TString &  prefix,
std::vector< Double_t > &  values 
)

Definition at line 98 of file QwPMT_Channel.cc.

References fTreeArrayIndex, fTreeArrayNumEntries, and VQwDataElement::GetElementName().

99 {
100  if (GetElementName() == "") {
101  // This channel is not used, so skip setting up the tree.
102  } else {
103  TString basename = prefix + GetElementName();
104  fTreeArrayIndex = values.size();
105 
106  values.push_back(0.0);
107  TString list = basename + "/D";
108 
109  fTreeArrayNumEntries = values.size() - fTreeArrayIndex;
110  tree->Branch(basename, &(values[fTreeArrayIndex]), list);
111  }
112 }
size_t fTreeArrayIndex
Definition: QwPMT_Channel.h:91
virtual const TString & GetElementName() const
Get the name of this element.
size_t fTreeArrayNumEntries
Definition: QwPMT_Channel.h:92

+ Here is the call graph for this function:

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

Construct the histograms for this data element.

Implements VQwDataElement.

Definition at line 67 of file QwPMT_Channel.cc.

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

68 {
69  // If we have defined a subdirectory in the ROOT file, then change into it.
70  if (folder != NULL) folder->cd();
71 
72  if (GetElementName() == "") {
73  // This channel is not used, so skip filling the histograms.
74  } else {
75  // Now create the histograms.
76  TString basename, fullname;
77  basename = prefix + GetElementName();
78 
79  fHistograms.resize(1, NULL);
80  size_t index = 0;
81  fHistograms[index] = gQwHists.Construct1DHist(basename);
82  index++;
83  }
84 }
std::vector< TH1_ptr > fHistograms
Histograms associated with this data element.
Definition: MQwHistograms.h:46
QwHistogramHelper gQwHists
Globally defined instance of the QwHistogramHelper class.
virtual const TString & GetElementName() const
Get the name of this element.
TH1F * Construct1DHist(const TString &inputfile, const TString &name_title)

+ Here is the call graph for this function:

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

Definition at line 45 of file QwPMT_Channel.cc.

References fValue, and VQwDataElement::IsNameEmpty().

46 {
47 // std::cout<<"QwPMT_Channel::EncodeEventData() not fully implemented yet."<<std::endl;
48 
49  Long_t localbuf;
50 
51  if (IsNameEmpty()) {
52  // This channel is not used, but is present in the data stream.
53  // Skip over this data.
54  } else {
55  localbuf = (Long_t) (this->fValue);
56  TrigBuffer.push_back(localbuf);
57  }
58 
59 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
Double_t fValue
Definition: QwPMT_Channel.h:95

+ Here is the call graph for this function:

void QwPMT_Channel::FillHistograms ( )
virtual

Fill the histograms for this data element.

Implements VQwDataElement.

Definition at line 86 of file QwPMT_Channel.cc.

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

87 {
88  size_t index = 0;
89  if (GetElementName() == "") {
90  // This channel is not used, so skip creating the histograms.
91  } else {
92  if (fHistograms[index] != NULL)
93  fHistograms[index]->Fill(fValue);
94  index++;
95  }
96 }
std::vector< TH1_ptr > fHistograms
Histograms associated with this data element.
Definition: MQwHistograms.h:46
Double_t fValue
Definition: QwPMT_Channel.h:95
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

void QwPMT_Channel::FillTreeVector ( std::vector< Double_t > &  values) const

Definition at line 114 of file QwPMT_Channel.cc.

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

115 {
116  if (GetElementName()==""){
117  // This channel is not used, so skip filling the tree vector.
118  } else if (fTreeArrayNumEntries<=0){
119  std::cerr << "QwPMT_Channel::FillTreeVector: fTreeArrayNumEntries=="
120  << fTreeArrayNumEntries << std::endl;
121  } else if (values.size() < fTreeArrayIndex+fTreeArrayNumEntries){
122  std::cerr << "QwPMT_Channel::FillTreeVector: values.size()=="
123  << values.size()
124  << "; fTreeArrayIndex+fTreeArrayNumEntries=="
126  << std::endl;
127  } else {
128  size_t index=fTreeArrayIndex;
129  values[index++] = this->fValue;
130  }
131 }
size_t fTreeArrayIndex
Definition: QwPMT_Channel.h:91
Double_t fValue
Definition: QwPMT_Channel.h:95
virtual const TString & GetElementName() const
Get the name of this element.
size_t fTreeArrayNumEntries
Definition: QwPMT_Channel.h:92

+ Here is the call graph for this function:

Int_t QwPMT_Channel::GetModule ( ) const
inline

Definition at line 61 of file QwPMT_Channel.h.

References fModule.

61 { return fModule; };
Int_t fModule
slot number
Definition: QwPMT_Channel.h:98
Int_t QwPMT_Channel::GetSubbankID ( ) const
inline

Definition at line 60 of file QwPMT_Channel.h.

References fCrate.

60 { return fCrate; };
Int_t fCrate
ROC number.
Definition: QwPMT_Channel.h:97
Double_t QwPMT_Channel::GetValue ( ) const
inline

Definition at line 57 of file QwPMT_Channel.h.

References fValue.

Referenced by PrintValue().

57 { return fValue; };
Double_t fValue
Definition: QwPMT_Channel.h:95

+ Here is the caller graph for this function:

void QwPMT_Channel::InitializeChannel ( TString  name)
inline

Definition at line 46 of file QwPMT_Channel.h.

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

Referenced by QwPMT_Channel().

46  {
47  SetElementName(name);
49  };
void SetElementName(const TString &name)
Set the name of this element.
void ClearEventData()
Clear the event data in this element.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 135 of file QwPMT_Channel.cc.

References fValue, and VQwDataElement::GetElementName().

135  {
136  if (GetElementName()!=""){
137  this->fValue = value.fValue;
138  }
139  return *this;
140 }
Double_t fValue
Definition: QwPMT_Channel.h:95
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

void QwPMT_Channel::PrintErrorCounters ( ) const
inlinevirtual

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

Reimplemented from VQwDataElement.

Definition at line 75 of file QwPMT_Channel.h.

75 {};
void QwPMT_Channel::PrintInfo ( ) const
virtual

Print multiple lines of information about this data element.

Reimplemented from VQwDataElement.

Definition at line 150 of file QwPMT_Channel.cc.

151 {
152  std::cout << "QwPMT_Channel::Print() not implemented yet." << std::endl;
153 }
void QwPMT_Channel::PrintValue ( ) const
virtual

Print single line of value and error of this data element.

Reimplemented from VQwDataElement.

Definition at line 142 of file QwPMT_Channel.cc.

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

143 {
144  QwMessage << std::setprecision(4)
145  << std::setw(18) << std::left << GetElementName() << ", "
146  << std::setw(15) << std::left << GetValue()
147  << QwLog::endl;
148 }
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
virtual const TString & GetElementName() const
Get the name of this element.
Double_t GetValue() const
Definition: QwPMT_Channel.h:57

+ Here is the call graph for this function:

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

Process the CODA event buffer for this element.

Implements VQwDataElement.

Definition at line 54 of file QwPMT_Channel.h.

54 {return 0;};
void QwPMT_Channel::ProcessEvent ( )

Definition at line 61 of file QwPMT_Channel.cc.

62 {
63 
64 }
void QwPMT_Channel::RandomizeEventData ( int  helicity,
int  SlotNum,
int  ChanNum 
)

Definition at line 30 of file QwPMT_Channel.cc.

References fValue.

30  {
31 
32  Double_t mean = 1500.0;
33  Double_t sigma = 300.0;
34  UInt_t fV775Dataword = abs( (Int_t)gRandom->Gaus(mean,sigma) );
35 
36  UInt_t fV775SlotNumber = SlotNum;
37  UInt_t fV775ChannelNumber = ChanNum;
38  const UInt_t fV775DataValidBit = 0x00004000;
39 
40  UInt_t word = fV775Dataword | (fV775SlotNumber<<27);
41  word = word | (fV775ChannelNumber<<16) | fV775DataValidBit;
42  fValue = word;
43 }
Double_t fValue
Definition: QwPMT_Channel.h:95
void QwPMT_Channel::SetModule ( const Int_t  slot_num)
inline

Definition at line 59 of file QwPMT_Channel.h.

References fModule.

59 { fModule = slot_num; };
Int_t fModule
slot number
Definition: QwPMT_Channel.h:98
void QwPMT_Channel::SetSubbankID ( const Int_t  bank_index)
inline

Definition at line 58 of file QwPMT_Channel.h.

References fCrate.

58 { fCrate = bank_index; };
Int_t fCrate
ROC number.
Definition: QwPMT_Channel.h:97
void QwPMT_Channel::SetValue ( Double_t  data)
inline

Definition at line 56 of file QwPMT_Channel.h.

References fValue.

56 { fValue = data; };
Double_t fValue
Definition: QwPMT_Channel.h:95

Field Documentation

Int_t QwPMT_Channel::fCrate
private

ROC number.

Definition at line 97 of file QwPMT_Channel.h.

Referenced by GetSubbankID(), and SetSubbankID().

Int_t QwPMT_Channel::fModule
private

slot number

Definition at line 98 of file QwPMT_Channel.h.

Referenced by GetModule(), and SetModule().

size_t QwPMT_Channel::fTreeArrayIndex
private

Definition at line 91 of file QwPMT_Channel.h.

Referenced by ConstructBranchAndVector(), and FillTreeVector().

size_t QwPMT_Channel::fTreeArrayNumEntries
private

Definition at line 92 of file QwPMT_Channel.h.

Referenced by ConstructBranchAndVector(), and FillTreeVector().

Double_t QwPMT_Channel::fValue
private
const Bool_t QwPMT_Channel::kDEBUG = kFALSE
staticprivate

Definition at line 75 of file QwPMT_Channel.h.

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 85 of file QwPMT_Channel.h.


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