7 #include "CLHEP/Random/RandFlat.h"
8 #include "CLHEP/Random/RandGauss.h"
20 #include "TMatrixDSym.h"
21 #include "TMatrixDSymEigen.h"
30 "PreSamplerB"_FCShash,
"EMB1"_FCShash,
"EMB2"_FCShash,
31 "EMB3"_FCShash,
"PreSamplerE"_FCShash,
"EME1"_FCShash,
32 "EME2"_FCShash,
"EME3"_FCShash,
"HEC0"_FCShash,
33 "HEC1"_FCShash,
"HEC2"_FCShash,
"HEC3"_FCShash,
34 "TileBar0"_FCShash,
"TileBar1"_FCShash,
"TileBar2"_FCShash,
35 "TileGap1"_FCShash,
"TileGap2"_FCShash,
"TileGap3"_FCShash,
36 "TileExt0"_FCShash,
"TileExt1"_FCShash,
"TileExt2"_FCShash,
37 "FCAL0"_FCShash,
"FCAL1"_FCShash,
"FCAL2"_FCShash};
39 const std::uint32_t TFCSVoxelHistoLateralCovarianceFluctuations::
41 "PreSamplerB_geo"_FCShash,
"EMB1_geo"_FCShash,
42 "EMB2_geo"_FCShash,
"EMB3_geo"_FCShash,
43 "PreSamplerE_geo"_FCShash,
"EME1_geo"_FCShash,
44 "EME2_geo"_FCShash,
"EME3_geo"_FCShash,
45 "HEC0_geo"_FCShash,
"HEC1_geo"_FCShash,
46 "HEC2_geo"_FCShash,
"HEC3_geo"_FCShash,
47 "TileBar0_geo"_FCShash,
"TileBar1_geo"_FCShash,
48 "TileBar2_geo"_FCShash,
"TileGap1_geo"_FCShash,
49 "TileGap2_geo"_FCShash,
"TileGap3_geo"_FCShash,
50 "TileExt0_geo"_FCShash,
"TileExt1_geo"_FCShash,
51 "TileExt2_geo"_FCShash,
"FCAL0_geo"_FCShash,
52 "FCAL1_geo"_FCShash,
"FCAL2_geo"_FCShash};
75 TH2 *temp =
dynamic_cast<TH2 *
>(
76 inputfile->Get(Form(
"voxel_template_cs%d_pca%d", cs,
bin)));
85 while (
inputfile->Get(Form(
"parMeans_cs%d_pca%d", cs,
bin))) {
87 TMatrixD EigenVectors;
89 std::vector<std::vector<TFCS1DFunction *>>
transform;
91 std::string
label = Form(
"_cs%d_pca%d", cs,
bin);
103 parMeans = *
dynamic_cast<TVectorT<double> *
>(
obj);
111 TMatrixTSym<double>
covMatrix = *
dynamic_cast<TMatrixTSym<double> *
>(
obj);
112 TMatrixDSymEigen eigenvariances = TMatrixDSymEigen(
covMatrix);
113 EigenVectors.ResizeTo(eigenvariances.GetEigenVectors());
114 EigenVectors = eigenvariances.GetEigenVectors();
117 EigenValues.ResizeTo(eigenvariances.GetEigenValues());
118 EigenValues = eigenvariances.GetEigenValues();
123 eigenvariances.GetEigenValues().Print();
124 eigenvariances.GetEigenVectors().Print();
130 EigenVectors.Print();
161 int Ebin = simulstate.
Ebin();
164 genPars.ResizeTo(nPars);
167 for (
int iPar = 0; iPar < nPars; iPar++) {
172 <<
") on iPar = " << iPar);
175 genPars[iPar] = CLHEP::RandGauss::shoot(simulstate.
randomEngine(),
176 rotParMeans[iPar], sqrt(variance));
178 <<
" rotParMeans[iPar]=" << rotParMeans[iPar]
179 <<
" sqrt(variance)=" << sqrt(variance));
199 int Ebin = simulstate.
Ebin();
203 weightvec =
static_cast<weight_t *
>(
211 voxel_temp =
static_cast<TH2 *
>(
238 TVectorD genPars(
m_parMeans[Ebin - 1].GetNrows());
249 (TMath::Erf(genPars[
count] * 2.0 / TMath::Pi()) + 1) / 2.0;
252 double orig_val =
m_transform[Ebin - 1][
x][
y]->rnd_to_fct(cdf_val);
255 (*weightvec)[
x][
y] = orig_val;
259 <<
" orig_val=" << orig_val);
270 ATH_MSG_DEBUG(
"simulstate after storing weight " << weightvec
283 const double center_r = hit.
center_r();
284 const double center_z = hit.
center_z();
289 weightvec =
static_cast<weight_t *
>(
293 ATH_MSG_ERROR(
"Weights not stored in simulstate for calosample=" << cs);
297 TH2 *voxel_template =
nullptr;
301 if (!voxel_template) {
303 "Voxel geometry not stored in simulstate for calosample=" << cs);
337 float deta_hit_minus_extrapol = hit.
eta() - center_eta;
342 deta_hit_minus_extrapol = -deta_hit_minus_extrapol;
344 float phi_dist2r = 1.0;
345 float dist000 = TMath::Sqrt(center_r * center_r + center_z * center_z);
346 float eta_jakobi = TMath::Abs(2.0 * TMath::Exp(-hit.
eta()) /
347 (1.0 + TMath::Exp(-2 * hit.
eta())));
349 float deta_hit_minus_extrapol_mm =
350 deta_hit_minus_extrapol * eta_jakobi * dist000;
351 float dphi_hit_minus_extrapol_mm =
352 dphi_hit_minus_extrapol * center_r * phi_dist2r;
355 TMath::ATan2(dphi_hit_minus_extrapol_mm, deta_hit_minus_extrapol_mm);
357 TMath::Sqrt(dphi_hit_minus_extrapol_mm * dphi_hit_minus_extrapol_mm +
358 deta_hit_minus_extrapol_mm * deta_hit_minus_extrapol_mm);
361 int iy = voxel_template->GetYaxis()->FindBin(radius_mm) - 1;
368 ix = voxel_template->GetXaxis()->FindBin(2 * TMath::Pi() -
372 ix = voxel_template->GetXaxis()->FindBin(alpha_mm) - 1;
375 const int sizex = (*weightvec).size();
378 if (ix >= 0 && ix < sizex) {
379 const int sizey = (*weightvec)[ix].size();
380 if (iy >= 0 && iy < sizey) {
381 weight = (*weightvec)[ix][iy];
388 <<
", r = " << center_r <<
", ix = " << ix
389 <<
", iy = " << iy <<
", weight = " <<
weight);