Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /// \file persistency/P01/src/ExP01TrackerSD.c << 27 /// \brief Implementation of the ExP01TrackerS << 28 // << 29 // 26 // >> 27 // $Id: ExP01TrackerSD.cc,v 1.2 2006/06/29 17:39:43 gunter Exp $ >> 28 // GEANT4 tag $Name: geant4-08-02 $ 30 // 29 // 31 //....oooOO0OOooo........oooOO0OOooo........oo 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 33 32 34 #include "ExP01TrackerSD.hh" 33 #include "ExP01TrackerSD.hh" 35 << 36 #include "RootIO.hh" << 37 << 38 #include "G4HCofThisEvent.hh" 34 #include "G4HCofThisEvent.hh" 39 #include "G4SDManager.hh" << 40 #include "G4Step.hh" 35 #include "G4Step.hh" 41 #include "G4ThreeVector.hh" 36 #include "G4ThreeVector.hh" >> 37 #include "G4SDManager.hh" 42 #include "G4ios.hh" 38 #include "G4ios.hh" 43 39 >> 40 #include "RootIO.hh" >> 41 44 //....oooOO0OOooo........oooOO0OOooo........oo 42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 45 43 46 ExP01TrackerSD::ExP01TrackerSD(G4String name) 44 ExP01TrackerSD::ExP01TrackerSD(G4String name) 47 : G4VSensitiveDetector(name), fTrackerCollec << 45 :G4VSensitiveDetector(name) 48 { 46 { 49 G4String HCname = name + "_HC"; << 47 G4String HCname; 50 collectionName.insert(HCname); << 48 collectionName.insert(HCname="trackerCollection"); 51 G4cout << collectionName.size() << " Calor << 52 << " collection Name: " << HCname << << 53 fHCID = -1; << 54 } 49 } 55 50 56 //....oooOO0OOooo........oooOO0OOooo........oo 51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 57 52 58 ExP01TrackerSD::~ExP01TrackerSD() << 53 ExP01TrackerSD::~ExP01TrackerSD(){ } 59 { << 60 RootIO::GetInstance()->Close(); << 61 } << 62 54 63 //....oooOO0OOooo........oooOO0OOooo........oo 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 64 56 65 void ExP01TrackerSD::Initialize(G4HCofThisEven 57 void ExP01TrackerSD::Initialize(G4HCofThisEvent* HCE) 66 { 58 { 67 fTrackerCollection = new ExP01TrackerHitsCol << 59 trackerCollection = new ExP01TrackerHitsCollection 68 if (fHCID < 0) { << 60 (SensitiveDetectorName,collectionName[0]); 69 G4cout << "CalorimeterSD::Initialize: " < << 61 static G4int HCID = -1; 70 << G4endl; << 62 if(HCID<0) 71 fHCID = G4SDManager::GetSDMpointer()->GetC << 63 { HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); } 72 } << 64 HCE->AddHitsCollection( HCID, trackerCollection ); 73 HCE->AddHitsCollection(fHCID, fTrackerCollec << 74 } 65 } 75 66 76 //....oooOO0OOooo........oooOO0OOooo........oo 67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 77 68 78 G4bool ExP01TrackerSD::ProcessHits(G4Step* aSt << 69 G4bool ExP01TrackerSD::ProcessHits(G4Step* aStep,G4TouchableHistory*) 79 { 70 { 80 G4double edep = aStep->GetTotalEnergyDeposit 71 G4double edep = aStep->GetTotalEnergyDeposit(); 81 72 82 if (edep == 0.) return false; << 73 if(edep==0.) return false; 83 74 84 ExP01TrackerHit* newHit = new ExP01TrackerHi 75 ExP01TrackerHit* newHit = new ExP01TrackerHit(); 85 newHit->SetTrackID(aStep->GetTrack()->GetTra << 76 newHit->SetTrackID (aStep->GetTrack()->GetTrackID()); 86 newHit->SetChamberNb(aStep->GetPreStepPoint( << 77 newHit->SetChamberNb(aStep->GetPreStepPoint()->GetTouchable() 87 newHit->SetEdep(edep); << 78 ->GetReplicaNumber()); 88 newHit->SetPos(aStep->GetPostStepPoint()->Ge << 79 newHit->SetEdep (edep); 89 fTrackerCollection->insert(newHit); << 80 newHit->SetPos (aStep->GetPostStepPoint()->GetPosition()); 90 << 81 trackerCollection->insert( newHit ); 91 // newHit->Print(); << 82 92 // newHit->Draw(); << 83 //newHit->Print(); >> 84 //newHit->Draw(); 93 85 94 return true; 86 return true; 95 } 87 } 96 88 97 //....oooOO0OOooo........oooOO0OOooo........oo 89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 98 90 99 void ExP01TrackerSD::EndOfEvent(G4HCofThisEven 91 void ExP01TrackerSD::EndOfEvent(G4HCofThisEvent*) 100 { 92 { 101 // storing the hits in ROOT file 93 // storing the hits in ROOT file 102 G4int NbHits = fTrackerCollection->entries() << 94 G4int NbHits = trackerCollection->entries(); 103 std::vector<ExP01TrackerHit*> hitsVector; 95 std::vector<ExP01TrackerHit*> hitsVector; 104 96 105 { << 97 { 106 G4cout << "\n-------->Storing hits in the << 98 G4cout << "\n-------->Storing hits in the ROOT file: in this event there are " << NbHits 107 << " hits in the tracker chambers: 99 << " hits in the tracker chambers: " << G4endl; 108 for (G4int i = 0; i < NbHits; i++) << 100 for (G4int i=0;i<NbHits;i++) (*trackerCollection)[i]->Print(); 109 (*fTrackerCollection)[i]->Print(); << 101 } 110 } << 111 << 112 for (G4int i = 0; i < NbHits; i++) << 113 hitsVector.push_back((*fTrackerCollection) << 114 102 >> 103 >> 104 for (G4int i=0;i<NbHits;i++) >> 105 hitsVector.push_back((*trackerCollection)[i]); >> 106 115 RootIO::GetInstance()->Write(&hitsVector); 107 RootIO::GetInstance()->Write(&hitsVector); 116 108 117 // 109 // 118 } 110 } 119 111 120 //....oooOO0OOooo........oooOO0OOooo........oo 112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 113 121 114