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: A01EmCalorimeterHit.cc,v 1.12 2006/11/14 07:11:19 perl Exp $ |
---|
27 | // -------------------------------------------------------------- |
---|
28 | // |
---|
29 | |
---|
30 | #include "A01EmCalorimeterHit.hh" |
---|
31 | #include "G4VVisManager.hh" |
---|
32 | #include "G4Colour.hh" |
---|
33 | #include "G4AttDefStore.hh" |
---|
34 | #include "G4AttDef.hh" |
---|
35 | #include "G4AttValue.hh" |
---|
36 | #include "G4UIcommand.hh" |
---|
37 | #include "G4UnitsTable.hh" |
---|
38 | #include "G4VisAttributes.hh" |
---|
39 | #include "G4LogicalVolume.hh" |
---|
40 | #include "G4ios.hh" |
---|
41 | |
---|
42 | G4Allocator<A01EmCalorimeterHit> A01EmCalorimeterHitAllocator; |
---|
43 | |
---|
44 | A01EmCalorimeterHit::A01EmCalorimeterHit() |
---|
45 | { |
---|
46 | cellID = -1; |
---|
47 | edep = 0.; |
---|
48 | pLogV = 0; |
---|
49 | } |
---|
50 | |
---|
51 | A01EmCalorimeterHit::A01EmCalorimeterHit(G4int z) |
---|
52 | { |
---|
53 | cellID = z; |
---|
54 | edep = 0.; |
---|
55 | pLogV = 0; |
---|
56 | } |
---|
57 | |
---|
58 | A01EmCalorimeterHit::~A01EmCalorimeterHit() |
---|
59 | {;} |
---|
60 | |
---|
61 | A01EmCalorimeterHit::A01EmCalorimeterHit(const A01EmCalorimeterHit &right) |
---|
62 | : G4VHit() { |
---|
63 | cellID = right.cellID; |
---|
64 | edep = right.edep; |
---|
65 | pos = right.pos; |
---|
66 | rot = right.rot; |
---|
67 | pLogV = right.pLogV; |
---|
68 | } |
---|
69 | |
---|
70 | const A01EmCalorimeterHit& A01EmCalorimeterHit::operator=(const A01EmCalorimeterHit &right) |
---|
71 | { |
---|
72 | cellID = right.cellID; |
---|
73 | edep = right.edep; |
---|
74 | pos = right.pos; |
---|
75 | rot = right.rot; |
---|
76 | pLogV = right.pLogV; |
---|
77 | return *this; |
---|
78 | } |
---|
79 | |
---|
80 | int A01EmCalorimeterHit::operator==(const A01EmCalorimeterHit &right) const |
---|
81 | { |
---|
82 | return (cellID==right.cellID); |
---|
83 | } |
---|
84 | |
---|
85 | void A01EmCalorimeterHit::Draw() |
---|
86 | { |
---|
87 | G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance(); |
---|
88 | if(pVVisManager&&(edep>0.)) |
---|
89 | { |
---|
90 | // Draw a calorimeter cell with a color corresponding to its energy deposit |
---|
91 | G4Transform3D trans(rot.inverse(),pos); |
---|
92 | G4VisAttributes attribs; |
---|
93 | const G4VisAttributes* pVA = pLogV->GetVisAttributes(); |
---|
94 | if(pVA) attribs = *pVA; |
---|
95 | G4double rcol = edep/(0.7*GeV); |
---|
96 | if(rcol>1.) rcol = 1.; |
---|
97 | if(rcol<0.4) rcol = 0.4; |
---|
98 | G4Colour colour(rcol,0.,0.); |
---|
99 | attribs.SetColour(colour); |
---|
100 | attribs.SetForceSolid(true); |
---|
101 | pVVisManager->Draw(*pLogV,attribs,trans); |
---|
102 | } |
---|
103 | } |
---|
104 | |
---|
105 | const std::map<G4String,G4AttDef>* A01EmCalorimeterHit::GetAttDefs() const |
---|
106 | { |
---|
107 | G4bool isNew; |
---|
108 | std::map<G4String,G4AttDef>* store |
---|
109 | = G4AttDefStore::GetInstance("A01EmCalorimeterHit",isNew); |
---|
110 | if (isNew) { |
---|
111 | G4String HitType("HitType"); |
---|
112 | (*store)[HitType] = G4AttDef(HitType,"Hit Type","Physics","","G4String"); |
---|
113 | |
---|
114 | G4String ID("ID"); |
---|
115 | (*store)[ID] = G4AttDef(ID,"ID","Physics","","G4int"); |
---|
116 | |
---|
117 | G4String Energy("Energy"); |
---|
118 | (*store)[Energy] = G4AttDef(Energy,"Energy Deposited","Physics","G4BestUnit","G4double"); |
---|
119 | |
---|
120 | G4String Pos("Pos"); |
---|
121 | (*store)[Pos] = G4AttDef(Pos, "Position", |
---|
122 | "Physics","G4BestUnit","G4ThreeVector"); |
---|
123 | |
---|
124 | G4String LVol("LVol"); |
---|
125 | (*store)[LVol] = G4AttDef(LVol,"Logical Volume","Physics","","G4String"); |
---|
126 | } |
---|
127 | return store; |
---|
128 | } |
---|
129 | |
---|
130 | std::vector<G4AttValue>* A01EmCalorimeterHit::CreateAttValues() const |
---|
131 | { |
---|
132 | std::vector<G4AttValue>* values = new std::vector<G4AttValue>; |
---|
133 | |
---|
134 | values->push_back(G4AttValue("HitType","EmCalorimeterHit","")); |
---|
135 | |
---|
136 | values->push_back |
---|
137 | (G4AttValue("ID",G4UIcommand::ConvertToString(cellID),"")); |
---|
138 | |
---|
139 | values->push_back |
---|
140 | (G4AttValue("Energy",G4BestUnit(edep,"Energy"),"")); |
---|
141 | |
---|
142 | values->push_back |
---|
143 | (G4AttValue("Pos",G4BestUnit(pos,"Length"),"")); |
---|
144 | |
---|
145 | if (pLogV) |
---|
146 | values->push_back |
---|
147 | (G4AttValue("LVol",pLogV->GetName(),"")); |
---|
148 | else |
---|
149 | values->push_back |
---|
150 | (G4AttValue("LVol"," ","")); |
---|
151 | |
---|
152 | return values; |
---|
153 | } |
---|
154 | |
---|
155 | void A01EmCalorimeterHit::Print() |
---|
156 | { |
---|
157 | G4cout << " Cell[" << cellID << "] " << edep/MeV << " (MeV)" << G4endl; |
---|
158 | } |
---|
159 | |
---|
160 | |
---|