10 #include "CLHEP/Random/RandGaussQ.h"
11 #include "CLHEP/Random/RandPoissonQ.h"
13 #include "CLHEP/Units/GlobalPhysicalConstants.h"
45 if (signalBuckets == 1) {
47 }
else if (signalBuckets == 3) {
49 }
else if (signalBuckets == 4) {
54 weight_ =
weight(binOfMax, signalBuckets, preSamples, numOfBuckets);
58 if (binOfMax>numOfBuckets)
59 bmax_ = numOfBuckets+5;
63 edm::LogInfo(
"HcalSim") <<
"HcalQie: initialized with binOfMax " << binOfMax
65 <<
"; signalBuckets " << signalBuckets
66 <<
" Baseline/Phase/Scale " <<
baseline <<
"/"
69 <<
"fC fCToPE " << qToPE <<
" EDepPerPE "
81 const float ts2 = 10.;
82 const float ts3 = 29.3;
83 const float thpd = 4.;
84 const float tpre = 5.;
87 const float wd2 = 0.7;
92 int j, hpd_siz = (int)(thpd);
93 std::vector<double> hpd_drift(hpd_siz);
94 for (j=0; j<hpd_siz; j++) {
95 double tmp = (double)j + 0.5;
96 hpd_drift[
j] = 1.0 + tmp/thpd;
100 for (j=0; j<hpd_siz; j++) {
101 hpd_drift[
j] /= norm;
105 int preamp_siz=(int)(6*tpre);
106 std::vector<double> preamp(preamp_siz);
108 for (j=0; j<preamp_siz; j++) {
109 double tmp = (double)j + 0.5;
110 preamp[
j] = tmp*
exp(-(tmp*tmp)/(tpre*tpre));
114 for (j=0; j<preamp_siz; j++) {
122 int tmax = 6 * (int)ts3;
123 std::vector<double> scnt_decay(tmax);
125 for (j=0; j<
tmax; j++) {
126 double tmp = (double)j + 0.5;
127 scnt_decay[
j] = wd1*
exp(-tmp/ts1) + wd2*
exp(-tmp/ts2) + wd3*
exp(-tmp/ts3);
128 norm += scnt_decay[
j];
131 for (j=0; j<
tmax; j++) {
132 scnt_decay[
j] /= norm;
135 int nsiz = tmax + hpd_siz + preamp_siz + 1;
136 std::vector<double> pulse(nsiz,0.0);
139 for (i=0; i<
tmax; i++) {
141 for (j=0; j<hpd_siz; j++) {
143 for (k=0; k<preamp_siz; k++) {
145 float tmp = scnt_decay[
i]*hpd_drift[
j]*preamp[
k];
153 edm::LogInfo(
"HcalSim") <<
"HcalQie: Convoluted Shape ============== "
154 <<
"Normalisation " << norm;
155 for (i=0; i<nsiz; i++) {
158 LogDebug(
"HcalSim") <<
"HcalQie: Pulse[" << std::setw(3) << i <<
"] "
159 << std::setw(8) << pulse[
i];
168 unsigned int CodeFADCdata[122] = {
169 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
170 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
171 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
172 30, 31, 34, 35, 36, 37, 38, 39,
173 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
174 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
175 60, 61, 62, 63, 66, 67, 68, 69,
176 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
177 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
178 90, 91, 92, 93, 94, 95, 98, 99,
179 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
180 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
181 120, 121, 122, 123, 124, 125, 126, 127 };
183 std::vector<int>
temp(122);
185 for (i = 0; i < 122; i++)
186 temp[i] = (
int)CodeFADCdata[
i];
189 int siz = temp.size();
190 LogDebug(
"HcalSim") <<
"HcalQie: Codes in array of size " << siz;
191 for (i=0; i<siz; i++)
192 LogDebug(
"HcalSim") <<
"HcalQie: Code[" << std::setw(3) << i <<
"] "
193 << std::setw(6) << temp[
i];
200 double ChargeFADCdata[122] = {
201 -1.5, -0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5,
202 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 16.5, 18.5, 20.5,
203 22.5, 24.5, 26.5, 28.5, 31.5, 34.5, 37.5, 40.5, 44.5, 48.5,
204 52.5, 57.5, 62.5, 67.5, 72.5, 77.5, 82.5, 87.5,
205 92.5, 97.5, 102.5, 107.5, 112.5, 117.5, 122.5, 127.5, 132.5, 142.5,
206 152.5, 162.5, 172.5, 182.5, 192.5, 202.5, 217.5, 232.5, 247.5, 262.5,
207 282.5, 302.5, 322.5, 347.5, 372.5, 397.5, 422.5, 447.5,
208 472.5, 497.5, 522.5, 547.5, 572.5, 597.5, 622.5, 647.5, 672.5, 697.5,
209 722.5, 772.5, 822.5, 872.5, 922.5, 972.5, 1022.5, 1072.5, 1147.5, 1222.5,
210 1297.5,1372.5, 1472.5, 1572.5, 1672.5, 1797.5, 1922.5, 2047.5,
211 2172.5,2297.5, 2422.5, 2547.5, 2672.5, 2797.5, 2922.5, 3047.5, 3172.5, 3397.5,
212 3422.5,3547.5, 3672.5, 3922.5, 4172.5, 4422.5, 4672.5, 4922.5, 5172.5, 5422.5,
213 5797.5,6172.5, 6547.5, 6922.5, 7422.5, 7922.5, 8422.5, 9047.5 };
215 std::vector<double>
temp(122);
217 for (i = 0; i < 122; i++)
218 temp[i] = (
double)(ChargeFADCdata[
i]);
221 int siz = temp.size();
222 LogDebug(
"HcalSim") <<
"HcalQie: Charges in array of size " << siz;
223 for (i=0; i<siz; i++)
224 LogDebug(
"HcalSim") <<
"HcalQie: Charge[" << std::setw(3) << i <<
"] "
225 << std::setw(8) << temp[
i];
233 std::vector<double>
temp(bucket,0);
235 for (i=binOfMax-1; i<binOfMax+mode-1; i++)
238 for (i=0; i<npre; i++) {
239 int j = binOfMax-2-
i;
240 temp[
j] =-(double)mode/(
double)npre;
245 int siz = temp.size();
246 LogDebug(
"HcalSim") <<
"HcalQie: Weights in array of size " << siz
247 <<
" and Npre " << npre;
248 for (i=0; i<siz; i++)
249 LogDebug(
"HcalSim") <<
"HcalQie: [Weight[" << i <<
"] = " << temp[
i];
258 for (
unsigned int i=0;
i<
code_.size();
i++) {
261 if (i ==
code_.size()-1)
265 tmp = charge_[
i] + 0.5*
delta;
277 for (
unsigned int i=0;
i<
charge_.size();
i++) {
279 if (i>0) tmp =
code_[i-1];
291 int k = (int) (time + 0.5);
292 if (k>=0 && k<((
int)(
shape_.size())-1))
301 const double bunchSpace=25.;
303 std::vector<double> work(nmax);
308 <<
"HcalQIE requires the RandomNumberGeneratorService\n"
309 <<
"which is not present in the configuration file. "
310 <<
"You must add the service\n in the configuration file or "
311 <<
"remove the modules that require it.";
314 CLHEP::RandPoissonQ randPoisson(rng->
getEngine());
319 work[
i] = randGauss.fire();
323 <<
" width " <<
sigma <<
" and " << nht <<
" hits";
325 LogDebug(
"HcalSim") <<
"HcalQie: Code[" <<
i <<
"] = " << work[
i];
327 double etot=0, esum=0,
photons=0;
331 std::vector<const CaloHit*> hits(nht);
332 std::vector<const CaloHit*>::iterator k1, k2;
334 for (kk = 0; kk < nht; kk++) {
335 hits[
kk] = &hitbuf[
kk];
340 for (kk = 0, k1 = hits.begin(); k1 != hits.end(); kk++, k1++) {
341 double ehit = (**k1).e();
342 double jitter= (**k1).t();
344 for (k2 = k1+1; k2 != hits.end() && (jitter-(**k2).t())<1. &&
345 (jitter-(**k2).t())>-1.; k2++) {
351 double photo = randPoisson.fire(avpe);
355 LogDebug(
"HcalSim") <<
"HcalQie::getCode: Hit " << kk <<
":" << kk+jump
356 <<
" Energy deposit " << ehit <<
" Time " << jitter
357 <<
" Average and true no of PE " << avpe <<
" "
363 <<
" binTime " << bintime;
365 std::vector<double> binsum(nmax,0);
366 double norm=0, sum=0.;
368 bintime += bunchSpace;
369 for (
int j=0;
j<(int)(bunchSpace);
j++) {
370 double tim = bintime +
j;
377 if (sum>0) norm = (photo/(sum*
qToPE));
379 LogDebug(
"HcalSim") <<
"HcalQie::getCode: PE " << photo <<
" Sum " << sum
380 <<
" Norm. " << norm;
383 work[
i] += binsum[
i]*norm;
390 std::vector<int>
temp(numOfBuckets,0);
396 LogDebug(
"HcalSim") <<
"HcalQie::getCode: Input " << etot <<
" GeV; Photons "
397 <<
photons <<
"; Output " << esum <<
" fc";
411 LogDebug(
"HcalSim") <<
"HcalQie::getEnergy: " << i <<
" code " << code[
i]
412 <<
" PE " << work[
i];
423 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()
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
std::vector< int > getCode(int, const std::vector< CaloHit > &)
std::vector< double > charge_
static const double tmax[3]
std::vector< std::vector< double > > tmp
std::vector< double > shape_
std::vector< double > weight(int binofmax, int mode, int npre, int numbucket)
std::vector< int > code()