ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GammaRayTelTrackerSD.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GammaRayTelTrackerSD.cc
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 // GEANT 4 class implementation file
29 // CERN Geneva Switzerland
30 //
31 //
32 // ------------ GammaRayTelTrackerSD ------
33 // by R.Giannitrapani, F.Longo & G.Santin (13 nov 2000)
34 //
35 // ************************************************************
36 #include "G4RunManager.hh"
37 #include "GammaRayTelTrackerSD.hh"
38 
39 #include "GammaRayTelTrackerHit.hh"
41 
42 #include "G4SystemOfUnits.hh"
43 #include "G4VPhysicalVolume.hh"
44 
45 #include "G4Step.hh"
46 #include "G4VTouchable.hh"
47 #include "G4TouchableHistory.hh"
48 #include "G4SDManager.hh"
49 
50 #include "G4ios.hh"
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
53 
55 {
57  Detector =
59 
60  G4int NbOfTKRTiles = Detector->GetNbOfTKRTiles();
63  NbOfTKRStrips = NbOfTKRStrips*NbOfTKRTiles;
64 
66 
69  collectionName.insert("TrackerCollection");
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
73 
75 {
76  delete [] ThitXID;
77  delete [] ThitYID;
78 }
79 
80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
81 
83 {
86 
87  for (G4int i=0;i<NbOfTKRChannels;i++)
88  {
89  ThitXID[i] = -1;
90  ThitYID[i] = -1;
91  };
92 }
93 
94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
95 
97 {
98 
99  G4double edep = 0.;
100  edep = aStep->GetTotalEnergyDeposit();
101  if (edep == 0.) return false;
102 
103  G4int StripTotal = Detector->GetNbOfTKRStrips();
104  G4int TileTotal = Detector->GetNbOfTKRTiles();
105 
106  // This TouchableHistory is used to obtain the physical volume
107  // of the hit
108  G4TouchableHistory* theTouchable
110 
111  //G4VPhysicalVolume* phys_tile = theTouchable->GetVolume();
112 
113  G4VPhysicalVolume* plane = theTouchable->GetVolume(2);
114 
115  G4int PlaneNumber = 0;
116  PlaneNumber=plane->GetCopyNo();
117  G4String PlaneName = plane->GetName();
118 
119  // The hits sees now the real strip
120 
121  G4int StripNumber = 0;
122  G4VPhysicalVolume* strip = 0;
123  strip = theTouchable->GetVolume();
124 
125  G4String StripName = strip->GetName();
126  StripNumber= strip->GetCopyNo();
127 
128  G4VPhysicalVolume* tile = theTouchable->GetVolume(1);
129  G4int TileNumber = tile->GetCopyNo();
130  G4String TileName = tile->GetName();
131 
132  G4int NTile = (TileNumber%TileTotal);
133  G4int j=0;
134 
135  G4int NChannel = 0;
136 
137  for (j=0;j<TileTotal;j++)
138  {
139  if(NTile==j) StripNumber += StripTotal*NTile;
140  }
141 
142  NChannel = PlaneNumber*TileTotal*StripTotal + StripNumber;
143 
144  /* G4cout << NChannel << " Channel Number" << G4endl;
145  G4cout << " Plane Number = " << PlaneNumber << " " << PlaneName
146  << G4endl;
147  G4cout << StripName << " " << StripNumber << G4endl; */
148 
149  if (PlaneName == "TKRDetectorX" )
150  // The hit is on an X silicon plane
151  {
152  // This is a new hit
153  if (ThitXID[NChannel]==-1)
154  {
156  TrackerHit->SetPlaneType(1);
157  TrackerHit->AddSil(edep);
158  TrackerHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
159  TrackerHit->SetNSilPlane(PlaneNumber);
160  TrackerHit->SetNStrip(StripNumber);
161  ThitXID[NChannel] =
162  TrackerCollection->insert(TrackerHit) -1;
163  }
164  else // This is not new
165  {
166  (*TrackerCollection)[ThitXID[NChannel]]->AddSil(edep);
167  // G4cout << "X" << PlaneNumber << " " << StripNumber << G4endl;
168  }
169  }
170 
171  if (PlaneName == "TKRDetectorY")
172  // The hit is on an Y silicon plane
173  {
174  // This is a new hit
175  if (ThitYID[NChannel]==-1)
176  {
178  TrackerHit->SetPlaneType(0);
179  TrackerHit->AddSil(edep);
180  TrackerHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
181  TrackerHit->SetNSilPlane(PlaneNumber);
182  TrackerHit->SetNStrip(StripNumber);
183  ThitYID[NChannel] =
184  TrackerCollection->insert(TrackerHit)-1;
185  }
186  else // This is not new
187  {
188  (*TrackerCollection)[ThitYID[NChannel]]->AddSil(edep);
189  // G4cout << "Y" << PlaneNumber << " " << StripNumber << G4endl;
190  }
191  }
192 
193  return true;
194 }
195 
196 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
197 
199 {
200  static G4int HCID = -1;
201  if(HCID<0)
202  {
204  }
206 
207 
208  for (G4int i=0;i<NbOfTKRChannels;i++)
209  {
210  ThitXID[i] = -1;
211  ThitYID[i] = -1;
212  };
213 }
214 
215 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
216 
218 {}
219 
220 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
221 
223 {}
224 
225 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
226 
228 {}
229 
230 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
231 
232 
233 
234 
235 
236 
237 
238 
239 
240 
241 
242 
243