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 // $Id$ 27 // ------------------------------------------- 28 // ------------------------------------------------------------ 28 // GEANT 4 class implementation file 29 // GEANT 4 class implementation file 29 // CERN Geneva Switzerland 30 // CERN Geneva Switzerland 30 // 31 // 31 // 32 // 32 // ------------ GammaRayTelDigitizer --- 33 // ------------ GammaRayTelDigitizer ------ 33 // by F.Longo, R.Giannitrapani & G 34 // by F.Longo, R.Giannitrapani & G.Santin (13 nov 2000) 34 // 35 // 35 // ******************************************* 36 // ************************************************************ 36 37 37 #include <vector> 38 #include <vector> 38 39 39 #include "GammaRayTelAnticoincidenceHit.hh" << 40 #include "GammaRayTelCalorimeterHit.hh" << 41 #include "GammaRayTelDigi.hh" << 42 #include "GammaRayTelDigitizer.hh" 40 #include "GammaRayTelDigitizer.hh" >> 41 #include "GammaRayTelDigi.hh" 43 #include "GammaRayTelDigitizerMessenger.hh" 42 #include "GammaRayTelDigitizerMessenger.hh" >> 43 44 #include "GammaRayTelTrackerHit.hh" 44 #include "GammaRayTelTrackerHit.hh" >> 45 #include "GammaRayTelCalorimeterHit.hh" >> 46 #include "GammaRayTelAnticoincidenceHit.hh" 45 47 46 #include "G4DigiManager.hh" << 48 #include "G4SystemOfUnits.hh" 47 #include "G4Event.hh" << 48 #include "G4EventManager.hh" 49 #include "G4EventManager.hh" 49 #include "G4ios.hh" << 50 #include "G4Event.hh" 50 #include "G4SDManager.hh" 51 #include "G4SDManager.hh" 51 #include "G4SystemOfUnits.hh" << 52 #include "G4DigiManager.hh" >> 53 #include "G4ios.hh" 52 54 53 //....oooOO0OOooo........oooOO0OOooo........oo 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 54 56 55 GammaRayTelDigitizer::GammaRayTelDigitizer(G4S << 57 GammaRayTelDigitizer::GammaRayTelDigitizer(G4String name) 56 constexpr auto DIGIT_COLLECTION_NAME{"Digi << 58 :G4VDigitizerModule(name) 57 collectionName.push_back(DIGIT_COLLECTION_ << 59 { 58 60 59 // create a messenger for this class << 60 digitizerMessenger = new GammaRayTelDigiti << 61 } << 62 61 63 //....oooOO0OOooo........oooOO0OOooo........oo << 62 G4String colName = "DigitsCollection"; >> 63 collectionName.push_back(colName); >> 64 Energy_Threshold = 120.*keV; >> 65 TotalEnergy = 0.; >> 66 ACDThreshold = 15*keV; >> 67 >> 68 //create a messenger for this class >> 69 digiMessenger = new GammaRayTelDigitizerMessenger(this); 64 70 65 GammaRayTelDigitizer::~GammaRayTelDigitizer() << 66 delete digitizerMessenger; << 67 } 71 } 68 72 69 //....oooOO0OOooo........oooOO0OOooo........oo 73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 70 74 71 void GammaRayTelDigitizer::Digitize() { << 75 GammaRayTelDigitizer::~GammaRayTelDigitizer() 72 digitsCollection = new GammaRayTelDigitsCo << 76 { 73 << 77 delete digiMessenger; 74 auto *digitManager = G4DigiManager::GetDMp << 78 } 75 << 76 G4int trackerCollectionIdentifier{0}; // T << 77 G4int calorimeterCollectionIdentifier{0}; << 78 G4int anticoincidenceCollectionIdentifier{ << 79 << 80 totalEnergy = 0.; // at each event << 81 79 82 // TKR hits collection << 80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 83 81 84 trackerCollectionIdentifier = digitManager << 82 void GammaRayTelDigitizer::Digitize() 85 GammaRayTelTrackerHitsCollection *trackerC << 83 { 86 trackerCollection = (GammaRayTelTrackerHit << 84 DigitsCollection = new GammaRayTelDigitsCollection >> 85 ("GammaRayTelDigitizer","DigitsCollection"); // to create the Digi Collection >> 86 >> 87 G4DigiManager* DigiMan = G4DigiManager::GetDMpointer(); >> 88 >> 89 G4int THCID; // TrackerCollection >> 90 G4int CHCID; // CalorimeterCollection >> 91 G4int AHCID; // AnticoincidenceCollection >> 92 >> 93 TotalEnergy = 0.; // at each event >> 94 >> 95 // TKR Hits collection >> 96 >> 97 THCID = DigiMan->GetHitsCollectionID("TrackerCollection"); >> 98 GammaRayTelTrackerHitsCollection* THC = 0; >> 99 THC = (GammaRayTelTrackerHitsCollection*) >> 100 (DigiMan->GetHitsCollection(THCID)); >> 101 >> 102 >> 103 // CAL Hits collection >> 104 >> 105 CHCID = DigiMan->GetHitsCollectionID("CalorimeterCollection"); >> 106 GammaRayTelCalorimeterHitsCollection* CHC = 0; >> 107 CHC = (GammaRayTelCalorimeterHitsCollection*) >> 108 (DigiMan->GetHitsCollection(CHCID)); >> 109 >> 110 // ACD Hits collection >> 111 >> 112 AHCID = DigiMan->GetHitsCollectionID("AnticoincidenceCollection"); >> 113 GammaRayTelAnticoincidenceHitsCollection* AHC = 0; >> 114 AHC = (GammaRayTelAnticoincidenceHitsCollection*) >> 115 (DigiMan->GetHitsCollection(AHCID)); >> 116 >> 117 >> 118 if (THC) >> 119 { >> 120 G4int n_hit = THC->entries(); >> 121 >> 122 for (G4int i=0;i<n_hit;i++) >> 123 { >> 124 G4double ESil = (*THC)[i]->GetEdepSil(); >> 125 G4int NStrip = (*THC)[i]->GetNStrip(); >> 126 G4int NPlane = (*THC)[i]->GetNSilPlane(); >> 127 G4int IsX = (*THC)[i]->GetPlaneType(); >> 128 >> 129 // digi generation only if energy deposit greater than threshold >> 130 >> 131 if (ESil>Energy_Threshold) >> 132 { >> 133 GammaRayTelDigi* Digi = new GammaRayTelDigi(); >> 134 Digi->SetPlaneNumber(NPlane); >> 135 Digi->SetPlaneType(IsX); >> 136 Digi->SetStripNumber(NStrip); >> 137 Digi->SetDigiType(0); >> 138 Digi->SetEnergy(0.); >> 139 DigitsCollection->insert(Digi); >> 140 } >> 141 } >> 142 } >> 143 if (CHC) >> 144 { >> 145 G4int n_hit = CHC->entries(); >> 146 >> 147 for (G4int i=0;i<n_hit;i++) >> 148 { >> 149 TotalEnergy +=(*CHC)[i]->GetEdepCAL(); >> 150 } >> 151 // digi generation only if energy deposit greater than 0. >> 152 >> 153 if (TotalEnergy>0.) >> 154 { >> 155 GammaRayTelDigi* Digi = new GammaRayTelDigi(); >> 156 Digi->SetPlaneNumber(0); >> 157 Digi->SetPlaneType(0); >> 158 Digi->SetStripNumber(0); >> 159 Digi->SetDigiType(1); >> 160 Digi->SetEnergy(TotalEnergy); >> 161 DigitsCollection->insert(Digi); >> 162 } 87 163 88 // CAL hits collection << 164 } 89 165 90 calorimeterCollectionIdentifier = digitMan << 166 if (AHC) 91 GammaRayTelCalorimeterHitsCollection *calo << 167 { 92 calorimeterCollection = (GammaRayTelCalori << 168 G4int n_hit = AHC->entries(); >> 169 >> 170 for (G4int i=0;i<n_hit;i++) >> 171 { >> 172 G4double energy = (*AHC)[i]->GetEdepACD(); >> 173 G4int type = (*AHC)[i]->GetACDTileNumber(); >> 174 >> 175 // digi generation only if energy deposit greater than 0. >> 176 >> 177 if (energy>ACDThreshold) >> 178 { >> 179 GammaRayTelDigi* Digi = new GammaRayTelDigi(); >> 180 Digi->SetPlaneNumber(0); >> 181 Digi->SetPlaneType(0); >> 182 Digi->SetStripNumber(type); >> 183 Digi->SetDigiType(2); >> 184 Digi->SetEnergy(energy); >> 185 DigitsCollection->insert(Digi); >> 186 } >> 187 >> 188 } >> 189 } >> 190 >> 191 if (THC||AHC||CHC){ >> 192 G4cout << "Number of digits in this event = " >> 193 << DigitsCollection->entries() >> 194 // << " " << DigitsCollection->GetName() >> 195 // << " " << DigitsCollection->GetDMname() >> 196 << G4endl; >> 197 } >> 198 >> 199 StoreDigiCollection(DigitsCollection); >> 200 >> 201 G4int DCID = -1; >> 202 if(DCID<0) >> 203 { >> 204 // DigiMan->List(); >> 205 DCID = DigiMan->GetDigiCollectionID("GammaRayTelDigitizer/DigitsCollection"); >> 206 } >> 207 >> 208 >> 209 } 93 210 94 // ACD hits collection << 95 211 96 anticoincidenceCollectionIdentifier = digi << 97 GammaRayTelAnticoincidenceHitsCollection * << 98 anticoincidenceCollection = (GammaRayTelAn << 99 212 100 if (trackerCollection != nullptr) { << 213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 101 G4int numberOfHits = trackerCollection << 102 214 103 for (auto i = 0; i < numberOfHits; i++ << 104 G4double depositedEnergy = (*track << 105 G4int stripNumber = (*trackerColle << 106 G4int planeNumber = (*trackerColle << 107 G4int IsX = (*trackerCollection)[i << 108 215 109 // digi generation only if energy << 110 216 111 if (depositedEnergy > energyThresh << 112 auto *digit = new GammaRayTelD << 113 digit->SetPlaneNumber(planeNum << 114 digit->SetPlaneType(IsX); << 115 digit->SetStripNumber(stripNum << 116 digit->SetDigitType(0); << 117 digit->SetEnergy(0.); << 118 digitsCollection->insert(digit << 119 } << 120 } << 121 } << 122 217 123 if (calorimeterCollection != nullptr) { << 124 G4int numberOfHits = calorimeterCollec << 125 218 126 for (auto i = 0; i < numberOfHits; i++ << 127 totalEnergy += (*calorimeterCollec << 128 } << 129 << 130 // digit generation only if energy dep << 131 << 132 if (totalEnergy > 0.) { << 133 auto *digit = new GammaRayTelDigi( << 134 digit->SetPlaneNumber(0); << 135 digit->SetPlaneType(0); << 136 digit->SetStripNumber(0); << 137 digit->SetDigitType(1); << 138 digit->SetEnergy(totalEnergy); << 139 digitsCollection->insert(digit); << 140 } << 141 } << 142 219 143 if (anticoincidenceCollection != nullptr) << 144 G4int numberOfHits = anticoincidenceCo << 145 220 146 for (G4int i = 0; i < numberOfHits; i+ << 147 auto energy = (*anticoincidenceCol << 148 auto type = (*anticoincidenceColle << 149 << 150 // digit generation only if energy << 151 << 152 if (energy > acdThreshold) { << 153 auto *digit = new GammaRayTelD << 154 digit->SetPlaneNumber(0); << 155 digit->SetPlaneType(0); << 156 digit->SetStripNumber(type); << 157 digit->SetDigitType(2); << 158 digit->SetEnergy(energy); << 159 digitsCollection->insert(digit << 160 } << 161 } << 162 } << 163 221 164 if (trackerCollection != nullptr || antico << 165 G4cout << "Number of digits in this ev << 166 // << " " << digitsCollection->GetName << 167 // << " " << digitsCollection->GetDMna << 168 << G4endl; << 169 } << 170 222 171 StoreDigiCollection(digitsCollection); << 172 223 173 G4int digitsCollectionIdentifier{-1}; << 174 if (digitsCollectionIdentifier < 0) { << 175 // digiManager->List(); << 176 digitsCollectionIdentifier = digitMana << 177 } << 178 } << 179 224