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