QwAnalysis
QwHelicityPattern.cc
Go to the documentation of this file.
1 /**********************************************************\
2 * File: QwHelicityPattern.cc *
3 * *
4 * Author: *
5 * Time-stamp: *
6 \**********************************************************/
7 
8 #include "QwHelicityPattern.h"
9 
10 // System headers
11 #include <stdexcept>
12 
13 // Qweak headers
14 #include "QwLog.h"
15 #include "QwHistogramHelper.h"
16 #include "QwHelicity.h"
17 #include "QwBlinder.h"
18 #include "VQwDataElement.h"
19 
20 
21 /*****************************************************************/
22 /**
23  * Defines configuration options using QwOptions functionality.
24  * @param options Options object
25  */
27 {
28  options.AddOptions("Helicity pattern")
29  ("enable-burstsum", po::value<bool>()->default_bool_value(false),
30  "enable burst sum calculation");
31  options.AddOptions("Helicity pattern")
32  ("enable-runningsum", po::value<bool>()->default_bool_value(true),
33  "enable running sum calculation");
34  options.AddOptions("Helicity pattern")
35  ("enable-differences", po::value<bool>()->default_bool_value(false),
36  "store pattern differences in tree");
37  options.AddOptions("Helicity pattern")
38  ("enable-alternateasym", po::value<bool>()->default_bool_value(false),
39  "enable alternate asymmetries");
40 
41  options.AddOptions("Helicity pattern")
42  ("print-burstsum", po::value<bool>()->default_bool_value(false),
43  "print burst sum of subsystems");
44  options.AddOptions("Helicity pattern")
45  ("print-runningsum", po::value<bool>()->default_bool_value(false),
46  "print running sum of subsystems");
47 
48  options.AddOptions("Helicity pattern")
49  ("burstlength", po::value<int>()->default_value(240),
50  "number of patterns per burst");
51 
52  QwBlinder::DefineOptions(options);
53 }
54 
55 /*****************************************************************/
57 {
58  fEnableBurstSum = options.GetValue<bool>("enable-burstsum");
59  fEnableRunningSum = options.GetValue<bool>("enable-runningsum");
60  fPrintBurstSum = options.GetValue<bool>("print-burstsum");
61  fPrintRunningSum = options.GetValue<bool>("print-runningsum");
62 
63  fEnableDifference = options.GetValue<bool>("enable-differences");
64  fEnableAlternateAsym = options.GetValue<bool>("enable-alternateasym");
65 
66  fBurstLength = options.GetValue<int>("burstlength");
67  if (fBurstLength == 0) DisableBurstSum();
68 
69  if (fEnableAlternateAsym && fPatternSize <= 2){
70  QwWarning << "QwHelicityPattern::ProcessOptions: "
71  << "The 'enable-alternateasym' flag is disabled for pair analysis."
72  << QwLog::endl;
73  fEnableAlternateAsym = kFALSE;
74  }
75 
76  fBlinder.ProcessOptions(options);
77 }
78 
79 /*****************************************************************/
81  : fBlinder(),
82  fHelicityIsMissing(kFALSE),
83  fIgnoreHelicity(kFALSE),
84  fYield(event),
85  fAsymmetry(event),
86  fEnableAlternateAsym(kFALSE),
87  fAsymmetry1(event),
88  fAsymmetry2(event),
89  fEnableBurstSum(kFALSE),
90  fPrintBurstSum(kFALSE),
91  fBurstYield(event),
92  fBurstDifference(event),
93  fBurstAsymmetry(event),
94  fRunningBurstYield(event),
95  fRunningBurstDifference(event),
96  fRunningBurstAsymmetry(event),
97  fEnableRunningSum(kTRUE),
98  fPrintRunningSum(kFALSE),
99  fRunningYield(event),
100  fRunningDifference(event),
101  fRunningAsymmetry(event),
102  fRunningAsymmetry1(event),
103  fRunningAsymmetry2(event),
104  fEnableDifference(kFALSE),
105  fDifference(event),
106  fAlternateDiff(event),
107  fPositiveHelicitySum(event),
108  fNegativeHelicitySum(event),
109  fLastWindowNumber(0),
110  fLastPatternNumber(0),
111  fLastPhaseNumber(0)
112 {
113  // Retrieve the helicity subsystem to query for
114  std::vector<VQwSubsystem*> subsys_helicity = event.GetSubsystemByType("QwHelicity");
115  if (subsys_helicity.size() > 0) {
116 
117  // Take the first helicity subsystem
118  // fHelicitySubsystem = dynamic_cast<QwHelicity*>(subsys_helicity.at(0));
119  QwHelicity* helicity = dynamic_cast<QwHelicity*>(subsys_helicity.at(0));
120 
121  // Get the maximum pattern phase (i.e. pattern size)
122  fPatternSize = helicity->GetMaxPatternPhase();
123 
124  // Warn if more than one helicity subsystem defined
125  if (subsys_helicity.size() > 1)
126  QwWarning << "Multiple helicity subsystems defined! "
127  << "Using " << helicity->GetSubsystemName() << "."
128  << QwLog::endl;
129 
130  } else {
131  // We are not using any helicity subsystem
132  QwError << "No helicity subsystem defined! "
133  << "Calculate asymmetries based on (+--+) quartets!"
134  << QwLog::endl;
135  fHelicityIsMissing = kTRUE;
136  fPatternSize = 4; // default to quartets
137  }
138  QwMessage << "QwHelicity::MaxPatternPhase = " << fPatternSize << QwLog::endl;
139 
140  try
141  {
142  if(fPatternSize%2 == 0)
143  {
144  fEvents.resize(fPatternSize,event);
145  fHelicity.resize(fPatternSize,-9999);
146  fEventNumber.resize(fPatternSize,-1);
147  fEventLoaded.resize(fPatternSize,kFALSE);
148 
149  // Initialize the pattern number
150  fQuartetNumber = 0;
152 
153  // Clear the burst sum
154  ClearBurstSum();
155 
156  // Clear the running sum
157  ClearRunningSum();
158 
159  }
160  else
161  {
162  TString loc=
163  "Standard exception from QwHelicityPattern : the pattern size has to be even; right now pattern_size=";
164  loc+=Form("%d",fPatternSize);
165  throw std::invalid_argument(loc.Data());
166  }
167  }
168  catch (std::exception& e)
169  {
170  std::cerr << e.what() << std::endl;
171  }
172 
173 }
174 
175 
176 //*****************************************************************
177 /**
178  * Load event data corresponding to the current pattern from the
179  * subsystems.
180  */
182 {
183 
184  Bool_t localdebug = kFALSE;
185  fPatternIsGood = kFALSE;
186 
187  Long_t localEventNumber = -1;
188  Long_t localPatternNumber = -1;
189  Int_t localPhaseNumber = -1;
190  Int_t localHelicityActual = -1;
191  Bool_t localIgnoreHelicity = kFALSE;
192 
193 
194  // Get the list of helicity subsystems
195  if (! fHelicityIsMissing){
196  std::vector<VQwSubsystem*> subsys_helicity = event.GetSubsystemByType("QwHelicity");
197  QwHelicity* helicity = 0;
198 
199  if (subsys_helicity.size() > 0) {
200  // Take the first helicity subsystem
201  helicity = dynamic_cast<QwHelicity*>(subsys_helicity.at(0));
202  if (helicity->HasDataLoaded()){
203  localIgnoreHelicity = helicity->IsHelicityIgnored();
204  // Get the event, pattern, phase number and helicity
205  localEventNumber = helicity->GetEventNumber();
206  localPatternNumber = helicity->GetPatternNumber();
207  localPhaseNumber = helicity->GetPhaseNumber() - helicity->GetMinPatternPhase(); // Use "reduced pattern phase", counts from 0.
208  localHelicityActual = helicity->GetHelicityActual();
209  } else {
210  QwError << "QwHelicityPattern::LoadEventData: The helicity subsystem does not have valid data!"
211  << QwLog::endl;
212  }
213  } else {
214  // We are not usng any helicity subsystem
215  static Bool_t user_has_been_warned = kFALSE;
216  if (! user_has_been_warned) {
217  QwError << "No helicity subsystem found! Dropping to \"Missing Helicity\" mode!" << QwLog::endl;
218  user_has_been_warned = kTRUE;
219  fHelicityIsMissing = kTRUE;
220  }
221  }
222  }
223  if (fHelicityIsMissing){
224  localIgnoreHelicity = kTRUE;
225  localPatternNumber = fLastPatternNumber;
226  localEventNumber = fLastWindowNumber + 1;
227  localPhaseNumber = fLastPhaseNumber + 1;
228  if(localPhaseNumber>=fPatternSize){
229  localPatternNumber++;
230  localPhaseNumber = 0; // Use "reduced pattern phase", counts from 0.
231  }
232  fLastWindowNumber = localEventNumber;
233  fLastPhaseNumber = localPhaseNumber;
234  fLastPatternNumber = localPatternNumber;
235  }
236  if(localdebug) {
237  std::cout<<"\n ###################################\n";
238  std::cout<<"QwHelicityPattern::LoadEventData :: ";
239  std::cout<<" event, pattern, phase # "<<localEventNumber<<" "<<localPatternNumber<<" "<<localPhaseNumber<<"\n";
240  std::cout<<" helicity ="<< localHelicityActual<<"\n";
241  for(size_t i=0; i<fEvents.size(); i++)
242  std::cout<<i<<":"<<fEventLoaded[i]<<" ";
243  std::cout<<"\n";
244  }
245  if(fCurrentPatternNumber!=localPatternNumber){
246  // new pattern
247  ClearEventData();
248  fCurrentPatternNumber=localPatternNumber;
249  }
250  if(localPhaseNumber<0){
251  QwWarning << "QwHelicityPattern::LoadEventData: "
252  << "Reduced event phase number is less than zero; ignore this event."
253  << QwLog::endl;
254  ClearEventData();
255  } else if(localPhaseNumber>=fPatternSize){
256  QwWarning<<" In QwHelicityPattern::LoadEventData trying upload an event with a phase larger than expected \n"
257  <<" phase ="<<localPhaseNumber+1<<" maximum expected phase="<<fPatternSize<<"\n"
258  <<" operation impossible, pattern reset to 0: no asymmetries will be computed "<<QwLog::endl;
259  ClearEventData();
260  } else {
261  if(localdebug){
262  std::cout<<"QwHelicityPattern::LoadEventData local i="
263  <<localPhaseNumber<<"\n";
264  }
265  fEvents[localPhaseNumber] = event;
266  fEventLoaded[localPhaseNumber] = kTRUE;
267  fHelicity[localPhaseNumber] = localHelicityActual;
268  fEventNumber[localPhaseNumber] = localEventNumber;
269  // Check to see if we should ignore the helicity; this is
270  // reset to false in ClearEventData.
271  fIgnoreHelicity |= localIgnoreHelicity;
272  SetDataLoaded(kTRUE);
273  }
274  if(localdebug){
275  Print();
276  }
277  return;
278 }
279 
280 //*****************************************************************
281 /**
282  * Check to see if the pattern is complete.
283  */
285 {
286  Bool_t localdebug=kFALSE;
287  Bool_t filled=kTRUE;
288  Int_t i=fPatternSize-1;
289  while(filled && i>-1)
290  {
291  if (localdebug){
292  std::cout<<" i="<<i<<" is loaded ?"
293  <<fEventLoaded[fEvents.size()-i-1]<<"\n";
294  }
295  if(!fEventLoaded[i])
296  filled=kFALSE;
297  i--;
298  }
299 
300 
301 
302  return filled;
303 }
304 
305 
306 //*****************************************************************
307 /**
308  * Calculate asymmetries for the current pattern.
309  */
311 {
312 
313  Bool_t localdebug=kFALSE;
314 
315  if(localdebug) std::cout<<"Entering QwHelicityPattern::CalculateAsymmetry \n";
316 
317  Int_t plushel = 1;
318  Int_t minushel = 0;
319  Int_t checkhel = 0;
320  Bool_t firstplushel=kTRUE;
321  Bool_t firstminushel=kTRUE;
322 
325 
326  if (fIgnoreHelicity){
327  // Don't check to see if we have equal numbers of even and odd helicity states in this pattern.
328  // Build an asymmetry with even-parity phases as "+" and odd-parity phases as "-"
329  for (size_t i = 0; i < (size_t) fPatternSize; i++) {
330  Int_t localhel = 1;
331  for (size_t j = 0; j < (size_t) fPatternSize/2; j++) {
332  localhel ^= ((i >> j)&0x1);
333  }
334  if (localhel == plushel) {
335  if (firstplushel) {
337  firstplushel = kFALSE;
338  } else {
339  fPositiveHelicitySum += fEvents.at(i);
340  }
341  } else if (localhel == minushel) {
342  if (firstminushel) {
344  firstminushel = kFALSE;
345  } else {
346  fNegativeHelicitySum += fEvents.at(i);
347  }
348  }
349  }
350  } else {
351  //
352  for (size_t i = 0; i < (size_t) fPatternSize; i++) {
353  if (fHelicity[i] == plushel) {
354  if (localdebug) std::cout<<"QwHelicityPattern::CalculateAsymmetry: here filling fPositiveHelicitySum \n";
355  if (firstplushel) {
356  if (localdebug) std::cout<<"QwHelicityPattern::CalculateAsymmetry: with = \n";
358  firstplushel = kFALSE;
359  } else {
360  if (localdebug) std::cout<<"QwHelicityPattern::CalculateAsymmetry: with += \n";
361  fPositiveHelicitySum += fEvents.at(i);
362  }
363  checkhel += 1;
364  } else if (fHelicity[i] == minushel) {
365  if (localdebug) std::cout<<"QwHelicityPattern::CalculateAsymmetry: here filling fNegativeHelicitySum \n";
366  if (firstminushel) {
367  if (localdebug) std::cout<<"QwHelicityPattern::CalculateAsymmetry: with = \n";
369  firstminushel = kFALSE;
370  } else {
371  if (localdebug) std::cout<<"QwHelicityPattern::CalculateAsymmetry: with += \n";
372  fNegativeHelicitySum += fEvents.at(i);
373  }
374  checkhel -= 1;
375  } else {
376  QwDebug << "QwHelicityPattern::CalculateAsymmetry: "
377  << "Helicity should be "<<plushel<<" or "<<minushel
378  <<" but is "<< fHelicity[i]
379  << "; Asymmetry computation aborted!"<<QwLog::endl;
380  ClearEventData();
381  i = fPatternSize;
382  checkhel = -9999;
383  // This is an unknown helicity event.
384  }
385  }
386  }
387 
388  if (checkhel == -9999) {
389  //do nothing the asymmetry computation has been aborted earlier in this function
390  fPatternIsGood = kFALSE;
391  } else if (checkhel!=0) {
392  fPatternIsGood = kFALSE;
393  // there is a different number of plus and minus helicity window.
394  QwError<<" QwHelicityPattern::CalculateAsymmetry == \n"
395  <<" you do not have the same number of positive and negative \n"
396  <<" impossible to compute assymetry \n"
397  <<" dropping every thing -- pattern number ="<<fCurrentPatternNumber<<QwLog::endl;
398  } else {
399  // This is a good pattern.
400  // Calculate the asymmetry.
401  fPatternIsGood = kTRUE;
402  fQuartetNumber++;//Then increment the quartet number
403  //std::cout<<" quartet count ="<<fQuartetNumber<<"\n";
404 
409 
410 
411 
412  if (! fIgnoreHelicity){
413  // Only blind the difference if we're using the real helicity.
415  // Update the global error code in fDifference, and use it
416  // to update the errors in fYield, in case blinder errors
417  // can propagate to the global error.
420  }
423 
424  /*
425  With additional two asymmetry calculations
426  Don't blind them!
427 
428  quartet pattern + - - +
429  1 2 3 4
430  fAsymmetry = (1+4)-(2+3)/(1+2+3+4)
431  fAsymmetry1 = (1+2)-(3+4)/(1+2+3+4)
432  fAsymmetry2 = (1+3)-(2+4)/(1+2+3+4)
433  */
434  if (fEnableAlternateAsym) {
435  // fAsymmetry1: (first 1/2 pattern - second 1/2 pattern)/fYield
440  if (fPatternSize/2 > 1){
441  for (size_t i = 1; i < (size_t) fPatternSize/2 ; i++){
442  fPositiveHelicitySum += fEvents.at(i);
444  }
445  }
449  // Do not blind this helicity-uncorrelated difference.
451  // fAsymmetry2: (even events - odd events)/fYield
452  // Only build fAsymmetry2 if fPatternSize>2.
453  if (fPatternSize > 2) {
458  if (fPatternSize/2 > 1){
459  for (size_t i = 1; i < (size_t) fPatternSize/2 ; i++){
460  fPositiveHelicitySum += fEvents.at(2*i);
461  fNegativeHelicitySum += fEvents.at(2*i + 1);
462  }
463  }
467  // Do not blind this helicity-uncorrelated difference.
469  }
470  }
471 
472  // Accumulate the burst and running sums
475 
476  if (localdebug) QwDebug << " pattern number =" << fQuartetNumber << QwLog::endl;
477  }
478 
479  return;
480 }
481 
482 //*****************************************************************
483 /**
484  * Clear event data and the vectors used for the calculation of.
485  * yields and asymmetries.
486  */
488 {
489  fIgnoreHelicity = kFALSE;
490  for(size_t i=0; i<fEvents.size(); i++)
491  {
492  fEvents[i].ClearEventData();
493  fEventLoaded[i]=kFALSE;
494  fHelicity[i]=-999;
495  }
497 
498  // Primary yield and asymmetry
501  // Alternate asymmetries
505  }
506 
511 
512  fPatternIsGood = kFALSE;
513  SetDataLoaded(kFALSE);
514 }
515 
516 //*****************************************************************
517 /**
518  * Clear the running sums of yield, difference and asymmetry.
519  * Also clear the running burst sums if enabled.
520  */
522 {
523  if (fEnableRunningSum) {
527  // Running alternate asymmetries
528  if (fEnableAlternateAsym) {
531  }
532  // Running burst sums
533  if (fEnableBurstSum) {
537  }
538  }
539 }
540 
541 //*****************************************************************
542 /**
543  * Clear the burst sums of yield and difference. No asymmetry
544  * burst sum is used.
545  */
547 {
548  if (fEnableBurstSum) {
552  }
553 }
554 
555 //*****************************************************************
556 /**
557  * Accumulate the burst sum by adding this helicity pattern to the
558  * burst sums of yield and difference. There is no burst sum of
559  * asymmetry, because that can only be calculated with meaningful
560  * moments at the end of a burst.
561  */
563 {
564  if (fPatternIsGood){
567  // The difference is blinded, so the burst difference is also blinded.
568  }
569 }
570 
571 //*****************************************************************
572 /**
573  * Accumulate the running sum by adding this helicity pattern to the
574  * running sums of yield, difference and asymmetry.
575  */
577 {
578  if (fPatternIsGood){
580  if (fEnableDifference){
582  // The difference is blinded, so the running difference is also blinded.
583  }
585  if (fEnableAlternateAsym) {
588  }
589  }
590 }
591 
592 //*****************************************************************
593 /**
594  * Accumulate the running burst sum by adding the current burst sum
595  * to the running sums of burst yield, difference and asymmetry.
596  */
598 {
599  // Accumulate the burst yield and difference
600  if (fEnableRunningSum) {
603  // The burst difference is blinded, so the running burst difference is also blinded.
604  }
605 
606  // Calculate asymmetry over this entire burst
608  // Accumulate this burst asymmetry
610 
611  // Be sure to clear the burst sums after this function!
612 }
613 
614 //*****************************************************************
615 /**
616  * Calculate the average burst yield, difference and asymmetry.
617  */
619 {
623 
625 }
626 
627 //*****************************************************************
628 /**
629  * Calculate the average running burst yield, difference and asymmetry.
630  */
632 {
636 
638 }
639 
640 //*****************************************************************
642 {
644  if (fEnableDifference){
646  }
648  if (fEnableAlternateAsym) {
651  }
653 }
654 
655 //*****************************************************************
657 {
658  QwMessage << " Running burst average of asymmetry" << QwLog::endl;
659  QwMessage << " ==============================" << QwLog::endl;
661 
662  QwMessage << " Running burst average of difference" << QwLog::endl;
663  QwMessage << " ==============================" << QwLog::endl;
665 
666  QwMessage << " Running burst average of yields" << QwLog::endl;
667  QwMessage << " ==============================" << QwLog::endl;
669 }
670 
671 //*****************************************************************
673 {
674  QwMessage << "QwHelicityPattern::PrintRunningAverage() const " << QwLog::endl;
675  // QwMessage << " Running average of yields " << QwLog::endl;
677  // QwMessage << " Running average of asymmetry " << QwLog::endl;
679  if (fEnableAlternateAsym) {
680  // QwMessage << " Running average of first half/second half asymmetry " << QwLog::endl;
682  // QwMessage << " Running average of even/odd asymmetry " << QwLog::endl;
684  }
685  if (fEnableDifference){
686  // QwMessage << " Running average of difference " << QwLog::endl;
688  }
689 
690 }
691 
692 //*****************************************************************
694 {
695  QwMessage << " Burst average of asymmetry " << QwLog::endl;
696  QwMessage << " ==============================" << QwLog::endl;
698 
699  QwMessage << " Burst average of difference " << QwLog::endl;
700  QwMessage << " ==============================" << QwLog::endl;
702 
703  QwMessage << " Burst average of yields " << QwLog::endl;
704  QwMessage << " ==============================" << QwLog::endl;
706 }
707 
708 //*****************************************************************
710 {
711  TString prefix = "yield_";
712  fYield.ConstructHistograms(folder,prefix);
713  prefix = "asym_";
714  fAsymmetry.ConstructHistograms(folder,prefix);
715 
716  if (fEnableDifference) {
717  prefix = "diff_";
718  fDifference.ConstructHistograms(folder,prefix);
719  }
720  if (fEnableAlternateAsym) {
721  prefix = "asym1_";
722  fAsymmetry1.ConstructHistograms(folder,prefix);
723  prefix = "asym2_";
724  fAsymmetry2.ConstructHistograms(folder,prefix);
725  }
726 }
727 
729 {
730  if (fPatternIsGood) {
733  if (fEnableDifference) {
735  }
739  }
740  }
741 }
742 
743 void QwHelicityPattern::ConstructBranchAndVector(TTree *tree, TString & prefix, std::vector <Double_t> &values)
744 {
745  TString newprefix = "yield_" + prefix;
746  fYield.ConstructBranchAndVector(tree, newprefix, values);
747  newprefix = "asym_" + prefix;
748  fAsymmetry.ConstructBranchAndVector(tree, newprefix, values);
749 
750  if (fEnableDifference) {
751  newprefix = "diff_" + prefix;
752  fDifference.ConstructBranchAndVector(tree, newprefix, values);
753  }
754  if (fEnableAlternateAsym) {
755  newprefix = "asym1_" + prefix;
756  fAsymmetry1.ConstructBranchAndVector(tree, newprefix, values);
757  newprefix = "asym2_" + prefix;
758  fAsymmetry2.ConstructBranchAndVector(tree, newprefix, values);
759  }
760 }
761 
762 void QwHelicityPattern::ConstructBranch(TTree *tree, TString & prefix)
763 {
764  TString newprefix = "yield_" + prefix;
765  fYield.ConstructBranch(tree, newprefix);
766  newprefix = "asym_" + prefix;
767  fAsymmetry.ConstructBranch(tree, newprefix);
768 
769  if (fEnableDifference) {
770  newprefix = "diff_" + prefix;
771  fDifference.ConstructBranch(tree, newprefix);
772  }
773  if (fEnableAlternateAsym) {
774  newprefix = "asym1_" + prefix;
775  fAsymmetry1.ConstructBranch(tree, newprefix);
776  newprefix = "asym2_" + prefix;
777  fAsymmetry2.ConstructBranch(tree, newprefix);
778  }
779 }
780 
781 void QwHelicityPattern::ConstructBranch(TTree *tree, TString & prefix, QwParameterFile &trim_tree)
782 {
783  TString newprefix = "yield_" + prefix;
784  fYield.ConstructBranch(tree, newprefix, trim_tree);
785  newprefix = "asym_" + prefix;
786  fAsymmetry.ConstructBranch(tree, newprefix, trim_tree);
787 
788  if (fEnableDifference) {
789  newprefix = "diff_" + prefix;
790  fDifference.ConstructBranch(tree, newprefix);
791  }
792  if (fEnableAlternateAsym) {
793  newprefix = "asym1_" + prefix;
794  fAsymmetry1.ConstructBranch(tree, newprefix, trim_tree);
795  newprefix = "asym2_" + prefix;
796  fAsymmetry2.ConstructBranch(tree, newprefix, trim_tree);
797  }
798 }
799 
800 void QwHelicityPattern::FillTreeVector(std::vector<Double_t> &values) const
801 {
802  if (fPatternIsGood) {
803  fYield.FillTreeVector(values);
804  fAsymmetry.FillTreeVector(values);
805  if (fEnableDifference) {
806  fDifference.FillTreeVector(values);
807  }
808  if (fEnableAlternateAsym) {
809  fAsymmetry1.FillTreeVector(values);
810  fAsymmetry2.FillTreeVector(values);
811  }
812  }
813 }
814 
815 
817 {
818  fBlinder.FillDB(db,"");
819 
820  fRunningYield.FillDB(db, "yield");
821  fRunningAsymmetry.FillDB(db, "asymmetry");
822  if (fEnableDifference) {
823  fRunningDifference.FillDB(db, "difference");
824  }
825  if (fEnableAlternateAsym) {
826  fRunningAsymmetry1.FillDB(db, "asymmetry1");
827  fRunningAsymmetry2.FillDB(db, "asymmetry2");
828  }
829 }
830 
831 
833 {
834  fBlinder.FillErrDB(db,"");
835  fAsymmetry.FillErrDB(db, "");
836  return;
837 };
838 
839 
841 {
842  fRunningYield.WritePromptSummary(ps, "yield");
843  fRunningAsymmetry.WritePromptSummary(ps, "asymmetry");
844 
845  return;
846 };
847 
848 
849 //*****************************************************************
850 
852 {
853  QwOut << "Pattern number = " << fCurrentPatternNumber << QwLog::endl;
854  for (Int_t i = 0; i < fPatternSize; i++)
855  QwOut << "Event " << fEventNumber[i] << ": "
856  << fEventLoaded[i] << ", " << fHelicity[i] << QwLog::endl;
857  QwOut << "Is a complete pattern? (n/y:0/1) " << IsCompletePattern() << QwLog::endl;
858 }
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
void ProcessOptions(QwOptions &options)
Update the status with new external information.
Definition: QwBlinder.cc:112
void FillHistograms()
Fill the histograms for this subsystem.
void FillErrDB(QwParityDB *db, TString datatype)
Definition: QwBlinder.cc:1014
Int_t GetPhaseNumber()
Definition: QwHelicity.cc:1084
std::vector< Int_t > fEventNumber
void PrintValue() const
Print value of all channels.
QwSubsystemArrayParity fBurstDifference
#define QwOut
Predefined log drain for explicit output.
Definition: QwLog.h:35
Bool_t IsHelicityIgnored()
Definition: QwHelicity.h:140
void ConstructHistograms()
Construct the histograms for this subsystem.
QwSubsystemArrayParity fDifference
#define default_bool_value(b)
Definition: QwOptions.h:51
void WritePromptSummary(QwPromptSummary *ps, TString type)
QwSubsystemArrayParity fRunningBurstDifference
QwSubsystemArrayParity fRunningAsymmetry
std::vector< Bool_t > fEventLoaded
void DisableBurstSum()
Disable burst sum calculation.
An options class.
Definition: QwOptions.h:133
QwSubsystemArrayParity fBurstAsymmetry
void Sum(const QwSubsystemArrayParity &value1, const QwSubsystemArrayParity &value2)
Sum of two subsystem arrays.
static void DefineOptions(QwOptions &options)
Define the configuration options.
void ConstructBranch(TTree *tree, TString &prefix)
QwHelicityPattern()
Private default constructor (not implemented, will throw linker error on use)
QwSubsystemArrayParity fNegativeHelicitySum
void AccumulateRunningSum(const QwSubsystemArrayParity &value)
Update the running sums for devices accumulated for the global error non-zero events/patterns.
static void DefineOptions(QwOptions &options)
Definition: QwBlinder.cc:54
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
Construct a branch and vector for this subsystem with a prefix.
QwSubsystemArrayParity fYield
void WritePromptSummary(QwPromptSummary *ps)
Bool_t HasDataLoaded() const
Definition: VQwSubsystem.h:94
Long_t GetPatternNumber()
Definition: QwHelicity.cc:1074
static const double e
Definition: QwUnits.h:91
void CalculateRunningAverage()
Calculate the average for all good events.
QwSubsystemArrayParity fAlternateDiff
Bool_t IsCompletePattern() const
QwSubsystemArrayParity fAsymmetry
void PrintBurstAverage() const
Int_t GetMaxPatternPhase()
Definition: QwHelicity.h:100
po::options_description_easy_init AddOptions(const std::string &blockname="Specialized options")
Add an option to a named block or create new block.
Definition: QwOptions.h:164
QwSubsystemArrayParity fPositiveHelicitySum
Long_t GetEventNumber()
Definition: QwHelicity.cc:1079
QwSubsystemArrayParity fRunningBurstYield
Int_t GetMinPatternPhase()
Definition: QwHelicity.h:103
QwSubsystemArrayParity fAsymmetry2
void Difference(const QwSubsystemArrayParity &value1, const QwSubsystemArrayParity &value2)
Difference of two subsystem arrays.
Definition of the pure virtual base class of all data elements.
T GetValue(const std::string &key)
Get a templated value.
Definition: QwOptions.h:240
Virtual base class for the parity subsystems.
void FillErrDB(QwParityDB *db, TString type)
void Scale(Double_t factor)
Scale this subsystem array.
void PrintRunningAverage() const
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
A logfile class, based on an identical class in the Hermes analyzer.
void Blind(QwSubsystemArrayParity &diff)
Blind the asymmetry of an array of subsystems.
Definition: QwBlinder.h:174
void ClearEventData()
Definition: QwBlinder.h:105
void FillTreeVector(std::vector< Double_t > &values) const
void ProcessOptions(QwOptions &options)
Process the configuration options.
void FillDB(QwParityDB *db, TString type)
Fill the database.
void FillDB(QwParityDB *db, TString datatype)
Write to the database.
Definition: QwBlinder.cc:937
void ConstructBranch(TTree *tree, TString &prefix)
Construct a branch for this subsystem with a prefix.
QwSubsystemArrayParity fRunningAsymmetry1
void SetDataLoaded(Bool_t flag)
QwSubsystemArrayParity fRunningAsymmetry2
A class for blinding data, adapted from G0 blinder class.
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
void LoadEventData(QwSubsystemArrayParity &event)
void FillErrDB(QwParityDB *db)
QwSubsystemArrayParity fAsymmetry1
void PrintRunningBurstAverage() const
void IncrementErrorCounters()
Update the data elements&#39; error counters based on their internal error flags.
#define QwWarning
Predefined log drain for warnings.
Definition: QwLog.h:45
std::vector< Int_t > fHelicity
std::vector< QwSubsystemArrayParity > fEvents
void UpdateErrorFlag()
Update the error flag internally from all the subsystems.
void FillDB(QwParityDB *db)
Int_t GetHelicityActual()
Definition: QwHelicity.cc:1064
QwSubsystemArrayParity fRunningDifference
QwSubsystemArrayParity fRunningYield
QwSubsystemArrayParity fBurstYield
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40
QwSubsystemArrayParity fRunningBurstAsymmetry
TString GetSubsystemName() const
Definition: VQwSubsystem.h:93
void FillTreeVector(std::vector< Double_t > &values) const
Fill the vector for this subsystem.
void Ratio(const QwSubsystemArrayParity &numer, const QwSubsystemArrayParity &denom)
Ratio of two subsystem arrays.