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10.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/GammaRayTelAnticoincidenceSD.cc (Version 11.3.0) and /examples/advanced/gammaray_telescope/src/GammaRayTelAnticoincidenceSD.cc (Version 7.1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                    <<   3 // * DISCLAIMER                                                       *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th <<   5 // * The following disclaimer summarizes all the specific disclaimers *
  6 // * the Geant4 Collaboration.  It is provided <<   6 // * of contributors to this software. The specific disclaimers,which *
  7 // * conditions of the Geant4 Software License <<   7 // * govern, are listed with their locations in:                      *
  8 // * LICENSE and available at  http://cern.ch/ <<   8 // *   http://cern.ch/geant4/license                                  *
  9 // * include a list of copyright holders.      << 
 10 // *                                                9 // *                                                                  *
 11 // * Neither the authors of this software syst     10 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     11 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     12 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     13 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  <<  14 // * use.                                                             *
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                               15 // *                                                                  *
 18 // * This  code  implementation is the result  <<  16 // * This  code  implementation is the  intellectual property  of the *
 19 // * technical work of the GEANT4 collaboratio <<  17 // * GEANT4 collaboration.                                            *
 20 // * By using,  copying,  modifying or  distri <<  18 // * By copying,  distributing  or modifying the Program (or any work *
 21 // * any work based  on the software)  you  ag <<  19 // * based  on  the Program)  you indicate  your  acceptance of  this *
 22 // * use  in  resulting  scientific  publicati <<  20 // * statement, and all its terms.                                    *
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // *******************************************     21 // ********************************************************************
 25 //                                                 22 //
 26 //                                                 23 //
                                                   >>  24 // $Id: GammaRayTelAnticoincidenceSD.cc,v 1.5 2003/05/30 15:09:00 flongo Exp $
                                                   >>  25 // GEANT4 tag $Name: geant4-07-01 $
 27 // -------------------------------------------     26 // ------------------------------------------------------------
 28 //      GEANT 4 class implementation file          27 //      GEANT 4 class implementation file
 29 //      CERN Geneva Switzerland                    28 //      CERN Geneva Switzerland
 30 //                                                 29 //
 31 //                                                 30 //
 32 //      ------------ GammaRayTelAnticoincidenc     31 //      ------------ GammaRayTelAnticoincidenceSD  ------
 33 //           by  R.Giannitrapani, F.Longo & G.     32 //           by  R.Giannitrapani, F.Longo & G.Santin (13 nov 2000)
 34 //                                                 33 //
 35 // *******************************************     34 // ************************************************************
 36                                                <<  35 #include "G4RunManager.hh"
 37 #include "GammaRayTelAnticoincidenceSD.hh"         36 #include "GammaRayTelAnticoincidenceSD.hh"
 38 #include "GammaRayTelAnticoincidenceHit.hh"        37 #include "GammaRayTelAnticoincidenceHit.hh"
 39 #include "GammaRayTelDetectorConstruction.hh"      38 #include "GammaRayTelDetectorConstruction.hh"
 40                                                    39 
 41 #include "G4ios.hh"                            << 
 42 #include "G4RunManager.hh"                     << 
 43 #include "G4SDManager.hh"                      << 
 44 #include "G4Step.hh"                           << 
 45 #include "G4SystemOfUnits.hh"                  << 
 46 #include "G4TouchableHistory.hh"               << 
 47 #include "G4VPhysicalVolume.hh"                    40 #include "G4VPhysicalVolume.hh"
                                                   >>  41 #include "G4Step.hh"
 48 #include "G4VTouchable.hh"                         42 #include "G4VTouchable.hh"
                                                   >>  43 #include "G4TouchableHistory.hh"
                                                   >>  44 #include "G4SDManager.hh"
                                                   >>  45 #include "G4ios.hh"
 49                                                    46 
 50 //....oooOO0OOooo........oooOO0OOooo........oo     47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 51                                                    48 
 52 GammaRayTelAnticoincidenceSD::GammaRayTelAntic <<  49 GammaRayTelAnticoincidenceSD::GammaRayTelAnticoincidenceSD(G4String name)
 53     auto *runManager = G4RunManager::GetRunMan <<  50 :G4VSensitiveDetector(name)
 54     detector = (GammaRayTelDetectorConstructio <<  51 {
 55                                                <<  52   G4RunManager* runManager = G4RunManager::GetRunManager();
 56     numberOfACDLateralTiles = detector->GetNbO <<  53   Detector =
 57     numberOfACDTopTiles = detector->GetNbOfACD <<  54     (GammaRayTelDetectorConstruction*)(runManager->GetUserDetectorConstruction());
 58                                                <<  55   
 59     G4cout << numberOfACDLateralTiles << " LAT <<  56   NbOfACDLateralTiles  =  Detector->GetNbOfACDLateralTiles();
 60     G4cout << numberOfACDTopTiles << " TOP " < <<  57   NbOfACDTopTiles  =  Detector->GetNbOfACDTopTiles(); 
 61                                                <<  58 
 62     hitLateralID = new G4int[numberOfACDLatera <<  59   G4cout <<  NbOfACDLateralTiles << " LAT " << G4endl;
 63     hitTopID = new G4int[numberOfACDTopTiles]; <<  60   G4cout <<  NbOfACDTopTiles << " TOP " << G4endl;
 64     collectionName.insert("AnticoincidenceColl <<  61   
                                                   >>  62   HitLateralID = new G4int[NbOfACDLateralTiles];
                                                   >>  63   HitTopID = new G4int[NbOfACDTopTiles];
                                                   >>  64   collectionName.insert("AnticoincidenceCollection");
                                                   >>  65 }
                                                   >>  66 
                                                   >>  67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >>  68 
                                                   >>  69 GammaRayTelAnticoincidenceSD::~GammaRayTelAnticoincidenceSD()
                                                   >>  70 {
                                                   >>  71   delete [] HitLateralID;
                                                   >>  72   delete [] HitTopID;
                                                   >>  73 }
                                                   >>  74 
                                                   >>  75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >>  76 
                                                   >>  77 void GammaRayTelAnticoincidenceSD::Initialize(G4HCofThisEvent*)
                                                   >>  78 {
                                                   >>  79   AnticoincidenceCollection = new GammaRayTelAnticoincidenceHitsCollection
                                                   >>  80     (SensitiveDetectorName,collectionName[0]);
                                                   >>  81   for (G4int i=0;i<NbOfACDLateralTiles;i++)
                                                   >>  82     {
                                                   >>  83       HitLateralID[i] = -1;
                                                   >>  84     };
                                                   >>  85   
                                                   >>  86   for (G4int j=0;j<NbOfACDTopTiles;j++) 
                                                   >>  87     {
                                                   >>  88       
                                                   >>  89       HitTopID[j] = -1;
                                                   >>  90     };
                                                   >>  91 }
                                                   >>  92 
                                                   >>  93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >>  94 
                                                   >>  95 G4bool GammaRayTelAnticoincidenceSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
                                                   >>  96 { 
                                                   >>  97   
                                                   >>  98   G4double edep = aStep->GetTotalEnergyDeposit();
                                                   >>  99   if ((edep/keV == 0.)) return false;      
                                                   >> 100   
                                                   >> 101   // This TouchableHistory is used to obtain the physical volume
                                                   >> 102   // of the hit
                                                   >> 103   G4TouchableHistory* theTouchable
                                                   >> 104     = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
                                                   >> 105   
                                                   >> 106   G4VPhysicalVolume* acd_tile = theTouchable->GetVolume();  
                                                   >> 107 
                                                   >> 108   G4int ACDTileNumber=acd_tile->GetCopyNo();
                                                   >> 109   G4String ACDTileName = acd_tile->GetName();
                                                   >> 110   
                                                   >> 111   //  G4cout << ACDTileName << " " << edep/keV << G4endl;
                                                   >> 112 
                                                   >> 113   if (ACDTileName == "ACT" )
                                                   >> 114     // The hit is on an top ACD tile (ACDType 0)
                                                   >> 115     {
                                                   >> 116       // This is a new hit
                                                   >> 117       if (HitTopID[ACDTileNumber]==-1)
                                                   >> 118   {       
                                                   >> 119     GammaRayTelAnticoincidenceHit* 
                                                   >> 120       AnticoincidenceHit = new GammaRayTelAnticoincidenceHit;
                                                   >> 121     AnticoincidenceHit->SetACDType(0);
                                                   >> 122     AnticoincidenceHit->AddEnergy(edep);
                                                   >> 123     AnticoincidenceHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
                                                   >> 124     AnticoincidenceHit->SetACDTileNumber(ACDTileNumber);
                                                   >> 125     HitTopID[ACDTileNumber] = 
                                                   >> 126       AnticoincidenceCollection->insert(AnticoincidenceHit) -1;
                                                   >> 127   }
                                                   >> 128       else // This is not new
                                                   >> 129   {
                                                   >> 130     (*AnticoincidenceCollection)
                                                   >> 131       [HitTopID[ACDTileNumber]]->AddEnergy(edep);
                                                   >> 132   }
                                                   >> 133     }
                                                   >> 134  
                                                   >> 135   if (ACDTileName == "ACL1")
                                                   >> 136     // The hit is on an lateral (left-right) ACD tile (ACDType 1)
                                                   >> 137     {   
                                                   >> 138       // This is a new hit
                                                   >> 139       if (HitLateralID[ACDTileNumber]==-1)
                                                   >> 140   {       
                                                   >> 141     GammaRayTelAnticoincidenceHit* 
                                                   >> 142       AnticoincidenceHit = new GammaRayTelAnticoincidenceHit;
                                                   >> 143     AnticoincidenceHit->SetACDType(1);
                                                   >> 144     AnticoincidenceHit->AddEnergy(edep);
                                                   >> 145     AnticoincidenceHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
                                                   >> 146     AnticoincidenceHit->SetACDTileNumber(ACDTileNumber);
                                                   >> 147     HitLateralID[ACDTileNumber] = 
                                                   >> 148       AnticoincidenceCollection->insert(AnticoincidenceHit) -1;
                                                   >> 149   }
                                                   >> 150       else // This is not new
                                                   >> 151   {
                                                   >> 152     (*AnticoincidenceCollection)
                                                   >> 153       [HitLateralID[ACDTileNumber]]->AddEnergy(edep);
                                                   >> 154   }
                                                   >> 155     }
                                                   >> 156 
                                                   >> 157    if (ACDTileName == "ACL2")
                                                   >> 158     // The hit is on an lateral (rear - front) ACD tile (ACDType 2)
                                                   >> 159     {   
                                                   >> 160       // This is a new hit
                                                   >> 161       if (HitLateralID[ACDTileNumber]==-1)
                                                   >> 162   {       
                                                   >> 163     GammaRayTelAnticoincidenceHit* 
                                                   >> 164       AnticoincidenceHit = new GammaRayTelAnticoincidenceHit;
                                                   >> 165     AnticoincidenceHit->SetACDType(2);
                                                   >> 166     AnticoincidenceHit->AddEnergy(edep);
                                                   >> 167     AnticoincidenceHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
                                                   >> 168     AnticoincidenceHit->SetACDTileNumber(ACDTileNumber);
                                                   >> 169     HitLateralID[ACDTileNumber] = 
                                                   >> 170       AnticoincidenceCollection->insert(AnticoincidenceHit) -1;
                                                   >> 171   }
                                                   >> 172       else // This is not new
                                                   >> 173   {
                                                   >> 174     (*AnticoincidenceCollection)
                                                   >> 175       [HitLateralID[ACDTileNumber]]->AddEnergy(edep);
                                                   >> 176   }
                                                   >> 177     }
                                                   >> 178   return true;
                                                   >> 179 }
                                                   >> 180 
                                                   >> 181 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 182 
                                                   >> 183 void GammaRayTelAnticoincidenceSD::EndOfEvent(G4HCofThisEvent* HCE)
                                                   >> 184 {
                                                   >> 185   static G4int HCID = -1;
                                                   >> 186   if(HCID<0)
                                                   >> 187     { 
                                                   >> 188       HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
                                                   >> 189     }
                                                   >> 190   HCE->AddHitsCollection(HCID,AnticoincidenceCollection);
                                                   >> 191 
                                                   >> 192   for (G4int i=0;i<NbOfACDLateralTiles;i++)
                                                   >> 193     {
                                                   >> 194       HitLateralID[i] = -1;
                                                   >> 195     };
                                                   >> 196   
                                                   >> 197   for (G4int j=0;j<NbOfACDTopTiles;j++) 
                                                   >> 198     {
                                                   >> 199       
                                                   >> 200       HitTopID[j] = -1;
                                                   >> 201     };
                                                   >> 202 
 65 }                                                 203 }
 66                                                   204 
 67 //....oooOO0OOooo........oooOO0OOooo........oo    205 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 68                                                   206 
 69 GammaRayTelAnticoincidenceSD::~GammaRayTelAnti << 207 void GammaRayTelAnticoincidenceSD::clear()
 70     delete[] hitLateralID;                     << 208 {} 
 71     delete[] hitTopID;                         << 
 72 }                                              << 
 73                                                   209 
 74 //....oooOO0OOooo........oooOO0OOooo........oo    210 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 75                                                   211 
 76 void GammaRayTelAnticoincidenceSD::Initialize( << 212 void GammaRayTelAnticoincidenceSD::DrawAll()
 77     anticoincidenceCollection = new GammaRayTe << 213 {} 
 78     for (auto i = 0; i < numberOfACDLateralTil << 
 79         hitLateralID[i] = -1;                  << 
 80     }                                          << 
 81                                                << 
 82     for (auto j = 0; j < numberOfACDTopTiles;  << 
 83         hitTopID[j] = -1;                      << 
 84     }                                          << 
 85 }                                              << 
 86                                                   214 
 87 //....oooOO0OOooo........oooOO0OOooo........oo    215 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 88                                                   216 
 89 auto GammaRayTelAnticoincidenceSD::ProcessHits << 217 void GammaRayTelAnticoincidenceSD::PrintAll()
 90     auto depositedEnergy = step->GetTotalEnerg << 218 {} 
 91     if (depositedEnergy / keV == 0.) {         << 
 92         return false;                          << 
 93     }                                          << 
 94                                                   219 
 95     // This TouchableHistory is used to obtain << 220 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 96     auto *theTouchable = (G4TouchableHistory*) << 
 97                                                   221 
 98     auto *acdTile = theTouchable->GetVolume(); << 
 99     auto acdTileNumber = acdTile->GetCopyNo(); << 
100     auto acdTileName = acdTile->GetName();     << 
101                                                << 
102     // G4cout << acdTileName << " " << deposit << 
103                                                << 
104     if (acdTileName == "ACT") { // The hit is  << 
105         if (hitTopID[acdTileNumber] == -1) { / << 
106             auto *anticoincidenceHit = new Gam << 
107             anticoincidenceHit->SetACDType(0); << 
108             anticoincidenceHit->AddEnergy(depo << 
109             anticoincidenceHit->SetPosition(st << 
110             anticoincidenceHit->SetACDTileNumb << 
111             hitTopID[acdTileNumber] = anticoin << 
112         } else { // This is not new            << 
113             (*anticoincidenceCollection)[hitTo << 
114         }                                      << 
115     }                                          << 
116                                                   222 
117     if (acdTileName == "ACL1") { // The hit is << 
118         if (hitLateralID[acdTileNumber] == -1) << 
119             auto *anticoincidenceHit = new Gam << 
120             anticoincidenceHit->SetACDType(1); << 
121             anticoincidenceHit->AddEnergy(depo << 
122             anticoincidenceHit->SetPosition(st << 
123             anticoincidenceHit->SetACDTileNumb << 
124             hitLateralID[acdTileNumber] = anti << 
125         } else { // This is not new            << 
126             (*anticoincidenceCollection)[hitLa << 
127         }                                      << 
128     }                                          << 
129                                                   223 
130     if (acdTileName == "ACL2") { // The hit is << 
131         if (hitLateralID[acdTileNumber] == -1) << 
132             auto *anticoincidenceHit = new Gam << 
133             anticoincidenceHit->SetACDType(2); << 
134             anticoincidenceHit->AddEnergy(depo << 
135             anticoincidenceHit->SetPosition(st << 
136             anticoincidenceHit->SetACDTileNumb << 
137             hitLateralID[acdTileNumber] = anti << 
138         } else { // This is not new            << 
139             (*anticoincidenceCollection)[hitLa << 
140         }                                      << 
141     }                                          << 
142                                                   224 
143     return true;                               << 
144 }                                              << 
145                                                   225 
146 //....oooOO0OOooo........oooOO0OOooo........oo << 
147                                                   226 
148 void GammaRayTelAnticoincidenceSD::EndOfEvent( << 
149     static G4int collectionIdentifier = -1;    << 
150     if (collectionIdentifier < 0) {            << 
151         collectionIdentifier = G4SDManager::Ge << 
152     }                                          << 
153     collection->AddHitsCollection(collectionId << 
154                                                   227 
155     for (auto i = 0; i < numberOfACDLateralTil << 
156         hitLateralID[i] = -1;                  << 
157     }                                          << 
158                                                   228 
159     for (auto j = 0; j < numberOfACDTopTiles;  << 
160         hitTopID[j] = -1;                      << 
161     }                                          << 
162 }                                              << 
163                                                   229 
164 //....oooOO0OOooo........oooOO0OOooo........oo << 
165                                                   230 
166 void GammaRayTelAnticoincidenceSD::clear() {   << 
167 }                                              << 
168                                                   231 
169 //....oooOO0OOooo........oooOO0OOooo........oo << 
170                                                   232 
171 void GammaRayTelAnticoincidenceSD::DrawAll() { << 
172 }                                              << 
173                                                   233 
174 //....oooOO0OOooo........oooOO0OOooo........oo << 
175                                                   234 
176 void GammaRayTelAnticoincidenceSD::PrintAll()  << 
177 }                                              << 
178                                                   235