Tools for Reactor-Antineutrino Studies in RAT-PAC  1.2.0
Code for running and analyzing reactor-IBD simulations
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TRefMatch Class Reference

Class implementing KS/AD-test reference-matching algorithm. //DOC//. More...

#include <TRefMatch.h>

Inheritance diagram for TRefMatch:
Inheritance graph
[legend]
Collaboration diagram for TRefMatch:
Collaboration graph
[legend]

Public Member Functions

 TRefMatch ()
 Default ctor.
 
 TRefMatch (const char *fileName, const char *treeName="T", const char *branchVarName="phi")
 Regular ctor. More...
 
void Init (const char *fileName, const char *treeName, const char *branchVarName)
 Setter version of Init() More...
 
const char * GetTestFileName ()
 
const char * GetTestTreeName ()
 
const char * GetTestVarName ()
 
TFile * GetFile ()
 
TTree * GetTree ()
 
TBranch * GetBranch ()
 
const char * GetReferenceTreeName ()
 
TList * GetReferenceFileList ()
 
TFile * GetOutFile ()
 
TRegexp GetReferenceFilePattern ()
 
TSystemDirectory * GetReferenceFileDir ()
 
Long64_t GetnTestSampleEvents ()
 
Long64_t GetnReferenceEvents ()
 
Bool_t GetAnderson ()
 
Double_t GetTestSamplePhiTrue ()
 
Double_t GetProb ()
 
Double_t GetSig ()
 
TMatrixD GetResultsMatrix ()
 
TVectorD GetResults ()
 
TFile * GetBestMatchFile ()
 
TCanvas * GetCanvas ()
 
TH1D * GetTestSampleHist ()
 
TGraph * GetResultsGraph ()
 
void SetReferenceFileDir (TSystemDirectory *refFileDir)
 Set directory (by pointer) to search for reference files. More...
 
void SetReferenceFileDir (const char *refFileDirName)
 Set directory (by name) to search for reference files. More...
 
void SetReferenceFilePattern (TRegexp patternRE)
 Set search pattern (by TRegexp object) for reference filenames. More...
 
void SetReferenceFilePattern (const char *pattern)
 Set search pattern (by string) for reference filenames. More...
 
void SetReferenceFileList (TList *fileList)
 
void SetAnderson (Bool_t bAnderson)
 
void SetReferenceTreeName (const char *treeName)
 
void FillReferenceFileList ()
 Populate the reference-file list based on the current reference-file directory and pattern.
 
void SetnEvents (Long64_t nTestSampleEvents=0, Long64_t nReferenceEvents=0)
 
Double_t Prob2Sig (Double_t prob)
 Convert probability to significance. More...
 
Double_t Sig2Prob (Double_t sig)
 Convert significance to probability. More...
 
void ExtractRef (const char *runName, const char *treeName="T", const char *branchName="phi")
 Extract distribution from reference run.
 
void ExtractTest (const char *runName, const char *treeName="T_ncap", const char *branchName="phi")
 Extract distribution from experimental run.
 
Double_t UnbinnedKSTest (TTree *T1, TTree *T2, const char *branchName1, const char *branchName2="", Long64_t nEvents1=0, Long64_t nEvents2=0)
 Apply unbinned Kolmogorov-Smirnov test.
 
Double_t AndersonDarlingTest (TTree *T1, TTree *T2, const char *branchName1, const char *branchName2="", Long64_t nEvents1=0, Long64_t nEvents2=0)
 Apply (unbinned) Anderson-Darling test. More...
 
void RefCompare ()
 Perform reference-comparison algorithm.
 
void DrawResults (Bool_t kDrawFit=kFALSE)
 Plot sample distribution and algorithm results.
 
void PrintVerbose ()
 Mostly settings.
 
void PrintResults ()
 Results summary.
 
void SaveResults ()
 Print canvas and save object.
 
void Close ()
 Close pads, files, etc.
 
void Run (Long64_t nTestSampleEvents=0)
 Execute a typical analysis.
 

Private Member Functions

void Init ()
 Initialize: validate and fill members.
 
void SetTestSamplePhiTrue (Double_t phi)
 
void SetProb (Double_t prob)
 
void SetSig (Double_t sig)
 
void SetResultsMatrix (TMatrixD resmat)
 
void SetResults (TVectorD res)
 
void SetBestMatchFile (TFile *bestMatchFile)
 
void SetCanvas (TCanvas *c)
 
void SetTestSampleHist (TH1D *h)
 
void SetResultsGraph (TGraph *g)
 

Private Attributes

const char * fTestFileName
 Name of file containing data sample to be tested.
 
const char * fTestTreeName
 Name of tree containing data sample to be tested.
 
const char * fTestVarName
 Name of branch/variable containing data sample to be tested.
 
TFile * fTestSampleFile
 Address of test-sample file.
 
TTree * fTestSampleTree
 Address of test-sample tree.
 
TBranch * fTestSampleBranch
 Address of test-sample branch.
 
const char * fReferenceTreeName
 Name of tree in reference files.
 
TList * fReferenceFileList
 List of files containing reference distributions.
 
TFile * fOutFile
 Output file.
 
TRegexp fReferenceFilePattern
 Regex describing reference files.
 
TSystemDirectory * fReferenceFileDir
 Directory containing reference files.
 
Long64_t fnTestSampleEvents
 Number of events to use from test-sample tree (default value 0 will use all events)
 
Long64_t fnReferenceEvents
 Number of events to use from reference trees (default value 0 will use all events)
 
Bool_t fkAnderson
 If true, use Anderson-Darling rather than Kolmogorov-Smirnov.
 
Double_t fTestSamplePhiTrue
 The true value of phi for the test sample.
 
Double_t fProb
 Match probability (current entry)
 
Double_t fSig
 Match significance (current entry)
 
TMatrixD fResultsMatrix
 Matrix of comparison results.
 
TVectorD fResults
 3x1 vector containing best match value and corresponding probability and significance
 
TFile * fBestMatchFile
 Address of best-match reference file.
 
Bool_t fkHasInit
 Status indicator for whether Init has been called yet.
 
Bool_t fkHasRun
 Status indicator for whether RefComp has been called yet.
 
TCanvas * fCanvas
 Canvas for drawing results.
 
TH1D * fTestSampleHist
 TH1 for test-sample data.
 
TGraph * fResultsGraph
 TGraph for algorithm results.
 

Detailed Description

Class implementing KS/AD-test reference-matching algorithm. //DOC//.

Standard Usage ( [R] = always required ):

  1. Instantiate (NOTE: must construct with "new") [R]
  2. Call Init ("setter version") if used default ctor
  3. Set reference directory / pattern if needed
  4. Call FillReferenceFileList [R]
  5. Set tree and branch names if needed
  6. Set number of events to use from {test-sample, reference-distrib} if desired
  7. Call RefCompare [R]
  8. Call DrawResults if desired
  9. Call Save if desired
  10. Call Close when finished

Constructor & Destructor Documentation

◆ TRefMatch()

TRefMatch::TRefMatch ( const char *  fileName,
const char *  treeName = "T",
const char *  branchVarName = "phi" 
)

Regular ctor.

Parameters
fileName– name of file containing experimental/test data
treeName– name of relevant TTree in input file
branchVarName– shared variable name (b/t input and ref. files)

Member Function Documentation

◆ AndersonDarlingTest()

Double_t TRefMatch::AndersonDarlingTest ( TTree *  T1,
TTree *  T2,
const char *  branchName1,
const char *  branchName2 = "",
Long64_t  nEvents1 = 0,
Long64_t  nEvents2 = 0 
)

Apply (unbinned) Anderson-Darling test.

Function to execute unbinned TMath::KolmogorovTest on a pair of TTrees containing TBranches with matching names – Usage: Double_t P = AndersonDarlingTest( TTree T1, TTree *T2, const char branchName ) – Branches must be of type Double_t – P is the probability for match – *T1 and *T2 are pointers to the two input trees – branchName{1,2} are the branch/variable names in the respective trees – nEvents{1,2} are the number of entries to use from each tree (default value 0 will use all entries) – See the notes in ROOT::Math::GoFTest for details

◆ Init()

void TRefMatch::Init ( const char *  fileName,
const char *  treeName,
const char *  branchVarName 
)

Setter version of Init()

Same parameters as Regular ctor.

See also
TRefMatch( const char* fileName, const char* treeName, const char* branchVarName )

◆ Prob2Sig()

Double_t TRefMatch::Prob2Sig ( Double_t  prob)

Convert probability to significance.

Convert a probability on (0,1) to its corresponding Gaussian significance.

Parameters
prob– decimal probability on (0,1)
Returns
sig – decimal significance on (0,inf)
See also
Sig2Prob()

◆ SetReferenceFileDir() [1/2]

void TRefMatch::SetReferenceFileDir ( const char *  refFileDirName)

Set directory (by name) to search for reference files.

Parameters
refFileDirName– name of directory to search

◆ SetReferenceFileDir() [2/2]

void TRefMatch::SetReferenceFileDir ( TSystemDirectory *  refFileDir)

Set directory (by pointer) to search for reference files.

Parameters
refFileDir– directory to search

◆ SetReferenceFilePattern() [1/2]

void TRefMatch::SetReferenceFilePattern ( const char *  pattern)

Set search pattern (by string) for reference filenames.

Parameters
pattern– string to use for regex for filenames

◆ SetReferenceFilePattern() [2/2]

void TRefMatch::SetReferenceFilePattern ( TRegexp  patternRE)

Set search pattern (by TRegexp object) for reference filenames.

Parameters
patternRE– regex for filenames

◆ Sig2Prob()

Double_t TRefMatch::Sig2Prob ( Double_t  sig)

Convert significance to probability.

Convert a significance to its corresponding Gaussian probability.

Parameters
sig– decimal significance on (0,inf)
Returns
prob – decimal probability on (0,1)
See also
Prob2Sig()

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