Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JACOUSTICS::JGEOMETRY::JDetector Struct Reference

Detector geometry. More...

#include <JGeometry.hh>

Inheritance diagram for JACOUSTICS::JGEOMETRY::JDetector:
JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t > JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > > JTOOLS::JMappableCollection< JKey_t, JValue_t > std::vector< std::pair< JKey_t, JValue_t > >

Classes

struct  module_type
 Auxiliary data structure for module location and position. More...
 

Public Types

typedef JKey_t key_type
 
typedef JValue_t mapped_type
 
typedef std::pair< JKey_t, JValue_t > value_type
 
typedef JHashMapEvaluator< JEvaluator_t > evaluator_type
 
typedef JHashCollection< value_type, evaluator_typecollection_type
 
typedef collection_type::container_type container_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
 

Public Member Functions

 JDetector ()
 Default constructor.
 
 JDetector (const JDETECTOR::JDetector &detector, const std::vector< JHydrophone > &hydrophones=std::vector< JHydrophone >())
 Constructor.
 
bool hasString (int string) const
 Check if this detector has given string.
 
bool hasLocation (const JLocation &location) const
 Check if this detector has given location.
 
virtual void clear () override
 Clear.
 
void reset ()
 Reset values.
 
void set (const JHashMap &source, const mapped_type &value)
 Set values corresponding to keys in given source.
 
virtual mapped_typeget (typename JClass< key_type >::argument_type key) override
 Get mapped value.
 
virtual const mapped_typeget (typename JClass< key_type >::argument_type key) const override
 Get mapped value.
 
value_typeget (const T &value)
 Get element with given value.
 
const value_typeget (const T &value) const
 Get element with given value.
 
void swap (JHashCollection &collection)
 Swap hash collection.
 
const_iterator find (const T &value) const
 Find element with given value.
 
iterator find (const T &value)
 Find element with given value.
 
virtual bool insert (const value_type &element)
 Insert element.
 
void insert (T __begin, T __end)
 Insert values.
 
void erase (iterator pos)
 Erase element at given position.
 
void erase (iterator __begin, iterator __end)
 Erase elements in given range.
 
bool erase (const T &value)
 Erase element with given value.
 
bool has (const T &value) const
 Test whether given value is present.
 
int getIndex (const T &value) const
 Get index of given value.
 
const mapped_typeoperator[] (typename JClass< key_type >::argument_type key) const
 Get mapped value.
 
mapped_typeoperator[] (typename JClass< key_type >::argument_type key)
 Get mapped value.
 
void put (typename JClass< key_type > ::argument_type key, typename JClass< mapped_type >::argument_type value)
 Put pair-wise element (key,value) into collection.
 

Public Attributes

JHashMapEvaluator< JHashEvaluatorgetValue
 Function object for evaluation of element.
 

Protected Attributes

JTOOLS::JHashCollection::router_type router
 

Private Member Functions

void operator[] (int)
 
void assign ()
 
void resize ()
 
void push_back ()
 
void pop_back ()
 

Friends

std::ostream & operator<< (std::ostream &out, const JDetector &detector)
 Write detector parameters to output stream.
 

Detailed Description

Detector geometry.

Definition at line 499 of file JGeometry.hh.

Member Typedef Documentation

◆ key_type

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

Definition at line 78 of file JHashMap.hh.

◆ mapped_type

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

Definition at line 79 of file JHashMap.hh.

◆ value_type

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

Definition at line 80 of file JHashMap.hh.

◆ evaluator_type

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

Definition at line 81 of file JHashMap.hh.

◆ collection_type

template<class JKey_t , class JValue_t , class JEvaluator_t = JHashEvaluator>
JHashCollection<value_type, evaluator_type> JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::collection_type
inherited

Definition at line 83 of file JHashMap.hh.

◆ container_type

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

Definition at line 84 of file JHashMap.hh.

◆ const_iterator

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

Definition at line 86 of file JHashMap.hh.

◆ const_reverse_iterator

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

Definition at line 87 of file JHashMap.hh.

◆ iterator

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

Definition at line 88 of file JHashMap.hh.

◆ reverse_iterator

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

Definition at line 89 of file JHashMap.hh.

Constructor & Destructor Documentation

◆ JDetector() [1/2]

JACOUSTICS::JGEOMETRY::JDetector::JDetector ( )
inline

Default constructor.

Definition at line 505 of file JGeometry.hh.

506 {}

◆ JDetector() [2/2]

JACOUSTICS::JGEOMETRY::JDetector::JDetector ( const JDETECTOR::JDetector & detector,
const std::vector< JHydrophone > & hydrophones = std::vector<JHydrophone>() )
inline

Constructor.

Note that the positions of the base modules correspond to the reference position of the string.
As a consequence, a base module (i.e. floor = 0) is required for each string.
Missing base modules should therefore be added beforehand (e.g. using application JDetectorDB.cc).

Note that if the position of a hydrophone is not available, it is assumed that there is no hydrophone on that string.
If the position of the hydrophone is manually set, the corresponding parameter JString::has_hydrophone should be set to true.

Parameters
detectordetector
hydrophonescontainer with data of hydrophones

Definition at line 524 of file JGeometry.hh.

526 {
527 using namespace std;
528 using namespace JPP;
529
530 map<int, vector<module_type> > buffer; // string -> modules
531
532 for (JDETECTOR::JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
533 buffer[module->getString()].push_back(module_type(module->getLocation(), module->getPosition()));
534 }
535
536 for (map<int, vector<module_type> >::iterator i = buffer.begin(); i != buffer.end(); ++i) {
537
538 sort(i->second.begin(), i->second.end(), make_comparator(&module_type::getFloor));
539
540 if (i->second[0].getFloor() == 0) {
541
542 JString& string = (*this)[i->first];
543
544 vector<module_type>::iterator p = i->second.begin();
545
546 ++p;
547
548 string = JGEOMETRY::JString(i->second[0].getPosition(), getMechanics(i->first), p, i->second.end());
549
550 try {
551
552 string.hydrophone = getPosition(hydrophones.begin(),
553 hydrophones.end(),
554 make_predicate(&JHydrophone::getString, i->first));
555
556 string.has_hydrophone = true;
557 }
558 catch(const exception&) {
559 string.has_hydrophone = false;
560 }
561
562 } else {
563
564 THROW(JNoValue, "No floor 0 in string " << i->first << "; use e.g. JDetectorDB -W.");
565 }
566 }
567 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
int getFloor() const
Get floor number.
Definition JLocation.hh:146
int getString() const
Get string number.
Definition JLocation.hh:135
Exception for missing value.
Wrapper class around STL string class.
Definition JString.hh:29
JVector3D getPosition(T __begin, T __end, const JPredicate< JTypename_t, JComparator_t > &predicate)
Get position from element in data which corresponds to given predicate.
static JDetectorMechanics getMechanics
Function object to get string mechanics.
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Detector file.
Definition JHead.hh:227

Member Function Documentation

◆ hasString()

bool JACOUSTICS::JGEOMETRY::JDetector::hasString ( int string) const
inline

Check if this detector has given string.

Parameters
stringstring
Returns
true if string present; else false

Definition at line 576 of file JGeometry.hh.

577 {
578 return this->has(string);
579 }

◆ hasLocation()

bool JACOUSTICS::JGEOMETRY::JDetector::hasLocation ( const JLocation & location) const
inline

Check if this detector has given location.

Parameters
locationlocation
Returns
true if location present; else false

Definition at line 588 of file JGeometry.hh.

589 {
590 return this->hasString(location.getString()) && (*this)[location.getString()].hasFloor(location.getFloor());
591 }
bool hasString(int string) const
Check if this detector has given string.
Definition JGeometry.hh:576

◆ clear()

template<class JKey_t , class JValue_t , class JEvaluator_t = JHashEvaluator>
virtual void JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::clear ( )
inlineoverridevirtualinherited

Clear.

Implements JTOOLS::JMappableCollection< JKey_t, JValue_t >.

Definition at line 107 of file JHashMap.hh.

108 {
110 }

◆ reset()

template<class JKey_t , class JValue_t , class JEvaluator_t = JHashEvaluator>
void JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::reset ( )
inlineinherited

Reset values.

Definition at line 116 of file JHashMap.hh.

117 {
118 for (iterator i = this->begin(); i != this->end(); ++i) {
119 i->second = mapped_type();
120 }
121 }
JValue_t mapped_type
Definition JHashMap.hh:79
container_type::iterator iterator
Definition JHashMap.hh:88

◆ set()

template<class JKey_t , class JValue_t , class JEvaluator_t = JHashEvaluator>
void JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::set ( const JHashMap< JKey_t, JValue_t, JEvaluator_t > & source,
const mapped_type & value )
inlineinherited

Set values corresponding to keys in given source.

Parameters
sourcesource
valuevalue

Definition at line 130 of file JHashMap.hh.

131 {
132 this->clear();
133
134 for (const_iterator i = source.begin(); i != source.end(); ++i) {
135 (*this)[i->first] = value;
136 }
137 }
container_type::const_iterator const_iterator
Definition JHashMap.hh:86
virtual void clear() override
Clear.
Definition JHashMap.hh:107

◆ get() [1/4]

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)
inlineoverridevirtualinherited

Get mapped value.

Parameters
keykey
Returns
mapped value

Implements JTOOLS::JMappableCollection< JKey_t, JValue_t >.

Definition at line 146 of file JHashMap.hh.

147 {
148 const int ival = this->getValue(key);
149
150 if (!this->router.has(ival)) {
152 }
153
154 return container_type::operator[](this->router.get(ival)).second;
155 }
virtual bool insert(const value_type &element)
Insert element.
std::pair< JKey_t, JValue_t > value_type
Definition JHashMap.hh:80

◆ get() [2/4]

template<class JKey_t , class JValue_t , class JEvaluator_t = JHashEvaluator>
virtual const mapped_type & JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t >::get ( typename JClass< key_type >::argument_type key) const
inlineoverridevirtualinherited

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

Implements JTOOLS::JMappableCollection< JKey_t, JValue_t >.

Definition at line 166 of file JHashMap.hh.

167 {
168 const int ival = this->getValue(key);
169
170 if (this->router.has(ival))
171 return container_type::operator[](this->router.get(ival)).second;
172 else
173 THROW(JIndexOutOfRange, "JHashMap::get(): invalid key " << STREAM("?") << key);
174 }
Auxiliary data structure for handling std::ostream.

◆ get() [3/4]

value_type & JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::get ( const T & value)
inlineinherited

Get element with given value.

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

Parameters
valuevalue
Returns
element

Definition at line 176 of file JHashCollection.hh.

177 {
178 const int ival = this->getValue(value);
179
180 if (!router.has(ival)) {
181 this->insert(value);
182 }
183
184 return container_type::operator[](router.get(ival)).second;
185 }

◆ get() [4/4]

const value_type & JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::get ( const T & value) const
inlineinherited

Get element with given value.

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

Parameters
valuevalue
Returns
element

Definition at line 197 of file JHashCollection.hh.

198 {
199 const int ival = this->getValue(value);
200
201 if (router.has(ival)) {
202 return container_type::operator[](router.get(ival)).second;
203 }
204
205 THROW(JIndexOutOfRange, "JHashCollection::get(): invalid value.");
206 }

◆ swap()

void JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::swap ( JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > > & collection)
inlineinherited

Swap hash collection.

Parameters
collectionhash collection

Definition at line 123 of file JHashCollection.hh.

124 {
125 router.swap(collection.router);
126
127 container_type::swap(collection);
128 }

◆ find() [1/2]

const_iterator JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::find ( const T & value) const
inlineinherited

Find element with given value.

Parameters
valuevalue
Returns
position of element with given value or end()

Definition at line 138 of file JHashCollection.hh.

139 {
140 const int ival = this->getValue(value);
141
142 if (router.has(ival))
143 return this->begin() + router.get(ival);
144 else
145 return this->end();
146 }

◆ find() [2/2]

iterator JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::find ( const T & value)
inlineinherited

Find element with given value.

Parameters
valuevalue
Returns
position of element with given value or end()

Definition at line 156 of file JHashCollection.hh.

157 {
158 const int ival = this->getValue(value);
159
160 if (router.has(ival))
161 return this->begin() + router.get(ival);
162 else
163 return this->end();
164 }

◆ insert() [1/2]

virtual bool JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::insert ( const value_type & element)
inlinevirtualinherited

Insert element.

Parameters
elementelement
Returns
true if inserted; else false

Definition at line 215 of file JHashCollection.hh.

216 {
217 const int ival = this->getValue(element);
218
219 if (!router.has(ival)) {
220
221 container_type::push_back(element);
222
223 router.put(ival, this->size() - 1);
224
225 return true;
226 }
227
228 return false;
229 }

◆ insert() [2/2]

void JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::insert ( T __begin,
T __end )
inlineinherited

Insert values.

Parameters
__beginbegin of values
__endend of values

Definition at line 239 of file JHashCollection.hh.

240 {
241 for (T i = __begin; i != __end; ++i) {
242 insert(*i);
243 }
244 }

◆ erase() [1/3]

void JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::erase ( iterator pos)
inlineinherited

Erase element at given position.

Parameters
posvalid position

Definition at line 252 of file JHashCollection.hh.

253 {
254 router.put(this->getValue(*pos), router.getDefaultAddress());
255
256 for (iterator i = container_type::erase(pos); i != this->end(); ++i) {
257 router.put(this->getValue(*i), distance(this->begin(), i));
258 }
259 }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.

◆ erase() [2/3]

void JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::erase ( iterator __begin,
iterator __end )
inlineinherited

Erase elements in given range.

Parameters
__beginbegin position (included)
__endend position (excluded)

Definition at line 268 of file JHashCollection.hh.

269 {
270 for (iterator i = __begin; i != __end; ++i) {
271 router.put(this->getValue(*i), router.getDefaultAddress());
272 }
273
274 for (iterator i = container_type::erase(__begin, __end); i != this->end(); ++i) {
275 router.put(this->getValue(*i), distance(this->begin(), i));
276 }
277 }

◆ erase() [3/3]

bool JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::erase ( const T & value)
inlineinherited

Erase element with given value.

Parameters
valuevalue
Returns
true if element has been erased; else false

Definition at line 287 of file JHashCollection.hh.

288 {
289 const int ival = this->getValue(value);
290
291 if (router.has(ival)) {
292
293 this->erase(this->begin() + router.get(ival));
294
295 return true;
296 }
297
298 return false;
299 }

◆ has()

bool JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::has ( const T & value) const
inlineinherited

Test whether given value is present.

Parameters
valuevalue
Returns
true if present; else false

Definition at line 309 of file JHashCollection.hh.

310 {
311 return router.has(this->getValue(value));
312 }

◆ getIndex()

int JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::getIndex ( const T & value) const
inlineinherited

Get index of given value.

Parameters
valuevalue
Returns
indecx

Definition at line 322 of file JHashCollection.hh.

323 {
324 return router.get(this->getValue(value));
325 }

◆ operator[]() [1/3]

void JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::operator[] ( int )
privateinherited

◆ operator[]() [2/3]

template<class JKey_t , class JValue_t >
const mapped_type & JTOOLS::JMappableCollection< JKey_t, JValue_t >::operator[] ( typename JClass< key_type >::argument_type key) const
inlineinherited

Get mapped value.

Parameters
keykey
Returns
value

Definition at line 73 of file JMappableCollection.hh.

74 {
75 return get(key);
76 }
virtual const mapped_type & get(typename JClass< key_type >::argument_type key) const =0
Get mapped value.

◆ operator[]() [3/3]

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 85 of file JMappableCollection.hh.

86 {
87 return get(key);
88 }

◆ assign()

void JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::assign ( )
privateinherited

◆ resize()

void JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::resize ( )
privateinherited

◆ push_back()

void JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::push_back ( )
privateinherited

◆ pop_back()

void JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::pop_back ( )
privateinherited

◆ put()

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 97 of file JMappableCollection.hh.

99 {
100 get(key) = value;
101 }

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const JDetector & detector )
friend

Write detector parameters to output stream.

Parameters
outoutput stream
detectordetector
Returns
output stream

Definition at line 601 of file JGeometry.hh.

602 {
603 using namespace std;
604
605 for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) {
606 out << setw(4) << i->first << endl << i->second;
607 }
608
609 return out;
610 }

Member Data Documentation

◆ getValue

JHashMapEvaluator< JHashEvaluator > JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::getValue
inherited

Function object for evaluation of element.

Definition at line 331 of file JHashCollection.hh.

◆ router

JTOOLS::JHashCollection::router_type JTOOLS::JHashCollection< std::pair< JKey_t, JValue_t >, JHashMapEvaluator< JHashEvaluator > >::router
protectedinherited

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