File indexing completed on 2025-01-18 09:17:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 #include "XrayFluoSD.hh"
0039 #include "XrayFluoSensorHit.hh"
0040 #include "XrayFluoDetectorConstruction.hh"
0041 #include "XrayFluoPlaneDetectorConstruction.hh"
0042 #include "XrayFluoMercuryDetectorConstruction.hh"
0043 #include "G4VPhysicalVolume.hh"
0044 #include "G4Step.hh"
0045 #include "G4VTouchable.hh"
0046 #include "G4TouchableHistory.hh"
0047 #include "G4SDManager.hh"
0048 #include "G4ios.hh"
0049 #include "G4VProcess.hh"
0050
0051
0052
0053 XrayFluoSD::XrayFluoSD(G4String name,
0054 XrayFluoDetectorConstruction* det)
0055 :G4VSensitiveDetector(name),Detector(0),planeDetector(0),mercuryDetector(0)
0056 {
0057
0058 Detector = det;
0059 collectionName.insert("HPGeCollection");
0060 HitHPGeID = new G4int[500];
0061 G4cout << "XrayFluoSD created" << G4endl;
0062
0063 }
0064
0065
0066
0067 XrayFluoSD::XrayFluoSD(G4String name,
0068 XrayFluoPlaneDetectorConstruction* det)
0069 :G4VSensitiveDetector(name),Detector(0),planeDetector(0),mercuryDetector(0)
0070 {
0071 planeDetector = det;
0072 collectionName.insert("HPGeCollection");
0073 HitHPGeID = new G4int[500];
0074 G4cout << "XrayFluoSD created" << G4endl;
0075
0076 }
0077
0078
0079
0080 XrayFluoSD::XrayFluoSD(G4String name,
0081 XrayFluoMercuryDetectorConstruction* det)
0082 :G4VSensitiveDetector(name),Detector(0),planeDetector(0),mercuryDetector(0)
0083 {
0084 mercuryDetector = det;
0085 collectionName.insert("HPGeCollection");
0086 HitHPGeID = new G4int[500];
0087 G4cout << "XrayFluoSD created" << G4endl;
0088 }
0089
0090
0091
0092
0093
0094
0095 XrayFluoSD::~XrayFluoSD()
0096 {
0097
0098 delete [] HitHPGeID;
0099
0100
0101
0102 G4cout << "XrayFluoSD deleted" << G4endl;
0103 }
0104
0105
0106
0107 void XrayFluoSD::Initialize(G4HCofThisEvent*)
0108
0109
0110
0111 {
0112 HPGeCollection = new XrayFluoSensorHitsCollection
0113 (SensitiveDetectorName,collectionName[0]);
0114
0115 G4int nPixel = 0;
0116
0117 if (Detector) {nPixel = Detector->GetNbOfPixels();}
0118 else if (planeDetector) {nPixel = planeDetector->GetNbOfPixels();}
0119 else if (mercuryDetector) {nPixel = mercuryDetector->GetNbOfPixels();}
0120
0121 for (G4int j=0;j<nPixel;j++)
0122 {HitHPGeID [j]= -1;};
0123 }
0124
0125
0126
0127 G4bool XrayFluoSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
0128 {
0129
0130
0131
0132 G4double edep = aStep->GetTotalEnergyDeposit();
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148 if (edep==0.) return false;
0149
0150
0151
0152 G4TouchableHistory* theTouchable
0153 = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
0154
0155
0156
0157 G4VPhysicalVolume* physVol = theTouchable->GetVolume();
0158 G4int PixelNumber = 0;
0159
0160 if (Detector && Detector->GetNbOfPixels()>1) {PixelNumber= physVol->GetCopyNo();}
0161 else if (planeDetector && planeDetector->GetNbOfPixels()>1) {PixelNumber= physVol->GetCopyNo();}
0162 else if (mercuryDetector && mercuryDetector->GetNbOfPixels()>1) {PixelNumber= physVol->GetCopyNo();}
0163
0164
0165
0166 if ( HitHPGeID[PixelNumber]==-1)
0167 {
0168 XrayFluoSensorHit* HPGeHit = new XrayFluoSensorHit();
0169 HPGeHit->AddEnergy(edep);
0170 HitHPGeID[PixelNumber] = HPGeCollection->insert(HPGeHit) - 1;
0171 if (verboseLevel>0){
0172 G4cout << " New Hit on pixel: " << PixelNumber << G4endl;
0173 }
0174 }
0175 else
0176 {
0177 (*HPGeCollection)[HitHPGeID[PixelNumber]]->AddEnergy(edep);
0178
0179 if (verboseLevel>0)
0180 G4cout << " Energy added to Pixel: " << PixelNumber << G4endl;
0181 }
0182
0183 return true;
0184 }
0185
0186
0187
0188
0189 void XrayFluoSD::EndOfEvent(G4HCofThisEvent* HCE)
0190 {
0191 static G4int HCID = -1;
0192 if(HCID<0)
0193 { HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); }
0194 HCE->AddHitsCollection(HCID,HPGeCollection);
0195 }
0196
0197
0198
0199 void XrayFluoSD::clear()
0200 {}
0201
0202
0203
0204 void XrayFluoSD::DrawAll()
0205 {}
0206
0207
0208
0209 void XrayFluoSD::PrintAll()
0210 {}
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227