source: trunk/examples/advanced/gammaray_telescope/src/GammaRayTelDigitizer.cc @ 1272

Last change on this file since 1272 was 1230, checked in by garnier, 14 years ago

update to geant4.9.3

File size: 6.4 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27// $Id: GammaRayTelDigitizer.cc,v 1.6 2006/06/29 15:56:31 gunter Exp $
28// GEANT4 tag $Name: geant4-09-03-cand-01 $
29// ------------------------------------------------------------
30//      GEANT 4 class implementation file
31//      CERN Geneva Switzerland
32//
33//
34//      ------------ GammaRayTelDigitizer  ------
35//           by   F.Longo, R.Giannitrapani & G.Santin (13 nov 2000)
36//
37// ************************************************************
38
39#include "GammaRayTelDigitizer.hh"
40#include "GammaRayTelDigi.hh"
41#include "GammaRayTelDigitizerMessenger.hh"
42
43#include "GammaRayTelTrackerHit.hh"
44#include "GammaRayTelCalorimeterHit.hh"
45#include "GammaRayTelAnticoincidenceHit.hh"
46
47#include "G4EventManager.hh"
48#include "G4Event.hh"
49#include "G4SDManager.hh"
50#include "G4DigiManager.hh"
51#include "G4ios.hh"
52
53//#include "G4CollectionNameVector.hh"
54#include <vector>
55
56//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
57
58GammaRayTelDigitizer::GammaRayTelDigitizer(G4String name)
59  :G4VDigitizerModule(name)
60{
61
62
63  G4String colName = "DigitsCollection";
64  collectionName.push_back(colName);
65  Energy_Threshold = 120.*keV;
66  TotalEnergy = 0.;
67  ACDThreshold = 15*keV;
68
69//create a messenger for this class
70  digiMessenger = new GammaRayTelDigitizerMessenger(this);
71
72}
73
74//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
75
76GammaRayTelDigitizer::~GammaRayTelDigitizer()
77{
78  delete digiMessenger;
79}
80
81//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
82
83void GammaRayTelDigitizer::Digitize()
84{
85  DigitsCollection = new GammaRayTelDigitsCollection
86        ("GammaRayTelDigitizer","DigitsCollection"); // to create the Digi Collection
87 
88  G4DigiManager* DigiMan = G4DigiManager::GetDMpointer();
89 
90  G4int THCID; // TrackerCollection
91  G4int CHCID; // CalorimeterCollection
92  G4int AHCID; // AnticoincidenceCollection
93
94  TotalEnergy = 0.; // at each event
95 
96  // TKR Hits collection
97 
98  THCID = DigiMan->GetHitsCollectionID("TrackerCollection"); 
99  GammaRayTelTrackerHitsCollection* THC = 0; 
100  THC = (GammaRayTelTrackerHitsCollection*)
101    (DigiMan->GetHitsCollection(THCID));
102
103
104  // CAL Hits collection
105
106  CHCID = DigiMan->GetHitsCollectionID("CalorimeterCollection");
107  GammaRayTelCalorimeterHitsCollection* CHC = 0;
108  CHC = (GammaRayTelCalorimeterHitsCollection*)
109                 (DigiMan->GetHitsCollection(CHCID));
110
111  // ACD Hits collection
112
113  AHCID = DigiMan->GetHitsCollectionID("AnticoincidenceCollection"); 
114  GammaRayTelAnticoincidenceHitsCollection* AHC = 0;
115  AHC = (GammaRayTelAnticoincidenceHitsCollection*)
116                 (DigiMan->GetHitsCollection(AHCID));
117
118 
119  if (THC)
120    {
121      G4int n_hit = THC->entries();
122
123      for (G4int i=0;i<n_hit;i++)
124        {
125          G4double ESil = (*THC)[i]->GetEdepSil();
126          G4int NStrip = (*THC)[i]->GetNStrip();
127          G4int NPlane = (*THC)[i]->GetNSilPlane();
128          G4int IsX = (*THC)[i]->GetPlaneType();
129         
130       // digi generation only if energy deposit greater than threshold
131
132          if (ESil>Energy_Threshold)
133            {
134              GammaRayTelDigi* Digi = new GammaRayTelDigi();
135              Digi->SetPlaneNumber(NPlane);
136              Digi->SetPlaneType(IsX);
137              Digi->SetStripNumber(NStrip);
138              Digi->SetDigiType(0);
139              Digi->SetEnergy(0.);
140              DigitsCollection->insert(Digi);   
141            } 
142        }
143    }
144  if (CHC)
145    {
146      G4int n_hit = CHC->entries();
147     
148      for (G4int i=0;i<n_hit;i++)
149        {
150          TotalEnergy +=(*CHC)[i]->GetEdepCAL();
151        }
152      // digi generation only if energy deposit greater than 0.
153     
154      if (TotalEnergy>0.)
155        {
156          GammaRayTelDigi* Digi = new GammaRayTelDigi();
157          Digi->SetPlaneNumber(0);
158          Digi->SetPlaneType(0);
159          Digi->SetStripNumber(0);
160          Digi->SetDigiType(1);
161          Digi->SetEnergy(TotalEnergy);
162          DigitsCollection->insert(Digi);       
163        } 
164
165    }
166
167  if (AHC)
168    {
169      G4int n_hit = AHC->entries();
170     
171      for (G4int i=0;i<n_hit;i++)
172        {
173          G4double energy = (*AHC)[i]->GetEdepACD();
174          G4int type = (*AHC)[i]->GetACDTileNumber();
175         
176          // digi generation only if energy deposit greater than 0.
177         
178          if (energy>ACDThreshold)
179            {
180              GammaRayTelDigi* Digi = new GammaRayTelDigi();
181              Digi->SetPlaneNumber(0);
182              Digi->SetPlaneType(0);
183              Digi->SetStripNumber(type);
184              Digi->SetDigiType(2);
185              Digi->SetEnergy(energy);
186              DigitsCollection->insert(Digi);   
187            } 
188         
189        }
190    }
191 
192  if (THC||AHC||CHC){
193    G4cout << "Number of digits in this event =  " 
194           << DigitsCollection->entries() 
195      // << " " << DigitsCollection->GetName() 
196      // << " " << DigitsCollection->GetDMname()
197           << G4endl;
198  }
199 
200  StoreDigiCollection(DigitsCollection);
201 
202  G4int DCID = -1;
203  if(DCID<0)
204    { 
205      //          DigiMan->List();
206      DCID = DigiMan->GetDigiCollectionID("GammaRayTelDigitizer/DigitsCollection");
207    }
208 
209 
210}
211
212
213
214//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
215
216
217
218
219
220
221
222
223
224
Note: See TracBrowser for help on using the repository browser.