BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcWaveform.cxx
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: EmcWaveform.cxx
11
12#include "EmcWaveform/EmcWaveform.h"
13#include <math.h>
14
15// Constructors
16
18 array_size = 60;
19 m_tau = 1000.;
20 m_sampleTime = 50.;
21 m_peakTime = 4000.;
22 m_timeOffset = 2500.;
23 emcWave = new double[array_size];
24
25 for ( int i = 0; i < array_size; i++ ) emcWave[i] = 0;
26}
27
28EmcWaveform::EmcWaveform( int size, double tau, double sampleTime )
29 : m_tau( tau ), m_sampleTime( sampleTime ) {
30 if ( size > 0 )
31 {
32 array_size = size;
33 emcWave = new double[array_size];
34 double* init = emcWave + array_size;
35 while ( init != emcWave ) *--init = 0.0;
36 }
37}
38
39// Destructors
41 delete[] emcWave;
42 emcWave = 0;
43}
44
45// Operators
46EmcWaveform& EmcWaveform::operator*=( const double scale ) {
47 for ( int i = 0; i < array_size; i++ ) emcWave[i] *= scale;
48 return *this;
49}
50
51EmcWaveform& EmcWaveform::operator/=( const double scale ) {
52 for ( int i = 0; i < array_size; i++ ) emcWave[i] /= scale;
53 return *this;
54}
55
57 for ( int i = 0; i < array_size; i++ ) emcWave[i] += assign[i];
58 return *this;
59}
60
62 if ( this != &assign )
63 {
64 if ( emcWave != 0 ) delete[] emcWave;
65 emcWave = new double[assign.array_size];
66 array_size = assign.array_size;
67 for ( int i = 0; i < array_size; i++ ) emcWave[i] = assign[i];
68 }
69 return *this;
70}
71
72double EmcWaveform::max( int& binOfMax ) const {
73 double maxi = emcWave[0];
74 binOfMax = 0;
75 for ( int i = 1; i < array_size; i++ )
76 {
77 if ( emcWave[i] > maxi )
78 {
79 maxi = emcWave[i];
80 binOfMax = i;
81 }
82 }
83 return maxi;
84}
85
87 double adc = emcWave[0];
88 for ( int i = 0; i < array_size; i++ )
89 {
90 if ( time >= i * m_sampleTime && time < ( i + 1 ) * m_sampleTime ) adc = emcWave[i];
91 }
92 return adc;
93}
94
95int EmcWaveform::frontEdgeTrg( double thres ) {
96 int binOfMax = -1;
97 for ( int i = 0; i < array_size; i++ )
98 {
99 if ( emcWave[i] > thres )
100 {
101 binOfMax = i;
102 break;
103 }
104 }
105 return binOfMax;
106}
107
109 double time0 = time * m_sampleTime + m_timeOffset - m_peakTime; // start time
110 double tempTime = 0; // time for each bin
111
112 double peak =
113 m_peakTime * m_peakTime * m_peakTime * m_peakTime * exp( -m_peakTime / m_tau ) / 24;
114
115 for ( int i = 0; i < array_size; i++ )
116 {
117 tempTime = i * m_sampleTime + m_timeOffset - time0;
118 if ( tempTime > 0 )
119 emcWave[i] += energy * tempTime * tempTime * tempTime * tempTime *
120 exp( -tempTime / m_tau ) / ( 24 * peak );
121 }
122}
123
124void EmcWaveform::makeWaveform( double energy, double time ) {
125 double time0 = time * m_sampleTime + m_timeOffset - m_peakTime; // start time
126 double tempTime = 0; // time for each bin
127
128 double peak =
129 m_peakTime * m_peakTime * m_peakTime * m_peakTime * exp( -m_peakTime / m_tau ) / 24;
130
131 for ( int i = 0; i < array_size; i++ )
132 {
133 tempTime = i * m_sampleTime + m_timeOffset - time0;
134 if ( tempTime > 0 )
135 emcWave[i] += energy * tempTime * tempTime * tempTime * tempTime *
136 exp( -tempTime / m_tau ) / ( 24 * peak );
137 }
138}
139
141 cout << "New Wave!" << endl;
142 for ( int i = 0; i < array_size; i++ ) cout << emcWave[i] << "\t";
143 cout << endl;
144}
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
EmcWaveform & operator+=(const EmcWaveform &)
double getADCTrg(int time)
double max(int &binOfMax) const
EmcWaveform & operator/=(const double)
EmcWaveform & operator=(const EmcWaveform &)
void makeWaveformTrg(double energy, double time)
EmcWaveform & operator*=(const double)
void makeWaveform(double energy, double time)
int frontEdgeTrg(double thres)