BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
BesEmcWaveform.cc
Go to the documentation of this file.
1//---------------------------------------------------------------------------//
2// BOOST --- BESIII Object_Oriented Simulation Tool //
3//---------------------------------------------------------------------------//
4//Description:
5//Author: Hemiao
6//Created: Oct 25, 2004
7//Modified:
8//Comment:
9//---------------------------------------------------------------------------//
10// $Id: BesEmcWaveform.cc
11
12#include "BesEmcWaveform.hh"
13#include "Randomize.hh"
14#include "CLHEP/Random/RanecuEngine.h"
15#include "CLHEP/Random/RandGauss.h"
16#include "BesEmcParameter.hh"
17#include "BesEmcDigi.hh"
18using namespace CLHEP;
19// Constructors
20
22{
24 //BesEmcParameter emcPara;
25 //emcPara.ReadData();
26 array_size = emcPara.GetArraySize();
27 m_tau = emcPara.GetTau();
28 m_highRange = emcPara.GetHighRange();
29 m_midRange = emcPara.GetMidRange();
30 m_lowRange = emcPara.GetLowRange();
31 m_sampleTime = emcPara.GetSampleTime();
32 m_peakTime = emcPara.GetPeakTime();
33 m_timeOffset = emcPara.GetTimeOffset();
34 m_bitNb = emcPara.GetADCbit();
35 m_photonsPerMeV = emcPara.GetPhotonsPerMeV();
36 m_nonuniformity = emcPara.GetNonuniformity();
37 m_flag = -1;
38 m_highPrecision = m_highRange/((G4double)(1<<m_bitNb));
39 m_midPrecision = m_midRange/((G4double)(1<<m_bitNb));
40 m_lowPrecision = m_lowRange/((G4double)(1<<m_bitNb));
41 emcWave=new G4double[array_size];
42
43 for (G4long i=0; i<array_size;i++)
44 emcWave[i]=0;
45}
46
47BesEmcWaveform::BesEmcWaveform(G4long size, G4double tau, G4double sampleTime)
48 :m_tau(tau),m_sampleTime(sampleTime)
49{
50 if(size>0){
51 array_size=size;
52 emcWave=new G4double[array_size];
53 G4double *init=emcWave+array_size;
54 while(init!=emcWave) *--init=0.0;
55 }
56 else{
57 G4Exception("Invalid size");
58 }
59}
60
61// Destructors
63 delete []emcWave;
64 emcWave=0;
65}
66
67// Operators
69{
70 for (G4long i=0; i<array_size;i++) emcWave[i]*=scale;
71 return *this;
72}
73
75{
76 for (G4long i=0; i<array_size;i++) emcWave[i]/=scale;
77 return *this;
78}
79
81{
82 for (G4long i=0; i<array_size;i++) emcWave[i]+=assign[i];
83 return *this;
84}
85
87{
88 if (this != &assign) {
89 if (emcWave!=0) delete []emcWave;
90 emcWave=new G4double[assign.array_size];
92 for (G4long i=0;i<array_size;i++) emcWave[i]=assign[i];
93 }
94 return *this;
95}
96
97G4double BesEmcWaveform::max(G4long &binOfMax) const
98{
99 G4double maxi=emcWave[0];
100 binOfMax = 0;
101 for (G4long i=1;i<array_size;i++)
102 {
103 if (emcWave[i]>maxi)
104 {
105 maxi=emcWave[i];
106 binOfMax = i;
107 }
108 }
109 return maxi;
110}
111
113{
114 G4double energy = hit->GetEdepCrystal();
115 G4double time = hit->GetTimeCrystal();
116
117 makeWaveform(energy, time);
118}
119
121{
122 G4double energy = digi->GetEnergy();
123 G4double time = digi->GetTime()*m_sampleTime+m_timeOffset-m_peakTime;
124
125 makeWaveform(energy, time);
126}
127
128void BesEmcWaveform::makeWaveform(G4double energy, G4double time)
129{
130 G4double amplitude;
131 if(m_photonsPerMeV==0)
132 {
133 amplitude = energy;
134 }
135 else
136 {
137 G4double photons = energy*m_photonsPerMeV;
138 if(photons>0) {
139 G4double photonStatFactor = RandGauss::shoot(photons, sqrt(photons))/photons;
140 amplitude = energy*photonStatFactor;
141 } else {
142 amplitude = 0;
143 }
144 }
145
146 G4double tempTime;
147 tempTime = 0;
148
149 G4double peak = m_peakTime*m_peakTime*m_peakTime*m_peakTime*exp(-m_peakTime/m_tau)/24;
150
151 for (G4long i=0;i<array_size;i++)
152 {
153 tempTime = i*m_sampleTime + m_timeOffset - time;
154 if(tempTime>0)
155 emcWave[i] += amplitude*tempTime*tempTime*tempTime*tempTime*exp(-tempTime/m_tau)/(24*peak);
156 }
157}
158
160{
161 G4double oneBitResolution;
162 oneBitResolution = m_midRange*2/((G4double)(1<<m_bitNb)); //not used now
163 G4double energy;
164
165 for(G4long i=0;i<array_size;i++)
166 {
167 energy = emcWave[i];
168 if(energy > m_highRange)
169 G4cout<<"---In BesEmcWaveform: Over measurement!--- energy="<<energy<<G4endl;
170 else if(energy > m_midRange)
171 {
172 m_flag = 2;
173 emcWave[i] = (G4double)((G4long)(emcWave[i]/m_highPrecision))*m_highPrecision;
174 }
175 else if(energy > m_lowRange)
176 {
177 m_flag = 1;
178 emcWave[i] = (G4double)((G4long)(emcWave[i]/m_midPrecision))*m_midPrecision;
179 }
180 else
181 {
182 m_flag = 0;
183 emcWave[i] = (G4double)((G4long)(emcWave[i]/m_lowPrecision))*m_lowPrecision;
184 }
185 }
186}
187
189{
190 G4cout<<"New Wave!"<<G4endl;
191 for(G4long i=0;i<array_size;i++)
192 G4cout<<emcWave[i]<<"\t";
193 G4cout<<G4endl;
194}
195
196void BesEmcWaveform::addElecNoise(G4double width, G4double coherentNoise)
197{
198 for(G4int i=0;i<array_size;i++)
199 {
200 emcWave[i] += RandGauss::shoot()*width;
201 emcWave[i] += coherentNoise;
202 emcWave[i] = emcWave[i]>0?emcWave[i]:0;
203 }
204}
EvtComplex exp(const EvtComplex &c)
Definition: EvtComplex.hh:252
************Class m_ypar INTEGER m_KeyWgt INTEGER m_KeyIHVP INTEGER m_KeyGPS INTEGER m_IsBeamPolarized INTEGER m_EvtGenInterface DOUBLE PRECISION m_Emin DOUBLE PRECISION m_sphot DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_q2 DOUBLE PRECISION m_PolBeam2 DOUBLE PRECISION m_xErrPb *COMMON c_KK2f $ !CMS energy average $ !Spin Polarization vector first beam $ !Spin Polarization vector second beam $ !Beam energy spread[GeV] $ !minimum hadronization energy[GeV] $ !input READ never touch them !$ !debug facility $ !maximum weight $ !inverse alfaQED $ !minimum real photon energy
Definition: KK2f.h:50
G4double GetEnergy()
Definition: BesEmcDigi.hh:52
G4double GetTime()
Definition: BesEmcDigi.hh:53
G4double GetTimeCrystal()
Definition: BesEmcHit.hh:60
G4double GetEdepCrystal()
Definition: BesEmcHit.hh:56
G4double GetHighRange()
G4double GetPeakTime()
static BesEmcParameter & GetInstance()
G4double GetNonuniformity()
G4double GetMidRange()
G4double GetTimeOffset()
G4double GetLowRange()
G4double GetPhotonsPerMeV()
G4double GetSampleTime()
virtual BesEmcWaveform & operator/=(const G4double &)
virtual ~BesEmcWaveform()
void updateWaveform(BesEmcHit *)
virtual BesEmcWaveform & operator+=(const BesEmcWaveform &)
void makeWaveform(G4double energy, G4double time)
void addElecNoise(G4double, G4double)
virtual BesEmcWaveform & operator=(const BesEmcWaveform &)
G4double * emcWave
virtual BesEmcWaveform & operator*=(const G4double &)
G4double max(G4long &binOfMax) const