Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
eRositaTrackerSD.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 // $Id$
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 {
58  trackerCollection = new eRositaTrackerHitsCollection
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