source: trunk/examples/extended/parallel/ParN04/src/ExN04CalorimeterSD.cc@ 1230

Last change on this file since 1230 was 807, checked in by garnier, 17 years ago

update

File size: 4.1 KB
Line 
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#include "ExN04CalorimeterSD.hh"
28#include "ExN04CalorimeterHit.hh"
29#include "G4VPhysicalVolume.hh"
30#include "G4LogicalVolume.hh"
31#include "G4Track.hh"
32#include "G4Step.hh"
33#include "G4ParticleDefinition.hh"
34#include "G4VTouchable.hh"
35#include "G4TouchableHistory.hh"
36#include "G4ios.hh"
37
38ExN04CalorimeterSD::ExN04CalorimeterSD(G4String name)
39:G4VSensitiveDetector(name),
40 numberOfCellsInZ(20),numberOfCellsInPhi(48)
41{
42 G4String HCname;
43 collectionName.insert(HCname="calCollection");
44}
45
46ExN04CalorimeterSD::~ExN04CalorimeterSD()
47{;}
48
49void ExN04CalorimeterSD::Initialize(G4HCofThisEvent*)
50{
51 CalCollection = new ExN04CalorimeterHitsCollection
52 (SensitiveDetectorName,collectionName[0]);
53 for(G4int j=0;j<numberOfCellsInZ;j++)
54 for(G4int k=0;k<numberOfCellsInPhi;k++)
55 {
56 CellID[j][k] = -1;
57 }
58 verboseLevel = 0;
59}
60
61G4bool ExN04CalorimeterSD::ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist)
62{
63 if(!ROhist) return false;
64 G4double edep = aStep->GetTotalEnergyDeposit();
65 if(verboseLevel>1) G4cout << "Next step edep(MeV) = " << edep/MeV << G4endl;
66 if(edep==0.) return false;
67
68 G4VPhysicalVolume* physVol = ROhist->GetVolume();
69 //ROhist->MoveUpHistory();
70 //G4VPhysicalVolume* mothVol = ROhist->GetVolume(1);
71 G4int copyIDinZ = ROhist->GetReplicaNumber();
72 G4int copyIDinPhi = ROhist->GetReplicaNumber(1);
73
74 if(CellID[copyIDinZ][copyIDinPhi]==-1)
75 {
76 ExN04CalorimeterHit* calHit
77 = new ExN04CalorimeterHit
78 (physVol->GetLogicalVolume(),copyIDinZ,copyIDinPhi);
79 calHit->SetEdep( edep );
80 G4AffineTransform aTrans = ROhist->GetHistory()->GetTopTransform();
81 aTrans.Invert();
82 calHit->SetPos(aTrans.NetTranslation());
83 calHit->SetRot(aTrans.NetRotation());
84 G4int icell = CalCollection->insert( calHit );
85 CellID[copyIDinZ][copyIDinPhi] = icell - 1;
86 if(verboseLevel>0)
87 { G4cout << " New Calorimeter Hit on CellID "
88 << copyIDinZ << " " << copyIDinPhi << G4endl; }
89 }
90 else
91 {
92 (*CalCollection)[CellID[copyIDinZ][copyIDinPhi]]->AddEdep(edep);
93 if(verboseLevel>0)
94 { G4cout << " Energy added to CellID "
95 << copyIDinZ << " " << copyIDinPhi << G4endl; }
96 }
97
98 return true;
99}
100
101void ExN04CalorimeterSD::EndOfEvent(G4HCofThisEvent*HCE)
102{
103 static G4int HCID = -1;
104 if(HCID<0)
105 { HCID = GetCollectionID(0); }
106 HCE->AddHitsCollection( HCID, CalCollection );
107}
108
109void ExN04CalorimeterSD::clear()
110{
111}
112
113void ExN04CalorimeterSD::DrawAll()
114{
115}
116
117void ExN04CalorimeterSD::PrintAll()
118{
119}
120
Note: See TracBrowser for help on using the repository browser.