Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Public Attributes | Protected Attributes | List of all members
JDETECTOR::JPMTDefaultSimulator Class Reference

Default PMT simulation. More...

#include <JPMTDefaultSimulator.hh>

Inheritance diagram for JDETECTOR::JPMTDefaultSimulator:
JDETECTOR::JPMTDefaultSimulatorInterface JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t > JDETECTOR::JPMTSimulator std::vector< std::pair< JKey_t, JValue_t > > JTOOLS::JMappableCollection< JKey_t, JValue_t > JDETECTOR::JPMTRunByRunSimulator

Public Types

typedef JKey_t key_type
 
typedef JValue_t mapped_type
 
typedef std::pair< JKey_t,
JValue_t > 
value_type
 
typedef JEvaluator_t evaluator_type
 
typedef std::vector< value_typecontainer_type
 
typedef
container_type::const_iterator 
const_iterator
 
typedef
container_type::const_reverse_iterator 
const_reverse_iterator
 
typedef container_type::iterator iterator
 
typedef
container_type::reverse_iterator 
reverse_iterator
 
typedef std::pair
< const_iterator, bool > 
pair_type
 

Public Member Functions

 JPMTDefaultSimulator ()
 Default constructor. More...
 
 JPMTDefaultSimulator (const JPMTParametersMap &parameters, const JDetector &detector)
 Constructor. More...
 
 JPMTDefaultSimulator (const JPMTParameters &parameters, const JPMTIdentifier &pmt)
 Constructor. More...
 
virtual const
JPMTSignalProcessorInterface
getPMTSignalProcessor (const JPMTIdentifier &pmt) const
 Get PMT signal processor. More...
 
virtual void processHits (const JPMTIdentifier &id, const JCalibration &calibration, const JPMTData< JPMTSignal > &input, JPMTData< JPMTPulse > &output) const
 Process hits. More...
 
virtual bool getPMTstatus (const JPMTIdentifier &id) const
 Get PMT status. More...
 
virtual void clear ()
 Clear. More...
 
virtual mapped_typeget (typename JClass< key_type >::argument_type key)
 Get mapped value. More...
 
const mapped_typeget (typename JClass< key_type >::argument_type key) const
 Get mapped value. More...
 
pair_type insert (const value_type &element)
 Insert element. More...
 
void erase (iterator pos)
 Erase element at given position. More...
 
void erase (iterator __begin, iterator __end)
 Erase elements in given range. More...
 
bool erase (typename JClass< key_type >::argument_type key) const
 Erase element. More...
 
bool has (typename JClass< key_type >::argument_type key) const
 Test whether key is present. More...
 
const JComparatorgetComparator () const
 Get comparator. More...
 
mapped_typeoperator[] (typename JClass< key_type >::argument_type key)
 Get mapped value. More...
 
void put (typename JClass< key_type >::argument_type key, typename JClass< mapped_type >::argument_type value)
 Put pair-wise element (key,value) into collection. More...
 

Public Attributes

JEvaluator_t getValue
 Function object for evaluation of key. More...
 

Protected Attributes

JComparator compare
 Function object for comparison. More...
 
JRouter< int > router
 

Detailed Description

Default PMT simulation.

This class implements the JPMTDefaultSimulatorInterface interface for a given detector using a map of the PMT parameters.

Definition at line 54 of file JPMTDefaultSimulator.hh.

Member Typedef Documentation

template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
typedef JKey_t JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::key_type
inherited

Definition at line 59 of file JHashMap.hh.

template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
typedef JValue_t JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::mapped_type
inherited

Definition at line 60 of file JHashMap.hh.

template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
typedef std::pair<JKey_t, JValue_t> JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::value_type
inherited

Definition at line 61 of file JHashMap.hh.

template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
typedef JEvaluator_t JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::evaluator_type
inherited

Definition at line 62 of file JHashMap.hh.

template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
typedef std::vector<value_type> JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::container_type
inherited

Definition at line 64 of file JHashMap.hh.

template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
typedef container_type::const_iterator JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::const_iterator
inherited

Definition at line 66 of file JHashMap.hh.

template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
typedef container_type::const_reverse_iterator JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::const_reverse_iterator
inherited

Definition at line 67 of file JHashMap.hh.

template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
typedef container_type::iterator JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::iterator
inherited

Definition at line 68 of file JHashMap.hh.

template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
typedef container_type::reverse_iterator JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::reverse_iterator
inherited

Definition at line 69 of file JHashMap.hh.

template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
typedef std::pair<const_iterator, bool> JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::pair_type
inherited

Definition at line 71 of file JHashMap.hh.

Constructor & Destructor Documentation

JDETECTOR::JPMTDefaultSimulator::JPMTDefaultSimulator ( )
inline

Default constructor.

Definition at line 62 of file JPMTDefaultSimulator.hh.

63  {}
JDETECTOR::JPMTDefaultSimulator::JPMTDefaultSimulator ( const JPMTParametersMap parameters,
const JDetector detector 
)
inline

Constructor.

Parameters
parametersPMT parameters
detectordetector

Definition at line 72 of file JPMTDefaultSimulator.hh.

74  {
75  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
76  for (size_t pmt = 0; pmt != module->size(); ++pmt) {
77  this->get(module->getID()).put(pmt, JPMTAnalogueSignalProcessor(parameters.getPMTParameters(JPMTIdentifier(module->getID(), pmt))));
78  }
79  }
80  }
const JPMTParameters & getPMTParameters(const JPMTIdentifier &id) const
Get PMT parameters.
void put(typename JClass< key_type >::argument_type key, typename JClass< mapped_type >::argument_type value)
Put pair-wise element (key,value) into collection.
JDETECTOR::JPMTDefaultSimulator::JPMTDefaultSimulator ( const JPMTParameters parameters,
const JPMTIdentifier pmt 
)
inline

Constructor.

Parameters
parametersPMT parameters
pmtPMT identifier

Definition at line 89 of file JPMTDefaultSimulator.hh.

91  {
92  this->get(pmt.getID()).put(pmt.getPMTAddress(), JPMTAnalogueSignalProcessor(parameters));
93  }
int getID() const
Get identifier.
Definition: JObjectID.hh:54
int getPMTAddress() const
Get PMT identifier (= TDC).
void put(typename JClass< key_type >::argument_type key, typename JClass< mapped_type >::argument_type value)
Put pair-wise element (key,value) into collection.

Member Function Documentation

virtual const JPMTSignalProcessorInterface& JDETECTOR::JPMTDefaultSimulator::getPMTSignalProcessor ( const JPMTIdentifier pmt) const
inlinevirtual

Get PMT signal processor.

Parameters
pmtPMT identifier
Returns
PMT signal processor

Reimplemented from JDETECTOR::JPMTDefaultSimulatorInterface.

Definition at line 102 of file JPMTDefaultSimulator.hh.

103  {
104  return this->get(pmt.getID())[pmt.getPMTAddress()];
105  }
int getID() const
Get identifier.
Definition: JObjectID.hh:54
int getPMTAddress() const
Get PMT identifier (= TDC).
virtual void JDETECTOR::JPMTDefaultSimulatorInterface::processHits ( const JPMTIdentifier id,
const JCalibration calibration,
const JPMTData< JPMTSignal > &  input,
JPMTData< JPMTPulse > &  output 
) const
inlinevirtualinherited

Process hits.

Parameters
idPMT identifier
calibrationPMT calibration
inputPMT signals
outputPMT hits

Implements JDETECTOR::JPMTSimulator.

Definition at line 36 of file JPMTDefaultSimulatorInterface.hh.

40  {
41  if (getPMTstatus(id)) {
42 
44 
45  cpu(calibration, input, output);
46  }
47  }
virtual bool getPMTstatus(const JPMTIdentifier &id) const
Get PMT status.
virtual const JPMTSignalProcessorInterface & getPMTSignalProcessor(const JPMTIdentifier &pmt) const
Get PMT signal processor.
virtual bool JDETECTOR::JPMTDefaultSimulatorInterface::getPMTstatus ( const JPMTIdentifier id) const
inlinevirtualinherited

Get PMT status.

If PMT status is false, the method processHits does not produce any hits.

Parameters
idPMT identifier
Returns
true

Reimplemented in JDETECTOR::JPMTRunByRunSimulator.

Definition at line 57 of file JPMTDefaultSimulatorInterface.hh.

58  {
59  return true;
60  }
template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
virtual void JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::clear ( )
inlinevirtualinherited

Clear.

Implements JTOOLS::JMappableCollection< JKey_t, JValue_t >.

Definition at line 141 of file JHashMap.hh.

142  {
143  // reset internal router
144 
145  for (iterator i = this->begin(); i != this->end(); ++i) {
146  router.put(this->getValue(i->first), router.getDefaultAddress());
147  }
148 
149  container_type::clear();
150  }
JRouter< int > router
Definition: JHashMap.hh:375
JEvaluator_t getValue
Function object for evaluation of key.
Definition: JHashMap.hh:366
template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
virtual mapped_type& JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::get ( typename JClass< key_type >::argument_type  key)
inlinevirtualinherited

Get mapped value.

Parameters
keykey
Returns
mapped value

Implements JTOOLS::JMappableCollection< JKey_t, JValue_t >.

Definition at line 159 of file JHashMap.hh.

160  {
161  const int ival = this->getValue(key);
162 
163  if (!router.has(ival)) {
164  insert(value_type(key, mapped_type()));
165  }
166 
167  return container_type::operator[](router.get(ival)).second;
168  }
JValue_t mapped_type
Definition: JHashMap.hh:60
JRouter< int > router
Definition: JHashMap.hh:375
JEvaluator_t getValue
Function object for evaluation of key.
Definition: JHashMap.hh:366
std::pair< JKey_t, JValue_t > value_type
Definition: JHashMap.hh:61
pair_type insert(const value_type &element)
Insert element.
Definition: JHashMap.hh:196
template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
const mapped_type& JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::get ( typename JClass< key_type >::argument_type  key) const
inlineinherited

Get mapped value.

This method will throw an exception if given key is not present following the prerequisite of constness.

Parameters
keykey
Returns
mapped value

Definition at line 179 of file JHashMap.hh.

180  {
181  const int ival = this->getValue(key);
182 
183  if (router.has(ival))
184  return container_type::operator[](router.get(ival)).second;
185  else
186  THROW(JIndexOutOfRange, "JHasMap::get(): invalid key.");
187  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:633
JRouter< int > router
Definition: JHashMap.hh:375
JEvaluator_t getValue
Function object for evaluation of key.
Definition: JHashMap.hh:366
template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
pair_type JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::insert ( const value_type element)
inlineinherited

Insert element.

Parameters
elementelement
Returns
(position, status), where status is true if inserted; else false

Definition at line 196 of file JHashMap.hh.

197  {
198  using namespace std;
199 
200  const int ival = this->getValue(element.first);
201 
202  if (!router.has(ival)) {
203 
204  iterator i = container_type::insert(lower_bound(this->begin(), this->end(), element.first, compare), element);
205 
206  router.put(ival, distance(this->begin(), i));
207 
208  for (iterator __i = i; ++__i != this->end(); ) {
209  router.put(this->getValue(__i->first), distance(this->begin(), __i));
210  }
211 
212  return pair_type(i, true);
213 
214  } else {
215 
216  return pair_type(this->end(), false);
217  }
218  }
JRouter< int > router
Definition: JHashMap.hh:375
JEvaluator_t getValue
Function object for evaluation of key.
Definition: JHashMap.hh:366
JComparator compare
Function object for comparison.
Definition: JHashMap.hh:373
std::pair< const_iterator, bool > pair_type
Definition: JHashMap.hh:71
template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
void JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::erase ( iterator  pos)
inlineinherited

Erase element at given position.

Parameters
posvalid position

Definition at line 226 of file JHashMap.hh.

227  {
228  this->router.put(this->getValue(*pos), this->router.getDefaultAddress());
229 
230  iterator i = pos;
231 
232  container_type::erase(i++);
233 
234  for ( ; i != this->end(); ++i) {
235  this->router.put(this->getValue(*i), distance(this->begin(), i));
236  }
237  }
JRouter< int > router
Definition: JHashMap.hh:375
JEvaluator_t getValue
Function object for evaluation of key.
Definition: JHashMap.hh:366
template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
void JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::erase ( iterator  __begin,
iterator  __end 
)
inlineinherited

Erase elements in given range.

Parameters
__beginbegin position (included)
__endend position (excluded)

Definition at line 246 of file JHashMap.hh.

247  {
248  iterator i = __begin;
249 
250  while (i != __end) {
251 
252  this->router.put(this->getValue(*i), this->router.getDefaultAddress());
253 
254  container_type::erase(i++);
255  }
256 
257  for ( ; i != this->end(); ++i) {
258  this->router.put(this->getValue(*i), distance(this->begin(), i));
259  }
260  }
JRouter< int > router
Definition: JHashMap.hh:375
JEvaluator_t getValue
Function object for evaluation of key.
Definition: JHashMap.hh:366
template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
bool JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::erase ( typename JClass< key_type >::argument_type  key) const
inlineinherited

Erase element.

Parameters
keykey
Returns
true if element with given key has been erased; else false

Definition at line 269 of file JHashMap.hh.

270  {
271  const int ival = this->getValue(key);
272 
273  if (router.has(ival)) {
274 
275  iterator pos = this->begin();
276 
277  std::advance(pos, this->router.get(ival));
278 
279  iterator i = container_type::erase(pos);
280 
281  for ( ; i != this->end(); ++i) {
282  this->router.put(this->getValue(*i), distance(this->begin(), i));
283  }
284 
285  return true;
286  }
287 
288  return false;
289  }
JRouter< int > router
Definition: JHashMap.hh:375
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
Definition: JCounter.hh:35
JEvaluator_t getValue
Function object for evaluation of key.
Definition: JHashMap.hh:366
template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
bool JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::has ( typename JClass< key_type >::argument_type  key) const
inlineinherited

Test whether key is present.

Parameters
keykey
Returns
true if present; else false

Definition at line 298 of file JHashMap.hh.

299  {
300  return router.has(this->getValue(key));
301  }
JRouter< int > router
Definition: JHashMap.hh:375
JEvaluator_t getValue
Function object for evaluation of key.
Definition: JHashMap.hh:366
template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
const JComparator& JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::getComparator ( ) const
inlineinherited

Get comparator.

Returns
comparator

Definition at line 309 of file JHashMap.hh.

310  {
311  return compare;
312  }
JComparator compare
Function object for comparison.
Definition: JHashMap.hh:373
template<class JKey_t, class JValue_t>
mapped_type& JTOOLS::JMappableCollection< JKey_t, JValue_t >::operator[] ( typename JClass< key_type >::argument_type  key)
inlineinherited

Get mapped value.

Parameters
keykey
Returns
value

Definition at line 64 of file JMappableCollection.hh.

65  {
66  return get(key);
67  }
template<class JKey_t, class JValue_t>
void JTOOLS::JMappableCollection< JKey_t, JValue_t >::put ( typename JClass< key_type >::argument_type  key,
typename JClass< mapped_type >::argument_type  value 
)
inlineinherited

Put pair-wise element (key,value) into collection.

Parameters
keykey
valuevalue

Definition at line 76 of file JMappableCollection.hh.

78  {
79  get(key) = value;
80  }

Member Data Documentation

template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
JEvaluator_t JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::getValue
inherited

Function object for evaluation of key.

Definition at line 366 of file JHashMap.hh.

template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
JComparator JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::compare
protectedinherited

Function object for comparison.

Definition at line 373 of file JHashMap.hh.

template<class JKey_t, class JValue_t, class JEvaluator_t = JHashEvaluator>
JRouter<int> JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::router
protectedinherited

Definition at line 375 of file JHashMap.hh.


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