ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
eRositaTrackerSD.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file 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 //
28 
29 #include "eRositaTrackerSD.hh"
30 #include "G4HCofThisEvent.hh"
31 #include "G4Step.hh"
32 #include "G4ThreeVector.hh"
33 #include "G4SDManager.hh"
34 #include "G4ios.hh"
35 #include "G4ParticleTypes.hh"
36 
37 #include <iostream>
38 #include <fstream>
39 
40 #include "AnalysisManager.hh"
41 
42 
43 
46 {
47  G4String HCname;
48  collectionName.insert(HCname="trackerCollection");
49 }
50 
51 
53 
54 
56 {
59  static G4int HCID = -1;
60  if (HCID < 0)
61  {
63  }
64  HCE->AddHitsCollection( HCID, trackerCollection );
65 }
66 
67 
69 {
70  if(aStep->GetTrack()->GetDefinition() != G4Gamma::GammaDefinition()) return false;
71 
72 // G4double edep = aStep->GetTotalEnergyDeposit();
74 
75  if (edep == 0.) return false;
76 
77  eRositaTrackerHit* newHit = new eRositaTrackerHit();
78  newHit->SetTrackID (aStep->GetTrack()->GetTrackID());
79  //newHit->SetChamberNb(aStep->GetPreStepPoint()->GetTouchableHandle()
80  // ->GetCopyNumber());
81  newHit->SetEdep(edep);
82  newHit->SetPos(aStep->GetPostStepPoint()->GetPosition());
83  trackerCollection->insert( newHit );
84 
85  //newHit->Print();
86  //newHit->Draw();
87 
88  //ofstream out("ASCII");
89  //newHit->PrintToFile(out);
90  //out.close();
91 
92  return true;
93 }
94 
95 
97 {
98  G4int NbHits = trackerCollection->entries();
99 
100  if (verboseLevel > 0)
101  {
102 
103  G4cout << std::endl
104  << "Hits Collection: in this event they are " << NbHits
105  << " hits in the tracker chambers: " << G4endl;
106  for (G4int i=0;i<NbHits;i++) (*trackerCollection)[i]->Print();
107 
108  }
109 
110  // ofstream out("ASCII");
111  //if (!out.is_open())
112  // {
113  // G4cout <<"...opening ASCII file failed";
114  // }
115 
116  double eTot = 0.;
117 
118  for (G4int i=0; i<NbHits; i++)
119  {
120  (*trackerCollection)[i]->PrintToFile();
121  eTot += (*trackerCollection)[i]->GetEdep();
122  };
123 
124 // if (eTot > 0.) AnalysisManager::Instance()->ScoreTot(eTot);
125 
126 //out.close();
127 }
128 
129 
130 
131