File indexing completed on 2026-09-22 08:08:10
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #include "EmCalorimeterHit.hh"
0030
0031 #include "G4AttDef.hh"
0032 #include "G4AttDefStore.hh"
0033 #include "G4AttValue.hh"
0034 #include "G4Colour.hh"
0035 #include "G4LogicalVolume.hh"
0036 #include "G4SystemOfUnits.hh"
0037 #include "G4UIcommand.hh"
0038 #include "G4UnitsTable.hh"
0039 #include "G4VVisManager.hh"
0040 #include "G4VisAttributes.hh"
0041
0042 namespace B5
0043 {
0044
0045
0046
0047 G4ThreadLocal G4Allocator<EmCalorimeterHit>* EmCalorimeterHitAllocator;
0048
0049
0050
0051 EmCalorimeterHit::EmCalorimeterHit(G4int cellID) : fCellID(cellID) {}
0052
0053
0054
0055 G4bool EmCalorimeterHit::operator==(const EmCalorimeterHit& right) const
0056 {
0057 return (fCellID == right.fCellID);
0058 }
0059
0060
0061
0062 void EmCalorimeterHit::Draw()
0063 {
0064 auto visManager = G4VVisManager::GetConcreteInstance();
0065 if (!visManager || (fEdep == 0.)) return;
0066
0067
0068 G4Transform3D trans(fRot.inverse(), fPos);
0069 G4VisAttributes attribs;
0070 auto pVA = fPLogV->GetVisAttributes();
0071 if (pVA) attribs = *pVA;
0072 auto rcol = fEdep / (0.7 * GeV);
0073 if (rcol > 1.) rcol = 1.;
0074 if (rcol < 0.4) rcol = 0.4;
0075 G4Colour colour(rcol, 0., 0.);
0076 attribs.SetColour(colour);
0077 attribs.SetForceSolid(true);
0078 visManager->Draw(*fPLogV, attribs, trans);
0079 }
0080
0081
0082
0083 const std::map<G4String, G4AttDef>* EmCalorimeterHit::GetAttDefs() const
0084 {
0085 G4bool isNew;
0086 auto store = G4AttDefStore::GetInstance("EmCalorimeterHit", isNew);
0087
0088 if (isNew) {
0089 (*store)["HitType"] = G4AttDef("HitType", "Hit Type", "Physics", "", "G4String");
0090
0091 (*store)["ID"] = G4AttDef("ID", "ID", "Physics", "", "G4int");
0092
0093 (*store)["Energy"] =
0094 G4AttDef("Energy", "Energy Deposited", "Physics", "G4BestUnit", "G4double");
0095
0096 (*store)["Pos"] = G4AttDef("Pos", "Position", "Physics", "G4BestUnit", "G4ThreeVector");
0097
0098 (*store)["LVol"] = G4AttDef("LVol", "Logical Volume", "Physics", "", "G4String");
0099 }
0100 return store;
0101 }
0102
0103
0104
0105 std::vector<G4AttValue>* EmCalorimeterHit::CreateAttValues() const
0106 {
0107 auto values = new std::vector<G4AttValue>;
0108
0109 values->push_back(G4AttValue("HitType", "EmCalorimeterHit", ""));
0110 values->push_back(G4AttValue("ID", G4UIcommand::ConvertToString(fCellID), ""));
0111 values->push_back(G4AttValue("Energy", G4BestUnit(fEdep, "Energy"), ""));
0112 values->push_back(G4AttValue("Pos", G4BestUnit(fPos, "Length"), ""));
0113
0114 if (fPLogV)
0115 values->push_back(G4AttValue("LVol", fPLogV->GetName(), ""));
0116 else
0117 values->push_back(G4AttValue("LVol", " ", ""));
0118
0119 return values;
0120 }
0121
0122
0123
0124 void EmCalorimeterHit::Print()
0125 {
0126 G4cout << " Cell[" << fCellID << "] " << fEdep / MeV << " (MeV)" << G4endl;
0127 }
0128
0129
0130
0131 }