90 "print correlations after determining them");
109 QwWarning <<
"QwCorrelator: expect 0 <= block <= 3 but block = "
143 linReg += std::make_pair(P, Y);
169 QwWarning <<
"QwCorrelator::AccumulateRunningSum "
170 <<
"can only accept other QwCorrelator objects."
178 if (
nP == 0 ||
nY == 0) {
192 <<
"< 1% good events, "
199 QwVerbose <<
" Entries failed due to error flag: "
227 linReg.printSummaryAlphas();
228 linReg.printSummaryMeansWithUnc();
229 linReg.printSummaryMeansWithUncCorrected();
254 std::pair<EQwHandleType,std::string> type_name;
268 if (primary_token ==
"iv") {
273 else if (primary_token ==
"dv") {
278 else if (primary_token ==
"treetype") {
282 QwError <<
"LoadChannelMap in QwCorrelator read invalid primary_token " << primary_token <<
QwLog::endl;
316 QwWarning <<
"QwCorrelator::ConnectChannels(QwSubsystemArrayParity& asym, QwSubsystemArrayParity& diff): "
318 <<
", for asym/diff correlator does not have proper type, type=="
324 QwWarning <<
"QwCombiner::ConnectChannels(QwSubsystemArrayParity& asym, QwSubsystemArrayParity& diff): Dependent variable, "
326 <<
", was not found (fullname=="
354 QwWarning <<
"Independent variable for correlator has unknown type."
385 const std::string& treeprefix,
386 const std::string& branchprefix)
389 if (
nP == 0 ||
nY == 0) {
404 const std::string name = treeprefix +
fTreeName;
408 if (
fTree == NULL)
return;
414 fTree->Branch(TString(branchprefix +
"n"), &(
linReg.fGoodEventNumber));
415 fTree->Branch(TString(branchprefix +
"ErrorFlag"), &(
linReg.fErrorFlag));
417 auto bn = [&](
const TString& n) {
418 return TString(branchprefix + n);
420 auto pm = [](TMatrixD& m) {
421 return m.GetMatrixArray();
423 auto lm = [](TMatrixD& m,
const TString& n) {
424 return Form(
"%s[%d][%d]/D", n.Data(), m.GetNrows(), m.GetNcols());
426 auto branchm = [&](TTree* tree, TMatrixD& m,
const TString& n) {
427 tree->Branch(bn(n),pm(m),lm(m,n));
429 auto pv = [](TVectorD& v) {
430 return v.GetMatrixArray();
432 auto lv = [](TVectorD& v,
const TString& n) {
433 return Form(
"%s[%d]/D", n.Data(), v.GetNrows());
435 auto branchv = [&](TTree* tree, TVectorD& v,
const TString& n) {
436 tree->Branch(bn(n),pv(v),lv(v,n));
477 if (
nP == 0 ||
nY == 0) {
483 name.ReplaceAll(
" ",
"_");
484 folder->mkdir(name)->cd();
488 for (
int i = 0; i <
nP; i++) {
493 fH1iv[i].GetXaxis()->SetNdivisions(4);
499 for (
int i = 0; i <
nP; i++) {
501 for (
int j = i+1; j <
nP; j++) {
504 Form(
"iv correlation P%d_P%d, pass=%s ;P%d=%s (ppm);P%d=%s (ppm) ",
508 fH2iv[i][j].GetXaxis()->SetTitleColor(kBlue);
509 fH2iv[i][j].GetYaxis()->SetTitleColor(kBlue);
510 fH2iv[i][j].GetXaxis()->SetNdivisions(4);
511 fH2iv[i][j].GetYaxis()->SetNdivisions(4);
517 for (
int i = 0; i <
nY; i++) {
522 fH1dv[i].GetXaxis()->SetNdivisions(4);
528 for (
int i = 0; i <
nP; i++) {
530 for (
int j = 0; j <
nY; j++) {
533 Form(
"iv-dv correlation P%d_Y%d, pass=%s ;P%d=%s (ppm);Y%d=%s (ppm) ",
537 fH2dv[i][j].GetXaxis()->SetTitleColor(kBlue);
538 fH2dv[i][j].GetYaxis()->SetTitleColor(kBlue);
539 fH2dv[i][j].GetXaxis()->SetNdivisions(4);
540 fH2dv[i][j].GetYaxis()->SetNdivisions(4);
546 fHnames[0] = TH1D(
"NamesIV",Form(
"IV name list nIV=%d",
nP),
nP,0,1);
547 for (
int i = 0; i <
nP; i++)
549 fHnames[1] = TH1D(
"NamesDV",Form(
"DV name list nIV=%d",
nY),
nY,0,1);
550 for (
int i = 0; i <
nY; i++)
561 if (
nP == 0 ||
nY == 0) {
587 linReg.Axy.Write(
"slopes");
588 linReg.dAxy.Write(
"sigSlopes");
590 linReg.mRPP.Write(
"IV_IV_correlation");
591 linReg.mRPY.Write(
"IV_DV_correlation");
592 linReg.mRYY.Write(
"DV_DV_correlation");
593 linReg.mRYYp.Write(
"DV_DV_correlation_prime");
595 linReg.mMP.Write(
"IV_mean");
596 linReg.mMY.Write(
"DV_mean");
597 linReg.mMYp.Write(
"DV_mean_prime");
601 Mstat(0,0)=
linReg.getUsedEve();
602 Mstat.Write(
"MyStat");
605 TH1D hiv(
"IVname",
"names of IVs",
nP,-0.5,
nP-0.5);
610 TH1D hdv(
"DVname",
"names of IVs",
nY,-0.5,
nY-0.5);
615 linReg.mSP.Write(
"IV_sigma");
616 linReg.mSY.Write(
"DV_sigma");
617 linReg.mSYp.Write(
"DV_sigma_prime");
620 linReg.mVPP.Write(
"IV_IV_rawVariance");
621 linReg.mVPY.Write(
"IV_DV_rawVariance");
622 linReg.mVYY.Write(
"DV_DV_rawVariance");
623 linReg.mVYYp.Write(
"DV_DV_rawVariance_prime");
624 TVectorD mVY2(TMatrixDDiag(
linReg.mVYY));
625 mVY2.Write(
"DV_rawVariance");
626 TVectorD mVP2(TMatrixDDiag(
linReg.mVPP));
627 mVP2.Write(
"IV_rawVariance");
628 TVectorD mVY2prime(TMatrixDDiag(
linReg.mVYYp));
629 mVY2prime.Write(
"DV_rawVariance_prime");
632 linReg.mSPP.Write(
"IV_IV_normVariance");
633 linReg.mSPY.Write(
"IV_DV_normVariance");
634 linReg.mSYY.Write(
"DV_DV_normVariance");
635 linReg.mSYYp.Write(
"DV_DV_normVariance_prime");
636 TVectorD sigY2(TMatrixDDiag(
linReg.mSYY));
637 sigY2.Write(
"DV_normVariance");
638 TVectorD sigX2(TMatrixDDiag(
linReg.mSPP));
639 sigX2.Write(
"IV_normVariance");
640 TVectorD sigY2prime(TMatrixDDiag(
linReg.mSYYp));
641 sigY2prime.Write(
"DV_normVariance_prime");
652 std::string file = path + name;
653 fAlphaOutputFile =
new TFile(TString(file),
"RECREATE",
"correlation coefficients");
666 std::replace(label.begin(), label.end(),
'.',
'_');
670 std::string file = path + name +
".C";
673 fAliasOutputFile << Form(
"void %s(int i = 0) {", name.c_str()) << std::endl;
708 fAliasOutputFile << Form(
" TTree* tree = (TTree*) gDirectory->Get(\"mul\");") << std::endl;
709 for (
int i = 0; i <
nY; i++) {
712 for (
int j = 0; j <
nP; j++) {
An options class which parses command line, config file and environment.
#define QwVerbose
Predefined log drain for verbose messages.
#define QwError
Predefined log drain for errors.
#define QwWarning
Predefined log drain for warnings.
#define QwMessage
Predefined log drain for regular messages.
ROOT file and tree management wrapper classes.
Parameter file parsing and management.
Definition of the pure virtual base class of all data elements.
Decoding and management for VQWK ADC channels (6x32-bit datawords)
#define REGISTER_DATA_HANDLER_FACTORY(A)
Correlator data handler using LinRegBlue algorithms.
Helicity pattern analysis and management.
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...
static std::ostream & endl(std::ostream &)
End of the line.
Command-line and configuration file options processor.
po::options_description_easy_init AddOptions(const std::string &blockname="Specialized options")
Add an option to a named block or create new block.
Configuration file parser with flexible tokenization and search capabilities.
Bool_t PopValue(const std::string keyname, T &retvalue)
void TrimWhitespace(TString::EStripType head_tail=TString::kBoth)
void TrimComment(const char commentchar)
std::string GetNextToken(const std::string &separatorchars)
Get next token as a string.
A wrapper class for a ROOT file or memory mapped file.
void NewTree(const std::string &name, const std::string &desc)
Create a new tree with name and description.
TTree * GetTree(const std::string &name)
Get the tree with name.
Abstract base for concrete hardware channels implementing dual-operator pattern.
Data handler computing correlations and linear-regression coefficients.
std::vector< std::string > fIndependentName
void OpenAliasFile(const std::string &prefix)
std::string fAlphaOutputPath
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
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 ConstructTreeBranches(QwRootFile *treerootfile, const std::string &treeprefix="", const std::string &branchprefix="") override
Construct the tree branches.
void ParseConfigFile(QwParameterFile &file) override
static bool fPrintCorrelations
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.
std::vector< int > fErrCounts_IV
static void DefineOptions(QwOptions &options)
Subsystem array container specialized for parity analysis with asymmetry calculations.
const UInt_t * GetEventcutErrorFlagPointer() const
std::vector< std::string > fDependentFull
void AccumulateRunningSum()
void SetEventcutErrorFlagPointer(const UInt_t *errorflagptr)
std::vector< Double_t > fDependentValues
virtual void ParseConfigFile(QwParameterFile &file)
std::vector< const VQwHardwareChannel * > fDependentVar
UInt_t GetEventcutErrorFlag() const
VQwDataHandler(const TString &name)
std::string ParseSeparator
std::pair< EQwHandleType, std::string > ParseHandledVariable(const std::string &variable)
std::vector< EQwHandleType > fDependentType
std::vector< std::string > fDependentName