JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwCorrelatorNew Class Reference

Data handler computing correlations and linear-regression coefficients. More...

#include <QwCorrelatorNew.h>

+ Inheritance diagram for QwCorrelatorNew:
+ Collaboration diagram for QwCorrelatorNew:

Public Member Functions

 QwCorrelatorNew (const TString &name)
 Constructor with name.
 
 QwCorrelatorNew (const QwCorrelatorNew &name)
 
 ~QwCorrelatorNew () override
 
void ProcessOptions (QwOptions &options)
 
void ParseConfigFile (QwParameterFile &file) override
 
Int_t LoadChannelMap (const std::string &mapfile) override
 
Int_t ConnectChannels (QwSubsystemArrayParity &asym, QwSubsystemArrayParity &diff) override
 Connect to Channels (asymmetry/difference only)
 
void ProcessData () override
 
void FinishDataHandler () override
 
void CalcCorrelations ()
 
void ConstructTreeBranches (QwRootFile *treerootfile, const std::string &treeprefix="", const std::string &branchprefix="") override
 Construct the tree branches.
 
void FillTreeBranches (QwRootFile *treerootfile) override
 Fill the tree branches.
 
void ConstructHistograms (TDirectory *folder, TString &prefix) override
 Construct the histograms in a folder with a prefix.
 
void FillHistograms () override
 Fill the histograms.
 
void ClearEventData () override
 
void AccumulateRunningSum (VQwDataHandler &value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override
 
void solve ()
 
bool failed ()
 
void printSummaryP () const
 
void printSummaryY () const
 
void printSummaryYP () const
 
void printSummaryAlphas () const
 
void printSummaryMeansWithUnc () const
 
void printSummaryMeansWithUncCorrected () const
 
void print ()
 
void init ()
 
void clear ()
 
void setDims (int a, int b)
 
Int_t getMeanP (const int i, Double_t &mean) const
 Get mean value of a variable, returns error code.
 
Int_t getMeanY (const int i, Double_t &mean) const
 
Int_t getMeanYprime (const int i, Double_t &mean) const
 
Int_t getSigmaP (const int i, Double_t &sigma) const
 Get mean value of a variable, returns error code.
 
Int_t getSigmaY (const int i, Double_t &sigma) const
 
Int_t getSigmaYprime (const int i, Double_t &sigma) const
 
Int_t getCovarianceP (int i, int j, Double_t &covar) const
 Get mean value of a variable, returns error code.
 
Int_t getCovariancePY (int ip, int iy, Double_t &covar) const
 
Int_t getCovarianceY (int i, int j, Double_t &covar) const
 
double getUsedEve () const
 
QwCorrelatorNewoperator+= (const std::pair< TVectorD, TVectorD > &rhs)
 
QwCorrelatorNewoperator+= (const QwCorrelatorNew &rhs)
 
- Public Member Functions inherited from VQwDataHandler
 VQwDataHandler (const TString &name)
 
 VQwDataHandler (const VQwDataHandler &source)
 
void SetPointer (QwHelicityPattern *ptr)
 
void SetPointer (QwSubsystemArrayParity *ptr)
 
virtual Int_t ConnectChannels (QwSubsystemArrayParity &, QwSubsystemArrayParity &asym, QwSubsystemArrayParity &diff)
 
virtual Int_t ConnectChannels (QwSubsystemArrayParity &)
 
Int_t ConnectChannels (QwHelicityPattern &helicitypattern)
 
virtual void UpdateBurstCounter (Short_t burstcounter)
 
 ~VQwDataHandler () override
 
TString GetName ()
 
void InitRunningSum ()
 
void AccumulateRunningSum ()
 
void CalculateRunningAverage ()
 
void PrintValue () const
 
void WritePromptSummary (QwPromptSummary *ps, TString type)
 
virtual void ConstructNTupleFields (QwRootFile *treerootfile, const std::string &treeprefix="", const std::string &branchprefix="")
 RNTuple methods.
 
virtual void FillNTupleFields (QwRootFile *treerootfile)
 
void FillTreeVector (QwRootTreeBranchVector &values) const
 
void ConstructBranchAndVector (TTree *tree, TString &prefix, QwRootTreeBranchVector &values)
 
void SetRunLabel (TString x)
 
Int_t LoadChannelMap ()
 
Bool_t PublishInternalValues () const override
 Publish all variables of the subsystem.
 
Bool_t PublishByRequest (TString device_name) override
 Try to publish an internal variable matching the submitted name.
 
- Public Member Functions inherited from MQwPublishable_child< QwDataHandlerArray, VQwDataHandler >
 MQwPublishable_child ()
 Default constructor Initializes the child object and sets up self-reference for publishing.
 
 MQwPublishable_child (const MQwPublishable_child &source)
 Copy constructor.
 
virtual ~MQwPublishable_child ()
 Virtual destructor.
 
void SetParent (QwDataHandlerArray *parent)
 Set the parent container for this child object.
 
QwDataHandlerArrayGetParent () const
 Get the parent container for this child object.
 
- Public Member Functions inherited from MQwCloneable< VQwDataHandler, QwCorrelatorNew >
 ~MQwCloneable () override
 Virtual destructor.
 
VQwDataHandlerClone () const override
 Concrete clone method.
 
const VQwFactory< VQwDataHandler > * Factory () const override
 Factory getter.
 
- Public Member Functions inherited from VQwCloneable< VQwDataHandler >
virtual ~VQwCloneable ()
 Virtual destructor.
 
std::string GetClassName () const
 Get demangled name of this class.
 

Static Public Member Functions

static void DefineOptions (QwOptions &options)
 
- Static Public Member Functions inherited from MQwCloneable< VQwDataHandler, QwCorrelatorNew >
static VQwDataHandlerCreate (const std::string &name)
 Object creation.
 
static QwCorrelatorNewCast (QwCorrelatorNew *type)
 Object dynamic cast.
 

Protected Member Functions

void OpenAlphaFile (const std::string &prefix)
 
void WriteAlphaFile ()
 
void CloseAlphaFile ()
 
void OpenAliasFile (const std::string &prefix)
 
void WriteAliasFile ()
 
void CloseAliasFile ()
 
- Protected Member Functions inherited from VQwDataHandler
 VQwDataHandler ()
 
void SetEventcutErrorFlagPointer (const UInt_t *errorflagptr)
 
UInt_t GetEventcutErrorFlag () const
 
std::pair< EQwHandleType, std::string > ParseHandledVariable (const std::string &variable)
 
void CalcOneOutput (const VQwHardwareChannel *dv, VQwHardwareChannel *output, std::vector< const VQwHardwareChannel * > &ivs, std::vector< Double_t > &sens)
 
- Protected Member Functions inherited from MQwPublishable_child< QwDataHandlerArray, VQwDataHandler >
Bool_t RequestExternalValue (const TString &name, VQwHardwareChannel *value) const
 Retrieve the variable name from other subsystem arrays Get the value corresponding to some variable name from a different data array.
 
const VQwHardwareChannelRequestExternalPointer (const TString &name) const
 Retrieve a pointer to an external variable by name Requests a direct pointer to a variable from sibling subsystems via the parent container.
 
Bool_t PublishInternalValue (const TString name, const TString desc, const VQwHardwareChannel *element) const
 Publish a variable from this child into the parent container.
 

Protected Attributes

Int_t fBlock
 
bool fDisableHistos
 
std::vector< std::string > fIndependentFull
 
std::vector< EQwHandleTypefIndependentType
 
std::vector< std::string > fIndependentName
 
std::vector< const VQwHardwareChannel * > fIndependentVar
 
std::vector< Double_t > fIndependentValues
 
std::string fAlphaOutputFileBase
 
std::string fAlphaOutputFileSuff
 
std::string fAlphaOutputPath
 
TFile * fAlphaOutputFile
 
TTree * fTree
 
std::string fAliasOutputFileBase
 
std::string fAliasOutputFileSuff
 
std::string fAliasOutputPath
 
std::ofstream fAliasOutputFile
 
int fTotalCount
 
int fGoodCount
 
int fErrCounts_EF
 
std::vector< int > fErrCounts_IV
 
std::vector< int > fErrCounts_DV
 
unsigned int fGoodEvent
 
- Protected Attributes inherited from VQwDataHandler
Int_t fPriority
 
Short_t fBurstCounter
 When a datahandler array is processed, handlers with lower priority will be processed before handlers with higher priority.
 
TString fName
 
std::string fMapFile
 
std::string fTreeName
 
std::string fTreeComment
 
std::string fPrefix
 
TString run_label
 
const UInt_t * fErrorFlagPtr
 Error flag pointer.
 
QwSubsystemArrayParityfSubsystemArray
 Single event pointer.
 
QwHelicityPatternfHelicityPattern
 Helicity pattern pointer.
 
std::vector< std::string > fDependentFull
 
std::vector< EQwHandleTypefDependentType
 
std::vector< std::string > fDependentName
 
std::vector< const VQwHardwareChannel * > fDependentVar
 
std::vector< Double_t > fDependentValues
 
std::vector< VQwHardwareChannel * > fOutputVar
 
std::vector< Double_t > fOutputValues
 
std::vector< std::vector< TString > > fPublishList
 
std::string ParseSeparator
 
Bool_t fKeepRunningSum
 
Bool_t fRunningsumFillsTree
 
VQwDataHandlerfRunningsum
 

Private Member Functions

 QwCorrelatorNew ()
 

Private Attributes

TString fNameNoSpaces
 
int nP
 
int nY
 
std::vector< TH1D > fHnames
 
std::vector< TH1D > fH1iv
 
std::vector< TH1D > fH1dv
 
std::vector< std::vector< TH2D > > fH2iv
 
std::vector< std::vector< TH2D > > fH2dv
 
Int_t fCycleCounter
 
Int_t fErrorFlag
 is information valid
 
Long64_t fGoodEventNumber
 accumulated so far
 
TMatrixD mRPY
 correlations
 
TMatrixD mRYP
 
TMatrixD mRPP
 
TMatrixD mRYY
 
TMatrixD mRYYp
 
TMatrixD mVPY
 unnormalized covariances
 
TMatrixD mVYP
 
TMatrixD mVPP
 
TMatrixD mVYY
 
TMatrixD mVYYp
 
TVectorD mVP
 variances
 
TVectorD mVY
 
TVectorD mVYp
 
TMatrixD mSPY
 normalized covariances
 
TMatrixD mSYP
 
TMatrixD mSPP
 
TMatrixD mSYY
 
TMatrixD mSYYp
 
TVectorD mSP
 sigmas
 
TVectorD mSY
 
TVectorD mSYp
 
TVectorD mMP
 mean values
 
TVectorD mMY
 
TVectorD mMYp
 
TMatrixD Axy
 slopes
 
TMatrixD Ayx
 
TMatrixD dAxy
 
TMatrixD dAyx
 

Static Private Attributes

static bool fPrintCorrelations = false
 

Friends

QwCorrelatorNew operator+ (QwCorrelatorNew lhs, const QwCorrelatorNew &rhs)
 
std::ostream & operator<< (std::ostream &stream, const QwCorrelatorNew &h)
 Output stream operator.
 

Additional Inherited Members

- Public Types inherited from VQwDataHandler
enum  EQwHandleType {
  kHandleTypeUnknown =0 , kHandleTypeMps , kHandleTypeAsym , kHandleTypeDiff ,
  kHandleTypeYield
}
 
typedef std::vector< VQwHardwareChannel * >::iterator Iterator_HdwChan
 
typedef std::vector< VQwHardwareChannel * >::const_iterator ConstIterator_HdwChan
 

Detailed Description

Data handler computing correlations and linear-regression coefficients.

Uses Bevington/Pebay algorithms to estimate correlations between independent and dependent variables selected from subsystem arrays. Produces summary histograms and optional output trees/files for further analysis.

Definition at line 26 of file QwCorrelatorNew.h.

Constructor & Destructor Documentation

◆ QwCorrelatorNew() [1/3]

QwCorrelatorNew::QwCorrelatorNew ( const TString & name)

Constructor with name.

Definition at line 21 of file QwCorrelatorNew.cc.

22: VQwDataHandler(name),
23 fBlock(-1),
24 fDisableHistos(true),
25 fAlphaOutputFileBase("blueR"),
26 fAlphaOutputFileSuff("new.slope.root"),
29 fTree(0),
30 fAliasOutputFileBase("regalias_"),
33 fNameNoSpaces(name),
34 nP(0),nY(0),
36{
37 fNameNoSpaces.ReplaceAll(" ","_");
38 // Set default tree name and descriptions (in VQwDataHandler)
39 fTreeName = "lrb";
40 fTreeComment = "Correlations";
41 // Parsing separator
42 ParseSeparator = "_";
43
44 // Clear all data
46}
void ClearEventData() override
std::string fAlphaOutputFileBase
std::string fAliasOutputPath
std::string fAlphaOutputPath
std::string fAlphaOutputFileSuff
std::string fAliasOutputFileSuff
std::string fAliasOutputFileBase
std::string ParseSeparator
std::string fTreeComment
std::string fTreeName

References ClearEventData(), fAliasOutputFileBase, fAliasOutputFileSuff, fAliasOutputPath, fAlphaOutputFile, fAlphaOutputFileBase, fAlphaOutputFileSuff, fAlphaOutputPath, fBlock, fCycleCounter, fDisableHistos, fNameNoSpaces, fTree, VQwDataHandler::fTreeComment, VQwDataHandler::fTreeName, nP, nY, VQwDataHandler::ParseSeparator, and VQwDataHandler::VQwDataHandler().

Referenced by AccumulateRunningSum(), operator+, operator+=(), operator+=(), operator<<, and QwCorrelatorNew().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ QwCorrelatorNew() [2/3]

QwCorrelatorNew::QwCorrelatorNew ( const QwCorrelatorNew & name)

Definition at line 709 of file QwCorrelatorNew.cc.

710: VQwDataHandler(source),
711 fBlock(source.fBlock),
712 fDisableHistos(source.fDisableHistos),
713 fAlphaOutputFileBase(source.fAlphaOutputFileBase),
714 fAlphaOutputFileSuff(source.fAlphaOutputFileSuff),
715 fAlphaOutputPath(source.fAlphaOutputPath),
717 fTree(0),
718 fAliasOutputFileBase(source.fAliasOutputFileBase),
719 fAliasOutputFileSuff(source.fAliasOutputFileSuff),
720 fAliasOutputPath(source.fAliasOutputPath),
721 nP(source.nP),nY(source.nY),
722 fCycleCounter(source.fCycleCounter),
723 fErrorFlag(-1),
725{
727
728 QwWarning << "QwCorrelatorNew copy constructor required but untested" << QwLog::endl;
729
730 // Clear all data
732}
#define QwWarning
Predefined log drain for warnings.
Definition QwLog.h:44
#define QwMessage
Predefined log drain for regular messages.
Definition QwLog.h:49
static std::ostream & endl(std::ostream &)
End of the line.
Definition QwLog.cc:297
Int_t fErrorFlag
is information valid
Long64_t fGoodEventNumber
accumulated so far

References ClearEventData(), QwLog::endl(), fAliasOutputFileBase, fAliasOutputFileSuff, fAliasOutputPath, fAlphaOutputFile, fAlphaOutputFileBase, fAlphaOutputFileSuff, fAlphaOutputPath, fBlock, fCycleCounter, fDisableHistos, fErrorFlag, fGoodEventNumber, fTree, nP, nY, QwCorrelatorNew(), QwMessage, QwWarning, and VQwDataHandler::VQwDataHandler().

+ Here is the call graph for this function:

◆ ~QwCorrelatorNew()

QwCorrelatorNew::~QwCorrelatorNew ( )
override

Definition at line 48 of file QwCorrelatorNew.cc.

49{
50 // Close alpha and alias file
53}

References CloseAliasFile(), and CloseAlphaFile().

+ Here is the call graph for this function:

◆ QwCorrelatorNew() [3/3]

QwCorrelatorNew::QwCorrelatorNew ( )
private

Definition at line 701 of file QwCorrelatorNew.cc.

702: nP(0),nY(0),
703 fErrorFlag(-1),
705{ }

References fErrorFlag, fGoodEventNumber, nP, and nY.

Member Function Documentation

◆ AccumulateRunningSum()

void QwCorrelatorNew::AccumulateRunningSum ( VQwDataHandler & value,
Int_t count = 0,
Int_t ErrorMask = 0xFFFFFFF )
overridevirtual

Reimplemented from VQwDataHandler.

Definition at line 132 of file QwCorrelatorNew.cc.

133{
134 QwCorrelatorNew* correlator = dynamic_cast<QwCorrelatorNew*>(&value);
135 if (correlator) {
136 operator+=(*correlator);
137 } else {
138 QwWarning << "QwCorrelatorNew::AccumulateRunningSum "
139 << "can only accept other QwCorrelatorNew objects."
140 << QwLog::endl;
141 }
142}
QwCorrelatorNew & operator+=(const std::pair< TVectorD, TVectorD > &rhs)
QwCorrelatorNew(const TString &name)
Constructor with name.

References QwLog::endl(), operator+=(), QwCorrelatorNew(), QwWarning, and VQwDataHandler::VQwDataHandler().

+ Here is the call graph for this function:

◆ CalcCorrelations()

void QwCorrelatorNew::CalcCorrelations ( )

Definition at line 144 of file QwCorrelatorNew.cc.

145{
146 // Check if any channels are active
147 if (nP == 0 || nY == 0) {
148 return;
149 }
150
151 QwMessage << "QwCorrelatorNew::CalcCorrelations(): name=" << GetName() << QwLog::endl;
152
153 // Print entry summary
154 QwVerbose << "QwCorrelatorNew: "
155 << "total entries: " << fTotalCount << ", "
156 << "good entries: " << fGoodCount
157 << QwLog::endl;
158 // and warn if zero
159 if (fTotalCount > 100 && fGoodCount == 0) {
160 QwWarning << "QwCorrelatorNew: "
161 << "< 1% good events, "
162 << fGoodCount << " of " << fTotalCount
163 << QwLog::endl;
164 }
165
166 // Event error flag
167 if (fErrCounts_EF > 0) {
168 QwVerbose << " Entries failed due to error flag: "
170 }
171 // Dependent variable error codes
172 for (size_t i = 0; i < fDependentVar.size(); ++i) {
173 if (fErrCounts_DV.at(i) > 0) {
174 QwVerbose << " Entries failed due to " << fDependentVar.at(i)->GetElementName()
175 << ": " << fErrCounts_DV.at(i) << QwLog::endl;
176 }
177 }
178 // Independent variable error codes
179 for (size_t i = 0; i < fIndependentVar.size(); ++i) {
180 if (fErrCounts_IV.at(i) > 0) {
181 QwVerbose << " Entries failed due to " << fIndependentVar.at(i)->GetElementName()
182 << ": " << fErrCounts_IV.at(i) << QwLog::endl;
183 }
184 }
185
186 if (! this->failed()) {
187
188 if (fPrintCorrelations) {
189 this->printSummaryP();
190 this->printSummaryY();
191 }
192
193 this->solve();
194
195 if (fPrintCorrelations) {
196 this->printSummaryAlphas();
199 }
200 }
201
202 // Fill tree
203 if (fTree) fTree->Fill();
204 else QwWarning << "No tree" << QwLog::endl;
205
206 // Write alpha and alias file
209}
#define QwVerbose
Predefined log drain for verbose messages.
Definition QwLog.h:54
void printSummaryAlphas() const
void printSummaryMeansWithUncCorrected() const
std::vector< int > fErrCounts_DV
void printSummaryP() const
void printSummaryY() const
std::vector< int > fErrCounts_IV
std::vector< const VQwHardwareChannel * > fIndependentVar
static bool fPrintCorrelations
void printSummaryMeansWithUnc() const
TString GetName()
std::vector< const VQwHardwareChannel * > fDependentVar

References QwLog::endl(), failed(), VQwDataHandler::fDependentVar, fErrCounts_DV, fErrCounts_EF, fErrCounts_IV, fGoodCount, fIndependentVar, fPrintCorrelations, fTotalCount, fTree, VQwDataHandler::GetName(), nP, nY, printSummaryAlphas(), printSummaryMeansWithUnc(), printSummaryMeansWithUncCorrected(), printSummaryP(), printSummaryY(), QwMessage, QwVerbose, QwWarning, solve(), WriteAliasFile(), and WriteAlphaFile().

Referenced by FinishDataHandler().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clear()

void QwCorrelatorNew::clear ( )

Definition at line 775 of file QwCorrelatorNew.cc.

776{
777 mMP.Zero();
778 mMY.Zero();
779 mMYp.Zero();
780
781 mVPP.Zero();
782 mVPY.Zero();
783 mVYP.Zero();
784 mVYY.Zero();
785 mVYYp.Zero();
786 mVP.Zero();
787 mVY.Zero();
788 mVYp.Zero();
789
790 mSPP.Zero();
791 mSPY.Zero();
792 mSYP.Zero();
793 mSYY.Zero();
794 mSYYp.Zero();
795
796 Axy.Zero();
797 Ayx.Zero();
798 dAxy.Zero();
799 dAyx.Zero();
800
801 mSP.Zero();
802 mSY.Zero();
803 mSYp.Zero();
804
805 mRPP.Zero();
806 mRPY.Zero();
807 mRYP.Zero();
808 mRYY.Zero();
809 mRYYp.Zero();
810
811 fErrorFlag = -1;
813}
TMatrixD Axy
slopes
TVectorD mMP
mean values
TMatrixD mRPY
correlations
TMatrixD mSPY
normalized covariances
TVectorD mSP
sigmas
TMatrixD mVPY
unnormalized covariances
TVectorD mVP
variances

References Axy, Ayx, dAxy, dAyx, fErrorFlag, fGoodEventNumber, mMP, mMY, mMYp, mRPP, mRPY, mRYP, mRYY, mRYYp, mSP, mSPP, mSPY, mSY, mSYP, mSYp, mSYY, mSYYp, mVP, mVPP, mVPY, mVY, mVYP, mVYp, mVYY, and mVYYp.

Referenced by ClearEventData().

+ Here is the caller graph for this function:

◆ ClearEventData()

void QwCorrelatorNew::ClearEventData ( )
overridevirtual

Reimplemented from VQwDataHandler.

Definition at line 116 of file QwCorrelatorNew.cc.

117{
118 // Clear error counters
119 fErrCounts_EF = 0;
120 std::fill(fErrCounts_DV.begin(), fErrCounts_DV.end(), 0);
121 std::fill(fErrCounts_IV.begin(), fErrCounts_IV.end(), 0);
122
123 // Clear event counts
124 fTotalCount = 0;
125 fGoodCount = 0;
126 fGoodEvent = -1;
127
128 // Clear regression
129 this->clear();
130}
unsigned int fGoodEvent

References clear(), fErrCounts_DV, fErrCounts_EF, fErrCounts_IV, fGoodCount, fGoodEvent, and fTotalCount.

Referenced by QwCorrelatorNew(), and QwCorrelatorNew().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CloseAliasFile()

void QwCorrelatorNew::CloseAliasFile ( )
protected

Definition at line 657 of file QwCorrelatorNew.cc.

658{
659 // Close alias output file
660 if (fAliasOutputFile.good()) {
661 fAliasOutputFile << "}" << std::endl << std::endl;
662 fAliasOutputFile.close();
663 } else {
664 QwWarning << "QwCorrelatorNew: Unable to close alias output file." << QwLog::endl;
665 }
666}
std::ofstream fAliasOutputFile

References QwLog::endl(), fAliasOutputFile, and QwWarning.

Referenced by ~QwCorrelatorNew().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CloseAlphaFile()

void QwCorrelatorNew::CloseAlphaFile ( )
protected

Definition at line 648 of file QwCorrelatorNew.cc.

649{
650 // Close slopes output file
651 if (fAlphaOutputFile) {
652 fAlphaOutputFile->Write();
653 fAlphaOutputFile->Close();
654 }
655}

References fAlphaOutputFile.

Referenced by ~QwCorrelatorNew().

+ Here is the caller graph for this function:

◆ ConnectChannels()

Int_t QwCorrelatorNew::ConnectChannels ( QwSubsystemArrayParity & asym,
QwSubsystemArrayParity & diff )
overridevirtual

Connect to Channels (asymmetry/difference only)

Parameters
asymSubsystem array with asymmetries
diffSubsystem array with differences
Returns
0 on success, non-zero on failure

Fill vector of pointers to the relevant data elements

Reimplemented from VQwDataHandler.

Definition at line 259 of file QwCorrelatorNew.cc.

260{
262
263 // Return if correlator is not enabled
264
265 /// Fill vector of pointers to the relevant data elements
266 for (size_t dv = 0; dv < fDependentName.size(); dv++) {
267 // Get the dependent variables
268
269 const VQwHardwareChannel* dv_ptr = 0;
270
271 if (fDependentType.at(dv)==kHandleTypeMps){
272 // Quietly ignore the MPS type when we're connecting the asym & diff
273 continue;
274 }else{
275 dv_ptr = this->RequestExternalPointer(fDependentFull.at(dv));
276 if (dv_ptr==NULL){
277 switch (fDependentType.at(dv)) {
278 case kHandleTypeAsym:
279 dv_ptr = asym.RequestExternalPointer(fDependentName.at(dv));
280 break;
281 case kHandleTypeDiff:
282 dv_ptr = diff.RequestExternalPointer(fDependentName.at(dv));
283 break;
284 default:
285 QwWarning << "QwCorrelatorNew::ConnectChannels(QwSubsystemArrayParity& asym, QwSubsystemArrayParity& diff): "
286 << "Dependent variable, " << fDependentName.at(dv)
287 << ", for asym/diff correlator does not have proper type, type=="
288 << fDependentType.at(dv) << "." << QwLog::endl;
289 break;
290 }
291 }
292 if (dv_ptr == NULL){
293 QwWarning << "QwCombiner::ConnectChannels(QwSubsystemArrayParity& asym, QwSubsystemArrayParity& diff): Dependent variable, "
294 << fDependentName.at(dv)
295 << ", was not found (fullname=="
296 << fDependentFull.at(dv)<< ")." << QwLog::endl;
297 continue;
298 }
299 }
300
301 // pair creation
302 if(dv_ptr != NULL){
303 // fDependentVarType.push_back(fDependentType.at(dv));
304 fDependentVar.push_back(dv_ptr);
305 }
306
307 }
308
309 // Add independent variables
310 for (size_t iv = 0; iv < fIndependentName.size(); iv++) {
311 // Get the independent variables
312 const VQwHardwareChannel* iv_ptr = 0;
313 iv_ptr = this->RequestExternalPointer(fIndependentFull.at(iv));
314 if (iv_ptr==NULL){
315 switch (fIndependentType.at(iv)) {
316 case kHandleTypeAsym:
317 iv_ptr = asym.RequestExternalPointer(fIndependentName.at(iv));
318 break;
319 case kHandleTypeDiff:
320 iv_ptr = diff.RequestExternalPointer(fIndependentName.at(iv));
321 break;
322 default:
323 QwWarning << "Independent variable for correlator has unknown type."
324 << QwLog::endl;
325 break;
326 }
327 }
328 if (iv_ptr) {
329 fIndependentVar.push_back(iv_ptr);
330 } else {
331 QwWarning << "Independent variable " << fIndependentName.at(iv) << " for correlator could not be found."
332 << QwLog::endl;
333 }
334
335 }
336 fIndependentValues.resize(fIndependentVar.size());
337 fDependentValues.resize(fDependentVar.size());
338
339 nP = fIndependentName.size();
340 nY = fDependentName.size();
341
342 this->setDims(nP, nY);
343 this->init();
344
345 fErrCounts_IV.resize(fIndependentVar.size(),0);
346 fErrCounts_DV.resize(fDependentVar.size(),0);
347
348 return 0;
349}
const VQwHardwareChannel * RequestExternalPointer(const TString &name) const
const VQwHardwareChannel * RequestExternalPointer(const TString &name) const
Retrieve a direct pointer to an external variable Searches for the named variable in external subsyst...
std::vector< Double_t > fIndependentValues
std::vector< std::string > fIndependentFull
std::vector< EQwHandleType > fIndependentType
std::vector< std::string > fIndependentName
void setDims(int a, int b)
const UInt_t * GetEventcutErrorFlagPointer() const
std::vector< std::string > fDependentFull
void SetEventcutErrorFlagPointer(const UInt_t *errorflagptr)
std::vector< Double_t > fDependentValues
std::vector< EQwHandleType > fDependentType
std::vector< std::string > fDependentName

References QwLog::endl(), VQwDataHandler::fDependentFull, VQwDataHandler::fDependentName, VQwDataHandler::fDependentType, VQwDataHandler::fDependentValues, VQwDataHandler::fDependentVar, fErrCounts_DV, fErrCounts_IV, fIndependentFull, fIndependentName, fIndependentType, fIndependentValues, fIndependentVar, QwSubsystemArrayParity::GetEventcutErrorFlagPointer(), init(), VQwDataHandler::kHandleTypeAsym, VQwDataHandler::kHandleTypeDiff, VQwDataHandler::kHandleTypeMps, nP, nY, QwWarning, MQwPublishable< U, T >::RequestExternalPointer(), MQwPublishable_child< QwDataHandlerArray, VQwDataHandler >::RequestExternalPointer(), setDims(), and VQwDataHandler::SetEventcutErrorFlagPointer().

+ Here is the call graph for this function:

◆ ConstructHistograms()

void QwCorrelatorNew::ConstructHistograms ( TDirectory * folder,
TString & prefix )
overridevirtual

Construct the histograms in a folder with a prefix.

Reimplemented from VQwDataHandler.

Definition at line 440 of file QwCorrelatorNew.cc.

441{
442 // Skip if disabled
443 if (fDisableHistos) return;
444
445 // Check if any channels are active
446 if (nP == 0 || nY == 0) {
447 return;
448 }
449
450 // Go to directory
451 TString name(fName);
452 name.ReplaceAll(" ","_");
453 folder->mkdir(name)->cd();
454
455 //..... 1D, iv
456 fH1iv.resize(nP);
457 for (int i = 0; i < nP; i++) {
458 fH1iv[i] = TH1D(
459 Form("P%d",i),
460 Form("iv P%d=%s, pass=%s ;iv=%s (ppm)",i,fIndependentName[i].c_str(),fName.Data(),fIndependentName[i].c_str()),
461 128,0.,0.);
462 fH1iv[i].GetXaxis()->SetNdivisions(4);
463 }
464
465 //..... 2D, iv correlations
466 Double_t x1 = 0;
467 fH2iv.resize(nP);
468 for (int i = 0; i < nP; i++) {
469 fH2iv[i].resize(nP);
470 for (int j = i+1; j < nP; j++) { // not all are used
471 fH2iv[i][j] = TH2D(
472 Form("P%d_P%d",i,j),
473 Form("iv correlation P%d_P%d, pass=%s ;P%d=%s (ppm);P%d=%s (ppm) ",
474 i,j,fName.Data(),i,fIndependentName[i].c_str(),j,fIndependentName[j].c_str()),
475 64,-x1,x1,
476 64,-x1,x1);
477 fH2iv[i][j].GetXaxis()->SetTitleColor(kBlue);
478 fH2iv[i][j].GetYaxis()->SetTitleColor(kBlue);
479 fH2iv[i][j].GetXaxis()->SetNdivisions(4);
480 fH2iv[i][j].GetYaxis()->SetNdivisions(4);
481 }
482 }
483
484 //..... 1D, dv
485 fH1dv.resize(nY);
486 for (int i = 0; i < nY; i++) {
487 fH1dv[i] = TH1D(
488 Form("Y%d",i),
489 Form("dv Y%d=%s, pass=%s ;dv=%s (ppm)",i,fDependentName[i].c_str(),fName.Data(),fDependentName[i].c_str()),
490 128,0.,0.);
491 fH1dv[i].GetXaxis()->SetNdivisions(4);
492 }
493
494 //..... 2D, dv-iv correlations
495 Double_t y1 = 0;
496 fH2dv.resize(nP);
497 for (int i = 0; i < nP; i++) {
498 fH2dv[i].resize(nY);
499 for (int j = 0; j < nY; j++) {
500 fH2dv[i][j] = TH2D(
501 Form("P%d_Y%d",i,j),
502 Form("iv-dv correlation P%d_Y%d, pass=%s ;P%d=%s (ppm);Y%d=%s (ppm) ",
503 i,j,fName.Data(),i,fIndependentName[i].c_str(),j,fDependentName[j].c_str()),
504 64,-x1,x1,
505 64,-y1,y1);
506 fH2dv[i][j].GetXaxis()->SetTitleColor(kBlue);
507 fH2dv[i][j].GetYaxis()->SetTitleColor(kBlue);
508 fH2dv[i][j].GetXaxis()->SetNdivisions(4);
509 fH2dv[i][j].GetYaxis()->SetNdivisions(4);
510 }
511 }
512
513 // store list of names to be archived
514 fHnames.resize(2);
515 fHnames[0] = TH1D("NamesIV",Form("IV name list nIV=%d",nP),nP,0,1);
516 for (int i = 0; i < nP; i++)
517 fHnames[0].Fill(fIndependentName[i].c_str(),1.*i);
518 fHnames[1] = TH1D("NamesDV",Form("DV name list nIV=%d",nY),nY,0,1);
519 for (int i = 0; i < nY; i++)
520 fHnames[1].Fill(fDependentName[i].c_str(),i*1.);
521}
std::vector< TH1D > fH1iv
std::vector< TH1D > fHnames
std::vector< TH1D > fH1dv
std::vector< std::vector< TH2D > > fH2iv
std::vector< std::vector< TH2D > > fH2dv

References VQwDataHandler::fDependentName, fDisableHistos, fH1dv, fH1iv, fH2dv, fH2iv, fHnames, fIndependentName, VQwDataHandler::fName, nP, and nY.

◆ ConstructTreeBranches()

void QwCorrelatorNew::ConstructTreeBranches ( QwRootFile * treerootfile,
const std::string & treeprefix = "",
const std::string & branchprefix = "" )
overridevirtual

Construct the tree branches.

Reimplemented from VQwDataHandler.

Definition at line 352 of file QwCorrelatorNew.cc.

356{
357 // Check if any channels are active
358 if (nP == 0 || nY == 0) {
359 return;
360 }
361
362 // Check if tree name is specified
363 if (fTreeName == "") {
364 QwWarning << "QwCorrelatorNew: no tree name specified, use 'tree-name = value'" << QwLog::endl;
365 return;
366 }
367
368 // Create alpha and alias files before trying to create the tree
369 OpenAlphaFile(treeprefix);
370 OpenAliasFile(treeprefix);
371
372 // Construct tree name and create new tree
373 const std::string name = treeprefix + fTreeName;
374 treerootfile->NewTree(name, fTreeComment.c_str());
375 fTree = treerootfile->GetTree(name);
376 // Check to make sure the tree was created successfully
377 if (fTree == NULL) return;
378
379 // Set up branches
380 fTree->Branch(TString(branchprefix + "total_count"), &fTotalCount);
381 fTree->Branch(TString(branchprefix + "good_count"), &fGoodCount);
382
383 fTree->Branch(TString(branchprefix + "n"), &(this->fGoodEventNumber));
384 fTree->Branch(TString(branchprefix + "ErrorFlag"), &(this->fErrorFlag));
385
386 auto bn = [&](const TString& n) {
387 return TString(branchprefix + n);
388 };
389 auto pm = [](TMatrixD& m) {
390 return m.GetMatrixArray();
391 };
392 auto lm = [](TMatrixD& m, const TString& n) {
393 return Form("%s[%d][%d]/D", n.Data(), m.GetNrows(), m.GetNcols());
394 };
395 auto branchm = [&](TTree* tree, TMatrixD& m, const TString& n) {
396 tree->Branch(bn(n),pm(m),lm(m,n));
397 };
398 auto pv = [](TVectorD& v) {
399 return v.GetMatrixArray();
400 };
401 auto lv = [](TVectorD& v, const TString& n) {
402 return Form("%s[%d]/D", n.Data(), v.GetNrows());
403 };
404 auto branchv = [&](TTree* tree, TVectorD& v, const TString& n) {
405 tree->Branch(bn(n),pv(v),lv(v,n));
406 };
407
408 branchm(fTree,this->Axy, "A");
409 branchm(fTree,this->dAxy, "dA");
410
411 branchm(fTree,this->mVPP, "VPP");
412 branchm(fTree,this->mVPY, "VPY");
413 branchm(fTree,this->mVYP, "VYP");
414 branchm(fTree,this->mVYY, "VYY");
415 branchm(fTree,this->mVYYp, "VYYp");
416
417 branchm(fTree,this->mSPP, "SPP");
418 branchm(fTree,this->mSPY, "SPY");
419 branchm(fTree,this->mSYP, "SYP");
420 branchm(fTree,this->mSYY, "SYY");
421 branchm(fTree,this->mSYYp, "SYYp");
422
423 branchm(fTree,this->mRPP, "RPP");
424 branchm(fTree,this->mRPY, "RPY");
425 branchm(fTree,this->mRYP, "RYP");
426 branchm(fTree,this->mRYY, "RYY");
427 branchm(fTree,this->mRYYp, "RYYp");
428
429 branchv(fTree,this->mMP, "MP"); // Parameter mean
430 branchv(fTree,this->mMY, "MY"); // Uncorrected mean
431 branchv(fTree,this->mMYp, "MYp"); // Corrected mean
432
433 branchv(fTree,this->mSP, "dMP"); // Parameter mean error
434 branchv(fTree,this->mSY, "dMY"); // Uncorrected mean error
435 branchv(fTree,this->mSYp, "dMYp"); // Corrected mean error
436
437}
void NewTree(const std::string &name, const std::string &desc)
Create a new tree with name and description.
Definition QwRootFile.h:934
TTree * GetTree(const std::string &name)
Get the tree with name.
Definition QwRootFile.h:968
void OpenAliasFile(const std::string &prefix)
void OpenAlphaFile(const std::string &prefix)

References Axy, dAxy, QwLog::endl(), fErrorFlag, fGoodCount, fGoodEventNumber, fTotalCount, fTree, VQwDataHandler::fTreeComment, VQwDataHandler::fTreeName, QwRootFile::GetTree(), mMP, mMY, mMYp, mRPP, mRPY, mRYP, mRYY, mRYYp, mSP, mSPP, mSPY, mSY, mSYP, mSYp, mSYY, mSYYp, mVPP, mVPY, mVYP, mVYY, mVYYp, QwRootFile::NewTree(), nP, nY, OpenAliasFile(), OpenAlphaFile(), and QwWarning.

+ Here is the call graph for this function:

◆ DefineOptions()

void QwCorrelatorNew::DefineOptions ( QwOptions & options)
static

Definition at line 55 of file QwCorrelatorNew.cc.

56{
57 options.AddOptions()("print-correlations",
58 po::value<bool>(&fPrintCorrelations)->default_bool_value(false),
59 "print correlations after determining them");
60}
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:170

References QwOptions::AddOptions(), and fPrintCorrelations.

+ Here is the call graph for this function:

◆ failed()

bool QwCorrelatorNew::failed ( )
inline

Definition at line 167 of file QwCorrelatorNew.h.

167{ return fGoodEventNumber < nP + 1; }

References fGoodEventNumber, and nP.

Referenced by CalcCorrelations().

+ Here is the caller graph for this function:

◆ FillHistograms()

void QwCorrelatorNew::FillHistograms ( )
overridevirtual

Fill the histograms.

Reimplemented from VQwDataHandler.

Definition at line 524 of file QwCorrelatorNew.cc.

525{
526 // Skip if disabled
527 if (fDisableHistos) return;
528
529 // Check if any channels are active
530 if (nP == 0 || nY == 0) {
531 return;
532 }
533
534 // Skip if bad event
535 if (fGoodEvent != 0) return;
536
537 // Fill histograms
538 for (size_t i = 0; i < fIndependentValues.size(); i++) {
539 fH1iv[i].Fill(fIndependentValues[i]);
540 for (size_t j = i+1; j < fIndependentValues.size(); j++)
542 }
543 for (size_t j = 0; j < fDependentValues.size(); j++) {
544 fH1dv[j].Fill(fDependentValues[j]);
545 for (size_t i = 0; i < fIndependentValues.size(); i++)
546 fH2dv[i][j].Fill(fIndependentValues[i], fDependentValues[j]);
547 }
548}

References VQwDataHandler::fDependentValues, fDisableHistos, fGoodEvent, fH1dv, fH1iv, fH2dv, fH2iv, fIndependentValues, nP, and nY.

◆ FillTreeBranches()

void QwCorrelatorNew::FillTreeBranches ( QwRootFile * treerootfile)
inlineoverridevirtual

Fill the tree branches.

Reimplemented from VQwDataHandler.

Definition at line 62 of file QwCorrelatorNew.h.

62{ };

◆ FinishDataHandler()

void QwCorrelatorNew::FinishDataHandler ( )
inlineoverridevirtual

Reimplemented from VQwDataHandler.

Definition at line 51 of file QwCorrelatorNew.h.

51 {
53 }

References CalcCorrelations().

+ Here is the call graph for this function:

◆ getCovarianceP()

Int_t QwCorrelatorNew::getCovarianceP ( int i,
int j,
Double_t & covar ) const

Get mean value of a variable, returns error code.

Definition at line 979 of file QwCorrelatorNew.cc.

980{
981 covar=-1e50;
982 if( i>j) { int k=i; i=j; j=k; }//swap i & j
983 //... now we need only upper right triangle
984 if(i<0 || i >= nP ) return -11;
985 if( fGoodEventNumber<2) return -14;
986 covar=mVPP(i,j)/(fGoodEventNumber-1.);
987 return 0;
988}

References fGoodEventNumber, mVPP, and nP.

Referenced by printSummaryP().

+ Here is the caller graph for this function:

◆ getCovariancePY()

Int_t QwCorrelatorNew::getCovariancePY ( int ip,
int iy,
Double_t & covar ) const

Definition at line 992 of file QwCorrelatorNew.cc.

993{
994 covar=-1e50;
995 //... now we need only upper right triangle
996 if(ip<0 || ip >= nP ) return -11;
997 if(iy<0 || iy >= nY ) return -12;
998 if( fGoodEventNumber<2) return -14;
999 covar=mVPY(ip,iy)/(fGoodEventNumber-1.);
1000 return 0;
1001}

References fGoodEventNumber, mVPY, nP, and nY.

Referenced by printSummaryYP().

+ Here is the caller graph for this function:

◆ getCovarianceY()

Int_t QwCorrelatorNew::getCovarianceY ( int i,
int j,
Double_t & covar ) const

Definition at line 1005 of file QwCorrelatorNew.cc.

1006{
1007 covar=-1e50;
1008 if( i>j) { int k=i; i=j; j=k; }//swap i & j
1009 //... now we need only upper right triangle
1010 if(i<0 || i >= nY ) return -11;
1011 if( fGoodEventNumber<2) return -14;
1012 covar=mVYY(i,j)/(fGoodEventNumber-1.);
1013 return 0;
1014}

References fGoodEventNumber, mVYY, and nY.

◆ getMeanP()

Int_t QwCorrelatorNew::getMeanP ( const int i,
Double_t & mean ) const

Get mean value of a variable, returns error code.

Definition at line 912 of file QwCorrelatorNew.cc.

913{
914 mean=-1e50;
915 if(i<0 || i >= nP ) return -1;
916 if( fGoodEventNumber<1) return -3;
917 mean = mMP(i); return 0;
918}

References fGoodEventNumber, mMP, and nP.

Referenced by printSummaryP().

+ Here is the caller graph for this function:

◆ getMeanY()

Int_t QwCorrelatorNew::getMeanY ( const int i,
Double_t & mean ) const

Definition at line 923 of file QwCorrelatorNew.cc.

924{
925 mean=-1e50;
926 if(i<0 || i >= nY ) return -1;
927 if( fGoodEventNumber<1) return -3;
928 mean = mMY(i); return 0;
929}

References fGoodEventNumber, mMY, and nY.

Referenced by printSummaryY(), and printSummaryYP().

+ Here is the caller graph for this function:

◆ getMeanYprime()

Int_t QwCorrelatorNew::getMeanYprime ( const int i,
Double_t & mean ) const

Definition at line 934 of file QwCorrelatorNew.cc.

935{
936 mean=-1e50;
937 if(i<0 || i >= nY ) return -1;
938 if( fGoodEventNumber<1) return -3;
939 mean = mMYp(i); return 0;
940}

References fGoodEventNumber, mMYp, and nY.

◆ getSigmaP()

Int_t QwCorrelatorNew::getSigmaP ( const int i,
Double_t & sigma ) const

Get mean value of a variable, returns error code.

Definition at line 945 of file QwCorrelatorNew.cc.

946{
947 sigma=-1e50;
948 if(i<0 || i >= nP ) return -1;
949 if( fGoodEventNumber<2) return -3;
950 sigma=sqrt(mVPP(i,i)/(fGoodEventNumber-1.));
951 return 0;
952}

References fGoodEventNumber, mVPP, and nP.

Referenced by printSummaryP(), and printSummaryYP().

+ Here is the caller graph for this function:

◆ getSigmaY()

Int_t QwCorrelatorNew::getSigmaY ( const int i,
Double_t & sigma ) const

Definition at line 957 of file QwCorrelatorNew.cc.

958{
959 sigma=-1e50;
960 if(i<0 || i >= nY ) return -1;
961 if( fGoodEventNumber<2) return -3;
962 sigma=sqrt(mVYY(i,i)/(fGoodEventNumber-1.));
963 return 0;
964}

References fGoodEventNumber, mVYY, and nY.

Referenced by printSummaryY(), and printSummaryYP().

+ Here is the caller graph for this function:

◆ getSigmaYprime()

Int_t QwCorrelatorNew::getSigmaYprime ( const int i,
Double_t & sigma ) const

Definition at line 968 of file QwCorrelatorNew.cc.

969{
970 sigma=-1e50;
971 if(i<0 || i >= nY ) return -1;
972 if( fGoodEventNumber<2) return -3;
973 sigma=sqrt(mVYYp(i,i)/(fGoodEventNumber-1.));
974 return 0;
975}

References fGoodEventNumber, mVYYp, and nY.

◆ getUsedEve()

double QwCorrelatorNew::getUsedEve ( ) const
inline

Definition at line 197 of file QwCorrelatorNew.h.

197{ return fGoodEventNumber; };

References fGoodEventNumber.

Referenced by WriteAlphaFile().

+ Here is the caller graph for this function:

◆ init()

void QwCorrelatorNew::init ( )

Definition at line 736 of file QwCorrelatorNew.cc.

737{
738 mMP.ResizeTo(nP);
739 mMY.ResizeTo(nY);
740 mMYp.ResizeTo(nY);
741
742 mVPP.ResizeTo(nP,nP);
743 mVPY.ResizeTo(nP,nY);
744 mVYP.ResizeTo(nY,nP);
745 mVYY.ResizeTo(nY,nY);
746 mVYYp.ResizeTo(nY,nY);
747 mVP.ResizeTo(nP);
748 mVY.ResizeTo(nY);
749 mVYp.ResizeTo(nY);
750
751 mSPP.ResizeTo(mVPP);
752 mSPY.ResizeTo(mVPY);
753 mSYP.ResizeTo(mVYP);
754 mSYY.ResizeTo(mVYY);
755 mSYYp.ResizeTo(mVYYp);
756
757 Axy.ResizeTo(nP,nY);
758 Ayx.ResizeTo(nY,nP);
759 dAxy.ResizeTo(Axy);
760 dAyx.ResizeTo(Ayx);
761
762 mSP.ResizeTo(nP);
763 mSY.ResizeTo(nY);
764 mSYp.ResizeTo(nY);
765
766 mRPP.ResizeTo(mVPP);
767 mRPY.ResizeTo(mVPY);
768 mRYP.ResizeTo(mVYP);
769 mRYY.ResizeTo(mVYY);
770 mRYYp.ResizeTo(mVYYp);
771
773}

References Axy, Ayx, dAxy, dAyx, fGoodEventNumber, mMP, mMY, mMYp, mRPP, mRPY, mRYP, mRYY, mRYYp, mSP, mSPP, mSPY, mSY, mSYP, mSYp, mSYY, mSYYp, mVP, mVPP, mVPY, mVY, mVYP, mVYp, mVYY, mVYYp, nP, and nY.

Referenced by ConnectChannels().

+ Here is the caller graph for this function:

◆ LoadChannelMap()

Int_t QwCorrelatorNew::LoadChannelMap ( const std::string & mapfile)
overridevirtual

Load the channel map

Parameters
mapfileFilename of map file
Returns
Zero when success

Reimplemented from VQwDataHandler.

Definition at line 217 of file QwCorrelatorNew.cc.

218{
219 // Open the file
220 QwParameterFile map(mapfile);
221
222 // Read the sections of dependent variables
223 std::pair<EQwHandleType,std::string> type_name;
224
225 // Add independent variables and sensitivities
226 while (map.ReadNextLine()) {
227 // Throw away comments, whitespace, empty lines
228 map.TrimComment();
229 map.TrimWhitespace();
230 if (map.LineIsEmpty()) continue;
231 // Get first token: label (dv or iv), second token is the name like "asym_blah"
232 string primary_token = map.GetNextToken(" ");
233 string current_token = map.GetNextToken(" ");
234 // Parse current token into independent variable type and name
235 type_name = ParseHandledVariable(current_token);
236
237 if (primary_token == "iv") {
238 fIndependentType.push_back(type_name.first);
239 fIndependentName.push_back(type_name.second);
240 fIndependentFull.push_back(current_token);
241 }
242 else if (primary_token == "dv") {
243 fDependentType.push_back(type_name.first);
244 fDependentName.push_back(type_name.second);
245 fDependentFull.push_back(current_token);
246 }
247 else if (primary_token == "treetype") {
248 QwMessage << "Tree Type read, ignoring." << QwLog::endl;
249 }
250 else {
251 QwError << "LoadChannelMap in QwCorrelatorNew read invalid primary_token " << primary_token << QwLog::endl;
252 }
253 }
254
255 return 0;
256}
#define QwError
Predefined log drain for errors.
Definition QwLog.h:39
std::pair< EQwHandleType, std::string > ParseHandledVariable(const std::string &variable)

References QwLog::endl(), VQwDataHandler::fDependentFull, VQwDataHandler::fDependentName, VQwDataHandler::fDependentType, fIndependentFull, fIndependentName, fIndependentType, QwParameterFile::GetNextToken(), QwParameterFile::LineIsEmpty(), VQwDataHandler::ParseHandledVariable(), QwError, QwMessage, QwParameterFile::ReadNextLine(), QwParameterFile::TrimComment(), and QwParameterFile::TrimWhitespace().

+ Here is the call graph for this function:

◆ OpenAliasFile()

void QwCorrelatorNew::OpenAliasFile ( const std::string & prefix)
protected

Definition at line 630 of file QwCorrelatorNew.cc.

631{
632 // Turn "." into "_" in run_label (no "." allowed in function name, and must
633 // agree with the filename)
634 std::string label(run_label);
635 std::replace(label.begin(), label.end(), '.', '_');
636 // Create old-style regalias script
637 std::string name = prefix + fAliasOutputFileBase + label + fAliasOutputFileSuff;
638 std::string path = fAliasOutputPath + "/";
639 std::string file = path + name + ".C"; // add extension outside of file suffix
640 fAliasOutputFile.open(file, std::ofstream::out);
641 if (fAliasOutputFile.good()) {
642 fAliasOutputFile << Form("void %s(int i = 0) {", name.c_str()) << std::endl;
643 } else {
644 QwWarning << "QwCorrelatorNew: Could not write to alias output file " << QwLog::endl;
645 }
646}

References QwLog::endl(), fAliasOutputFile, fAliasOutputFileBase, fAliasOutputFileSuff, fAliasOutputPath, QwWarning, and VQwDataHandler::run_label.

Referenced by ConstructTreeBranches().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OpenAlphaFile()

void QwCorrelatorNew::OpenAlphaFile ( const std::string & prefix)
protected

Definition at line 616 of file QwCorrelatorNew.cc.

617{
618 // Create old-style blueR ROOT file
619 std::string name = prefix + fAlphaOutputFileBase + run_label.Data() + fAlphaOutputFileSuff;
620 std::string path = fAlphaOutputPath + "/";
621 std::string file = path + name;
622 fAlphaOutputFile = new TFile(TString(file), "RECREATE", "correlation coefficients");
623 if (! fAlphaOutputFile->IsWritable()) {
624 QwError << "QwCorrelatorNew could not create output file " << file << QwLog::endl;
625 delete fAlphaOutputFile;
627 }
628}

References QwLog::endl(), fAlphaOutputFile, fAlphaOutputFileBase, fAlphaOutputFileSuff, fAlphaOutputPath, QwError, and VQwDataHandler::run_label.

Referenced by ConstructTreeBranches().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator+=() [1/2]

QwCorrelatorNew & QwCorrelatorNew::operator+= ( const QwCorrelatorNew & rhs)

Definition at line 871 of file QwCorrelatorNew.cc.

872{
873 // If set X = A + B, then
874 // Cov[X] = Cov[A] + Cov[B]
875 // + (E[x_A] - E[x_B]) * (E[y_A] - E[y_B]) * n_A * n_B / n_X
876 // Ref: E. Schubert, M. Gertz (9 July 2018).
877 // "Numerically stable parallel computation of (co-)variance".
878 // SSDBM '18 Proceedings of the 30th International Conference
879 // on Scientific and Statistical Database Management.
880 // https://doi.org/10.1145/3221269.3223036
881
883 return *this;
884
885 // Deviations from mean
886 TVectorD delta_y(mMY - rhs.mMY);
887 TVectorD delta_p(mMP - rhs.mMP);
888
889 // Update covariances
890 Double_t alpha = fGoodEventNumber * rhs.fGoodEventNumber
892 mVYY += rhs.mVYY;
893 mVYY.Rank1Update(delta_y, alpha);
894 mVPY += rhs.mVPY;
895 mVPY.Rank1Update(delta_p, delta_y, alpha);
896 mVPP += rhs.mVPP;
897 mVPP.Rank1Update(delta_p, alpha);
898
899 // Update means
900 Double_t beta = rhs.fGoodEventNumber / (fGoodEventNumber + rhs.fGoodEventNumber);
901 mMY += delta_y * beta;
902 mMP += delta_p * beta;
903
905
906 return *this;
907}

References fGoodEventNumber, mMP, mMY, mVPP, mVPY, mVYY, and QwCorrelatorNew().

+ Here is the call graph for this function:

◆ operator+=() [2/2]

QwCorrelatorNew & QwCorrelatorNew::operator+= ( const std::pair< TVectorD, TVectorD > & rhs)

Definition at line 832 of file QwCorrelatorNew.cc.

833{
834 // Get independent and dependent components
835 const TVectorD& P = rhs.first;
836 const TVectorD& Y = rhs.second;
837
838 // Update number of events
840
841 if (fGoodEventNumber <= 1) {
842 // First event, set covariances to zero and means to first value
843 mVPP.Zero();
844 mVPY.Zero();
845 mVYY.Zero();
846 mMP = P;
847 mMY = Y;
848 } else {
849 // Deviations from mean
850 TVectorD delta_y(Y - mMY);
851 TVectorD delta_p(P - mMP);
852
853 // Update covariances
854 Double_t alpha = (fGoodEventNumber - 1.0) / fGoodEventNumber;
855 mVPP.Rank1Update(delta_p, alpha);
856 mVPY.Rank1Update(delta_p, delta_y, alpha);
857 mVYY.Rank1Update(delta_y, alpha);
858
859 // Update means
860 Double_t beta = 1.0 / fGoodEventNumber;
861 mMP += delta_p * beta;
862 mMY += delta_y * beta;
863 }
864
865 return *this;
866}

References fGoodEventNumber, mMP, mMY, mVPP, mVPY, mVYY, and QwCorrelatorNew().

Referenced by AccumulateRunningSum(), and ProcessData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ParseConfigFile()

void QwCorrelatorNew::ParseConfigFile ( QwParameterFile & file)
overridevirtual

Parse configuration file for map file, priority, tree settings.

Reimplemented from VQwDataHandler.

Definition at line 66 of file QwCorrelatorNew.cc.

67{
69 file.PopValue("slope-file-base", fAlphaOutputFileBase);
70 file.PopValue("slope-file-suff", fAlphaOutputFileSuff);
71 file.PopValue("slope-path", fAlphaOutputPath);
72 file.PopValue("alias-file-base", fAliasOutputFileBase);
73 file.PopValue("alias-file-suff", fAliasOutputFileSuff);
74 file.PopValue("alias-path", fAliasOutputPath);
75 file.PopValue("disable-histos", fDisableHistos);
76 file.PopValue("block", fBlock);
77 if (fBlock >= 4)
78 QwWarning << "QwCorrelatorNew: expect 0 <= block <= 3 but block = "
79 << fBlock << QwLog::endl;
80}
Bool_t PopValue(const std::string keyname, T &retvalue)
virtual void ParseConfigFile(QwParameterFile &file)

References QwLog::endl(), fAliasOutputFileBase, fAliasOutputFileSuff, fAliasOutputPath, fAlphaOutputFileBase, fAlphaOutputFileSuff, fAlphaOutputPath, fBlock, fDisableHistos, VQwDataHandler::ParseConfigFile(), QwParameterFile::PopValue(), and QwWarning.

+ Here is the call graph for this function:

◆ print()

void QwCorrelatorNew::print ( )

Definition at line 817 of file QwCorrelatorNew.cc.

818{
819 QwMessage << "LinReg dims: nP=" << nP << " nY=" << nY << QwLog::endl;
820
821 QwMessage << "MP:"; mMP.Print();
822 QwMessage << "MY:"; mMY.Print();
823 QwMessage << "VPP:"; mVPP.Print();
824 QwMessage << "VPY:"; mVPY.Print();
825 QwMessage << "VYY:"; mVYY.Print();
826 QwMessage << "VYYprime:"; mVYYp.Print();
827}

References QwLog::endl(), mMP, mMY, mVPP, mVPY, mVYY, mVYYp, nP, nY, and QwMessage.

+ Here is the call graph for this function:

◆ printSummaryAlphas()

void QwCorrelatorNew::printSummaryAlphas ( ) const

Definition at line 1075 of file QwCorrelatorNew.cc.

1076{
1077 QwMessage << Form("\nLinRegBevPeb::printSummaryAlphas seen good eve=%lld",fGoodEventNumber)<<QwLog::endl;
1078 QwMessage << Form("\n j slope sigma mean/sigma\n");
1079 for (int iy = 0; iy <nY; iy++) {
1080 QwMessage << Form("dv=Y%d: ",iy)<<QwLog::endl;
1081 for (int j = 0; j < nP; j++) {
1082 double val=Axy(j,iy);
1083 double err=dAxy(j,iy);
1084 double nSig=val/err;
1085 char x=' ';
1086 if(fabs(nSig)>3.) x='*';
1087 QwMessage << Form(" slope_%d = %11.3g +/-%11.3g (nSig=%.2f) %c\n",j,val, err,nSig,x);
1088 }
1089 }
1090}

References Axy, dAxy, QwLog::endl(), fGoodEventNumber, nP, nY, and QwMessage.

Referenced by CalcCorrelations().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ printSummaryMeansWithUnc()

void QwCorrelatorNew::printSummaryMeansWithUnc ( ) const

Definition at line 1125 of file QwCorrelatorNew.cc.

1126{
1127 QwMessage << "Uncorrected Y values:" << QwLog::endl;
1128 QwMessage << " mean sig" << QwLog::endl;
1129 for (int i = 0; i < nY; i++){
1130 QwMessage << "Y" << i << ": " << mMY(i) << " +- " << mSY(i) << QwLog::endl;
1131 }
1133}

References QwLog::endl(), mMY, mSY, nY, and QwMessage.

Referenced by CalcCorrelations().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ printSummaryMeansWithUncCorrected()

void QwCorrelatorNew::printSummaryMeansWithUncCorrected ( ) const

Definition at line 1138 of file QwCorrelatorNew.cc.

1139{
1140 QwMessage << "Corrected Y values:" << QwLog::endl;
1141 QwMessage << " mean sig" << QwLog::endl;
1142 for (int i = 0; i < nY; i++){
1143 QwMessage << "Y" << i << ": " << mMYp(i) << " +- " << mSYp(i) << QwLog::endl;
1144 }
1146}

References QwLog::endl(), mMYp, mSYp, nY, and QwMessage.

Referenced by CalcCorrelations().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ printSummaryP()

void QwCorrelatorNew::printSummaryP ( ) const

Definition at line 1018 of file QwCorrelatorNew.cc.

1019{
1020 QwMessage << Form("\nLinRegBevPeb::printSummaryP seen good eve=%lld",fGoodEventNumber)<<QwLog::endl;
1021
1022 size_t dim=nP;
1023 if(fGoodEventNumber>2) { // print full matrix
1024 QwMessage << Form("\nname: ");
1025 for (size_t i = 1; i <dim; i++) {
1026 QwMessage << Form("P%d%11s",(int)i," ");
1027 }
1028 QwMessage << Form("\n mean sig(distrib) nSig(mean) correlation-matrix ....\n");
1029 for (size_t i = 0; i <dim; i++) {
1030 double meanI,sigI;
1031 if (getMeanP(i,meanI) < 0) QwWarning << "LRB::getMeanP failed" << QwLog::endl;
1032 if (getSigmaP(i,sigI) < 0) QwWarning << "LRB::getSigmaP failed" << QwLog::endl;
1033 double nSig=-1;
1034 double err=sigI/sqrt(fGoodEventNumber);
1035 if(sigI>0.) nSig=meanI/err;
1036
1037 QwMessage << Form("P%d: %+12.4g %12.3g %.1f ",(int)i,meanI,sigI,nSig);
1038 for (size_t j = 1; j <dim; j++) {
1039 if( j<=i) { QwMessage << Form(" %12s","._._._."); continue;}
1040 double sigJ,cov;
1041 if (getSigmaP(j,sigJ) < 0) QwWarning << "LRB::getSigmaP failed" << QwLog::endl;
1042 if (getCovarianceP(i,j,cov) < 0) QwWarning << "LRB::getCovarianceP failed" << QwLog::endl;
1043 double corel=cov / sigI / sigJ;
1044
1045 QwMessage << Form(" %12.3g",corel);
1046 }
1047 QwMessage << Form("\n");
1048 }
1049 }
1050}
Int_t getSigmaP(const int i, Double_t &sigma) const
Get mean value of a variable, returns error code.
Int_t getMeanP(const int i, Double_t &mean) const
Get mean value of a variable, returns error code.
Int_t getCovarianceP(int i, int j, Double_t &covar) const
Get mean value of a variable, returns error code.

References QwLog::endl(), fGoodEventNumber, getCovarianceP(), getMeanP(), getSigmaP(), nP, QwMessage, and QwWarning.

Referenced by CalcCorrelations().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ printSummaryY()

void QwCorrelatorNew::printSummaryY ( ) const

Definition at line 1055 of file QwCorrelatorNew.cc.

1056{
1057 QwMessage << Form("\nLinRegBevPeb::printSummaryY seen good eve=%lld (CSV-format)",fGoodEventNumber)<<QwLog::endl;
1058 QwMessage << Form(" j, mean, sig(mean), nSig(mean), sig(distribution) \n");
1059
1060 for (int i = 0; i <nY; i++) {
1061 double meanI,sigI;
1062 if (getMeanY(i,meanI) < 0) QwWarning << "LRB::getMeanY failed" << QwLog::endl;
1063 if (getSigmaY(i,sigI) < 0) QwWarning << "LRB::getSigmaY failed" << QwLog::endl;
1064 double err = sigI / sqrt(fGoodEventNumber);
1065 double nSigErr = meanI / err;
1066 QwMessage << Form("Y%02d, %+11.4g, %12.4g, %8.1f, %12.4g "" ",i,meanI,err,nSigErr,sigI)<<QwLog::endl;
1067
1068 }
1069}
Int_t getSigmaY(const int i, Double_t &sigma) const
Int_t getMeanY(const int i, Double_t &mean) const

References QwLog::endl(), fGoodEventNumber, getMeanY(), getSigmaY(), nY, QwMessage, and QwWarning.

Referenced by CalcCorrelations().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ printSummaryYP()

void QwCorrelatorNew::printSummaryYP ( ) const

Definition at line 1095 of file QwCorrelatorNew.cc.

1096{
1097 QwMessage << Form("\nLinRegBevPeb::printSummaryYP seen good eve=%lld",fGoodEventNumber)<<QwLog::endl;
1098
1099 if(fGoodEventNumber<2) { QwMessage<<" too few events, skip"<<QwLog::endl; return;}
1100 QwMessage << Form("\n name: ");
1101 for (int i = 0; i <nP; i++) {
1102 QwMessage << Form(" %10sP%d "," ",i);
1103 }
1104 QwMessage << Form("\n j meanY sigY correlation with Ps ....\n");
1105 for (int iy = 0; iy <nY; iy++) {
1106 double meanI,sigI;
1107 if (getMeanY(iy,meanI) < 0) QwWarning << "LRB::getMeanY failed" << QwLog::endl;
1108 if (getSigmaY(iy,sigI) < 0) QwWarning << "LRB::getSigmaY failed" << QwLog::endl;
1109
1110 QwMessage << Form(" %3d %6sY%d: %+12.4g %12.4g ",iy," ",iy,meanI,sigI);
1111 for (int ip = 0; ip <nP; ip++) {
1112 double sigJ,cov;
1113 if (getSigmaP(ip,sigJ) < 0) QwWarning << "LRB::getSigmaP failed" << QwLog::endl;
1114 if (getCovariancePY(ip,iy,cov) < 0) QwWarning << "LRB::getCovariancePY failed" << QwLog::endl;
1115 double corel = cov / sigI / sigJ;
1116 QwMessage << Form(" %12.3g",corel);
1117 }
1118 QwMessage << Form("\n");
1119 }
1120}
Int_t getCovariancePY(int ip, int iy, Double_t &covar) const

References QwLog::endl(), fGoodEventNumber, getCovariancePY(), getMeanY(), getSigmaP(), getSigmaY(), nP, nY, QwMessage, and QwWarning.

+ Here is the call graph for this function:

◆ ProcessData()

void QwCorrelatorNew::ProcessData ( )
overridevirtual

Copy dependent variables to output variables (default processing).

Reimplemented from VQwDataHandler.

Definition at line 82 of file QwCorrelatorNew.cc.

83{
84 // Add to total count
86
87 // Start as good event
88 fGoodEvent = 0;
89
90 // Event error flag
93 // Dependent variable error codes
94 for (size_t i = 0; i < fDependentVar.size(); ++i) {
95 fGoodEvent |= fDependentVar.at(i)->GetErrorCode();
96 fDependentValues.at(i) = (fDependentVar[i]->GetValue(fBlock+1));
97 if (fDependentVar.at(i)->GetErrorCode() !=0) (fErrCounts_DV.at(i))++;
98 }
99 // Independent variable error codes
100 for (size_t i = 0; i < fIndependentVar.size(); ++i) {
101 fGoodEvent |= fIndependentVar.at(i)->GetErrorCode();
102 fIndependentValues.at(i) = (fIndependentVar[i]->GetValue(fBlock+1));
103 if (fIndependentVar.at(i)->GetErrorCode() !=0) (fErrCounts_IV.at(i))++;
104 }
105
106 // If good, process event
107 if (fGoodEvent == 0) {
108 fGoodCount++;
109
110 TVectorD P(fIndependentValues.size(), fIndependentValues.data());
111 TVectorD Y(fDependentValues.size(), fDependentValues.data());
112 operator+= (std::make_pair(P, Y));
113 }
114}
UInt_t GetEventcutErrorFlag() const

References fBlock, VQwDataHandler::fDependentValues, VQwDataHandler::fDependentVar, fErrCounts_DV, fErrCounts_EF, fErrCounts_IV, fGoodCount, fGoodEvent, fIndependentValues, fIndependentVar, fTotalCount, VQwDataHandler::GetEventcutErrorFlag(), and operator+=().

+ Here is the call graph for this function:

◆ ProcessOptions()

void QwCorrelatorNew::ProcessOptions ( QwOptions & options)

Definition at line 62 of file QwCorrelatorNew.cc.

63{
64}

◆ setDims()

void QwCorrelatorNew::setDims ( int a,
int b )
inline

Definition at line 180 of file QwCorrelatorNew.h.

180{ nP = a; nY = b;}

References nP, and nY.

Referenced by ConnectChannels().

+ Here is the caller graph for this function:

◆ solve()

void QwCorrelatorNew::solve ( )

normalized covariances

Definition at line 1151 of file QwCorrelatorNew.cc.

1152{
1153 // off-diagonal raw covariance
1154 mVYP.Transpose(mVPY);
1155
1156 // diagonal variances
1157 mVP = TMatrixDDiag(mVPP); mVP.Sqrt();
1158 mVY = TMatrixDDiag(mVYY); mVY.Sqrt();
1159
1160 // correlation matrices
1161 mRPP = mVPP; mRPP.NormByColumn(mVP); mRPP.NormByRow(mVP);
1162 mRYY = mVYY; mRYY.NormByColumn(mVY); mRYY.NormByRow(mVY);
1163 mRPY = mVPY; mRPY.NormByColumn(mVP); mRPY.NormByRow(mVY);
1164
1165 /// normalized covariances
1166 mSYY = mVYY * (1.0 / (fGoodEventNumber - 1.));
1167 mSPP = mVPP * (1.0 / (fGoodEventNumber - 1.));
1168 mSPY = mVPY * (1.0 / (fGoodEventNumber - 1.));
1169 mSYP.Transpose(mSPY);
1170
1171 // uncertainties on the means
1172 mSP = TMatrixDDiag(mSPP); mSP.Sqrt();
1173 mSY = TMatrixDDiag(mSYY); mSY.Sqrt();
1174
1175 // Warn if correlation matrix determinant close to zero (heuristic)
1176 if (mRPP.Determinant() < std::pow(10,-(2*nP))) {
1177 QwWarning << "LRB: correlation matrix nearly singular, "
1178 << "determinant = " << mRPP.Determinant()
1179 << " (set includes highly correlated variable pairs)"
1180 << QwLog::endl;
1181 if (fGoodEventNumber > 10*nP) {
1182 QwMessage << fGoodEventNumber << " events" << QwLog::endl;
1183 QwMessage << "Covariance matrix: " << QwLog::endl; mVPP.Print();
1184 QwMessage << "Correlation matrix: " << QwLog::endl; mRPP.Print();
1185 }
1186 QwWarning << "LRB: solving failed (this happens when only few events)."
1187 << QwLog::endl;
1188 return;
1189 }
1190 // slopes
1191 TMatrixD invRPP(TMatrixD::kInverted, mRPP);
1192 Axy = TMatrixD(invRPP, TMatrixD::kMult, mRPY);
1193 Axy.NormByColumn(mSP); // divide
1194 Axy.NormByRow(mSY, ""); // mult
1195 Ayx.Transpose(Axy);
1196
1197 // new means
1198 mMYp = mMY - Ayx * mMP;
1199
1200 // new raw covariance
1201 mVYYp = mVYY + Ayx * mVPP * Axy - (Ayx * mVPY + mVYP * Axy);
1202 // new variances
1203 mVYp = TMatrixDDiag(mVYYp); mVYp.Sqrt();
1204
1205 // new normalized covariance
1206 mSYYp = mSYY + Ayx * mSPP * Axy - (Ayx * mSPY + mSYP * Axy);
1207 // uncertainties on the new means
1208 mSYp = TMatrixDDiag(mSYYp); mSYp.Sqrt();
1209
1210 // new correlation matrix
1211 mRYYp = mVYYp; mRYYp.NormByColumn(mVYp); mRYYp.NormByRow(mVYp);
1212
1213 // slope uncertainties
1214 double norm = 1. / (fGoodEventNumber - nP - 1);
1215 dAxy.Zero();
1216 dAxy.Rank1Update(TMatrixDDiag(invRPP), TMatrixDDiag(mRYYp), norm); // diag mRYYp = row of ones
1217 dAxy.Sqrt();
1218 dAxy.NormByColumn(mSP); // divide
1219 dAxy.NormByRow(mSYp, ""); // mult
1220 dAyx.Transpose(dAxy);
1221
1222 fErrorFlag = 0;
1223}

References Axy, Ayx, dAxy, dAyx, QwLog::endl(), fErrorFlag, fGoodEventNumber, mMP, mMY, mMYp, mRPP, mRPY, mRYY, mRYYp, mSP, mSPP, mSPY, mSY, mSYP, mSYp, mSYY, mSYYp, mVP, mVPP, mVPY, mVY, mVYP, mVYp, mVYY, mVYYp, nP, QwMessage, and QwWarning.

Referenced by CalcCorrelations().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WriteAliasFile()

void QwCorrelatorNew::WriteAliasFile ( )
protected

Definition at line 668 of file QwCorrelatorNew.cc.

669{
670 // Ensure output file is open
671 if (fAliasOutputFile.bad()) {
672 QwWarning << "QwCorrelatorNew: Could not write to alias output file " << QwLog::endl;
673 return;
674 }
675
676 fAliasOutputFile << " if (i == " << fCycleCounter << ") {" << std::endl;
677 fAliasOutputFile << Form(" TTree* tree = (TTree*) gDirectory->Get(\"mul\");") << std::endl;
678 for (int i = 0; i < nY; i++) {
679 fAliasOutputFile << Form(" tree->SetAlias(\"reg_%s\",",fDependentFull[i].c_str()) << std::endl;
680 fAliasOutputFile << Form(" \"%s",fDependentFull[i].c_str());
681 for (int j = 0; j < nP; j++) {
682 fAliasOutputFile << Form("%+.4e*%s", -this->Axy(j,i), fIndependentFull[j].c_str());
683 }
684 fAliasOutputFile << "\");" << std::endl;
685 }
686 fAliasOutputFile << " }" << std::endl;
687
688 // Increment call counter
690}

References Axy, QwLog::endl(), fAliasOutputFile, fCycleCounter, VQwDataHandler::fDependentFull, fIndependentFull, nP, nY, and QwWarning.

Referenced by CalcCorrelations().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WriteAlphaFile()

void QwCorrelatorNew::WriteAlphaFile ( )
protected

Definition at line 550 of file QwCorrelatorNew.cc.

551{
552 // Ensure in output file
554
555 // Write objects
556 this->Axy.Write("slopes");
557 this->dAxy.Write("sigSlopes");
558
559 this->mRPP.Write("IV_IV_correlation");
560 this->mRPY.Write("IV_DV_correlation");
561 this->mRYY.Write("DV_DV_correlation");
562 this->mRYYp.Write("DV_DV_correlation_prime");
563
564 this->mMP.Write("IV_mean");
565 this->mMY.Write("DV_mean");
566 this->mMYp.Write("DV_mean_prime");
567
568 // number of events
569 TMatrixD Mstat(1,1);
570 Mstat(0,0)=this->getUsedEve();
571 Mstat.Write("MyStat");
572
573 //... IVs
574 TH1D hiv("IVname","names of IVs",nP,-0.5,nP-0.5);
575 for (int i=0;i<nP;i++) hiv.Fill(fIndependentFull[i].c_str(),i);
576 hiv.Write();
577
578 //... DVs
579 TH1D hdv("DVname","names of IVs",nY,-0.5,nY-0.5);
580 for (int i=0;i<nY;i++) hdv.Fill(fDependentFull[i].c_str(),i);
581 hdv.Write();
582
583 // sigmas
584 this->mSP.Write("IV_sigma");
585 this->mSY.Write("DV_sigma");
586 this->mSYp.Write("DV_sigma_prime");
587
588 // raw covariances
589 this->mVPP.Write("IV_IV_rawVariance");
590 this->mVPY.Write("IV_DV_rawVariance");
591 this->mVYY.Write("DV_DV_rawVariance");
592 this->mVYYp.Write("DV_DV_rawVariance_prime");
593 TVectorD mVY2(TMatrixDDiag(this->mVYY));
594 mVY2.Write("DV_rawVariance");
595 TVectorD mVP2(TMatrixDDiag(this->mVPP));
596 mVP2.Write("IV_rawVariance");
597 TVectorD mVY2prime(TMatrixDDiag(this->mVYYp));
598 mVY2prime.Write("DV_rawVariance_prime");
599
600 // normalized covariances
601 this->mSPP.Write("IV_IV_normVariance");
602 this->mSPY.Write("IV_DV_normVariance");
603 this->mSYY.Write("DV_DV_normVariance");
604 this->mSYYp.Write("DV_DV_normVariance_prime");
605 TVectorD sigY2(TMatrixDDiag(this->mSYY));
606 sigY2.Write("DV_normVariance");
607 TVectorD sigX2(TMatrixDDiag(this->mSPP));
608 sigX2.Write("IV_normVariance");
609 TVectorD sigY2prime(TMatrixDDiag(this->mSYYp));
610 sigY2prime.Write("DV_normVariance_prime");
611
612 this->Axy.Write("A_xy");
613 this->Ayx.Write("A_yx");
614}
double getUsedEve() const

References Axy, Ayx, dAxy, fAlphaOutputFile, VQwDataHandler::fDependentFull, fIndependentFull, getUsedEve(), mMP, mMY, mMYp, mRPP, mRPY, mRYY, mRYYp, mSP, mSPP, mSPY, mSY, mSYp, mSYY, mSYYp, mVPP, mVPY, mVYY, mVYYp, nP, and nY.

Referenced by CalcCorrelations().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator+

QwCorrelatorNew operator+ ( QwCorrelatorNew lhs,
const QwCorrelatorNew & rhs )
friend

Definition at line 205 of file QwCorrelatorNew.h.

207 {
208 lhs += rhs; // reuse compound assignment
209 return lhs; // return the result by value (uses move constructor)
210 }

References QwCorrelatorNew().

◆ operator<<

std::ostream & operator<< ( std::ostream & stream,
const QwCorrelatorNew & h )
friend

Output stream operator.

Definition at line 217 of file QwCorrelatorNew.h.

218{
219 stream << "LRB: " << h.fGoodEventNumber << " events";
220 return stream;
221}

References fGoodEventNumber, and QwCorrelatorNew().

Field Documentation

◆ Axy

TMatrixD QwCorrelatorNew::Axy
private

◆ Ayx

TMatrixD QwCorrelatorNew::Ayx
private

Definition at line 162 of file QwCorrelatorNew.h.

Referenced by clear(), init(), solve(), and WriteAlphaFile().

◆ dAxy

TMatrixD QwCorrelatorNew::dAxy
private

◆ dAyx

TMatrixD QwCorrelatorNew::dAyx
private

Definition at line 162 of file QwCorrelatorNew.h.

Referenced by clear(), init(), and solve().

◆ fAliasOutputFile

std::ofstream QwCorrelatorNew::fAliasOutputFile
protected

Definition at line 100 of file QwCorrelatorNew.h.

Referenced by CloseAliasFile(), OpenAliasFile(), and WriteAliasFile().

◆ fAliasOutputFileBase

std::string QwCorrelatorNew::fAliasOutputFileBase
protected

Definition at line 97 of file QwCorrelatorNew.h.

Referenced by OpenAliasFile(), ParseConfigFile(), QwCorrelatorNew(), and QwCorrelatorNew().

◆ fAliasOutputFileSuff

std::string QwCorrelatorNew::fAliasOutputFileSuff
protected

Definition at line 98 of file QwCorrelatorNew.h.

Referenced by OpenAliasFile(), ParseConfigFile(), QwCorrelatorNew(), and QwCorrelatorNew().

◆ fAliasOutputPath

std::string QwCorrelatorNew::fAliasOutputPath
protected

Definition at line 99 of file QwCorrelatorNew.h.

Referenced by OpenAliasFile(), ParseConfigFile(), QwCorrelatorNew(), and QwCorrelatorNew().

◆ fAlphaOutputFile

TFile* QwCorrelatorNew::fAlphaOutputFile
protected

◆ fAlphaOutputFileBase

std::string QwCorrelatorNew::fAlphaOutputFileBase
protected

Definition at line 87 of file QwCorrelatorNew.h.

Referenced by OpenAlphaFile(), ParseConfigFile(), QwCorrelatorNew(), and QwCorrelatorNew().

◆ fAlphaOutputFileSuff

std::string QwCorrelatorNew::fAlphaOutputFileSuff
protected

Definition at line 88 of file QwCorrelatorNew.h.

Referenced by OpenAlphaFile(), ParseConfigFile(), QwCorrelatorNew(), and QwCorrelatorNew().

◆ fAlphaOutputPath

std::string QwCorrelatorNew::fAlphaOutputPath
protected

Definition at line 89 of file QwCorrelatorNew.h.

Referenced by OpenAlphaFile(), ParseConfigFile(), QwCorrelatorNew(), and QwCorrelatorNew().

◆ fBlock

Int_t QwCorrelatorNew::fBlock
protected

Definition at line 74 of file QwCorrelatorNew.h.

Referenced by ParseConfigFile(), ProcessData(), QwCorrelatorNew(), and QwCorrelatorNew().

◆ fCycleCounter

Int_t QwCorrelatorNew::fCycleCounter
private

Definition at line 126 of file QwCorrelatorNew.h.

Referenced by QwCorrelatorNew(), QwCorrelatorNew(), and WriteAliasFile().

◆ fDisableHistos

bool QwCorrelatorNew::fDisableHistos
protected

◆ fErrCounts_DV

std::vector<int> QwCorrelatorNew::fErrCounts_DV
protected

Definition at line 110 of file QwCorrelatorNew.h.

Referenced by CalcCorrelations(), ClearEventData(), ConnectChannels(), and ProcessData().

◆ fErrCounts_EF

int QwCorrelatorNew::fErrCounts_EF
protected

Definition at line 108 of file QwCorrelatorNew.h.

Referenced by CalcCorrelations(), ClearEventData(), and ProcessData().

◆ fErrCounts_IV

std::vector<int> QwCorrelatorNew::fErrCounts_IV
protected

Definition at line 109 of file QwCorrelatorNew.h.

Referenced by CalcCorrelations(), ClearEventData(), ConnectChannels(), and ProcessData().

◆ fErrorFlag

Int_t QwCorrelatorNew::fErrorFlag
private

is information valid

Definition at line 133 of file QwCorrelatorNew.h.

Referenced by clear(), ConstructTreeBranches(), QwCorrelatorNew(), QwCorrelatorNew(), and solve().

◆ fGoodCount

int QwCorrelatorNew::fGoodCount
protected

◆ fGoodEvent

unsigned int QwCorrelatorNew::fGoodEvent
protected

Definition at line 112 of file QwCorrelatorNew.h.

Referenced by ClearEventData(), FillHistograms(), and ProcessData().

◆ fGoodEventNumber

◆ fH1dv

std::vector<TH1D> QwCorrelatorNew::fH1dv
private

Definition at line 122 of file QwCorrelatorNew.h.

Referenced by ConstructHistograms(), and FillHistograms().

◆ fH1iv

std::vector<TH1D> QwCorrelatorNew::fH1iv
private

Definition at line 121 of file QwCorrelatorNew.h.

Referenced by ConstructHistograms(), and FillHistograms().

◆ fH2dv

std::vector<std::vector<TH2D> > QwCorrelatorNew::fH2dv
private

Definition at line 124 of file QwCorrelatorNew.h.

Referenced by ConstructHistograms(), and FillHistograms().

◆ fH2iv

std::vector<std::vector<TH2D> > QwCorrelatorNew::fH2iv
private

Definition at line 123 of file QwCorrelatorNew.h.

Referenced by ConstructHistograms(), and FillHistograms().

◆ fHnames

std::vector<TH1D> QwCorrelatorNew::fHnames
private

Definition at line 120 of file QwCorrelatorNew.h.

Referenced by ConstructHistograms().

◆ fIndependentFull

std::vector< std::string > QwCorrelatorNew::fIndependentFull
protected

Definition at line 78 of file QwCorrelatorNew.h.

Referenced by ConnectChannels(), LoadChannelMap(), WriteAliasFile(), and WriteAlphaFile().

◆ fIndependentName

std::vector< std::string > QwCorrelatorNew::fIndependentName
protected

Definition at line 82 of file QwCorrelatorNew.h.

Referenced by ConnectChannels(), ConstructHistograms(), and LoadChannelMap().

◆ fIndependentType

std::vector< EQwHandleType > QwCorrelatorNew::fIndependentType
protected

Definition at line 81 of file QwCorrelatorNew.h.

Referenced by ConnectChannels(), and LoadChannelMap().

◆ fIndependentValues

std::vector< Double_t > QwCorrelatorNew::fIndependentValues
protected

Definition at line 85 of file QwCorrelatorNew.h.

Referenced by ConnectChannels(), FillHistograms(), and ProcessData().

◆ fIndependentVar

std::vector< const VQwHardwareChannel* > QwCorrelatorNew::fIndependentVar
protected

Definition at line 84 of file QwCorrelatorNew.h.

Referenced by CalcCorrelations(), ConnectChannels(), and ProcessData().

◆ fNameNoSpaces

TString QwCorrelatorNew::fNameNoSpaces
private

Definition at line 116 of file QwCorrelatorNew.h.

Referenced by QwCorrelatorNew().

◆ fPrintCorrelations

bool QwCorrelatorNew::fPrintCorrelations = false
staticprivate

Definition at line 35 of file QwCorrelatorNew.h.

Referenced by CalcCorrelations(), and DefineOptions().

◆ fTotalCount

int QwCorrelatorNew::fTotalCount
protected

◆ fTree

TTree* QwCorrelatorNew::fTree
protected

◆ mMP

TVectorD QwCorrelatorNew::mMP
private

◆ mMY

TVectorD QwCorrelatorNew::mMY
private

◆ mMYp

TVectorD QwCorrelatorNew::mMYp
private

◆ mRPP

TMatrixD QwCorrelatorNew::mRPP
private

Definition at line 138 of file QwCorrelatorNew.h.

Referenced by clear(), ConstructTreeBranches(), init(), solve(), and WriteAlphaFile().

◆ mRPY

TMatrixD QwCorrelatorNew::mRPY
private

correlations

Definition at line 137 of file QwCorrelatorNew.h.

Referenced by clear(), ConstructTreeBranches(), init(), solve(), and WriteAlphaFile().

◆ mRYP

TMatrixD QwCorrelatorNew::mRYP
private

Definition at line 137 of file QwCorrelatorNew.h.

Referenced by clear(), ConstructTreeBranches(), and init().

◆ mRYY

TMatrixD QwCorrelatorNew::mRYY
private

Definition at line 138 of file QwCorrelatorNew.h.

Referenced by clear(), ConstructTreeBranches(), init(), solve(), and WriteAlphaFile().

◆ mRYYp

TMatrixD QwCorrelatorNew::mRYYp
private

Definition at line 139 of file QwCorrelatorNew.h.

Referenced by clear(), ConstructTreeBranches(), init(), solve(), and WriteAlphaFile().

◆ mSP

TVectorD QwCorrelatorNew::mSP
private

sigmas

Definition at line 154 of file QwCorrelatorNew.h.

Referenced by clear(), ConstructTreeBranches(), init(), solve(), and WriteAlphaFile().

◆ mSPP

TMatrixD QwCorrelatorNew::mSPP
private

Definition at line 151 of file QwCorrelatorNew.h.

Referenced by clear(), ConstructTreeBranches(), init(), solve(), and WriteAlphaFile().

◆ mSPY

TMatrixD QwCorrelatorNew::mSPY
private

normalized covariances

Definition at line 150 of file QwCorrelatorNew.h.

Referenced by clear(), ConstructTreeBranches(), init(), solve(), and WriteAlphaFile().

◆ mSY

TVectorD QwCorrelatorNew::mSY
private

◆ mSYP

TMatrixD QwCorrelatorNew::mSYP
private

Definition at line 150 of file QwCorrelatorNew.h.

Referenced by clear(), ConstructTreeBranches(), init(), and solve().

◆ mSYp

TVectorD QwCorrelatorNew::mSYp
private

◆ mSYY

TMatrixD QwCorrelatorNew::mSYY
private

Definition at line 151 of file QwCorrelatorNew.h.

Referenced by clear(), ConstructTreeBranches(), init(), solve(), and WriteAlphaFile().

◆ mSYYp

TMatrixD QwCorrelatorNew::mSYYp
private

Definition at line 152 of file QwCorrelatorNew.h.

Referenced by clear(), ConstructTreeBranches(), init(), solve(), and WriteAlphaFile().

◆ mVP

TVectorD QwCorrelatorNew::mVP
private

variances

Definition at line 146 of file QwCorrelatorNew.h.

Referenced by clear(), init(), and solve().

◆ mVPP

TMatrixD QwCorrelatorNew::mVPP
private

◆ mVPY

TMatrixD QwCorrelatorNew::mVPY
private

unnormalized covariances

Definition at line 142 of file QwCorrelatorNew.h.

Referenced by clear(), ConstructTreeBranches(), getCovariancePY(), init(), operator+=(), operator+=(), print(), solve(), and WriteAlphaFile().

◆ mVY

TVectorD QwCorrelatorNew::mVY
private

Definition at line 146 of file QwCorrelatorNew.h.

Referenced by clear(), init(), and solve().

◆ mVYP

TMatrixD QwCorrelatorNew::mVYP
private

Definition at line 142 of file QwCorrelatorNew.h.

Referenced by clear(), ConstructTreeBranches(), init(), and solve().

◆ mVYp

TVectorD QwCorrelatorNew::mVYp
private

Definition at line 147 of file QwCorrelatorNew.h.

Referenced by clear(), init(), and solve().

◆ mVYY

TMatrixD QwCorrelatorNew::mVYY
private

◆ mVYYp

TMatrixD QwCorrelatorNew::mVYYp
private

◆ nP

◆ nY


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