Jpp  15.0.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
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. More...
 
 ClassDef (JDAQTimesliceL0, 1)
 
 ClassDef (JDAQTimeslice, 4)
 
 ClassDef (JDAQPreamble, 1)
 
 ClassDef (JDAQTimesliceHeader, 2)
 
 ClassDef (JDAQHeader, 2)
 
 ClassDef (JDAQChronometer, 3)
 
void clear ()
 Clear data. More...
 
JDAQTimesliceadd (const JDAQTimeslice &timeslice)
 Add another timeslice. More...
 
std::ostream & print (std::ostream &out, const bool lpr=false) const
 Print DAQ Timeslice. More...
 
int getLength () const
 Get length. More...
 
int getDataType () const
 Get data type. More...
 
 ClassDefNV (JDAQAbstractPreamble, 1)
 
const JDAQTimesliceHeadergetDAQTimesliceHeader () const
 Get DAQ time slice header. More...
 
const JDAQHeadergetDAQHeader () const
 Get DAQ header. More...
 
void setDAQHeader (const JDAQHeader &header)
 Set DAQ header. More...
 
const JDAQChronometergetDAQChronometer () const
 Get DAQ chronometer. More...
 
void setDAQChronometer (const JDAQChronometer &chronometer)
 Set DAQ chronometer. More...
 
int getDetectorID () const
 Get detector identifier. More...
 
int getRunNumber () const
 Get run number. More...
 
int getFrameIndex () const
 Get frame index. More...
 
JDAQUTCExtended getTimesliceStart () const
 Get start of timeslice. More...
 
void setRunNumber (const int run)
 Set run number. More...
 
void setFrameIndex (const int frame_index)
 Set frame index. More...
 
void setTimesliceStart (const JDAQUTCExtended &timeslice_start)
 Set timeslice start time. More...
 

Static Public Member Functions

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

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

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  }
static const JRange< double, std::less< double > > DEFAULT_RANGE
Default range.
Definition: JRange.hh:568
void reset(size_t size)
Reset buffers.
Data structure for PMT analogue signal.
Data structure for a composite optical module.
Definition: JModule.hh:68
Data structure for PMT data corresponding to a detector module.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
int second
index of PMT in module data structure.
Definition: JPMTAddress.hh:100
bool hasPMT(const JObjectID &id) const
Has PMT.
Definition: JPMTRouter.hh:114
const JPMT & getPMT(const JPMTAddress &address) const
Get PMT.
Definition: JPMTRouter.hh:90
Auxiliary class to convert DAQ hit time to/from Monte Carlo hit time.
double getTime(const Hit &hit)
Get true time of hit.
const JModule & getModule(const JModuleAddress &address) const
Get module.
Definition: JPMTRouter.hh:150
JTimeRange getTimeRange(const Evt &event)
Get time range (i.e. time between earliest and latest hit) of Monte Carlo event.
virtual void generateHits(const JModule &module, const JTimeRange &period, JModuleData &output) const
Generate hits.
int first
index of module in detector data structure
bool hasPMTSimulator() const
Check availability of PMT simulator.
bool has(const int bit) const
Test PMT status.
Definition: JStatus.hh:108
int getID() const
Get identifier.
Definition: JObjectID.hh:50
void setDAQChronometer(const JDAQChronometer &chronometer)
Set DAQ chronometer.
Address of module in detector data structure.
bool hasK40Simulator() const
Check availability of K40 simulator.
bool hasCLBSimulator() const
Check availability of CLB simulator.
bool is_valid() const
Check validity of range.
Definition: JRange.hh:311
Address of PMT in detector data structure.
Definition: JPMTAddress.hh:32
std::vector< Hit > mc_hits
MC: list of MC truth hits.
Definition: Evt.hh:45
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
static const int MODULE_OUT_OF_SYNC
Enable (disable) synchronous signal from this module if this status bit is 0 (1);.
double getNPE(const Hit &hit)
Get true charge of hit.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
Data frame of one optical module.
const JPMTAddress & getAddress(const JObjectID &id) const
Get address of PMT.
Definition: JPMTRouter.hh:78

Member Function Documentation

KM3NETDAQ::JDAQTimesliceL0::ClassDef ( JDAQTimesliceL0  ,
 
)
inherited
KM3NETDAQ::JDAQTimeslice::ClassDef ( JDAQTimeslice  ,
 
)
inherited
KM3NETDAQ::JDAQPreamble::ClassDef ( JDAQPreamble  ,
 
)
inherited
KM3NETDAQ::JDAQTimesliceHeader::ClassDef ( JDAQTimesliceHeader  ,
 
)
inherited
KM3NETDAQ::JDAQHeader::ClassDef ( JDAQHeader  ,
 
)
inherited
KM3NETDAQ::JDAQChronometer::ClassDef ( JDAQChronometer  ,
 
)
inherited
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  }
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  }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
const_iterator begin() const
Definition: JDAQFrame.hh:136
Data frame of one optical module.
JDAQSuperFrame & add(const JDAQSuperFrame &super_frame)
Add data from same optical module.
const_iterator end() const
Definition: JDAQFrame.hh:137
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(6) << frame->size();
189 
190  if (!lpr) {
191 
192  if (!frame->empty()) {
193 
194  out << ' ' << setw(10) << frame-> begin()->getT();
195  out << " ... ";
196  out << ' ' << setw(10) << frame->rbegin()->getT();
197  }
198 
199  out << endl;
200 
201  } else {
202 
203  out << endl;
204 
205  int n = 1;
206 
207  for (JDAQFrame::const_iterator hit = frame->begin(); hit != frame->end(); ++hit, ++n) {
208  out << setw(2) << (int) hit->getPMT() << ' '
209  << setw(8) << (int) hit->getT() << ' '
210  << setw(3) << (int) hit->getToT() << (n%10 == 0 ? '\n' : ' ');
211  }
212 
213  out << endl;
214  }
215  }
216 
217  return out;
218  }
const int n
Definition: JPolint.hh:660
Hit data structure.
Definition: JDAQHit.hh:34
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);
81  preamble.type = KM3NETDAQ::getDataType<T>();
82 
83  return preamble;
84  }
friend size_t getSizeof()
Definition of method to get size of data type.
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  }
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  }
KM3NETDAQ::JDAQAbstractPreamble::ClassDefNV ( JDAQAbstractPreamble  ,
 
)
inherited
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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

int KM3NETDAQ::JDAQAbstractPreamble::length
protectedinherited

Definition at line 69 of file JDAQAbstractPreamble.hh.

int KM3NETDAQ::JDAQAbstractPreamble::type
protectedinherited

Definition at line 70 of file JDAQAbstractPreamble.hh.

int KM3NETDAQ::JDAQChronometer::detector_id
protectedinherited

Definition at line 187 of file JDAQChronometer.hh.

int KM3NETDAQ::JDAQChronometer::run
protectedinherited

Definition at line 188 of file JDAQChronometer.hh.

int KM3NETDAQ::JDAQChronometer::frame_index
protectedinherited

Definition at line 189 of file JDAQChronometer.hh.

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: