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4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/gammaray_telescope/src/GammaRayTelCalorimeterSD.cc (Version 11.3.0) and /examples/advanced/gammaray_telescope/src/GammaRayTelCalorimeterSD.cc (Version 10.7.p1)


  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 // -------------------------------------------     27 // ------------------------------------------------------------
 28 //      GEANT 4 class implementation file          28 //      GEANT 4 class implementation file
 29 //      CERN Geneva Switzerland                    29 //      CERN Geneva Switzerland
 30 //                                                 30 //
 31 //                                                 31 //
 32 //      ------------ GammaRayTelCalorimeterSD      32 //      ------------ GammaRayTelCalorimeterSD  ------
 33 //           by  R.Giannitrapani, F.Longo & G.     33 //           by  R.Giannitrapani, F.Longo & G.Santin (13 nov 2000)
 34 //                                                 34 //
 35 // *******************************************     35 // ************************************************************
 36                                                << 
 37 #include "G4RunManager.hh"                         36 #include "G4RunManager.hh"
 38 #include "GammaRayTelCalorimeterSD.hh"             37 #include "GammaRayTelCalorimeterSD.hh"
 39 #include "GammaRayTelCalorimeterHit.hh"            38 #include "GammaRayTelCalorimeterHit.hh"
 40 #include "GammaRayTelDetectorConstruction.hh"      39 #include "GammaRayTelDetectorConstruction.hh"
 41                                                    40 
 42 #include "G4SystemOfUnits.hh"                      41 #include "G4SystemOfUnits.hh"
 43 #include "G4VPhysicalVolume.hh"                    42 #include "G4VPhysicalVolume.hh"
 44 #include "G4Step.hh"                               43 #include "G4Step.hh"
 45 #include "G4VTouchable.hh"                         44 #include "G4VTouchable.hh"
 46 #include "G4TouchableHistory.hh"                   45 #include "G4TouchableHistory.hh"
 47 #include "G4SDManager.hh"                          46 #include "G4SDManager.hh"
 48 #include "G4ios.hh"                                47 #include "G4ios.hh"
 49                                                    48 
 50 //....oooOO0OOooo........oooOO0OOooo........oo     49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 51                                                    50 
 52 GammaRayTelCalorimeterSD::GammaRayTelCalorimet <<  51 GammaRayTelCalorimeterSD::GammaRayTelCalorimeterSD(G4String name):G4VSensitiveDetector(name)
 53   auto *runManager = G4RunManager::GetRunManag <<  52 {
 54   detector = (GammaRayTelDetectorConstruction* <<  53  G4RunManager* runManager = G4RunManager::GetRunManager();
 55                                                <<  54   Detector =
 56   numberOfCALBars = detector->GetNbOfCALBars() <<  55     (GammaRayTelDetectorConstruction*)(runManager->GetUserDetectorConstruction());
 57   numberOfCALLayers = detector->GetNbOfCALLaye <<  56   
                                                   >>  57   NbOfCALBars  = Detector->GetNbOfCALBars();
                                                   >>  58   NbOfCALLayers  = Detector->GetNbOfCALLayers();
                                                   >>  59 
                                                   >>  60   //G4cout <<  NbOfCALBars << " bars " << G4endl;
                                                   >>  61   //G4cout <<  NbOfCALLayers << " layers " << G4endl;
                                                   >>  62   
                                                   >>  63   NbOfCALChannels = NbOfCALBars*NbOfCALLayers;
                                                   >>  64   
                                                   >>  65   ChitXID = new G4int[NbOfCALChannels];
                                                   >>  66   ChitYID = new G4int[NbOfCALChannels];
                                                   >>  67   collectionName.insert("CalorimeterCollection");
                                                   >>  68 }
                                                   >>  69 
                                                   >>  70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >>  71 
                                                   >>  72 GammaRayTelCalorimeterSD::~GammaRayTelCalorimeterSD()
                                                   >>  73 {
                                                   >>  74   delete [] ChitXID;
                                                   >>  75   delete [] ChitYID;
                                                   >>  76 }
                                                   >>  77 
                                                   >>  78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >>  79 
                                                   >>  80 void GammaRayTelCalorimeterSD::Initialize(G4HCofThisEvent*)
                                                   >>  81 {
                                                   >>  82   CalorimeterCollection = new GammaRayTelCalorimeterHitsCollection
                                                   >>  83     (SensitiveDetectorName,collectionName[0]);
                                                   >>  84   for (G4int i=0;i<NbOfCALChannels;i++)
                                                   >>  85       {
                                                   >>  86   ChitXID[i] = -1;
                                                   >>  87   ChitYID[i] = -1;
                                                   >>  88       };
                                                   >>  89 }
                                                   >>  90 
                                                   >>  91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >>  92 
                                                   >>  93 G4bool GammaRayTelCalorimeterSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
                                                   >>  94 { 
                                                   >>  95   
                                                   >>  96   G4double edep = 0.;
                                                   >>  97   edep = aStep->GetTotalEnergyDeposit();
                                                   >>  98   if (edep == 0.) return false;      
                                                   >>  99   
                                                   >> 100   // This TouchableHistory is used to obtain the physical volume
                                                   >> 101   // of the hit
                                                   >> 102   G4TouchableHistory* theTouchable
                                                   >> 103     = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
                                                   >> 104   
                                                   >> 105   G4VPhysicalVolume* cal_bar = theTouchable->GetVolume();  
                                                   >> 106   G4VPhysicalVolume* cal_plane = theTouchable->GetVolume(1);
                                                   >> 107 
                                                   >> 108   G4int CALBarNumber=cal_bar->GetCopyNo();
                                                   >> 109   G4String CALBarName = cal_bar->GetName();
                                                   >> 110   
                                                   >> 111   G4int PlaneNumber = 0;
                                                   >> 112   PlaneNumber=cal_plane->GetCopyNo();
                                                   >> 113   G4String PlaneName = cal_plane->GetName();
                                                   >> 114 
                                                   >> 115 
                                                   >> 116   G4int NChannel = 0;
                                                   >> 117   
                                                   >> 118   NChannel = PlaneNumber * NbOfCALBars + CALBarNumber; 
                                                   >> 119   
                                                   >> 120   if (PlaneName == "CALLayerX" )
                                                   >> 121     
                                                   >> 122     // The hit is on an X CsI plane
                                                   >> 123     
                                                   >> 124     {
                                                   >> 125       // This is a new hit
                                                   >> 126       if (ChitXID[NChannel]==-1)
                                                   >> 127   {       
                                                   >> 128     GammaRayTelCalorimeterHit* CalorimeterHit = new GammaRayTelCalorimeterHit;
                                                   >> 129     CalorimeterHit->SetCALType(1);
                                                   >> 130     CalorimeterHit->AddEnergy(edep);
                                                   >> 131     CalorimeterHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
                                                   >> 132     CalorimeterHit->SetCALPlaneNumber(PlaneNumber);
                                                   >> 133     CalorimeterHit->SetCALBarNumber(CALBarNumber);
                                                   >> 134     ChitXID[NChannel] = 
                                                   >> 135       CalorimeterCollection->insert(CalorimeterHit) -1;
                                                   >> 136   }
                                                   >> 137       else // This is not new
                                                   >> 138   {
                                                   >> 139     (*CalorimeterCollection)
                                                   >> 140       [ChitXID[NChannel]]->AddEnergy(edep);
                                                   >> 141   }
                                                   >> 142     }
                                                   >> 143  
                                                   >> 144   if (PlaneName == "CALLayerY")
                                                   >> 145     // The hit is on an Y CsI plane    
                                                   >> 146     {   
                                                   >> 147       // This is a new hit
                                                   >> 148       if (ChitYID[NChannel]==-1)
                                                   >> 149   {       
                                                   >> 150     GammaRayTelCalorimeterHit* CalorimeterHit 
                                                   >> 151       = new GammaRayTelCalorimeterHit;
                                                   >> 152     CalorimeterHit->SetCALType(0);
                                                   >> 153     CalorimeterHit->AddEnergy(edep);
                                                   >> 154     CalorimeterHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
                                                   >> 155     CalorimeterHit->SetCALPlaneNumber(PlaneNumber);
                                                   >> 156     CalorimeterHit->SetCALBarNumber(CALBarNumber);
                                                   >> 157     ChitYID[NChannel] = 
                                                   >> 158       CalorimeterCollection->insert(CalorimeterHit)-1;
                                                   >> 159   }
                                                   >> 160       else // This is not new
                                                   >> 161   {
                                                   >> 162     (*CalorimeterCollection)
                                                   >> 163       [ChitYID[NChannel]]->AddEnergy(edep);
                                                   >> 164   }
                                                   >> 165     }
                                                   >> 166   
                                                   >> 167   return true;
                                                   >> 168 }
                                                   >> 169 
                                                   >> 170 
                                                   >> 171 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 172 void GammaRayTelCalorimeterSD::EndOfEvent(G4HCofThisEvent* HCE)
                                                   >> 173 {
                                                   >> 174   static G4int HCID = -1;
                                                   >> 175   if(HCID<0)
                                                   >> 176     { 
                                                   >> 177       HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
                                                   >> 178     }
                                                   >> 179   HCE->AddHitsCollection(HCID,CalorimeterCollection);
                                                   >> 180 
                                                   >> 181 
                                                   >> 182   for (G4int i=0;i<NbOfCALChannels;i++) 
                                                   >> 183     {
                                                   >> 184       ChitXID[i] = -1;
                                                   >> 185       ChitYID[i] = -1;
                                                   >> 186     };
                                                   >> 187 }
 58                                                   188 
 59   // G4cout << NbOfCALBars << " bars " << G4en << 
 60   // G4cout << NbOfCALLayers << " layers " <<  << 
 61                                                   189 
 62   numberOfCALChannels = numberOfCALBars * numb << 190 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 63                                                   191 
 64   calHitXID = new G4int[numberOfCALChannels];  << 192 void GammaRayTelCalorimeterSD::clear()
 65   calHitYID = new G4int[numberOfCALChannels];  << 193 {} 
 66   collectionName.insert("CalorimeterCollection << 
 67 }                                              << 
 68                                                   194 
 69 //....oooOO0OOooo........oooOO0OOooo........oo    195 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 70                                                   196 
 71 GammaRayTelCalorimeterSD::~GammaRayTelCalorime << 197 void GammaRayTelCalorimeterSD::DrawAll()
 72   delete[] calHitXID;                          << 198 {} 
 73   delete[] calHitYID;                          << 
 74 }                                              << 
 75                                                   199 
 76 //....oooOO0OOooo........oooOO0OOooo........oo    200 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 77                                                   201 
 78 void GammaRayTelCalorimeterSD::Initialize(G4HC << 202 void GammaRayTelCalorimeterSD::PrintAll()
 79     calorimeterCollection = new GammaRayTelCal << 203 {} 
 80   for (auto i = 0; i < numberOfCALChannels; i+ << 
 81     calHitXID[i] = -1;                         << 
 82     calHitYID[i] = -1;                         << 
 83   }                                            << 
 84 }                                              << 
 85                                                   204 
 86 //....oooOO0OOooo........oooOO0OOooo........oo    205 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 87                                                   206 
 88 auto GammaRayTelCalorimeterSD::ProcessHits(G4S << 
 89   G4double depositedEnergy = 0.;               << 
 90   depositedEnergy = step->GetTotalEnergyDeposi << 
 91   if (depositedEnergy == 0.) {                 << 
 92     return false;                              << 
 93   }                                            << 
 94                                                   207 
 95   // This TouchableHistory is used to obtain t << 
 96   auto *theTouchable = (G4TouchableHistory*) ( << 
 97   auto *calorimeterBar = theTouchable->GetVolu << 
 98   auto *calorimeterPlane = theTouchable->GetVo << 
 99   auto calorimeterBarNumber = calorimeterBar-> << 
100   auto calorimeterBarName = calorimeterBar->Ge << 
101                                                << 
102   G4int planeNumber{0};                        << 
103   planeNumber = calorimeterPlane->GetCopyNo(); << 
104                                                << 
105   auto planeName = calorimeterPlane->GetName() << 
106                                                << 
107   G4int NChannel = 0;                          << 
108   NChannel = planeNumber * numberOfCALBars + c << 
109                                                << 
110   if (planeName == "CALLayerX") { // The hit i << 
111     if (calHitXID[NChannel] == -1) { // This i << 
112       auto *calorimeterHit = new GammaRayTelCa << 
113       calorimeterHit->SetCALType(1);           << 
114       calorimeterHit->AddEnergy(depositedEnerg << 
115       calorimeterHit->SetPosition(step->GetPre << 
116       calorimeterHit->SetCALPlaneNumber(planeN << 
117       calorimeterHit->SetCALBarNumber(calorime << 
118       calHitXID[NChannel] = calorimeterCollect << 
119     } else { // This is not new                << 
120       (*calorimeterCollection)[calHitXID[NChan << 
121     }                                          << 
122   }                                            << 
123                                                   208 
124   if (planeName == "CALLayerY") { // The hit i << 
125     if (calHitYID[NChannel] == -1) { // This i << 
126       auto *calorimeterHit = new GammaRayTelCa << 
127       calorimeterHit->SetCALType(0);           << 
128       calorimeterHit->AddEnergy(depositedEnerg << 
129       calorimeterHit->SetPosition(step->GetPre << 
130       calorimeterHit->SetCALPlaneNumber(planeN << 
131       calorimeterHit->SetCALBarNumber(calorime << 
132       calHitYID[NChannel] = calorimeterCollect << 
133     } else { // This is not new                << 
134       (*calorimeterCollection)[calHitYID[NChan << 
135     }                                          << 
136   }                                            << 
137                                                   209 
138   return true;                                 << 
139 }                                              << 
140                                                   210 
141 //....oooOO0OOooo........oooOO0OOooo........oo << 
142                                                   211 
143 void GammaRayTelCalorimeterSD::EndOfEvent(G4HC << 
144   static G4int collectionIdentifier = -1;      << 
145   if (collectionIdentifier < 0) {              << 
146     collectionIdentifier = G4SDManager::GetSDM << 
147   }                                            << 
148   HCE->AddHitsCollection(collectionIdentifier, << 
149                                                   212 
150   for (auto i = 0; i < numberOfCALChannels; i+ << 
151     calHitXID[i] = -1;                         << 
152     calHitYID[i] = -1;                         << 
153   }                                            << 
154 }                                              << 
155                                                   213 
156 //....oooOO0OOooo........oooOO0OOooo........oo << 
157                                                   214 
158 void GammaRayTelCalorimeterSD::clear() {       << 
159 }                                              << 
160                                                   215 
161 //....oooOO0OOooo........oooOO0OOooo........oo << 
162                                                   216 
163 void GammaRayTelCalorimeterSD::DrawAll() {     << 
164 }                                              << 
165                                                   217 
166 //....oooOO0OOooo........oooOO0OOooo........oo << 
167                                                   218 
168 void GammaRayTelCalorimeterSD::PrintAll() {    << 219 
169 }                                              << 
170                                                   220