Loading...
Searching...
No Matches
Par04Hit.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#include "Par04Hit.hh"
27#include <CLHEP/Units/SystemOfUnits.h> // for mm, pi, MeV, cm, rad
28#include <CLHEP/Vector/ThreeVector.h> // for operator/, operator<<, Hep...
29#include <G4RotationMatrix.hh> // for G4RotationMatrix
30#include <G4String.hh> // for G4String
31#include <G4ThreeVector.hh> // for G4ThreeVector
32#include <G4Transform3D.hh> // for G4Transform3D
33#include <G4VHit.hh> // for G4VHit
34#include <algorithm> // for max
35#include <iostream> // for operator<<, basic_ostream:...
36#include <string> // for operator<
37#include "G4AttDef.hh" // for G4AttDef
38#include "G4AttDefStore.hh" // for GetInstance
39#include "G4AttValue.hh" // for G4AttValue
40#include "G4Colour.hh" // for G4Colour
41#include "G4SystemOfUnits.hh" // for mm, MeV, cm, rad
42#include "G4Tubs.hh" // for G4Tubs
43#include "G4UnitsTable.hh" // for G4BestUnit
44#include "G4VVisManager.hh" // for G4VVisManager
45#include "G4VisAttributes.hh" // for G4VisAttributes
46#include <cmath> // for log10
47template <class Type> class G4Allocator;
48
50
51//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52
56
57//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58
59Par04Hit::~Par04Hit() = default;
60
61//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62
64 : G4VHit()
65{
66 fEdep = aRight.fEdep;
67 fNdep = aRight.fNdep;
68 fZId = aRight.fZId;
69 fRhoId = aRight.fRhoId;
70 fPhiId = aRight.fPhiId;
71 fTime = aRight.fTime;
72 fPos = aRight.fPos;
73 fRot = aRight.fRot;
74 fType = aRight.fType;
75 fLogVol = aRight.fLogVol;
76}
77
78//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79
81{
82 fEdep = aRight.fEdep;
83 fNdep = aRight.fNdep;
84 fZId = aRight.fZId;
85 fRhoId = aRight.fRhoId;
86 fPhiId = aRight.fPhiId;
87 fTime = aRight.fTime;
88 fPos = aRight.fPos;
89 fRot = aRight.fRot;
90 fType = aRight.fType;
91 fLogVol = aRight.fLogVol;
92 return *this;
93}
94
95//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
96
97int Par04Hit::operator==(const Par04Hit& aRight) const
98{
99 return (fRhoId == aRight.fRhoId && fPhiId == aRight.fPhiId && fZId == aRight.fZId);
100}
101
102//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
103
105{
106 /// Arbitrary size corresponds to the example macros
107 G4ThreeVector meshSize(2.325 * mm, 2 * CLHEP::pi / 50. * CLHEP::rad, 3.4 * mm);
108 G4int numPhiCells = CLHEP::pi * 2. / meshSize.y();
109 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
110 // Hits can be filtered out in visualisation
111 if(!pVVisManager->FilterHit(*this))
112 return;
113 // Do not plot hits from parallel world
114 if(fType >= 2)
115 return;
116 // Do not draw empty hits
117 if(fEdep <= 0)
118 return;
119 // Do not plot if default values were not changed
120 if(fRhoId == -1 && fZId == -1 && fPhiId == -1)
121 return;
122 if(pVVisManager)
123 {
124 G4Transform3D trans(fRot, fPos);
125 G4VisAttributes attribs;
126 G4Tubs solid("draw", fRhoId * meshSize.x(), (fRhoId + 1) * meshSize.x(), meshSize.z() / 2.,
127 (-numPhiCells / 2. + fPhiId) * meshSize.y(), meshSize.y());
128 // Set colours depending on type of hit (full/fast sim)
129 G4double colR = fType == 0 ? 0 : 1;
130 G4double colG = fType == 0 ? 1 : 0;
131 G4double colB = 0;
132 // Set transparency depending on the energy
133 // Arbitrary formula
134 G4double alpha = 2 * std::log10(fEdep + 1);
135 G4Colour colour(colR, colG, colB, alpha);
136 attribs.SetColour(colour);
137 attribs.SetForceSolid(true);
138 pVVisManager->Draw(solid, attribs, trans);
139 }
140}
141
142//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
143
144const std::map<G4String, G4AttDef>* Par04Hit::GetAttDefs() const
145{
146 G4bool isNew;
147 std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("Par04Hit", isNew);
148 if(isNew)
149 {
150 (*store)["HitType"] = G4AttDef("HitType", "Hit Type", "Physics", "", "G4String");
151 (*store)["Energy"] =
152 G4AttDef("Energy", "Energy Deposited", "Physics", "G4BestUnit", "G4double");
153 (*store)["Time"] = G4AttDef("Time", "Time", "Physics", "G4BestUnit", "G4double");
154 (*store)["Pos"] = G4AttDef("Pos", "Position", "Physics", "G4BestUnit", "G4ThreeVector");
155 }
156 return store;
157}
158
159//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
160
161std::vector<G4AttValue>* Par04Hit::CreateAttValues() const
162{
163 std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
164 values->push_back(G4AttValue("HitType", "HadPar04Hit", ""));
165 values->push_back(G4AttValue("Energy", G4BestUnit(fEdep, "Energy"), ""));
166 values->push_back(G4AttValue("Time", G4BestUnit(fTime, "Time"), ""));
167 values->push_back(G4AttValue("Pos", G4BestUnit(fPos, "Length"), ""));
168 return values;
169}
170
171//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
172
174{
175 std::cout << "\tHit " << fEdep / MeV << " MeV from " << fNdep << " deposits at " << fPos / cm
176 << " cm rotation " << fRot << " (R,phi,z)= (" << fRhoId << ", " << fPhiId
177 << ", " << fZId << "), " << fTime << " ns" << std::endl;
178}
G4ThreadLocal G4Allocator< Par04Hit > * Par04HitAllocator
Definition Par04Hit.cc:49
Hit class to store energy deposited in the sensitive detector.
G4int fZId
Z ID of readout cell.
Definition Par04Hit.hh:128
G4double fTime
Time.
Definition Par04Hit.hh:138
virtual void Print() final
Print hit properties.
Definition Par04Hit.cc:173
virtual void Draw() final
Visualise hits.
Definition Par04Hit.cc:104
G4int fPhiId
Phi ID of readout cell.
Definition Par04Hit.hh:132
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const final
Retrieve atributes' names in order to allow filtering.
Definition Par04Hit.cc:144
virtual ~Par04Hit()
virtual std::vector< G4AttValue > * CreateAttValues() const final
Create attributes for the visualisation.
Definition Par04Hit.cc:161
G4int fRhoId
Rho ID of readout cell.
Definition Par04Hit.hh:130
const Par04Hit & operator=(const Par04Hit &aRight)
Definition Par04Hit.cc:80
G4int fNdep
Counter of deposits in a hit/cell.
Definition Par04Hit.hh:126
G4ThreeVector fPos
Position.
Definition Par04Hit.hh:134
G4LogicalVolume * fLogVol
Pointer to logical volume for visualisation.
Definition Par04Hit.hh:142
G4RotationMatrix fRot
Rotation.
Definition Par04Hit.hh:136
G4double fEdep
Energy deposit.
Definition Par04Hit.hh:124
G4int fType
Type: 0 = full sim, 1 = fast sim.
Definition Par04Hit.hh:140
int operator==(const Par04Hit &aRight) const
Definition Par04Hit.cc:97

Applications | User Support | Publications | Collaboration