Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GammaRayTelTrackerSD.cc
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 // 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();
61  NbOfTKRStrips = Detector->GetNbOfTKRStrips();
62  NbOfTKRLayers = Detector->GetNbOfTKRLayers();
63  NbOfTKRStrips = NbOfTKRStrips*NbOfTKRTiles;
64 
65  NbOfTKRChannels = NbOfTKRStrips* NbOfTKRTiles * NbOfTKRLayers;
66 
67  ThitXID = new G4int[NbOfTKRChannels];
68  ThitYID = new G4int[NbOfTKRChannels];
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 {
84  TrackerCollection = new GammaRayTelTrackerHitsCollection
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 = aStep->GetTotalEnergyDeposit();
100  if ((edep/keV == 0.)) return false;
101 
102  G4int StripTotal = Detector->GetNbOfTKRStrips();
103  G4int TileTotal = Detector->GetNbOfTKRTiles();
104 
105  // This TouchableHistory is used to obtain the physical volume
106  // of the hit
107  G4TouchableHistory* theTouchable
109 
110  //G4VPhysicalVolume* phys_tile = theTouchable->GetVolume();
111 
112  G4VPhysicalVolume* plane = theTouchable->GetVolume(2);
113 
114  G4int PlaneNumber = 0;
115  PlaneNumber=plane->GetCopyNo();
116  G4String PlaneName = plane->GetName();
117 
118  // The hits sees now the real strip
119 
120  G4int StripNumber = 0;
121  G4VPhysicalVolume* strip = 0;
122  strip = theTouchable->GetVolume();
123 
124  G4String StripName = strip->GetName();
125  StripNumber= strip->GetCopyNo();
126 
127  G4VPhysicalVolume* tile = theTouchable->GetVolume(1);
128  G4int TileNumber = tile->GetCopyNo();
129  G4String TileName = tile->GetName();
130 
131  G4int NTile = (TileNumber%TileTotal);
132  G4int j=0;
133 
134  G4int NChannel = 0;
135 
136  for (j=0;j<TileTotal;j++)
137  {
138  if(NTile==j) StripNumber += StripTotal*NTile;
139  }
140 
141  NChannel = PlaneNumber*TileTotal*StripTotal + StripNumber;
142 
143  /* G4cout << NChannel << " Channel Number" << G4endl;
144  G4cout << " Plane Number = " << PlaneNumber << " " << PlaneName
145  << G4endl;
146  G4cout << StripName << " " << StripNumber << G4endl; */
147 
148  if (PlaneName == "TKRDetectorX" )
149  // The hit is on an X silicon plane
150  {
151  // This is a new hit
152  if (ThitXID[NChannel]==-1)
153  {
155  TrackerHit->SetPlaneType(1);
156  TrackerHit->AddSil(edep);
157  TrackerHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
158  TrackerHit->SetNSilPlane(PlaneNumber);
159  TrackerHit->SetNStrip(StripNumber);
160  ThitXID[NChannel] =
161  TrackerCollection->insert(TrackerHit) -1;
162  }
163  else // This is not new
164  {
165  (*TrackerCollection)[ThitXID[NChannel]]->AddSil(edep);
166  // G4cout << "X" << PlaneNumber << " " << StripNumber << G4endl;
167  }
168  }
169 
170  if (PlaneName == "TKRDetectorY")
171  // The hit is on an Y silicon plane
172  {
173  // This is a new hit
174  if (ThitYID[NChannel]==-1)
175  {
177  TrackerHit->SetPlaneType(0);
178  TrackerHit->AddSil(edep);
179  TrackerHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
180  TrackerHit->SetNSilPlane(PlaneNumber);
181  TrackerHit->SetNStrip(StripNumber);
182  ThitYID[NChannel] =
183  TrackerCollection->insert(TrackerHit)-1;
184  }
185  else // This is not new
186  {
187  (*TrackerCollection)[ThitYID[NChannel]]->AddSil(edep);
188  // G4cout << "Y" << PlaneNumber << " " << StripNumber << G4endl;
189  }
190  }
191 
192  return true;
193 }
194 
195 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
196 
198 {
199  static G4int HCID = -1;
200  if(HCID<0)
201  {
203  }
204  HCE->AddHitsCollection(HCID,TrackerCollection);
205 
206 
207  for (G4int i=0;i<NbOfTKRChannels;i++)
208  {
209  ThitXID[i] = -1;
210  ThitYID[i] = -1;
211  };
212 }
213 
214 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
215 
217 {}
218 
219 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
220 
222 {}
223 
224 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
225 
227 {}
228 
229 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
230 
231 
232 
233 
234 
235 
236 
237 
238 
239 
240 
241 
242 
const XML_Char * name
Definition: expat.h:151
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
G4VPhysicalVolume * GetVolume(G4int depth=0) const
const G4VUserDetectorConstruction * GetUserDetectorConstruction() const
G4int insert(T *aHit)
const G4VTouchable * GetTouchable() const
int G4int
Definition: G4Types.hh:78
G4StepPoint * GetPreStepPoint() const
void Initialize(G4HCofThisEvent *)
G4bool ProcessHits(G4Step *astep, G4TouchableHistory *ROHist)
const G4String & GetName() const
const G4ThreeVector & GetPosition() const
bool G4bool
Definition: G4Types.hh:79
Definition: G4Step.hh:76
void SetPos(G4ThreeVector xyz)
G4THitsCollection< GammaRayTelTrackerHit > GammaRayTelTrackerHitsCollection
G4double GetTotalEnergyDeposit() const
void AddHitsCollection(G4int HCID, G4VHitsCollection *aHC)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
virtual G4int GetCopyNo() const =0
void EndOfEvent(G4HCofThisEvent *)
G4CollectionNameVector collectionName
double G4double
Definition: G4Types.hh:76
static constexpr double keV
Definition: G4SIunits.hh:216