CMS 3D CMS Logo

HCALResponse.cc
Go to the documentation of this file.
1 //updated by Reza Goldouzian
2 //FastSimulation headers
6 
7 // CMSSW Headers
10 
11 #include <iostream>
12 #include <vector>
13 #include <string>
14 #include <cmath>
15 
16 using namespace edm;
17 
19  //switches
20  debug = pset.getParameter<bool>("debug");
21  usemip = pset.getParameter<bool>("usemip");
22 
23  //values for "old" response parameterizations
24  //--------------------------------------------------------------------
25  RespPar[HCAL][0][0] = pset.getParameter<double>("HadronBarrelResolution_Stochastic");
26  RespPar[HCAL][0][1] = pset.getParameter<double>("HadronBarrelResolution_Constant");
27  RespPar[HCAL][0][2] = pset.getParameter<double>("HadronBarrelResolution_Noise");
28 
29  RespPar[HCAL][1][0] = pset.getParameter<double>("HadronEndcapResolution_Stochastic");
30  RespPar[HCAL][1][1] = pset.getParameter<double>("HadronEndcapResolution_Constant");
31  RespPar[HCAL][1][2] = pset.getParameter<double>("HadronEndcapResolution_Noise");
32 
33  RespPar[VFCAL][0][0] = pset.getParameter<double>("HadronForwardResolution_Stochastic");
34  RespPar[VFCAL][0][1] = pset.getParameter<double>("HadronForwardResolution_Constant");
35  RespPar[VFCAL][0][2] = pset.getParameter<double>("HadronForwardResolution_Noise");
36 
37  RespPar[VFCAL][1][0] = pset.getParameter<double>("ElectronForwardResolution_Stochastic");
38  RespPar[VFCAL][1][1] = pset.getParameter<double>("ElectronForwardResolution_Constant");
39  RespPar[VFCAL][1][2] = pset.getParameter<double>("ElectronForwardResolution_Noise");
40 
41  eResponseScale[0] = pset.getParameter<double>("eResponseScaleHB");
42  eResponseScale[1] = pset.getParameter<double>("eResponseScaleHE");
43  eResponseScale[2] = pset.getParameter<double>("eResponseScaleHF");
44 
45  eResponsePlateau[0] = pset.getParameter<double>("eResponsePlateauHB");
46  eResponsePlateau[1] = pset.getParameter<double>("eResponsePlateauHE");
47  eResponsePlateau[2] = pset.getParameter<double>("eResponsePlateauHF");
48 
49  eResponseExponent = pset.getParameter<double>("eResponseExponent");
50  eResponseCoefficient = pset.getParameter<double>("eResponseCoefficient");
51 
52  //pion parameters
53  //--------------------------------------------------------------------
54  //energy values
55  maxHDe[0] = pset.getParameter<int>("maxHBe");
56  maxHDe[1] = pset.getParameter<int>("maxHEe");
57  maxHDe[2] = pset.getParameter<int>("maxHFe");
58  maxHDe[3] = pset.getParameter<int>("maxHFlowe");
59 
60  eGridHD[0] = pset.getParameter<vec1>("eGridHB");
61  eGridHD[1] = pset.getParameter<vec1>("eGridHE");
62  eGridHD[2] = pset.getParameter<vec1>("eGridHF");
63  eGridHD[3] = pset.getParameter<vec1>("loweGridHF");
64 
65  //region eta indices calculated from eta values
66  etaStep = pset.getParameter<double>("etaStep");
67  //eta boundaries
68  HDeta[0] = abs((int)(pset.getParameter<double>("HBeta") / etaStep));
69  HDeta[1] = abs((int)(pset.getParameter<double>("HEeta") / etaStep));
70  HDeta[2] = abs((int)(pset.getParameter<double>("HFeta") / etaStep));
71  HDeta[3] = abs((int)(pset.getParameter<double>("maxHDeta") / etaStep)); //add 1 because this is the max index
72  //eta ranges
73  maxHDetas[0] = HDeta[1] - HDeta[0];
74  maxHDetas[1] = HDeta[2] - HDeta[1];
75  maxHDetas[2] = HDeta[3] - HDeta[2];
76 
77  //parameter info
78  nPar = pset.getParameter<int>("nPar");
79  parNames = pset.getParameter<std::vector<std::string> >("parNames");
80  std::string detNames[] = {"_HB", "_HE", "_HF"};
81  std::string mipNames[] = {"_mip", "_nomip", ""};
82  std::string fraction = "f";
83  //setup parameters (5D vector)
84  parameters = vec5(nPar, vec4(3, vec3(3)));
85  for (int p = 0; p < nPar; p++) { //loop over parameters
86  for (int m = 0; m < 3; m++) { //loop over mip, nomip, total
87  for (int d = 0; d < 3; d++) { //loop over dets: HB, HE, HF
88  //get from python
89  std::string pname = parNames[p] + detNames[d] + mipNames[m];
90  vec1 tmp = pset.getParameter<vec1>(pname);
91 
92  //resize vector for energy range of det d
93  parameters[p][m][d].resize(maxHDe[d]);
94 
95  for (int i = 0; i < maxHDe[d]; i++) { //loop over energy for det d
96  //resize vector for eta range of det d
97  parameters[p][m][d][i].resize(maxHDetas[d]);
98 
99  for (int j = 0; j < maxHDetas[d]; j++) { //loop over eta for det d
100  //fill in parameters vector from python
101  parameters[p][m][d][i][j] = tmp[i * maxHDetas[d] + j];
102  }
103  }
104  }
105  }
106  }
107  //set up Poisson parameters for low energy Hadrons in HF
108  //----------------------------------------------------------------------
109  PoissonParameters = vec3(4);
110  std::string PoissonParName[] = {"mean_overall", "shift_overall", "mean_between", "shift_between"};
111  for (int d = 0; d < 4; d++) { //loop over Poisson parameteres
112  vec1 tmp1 = pset.getParameter<vec1>(PoissonParName[d]);
113  for (int i = 0; i < maxHDe[3]; i++) { //loop over energy for low HF energy points
114  PoissonParameters[d].resize(maxHDe[3]);
115  for (int j = 0; j < maxHDetas[2]; j++) { //loop over HF eta points
116  PoissonParameters[d][i].resize(maxHDetas[2]);
117  PoissonParameters[d][i][j] = tmp1[i * maxHDetas[2] + j];
118  }
119  }
120  }
121 
122  //MIP fraction fill in 3d vector
124  mipfraction = vec3(3);
125  for (int d = 0; d < 3; d++) { //loop over dets: HB, HE, HF
126  //get from python
127  std::string mipname = fraction + mipNames[0] + detNames[d];
128  vec1 tmp1 = pset.getParameter<vec1>(mipname);
129  mipfraction[d].resize(maxHDe[d]);
130  for (int i = 0; i < maxHDe[d]; i++) { //loop over energy for det d
131  //resize vector for eta range of det d
132  mipfraction[d][i].resize(maxHDetas[d]);
133  for (int j = 0; j < maxHDetas[d]; j++) { //loop over eta for det d
134  //fill in parameters vector from python
135  mipfraction[d][i][j] = tmp1[i * maxHDetas[d] + j];
136  }
137  }
138  }
139 
140  // MUON probability histos for bin size = 0.25 GeV (0-10 GeV, 40 bins)
141  //--------------------------------------------------------------------
142  muStep = pset.getParameter<double>("muStep");
143  maxMUe = pset.getParameter<int>("maxMUe");
144  maxMUeta = pset.getParameter<int>("maxMUeta");
145  maxMUbin = pset.getParameter<int>("maxMUbin");
146  eGridMU = pset.getParameter<vec1>("eGridMU");
147  etaGridMU = pset.getParameter<vec1>("etaGridMU");
148  vec1 _responseMU[2] = {pset.getParameter<vec1>("responseMUBarrel"), pset.getParameter<vec1>("responseMUEndcap")};
149 
150  //get muon region eta indices from the eta grid
151  double _barrelMUeta = pset.getParameter<double>("barrelMUeta");
152  double _endcapMUeta = pset.getParameter<double>("endcapMUeta");
154  for (int i = 0; i < maxMUeta; i++) {
155  if (fabs(_barrelMUeta) <= etaGridMU[i]) {
156  barrelMUeta = i;
157  break;
158  }
159  }
160  for (int i = 0; i < maxMUeta; i++) {
161  if (fabs(_endcapMUeta) <= etaGridMU[i]) {
162  endcapMUeta = i;
163  break;
164  }
165  }
166  int maxMUetas[] = {endcapMUeta - barrelMUeta, maxMUeta - endcapMUeta};
167 
168  //initialize 3D vector
169  responseMU = vec3(maxMUe, vec2(maxMUeta, vec1(maxMUbin, 0)));
170 
171  //fill in 3D vector
172  //(complementary cumulative distribution functions, from normalized response distributions)
173  int loc, eta_loc;
174  loc = eta_loc = -1;
175  for (int i = 0; i < maxMUe; i++) {
176  for (int j = 0; j < maxMUeta; j++) {
177  //check location - barrel, endcap, or forward
178  if (j == barrelMUeta) {
179  loc = 0;
180  eta_loc = barrelMUeta;
181  } else if (j == endcapMUeta) {
182  loc = 1;
183  eta_loc = endcapMUeta;
184  }
185 
186  for (int k = 0; k < maxMUbin; k++) {
187  responseMU[i][j][k] = _responseMU[loc][i * maxMUetas[loc] * maxMUbin + (j - eta_loc) * maxMUbin + k];
188 
189  if (debug) {
190  //cout.width(6);
191  LogInfo("FastCalorimetry") << " responseMU " << i << " " << j << " " << k << " = " << responseMU[i][j][k]
192  << std::endl;
193  }
194  }
195  }
196  }
197 
198  // values for EM response in HF
199  //--------------------------------------------------------------------
200  maxEMe = pset.getParameter<int>("maxEMe");
201  maxEMeta = maxHDetas[2];
202  respFactorEM = pset.getParameter<double>("respFactorEM");
203  eGridEM = pset.getParameter<vec1>("eGridEM");
204 
205  // e-gamma mean response and sigma in HF
206  vec1 _meanEM = pset.getParameter<vec1>("meanEM");
207  vec1 _sigmaEM = pset.getParameter<vec1>("sigmaEM");
208 
209  //fill in 2D vectors (w/ correction factor applied)
210  meanEM = vec2(maxEMe, vec1(maxEMeta, 0));
211  sigmaEM = vec2(maxEMe, vec1(maxEMeta, 0));
212  for (int i = 0; i < maxEMe; i++) {
213  for (int j = 0; j < maxEMeta; j++) {
214  meanEM[i][j] = respFactorEM * _meanEM[i * maxEMeta + j];
215  sigmaEM[i][j] = respFactorEM * _sigmaEM[i * maxEMeta + j];
216  }
217  }
218 
219  // HF correction for SL
220  //---------------------
221  maxEta = pset.getParameter<int>("maxEta");
222  maxEne = pset.getParameter<int>("maxEne");
223  energyHF = pset.getParameter<vec1>("energyHF");
224  vec1 _corrHFgEm = pset.getParameter<vec1>("corrHFgEm");
225  vec1 _corrHFgHad = pset.getParameter<vec1>("corrHFgHad");
226  vec1 _corrHFhEm = pset.getParameter<vec1>("corrHFhEm");
227  vec1 _corrHFhHad = pset.getParameter<vec1>("corrHFhHad");
228  corrHFem = vec1(maxEta, 0);
229  corrHFhad = vec1(maxEta, 0);
230 
231  // initialize 2D vector corrHFgEm[energy][eta]
232  corrHFgEm = vec2(maxEne, vec1(maxEta, 0));
233  corrHFgHad = vec2(maxEne, vec1(maxEta, 0));
234  corrHFhEm = vec2(maxEne, vec1(maxEta, 0));
235  corrHFhHad = vec2(maxEne, vec1(maxEta, 0));
236  // Fill
237  for (int i = 0; i < maxEne; i++) {
238  for (int j = 0; j < maxEta; j++) {
239  corrHFgEm[i][j] = _corrHFgEm[i * maxEta + j];
240  corrHFgHad[i][j] = _corrHFgHad[i * maxEta + j];
241  corrHFhEm[i][j] = _corrHFhEm[i * maxEta + j];
242  corrHFhHad[i][j] = _corrHFhHad[i * maxEta + j];
243  }
244  }
245 }
246 
247 double HCALResponse::getMIPfraction(double energy, double eta) {
248  int ieta = abs((int)(eta / etaStep));
249  int ie = -1;
250  //check eta and det
251  int det = getDet(ieta);
252  int deta = ieta - HDeta[det];
253  if (deta >= maxHDetas[det])
254  deta = maxHDetas[det] - 1;
255  else if (deta < 0)
256  deta = 0;
257  //find energy range
258  for (int i = 0; i < maxHDe[det]; i++) {
259  if (energy < eGridHD[det][i]) {
260  if (i == 0)
261  return mipfraction[det][0][deta]; // less than minimal - the first value is used instead of extrapolating
262  else
263  ie = i - 1;
264  break;
265  }
266  }
267  if (ie == -1)
268  return mipfraction[det][maxHDe[det] - 1]
269  [deta]; // more than maximal - the last value is used instead of extrapolating
270  double y1, y2;
271  double x1 = eGridHD[det][ie];
272  double x2 = eGridHD[det][ie + 1];
273  y1 = mipfraction[det][ie][deta];
274  y2 = mipfraction[det][ie + 1][deta];
275  double mean = 0;
276  mean = (y1 * (x2 - energy) + y2 * (energy - x1)) / (x2 - x1);
277  return mean;
278 }
279 
281  int _mip, double energy, double eta, int partype, RandomEngineAndDistribution const* random) {
282  int ieta = abs((int)(eta / etaStep));
283  int ie = -1;
284 
285  int mip;
286  if (usemip)
287  mip = _mip;
288  else
289  mip = 2; //ignore mip, use only overall (mip + nomip) parameters
290 
291  double mean = 0;
292 
293  // e/gamma in HF
294  if (partype == 0) {
295  //check eta
296  ieta -= HDeta[2]; // HF starts at ieta=30 till ieta=51
297  // but resp.vector from index=0 through 20
298  if (ieta >= maxEMeta)
299  ieta = maxEMeta - 1;
300  else if (ieta < 0)
301  ieta = 0;
302 
303  //find energy range
304  for (int i = 0; i < maxEMe; i++) {
305  if (energy < eGridEM[i]) {
306  if (i == 0)
307  ie = 0; // less than minimal - back extrapolation with the 1st interval
308  else
309  ie = i - 1;
310  break;
311  }
312  }
313  if (ie == -1)
314  ie = maxEMe - 2; // more than maximum - extrapolation with last interval
315 
316  //do smearing
317  mean = interEM(energy, ie, ieta, random);
318  }
319 
320  // hadrons
321  else if (partype == 1) {
322  //check eta and det
323  int det = getDet(ieta);
324  int deta = ieta - HDeta[det];
325  if (deta >= maxHDetas[det])
326  deta = maxHDetas[det] - 1;
327  else if (deta < 0)
328  deta = 0;
329 
330  //find energy range
331  for (int i = 0; i < maxHDe[det]; i++) {
332  if (energy < eGridHD[det][i]) {
333  if (i == 0)
334  ie = 0; // less than minimal - back extrapolation with the 1st interval
335  else
336  ie = i - 1;
337  break;
338  }
339  }
340  if (ie == -1)
341  ie = maxHDe[det] - 2; // more than maximum - extrapolation with last interval
342 
343  //different energy smearing for low energy hadrons in HF
344  if (det == 2 && energy < 20 && deta > 5) {
345  for (int i = 0; i < maxHDe[3]; i++) {
346  if (energy < eGridHD[3][i]) {
347  if (i == 0)
348  ie = 0; // less than minimal - back extrapolation with the 1st interval
349  else
350  ie = i - 1;
351  break;
352  }
353  }
354  }
355  //do smearing
356  mean = interHD(mip, energy, ie, deta, det, random);
357  }
358 
359  // muons
360  else if (partype == 2) {
361  //check eta
362  ieta = maxMUeta;
363  for (int i = 0; i < maxMUeta; i++) {
364  if (fabs(eta) < etaGridMU[i]) {
365  ieta = i;
366  break;
367  }
368  }
369  if (ieta < 0)
370  ieta = 0;
371 
372  if (ieta < maxMUeta) { // HB-HE
373  //find energy range
374  for (int i = 0; i < maxMUe; i++) {
375  if (energy < eGridMU[i]) {
376  if (i == 0)
377  ie = 0; // less than minimal - back extrapolation with the 1st interval
378  else
379  ie = i - 1;
380  break;
381  }
382  }
383  if (ie == -1)
384  ie = maxMUe - 2; // more than maximum - extrapolation with last interval
385 
386  //do smearing
387  mean = interMU(energy, ie, ieta, random);
388  if (mean > energy)
389  mean = energy;
390  }
391  }
392 
393  // debugging
394  if (debug) {
395  // cout.width(6);
396  LogInfo("FastCalorimetry") << std::endl
397  << " HCALResponse::responseHCAL, partype = " << partype << " E, eta = " << energy << " "
398  << eta << " mean = " << mean << std::endl;
399  }
400 
401  return mean;
402 }
403 
404 double HCALResponse::interMU(double e, int ie, int ieta, RandomEngineAndDistribution const* random) {
405  double x = random->flatShoot();
406 
407  int bin1 = maxMUbin;
408  for (int i = 0; i < maxMUbin; i++) {
409  if (x > responseMU[ie][ieta][i]) {
410  bin1 = i - 1;
411  break;
412  }
413  }
414  int bin2 = maxMUbin;
415  for (int i = 0; i < maxMUbin; i++) {
416  if (x > responseMU[ie + 1][ieta][i]) {
417  bin2 = i - 1;
418  break;
419  }
420  }
421 
422  double x1 = eGridMU[ie];
423  double x2 = eGridMU[ie + 1];
424  double y1 = (bin1 + random->flatShoot()) * muStep;
425  double y2 = (bin2 + random->flatShoot()) * muStep;
426 
427  if (debug) {
428  // cout.width(6);
429  LogInfo("FastCalorimetry") << std::endl
430  << " HCALResponse::interMU " << std::endl
431  << " x, x1-x2, y1-y2 = " << e << ", " << x1 << "-" << x2 << " " << y1 << "-" << y2
432  << std::endl;
433  }
434 
435  //linear interpolation
436  double mean = (y1 * (x2 - e) + y2 * (e - x1)) / (x2 - x1);
437 
438  if (debug) {
439  //cout.width(6);
440  LogInfo("FastCalorimetry") << std::endl
441  << " HCALResponse::interMU " << std::endl
442  << " e, ie, ieta = " << e << " " << ie << " " << ieta << std::endl
443  << " response = " << mean << std::endl;
444  }
445 
446  return mean;
447 }
448 
449 double HCALResponse::interHD(int mip, double e, int ie, int ieta, int det, RandomEngineAndDistribution const* random) {
450  double x1, x2;
451  double y1, y2;
452  if (det == 2)
453  mip = 2; //ignore mip status for HF
454  double mean = 0;
455  vec1 pars(nPar, 0);
456 
457  // for ieta < 5 there is overlap between HE and HF, and measurement comes from HE
458  if (det == 2 && ieta > 5 && e < 20) {
459  for (int p = 0; p < 4; p++) {
460  y1 = PoissonParameters[p][ie][ieta];
461  y2 = PoissonParameters[p][ie + 1][ieta];
462  if (e > 5) {
463  x1 = eGridHD[det + 1][ie];
464  x2 = eGridHD[det + 1][ie + 1];
465  pars[p] = (y1 * (x2 - e) + y2 * (e - x1)) / (x2 - x1);
466  } else
467  pars[p] = y1;
468  }
469  mean =
470  random->poissonShoot((int(PoissonShootNoNegative(pars[0], pars[1], random)) +
471  (int(PoissonShootNoNegative(pars[2], pars[3], random))) / 4 + random->flatShoot() / 4) *
472  6) /
473  (0.3755 * 6);
474  }
475 
476  else {
477  x1 = eGridHD[det][ie];
478  x2 = eGridHD[det][ie + 1];
479 
480  //calculate all parameters
481  for (int p = 0; p < nPar; p++) {
482  y1 = parameters[p][mip][det][ie][ieta];
483  y2 = parameters[p][mip][det][ie + 1][ieta];
484 
485  //par-specific checks
486  double custom = 0;
487  bool use_custom = false;
488 
489  //do not let mu or sigma get extrapolated below zero for low energies
490  //especially important for HF since extrapolation is used for E < 15 GeV
491  if ((p == 0 || p == 1) && e < x1) {
492  double tmp = (y1 * x2 - y2 * x1) / (x2 - x1); //extrapolate down to e=0
493  if (tmp < 0) { //require mu,sigma > 0 for E > 0
494  custom = y1 * e / x1;
495  use_custom = true;
496  }
497  }
498  //tail parameters have lower bounds - never extrapolate down
499  else if ((p == 2 || p == 3 || p == 4 || p == 5)) {
500  if (e < x1 && y1 < y2) {
501  custom = y1;
502  use_custom = true;
503  } else if (e > x2 && y2 < y1) {
504  custom = y2;
505  use_custom = true;
506  }
507  }
508 
509  //linear interpolation
510  if (use_custom)
511  pars[p] = custom;
512  else
513  pars[p] = (y1 * (x2 - e) + y2 * (e - x1)) / (x2 - x1);
514  }
515 
516  //random smearing
517  if (nPar == 6)
518  mean = cballShootNoNegative(pars[0], pars[1], pars[2], pars[3], pars[4], pars[5], random);
519  else if (nPar == 2)
520  mean = gaussShootNoNegative(pars[0], pars[1], random); //gaussian fallback
521  }
522  return mean;
523 }
524 
525 double HCALResponse::interEM(double e, int ie, int ieta, RandomEngineAndDistribution const* random) {
526  double y1 = meanEM[ie][ieta];
527  double y2 = meanEM[ie + 1][ieta];
528  double x1 = eGridEM[ie];
529  double x2 = eGridEM[ie + 1];
530 
531  if (debug) {
532  // cout.width(6);
533  LogInfo("FastCalorimetry") << std::endl
534  << " HCALResponse::interEM mean " << std::endl
535  << " x, x1-x2, y1-y2 = " << e << ", " << x1 << "-" << x2 << " " << y1 << "-" << y2
536  << std::endl;
537  }
538 
539  //linear interpolation
540  double mean = (y1 * (x2 - e) + y2 * (e - x1)) / (x2 - x1);
541 
542  y1 = sigmaEM[ie][ieta];
543  y2 = sigmaEM[ie + 1][ieta];
544 
545  if (debug) {
546  // cout.width(6);
547  LogInfo("FastCalorimetry") << std::endl
548  << " HCALResponse::interEM sigma" << std::endl
549  << " x, x1-x2, y1-y2 = " << e << ", " << x1 << "-" << x2 << " " << y1 << "-" << y2
550  << std::endl;
551  }
552 
553  //linear interpolation
554  double sigma = (y1 * (x2 - e) + y2 * (e - x1)) / (x2 - x1);
555 
556  //random smearing
557  double rndm = gaussShootNoNegative(mean, sigma, random);
558 
559  return rndm;
560 }
561 
562 // Old parameterization of the calo response to hadrons
564  //response
565  double s = eResponseScale[hit];
566  double n = eResponseExponent;
567  double p = eResponsePlateau[hit];
568  double c = eResponseCoefficient;
569 
570  double response = e * p / (1 + c * exp(n * log(s / e)));
571 
572  if (response < 0.)
573  response = 0.;
574 
575  //resolution
576  double resolution;
577  if (hit == hcforward)
578  resolution =
579  e * sqrt(RespPar[VFCAL][1][0] * RespPar[VFCAL][1][0] / e + RespPar[VFCAL][1][1] * RespPar[VFCAL][1][1]);
580  else
581  resolution =
582  e * sqrt(RespPar[HCAL][hit][0] * RespPar[HCAL][hit][0] / (e) + RespPar[HCAL][hit][1] * RespPar[HCAL][hit][1]);
583 
584  //random smearing
585  double rndm = gaussShootNoNegative(response, resolution, random);
586 
587  return rndm;
588 }
589 
590 //find subdet and eta offset
592  int d;
593  for (d = 0; d < 2; d++) {
594  if (ieta < HDeta[d + 1]) {
595  break;
596  }
597  }
598  return d;
599 }
600 
601 // Remove (most) hits with negative energies
602 double HCALResponse::gaussShootNoNegative(double e, double sigma, RandomEngineAndDistribution const* random) {
603  double out = random->gaussShoot(e, sigma);
604  if (e >= 0.) {
605  while (out < 0.)
606  out = random->gaussShoot(e, sigma);
607  }
608  //else give up on re-trying, otherwise too much time can be lost before emeas comes out positive
609 
610  return out;
611 }
612 
613 // Remove (most) hits with negative energies
615  double mu, double sigma, double aL, double nL, double aR, double nR, RandomEngineAndDistribution const* random) {
616  double out = cball.shoot(mu, sigma, aL, nL, aR, nR, random);
617  if (mu >= 0.) {
618  while (out < 0.)
619  out = cball.shoot(mu, sigma, aL, nL, aR, nR, random);
620  }
621  //else give up on re-trying, otherwise too much time can be lost before emeas comes out positive
622 
623  return out;
624 }
625 double HCALResponse::PoissonShootNoNegative(double e, double sigma, RandomEngineAndDistribution const* random) {
626  double out = -1;
627  while (out < 0.) {
628  out = random->poissonShoot(e);
629  out = out + sigma;
630  }
631  return out;
632 }
633 
634 void HCALResponse::correctHF(double ee, int type) {
635  int jmin = 0;
636  for (int i = 0; i < maxEne; i++) {
637  if (ee >= energyHF[i])
638  jmin = i;
639  }
640 
641  double x1, x2;
642  double y1em, y2em;
643  double y1had, y2had;
644  for (int i = 0; i < maxEta; ++i) {
645  if (ee < energyHF[0]) {
646  if (abs(type) == 11 || abs(type) == 22) {
647  corrHFem[i] = corrHFgEm[0][i];
648  corrHFhad[i] = corrHFgHad[0][i];
649  } else {
650  corrHFem[i] = corrHFhEm[0][i];
651  corrHFhad[i] = corrHFhHad[0][i];
652  }
653  } else if (jmin >= maxEne - 1) {
654  if (abs(type) == 11 || abs(type) == 22) {
655  corrHFem[i] = corrHFgEm[maxEta][i];
656  corrHFhad[i] = corrHFgHad[maxEta][i];
657  } else {
658  corrHFem[i] = corrHFhEm[maxEta][i];
659  corrHFhad[i] = corrHFhHad[maxEta][i];
660  }
661  } else {
662  x1 = energyHF[jmin];
663  x2 = energyHF[jmin + 1];
664  if (abs(type) == 11 || abs(type) == 22) {
665  y1em = corrHFgEm[jmin][i];
666  y2em = corrHFgEm[jmin + 1][i];
667  y1had = corrHFgHad[jmin][i];
668  y2had = corrHFgHad[jmin + 1][i];
669  } else {
670  y1em = corrHFhEm[jmin][i];
671  y2em = corrHFhEm[jmin + 1][i];
672  y1had = corrHFhHad[jmin][i];
673  y2had = corrHFhHad[jmin + 1][i];
674  }
675  corrHFem[i] = y1em + (ee - x1) * ((y2em - y1em) / (x2 - x1));
676  corrHFhad[i] = y1had + (ee - x1) * ((y2had - y1had) / (x2 - x1));
677  }
678  }
679 }
HCALResponse::gaussShootNoNegative
double gaussShootNoNegative(double e, double sigma, RandomEngineAndDistribution const *)
Definition: HCALResponse.cc:602
HCALResponse::cballShootNoNegative
double cballShootNoNegative(double mu, double sigma, double aL, double nL, double aR, double nR, RandomEngineAndDistribution const *)
Definition: HCALResponse.cc:614
mps_fire.i
i
Definition: mps_fire.py:355
vec5
std::vector< vec4 > vec5
Definition: HCALResponse.h:19
HCALResponse::getHCALEnergyResponse
double getHCALEnergyResponse(double e, int hit, RandomEngineAndDistribution const *)
Definition: HCALResponse.cc:563
HcalResponse_cfi.corrHFhEm
corrHFhEm
Definition: HcalResponse_cfi.py:1181
HcalResponse_cfi.maxEMe
maxEMe
Definition: HcalResponse_cfi.py:1061
MessageLogger.h
vec3
std::vector< vec2 > vec3
Definition: HCALResponse.h:17
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
HcalResponse_cfi.maxMUbin
maxMUbin
Definition: HcalResponse_cfi.py:1020
HcalResponse_cfi.corrHFhHad
corrHFhHad
Definition: HcalResponse_cfi.py:1229
HCALResponse::interHD
double interHD(int mip, double e, int ie, int ieta, int det, RandomEngineAndDistribution const *)
Definition: HCALResponse.cc:449
HcalResponse_cfi.maxEne
maxEne
Definition: HcalResponse_cfi.py:1083
HcalResponse_cfi.eResponseCoefficient
eResponseCoefficient
Definition: HcalResponse_cfi.py:1279
vec1
std::vector< double > vec1
Definition: HCALResponse.h:15
HCALResponse::interEM
double interEM(double e, int ie, int ieta, RandomEngineAndDistribution const *)
Definition: HCALResponse.cc:525
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
edm
HLT enums.
Definition: AlignableModifier.h:19
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
HCALResponse::interMU
double interMU(double e, int ie, int ieta, RandomEngineAndDistribution const *)
Definition: HCALResponse.cc:404
edm::LogInfo
Definition: MessageLogger.h:254
vec4
std::vector< vec3 > vec4
Definition: HCALResponse.h:18
hcforward
Definition: HCALResponse.h:20
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
HCALResponse::getDet
int getDet(int ieta)
Definition: HCALResponse.cc:591
vec2
std::vector< vec1 > vec2
Definition: HCALResponse.h:16
HcalResponse_cfi.corrHFgHad
corrHFgHad
Definition: HcalResponse_cfi.py:1133
RandomEngineAndDistribution.h
parameters
parameters
Definition: BeamSpot_PayloadInspector.cc:14
HcalResponse_cfi.barrelMUeta
barrelMUeta
Definition: HcalResponse_cfi.py:1018
HcalResponse_cfi.nPar
nPar
Definition: HcalResponse_cfi.py:33
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
alignCSCRings.s
s
Definition: alignCSCRings.py:92
testProducerWithPsetDescEmpty_cfi.y1
y1
Definition: testProducerWithPsetDescEmpty_cfi.py:29
debug
#define debug
Definition: HDRShower.cc:19
HcalResponse_cfi.muStep
muStep
Definition: HcalResponse_cfi.py:1015
PVValHelper::eta
Definition: PVValidationHelpers.h:69
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
maxEta
double maxEta
Definition: PFJetBenchmarkAnalyzer.cc:76
L1TObjectsTimingClient_cff.resolution
resolution
Definition: L1TObjectsTimingClient_cff.py:52
HCALResponse::PoissonShootNoNegative
double PoissonShootNoNegative(double e, double sigma, RandomEngineAndDistribution const *)
Definition: HCALResponse.cc:625
HcalResponse_cfi.eGridMU
eGridMU
Definition: HcalResponse_cfi.py:1021
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
HcalResponse_cfi.etaStep
etaStep
Definition: HcalResponse_cfi.py:21
dqmdumpme.k
k
Definition: dqmdumpme.py:60
HCAL
Definition: HCAL.py:1
HCAL
Definition: HCALResponse.h:21
unpackData-CaloStage2.pname
pname
Definition: unpackData-CaloStage2.py:76
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
testProducerWithPsetDescEmpty_cfi.y2
y2
Definition: testProducerWithPsetDescEmpty_cfi.py:30
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
edm::ParameterSet
Definition: ParameterSet.h:36
HCALResponse::responseHCAL
double responseHCAL(int _mip, double energy, double eta, int partype, RandomEngineAndDistribution const *)
Definition: HCALResponse.cc:280
HcalResponse_cfi.usemip
usemip
Definition: HcalResponse_cfi.py:18
HCALResponse::getMIPfraction
double getMIPfraction(double energy, double eta)
Definition: HCALResponse.cc:247
HCALResponse.h
HcalResponse_cfi.energyHF
energyHF
Definition: HcalResponse_cfi.py:1084
HcalResponse_cfi.eGridEM
eGridEM
Definition: HcalResponse_cfi.py:1063
HcalResponse_cfi.maxMUeta
maxMUeta
Definition: HcalResponse_cfi.py:1017
HcalResponse_cfi.eResponseExponent
eResponseExponent
Definition: HcalResponse_cfi.py:1287
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
RandomEngineAndDistribution::flatShoot
double flatShoot(double xmin=0.0, double xmax=1.0) const
Definition: RandomEngineAndDistribution.h:27
HcalResponse_cfi.corrHFgEm
corrHFgEm
Definition: HcalResponse_cfi.py:1085
HCALResponse::correctHF
void correctHF(double e, int type)
Definition: HCALResponse.cc:634
type
type
Definition: HCALResponse.h:21
HCALResponse::HCALResponse
HCALResponse(const edm::ParameterSet &pset)
Definition: HCALResponse.cc:18
VFCAL
Definition: HCALResponse.h:21
HcalResponse_cfi.maxMUe
maxMUe
Definition: HcalResponse_cfi.py:1016
HcalResponse_cfi.meanEM
meanEM
Definition: HcalResponse_cfi.py:1064
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
ztail.d
d
Definition: ztail.py:151
HcalResponse_cfi.parNames
parNames
Definition: HcalResponse_cfi.py:34
HcalResponse_cfi.etaGridMU
etaGridMU
Definition: HcalResponse_cfi.py:1022
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
HcalResponse_cfi.sigmaEM
sigmaEM
Definition: HcalResponse_cfi.py:1072
RandomEngineAndDistribution::gaussShoot
double gaussShoot(double mean=0.0, double sigma=1.0) const
Definition: RandomEngineAndDistribution.h:29
HLT_2018_cff.fraction
fraction
Definition: HLT_2018_cff.py:51317
DoubleCrystalBallGenerator.h
RandomEngineAndDistribution::poissonShoot
unsigned int poissonShoot(double mean) const
Definition: RandomEngineAndDistribution.h:33
hit
Definition: SiStripHitEffFromCalibTree.cc:88
HcalResponse_cfi.respFactorEM
respFactorEM
Definition: HcalResponse_cfi.py:1062
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
HcalResponse_cfi.endcapMUeta
endcapMUeta
Definition: HcalResponse_cfi.py:1019
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
RandomEngineAndDistribution
Definition: RandomEngineAndDistribution.h:18