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