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