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 // $Id: FCALHadModuleSD.cc,v 1.10 2006/07/21 11:45:53 ribon Exp $ >> 27 // GEANT4 tag $Name: geant4-09-02 $ 26 // 28 // 27 // 29 // 28 30 29 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 30 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 31 33 32 #include <iostream> << 33 << 34 << 35 #include "FCALHadModuleSD.hh" 34 #include "FCALHadModuleSD.hh" 36 35 37 #include "FCALCalorHit.hh" 36 #include "FCALCalorHit.hh" 38 37 39 #include "FCALTestbeamSetup.hh" 38 #include "FCALTestbeamSetup.hh" 40 #include "FCALHadModule.hh" 39 #include "FCALHadModule.hh" 41 40 42 #include "G4SystemOfUnits.hh" << 43 #include "G4VPhysicalVolume.hh" 41 #include "G4VPhysicalVolume.hh" 44 #include "G4Step.hh" 42 #include "G4Step.hh" 45 #include "G4Track.hh" 43 #include "G4Track.hh" 46 #include "G4VTouchable.hh" 44 #include "G4VTouchable.hh" 47 #include "G4TouchableHistory.hh" 45 #include "G4TouchableHistory.hh" 48 #include "G4SDManager.hh" 46 #include "G4SDManager.hh" 49 47 50 #include "G4ios.hh" 48 #include "G4ios.hh" 51 << 49 #include <iostream> >> 50 #include <fstream> 52 //....oooOO0OOooo........oooOO0OOooo........oo 51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 53 52 54 FCALHadModuleSD::FCALHadModuleSD(G4String name 53 FCALHadModuleSD::FCALHadModuleSD(G4String name) : G4VSensitiveDetector(name), 55 InitF2(0) 54 InitF2(0) 56 { 55 { 57 HadModule = new FCALHadModule(); << 56 HadModule = new FCALHadModule(); 58 } 57 } 59 58 60 //....oooOO0OOooo........oooOO0OOooo........oo 59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 61 60 62 FCALHadModuleSD::~FCALHadModuleSD() 61 FCALHadModuleSD::~FCALHadModuleSD() 63 { 62 { 64 delete HadModule; 63 delete HadModule; 65 } 64 } 66 65 67 //....oooOO0OOooo........oooOO0OOooo........oo 66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 68 67 69 void FCALHadModuleSD::Initialize(G4HCofThisEve 68 void FCALHadModuleSD::Initialize(G4HCofThisEvent*) 70 { 69 { 71 if(InitF2 == 0) { 70 if(InitF2 == 0) { 72 HadModule->InitializeGeometry(); 71 HadModule->InitializeGeometry(); 73 InitF2++; 72 InitF2++; 74 } 73 } 75 for (G4int j=0; j<2330; j++) { EvisF2Tile[j] 74 for (G4int j=0; j<2330; j++) { EvisF2Tile[j]=0.;} 76 } 75 } 77 76 78 //....oooOO0OOooo........oooOO0OOooo........oo 77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 79 78 80 G4bool FCALHadModuleSD::ProcessHits(G4Step* aS 79 G4bool FCALHadModuleSD::ProcessHits(G4Step* aStep,G4TouchableHistory*) 81 { 80 { 82 81 83 G4double edep = aStep->GetTotalEnergyDeposit 82 G4double edep = aStep->GetTotalEnergyDeposit(); 84 if (edep==0.) return false; 83 if (edep==0.) return false; 85 84 86 G4TouchableHistory* theTouchable 85 G4TouchableHistory* theTouchable 87 = (G4TouchableHistory*)(aStep->GetPreStepP 86 = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable()); 88 G4VPhysicalVolume* physVol = theTouchable->G 87 G4VPhysicalVolume* physVol = theTouchable->GetVolume(); 89 88 90 89 91 if(strcmp(physVol->GetName(),"F2LArGapPhys 90 if(strcmp(physVol->GetName(),"F2LArGapPhysical")==0){ 92 G4int F2LArGapId = physVol->GetCopyNo(); 91 G4int F2LArGapId = physVol->GetCopyNo(); 93 G4int F2TileId = HadModule->GetF2TileID(F2 92 G4int F2TileId = HadModule->GetF2TileID(F2LArGapId); 94 EvisF2Tile[F2TileId] = EvisF2Tile[F2TileId 93 EvisF2Tile[F2TileId] = EvisF2Tile[F2TileId] + edep; 95 }; 94 }; 96 95 97 return true; 96 return true; 98 } 97 } 99 98 100 //....oooOO0OOooo........oooOO0OOooo........oo 99 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 101 100 102 void FCALHadModuleSD::EndOfEvent(G4HCofThisEve 101 void FCALHadModuleSD::EndOfEvent(G4HCofThisEvent*) 103 { 102 { 104 G4int NF2Tile = 0; 103 G4int NF2Tile = 0; >> 104 G4int AddTileP[300]; >> 105 G4double EvisTileP[300]; 105 G4int i=0; 106 G4int i=0; >> 107 106 for (i=0; i<2330; i++){ 108 for (i=0; i<2330; i++){ 107 if(EvisF2Tile[i] > 0.) { 109 if(EvisF2Tile[i] > 0.) { 108 NF2Tile++; 110 NF2Tile++; >> 111 AddTileP[NF2Tile] = i; >> 112 EvisTileP[NF2Tile] = EvisF2Tile[i]; 109 };}; 113 };}; 110 114 111 G4cout << "Number of F2 tiles with Positive 115 G4cout << "Number of F2 tiles with Positive energy : " << NF2Tile << G4endl; 112 116 >> 117 // Write data in File >> 118 //------------------- >> 119 G4String FileName = "HadModule_802_1mm.dat"; >> 120 std::ios::openmode iostemp; >> 121 if(InitF2 == 1) { >> 122 iostemp = std::ios::out; >> 123 InitF2++; >> 124 } else { >> 125 iostemp = std::ios::out|std::ios::app; // std::ios::app; >> 126 }; >> 127 >> 128 std::ofstream HadDatafile(FileName, iostemp); >> 129 // EmDatafile.precision(5); >> 130 >> 131 HadDatafile << NF2Tile << std::endl; >> 132 for (i=1; i <= NF2Tile; i++) { >> 133 HadDatafile << AddTileP[i] << " " << EvisTileP[i]/MeV << std::endl; >> 134 } >> 135 HadDatafile.close(); >> 136 >> 137 >> 138 >> 139 113 } 140 } 114 141 115 //....oooOO0OOooo........oooOO0OOooo........oo 142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 116 143 117 void FCALHadModuleSD::clear() 144 void FCALHadModuleSD::clear() 118 {} 145 {} 119 146 120 //....oooOO0OOooo........oooOO0OOooo........oo 147 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 121 148 122 void FCALHadModuleSD::DrawAll() 149 void FCALHadModuleSD::DrawAll() 123 {} 150 {} 124 151 125 //....oooOO0OOooo........oooOO0OOooo........oo 152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 126 153 127 void FCALHadModuleSD::PrintAll() 154 void FCALHadModuleSD::PrintAll() 128 {} 155 {} 129 156 130 //....oooOO0OOooo........oooOO0OOooo........oo 157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 131 158 132 159