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 // 26 // 27 /// \file RE05/src/RE05CalorimeterSD.cc 27 /// \file RE05/src/RE05CalorimeterSD.cc 28 /// \brief Implementation of the RE05Calorimet 28 /// \brief Implementation of the RE05CalorimeterSD class 29 // 29 // 30 30 31 #include "RE05CalorimeterSD.hh" 31 #include "RE05CalorimeterSD.hh" 32 << 33 #include "RE05CalorimeterHit.hh" 32 #include "RE05CalorimeterHit.hh" 34 << 33 #include "G4VPhysicalVolume.hh" 35 #include "G4LogicalVolume.hh" 34 #include "G4LogicalVolume.hh" 36 #include "G4ParticleDefinition.hh" << 37 #include "G4Step.hh" << 38 #include "G4SystemOfUnits.hh" << 39 #include "G4TouchableHistory.hh" << 40 #include "G4Track.hh" 35 #include "G4Track.hh" 41 #include "G4VPhysicalVolume.hh" << 36 #include "G4Step.hh" >> 37 #include "G4ParticleDefinition.hh" 42 #include "G4VTouchable.hh" 38 #include "G4VTouchable.hh" >> 39 #include "G4TouchableHistory.hh" >> 40 #include "G4SystemOfUnits.hh" 43 #include "G4ios.hh" 41 #include "G4ios.hh" 44 42 45 //....oooOO0OOooo........oooOO0OOooo........oo 43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 46 44 47 RE05CalorimeterSD::RE05CalorimeterSD(G4String 45 RE05CalorimeterSD::RE05CalorimeterSD(G4String name) 48 : G4VSensitiveDetector(name), fNumberOfCells << 46 :G4VSensitiveDetector(name), >> 47 fNumberOfCellsInZ(20),fNumberOfCellsInPhi(48) 49 { 48 { 50 G4String HCname; 49 G4String HCname; 51 collectionName.insert(HCname = "calCollectio << 50 collectionName.insert(HCname="calCollection"); 52 } 51 } 53 52 54 //....oooOO0OOooo........oooOO0OOooo........oo 53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 55 54 56 RE05CalorimeterSD::~RE05CalorimeterSD() {} << 55 RE05CalorimeterSD::~RE05CalorimeterSD() >> 56 {} 57 57 58 //....oooOO0OOooo........oooOO0OOooo........oo 58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 59 59 60 void RE05CalorimeterSD::Initialize(G4HCofThisE 60 void RE05CalorimeterSD::Initialize(G4HCofThisEvent*) 61 { 61 { 62 fCalCollection = new RE05CalorimeterHitsColl << 62 fCalCollection = new RE05CalorimeterHitsCollection 63 for (G4int j = 0; j < fNumberOfCellsInZ; j++ << 63 (SensitiveDetectorName,collectionName[0]); 64 for (G4int k = 0; k < fNumberOfCellsInPhi; << 64 for(G4int j=0;j<fNumberOfCellsInZ;j++) 65 fCellID[j][k] = -1; << 65 for(G4int k=0;k<fNumberOfCellsInPhi;k++) 66 } << 66 { >> 67 fCellID[j][k] = -1; >> 68 } 67 verboseLevel = 0; 69 verboseLevel = 0; 68 } 70 } 69 71 70 //....oooOO0OOooo........oooOO0OOooo........oo 72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 71 73 72 G4bool RE05CalorimeterSD::ProcessHits(G4Step* << 74 G4bool RE05CalorimeterSD::ProcessHits(G4Step*aStep,G4TouchableHistory*) 73 { 75 { 74 //***** RE05CalorimeterSD has been migrated << 76 //***** RE05CalorimeterSD has been migrated to Geant4 version 10 that does not 75 //***** support Readout Geometry in multi-th << 77 //***** support Readout Geometry in multi-threaded mode. Now RE05CalorimeterSD 76 //***** is assigned to a dedicated parallel << 78 //***** is assigned to a dedicated parallel world. The pointer "aStep" points to 77 //***** a G4Step object for the parallel wor << 79 //***** a G4Step object for the parallel world. 78 80 79 G4double edep = aStep->GetTotalEnergyDeposit 81 G4double edep = aStep->GetTotalEnergyDeposit(); 80 if (verboseLevel > 1) G4cout << "Next step e << 82 if(verboseLevel>1) G4cout << "Next step edep(MeV) = " << edep/MeV << G4endl; 81 if (edep == 0.) return false; << 83 if(edep==0.) return false; 82 84 83 const G4VTouchable* touchable = aStep->GetPr 85 const G4VTouchable* touchable = aStep->GetPreStepPoint()->GetTouchable(); 84 G4int copyIDinZ = touchable->GetReplicaNumbe 86 G4int copyIDinZ = touchable->GetReplicaNumber(0); 85 G4int copyIDinPhi = touchable->GetReplicaNum 87 G4int copyIDinPhi = touchable->GetReplicaNumber(1); 86 88 87 if (fCellID[copyIDinZ][copyIDinPhi] == -1) { << 89 if(fCellID[copyIDinZ][copyIDinPhi]==-1) 88 RE05CalorimeterHit* calHit = << 90 { 89 new RE05CalorimeterHit(touchable->GetVol << 91 RE05CalorimeterHit* calHit 90 calHit->SetEdep(edep); << 92 = new RE05CalorimeterHit >> 93 (touchable->GetVolume()->GetLogicalVolume(),copyIDinZ,copyIDinPhi); >> 94 calHit->SetEdep( edep ); 91 G4AffineTransform aTrans = touchable->GetH 95 G4AffineTransform aTrans = touchable->GetHistory()->GetTopTransform(); 92 aTrans.Invert(); 96 aTrans.Invert(); 93 calHit->SetPos(aTrans.NetTranslation()); 97 calHit->SetPos(aTrans.NetTranslation()); 94 calHit->SetRot(aTrans.NetRotation()); 98 calHit->SetRot(aTrans.NetRotation()); 95 G4int icell = fCalCollection->insert(calHi << 99 G4int icell = fCalCollection->insert( calHit ); 96 fCellID[copyIDinZ][copyIDinPhi] = icell - 100 fCellID[copyIDinZ][copyIDinPhi] = icell - 1; 97 if (verboseLevel > 0) { << 101 if(verboseLevel>0) 98 G4cout << " New Calorimeter Hit on fCell << 102 { G4cout << " New Calorimeter Hit on fCellID " 99 } << 103 << copyIDinZ << " " << copyIDinPhi << G4endl; } 100 } 104 } 101 else { << 105 else >> 106 { 102 (*fCalCollection)[fCellID[copyIDinZ][copyI 107 (*fCalCollection)[fCellID[copyIDinZ][copyIDinPhi]]->AddEdep(edep); 103 if (verboseLevel > 0) { << 108 if(verboseLevel>0) 104 G4cout << " Energy added to fCellID " << << 109 { G4cout << " Energy added to fCellID " 105 } << 110 << copyIDinZ << " " << copyIDinPhi << G4endl; } 106 } 111 } 107 112 108 return true; 113 return true; 109 } 114 } 110 115 111 //....oooOO0OOooo........oooOO0OOooo........oo 116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 112 117 113 void RE05CalorimeterSD::EndOfEvent(G4HCofThisE << 118 void RE05CalorimeterSD::EndOfEvent(G4HCofThisEvent*HCE) 114 { 119 { 115 static G4int HCID = -1; 120 static G4int HCID = -1; 116 if (HCID < 0) { << 121 if(HCID<0) 117 HCID = GetCollectionID(0); << 122 { HCID = GetCollectionID(0); } 118 } << 123 HCE->AddHitsCollection( HCID, fCalCollection ); 119 HCE->AddHitsCollection(HCID, fCalCollection) << 120 } 124 } 121 125 122 //....oooOO0OOooo........oooOO0OOooo........oo 126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 123 127 124 void RE05CalorimeterSD::clear() {} << 128 void RE05CalorimeterSD::clear() >> 129 {} 125 130 126 //....oooOO0OOooo........oooOO0OOooo........oo 131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 127 132 128 void RE05CalorimeterSD::DrawAll() {} << 133 void RE05CalorimeterSD::DrawAll() >> 134 {} 129 135 130 //....oooOO0OOooo........oooOO0OOooo........oo 136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 131 137 132 void RE05CalorimeterSD::PrintAll() {} << 138 void RE05CalorimeterSD::PrintAll() >> 139 {} 133 140 134 //....oooOO0OOooo........oooOO0OOooo........oo 141 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 135 142