SND@LHC Software
Loading...
Searching...
No Matches
snd::analysis_tools::USPlane Class Reference

#include <sndUSPlane.h>

Collaboration diagram for snd::analysis_tools::USPlane:

Classes

struct  rl_pair
 
struct  sl_pair
 
struct  USHit
 

Public Member Functions

 USPlane (std::vector< MuFilterHit * > snd_hits, const Configuration &configuration, MuFilter *muon_filter_geometry, int station, bool use_small_sipms=false)
 
const sl_pair< int > GetNHits () const
 
const int GetStation () const
 
const sl_pair< double > GetTotQdc () const
 
const sl_pair< double > GetTotEnergy () const
 
const rl_pair< double > GetSideQdc () const
 
const rl_pair< double > GetBarQdc (int bar_to_compute) const
 
const sl_pair< int > GetBarNHits (int bar_to_compute) const
 
const std::vector< USHitGetHits () const
 
double HasShower () const
 
void FindCentroid ()
 
ROOT::Math::XYZPoint GetCentroid () const
 
ROOT::Math::XYZPoint GetCentroidError () const
 
const int GetNHitBars () const
 
void TimeFilter (double min_timestamp, double max_timestamp)
 

Private Attributes

std::vector< USHithits_
 
Configuration configuration_
 
ROOT::Math::XYZPoint centroid_
 
ROOT::Math::XYZPoint centroid_error_
 
int station_
 

Detailed Description

Definition at line 13 of file sndUSPlane.h.

Constructor & Destructor Documentation

◆ USPlane()

snd::analysis_tools::USPlane::USPlane ( std::vector< MuFilterHit * >  snd_hits,
const Configuration configuration,
MuFilter muon_filter_geometry,
int  station,
bool  use_small_sipms = false 
)

Definition at line 13 of file sndUSPlane.cxx.

13 : configuration_(configuration), centroid_(std::nan(""), std::nan(""), std::nan("")), centroid_error_(std::nan(""), std::nan(""),std::nan("")), station_(station)
14{
15 for ( auto mu_hit : snd_hits)
16 {
17 TVector3 A, B;
18 int detectorID = mu_hit->GetDetectorID();
19 muon_filter_geometry->GetPosition(detectorID, A, B);
20 for (int i{0}; i < 16; ++i)
21 {
22 if (mu_hit->isMasked(i) || mu_hit->GetSignal(i) < -990.) continue;
23 USHit hit;
24 hit.bar = static_cast<int>(detectorID % 1000);
25 hit.channel_index = 16 * hit.bar + i;
26 hit.is_large = !mu_hit->isShort(i);
27 hit.is_right = i > 7 ? true : false;
28
29 if (!hit.is_large && !use_small_sipms_sipms)
30 {
31 hit.timestamp = std::nan("");
32 hit.qdc = std::nan("");
33 hit.x = std::nan("");
34 hit.y = std::nan("");
35 hit.z = std::nan("");
36 }
37 else
38 {
39 hit.timestamp = configuration_.is_mc ? mu_hit->GetTime(i) / ShipUnit::snd_TDC2ns : mu_hit->GetTime(i);
40 hit.qdc = mu_hit->GetSignal(i);
41 // use the left and right measurements to calculate the x coordinate along the bar
42 float timeConversion = configuration_.is_mc ? 1. : ShipUnit::snd_TDC2ns;
43 hit.x = A.X() - 0.5*(mu_hit->GetDeltaT()*timeConversion*configuration_.us_signal_speed+configuration_.us_bar_length);
44 hit.y = A.Y();
45 hit.z = A.Z();
46 }
47 hits_.push_back(hit);
48 }
49 }
50}
void GetPosition(Int_t id, TVector3 &vLeft, TVector3 &vRight)
Definition MuFilter.cxx:639
ROOT::Math::XYZPoint centroid_
Definition sndUSPlane.h:72
std::vector< USHit > hits_
Definition sndUSPlane.h:70
ROOT::Math::XYZPoint centroid_error_
Definition sndUSPlane.h:73
int i
Definition ShipAna.py:86

Member Function Documentation

◆ FindCentroid()

void snd::analysis_tools::USPlane::FindCentroid ( )

Definition at line 52 of file sndUSPlane.cxx.

53{
54 // select large SiPM channels with positive qdc
55 std::vector<USHit> cleaned_hits = hits_;
56
57 cleaned_hits.erase(std::remove_if(cleaned_hits.begin(), cleaned_hits.end(),
58 [&](auto &hit)
59 { return (hit.qdc <= 0 || hit.is_large == false); }),
60 cleaned_hits.end());
61
62 // min number of hit in the plane to attempt to find a centroid
63 if (static_cast<int>(cleaned_hits.size()) < configuration_.us_min_n_hits_for_centroid)
64 {
65 // std::cout<<"Not enough hits in US plane " << station_ <<" to find centroid\n";
66 return;
67 }
68
69 // weigthed sum calculated per plane
70 double weighted_sum_x{0.0}, weighted_sum_y{0.0}, weighted_sum_z{0.0};
71 double total_qdc_positive{0.0}, sum_qdc2_positive{0.0};
72 // loop over hits in the plane
73 for (const auto &hit : cleaned_hits)
74 {
75 weighted_sum_x += hit.x * hit.qdc;
76 weighted_sum_y += hit.y * hit.qdc;
77 weighted_sum_z += hit.z * hit.qdc;
78 total_qdc_positive += hit.qdc;
79 sum_qdc2_positive += hit.qdc*hit.qdc;
80 }
81 weighted_sum_x /= total_qdc_positive;
82 weighted_sum_y /= total_qdc_positive;
83 weighted_sum_z /= total_qdc_positive;
84 centroid_.SetXYZ(weighted_sum_x, weighted_sum_y, weighted_sum_z);
85 auto qdc_error_scaler = sqrt(sum_qdc2_positive)/total_qdc_positive;
87 configuration_.us_centroid_error_y*qdc_error_scaler,
88 configuration_.us_centroid_error_z*qdc_error_scaler);
89}

◆ GetBarNHits()

const snd::analysis_tools::USPlane::sl_pair< int > snd::analysis_tools::USPlane::GetBarNHits ( int  bar_to_compute) const

Definition at line 153 of file sndUSPlane.cxx.

154{
155 sl_pair<int> bar_hit{0, 0};
156 for (const auto &hit : hits_)
157 {
158 if (hit.bar != bar_to_compute)
159 continue;
160 else
161 {
162 if (hit.is_large)
163
164 bar_hit.large++;
165 else
166 bar_hit.small++;
167
168 }
169 }
170 return bar_hit;
171}

◆ GetBarQdc()

const snd::analysis_tools::USPlane::rl_pair< double > snd::analysis_tools::USPlane::GetBarQdc ( int  bar_to_compute) const

Definition at line 132 of file sndUSPlane.cxx.

133{
134 rl_pair<double> bar_qdc{0.0, 0.0};
135 for (const auto &hit : hits_)
136 {
137 if (hit.bar != bar_to_compute)
138 continue;
139 else
140 {
141 if (hit.is_large)
142 {
143 if (hit.is_right)
144 bar_qdc.right += hit.qdc;
145 else
146 bar_qdc.left += hit.qdc;
147 }
148 }
149 }
150 return bar_qdc;
151}

◆ GetCentroid()

ROOT::Math::XYZPoint snd::analysis_tools::USPlane::GetCentroid ( ) const
inline

Definition at line 62 of file sndUSPlane.h.

62{ return centroid_; }

◆ GetCentroidError()

ROOT::Math::XYZPoint snd::analysis_tools::USPlane::GetCentroidError ( ) const
inline

Definition at line 63 of file sndUSPlane.h.

63{ return centroid_error_; }

◆ GetHits()

const std::vector< USHit > snd::analysis_tools::USPlane::GetHits ( ) const
inline

Definition at line 58 of file sndUSPlane.h.

58{ return hits_; };

◆ GetNHitBars()

const int snd::analysis_tools::USPlane::GetNHitBars ( ) const

Definition at line 191 of file sndUSPlane.cxx.

191 {
192 int count{0};
193 for (int bar{0}; bar < configuration_.us_bar_per_station; ++bar) {
195 }
196 return count;
197}
const sl_pair< int > GetBarNHits(int bar_to_compute) const
int bar
Definition hepunit.py:152

◆ GetNHits()

const snd::analysis_tools::USPlane::sl_pair< int > snd::analysis_tools::USPlane::GetNHits ( ) const

Definition at line 181 of file sndUSPlane.cxx.

182{
183 sl_pair<int> counts{0, 0};
184 counts.large = std::count_if(hits_.begin(), hits_.end(), [](auto &hit)
185 { return hit.is_large; });
186 counts.small = static_cast<int>(hits_.size()) - counts.large;
187
188 return counts;
189}

◆ GetSideQdc()

const snd::analysis_tools::USPlane::rl_pair< double > snd::analysis_tools::USPlane::GetSideQdc ( ) const

Definition at line 116 of file sndUSPlane.cxx.

117{
118 rl_pair<double> side_qdc{0.0, 0.0};
119 for (const auto &hit : hits_)
120 {
121 if (hit.is_large)
122 {
123 if (hit.is_right)
124 side_qdc.right += hit.qdc;
125 else
126 side_qdc.left += hit.qdc;
127 }
128 }
129 return side_qdc;
130}

◆ GetStation()

const int snd::analysis_tools::USPlane::GetStation ( ) const
inline

Definition at line 51 of file sndUSPlane.h.

51{ return station_; }

◆ GetTotEnergy()

const snd::analysis_tools::USPlane::sl_pair< double > snd::analysis_tools::USPlane::GetTotEnergy ( ) const

Definition at line 104 of file sndUSPlane.cxx.

105{
106 sl_pair<double> tot_energy{0.0, 0.0};
107 sl_pair<double> tot_qdc = GetTotQdc();
108
109 tot_energy.large = tot_qdc.large *configuration_.us_qdc_to_gev;
110 tot_energy.small = tot_qdc.small *configuration_.us_qdc_to_gev;
111
112 return tot_energy;
113}
const sl_pair< double > GetTotQdc() const

◆ GetTotQdc()

const snd::analysis_tools::USPlane::sl_pair< double > snd::analysis_tools::USPlane::GetTotQdc ( ) const

Definition at line 91 of file sndUSPlane.cxx.

92{
93 sl_pair<double> totQdc{0.0, 0.0};
94 for (const auto &hit : hits_)
95 {
96 if (hit.is_large)
97 totQdc.large += hit.qdc;
98 else
99 totQdc.small += hit.qdc;
100 }
101 return totQdc;
102}

◆ HasShower()

double snd::analysis_tools::USPlane::HasShower ( ) const
inline

Definition at line 59 of file sndUSPlane.h.

const sl_pair< int > GetNHits() const

◆ TimeFilter()

void snd::analysis_tools::USPlane::TimeFilter ( double  min_timestamp,
double  max_timestamp 
)

Definition at line 173 of file sndUSPlane.cxx.

174{
175 hits_.erase(std::remove_if(hits_.begin(), hits_.end(),
176 [&](auto &hit)
177 { return hit.timestamp < min_timestamp || hit.timestamp > max_timestamp; }),
178 hits_.end());
179}

Member Data Documentation

◆ centroid_

ROOT::Math::XYZPoint snd::analysis_tools::USPlane::centroid_
private

Definition at line 72 of file sndUSPlane.h.

◆ centroid_error_

ROOT::Math::XYZPoint snd::analysis_tools::USPlane::centroid_error_
private

Definition at line 73 of file sndUSPlane.h.

◆ configuration_

Configuration snd::analysis_tools::USPlane::configuration_
private

Definition at line 71 of file sndUSPlane.h.

◆ hits_

std::vector<USHit> snd::analysis_tools::USPlane::hits_
private

Definition at line 70 of file sndUSPlane.h.

◆ station_

int snd::analysis_tools::USPlane::station_
private

Definition at line 74 of file sndUSPlane.h.


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