Geant4_10
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 
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(1);
113 
114  G4int PlaneNumber = 0;
115  PlaneNumber=plane->GetCopyNo();
116  G4String PlaneName = plane->GetName();
117 
118  // The RO History is used to obtain the real strip
119  // of the hit
120 
121  G4int StripNumber = 0;
122  G4VPhysicalVolume* strip = 0;
123  strip = ROhist->GetVolume();
124 
125  // if (strip){
126  G4String StripName = strip->GetName();
127  StripNumber= strip->GetCopyNo();
128  // }
129  // ROhist->MoveUpHistory();
130  G4VPhysicalVolume* tile = ROhist->GetVolume(1);
131  G4int TileNumber = tile->GetCopyNo();
132  G4String TileName = tile->GetName();
133 
134  G4int NTile = (TileNumber%TileTotal);
135  G4int j=0;
136 
137  G4int NChannel = 0;
138 
139  for (j=0;j<TileTotal;j++)
140  {
141  if(NTile==j) StripNumber += StripTotal*NTile;
142  }
143 
144  NChannel = PlaneNumber*TileTotal*StripTotal + StripNumber;
145 
146  /* G4cout << NChannel << " Channel Number" << G4endl;
147  G4cout << " Plane Number = " << PlaneNumber << " " << PlaneName
148  << G4endl;
149  G4cout << StripName << " " << StripNumber << G4endl; */
150 
151  if (PlaneName == "TKRDetectorX" )
152  // The hit is on an X silicon plane
153  {
154  // This is a new hit
155  if (ThitXID[NChannel]==-1)
156  {
158  TrackerHit->SetPlaneType(1);
159  TrackerHit->AddSil(edep);
160  TrackerHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
161  TrackerHit->SetNSilPlane(PlaneNumber);
162  TrackerHit->SetNStrip(StripNumber);
163  ThitXID[NChannel] =
164  TrackerCollection->insert(TrackerHit) -1;
165  }
166  else // This is not new
167  {
168  (*TrackerCollection)[ThitXID[NChannel]]->AddSil(edep);
169  // G4cout << "X" << PlaneNumber << " " << StripNumber << G4endl;
170  }
171  }
172 
173  if (PlaneName == "TKRDetectorY")
174  // The hit is on an Y silicon plane
175  {
176  // This is a new hit
177  if (ThitYID[NChannel]==-1)
178  {
180  TrackerHit->SetPlaneType(0);
181  TrackerHit->AddSil(edep);
182  TrackerHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
183  TrackerHit->SetNSilPlane(PlaneNumber);
184  TrackerHit->SetNStrip(StripNumber);
185  ThitYID[NChannel] =
186  TrackerCollection->insert(TrackerHit)-1;
187  }
188  else // This is not new
189  {
190  (*TrackerCollection)[ThitYID[NChannel]]->AddSil(edep);
191  // G4cout << "Y" << PlaneNumber << " " << StripNumber << G4endl;
192  }
193  }
194 
195  return true;
196 }
197 
198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
199 
201 {
202  static G4int HCID = -1;
203  if(HCID<0)
204  {
206  }
207  HCE->AddHitsCollection(HCID,TrackerCollection);
208 
209 
210  for (G4int i=0;i<NbOfTKRChannels;i++)
211  {
212  ThitXID[i] = -1;
213  ThitYID[i] = -1;
214  };
215 }
216 
217 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
218 
220 {}
221 
222 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
223 
225 {}
226 
227 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
228 
230 {}
231 
232 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
233 
234 
235 
236 
237 
238 
239 
240 
241 
242 
243 
244 
245 
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:131
G4VPhysicalVolume * GetVolume(G4int depth=0) const
const G4VUserDetectorConstruction * GetUserDetectorConstruction() const
const XML_Char * name
Definition: expat.h:151
G4int insert(T *aHit)
const G4VTouchable * GetTouchable() const
int G4int
Definition: G4Types.hh:78
Double_t edep
Definition: macro.C:13
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:74
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
virtual G4int GetCopyNo() const =0
void EndOfEvent(G4HCofThisEvent *)
G4CollectionNameVector collectionName
double G4double
Definition: G4Types.hh:76