Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:13

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 //      GEANT 4 class implementation file
0029 //      CERN Geneva Switzerland
0030 //
0031 //
0032 //      ------------ GammaRayTelAnticoincidenceSD  ------
0033 //           by  R.Giannitrapani, F.Longo & G.Santin (13 nov 2000)
0034 //
0035 // ************************************************************
0036 
0037 #include "GammaRayTelAnticoincidenceSD.hh"
0038 #include "GammaRayTelAnticoincidenceHit.hh"
0039 #include "GammaRayTelDetectorConstruction.hh"
0040 
0041 #include "G4ios.hh"
0042 #include "G4RunManager.hh"
0043 #include "G4SDManager.hh"
0044 #include "G4Step.hh"
0045 #include "G4SystemOfUnits.hh"
0046 #include "G4TouchableHistory.hh"
0047 #include "G4VPhysicalVolume.hh"
0048 #include "G4VTouchable.hh"
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0051 
0052 GammaRayTelAnticoincidenceSD::GammaRayTelAnticoincidenceSD(G4String name) : G4VSensitiveDetector(name) {
0053     auto *runManager = G4RunManager::GetRunManager();
0054     detector = (GammaRayTelDetectorConstruction*) (runManager->GetUserDetectorConstruction());
0055 
0056     numberOfACDLateralTiles = detector->GetNbOfACDLateralTiles();
0057     numberOfACDTopTiles = detector->GetNbOfACDTopTiles();
0058 
0059     G4cout << numberOfACDLateralTiles << " LATERAL " << G4endl;
0060     G4cout << numberOfACDTopTiles << " TOP " << G4endl;
0061 
0062     hitLateralID = new G4int[numberOfACDLateralTiles];
0063     hitTopID = new G4int[numberOfACDTopTiles];
0064     collectionName.insert("AnticoincidenceCollection");
0065 }
0066 
0067 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0068 
0069 GammaRayTelAnticoincidenceSD::~GammaRayTelAnticoincidenceSD() {
0070     delete[] hitLateralID;
0071     delete[] hitTopID;
0072 }
0073 
0074 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0075 
0076 void GammaRayTelAnticoincidenceSD::Initialize(G4HCofThisEvent*) {
0077     anticoincidenceCollection = new GammaRayTelAnticoincidenceHitsCollection(SensitiveDetectorName, collectionName[0]);
0078     for (auto i = 0; i < numberOfACDLateralTiles; i++) {
0079         hitLateralID[i] = -1;
0080     }
0081 
0082     for (auto j = 0; j < numberOfACDTopTiles; j++) {
0083         hitTopID[j] = -1;
0084     }
0085 }
0086 
0087 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0088 
0089 auto GammaRayTelAnticoincidenceSD::ProcessHits(G4Step *step, G4TouchableHistory*) -> G4bool {
0090     auto depositedEnergy = step->GetTotalEnergyDeposit();
0091     if (depositedEnergy / keV == 0.) {
0092         return false;
0093     }
0094 
0095     // This TouchableHistory is used to obtain the physical volume of the hit
0096     auto *theTouchable = (G4TouchableHistory*) (step->GetPreStepPoint()->GetTouchable());
0097 
0098     auto *acdTile = theTouchable->GetVolume();
0099     auto acdTileNumber = acdTile->GetCopyNo();
0100     auto acdTileName = acdTile->GetName();
0101 
0102     // G4cout << acdTileName << " " << depositedEnergy / keV << G4endl;
0103 
0104     if (acdTileName == "ACT") { // The hit is on a top ACD tile (ACDType: 0)
0105         if (hitTopID[acdTileNumber] == -1) { // This is a new hit
0106             auto *anticoincidenceHit = new GammaRayTelAnticoincidenceHit;
0107             anticoincidenceHit->SetACDType(0);
0108             anticoincidenceHit->AddEnergy(depositedEnergy);
0109             anticoincidenceHit->SetPosition(step->GetPreStepPoint()->GetPosition());
0110             anticoincidenceHit->SetACDTileNumber(acdTileNumber);
0111             hitTopID[acdTileNumber] = anticoincidenceCollection->insert(anticoincidenceHit) - 1;
0112         } else { // This is not new
0113             (*anticoincidenceCollection)[hitTopID[acdTileNumber]]->AddEnergy(depositedEnergy);
0114         }
0115     }
0116 
0117     if (acdTileName == "ACL1") { // The hit is on a lateral (left-right) ACD tile (ACDType: 1)
0118         if (hitLateralID[acdTileNumber] == -1) { // This is a new hit
0119             auto *anticoincidenceHit = new GammaRayTelAnticoincidenceHit;
0120             anticoincidenceHit->SetACDType(1);
0121             anticoincidenceHit->AddEnergy(depositedEnergy);
0122             anticoincidenceHit->SetPosition(step->GetPreStepPoint()->GetPosition());
0123             anticoincidenceHit->SetACDTileNumber(acdTileNumber);
0124             hitLateralID[acdTileNumber] = anticoincidenceCollection->insert(anticoincidenceHit) - 1;
0125         } else { // This is not new
0126             (*anticoincidenceCollection)[hitLateralID[acdTileNumber]]->AddEnergy(depositedEnergy);
0127         }
0128     }
0129 
0130     if (acdTileName == "ACL2") { // The hit is on a lateral (rear-front) ACD tile (ACDType: 2)
0131         if (hitLateralID[acdTileNumber] == -1) { // This is a new hit
0132             auto *anticoincidenceHit = new GammaRayTelAnticoincidenceHit;
0133             anticoincidenceHit->SetACDType(2);
0134             anticoincidenceHit->AddEnergy(depositedEnergy);
0135             anticoincidenceHit->SetPosition(step->GetPreStepPoint()->GetPosition());
0136             anticoincidenceHit->SetACDTileNumber(acdTileNumber);
0137             hitLateralID[acdTileNumber] = anticoincidenceCollection->insert(anticoincidenceHit) - 1;
0138         } else { // This is not new
0139             (*anticoincidenceCollection)[hitLateralID[acdTileNumber]]->AddEnergy(depositedEnergy);
0140         }
0141     }
0142 
0143     return true;
0144 }
0145 
0146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0147 
0148 void GammaRayTelAnticoincidenceSD::EndOfEvent(G4HCofThisEvent *collection) {
0149     static G4int collectionIdentifier = -1;
0150     if (collectionIdentifier < 0) {
0151         collectionIdentifier = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
0152     }
0153     collection->AddHitsCollection(collectionIdentifier, anticoincidenceCollection);
0154 
0155     for (auto i = 0; i < numberOfACDLateralTiles; i++) {
0156         hitLateralID[i] = -1;
0157     }
0158 
0159     for (auto j = 0; j < numberOfACDTopTiles; j++) {
0160         hitTopID[j] = -1;
0161     }
0162 }
0163 
0164 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0165 
0166 void GammaRayTelAnticoincidenceSD::clear() {
0167 }
0168 
0169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0170 
0171 void GammaRayTelAnticoincidenceSD::DrawAll() {
0172 }
0173 
0174 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0175 
0176 void GammaRayTelAnticoincidenceSD::PrintAll() {
0177 }