Once all the signals quantities are stored in n-tuples, the class `/$HOME/foot_turin/Script/PythonScript/sw_standalone/read_ntuple.py` allows to quickly generate all the histograms/plots required by the user.
Once all the signals quantities are stored in n-tuples, the class `/$HOME/foot_turin/Script/PythonScript/sw_standalone/read_ntuple.py` allows to quickly generate all the histograms/plots required by the user.
In this class the event-selection is performed. The event-selection is based on two cut levels:
In this class the event-selection is performed. The event-selection is based on three cut levels:
1. Baseline RMS selection: signals with a baseline RMS greater than a threshold value are rejected
1. Baseline RMS selection: signals with a baseline RMS greater than a threshold value are rejected
2.χ$`^2`$ selection
2.χ$`^2`$ selection: signals with a χ$`^2`$ greater than a threshold value are rejected
3. Bragg Peak selection (**only for pulse shape analysis**): only the signals with an amplitude within the range of the histogram peak are selected for the pulse shape analysis
Moreover this class manages the signal corrections. Three different correction can be applied:
1. Temperature correction
2. Particle range correction
3. Crystals equalization
### Campaigns
Different campaigns allow to choose the specific events-selection and signals-correction related to test beams under study.
The campaigns are located in `$HOME/foot_turin/Script/PythonScript/sw_standalone/campaign/`. Each campaign directory contains three different files:
1. Calibration.par: it contains for each crystal the crystal equalization values. Example:
```
[bgo_eq]
#ch: Amp, charge
#k_mean
0: 0.932, 1.
1: 0.985, 1.
2: 1., 1.
```
**Note:** the temperature and the range correction values are deprecated.
2. InitCut.par: it contains for each run the list of the events-selection values for each crystal. The file is composed by three sections, one per events-selection types. Example:
```
[rms_bas]
#run: ch0, ch1, ...
1: 1., 0, 0, 0, 0, 0, 0, 0, 0
2: 1., 0, 0, 0, 0, 0, 0, 0, 0
[...]
[chi2]
#run: ch0, ch1, ...
1: 1.1, 0, 0, 0, 0, 0, 0, 0, 0
2: 1.1, 0, 0, 0, 0, 0, 0, 0, 0
[...]
[ev_peak]
#run: min_peak, max_peak
1: 890,910
2: 890,910
[...]
```
3. Configuration.par: it is a configuration file where the user can select the type of events-selction or signals-correction that wants to enable/disable. Example:
```
EnableCuts: rms_bas, chi2
temperature: n
range: y
bgo_eq: y
```
### Class methods list
### Class methods list
The list of the class methods are:
The list of the class methods are:
-`def _init_(self, file_in, ch_list, run, c_id_trg)`: class constructor
-`def _init_(self, file_in, ch_list, run, c_id_trg)`: class constructor
-`def load_campaign(self, cam)`: it loads the test beam campaigns
-`def load_campaign(self, cam)`: it loads the test beam campaigns
-`def constant_numbers(self)`: it defines some constant numbers
-`def init_data(self)`: it initialises the quantities
-`def reset_data(self)`: it resets the quantities at each event
-`def open_ntuple(self)`: it opens the ROOT file which contains the n-tuples
-`def cut_init(self)`: it initialies the events-selection located in the CutInit.par
-`def calibration_par(self)`: it initialies the signals-correction values located in the Calibration.par
-`def temperature_correction_init(self)`: it defines the function for temperature correction
-`def temperature_correction(self, amp, charge, i, c_id)`: it performs the temperature correction
-`def analyze_ntuple(self, ev_start, ev_stop, fout)`: main function which recalls all the previous ones
-`def booking_histos(self)`: it initialises all the hisograms
-`def write_output(self)`: it writes the output ROOT file with all the plots
### How to run
The class can be run through the `/$HOME/foot_turin/Script/PythonScript/sw_standalone/analyze_ntuple.py` script.
This script need some POSITIONAL arguments:
- the path of the input n-tuples file
- the number of start event
- the number of the stop event
and some OPTIONAL arguments:
- the list of the channel (i.e. the crystal ID number): `[-c]`
- the run number, required by the events-selection: `[-r]`
- the campaign selected. If any campaign is required by the user, an empty `Default` campaing is present: `[-exp]`
- the path of the output file: `[-o]`
- keyword to trigger on a specific crystal (e.g. the central one): `[-t]`