QwAnalysis
QwLinearDiodeArray.cc
Go to the documentation of this file.
1 /**********************************************************\
2 * File: QwLinearDiodeArray.cc *
3 * *
4 * Author: B. Waidyawansa *
5 * Time-stamp: 09-14-2010 *
6 \**********************************************************/
7 
8 #include "QwLinearDiodeArray.h"
9 
10 // System headers
11 #include <stdexcept>
12 
13 // Qweak headers
14 #include "QwParameterFile.h"
15 #include "QwDBInterface.h"
16 
17 const size_t QwLinearDiodeArray::kMaxElements = 8;
18 
19 /*Individual pads of the linear array*/
20 const TString QwLinearDiodeArray::subelement[8]={"p1","p2","p3","p4","p5","p6","p7","p8"};
21 
22 /* Pad size in mm*/
24 
26 {
27 
28  Int_t i=0;
29  Bool_t localdebug = kFALSE;
31 
32  for(i=0;i<8;i++) {
33  fPhotodiode[i].InitializeChannel(name+subelement[i],"raw");
34 
35  if(localdebug)
36  std::cout<<" photodiode ["<<i<<"]="<<fPhotodiode[i].GetElementName()<<"\n";
37  }
38 
39 
40  fEffectiveCharge.InitializeChannel(name+"_EffectiveCharge","derived");
41 
42  // We don't initialize the photodiode channels yet.
43  fRelPos[0].InitializeChannel(name+"RelMean","derived");
44  fRelPos[1].InitializeChannel(name+"RelVariance","derived");
45 
46  bFullSave=kTRUE;
47 
48  return;
49 }
50 
51 void QwLinearDiodeArray::InitializeChannel(TString subsystem, TString name)
52 {
53 
54  Int_t i=0;
55  Bool_t localdebug = kFALSE;
56 
58 
59  for(i=0;i<8;i++) {
60  fPhotodiode[i].InitializeChannel(subsystem, "QwLinearDiodeArray", name+subelement[i],"raw");
61  if(localdebug)
62  std::cout<<" photodiode ["<<i<<"]="<<fPhotodiode[i].GetElementName()<<"\n";
63  }
64 
65  fEffectiveCharge.InitializeChannel(subsystem, "QwLinearDiodeArray", name+"_EffectiveCharge","derived");
66 
67  // We don't initialize the photodiode channels yet.
68 
69  fRelPos[0].InitializeChannel(subsystem, "QwLinearDiodeArray", name+"RelMean","derived");
70  fRelPos[1].InitializeChannel(subsystem, "QwLinearDiodeArray", name+"RelVariance","derived");
71 
72  bFullSave=kTRUE;
73 
74  return;
75 }
76 
78 {
79  size_t i=0;
80 
81  for(i=0;i<8;i++) fPhotodiode[i].ClearEventData();
82 
83  for(i=kXAxis;i<kNumAxes;i++){
85  }
87 
88  return;
89 }
90 
91 
93 {
94  Bool_t eventokay=kTRUE;
95 
96  UInt_t deviceerror=0;
97  for(size_t i=0;i<8;i++)
98  {
99  deviceerror|= fPhotodiode[i].ApplyHWChecks(); //OR the error code from each wire
100  eventokay &= (deviceerror & 0x0);//AND with 0 since zero means HW is good.
101 
102  if (bDEBUG) std::cout<<" Inconsistent within LinearArray terminals photodiode[ "<<i<<" ] "<<std::endl;
103  if (bDEBUG) std::cout<<" photodiode[ "<<i<<" ] sequence num "<<fPhotodiode[i].GetSequenceNumber()<<" sample size "<<fPhotodiode[i].GetNumberOfSamples()<<std::endl;
104  }
105 
106  return eventokay;
107 }
108 
110 {
111  size_t i=0;
112  for(i=0;i<8;i++) fPhotodiode[i].IncrementErrorCounters();
113  for(i=kXAxis;i<kNumAxes;i++) {
115  }
117 }
118 
120 {
121  size_t i=0;
122  for(i=0;i<8;i++) fPhotodiode[i].PrintErrorCounters();
123  for(i=kXAxis;i<kNumAxes;i++) {
125  }
127 }
128 
130 {
131  size_t i=0;
132  UInt_t error=0;
133  for(i=0;i<8;i++) error|=fPhotodiode[i].GetEventcutErrorFlag();
134  for(i=kXAxis;i<kNumAxes;i++) {
135  error|=fRelPos[i].GetEventcutErrorFlag();
136  }
138 
139  return error;
140 }
141 
143 {
144  size_t i=0;
145  UInt_t error1=0;
146  UInt_t error2=0;
147  for(i=0;i<8;i++){
148  error1|=fPhotodiode[i].GetErrorCode();
149  error2|=fPhotodiode[i].GetEventcutErrorFlag();
150  }
151  for(i=kXAxis;i<kNumAxes;i++) {
152  fRelPos[i].UpdateErrorFlag(error1);
153  error2|=fRelPos[i].GetEventcutErrorFlag();
154  }
157  return error2;
158 }
159 
161 {
162  Bool_t status=kTRUE;
163  size_t i=0;
164  UInt_t error_code = 0;
165  //Event cuts for four wires
166  for(i=0;i<8;i++){
168  status&=kTRUE;
169  }
170  else{
171  status&=kFALSE;
172  if (bDEBUG) std::cout<<" array ["<<i<<"] event cut failed ";
173  }
174  //Get the Event cut error flag for wires
175  error_code|=fPhotodiode[i].GetErrorCode();
176  }
177 
178  //Event cuts for Relative X & Y
179  for(i=kXAxis;i<kNumAxes;i++){
180  fRelPos[i].UpdateErrorFlag(error_code);//To update the event cut failed error code from the channels/wires error codes
181  if (fRelPos[i].ApplySingleEventCuts()){ //for RelX
182  status&=kTRUE;
183  }
184  else{
185  status&=kFALSE;
186  if (bDEBUG) std::cout<<" Rel X event cut failed ";
187  }
188  }
189 
190  //Event cuts for four wire sum (EffectiveCharge)
191  fEffectiveCharge.UpdateErrorFlag(error_code);//To update the eff-charge error code from the channels/wires event cut error codes
193  status&=kTRUE;
194  }
195  else{
196  status&=kFALSE;
197  if (bDEBUG) std::cout<<"EffectiveCharge event cut failed ";
198  }
199  return status;
200 }
201 
202 
204 {
205  VQwHardwareChannel* tmpptr = NULL;
206  ch_name.ToLower();
207  if (ch_name=="relx"){
208  tmpptr = &fRelPos[0];
209  }else if (ch_name=="rely"){
210  tmpptr = &fRelPos[1];
211  }else if (ch_name=="absx" || ch_name=="x" ){
212  tmpptr = &fAbsPos[0];
213  }else if (ch_name=="absy" || ch_name=="y"){
214  tmpptr = &fAbsPos[1];
215  }else if (ch_name=="effectivecharge" || ch_name=="charge"){
216  tmpptr = &fEffectiveCharge;
217  } else {
218  TString loc="QwLinearDiodeArray::GetSubelementByName for"
219  + this->GetElementName() + " was passed "
220  + ch_name + ", which is an unrecognized subelement name.";
221  throw std::invalid_argument(loc.Data());
222  }
223  return tmpptr;
224 }
225 
226 /*
227 void QwLinearDiodeArray::SetSingleEventCuts(TString ch_name, Double_t minX, Double_t maxX)
228 {
229  QwWarning << "QwLinearDiodeArray::SetSingleEventCuts: "
230  << "Does not do anything yet." << QwLog::endl;
231 }
232 
233 void QwLinearDiodeArray::SetSingleEventCuts(TString ch_name, UInt_t errorflag,Double_t minX, Double_t maxX, Double_t stability){
234  errorflag|=kBPMErrorFlag;//update the device flag (Do not have a error flag yet)
235  // QwWarning << "QwLinearDiodeArray::SetSingleEventCuts: " << "Does not do anything yet." << QwLog::endl;
236  if (ch_name=="relx"){
237  QwMessage<<"RelX LL " << minX <<" UL " << maxX <<QwLog::endl;
238  fRelPos[0].SetSingleEventCuts(errorflag,minX,maxX,stability);
239 
240  }else if (ch_name=="rely"){
241  QwMessage<<"RelY LL " << minX <<" UL " << maxX <<QwLog::endl;
242  fRelPos[1].SetSingleEventCuts(errorflag,minX,maxX,stability);
243 
244  } else if (ch_name=="effectivecharge"){
245  QwMessage<<"EffectveQ LL " << minX <<" UL " << maxX <<QwLog::endl;
246  fEffectiveCharge.SetSingleEventCuts(errorflag,minX,maxX,stability);
247  }
248 }
249 */
250 
252  Short_t i=0;
253  try {
254  if(typeid(*ev_error)==typeid(*this)) {
255  // std::cout<<" Here in QwQPD::UpdateErrorFlag \n";
256  if (this->GetElementName()!="") {
257  const QwLinearDiodeArray* value_bpm = dynamic_cast<const QwLinearDiodeArray* >(ev_error);
258  for(i=0;i<4;i++){
259  fPhotodiode[i].UpdateErrorFlag(value_bpm->fPhotodiode[i]);
260  }
261  for(i=kXAxis;i<kNumAxes;i++) {
262  fRelPos[i].UpdateErrorFlag(value_bpm->fRelPos[i]);
263  }
265  }
266  } else {
267  TString loc="Standard exception from QwLinearDiodeArray::UpdateErrorFlag :"+
268  ev_error->GetElementName()+" "+this->GetElementName()+" are not of the "
269  +"same type";
270  throw std::invalid_argument(loc.Data());
271  }
272  } catch (std::exception& e) {
273  std::cerr<< e.what()<<std::endl;
274  }
275 };
276 
278 {
279  Bool_t localdebug = kFALSE;
280  static QwVQWK_Channel mean, meansqr;
281  static QwVQWK_Channel tmp("tmp");
282  static QwVQWK_Channel tmp2("tmp2");
283 
284  mean.InitializeChannel("mean","raw");
285  meansqr.InitializeChannel("meansqr","raw");
286 
287 
288  size_t i = 0;
289 
290 
291  ApplyHWChecks();
292  //first apply HW checks and update HW error flags.
293  // Calling this routine here and not in ApplySingleEventCuts
294  //makes a difference for a LinearArrays because they have derrived devices.
295 
297  for(i=0;i<8;i++){
300  }
301 
302 
303  // First calculate the mean pad position and mean of squared pad position
304  // with respect to the center of the array, in units of pad spacing.
305  mean.ClearEventData();
306  meansqr.ClearEventData();
307  for (i=0;i<8;i++){
308  Double_t pos = kQwLinearDiodeArrayPadSize*i*0.5;
309  tmp = fPhotodiode[i];
310  tmp.Scale(pos); // Scale for S(i)*pos
311  mean+=tmp;
312  tmp.Scale(pos); // Scale again for S(i)*(pos**2)
313  meansqr+=tmp;
314  }
315  fRelPos[0].Ratio(mean,fEffectiveCharge);
316  tmp = meansqr;
317  meansqr.Ratio(tmp,fEffectiveCharge);
318  tmp2.Product(fRelPos[0], fRelPos[0]);
319 
320  // Now calculate the variance
321  fRelPos[1].Difference(meansqr,tmp2);
322 
323  if(localdebug){
324  std::cout<<"\n#################"<<std::endl;
325  std::cout<<" LinearArray name="<<fElementName<<std::endl;
326  std::cout<<" Size of the linear array = "<<8<<std::endl;
327  std::cout<<" event number= "<<fPhotodiode[0].GetSequenceNumber()<<std::endl;
328  for(Int_t i = 0; i<8; i++)
329  std::cout<<" pad"<<i<<" ="<<fPhotodiode[i].GetValue()<<std::endl;
330  std::cout<<" mean ="<<fRelPos[0].GetValue()<<std::endl;
331  std::cout<<" varaiance ="<<fRelPos[1].GetValue()<<std::endl;
332  std::cout<<" total charge ="<<fEffectiveCharge.GetValue()<<std::endl;
333 
334  }
335 
336  return;
337 }
338 
339 
340 Int_t QwLinearDiodeArray::ProcessEvBuffer(UInt_t* buffer, UInt_t word_position_in_buffer,UInt_t index)
341 {
342  if(index<8)
343  {
344  fPhotodiode[index].ProcessEvBuffer(buffer,word_position_in_buffer);
345  }
346  else
347  {
348  std::cerr <<
349  "QwLinearDiodeArray::ProcessEvBuffer(): attemp to fill in raw data for a pad that doesn't exist \n";
350  }
351  return word_position_in_buffer;
352 }
353 
354 
355 
357 {
358  for (size_t i = 0; i < 2; i++) {
359  fRelPos[i].PrintValue();
360  }
361  return;
362 }
363 
365 {
366  size_t i = 0;
367  for (i = 0; i < 8; i++) fPhotodiode[i].PrintInfo();
368  for (i = 0; i < 2; i++) {
369  fAbsPos[i].PrintInfo();
370  }
372 }
373 
374 
376 {
377  TString thisname;
378  size_t localindex=kInvalidSubelementIndex;
379  if (subindex>-1) localindex = subindex;
380 
381  if(localindex<8)
382  thisname=fPhotodiode[subindex].GetElementName();
383  else
384  std::cerr<< "QwLinearDiodeArray::GetSubElementName for "
385  << GetElementName()<<" this subindex, "
386  << subindex << ", doesn't exist \n";
387 
388  return thisname;
389 }
390 
392 {
393  size_t localindex=kInvalidSubelementIndex;
394  TString padindex;
395 
396  padindex = subname(subname.Sizeof()-2,1);
397  // Interpret the subname as the pad index.
398  if (padindex.IsDigit()){
399  Int_t tmpval = padindex.Atoi();
400  if (tmpval>-1) localindex = tmpval-1;
401  }
402 
403  // localindex is unsigned int and always positive
404  if (localindex > kMaxElements){
405  std::cerr << "QwLinearDiodeArray::GetSubElementIndex is unable to associate the string -"
406  <<subname<<"- to any index"<<std::endl;
407  localindex=kInvalidSubelementIndex;
408  }
409  return localindex;
410 }
411 
413 {
414  for(size_t i=kXAxis;i<kNumAxes;i++){
416  }
417 
418 }
419 
420 
422 {
423  *(dynamic_cast<QwLinearDiodeArray*>(this)) =
424  *(dynamic_cast<const QwLinearDiodeArray*>(&value));
425  return *this;
426 }
427 
429 {
430  VQwBPM::operator= (value);
431 
432  if (GetElementName()!=""){
433  size_t i = 0;
435  for(i=0;i<8;i++) this->fPhotodiode[i]=value.fPhotodiode[i];
436  for(i=kXAxis;i<kNumAxes;i++) {
437  this->fRelPos[i]=value.fRelPos[i];
438  }
439  }
440  return *this;
441 }
442 
444 {
445  *(dynamic_cast<QwLinearDiodeArray*>(this)) +=
446  *(dynamic_cast<const QwLinearDiodeArray*>(&value));
447  return *this;
448 }
449 
451 {
452 
453  if (GetElementName()!=""){
454  size_t i = 0;
455  this->fEffectiveCharge+=value.fEffectiveCharge;
456  for(i=0;i<8;i++) this->fPhotodiode[i]+=value.fPhotodiode[i];
457  for(i=kXAxis;i<kNumAxes;i++) {
458  this->fRelPos[i]+=value.fRelPos[i];
459  }
460  }
461  return *this;
462 }
463 
465 {
466  *(dynamic_cast<QwLinearDiodeArray*>(this)) -=
467  *(dynamic_cast<const QwLinearDiodeArray*>(&value));
468  return *this;
469 }
470 
472 {
473 
474  if (GetElementName()!=""){
475  size_t i = 0;
476  this->fEffectiveCharge-=value.fEffectiveCharge;
477  for(i=0;i<8;i++) this->fPhotodiode[i]-=value.fPhotodiode[i];
478  for(i=kXAxis;i<kNumAxes;i++) {
479  this->fRelPos[i]-=value.fRelPos[i];
480  }
481  }
482  return *this;
483 }
484 
485 
487 {
488  // this function is called when forming asymmetries. In this case waht we actually want for the
489  // LinearArray is the difference only not the asymmetries
490 
491  *this=numer;
493  return;
494 }
495 
496 
497 
498 void QwLinearDiodeArray::Scale(Double_t factor)
499 {
500  size_t i = 0;
501  fEffectiveCharge.Scale(factor);
502 
503  for(i=0;i<8;i++) fPhotodiode[i].Scale(factor);
504  for(i=kXAxis;i<kNumAxes;i++){
505  fRelPos[i].Scale(factor);
506  }
507  return;
508 }
509 
510 
512 {
513  size_t i = 0;
514  for(i=0;i<8;i++) fPhotodiode[i].CalculateRunningAverage();
515  for (i = 0; i < 2; i++) fRelPos[i].CalculateRunningAverage();
517  return;
518 }
519 
521  AccumulateRunningSum(*dynamic_cast<const QwLinearDiodeArray* >(&value));
522 }
523 
525 {
526  size_t i = 0;
527  for(i=0;i<8;i++) fPhotodiode[i].AccumulateRunningSum(value.fPhotodiode[i]);
528  for (i = 0; i < 2; i++) fRelPos[i].AccumulateRunningSum(value.fRelPos[i]);
530  return;
531 }
532 
534  DeaccumulateRunningSum(*dynamic_cast<QwLinearDiodeArray* >(&value));
535 }
536 
538 {
539  size_t i = 0;
540  for(i=0;i<8;i++) fPhotodiode[i].DeaccumulateRunningSum(value.fPhotodiode[i]);
541  for (i = 0; i < 2; i++) fRelPos[i].DeaccumulateRunningSum(value.fRelPos[i]);
543  return;
544 }
545 
546 
547 
548 void QwLinearDiodeArray::ConstructHistograms(TDirectory *folder, TString &prefix)
549 {
550 
551  if (GetElementName()=="") {
552  // This channel is not used, so skip filling the histograms.
553  } else {
554  fEffectiveCharge.ConstructHistograms(folder, prefix);
555  TString thisprefix=prefix;
556 
557  if(prefix=="asym_")
558  thisprefix="diff_";
559  SetRootSaveStatus(prefix);
560  size_t i = 0;
561  if(bFullSave) {
562  for(i=0;i<8;i++) fPhotodiode[i].ConstructHistograms(folder, thisprefix);
563  }
564  for(i=kXAxis;i<kNumAxes;i++) {
565  fRelPos[i].ConstructHistograms(folder, thisprefix);
566  }
567  }
568  return;
569 }
570 
572 {
573  if (GetElementName()=="") {
574  // This channel is not used, so skip filling the histograms.
575  }
576  else {
578  size_t i = 0;
579  if(bFullSave) {
580  for(i=0;i<8;i++) fPhotodiode[i].FillHistograms();
581  }
582  for(i=kXAxis;i<kNumAxes;i++){
583  fRelPos[i].FillHistograms();
584  }
585  }
586  return;
587 }
588 
589 void QwLinearDiodeArray::ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector<Double_t> &values)
590 {
591  if (GetElementName()==""){
592  // This channel is not used, so skip constructing trees.
593  }
594  else {
595  TString thisprefix=prefix;
596  if(prefix=="asym_")
597  thisprefix="diff_";
598 
599  SetRootSaveStatus(prefix);
600 
601  fEffectiveCharge.ConstructBranchAndVector(tree,prefix,values);
602  size_t i = 0;
603  if(bFullSave) {
604  for(i=0;i<8;i++) fPhotodiode[i].ConstructBranchAndVector(tree,thisprefix,values);
605  }
606  for(i=kXAxis;i<kNumAxes;i++) {
607  fRelPos[i].ConstructBranchAndVector(tree,thisprefix,values);
608  }
609 
610  }
611  return;
612 }
613 
614 void QwLinearDiodeArray::ConstructBranch(TTree *tree, TString &prefix)
615 {
616  if (GetElementName()==""){
617  // This channel is not used, so skip constructing trees.
618  }
619  else {
620  TString thisprefix=prefix;
621  if(prefix=="asym_")
622  thisprefix="diff_";
623 
624  SetRootSaveStatus(prefix);
625 
626  fEffectiveCharge.ConstructBranch(tree,prefix);
627  size_t i = 0;
628  if(bFullSave) {
629  for(i=0;i<8;i++) fPhotodiode[i].ConstructBranch(tree,thisprefix);
630  }
631  for(i=kXAxis;i<kNumAxes;i++) {
632  fRelPos[i].ConstructBranch(tree,thisprefix);
633  }
634 
635  }
636  return;
637 }
638 
639 void QwLinearDiodeArray::ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& modulelist)
640 {
641  TString devicename;
642 
643  devicename=GetElementName();
644  devicename.ToLower();
645  if (GetElementName()==""){
646  // This channel is not used, so skip filling the histograms.
647  } else
648  {
649  if (modulelist.HasValue(devicename)){
650  TString thisprefix=prefix;
651  if(prefix=="asym_")
652  thisprefix="diff_";
653 
654  SetRootSaveStatus(prefix);
655 
656  fEffectiveCharge.ConstructBranch(tree,prefix);
657  size_t i = 0;
658  if(bFullSave) {
659  for(i=0;i<8;i++) fPhotodiode[i].ConstructBranch(tree,thisprefix);
660  }
661  for(i=kXAxis;i<kNumAxes;i++) {
662  fRelPos[i].ConstructBranch(tree,thisprefix);
663  }
664 
665  QwMessage <<" Tree leaves added to "<<devicename<<" Corresponding channels"<<QwLog::endl;
666  }
667  // this functions doesn't do anything yet
668  }
669 
670 
671 
672 
673 
674  return;
675 }
676 
677 void QwLinearDiodeArray::FillTreeVector(std::vector<Double_t> &values) const
678 {
679  if (GetElementName()=="") {
680  // This channel is not used, so skip filling the tree.
681  }
682  else {
684  size_t i = 0;
685  if(bFullSave) {
686  for(i=0;i<8;i++) fPhotodiode[i].FillTreeVector(values);
687  }
688  for(i=kXAxis;i<kNumAxes;i++){
689  fRelPos[i].FillTreeVector(values);
690  }
691  }
692  return;
693 }
694 
695 
697 {
698  size_t i = 0;
699  // bEVENTCUTMODE=bcuts;
700  for (i=0;i<8;i++) fPhotodiode[i].SetEventCutMode(bcuts);
701  for (i=kXAxis;i<kNumAxes;i++) {
702  fRelPos[i].SetEventCutMode(bcuts);
703  fAbsPos[i].SetEventCutMode(bcuts);
704  }
706 }
707 
708 
710 {
711  for (size_t i = kXAxis; i < kNumAxes; i++) {
712  QwVQWK_Channel relpos(fRelPos[i]);
713  relpos = fRelPos[i];
714  fLinearArrayElementList.push_back(relpos);
715  }
716  QwVQWK_Channel effectivecharge(fEffectiveCharge);
717  effectivecharge = fEffectiveCharge;
718  fLinearArrayElementList.push_back(effectivecharge);
719 }
720 
721 
722 std::vector<QwDBInterface> QwLinearDiodeArray::GetDBEntry()
723 {
724  std::vector <QwDBInterface> row_list;
725  row_list.clear();
726 
727  for(size_t i=0;i<2;i++) {
728  fRelPos[i].AddEntriesToList(row_list);
729  }
731  return row_list;
732 
733 
734 }
735 
736 
737 std::vector<QwErrDBInterface> QwLinearDiodeArray::GetErrDBEntry()
738 {
739  std::vector <QwErrDBInterface> row_list;
740  row_list.clear();
741  for(size_t i=0;i<2;i++) {
742  fRelPos[i].AddErrEntriesToList(row_list);
743  }
745  return row_list;
746 
747 
748 }
749 
750 
751 
752 /**********************************
753  * Mock data generation routines
754  **********************************/
755 
756 void QwLinearDiodeArray::SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY)
757 {
758  // Average values of the signals in the stripline ADCs
759  Double_t sumX = 1.1e8; // These are just guesses, but I made X and Y different
760  Double_t sumY = 0.9e8; // to make it more interesting for the analyzer...
761 
762 
763  // Determine the asymmetry from the position
764  Double_t meanXP = (1.0 + meanX) * sumX / 2.0;
765  Double_t meanXM = (1.0 - meanX) * sumX / 2.0; // = sumX - meanXP;
766  Double_t meanYP = (1.0 + meanY) * sumY / 2.0;
767  Double_t meanYM = (1.0 - meanY) * sumY / 2.0; // = sumY - meanYP;
768 
769  // Determine the spread of the asymmetry (this is not tested yet)
770  // (negative sigma should work in the QwVQWK_Channel, but still using fabs)
771  Double_t sigmaXP = fabs(sumX * sigmaX / meanX);
772  Double_t sigmaXM = sigmaXP;
773  Double_t sigmaYP = fabs(sumY * sigmaY / meanY);
774  Double_t sigmaYM = sigmaYP;
775 
776  // Propagate these parameters to the ADCs
777  fPhotodiode[0].SetRandomEventParameters(meanXP, sigmaXP);
778  fPhotodiode[1].SetRandomEventParameters(meanXM, sigmaXM);
779  fPhotodiode[2].SetRandomEventParameters(meanYP, sigmaYP);
780  fPhotodiode[3].SetRandomEventParameters(meanYM, sigmaYM);
781 }
782 
783 
784 void QwLinearDiodeArray::RandomizeEventData(int helicity, double time)
785 {
786  for (size_t i=0; i<8; i++) fPhotodiode[i].RandomizeEventData(helicity, time);
787 
788  return;
789 }
790 
791 
792 void QwLinearDiodeArray::SetEventData(Double_t* relpos, UInt_t sequencenumber)
793 {
794  for (size_t i=0; i<2; i++)
795  {
796  fRelPos[i].SetHardwareSum(relpos[i], sequencenumber);
797  }
798 
799  return;
800 }
801 
802 
803 void QwLinearDiodeArray::EncodeEventData(std::vector<UInt_t> &buffer)
804 {
805  for (size_t i=0; i<8; i++) fPhotodiode[i].EncodeEventData(buffer);
806 }
807 
808 
810 {
811  for(size_t i=0;i<8;i++) fPhotodiode[i].SetDefaultSampleSize((size_t)sample_size);
812  return;
813 }
814 
815 
816 void QwLinearDiodeArray::SetSubElementPedestal(Int_t j, Double_t value)
817 {
818  fPhotodiode[j].SetPedestal(value);
819  return;
820 }
821 
823 {
825  return;
826 }
827 
UInt_t UpdateErrorFlag()
Update the error flag based on the error flags of internally contained objects Return paramter is the...
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t num_words_left, UInt_t index=0)
Decode the event data from a CODA buffer.
void ProcessEvent()
Process the event data according to pedestal and calibration factor.
static const size_t kMaxElements
size_t GetNumberOfSamples() const
void EncodeEventData(std::vector< UInt_t > &buffer)
std::vector< QwVQWK_Channel > fLinearArrayElementList
Int_t ApplyHWChecks()
static UInt_t GetSubElementIndex(TString subname)
void SetRootSaveStatus(TString &prefix)
Definition: VQwBPM.cc:178
void SetRandomEventParameters(Double_t mean, Double_t sigma)
Set the normal random event parameters.
Definition: MQwMockable.cc:41
UInt_t UpdateErrorFlag()
Update the error flag based on the error flags of internally contained objects Return paramter is the...
static const Bool_t bDEBUG
Definition: VQwBPM.h:275
void DeaccumulateRunningSum(const QwVQWK_Channel &value)
void Ratio(const QwVQWK_Channel &numer, const QwVQWK_Channel &denom)
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
void SetSubElementPedestal(Int_t j, Double_t value)
void PrintInfo() const
Print multiple lines of information about this data element.
void SetPedestal(Double_t ped)
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
Double_t GetValue(size_t element) const
void ConstructHistograms(TDirectory *folder, TString &prefix)
Construct the histograms for this data element.
static const double e
Definition: QwUnits.h:91
void PrintInfo() const
Print multiple lines of information about this data element.
Double_t fPositionCenter[3]
Definition: VQwBPM.h:256
void SetEventCutMode(Int_t bcuts)
void Scale(Double_t Offset)
TString GetSubElementName(Int_t subindex)
std::vector< QwDBInterface > GetDBEntry()
VQwBPM & operator+=(const VQwBPM &value)
VQwHardwareChannel * GetSubelementByName(TString ch_name)
void ConstructBranch(TTree *tree, TString &prefix)
static const UInt_t kInvalidSubelementIndex
Definition: QwTypes.h:191
virtual UInt_t GetErrorCode() const
void ClearEventData()
Clear the event data in this element.
void SetHardwareSum(Double_t hwsum, UInt_t sequencenumber=0)
VQwBPM & operator=(const VQwBPM &value)
void FillTreeVector(std::vector< Double_t > &values) const
void ConstructHistograms(TDirectory *folder, TString &prefix)
Construct the histograms for this data element.
Bool_t bFullSave
Definition: VQwBPM.h:273
Bool_t HasValue(TString &vname)
void AccumulateRunningSum(const QwLinearDiodeArray &value)
virtual UInt_t GetEventcutErrorFlag()
return the error flag on this channel/device
void SetCalibrationFactor(Double_t factor)
void PrintValue() const
Print single line of value and error of this data element.
void InitializeChannel(TString name)
void SetSubElementCalibrationFactor(Int_t j, Double_t value)
void AddEntriesToList(std::vector< QwDBInterface > &row_list)
void PrintErrorCounters() const
report number of events failed due to HW and event cut failure
void ClearEventData()
Clear the event data in this element.
void ConstructBranch(TTree *tree, TString &prefix)
Bool_t ApplySingleEventCuts(Double_t LL, Double_t UL)
void SetEventData(Double_t *block, UInt_t sequencenumber)
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t word_position_in_buffer, UInt_t indexnumber)
Process the CODA event buffer for this element.
void FillTreeVector(std::vector< Double_t > &values) const
QwVQWK_Channel fPhotodiode[8]
void InitializeChannel(TString name)
Definition: VQwBPM.cc:25
void Scale(Double_t factor)
void PrintErrorCounters() const
report number of events failed due to HW and event cut failure
UInt_t GetEventcutErrorFlag()
return the error flag on this channel/device
void SetEventCutMode(Int_t bcuts)
Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel.
void FillHistograms()
Fill the histograms for this data element.
void Product(const QwVQWK_Channel &value1, const QwVQWK_Channel &value2)
VQwBPM & operator-=(const VQwBPM &value)
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
Definition: VQwBPM.h:34
TString fElementName
Name of this data element.
virtual const TString & GetElementName() const
Get the name of this element.
void Difference(const QwVQWK_Channel &value1, const QwVQWK_Channel &value2)
void Ratio(QwLinearDiodeArray &numer, QwLinearDiodeArray &denom)
void FillHistograms()
Fill the histograms for this data element.
void DeaccumulateRunningSum(QwLinearDiodeArray &value)
QwVQWK_Channel fRelPos[2]
void PrintValue() const
Print single line of value and error of this data element.
void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY)
size_t GetSequenceNumber() const
void RandomizeEventData(int helicity=0, double time=0.0)
QwVQWK_Channel fEffectiveCharge
std::vector< QwErrDBInterface > GetErrDBEntry()
virtual VQwBPM & operator=(const VQwBPM &value)=0
Definition: VQwBPM.cc:115
void InitializeChannel(TString name, TString datatosave)
Initialize the fields in this object.
void AddChannelOffset(Double_t Offset)
void AddErrEntriesToList(std::vector< QwErrDBInterface > &row_list)
void IncrementErrorCounters()
void CalculateRunningAverage()
static const TString subelement[8]
static const Double_t kQwLinearDiodeArrayPadSize
QwVQWK_Channel fAbsPos[2]
void SetDefaultSampleSize(Int_t sample_size)
void AccumulateRunningSum(const QwVQWK_Channel &value)