BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
BesEmcDigitization.cc
Go to the documentation of this file.
1//---------------------------------------------------------------------------//
2// BOOST --- BESIII Object_Oreiented Simulation Tool //
3//---------------------------------------------------------------------------//
4//Descpirtion: EMC detector
5//Author: Fu Chengdong
6//Created: Dec 15, 2003
7//Comment:
8//---------------------------------------------------------------------------//
9//
10#include "BesEmcDigitization.hh"
11#include "BesEmcHit.hh"
12
13#include "G4Event.hh"
14#include "G4EventManager.hh"
15#include "G4HCofThisEvent.hh"
16#include "G4VHitsCollection.hh"
17#include "G4SDManager.hh"
18#include "G4ios.hh"
19#include "G4UnitsTable.hh"
20
22 :calorimeterCollID(-1),fNHits(0),fTotECrystal(0),fTotLCrystal(0),
23 fNCrystalSignal(0)
24{
25 for(int i=0;i<50;i++)
26 {for(int j=0;j<150;j++)
27 fSingleECrystal[i][j]=0;
28 }
29 G4SDManager * SDman = G4SDManager::GetSDMpointer();
30 calorimeterCollID= SDman->GetCollectionID("CalCollection");
31}
32
34{
35 delete[]fEnergySignal;
36 delete[]fNThetaSignal;
37 delete[]fNPhiSignal;
38}
39
40G4bool BesEmcDigitization::Digitize(const G4Event* evt, G4double ecut)
41{
42 G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
43 BesEmcHitsCollection* CHC = 0;
44
45 if (HCE)
46 CHC = (BesEmcHitsCollection*)(HCE->GetHC(calorimeterCollID));
47 else
48 return false;
49
50 G4int i=0,j=0;
51 if (CHC)
52 {
53 fNHits = CHC->entries();
54 if(fNHits)
55 for (i=0;i<fNHits;i++)
56 {
57 fTotECrystal += (*CHC)[i]->GetEdepCrystal();
58 fTotLCrystal += (*CHC)[i]->GetTrakCrystal();
59 G4int nTheta=45-(*CHC)[i]->GetNumThetaCrystal();
60 G4int nPhi =(*CHC)[i]->GetNumPhiCrystal();
61 if(nTheta>0&&nTheta<50&&nPhi>0&&nPhi<150)//waiting upgrade
62 {
63 fSingleECrystal[nTheta][nPhi]+=(*CHC)[i]->GetEdepCrystal();
64 //G4cout << "EMC Hit in crystal("
65 // << nTheta << "," <<nPhi<< ")" << G4endl;
66 }
67 else
68 {
69 G4cout << "EMC Hit out range:"
70 << nTheta <<','<< nPhi << G4endl;
71 }
72 }
73 }
74 else
75 return false;
76
77 for(i=1;i<50;i++)
78 {for(j=1;j<150;j++)
79 {
80 if(fSingleECrystal[i][j]>ecut)
81 {
82 fNCrystalSignal++;
83 }
84 }
85 }
86 if((fEnergySignal=new G4double[fNCrystalSignal+1])==NULL||
87 (fNThetaSignal=new G4int[fNCrystalSignal+1])==NULL||
88 (fNPhiSignal=new G4int[fNCrystalSignal+1])==NULL)
89 {
90 G4Exception("BesEmcDigitization:can't allocate memory for Signal");
91 }
92 G4int n=0;
93 for(i=1;i<50;i++)
94 {for(j=1;j<150;j++)
95 {
96 if(fSingleECrystal[i][j]>ecut)
97 {
98 n++;
99 fEnergySignal[n]=fSingleECrystal[i][j];
100 fNThetaSignal[n]=45-i;
101 fNPhiSignal [n]=j;
102 }
103 }
104 }
105
106 return true;
107}
108
109G4double BesEmcDigitization::GetEmcSignal(G4int nTheta, G4int nPhi)
110{
111 if(nTheta>0&&nTheta<50&&nPhi>0&&nPhi<150)
112 return fSingleECrystal[nTheta][nPhi];
113 else
114 return 0;
115}
116
118{
119 G4cout
120 << " Absorber: total energy: "
121 << fTotECrystal/GeV << " GeV" << G4endl
122 << " total track length: "
123 << fTotLCrystal/cm << " cm" << G4endl;
124
125 G4cout << "\n " << fNHits
126 << " hits are stored in BesEmcHitsCollection." << G4endl;
127}
G4THitsCollection< BesEmcHit > BesEmcHitsCollection
Definition: BesEmcHit.hh:83
const int nPhi
const Int_t n
#define NULL
G4double GetEmcSignal(G4int, G4int)
G4bool Digitize(const G4Event *, G4double)