8 #include "CLHEP/Random/RandGaussQ.h" 9 #include "CLHEP/Random/RandPoissonQ.h" 10 #include "CLHEP/Units/GlobalPhysicalConstants.h" 42 if (signalBuckets == 1) {
44 }
else if (signalBuckets == 3) {
46 }
else if (signalBuckets == 4) {
51 weight_ =
weight(binOfMax, signalBuckets, preSamples, numOfBuckets);
55 if (binOfMax>numOfBuckets)
56 bmax_ = numOfBuckets+5;
60 edm::LogInfo(
"HcalSim") <<
"HcalQie: initialized with binOfMax " << binOfMax
62 <<
"; signalBuckets " << signalBuckets
63 <<
" Baseline/Phase/Scale " <<
baseline <<
"/" 66 <<
"fC fCToPE " << qToPE <<
" EDepPerPE " 78 const float ts2 = 10.;
79 const float ts3 = 29.3;
80 const float thpd = 4.;
81 const float tpre = 5.;
84 const float wd2 = 0.7;
89 int j, hpd_siz = (
int)(thpd);
90 std::vector<double> hpd_drift(hpd_siz);
91 for (j=0; j<hpd_siz; j++) {
92 double tmp = (double)j + 0.5;
93 hpd_drift[j] = 1.0 + tmp/thpd;
97 for (j=0; j<hpd_siz; j++) {
102 int preamp_siz=(
int)(6*tpre);
103 std::vector<double> preamp(preamp_siz);
105 for (j=0; j<preamp_siz; j++) {
106 double tmp = (double)j + 0.5;
107 preamp[j] = tmp*
exp(-(tmp*tmp)/(tpre*tpre));
111 for (j=0; j<preamp_siz; j++) {
120 std::vector<double> scnt_decay(tmax);
122 for (j=0; j<
tmax; j++) {
123 double tmp = (double)j + 0.5;
124 scnt_decay[j] = wd1*
exp(-tmp/ts1) + wd2*
exp(-tmp/ts2) + wd3*
exp(-tmp/ts3);
125 norm += scnt_decay[j];
128 for (j=0; j<
tmax; j++) {
129 scnt_decay[j] /= norm;
132 int nsiz = tmax + hpd_siz + preamp_siz + 1;
133 std::vector<double> pulse(nsiz,0.0);
136 for (i=0; i<
tmax; i++) {
138 for (j=0; j<hpd_siz; j++) {
140 for (k=0; k<preamp_siz; k++) {
142 float tmp = scnt_decay[
i]*hpd_drift[j]*preamp[
k];
150 edm::LogInfo(
"HcalSim") <<
"HcalQie: Convoluted Shape ============== " 151 <<
"Normalisation " << norm;
152 for (i=0; i<nsiz; i++) {
155 LogDebug(
"HcalSim") <<
"HcalQie: Pulse[" << std::setw(3) << i <<
"] " 156 << std::setw(8) << pulse[
i];
165 unsigned int CodeFADCdata[122] = {
166 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
167 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
168 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
169 30, 31, 34, 35, 36, 37, 38, 39,
170 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
171 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
172 60, 61, 62, 63, 66, 67, 68, 69,
173 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
174 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
175 90, 91, 92, 93, 94, 95, 98, 99,
176 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
177 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
178 120, 121, 122, 123, 124, 125, 126, 127 };
180 std::vector<int>
temp(122);
182 for (i = 0; i < 122; i++)
183 temp[i] = (
int)CodeFADCdata[
i];
186 int siz = temp.size();
187 LogDebug(
"HcalSim") <<
"HcalQie: Codes in array of size " << siz;
188 for (i=0; i<siz; i++)
189 LogDebug(
"HcalSim") <<
"HcalQie: Code[" << std::setw(3) << i <<
"] " 190 << std::setw(6) << temp[
i];
197 double ChargeFADCdata[122] = {
198 -1.5, -0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5,
199 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 16.5, 18.5, 20.5,
200 22.5, 24.5, 26.5, 28.5, 31.5, 34.5, 37.5, 40.5, 44.5, 48.5,
201 52.5, 57.5, 62.5, 67.5, 72.5, 77.5, 82.5, 87.5,
202 92.5, 97.5, 102.5, 107.5, 112.5, 117.5, 122.5, 127.5, 132.5, 142.5,
203 152.5, 162.5, 172.5, 182.5, 192.5, 202.5, 217.5, 232.5, 247.5, 262.5,
204 282.5, 302.5, 322.5, 347.5, 372.5, 397.5, 422.5, 447.5,
205 472.5, 497.5, 522.5, 547.5, 572.5, 597.5, 622.5, 647.5, 672.5, 697.5,
206 722.5, 772.5, 822.5, 872.5, 922.5, 972.5, 1022.5, 1072.5, 1147.5, 1222.5,
207 1297.5,1372.5, 1472.5, 1572.5, 1672.5, 1797.5, 1922.5, 2047.5,
208 2172.5,2297.5, 2422.5, 2547.5, 2672.5, 2797.5, 2922.5, 3047.5, 3172.5, 3397.5,
209 3422.5,3547.5, 3672.5, 3922.5, 4172.5, 4422.5, 4672.5, 4922.5, 5172.5, 5422.5,
210 5797.5,6172.5, 6547.5, 6922.5, 7422.5, 7922.5, 8422.5, 9047.5 };
212 std::vector<double>
temp(122);
214 for (i = 0; i < 122; i++)
215 temp[i] = (
double)(ChargeFADCdata[
i]);
218 int siz = temp.size();
219 LogDebug(
"HcalSim") <<
"HcalQie: Charges in array of size " << siz;
220 for (i=0; i<siz; i++)
221 LogDebug(
"HcalSim") <<
"HcalQie: Charge[" << std::setw(3) << i <<
"] " 222 << std::setw(8) << temp[
i];
230 std::vector<double>
temp(bucket,0);
232 for (i=binOfMax-1; i<binOfMax+mode-1; i++)
235 for (i=0; i<npre; i++) {
236 int j = binOfMax-2-
i;
237 temp[j] =-(double)mode/(
double)npre;
242 int siz = temp.size();
243 LogDebug(
"HcalSim") <<
"HcalQie: Weights in array of size " << siz
244 <<
" and Npre " << npre;
245 for (i=0; i<siz; i++)
246 LogDebug(
"HcalSim") <<
"HcalQie: [Weight[" << i <<
"] = " << temp[
i];
255 for (
unsigned int i=0;
i<
code_.size();
i++) {
258 if (i ==
code_.size()-1)
262 tmp = charge_[
i] + 0.5*
delta;
274 for (
unsigned int i=0;
i<
charge_.size();
i++) {
276 if (i>0) tmp =
code_[i-1];
288 int k = (
int) (time + 0.5);
289 if (k>=0 && k<((
int)(
shape_.size())-1))
297 CLHEP::HepRandomEngine* engine) {
299 const double bunchSpace=25.;
301 std::vector<double>
work(nmax);
309 <<
" width " <<
sigma <<
" and " << nht <<
" hits";
311 LogDebug(
"HcalSim") <<
"HcalQie: Code[" <<
i <<
"] = " << work[
i];
313 double etot=0, esum=0,
photons=0;
317 std::vector<const CaloHit*>
hits(nht);
318 std::vector<const CaloHit*>::iterator k1, k2;
320 for (kk = 0; kk < nht; kk++) {
321 hits[
kk] = &hitbuf[
kk];
326 for (kk = 0, k1 = hits.begin(); k1 != hits.end(); kk++, k1++) {
327 double ehit = (**k1).e();
328 double jitter= (**k1).t();
330 for (k2 = k1+1; k2 != hits.end() && (jitter-(**k2).t())<1. &&
331 (jitter-(**k2).t())>-1.; k2++) {
337 CLHEP::RandPoissonQ randPoissonQ(*engine, avpe);
338 double photo = randPoissonQ.fire();
342 LogDebug(
"HcalSim") <<
"HcalQie::getCode: Hit " << kk <<
":" << kk+jump
343 <<
" Energy deposit " << ehit <<
" Time " << jitter
344 <<
" Average and true no of PE " << avpe <<
" " 350 <<
" binTime " << bintime;
352 std::vector<double> binsum(nmax,0);
353 double norm=0, sum=0.;
355 bintime += bunchSpace;
356 for (
int j=0; j<(
int)(bunchSpace); j++) {
357 double tim = bintime + j;
364 if (sum>0) norm = (photo/(sum*
qToPE));
366 LogDebug(
"HcalSim") <<
"HcalQie::getCode: PE " << photo <<
" Sum " << sum
367 <<
" Norm. " << norm;
370 work[
i] += binsum[
i]*norm;
377 std::vector<int>
temp(numOfBuckets,0);
383 LogDebug(
"HcalSim") <<
"HcalQie::getCode: Input " << etot <<
" GeV; Photons " 384 <<
photons <<
"; Output " << esum <<
" fc";
398 LogDebug(
"HcalSim") <<
"HcalQie::getEnergy: " << i <<
" code " << code[
i]
399 <<
" PE " << work[
i];
410 LogDebug(
"HcalSim") <<
"HcalQie::getEnergy: PE " << sum*
qToPE <<
" Energy "
T getParameter(std::string const &) const
std::vector< double > shape()
HcalQie(edm::ParameterSet const &p)
double getShape(double time)
std::vector< double > weight_
auto const T2 &decltype(t1.eta()) t2
double getEnergy(const std::vector< int > &)
std::vector< double > charge()
std::vector< double > charge_
static const double tmax[3]
std::vector< std::vector< double > > tmp
std::vector< int > getCode(int, const std::vector< CaloHit > &, CLHEP::HepRandomEngine *)
std::vector< double > shape_
std::vector< double > weight(int binofmax, int mode, int npre, int numbucket)
std::vector< int > code()