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 (TClonesArray *snd_hits, Configuration configuration, MuFilter *muon_filter_geometry, int index_begin, int index_end, int station)
 
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
 
void FindCentroid ()
 
const TVector3 GetCentroid () const
 
const TVector3 GetCentroidError () const
 
void TimeFilter (double min_timestamp, double max_timestamp)
 

Private Attributes

std::vector< USHithits_
 
Configuration configuration_
 
TVector3 centroid_
 
TVector3 centroid_error_
 
int station_
 

Detailed Description

Definition at line 13 of file sndUSPlane.h.

Constructor & Destructor Documentation

◆ USPlane()

snd::analysis_tools::USPlane::USPlane ( TClonesArray *  snd_hits,
snd::Configuration  configuration,
MuFilter muon_filter_geometry,
int  index_begin,
int  index_end,
int  station 
)

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 if (index_begin > index_end)
16 {
17 throw std::runtime_error{"Begin index > end index"};
18 }
19 for (int j{index_begin}; j < index_end; ++j)
20 {
21 auto mu_hit = static_cast<MuFilterHit *>(snd_hits->At(j));
22
23 for (int i{0}; i < 16; ++i)
24 {
25 if (mu_hit->isMasked(i) || mu_hit->GetSignal(i) < -990.) continue;
26 USHit hit;
27 hit.bar = static_cast<int>(mu_hit->GetDetectorID() % 1000);
28 hit.channel_index = 16 * hit.bar + i;
29 hit.timestamp = mu_hit->GetTime(i);
30 hit.qdc = mu_hit->GetSignal(i);
31 hit.is_large = !mu_hit->isShort(i);
32
33 TVector3 A, B;
34 int detectorID = mu_hit->GetDetectorID();
35 muon_filter_geometry->GetPosition(detectorID, A, B);
36 hit.is_right = i > 7 ? true : false;
37 hit.x = hit.is_right ? B.X() : A.X();
38 hit.y = A.Y();
39 hit.z = A.Z();
40 hits_.push_back(hit);
41 }
42 }
43}
void GetPosition(Int_t id, TVector3 &vLeft, TVector3 &vRight)
Definition MuFilter.cxx:639
std::vector< USHit > hits_
Definition sndUSPlane.h:67
int i
Definition ShipAna.py:86

Member Function Documentation

◆ FindCentroid()

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

Definition at line 45 of file sndUSPlane.cxx.

46{
47 // min number of hit in the plane to attempt to find a centroid
49 {
50 // std::cout<<"Not enough hits in US plane " << station_ <<" to find centroid\n";
51 return;
52 }
53
54 double total_qdc = GetTotQdc().large;
55 if (total_qdc > 0.0)
56 {
57 for (const auto &hit : hits_)
58 {
59 // weigthed sum
60 double weighted_sum_x{0.0}, weighted_sum_y{0.0}, weighted_sum_z{0.0};
61 double total_qdc_positive{0.0};
62
63 if (hit.qdc > 0.0)
64 {
65 weighted_sum_x += hit.x * hit.qdc;
66 weighted_sum_y += hit.y * hit.qdc;
67 weighted_sum_z += hit.z * hit.qdc;
68 total_qdc_positive += hit.qdc;
69 }
70
71 double x = weighted_sum_x / total_qdc_positive;
72 double y = weighted_sum_y / total_qdc_positive;
73 double z = weighted_sum_z / total_qdc_positive;
74 centroid_.SetXYZ(x, y, z);
75 }
76 }
78}
const sl_pair< double > GetTotQdc() const

◆ GetBarNHits()

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

Definition at line 142 of file sndUSPlane.cxx.

143{
144 sl_pair<int> bar_hit{0, 0};
145 for (const auto &hit : hits_)
146 {
147 if (hit.bar != bar_to_compute)
148 continue;
149 else
150 {
151 if (hit.is_large)
152
153 bar_hit.large++;
154 else
155 bar_hit.small++;
156
157 }
158 }
159 return bar_hit;
160}

◆ GetBarQdc()

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

Definition at line 121 of file sndUSPlane.cxx.

122{
123 rl_pair<double> bar_qdc{0.0, 0.0};
124 for (const auto &hit : hits_)
125 {
126 if (hit.bar != bar_to_compute)
127 continue;
128 else
129 {
130 if (hit.is_large)
131 {
132 if (hit.is_right)
133 bar_qdc.right += hit.qdc;
134 else
135 bar_qdc.left += hit.qdc;
136 }
137 }
138 }
139 return bar_qdc;
140}

◆ GetCentroid()

const TVector3 snd::analysis_tools::USPlane::GetCentroid ( ) const
inline

Definition at line 61 of file sndUSPlane.h.

61{ return centroid_; };

◆ GetCentroidError()

const TVector3 snd::analysis_tools::USPlane::GetCentroidError ( ) const
inline

Definition at line 62 of file sndUSPlane.h.

62{ 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_; };

◆ GetNHits()

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

Definition at line 170 of file sndUSPlane.cxx.

171{
172 sl_pair<int> counts{0, 0};
173 counts.large = std::count_if(hits_.begin(), hits_.end(), [](auto &hit)
174 { return hit.is_large; });
175 counts.small = hits_.size() - counts.large;
176
177 return counts;
178}

◆ GetSideQdc()

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

Definition at line 105 of file sndUSPlane.cxx.

106{
107 rl_pair<double> side_qdc{0.0, 0.0};
108 for (const auto &hit : hits_)
109 {
110 if (hit.is_large)
111 {
112 if (hit.is_right)
113 side_qdc.right += hit.qdc;
114 else
115 side_qdc.left += hit.qdc;
116 }
117 }
118 return side_qdc;
119}

◆ 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 93 of file sndUSPlane.cxx.

94{
95 sl_pair<double> tot_energy{0.0, 0.0};
96 sl_pair<double> tot_qdc = GetTotQdc();
97
98 tot_energy.large = tot_qdc.large *configuration_.us_qdc_to_gev;
99 tot_energy.small = tot_qdc.small *configuration_.us_qdc_to_gev;
100
101 return tot_energy;
102}

◆ GetTotQdc()

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

Definition at line 80 of file sndUSPlane.cxx.

81{
82 sl_pair<double> totQdc{0.0, 0.0};
83 for (const auto &hit : hits_)
84 {
85 if (hit.is_large)
86 totQdc.large += hit.qdc;
87 else
88 totQdc.small += hit.qdc;
89 }
90 return totQdc;
91}

◆ TimeFilter()

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

Definition at line 162 of file sndUSPlane.cxx.

163{
164 hits_.erase(std::remove_if(hits_.begin(), hits_.end(),
165 [&](auto &hit)
166 { return hit.timestamp < min_timestamp || hit.timestamp > max_timestamp; }),
167 hits_.end());
168}

Member Data Documentation

◆ centroid_

TVector3 snd::analysis_tools::USPlane::centroid_
private

Definition at line 69 of file sndUSPlane.h.

◆ centroid_error_

TVector3 snd::analysis_tools::USPlane::centroid_error_
private

Definition at line 70 of file sndUSPlane.h.

◆ configuration_

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

Definition at line 68 of file sndUSPlane.h.

◆ hits_

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

Definition at line 67 of file sndUSPlane.h.

◆ station_

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

Definition at line 71 of file sndUSPlane.h.


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