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 //      ------------ GammaRayTelDigitizer  ------
0033 //           by   F.Longo, R.Giannitrapani & G.Santin (13 nov 2000)
0034 //
0035 // ************************************************************
0036 
0037 #include <vector>
0038 
0039 #include "GammaRayTelAnticoincidenceHit.hh"
0040 #include "GammaRayTelCalorimeterHit.hh"
0041 #include "GammaRayTelDigi.hh"
0042 #include "GammaRayTelDigitizer.hh"
0043 #include "GammaRayTelDigitizerMessenger.hh"
0044 #include "GammaRayTelTrackerHit.hh"
0045 
0046 #include "G4DigiManager.hh"
0047 #include "G4Event.hh"
0048 #include "G4EventManager.hh"
0049 #include "G4ios.hh"
0050 #include "G4SDManager.hh"
0051 #include "G4SystemOfUnits.hh"
0052 
0053 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0054 
0055 GammaRayTelDigitizer::GammaRayTelDigitizer(G4String name) : G4VDigitizerModule(name) {
0056     constexpr auto DIGIT_COLLECTION_NAME{"DigitsCollection"};
0057     collectionName.push_back(DIGIT_COLLECTION_NAME);
0058 
0059     // create a messenger for this class
0060     digitizerMessenger = new GammaRayTelDigitizerMessenger(this);
0061 }
0062 
0063 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0064 
0065 GammaRayTelDigitizer::~GammaRayTelDigitizer() {
0066     delete digitizerMessenger;
0067 }
0068 
0069 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0070 
0071 void GammaRayTelDigitizer::Digitize() {
0072     digitsCollection = new GammaRayTelDigitsCollection("GammaRayTelDigitizer", "DigitsCollection"); // to create the Digi Collection
0073 
0074     auto *digitManager = G4DigiManager::GetDMpointer();
0075 
0076     G4int trackerCollectionIdentifier{0}; // TrackerCollection
0077     G4int calorimeterCollectionIdentifier{0}; // CalorimeterCollection
0078     G4int anticoincidenceCollectionIdentifier{0}; // AnticoincidenceCollection
0079 
0080     totalEnergy = 0.; // at each event
0081 
0082     // TKR hits collection
0083 
0084     trackerCollectionIdentifier = digitManager->GetHitsCollectionID("TrackerCollection");
0085     GammaRayTelTrackerHitsCollection *trackerCollection{nullptr};
0086     trackerCollection = (GammaRayTelTrackerHitsCollection*) (digitManager->GetHitsCollection(trackerCollectionIdentifier));
0087 
0088     // CAL hits collection
0089 
0090     calorimeterCollectionIdentifier = digitManager->GetHitsCollectionID("CalorimeterCollection");
0091     GammaRayTelCalorimeterHitsCollection *calorimeterCollection{nullptr};
0092     calorimeterCollection = (GammaRayTelCalorimeterHitsCollection*) (digitManager->GetHitsCollection(calorimeterCollectionIdentifier));
0093 
0094     // ACD hits collection
0095 
0096     anticoincidenceCollectionIdentifier = digitManager->GetHitsCollectionID("AnticoincidenceCollection");
0097     GammaRayTelAnticoincidenceHitsCollection *anticoincidenceCollection{nullptr};
0098     anticoincidenceCollection = (GammaRayTelAnticoincidenceHitsCollection*) (digitManager->GetHitsCollection(anticoincidenceCollectionIdentifier));
0099 
0100     if (trackerCollection != nullptr) {
0101         G4int numberOfHits = trackerCollection->entries();
0102 
0103         for (auto i = 0; i < numberOfHits; i++) {
0104             G4double depositedEnergy = (*trackerCollection)[i]->GetDepositedEnergy();
0105             G4int stripNumber = (*trackerCollection)[i]->GetStripNumber();
0106             G4int planeNumber = (*trackerCollection)[i]->GetSiliconPlaneNumber();
0107             G4int IsX = (*trackerCollection)[i]->GetPlaneType();
0108 
0109             // digi generation only if energy deposit is greater than threshold
0110 
0111             if (depositedEnergy > energyThreshold) {
0112                 auto *digit = new GammaRayTelDigi();
0113                 digit->SetPlaneNumber(planeNumber);
0114                 digit->SetPlaneType(IsX);
0115                 digit->SetStripNumber(stripNumber);
0116                 digit->SetDigitType(0);
0117                 digit->SetEnergy(0.);
0118                 digitsCollection->insert(digit);
0119             }
0120         }
0121     }
0122 
0123     if (calorimeterCollection != nullptr) {
0124         G4int numberOfHits = calorimeterCollection->entries();
0125 
0126         for (auto i = 0; i < numberOfHits; i++) {
0127             totalEnergy += (*calorimeterCollection)[i]->GetCALDepositedEnergy();
0128         }
0129 
0130         // digit generation only if energy deposit is greater than 0.
0131 
0132         if (totalEnergy > 0.) {
0133             auto *digit = new GammaRayTelDigi();
0134             digit->SetPlaneNumber(0);
0135             digit->SetPlaneType(0);
0136             digit->SetStripNumber(0);
0137             digit->SetDigitType(1);
0138             digit->SetEnergy(totalEnergy);
0139             digitsCollection->insert(digit);
0140         }
0141     }
0142 
0143     if (anticoincidenceCollection != nullptr) {
0144         G4int numberOfHits = anticoincidenceCollection->entries();
0145 
0146         for (G4int i = 0; i < numberOfHits; i++) {
0147             auto energy = (*anticoincidenceCollection)[i]->GetEdepACD();
0148             auto type = (*anticoincidenceCollection)[i]->GetACDTileNumber();
0149 
0150             // digit generation only if energy deposit is greater than 0.
0151 
0152             if (energy > acdThreshold) {
0153                 auto *digit = new GammaRayTelDigi();
0154                 digit->SetPlaneNumber(0);
0155                 digit->SetPlaneType(0);
0156                 digit->SetStripNumber(type);
0157                 digit->SetDigitType(2);
0158                 digit->SetEnergy(energy);
0159                 digitsCollection->insert(digit);
0160             }
0161         }
0162     }
0163 
0164     if (trackerCollection != nullptr || anticoincidenceCollection != nullptr || calorimeterCollection != nullptr) {
0165         G4cout << "Number of digits in this event: " << digitsCollection->entries()
0166         // << " " << digitsCollection->GetName()
0167         // << " " << digitsCollection->GetDMname()
0168             << G4endl;
0169     }
0170 
0171     StoreDigiCollection(digitsCollection);
0172 
0173     G4int digitsCollectionIdentifier{-1};
0174     if (digitsCollectionIdentifier < 0) {
0175         // digiManager->List();
0176         digitsCollectionIdentifier = digitManager->GetDigiCollectionID("GammaRayTelDigitizer/DigitsCollection");
0177     }
0178 }