source: trunk/examples/advanced/lAr_calorimeter/src/FCALHadModuleSD.cc@ 1254

Last change on this file since 1254 was 1230, checked in by garnier, 16 years ago

update to geant4.9.3

File size: 4.8 KB
RevLine 
[807]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// $Id: FCALHadModuleSD.cc,v 1.10 2006/07/21 11:45:53 ribon Exp $
[1230]27// GEANT4 tag $Name: geant4-09-03-cand-01 $
[807]28//
29//
30
31//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
32//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
33
34#include "FCALHadModuleSD.hh"
35
36#include "FCALCalorHit.hh"
37
38#include "FCALTestbeamSetup.hh"
39#include "FCALHadModule.hh"
40
41#include "G4VPhysicalVolume.hh"
42#include "G4Step.hh"
43#include "G4Track.hh"
44#include "G4VTouchable.hh"
45#include "G4TouchableHistory.hh"
46#include "G4SDManager.hh"
47
48#include "G4ios.hh"
49#include <iostream>
50#include <fstream>
51//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
52
53FCALHadModuleSD::FCALHadModuleSD(G4String name) : G4VSensitiveDetector(name),
54 InitF2(0)
55{
56 HadModule = new FCALHadModule();
57}
58
59//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
60
61FCALHadModuleSD::~FCALHadModuleSD()
62{
63 delete HadModule;
64}
65
66//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
67
68void FCALHadModuleSD::Initialize(G4HCofThisEvent*)
69{
70 if(InitF2 == 0) {
71 HadModule->InitializeGeometry();
72 InitF2++;
73 }
74 for (G4int j=0; j<2330; j++) { EvisF2Tile[j]=0.;}
75}
76
77//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
78
79G4bool FCALHadModuleSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
80{
81
82 G4double edep = aStep->GetTotalEnergyDeposit();
83 if (edep==0.) return false;
84
85 G4TouchableHistory* theTouchable
86 = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
87 G4VPhysicalVolume* physVol = theTouchable->GetVolume();
88
89
90 if(strcmp(physVol->GetName(),"F2LArGapPhysical")==0){
91 G4int F2LArGapId = physVol->GetCopyNo();
92 G4int F2TileId = HadModule->GetF2TileID(F2LArGapId);
93 EvisF2Tile[F2TileId] = EvisF2Tile[F2TileId] + edep;
94 };
95
96 return true;
97}
98
99//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
100
101void FCALHadModuleSD::EndOfEvent(G4HCofThisEvent*)
102{
103 G4int NF2Tile = 0;
104 G4int AddTileP[300];
105 G4double EvisTileP[300];
106 G4int i=0;
107
108 for (i=0; i<2330; i++){
109 if(EvisF2Tile[i] > 0.) {
110 NF2Tile++;
111 AddTileP[NF2Tile] = i;
112 EvisTileP[NF2Tile] = EvisF2Tile[i];
113 };};
114
115 G4cout << "Number of F2 tiles with Positive energy : " << NF2Tile << G4endl;
116
117 // Write data in File
118 //-------------------
119 G4String FileName = "HadModule_802_1mm.dat";
120 std::ios::openmode iostemp;
121 if(InitF2 == 1) {
122 iostemp = std::ios::out;
123 InitF2++;
124 } else {
125 iostemp = std::ios::out|std::ios::app; // std::ios::app;
126 };
127
128 std::ofstream HadDatafile(FileName, iostemp);
129 // EmDatafile.precision(5);
130
131 HadDatafile << NF2Tile << std::endl;
132 for (i=1; i <= NF2Tile; i++) {
133 HadDatafile << AddTileP[i] << " " << EvisTileP[i]/MeV << std::endl;
134 }
135 HadDatafile.close();
136
137
138
139
140}
141
142//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
143
144void FCALHadModuleSD::clear()
145{}
146
147//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
148
149void FCALHadModuleSD::DrawAll()
150{}
151
152//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
153
154void FCALHadModuleSD::PrintAll()
155{}
156
157//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
158
Note: See TracBrowser for help on using the repository browser.