Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:53

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 //
0027 /// \file B5/src/EmCalorimeterHit.cc
0028 /// \brief Implementation of the B5::EmCalorimeterHit class
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0047 
0048 G4ThreadLocal G4Allocator<EmCalorimeterHit>* EmCalorimeterHitAllocator;
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 
0052 EmCalorimeterHit::EmCalorimeterHit(G4int cellID) : fCellID(cellID) {}
0053 
0054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0055 
0056 G4bool EmCalorimeterHit::operator==(const EmCalorimeterHit& right) const
0057 {
0058   return (fCellID == right.fCellID);
0059 }
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0062 
0063 void EmCalorimeterHit::Draw()
0064 {
0065   auto visManager = G4VVisManager::GetConcreteInstance();
0066   if (!visManager || (fEdep == 0.)) return;
0067 
0068   // Draw a calorimeter cell with a color corresponding to its energy deposit
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0124 
0125 void EmCalorimeterHit::Print()
0126 {
0127   G4cout << "  Cell[" << fCellID << "] " << fEdep / MeV << " (MeV)" << G4endl;
0128 }
0129 
0130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0131 
0132 }  // namespace B5