ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B5EmCalorimeterHit.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file B5EmCalorimeterHit.cc
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 //
29 
30 #include "B5EmCalorimeterHit.hh"
31 
32 #include "G4VVisManager.hh"
33 #include "G4VisAttributes.hh"
34 #include "G4Colour.hh"
35 #include "G4AttDefStore.hh"
36 #include "G4AttDef.hh"
37 #include "G4AttValue.hh"
38 #include "G4UIcommand.hh"
39 #include "G4UnitsTable.hh"
40 #include "G4SystemOfUnits.hh"
41 #include "G4ios.hh"
42 
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44 
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 
50 : G4VHit(),
51  fCellID(-1), fEdep(0.), fPos(0.), fPLogV(nullptr)
52 {}
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
57 : G4VHit(),
58  fCellID(cellID), fEdep(0.), fPos(0.), fPLogV(nullptr)
59 {}
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 
64 {}
65 
66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
67 
69 : G4VHit(),
70  fCellID(right.fCellID),
71  fEdep(right.fEdep),
72  fPos(right.fPos),
73  fRot(right.fRot),
74  fPLogV(right.fPLogV)
75 {}
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 
80  &right)
81 {
82  fCellID = right.fCellID;
83  fEdep = right.fEdep;
84  fPos = right.fPos;
85  fRot = right.fRot;
86  fPLogV = right.fPLogV;
87  return *this;
88 }
89 
90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
91 
93 {
94  return (fCellID==right.fCellID);
95 }
96 
97 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
98 
100 {
101  auto visManager = G4VVisManager::GetConcreteInstance();
102  if ( ! visManager || (fEdep==0.) ) return;
103 
104  // Draw a calorimeter cell with a color corresponding to its energy deposit
105  G4Transform3D trans(fRot.inverse(),fPos);
106  G4VisAttributes attribs;
107  auto pVA = fPLogV->GetVisAttributes();
108  if (pVA) attribs = *pVA;
109  auto rcol = fEdep/(0.7*GeV);
110  if (rcol>1.) rcol = 1.;
111  if (rcol<0.4) rcol = 0.4;
112  G4Colour colour(rcol,0.,0.);
113  attribs.SetColour(colour);
114  attribs.SetForceSolid(true);
115  visManager->Draw(*fPLogV,attribs,trans);
116 }
117 
118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
119 
120 const std::map<G4String,G4AttDef>* B5EmCalorimeterHit::GetAttDefs() const
121 {
122  G4bool isNew;
123  auto store = G4AttDefStore::GetInstance("B5EmCalorimeterHit",isNew);
124 
125  if (isNew) {
126  (*store)["HitType"]
127  = G4AttDef("HitType","Hit Type","Physics","","G4String");
128 
129  (*store)["ID"]
130  = G4AttDef("ID","ID","Physics","","G4int");
131 
132  (*store)["Energy"]
133  = G4AttDef("Energy", "Energy Deposited", "Physics", "G4BestUnit",
134  "G4double");
135 
136  (*store)["Pos"]
137  = G4AttDef("Pos", "Position", "Physics","G4BestUnit",
138  "G4ThreeVector");
139 
140  (*store)["LVol"]
141  = G4AttDef("LVol","Logical Volume","Physics","","G4String");
142  }
143  return store;
144 }
145 
146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
147 
148 std::vector<G4AttValue>* B5EmCalorimeterHit::CreateAttValues() const
149 {
150  auto values = new std::vector<G4AttValue>;
151 
152  values
153  ->push_back(G4AttValue("HitType","EmCalorimeterHit",""));
154  values
155  ->push_back(G4AttValue("ID",G4UIcommand::ConvertToString(fCellID),""));
156  values
157  ->push_back(G4AttValue("Energy",G4BestUnit(fEdep,"Energy"),""));
158  values
159  ->push_back(G4AttValue("Pos",G4BestUnit(fPos,"Length"),""));
160 
161  if (fPLogV)
162  values->push_back(G4AttValue("LVol",fPLogV->GetName(),""));
163  else
164  values->push_back(G4AttValue("LVol"," ",""));
165 
166  return values;
167 }
168 
169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
170 
172 {
173  G4cout << " Cell[" << fCellID << "] " << fEdep/MeV << " (MeV)" << G4endl;
174 }
175 
176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......