Geant4  10.01
XAluminumElectrodeSensitivity.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 //
28 //
29 // $Id: XAluminumElectrodeSensitivity.cc 76246 2013-11-08 11:17:29Z gcosmo $
30 //
32 
33 #include "XAluminumElectrodeHit.hh"
34 #include "G4HCofThisEvent.hh"
35 #include "G4TouchableHistory.hh"
36 #include "G4Track.hh"
37 #include "G4Step.hh"
38 #include "G4SDManager.hh"
39 #include "G4Navigator.hh"
40 #include "G4SystemOfUnits.hh"
41 #include "G4ios.hh"
42 
43 
44 using namespace std;
45 
48 
49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
50 
53 {
54  G4String HCname;
55  collectionName.insert(HCname="XAluminumElectrodeHit");
56  fHCID = -1;
57  fWriter.open("caustic.ssv", fstream::out | fstream::ate);
58  fWriter2.open("timing.ssv", fstream::out | fstream::ate);
59 
60  if(!fWriter.is_open()){
61  G4cout<<"\nXAluminumElectrodeSensitivity::Constructor:";
62  G4cout<<"\n\tFailed to open caustic.ssv for appending data.";
63  G4cout<<"\n\tCreating caustic.ssv" << G4endl;
64  fWriter.open("caustic.ssv");
65  }
66 
67  if(!fWriter2.is_open()){
68  G4cout<<"\nXAluminumElectrodeSensitivity::Constructor: ";
69  G4cout<<"\n\tFailed to open timing.ssv for appending data.";
70  G4cout<<"\n\tCreating timing.ssv." << G4endl;
71  fWriter2.open("timing.ssv");
72  }
73 
74  if(!(fWriter.is_open() && fWriter2.is_open())){
75  G4cout<<"\nXAluminumElectrodeSensitivity::Constructor: "
76  <<"\nERROR: COULD NOT CREATE OUTPUT FILES FOR WRITING" << G4endl;
77  }
78 }
79 
80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
81 
83  fWriter.close();
84  fWriter2.close();
85 }
86 
87 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
88 
91  return fHitsCollection;
92 }
93 
94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
95 
97 {
100  if(fHCID<0)
103 }
104 
105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
106 
108  G4TouchableHistory* /*ROhist*/)
109 {
110  //if(aStep->GetTrack()->GetDefinition()!=Phonon::PhononDefinition()) return true;
111  G4double edp = aStep->GetNonIonizingEnergyDeposit();
112  if(edp==0.) return true;
113 
114  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
115  G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
116  G4TouchableHistory* theTouchable
117  = (G4TouchableHistory*)(preStepPoint->GetTouchable());
118  G4ThreeVector fWorldPos = postStepPoint->GetPosition();
119  G4ThreeVector fLocalPos
120  = theTouchable->GetHistory()->GetTopTransform().TransformPoint(fWorldPos);
121 
123  aHit->SetTime(postStepPoint->GetGlobalTime());
124  aHit->SetEDep(edp);
125  aHit->SetWorldPos(fWorldPos);
126  aHit->SetLocalPos(fLocalPos);
127 
128  fHitsCollection->insert(aHit);
129 
130  fWriter<<"\n"<<fWorldPos.getX()/mm
131  <<","<<fWorldPos.getY()/mm
132  <<","<<fWorldPos.getZ()/mm;
133 
134  fWriter2<<"\n"<<postStepPoint->GetGlobalTime()/ns<<" "
135  <<aHit->GetEDep()/eV;
136 
137  return true;
138 }
139 
140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
141 
143 {;}
144 
void SetWorldPos(G4ThreeVector xyz)
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:131
CLHEP::Hep3Vector G4ThreeVector
void SetLocalPos(G4ThreeVector xyz)
G4String name
Definition: TRTMaterials.hh:40
G4double GetNonIonizingEnergyDeposit() const
G4int insert(T *aHit)
const G4VTouchable * GetTouchable() const
G4StepPoint * GetPreStepPoint() const
G4GLOB_DLL std::ostream G4cout
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)
const G4ThreeVector & GetPosition() const
bool G4bool
Definition: G4Types.hh:79
XAluminumElectrodeHitsCollection * GetHitsCollection()
Definition: G4Step.hh:76
G4THitsCollection< XAluminumElectrodeHit > XAluminumElectrodeHitsCollection
Definition of the XAluminumElectrodeHit class.
void AddHitsCollection(G4int HCID, G4VHitsCollection *aHC)
Definition of the XAluminumElectrodeSensitivity class.
static const double eV
Definition: G4SIunits.hh:194
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
G4StepPoint * GetPostStepPoint() const
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
static XAluminumElectrodeHitsCollection * fHitsCollection
virtual void Initialize(G4HCofThisEvent *)
#define G4endl
Definition: G4ios.hh:61
G4double GetGlobalTime() const
const G4AffineTransform & GetTopTransform() const
G4CollectionNameVector collectionName
const G4NavigationHistory * GetHistory() const
virtual void EndOfEvent(G4HCofThisEvent *)
double G4double
Definition: G4Types.hh:76
static const double mm
Definition: G4SIunits.hh:102
#define ns
Definition: xmlparse.cc:597