QwAnalysis
QwSIS3320_Channel Class Reference

Class for the decoding of the SIS3320 sampling ADC data. More...

#include <QwSIS3320_Channel.h>

+ Inheritance diagram for QwSIS3320_Channel:
+ Collaboration diagram for QwSIS3320_Channel:

Public Member Functions

 QwSIS3320_Channel (UInt_t channel=0, TString name="auto")
 
 QwSIS3320_Channel (const QwSIS3320_Channel &source)
 
virtual ~QwSIS3320_Channel ()
 
void AddLogicalAccumulator (const TString name, const std::vector< TString > accums, const std::vector< Double_t > weights)
 
void InitializeChannel (UInt_t channel, TString name)
 
void ClearEventData ()
 
void RandomizeEventData (int helicity=0, double time=0.0)
 Internally generate random event data. More...
 
void EncodeEventData (std::vector< UInt_t > &buffer)
 Encode the event data into a CODA buffer. More...
 
Int_t ProcessEvBuffer (UInt_t *buffer, UInt_t num_words_left, UInt_t index=0)
 
void ProcessEvent ()
 
const QwSIS3320_Channel operator+ (const Double_t &value) const
 
const QwSIS3320_Channel operator- (const Double_t &value) const
 
const QwSIS3320_Channel operator+ (const QwSIS3320_Channel &value) const
 
const QwSIS3320_Channel operator- (const QwSIS3320_Channel &value) const
 
QwSIS3320_Channeloperator= (const QwSIS3320_Channel &value)
 
QwSIS3320_Channeloperator+= (const Double_t &value)
 
QwSIS3320_Channeloperator-= (const Double_t &value)
 
QwSIS3320_Channeloperator+= (const QwSIS3320_Channel &value)
 
QwSIS3320_Channeloperator-= (const QwSIS3320_Channel &value)
 
void Sum (QwSIS3320_Channel &value1, QwSIS3320_Channel &value2)
 
void Difference (QwSIS3320_Channel &value1, QwSIS3320_Channel &value2)
 
void Ratio (QwSIS3320_Channel &numer, QwSIS3320_Channel &denom)
 
void Offset (Double_t Offset)
 
void Scale (Double_t Offset)
 
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
 
QwSIS3320_SamplesGetSamples (size_t i)
 
QwSIS3320_SamplesGetSamplesRaw (size_t i)
 
size_t GetNumberOfEvents () const
 
void SetNumberOfEvents (UInt_t nevents)
 
size_t GetNumberOfAccumulators () const
 
void SetNumberOfAccumulators (UInt_t naccumulators)
 
void SetPedestal (const Double_t ped)
 
Double_t GetPedestal () const
 
void SetCalibrationFactor (const Double_t factor)
 
Double_t GetCalibrationFactor () const
 
Bool_t IsGoodEvent ()
 
void PrintValue () const
 
void PrintInfo () const
 
- 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 void PrintErrorCounters () const
 report number of events failed due to HW and event cut failure 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...
 
- Public Member Functions inherited from MQwMockable
 MQwMockable ()
 
virtual ~MQwMockable ()
 
void SetRandomEventDriftParameters (Double_t amplitude, Double_t phase, Double_t frequency)
 Set a single set of harmonic drift parameters. More...
 
void AddRandomEventDriftParameters (Double_t amplitude, Double_t phase, Double_t frequency)
 Add drift parameters to the internal set. More...
 
void SetRandomEventParameters (Double_t mean, Double_t sigma)
 Set the normal random event parameters. More...
 
void SetRandomEventAsymmetry (Double_t asymmetry)
 Set the helicity asymmetry. More...
 
Double_t GetRandomValue ()
 
void UseExternalRandomVariable ()
 Set the flag to use an externally provided random variable. More...
 
void SetExternalRandomVariable (Double_t random_variable)
 Set the externally provided random variable. More...
 

Private Attributes

UInt_t fChannel
 
Bool_t fHasSamplingData
 
Bool_t fHasAccumulatorData
 
Double_t fPedestal
 
Double_t fCalibrationFactor
 
Int_t fCurrentEvent
 
UInt_t fNumberOfEvents
 Current triggered event (allow for negative sentinel) More...
 
UInt_t fSampleFormat
 Number of triggered events. More...
 
std::vector< QwSIS3320_SamplesfSamples
 
std::vector< QwSIS3320_SamplesfSamplesRaw
 
QwSIS3320_Samples fAverageSamples
 
QwSIS3320_Samples fAverageSamplesRaw
 
std::vector< Double_t > fTimeWindowAverages
 
std::vector< std::pair< UInt_t,
UInt_t > > 
fTimeWindows
 
std::vector< Double_t > fSampleWindowAverages
 
std::vector< std::pair
< Double_t, Double_t > > 
fSampleWindows
 
Int_t fNumberOfAccumulators
 
Int_t fAccumulatorDAC
 
Int_t fAccumulatorThreshold1
 
Int_t fAccumulatorThreshold2
 
Int_t fAccumulatorTimingBefore5
 
Int_t fAccumulatorTimingAfter5
 
Int_t fAccumulatorTimingBefore6
 
Int_t fAccumulatorTimingAfter6
 
std::vector
< QwSIS3320_Accumulator
fAccumulators
 
std::vector
< QwSIS3320_Accumulator
fAccumulatorsRaw
 
std::vector
< QwSIS3320_LogicalAccumulator
fLogicalAccumulators
 

Static Private Attributes

static const Bool_t kDEBUG = kFALSE
 
static const Double_t kVoltsPerBit = 5.0 / pow(2.0, 12)
 
static const Double_t kNanoSecondsPerSample = 4.0
 
static const unsigned int MODE_ACCUM_EVENT = 0x1
 
static const unsigned int MODE_MULTI_EVENT = 0x3
 
static const unsigned int MODE_SINGLE_EVENT = 0x4
 
static const unsigned int MODE_NOTREADY = 0xda00
 
static const unsigned int FORMAT_ACCUMULATOR = 0x0
 
static const unsigned int FORMAT_LONG_WORD_SAMPLING = 0x1
 
static const unsigned int FORMAT_SHORT_WORD_SAMPLING = 0x2
 

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...
 
- Protected Attributes inherited from MQwMockable
bool fUseExternalRandomVariable
 Flag to use an externally provided normal random variable. More...
 
double fExternalRandomVariable
 Externally provided normal random variable. More...
 
Double_t fMockAsymmetry
 Helicity asymmetry. More...
 
Double_t fMockGaussianMean
 Mean of normal distribution. More...
 
Double_t fMockGaussianSigma
 Sigma of normal distribution. More...
 
std::vector< Double_t > fMockDriftAmplitude
 Harmonic drift amplitude. More...
 
std::vector< Double_t > fMockDriftFrequency
 Harmonic drift frequency. More...
 
std::vector< Double_t > fMockDriftPhase
 Harmonic drift phase. More...
 
- Static Protected Attributes inherited from MQwMockable
static boost::mt19937 fRandomnessGenerator
 Internal randomness generator. More...
 
static
boost::normal_distribution
< double > 
fNormalDistribution
 Internal normal probability distribution. More...
 
static
boost::variate_generator
< boost::mt19937,
boost::normal_distribution
< double > > 
fNormalRandomVariable
 Internal normal random variable. More...
 

Detailed Description

Class for the decoding of the SIS3320 sampling ADC data.

Author
W. Deconinck
Date
2009-09-04 18:06:23

The QwSIS3320_Channel class is defined to read the integrated and sampled data from the Compton photon detector. Because the scope of this module is similar the the VQWK ADC module (integration and asymmetries), parts of this class are very similar to QwVQWK_Channel.

The main data members of a QwSIS3320_Channel are the vector fSamples of QwSIS3320_Samples where each entry stores a sample event, and the vector of fAccumulators of QwSIS3320_Accumulator where each entry stores an accumulator block. Both of these data members are derived from their –Raw counterparts by subtraction of pedestals and multiplication with calibration constants.

Definition at line 44 of file QwSIS3320_Channel.h.

Constructor & Destructor Documentation

QwSIS3320_Channel::QwSIS3320_Channel ( UInt_t  channel = 0,
TString  name = "auto" 
)
inline

Definition at line 48 of file QwSIS3320_Channel.h.

References InitializeChannel().

50  InitializeChannel(channel, name);
51  };
VQwDataElement()
Default constructor.
void InitializeChannel(UInt_t channel, TString name)

+ Here is the call graph for this function:

QwSIS3320_Channel::QwSIS3320_Channel ( const QwSIS3320_Channel source)
inline

Definition at line 52 of file QwSIS3320_Channel.h.

53  : VQwDataElement(source),MQwMockable(source),
54  fChannel(source.fChannel),
57  fPedestal(source.fPedestal),
62  fSamples(source.fSamples),
63  fSamplesRaw(source.fSamplesRaw),
66  fTimeWindows(source.fTimeWindows),
78  { }
std::vector< Double_t > fSampleWindowAverages
VQwDataElement()
Default constructor.
std::vector< QwSIS3320_Samples > fSamples
std::vector< QwSIS3320_Samples > fSamplesRaw
UInt_t fSampleFormat
Number of triggered events.
std::vector< QwSIS3320_Accumulator > fAccumulatorsRaw
std::vector< std::pair< UInt_t, UInt_t > > fTimeWindows
std::vector< QwSIS3320_Accumulator > fAccumulators
std::vector< Double_t > fTimeWindowAverages
QwSIS3320_Samples fAverageSamples
std::vector< std::pair< Double_t, Double_t > > fSampleWindows
UInt_t fNumberOfEvents
Current triggered event (allow for negative sentinel)
virtual QwSIS3320_Channel::~QwSIS3320_Channel ( )
inlinevirtual

Definition at line 79 of file QwSIS3320_Channel.h.

79 { };

Member Function Documentation

void QwSIS3320_Channel::AddLogicalAccumulator ( const TString  name,
const std::vector< TString >  accums,
const std::vector< Double_t >  weights 
)

Create a logical accumulator

Definition at line 756 of file QwSIS3320_Channel.cc.

References QwSIS3320_LogicalAccumulator::AddAccumulatorReference(), QwLog::endl(), fAccumulators, fLogicalAccumulators, VQwDataElement::GetElementName(), and QwWarning.

760 {
761  // Create new logical accumulator with requested name
762  QwSIS3320_LogicalAccumulator localLogAccum(GetElementName() + "_accum" + name);
763 
764  // Loop over all entries in this logical accumulator
765  for (size_t i = 0; i < accums.size(); i++) {
766 
767  // Find the accumulator with the correct name
768  size_t j;
769  for (j = 0; j < fAccumulators.size(); j++) {
770  if (accums[i] == fAccumulators[j].GetElementName())
771  break;
772  }
773  // Not found
774  if (j == fAccumulators.size()) {
775  QwWarning << "Logical accumulator " << name << " has undefined components: " << QwLog::endl;
776  QwWarning << accums[i] << " could not be found." << QwLog::endl;
777  return;
778  }
779 
780  // Add reference and weight
781  localLogAccum.AddAccumulatorReference(&(fAccumulators[j]),weights[i]);
782  }
783 
784  // Add logical accumulator to the list
785  fLogicalAccumulators.push_back(localLogAccum);
786 }
SIS3320 sampling ADC accumulator.
std::vector< QwSIS3320_LogicalAccumulator > fLogicalAccumulators
std::vector< QwSIS3320_Accumulator > fAccumulators
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.
#define QwWarning
Predefined log drain for warnings.
Definition: QwLog.h:45

+ Here is the call graph for this function:

void QwSIS3320_Channel::ClearEventData ( )
virtual

Clear the event data in sampling buffer and accumulators

Reimplemented from VQwDataElement.

Definition at line 118 of file QwSIS3320_Channel.cc.

References QwSIS3320_Samples::ClearEventData(), fAccumulators, fAccumulatorsRaw, fAverageSamples, fAverageSamplesRaw, fLogicalAccumulators, fSamples, and fSamplesRaw.

119 {
120  // Clear the sampled events
121  for (size_t i = 0; i < fSamples.size(); i++)
122  fSamples.at(i).ClearEventData();
123  fSamples.clear(); // and back to zero events
124  for (size_t i = 0; i < fSamplesRaw.size(); i++)
125  fSamplesRaw.at(i).ClearEventData();
126  fSamplesRaw.clear(); // and back to zero events
127  // Clear the average samples
130 
131  // Clear the accumulators
132  for (size_t i = 0; i < fAccumulators.size(); i++)
133  fAccumulators.at(i).ClearEventData();
134  for (size_t i = 0; i < fAccumulatorsRaw.size(); i++)
135  fAccumulatorsRaw.at(i).ClearEventData();
136  for (size_t i = 0; i < fLogicalAccumulators.size(); i++)
137  fLogicalAccumulators.at(i).ClearEventData();
138  // (the number of accumulators is constant, don't clear them)
139 }
std::vector< QwSIS3320_Samples > fSamples
std::vector< QwSIS3320_Samples > fSamplesRaw
std::vector< QwSIS3320_Accumulator > fAccumulatorsRaw
std::vector< QwSIS3320_LogicalAccumulator > fLogicalAccumulators
std::vector< QwSIS3320_Accumulator > fAccumulators
QwSIS3320_Samples fAverageSamples
QwSIS3320_Samples fAverageSamplesRaw

+ Here is the call graph for this function:

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

Definition at line 673 of file QwSIS3320_Channel.cc.

References fAccumulators, fAccumulatorsRaw, fLogicalAccumulators, fSamples, and VQwDataElement::GetElementName().

674 {
675  // Accumulators
676  for (size_t i = 0; i < fAccumulators.size(); i++) {
677  fAccumulators[i].ConstructBranchAndVector(tree, prefix, values);
678  fAccumulatorsRaw[i].ConstructBranchAndVector(tree, prefix, values);
679  }
680  // Logical Accumulators
681  for (size_t i = 0; i < fLogicalAccumulators.size(); i++)
682  fLogicalAccumulators[i].ConstructBranchAndVector(tree, prefix, values);
683 
684  // Samples (only collected when running over data, so structure does not
685  // actually exist yet at time of branch construction)
686  TString basename = prefix + GetElementName() + "_samples";
687  tree->Branch(basename, &fSamples);
688  //tree->Branch(basename + "_avg", &fAverageSamples);
689 }
std::vector< QwSIS3320_Samples > fSamples
std::vector< QwSIS3320_Accumulator > fAccumulatorsRaw
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
std::vector< QwSIS3320_LogicalAccumulator > fLogicalAccumulators
std::vector< QwSIS3320_Accumulator > fAccumulators
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

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

Construct the histograms for this data element.

Implements VQwDataElement.

Definition at line 615 of file QwSIS3320_Channel.cc.

References QwHistogramHelper::Construct1DHist(), fAccumulators, fAccumulatorsRaw, MQwHistograms::fHistograms, fLogicalAccumulators, VQwDataElement::GetElementName(), gQwHists, and VQwDataElement::IsNameEmpty().

616 {
617  // If we have defined a subdirectory in the ROOT file, then change into it.
618  if (folder != NULL) folder->cd();
619 
620  if (IsNameEmpty()) {
621  // This channel is not used, so skip filling the histograms.
622  } else {
623 
624  // Accumulators
625  for (size_t i = 0; i < fAccumulators.size(); i++) {
626  fAccumulators[i].ConstructHistograms(folder,prefix);
627  fAccumulatorsRaw[i].ConstructHistograms(folder,prefix);
628  }
629 
630  // Logical Accumulators
631  for (size_t i = 0; i < fLogicalAccumulators.size(); i++)
632  fLogicalAccumulators[i].ConstructHistograms(folder,prefix);
633 
634  TString basename = prefix + GetElementName();
635 
636  fHistograms.resize(3, NULL);
637  size_t index = 0;
638  fHistograms[index++] = gQwHists.Construct1DHist(basename+Form("_sum"));
639  fHistograms[index++] = gQwHists.Construct1DHist(basename+Form("_ped"));
640  fHistograms[index++] = gQwHists.Construct1DHist(basename+Form("_ped_raw"));
641  }
642 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
std::vector< TH1_ptr > fHistograms
Histograms associated with this data element.
Definition: MQwHistograms.h:46
void ConstructHistograms(TDirectory *folder, TString &prefix)
Construct the histograms for this data element.
std::vector< QwSIS3320_Accumulator > fAccumulatorsRaw
std::vector< QwSIS3320_LogicalAccumulator > fLogicalAccumulators
QwHistogramHelper gQwHists
Globally defined instance of the QwHistogramHelper class.
std::vector< QwSIS3320_Accumulator > fAccumulators
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 QwSIS3320_Channel::Difference ( QwSIS3320_Channel value1,
QwSIS3320_Channel value2 
)

Difference of two channels

Parameters
value1
value2

Definition at line 568 of file QwSIS3320_Channel.cc.

569 {
570  *this = value1;
571  *this -= value2;
572 }
void QwSIS3320_Channel::EncodeEventData ( std::vector< UInt_t > &  buffer)
virtual

Encode the event data into a CODA buffer.

Implements MQwMockable.

Definition at line 336 of file QwSIS3320_Channel.cc.

References fChannel, fNumberOfEvents, fSampleFormat, and VQwDataElement::IsNameEmpty().

337 {
338  // Long_t sample;
339  std::vector<UInt_t> header;
340  std::vector<UInt_t> samples;
341 
342  if (IsNameEmpty()) {
343  // This channel is not used, but is present in the data stream.
344  // Skip over this data.
345  } else {
346  header.push_back(fChannel); // Channel number
347  header.push_back(fSampleFormat); // Sample format (e.g. 0x20003)
348 // TODO
349 // header.push_back(fNumberOfSamples * fNumberOfEvents); // Total number of samples
350 // header.push_back(fNumberOfSamples); // Number of samples per event
351  header.push_back(fNumberOfEvents); // Number of events
352  // Data is stored with two short words per long word
353 // for (size_t i = 0; i < fSamplesRaw.size() / 2; i++) {
354 // sample = fSamplesRaw.at(2*i) << 16;
355 // sample |= fSamplesRaw.at(2*i+1);
356 // samples.push_back(sample);
357 // }
358 
359  for (size_t i = 0; i < header.size(); i++)
360  buffer.push_back(header.at(i));
361  for (size_t i = 0; i < samples.size(); i++)
362  buffer.push_back(samples.at(i));
363  }
364 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
UInt_t fSampleFormat
Number of triggered events.
UInt_t fNumberOfEvents
Current triggered event (allow for negative sentinel)

+ Here is the call graph for this function:

void QwSIS3320_Channel::FillHistograms ( )
virtual

Fill the histograms for this data element.

Implements VQwDataElement.

Definition at line 644 of file QwSIS3320_Channel.cc.

References fAccumulators, fAccumulatorsRaw, fAverageSamples, fAverageSamplesRaw, MQwHistograms::fHistograms, fLogicalAccumulators, fSamples, QwSIS3320_Samples::GetSample(), QwSIS3320_Samples::GetSum(), and VQwDataElement::IsNameEmpty().

645 {
646  size_t index = -1;
647  if (fSamples.size() == 0) return;
648 
649  if (IsNameEmpty()) {
650  // This channel is not used, so skip creating the histograms.
651  } else {
652 
653  // Accumulators
654  for (size_t i = 0; i < fAccumulators.size(); i++) {
655  fAccumulators[i].FillHistograms();
656  fAccumulatorsRaw[i].FillHistograms();
657  }
658 
659  // Logical Accumulators
660  for (size_t i = 0; i< fLogicalAccumulators.size(); i++ ) {
661  fLogicalAccumulators[i].FillHistograms();
662  }
663 
664  if (fHistograms[++index] != NULL)
665  fHistograms[index]->Fill(fAverageSamples.GetSum());
666  if (fHistograms[++index] != NULL)
667  fHistograms[index]->Fill(fAverageSamples.GetSample(0));
668  if (fHistograms[++index] != NULL)
669  fHistograms[index]->Fill(fAverageSamplesRaw.GetSample(0));
670  }
671 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
std::vector< QwSIS3320_Samples > fSamples
std::vector< TH1_ptr > fHistograms
Histograms associated with this data element.
Definition: MQwHistograms.h:46
std::vector< QwSIS3320_Accumulator > fAccumulatorsRaw
std::vector< QwSIS3320_LogicalAccumulator > fLogicalAccumulators
std::vector< QwSIS3320_Accumulator > fAccumulators
QwSIS3320_Samples fAverageSamples
QwSIS3320_Type GetSum() const
QwSIS3320_Samples fAverageSamplesRaw
QwSIS3320_Type GetSample(size_t i) const

+ Here is the call graph for this function:

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

Definition at line 691 of file QwSIS3320_Channel.cc.

References fAccumulators, fAccumulatorsRaw, and fLogicalAccumulators.

692 {
693  // Accumulators
694  for (size_t i = 0; i < fAccumulators.size(); i++) {
695  fAccumulators[i].FillTreeVector(values);
696  fAccumulatorsRaw[i].FillTreeVector(values);
697  }
698 
699  // Logical Accumulators
700  for (size_t i = 0; i < fLogicalAccumulators.size(); i++)
702 }
std::vector< QwSIS3320_Accumulator > fAccumulatorsRaw
std::vector< QwSIS3320_LogicalAccumulator > fLogicalAccumulators
void FillTreeVector(std::vector< Double_t > &values) const
std::vector< QwSIS3320_Accumulator > fAccumulators
Double_t QwSIS3320_Channel::GetCalibrationFactor ( ) const
inline

Definition at line 136 of file QwSIS3320_Channel.h.

References fCalibrationFactor.

136 { return fCalibrationFactor; };
size_t QwSIS3320_Channel::GetNumberOfAccumulators ( ) const
inline

Definition at line 126 of file QwSIS3320_Channel.h.

References fNumberOfAccumulators.

126 { return (fNumberOfAccumulators); };
size_t QwSIS3320_Channel::GetNumberOfEvents ( ) const
inline

Definition at line 119 of file QwSIS3320_Channel.h.

References fNumberOfEvents.

Referenced by PrintInfo(), PrintValue(), and ProcessEvBuffer().

119 { return (fNumberOfEvents); };
UInt_t fNumberOfEvents
Current triggered event (allow for negative sentinel)

+ Here is the caller graph for this function:

Double_t QwSIS3320_Channel::GetPedestal ( ) const
inline

Definition at line 134 of file QwSIS3320_Channel.h.

References fPedestal.

134 { return fPedestal; };
QwSIS3320_Samples& QwSIS3320_Channel::GetSamples ( size_t  i)
inline

Definition at line 116 of file QwSIS3320_Channel.h.

References fSamples.

116 { return fSamples.at(i); };
std::vector< QwSIS3320_Samples > fSamples
QwSIS3320_Samples& QwSIS3320_Channel::GetSamplesRaw ( size_t  i)
inline

Definition at line 117 of file QwSIS3320_Channel.h.

References fSamplesRaw.

117 { return fSamplesRaw.at(i); };
std::vector< QwSIS3320_Samples > fSamplesRaw
void QwSIS3320_Channel::InitializeChannel ( UInt_t  channel,
TString  name 
)

Initialize the QwSIS3320_Channel by assigning it a name

Parameters
channelNumber of the channel
nameName for the channel

Definition at line 59 of file QwSIS3320_Channel.cc.

References QwSIS3320_Samples::ClearEventData(), fAccumulators, fAccumulatorsRaw, fAverageSamples, fAverageSamplesRaw, fCalibrationFactor, fChannel, fCurrentEvent, fHasAccumulatorData, fHasSamplingData, MQwMockable::fMockAsymmetry, MQwMockable::fMockGaussianMean, MQwMockable::fMockGaussianSigma, fPedestal, fSamples, fSamplesRaw, VQwDataElement::GetElementName(), VQwDataElement::SetElementName(), and VQwDataElement::SetNumberOfDataWords().

Referenced by QwSIS3320_Channel().

60 {
61  // Inherited from VQwDataElement
62  SetElementName(name);
64 
65  // Set channel number
66  fChannel = channel;
67 
68  // Set accumulator names
69  for (size_t i = 0; i < fAccumulators.size(); i++) {
70  TString name = GetElementName() + TString("_accum") + Form("%ld",i);
71  fAccumulators[i].SetElementName(name);
72  fAccumulatorsRaw[i].SetElementName(name + "_raw");
73  }
74 
75  // Start with zero samples
76  fSamples.clear(); fSamplesRaw.clear();
77  // Clear the average samples
80 
81  // Enabled by MMD
82  //for (size_t i = 0; i < fSamples.size(); i++) {
83  // TString name = GetElementName() + TString("_samples") + Form("%ld",i);
84  // fSamples[i].SetElementName(name);
85  // fSamplesRaw[i].SetElementName(name + "_raw");
86  //}
87 
88  // Default values when no event read yet
89  fCurrentEvent = -1;
90  fHasSamplingData = kFALSE;
91  fHasAccumulatorData = kFALSE;
92 
93  // Pedestal calibration
94  fPedestal = 0.0;
95  fCalibrationFactor = 1.0;
96 
97  // Mock data parameters
98  fMockAsymmetry = 0.0;
99  fMockGaussianMean = 0.0;
100  fMockGaussianSigma = 0.0;
101 }
std::vector< QwSIS3320_Samples > fSamples
std::vector< QwSIS3320_Samples > fSamplesRaw
Double_t fMockGaussianSigma
Sigma of normal distribution.
Definition: MQwMockable.h:93
std::vector< QwSIS3320_Accumulator > fAccumulatorsRaw
Double_t fMockGaussianMean
Mean of normal distribution.
Definition: MQwMockable.h:92
void SetElementName(const TString &name)
Set the name of this element.
Double_t fMockAsymmetry
Helicity asymmetry.
Definition: MQwMockable.h:91
void SetNumberOfDataWords(const UInt_t &numwords)
Set the number of data words in this data element.
std::vector< QwSIS3320_Accumulator > fAccumulators
QwSIS3320_Samples fAverageSamples
virtual const TString & GetElementName() const
Get the name of this element.
QwSIS3320_Samples fAverageSamplesRaw

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Bool_t QwSIS3320_Channel::IsGoodEvent ( )

Check whether the event is a good event from the number of read samples

Returns
kTRUE if samples have been read

Definition at line 107 of file QwSIS3320_Channel.cc.

References fSamples.

108 {
109  Bool_t fEventIsGood = kTRUE;
110  for (size_t i = 0; i < fSamples.size(); i++)
111  fEventIsGood &= (fSamples[i].GetNumberOfSamples() > 0);
112  return fEventIsGood;
113 }
std::vector< QwSIS3320_Samples > fSamples
void QwSIS3320_Channel::Offset ( Double_t  offset)

Addition of a offset

Parameters
offset

Definition at line 589 of file QwSIS3320_Channel.cc.

References fAccumulators, fSamples, and VQwDataElement::IsNameEmpty().

590 {
591  if (!IsNameEmpty()) {
592  for (size_t i = 0; i < fSamples.size(); i++)
593  fSamples[i] += offset;
594  for (size_t i = 0; i < fAccumulators.size(); i++)
595  fAccumulators[i] += offset;
596  }
597 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
std::vector< QwSIS3320_Samples > fSamples
std::vector< QwSIS3320_Accumulator > fAccumulators

+ Here is the call graph for this function:

const QwSIS3320_Channel QwSIS3320_Channel::operator+ ( const Double_t &  value) const

Addition of offset

Parameters
valueRight-hand side
Returns
Left-hand side

Definition at line 418 of file QwSIS3320_Channel.cc.

419 {
420  QwSIS3320_Channel result = *this;
421  result += value;
422  return result;
423 }
Class for the decoding of the SIS3320 sampling ADC data.
const QwSIS3320_Channel QwSIS3320_Channel::operator+ ( const QwSIS3320_Channel value) const

Addition

Parameters
valueRight-hand side
Returns
Left-hand side

Definition at line 442 of file QwSIS3320_Channel.cc.

443 {
444  QwSIS3320_Channel result = *this;
445  result += value;
446  return result;
447 }
Class for the decoding of the SIS3320 sampling ADC data.
QwSIS3320_Channel & QwSIS3320_Channel::operator+= ( const Double_t &  value)

Addition assignment of offset

Parameters
valueRight-hand side
Returns
Left-hand side

Definition at line 485 of file QwSIS3320_Channel.cc.

References fAccumulators, fLogicalAccumulators, fSamples, and VQwDataElement::IsNameEmpty().

486 {
487  if (!IsNameEmpty()) {
488  for (size_t i = 0; i < fSamples.size(); i++)
489  fSamples[i] += value;
490  for (size_t i = 0; i < fAccumulators.size(); i++)
491  fAccumulators[i] += value;
492  for (size_t i = 0; i < fLogicalAccumulators.size(); i++)
493  fLogicalAccumulators[i] += value;
494  }
495  return *this;
496 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
std::vector< QwSIS3320_Samples > fSamples
std::vector< QwSIS3320_LogicalAccumulator > fLogicalAccumulators
std::vector< QwSIS3320_Accumulator > fAccumulators

+ Here is the call graph for this function:

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

Addition assignment

Parameters
valueRight-hand side
Returns
Left-hand side

Definition at line 521 of file QwSIS3320_Channel.cc.

References fAccumulators, fLogicalAccumulators, fSamples, and VQwDataElement::IsNameEmpty().

522 {
523  if (!IsNameEmpty()) {
524  for (size_t i = 0; i < fSamples.size(); i++)
525  fSamples[i] += value.fSamples.at(i);
526  for (size_t i = 0; i < fAccumulators.size(); i++)
527  fAccumulators[i] += value.fAccumulators.at(i);
528  for (size_t i = 0; i < fLogicalAccumulators.size(); i++)
529  fLogicalAccumulators[i] += value.fLogicalAccumulators.at(i);
530  }
531  return *this;
532 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
std::vector< QwSIS3320_Samples > fSamples
std::vector< QwSIS3320_LogicalAccumulator > fLogicalAccumulators
std::vector< QwSIS3320_Accumulator > fAccumulators

+ Here is the call graph for this function:

const QwSIS3320_Channel QwSIS3320_Channel::operator- ( const Double_t &  value) const

Subtraction of offset

Parameters
valueRight-hand side
Returns
Left-hand side

Definition at line 430 of file QwSIS3320_Channel.cc.

431 {
432  QwSIS3320_Channel result = *this;
433  result -= value;
434  return result;
435 }
Class for the decoding of the SIS3320 sampling ADC data.
const QwSIS3320_Channel QwSIS3320_Channel::operator- ( const QwSIS3320_Channel value) const

Subtraction

Parameters
valueRight-hand side
Returns
Left-hand side

Definition at line 454 of file QwSIS3320_Channel.cc.

455 {
456  QwSIS3320_Channel result = *this;
457  result -= value;
458  return result;
459 }
Class for the decoding of the SIS3320 sampling ADC data.
QwSIS3320_Channel & QwSIS3320_Channel::operator-= ( const Double_t &  value)

Subtraction assignment of offset

Parameters
valueRight-hand side
Returns
Left-hand side

Definition at line 503 of file QwSIS3320_Channel.cc.

References fAccumulators, fLogicalAccumulators, fSamples, and VQwDataElement::IsNameEmpty().

504 {
505  if (!IsNameEmpty()) {
506  for (size_t i = 0; i < fSamples.size(); i++)
507  fSamples[i] -= value;
508  for (size_t i = 0; i < fAccumulators.size(); i++)
509  fAccumulators[i] -= value;
510  for (size_t i = 0; i < fLogicalAccumulators.size(); i++)
511  fLogicalAccumulators[i] -= value;
512  }
513  return *this;
514 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
std::vector< QwSIS3320_Samples > fSamples
std::vector< QwSIS3320_LogicalAccumulator > fLogicalAccumulators
std::vector< QwSIS3320_Accumulator > fAccumulators

+ Here is the call graph for this function:

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

Subtraction assignment

Parameters
valueRight-hand side
Returns
Left-hand side

Definition at line 539 of file QwSIS3320_Channel.cc.

References fAccumulators, fLogicalAccumulators, fSamples, and VQwDataElement::IsNameEmpty().

540 {
541  if (!IsNameEmpty()) {
542  for (size_t i = 0; i < fSamples.size(); i++)
543  fSamples[i] -= value.fSamples.at(i);
544  for (size_t i = 0; i < fAccumulators.size(); i++)
545  fAccumulators[i] -= value.fAccumulators.at(i);
546  for (size_t i = 0; i < fLogicalAccumulators.size(); i++)
547  fLogicalAccumulators[i] -= value.fLogicalAccumulators.at(i);
548  }
549  return *this;
550 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
std::vector< QwSIS3320_Samples > fSamples
std::vector< QwSIS3320_LogicalAccumulator > fLogicalAccumulators
std::vector< QwSIS3320_Accumulator > fAccumulators

+ Here is the call graph for this function:

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

Assignment

Parameters
valueRight-hand side
Returns
Left-hand side

Definition at line 466 of file QwSIS3320_Channel.cc.

References fAccumulators, fLogicalAccumulators, fSamples, and VQwDataElement::IsNameEmpty().

467 {
468  if (!IsNameEmpty()) {
469  for (size_t i = 0; i < fSamples.size(); i++)
470  fSamples[i] = value.fSamples.at(i);
471  for (size_t i = 0; i < fAccumulators.size(); i++ ) {
472  fAccumulators[i] = value.fAccumulators.at(i);
473  }
474  for (size_t i = 0; i < fLogicalAccumulators.size(); i++ )
476  }
477  return *this;
478 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
std::vector< QwSIS3320_Samples > fSamples
std::vector< QwSIS3320_LogicalAccumulator > fLogicalAccumulators
std::vector< QwSIS3320_Accumulator > fAccumulators

+ Here is the call graph for this function:

void QwSIS3320_Channel::PrintInfo ( ) const
virtual

Print some debugging information about the QwSIS3320_Channel

Reimplemented from VQwDataElement.

Definition at line 723 of file QwSIS3320_Channel.cc.

References QwLog::endl(), fAccumulators, fAccumulatorsRaw, fAverageSamples, fAverageSamplesRaw, fLogicalAccumulators, fSamples, fSamplesRaw, VQwDataElement::GetElementName(), GetNumberOfEvents(), QwSIS3320_Samples::GetSum(), QwSIS3320_Samples::GetSumInTimeWindow(), and QwOut.

724 {
725  QwOut << "QwSIS3320_Channel \"" << GetElementName() << "\":" << QwLog::endl;
726  QwOut << "Number of events: " << GetNumberOfEvents() << QwLog::endl;
727  QwOut << "fSamplesRaw:" << QwLog::endl;
728  for (size_t i = 0; i < fSamplesRaw.size(); i++) {
729  QwOut << "event " << i << ": " << fSamplesRaw.at(i) << QwLog::endl;
730  }
731  QwOut << "avg: " << fAverageSamplesRaw << QwLog::endl;
732  QwOut << "avg sum: " << fAverageSamplesRaw.GetSum() << QwLog::endl;
733  QwOut << "fSamples:" << QwLog::endl;
734  for (size_t i = 0; i < fSamples.size(); i++) {
735  QwOut << "event " << i << ": " << fSamples.at(i) << QwLog::endl;
736  }
737  QwOut << "avg: " << fAverageSamples << QwLog::endl;
738  QwOut << "avg sum: " << fAverageSamples.GetSum() << QwLog::endl;
739  QwOut << "fAccumulators -> fAccumulatorsRaw:" << QwLog::endl;
740  for (size_t i = 0; i < fAccumulators.size(); i++) {
741  QwOut << i << ": " << fAccumulatorsRaw.at(i) << " -> " << fAccumulators.at(i) << QwLog::endl;
742  }
743  QwOut << "fLogicalAccumulators:" << QwLog::endl;
744  for (size_t i = 0; i < fLogicalAccumulators.size(); i++) {
745  QwOut << i << ": " << fLogicalAccumulators.at(i) << QwLog::endl;
746  }
747  UInt_t nped = 10;
748  if (fSamplesRaw.size() > 0) {
749  QwOut << "Average pedestal is: " << fAverageSamplesRaw.GetSumInTimeWindow(0, nped) / (Double_t) nped << QwLog::endl;
750  }
751 }
#define QwOut
Predefined log drain for explicit output.
Definition: QwLog.h:35
std::vector< QwSIS3320_Samples > fSamples
std::vector< QwSIS3320_Samples > fSamplesRaw
size_t GetNumberOfEvents() const
std::vector< QwSIS3320_Accumulator > fAccumulatorsRaw
std::vector< QwSIS3320_LogicalAccumulator > fLogicalAccumulators
QwSIS3320_Type GetSumInTimeWindow(const UInt_t start, const UInt_t stop) const
std::vector< QwSIS3320_Accumulator > fAccumulators
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
QwSIS3320_Samples fAverageSamples
virtual const TString & GetElementName() const
Get the name of this element.
QwSIS3320_Type GetSum() const
QwSIS3320_Samples fAverageSamplesRaw

+ Here is the call graph for this function:

void QwSIS3320_Channel::PrintValue ( ) const
virtual

Print value of the QwSIS3320_Channel

Reimplemented from VQwDataElement.

Definition at line 707 of file QwSIS3320_Channel.cc.

References QwLog::endl(), fAccumulators, fLogicalAccumulators, VQwDataElement::GetElementName(), GetNumberOfEvents(), and QwMessage.

708 {
709  QwMessage << std::setprecision(4)
710  << std::setw(18) << std::left << GetElementName() << ", "
711  << std::setw(15) << std::left << GetNumberOfEvents();
712  for (size_t i = 0; i < fAccumulators.size(); i++)
713  QwMessage << ", " << i << ":" << fAccumulators[i].GetAccumulatorSum();
714  for (size_t i = 0; i < fLogicalAccumulators.size(); i++)
715  QwMessage << ", " << i << ":" << fLogicalAccumulators[i].GetAccumulatorSum();
717 }
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
size_t GetNumberOfEvents() const
std::vector< QwSIS3320_LogicalAccumulator > fLogicalAccumulators
std::vector< QwSIS3320_Accumulator > fAccumulators
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.

+ Here is the call graph for this function:

Int_t QwSIS3320_Channel::ProcessEvBuffer ( UInt_t *  buffer,
UInt_t  num_words_left,
UInt_t  index = 0 
)
virtual

Extract the sampling and accumulator data from the CODA buffer

Parameters
bufferInput buffer
num_words_leftNumber of words left in the input buffer
indexStarting position in the buffer
Returns
Number of words processed in this method

Implements VQwDataElement.

Definition at line 148 of file QwSIS3320_Channel.cc.

References QwLog::endl(), fAccumulatorDAC, fAccumulatorsRaw, fAccumulatorThreshold1, fAccumulatorThreshold2, fAccumulatorTimingAfter5, fAccumulatorTimingAfter6, fAccumulatorTimingBefore5, fAccumulatorTimingBefore6, fChannel, fHasAccumulatorData, fHasSamplingData, VQwDataElement::fNumberOfDataWords, FORMAT_ACCUMULATOR, FORMAT_LONG_WORD_SAMPLING, FORMAT_SHORT_WORD_SAMPLING, fSamplesRaw, GetNumberOfEvents(), VQwDataElement::IsNameEmpty(), kDEBUG, MODE_ACCUM_EVENT, MODE_MULTI_EVENT, MODE_NOTREADY, MODE_SINGLE_EVENT, QwError, QwOut, QwWarning, and SetNumberOfEvents().

149 {
150  UInt_t words_read = 0;
151 
152  if (IsNameEmpty()) {
153  // This channel is not used, but is present in the data stream.
154  // Skip over this data.
155  words_read = fNumberOfDataWords;
156  } else if (num_words_left >= fNumberOfDataWords) {
157 
158  // The first word of the buffer is in the format: 0xFADC/id/ch/, where id
159  // is the module identification, and ch the channel number in that module.
160 
161  // Check whether the first word has 0xFADC as the upper half
162  UInt_t local_tag = (buffer[0] >> 16) & 0xFFFF;
163  if (local_tag != 0xFADC) return words_read;
164 
165  // Check whether the first word contains the correct channel number
166  //UInt_t local_module = (buffer[0] >> 8) & 0xFF;
167  UInt_t local_channel = buffer[0] & 0xFF;
168 
169  if (local_channel != fChannel) return words_read;
170 
171  // Determine whether we are receiving a sampling or accumulator buffer:
172  // Most significant short word (upper half):
173  // - 0x0 in accumulator mode
174  // - 0x1 when an expanded sampling buffer follows (12-bit sample / 32-bit word)
175  // - 0x2 when a packed sampling buffer follows (2 * 12-bit samples / 32-bit word)
176  // Least significant short word (lower half): 0x/stop mode/setup mode/ where
177  // - stop mode is 1 for hardware trigger
178  // - setup mode is 1,2,3,4...
179  UInt_t local_format = (buffer[1] >> 16) & 0xFFFF;
180  //UInt_t local_stopmode = (buffer[1] >> 8) & 0xFF;
181 
182  UInt_t local_setupmode = (buffer[1]) & 0xFF;
183  words_read = 2;
184  UInt_t packedtiming; // locals declared outside of switch/case
185  switch (local_format) {
186 
187  // This is a sampling buffer using long words
189  QwWarning << "QwSIS3320_Channel: Expanded word format not implemented"
190  << QwLog::endl;
191  break; // end of FORMAT_LONG_WORD_SAMPLING
192 
193  // This is a sampling buffer using short words
195  UInt_t numberofsamples, numberofevents_expected, numberofevents_actual;
196  UInt_t samplepointer;
197  switch (local_setupmode) {
198 
199  // This is a sampling buffer in multi event mode:
200  // - many events are saved in one buffer for a complete helicity event
201  case MODE_ACCUM_EVENT:
202  case MODE_MULTI_EVENT:
203  samplepointer = buffer[2];
204  numberofsamples = buffer[3];
205  numberofevents_expected = buffer[4];
206  words_read = 5;
207 
208  // For all events in this buffer
209  SetNumberOfEvents(numberofevents_expected);
210  numberofevents_actual = 0; // double check while reading the events
211  for (size_t event = 0; event < GetNumberOfEvents(); event++) {
212  // create a new raw sampled event
213  fSamplesRaw[event].SetNumberOfSamples(numberofsamples);
214  fSamplesRaw[event].SetSamplePointer(samplepointer);
215  // pass the buffer to read the samples
216  UInt_t samples_read = fSamplesRaw[event].ProcessEvBuffer(&(buffer[words_read]), num_words_left-words_read);
217  // check whether we actually read any data
218  if (samples_read == 0) break;
219  // an actual sampled event was read
220  words_read += samples_read;
221  numberofevents_actual++;
222  if (kDEBUG) QwOut << "Samples " << event << ": " << fSamplesRaw[event] << QwLog::endl;
223  }
224  if (numberofevents_expected != numberofevents_actual) {
225  QwWarning << "QwSIS3320_Channel: Expected " << numberofevents_expected << " events, "
226  << "but only read " << numberofevents_actual << "." << QwLog::endl;
227  SetNumberOfEvents(numberofevents_actual);
228  }
229 
230  break;
231 
232  // This is a sampling buffer in single event mode:
233  // - one event only is saved in the buffer, and each event triggers
234  // a read-out so multiple event can occur in one helicity period
235  // - because a circular buffer is used the pointer to the last sample
236  // is stored
237  case MODE_SINGLE_EVENT:
238  samplepointer = buffer[2];
239  numberofsamples = buffer[3];
240  numberofevents_expected = 1;
241 
242  // Create a new raw sampled event
243  SetNumberOfEvents(numberofevents_expected);
244  // Pass the buffer to read the samples (only one event)
245  fSamplesRaw.at(0).SetNumberOfSamples(numberofsamples);
246  fSamplesRaw.at(0).SetSamplePointer(samplepointer);
247  fSamplesRaw.at(0).ProcessEvBuffer(buffer, num_words_left, samplepointer);
248 
249  break;
250 
251  // Default
252  default:
253  QwError << "QwSIS3320_Channel: Received unknown sampling format: "
254  << std::hex << local_setupmode << std::dec << "." << QwLog::endl;
255  words_read = 0;
256  return words_read;
257 
258  } // end of switch (local_setupmode)
259 
260  fHasSamplingData = kTRUE;
261  break; // end of FORMAT_SHORT_WORD_SAMPLING
262 
263  // This is an accumulator buffer
264  case FORMAT_ACCUMULATOR:
265 
266  // Definition of the accumulators: (numbered from 1)
267  // 1: digital sum of all samples in the event
268  //
269  // 2: threshold 1 < sample value
270  // 3: threshold 2 < sample value <= threshold 1
271  // 4: sample value <= threshold 2
272  // Test: 1 == 2 + 3 + 4
273  //
274  // 6: sample value <= threshold 2
275  // and add samples before and after
276  // 5: threshold 2 < sample value <= threshold 1
277  // and add samples before and after
278  // but samples added in accumulator 6 are not added to accumulator 5
279 
280  // Read the accumulator blocks
281  for (size_t i = 0; i < fAccumulatorsRaw.size(); i++) {
282  words_read += fAccumulatorsRaw[i].ProcessEvBuffer(&(buffer[words_read]), num_words_left-words_read);
283  if (kDEBUG) QwOut << "Accum " << i+1 << ": " << fAccumulatorsRaw[i] << QwLog::endl;
284  }
285  // Read the threshold information
286  fAccumulatorDAC = buffer[words_read++];
287  // Thresholds are maximum 12 bits, so they seem to have wasted a word here :-)
288  fAccumulatorThreshold1 = buffer[words_read++];
289  fAccumulatorThreshold2 = buffer[words_read++];
290  // Read the timing information, packed in one word
291  packedtiming = buffer[words_read++];
292  fAccumulatorTimingAfter6 = (packedtiming >>= 8) & 0xFF;
293  fAccumulatorTimingBefore6 = (packedtiming >>= 8) & 0xFF;
294  fAccumulatorTimingAfter5 = (packedtiming >>= 8) & 0xFF;
295  fAccumulatorTimingBefore5 = (packedtiming >>= 8) & 0xFF;
296  if (kDEBUG) {
297  QwOut << "DAC: " << fAccumulatorDAC << QwLog::endl;
298  QwOut << "Thresholds: " << fAccumulatorThreshold1 << ", "
300  QwOut << "Timings on accum 5: " << fAccumulatorTimingAfter5 << ", "
302  QwOut << "Timings on accum 6: " << fAccumulatorTimingAfter6 << ", "
304  }
305  if (kDEBUG) {
306  QwSIS3320_Accumulator sum("sum");
308  QwOut << "Accum 1: " << fAccumulatorsRaw[0] << QwLog::endl;
309  QwOut << "Accum 2 + 3 + 4: " << sum << QwLog::endl;
310  }
311 
312  fHasAccumulatorData = kTRUE;
313  break; // end of FORMAT_ACCUMULATOR
314 
315  // This is an incomplete buffer
316  case MODE_NOTREADY:
317  QwError << "QwSIS3320_Channel: SIS3320 was not ready yet!" << QwLog::endl;
318  break; // end of FORMAT_NOTREADY
319 
320  // Default
321  default:
322  QwError << "QwSIS3320_Channel: Received unknown mode: "
323  << std::hex << local_format << std::dec << "." << QwLog::endl;
324  words_read = 0;
325  return words_read;
326 
327  } // end of switch (local_format)
328 
329  } else {
330  QwError << "QwSIS3320_Channel: Not enough words while processing buffer!" << QwLog::endl;
331  }
332 
333  return words_read;
334 }
static const Bool_t kDEBUG
#define QwOut
Predefined log drain for explicit output.
Definition: QwLog.h:35
static const unsigned int MODE_MULTI_EVENT
static const unsigned int FORMAT_ACCUMULATOR
Bool_t IsNameEmpty() const
Is the name of this element empty?
SIS3320 sampling ADC accumulator.
std::vector< QwSIS3320_Samples > fSamplesRaw
static const unsigned int MODE_SINGLE_EVENT
static const unsigned int FORMAT_SHORT_WORD_SAMPLING
size_t GetNumberOfEvents() const
static const unsigned int FORMAT_LONG_WORD_SAMPLING
std::vector< QwSIS3320_Accumulator > fAccumulatorsRaw
void SetNumberOfEvents(UInt_t nevents)
UInt_t fNumberOfDataWords
Number of raw data words in this data element.
static const unsigned int MODE_ACCUM_EVENT
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
#define QwWarning
Predefined log drain for warnings.
Definition: QwLog.h:45
static const unsigned int MODE_NOTREADY
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

void QwSIS3320_Channel::ProcessEvent ( )

Process the event by removing pedestals and applying calibration

Definition at line 369 of file QwSIS3320_Channel.cc.

References fAccumulators, fAccumulatorsRaw, fAverageSamples, fAverageSamplesRaw, fCalibrationFactor, fLogicalAccumulators, fPedestal, fSamples, fSamplesRaw, fTimeWindowAverages, fTimeWindows, and QwSIS3320_Samples::SetNumberOfSamples().

370 {
371  // Correct for pedestal and calibration factor
372  if (fSamplesRaw.size() > 0) fSamples.resize(fSamplesRaw.size(), fSamplesRaw[0]);
373  for (size_t i = 0; i < fSamplesRaw.size(); i++) {
374  fSamples[i] = fSamplesRaw[i];
375  fSamples[i] -= fPedestal;
377  fSamples[i].UpdateGraph();
378  }
379  for (size_t i = 0; i < fAccumulatorsRaw.size(); i++) {
381  fAccumulators[i] -= fPedestal * fAccumulatorsRaw[i].GetNumberOfSamples();
383  }
384 
385  for (size_t i = 0; i < fLogicalAccumulators.size(); i++) {
386  fLogicalAccumulators[i].ProcessEvent();
387  }
388 
389  // Calculate the average sample snapshot
390  if (fSamples.size() > 0) {
391  fAverageSamples.SetNumberOfSamples(fSamples[0].GetNumberOfSamples());
392  fAverageSamplesRaw.SetNumberOfSamples(fSamples[0].GetNumberOfSamples());
393  }
394  for (size_t i = 0; i < fSamples.size(); i++) {
397  }
398  if (fSamples.size() > 0) {
399  fAverageSamples /= fSamples.size();
401  }
402 
403  // Calculate the windowed sample sums
404  for (size_t i = 0; i < fSamples.size(); i++) {
405  for (size_t timewindow = 0; timewindow < fTimeWindows.size(); timewindow++) {
406  UInt_t start = fTimeWindows[timewindow].first;
407  UInt_t stop = fTimeWindows[timewindow].second;
408  fTimeWindowAverages[timewindow] += fSamples[i].GetSumInTimeWindow(start, stop);
409  }
410  }
411 }
std::vector< QwSIS3320_Samples > fSamples
std::vector< QwSIS3320_Samples > fSamplesRaw
std::vector< QwSIS3320_Accumulator > fAccumulatorsRaw
std::vector< std::pair< UInt_t, UInt_t > > fTimeWindows
void SetNumberOfSamples(const UInt_t nsamples)
std::vector< QwSIS3320_LogicalAccumulator > fLogicalAccumulators
std::vector< QwSIS3320_Accumulator > fAccumulators
std::vector< Double_t > fTimeWindowAverages
QwSIS3320_Samples fAverageSamples
QwSIS3320_Samples fAverageSamplesRaw

+ Here is the call graph for this function:

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

Internally generate random event data.

Implements MQwMockable.

Definition at line 89 of file QwSIS3320_Channel.h.

89 { };
void QwSIS3320_Channel::Ratio ( QwSIS3320_Channel numer,
QwSIS3320_Channel denom 
)

Definition at line 574 of file QwSIS3320_Channel.cc.

References fAccumulators, fLogicalAccumulators, and VQwDataElement::IsNameEmpty().

575 {
576  if (!IsNameEmpty()) {
577  for (size_t i = 0; i < fAccumulators.size(); i++)
578  fAccumulators[i].Ratio(numer.fAccumulators[i],denom.fAccumulators[i]);
579  for (size_t i = 0; i < fLogicalAccumulators.size(); i++)
581  denom.fLogicalAccumulators[i]);
582  }
583 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
std::vector< QwSIS3320_LogicalAccumulator > fLogicalAccumulators
void Ratio(QwSIS3320_Channel &numer, QwSIS3320_Channel &denom)
std::vector< QwSIS3320_Accumulator > fAccumulators

+ Here is the call graph for this function:

void QwSIS3320_Channel::Scale ( Double_t  scale)

Scaling by a scale factor

Parameters
scale

Definition at line 603 of file QwSIS3320_Channel.cc.

References fAccumulators, fLogicalAccumulators, fSamples, and VQwDataElement::IsNameEmpty().

604 {
605  if (!IsNameEmpty()) {
606  for (size_t i = 0; i < fSamples.size(); i++)
607  fSamples[i] *= scale;
608  for (size_t i = 0; i < fAccumulators.size(); i++)
609  fAccumulators[i] *= scale;
610  for (size_t i = 0; i < fLogicalAccumulators.size(); i++)
611  fLogicalAccumulators[i] *= scale;
612  }
613 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
std::vector< QwSIS3320_Samples > fSamples
std::vector< QwSIS3320_LogicalAccumulator > fLogicalAccumulators
std::vector< QwSIS3320_Accumulator > fAccumulators

+ Here is the call graph for this function:

void QwSIS3320_Channel::SetCalibrationFactor ( const Double_t  factor)
inline

Definition at line 135 of file QwSIS3320_Channel.h.

References fCalibrationFactor.

135 { fCalibrationFactor = factor; };
void QwSIS3320_Channel::SetNumberOfAccumulators ( UInt_t  naccumulators)
inline

Definition at line 127 of file QwSIS3320_Channel.h.

References fAccumulators, fAccumulatorsRaw, and fNumberOfAccumulators.

127  {
128  fNumberOfAccumulators = naccumulators;
129  fAccumulatorsRaw.resize(naccumulators);
130  fAccumulators.resize(naccumulators);
131  };
std::vector< QwSIS3320_Accumulator > fAccumulatorsRaw
std::vector< QwSIS3320_Accumulator > fAccumulators
void QwSIS3320_Channel::SetNumberOfEvents ( UInt_t  nevents)
inline

Definition at line 120 of file QwSIS3320_Channel.h.

References fNumberOfEvents, fSamples, and fSamplesRaw.

Referenced by ProcessEvBuffer().

120  {
121  fNumberOfEvents = nevents;
122  fSamplesRaw.resize(nevents);
123  fSamples.resize(nevents);
124  };
std::vector< QwSIS3320_Samples > fSamples
std::vector< QwSIS3320_Samples > fSamplesRaw
UInt_t fNumberOfEvents
Current triggered event (allow for negative sentinel)

+ Here is the caller graph for this function:

void QwSIS3320_Channel::SetPedestal ( const Double_t  ped)
inline

Definition at line 133 of file QwSIS3320_Channel.h.

References fPedestal.

133 { fPedestal = ped; };
void QwSIS3320_Channel::Sum ( QwSIS3320_Channel value1,
QwSIS3320_Channel value2 
)

Sum of two channels

Parameters
value1
value2

Definition at line 557 of file QwSIS3320_Channel.cc.

558 {
559  *this = value1;
560  *this += value2;
561 }

Field Documentation

Int_t QwSIS3320_Channel::fAccumulatorDAC
private

Definition at line 176 of file QwSIS3320_Channel.h.

Referenced by ProcessEvBuffer().

Int_t QwSIS3320_Channel::fAccumulatorThreshold1
private

Definition at line 177 of file QwSIS3320_Channel.h.

Referenced by ProcessEvBuffer().

Int_t QwSIS3320_Channel::fAccumulatorThreshold2
private

Definition at line 177 of file QwSIS3320_Channel.h.

Referenced by ProcessEvBuffer().

Int_t QwSIS3320_Channel::fAccumulatorTimingAfter5
private

Definition at line 178 of file QwSIS3320_Channel.h.

Referenced by ProcessEvBuffer().

Int_t QwSIS3320_Channel::fAccumulatorTimingAfter6
private

Definition at line 179 of file QwSIS3320_Channel.h.

Referenced by ProcessEvBuffer().

Int_t QwSIS3320_Channel::fAccumulatorTimingBefore5
private

Definition at line 178 of file QwSIS3320_Channel.h.

Referenced by ProcessEvBuffer().

Int_t QwSIS3320_Channel::fAccumulatorTimingBefore6
private

Definition at line 179 of file QwSIS3320_Channel.h.

Referenced by ProcessEvBuffer().

QwSIS3320_Samples QwSIS3320_Channel::fAverageSamples
private
QwSIS3320_Samples QwSIS3320_Channel::fAverageSamplesRaw
private
Double_t QwSIS3320_Channel::fCalibrationFactor
private
UInt_t QwSIS3320_Channel::fChannel
private

Definition at line 148 of file QwSIS3320_Channel.h.

Referenced by EncodeEventData(), InitializeChannel(), and ProcessEvBuffer().

Int_t QwSIS3320_Channel::fCurrentEvent
private

Definition at line 159 of file QwSIS3320_Channel.h.

Referenced by InitializeChannel().

Bool_t QwSIS3320_Channel::fHasAccumulatorData
private

Definition at line 150 of file QwSIS3320_Channel.h.

Referenced by InitializeChannel(), and ProcessEvBuffer().

Bool_t QwSIS3320_Channel::fHasSamplingData
private

Definition at line 149 of file QwSIS3320_Channel.h.

Referenced by InitializeChannel(), and ProcessEvBuffer().

Int_t QwSIS3320_Channel::fNumberOfAccumulators
private

Definition at line 175 of file QwSIS3320_Channel.h.

Referenced by GetNumberOfAccumulators(), and SetNumberOfAccumulators().

UInt_t QwSIS3320_Channel::fNumberOfEvents
private

Current triggered event (allow for negative sentinel)

Definition at line 160 of file QwSIS3320_Channel.h.

Referenced by EncodeEventData(), GetNumberOfEvents(), and SetNumberOfEvents().

const unsigned int QwSIS3320_Channel::FORMAT_ACCUMULATOR = 0x0
staticprivate

Definition at line 191 of file QwSIS3320_Channel.h.

Referenced by ProcessEvBuffer().

const unsigned int QwSIS3320_Channel::FORMAT_LONG_WORD_SAMPLING = 0x1
staticprivate

Definition at line 192 of file QwSIS3320_Channel.h.

Referenced by ProcessEvBuffer().

const unsigned int QwSIS3320_Channel::FORMAT_SHORT_WORD_SAMPLING = 0x2
staticprivate

Definition at line 193 of file QwSIS3320_Channel.h.

Referenced by ProcessEvBuffer().

Double_t QwSIS3320_Channel::fPedestal
private

Definition at line 155 of file QwSIS3320_Channel.h.

Referenced by GetPedestal(), InitializeChannel(), ProcessEvent(), and SetPedestal().

UInt_t QwSIS3320_Channel::fSampleFormat
private

Number of triggered events.

Definition at line 163 of file QwSIS3320_Channel.h.

Referenced by EncodeEventData().

std::vector<QwSIS3320_Samples> QwSIS3320_Channel::fSamplesRaw
private
std::vector<Double_t> QwSIS3320_Channel::fSampleWindowAverages
private

Definition at line 171 of file QwSIS3320_Channel.h.

std::vector<std::pair<Double_t, Double_t> > QwSIS3320_Channel::fSampleWindows
private

Definition at line 172 of file QwSIS3320_Channel.h.

std::vector<Double_t> QwSIS3320_Channel::fTimeWindowAverages
private

Definition at line 169 of file QwSIS3320_Channel.h.

Referenced by ProcessEvent().

std::vector<std::pair<UInt_t, UInt_t> > QwSIS3320_Channel::fTimeWindows
private

Definition at line 170 of file QwSIS3320_Channel.h.

Referenced by ProcessEvent().

const Bool_t QwSIS3320_Channel::kDEBUG = kFALSE
staticprivate

Definition at line 145 of file QwSIS3320_Channel.h.

Referenced by ProcessEvBuffer().

const Double_t QwSIS3320_Channel::kNanoSecondsPerSample = 4.0
staticprivate

Conversion factor to translate the single sampling period to time. The ADC will sample at 250 MHz, corresponding with 4 ns per sample.

Definition at line 154 of file QwSIS3320_Channel.h.

const Double_t QwSIS3320_Channel::kVoltsPerBit = 5.0 / pow(2.0, 12)
staticprivate

Conversion factor to translate the average bit count in an ADC channel of the SIS3320 into average voltage. There are 2^12 possible states over the full 5 V range.

Definition at line 153 of file QwSIS3320_Channel.h.

const unsigned int QwSIS3320_Channel::MODE_ACCUM_EVENT = 0x1
staticprivate

Definition at line 185 of file QwSIS3320_Channel.h.

Referenced by ProcessEvBuffer().

const unsigned int QwSIS3320_Channel::MODE_MULTI_EVENT = 0x3
staticprivate

Definition at line 186 of file QwSIS3320_Channel.h.

Referenced by ProcessEvBuffer().

const unsigned int QwSIS3320_Channel::MODE_NOTREADY = 0xda00
staticprivate

Definition at line 188 of file QwSIS3320_Channel.h.

Referenced by ProcessEvBuffer().

const unsigned int QwSIS3320_Channel::MODE_SINGLE_EVENT = 0x4
staticprivate

Definition at line 187 of file QwSIS3320_Channel.h.

Referenced by ProcessEvBuffer().


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