WCSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WCSimWCDigi.cc
Go to the documentation of this file.
1 #include "WCSimWCDigi.hh"
2 #include "G4RotationMatrix.hh"
3 
4 #ifndef WCSIMWCDIGI_VERBOSE
5 //#define WCSIMWCDIGI_VERBOSE
6 #endif
7 
8 G4Allocator<WCSimWCDigi> WCSimWCDigiAllocator;
9 
11 {
12  tubeID = 0;
13  Gates.clear();
14  TriggerTimes.clear();
15  // TriggerTimes.reserve(10);
16  pe.clear();
17  time.clear();
18  time_presmear.clear();
19  totalPe = 0;
20 }
21 
23 
24 
25 
26 
28  :G4VDigi()
29 {
30  // in principle assignment = is defined for containers...
31  Gates = right.Gates;
32  tubeID = right.tubeID;
33  pe = right.pe;
34  time = right.time;
36 }
37 
39 {
40  TriggerTimes = right.TriggerTimes;
41  tubeID = right.tubeID;
42  pe = right.pe;
43  time = right.time;
45  return *this;
46 }
47 
48 
49 int WCSimWCDigi::operator==(const WCSimWCDigi& right) const
50 {
51  return ( (tubeID==right.tubeID) && (pe==right.pe) && (time==right.time)
52  && (time_presmear==right.time_presmear)
53  && (TriggerTimes==right.TriggerTimes) && (tubeID==right.tubeID) );
54 }
55 
57 
59 {
60  G4cout << "TubeID: " << tubeID
61  <<"Number of Gates " << NumberOfGates();
62  for (unsigned int i = 0 ; i < pe.size() ; i++) {
63  G4cout << "Gate = " << i
64  << " PE: " << pe[i]
65  << " Time:" << time[i] << G4endl;
66  }
67 }
68 
69 std::vector<int> WCSimWCDigi::GetDigiCompositionInfo(int gate)
70 {
71 #ifdef WCSIMWCDIGI_VERBOSE
72  G4cout << "WCSimWCDigi::GetDigiCompositionInfo fDigiComp has size " << fDigiComp.size() << G4endl;
73  for(int i = 0; i < fDigiComp[gate].size(); i++)
74  G4cout << "WCSimWCDigi::GetDigiCompositionInfo found photon with ID " << fDigiComp[gate][i] << G4endl;
75 #endif
76  return fDigiComp[gate];
77 }
78 
80 {
81  //this removes an element from the maps, vectors, and sets, and counters that were filled by WCSimWCDigitizerBase::AddNewDigit()
82  //Gates and TriggerTimes are NOT set
83 
84  //pe map
85  pe.erase(gate);
86  //time map and time_double vector
87  double gatetime = time[gate];
88  time.erase(gate);
89  time_presmear.erase(gate);
90  std::vector<G4double>::iterator it = std::find(time_double.begin(), time_double.end(), gatetime);
91  if(it != time_double.end())
92  time_double.erase(it);
93  else
94  G4cerr << "Could not erase time " << gatetime << " from WCSimWCDigi member time_double" << G4endl;
95 
96  // the following are not necessarily filled, so need to check that they exist before trying to erase them
97  //
98  //digit composition vector (pair of digit_id, photon_id)
99  if(fDigiComp.find(gate) != fDigiComp.end())
100  fDigiComp.erase(gate);
101  //parent id
102  if(primaryParentID.find(gate) != primaryParentID.end())
103  primaryParentID.erase(gate);
104 
105  //number of entries counter
106  totalPe--;
107 }
108 
109 
110 // G. Pronost:
111 // Sort function by Hit Time
113  const WCSimWCDigi * const &a,
114  const WCSimWCDigi * const &b) const {
115 
116  G4double ta, tb;
117  if ( a->time_double.size() > 0 )
118  ta = a->time_double[0];
119  else return false;
120 
121  if ( b->time_double.size() > 0 )
122  tb = b->time_double[0];
123  else return true;
124 
125  return ta < tb;
126 }
int operator==(const WCSimWCDigi &) const
Definition: WCSimWCDigi.cc:49
G4Allocator< WCSimWCDigi > WCSimWCDigiAllocator
Definition: WCSimWCDigi.cc:8
int NumberOfGates()
Definition: WCSimWCDigi.hh:112
std::set< int > Gates
Definition: WCSimWCDigi.hh:53
std::map< int, std::vector< int > > GetDigiCompositionInfo()
Definition: WCSimWCDigi.hh:110
std::vector< G4double > time_double
Same information as &quot;time&quot; but stored in a vector for quick time sorting.
Definition: WCSimWCDigi.hh:60
const WCSimWCDigi & operator=(const WCSimWCDigi &)
Definition: WCSimWCDigi.cc:38
bool operator()(const WCSimWCDigi *const &a, const WCSimWCDigi *const &b) const
Definition: WCSimWCDigi.cc:112
G4int tubeID
Definition: WCSimWCDigi.hh:46
G4int totalPe
Definition: WCSimWCDigi.hh:74
std::map< int, double > time_presmear
Time of each Digi, before smearing.
Definition: WCSimWCDigi.hh:58
std::map< int, double > time
Time of each Digi.
Definition: WCSimWCDigi.hh:59
void RemoveDigitizedGate(G4int gate)
Definition: WCSimWCDigi.cc:79
std::map< int, double > pe
Charge of each Digi.
Definition: WCSimWCDigi.hh:57
std::vector< double > TriggerTimes
Definition: WCSimWCDigi.hh:54
std::map< int, std::vector< int > > fDigiComp
IDs of the hits that make up this Digit (do not use for Hits)
Definition: WCSimWCDigi.hh:69
std::map< int, G4int > primaryParentID
Primary parent ID of the Hit (do not use for Digits)
Definition: WCSimWCDigi.hh:70
void Print()
Definition: WCSimWCDigi.cc:58
void Draw()
Definition: WCSimWCDigi.cc:56