Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-08 07:52:49

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 HadCalorimeterHit.cc
0027 /// \brief Implementation of the B5::HadCalorimeterHit class
0028 
0029 #include "HadCalorimeterHit.hh"
0030 
0031 #include "G4AttDef.hh"
0032 #include "G4AttDefStore.hh"
0033 #include "G4AttValue.hh"
0034 #include "G4Box.hh"
0035 #include "G4Colour.hh"
0036 #include "G4SystemOfUnits.hh"
0037 #include "G4Transform3D.hh"
0038 #include "G4UIcommand.hh"
0039 #include "G4UnitsTable.hh"
0040 #include "G4VVisManager.hh"
0041 #include "G4VisAttributes.hh"
0042 #include "G4ios.hh"
0043 
0044 namespace B5
0045 {
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 G4ThreadLocal G4Allocator<HadCalorimeterHit>* HadCalorimeterHitAllocator;
0050 
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0052 
0053 HadCalorimeterHit::HadCalorimeterHit(G4int columnID, G4int rowID)
0054   : fColumnID(columnID), fRowID(rowID)
0055 {}
0056 
0057 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0058 
0059 G4bool HadCalorimeterHit::operator==(const HadCalorimeterHit& right) const
0060 {
0061   return (fColumnID == right.fColumnID && fRowID == right.fRowID);
0062 }
0063 
0064 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0065 
0066 void HadCalorimeterHit::Draw()
0067 {
0068   auto visManager = G4VVisManager::GetConcreteInstance();
0069   if (!visManager || (fEdep == 0.)) return;
0070 
0071   // Draw a calorimeter cell with depth propotional to the energy deposition
0072   G4Transform3D trans(fRot.inverse(), fPos);
0073   G4VisAttributes attribs;
0074   attribs.SetColour(G4Colour::Red());
0075   attribs.SetForceSolid(true);
0076   G4Box box("dummy", 15. * cm, 15. * cm, 1. * m * fEdep / (0.1 * GeV));
0077   visManager->Draw(box, attribs, trans);
0078 }
0079 
0080 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0081 
0082 const std::map<G4String, G4AttDef>* HadCalorimeterHit::GetAttDefs() const
0083 {
0084   G4bool isNew;
0085   auto store = G4AttDefStore::GetInstance("HadCalorimeterHit", isNew);
0086 
0087   if (isNew) {
0088     (*store)["HitType"] = G4AttDef("HitType", "Hit Type", "Physics", "", "G4String");
0089 
0090     (*store)["Column"] = G4AttDef("Column", "Column ID", "Physics", "", "G4int");
0091 
0092     (*store)["Row"] = G4AttDef("Row", "Row 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   return store;
0100 }
0101 
0102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0103 
0104 std::vector<G4AttValue>* HadCalorimeterHit::CreateAttValues() const
0105 {
0106   auto values = new std::vector<G4AttValue>;
0107 
0108   values->push_back(G4AttValue("HitType", "HadCalorimeterHit", ""));
0109   values->push_back(G4AttValue("Column", G4UIcommand::ConvertToString(fColumnID), ""));
0110   values->push_back(G4AttValue("Row", G4UIcommand::ConvertToString(fRowID), ""));
0111   values->push_back(G4AttValue("Energy", G4BestUnit(fEdep, "Energy"), ""));
0112   values->push_back(G4AttValue("Pos", G4BestUnit(fPos, "Length"), ""));
0113 
0114   return values;
0115 }
0116 
0117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0118 
0119 void HadCalorimeterHit::Print()
0120 {
0121   G4cout << "  Cell[" << fRowID << ", " << fColumnID << "] " << fEdep / MeV << " (MeV) " << fPos
0122          << G4endl;
0123 }
0124 
0125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0126 
0127 }  // namespace B5