|
||||
File indexing completed on 2025-01-31 09:22:50
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 B2/B2b/src/TrackerSD.cc 0028 /// \brief Implementation of the B2::TrackerSD class 0029 0030 #include "TrackerSD.hh" 0031 0032 #include "G4HCofThisEvent.hh" 0033 #include "G4SDManager.hh" 0034 #include "G4Step.hh" 0035 0036 namespace B2 0037 { 0038 0039 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0040 0041 TrackerSD::TrackerSD(const G4String& name, const G4String& hitsCollectionName) 0042 : G4VSensitiveDetector(name) 0043 { 0044 collectionName.insert(hitsCollectionName); 0045 } 0046 0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0048 0049 void TrackerSD::Initialize(G4HCofThisEvent* hce) 0050 { 0051 // Create hits collection 0052 0053 fHitsCollection = new TrackerHitsCollection(SensitiveDetectorName, collectionName[0]); 0054 0055 // Add this collection in hce 0056 0057 G4int hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); 0058 hce->AddHitsCollection(hcID, fHitsCollection); 0059 } 0060 0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0062 0063 G4bool TrackerSD::ProcessHits(G4Step* step, G4TouchableHistory*) 0064 { 0065 // energy deposit 0066 G4double edep = step->GetTotalEnergyDeposit(); 0067 0068 if (edep == 0.) return false; 0069 0070 auto newHit = new TrackerHit(); 0071 0072 newHit->SetTrackID(step->GetTrack()->GetTrackID()); 0073 newHit->SetChamberNb(step->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber()); 0074 newHit->SetEdep(edep); 0075 newHit->SetPos(step->GetPostStepPoint()->GetPosition()); 0076 0077 fHitsCollection->insert(newHit); 0078 0079 // newHit->Print(); 0080 0081 return true; 0082 } 0083 0084 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0085 0086 void TrackerSD::EndOfEvent(G4HCofThisEvent*) 0087 { 0088 if (verboseLevel > 1) { 0089 std::size_t nofHits = fHitsCollection->entries(); 0090 G4cout << G4endl << "-------->Hits Collection: in this event they are " << nofHits 0091 << " hits in the tracker chambers: " << G4endl; 0092 for (std::size_t i = 0; i < nofHits; i++) 0093 (*fHitsCollection)[i]->Print(); 0094 } 0095 } 0096 0097 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0098 0099 } // namespace B2
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |