Update 'PlotTMVA.cpp'

Renata Kopecná 2022-02-02 13:59:45 +01:00
parent eacec24d0d
commit a4e5365ee9

@ -1,16 +1,41 @@
Welcome to the Wiki. ## Table of Contents
## Global variables: * [Functions](#functions)
* [TFile *GetTMVAfile()](#tfile-gettmvafile)
*} * [TH2F *GetCorrelationMatrix()](#th2f-getcorrelationmatrix)
*return v_var * [TH2F *GetCorrelationMatrixSignal()](#th2f-getcorrelationmatrixsignal)
* [TH2F *GetCorrelationMatrixBackground()](#th2f-getcorrelationmatrixbackground)
* [string oberFolder()](#string-oberfolder)
* [TH1F *GetTMVAresponse()](#th1f-gettmvaresponse)
* [TH1F *GetTMVAresponseSignal()](#th1f-gettmvaresponsesignal)
* [TH1F *GetTMVAresponseBackground()](#th1f-gettmvaresponsebackground)
* [TH1F *GetTMVAresponseTrainingSignal()](#th1f-gettmvaresponsetrainingsignal)
* [TH1F *GetTMVAresponseTrainingBackground()](#th1f-gettmvaresponsetrainingbackground)
* [TH1F *GetVariableSignal()](#th1f-getvariablesignal)
* [TH1F *GetVariableBackground()](#th1f-getvariablebackground)
* [TH1F *GetEfficiencySignal()](#th1f-getefficiencysignal)
* [TH1F *GetEfficiencyBackground()](#th1f-getefficiencybackground)
* [TH1F *GetROC()](#th1f-getroc)
* [TTree *GetTrainTree()](#ttree-gettraintree)
* [TTree *GetTestTree()](#ttree-gettesttree)
* [int GetTrainEvents()](#int-gettrainevents)
* [int GetTrainSignalEvents()](#int-gettrainsignalevents)
* [int GetTrainBackgroundEvents()](#int-gettrainbackgroundevents)
* [bool SaveCorrelationPlot()](#bool-savecorrelationplot)
* [vector <string> v_variables()](#vector-string-v_variables)
* [bool SaveVariablesSignalVsBackground()](#bool-savevariablessignalvsbackground)
* [bool SaveMVAResponse()](#bool-savemvaresponse)
* [bool SaveMVAOvertraining()](#bool-savemvaovertraining)
* [bool SaveEfficiency()](#bool-saveefficiency)
* [string getROCmethod()](#string-getrocmethod)
* [bool SaveROCs()](#bool-saverocs)
* [bool SaveMultipleROCS()](#bool-savemultiplerocs)
* [void nEvents()](#void-nevents)
* [bool SaveAllFromOneFile()](#bool-saveallfromonefile)
* [bool SaveMultipleROCS()](#bool-savemultiplerocs-1)
# Classes # Functions
# Functions and their parameters:
### TFile \*GetTMVAfile() ### TFile \*GetTMVAfile()
* **Parameters** * **Parameters**
@ -23,43 +48,46 @@ Welcome to the Wiki.
* string customTMbranch * string customTMbranch
* bool gammaTM * bool gammaTM
* **Return** * **Return**
* Opens and returns the TFile with the MVA training information (config file)
### TH2F \*GetCorrelationMatrix() ### TH2F \*GetCorrelationMatrix()
* **Parameters** * **Parameters**
* TFile \*file * TFile \*file
* string type //type = S * string type //S or B (for signal or background)
* B
* **Return** * **Return**
* Returns the signal or background correlation matrix from the config file
### TH2F \*GetCorrelationMatrixSignal() ### TH2F \*GetCorrelationMatrixSignal()
* **Parameters** * **Parameters**
* TFile \*file * TFile \*file
* **Return** * **Return**
* Returns the signal correlation matrix from the config file
### TH2F \*GetCorrelationMatrixBackground() ### TH2F \*GetCorrelationMatrixBackground()
* **Parameters** * **Parameters**
* TFile \*file * TFile \*file
* **Return** * **Return**
* Returns the background correlation matrix from the config file
### string oberFolder() ### string oberFolder()
* **Parameters** * **Parameters**
* string method * string method
* **Return** * **Return**
* A string with the name of the folder where the histograms are saved in the TFile
### TH1F \*GetTMVAresponse() ### TH1F \*GetTMVAresponse()
* **Parameters** * **Parameters**
* TFile \*file * TFile \*file
* string method * string method
* string type //type = S * string type // S, B, Train_S, Train_B
* B
* Train_S
* Train_B
* **Return** * **Return**
* Histogram with the MVA responses for the signal and background either from training or from all
### TH1F \*GetTMVAresponseSignal() ### TH1F \*GetTMVAresponseSignal()
@ -67,6 +95,7 @@ Welcome to the Wiki.
* TFile \*file * TFile \*file
* string method * string method
* **Return** * **Return**
* Histogram with the signal MVA response
### TH1F \*GetTMVAresponseBackground() ### TH1F \*GetTMVAresponseBackground()
@ -74,6 +103,7 @@ Welcome to the Wiki.
* TFile \*file * TFile \*file
* string method * string method
* **Return** * **Return**
* Histogram with the background MVA response
### TH1F \*GetTMVAresponseTrainingSignal() ### TH1F \*GetTMVAresponseTrainingSignal()
@ -81,6 +111,7 @@ Welcome to the Wiki.
* TFile \*file * TFile \*file
* string method * string method
* **Return** * **Return**
* Histogram with the signal MVA response in the training sample
### TH1F \*GetTMVAresponseTrainingBackground() ### TH1F \*GetTMVAresponseTrainingBackground()
@ -88,6 +119,7 @@ Welcome to the Wiki.
* TFile \*file * TFile \*file
* string method * string method
* **Return** * **Return**
* Histogram with the background MVA response in the training sample
### TH1F \*GetVariableSignal() ### TH1F \*GetVariableSignal()
@ -95,6 +127,7 @@ Welcome to the Wiki.
* TFile \*file * TFile \*file
* string variable * string variable
* **Return** * **Return**
* Histogram with the disrtibution of the desired variable, signal events only
### TH1F \*GetVariableBackground() ### TH1F \*GetVariableBackground()
@ -102,6 +135,7 @@ Welcome to the Wiki.
* TFile \*file * TFile \*file
* string variable * string variable
* **Return** * **Return**
* Histogram with the disrtibution of the desired variable, background events only
### TH1F \*GetEfficiencySignal() ### TH1F \*GetEfficiencySignal()
@ -109,6 +143,7 @@ Welcome to the Wiki.
* TFile \*file * TFile \*file
* string method * string method
* **Return** * **Return**
* Histogram with the MVA efficiency for signal
### TH1F \*GetEfficiencyBackground() ### TH1F \*GetEfficiencyBackground()
@ -116,6 +151,7 @@ Welcome to the Wiki.
* TFile \*file * TFile \*file
* string method * string method
* **Return** * **Return**
* Histogram with the MVA efficiency for signal
### TH1F \*GetROC() ### TH1F \*GetROC()
@ -123,79 +159,88 @@ Welcome to the Wiki.
* TFile \*file * TFile \*file
* string method * string method
* **Return** * **Return**
* Histogram with the ROC curve for the given method
### TTree \*GetTrainTree() ### TTree \*GetTrainTree()
* **Parameters** * **Parameters**
* TFile \*file * TFile \*file
* **Return** * **Return**
* The TTree used for the MVA training
### TTree \*GetTestTree() ### TTree \*GetTestTree()
* **Parameters** * **Parameters**
* TFile \*file * TFile \*file
* **Return** * **Return**
* The TTree used for the MVA testing
### int GetTrainEvents() ### int GetTrainEvents()
* **Parameters** * **Parameters**
* TFile \*file * TFile \*file
* **Return** * **Return**
* The number of events used for the MVA training
### int GetTrainSignalEvents() ### int GetTrainSignalEvents()
* **Parameters** * **Parameters**
* TFile \*file * TFile \*file
* **Return** * **Return**
* The number of signal events used for the MVA training
### int GetTrainBackgroundEvents() ### int GetTrainBackgroundEvents()
* **Parameters** * **Parameters**
* TFile \*file * TFile \*file
* **Return** * **Return**
* The number of background events used for the MVA training
### bool SaveCorrelationPlot() ### bool SaveCorrelationPlot()
Read the correlation histograms from the file, makes them pretty and saves them.
* **Parameters** * **Parameters**
* TFile \*file * TFile \*file
* string type * string type
* string savePath * string savePath
* **Return** * **Return**
* True if everything is fine, False if something fails
### vector <string> v_variables() ### vector \<string> v_variables()
* **Parameters** * **Parameters**
* string DL="" * string DL="" //LL or DD
* **Return** * **Return**
* A vector with all variable names from the MVA reader (see [MVA.cpp](https://git.physi.uni-heidelberg.de/kopecna/EWP-BplusToKstMuMu-AngAna/wiki/MVA-Class#mva_variables-mva_variables) )
### bool SaveVariablesSignalVsBackground() ### bool SaveVariablesSignalVsBackground()
Loads the variable distributions in the signal and background sample, plots them both and saves the plot.
* **Parameters** * **Parameters**
* TFile \*file * TFile \*file
* string savePath * string savePath
* string DL="" * string DL="" //LL or DD
* **Return** * **Return**
* True if everything is fine, False if something fails
### bool SaveMVAResponse() ### bool SaveMVAResponse()
Loads the MVA response in the signal and background samples,plots them both and saves the plot.
* **Parameters** * **Parameters**
* TFile \*file * TFile \*file
* string savePath * string savePath
* string method //Check if folder for the plots exists and if not * string method
* create one
* **Return** * **Return**
* True if everything is fine, False if something fails
### bool SaveMVAOvertraining() ### bool SaveMVAOvertraining()
Retrieves and plots the training and test sample MVA response for the signal and background. The plot is saved.
* **Parameters** * **Parameters**
* TFile \*file * TFile \*file
* string savePath * string savePath
* string method //Check if folder for the plots exists and if not * string method
* create one
* **Return** * **Return**
* True if everything is fine, False if something fails
### bool SaveEfficiency() ### bool SaveEfficiency()
Retrieves and plots the MVA efficiency, purity, and significance of the signal and background. The plot is saved.
* **Parameters** * **Parameters**
* TFile \*file * TFile \*file
* string savePath * string savePath
@ -203,31 +248,35 @@ Welcome to the Wiki.
* int nSig * int nSig
* int nBkg * int nBkg
* **Return** * **Return**
* True if everything is fine, False if something fails
### string getROCmethod() ### string getROCmethod()
* **Parameters** * **Parameters**
* TH1F \*h_ROC * TH1F \*h_ROC
* **Return** * **Return**
* The name of the ROC histogram stripped of the MVA_ at the begining.
### bool SaveROCs() ### bool SaveROCs()
Retrieves the ROC curves for listed methods, plots them in one canvas, saves the plot.
* **Parameters** * **Parameters**
* TFile \*file * TFile \*file
* string savePath * string savePath
* vector <string> methods * vector \<string> methods
* **Return** * **Return**
* True if everything is fine, False if something fails
### bool SaveMultipleROCS() ### bool SaveMultipleROCS()
Retrieves the ROC curves from the listed files, plots them in one canvas, saves the plot.
* **Parameters** * **Parameters**
* vector <TFile \*> files * vector \<TFile \*> files
* string savePath * string savePath
* string method * string method
* **Return** * **Return**
* True if everything is fine, False if something fails
### void nEvents() ### void nEvents()
Saves the number of signal and background events into `nSig` and `nBkg`. It has to be checked, as the input is hardcoded!
* **Parameters** * **Parameters**
* int year * int year
* int Run * int Run
@ -237,10 +286,10 @@ Welcome to the Wiki.
* bool UseLowQ2Range * bool UseLowQ2Range
* int& nSig * int& nSig
* int& nBkg * int& nBkg
* **Return**
### bool SaveAllFromOneFile() ### bool SaveAllFromOneFile()
Effectivelly saves all plots needed for the MVA training. Calls [SaveAllFromOneFile()](#int-saveallfromonefile), [SaveVariablesSignalVsBackground()](#int-savevariablessignalvsbackground), [nEvents()](#void-nevents), [SaveMVAOvertraining()](#int-savemvaovertraining), [SaveEfficiency()](#int-saveefficiency) and [SaveROCs()](#int-saverocs) for the given file.
* **Parameters** * **Parameters**
* int year * int year
* int Run * int Run
@ -251,23 +300,13 @@ Welcome to the Wiki.
* string customTMbranch * string customTMbranch
* bool gammaTM * bool gammaTM
* **Return** * **Return**
* True if everything is fine, False if something fails
### bool SaveMultipleROCS() ### bool SaveMultipleROCS()
Gets a list of config files and calls [SaveMultipleROCS()](#int-savemultiplerocs).
* **Parameters** * **Parameters**
* int Run =1 * int Run =1
* int nLow = 0 * int nLow = 0
* int nHigh = 3 * int nHigh = 3
* **Return** * **Return**
* True if everything is fine, False if something fails
### bool testFunction()
* **Parameters**
* int Run =1
* **Return**
### void test()
* **Parameters**
*
* **Return**