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 Par01/src/Par01CalorimeterSD.cc 26 /// \file Par01/src/Par01CalorimeterSD.cc 27 /// \brief Implementation of the Par01Calorime 27 /// \brief Implementation of the Par01CalorimeterSD class 28 // 28 // 29 // 29 // 30 // 30 // 31 31 32 #include "Par01CalorimeterSD.hh" 32 #include "Par01CalorimeterSD.hh" 33 << 34 #include "Par01CalorimeterHit.hh" 33 #include "Par01CalorimeterHit.hh" 35 34 >> 35 #include "G4VPhysicalVolume.hh" 36 #include "G4LogicalVolume.hh" 36 #include "G4LogicalVolume.hh" >> 37 #include "G4Track.hh" 37 #include "G4ParticleDefinition.hh" 38 #include "G4ParticleDefinition.hh" 38 #include "G4SDManager.hh" 39 #include "G4SDManager.hh" 39 #include "G4Track.hh" << 40 #include "G4VPhysicalVolume.hh" << 41 #include "G4ios.hh" 40 #include "G4ios.hh" 42 41 43 //....oooOO0OOooo........oooOO0OOooo........oo 42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 44 43 45 Par01CalorimeterSD::Par01CalorimeterSD(G4Strin << 44 Par01CalorimeterSD::Par01CalorimeterSD( G4String name, 46 : G4VSensitiveDetector(name), fNumberOfCells << 45 G4int nCells, >> 46 G4String colName ) >> 47 : G4VSensitiveDetector(name), >> 48 fNumberOfCells(nCells), >> 49 fHCID(-1) 47 { 50 { 48 G4String HCname; 51 G4String HCname; 49 collectionName.insert(HCname = colName); << 52 collectionName.insert(HCname=colName); 50 fCellID = new G4int[fNumberOfCells]; 53 fCellID = new G4int[fNumberOfCells]; 51 } 54 } 52 55 53 //....oooOO0OOooo........oooOO0OOooo........oo 56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 54 57 55 Par01CalorimeterSD::~Par01CalorimeterSD() 58 Par01CalorimeterSD::~Par01CalorimeterSD() 56 { 59 { 57 delete[] fCellID; << 60 delete [] fCellID; 58 } 61 } 59 62 60 //....oooOO0OOooo........oooOO0OOooo........oo 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 61 64 62 void Par01CalorimeterSD::Initialize(G4HCofThis 65 void Par01CalorimeterSD::Initialize(G4HCofThisEvent*) 63 { 66 { 64 fCalCollection = new Par01CalorimeterHitsCol << 67 fCalCollection = new Par01CalorimeterHitsCollection 65 for (G4int j = 0; j < fNumberOfCells; j++) { << 68 (SensitiveDetectorName,collectionName[0]); 66 fCellID[j] = -1; << 69 for(G4int j=0;j<fNumberOfCells;j++) 67 } << 70 { >> 71 fCellID[j] = -1; >> 72 } 68 } 73 } 69 74 70 //....oooOO0OOooo........oooOO0OOooo........oo 75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 71 76 72 G4bool Par01CalorimeterSD::ProcessHits(G4Step* 77 G4bool Par01CalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) 73 { 78 { 74 G4double edep = aStep->GetTotalEnergyDeposit 79 G4double edep = aStep->GetTotalEnergyDeposit(); 75 if (edep <= 0.) return false; << 80 if(edep<=0.) return false; 76 << 81 77 auto hist = (G4TouchableHistory*)(aStep->Get << 82 auto hist = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable()); 78 const G4VPhysicalVolume* physVol = hist->Get 83 const G4VPhysicalVolume* physVol = hist->GetVolume(); 79 G4int copyID = hist->GetReplicaNumber(); 84 G4int copyID = hist->GetReplicaNumber(); 80 << 85 81 if (fCellID[copyID] == -1) { << 86 if(fCellID[copyID]==-1) 82 Par01CalorimeterHit* calHit = new Par01Cal << 87 { 83 calHit->SetEdep(edep); << 88 Par01CalorimeterHit* calHit = 84 G4AffineTransform aTrans = hist->GetHistor << 89 new Par01CalorimeterHit(physVol->GetLogicalVolume()); 85 aTrans.Invert(); << 90 calHit->SetEdep( edep ); 86 calHit->SetPos(aTrans.NetTranslation()); << 91 G4AffineTransform aTrans = hist->GetHistory()->GetTopTransform(); 87 calHit->SetRot(aTrans.NetRotation()); << 92 aTrans.Invert(); 88 G4int icell = fCalCollection->insert(calHi << 93 calHit->SetPos(aTrans.NetTranslation()); 89 fCellID[copyID] = icell - 1; << 94 calHit->SetRot(aTrans.NetRotation()); 90 if (verboseLevel > 0) { << 95 G4int icell = fCalCollection->insert( calHit ); 91 G4cout << " New Calorimeter Hit on CellI << 96 fCellID[copyID] = icell - 1; >> 97 if(verboseLevel>0) >> 98 { G4cout << " New Calorimeter Hit on CellID " << copyID << G4endl; } 92 } 99 } 93 } << 100 else 94 else { << 101 { 95 (*fCalCollection)[fCellID[copyID]]->AddEde << 102 (*fCalCollection)[fCellID[copyID]]->AddEdep( edep ); 96 if (verboseLevel > 0) { << 103 if(verboseLevel>0) 97 G4cout << " Energy added to CellID " << << 104 { G4cout << " Energy added to CellID " << copyID << G4endl; } 98 } 105 } 99 } << 106 100 << 101 return true; 107 return true; 102 } 108 } 103 109 104 //....oooOO0OOooo........oooOO0OOooo........oo 110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 105 111 106 void Par01CalorimeterSD::EndOfEvent(G4HCofThis << 112 void Par01CalorimeterSD::EndOfEvent(G4HCofThisEvent*HCE) 107 { 113 { 108 if (fHCID < 0) { << 114 if(fHCID<0) 109 fHCID = G4SDManager::GetSDMpointer()->GetC << 115 { fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); } 110 } << 116 HCE->AddHitsCollection( fHCID, fCalCollection ); 111 HCE->AddHitsCollection(fHCID, fCalCollection << 112 } 117 } 113 118 114 //....oooOO0OOooo........oooOO0OOooo........oo 119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 115 120 116 void Par01CalorimeterSD::clear() {} << 121 void Par01CalorimeterSD::clear() >> 122 { >> 123 } 117 124 118 //....oooOO0OOooo........oooOO0OOooo........oo 125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 119 126 120 void Par01CalorimeterSD::DrawAll() {} << 127 void Par01CalorimeterSD::DrawAll() >> 128 { >> 129 } 121 130 122 //....oooOO0OOooo........oooOO0OOooo........oo 131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 123 132 124 void Par01CalorimeterSD::PrintAll() {} << 133 void Par01CalorimeterSD::PrintAll() >> 134 { >> 135 } 125 136