13 #include "StHbtCorrFctnDirectYlm.h"
16 #include "gsl/gsl_blas.h"
17 #include "gsl/gsl_linalg.h"
18 #include "gsl/gsl_complex.h"
32 StHbtCorrFctnDirectYlm::StHbtCorrFctnDirectYlm(
const char* name,
int maxl,
int ibin = 30,
double vmin = 0.0,
double vmax = 0.3)
33 : cftnreal(0), cftnimag(0), covnum(0), covden(0), fR2factor(0),
34 mDoEMCIC(false), emcicP1P2T(NULL), emcicP1P2Z(NULL), emcicE1E2(NULL), emcicE1plusE2(NULL),
35 mName(name), mNbins(ibin), mkmin(vmin), mkmax(vmax),
36 mNormRadius(0.0), mNormBohr(0.0), mNormBinMin(0), mNormBinMax(0)
39 maxjm = (maxl + 1) * (maxl + 1);
42 factorials =
new double[( 4 * (maxl + 1) )];
45 for (
int iter = 1; iter < 4 * (maxl + 1); iter++) {
47 factorials[iter] = fac;
54 els =
new double[maxjm];
55 ems =
new double[maxjm];
56 elsi =
new int[maxjm];
57 emsi =
new int[maxjm];
74 numsreal =
new TH1D*[maxjm];
75 numsimag =
new TH1D*[maxjm];
76 densreal =
new TH1D*[maxjm];
77 densimag =
new TH1D*[maxjm];
80 for (
int ihist = 0; ihist < maxjm; ihist++) {
81 int em = emsi[ihist] < 0 ? elsi[ihist] - emsi[ihist] : emsi[ihist];
83 sprintf(bufname,
"NumReYlm%i%i%s", elsi[ihist], em, name);
84 numsreal[ihist] =
new TH1D(bufname, bufname, ibin, vmin, vmax);
85 sprintf(bufname,
"NumImYlm%i%i%s", elsi[ihist], em, name);
86 numsimag[ihist] =
new TH1D(bufname, bufname, ibin, vmin, vmax);
87 sprintf(bufname,
"DenReYlm%i%i%s", elsi[ihist], em, name);
88 densreal[ihist] =
new TH1D(bufname, bufname, ibin, vmin, vmax);
89 sprintf(bufname,
"DenImYlm%i%i%s", elsi[ihist], em, name);
90 densimag[ihist] =
new TH1D(bufname, bufname, ibin, vmin, vmax);
92 numsreal[ihist]->Sumw2();
93 numsimag[ihist]->Sumw2();
94 densreal[ihist]->Sumw2();
95 densimag[ihist]->Sumw2();
98 sprintf(bufname,
"BinCountNum%s", name);
99 binctn =
new TH1D(bufname, bufname, ibin, vmin, vmax);
101 sprintf(bufname,
"BinCountDen%s", name);
102 binctd =
new TH1D(bufname, bufname, ibin, vmin, vmax);
104 ylmbuffer =
new complex<double>[maxjm];
107 covmnum =
new double[maxjm * maxjm * 4 * ibin];
108 covmden =
new double[maxjm * maxjm * 4 * ibin];
112 void StHbtCorrFctnDirectYlm::DoEMCIC()
115 emcicP1P2T =
new TH1D*[maxjm];
116 emcicP1P2Z =
new TH1D*[maxjm];
117 emcicE1E2 =
new TH1D*[maxjm];
118 emcicE1plusE2 =
new TH1D*[maxjm];
120 for (
int ihist = 0; ihist < maxjm; ihist++) {
121 int em = emsi[ihist] < 0 ? elsi[ihist] - emsi[ihist] : emsi[ihist];
122 sprintf( bufname,
"emcicP1P2T%i%i%s", elsi[ihist], em, mName.c_str() );
123 emcicP1P2T[ihist] =
new TH1D(bufname, bufname, mNbins, mkmin, mkmax);
124 emcicP1P2T[ihist]->Sumw2();
125 sprintf( bufname,
"emcicP1P2Z%i%i%s", elsi[ihist], em, mName.c_str() );
126 emcicP1P2Z[ihist] =
new TH1D(bufname, bufname, mNbins, mkmin, mkmax);
127 emcicP1P2Z[ihist]->Sumw2();
128 sprintf( bufname,
"emcicE1E2%i%i%s", elsi[ihist], em, mName.c_str() );
129 emcicE1E2[ihist] =
new TH1D(bufname, bufname, mNbins, mkmin, mkmax);
130 emcicE1E2[ihist]->Sumw2();
131 sprintf( bufname,
"emcicE1plusE2%i%i%s", elsi[ihist], em, mName.c_str() );
132 emcicE1plusE2[ihist] =
new TH1D(bufname, bufname, mNbins, mkmin, mkmax);
133 emcicE1plusE2[ihist]->Sumw2();
138 StHbtCorrFctnDirectYlm::StHbtCorrFctnDirectYlm()
144 StHbtCorrFctnDirectYlm::~StHbtCorrFctnDirectYlm()
147 for (
int ihist = 0; ihist < maxjm; ihist++) {
148 if (numsreal[ihist])
delete numsreal[ihist];
149 if (numsimag[ihist])
delete numsimag[ihist];
150 if (densreal[ihist])
delete densreal[ihist];
151 if (densimag[ihist])
delete densimag[ihist];
152 if (cftnreal && cftnreal[ihist])
delete cftnreal[ihist];
153 if (cftnimag && cftnimag[ihist])
delete cftnimag[ihist];
155 delete emcicP1P2T[ihist];
156 delete emcicP1P2Z[ihist];
157 delete emcicE1E2[ihist];
158 delete emcicE1plusE2[ihist];
166 delete []emcicE1plusE2;
176 if (cftnreal)
delete []cftnreal;
177 if (cftnimag)
delete []cftnimag;
195 double StHbtCorrFctnDirectYlm::ClebschGordan(
double aJot1,
double aEm1,
double aJot2,
double aEm2,
double aJot,
double aEm)
202 maxt = lrint(aJot1 + aJot2 - aJot);
204 if (lrint(aJot1 - aEm1) < maxt) maxt = lrint(aJot1 - aEm1);
205 if (lrint(aJot2 + aEm2) < maxt) maxt = lrint(aJot2 + aEm2);
206 if (lrint( -(aJot - aJot2 + aEm1) ) > mint) mint = lrint( -(aJot - aJot2 + aEm1) );
207 if (lrint( -(aJot - aJot1 - aEm2) ) > mint) mint = lrint( -(aJot - aJot1 - aEm2) );
209 for (titer = mint; titer <= maxt; titer++) {
210 coef = TMath::Power(-1, titer);
211 coef *= TMath::Sqrt( (2 * aJot + 1) *
212 factorials[lrint(aJot1 + aEm1)] *
213 factorials[lrint(aJot1 - aEm1)] *
214 factorials[lrint(aJot2 + aEm2)] *
215 factorials[lrint(aJot2 - aEm2)] *
216 factorials[lrint(aJot + aEm)] *
217 factorials[lrint(aJot - aEm)] );
218 coef /= (factorials[titer] *
219 factorials[lrint(aJot1 + aJot2 - aJot - titer)] *
220 factorials[lrint(aJot1 - aEm1 - titer)] *
221 factorials[lrint(aJot2 + aEm2 - titer)] *
222 factorials[lrint(aJot - aJot2 + aEm1 + titer)] *
223 factorials[lrint(aJot - aJot1 - aEm2 + titer)]);
228 cgc *= DeltaJ(aJot1, aJot2, aJot);
234 double StHbtCorrFctnDirectYlm::DeltaJ(
double aJot1,
double aJot2,
double aJot)
236 if ( (aJot1 + aJot2 - aJot) < 0 ) {
240 if ( (aJot1 - aJot2 + aJot) < 0 ) {
244 if ( (-aJot1 + aJot2 + aJot) < 0 ) {
248 if ( (aJot1 + aJot2 + aJot + 1) < 0 ) {
252 double res = TMath::Sqrt(1.0 *
253 factorials[lrint(aJot1 + aJot2 - aJot)] *
254 factorials[lrint(aJot1 - aJot2 + aJot)] *
255 factorials[lrint(-aJot1 + aJot2 + aJot)] /
256 factorials[lrint(aJot1 + aJot2 + aJot + 1)]);
262 double StHbtCorrFctnDirectYlm::WignerSymbol(
double aJot1,
double aEm1,
double aJot2,
double aEm2,
double aJot,
double aEm)
264 if (lrint(aEm1 + aEm2 + aEm) != 0.0)
266 double cge = ClebschGordan(aJot1, aEm1, aJot2, aEm2, aJot, -aEm);
267 if (lrint( abs(aJot1 - aJot2 - aEm) ) % 2)
269 cge /= sqrt(2 * aJot + 1);
271 if (cge == -0.0) cge = 0.0;
277 void StHbtCorrFctnDirectYlm::GetMtilde(complex<double>* aMat,
double* aMTilde)
288 for (
int iz = 0; iz < GetMaxJM() * 2; iz++)
289 for (
int ip = 0; ip < GetMaxJM() * 2; ip++)
290 aMTilde[iz * GetMaxJM() * 2 + ip] = 0.0;
292 for (
int izero = 0; izero < GetMaxJM(); izero++) {
293 GetElEmForIndex(izero, &lzero, &mzero);
294 GetElEmForIndex(izero, &lzeroi, &mzeroi);
295 for (
int ibis = 0; ibis < GetMaxJM(); ibis++) {
296 GetElEmForIndex(ibis, &lbis, &mbis);
297 GetElEmForIndex(ibis, &lbisi, &mbisi);
298 complex<double> val = complex<double>(0.0, 0.0);
299 complex<double> mcomp[MAXJM];
300 for (
int iprim = 0; iprim < GetMaxJM(); iprim++) {
301 GetElEmForIndex(iprim, &lprim, &mprim);
302 GetElEmForIndex(iprim, &lprimi, &mprimi);
304 if (abs(mzeroi) % 2) mcomp[iprim] = complex<double>(-1.0, 0.0);
305 else mcomp[iprim] = complex<double>(1.0, 0.0);
308 mcomp[iprim] *= sqrt( (2 * lzero + 1) * (2 * lprim + 1) * (2 * lbis + 1) );
310 mcomp[iprim] *= WignerSymbol(lzero, 0, lprim, 0, lbis, 0);
312 mcomp[iprim] *= WignerSymbol(lzero, -mzero, lprim, mprim, lbis, mbis);
313 mcomp[iprim] *= aMat[iprim];
317 aMTilde[(izero * 2) * ( 2 * GetMaxJM() ) + (ibis * 2)] = real(val);
318 aMTilde[(izero * 2 + 1) * ( 2 * GetMaxJM() ) + (ibis * 2)] = imag(val);
319 if (imag(val) != 0.0)
320 aMTilde[(izero * 2) * ( 2 * GetMaxJM() ) + (ibis * 2 + 1)] = -imag(val);
322 aMTilde[(izero * 2) * ( 2 * GetMaxJM() ) + (ibis * 2 + 1)] = 0.0;
323 aMTilde[(izero * 2 + 1) * ( 2 * GetMaxJM() ) + (ibis * 2 + 1)] = real(val);
328 int StHbtCorrFctnDirectYlm::GetMaxJM()
331 void StHbtCorrFctnDirectYlm::GetElEmForIndex(
int aIndex,
double* aEl,
double* aEm)
337 void StHbtCorrFctnDirectYlm::GetElEmForIndex(
int aIndex,
int* aEl,
int* aEm)
343 int StHbtCorrFctnDirectYlm::GetBin(
int qbin,
int ilmzero,
int zeroimag,
int ilmprim,
int primimag)
345 return (qbin * GetMaxJM() * GetMaxJM() * 4 +
346 (ilmprim * 2 + primimag) * GetMaxJM() * 2 +
347 ilmzero * 2 + zeroimag);
351 void StHbtCorrFctnDirectYlm::AddRealPair(
const StHbtPair* aPair,
double weight)
353 double qout = aPair->dKOut();
354 double qside = aPair->dKSide();
355 double qlong = aPair->dKLong();
356 double kv = sqrt(qout * qout + qside * qside + qlong * qlong);
357 if (kv >= mkmax || kv < mkmin)
return;
358 int nqbin = binctn->GetXaxis()->FindFixBin(kv) - 1;
359 if (fR2factor) weight *= ( 1.0 / (kv * kv) );
361 StHbtYlm::YlmUpToL(elsi[GetMaxJM() - 1], qout, qside, qlong, ylmbuffer);
363 for (
int ilm = 0; ilm < GetMaxJM(); ilm++) {
364 if ( TMath::IsNaN(real(ylmbuffer[ilm]) * weight) )
return;
365 if ( TMath::IsNaN(imag(ylmbuffer[ilm]) * weight) )
return;
366 if ( ::isinf(real(ylmbuffer[ilm]) * weight) )
return;
367 if ( ::isinf(imag(ylmbuffer[ilm]) * weight) )
return;
369 if ( nqbin < binctn->GetNbinsX() )
370 for (
int ilmzero = 0; ilmzero < GetMaxJM(); ilmzero++)
371 for (
int ilmprim = 0; ilmprim < GetMaxJM(); ilmprim++) {
372 if ( TMath::IsNaN(real(ylmbuffer[ilmzero]) * real(ylmbuffer[ilmprim]) * weight * weight) )
return;
373 if ( TMath::IsNaN(real(ylmbuffer[ilmzero]) * -imag(ylmbuffer[ilmprim]) * weight * weight) )
return;
374 if ( TMath::IsNaN(imag(ylmbuffer[ilmzero]) * real(ylmbuffer[ilmprim]) * weight * weight) )
return;
375 if ( TMath::IsNaN(imag(ylmbuffer[ilmzero]) * -imag(ylmbuffer[ilmprim]) * weight * weight) )
return;
376 if ( ::isinf(real(ylmbuffer[ilmzero]) * real(ylmbuffer[ilmprim]) * weight * weight) )
return;
377 if ( ::isinf(real(ylmbuffer[ilmzero]) * -imag(ylmbuffer[ilmprim]) * weight * weight) )
return;
378 if ( ::isinf(imag(ylmbuffer[ilmzero]) * real(ylmbuffer[ilmprim]) * weight * weight) )
return;
379 if ( ::isinf(imag(ylmbuffer[ilmzero]) * -imag(ylmbuffer[ilmprim]) * weight * weight) )
return;
382 for (
int ilm = 0; ilm < GetMaxJM(); ilm++) {
383 numsreal[ilm]->Fill(kv, real(ylmbuffer[ilm]) * weight);
384 numsimag[ilm]->Fill(kv, -imag(ylmbuffer[ilm]) * weight);
385 binctn->Fill(kv, 1.0);
388 double p1p2t = sqrt( aPair->track1()->FourMomentum().px() * aPair->track1()->FourMomentum().py() + aPair->track2()->FourMomentum().px() * aPair->track2(
389 )->FourMomentum().py() );
390 double p1p2z = aPair->track1()->FourMomentum().pz() * aPair->track2()->FourMomentum().pz();
391 double e1e2 = aPair->track1()->FourMomentum().e() * aPair->track2()->FourMomentum().e();
392 double e1pluse2 = aPair->track1()->FourMomentum().e() + aPair->track2()->FourMomentum().e();
393 if ( !( ::isnan(p1p2t) || ::isnan(p1p2z) || ::isnan(e1e2) || ::isnan(e1pluse2) ||
394 ::isinf(p1p2t) || ::isinf(p1p2z) || ::isinf(e1e2) || ::isinf(e1pluse2) ) )
396 for (
int ilm = 0; ilm < GetMaxJM(); ilm++) {
397 emcicP1P2T[ilm]->Fill(kv, p1p2t);
398 emcicP1P2Z[ilm]->Fill(kv, p1p2z);
399 emcicE1plusE2[ilm]->Fill(kv, e1pluse2);
400 emcicE1E2[ilm]->Fill(kv, e1e2);
408 if ( nqbin < binctn->GetNbinsX() )
409 for (
int ilmzero = 0; ilmzero < GetMaxJM(); ilmzero++)
410 for (
int ilmprim = 0; ilmprim < GetMaxJM(); ilmprim++) {
411 covmnum[GetBin(nqbin, ilmzero, 0, ilmprim, 0)] += real(ylmbuffer[ilmzero]) * real(ylmbuffer[ilmprim]) * weight * weight;
412 covmnum[GetBin(nqbin, ilmzero, 0, ilmprim, 1)] += real(ylmbuffer[ilmzero]) * -imag(ylmbuffer[ilmprim]) * weight * weight;
413 covmnum[GetBin(nqbin, ilmzero, 1, ilmprim, 0)] += -imag(ylmbuffer[ilmzero]) * real(ylmbuffer[ilmprim]) * weight * weight;
414 covmnum[GetBin(nqbin, ilmzero, 1, ilmprim, 1)] += -imag(ylmbuffer[ilmzero]) * -imag(ylmbuffer[ilmprim]) * weight * weight;
419 void StHbtCorrFctnDirectYlm::AddMixedPair(
const StHbtPair* aPair,
double weight)
421 double qout = aPair->dKOut();
422 double qside = aPair->dKSide();
423 double qlong = aPair->dKLong();
424 double kv = sqrt(qout * qout + qside * qside + qlong * qlong);
425 if (kv >= mkmax || kv < mkmin)
return;
427 if (fR2factor) weight *= ( 1.0 / (kv * kv) );
429 StHbtYlm::YlmUpToL(elsi[GetMaxJM() - 1], qout, qside, qlong, ylmbuffer);
431 for (
int ilm = 0; ilm < GetMaxJM(); ilm++) {
432 if ( TMath::IsNaN(real(ylmbuffer[ilm]) * weight) )
return;
433 if ( TMath::IsNaN(imag(ylmbuffer[ilm]) * weight) )
return;
435 for (
int ilmzero = 0; ilmzero < GetMaxJM(); ilmzero++)
436 for (
int ilmprim = 0; ilmprim < GetMaxJM(); ilmprim++) {
437 if ( TMath::IsNaN( real(ylmbuffer[ilmzero]) * real(ylmbuffer[ilmprim]) ) )
return;
438 if ( TMath::IsNaN( real(ylmbuffer[ilmzero]) * -imag(ylmbuffer[ilmprim]) ) )
return;
439 if ( TMath::IsNaN( imag(ylmbuffer[ilmzero]) * real(ylmbuffer[ilmprim]) ) )
return;
440 if ( TMath::IsNaN( imag(ylmbuffer[ilmzero]) * -imag(ylmbuffer[ilmprim]) ) )
return;
442 for (
int ilm = 0; ilm < GetMaxJM(); ilm++) {
443 densreal[ilm]->Fill(kv, real(ylmbuffer[ilm]) * weight);
444 densimag[ilm]->Fill(kv, -imag(ylmbuffer[ilm]) * weight);
445 binctd->Fill(kv, 1.0);
449 int nqbin = binctn->GetXaxis()->FindFixBin(kv) - 1;
451 if ( nqbin < binctn->GetNbinsX() )
452 for (
int ilmzero = 0; ilmzero < GetMaxJM(); ilmzero++)
453 for (
int ilmprim = 0; ilmprim < GetMaxJM(); ilmprim++) {
454 covmden[GetBin(nqbin, ilmzero, 0, ilmprim, 0)] += real(ylmbuffer[ilmzero]) * real(ylmbuffer[ilmprim]);
455 covmden[GetBin(nqbin, ilmzero, 0, ilmprim, 1)] += real(ylmbuffer[ilmzero]) * -imag(ylmbuffer[ilmprim]);
456 covmden[GetBin(nqbin, ilmzero, 1, ilmprim, 0)] += -imag(ylmbuffer[ilmzero]) * real(ylmbuffer[ilmprim]);
457 covmden[GetBin(nqbin, ilmzero, 1, ilmprim, 1)] += -imag(ylmbuffer[ilmzero]) * -imag(ylmbuffer[ilmprim]);
462 void StHbtCorrFctnDirectYlm::Finish()
467 for (
int ilm = 0; ilm < maxjm; ilm++) {
468 numsreal[ilm]->Write();
469 numsimag[ilm]->Write();
470 densreal[ilm]->Write();
471 densimag[ilm]->Write();
472 if (cftnreal && cftnreal[ilm]) cftnreal[ilm]->Write();
473 if (cftnimag && cftnimag[ilm]) cftnimag[ilm]->Write();
475 emcicP1P2T[ilm]->Write();
476 emcicP1P2Z[ilm]->Write();
477 emcicE1E2[ilm]->Write();
478 emcicE1plusE2[ilm]->Write();
481 if (covnum) covnum->Write();
482 if (covden) covden->Write();
486 void StHbtCorrFctnDirectYlm::Write(TFile* rfile)
489 for (
int ilm = 0; ilm < maxjm; ilm++) {
490 numsreal[ilm]->Write();
491 numsimag[ilm]->Write();
492 densreal[ilm]->Write();
493 densimag[ilm]->Write();
494 if (cftnreal && cftnreal[ilm]) cftnreal[ilm]->Write();
495 if (cftnimag && cftnimag[ilm]) cftnimag[ilm]->Write();
497 emcicP1P2T[ilm]->Write();
498 emcicP1P2Z[ilm]->Write();
499 emcicE1E2[ilm]->Write();
500 emcicE1plusE2[ilm]->Write();
503 if (covnum) covnum->Write();
504 if (covden) covden->Write();
508 void StHbtCorrFctnDirectYlm::ReadFromFile(TFile* ifile)
515 for (
int ihist = 0; ihist < maxjm; ihist++) {
516 int em = emsi[ihist] < 0 ? elsi[ihist] - emsi[ihist] : emsi[ihist];
517 sprintf(bufname,
"NumReYlm%i%i%s", elsi[ihist], em, mName.c_str());
518 if (numsreal[ihist])
delete numsreal[ihist];
519 numsreal[ihist] =
new TH1D( *( (TH1D*) ifile->Get(bufname) ) );
521 sprintf(bufname,
"NumImYlm%i%i%s", elsi[ihist], em, mName.c_str());
522 if (numsimag[ihist])
delete numsimag[ihist];
523 numsimag[ihist] =
new TH1D( *( (TH1D*) ifile->Get(bufname) ) );
525 sprintf(bufname,
"DenReYlm%i%i%s", elsi[ihist], em, mName.c_str());
526 if (densreal[ihist])
delete densreal[ihist];
527 densreal[ihist] =
new TH1D( *( (TH1D*) ifile->Get(bufname) ) );
529 sprintf(bufname,
"DenImYlm%i%i%s", elsi[ihist], em, mName.c_str());
530 if (densimag[ihist])
delete densimag[ihist];
531 densimag[ihist] =
new TH1D( *( (TH1D*) ifile->Get(bufname) ) );
533 sprintf(bufname,
"CfnReYlm%i%i%s", elsi[ihist], em, mName.c_str());
534 string keyname(bufname);
535 if (ifile->FindKey( (keyname +
";*").c_str() ) ) ifile->Delete( (keyname +
";*").c_str() );
537 sprintf(bufname,
"CfnImYlm%i%i%s", elsi[ihist], em, mName.c_str());
538 keyname = string(bufname);
539 if (ifile->FindKey( (keyname +
";*").c_str() ) ) ifile->Delete( (keyname +
";*").c_str() );
542 if (covnum)
delete covnum;
543 sprintf(bufname,
"CovNum%s", mName.c_str());
544 covnum =
new TH3D ( *( (TH3D*) ifile->Get(bufname) ) );
546 if (covden)
delete covden;
547 sprintf(bufname,
"CovDen%s", mName.c_str() );
548 covden =
new TH3D ( *( (TH3D*) ifile->Get(bufname) ) );
550 if ( (covnum) && (covden) ) {
555 cout <<
"Creating fake covariance matrices" << endl;
557 for (
int ibin = 1; ibin <= numsreal[0]->GetNbinsX(); ibin++) {
558 double nent = numsreal[0]->GetEntries();
559 double nentd = densreal[0]->GetEntries();
560 for (
int ilmx = 0; ilmx < GetMaxJM(); ilmx++) {
561 for (
int ilmy = 0; ilmy < GetMaxJM(); ilmy++) {
562 double t1t2rr = numsreal[ilmx]->GetBinContent(ibin) * numsreal[ilmy]->GetBinContent(ibin) / nent / nent;
563 double t1t2ri = numsreal[ilmx]->GetBinContent(ibin) * numsimag[ilmy]->GetBinContent(ibin) / nent / nent;
564 double t1t2ir = numsimag[ilmx]->GetBinContent(ibin) * numsreal[ilmy]->GetBinContent(ibin) / nent / nent;
565 double t1t2ii = numsimag[ilmx]->GetBinContent(ibin) * numsimag[ilmy]->GetBinContent(ibin) / nent / nent;
567 covmnum[GetBin(ibin - 1, ilmx, 0, ilmy, 0)] = nent * (TMath::Power(numsreal[ilmx]->GetBinError(ibin) / nent, 2) * (nent - 1) + t1t2rr);
568 covmnum[GetBin(ibin - 1, ilmx, 0, ilmy, 1)] = nent * t1t2ri;
569 covmnum[GetBin(ibin - 1, ilmx, 1, ilmy, 0)] = nent * t1t2ir;
570 covmnum[GetBin(ibin - 1, ilmx, 1, ilmy, 1)] = nent * (TMath::Power(numsimag[ilmx]->GetBinError(ibin) / nent, 2) * (nent - 1) + t1t2rr);
573 covmnum[GetBin(ibin - 1, ilmx, 0, ilmy, 0)] = nent * t1t2rr;
574 covmnum[GetBin(ibin - 1, ilmx, 0, ilmy, 1)] = nent * t1t2ri;
575 covmnum[GetBin(ibin - 1, ilmx, 1, ilmy, 0)] = nent * t1t2ir;
576 covmnum[GetBin(ibin - 1, ilmx, 1, ilmy, 1)] = nent * t1t2ii;
578 t1t2rr = densreal[ilmx]->GetBinContent(ibin) * densreal[ilmy]->GetBinContent(ibin) / nentd / nentd;
579 t1t2ri = densreal[ilmx]->GetBinContent(ibin) * densimag[ilmy]->GetBinContent(ibin) / nentd / nentd;
580 t1t2ir = densimag[ilmx]->GetBinContent(ibin) * densreal[ilmy]->GetBinContent(ibin) / nentd / nentd;
581 t1t2ii = densimag[ilmx]->GetBinContent(ibin) * densimag[ilmy]->GetBinContent(ibin) / nentd / nentd;
583 covmden[GetBin(ibin - 1, ilmx, 0, ilmy, 0)] = nentd * t1t2rr;
584 covmden[GetBin(ibin - 1, ilmx, 0, ilmy, 1)] = nentd * t1t2ri;
585 covmden[GetBin(ibin - 1, ilmx, 1, ilmy, 0)] = nentd * t1t2ir;
586 covmden[GetBin(ibin - 1, ilmx, 1, ilmy, 1)] = nentd * t1t2ii;
597 for (
int ilm = 0; ilm < maxjm; ilm++) {
598 cftnreal[ilm]->Write();
599 cftnimag[ilm]->Write();
603 int StHbtCorrFctnDirectYlm::PackYlmVector(
double* invec,
double* outvec)
607 for (
int ilm = 0; ilm < GetMaxJM(); ilm++) {
608 GetElEmForIndex(ilm, &el, &em);
609 outvec[ioutcount++] = invec[ilm * 2];
610 if (em == 0)
continue;
611 outvec[ioutcount++] = invec[ilm * 2 + 1];
617 int StHbtCorrFctnDirectYlm::PackYlmMatrix(
double* inmat,
double* outmat)
625 for (
int ilm = 0; ilm < GetMaxJM(); ilm++) {
626 GetElEmForIndex(ilm, &elz, &emz);
628 if (emz == 0)
continue;
632 for (
int ilmz = 0; ilmz < GetMaxJM(); ilmz++) {
633 GetElEmForIndex(ilmz, &elz, &emz);
635 for (
int ilmp = 0; ilmp < GetMaxJM(); ilmp++) {
636 GetElEmForIndex(ilmp, &elp, &emp);
637 outmat[ioutcountz * finalsize + ioutcountp] = inmat[GetBin(0, ilmz, 0, ilmp, 0)];
639 if (emp == 0)
continue;
640 outmat[ioutcountz * finalsize + ioutcountp] = inmat[GetBin(0, ilmz, 0, ilmp, 1)];
645 if (emz == 0)
continue;
647 for (
int ilmp = 0; ilmp < GetMaxJM(); ilmp++) {
648 GetElEmForIndex(ilmp, &elp, &emp);
649 outmat[ioutcountz * finalsize + ioutcountp] = inmat[GetBin(0, ilmz, 1, ilmp, 0)];
651 if (emp == 0)
continue;
652 outmat[ioutcountz * finalsize + ioutcountp] = inmat[GetBin(0, ilmz, 1, ilmp, 1)];
661 void StHbtCorrFctnDirectYlm::PackCovariances()
665 sprintf(bufname,
"CovNum%s", numsreal[0]->GetName() + 10);
666 if (covnum)
delete covnum;
667 covnum =
new TH3D( bufname, bufname,
668 numsreal[0]->GetNbinsX(), numsreal[0]->GetXaxis()->GetXmin(), numsreal[0]->GetXaxis()->GetXmax(),
669 GetMaxJM() * 2, -0.5, GetMaxJM() * 2 - 0.5,
670 GetMaxJM() * 2, -0.5, GetMaxJM() * 2 - 0.5);
672 for (
int ibin = 1; ibin <= covnum->GetNbinsX(); ibin++)
673 for (
int ilmz = 0; ilmz < GetMaxJM() * 2; ilmz++)
674 for (
int ilmp = 0; ilmp < GetMaxJM() * 2; ilmp++)
675 covnum->SetBinContent(ibin, ilmz + 1, ilmp + 1, covmnum[GetBin(ibin - 1, ilmz / 2, ilmz % 2, ilmp / 2, ilmp % 2)]);
677 sprintf(bufname,
"CovDen%s", numsreal[0]->GetName() + 10);
678 if (covden)
delete covden;
679 covden =
new TH3D( bufname, bufname,
680 densreal[0]->GetNbinsX(), densreal[0]->GetXaxis()->GetXmin(), densreal[0]->GetXaxis()->GetXmax(),
681 GetMaxJM() * 2, -0.5, GetMaxJM() * 2 - 0.5,
682 GetMaxJM() * 2, -0.5, GetMaxJM() * 2 - 0.5);
684 for (
int ibin = 1; ibin <= covden->GetNbinsX(); ibin++)
685 for (
int ilmz = 0; ilmz < GetMaxJM() * 2; ilmz++)
686 for (
int ilmp = 0; ilmp < GetMaxJM() * 2; ilmp++)
687 covden->SetBinContent(ibin, ilmz + 1, ilmp + 1, covmden[GetBin(ibin - 1, ilmz / 2, ilmz % 2, ilmp / 2, ilmp % 2)]);
691 void StHbtCorrFctnDirectYlm::UnpackCovariances()
694 for (
int ibin = 1; ibin <= covnum->GetNbinsX(); ibin++)
695 for (
int ilmz = 0; ilmz < GetMaxJM() * 2; ilmz++)
696 for (
int ilmp = 0; ilmp < GetMaxJM() * 2; ilmp++)
697 covmnum[GetBin(ibin - 1, ilmz / 2, ilmz % 2, ilmp / 2, ilmp % 2)] = covnum->GetBinContent(ibin, ilmz + 1, ilmp + 1);
700 for (
int ibin = 1; ibin <= covden->GetNbinsX(); ibin++)
701 for (
int ilmz = 0; ilmz < GetMaxJM() * 2; ilmz++)
702 for (
int ilmp = 0; ilmp < GetMaxJM() * 2; ilmp++)
703 covmden[GetBin(ibin - 1, ilmz / 2, ilmz % 2, ilmp / 2, ilmp % 2)] = covden->GetBinContent(ibin, ilmz + 1, ilmp + 1);
707 int StHbtCorrFctnDirectYlm::GetIndexForLM(
int el,
int em)
709 for (
int iter = 0; iter < maxjm; iter++)
710 if ( (el == elsi[iter]) && (em == emsi[iter]) )
715 TH1D* StHbtCorrFctnDirectYlm::GetNumRealHist(
int el,
int em)
717 if (GetIndexForLM(el, em) >= 0)
718 return (numsreal[GetIndexForLM(el, em)]);
723 TH1D* StHbtCorrFctnDirectYlm::GetNumImagHist(
int el,
int em)
725 if (GetIndexForLM(el, em) >= 0)
726 return (numsimag[GetIndexForLM(el, em)]);
731 TH1D* StHbtCorrFctnDirectYlm::GetDenRealHist(
int el,
int em)
733 if (GetIndexForLM(el, em) >= 0)
734 return (densreal[GetIndexForLM(el, em)]);
739 TH1D* StHbtCorrFctnDirectYlm::GetDenImagHist(
int el,
int em)
741 if (GetIndexForLM(el, em) >= 0)
742 return (densimag[GetIndexForLM(el, em)]);
747 StHbtString StHbtCorrFctnDirectYlm::Report()
749 return (
"StHbtCorrFctnDirectYlm::Finish");
752 void StHbtCorrFctnDirectYlm::SetR2Factor(
bool aFactor)
758 void StHbtCorrFctnDirectYlm::CalcCorrFctn()
760 cftnreal =
new TH1D*[maxjm];
761 cftnimag =
new TH1D*[maxjm];
764 for (
int ihist = 0; ihist < maxjm; ihist++) {
765 int em = emsi[ihist] < 0 ? elsi[ihist] - emsi[ihist] : emsi[ihist];
767 sprintf( bufname,
"CfnReYlm%i%i%s", elsi[ihist], em, mName.c_str() );
768 cftnreal[ihist] =
new TH1D(bufname, bufname, mNbins, mkmin, mkmax);
769 sprintf( bufname,
"CfnImYlm%i%i%s", elsi[ihist], em, mName.c_str() );
770 cftnimag[ihist] =
new TH1D(bufname, bufname, mNbins, mkmin, mkmax);
772 cftnreal[ihist]->Sumw2();
773 cftnimag[ihist]->Sumw2();
776 covmcfc =
new double[maxjm * maxjm * 4 * mNbins];
778 complex<double> tMq0[maxjm];
779 complex<double> tTq0[maxjm];
780 double tMTilde[maxjm * maxjm * 4];
781 complex<double> tCq0[maxjm];
784 if ( (covnum) && (covnum->GetBinContent(0, 0, 0) > 0.0) ) {
785 cout <<
"Detected calculated covariance matrix. Do not recalculate !!!\n";
798 double normfactor = 1.0;
799 if (mNormBinMax > 0) {
804 if (mNormBinMin < 1) mNormBinMin = 1;
805 if ( mNormBinMax > densreal[0]->GetNbinsX() )
806 mNormBinMax = densreal[0]->GetNbinsX();
808 for (
int ib = mNormBinMin; ib <= mNormBinMax; ib++) {
809 ks = densreal[0]->GetXaxis()->GetBinCenter(ib);
810 sk = numsreal[0]->GetBinContent(ib) / ( densreal[0]->GetBinContent(ib) * ( 1.0 - mNormPurity / (mNormRadius * mNormBohr * ks * ks) ) );
811 wk = numsreal[0]->GetBinContent(ib);
815 normfactor *= sksum / wksum;
816 normfactor /= numsreal[0]->GetEntries() / densreal[0]->GetEntries();
819 for (
int ibin = 1; ibin <= numsreal[0]->GetNbinsX(); ibin++) {
820 for (
int ilm = 0; ilm < maxjm; ilm++) {
822 tMq0[ilm] = complex<double>( densreal[ilm]->GetBinContent(ibin) / (densreal[0]->GetEntries() / normfactor),
823 densimag[ilm]->GetBinContent(ibin) / (densreal[0]->GetEntries() / normfactor) );
824 tTq0[ilm] = complex<double>( numsreal[ilm]->GetBinContent(ibin) / numsreal[0]->GetEntries(),
825 numsimag[ilm]->GetBinContent(ibin) / numsreal[0]->GetEntries() );
828 tMq0[ilm] = complex<double>(densreal[ilm]->GetBinContent(ibin) / normfactor,
829 densimag[ilm]->GetBinContent(ibin) / normfactor);
830 tTq0[ilm] = complex<double>( numsreal[ilm]->GetBinContent(ibin),
831 numsimag[ilm]->GetBinContent(ibin) );
838 for (
int ilmzero = 0; ilmzero < GetMaxJM(); ilmzero++) {
839 for (
int ilmprim = 0; ilmprim < GetMaxJM(); ilmprim++) {
840 if ( ::isnan(covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 0)]) ) {
841 cout <<
"NaN !!!! RR " << ilmzero <<
" " << ilmprim << endl;
843 if ( ::isnan(covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 1)]) ) {
844 cout <<
"NaN !!!! RI " << ilmzero <<
" " << ilmprim << endl;
846 if ( ::isnan(covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 0)]) ) {
847 cout <<
"NaN !!!! IR " << ilmzero <<
" " << ilmprim << endl;
849 if ( ::isnan(covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 1)]) ) {
850 cout <<
"NaN !!!! II " << ilmzero <<
" " << ilmprim << endl;
853 covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 0)] /= numsreal[0]->GetEntries();
854 covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 1)] /= numsreal[0]->GetEntries();
855 covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 0)] /= numsreal[0]->GetEntries();
856 covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 1)] /= numsreal[0]->GetEntries();
858 if ( ::isnan(covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 0)]) ) {
859 cout <<
"NaN !!!! RR" << endl;
861 if ( ::isnan(covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 1)]) ) {
862 cout <<
"NaN !!!! RI" << endl;
864 if ( ::isnan(covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 0)]) ) {
865 cout <<
"NaN !!!! IR" << endl;
867 if ( ::isnan(covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 1)]) ) {
868 cout <<
"NaN !!!! II" << endl;
871 covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 0)] -= real(tTq0[ilmzero]) * real(tTq0[ilmprim]);
872 covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 1)] -= real(tTq0[ilmzero]) * imag(tTq0[ilmprim]);
873 covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 0)] -= imag(tTq0[ilmzero]) * real(tTq0[ilmprim]);
874 covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 1)] -= imag(tTq0[ilmzero]) * imag(tTq0[ilmprim]);
876 if ( ::isnan(covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 0)]) ) {
877 cout <<
"NaN !!!! RR" << endl;
879 if ( ::isnan(covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 1)]) ) {
880 cout <<
"NaN !!!! RI" << endl;
882 if ( ::isnan(covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 0)]) ) {
883 cout <<
"NaN !!!! IR" << endl;
885 if ( ::isnan(covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 1)]) ) {
886 cout <<
"NaN !!!! II" << endl;
889 covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 0)] /= (numsreal[0]->GetEntries() - 1);
890 covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 1)] /= (numsreal[0]->GetEntries() - 1);
891 covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 0)] /= (numsreal[0]->GetEntries() - 1);
892 covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 1)] /= (numsreal[0]->GetEntries() - 1);
894 if ( ::isnan(covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 0)]) ) {
895 cout <<
"NaN !!!! RR" << endl;
897 if ( ::isnan(covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 1)]) ) {
898 cout <<
"NaN !!!! RI" << endl;
900 if ( ::isnan(covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 0)]) ) {
901 cout <<
"NaN !!!! IR" << endl;
903 if ( ::isnan(covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 1)]) ) {
904 cout <<
"NaN !!!! II" << endl;
909 GetMtilde(tMq0, tMTilde);
912 double mDeltaT[maxjm * maxjm * 4];
913 for (
int ilmzero = 0; ilmzero < GetMaxJM() * 2; ilmzero++)
914 for (
int ilmprim = 0; ilmprim < GetMaxJM() * 2; ilmprim++)
915 mDeltaT[(ilmzero * maxjm * 2) + ilmprim] = (covmnum[GetBin(ibin - 1, ilmzero / 2, ilmzero % 2, ilmprim / 2, ilmprim % 2)]);
918 cout <<
"Delta T matrix " << endl;
919 for (
int ilmz = 0; ilmz < GetMaxJM() * 2; ilmz++) {
920 for (
int ilmp = 0; ilmp < GetMaxJM() * 2; ilmp++) {
923 cout << mDeltaT[ilmz * GetMaxJM() * 2 + ilmp];
929 double mDeltaTPacked[maxjm * maxjm * 4];
930 int msize = PackYlmMatrixIndependentOnly(mDeltaT, mDeltaTPacked);
933 cout <<
"Delta T matrix packed " << endl;
934 for (
int ilmz = 0; ilmz < msize; ilmz++) {
935 for (
int ilmp = 0; ilmp < msize; ilmp++) {
938 cout << mDeltaTPacked[ilmz * msize + ilmp];
946 double mM[maxjm * maxjm * 4];
947 double mMPacked[maxjm * maxjm * 4];
948 for (
int iter = 0; iter < maxjm * maxjm * 4; iter++)
949 mM[iter] = tMTilde[iter];
950 PackYlmMatrixIndependentOnly(mM, mMPacked);
952 gsl_matrix_view matM = gsl_matrix_view_array(mMPacked, msize, msize);
955 cout <<
"Mtilde matrix " << endl;
956 for (
int ilmz = 0; ilmz < GetMaxJM() * 2; ilmz++) {
957 for (
int ilmp = 0; ilmp < GetMaxJM() * 2; ilmp++) {
960 cout << mM[ilmz * GetMaxJM() * 2 + ilmp];
964 cout <<
"Mtilde matrix packed " << endl;
965 for (
int ilmz = 0; ilmz < msize; ilmz++) {
966 for (
int ilmp = 0; ilmp < msize; ilmp++) {
969 cout << mMPacked[ilmz * msize + ilmp];
976 double mU[maxjm * maxjm * 4];
977 InvertYlmIndependentMatrix(mDeltaT, mU);
979 double mDTInvertedPacked[maxjm * maxjm * 4];
980 PackYlmMatrixIndependentOnly(mU, mDTInvertedPacked);
982 gsl_matrix_view matDTI = gsl_matrix_view_array(mDTInvertedPacked, msize, msize);
984 cout <<
"Delta T matrix inverted packed " << endl;
985 for (
int ilmz = 0; ilmz < msize; ilmz++) {
986 for (
int ilmp = 0; ilmp < msize; ilmp++) {
989 cout << mDTInvertedPacked[ilmz * msize + ilmp];
996 double mQ[maxjm * maxjm * 4];
997 for (
int iter = 0; iter < msize * msize; iter++)
999 gsl_matrix_view matQ = gsl_matrix_view_array(mQ, msize, msize);
1000 gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1.0, &matDTI.matrix, &matM.matrix, 0.0, &matQ.matrix);
1002 double mTest[maxjm * maxjm * 4];
1003 gsl_matrix_view matTest = gsl_matrix_view_array(mTest, msize, msize);
1005 double mF[maxjm * maxjm * 4];
1006 for (
int iter = 0; iter < maxjm * maxjm * 4; iter++)
1007 mF[iter] = mDeltaTPacked[iter];
1008 gsl_matrix_view matF = gsl_matrix_view_array(mF, msize, msize);
1009 gsl_blas_dgemm(CblasTrans, CblasNoTrans, 1.0, &matF.matrix, &matQ.matrix, 0.0, &matTest.matrix);
1011 cout <<
"Test matrix packed - compare to Mtilde" << endl;
1012 for (
int ilmz = 0; ilmz < msize; ilmz++) {
1013 for (
int ilmp = 0; ilmp < msize; ilmp++) {
1016 cout << mTest[ilmz * msize + ilmp];
1022 double mP[maxjm * maxjm * 4];
1023 for (
int iter = 0; iter < maxjm * maxjm * 4; iter++)
1026 gsl_matrix_view matP = gsl_matrix_view_array(mP, msize, msize);
1027 gsl_blas_dgemm(CblasTrans, CblasNoTrans, 1.0, &matM.matrix, &matQ.matrix, 0.0, &matP.matrix);
1030 cout <<
"P matrix packed" << endl;
1031 for (
int ilmz = 0; ilmz < msize; ilmz++) {
1032 for (
int ilmp = 0; ilmp < msize; ilmp++) {
1035 cout << mP[ilmz * msize + ilmp];
1042 double mPUnpacked[maxjm * maxjm * 4];
1043 UnPackYlmMatrixIndependentOnly(mP, mPUnpacked, msize);
1046 cout <<
"P matrix unpacked" << endl;
1047 for (
int ilmz = 0; ilmz < GetMaxJM() * 2; ilmz++) {
1048 for (
int ilmp = 0; ilmp < GetMaxJM() * 2; ilmp++) {
1051 cout << mPUnpacked[ilmz * GetMaxJM() * 2 + ilmp];
1058 double mPInverted[maxjm * maxjm * 4];
1059 InvertYlmIndependentMatrix(mPUnpacked, mPInverted);
1061 double mPInvertedPacked[maxjm * maxjm * 4];
1062 PackYlmMatrixIndependentOnly(mPInverted, mPInvertedPacked);
1064 gsl_matrix_view matPI = gsl_matrix_view_array(mPInvertedPacked, msize, msize);
1067 cout <<
"P matrix inverted packed" << endl;
1068 for (
int ilmz = 0; ilmz < msize; ilmz++) {
1069 for (
int ilmp = 0; ilmp < msize; ilmp++) {
1072 cout << mPInvertedPacked[ilmz * msize + ilmp];
1078 double mR[maxjm * maxjm * 4];
1079 for (
int ir = 0; ir < maxjm * maxjm * 4; ir++)
1081 gsl_matrix_view matR = gsl_matrix_view_array(mR, msize, msize);
1086 cout <<
"Matrix M Packed " << endl;
1087 for (
int ilmz = 0; ilmz < msize; ilmz++) {
1088 for (
int ilmp = 0; ilmp < msize; ilmp++) {
1091 cout << mMPacked[ilmz * msize + ilmp];
1097 gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1.0, &matPI.matrix, &matM.matrix, 1.0, &matR.matrix);
1100 cout <<
"R matrix packed " << endl;
1101 for (
int ilmz = 0; ilmz < msize; ilmz++) {
1102 for (
int ilmp = 0; ilmp < msize; ilmp++) {
1105 cout << mR[ilmz * msize + ilmp];
1112 double vL[maxjm * 2];
1113 gsl_vector_view vecL = gsl_vector_view_array(vL, msize);
1118 double vB[maxjm * 2];
1119 for (
int iter = 0; iter < GetMaxJM(); iter++) {
1120 vB[iter * 2] = real(tTq0[iter]);
1121 vB[iter * 2 + 1] = imag(tTq0[iter]);
1124 double vBPacked[maxjm * 2];
1125 PackYlmVectorIndependentOnly(vB, vBPacked);
1127 gsl_vector_view vecB = gsl_vector_view_array(vBPacked, msize);
1134 cout <<
"L vector packed " << endl;
1135 for (
int ilmp = 0; ilmp < msize; ilmp++) {
1144 gsl_blas_dgemv(CblasNoTrans, 1.0, &matDTI.matrix, &vecB.vector, 0.0, &vecL.vector);
1147 double vY[maxjm * 2];
1148 for (
int iter = 0; iter < GetMaxJM() * 2; iter++) {
1153 gsl_vector_view vecY = gsl_vector_view_array(vY, msize);
1154 gsl_blas_dgemv (CblasNoTrans, 1.0, &matR.matrix, &vecL.vector, 0.0, &vecY.vector);
1157 cout <<
"C vector packed" << endl;
1158 for (
int ilmp = 0; ilmp < msize; ilmp++) {
1169 for (
int ilm = 0; ilm < maxjm; ilm++) {
1171 GetElEmForIndex(ilm, &el, &em);
1173 cftnreal[ilm]->SetBinContent(ibin, 0.0);
1174 cftnimag[ilm]->SetBinContent(ibin, 0.0);
1177 cftnreal[ilm]->SetBinContent(ibin, vY[mpack++]);
1179 cftnimag[ilm]->SetBinContent(ibin, 0);
1182 cftnimag[ilm]->SetBinContent(ibin, vY[mpack++]);
1188 for (
int ilm = 0; ilm < maxjm; ilm++) {
1189 GetElEmForIndex(ilm, &el, &em);
1191 cftnreal[ilm]->SetBinError(ibin, 0);
1192 cftnimag[ilm]->SetBinError(ibin, 0);
1195 cftnreal[ilm]->SetBinError( ibin, sqrt( fabs(mPInvertedPacked[mpack * msize + mpack]) ) );
1198 cftnimag[ilm]->SetBinError(ibin, 0);
1200 cftnimag[ilm]->SetBinError( ibin, sqrt( fabs(mPInvertedPacked[mpack * msize + mpack]) ) );
1206 for (
int ilmz = 0; ilmz < GetMaxJM() * 2; ilmz++) {
1207 for (
int ilmp = 0; ilmp < GetMaxJM() * 2; ilmp++) {
1209 covmcfc[GetBin(ibin - 1, ilmz / 2, ilmz % 2, ilmp / 2, ilmp % 2)] = mPInverted[ilmz * GetMaxJM() * 2 + ilmp];
1211 covmcfc[GetBin(ibin - 1, ilmz / 2, ilmz % 2, ilmp / 2, ilmp % 2)] = mPInverted[ilmp * GetMaxJM() * 2 + ilmz];
1221 int StHbtCorrFctnDirectYlm::PackYlmMatrixIndependentOnly(
double* inmat,
double* outmat)
1229 for (
int ilm = 0; ilm < GetMaxJM(); ilm++) {
1230 GetElEmForIndex(ilm, &elz, &emz);
1231 if (emz < 0)
continue;
1233 if (emz == 0)
continue;
1238 for (
int ilmz = 0; ilmz < GetMaxJM(); ilmz++) {
1239 GetElEmForIndex(ilmz, &elz, &emz);
1242 if (emz < 0)
continue;
1243 for (
int ilmp = 0; ilmp < GetMaxJM(); ilmp++) {
1244 GetElEmForIndex(ilmp, &elp, &emp);
1245 if (emp < 0)
continue;
1246 outmat[ioutcountz * finalsize + ioutcountp] = inmat[GetBin(0, ilmz, 0, ilmp, 0)];
1248 if (emp == 0)
continue;
1249 outmat[ioutcountz * finalsize + ioutcountp] = inmat[GetBin(0, ilmz, 0, ilmp, 1)];
1254 if (emz == 0)
continue;
1256 for (
int ilmp = 0; ilmp < GetMaxJM(); ilmp++) {
1257 GetElEmForIndex(ilmp, &elp, &emp);
1258 if (emp < 0)
continue;
1259 outmat[ioutcountz * finalsize + ioutcountp] = inmat[GetBin(0, ilmz, 1, ilmp, 0)];
1261 if (emp == 0)
continue;
1262 outmat[ioutcountz * finalsize + ioutcountp] = inmat[GetBin(0, ilmz, 1, ilmp, 1)];
1267 return (ioutcountz);
1271 void StHbtCorrFctnDirectYlm::InvertYlmIndependentMatrix(
double* inmat,
double* outmat)
1277 double mU[maxjm * maxjm * 4];
1278 int isize = PackYlmMatrixIndependentOnly(inmat, mU);
1281 gsl_matrix_view matU = gsl_matrix_view_array(mU, isize, isize);
1284 cout <<
"Input matrix independent only " << endl;
1285 for (
int ilmz = 0; ilmz < isize; ilmz++) {
1286 for (
int ilmp = 0; ilmp < isize; ilmp++) {
1289 cout << mU[ilmz * isize + ilmp];
1296 double mI[maxjm * maxjm * 4];
1297 for (
int iterm = 0; iterm < isize; iterm++)
1298 for (
int iterp = 0; iterp < isize; iterp++)
1300 mI[iterm * isize + iterp] = 1.0;
1302 mI[iterm * isize + iterp] = 0.0;
1304 gsl_matrix_view matI = gsl_matrix_view_array(mI, isize, isize);
1307 gsl_blas_dtrsm(CblasLeft, CblasUpper, CblasNoTrans, CblasNonUnit, 1.0, &matU.matrix, &matI.matrix);
1309 UnPackYlmMatrixIndependentOnly(mI, outmat, isize);
1313 void StHbtCorrFctnDirectYlm::UnPackYlmMatrixIndependentOnly(
double* inmat,
double* outmat,
int insize)
1315 int lmax = sqrt(insize) - 1;
1317 int tmax = (lmax + 1) * (lmax + 1) * 2;
1318 int indexfrom[tmax];
1322 for (
int iter = 0; iter < tmax; iter++) {
1324 GetElEmForIndex(iter / 2, &el, &em);
1327 indexfrom[iter] = 0;
1331 indexfrom[iter] = el * el;
1336 indexfrom[iter] = (el * el) + (-em) * 2 - 1;
1337 if (im) indexfrom[iter]++;
1339 if (im) multfrom[iter] = 1;
1340 else multfrom[iter] = -1;
1342 if (im) multfrom[iter] = -1;
1343 else multfrom[iter] = 1;
1346 indexfrom[iter] = (el * el) + (em) * 2 - 1;
1347 if (im) indexfrom[iter]++;
1352 for (
int ilmz = 0; ilmz < GetMaxJM() * 2; ilmz++)
1353 for (
int ilmp = 0; ilmp < GetMaxJM() * 2; ilmp++)
1354 outmat[ilmz * GetMaxJM() * 2 + ilmp] = inmat[(indexfrom[ilmz] * insize) + indexfrom[ilmp]] * multfrom[ilmz] * multfrom[ilmp];
1358 int StHbtCorrFctnDirectYlm::PackYlmVectorIndependentOnly(
double* invec,
double* outvec)
1362 for (
int ilm = 0; ilm < GetMaxJM(); ilm++) {
1363 GetElEmForIndex(ilm, &el, &em);
1364 if (em < 0)
continue;
1365 outvec[ioutcount++] = invec[ilm * 2];
1368 outvec[ioutcount++] = invec[ilm * 2 + 1];