Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-07 07:54:07

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file Par03Hit.cc
0027 /// \brief Implementation of the Par03Hit class
0028 
0029 #include "Par03Hit.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 "G4Tubs.hh"
0038 #include "G4UnitsTable.hh"
0039 #include "G4VVisManager.hh"
0040 #include "G4VisAttributes.hh"
0041 
0042 G4ThreadLocal G4Allocator<Par03Hit>* Par03HitAllocator;
0043 
0044 Par03Hit::Par03Hit() : G4VHit() {}
0045 
0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0047 
0048 Par03Hit::~Par03Hit() = default;
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 
0052 Par03Hit::Par03Hit(const Par03Hit& aRight) : G4VHit()
0053 {
0054   fEdep = aRight.fEdep;
0055   fZId = aRight.fZId;
0056   fRhoId = aRight.fRhoId;
0057   fPhiId = aRight.fPhiId;
0058   fTime = aRight.fTime;
0059   fPos = aRight.fPos;
0060   fRot = aRight.fRot;
0061   fType = aRight.fType;
0062   fLogVol = aRight.fLogVol;
0063 }
0064 
0065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0066 
0067 const Par03Hit& Par03Hit::operator=(const Par03Hit& aRight)
0068 {
0069   fEdep = aRight.fEdep;
0070   fZId = aRight.fZId;
0071   fRhoId = aRight.fRhoId;
0072   fPhiId = aRight.fPhiId;
0073   fTime = aRight.fTime;
0074   fPos = aRight.fPos;
0075   fRot = aRight.fRot;
0076   fType = aRight.fType;
0077   fLogVol = aRight.fLogVol;
0078   return *this;
0079 }
0080 
0081 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0082 
0083 int Par03Hit::operator==(const Par03Hit& aRight) const
0084 {
0085   return (fRhoId == aRight.fRhoId && fPhiId == aRight.fPhiId && fZId == aRight.fZId);
0086 }
0087 
0088 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0089 
0090 void Par03Hit::Draw()
0091 {
0092   G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
0093   // Hits can be filtered out in visualisation
0094   if (!pVVisManager->FilterHit(*this)) return;
0095   // Do not draw empty hits
0096   if (fEdep < 0) return;
0097   if (pVVisManager) {
0098     G4Transform3D trans(fRot, fPos);
0099     G4VisAttributes attribs;
0100     // Create default dimensions
0101     G4Tubs solid("draw", 0, 1 * cm, 1 * cm, 0, 0.05 * CLHEP::pi);
0102     if (fLogVol) {
0103       const G4VisAttributes* pVA = fLogVol->GetVisAttributes();
0104       if (pVA) attribs = *pVA;
0105       // Cannot use directly fLogVol due to rho parametrisation (change of
0106       // solid!) Recalculation of radius is needed
0107       solid = *dynamic_cast<G4Tubs*>(fLogVol->GetSolid());
0108       double dR = solid.GetOuterRadius() - solid.GetInnerRadius();
0109       solid.SetInnerRadius(solid.GetInnerRadius() + fRhoId * dR);
0110       solid.SetOuterRadius(solid.GetOuterRadius() + fRhoId * dR);
0111     }
0112     // Set colours depending on type of hit (full/fast sim)
0113     G4double colR = fType == 0 ? 0 : 1;
0114     G4double colG = fType == 0 ? 1 : 0;
0115     G4double colB = 0;
0116     G4Colour colour(colR, colG, colB, 0.5);
0117     attribs.SetColour(colour);
0118     attribs.SetForceSolid(true);
0119     pVVisManager->Draw(solid, attribs, trans);
0120   }
0121 }
0122 
0123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0124 
0125 const std::map<G4String, G4AttDef>* Par03Hit::GetAttDefs() const
0126 {
0127   G4bool isNew;
0128   std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("Par03Hit", isNew);
0129   if (isNew) {
0130     (*store)["HitType"] = G4AttDef("HitType", "Hit Type", "Physics", "", "G4String");
0131     (*store)["Energy"] =
0132       G4AttDef("Energy", "Energy Deposited", "Physics", "G4BestUnit", "G4double");
0133     (*store)["Time"] = G4AttDef("Time", "Time", "Physics", "G4BestUnit", "G4double");
0134     (*store)["Pos"] = G4AttDef("Pos", "Position", "Physics", "G4BestUnit", "G4ThreeVector");
0135   }
0136   return store;
0137 }
0138 
0139 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0140 
0141 std::vector<G4AttValue>* Par03Hit::CreateAttValues() const
0142 {
0143   std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
0144   values->push_back(G4AttValue("HitType", "HadPar03Hit", ""));
0145   values->push_back(G4AttValue("Energy", G4BestUnit(fEdep, "Energy"), ""));
0146   values->push_back(G4AttValue("Time", G4BestUnit(fTime, "Time"), ""));
0147   values->push_back(G4AttValue("Pos", G4BestUnit(fPos, "Length"), ""));
0148   return values;
0149 }
0150 
0151 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0152 
0153 void Par03Hit::Print()
0154 {
0155   std::cout << "\tHit " << fEdep / MeV << " MeV at " << fPos / cm << " cm (R,phi,z)= (" << fRhoId
0156             << ", " << fPhiId << ", " << fZId << "), " << fTime << " ns" << std::endl;
0157 }