Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:17:11

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 //
0028 // Author: Elena Guardincerri (Elena.Guardincerri@ge.infn.it)
0029 //
0030 // History:
0031 // -----------
0032 // 28 Nov 2001 Elena Guardincerri     Created
0033 // 29 Nov 2002 Energy deposition bug fixed (Alfonso.mantero@ge.infn.it)
0034 // 17 Jul 2003 Name changed to XrayFluoSD
0035 // 01 Sep 2003 Constructor overload for different geometries handling
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
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 // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0091 
0092 
0093 
0094 
0095 XrayFluoSD::~XrayFluoSD()
0096 {
0097 
0098   delete [] HitHPGeID;
0099 
0100   // delete HPGeCollection;
0101 
0102   G4cout << "XrayFluoSD deleted" << G4endl;
0103 }
0104 
0105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0106 
0107 void XrayFluoSD::Initialize(G4HCofThisEvent*)
0108  
0109 //initializes HCE with the hits collection(s) created by this 
0110   //sensitive detector
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0126 
0127 G4bool XrayFluoSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
0128 {   
0129 
0130 
0131 
0132   G4double edep = aStep->GetTotalEnergyDeposit();
0133 
0134   /*
0135     G4String particleName = aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->GetParticleName();
0136 
0137     G4Track* track = aStep->GetTrack();
0138     G4int trackId = track->GetTrackID();
0139     //G4String processName = aStep->GetTrack()->GetCreatorProcess()->GetProcessName();
0140 
0141     G4double partEnergy = aStep->GetPreStepPoint()->GetKineticEnergy(); 
0142     G4double secondEnergy = aStep->GetPostStepPoint()->GetKineticEnergy();
0143     G4cout << " la particella che deposita e': " << particleName << " ha una energia di keV "
0144        << partEnergy  << " e deposita "<< edep << G4endl;
0145     G4cout << " la particella creata ha energia cinetica: " << secondEnergy << G4endl;  
0146   */
0147 
0148   if (edep==0.) return false;      
0149 
0150   //G4cout << " edep =  " << edep << G4endl;
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       //G4double ED =(*HPGeCollection)[HitHPGeID[PixelNumber]]->GetEdepTot(); 
0179       if (verboseLevel>0)
0180     G4cout << " Energy added to Pixel: " << PixelNumber << G4endl; 
0181     }
0182   
0183   return true;
0184 }
0185 
0186 
0187 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0198 
0199 void XrayFluoSD::clear()
0200 {} 
0201 
0202 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0203 
0204 void XrayFluoSD::DrawAll()
0205 {} 
0206 
0207 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0208 
0209 void XrayFluoSD::PrintAll()
0210 {} 
0211 
0212 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0213 
0214 
0215 
0216 
0217 
0218 
0219 
0220 
0221 
0222 
0223 
0224 
0225 
0226 
0227