16
16
#include " FairRootManager.h"
17
17
#include " FairRunAna.h"
18
18
#include " FairRuntimeDb.h"
19
+ #include " NeulandPointFilter.h"
20
+ #include " R3BDataMonitor.h"
19
21
#include " TGeoManager.h"
20
22
#include " TGeoNode.h"
21
23
#include " TH1F.h"
26
28
#include < TFile.h>
27
29
#include < iostream>
28
30
#include < stdexcept>
31
+ #include < string_view>
29
32
#include < utility>
30
33
31
- R3BNeulandDigitizer::R3BNeulandDigitizer (TString input, TString output )
32
- : R3BNeulandDigitizer(Digitizing::CreateEngine(UsePaddle<NeulandPaddle>(), UseChannel<TacquilaChannel>()),
33
- std::move(input),
34
- std::move(output) )
34
+ R3BNeulandDigitizer::R3BNeulandDigitizer ()
35
+ : R3BNeulandDigitizer(Digitizing::CreateEngine(UsePaddle<NeulandPaddle>(), UseChannel<TacquilaChannel>())
36
+
37
+ )
35
38
{
36
39
}
37
40
38
- R3BNeulandDigitizer::R3BNeulandDigitizer (std::unique_ptr<Digitizing::DigitizingEngineInterface> engine,
39
- TString input,
40
- TString output)
41
+ R3BNeulandDigitizer::R3BNeulandDigitizer (std::unique_ptr<Digitizing::DigitizingEngineInterface> engine)
41
42
: FairTask(" R3BNeulandDigitizer" )
42
- , fPoints(std::move(input))
43
- , fHits(std::move(output))
44
- , fDigitizingEngine(std::move(engine))
43
+ , digitizing_engine_(std::move(engine))
45
44
{
46
45
}
47
46
48
47
void R3BNeulandDigitizer::SetEngine (std::unique_ptr<Digitizing::DigitizingEngineInterface> engine)
49
48
{
50
- fDigitizingEngine = std::move (engine);
49
+ digitizing_engine_ = std::move (engine);
51
50
}
52
51
53
52
void R3BNeulandDigitizer::SetParContainers ()
@@ -64,48 +63,64 @@ void R3BNeulandDigitizer::SetParContainers()
64
63
LOG (fatal) << " R3BNeulandDigitizer::SetParContainers: No runtime database" ;
65
64
}
66
65
67
- fNeulandGeoPar = dynamic_cast <R3BNeulandGeoPar*>(rtdb->getContainer (" R3BNeulandGeoPar" ));
68
- if (fNeulandGeoPar == nullptr )
66
+ neuland_geo_par_ = dynamic_cast <R3BNeulandGeoPar*>(rtdb->getContainer (" R3BNeulandGeoPar" ));
67
+ if (neuland_geo_par_ == nullptr )
69
68
{
70
69
LOG (fatal) << " R3BNeulandDigitizer::SetParContainers: No R3BNeulandGeoPar" ;
71
70
}
72
71
73
- fDigitizingEngine ->Init ();
72
+ digitizing_engine_ ->Init ();
74
73
}
75
74
76
- InitStatus R3BNeulandDigitizer::Init ()
75
+ void R3BNeulandDigitizer::SetNeulandPointFilter (R3B::Neuland::BitSetParticle particle)
76
+ {
77
+ neuland_point_filter_.SetFilter (particle);
78
+ }
79
+ void R3BNeulandDigitizer::SetNeulandPointFilter (R3B::Neuland::BitSetParticle particle,
80
+ double minimum_allowed_energy_gev)
77
81
{
78
- fPoints . Init ( );
79
- fHits . Init ();
82
+ neuland_point_filter_. SetFilter (particle, minimum_allowed_energy_gev );
83
+ }
80
84
85
+ auto R3BNeulandDigitizer::Init () -> InitStatus
86
+ {
87
+ neuland_points_.init ();
88
+ neuland_hits_.init ();
81
89
// Initialize control histograms
82
90
auto const PaddleMulSize = 3000 ;
83
- hMultOne = R3B::root_owned <TH1I>(
91
+ mult_one_ = data_monitor_. add_hist <TH1I>(
84
92
" MultiplicityOne" , " Paddle multiplicity: only one PMT per paddle" , PaddleMulSize, 0 , PaddleMulSize);
85
- hMultTwo = R3B::root_owned<TH1I>(
93
+
94
+ mult_two_ = data_monitor_.add_hist <TH1I>(
86
95
" MultiplicityTwo" , " Paddle multiplicity: both PMTs of a paddle" , PaddleMulSize, 0 , PaddleMulSize);
87
96
auto const timeBinSize = 200 ;
88
- hRLTimeToTrig = R3B::root_owned <TH1F>(" hRLTimeToTrig" , " R/Ltime-triggerTime" , timeBinSize, -100 ., 100 .);
97
+ rl_time_to_trig_ = data_monitor_. add_hist <TH1F>(" hRLTimeToTrig" , " R/Ltime-triggerTime" , timeBinSize, -100 ., 100 .);
89
98
90
99
return kSUCCESS ;
91
100
}
92
101
93
102
void R3BNeulandDigitizer::Exec (Option_t* /* option*/ )
94
103
{
95
- fHits . Reset ();
104
+ neuland_hits_. clear ();
96
105
const auto GeVToMeVFac = 1000 .;
97
106
98
107
std::map<UInt_t, Double_t> paddleEnergyDeposit;
99
108
// Look at each Land Point, if it deposited energy in the scintillator, store it with reference to the bar
100
- for (const auto & point : fPoints . Retrieve () )
109
+ for (const auto & point : neuland_points_ )
101
110
{
102
- if (point->GetEnergyLoss () > 0 .)
111
+ if (((neuland_point_filter_.GetFilter () != R3B::Neuland::BitSetParticle::none) or
112
+ (neuland_point_filter_.GetMinimumAllowedEnergy () != 0 )) and
113
+ neuland_point_filter_.CheckFiltered (point))
103
114
{
104
- const Int_t paddleID = point->GetPaddle ();
115
+ continue ;
116
+ }
117
+ if (point.GetEnergyLoss () > 0 .)
118
+ {
119
+ const Int_t paddleID = point.GetPaddle ();
105
120
106
121
// Convert position of point to paddle-coordinates, including any rotation or translation
107
- const TVector3 position = point-> GetPosition ();
108
- const TVector3 converted_position = fNeulandGeoPar ->ConvertToLocalCoordinates (position, paddleID);
122
+ const TVector3 position = point. GetPosition ();
123
+ const TVector3 converted_position = neuland_geo_par_ ->ConvertToLocalCoordinates (position, paddleID);
109
124
LOG (debug2) << " NeulandDigitizer: Point in paddle " << paddleID
110
125
<< " with global position XYZ: " << position.X () << " " << position.Y () << " " << position.Z ();
111
126
LOG (debug2) << " NeulandDigitizer: Converted to local position XYZ: " << converted_position.X () << " "
@@ -114,22 +129,22 @@ void R3BNeulandDigitizer::Exec(Option_t* /*option*/)
114
129
// Within the paddle frame, the relevant distance of the light from the pmt is always given by the
115
130
// X-Coordinate
116
131
const Double_t dist = converted_position.X ();
117
- fDigitizingEngine ->DepositLight (paddleID, point-> GetTime (), point-> GetLightYield () * GeVToMeVFac, dist);
118
- paddleEnergyDeposit[paddleID] += point-> GetEnergyLoss () * GeVToMeVFac;
132
+ digitizing_engine_ ->DepositLight (paddleID, point. GetTime (), point. GetLightYield () * GeVToMeVFac, dist);
133
+ paddleEnergyDeposit[paddleID] += point. GetEnergyLoss () * GeVToMeVFac;
119
134
} // eloss
120
135
} // points
121
136
122
- const Double_t triggerTime = fDigitizingEngine ->GetTriggerTime ();
123
- const auto paddles = fDigitizingEngine ->ExtractPaddles ();
137
+ const Double_t triggerTime = digitizing_engine_ ->GetTriggerTime ();
138
+ const auto paddles = digitizing_engine_ ->ExtractPaddles ();
124
139
125
140
// Fill control histograms
126
- hMultOne ->Fill (static_cast <int >(std::count_if (
141
+ mult_one_ ->Fill (static_cast <int >(std::count_if (
127
142
paddles.begin (), paddles.end (), [](const auto & keyValue) { return keyValue.second ->HasHalfFired (); })));
128
143
129
- hMultTwo ->Fill (static_cast <int >(std::count_if (
144
+ mult_two_ ->Fill (static_cast <int >(std::count_if (
130
145
paddles.begin (), paddles.end (), [](const auto & keyValue) { return keyValue.second ->HasFired (); })));
131
146
132
- hRLTimeToTrig ->Fill (triggerTime);
147
+ rl_time_to_trig_ ->Fill (triggerTime);
133
148
134
149
// Create Hits
135
150
for (const auto & [paddleID, paddle] : paddles)
@@ -144,8 +159,8 @@ void R3BNeulandDigitizer::Exec(Option_t* /*option*/)
144
159
for (const auto signal : signals)
145
160
{
146
161
const TVector3 hitPositionLocal = TVector3 (signal.position , 0 ., 0 .);
147
- const TVector3 hitPositionGlobal = fNeulandGeoPar ->ConvertToGlobalCoordinates (hitPositionLocal, paddleID);
148
- const TVector3 hitPixel = fNeulandGeoPar ->ConvertGlobalToPixel (hitPositionGlobal);
162
+ const TVector3 hitPositionGlobal = neuland_geo_par_ ->ConvertToGlobalCoordinates (hitPositionLocal, paddleID);
163
+ const TVector3 hitPixel = neuland_geo_par_ ->ConvertGlobalToPixel (hitPositionGlobal);
149
164
150
165
R3BNeulandHit hit (paddleID,
151
166
signal.leftChannel .tdc ,
@@ -157,30 +172,16 @@ void R3BNeulandDigitizer::Exec(Option_t* /*option*/)
157
172
hitPositionGlobal,
158
173
hitPixel);
159
174
160
- if (fHitFilters .IsValid (hit))
175
+ if (neuland_hit_filters_ .IsValid (hit))
161
176
{
162
- fHits . Insert (std::move (hit));
177
+ neuland_hits_. get (). emplace_back (std::move (hit));
163
178
LOG (debug) << " Adding neuland hit with id = " << paddleID << " , time = " << signal.time
164
179
<< " , energy = " << signal.energy ;
165
180
}
166
181
} // loop over all hits for each paddle
167
182
} // loop over paddles
168
183
169
- LOG (debug) << " R3BNeulandDigitizer: produced " << fHits .Size () << " hits" ;
170
- }
171
-
172
- void R3BNeulandDigitizer::Finish ()
173
- {
174
- TDirectory* tmp = gDirectory ;
175
- FairRootManager::Instance ()->GetOutFile ()->cd ();
176
-
177
- gDirectory ->mkdir (" R3BNeulandDigitizer" );
178
- gDirectory ->cd (" R3BNeulandDigitizer" );
179
-
180
- hMultOne->Write ();
181
- hMultTwo->Write ();
182
-
183
- gDirectory = tmp;
184
+ LOG (debug) << " R3BNeulandDigitizer: produced " << neuland_hits_.get ().size () << " hits" ;
184
185
}
185
186
186
187
ClassImp (R3BNeulandDigitizer); // NOLINT
0 commit comments