Jpp 20.0.0-27-g39925593c-D
the software that should make you happy
Loading...
Searching...
No Matches
JDetectorSimulator.hh
Go to the documentation of this file.
1#ifndef __JDETECTOR__JDETECTORSIMULATOR__
2#define __JDETECTOR__JDETECTORSIMULATOR__
3
4#include <memory>
5
11#include "JLang/JException.hh"
12
13
14/**
15 * \author mdejong
16 */
17
18namespace JDETECTOR {}
19namespace JPP { using namespace JDETECTOR; }
20
21namespace JDETECTOR {
22
24
25
26 /**
27 * Detector simulation.
28 *
29 * This class implements the JK40Simulator, JPMTSimulator and JCLBSimulator interfaces.
30 * The implementations of these interfaces should be provided via pointers to corresponding objects.
31 *
32 * N.B: This class owns the objects pointed to using class JLANG::JSinglePointer.
33 */
35 public JPMTRouter,
36 public JK40Simulator,
37 public JPMTSimulator,
38 public JCLBSimulator
39 {
40 private:
41 /**
42 * Make copy constructor inaccesible.
43 */
45
46
47 /**
48 * Make assignment operator inaccesible
49 */
51
52
53 public:
54 /**
55 * Constructor.
56 *
57 * \param detector detector
58 */
62
63
64 /**
65 * Check availability of K40 simulator.
66 *
67 * \return true if simulator available; else false
68 */
69 bool hasK40Simulator() const
70 {
71 return k40Simulator.get() != NULL;
72 }
73
74
75
76 /**
77 * Check availability of PMT simulator.
78 *
79 * \return true if simulator available; else false
80 */
81 bool hasPMTSimulator() const
82 {
83 return pmtSimulator.get() != NULL;
84 }
85
86
87 /**
88 * Check availability of CLB simulator.
89 *
90 * \return true if simulator available; else false
91 */
92 bool hasCLBSimulator() const
93 {
94 return clbSimulator.get() != NULL;
95 }
96
97
98 /**
99 * Get K40 simulator.
100 *
101 * \return K40 simulator
102 */
104 {
105 if (hasK40Simulator())
106 return *k40Simulator;
107 else
108 THROW(JPointerException, "JDetectorSimulator: K40 simulator not avaliable.");
109 }
110
111
112 /**
113 * Get PMT simulator.
114 *
115 * \return PMT simulator
116 */
118 {
119 if (hasPMTSimulator())
120 return *pmtSimulator;
121 else
122 THROW(JPointerException, "JDetectorSimulator: PMT simulator not avaliable.");
123 }
124
125
126 /**
127 * Get CLB simulator.
128 *
129 * \return CLB simulator
130 */
132 {
133 if (hasCLBSimulator())
134 return *clbSimulator;
135 else
136 THROW(JPointerException, "JDetectorSimulator: CLB simulator not avaliable.");
137 }
138
139
140 /**
141 * Reset K40 simulator.
142 *
143 * \param k40Simulator K40 simulator
144 */
146 {
147 this->k40Simulator.reset(k40Simulator);
148 }
149
150
151
152 /**
153 * Reset PMT simulator.
154 *
155 * \param pmtSimulator PMT simulator
156 */
158 {
159 this->pmtSimulator.reset(pmtSimulator);
160 }
161
162
163 /**
164 * Reset CLB simulator.
165 *
166 * \param clbSimulator CLB simulator
167 */
169 {
170 this->clbSimulator.reset(clbSimulator);
171 }
172
173
174 /**
175 * Generate hits.
176 *
177 * \param module module
178 * \param period time window [ns]
179 * \param output background data
180 */
181 virtual void generateHits(const JModule& module,
182 const JTimeRange& period,
183 JModuleData& output) const override
184 {
185 getK40Simulator().generateHits(module, period, output);
186 }
187
188
189 /**
190 * Process hits.
191 *
192 * \param ID PMT identifier
193 * \param calibration PMT calibration
194 * \param status PMT status
195 * \param input PMT signals
196 * \param output PMT hits
197 */
198 virtual void processHits(const JPMTIdentifier& ID,
200 const JStatus& status,
201 const JPMTData<JPMTSignal>& input,
202 JPMTData<JPMTPulse>& output) const override
203 {
204 getPMTSimulator().processHits(ID, calibration, status, input, output);
205 }
206
207
208 /**
209 * Process data.
210 *
211 * \param id module identifier
212 * \param input PMT data
213 * \param output CLB data
214 */
215 virtual void processData(const JModuleIdentifier& id, const JCLBInput& input, JDAQSuperFrame& output) const override
216 {
217 getCLBSimulator().processData(id, input, output);
218 }
219
220
221 /**
222 * Process module data in one step.
223 *
224 * \param module module
225 * \param input PMT signals
226 * \param output CLB data
227 */
228 virtual void operator()(const JModule& module,
229 JModuleData& input,
230 JDAQSuperFrame& output) const
231 {
232 // PMT simulation
233
234 JCLBInput buffer(input.size());
235
236 for (unsigned int i = 0; i != input.size(); ++i) {
237
238 input[i].sort();
239
240 const JPMT& pmt = module.getPMT(i);
241
242 processHits(JPMTIdentifier(module.getID(), i),
243 pmt.getCalibration(),
244 pmt.getStatus(),
245 input [i],
246 buffer[i]);
247 }
248
249 // CLB simulation
250
251 processData(module, buffer, output);
252 }
253
254
255 protected:
256 std::unique_ptr<JK40Simulator> k40Simulator;
257 std::unique_ptr<JPMTSimulator> pmtSimulator;
258 std::unique_ptr<JCLBSimulator> clbSimulator;
259 };
260}
261
262#endif
Data structure for detector geometry and calibration.
Exceptions.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Direct access to PMT in detector data structure.
Interface for CLB simulation.
Data structure for time calibration.
const JCalibration & getCalibration() const
Get calibration.
std::unique_ptr< JPMTSimulator > pmtSimulator
const JCLBSimulator & getCLBSimulator() const
Get CLB simulator.
virtual void operator()(const JModule &module, JModuleData &input, JDAQSuperFrame &output) const
Process module data in one step.
void reset(JCLBSimulator *clbSimulator)
Reset CLB simulator.
virtual void generateHits(const JModule &module, const JTimeRange &period, JModuleData &output) const override
Generate hits.
JDetectorSimulator(const JDetector &detector)
Constructor.
JDetectorSimulator & operator=(const JDetectorSimulator &)
Make assignment operator inaccesible.
void reset(JK40Simulator *k40Simulator)
Reset K40 simulator.
const JK40Simulator & getK40Simulator() const
Get K40 simulator.
bool hasPMTSimulator() const
Check availability of PMT simulator.
const JPMTSimulator & getPMTSimulator() const
Get PMT simulator.
void reset(JPMTSimulator *pmtSimulator)
Reset PMT simulator.
JDetectorSimulator(const JDetectorSimulator &)
Make copy constructor inaccesible.
bool hasK40Simulator() const
Check availability of K40 simulator.
bool hasCLBSimulator() const
Check availability of CLB simulator.
virtual void processData(const JModuleIdentifier &id, const JCLBInput &input, JDAQSuperFrame &output) const override
Process data.
std::unique_ptr< JCLBSimulator > clbSimulator
std::unique_ptr< JK40Simulator > k40Simulator
virtual void processHits(const JPMTIdentifier &ID, const JCalibration &calibration, const JStatus &status, const JPMTData< JPMTSignal > &input, JPMTData< JPMTPulse > &output) const override
Process hits.
Detector data structure.
Definition JDetector.hh:96
Interface for simulation of K40 background.
Data structure for PMT data corresponding to a detector module.
Data structure for a composite optical module.
Definition JModule.hh:76
Router for direct addressing of PMT data in detector data structure.
Definition JPMTRouter.hh:37
Interface for PMT simulation.
Data structure for PMT geometry, calibration and status.
Definition JPMT.hh:49
Auxiliary class for object identification.
Definition JObjectID.hh:25
Exception for accessing an invalid pointer.
Template definition of a multi-dimensional oscillation probability interpolation table.
Data frame of one optical module.
file Auxiliary data structures and methods for detector calibration.
Definition JAnchor.hh:12
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Calibration.
Definition JHead.hh:330
Detector file.
Definition JHead.hh:227
Auxiliary class for handling status.
Definition JStatus.hh:31
status_type getStatus(const JType< status_type > &type) const
Get status.
Definition JStatus.hh:60