Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
eRositaTrackerSD.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 // $Id: eRositaTrackerSD.cc 107396 2017-11-10 08:28:08Z gcosmo $
28 //
29 
30 #include "eRositaTrackerSD.hh"
31 #include "G4HCofThisEvent.hh"
32 #include "G4Step.hh"
33 #include "G4ThreeVector.hh"
34 #include "G4SDManager.hh"
35 #include "G4ios.hh"
36 #include "G4ParticleTypes.hh"
37 
38 #include <iostream>
39 #include <fstream>
40 
41 #include "AnalysisManager.hh"
42 
43 
44 
47 {
48  G4String HCname;
49  collectionName.insert(HCname="trackerCollection");
50 }
51 
52 
54 
55 
57 {
60  static G4int HCID = -1;
61  if (HCID < 0)
62  {
64  }
65  HCE->AddHitsCollection( HCID, trackerCollection );
66 }
67 
68 
70 {
71  if(aStep->GetTrack()->GetDefinition() != G4Gamma::GammaDefinition()) return false;
72 
73 // G4double edep = aStep->GetTotalEnergyDeposit();
75 
76  if (edep == 0.) return false;
77 
78  eRositaTrackerHit* newHit = new eRositaTrackerHit();
79  newHit->SetTrackID (aStep->GetTrack()->GetTrackID());
80  //newHit->SetChamberNb(aStep->GetPreStepPoint()->GetTouchableHandle()
81  // ->GetCopyNumber());
82  newHit->SetEdep(edep);
83  newHit->SetPos(aStep->GetPostStepPoint()->GetPosition());
84  trackerCollection->insert( newHit );
85 
86  //newHit->Print();
87  //newHit->Draw();
88 
89  //ofstream out("ASCII");
90  //newHit->PrintToFile(out);
91  //out.close();
92 
93  return true;
94 }
95 
96 
98 {
99  G4int NbHits = trackerCollection->entries();
100 
101  if (verboseLevel > 0)
102  {
103 
104  G4cout << std::endl
105  << "Hits Collection: in this event they are " << NbHits
106  << " hits in the tracker chambers: " << G4endl;
107  for (G4int i=0;i<NbHits;i++) (*trackerCollection)[i]->Print();
108 
109  }
110 
111  // ofstream out("ASCII");
112  //if (!out.is_open())
113  // {
114  // G4cout <<"...opening ASCII file failed";
115  // }
116 
117  double eTot = 0.;
118 
119  for (G4int i=0; i<NbHits; i++)
120  {
121  (*trackerCollection)[i]->PrintToFile();
122  eTot += (*trackerCollection)[i]->GetEdep();
123  };
124 
125 // if (eTot > 0.) AnalysisManager::Instance()->ScoreTot(eTot);
126 
127 //out.close();
128 }
129 
130 
131 
132 
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
void SetPos(G4ThreeVector xyz)
void EndOfEvent(G4HCofThisEvent *)
const XML_Char * name
Definition: expat.h:151
eRositaTrackerHitsCollection * trackerCollection
G4bool ProcessHits(G4Step *, G4TouchableHistory *)
G4StepPoint * GetPreStepPoint() const
#define G4endl
Definition: G4ios.hh:61
void AddHitsCollection(G4int HCID, G4VHitsCollection *aHC)
G4int GetTrackID() const
G4ParticleDefinition * GetDefinition() const
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
void Initialize(G4HCofThisEvent *)
const G4ThreeVector & GetPosition() const
G4THitsCollection< eRositaTrackerHit > eRositaTrackerHitsCollection
G4Track * GetTrack() const
Definition: G4Step.hh:76
G4StepPoint * GetPostStepPoint() const
G4double GetKineticEnergy() const
Double_t edep
static G4Gamma * GammaDefinition()
Definition: G4Gamma.cc:81
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
int G4int
Definition: G4Types.hh:78
void SetTrackID(G4int track)
G4CollectionNameVector collectionName
eRositaTrackerSD(G4String)
G4GLOB_DLL std::ostream G4cout
void SetEdep(G4double de)