JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwCorrelator.h
Go to the documentation of this file.
1/*!
2 * \file QwCorrelator.h
3 * \brief Correlator data handler using LinRegBlue algorithms
4 * \author Michael Vallee
5 * \date 2018-08-01
6 */
7
8#pragma once
9
10// Parent Class
11#include "VQwDataHandler.h"
12
13// LinRegBlue Correlator Class
15
16// System headers
17#include <fstream>
18
19// Forward declarations
20class TH1D;
21class TH2D;
22class QwRootFile;
23
24/**
25 * \class QwCorrelator
26 * \ingroup QwAnalysis
27 * \brief Data handler computing correlations and linear-regression coefficients
28 *
29 * Uses Bevington/Pebay algorithms to estimate correlations between independent
30 * and dependent variables selected from subsystem arrays. Produces summary
31 * histograms and optional output trees/files for further analysis.
32 */
33class QwCorrelator : public VQwDataHandler, public MQwDataHandlerCloneable<QwCorrelator>
34{
35 public:
36 /// \brief Constructor with name
37 QwCorrelator(const TString& name);
38 QwCorrelator(const QwCorrelator& name);
39 ~QwCorrelator() override;
40
41 private:
42 static bool fPrintCorrelations;
43 public:
44 static void DefineOptions(QwOptions &options);
45 void ProcessOptions(QwOptions &options);
46
47 void ParseConfigFile(QwParameterFile& file) override;
48
49 Int_t LoadChannelMap(const std::string& mapfile) override;
50
51 /// \brief Connect to Channels (asymmetry/difference only)
52 /// \param asym Subsystem array with asymmetries
53 /// \param diff Subsystem array with differences
54 /// \return 0 on success, non-zero on failure
56
57 void ProcessData() override;
58 void FinishDataHandler() override{
60 }
61 void CalcCorrelations();
62
63 /// \brief Construct the tree branches
65 QwRootFile *treerootfile,
66 const std::string& treeprefix = "",
67 const std::string& branchprefix = "") override;
68 /// \brief Fill the tree branches
69 void FillTreeBranches(QwRootFile *treerootfile) override { };
70
71 /// \brief Construct the histograms in a folder with a prefix
72 void ConstructHistograms(TDirectory *folder, TString &prefix) override;
73 /// \brief Fill the histograms
74 void FillHistograms() override;
75
76 void ClearEventData() override;
77 void AccumulateRunningSum(VQwDataHandler &value, Int_t count = 0, Int_t ErrorMask = 0xFFFFFFF) override;
78
79 protected:
80
81 Int_t fBlock;
82
84
85 std::vector< std::string > fIndependentFull;
86
87 // Using the fDependentType and fDependentName from base class, but override the IV arrays
88 std::vector< EQwHandleType > fIndependentType;
89 std::vector< std::string > fIndependentName;
90
91 std::vector< const VQwHardwareChannel* > fIndependentVar;
92 std::vector< Double_t > fIndependentValues;
93
96 std::string fAlphaOutputPath;
98 void OpenAlphaFile(const std::string& prefix);
99 void WriteAlphaFile();
100 void CloseAlphaFile();
101
102 TTree* fTree;
103
106 std::string fAliasOutputPath;
107 std::ofstream fAliasOutputFile;
108 void OpenAliasFile(const std::string& prefix);
109 void WriteAliasFile();
110 void CloseAliasFile();
111
114
116 std::vector<int> fErrCounts_IV;
117 std::vector<int> fErrCounts_DV;
118
119 unsigned int fGoodEvent;
120
121 private:
122
124 int nP, nY;
125
126 // monitoring histos for iv & dv
127 std::vector<TH1D> fHnames;
128 std::vector<TH1D> fH1iv;
129 std::vector<TH1D> fH1dv;
130 std::vector<std::vector<TH2D>> fH2iv;
131 std::vector<std::vector<TH2D>> fH2dv;
132
134
136
137 // Default constructor
139
140};
Virtual base class for data handlers accessing multiple subsystems.
Linear regression utility class based on Bevington and Pebay algorithms.
Command-line and configuration file options processor.
Definition QwOptions.h:141
Configuration file parser with flexible tokenization and search capabilities.
A wrapper class for a ROOT file or memory mapped file.
Definition QwRootFile.h:827
Online linear regression with incremental covariance updates.
std::vector< std::string > fIndependentName
void OpenAliasFile(const std::string &prefix)
unsigned int fGoodEvent
void WriteAlphaFile()
std::string fAlphaOutputPath
void CloseAliasFile()
void ClearEventData() override
std::string fAliasOutputFileBase
void OpenAlphaFile(const std::string &prefix)
void ProcessData() override
QwCorrelator(const TString &name)
Constructor with name.
std::vector< std::vector< TH2D > > fH2iv
void CalcCorrelations()
~QwCorrelator() override
std::vector< Double_t > fIndependentValues
std::string fAlphaOutputFileBase
std::vector< EQwHandleType > fIndependentType
std::string fAliasOutputPath
std::ofstream fAliasOutputFile
Int_t ConnectChannels(QwSubsystemArrayParity &asym, QwSubsystemArrayParity &diff) override
Connect to Channels (asymmetry/difference only)
void FillTreeBranches(QwRootFile *treerootfile) override
Fill the tree branches.
TString fNameNoSpaces
TFile * fAlphaOutputFile
void FinishDataHandler() override
void ConstructTreeBranches(QwRootFile *treerootfile, const std::string &treeprefix="", const std::string &branchprefix="") override
Construct the tree branches.
void ParseConfigFile(QwParameterFile &file) override
void CloseAlphaFile()
Int_t fCycleCounter
static bool fPrintCorrelations
void WriteAliasFile()
LinRegBevPeb linReg
void ConstructHistograms(TDirectory *folder, TString &prefix) override
Construct the histograms in a folder with a prefix.
std::vector< std::string > fIndependentFull
std::vector< const VQwHardwareChannel * > fIndependentVar
std::string fAlphaOutputFileSuff
std::vector< TH1D > fHnames
std::vector< TH1D > fH1dv
std::string fAliasOutputFileSuff
std::vector< std::vector< TH2D > > fH2dv
std::vector< TH1D > fH1iv
void ProcessOptions(QwOptions &options)
std::vector< int > fErrCounts_DV
void FillHistograms() override
Fill the histograms.
bool fDisableHistos
std::vector< int > fErrCounts_IV
static void DefineOptions(QwOptions &options)
Subsystem array container specialized for parity analysis with asymmetry calculations.
Abstract base for handlers that consume multiple subsystems and produce derived outputs.
void AccumulateRunningSum()
VQwDataHandler(const TString &name)