SND@LHC Software
Loading...
Searching...
No Matches
sndSciFiTools.h
Go to the documentation of this file.
1#pragma once
2
3#include <map>
4#include "TClonesArray.h"
5#include "ShipUnit.h"
6
7namespace snd {
8 namespace analysis_tools {
9
10 // Function to get the number of hits per station in SciFi
11 void getSciFiHitsPerStation(const TClonesArray * digiHits, std::vector<int> &horizontal_hits, std::vector<int> &vertical_hits);
12
13 // Function to get the total number of SciFi hits
14 int getTotalSciFiHits(std::vector<int> &horizontal_hits, std::vector<int> &vertical_hits);
15 int getTotalSciFiHits(const TClonesArray * digiHits);
16
17 // Function to get the SciFi fractional hits per plane
18 std::vector<float> getFractionalHitsPerScifiPlane(std::vector<int> &horizontal_hits, std::vector<int> &vertical_hits);
19 std::vector<float> getFractionalHitsPerScifiPlane(const TClonesArray * digiHits);
20
21 // Function to find the station where the interaction ocurred by checking the station at which the cumulative hit fraction exceeds a threshold
22 int findScifiStation(std::vector<int> &horizontal_hits, std::vector<int> &vertical_hits, float threshold);
23 int findScifiStation(const TClonesArray * digiHits, float threshold);
24
25 // Function to get the peak of the Scifi hit timing distribution for any given plane
26 float peakScifiTiming(const TClonesArray &digiHits, int bins, float min_x, float max_x);
27
28 // Function to get the hits in station n and plane X or Y
29 // Station and orientation are defined with the same convention as the outputs of
30 // sndScifiHit->GetStation() and sndScifiHits->isVertical()
31 std::unique_ptr<TClonesArray> getScifiHits(const TClonesArray &digiHits, int station, bool orientation);
32
33 // Function to select the Scifi hits of station n and plane X or Y that are in the range
34 // [peakTiming-range_lower; peakTiming+range_upper] of the peak of its time distribution
35 // selection_parameters should have the form [bins_x, min_x, max_x, time_lower_range,
36 // time_upper_range ] (bins_x is converted to int before creating the histogram)
37 // if len(selection_parameters) == 4 => time_lower_range = time_upper_range =
38 // selection_parameters[3]
39 // make_selection determines whether you want to select the hits for the respective plane
40 // or not and skip that step (in case the hits are already curated)
41 std::unique_ptr<TClonesArray> selectScifiHits(const TClonesArray &digiHits, int station, bool orientation, int bins_x=52, float min_x=0.0, float max_x=26.0, float time_lower_range=1E9/(2*ShipUnit::snd_freq), float time_upper_range=2E9/(ShipUnit::snd_freq/ShipUnit::hertz), bool make_selection=true);
42 std::unique_ptr<TClonesArray> selectScifiHits(const TClonesArray &digiHits, int station, bool orientation, const std::map<std::string, float> &selection_parameters, bool make_selection=true);
43
44 // Function to obtain the ScifiHits that are considered to be useful from an event
45 // selection_parameters is the number of bins for the histogram, min_x, max_x and
46 // range of the selected hits in ns
47 // Methods available are as follows:
48 // (0) Events within \pm range of the peak of the time distribution for Scifi Hits within
49 // each station and orientation
50 std::unique_ptr<TClonesArray> filterScifiHits(const TClonesArray &digiHits, const std::map<std::string, float> &selection_parameters, int method=0, std::string setup="TI18");
51 //Foregoing the selection_parameters option runs with the default values
52 std::unique_ptr<TClonesArray> filterScifiHits(const TClonesArray &digiHits, int method=0, std::string setup="TI18");
53
54 // Function to calculate the number of the SiPM channel with respect to the whole station
55 // referene_SiPM given in the format of sndScifiHit->GetChannelID()
56 int calculateSiPMNumber(int reference_SiPM);
57
58 // Function to determine SciFi hit density for channel reference_SiPM around a radius of r
59 // SiPM channels
60 // If min_check == True the function stops checking the density once it reaches the minimum
61 // requirement, and immediately returns -1 in case the minimum density cannot be achieved
62 int densityScifi(int reference_SiPM, const TClonesArray &digiHits, int radius, int min_hit_density, bool min_check);
63
64 // Function to check efficiently wether a plane has a required hit density within a radius of r
65 // SiPM channels
66 bool densityCheck(const TClonesArray &digiHits, int radius=64, int min_hit_density=36, int station=1, bool orientation=false);
67
68 // Function to get the starting wall for a shower in the Scifi
69 // Method 0 checks for a minimum Scifi Cluster density to determine whether a shower is
70 // propagating on a given Scifi station or not by checking both orientations of the station,
71 // and declares the interaction block as being the previous one to pass the check
72 // selection_parameters must contain "radius" and "min_hit_density". In case you want the
73 // selection to be made relying on a single orientation, then "orientation" can be provided
74 // in the for of 0 or 1, for the horizontal and vertical orientations, respectively
75 int showerInteractionWall(const TClonesArray &digiHits, const std::map<std::string, float> &selection_parameters, int method=0, std::string setup="TI18");
76 //Foregoing the selection_parameters option runs with the default values
77 int showerInteractionWall(const TClonesArray &digiHits, int method=0, std::string setup="TI18");
78
79 }
80}
int calculateSiPMNumber(int reference_SiPM)
int findScifiStation(std::vector< int > &horizontal_hits, std::vector< int > &vertical_hits, float threshold)
int showerInteractionWall(const TClonesArray &digiHits, const std::map< std::string, float > &selection_parameters, int method=0, std::string setup="TI18")
void getSciFiHitsPerStation(const TClonesArray *digiHits, std::vector< int > &horizontal_hits, std::vector< int > &vertical_hits)
float peakScifiTiming(const TClonesArray &digiHits, int bins, float min_x, float max_x)
std::unique_ptr< TClonesArray > filterScifiHits(const TClonesArray &digiHits, const std::map< std::string, float > &selection_parameters, int method=0, std::string setup="TI18")
std::unique_ptr< TClonesArray > getScifiHits(const TClonesArray &digiHits, int station, bool orientation)
int densityScifi(int reference_SiPM, const TClonesArray &digiHits, int radius, int min_hit_density, bool min_check)
bool densityCheck(const TClonesArray &digiHits, int radius=64, int min_hit_density=36, int station=1, bool orientation=false)
std::vector< float > getFractionalHitsPerScifiPlane(std::vector< int > &horizontal_hits, std::vector< int > &vertical_hits)
int getTotalSciFiHits(std::vector< int > &horizontal_hits, std::vector< int > &vertical_hits)
std::unique_ptr< TClonesArray > selectScifiHits(const TClonesArray &digiHits, int station, bool orientation, int bins_x=52, float min_x=0.0, float max_x=26.0, float time_lower_range=1E9/(2 *ShipUnit::snd_freq), float time_upper_range=2E9/(ShipUnit::snd_freq/ShipUnit::hertz), bool make_selection=true)