Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 /// \file runAndEvent/RE01/src/RE01StackingAct << 23 // $Id: RE01StackingAction.cc,v 1.1 2004/11/26 07:37:42 asaim Exp $ 27 /// \brief Implementation of the RE01StackingA << 24 // GEANT4 tag $Name: geant4-08-00 $ 28 // << 29 // 25 // 30 26 31 #include "RE01StackingAction.hh" << 32 27 33 #include "RE01CalorimeterHit.hh" << 28 #include "RE01StackingAction.hh" 34 #include "RE01TrackInformation.hh" << 35 29 >> 30 #include "G4SDManager.hh" >> 31 #include "G4RunManager.hh" 36 #include "G4Event.hh" 32 #include "G4Event.hh" 37 #include "G4HCofThisEvent.hh" 33 #include "G4HCofThisEvent.hh" 38 #include "G4ParticleDefinition.hh" << 39 #include "G4ParticleTypes.hh" << 40 #include "G4RunManager.hh" << 41 #include "G4SDManager.hh" << 42 #include "G4SystemOfUnits.hh" << 43 #include "G4Track.hh" 34 #include "G4Track.hh" 44 #include "G4TrackStatus.hh" 35 #include "G4TrackStatus.hh" >> 36 #include "G4ParticleDefinition.hh" >> 37 #include "G4ParticleTypes.hh" 45 #include "G4ios.hh" 38 #include "G4ios.hh" 46 39 47 //....oooOO0OOooo........oooOO0OOooo........oo << 40 #include "RE01TrackInformation.hh" >> 41 #include "RE01CalorimeterHit.hh" >> 42 48 RE01StackingAction::RE01StackingAction() 43 RE01StackingAction::RE01StackingAction() 49 : G4UserStackingAction(), fStage(0), fCalori << 44 :stage(0),trackerHitsColID(-1),calorimeterHitsColID(-1) 50 { << 45 { ; } 51 ; << 52 } << 53 46 54 //....oooOO0OOooo........oooOO0OOooo........oo << 55 RE01StackingAction::~RE01StackingAction() 47 RE01StackingAction::~RE01StackingAction() 56 { << 48 { ; } 57 ; << 58 } << 59 49 60 //....oooOO0OOooo........oooOO0OOooo........oo << 50 G4ClassificationOfNewTrack 61 G4ClassificationOfNewTrack RE01StackingAction << 51 RE01StackingAction::ClassifyNewTrack(const G4Track * aTrack) 62 { 52 { 63 G4ClassificationOfNewTrack classification = 53 G4ClassificationOfNewTrack classification = fUrgent; 64 54 65 if (fStage == 0) { << 55 if(stage==0) >> 56 { 66 RE01TrackInformation* trackInfo; 57 RE01TrackInformation* trackInfo; 67 if (aTrack->GetTrackStatus() == fSuspend) << 58 if(aTrack->GetTrackStatus()==fSuspend) // Track reached to calorimeter 68 { 59 { 69 trackInfo = (RE01TrackInformation*)(aTra 60 trackInfo = (RE01TrackInformation*)(aTrack->GetUserInformation()); 70 trackInfo->SetTrackingStatus(0); 61 trackInfo->SetTrackingStatus(0); 71 trackInfo->SetSourceTrackInformation(aTr 62 trackInfo->SetSourceTrackInformation(aTrack); 72 // G4cout << "Track " << aTrack->Ge << 63 // G4cout << "Track " << aTrack->GetTrackID() << " (parentID " << aTrack->GetParentID() 73 // << " (parentID " << aTrac << 64 // << ") has reached to calorimeter and has been suspended at " << aTrack->GetPosition() << G4endl; 74 // << ") has reached to calo << 75 // << aTrack->GetPosition() << 76 classification = fWaiting; 65 classification = fWaiting; 77 } 66 } 78 else if (aTrack->GetParentID() == 0) // P << 67 else if(aTrack->GetParentID()==0) // Primary particle 79 { 68 { 80 trackInfo = new RE01TrackInformation(aTr 69 trackInfo = new RE01TrackInformation(aTrack); 81 trackInfo->SetTrackingStatus(1); 70 trackInfo->SetTrackingStatus(1); 82 G4Track* theTrack = (G4Track*)aTrack; 71 G4Track* theTrack = (G4Track*)aTrack; 83 theTrack->SetUserInformation(trackInfo); 72 theTrack->SetUserInformation(trackInfo); 84 } 73 } 85 } 74 } 86 return classification; 75 return classification; 87 } 76 } 88 77 89 //....oooOO0OOooo........oooOO0OOooo........oo << 90 G4VHitsCollection* RE01StackingAction::GetCalC 78 G4VHitsCollection* RE01StackingAction::GetCalCollection() 91 { 79 { 92 G4SDManager* SDMan = G4SDManager::GetSDMpoin 80 G4SDManager* SDMan = G4SDManager::GetSDMpointer(); 93 G4RunManager* runMan = G4RunManager::GetRunM 81 G4RunManager* runMan = G4RunManager::GetRunManager(); 94 if (fCalorimeterHitsColID < 0) { << 82 if(calorimeterHitsColID<0) 95 fCalorimeterHitsColID = SDMan->GetCollecti << 83 { calorimeterHitsColID = SDMan->GetCollectionID("calCollection"); } 96 } << 84 if(calorimeterHitsColID>=0) 97 if (fCalorimeterHitsColID >= 0) { << 85 { 98 const G4Event* currentEvent = runMan->GetC 86 const G4Event* currentEvent = runMan->GetCurrentEvent(); 99 G4HCofThisEvent* HCE = currentEvent->GetHC 87 G4HCofThisEvent* HCE = currentEvent->GetHCofThisEvent(); 100 return HCE->GetHC(fCalorimeterHitsColID); << 88 return HCE->GetHC(calorimeterHitsColID); 101 } 89 } 102 return 0; 90 return 0; 103 } 91 } 104 92 105 //....oooOO0OOooo........oooOO0OOooo........oo << 106 void RE01StackingAction::NewStage() 93 void RE01StackingAction::NewStage() 107 { 94 { 108 // G4cout << "+++++++++++ Stage " << fStage << 95 if(stage==0) 109 if (fStage == 0) { << 96 { 110 // display trajetory information in the tr 97 // display trajetory information in the tracking region 111 G4cout << G4endl; 98 G4cout << G4endl; 112 G4cout << "Tracks in tracking region have 99 G4cout << "Tracks in tracking region have been processed. -- Stage 0 over." << G4endl; 113 G4cout << G4endl; 100 G4cout << G4endl; 114 } 101 } 115 else { << 102 else 116 // display calorimeter information caused << 103 { 117 // in the tracker region << 104 // display calorimeter information caused by a "source" track in the tracker region 118 // G4cout << G4endl; << 105 // G4cout << G4endl; 119 // G4cout << "Processing one shower ori << 106 // G4cout << "Processing one shower originated by a source track in tracker region is over." << G4endl; 120 // << "in tracker region is over << 107 // G4cout << G4endl; 121 // G4cout << G4endl; << 108 122 RE01CalorimeterHitsCollection* CHC = (RE01 109 RE01CalorimeterHitsCollection* CHC = (RE01CalorimeterHitsCollection*)GetCalCollection(); 123 if (CHC) { << 110 if(CHC) >> 111 { 124 int n_hit = CHC->entries(); 112 int n_hit = CHC->entries(); 125 G4double totE = 0; 113 G4double totE = 0; 126 G4int n_hitByATrack = 0; 114 G4int n_hitByATrack = 0; 127 for (int i = 0; i < n_hit; i++) { << 115 for(int i=0;i<n_hit;i++) >> 116 { 128 G4double edepByATrack = (*CHC)[i]->Get 117 G4double edepByATrack = (*CHC)[i]->GetEdepByATrack(); 129 if (edepByATrack > 0.) { << 118 if(edepByATrack>0.) >> 119 { 130 totE += edepByATrack; 120 totE += edepByATrack; 131 if (n_hitByATrack == 0) { << 121 if(n_hitByATrack==0) 132 (*CHC)[i]->GetTrackInformation()-> << 122 { (*CHC)[i]->GetTrackInformation()->Print(); } 133 } << 134 n_hitByATrack++; 123 n_hitByATrack++; 135 G4cout << "Cell[" << (*CHC)[i]->GetZ << 124 G4cout << "Cell[" << (*CHC)[i]->GetZ() << "," << (*CHC)[i]->GetPhi() << "] " 136 << edepByATrack / GeV << " [G << 125 << edepByATrack/GeV << " [GeV]" << G4endl; 137 (*CHC)[i]->ClearEdepByATrack(); 126 (*CHC)[i]->ClearEdepByATrack(); 138 } 127 } 139 } 128 } 140 if (n_hitByATrack > 0) { << 129 if(n_hitByATrack>0) >> 130 { 141 G4cout << "### Total energy depositio 131 G4cout << "### Total energy deposition in calorimeter by a source track in " 142 << n_hitByATrack << " cells : " 132 << n_hitByATrack << " cells : " << totE / GeV << " (GeV)" << G4endl; 143 G4cout << G4endl; 133 G4cout << G4endl; 144 } 134 } 145 } 135 } 146 } 136 } 147 137 148 if (stackManager->GetNUrgentTrack()) { << 138 // Transfer all tracks in Urgent stack to Waiting stack, since all tracks 149 // Transfer all tracks in Urgent stack to << 139 // in Waiting stack have already been transfered to Urgent stack before 150 // in Waiting stack have already been tran << 140 // invokation of this method. 151 // invokation of this method. << 141 stackManager->TransferStackedTracks(fUrgent,fWaiting); 152 stackManager->TransferStackedTracks(fUrgen << 153 142 154 // Then, transfer only one track to Urgent << 143 // Then, transfer only one track to Urgent stack. 155 stackManager->TransferOneStackedTrack(fWai << 144 stackManager->TransferOneStackedTrack(fWaiting,fUrgent); 156 145 157 fStage++; << 146 stage++; 158 } << 159 } 147 } 160 << 148 161 //....oooOO0OOooo........oooOO0OOooo........oo << 162 void RE01StackingAction::PrepareNewEvent() 149 void RE01StackingAction::PrepareNewEvent() 163 { << 150 { 164 fStage = 0; << 151 stage = 0; 165 } 152 } >> 153 >> 154 166 155