BOSS 7.1.2
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"
20using namespace CLHEP;
21
23 :calorimeterCollID(-1),fNHits(0),fTotECrystal(0),fTotLCrystal(0),
24 fNCrystalSignal(0)
25{
26 for(int i=0;i<50;i++)
27 {for(int j=0;j<150;j++)
28 fSingleECrystal[i][j]=0;
29 }
30 G4SDManager * SDman = G4SDManager::GetSDMpointer();
31 calorimeterCollID= SDman->GetCollectionID("CalCollection");
32}
33
35{
36 delete[]fEnergySignal;
37 delete[]fNThetaSignal;
38 delete[]fNPhiSignal;
39}
40
41G4bool BesEmcDigitization::Digitize(const G4Event* evt, G4double ecut)
42{
43 G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
44 BesEmcHitsCollection* CHC = 0;
45
46 if (HCE)
47 CHC = (BesEmcHitsCollection*)(HCE->GetHC(calorimeterCollID));
48 else
49 return false;
50
51 G4int i=0,j=0;
52 if (CHC)
53 {
54 fNHits = CHC->entries();
55 if(fNHits)
56 for (i=0;i<fNHits;i++)
57 {
58 fTotECrystal += (*CHC)[i]->GetEdepCrystal();
59 fTotLCrystal += (*CHC)[i]->GetTrakCrystal();
60 G4int nTheta=45-(*CHC)[i]->GetNumThetaCrystal();
61 G4int nPhi =(*CHC)[i]->GetNumPhiCrystal();
62 if(nTheta>0&&nTheta<50&&nPhi>0&&nPhi<150)//waiting upgrade
63 {
64 fSingleECrystal[nTheta][nPhi]+=(*CHC)[i]->GetEdepCrystal();
65 //G4cout << "EMC Hit in crystal("
66 // << nTheta << "," <<nPhi<< ")" << G4endl;
67 }
68 else
69 {
70 G4cout << "EMC Hit out range:"
71 << nTheta <<','<< nPhi << G4endl;
72 }
73 }
74 }
75 else
76 return false;
77
78 for(i=1;i<50;i++)
79 {for(j=1;j<150;j++)
80 {
81 if(fSingleECrystal[i][j]>ecut)
82 {
83 fNCrystalSignal++;
84 }
85 }
86 }
87 if((fEnergySignal=new G4double[fNCrystalSignal+1])==NULL||
88 (fNThetaSignal=new G4int[fNCrystalSignal+1])==NULL||
89 (fNPhiSignal=new G4int[fNCrystalSignal+1])==NULL)
90 {
91 //G4Exception("BesEmcDigitization:can't allocate memory for Signal");
92 G4cout<<"BesEmcDigitization:can't allocate memory for Signal"<<G4endl;
93 exit(-1);
94 }
95 G4int n=0;
96 for(i=1;i<50;i++)
97 {for(j=1;j<150;j++)
98 {
99 if(fSingleECrystal[i][j]>ecut)
100 {
101 n++;
102 fEnergySignal[n]=fSingleECrystal[i][j];
103 fNThetaSignal[n]=45-i;
104 fNPhiSignal [n]=j;
105 }
106 }
107 }
108
109 return true;
110}
111
112G4double BesEmcDigitization::GetEmcSignal(G4int nTheta, G4int nPhi)
113{
114 if(nTheta>0&&nTheta<50&&nPhi>0&&nPhi<150)
115 return fSingleECrystal[nTheta][nPhi];
116 else
117 return 0;
118}
119
121{
122 G4cout
123 << " Absorber: total energy: "
124 << fTotECrystal/GeV << " GeV" << G4endl
125 << " total track length: "
126 << fTotLCrystal/cm << " cm" << G4endl;
127
128 G4cout << "\n " << fNHits
129 << " hits are stored in BesEmcHitsCollection." << G4endl;
130}
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)