Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
A01EmCalorimeterHit.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 //
28 //
29 // $Id$
30 // --------------------------------------------------------------
31 //
32 
33 #include "A01EmCalorimeterHit.hh"
34 #include "G4VVisManager.hh"
35 #include "G4Colour.hh"
36 #include "G4AttDefStore.hh"
37 #include "G4AttDef.hh"
38 #include "G4AttValue.hh"
39 #include "G4UIcommand.hh"
40 #include "G4UnitsTable.hh"
41 #include "G4VisAttributes.hh"
42 #include "G4LogicalVolume.hh"
43 #include "G4SystemOfUnits.hh"
44 #include "G4ios.hh"
45 
47 
49 {
50  fCellID = -1;
51  fEdep = 0.;
52  fPLogV = 0;
53 }
54 
56 {
57  fCellID = z;
58  fEdep = 0.;
59  fPLogV = 0;
60 }
61 
63 {;}
64 
66  : G4VHit() {
67  fCellID = right.fCellID;
68  fEdep = right.fEdep;
69  fPos = right.fPos;
70  fRot = right.fRot;
71  fPLogV = right.fPLogV;
72 }
73 
75 {
76  fCellID = right.fCellID;
77  fEdep = right.fEdep;
78  fPos = right.fPos;
79  fRot = right.fRot;
80  fPLogV = right.fPLogV;
81  return *this;
82 }
83 
85 {
86  return (fCellID==right.fCellID);
87 }
88 
90 {
92  if(pVVisManager&&(fEdep>0.))
93  {
94  // Draw a calorimeter cell with a color corresponding to its energy deposit
95  G4Transform3D trans(fRot.inverse(),fPos);
96  G4VisAttributes attribs;
97  const G4VisAttributes* pVA = fPLogV->GetVisAttributes();
98  if(pVA) attribs = *pVA;
99  G4double rcol = fEdep/(0.7*GeV);
100  if(rcol>1.) rcol = 1.;
101  if(rcol<0.4) rcol = 0.4;
102  G4Colour colour(rcol,0.,0.);
103  attribs.SetColour(colour);
104  attribs.SetForceSolid(true);
105  pVVisManager->Draw(*fPLogV,attribs,trans);
106  }
107 }
108 
109 const std::map<G4String,G4AttDef>* A01EmCalorimeterHit::GetAttDefs() const
110 {
111  G4bool isNew;
112  std::map<G4String,G4AttDef>* store
113  = G4AttDefStore::GetInstance("A01EmCalorimeterHit",isNew);
114  if (isNew) {
115  G4String HitType("HitType");
116  (*store)[HitType] = G4AttDef(HitType,"Hit Type","Physics","","G4String");
117 
118  G4String ID("ID");
119  (*store)[ID] = G4AttDef(ID,"ID","Physics","","G4int");
120 
121  G4String Energy("Energy");
122  (*store)[Energy] = G4AttDef(Energy,"Energy Deposited","Physics","G4BestUnit","G4double");
123 
124  G4String Pos("Pos");
125  (*store)[Pos] = G4AttDef(Pos, "Position",
126  "Physics","G4BestUnit","G4ThreeVector");
127 
128  G4String LVol("LVol");
129  (*store)[LVol] = G4AttDef(LVol,"Logical Volume","Physics","","G4String");
130  }
131  return store;
132 }
133 
134 std::vector<G4AttValue>* A01EmCalorimeterHit::CreateAttValues() const
135 {
136  std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
137 
138  values->push_back(G4AttValue("HitType","EmCalorimeterHit",""));
139 
140  values->push_back
141  (G4AttValue("ID",G4UIcommand::ConvertToString(fCellID),""));
142 
143  values->push_back
144  (G4AttValue("Energy",G4BestUnit(fEdep,"Energy"),""));
145 
146  values->push_back
147  (G4AttValue("Pos",G4BestUnit(fPos,"Length"),""));
148 
149  if (fPLogV)
150  values->push_back
151  (G4AttValue("LVol",fPLogV->GetName(),""));
152  else
153  values->push_back
154  (G4AttValue("LVol"," ",""));
155 
156  return values;
157 }
158 
160 {
161  G4cout << " Cell[" << fCellID << "] " << fEdep/MeV << " (MeV)" << G4endl;
162 }
163 
164