R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandHitMon.cxx
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2019-2025 Members of R3B Collaboration *
4 * *
5 * This software is distributed under the terms of the *
6 * GNU General Public Licence (GPL) version 3, *
7 * copied verbatim in the file "LICENSE". *
8 * *
9 * In applying this license GSI does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 ******************************************************************************/
13
14#include "R3BNeulandHitMon.h"
15#include "FairRootManager.h"
16#include "R3BNeulandHit.h"
17#include <FairTask.h>
18#include <Rtypes.h>
19#include <RtypesCore.h>
20#include <TFile.h>
21#include <TH3.h>
22#include <TString.h>
23#include <algorithm>
24#include <cstdlib>
25#include <fairlogger/Logger.h>
26#include <map>
27#include <numeric>
28#include <string_view>
29#include <utility>
30
31R3BNeulandHitMon::R3BNeulandHitMon(std::string_view hits_name, const Option_t* option)
32 : FairTask("R3B NeuLAND NeulandHit Monitor")
33 , neuland_hits_{ hits_name }
34{
35 LOG(info) << "Using R3B NeuLAND NeulandHit Monitor";
36
37 TString opt = option;
38 opt.ToUpper();
39 if (opt.Contains("3DTRACK"))
40 {
42 LOG(info) << "... with 3D track visualization";
43 }
44}
45
46auto R3BNeulandHitMon::Init() -> InitStatus
47{
48 neuland_hits_.init();
49
51 {
52 // XYZ -> ZXY (side view)
53 const auto xbinN = 60;
54 const auto ybinN = 50;
55 const auto zbinN = 50;
56
57 // define additional histogram parameters
58 const auto x_bounds_lower = 1400.;
59 const auto x_bounds_upper = 1700.;
60 const auto yz_bounds_lower = -125.;
61 const auto yz_bounds_upper = 125.;
62
63 hist_3_ = data_monitor_.add_hist<TH3D>("hHits",
64 "hHits",
65 xbinN,
66 x_bounds_lower,
67 x_bounds_upper,
68 ybinN,
69 yz_bounds_lower,
70 yz_bounds_upper,
71 zbinN,
72 yz_bounds_lower,
73 yz_bounds_upper);
74 hist_3_->SetTitle("NeuLAND Hits");
75 hist_3_->GetXaxis()->SetTitle("Z");
76 hist_3_->GetYaxis()->SetTitle("X");
77 hist_3_->GetZaxis()->SetTitle("Y");
78 FairRootManager::Instance()->Register("NeulandHitMon", "Hits in NeuLAND", hist_3_, kTRUE);
79 }
80
81 // define number of bins for histograms
82 const auto maxHitNum = 200;
83 const auto timeBinN = 30000;
84 const auto zDepBinN = 60;
85 const auto energyBinN = 500;
86 const auto totenergyBinN = 1000;
87 const auto posXYBinN = 300;
88 const auto velocityBinN = 200;
89
90 // define additional histogram parameters
91 const auto z_dep_lower = 1400.;
92 const auto z_dep_upper = 1700.;
93 const auto total_energy_upper = 10000.;
94 const auto pos_xy_lower = -150.;
95 const auto pos_xy_upper = 150.;
96 const auto time_para = -15.;
97 const auto energy_upper_foremost_vs_e_tot_a = 2000.;
98 const auto energy_upper_foremost_vs_e_tot_b = 250.;
99
100 hist_time_ = data_monitor_.add_hist<TH1D>("hTime", "Hit time", timeBinN, -1000., 1000.);
102 data_monitor_.add_hist<TH1D>("hTimeAdj", "Hit Time adjusted for flight path", timeBinN, -1000., 1000.);
103
104 hist_mult_ = data_monitor_.add_hist<TH1I>("hMult", "Hit Multiplicity", maxHitNum, 0, maxHitNum);
105
107 data_monitor_.add_hist<TH1D>("hDepth", "Maxial penetration depth", zDepBinN, z_dep_lower, z_dep_upper);
109 "hDepthVSFrontEnergy", "Depth vs Foremost Energy", zDepBinN, z_dep_lower, z_dep_upper, energyBinN, 0., 100.);
110 hist_depth_vs_sternmost_energy_ = data_monitor_.add_hist<TH2D>("hDepthVSSternmostEnergy",
111 "Depth vs Sternmost Energy",
112 zDepBinN,
113 z_dep_lower,
114 z_dep_upper,
115 energyBinN,
116 0,
117 100.);
119 "hDepthVSEtot", "Depth vs Total Energy", zDepBinN, z_dep_lower, z_dep_upper, totenergyBinN, 0, 1000.);
121 data_monitor_.add_hist<TH1D>("hForemostEnergy", "Foremost energy deposition", energyBinN, 0, 100.);
123 data_monitor_.add_hist<TH1D>("hSternmostEnergy", "Sternmost energy deposition", energyBinN, 0, 100.);
124 hist_energy_tot_ = data_monitor_.add_hist<TH1D>("hEtot", "Total Energy", totenergyBinN, 0, total_energy_upper);
125 hdeltaEE = data_monitor_.add_hist<TH2D>("hdeltaEE",
126 "Energy in Foremost Plane vs Etot",
127 energyBinN,
128 0,
129 energy_upper_foremost_vs_e_tot_a,
130 energyBinN,
131 0,
132 energy_upper_foremost_vs_e_tot_b);
133 hist_pos_vs_energy_ = data_monitor_.add_hist<TH2D>(
134 "hPosVSEnergy", "Position vs Energy deposition", zDepBinN, z_dep_lower, z_dep_upper, totenergyBinN, 0, 1000.);
135 hist_beta_ = data_monitor_.add_hist<TH1D>("hBeta", "Velocity", velocityBinN, 0., 1.);
136 hist_energy_ = data_monitor_.add_hist<TH1D>("hE", "Hit Energy", energyBinN, 0., 100.);
137 hist_x_ = data_monitor_.add_hist<TH1D>("hX", "Hit X", posXYBinN, pos_xy_lower, pos_xy_upper);
138 hist_y_ = data_monitor_.add_hist<TH1D>("hY", "Hit Y", posXYBinN, pos_xy_lower, pos_xy_upper);
139 hT = data_monitor_.add_hist<TH1D>("hT", "Hit Delta T", timeBinN, time_para, time_para);
140 hTNeigh = data_monitor_.add_hist<TH1D>("hTNeigh", "Hit Neigh Delta T", timeBinN, time_para, time_para);
141
142 return kSUCCESS;
143}
144
145void R3BNeulandHitMon::Exec(Option_t* /*option*/)
146{
147 const auto& hits = neuland_hits_.get();
148
149 // checking paddle multihits
150 std::map<Int_t, Int_t> paddlenum;
151 for (const auto& hit : hits)
152 {
153 auto result = paddlenum.insert(std::pair<Int_t, Int_t>(hit.GetPaddle(), 1));
154 if (!result.second)
155 {
156 result.first->second++;
157 }
158 }
159 auto max = std::max_element(paddlenum.begin(),
160 paddlenum.end(),
161 [](std::pair<Int_t, Int_t> lhs, std::pair<Int_t, Int_t> rhs)
162 { return (lhs.second < rhs.second); });
163 LOG(debug) << "max dupli: " << max->second;
164
166 {
167 hist_3_->Reset("ICES");
168 for (const auto& hit : hits)
169 {
170 hist_3_->Fill(hit.GetPosition().Z(), hit.GetPosition().X(), hit.GetPosition().Y(), hit.GetE());
171 }
172 }
173
174 hist_mult_->Fill(static_cast<double>(hits.size()));
175 for (const auto& hit : hits)
176 {
177 hist_pos_vs_energy_->Fill(hit.GetPosition().Z(), hit.GetE());
178 hist_time_->Fill(hit.GetT());
179 hist_time_adj_->Fill(distance_to_target_ / hit.GetPosition().Mag() * hit.GetT());
180 hist_beta_->Fill(hit.GetBeta());
181 hist_energy_->Fill(hit.GetE());
182 hist_x_->Fill(hit.GetPosition().X());
183 hist_y_->Fill(hit.GetPosition().Y());
184 }
185
186 for (auto it1 = hits.begin(); it1 != hits.end(); it1++)
187 {
188 for (auto it2 = it1 + 1; it2 != hits.end(); it2++)
189 {
190 const auto pos_delta_cutoff = 7.5;
191 if (std::abs((*it1).GetPosition().X() - (*it2).GetPosition().X()) < pos_delta_cutoff &&
192 std::abs((*it1).GetPosition().Y() - (*it2).GetPosition().Y()) < pos_delta_cutoff &&
193 std::abs((*it1).GetPosition().Z() - (*it2).GetPosition().Z()) < pos_delta_cutoff)
194 {
195 hTNeigh->Fill((*it1).GetT() - (*it2).GetT());
196 }
197 hT->Fill((*it1).GetT() - (*it2).GetT());
198 }
199 }
200
201 auto maxDepthHit = std::max_element(hits.begin(),
202 hits.end(),
203 [](const R3BNeulandHit& one, const R3BNeulandHit& another)
204 { return one.GetPosition().Z() < another.GetPosition().Z(); });
205 if (maxDepthHit != hits.end())
206 {
207 hist_depth_->Fill((*maxDepthHit).GetPosition().Z());
208 hist_sternmost_energy_->Fill((*maxDepthHit).GetE());
209 hist_depth_vs_sternmost_energy_->Fill((*maxDepthHit).GetPosition().Z(), (*maxDepthHit).GetE());
210 }
211
212 auto minDepthHit = std::min_element(hits.begin(),
213 hits.end(),
214 [](const R3BNeulandHit& one, const R3BNeulandHit& another)
215 { return one.GetPosition().Z() < another.GetPosition().Z(); });
216 auto Etot =
217 std::accumulate(hits.begin(), hits.end(), 0., [](double init, const auto& hit) { return init + hit.GetE(); });
218
219 if (minDepthHit != hits.end())
220 {
221 hist_foremost_energy_->Fill((*minDepthHit).GetE());
222 hist_depth_vs_foremost_energy_->Fill((*maxDepthHit).GetPosition().Z(), (*minDepthHit).GetE());
223 hdeltaEE->Fill(Etot, (*minDepthHit).GetE());
224 }
225
226 hist_energy_tot_->Fill(Etot);
227 if (maxDepthHit != hits.end())
228 {
229 hist_depth_vs_energy_tot_->Fill((*maxDepthHit).GetPosition().Z(), Etot);
230 }
231}
232
233ClassImp(R3BNeulandHitMon) // NOLINT
ClassImp(R3B::Neuland::Cal2HitPar)
auto Init() -> InitStatus override
TH2D * hist_depth_vs_energy_tot_
TH2D * hist_depth_vs_sternmost_energy_
R3B::DataMonitor data_monitor_
R3BNeulandHitMon(std::string_view hits_name="NeulandHits", const Option_t *option="")
void Exec(Option_t *) override
R3B::InputVectorConnector< R3BNeulandHit > neuland_hits_
TH2D * hist_depth_vs_foremost_energy_