Back to home page

EIC code displayed by LXR

 
 

    


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

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 #include "SiliconPixelSD.hh"
0027 
0028 #include "G4String.hh"
0029 
0030 SiliconPixelSD::SiliconPixelSD(G4String name)
0031     : G4VSensitiveDetector("SiliconPixelHitCollection") {
0032   G4cout << "creating a sensitive detector with name: " << name << G4endl;
0033   collectionName.insert("SiliconPixelHitCollection");
0034 }
0035 
0036 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0037 
0038 SiliconPixelSD::~SiliconPixelSD() {}
0039 
0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0041 
0042 void SiliconPixelSD::Initialize(G4HCofThisEvent *HCE) {
0043   fHitCollection = new SiliconPixelHitCollection(GetName(), collectionName[0]);
0044 
0045   if (fHCID < 0)
0046     fHCID = GetCollectionID(0);
0047   HCE->AddHitsCollection(fHCID, fHitCollection);
0048 
0049   fTmpHits.clear();
0050 }
0051 
0052 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0053 
0054 void SiliconPixelSD::EndOfEvent(G4HCofThisEvent *) {
0055   for (auto it = fTmpHits.begin(); it != fTmpHits.end(); ++it)
0056     fHitCollection->insert(it->second);
0057 }
0058 
0059 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0060 
0061 G4bool SiliconPixelSD::ProcessHits(G4Step *step, G4TouchableHistory *) {
0062   G4TouchableHandle touchable = step->GetPreStepPoint()->GetTouchableHandle();
0063 
0064   G4int copyNumCell = touchable->GetVolume(0)->GetCopyNo();
0065   G4int copyNumSensor = touchable->GetVolume(1)->GetCopyNo();
0066   int tmp_ID = 1000 * copyNumSensor + copyNumCell;
0067   if (fTmpHits.find(tmp_ID) == fTmpHits.end()) { // make new hit
0068     G4String vol_name = touchable->GetVolume(0)->GetName();
0069     fTmpHits[tmp_ID] =
0070         new SiliconPixelHit(vol_name, copyNumSensor, copyNumCell);
0071     G4double hitX = (touchable->GetVolume(1)->GetTranslation().x() +
0072                      touchable->GetVolume(0)->GetTranslation().x()) /
0073                     CLHEP::cm;
0074     G4double hitY = (touchable->GetVolume(1)->GetTranslation().y() +
0075                      touchable->GetVolume(0)->GetTranslation().y()) /
0076                     CLHEP::cm;
0077     G4double hitZ = touchable->GetVolume(1)->GetTranslation().z() / CLHEP::cm;
0078     fTmpHits[tmp_ID]->SetPosition(hitX, hitY, hitZ); // in cm
0079   }
0080 
0081   G4double edep = step->GetTotalEnergyDeposit() / CLHEP::keV; // in keV
0082   G4double edepNonIonizing = step->GetNonIonizingEnergyDeposit() / CLHEP::keV;
0083 
0084   G4double timedep = step->GetPostStepPoint()->GetGlobalTime() / CLHEP::ns;
0085 
0086   fTmpHits[tmp_ID]->AddEdep(edep, timedep);
0087   fTmpHits[tmp_ID]->AddEdepNonIonizing(edepNonIonizing, timedep);
0088 
0089   return true;
0090 }
0091 
0092 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......