Jpp 19.3.0-rc.1
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
10#include "JLang/JException.hh"
11
12
13/**
14 * \author mdejong
15 */
16
17namespace JDETECTOR {}
18namespace JPP { using namespace JDETECTOR; }
19
20namespace JDETECTOR {
21
23
24
25 /**
26 * Detector simulation.
27 *
28 * This class implements the JK40Simulator, JPMTSimulator and JCLBSimulator interfaces.
29 * The implementations of these interfaces should be provided via pointers to corresponding objects.
30 *
31 * N.B: This class owns the objects pointed to using class JLANG::JSinglePointer.
32 */
34 public JPMTRouter,
35 public JK40Simulator,
36 public JPMTSimulator,
37 public JCLBSimulator
38 {
39 private:
40 /**
41 * Make copy constructor inaccesible.
42 */
44
45
46 /**
47 * Make assignment operator inaccesible
48 */
50
51
52 public:
53 /**
54 * Constructor.
55 *
56 * \param detector detector
57 */
61
62
63 /**
64 * Check availability of K40 simulator.
65 *
66 * \return true if simulator available; else false
67 */
68 bool hasK40Simulator() const
69 {
70 return k40Simulator.get() != NULL;
71 }
72
73
74
75 /**
76 * Check availability of PMT simulator.
77 *
78 * \return true if simulator available; else false
79 */
80 bool hasPMTSimulator() const
81 {
82 return pmtSimulator.get() != NULL;
83 }
84
85
86 /**
87 * Check availability of CLB simulator.
88 *
89 * \return true if simulator available; else false
90 */
91 bool hasCLBSimulator() const
92 {
93 return clbSimulator.get() != NULL;
94 }
95
96
97 /**
98 * Get K40 simulator.
99 *
100 * \return K40 simulator
101 */
103 {
104 if (hasK40Simulator())
105 return *k40Simulator;
106 else
107 THROW(JPointerException, "JDetectorSimulator: K40 simulator not avaliable.");
108 }
109
110
111 /**
112 * Get PMT simulator.
113 *
114 * \return PMT simulator
115 */
117 {
118 if (hasPMTSimulator())
119 return *pmtSimulator;
120 else
121 THROW(JPointerException, "JDetectorSimulator: PMT simulator not avaliable.");
122 }
123
124
125 /**
126 * Get CLB simulator.
127 *
128 * \return CLB simulator
129 */
131 {
132 if (hasCLBSimulator())
133 return *clbSimulator;
134 else
135 THROW(JPointerException, "JDetectorSimulator: CLB simulator not avaliable.");
136 }
137
138
139 /**
140 * Reset K40 simulator.
141 *
142 * \param k40Simulator K40 simulator
143 */
145 {
146 this->k40Simulator.reset(k40Simulator);
147 }
148
149
150
151 /**
152 * Reset PMT simulator.
153 *
154 * \param pmtSimulator PMT simulator
155 */
157 {
158 this->pmtSimulator.reset(pmtSimulator);
159 }
160
161
162 /**
163 * Reset CLB simulator.
164 *
165 * \param clbSimulator CLB simulator
166 */
168 {
169 this->clbSimulator.reset(clbSimulator);
170 }
171
172
173 /**
174 * Generate hits.
175 *
176 * \param module module
177 * \param period time window [ns]
178 * \param output background data
179 */
180 virtual void generateHits(const JModule& module,
181 const JTimeRange& period,
182 JModuleData& output) const override
183 {
184 getK40Simulator().generateHits(module, period, output);
185 }
186
187
188 /**
189 * Process hits.
190 *
191 * \param ID PMT identifier
192 * \param calibration PMT calibration
193 * \param status PMT status
194 * \param input PMT signals
195 * \param output PMT hits
196 */
197 virtual void processHits(const JPMTIdentifier& ID,
199 const JStatus& status,
200 const JPMTData<JPMTSignal>& input,
201 JPMTData<JPMTPulse>& output) const override
202 {
203 getPMTSimulator().processHits(ID, calibration, status, input, output);
204 }
205
206
207 /**
208 * Process data.
209 *
210 * \param id module identifier
211 * \param input PMT data
212 * \param output CLB data
213 */
214 virtual void processData(const JModuleIdentifier& id, const JCLBInput& input, JDAQSuperFrame& output) const override
215 {
216 getCLBSimulator().processData(id, input, output);
217 }
218
219
220 /**
221 * Process module data in one step.
222 *
223 * \param module module
224 * \param input PMT signals
225 * \param output CLB data
226 */
227 virtual void operator()(const JModule& module,
228 JModuleData& input,
229 JDAQSuperFrame& output) const
230 {
231 // PMT simulation
232
233 buffer.reset(input.size());
234
235 for (unsigned int i = 0; i != input.size(); ++i) {
236
237 input[i].sort();
238
239 const JPMT& pmt = module.getPMT(i);
240
241 processHits(JPMTIdentifier(module.getID(), i),
242 pmt.getCalibration(),
243 pmt.getStatus(),
244 input [i],
245 buffer[i]);
246 }
247
248 // CLB simulation
249
250 processData(module, buffer, output);
251 }
252
253
254 protected:
258
259 private:
261 };
262}
263
264#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.
virtual void processData(const JModuleIdentifier &id, const JCLBInput &input, JDAQSuperFrame &output) const =0
Process data.
Data structure for time calibration.
const JCalibration & getCalibration() const
Get calibration.
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.
JLANG::JSinglePointer< JK40Simulator > k40Simulator
virtual void generateHits(const JModule &module, const JTimeRange &period, JModuleData &output) const override
Generate hits.
JLANG::JSinglePointer< JCLBSimulator > clbSimulator
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.
JLANG::JSinglePointer< JPMTSimulator > pmtSimulator
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.
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.
virtual void generateHits(const JModule &module, const JTimeRange &period, JModuleData &output) const =0
Generate hits.
Data structure for PMT data corresponding to a detector module.
Data structure for a composite optical module.
Definition JModule.hh:75
Template data structure for PMT I/O.
Router for direct addressing of PMT data in detector data structure.
Definition JPMTRouter.hh:37
Interface for PMT simulation.
virtual void processHits(const JPMTIdentifier &id, const JCalibration &calibration, const JStatus &status, const JPMTData< JPMTSignal > &input, JPMTData< JPMTPulse > &output) const =0
Process hits.
Data structure for PMT geometry, calibration and status.
Definition JPMT.hh:49
Auxiliary class for object identification.
Definition JObjectID.hh:25
int getID() const
Get identifier.
Definition JObjectID.hh:50
Exception for accessing an invalid pointer.
The template JSinglePointer class can be used to hold a pointer to an object.
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
Wrapper for CLB input.
void reset(size_t size)
Reset CLB buffers.
Auxiliary class for handling status.
Definition JStatus.hh:39
int getStatus() const
Get status.
Definition JStatus.hh:63