Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
ExP01TrackerSD.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 //
28 //
29 //
30 // $Id: ExP01TrackerSD.cc 71111 2013-06-11 10:51:02Z gcosmo $
31 //
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 
35 #include "ExP01TrackerSD.hh"
36 #include "G4HCofThisEvent.hh"
37 #include "G4Step.hh"
38 #include "G4ThreeVector.hh"
39 #include "G4SDManager.hh"
40 #include "G4ios.hh"
41 
42 #include "RootIO.hh"
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
47  :G4VSensitiveDetector(name), fTrackerCollection(0), fHCID(0)
48 {
49  G4String HCname = name + "_HC";
50  collectionName.insert(HCname);
51  G4cout << collectionName.size() << " CalorimeterSD name: " << name << " collection Name: "
52  << HCname << G4endl;
53  fHCID = -1;
54 }
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
59 {
61 }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 
66 {
69  if (fHCID < 0) {
70  G4cout << "CalorimeterSD::Initialize: " << SensitiveDetectorName << " "
71  << collectionName[0] << G4endl;
73 
74  }
76 }
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79 
81 {
83 
84  if(edep==0.) return false;
85 
86  ExP01TrackerHit* newHit = new ExP01TrackerHit();
87  newHit->SetTrackID (aStep->GetTrack()->GetTrackID());
88  newHit->SetChamberNb(aStep->GetPreStepPoint()->GetTouchable()
89  ->GetReplicaNumber());
90  newHit->SetEdep (edep);
91  newHit->SetPos (aStep->GetPostStepPoint()->GetPosition());
92  fTrackerCollection->insert( newHit );
93 
94  //newHit->Print();
95  //newHit->Draw();
96 
97  return true;
98 }
99 
100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
101 
103 {
104  // storing the hits in ROOT file
105  G4int NbHits = fTrackerCollection->entries();
106  std::vector<ExP01TrackerHit*> hitsVector;
107 
108  {
109  G4cout << "\n-------->Storing hits in the ROOT file: in this event there are " << NbHits
110  << " hits in the tracker chambers: " << G4endl;
111  for (G4int i=0;i<NbHits;i++) (*fTrackerCollection)[i]->Print();
112  }
113 
114 
115  for (G4int i=0;i<NbHits;i++)
116  hitsVector.push_back((*fTrackerCollection)[i]);
117 
118  RootIO::GetInstance()->Write(&hitsVector);
119 
120  //
121 }
122 
123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
124 
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
const XML_Char * name
Definition: expat.h:151
const G4VTouchable * GetTouchable() const
void SetPos(G4ThreeVector xyz)
G4THitsCollection< ExP01TrackerHit > ExP01TrackerHitsCollection
G4StepPoint * GetPreStepPoint() const
#define G4endl
Definition: G4ios.hh:61
virtual void Initialize(G4HCofThisEvent *)
void AddHitsCollection(G4int HCID, G4VHitsCollection *aHC)
Hit implementation for the persistency example.
G4int GetTrackID() const
void Write(std::vector< ExP01TrackerHit * > *)
Definition: RootIO.cc:79
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
const G4ThreeVector & GetPosition() const
void SetChamberNb(G4int chamb)
Definition of the RootIO class.
G4Track * GetTrack() const
G4double GetTotalEnergyDeposit() const
Definition: G4Step.hh:76
G4StepPoint * GetPostStepPoint() const
void SetTrackID(G4int track)
Double_t edep
virtual void EndOfEvent(G4HCofThisEvent *)
ExP01TrackerSD(G4String)
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
int G4int
Definition: G4Types.hh:78
G4CollectionNameVector collectionName
virtual G4int GetReplicaNumber(G4int depth=0) const
Definition: G4VTouchable.cc:58
G4GLOB_DLL std::ostream G4cout
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)
Definition of the ExP01TrackerSD class.
ExP01TrackerHitsCollection * fTrackerCollection
void SetEdep(G4double de)
void Close()
Definition: RootIO.cc:96
static RootIO * GetInstance()
Definition: RootIO.cc:68