MarlinTPC  1.2.0
VoxelTPC.h
1 #ifndef VOXELTPC_H
2 #define VOXELTPC_H 1
3 
4 //MARLINTPC
5 #include "TPCVoxel.h"
6 #include "HitDistributor.h"
7 
8 //C++
9 #include <map>
10 #include <vector>
11 #include <stdexcept>
12 
13 //LCIO
14 #include <EVENT/SimTrackerHit.h>
15 #include <IMPL/LCCollectionVec.h>
16 
17 //GEAR
18 #include <gear/PadRowLayout2D.h>
19 #include <gearimpl/RectangularPadRowLayout.h>
20 #include <gearimpl/FixedPadSizeDiskLayout.h>
21 
22 //MARLIN
23 #include <marlin/Global.h>
24 
25 
26 namespace marlintpc
27 {
28 
29 class TPCVoxel;
30 
42 class VoxelTPC
43 {
44  public:
47  VoxelTPC( gear::TPCParameters const * tpcParameters , double lengthOfTimeBin, double inductionFactor=0 );
48 
51  ~VoxelTPC();
52 
56  struct VoxelIndex {
57 
58  VoxelIndex(int _padIndex, int _zBin, int _moduleID) : zBin(_zBin), padIndex(_padIndex), moduleID(_moduleID){}
59  ~VoxelIndex(){}
60 
61  int zBin;
62  int padIndex;
63  int moduleID;
64 
65  bool operator()(VoxelIndex* vi1, VoxelIndex* vi2)
66  {
67  return *vi1 < *vi2;
68  }
69 
70  bool operator<(VoxelIndex const vi) const
71  {
72  if ( zBin == vi.zBin )
73  { // the z bins are equal, use the module id to distinguish
74  if ( moduleID == vi.moduleID )
75  { //also the module ids are equal, use the pad index
76  return padIndex < vi.padIndex;
77  }
78  else // use the module id
79  {
80  return moduleID < vi.moduleID;
81  }
82  }
83  else // use zBin
84  {
85  return zBin < vi.zBin;
86  }
87  }// operator <
88 
89  };
90 
100  LCCollectionVec * getVoxelCollection( double outputLength = -1 );
101 
105  LCCollectionVec * fetchVoxelCollection( double outputLength = -1 );
106 
111  std::list< std::pair< VoxelIndex, int > > * getVoxelList( double outputLength = -1 , bool erase = false );
112 
115  std::list< std::pair< VoxelIndex, int > > * fetchVoxelList( double outputLength = -1 );
116 
127  void putChargeInVoxels( SimTrackerHit *hit, double sigmaTrans, double sigmaLong = 0 );
128 
135  void putChargeInVoxel( TPCVoxel const &voxel);
136 
141  void putChargeInVoxel( int padIndex, double zLength, int charge, int moduleID=0 );
142 
146  TPCVoxel getVoxel( int padIndex, int timeIndex, int moduleID=0 );
147 
150  std::vector<TPCVoxel> getVoxelsOnPad(int padIndex, int moduleID=0);
151 
154  std::vector<TPCVoxel> getVoxelsWithZBin(int zBin);
155 
158  void addCollection(LCCollection* voxelCol);
159 
160 
165  void removeVoxel(TPCVoxel const &voxel);
166 
169  void removeVoxel(int padIndex, int zBin, int moduleID=0);
170 
175  void removeVoxels(std::vector<TPCVoxel> const &voxelVec);
176 
179  void removeVoxelsOnPad(int padIndex, int moduleID=0);
180 
183  void removeVoxelsWithZBin(int zBin);
184 
187  int getZBin( double zLength );
188 
189 
192  size_t getSize();
193 
194 
195  protected:
196 
201  std::map<VoxelIndex, int> _voxelMap;
202 
205  gear::TPCParameters const * _tpcParameters;
206 
210 
214 };
215 
216 } //namespace marlintpc
217 
218 #endif // VOXELTPC_H
219 
LCCollectionVec * fetchVoxelCollection(double outputLength=-1)
Does the same as getVoxelCollection() but erases the voxels from the map.
Definition: VoxelTPC.cc:27
void removeVoxels(std::vector< TPCVoxel > const &voxelVec)
Removes voxels in vector from the set.
Definition: VoxelTPC.cc:303
int getZBin(double zLength)
Takes a length in z and returns the number of the corresponding zBin.
Definition: VoxelTPC.cc:340
void putChargeInVoxels(SimTrackerHit *hit, double sigmaTrans, double sigmaLong=0)
Distributes the charge onto the pads assuming a 2D Gaussian distribution with the width sigmaTrans...
Definition: VoxelTPC.cc:168
The VoxelTPC is a helper class containing a std::map of all TPCVoxels which contain charge...
Definition: VoxelTPC.h:42
std::list< std::pair< VoxelIndex, int > > * getVoxelList(double outputLength=-1, bool erase=false)
This function works like getVoxelCollection, but the output format is different.
Definition: VoxelTPC.cc:119
double _lengthOfZBin
Instantiation parameters.
Definition: VoxelTPC.h:213
HitDistributor * _distributeHitPtr
Pointer on HitSmearer for the distribution of the hits.
Definition: VoxelTPC.h:209
~VoxelTPC()
Destructor of VoxelTPC.
Definition: VoxelTPC.cc:22
void removeVoxelsWithZBin(int zBin)
Removes all voxels with given time index.
Definition: VoxelTPC.cc:321
std::vector< TPCVoxel > getVoxelsWithZBin(int zBin)
Returns a vector of all non-empty voxels with a specific time index.
Definition: VoxelTPC.cc:266
void removeVoxel(TPCVoxel const &voxel)
Removes a voxel from the set.
Definition: VoxelTPC.cc:291
void putChargeInVoxel(TPCVoxel const &voxel)
Puts the charge into the voxel.
Definition: VoxelTPC.cc:181
size_t getSize()
For debugging: get the size of the map.
Definition: VoxelTPC.cc:347
LCCollectionVec * getVoxelCollection(double outputLength=-1)
Returns an LCCollectionVec of the stored TPCVoxels.
Definition: VoxelTPC.cc:79
Definition: HitDistributor.h:41
An LCFixedObject class to store charge in voxels of a TPC.
Definition: TPCVoxel.h:23
void addCollection(LCCollection *voxelCol)
Adds the given collection of TPCVoxels to the map.
Definition: VoxelTPC.cc:277
void removeVoxelsOnPad(int padIndex, int moduleID=0)
Removes all voxels with given pad index.
Definition: VoxelTPC.cc:309
VoxelTPC(gear::TPCParameters const *tpcParameters, double lengthOfTimeBin, double inductionFactor=0)
Constructor of VoxelTPC.
Definition: VoxelTPC.cc:12
std::list< std::pair< VoxelIndex, int > > * fetchVoxelList(double outputLength=-1)
Convenience function: calls getVoxelMap with erase = true.
Definition: VoxelTPC.cc:160
gear::TPCParameters const * _tpcParameters
Pointer on the gear pad layout.
Definition: VoxelTPC.h:205
std::vector< TPCVoxel > getVoxelsOnPad(int padIndex, int moduleID=0)
Returns a vector with all voxels with a specific pad (and module) index.
Definition: VoxelTPC.cc:227
std::map< VoxelIndex, int > _voxelMap
Map to store the information contained in the voxels.
Definition: VoxelTPC.h:201
This structure is for the sorting of the voxels.
Definition: VoxelTPC.h:56
TPCVoxel getVoxel(int padIndex, int timeIndex, int moduleID=0)
Get the voxel with a given index.
Definition: VoxelTPC.cc:211