Loading...
Searching...
No Matches
Par03Hit.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 "Par03Hit.hh"
27
28#include "G4VisAttributes.hh"
29#include "G4Tubs.hh"
30#include "G4Colour.hh"
31#include "G4AttDefStore.hh"
32#include "G4AttDef.hh"
33#include "G4AttValue.hh"
34#include "G4UnitsTable.hh"
35#include "G4SystemOfUnits.hh"
36#include "G4VVisManager.hh"
37#include "G4LogicalVolume.hh"
38
40
44
45//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46
47Par03Hit::~Par03Hit() = default;
48
49//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50
52 : G4VHit()
53{
54 fEdep = aRight.fEdep;
55 fZId = aRight.fZId;
56 fRhoId = aRight.fRhoId;
57 fPhiId = aRight.fPhiId;
58 fTime = aRight.fTime;
59 fPos = aRight.fPos;
60 fRot = aRight.fRot;
61 fType = aRight.fType;
62 fLogVol = aRight.fLogVol;
63}
64
65//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66
68{
69 fEdep = aRight.fEdep;
70 fZId = aRight.fZId;
71 fRhoId = aRight.fRhoId;
72 fPhiId = aRight.fPhiId;
73 fTime = aRight.fTime;
74 fPos = aRight.fPos;
75 fRot = aRight.fRot;
76 fType = aRight.fType;
77 fLogVol = aRight.fLogVol;
78 return *this;
79}
80
81//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82
83int Par03Hit::operator==(const Par03Hit& aRight) const
84{
85 return (fRhoId == aRight.fRhoId && fPhiId == aRight.fPhiId &&
86 fZId == aRight.fZId);
87}
88
89//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90
92{
93 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
94 // Hits can be filtered out in visualisation
95 if(!pVVisManager->FilterHit(*this))
96 return;
97 // Do not draw empty hits
98 if(fEdep < 0)
99 return;
100 if(pVVisManager)
101 {
102 G4Transform3D trans(fRot, fPos);
103 G4VisAttributes attribs;
104 // Create default dimensions
105 G4Tubs solid("draw", 0, 1 * cm, 1 * cm, 0, 0.05 * CLHEP::pi);
106 if(fLogVol)
107 {
108 const G4VisAttributes* pVA = fLogVol->GetVisAttributes();
109 if(pVA)
110 attribs = *pVA;
111 // Cannot use directly fLogVol due to rho parametrisation (change of
112 // solid!) Recalculation of radius is needed
113 solid = *dynamic_cast<G4Tubs*>(fLogVol->GetSolid());
114 double dR = solid.GetOuterRadius() - solid.GetInnerRadius();
115 solid.SetInnerRadius(solid.GetInnerRadius() + fRhoId * dR);
116 solid.SetOuterRadius(solid.GetOuterRadius() + fRhoId * dR);
117 }
118 // Set colours depending on type of hit (full/fast sim)
119 G4double colR = fType == 0 ? 0 : 1;
120 G4double colG = fType == 0 ? 1 : 0;
121 G4double colB = 0;
122 G4Colour colour(colR, colG, colB, 0.5);
123 attribs.SetColour(colour);
124 attribs.SetForceSolid(true);
125 pVVisManager->Draw(solid, attribs, trans);
126 }
127}
128
129//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
130
131const std::map<G4String, G4AttDef>* Par03Hit::GetAttDefs() const
132{
133 G4bool isNew;
134 std::map<G4String, G4AttDef>* store =
135 G4AttDefStore::GetInstance("Par03Hit", isNew);
136 if(isNew)
137 {
138 (*store)["HitType"] =
139 G4AttDef("HitType", "Hit Type", "Physics", "", "G4String");
140 (*store)["Energy"] = G4AttDef("Energy", "Energy Deposited", "Physics",
141 "G4BestUnit", "G4double");
142 (*store)["Time"] =
143 G4AttDef("Time", "Time", "Physics", "G4BestUnit", "G4double");
144 (*store)["Pos"] =
145 G4AttDef("Pos", "Position", "Physics", "G4BestUnit", "G4ThreeVector");
146 }
147 return store;
148}
149
150//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
151
152std::vector<G4AttValue>* Par03Hit::CreateAttValues() const
153{
154 std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
155 values->push_back(G4AttValue("HitType", "HadPar03Hit", ""));
156 values->push_back(G4AttValue("Energy", G4BestUnit(fEdep, "Energy"), ""));
157 values->push_back(G4AttValue("Time", G4BestUnit(fTime, "Time"), ""));
158 values->push_back(G4AttValue("Pos", G4BestUnit(fPos, "Length"), ""));
159 return values;
160}
161
162//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
163
165{
166 std::cout << "\tHit " << fEdep / MeV << " MeV at " << fPos / cm
167 << " cm (R,phi,z)= (" << fRhoId << ", " << fPhiId << ", " << fZId
168 << "), " << fTime << " ns" << std::endl;
169}
G4ThreadLocal G4Allocator< Par03Hit > * Par03HitAllocator
Definition Par03Hit.cc:39
Hit class to store energy deposited in the sensitive detector.
virtual void Print()
Print hit properties.
Definition Par03Hit.cc:164
G4ThreeVector fPos
Position.
Definition Par03Hit.hh:121
G4int fPhiId
Phi ID of readout cell.
Definition Par03Hit.hh:119
G4int fType
Type: 0 = full sim, 1 = fast sim.
Definition Par03Hit.hh:127
virtual void Draw()
Visualise hits.
Definition Par03Hit.cc:91
G4double fEdep
Energy deposit.
Definition Par03Hit.hh:113
G4LogicalVolume * fLogVol
Pointer to logical volume for visualisation.
Definition Par03Hit.hh:129
G4int fRhoId
Rho ID of readout cell.
Definition Par03Hit.hh:117
G4RotationMatrix fRot
Rotation.
Definition Par03Hit.hh:123
G4double fTime
Time.
Definition Par03Hit.hh:125
G4int fZId
Z ID of readout cell.
Definition Par03Hit.hh:115
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
Retrieve atributes' names in order to allow filtering.
Definition Par03Hit.cc:131
virtual std::vector< G4AttValue > * CreateAttValues() const
Create attributes for the visualisation.
Definition Par03Hit.cc:152
int operator==(const Par03Hit &aRight) const
Definition Par03Hit.cc:83
const Par03Hit & operator=(const Par03Hit &aRight)
Definition Par03Hit.cc:67
virtual ~Par03Hit()

Applications | User Support | Publications | Collaboration