Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
KM3NETDAQ::JEventTimeslice Struct Reference

Timeslice with Monte Carlo event. More...

#include <JEventTimeslice.hh>

Inheritance diagram for KM3NETDAQ::JEventTimeslice:
KM3NETDAQ::JTimesliceL0 KM3NETDAQ::JDAQTimesliceL0 KM3NETDAQ::JDAQTimeslice KM3NETDAQ::JDAQPreamble KM3NETDAQ::JDAQTimesliceHeader std::vector< JDAQSuperFrame > KM3NETDAQ::JDAQAbstractPreamble TObject KM3NETDAQ::JDAQHeader KM3NETDAQ::JDAQChronometer

Public Member Functions

 JEventTimeslice (const JDAQChronometer &chronometer, const JDetectorSimulator &simbad, const Evt &event, const JTimeRange &period=JTimeRange::DEFAULT_RANGE())
 Constructor.
 
 ClassDef (JDAQTimesliceL0, 1)
 
 ClassDef (JDAQTimeslice, 4)
 
 ClassDef (JDAQPreamble, 1)
 
 ClassDef (JDAQTimesliceHeader, 2)
 
 ClassDef (JDAQHeader, 2)
 
 ClassDef (JDAQChronometer, 3)
 
void clear ()
 Clear data.
 
JDAQTimesliceadd (const JDAQTimeslice &timeslice)
 Add another timeslice.
 
std::ostream & print (std::ostream &out, const bool lpr=false) const
 Print DAQ Timeslice.
 
int getLength () const
 Get length.
 
int getDataType () const
 Get data type.
 
 ClassDefNV (JDAQAbstractPreamble, 1)
 
const JDAQTimesliceHeadergetDAQTimesliceHeader () const
 Get DAQ time slice header.
 
const JDAQHeadergetDAQHeader () const
 Get DAQ header.
 
void setDAQHeader (const JDAQHeader &header)
 Set DAQ header.
 
const JDAQChronometergetDAQChronometer () const
 Get DAQ chronometer.
 
void setDAQChronometer (const JDAQChronometer &chronometer)
 Set DAQ chronometer.
 
int getDetectorID () const
 Get detector identifier.
 
int getRunNumber () const
 Get run number.
 
int getFrameIndex () const
 Get frame index.
 
JDAQUTCExtended getTimesliceStart () const
 Get start of timeslice.
 
void setRunNumber (const int run)
 Set run number.
 
void setFrameIndex (const int frame_index)
 Set frame index.
 
void setTimesliceStart (const JDAQUTCExtended &timeslice_start)
 Set timeslice start time.
 

Static Public Member Functions

template<class T >
static JDAQPreamble getDAQPreamble (const T &object)
 Get DAQ preamble.
 

Protected Attributes

int length
 
int type
 
int detector_id
 
int run
 
int frame_index
 
JDAQUTCExtended timeslice_start
 

Detailed Description

Timeslice with Monte Carlo event.

Definition at line 37 of file JEventTimeslice.hh.

Constructor & Destructor Documentation

◆ JEventTimeslice()

KM3NETDAQ::JEventTimeslice::JEventTimeslice ( const JDAQChronometer & chronometer,
const JDetectorSimulator & simbad,
const Evt & event,
const JTimeRange & period = JTimeRange::DEFAULT_RANGE() )
inline

Constructor.

This constructor converts the Monte Carlo event to a DAQ timeslice. In this, both the PMT and CLB simulations are applied. If the K40 simulator is available and the given time window is valid, the K40 background is generated and added to the time slice data. N.B. The given time window extends the time range of hits in the event, if any.

Parameters
chronometerchronometer
simbaddetector simulator
eventMonte Carlo event
periodtime window [ns]

Definition at line 55 of file JEventTimeslice.hh.

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 }
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
bool is_valid() const
Check validity of range.
Definition JRange.hh:311
static JRange< double, std::less< double > > DEFAULT_RANGE()
Definition JRange.hh:555
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.
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.
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
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

Member Function Documentation

◆ ClassDef() [1/6]

KM3NETDAQ::JDAQTimesliceL0::ClassDef ( JDAQTimesliceL0 ,
1  )
inherited

◆ ClassDef() [2/6]

KM3NETDAQ::JDAQTimeslice::ClassDef ( JDAQTimeslice ,
4  )
inherited

◆ ClassDef() [3/6]

KM3NETDAQ::JDAQPreamble::ClassDef ( JDAQPreamble ,
1  )
inherited

◆ ClassDef() [4/6]

KM3NETDAQ::JDAQTimesliceHeader::ClassDef ( JDAQTimesliceHeader ,
2  )
inherited

◆ ClassDef() [5/6]

KM3NETDAQ::JDAQHeader::ClassDef ( JDAQHeader ,
2  )
inherited

◆ ClassDef() [6/6]

KM3NETDAQ::JDAQChronometer::ClassDef ( JDAQChronometer ,
3  )
inherited

◆ clear()

void KM3NETDAQ::JDAQTimeslice::clear ( )
inlineinherited

Clear data.

Definition at line 97 of file JDAQTimeslice.hh.

98 {
99 for (iterator i = this->begin(); i != this->end(); ++i) {
100 i->clear();
101 }
102
104 }

◆ add()

JDAQTimeslice & KM3NETDAQ::JDAQTimeslice::add ( const JDAQTimeslice & timeslice)
inlineinherited

Add another timeslice.

Parameters
timeslicetimeslice
Returns
this timeslice

Definition at line 133 of file JDAQTimeslice.hh.

134 {
135 using namespace std;
136
138
139 for (const_iterator i = this->begin(); i != this->end(); ++i) {
140 buffer[i->getModuleIdentifier()] = distance(static_cast<const JDAQTimeslice&>(*this).begin(),i);
141 }
142
143 for (JDAQTimeslice::const_iterator i = timeslice.begin(); i != timeslice.end(); ++i) {
144
145 map<JDAQModuleIdentifier, int>::const_iterator p = buffer.find(i->getModuleIdentifier());
146
147 if (p != buffer.end()) {
148
149 JDAQSuperFrame& frame = this->at(p->second);
150
151 frame.add(*i);
152
153 sort(frame.begin(), frame.end());
154
155 } else {
156
157 this->push_back(*i);
158 }
159 }
160
161 return *this;
162 }
const_iterator end() const
Definition JDAQFrame.hh:166
const_iterator begin() const
Definition JDAQFrame.hh:165
JDAQSuperFrame & add(const JDAQSuperFrame &super_frame)
Add data from same optical module.

◆ print()

std::ostream & KM3NETDAQ::JDAQTimeslice::print ( std::ostream & out,
const bool lpr = false ) const
inlineinherited

Print DAQ Timeslice.

Parameters
outoutput stream
lprlong print
Returns
output stream

Definition at line 172 of file JDAQTimeslice.hh.

173 {
174 using namespace std;
175
176 out << this->ClassName() << endl;
177 out << dynamic_cast<const JDAQPreamble&> (*this) << endl;
178 out << dynamic_cast<const JDAQChronometer&>(*this) << endl;
179
180 for (JDAQTimeslice::const_iterator frame = this->begin(); frame != this->end(); ++frame) {
181
182 out << ' ' << setw(10) << frame->getModuleID();
183 out << ' ' << setw(6) << frame->getLength();
184 out << ' ' << setw(6) << frame->getDataType();
185 out << ' ' << setw(6) << frame->getTimesliceStart();
186 out << ' ' << setw(8) << setfill('0') << hex << frame->getStatus() << dec << setfill(' ');
187 out << '|' << setw(8) << setfill('0') << hex << frame->getFIFOStatus() << dec << setfill(' ');
188 out << ' ' << setw(2) << frame->getUDPNumberOfReceivedPackets();
189 out << '/' << setw(2) << frame->getUDPMaximalSequenceNumber();
190 out << ' ' << setw(6) << frame->size();
191
192 if (!lpr) {
193
194 if (!frame->empty()) {
195
196 out << ' ' << setw(10) << frame-> begin()->getT();
197 out << " ... ";
198 out << ' ' << setw(10) << frame->rbegin()->getT();
199 }
200
201 out << endl;
202
203 } else {
204
205 out << endl;
206
207 int n = 1;
208
209 for (JDAQFrame::const_iterator hit = frame->begin(); hit != frame->end(); ++hit, ++n) {
210 out << setw(2) << (int) hit->getPMT() << ' '
211 << setw(8) << (int) hit->getT() << ' '
212 << setw(3) << (int) hit->getToT() << (n%10 == 0 ? '\n' : ' ');
213 }
214
215 out << endl;
216 }
217 }
218
219 return out;
220 }
Hit data structure.
Definition JDAQHit.hh:35
const int n
Definition JPolint.hh:791

◆ getDAQPreamble()

template<class T >
static JDAQPreamble KM3NETDAQ::JDAQPreamble::getDAQPreamble ( const T & object)
inlinestaticinherited

Get DAQ preamble.

This method should be used for binary I/O to get the actual data for the given object.
To this end, the following method should be overloaded for the corresponding data type.

   size_t  getSizeof(const T&);
Parameters
objectobject
Returns
preamble

Definition at line 76 of file JDAQPreamble.hh.

77 {
78 static JDAQPreamble preamble;
79
80 preamble.length = getSizeof(object);
82
83 return preamble;
84 }
friend size_t getSizeof()
Definition of method to get size of data type.
int getDataType()
Template definition for method returning data type.

◆ getLength()

int KM3NETDAQ::JDAQAbstractPreamble::getLength ( ) const
inlineinherited

Get length.

Returns
number of bytes

Definition at line 49 of file JDAQAbstractPreamble.hh.

50 {
51 return length;
52 }

◆ getDataType()

int KM3NETDAQ::JDAQAbstractPreamble::getDataType ( ) const
inlineinherited

Get data type.

Returns
data type

Definition at line 60 of file JDAQAbstractPreamble.hh.

61 {
62 return type;
63 }

◆ ClassDefNV()

KM3NETDAQ::JDAQAbstractPreamble::ClassDefNV ( JDAQAbstractPreamble ,
1  )
inherited

◆ getDAQTimesliceHeader()

const JDAQTimesliceHeader & KM3NETDAQ::JDAQTimesliceHeader::getDAQTimesliceHeader ( ) const
inlineinherited

Get DAQ time slice header.

Returns
DAQ time slice header

Definition at line 43 of file JDAQTimesliceHeader.hh.

44 {
45 return static_cast<const JDAQTimesliceHeader&>(*this);
46 }

◆ getDAQHeader()

const JDAQHeader & KM3NETDAQ::JDAQHeader::getDAQHeader ( ) const
inlineinherited

Get DAQ header.

Returns
DAQ header

Definition at line 49 of file JDAQHeader.hh.

50 {
51 return static_cast<const JDAQHeader&>(*this);
52 }

◆ setDAQHeader()

void KM3NETDAQ::JDAQHeader::setDAQHeader ( const JDAQHeader & header)
inlineinherited

Set DAQ header.

Parameters
headerDAQ header

Definition at line 60 of file JDAQHeader.hh.

61 {
62 static_cast<JDAQHeader&>(*this) = header;
63 }

◆ getDAQChronometer()

const JDAQChronometer & KM3NETDAQ::JDAQChronometer::getDAQChronometer ( ) const
inlineinherited

Get DAQ chronometer.

Returns
DAQ chronometer

Definition at line 88 of file JDAQChronometer.hh.

89 {
90 return static_cast<const JDAQChronometer&>(*this);
91 }

◆ setDAQChronometer()

void KM3NETDAQ::JDAQChronometer::setDAQChronometer ( const JDAQChronometer & chronometer)
inlineinherited

Set DAQ chronometer.

Parameters
chronometerDAQ chronometer

Definition at line 99 of file JDAQChronometer.hh.

100 {
101 static_cast<JDAQChronometer&>(*this) = chronometer;
102 }

◆ getDetectorID()

int KM3NETDAQ::JDAQChronometer::getDetectorID ( ) const
inlineinherited

Get detector identifier.

Returns
detector identifier

Definition at line 110 of file JDAQChronometer.hh.

111 {
112 return detector_id;
113 }

◆ getRunNumber()

int KM3NETDAQ::JDAQChronometer::getRunNumber ( ) const
inlineinherited

Get run number.

Returns
run number

Definition at line 121 of file JDAQChronometer.hh.

122 {
123 return run;
124 }

◆ getFrameIndex()

int KM3NETDAQ::JDAQChronometer::getFrameIndex ( ) const
inlineinherited

Get frame index.

Returns
frame index

Definition at line 132 of file JDAQChronometer.hh.

133 {
134 return frame_index;
135 }

◆ getTimesliceStart()

JDAQUTCExtended KM3NETDAQ::JDAQChronometer::getTimesliceStart ( ) const
inlineinherited

Get start of timeslice.

Returns
timeslice start

Definition at line 144 of file JDAQChronometer.hh.

145 {
146 return timeslice_start;
147 }

◆ setRunNumber()

void KM3NETDAQ::JDAQChronometer::setRunNumber ( const int run)
inlineinherited

Set run number.

Parameters
runrun number

Definition at line 155 of file JDAQChronometer.hh.

156 {
157 this->run = run;
158 }

◆ setFrameIndex()

void KM3NETDAQ::JDAQChronometer::setFrameIndex ( const int frame_index)
inlineinherited

Set frame index.

Parameters
frame_indexframe index

Definition at line 166 of file JDAQChronometer.hh.

167 {
168 this->frame_index = frame_index;
169 }

◆ setTimesliceStart()

void KM3NETDAQ::JDAQChronometer::setTimesliceStart ( const JDAQUTCExtended & timeslice_start)
inlineinherited

Set timeslice start time.

Parameters
timeslice_starttimeslice start time

Definition at line 177 of file JDAQChronometer.hh.

178 {
179 this->timeslice_start = timeslice_start;
180 }

Member Data Documentation

◆ length

int KM3NETDAQ::JDAQAbstractPreamble::length
protectedinherited

Definition at line 69 of file JDAQAbstractPreamble.hh.

◆ type

int KM3NETDAQ::JDAQAbstractPreamble::type
protectedinherited

Definition at line 70 of file JDAQAbstractPreamble.hh.

◆ detector_id

int KM3NETDAQ::JDAQChronometer::detector_id
protectedinherited

Definition at line 187 of file JDAQChronometer.hh.

◆ run

int KM3NETDAQ::JDAQChronometer::run
protectedinherited

Definition at line 188 of file JDAQChronometer.hh.

◆ frame_index

int KM3NETDAQ::JDAQChronometer::frame_index
protectedinherited

Definition at line 189 of file JDAQChronometer.hh.

◆ timeslice_start

JDAQUTCExtended KM3NETDAQ::JDAQChronometer::timeslice_start
protectedinherited

Definition at line 190 of file JDAQChronometer.hh.


The documentation for this struct was generated from the following file: