BOSS 7.1.2
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 G4cout<<"BesEmcWaveform:: Invalid size"<<G4endl;
58 exit(-1);
59 }
60}
61
62// Destructors
67
68// Operators
70{
71 for (G4long i=0; i<array_size;i++) emcWave[i]*=scale;
72 return *this;
73}
74
76{
77 for (G4long i=0; i<array_size;i++) emcWave[i]/=scale;
78 return *this;
79}
80
82{
83 for (G4long i=0; i<array_size;i++) emcWave[i]+=assign[i];
84 return *this;
85}
86
88{
89 if (this != &assign) {
90 if (emcWave!=0) delete []emcWave;
91 emcWave=new G4double[assign.array_size];
93 for (G4long i=0;i<array_size;i++) emcWave[i]=assign[i];
94 }
95 return *this;
96}
97
98G4double BesEmcWaveform::max(G4long &binOfMax) const
99{
100 G4double maxi=emcWave[0];
101 binOfMax = 0;
102 for (G4long i=1;i<array_size;i++)
103 {
104 if (emcWave[i]>maxi)
105 {
106 maxi=emcWave[i];
107 binOfMax = i;
108 }
109 }
110 return maxi;
111}
112
114{
115 G4double energy = hit->GetEdepCrystal();
116 G4double time = hit->GetTimeCrystal();
117
119}
120
122{
123 G4double energy = digi->GetEnergy();
124 G4double time = digi->GetTime()*m_sampleTime+m_timeOffset-m_peakTime;
125
127}
128
130{
131 G4double amplitude;
132 if(m_photonsPerMeV==0)
133 {
134 amplitude = energy;
135 }
136 else
137 {
138 G4double photons = energy*m_photonsPerMeV;
139 if(photons>0) {
140 G4double photonStatFactor = RandGauss::shoot(photons, sqrt(photons))/photons;
141 amplitude = energy*photonStatFactor;
142 } else {
143 amplitude = 0;
144 }
145 }
146
147 G4double tempTime;
148 tempTime = 0;
149
150 G4double peak = m_peakTime*m_peakTime*m_peakTime*m_peakTime*exp(-m_peakTime/m_tau)/24;
151
152 for (G4long i=0;i<array_size;i++)
153 {
154 tempTime = i*m_sampleTime + m_timeOffset - time;
155 if(tempTime>0)
156 emcWave[i] += amplitude*tempTime*tempTime*tempTime*tempTime*exp(-tempTime/m_tau)/(24*peak);
157 }
158}
159
161{
162 G4double oneBitResolution;
163 oneBitResolution = m_midRange*2/((G4double)(1<<m_bitNb)); //not used now
164 G4double energy;
165
166 for(G4long i=0;i<array_size;i++)
167 {
168 energy = emcWave[i];
169 if(energy > m_highRange)
170 G4cout<<"---In BesEmcWaveform: Over measurement!--- energy="<<energy<<G4endl;
171 else if(energy > m_midRange)
172 {
173 m_flag = 2;
174 emcWave[i] = (G4double)((G4long)(emcWave[i]/m_highPrecision))*m_highPrecision;
175 }
176 else if(energy > m_lowRange)
177 {
178 m_flag = 1;
179 emcWave[i] = (G4double)((G4long)(emcWave[i]/m_midPrecision))*m_midPrecision;
180 }
181 else
182 {
183 m_flag = 0;
184 emcWave[i] = (G4double)((G4long)(emcWave[i]/m_lowPrecision))*m_lowPrecision;
185 }
186 }
187}
188
190{
191 G4cout<<"New Wave!"<<G4endl;
192 for(G4long i=0;i<array_size;i++)
193 G4cout<<emcWave[i]<<"\t";
194 G4cout<<G4endl;
195}
196
197void BesEmcWaveform::addElecNoise(G4double width, G4double coherentNoise)
198{
199 for(G4int i=0;i<array_size;i++)
200 {
201 emcWave[i] += RandGauss::shoot()*width;
202 emcWave[i] += coherentNoise;
203 emcWave[i] = emcWave[i]>0?emcWave[i]:0;
204 }
205}
Double_t time
EvtComplex exp(const EvtComplex &c)
************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