QwAnalysis
QwRegression.h
Go to the documentation of this file.
1 /*
2  * QwRegression.h
3  *
4  * Created on: Oct 22, 2010
5  * Author: wdconinc
6  */
7 
8 #ifndef QWREGRESSION_H_
9 #define QWREGRESSION_H_
10 
11 // Qweak headers
12 #include "QwHelicityPattern.h"
13 #include "QwSubsystemArrayParity.h"
14 #include "VQwHardwareChannel.h"
15 
16 /**
17  * ... info to follow ... really, I promise ...
18  */
19 class QwRegression {
20 
21  public:
22 
23  /// Type of regression variable
24  enum EQwRegType {
26  };
27 
28  typedef std::vector< std::pair< VQwHardwareChannel*,VQwHardwareChannel*> >::iterator PairIterator;
29  typedef std::vector< std::pair< VQwHardwareChannel*,VQwHardwareChannel*> >::const_iterator PairConstIterator;
30 
31  public:
32 
33  /// \brief Constructor with single event and helicity pattern
34  QwRegression(QwOptions &options,
36  QwHelicityPattern& helicitypattern);
37  /// \brief Constructor with single event
39  /// \brief Constructor with helicity pattern
40  QwRegression(QwOptions &options, QwHelicityPattern& helicitypattern);
41  /// \brief Constructor with only options
42  QwRegression(QwOptions &options);
43  /// \brief Copy constructor
44  QwRegression(const QwRegression &source);
45  /// Virtual destructor
46  virtual ~QwRegression();
47 
48 
49  /// \brief Define the configuration options
50  static void DefineOptions(QwOptions &options);
51  /// \brief Process the configuration options
52  void ProcessOptions(QwOptions &options);
53 
54 
55  /// \brief Load the channels and sensitivities
56  Int_t LoadChannelMap(const std::string& mapfile);
57  /// \brief Connect to channels
61  /// \brief Connect to Channels (event only)
63  /// \brief Connect to Channels (asymmetry/difference only)
66 
67  /// \brief Linear regression
68  void LinearRegression(EQwRegType type);
69 
70 
71  /// \name Tree and vector construction and maintenance
72  // @{
73  /// Construct the tree and vector for this subsystem
74  void ConstructBranchAndVector(TTree *tree, std::vector <Double_t> &values) {
75  TString tmpstr("");
76  ConstructBranchAndVector(tree,tmpstr,values);
77  };
78  /// \brief Construct a branch and vector for this subsystem with a prefix
79  void ConstructBranchAndVector(TTree *tree, TString& prefix, std::vector <Double_t> &values);
80 
81  /// \brief Fill the vector for this subsystem
82  void FillTreeVector(std::vector<Double_t> &values) const;
83  // @}
84 
85 
86 
89  void PrintValue() const;
90  void FillDB(QwParityDB *db, TString datatype);
91  private:
92 
93  /// Private default constructor
94  QwRegression() { };
95 
96  protected:
97  /// Flag to enable regression
98  bool fEnableRegression;
99 
100  /// Regression dependent and independent variable map
101  std::string fRegressionMapFile;
102 
103  /// Single event pointer
105  /// Helicity pattern pointer
107 
108  UInt_t fErrorFlag;
109 
110  /// Parse regression variable in type and name
111  std::pair<EQwRegType,std::string> ParseRegressionVariable(const std::string& variable);
112 
113  /// List of channels to use in the regression
114  std::vector< EQwRegType > fDependentType;
115  std::vector< std::string > fDependentName;
116  std::vector< std::vector< EQwRegType > > fIndependentType;
117  std::vector< std::vector< std::string > > fIndependentName;
118  std::vector< std::vector< Double_t> > fSensitivity;
119 
120  std::vector< EQwRegType > fDependentVarType;
121  std::vector< std::pair< VQwHardwareChannel*, VQwHardwareChannel*> > fDependentVar;
122  std::vector< std::vector< std::pair< Double_t, const VQwHardwareChannel* > > > fIndependentVar;
123 
124 
125 }; // class QwRegression
126 
127 inline std::ostream& operator<< (std::ostream& stream, const QwRegression::EQwRegType& i) {
128  switch (i){
129  case QwRegression::kRegTypeMps: stream << "mps"; break;
130  case QwRegression::kRegTypeAsym: stream << "asym"; break;
131  case QwRegression::kRegTypeDiff: stream << "diff"; break;
132  default: stream << "Unknown";
133  }
134  return stream;
135 }
136 
137 
138 #endif // QWREGRESSION_H_
std::vector< std::string > fDependentName
Definition: QwRegression.h:115
std::string fRegressionMapFile
Regression dependent and independent variable map.
Definition: QwRegression.h:101
std::pair< EQwRegType, std::string > ParseRegressionVariable(const std::string &variable)
Parse regression variable in type and name.
QwSubsystemArrayParity * fSubsystemArray
Single event pointer.
Definition: QwRegression.h:104
std::ostream & operator<<(std::ostream &out, const QwColor &color)
Output stream operator which uses the enum-to-escape-code mapping.
Definition: QwColor.h:153
std::vector< std::vector< Double_t > > fSensitivity
Definition: QwRegression.h:118
virtual ~QwRegression()
Virtual destructor.
An options class.
Definition: QwOptions.h:133
EQwRegType
Type of regression variable.
Definition: QwRegression.h:24
void AccumulateRunningSum(QwRegression value)
std::vector< std::pair< VQwHardwareChannel *, VQwHardwareChannel * > > fDependentVar
Definition: QwRegression.h:121
QwHelicityPattern * fHelicityPattern
Helicity pattern pointer.
Definition: QwRegression.h:106
void LinearRegression(EQwRegType type)
Linear regression.
UInt_t fErrorFlag
Definition: QwRegression.h:108
std::vector< std::vector< std::pair< Double_t, const VQwHardwareChannel * > > > fIndependentVar
Definition: QwRegression.h:122
void CalculateRunningAverage()
Virtual base class for the parity subsystems.
std::vector< std::vector< std::string > > fIndependentName
Definition: QwRegression.h:117
void FillDB(QwParityDB *db, TString datatype)
bool fEnableRegression
Flag to enable regression.
Definition: QwRegression.h:94
static void DefineOptions(QwOptions &options)
Define the configuration options.
void PrintValue() const
void ConstructBranchAndVector(TTree *tree, std::vector< Double_t > &values)
Construct the tree and vector for this subsystem.
Definition: QwRegression.h:74
Int_t ConnectChannels(QwSubsystemArrayParity &event, QwSubsystemArrayParity &asym, QwSubsystemArrayParity &diff)
Connect to channels.
void FillTreeVector(std::vector< Double_t > &values) const
Fill the vector for this subsystem.
void ProcessOptions(QwOptions &options)
Process the configuration options.
QwRegression()
Private default constructor.
Definition: QwRegression.h:94
Int_t LoadChannelMap(const std::string &mapfile)
Load the channels and sensitivities.
std::vector< std::vector< EQwRegType > > fIndependentType
Definition: QwRegression.h:116
std::vector< EQwRegType > fDependentVarType
Definition: QwRegression.h:120
std::vector< std::pair< VQwHardwareChannel *, VQwHardwareChannel * > >::const_iterator PairConstIterator
Definition: QwRegression.h:29
std::vector< EQwRegType > fDependentType
List of channels to use in the regression.
Definition: QwRegression.h:114
std::vector< std::pair< VQwHardwareChannel *, VQwHardwareChannel * > >::iterator PairIterator
Definition: QwRegression.h:28