Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /geant4/examples/extended/parameterisations/Par04/src/Par04Hit.cc was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 Par04Hit.cc
0027 /// \brief Implementation of the Par04Hit class
0028 
0029 #include "Par04Hit.hh"
0030 
0031 #include "G4AttDef.hh"  // for G4AttDef
0032 #include "G4AttDefStore.hh"  // for GetInstance
0033 #include "G4AttValue.hh"  // for G4AttValue
0034 #include "G4Colour.hh"  // for G4Colour
0035 #include "G4SystemOfUnits.hh"  // for mm, MeV, cm, rad
0036 #include "G4Tubs.hh"  // for G4Tubs
0037 #include "G4UnitsTable.hh"  // for G4BestUnit
0038 #include "G4VVisManager.hh"  // for G4VVisManager
0039 #include "G4VisAttributes.hh"  // for G4VisAttributes
0040 
0041 #include <CLHEP/Units/SystemOfUnits.h>  // for mm, pi, MeV, cm, rad
0042 #include <CLHEP/Vector/ThreeVector.h>  // for operator/, operator<<, Hep...
0043 #include <G4RotationMatrix.hh>  // for G4RotationMatrix
0044 #include <G4String.hh>  // for G4String
0045 #include <G4ThreeVector.hh>  // for G4ThreeVector
0046 #include <G4Transform3D.hh>  // for G4Transform3D
0047 #include <G4VHit.hh>  // for G4VHit
0048 #include <algorithm>  // for max
0049 #include <cmath>  // for log10
0050 #include <iostream>  // for operator<<, basic_ostream:...
0051 #include <string>  // for operator<
0052 template<class Type>
0053 class G4Allocator;
0054 
0055 G4ThreadLocal G4Allocator<Par04Hit>* Par04HitAllocator;
0056 
0057 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0058 
0059 Par04Hit::Par04Hit() : G4VHit() {}
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0062 
0063 Par04Hit::~Par04Hit() = default;
0064 
0065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0066 
0067 Par04Hit::Par04Hit(const Par04Hit& aRight) : G4VHit()
0068 {
0069   fEdep = aRight.fEdep;
0070   fNdep = aRight.fNdep;
0071   fZId = aRight.fZId;
0072   fRhoId = aRight.fRhoId;
0073   fPhiId = aRight.fPhiId;
0074   fTime = aRight.fTime;
0075   fPos = aRight.fPos;
0076   fRot = aRight.fRot;
0077   fType = aRight.fType;
0078   fLogVol = aRight.fLogVol;
0079 }
0080 
0081 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0082 
0083 const Par04Hit& Par04Hit::operator=(const Par04Hit& aRight)
0084 {
0085   fEdep = aRight.fEdep;
0086   fNdep = aRight.fNdep;
0087   fZId = aRight.fZId;
0088   fRhoId = aRight.fRhoId;
0089   fPhiId = aRight.fPhiId;
0090   fTime = aRight.fTime;
0091   fPos = aRight.fPos;
0092   fRot = aRight.fRot;
0093   fType = aRight.fType;
0094   fLogVol = aRight.fLogVol;
0095   return *this;
0096 }
0097 
0098 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0099 
0100 int Par04Hit::operator==(const Par04Hit& aRight) const
0101 {
0102   return (fRhoId == aRight.fRhoId && fPhiId == aRight.fPhiId && fZId == aRight.fZId);
0103 }
0104 
0105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0106 
0107 void Par04Hit::Draw()
0108 {
0109   /// Arbitrary size corresponds to the example macros
0110   G4ThreeVector meshSize(4.65 * mm, 2 * CLHEP::pi / 18. * CLHEP::rad, 3.4 * mm);
0111   G4int numPhiCells = CLHEP::pi * 2. / meshSize.y();
0112   G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
0113   // Hits can be filtered out in visualisation
0114   if (!pVVisManager->FilterHit(*this)) return;
0115   // Do not plot hits from parallel world
0116   if (fType >= 2) return;
0117   // Do not draw empty hits
0118   if (fEdep <= 0) return;
0119   // Do not plot if default values were not changed
0120   if (fRhoId == -1 && fZId == -1 && fPhiId == -1) return;
0121   if (pVVisManager) {
0122     G4Transform3D trans(fRot, fPos);
0123     G4VisAttributes attribs;
0124     G4Tubs solid("draw", fRhoId * meshSize.x(), (fRhoId + 1) * meshSize.x(), meshSize.z() / 2.,
0125                  (-numPhiCells / 2. + fPhiId) * meshSize.y(), meshSize.y());
0126     // Set colours depending on type of hit (full/fast sim)
0127     G4double colR = fType == 0 ? 0 : 1;
0128     G4double colG = fType == 0 ? 1 : 0;
0129     G4double colB = 0;
0130     // Set transparency depending on the energy
0131     // Arbitrary formula
0132     G4double alpha = 2 * std::log10(fEdep + 1);
0133     G4Colour colour(colR, colG, colB, alpha);
0134     attribs.SetColour(colour);
0135     attribs.SetForceSolid(true);
0136     pVVisManager->Draw(solid, attribs, trans);
0137   }
0138 }
0139 
0140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0141 
0142 const std::map<G4String, G4AttDef>* Par04Hit::GetAttDefs() const
0143 {
0144   G4bool isNew;
0145   std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("Par04Hit", isNew);
0146   if (isNew) {
0147     (*store)["HitType"] = G4AttDef("HitType", "Hit Type", "Physics", "", "G4String");
0148     (*store)["Energy"] =
0149       G4AttDef("Energy", "Energy Deposited", "Physics", "G4BestUnit", "G4double");
0150     (*store)["Time"] = G4AttDef("Time", "Time", "Physics", "G4BestUnit", "G4double");
0151     (*store)["Pos"] = G4AttDef("Pos", "Position", "Physics", "G4BestUnit", "G4ThreeVector");
0152   }
0153   return store;
0154 }
0155 
0156 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0157 
0158 std::vector<G4AttValue>* Par04Hit::CreateAttValues() const
0159 {
0160   std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
0161   values->push_back(G4AttValue("HitType", "HadPar04Hit", ""));
0162   values->push_back(G4AttValue("Energy", G4BestUnit(fEdep, "Energy"), ""));
0163   values->push_back(G4AttValue("Time", G4BestUnit(fTime, "Time"), ""));
0164   values->push_back(G4AttValue("Pos", G4BestUnit(fPos, "Length"), ""));
0165   return values;
0166 }
0167 
0168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0169 
0170 void Par04Hit::Print()
0171 {
0172   G4cout << "\tHit " << fEdep / MeV << " MeV from " << fNdep << " deposits at " << fPos / cm
0173          << " cm with rotation " << fRot << " (R,phi,z)= (" << fRhoId << ", " << fPhiId << ", "
0174          << fZId << "), " << fTime << " ns" << G4endl;
0175 }