Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B5EmCalorimeterHit.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 //
26 // $Id: B5EmCalorimeterHit.cc 101036 2016-11-04 09:00:23Z gcosmo $
27 //
30 
31 #include "B5EmCalorimeterHit.hh"
32 
33 #include "G4VVisManager.hh"
34 #include "G4VisAttributes.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 "G4SystemOfUnits.hh"
42 #include "G4ios.hh"
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
47 
48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 
51 : G4VHit(),
52  fCellID(-1), fEdep(0.), fPos(0.), fPLogV(nullptr)
53 {}
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
58 : G4VHit(),
59  fCellID(cellID), fEdep(0.), fPos(0.), fPLogV(nullptr)
60 {}
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
65 {}
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 
70 : G4VHit(),
71  fCellID(right.fCellID),
72  fEdep(right.fEdep),
73  fPos(right.fPos),
74  fRot(right.fRot),
75  fPLogV(right.fPLogV)
76 {}
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79 
81  &right)
82 {
83  fCellID = right.fCellID;
84  fEdep = right.fEdep;
85  fPos = right.fPos;
86  fRot = right.fRot;
87  fPLogV = right.fPLogV;
88  return *this;
89 }
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92 
94 {
95  return (fCellID==right.fCellID);
96 }
97 
98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
99 
101 {
102  auto visManager = G4VVisManager::GetConcreteInstance();
103  if ( ! visManager || (fEdep==0.) ) return;
104 
105  // Draw a calorimeter cell with a color corresponding to its energy deposit
106  G4Transform3D trans(fRot.inverse(),fPos);
107  G4VisAttributes attribs;
108  auto pVA = fPLogV->GetVisAttributes();
109  if (pVA) attribs = *pVA;
110  auto rcol = fEdep/(0.7*GeV);
111  if (rcol>1.) rcol = 1.;
112  if (rcol<0.4) rcol = 0.4;
113  G4Colour colour(rcol,0.,0.);
114  attribs.SetColour(colour);
115  attribs.SetForceSolid(true);
116  visManager->Draw(*fPLogV,attribs,trans);
117 }
118 
119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
120 
121 const std::map<G4String,G4AttDef>* B5EmCalorimeterHit::GetAttDefs() const
122 {
123  G4bool isNew;
124  auto store = G4AttDefStore::GetInstance("B5EmCalorimeterHit",isNew);
125 
126  if (isNew) {
127  (*store)["HitType"]
128  = G4AttDef("HitType","Hit Type","Physics","","G4String");
129 
130  (*store)["ID"]
131  = G4AttDef("ID","ID","Physics","","G4int");
132 
133  (*store)["Energy"]
134  = G4AttDef("Energy", "Energy Deposited", "Physics", "G4BestUnit",
135  "G4double");
136 
137  (*store)["Pos"]
138  = G4AttDef("Pos", "Position", "Physics","G4BestUnit",
139  "G4ThreeVector");
140 
141  (*store)["LVol"]
142  = G4AttDef("LVol","Logical Volume","Physics","","G4String");
143  }
144  return store;
145 }
146 
147 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
148 
149 std::vector<G4AttValue>* B5EmCalorimeterHit::CreateAttValues() const
150 {
151  auto values = new std::vector<G4AttValue>;
152 
153  values
154  ->push_back(G4AttValue("HitType","EmCalorimeterHit",""));
155  values
156  ->push_back(G4AttValue("ID",G4UIcommand::ConvertToString(fCellID),""));
157  values
158  ->push_back(G4AttValue("Energy",G4BestUnit(fEdep,"Energy"),""));
159  values
160  ->push_back(G4AttValue("Pos",G4BestUnit(fPos,"Length"),""));
161 
162  if (fPLogV)
163  values->push_back(G4AttValue("LVol",fPLogV->GetName(),""));
164  else
165  values->push_back(G4AttValue("LVol"," ",""));
166 
167  return values;
168 }
169 
170 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
171 
173 {
174  G4cout << " Cell[" << fCellID << "] " << fEdep/MeV << " (MeV)" << G4endl;
175 }
176 
177 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ThreadLocal G4Allocator< B5EmCalorimeterHit > * B5EmCalorimeterHitAllocator
static G4VVisManager * GetConcreteInstance()
virtual std::vector< G4AttValue > * CreateAttValues() const
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:372
const B5EmCalorimeterHit & operator=(const B5EmCalorimeterHit &right)
Definition: G4VHit.hh:48
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
int operator==(const B5EmCalorimeterHit &right) const
HepRotation inverse() const
Definition of the B5EmCalorimeterHit class.
G4GLOB_DLL std::ostream G4cout
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
bool G4bool
Definition: G4Types.hh:79
const G4VisAttributes * GetVisAttributes() const
static constexpr double GeV
Definition: G4SIunits.hh:217
#define G4endl
Definition: G4ios.hh:61
static constexpr double MeV
Definition: G4SIunits.hh:214
std::map< G4String, G4AttDef > * GetInstance(const G4String &storeKey, G4bool &isNew)
const G4String & GetName() const