Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JEventTimeslice.hh
Go to the documentation of this file.
1#ifndef __JTIMESLICE__JEVENTTIMESLICE__
2#define __JTIMESLICE__JEVENTTIMESLICE__
3
4#include <exception>
5#include <map>
6
13
15
20
22
23
24/**
25 * \author mdejong
26 */
27
28namespace KM3NETDAQ {
29
32
33
34 /**
35 * Timeslice with Monte Carlo event.
36 */
38 public JTimesliceL0
39 {
40 /**
41 * Constructor.
42 *
43 * This constructor converts the Monte Carlo event to a DAQ timeslice.
44 * In this, both the PMT and CLB simulations are applied.
45 * If the K40 simulator is available and the given time window is valid,
46 * the K40 background is generated and added to the time slice data.
47 * N.B. The given time window extends the time range of hits in the event, if any.
48 *
49 *
50 * \param chronometer chronometer
51 * \param simbad detector simulator
52 * \param event Monte Carlo event
53 * \param period time window [ns]
54 */
55 JEventTimeslice(const JDAQChronometer& chronometer,
56 const JDetectorSimulator& simbad,
57 const Evt& event,
58 const JTimeRange& period = JTimeRange::DEFAULT_RANGE())
59 {
60 using namespace std;
61 using namespace JPP;
62
63 setDAQChronometer(chronometer);
64
65
66 if (simbad.hasPMTSimulator() &&
67 simbad.hasCLBSimulator()) {
68
69 const time_converter converter(event, chronometer);
70
71 const JTimeRange timeRange = (period.is_valid() ? getTimeRange(event, period) : getTimeRange(event));
72
73 typedef map<int, JModuleData> JMap_t; // map module index to data
74
75 JMap_t data;
76
77 for (vector<Hit>::const_iterator hit = event.mc_hits.begin(); hit != event.mc_hits.end(); ++hit) {
78
79 if (simbad.hasPMT(hit->pmt_id)) {
80
81 const JPMTAddress& address = simbad.getAddress(hit->pmt_id);
82
83 if (!period.is_valid() || timeRange(getTime(*hit))) {
84
85 if (!simbad.getModule(address).has(MODULE_OUT_OF_SYNC) &&
86 !simbad.getPMT (address).has(OUT_OF_SYNC)) {
87
88 data[address.first].resize(NUMBER_OF_PMTS);
89
90 data[address.first][address.second].push_back(JPMTSignal(converter.putTime(getTime(*hit)), (int) getNPE(*hit)));
91 }
92 }
93 }
94 }
95
96
97 if (simbad.hasK40Simulator() && period.is_valid()) {
98
99
101
102 for (JMap_t::const_iterator i = data.begin(); i != data.end(); ++i) {
103 time_range.combine(getTimeRange(i->second));
104 }
105
106 time_range.add(period);
107
108
109 JModuleData buffer;
110
111 for (JDetector::const_iterator module = simbad->begin(); module != simbad->end(); ++module) {
112
113 if (!module->empty()) {
114
115 // signal
116
117 JMap_t::iterator i = data.find(distance(simbad->begin(),module));
118
119 if (i != data.end())
120 buffer.swap(i->second);
121 else
122 buffer.reset(module->size());
123
124 // background
125
126 simbad.generateHits(*module, time_range, buffer);
127
128 this->push_back(JDAQSuperFrame(JDAQSuperFrameHeader(chronometer, module->getID())));
129
130 simbad(*module, buffer, *(this->rbegin()));
131 }
132 }
133
134 } else {
135
136 for (JMap_t::iterator i = data.begin(); i != data.end(); ++i) {
137
138 const JModule& module = simbad.getModule(JModuleAddress(i->first));
139
140 this->push_back(JDAQSuperFrame(JDAQSuperFrameHeader(chronometer, module.getID())));
141
142 simbad(module, i->second, *(this->rbegin()));
143 }
144 }
145 }
146 }
147 };
148}
149
150#endif
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
KM3NeT DAQ constants, bit handling, etc.
Auxiliaries for creation of time slice data.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
virtual void generateHits(const JModule &module, const JTimeRange &period, JModuleData &output) const override
Generate hits.
bool hasPMTSimulator() const
Check availability of PMT simulator.
bool hasK40Simulator() const
Check availability of K40 simulator.
bool hasCLBSimulator() const
Check availability of CLB simulator.
Address of module in detector data structure.
int first
index of module in detector data structure
Data structure for PMT data corresponding to a detector module.
void reset(size_t size)
Reset buffers.
Data structure for a composite optical module.
Definition JModule.hh:75
bool has(const int bit) const
Test PMT status.
Definition JStatus.hh:120
Address of PMT in detector data structure.
int second
index of PMT in module data structure.
bool hasPMT(const JObjectID &id) const
Has PMT.
const JPMT & getPMT(const JPMTAddress &address) const
Get PMT.
Definition JPMTRouter.hh:92
const JModule & getModule(const JModuleAddress &address) const
Get module.
const JPMTAddress & getAddress(const JObjectID &id) const
Get address of PMT.
Definition JPMTRouter.hh:80
int getID() const
Get identifier.
Definition JObjectID.hh:50
static JRange< double, std::less< double > > DEFAULT_RANGE()
Definition JRange.hh:555
range_type & combine(const range_type &range)
Combine ranges.
Definition JRange.hh:432
range_type & add(argument_type x)
Add offset.
Definition JRange.hh:446
void setDAQChronometer(const JDAQChronometer &chronometer)
Set DAQ chronometer.
Data frame of one optical module.
Auxiliary class to convert DAQ hit time to/from Monte Carlo hit time.
double putTime() const
Get Monte Carlo time minus DAQ/trigger time.
static const int MODULE_OUT_OF_SYNC
Enable (disable) synchronous signal from this module if this status bit is 0 (1);.
JTimeRange getTimeRange(const Evt &event)
Get time range (i.e. time between earliest and latest hit) of Monte Carlo event.
double getNPE(const Hit &hit)
Get true charge of hit.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const char * getTime()
Get current local time conform ISO-8601 standard.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
static const int OUT_OF_SYNC
Enable (disable) synchronous signal from this PMT if this status bit is 0 (1);.
Definition pmt_status.hh:17
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
std::vector< Hit > mc_hits
MC: list of MC truth hits.
Definition Evt.hh:48
Data structure for PMT analogue signal.
bool has(const int bit) const
Test PMT status.
Definition JStatus.hh:120
Timeslice with Monte Carlo event.
JEventTimeslice(const JDAQChronometer &chronometer, const JDetectorSimulator &simbad, const Evt &event, const JTimeRange &period=JTimeRange::DEFAULT_RANGE())
Constructor.
Base class class for generation of time slice data.
Auxiliary include file for time conversion between DAQ/trigger hit and Monte Carlo hit.