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