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