Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4THitsVector.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27//
28#ifndef G4THitsVector_h
29#define G4THitsVector_h 1
30
31#include "G4THitsCollection.hh"
32#include "globals.hh"
33
34#include "G4THitsMap.hh"
35
36#include <vector>
37#include <deque>
38#include <map>
39#include <unordered_map>
40
41// class description:
42//
43// This is a template class of hits Vector and parametrized by
44// The concrete class of G4VHit. This is a uniform collection for
45// a particular concrete hit class objects.
46// An intermediate layer class G4HitsVector appeared in this
47// header file is used just for G4Allocator, because G4Allocator
48// cannot be instansiated with a template class. Thus G4HitsVector
49// class MUST NOT be directly used by the user.
50
51template <typename T, typename Vector_t = std::deque<T*>>
53{
54 public:
56 typedef T value_type;
57 typedef Vector_t vector_type;
58 typedef typename vector_type::iterator iterator;
59 typedef typename vector_type::const_iterator const_iterator;
60
61 typedef typename Vector_t::value_type store_type;
62 typedef std::pair<G4int, store_type> pair_t;
63 typedef std::map<G4int, store_type> map_t;
64 typedef std::unordered_map<G4int, store_type> uomap_t;
65 typedef std::multimap<G4int, store_type> mmap_t;
66 typedef std::unordered_multimap<G4int, store_type> uommap_t;
67
68 private:
69#define is_same_t(_Tp, _Up) std::is_same<_Tp, _Up>::value
70#define is_fundamental_t(_Tp) std::is_fundamental<_Tp>::value
71
72#define is_std_map_t(_Mp) std::is_same<_Mp, map_t>::value
73#define is_std_uomap_t(_Mp) std::is_same<_Mp, uomap_t>::value
74#define is_std_mmap_t(_Mp) std::is_same<_Mp, mmap_t>::value
75#define is_std_uommap_t(_Mp) std::is_same<_Mp, uommap_t>::value
76#define is_map_t(_Mp) \
77 (is_std_map_t(_Mp) ||\ is_std_mmap_t(_Mp) || \ is_std_uomap_t( \
78 _Mp) || \ is_std_uommap_t(_Mp))
79#define is_pointer_t(_Tp) std::is_pointer<_Tp>::value
80#define scast(_Tp) static_cast<_Tp>
81
82 template <bool _Bp, typename _Tp = void>
83 using enable_if_t = typename std::enable_if<_Bp, _Tp>::type;
84
85 public:
86 // generic constructor
87 G4VTHitsVector(G4int init_size = 0);
88 // det + collection description constructor
89 G4VTHitsVector(G4String detName, G4String colNam, G4int init_size = 0);
90 // destructor
91 virtual ~G4VTHitsVector();
92 // equivalence operator
93 G4bool operator==(const this_type& rhs) const;
94
95 virtual void DrawAllHits();
96 virtual void PrintAllHits();
97 // These two methods invokes Draw() and Print() methods of all of
98 // hit objects stored in this map, respectively.
99
100 // Generic iteration
101 inline Vector_t* GetContainer() const
102 {
103 return scast(Vector_t*)(theCollection);
104 }
105
106 inline typename Vector_t::size_type size() { return GetContainer()->size(); }
107
108 inline typename Vector_t::size_type GetIndex(iterator itr)
109 {
110 return std::distance(begin(), itr);
111 }
112
113 inline typename Vector_t::size_type GetIndex(const_iterator itr) const
114 {
115 return std::distance(begin(), itr);
116 }
117
118 template <typename U = store_type, enable_if_t<(is_pointer_t(U)), G4int> = 0>
119 inline T* GetObject(G4int idx) const
120 {
121 return (idx < (G4int) GetContainer()->size()) ? (*GetContainer())[idx]
122 : nullptr;
123 }
124
125 template <typename U = store_type, enable_if_t<(is_pointer_t(U)), G4int> = 0>
126 inline T* GetObject(iterator itr) const
127 {
128 return (*itr);
129 }
130
131 template <typename U = store_type, enable_if_t<(is_pointer_t(U)), G4int> = 0>
132 inline const T* GetObject(const_iterator itr) const
133 {
134 return (*itr);
135 }
136
137 template <typename U = store_type, enable_if_t<(!is_pointer_t(U)), G4int> = 0>
138 inline T* GetObject(G4int idx) const
139 {
140 return (idx < (G4int) GetContainer()->size()) ? &(*GetContainer())[idx]
141 : nullptr;
142 }
143
144 template <typename U = store_type, enable_if_t<(!is_pointer_t(U)), G4int> = 0>
145 inline T* GetObject(iterator itr) const
146 {
147 return &(*itr);
148 }
149
150 template <typename U = store_type, enable_if_t<(!is_pointer_t(U)), G4int> = 0>
151 inline const T* GetObject(const_iterator itr) const
152 {
153 return &(*itr);
154 }
155
156 iterator begin() { return GetContainer()->begin(); }
157 iterator end() { return GetContainer()->end(); }
158 const_iterator begin() const { return GetContainer()->begin(); }
159 const_iterator end() const { return GetContainer()->end(); }
160 const_iterator cbegin() const { return GetContainer()->cbegin(); }
161 const_iterator cend() const { return GetContainer()->cend(); }
162
163 // Returns a pointer to a concrete hit object.
164 inline Vector_t* GetVector() const { return scast(Vector_t*)(theCollection); }
165
166 // Overwrite a hit object. Total number of hit objects stored in this
167 // map is returned.
168 inline std::size_t entries() const
169 {
170 return (scast(Vector_t*)(theCollection))->size();
171 }
172
173 // Returns the number of hit objects stored in this map
174 inline void clear();
175
176 virtual G4VHit* GetHit(std::size_t) const { return nullptr; }
177 virtual std::size_t GetSize() const
178 {
179 return (scast(Vector_t*)(theCollection))->size();
180 }
181
182 inline map_t* GetMap() const;
183
184 public:
185 //------------------------------------------------------------------------//
186 // POINTER TYPE
187 //------------------------------------------------------------------------//
188 // ensure fundamental types are initialized to zero
189 template <typename U = T, typename V = store_type,
190 enable_if_t<(is_fundamental_t(U) && is_pointer_t(V)), G4int> = 0>
192 {
193 return new T(0.);
194 }
195
196 // non-fundamental types should set values to appropriate values
197 // and G4StatDouble stat(0.); stat += 1.0; gives n == 2;
198 template <typename U = T, typename V = store_type,
199 enable_if_t<(!is_fundamental_t(U) && is_pointer_t(V)), G4int> = 0>
201 {
202 return new T();
203 }
204
205 // ensure fundamental types are initialized to zero
206 template <typename U = store_type, enable_if_t<(is_pointer_t(U)), G4int> = 0>
208 {
209 return nullptr;
210 }
211
212 //------------------------------------------------------------------------//
213 // NON-POINTER TYPE
214 //------------------------------------------------------------------------//
215 // ensure fundamental types are initialized to zero
216 template <typename U = T, typename V = store_type,
217 enable_if_t<(is_fundamental_t(U) && !is_pointer_t(V)), G4int> = 0>
219 {
220 return T(0.);
221 }
222 // non-fundamental types should set values to appropriate values
223 // and G4StatDouble stat(0.); stat += 1.0; gives n == 2;
224 template <typename U = T, typename V = store_type,
225 enable_if_t<(!is_fundamental_t(U) && !is_pointer_t(V)), G4int> = 0>
227 {
228 return T();
229 }
230
231 // ensure fundamental types are initialized to zero
232 template <typename U = store_type, enable_if_t<(!is_pointer_t(U)), G4int> = 0>
234 {
235 return store_type();
236 }
237
238 public:
239 //------------------------------------------------------------------------//
240 // Generic operator += where add(...) overloads handle various
241 // U and VectorU_t types
242 //------------------------------------------------------------------------//
243 template <
244 typename U, typename VectorU_t,
245 enable_if_t<(is_pointer_t(typename VectorU_t::value_type)), G4int> = 0>
246 this_type& operator+=(const G4VTHitsVector<U, VectorU_t>& right) const
247 {
248 VectorU_t* aHitsVector = right.GetVector();
249 for(auto itr = aHitsVector->begin(); itr != aHitsVector->end(); ++itr)
250 {
251 auto _ptr = (*itr) ? (*itr) : null();
252 if(_ptr)
253 add<U>(std::distance(aHitsVector->begin(), itr), *_ptr);
254 }
255 return static_cast<this_type&>(*(const_cast<this_type*>(this)));
256 }
257 //------------------------------------------------------------------------//
258 template <
259 typename U, typename VectorU_t,
260 enable_if_t<(!is_pointer_t(typename VectorU_t::value_type)), G4int> = 0>
261 this_type& operator+=(const G4VTHitsVector<U, VectorU_t>& right) const
262 {
263 VectorU_t* aHitsVector = right.GetVector();
264 for(auto itr = aHitsVector->begin(); itr != aHitsVector->end(); ++itr)
265 {
266 auto _ptr = (*itr) ? (*itr) : allocate();
267 add<U>(std::distance(aHitsVector->begin(), itr), _ptr);
268 }
269 return static_cast<this_type&>(*(const_cast<this_type*>(this)));
270 }
271 //------------------------------------------------------------------------//
272 template <
273 typename U, typename MapU_t,
274 enable_if_t<(is_pointer_t(typename MapU_t::mapped_type)), G4int> = 0>
275 this_type& operator+=(const G4VTHitsMap<U, MapU_t>& right) const
276 {
277 MapU_t* aHitsMap = right.GetMap();
278 for(auto itr = aHitsMap->begin(); itr != aHitsMap->end(); ++itr)
279 add<U>(itr->first, *(itr->second));
280 return static_cast<this_type&>(*(const_cast<this_type*>(this)));
281 }
282 //------------------------------------------------------------------------//
283 template <
284 typename U, typename MapU_t,
285 enable_if_t<!(is_pointer_t(typename MapU_t::mapped_type)), G4int> = 0>
286 this_type& operator+=(const G4VTHitsMap<U, MapU_t>& right) const
287 {
288 MapU_t* aHitsMap = right.GetMap();
289 for(auto itr = aHitsMap->begin(); itr != aHitsMap->end(); ++itr)
290 add<U>(itr->first, itr->second);
291 return static_cast<this_type&>(*(const_cast<this_type*>(this)));
292 }
293 //------------------------------------------------------------------------//
294
295 public:
296 //------------------------------------------------------------------------//
297 // Insert a hit object. Total number of hit objects stored in this
298 // map is returned.
299 //------------------------------------------------------------------------//
300 // Standard vector overload for any type
301 // assumes type T has overload of += operator for U
302 //------------------------------------------------------------------------//
303 template <typename U = T, enable_if_t<is_same_t(U, T), G4int> = 0>
304 std::size_t add(const G4int& key, U*& aHit) const
305 {
306 vector_type* theHitsVector = GetVector(key);
307 _add(theHitsVector, key, *aHit);
308 return theHitsVector->size();
309 }
310 //------------------------------------------------------------------------//
311 // Overload for different types
312 //------------------------------------------------------------------------//
313 template <typename U = T, enable_if_t<!is_same_t(U, T), G4int> = 0>
314 std::size_t add(const G4int& key, U*& aHit) const
315 {
316 vector_type* theHitsVector = GetVector(key);
317 store_type hit = allocate();
318 get_reference(hit) += *aHit;
319 _add(theHitsVector, key, *hit);
320 return theHitsVector->size();
321 }
322 //------------------------------------------------------------------------//
323 // Overload for same type
324 //------------------------------------------------------------------------//
325 template <typename U = T, enable_if_t<is_same_t(U, T), G4int> = 0>
326 std::size_t add(const G4int& key, U& aHit) const
327 {
328 vector_type* theHitsVector = GetVector(key);
329 _add(theHitsVector, key, aHit);
330 return theHitsVector->size();
331 }
332 //------------------------------------------------------------------------//
333 // Overload for different types
334 //------------------------------------------------------------------------//
335 template <typename U = T, enable_if_t<!is_same_t(U, T), G4int> = 0>
336 std::size_t add(const G4int& key, U& aHit) const
337 {
338 vector_type* theHitsVector = GetVector(key);
339 _add(theHitsVector, key, aHit);
340 return theHitsVector->size();
341 }
342 //------------------------------------------------------------------------//
343
344 public:
345 //------------------------------------------------------------------------//
346 // Set a hit object. Total number of hit objects stored in this
347 // map is returned.
348 //------------------------------------------------------------------------//
349 // Overload for same type T
350 //------------------------------------------------------------------------//
351 template <typename U = T, enable_if_t<is_same_t(U, T), G4int> = 0>
352 inline std::size_t set(const G4int& key, U*& aHit) const
353 {
354 vector_type* theHitsVector = GetVector(key);
355 _assign(theHitsVector, key, aHit);
356 return theHitsVector->size();
357 }
358 //------------------------------------------------------------------------//
359 // Overload for different types
360 //------------------------------------------------------------------------//
361 template <typename U = T, enable_if_t<!is_same_t(U, T), G4int> = 0>
362 inline std::size_t set(const G4int& key, U*& aHit) const
363 {
364 vector_type* theHitsVector = GetVector(key);
365 store_type hit = allocate();
366 get_reference(hit) += *aHit;
367 _assign(theHitsVector, key, hit);
368 return theHitsVector->size();
369 }
370 //------------------------------------------------------------------------//
371
372 public:
373 //------------------------------------------------------------------------//
374 // Set a hit object. Total number of hit objects stored in this
375 // map is returned.
376 //------------------------------------------------------------------------//
377 // Overload for same type T
378 //------------------------------------------------------------------------//
379 template <typename U = T, enable_if_t<is_same_t(U, T), G4int> = 0>
380 inline std::size_t set(const G4int& key, U& aHit) const
381 {
382 vector_type* theHitsVector = GetVector(key);
383 _assign(theHitsVector, key, &aHit);
384 return theHitsVector->size();
385 }
386 //------------------------------------------------------------------------//
387 // Overload for different types
388 //------------------------------------------------------------------------//
389 template <typename U = T, enable_if_t<!is_same_t(U, T), G4int> = 0>
390 inline std::size_t set(const G4int& key, U& aHit) const
391 {
392 vector_type* theHitsVector = GetVector(key);
393 store_type hit = allocate();
394 get_reference(hit) += aHit;
395 _assign(theHitsVector, key, &aHit);
396 return theHitsVector->size();
397 }
398 //------------------------------------------------------------------------//
399
400 public:
401 //------------------------------------------------------------------------//
402 T* at(G4int key) const
403 {
404 vector_type* theHitsVector = GetVector();
405 resize(theHitsVector, key);
406 return &get_reference((*theHitsVector)[key]);
407 }
408 //------------------------------------------------------------------------//
409 T* operator[](G4int key) const
410 {
411 vector_type* theHitsVector = GetVector();
412 resize(theHitsVector, key);
413 return &get_reference((*theHitsVector)[key]);
414 }
415 //------------------------------------------------------------------------//
416
417 protected:
418 template <typename U = store_type, enable_if_t<(is_pointer_t(U)), G4int> = 0>
419 void resize(vector_type*& theHitsVector, const G4int& key) const
420 {
421 // ensure the proper size
422 if(key >= (G4int) theHitsVector->size())
423 theHitsVector->resize(key + 1, null());
424
425 // if null pointer for vector entry: allocate
426 if(!theHitsVector->at(key))
427 {
428 store_type init = allocate();
429 _assign(theHitsVector, key, init);
430 }
431 }
432
433 template <typename U = store_type, enable_if_t<(!is_pointer_t(U)), G4int> = 0>
434 void resize(vector_type*& theHitsVector, const G4int& key) const
435 {
436 // ensure the proper size
437 if(key >= (G4int) theHitsVector->size())
438 theHitsVector->resize(key + 1, null());
439 }
440
441 vector_type* GetVector(const G4int& key) const
442 {
443 vector_type* theHitsVector = GetVector();
444 resize(theHitsVector, key);
445 return theHitsVector;
446 }
447
448 //------------------------------------------------------------------------//
449 // Assign/Add when the storage type is pointer
450 // assumes type T has overload of += operator for U
451 //------------------------------------------------------------------------//
452 template <typename U = store_type, enable_if_t<is_pointer_t(U), G4int> = 0>
453 void _assign(vector_type*& theHitsVector, const G4int& key, T& val) const
454 {
455 delete(*theHitsVector)[key];
456 *(*theHitsVector)[key] = val;
457 }
458
459 template <typename U = store_type, enable_if_t<is_pointer_t(U), G4int> = 0>
460 void _assign(vector_type*& theHitsVector, const G4int& key, T*& val) const
461 {
462 delete(*theHitsVector)[key];
463 (*theHitsVector)[key] = val;
464 }
465
466 template <typename U = store_type, enable_if_t<is_pointer_t(U), G4int> = 0>
467 void _add(vector_type*& theHitsVector, const G4int& key, T& val) const
468 {
469 *(*theHitsVector)[key] += val;
470 }
471
472 template <typename U = store_type, enable_if_t<is_pointer_t(U), G4int> = 0>
473 void _add(vector_type*& theHitsVector, const G4int& key, T*& val) const
474 {
475 *(*theHitsVector)[key] += *val;
476 }
477
478 template <typename V, typename U = store_type,
479 enable_if_t<is_pointer_t(U), G4int> = 0>
480 void _add(vector_type*& theHitsVector, const G4int& key, V& val) const
481 {
482 *(*theHitsVector)[key] += val;
483 }
484
485 template <typename V, typename U = store_type,
486 enable_if_t<is_pointer_t(U), G4int> = 0>
487 void _add(vector_type*& theHitsVector, const G4int& key, V*& val) const
488 {
489 *(*theHitsVector)[key] += *val;
490 }
491
492 template <typename U = store_type, enable_if_t<is_pointer_t(U), G4int> = 0>
493 T& get(U& val) const
494 {
495 return *val;
496 }
497
498 template <typename U = store_type, enable_if_t<is_pointer_t(U), G4int> = 0>
499 void delete_contents(vector_type*& theHitsVector) const
500 {
501 for(iterator itr = theHitsVector->begin(); itr != theHitsVector->end();
502 ++itr)
503 delete *itr;
504 }
505
506 template <typename U = store_type, enable_if_t<is_pointer_t(U), G4int> = 0>
507 T& get_reference(U& val) const
508 {
509 return *val;
510 }
511
512 //------------------------------------------------------------------------//
513 // Assign/Add when the storage type is pointer
514 // assumes type T has overload of += operator for U
515 //------------------------------------------------------------------------//
516 template <typename U = store_type, enable_if_t<!is_pointer_t(U), G4int> = 0>
517 void _assign(vector_type*& theHitsVector, const G4int& key, T& val) const
518 {
519 (*theHitsVector)[key] = val;
520 }
521
522 template <typename U = store_type, enable_if_t<!is_pointer_t(U), G4int> = 0>
523 void _assign(vector_type*& theHitsVector, const G4int& key, T*& val) const
524 {
525 delete(*theHitsVector)[key];
526 (*theHitsVector)[key] = *val;
527 }
528
529 template <typename U = store_type, enable_if_t<!is_pointer_t(U), G4int> = 0>
530 void _add(vector_type*& theHitsVector, const G4int& key, T& val) const
531 {
532 (*theHitsVector)[key] += val;
533 }
534
535 template <typename U = store_type, enable_if_t<!is_pointer_t(U), G4int> = 0>
536 void _add(vector_type*& theHitsVector, const G4int& key, T*& val) const
537 {
538 (*theHitsVector)[key] += *val;
539 }
540
541 template <typename V, typename U = store_type,
542 enable_if_t<!is_pointer_t(U), G4int> = 0>
543 void _add(vector_type*& theHitsVector, const G4int& key, V& val) const
544 {
545 (*theHitsVector)[key] += val;
546 }
547
548 template <typename V, typename U = store_type,
549 enable_if_t<!is_pointer_t(U), G4int> = 0>
550 void _add(vector_type*& theHitsVector, const G4int& key, V*& val) const
551 {
552 (*theHitsVector)[key] += *val;
553 }
554
555 template <typename U = store_type, enable_if_t<!is_pointer_t(U), G4int> = 0>
557 {}
558
559 template <typename U = store_type, enable_if_t<!is_pointer_t(U), G4int> = 0>
560 T& get_reference(U& val) const
561 {
562 return val;
563 }
564
565#undef is_same_t
566#undef is_fundamental_t
567#undef is_std_map_t
568#undef is_std_mmap_t
569#undef is_std_uomap_t
570#undef is_std_uommap_t
571#undef is_map_t
572#undef is_pointer_t
573#undef scast
574};
575
576//============================================================================//
577
578template <typename T, typename Vector_t>
580{
581 theCollection = static_cast<void*>(new Vector_t);
582 if(init_size > 0)
583 {
584 vector_type* theHitsVector = GetVector();
585 resize(theHitsVector, init_size - 1);
586 }
587}
588
589//============================================================================//
590
591template <typename T, typename Vector_t>
593 G4int init_size)
594 : G4HitsCollection(detName, colNam)
595{
596 theCollection = static_cast<void*>(new Vector_t);
597 if(init_size > 0)
598 {
599 vector_type* theHitsVector = GetVector();
600 resize(theHitsVector, init_size - 1);
601 }
602}
603
604//============================================================================//
605
606template <typename T, typename Vector_t>
608{
609 vector_type* theHitsVector = GetVector();
610 delete_contents(theHitsVector);
611 delete theHitsVector;
612}
613
614//============================================================================//
615
616template <typename T, typename Vector_t>
618 const G4VTHitsVector<T, Vector_t>& right) const
619{
620 return (collectionName == right.collectionName);
621}
622
623//============================================================================//
624
625template <typename T, typename Vector_t>
628{
629 G4ThreadLocalStatic map_t* theHitsMap = new map_t();
630 theHitsMap->clear();
631 vector_type* theHitsVector = GetVector();
632 for(std::size_t i = 0; i < theHitsVector->size(); ++i)
633 {
634 store_type& _obj = (*theHitsVector)[i];
635 if(_obj)
636 (*theHitsMap)[i] = _obj;
637 }
638 return theHitsMap;
639}
640//============================================================================//
641
642template <typename T, typename Vector_t>
644{
645 ;
646}
647
648//============================================================================//
649
650template <typename T, typename Vector_t>
652{
653 G4cout << "G4THitsVector " << SDname << " / " << collectionName << " --- "
654 << entries() << " entries" << G4endl;
655 /*----- commented out for the use-case where <T> cannot be initialized
656 to be zero or does not support += operator.
657 Vector_t * theHitsVector = GetVector();
658 typename Vector_t::iterator itr = theHitsVector->begin();
659 T sum = 0.;
660 for(; itr != theHitsVector->end(); ++itr) {
661 G4cout << " " << itr->first << " : "
662 << *(itr->second) << G4endl;
663 sum += *(itr->second);
664 }
665 G4cout << " Total : " << sum << G4endl;
666 ----------------------------------------------------------------------*/
667}
668
669//============================================================================//
670
671template <typename T, typename Vector_t>
673{
674 vector_type* theHitsVector = GetVector();
675 delete_contents(theHitsVector);
676 theHitsVector->clear();
677}
678
679//============================================================================//
680// //
681// //
682// Helpers for different map types //
683// //
684// //
685//============================================================================//
686
687template <typename _Tp>
688class G4THitsVector : public G4VTHitsVector<_Tp, std::vector<_Tp*>>
689{
690 public:
692
693 public:
694 G4THitsVector(G4int init_size = 0)
695 : parent_type(init_size)
696 {}
697 G4THitsVector(G4String detName, G4String colName, G4int init_size = 0)
698 : parent_type(detName, colName, init_size)
699 {}
700
701 using parent_type::operator+=;
702 using parent_type::operator==;
703 using parent_type::operator[];
704 using parent_type::add;
705 using parent_type::begin;
707 using parent_type::cend;
708 using parent_type::clear;
710 using parent_type::end;
717 using parent_type::set;
718};
719
720//============================================================================//
721
722template <typename _Tp>
723class G4THitsDeque : public G4VTHitsVector<_Tp, std::deque<_Tp*>>
724{
725 public:
727
728 public:
729 G4THitsDeque(G4int init_size = 0)
730 : parent_type(init_size)
731 {}
732 G4THitsDeque(G4String detName, G4String colName, G4int init_size = 0)
733 : parent_type(detName, colName, init_size)
734 {}
735
736 using parent_type::operator+=;
737 using parent_type::operator==;
738 using parent_type::operator[];
739 using parent_type::add;
740 using parent_type::begin;
742 using parent_type::cend;
743 using parent_type::clear;
745 using parent_type::end;
752 using parent_type::set;
753};
754
755//============================================================================//
756
757#endif
#define is_fundamental_t(_Tp)
#define scast(_Tp)
#define is_pointer_t(_Tp)
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4VTHitsVector< _Tp, std::deque< _Tp * > > parent_type
G4THitsDeque(G4int init_size=0)
G4THitsDeque(G4String detName, G4String colName, G4int init_size=0)
G4THitsVector(G4int init_size=0)
G4VTHitsVector< _Tp, std::vector< _Tp * > > parent_type
G4THitsVector(G4String detName, G4String colName, G4int init_size=0)
Definition: G4VHit.hh:48
Map_t * GetMap() const
Definition: G4THitsMap.hh:155
void _assign(vector_type *&theHitsVector, const G4int &key, T &val) const
T * GetObject(G4int idx) const
vector_type::const_iterator const_iterator
const_iterator cend() const
void delete_contents(vector_type *&theHitsVector) const
std::unordered_multimap< G4int, store_type > uommap_t
void _add(vector_type *&theHitsVector, const G4int &key, V *&val) const
map_t * GetMap() const
G4bool operator==(const this_type &rhs) const
void _add(vector_type *&theHitsVector, const G4int &key, V &val) const
iterator end()
virtual ~G4VTHitsVector()
void _add(vector_type *&theHitsVector, const G4int &key, T &val) const
std::map< G4int, store_type > map_t
Vector_t::size_type GetIndex(iterator itr)
std::unordered_map< G4int, store_type > uomap_t
std::size_t set(const G4int &key, U &aHit) const
void _add(vector_type *&theHitsVector, const G4int &key, T *&val) const
Vector_t::size_type size()
store_type null() const
Vector_t::size_type GetIndex(const_iterator itr) const
T * at(G4int key) const
void delete_contents(vector_type *&) const
const_iterator cbegin() const
virtual void PrintAllHits()
std::multimap< G4int, store_type > mmap_t
Vector_t * GetVector() const
const_iterator begin() const
G4VTHitsVector(G4int init_size=0)
std::size_t set(const G4int &key, U *&aHit) const
Vector_t::value_type store_type
vector_type::iterator iterator
void _assign(vector_type *&theHitsVector, const G4int &key, T *&val) const
T & get(U &val) const
virtual void DrawAllHits()
void resize(vector_type *&theHitsVector, const G4int &key) const
std::size_t add(const G4int &key, U *&aHit) const
const T * GetObject(const_iterator itr) const
T * GetObject(iterator itr) const
Vector_t vector_type
virtual std::size_t GetSize() const
T * operator[](G4int key) const
G4VTHitsVector(G4String detName, G4String colNam, G4int init_size=0)
vector_type * GetVector(const G4int &key) const
iterator begin()
std::pair< G4int, store_type > pair_t
Vector_t * GetContainer() const
store_type allocate() const
std::size_t add(const G4int &key, U &aHit) const
std::size_t entries() const
G4VTHitsVector< T, Vector_t > this_type
const_iterator end() const
virtual G4VHit * GetHit(std::size_t) const
T & get_reference(U &val) const
#define G4ThreadLocalStatic
Definition: tls.hh:76