QwAnalysis
QwIntegrationPMT.cc
Go to the documentation of this file.
1 /**********************************************************\
2 * File: QwIntegrationPMT.cc *
3 * *
4 * Author: *
5 * Time-stamp: *
6 \**********************************************************/
7 
8 #include "QwIntegrationPMT.h"
9 
10 // System headers
11 #include <stdexcept>
12 
13 // Qweak headers
14 #include "QwDBInterface.h"
15 
16 /********************************************************/
17 void QwIntegrationPMT::SetPedestal(Double_t pedestal)
18 {
19  fPedestal=pedestal;
21  return;
22 }
23 
25 {
26  fCalibration=calib;
28  return;
29 }
30 /********************************************************/
31 void QwIntegrationPMT::InitializeChannel(TString name, TString datatosave)
32 {
33  SetPedestal(0.);
35  fTriumf_ADC.InitializeChannel(name,datatosave);
36  SetElementName(name);
37  SetBlindability(kTRUE);
38  SetNormalizability(kTRUE);
39  return;
40 }
41 /********************************************************/
42 void QwIntegrationPMT::InitializeChannel(TString subsystem, TString name, TString datatosave)
43 {
44  SetPedestal(0.);
46  fTriumf_ADC.InitializeChannel(subsystem,"QwIntegrationPMT", name, datatosave);
47  SetElementName(name);
48  SetBlindability(kTRUE);
49  SetNormalizability(kTRUE);
50  return;
51 }
52 /********************************************************/
53 void QwIntegrationPMT::InitializeChannel(TString subsystem, TString module, TString name, TString datatosave)
54 {
55  SetPedestal(0.);
57  fTriumf_ADC.InitializeChannel(subsystem,module, name, datatosave);
58  SetElementName(name);
59  SetBlindability(kTRUE);
60  SetNormalizability(kTRUE);
61  return;
62 }
63 /********************************************************/
65 {
67  return;
68 }
69 /********************************************************/
72 }
73 /********************************************************/
75 {
77  return;
78 }
79 /********************************************************/
80 void QwIntegrationPMT::SetExternalRandomVariable(double random_variable)
81 {
82  fTriumf_ADC.SetExternalRandomVariable(random_variable);
83  return;
84 }
85 /********************************************************/
86 void QwIntegrationPMT::SetRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)
87 {
88  fTriumf_ADC.SetRandomEventDriftParameters(amplitude, phase, frequency);
89  return;
90 }
91 /********************************************************/
92 void QwIntegrationPMT::AddRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)
93 {
94  fTriumf_ADC.AddRandomEventDriftParameters(amplitude, phase, frequency);
95  return;
96 }
97 /********************************************************/
98 void QwIntegrationPMT::SetRandomEventParameters(Double_t mean, Double_t sigma)
99 {
101  return;
102 }
103 /********************************************************/
105 {
107  return;
108 }
109 /********************************************************/
110 void QwIntegrationPMT::RandomizeEventData(int helicity, double time)
111 {
112  fTriumf_ADC.RandomizeEventData(helicity, time);
113  return;
114 }
115 /********************************************************/
116 void QwIntegrationPMT::SetHardwareSum(Double_t hwsum, UInt_t sequencenumber)
117 {
118  fTriumf_ADC.SetHardwareSum(hwsum, sequencenumber);
119  return;
120 }
121 
123 {
124  return fTriumf_ADC.GetValue();
125 }
126 
127 Double_t QwIntegrationPMT::GetValue(Int_t blocknum)
128 {
129  return fTriumf_ADC.GetValue(blocknum);
130 }
131 
132 /********************************************************/
133 void QwIntegrationPMT::SetEventData(Double_t* block, UInt_t sequencenumber)
134 {
135  fTriumf_ADC.SetEventData(block, sequencenumber);
136  return;
137 }
138 /********************************************************/
139 void QwIntegrationPMT::EncodeEventData(std::vector<UInt_t> &buffer)
140 {
142 }
143 /********************************************************/
145 {
146  ApplyHWChecks();//first apply HW checks and update HW error flags.
148 
149  return;
150 }
151 /********************************************************/
153 {
154  Bool_t eventokay=kTRUE;
155 
156  UInt_t deviceerror=fTriumf_ADC.ApplyHWChecks();//will check for consistancy between HWSUM and SWSUM also check for sample size
157  eventokay=(deviceerror & 0x0);//if no HW error return true
158 
159 
160  return eventokay;
161 }
162 /********************************************************/
163 
164 Int_t QwIntegrationPMT::SetSingleEventCuts(Double_t LL=0, Double_t UL=0){//std::vector<Double_t> & dEventCuts){//two limts and sample size
166  return 1;
167 }
168 
169 /********************************************************/
170 void QwIntegrationPMT::SetSingleEventCuts(UInt_t errorflag, Double_t LL=0, Double_t UL=0, Double_t stability=0){
171  //set the unique tag to identify device type (bcm,bpm & etc)
172  errorflag|=kPMTErrorFlag;
173  QwMessage<<"QwIntegrationPMT Error Code passing to QwVQWK_Ch "<<errorflag<<QwLog::endl;
174  fTriumf_ADC.SetSingleEventCuts(errorflag,LL,UL,stability);
175 
176 }
177 
178 /********************************************************/
179 
181  fTriumf_ADC.SetDefaultSampleSize((size_t)sample_size);
182 }
183 //*/
184 
185 /********************************************************/
187 
188 
189 //std::cout<<" QwBCM::SingleEventCuts() "<<std::endl;
190  Bool_t status=kTRUE;
191 
193  status=kTRUE;
194  //std::cout<<" BCM Sample size "<<fTriumf_ADC.GetNumberOfSamples()<<std::endl;
195  }
196  else{
197  status&=kFALSE;//kTRUE;//kFALSE;
198  }
199 
200  return status;
201 
202 }
203 
204 /********************************************************/
205 
206 void QwIntegrationPMT::PrintErrorCounters() const{// report number of events failed due to HW and event cut faliure
208 }
209 
210 /********************************************************/
212  try {
213  if(typeid(*ev_error)==typeid(*this)) {
214  // std::cout<<" Here in QwIntegrationPMT::UpdateErrorFlag \n";
215  if (this->GetElementName()!="") {
217  }
218  } else {
219  TString loc="Standard exception from QwIntegrationPMT::UpdateErrorFlag :"+
220  ev_error->GetElementName()+" "+this->GetElementName()+" are not of the "
221  +"same type";
222  throw std::invalid_argument(loc.Data());
223  }
224  } catch (std::exception& e) {
225  std::cerr<< e.what()<<std::endl;
226  }
227 };
228 
229 /********************************************************/
230 
231 
232 Int_t QwIntegrationPMT::ProcessEvBuffer(UInt_t* buffer, UInt_t word_position_in_buffer, UInt_t subelement)
233 {
234  fTriumf_ADC.ProcessEvBuffer(buffer,word_position_in_buffer);
235 
236  return word_position_in_buffer;
237 } Double_t fULimit, fLLimit;
238 
239 /********************************************************/
241 {
242 // std::cout<<" Here in QwIntegrationPMT::operator= \n";
243  if (GetElementName()!="")
244  {
245  this->fTriumf_ADC=value.fTriumf_ADC;
246  this->fPedestal=value.fPedestal;
247  this->fCalibration=value.fCalibration;
248  }
249 // std::cout<<" to be copied \n";
250 // value.Print();
251 // std::cout<<" copied \n";
252 // this->Print();
253 
254  return *this;
255 }
256 
258 {
259  if (GetElementName()!="")
260  {
261  this->fTriumf_ADC+=value.fTriumf_ADC;
262  this->fPedestal+=value.fPedestal;
263  this->fCalibration=0;
264  }
265  return *this;
266 }
267 
269 {
270  if (GetElementName()!="")
271  {
272  this->fTriumf_ADC-=value.fTriumf_ADC;
273  this->fPedestal-=value.fPedestal;
274  this->fCalibration=0;
275  }
276  return *this;
277 }
278 
279 
281  *this = value1;
282  *this += value2;
283 }
284 
286  *this = value1;
287  *this -= value2;
288 }
289 
291 {
292  // std::cout<<"QwIntegrationPMT::Ratio element name ="<<GetElementName()<<" \n";
293  if (GetElementName()!="")
294  {
295  // std::cout<<"here in \n";
296  this->fTriumf_ADC.Ratio(numer.fTriumf_ADC,denom.fTriumf_ADC);
297  this->fPedestal=0;
298  this->fCalibration=0;
299  }
300  return;
301 }
302 
303 void QwIntegrationPMT::Scale(Double_t factor)
304 {
305  fTriumf_ADC.Scale(factor);
306  return;
307 }
308 
310 {
311  if (fIsNormalizable) {
312  QwVQWK_Channel* denom_ptr = dynamic_cast<QwVQWK_Channel*>(denom);
313  QwVQWK_Channel vqwk_denom(*denom_ptr);
314  fTriumf_ADC.DivideBy(vqwk_denom);
315  }
316 }
317 
319 {
321 }
322 
324 {
325  //std::cout<<"QwVQWK_Channel Info " <<std::endl;
326  //std::cout<<" Running AVG "<<GetElementName()<<" current running AVG "<<IntegrationPMT_Running_AVG<<std::endl;
327  std::cout<<"QwVQWK_Channel Info " <<std::endl;
329  std::cout<< "Blindability is " << (fIsBlindable?"TRUE":"FALSE")
330  <<std::endl;
331  std::cout<< "Normalizability is " << (fIsNormalizable?"TRUE":"FALSE")
332  <<std::endl;
333  return;
334 }
335 
336 /********************************************************/
337 void QwIntegrationPMT::ConstructHistograms(TDirectory *folder, TString &prefix)
338 {
339  if (GetElementName()=="")
340  {
341  // This channel is not used, so skip filling the histograms.
342  }
343  else
344  {
345  fTriumf_ADC.ConstructHistograms(folder, prefix);
346  }
347  return;
348 }
349 
351 {
352  if (GetElementName()=="")
353  {
354  // This channel is not used, so skip filling the histograms.
355  }
356  else
357  {
359  }
360 
361 
362  return;
363 }
364 
365 void QwIntegrationPMT::ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector<Double_t> &values)
366 {
367  if (GetElementName()==""){
368  // This channel is not used, so skip filling the histograms.
369  } else
370  {
371  fTriumf_ADC.ConstructBranchAndVector(tree, prefix,values);
372  }
373  return;
374 }
375 
376 void QwIntegrationPMT::ConstructBranch(TTree *tree, TString &prefix)
377 {
378  if (GetElementName()==""){
379  // This channel is not used, so skip filling the histograms.
380  } else
381  {
382  fTriumf_ADC.ConstructBranch(tree, prefix);
383  }
384  return;
385 }
386 
387 void QwIntegrationPMT::ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& modulelist)
388 {
389  TString devicename;
390  devicename=GetElementName();
391  devicename.ToLower();
392  if (GetElementName()==""){
393  // This channel is not used, so skip filling the histograms.
394  } else {
395  if (modulelist.HasValue(devicename)){
396  fTriumf_ADC.ConstructBranch(tree, prefix);
397  QwMessage <<"QwIntegrationPMT Tree leave added to "<<devicename<<QwLog::endl;
398  }
399 
400  }
401  return;
402 }
403 
404 
405 void QwIntegrationPMT::FillTreeVector(std::vector<Double_t> &values) const
406 {
407  if (GetElementName()==""){
408  // This channel is not used, so skip filling the histograms.
409  } else {
410  fTriumf_ADC.FillTreeVector(values);
411  }
412 }
413 
415 {
417 }
418 
420 {
422 }
423 
425 {
427 }
428 
429 
430 void QwIntegrationPMT::Blind(const QwBlinder *blinder)
431 {
432  if (fIsBlindable) fTriumf_ADC.Blind(blinder);
433 }
434 
435 void QwIntegrationPMT::Blind(const QwBlinder *blinder, const QwIntegrationPMT& yield)
436 {
437  if (fIsBlindable) fTriumf_ADC.Blind(blinder, yield.fTriumf_ADC);
438 }
439 
440 
441 std::vector<QwDBInterface> QwIntegrationPMT::GetDBEntry()
442 {
443  std::vector <QwDBInterface> row_list;
444  row_list.clear();
445  fTriumf_ADC.AddEntriesToList(row_list);
446  return row_list;
447 
448 }
449 
450 
451 
452 
453 std::vector<QwErrDBInterface> QwIntegrationPMT::GetErrDBEntry()
454 {
455  std::vector <QwErrDBInterface> row_list;
456  row_list.clear();
458  return row_list;
459 };
UInt_t UpdateErrorFlag()
Update the error flag based on the error flags of internally contained objects Return paramter is the...
void AddRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
Double_t fULimit
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t num_words_left, UInt_t index=0)
Decode the event data from a CODA buffer.
std::vector< QwDBInterface > GetDBEntry()
void ProcessEvent()
Process the event data according to pedestal and calibration factor.
void ClearEventData()
Clear the event data in this element.
Bool_t ApplySingleEventCuts()
void AccumulateRunningSum(const QwIntegrationPMT &value)
void RandomizeEventData(int helicity=0, double time=0.0)
void RandomizeEventData(int helicity=0.0, double time=0.0)
Internally generate random event data.
Int_t ApplyHWChecks()
void SetRandomEventParameters(Double_t mean, Double_t sigma)
Set the normal random event parameters.
Definition: MQwMockable.cc:41
void Scale(Double_t factor)
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t word_position_in_buffer, UInt_t subelement=0)
Process the CODA event buffer for this element.
void SetNormalizability(Bool_t isnormalizable)
void Normalize(VQwDataElement *denom)
QwIntegrationPMT & operator-=(const QwIntegrationPMT &value)
void DeaccumulateRunningSum(const QwVQWK_Channel &value)
void Ratio(const QwVQWK_Channel &numer, const QwVQWK_Channel &denom)
void SetSingleEventCuts(Double_t min, Double_t max)
Set the upper and lower limits (fULimit and fLLimit) for this channel.
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
Class for blinding data, adapted from G0 blinder class.
Definition: QwBlinder.h:64
QwIntegrationPMT & operator=(const QwIntegrationPMT &value)
void AddRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)
Add drift parameters to the internal set.
Definition: MQwMockable.cc:32
void PrintInfo() const
Print multiple lines of information about this data element.
void SetPedestal(Double_t ped)
void ConstructHistograms(TDirectory *folder, TString &prefix)
Construct the histograms for this data element.
void SetEventData(Double_t *block, UInt_t sequencenumber=0)
Double_t GetValue(size_t element) const
void DivideBy(const VQwHardwareChannel *valueptr)
void FillHistograms()
Fill the histograms for this data element.
UInt_t UpdateErrorFlag()
Update the error flag based on the error flags of internally contained objects Return paramter is the...
void SetDefaultSampleSize(size_t num_samples_map)
static const double e
Definition: QwUnits.h:91
void InitializeChannel(TString name, TString datatosave)
void Scale(Double_t Offset)
void ConstructBranch(TTree *tree, TString &prefix)
void Ratio(QwIntegrationPMT &numer, QwIntegrationPMT &denom)
void SetHardwareSum(Double_t hwsum, UInt_t sequencenumber=0)
void ConstructHistograms(TDirectory *folder, TString &prefix)
Construct the histograms for this data element.
void SetRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)
Set a single set of harmonic drift parameters.
Definition: MQwMockable.cc:19
void SetExternalRandomVariable(Double_t random_variable)
Bool_t HasValue(TString &vname)
The pure virtual base class of all data elements.
void SetCalibrationFactor(Double_t factor)
void PrintValue() const
Print single line of value and error of this data element.
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
void AddEntriesToList(std::vector< QwDBInterface > &row_list)
void PrintValue() const
Print single line of value and error of this data element.
Int_t SetSingleEventCuts(Double_t, Double_t)
void ClearEventData()
Clear the event data in this element.
void SetRandomEventParameters(Double_t mean, Double_t sigma)
Bool_t ApplySingleEventCuts(Double_t LL, Double_t UL)
void FillTreeVector(std::vector< Double_t > &values) const
void SetBlindability(Bool_t isblindable)
void SetRandomEventAsymmetry(Double_t asymmetry)
void DeaccumulateRunningSum(QwIntegrationPMT &value)
void PrintErrorCounters() const
report number of events failed due to HW and event cut failure
void SetHardwareSum(Double_t hwsum, UInt_t sequencenumber=0)
void Sum(QwIntegrationPMT &value1, QwIntegrationPMT &value2)
void Blind(const QwBlinder *blinder)
Blind the asymmetry.
void FillHistograms()
Fill the histograms for this data element.
void SetEventData(Double_t *block, UInt_t sequencenumber)
void FillTreeVector(std::vector< Double_t > &values) const
void EncodeEventData(std::vector< UInt_t > &buffer)
void SetExternalRandomVariable(Double_t random_variable)
Set the externally provided random variable.
Definition: MQwMockable.h:69
QwVQWK_Channel fTriumf_ADC
static const UInt_t kPMTErrorFlag
Definition: QwTypes.h:170
void UseExternalRandomVariable()
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.
void UseExternalRandomVariable()
Set the flag to use an externally provided random variable.
Definition: MQwMockable.h:67
void SetRandomEventAsymmetry(Double_t asymmetry)
Set the helicity asymmetry.
Definition: MQwMockable.cc:48
void SetPedestal(Double_t ped)
std::vector< QwErrDBInterface > GetErrDBEntry()
void ConstructBranch(TTree *tree, TString &prefix)
void SetElementName(const TString &name)
void SetRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)
QwIntegrationPMT & operator+=(const QwIntegrationPMT &value)
Double_t fLLimit
void EncodeEventData(std::vector< UInt_t > &buffer)
Encode the event data into a CODA buffer.
void SetDefaultSampleSize(Int_t sample_size)
void InitializeChannel(TString name, TString datatosave)
Initialize the fields in this object.
void AddErrEntriesToList(std::vector< QwErrDBInterface > &row_list)
void SetCalibrationFactor(Double_t calib)
void Difference(QwIntegrationPMT &value1, QwIntegrationPMT &value2)
void CalculateRunningAverage()
void Blind(const QwBlinder *blinder)
Blind this channel as an asymmetry.
void PrintInfo() const
Print multiple lines of information about this data element.
void AccumulateRunningSum(const QwVQWK_Channel &value)