3 #include "StDetectorDbMaker.h"
9 #include "Math/SMatrix.h"
10 using namespace ROOT::Math;
13 #include "St_db_Maker/St_db_Maker.h"
15 #include "tables/St_tpcCorrection_Table.h"
16 #include "tables/St_pidCorrection_Table.h"
17 #include "tables/St_tpcSectorT0offset_Table.h"
18 #include "tables/St_tofTrayConfig_Table.h"
19 #define makeSTRING(PATH) # PATH
20 #define CHECKTABLED(C_STRUCT) \
21 if (table->InheritsFrom("St_" # C_STRUCT)) { \
22 St_ ## C_STRUCT *t = (St_ ## C_STRUCT *) table ; \
23 C_STRUCT ## _st *s = t->GetTable(); Nrows = s->nrows; \
24 C_STRUCT ## _st def = {0}; \
27 Int_t NrowSize = t->GetRowSize(); \
28 if (! strcmp(makeSTRING(C_STRUCT),"Survey")) {shift = 4; NrowSize = 12*8;} \
29 if (! strcmp(makeSTRING(C_STRUCT),"tpcSectorT0offset")) {for (Int_t i = 0; i < 24; i++) def.t0[i] = -22.257;} \
30 if (! strcmp(makeSTRING(C_STRUCT),"tofTrayConfig")) {def.entries = 120; for (Int_t i = 0; i < 120; i++) {def.iTray[i] = i+1; def.nModules[i] = 32;} \
31 for (Int_t i = 0; i < table->GetNRows(); i++, s++) { \
32 if (memcmp(&def+shift, s+shift, NrowSize)) {iprt = kTRUE; break;} \
36 #define DEBUGTABLE(STRUCT) \
38 Bool_t iprt = kTRUE; \
40 if (St_db_Maker::GetValidity(table,t) > 0) { \
41 if (table->InheritsFrom("St_tpcCorrection") ) { \
42 St_tpcCorrection *tt = (St_tpcCorrection *) table; \
43 tpcCorrection_st *s = tt->GetTable(); Nrows = s->nrows; \
44 } else if (table->InheritsFrom("St_pidCorrection") ) { \
45 St_pidCorrection *tt = (St_pidCorrection *) table; \
46 pidCorrection_st *s = tt->GetTable(); Nrows = s->nrows; \
48 LOG_WARN << "St_" << makeSTRING(STRUCT) << "C::instance found table " << table->GetName() \
49 << " with NRows = " << Nrows << " in db" \
50 << Form("\tValidity:%8i.%06i",t[0].GetDate(),t[0].GetTime()) \
51 << Form(" - %8i.%06i",t[1].GetDate(),t[1].GetTime()) << endm; \
52 if (Nrows > 10) Nrows = 10; \
53 CHECKTABLED(tpcCorrection); \
54 CHECKTABLED(tpcHVPlanes); \
55 CHECKTABLED(Survey); \
56 CHECKTABLED(tpcSectorT0offset); \
57 CHECKTABLED(tofTrayConfig); \
59 if (table->GetRowSize() < 512) table->Print(0,Nrows); \
61 LOG_WARN << "Default table" << endm; \
66 #include "StarChairDefs.h"
67 static Int_t _debug = 0;
70 #include "StDetectorDbFTPCGas.h"
72 #include "St_ftpcGasSystemC.h"
73 MakeChairInstance(ftpcGasSystem,Calibrations/ftpc/ftpcGasSystem);
74 #include "St_ftpcGasOutC.h"
75 MakeChairInstance(ftpcGasOut,Calibrations/ftpc/ftpcGasOut);
76 #include "St_ftpcVoltageC.h"
77 MakeChairInstance(ftpcVoltage,Calibrations/ftpc/ftpcVoltage);
78 #include "St_ftpcVoltageStatusC.h"
79 MakeChairInstance(ftpcVoltageStatus,Calibrations/ftpc/ftpcVoltageStatus);
81 #include "St_tpcGasC.h"
82 MakeChairInstance(tpcGas,Calibrations/tpc/tpcGas);
83 #include "St_TpcEffectivedXC.h"
84 MakeChairInstance(TpcEffectivedX,Calibrations/tpc/TpcEffectivedX);
85 #include "St_tpcGridLeakC.h"
86 MakeChairInstance(tpcGridLeak,Calibrations/tpc/tpcGridLeak);
87 #include "St_tpcOmegaTauC.h"
88 MakeChairInstance(tpcOmegaTau,Calibrations/tpc/tpcOmegaTau);
89 #include "St_tpcDriftVelocityC.h"
90 #include "St_starClockOnlC.h"
91 MakeChairInstance(tpcDriftVelocity,Calibrations/tpc/tpcDriftVelocity);
92 Float_t St_tpcDriftVelocityC::timeBucketPitch(Int_t i) {
93 return laserDriftVelocityEast(i)/St_starClockOnlC::instance()->Frequency()*1e6;
95 #include "St_TpcSecRowCorC.h"
97 #include "St_TpcSecRowBC.h"
98 MakeChairInstance2(TpcSecRowCor,
St_TpcSecRowBC,Calibrations/tpc/TpcSecRowB);
99 #include "St_TpcSecRowCC.h"
100 MakeChairOptionalInstance2(TpcSecRowCor,
St_TpcSecRowCC,Calibrations/tpc/TpcSecRowC);
101 #include "St_TpcSecRowXC.h"
102 MakeChairInstance2(TpcSecRowCor,
St_TpcSecRowXC,Calibrations/tpc/TpcSecRowX);
103 #include "St_tpcCorrectionC.h"
104 #include "St_tpcCalibResolutionsC.h"
105 MakeChairInstance(tpcCalibResolutions,Calibrations/tpc/tpcCalibResolutions);
106 #include "St_tpcChargeEventC.h"
107 MakeChairInstance(tpcChargeEvent,Calibrations/tpc/tpcChargeEvent);
108 #include "St_tpcSCGLC.h"
109 MakeChairInstance(tpcSCGL,Calibrations/tpc/tpcSCGL);
112 Double_t St_tpcCorrectionC::CalcCorrection(Int_t i, Double_t x, Double_t z, Int_t NparMax)
const {
113 tpcCorrection_st *cor = ((St_tpcCorrection *) Table())->GetTable() + i;
114 return SumSeries(cor, x, z, NparMax);
117 Double_t St_tpcCorrectionC::CalcXDerivative(Int_t i, Double_t x, Double_t z, Int_t NparMax)
const {
118 tpcCorrection_st *cor = ((St_tpcCorrection *) Table())->GetTable() + i;
119 return SumSeriesXDerivative(cor, x, z, NparMax);
122 Double_t St_tpcCorrectionC::SumSeries(tpcCorrection_st *cor, Double_t x, Double_t z, Int_t NparMax)
const {
124 if (! cor)
return Sum;
125 Int_t N = TMath::Abs(cor->npar)%100;
126 if (N == 0)
return Sum;
127 if (NparMax > 0) N = NparMax;
128 static Double_t T0, T1, T2;
131 if (cor->npar < 0) X = TMath::Exp(x);
138 X = TMath::Log(x);
break;
140 if (cor->min < cor->max) X = -1 + 2*TMath::Max(0.,TMath::Min(1.,(X - cor->min)/( cor->max - cor->min)));
143 if (cor->min < cor->max) X = TMath::Max(0.,TMath::Min(1.,(X - cor->min)/( cor->max - cor->min)));
146 if (TMath::Abs(x) >= 1) X = 0;
147 else X = TMath::Log(1. - TMath::Abs(x));
150 if (TMath::Abs(x) >= 1) X = 0;
151 else X = TMath::Sign(TMath::Log(1. - TMath::Abs(x)),x);
154 if (x < 1e-7) X = -16.118;
155 else X = TMath::Log(x);
160 default: X = x;
break;
163 if (cor->type != 1 && cor->type != 2 &&
164 cor->min < cor->max) {
165 if (X < cor->min) X = cor->min;
166 if (X > cor->max) X = cor->max;
168 static TF1 *f1000 = 0, *f1100 = 0, *f1200 = 0, *f1300 = 0, *f1400 = 0, *f1500 = 0;
169 static TF1 *f2000 = 0, *f2100 = 0, *f2200 = 0, *f2300 = 0, *f2400 = 0, *f2500 = 0;
178 for (
int n = 2; n <= N; n++) {
191 for (
int n = 2; n <= N; n++) {
192 T2 = 2*(2*X - 1)*T1 - T0;
200 for (
int n = N-2; n>=0; n--) Sum = X*Sum + cor->a[n];
201 Sum += TMath::Log(1. + cor->OffSet/x);
202 Sum = TMath::Exp(Sum);
206 Sum = cor->a[1] + z*cor->a[2] + z*X*cor->a[3] + TMath::Exp(X*(cor->a[4] + X*cor->a[5]) + cor->a[6]);
207 Sum *= TMath::Exp(-cor->a[0]);
210 Sum = cor->a[1] + z*cor->a[2] + z*z*cor->a[3] + TMath::Exp(X*(cor->a[4] + X*cor->a[5]) + cor->a[6]);
211 Sum *= TMath::Exp(-cor->a[0]);
214 Sum = x * TMath::Exp(cor->a[0] + cor->a[1] + TMath::Exp(cor->a[2] + cor->a[3]*x));
217 Sum = cor->a[0]+cor->a[1]*TMath::TanH(cor->a[2]*(x-cor->a[3]));
225 if (cor->type == 1000) {
226 if (! f1000) f1000 =
new TF1(
"f1000",
"gaus+pol0(3)");
228 }
else if (cor->type == 1100) {
229 if (! f1100) f1100 =
new TF1(
"f1100",
"gaus+pol1(3)");
231 }
else if (cor->type == 1200) {
232 if (! f1200) f1200 =
new TF1(
"f1200",
"gaus+pol2(3)");
234 }
else if (cor->type == 1300) {
235 if (! f1300) f1300 =
new TF1(
"f1300",
"gaus+pol3(3)");
237 }
else if (cor->type == 1400) {
238 if (! f1400) f1400 =
new TF1(
"f1400",
"gaus+pol4(3)");
240 }
else if (cor->type == 1500) {
241 if (! f1500) f1500 =
new TF1(
"f1500",
"gaus+pol5(3)");
245 f->SetParameters(cor->a);
254 if (cor->type == 2000) {
255 if (! f2000) f2000 =
new TF1(
"f2000",
"expo+pol0(2)");
257 }
else if (cor->type == 2100) {
258 if (! f2100) f2100 =
new TF1(
"f2100",
"expo+pol1(2)");
260 }
else if (cor->type == 2200) {
261 if (! f2200) f2200 =
new TF1(
"f2200",
"expo+pol2(2)");
263 }
else if (cor->type == 2300) {
264 if (! f2300) f2300 =
new TF1(
"f2300",
"expo+pol3(2)");
266 }
else if (cor->type == 2400) {
267 if (! f2400) f2400 =
new TF1(
"f2400",
"expo+pol4(2)");
269 }
else if (cor->type == 2500) {
270 if (! f2500) f2500 =
new TF1(
"f2500",
"expo+pol5(2)");
274 f->SetParameters(cor->a);
279 for (
int n = N-2; n>=0; n--) Sum = X*Sum + cor->a[n];
285 Double_t St_tpcCorrectionC::SumSeriesXDerivative(tpcCorrection_st *cor, Double_t x, Double_t z, Int_t NparMax)
const {
288 if (! cor)
return Sum;
289 Int_t N = TMath::Abs(cor->npar)%100;
290 if (N == 0)
return Sum;
291 if (NparMax > 0) N = NparMax;
294 Double_t Jacobian = 1;
295 if (cor->npar < 0) {X = TMath::Exp(x); Jacobian = X;}
306 if (cor->min < cor->max) X = -1 + 2*TMath::Max(0.,TMath::Min(1.,(X - cor->min)/( cor->max - cor->min)));
310 if (cor->min < cor->max) X = TMath::Max(0.,TMath::Min(1.,(X - cor->min)/( cor->max - cor->min)));
314 if (TMath::Abs(x) >= 1) X = 0;
315 else X = TMath::Log(1. - TMath::Abs(x));
319 if (TMath::Abs(x) >= 1) X = 0;
320 else X = TMath::Sign(TMath::Log(1. - TMath::Abs(x)),x);
324 if (x < 1e-7) X = -16.118;
325 else X = TMath::Log(x);
326 Jacobian = TMath::Exp(-X);
330 Jacobian = TMath::Sign(1., x);
332 default: X = x;
break;
335 if (TMath::Abs(Jacobian) < 1e-7)
return 0;
336 if (cor->type != 1 && cor->type != 2 &&
337 cor->min < cor->max) {
338 if (X < cor->min) X = cor->min;
339 if (X > cor->max) X = cor->max;
341 Sum = cor->a[N-1] * (N - 1);
342 for (
int n = N-2; n>=1; n--) Sum = X*Sum + cor->a[n] * n;
347 Int_t St_tpcCorrectionC::IsActiveChair()
const {
348 const St_tpcCorrection *tableC = (
const St_tpcCorrection *) Table();
350 if (! tableC)
return npar;
351 tpcCorrection_st *cor = tableC->GetTable();
352 Int_t N = tableC->GetNRows();
357 for (Int_t i = 0; i < N; i++, cor++) {
358 if (cor->nrows == 0 && cor->idx == 0)
continue;
359 if (TMath::Abs(cor->npar) > 0 ||
360 TMath::Abs(cor->OffSet) > 1.e-7 ||
361 TMath::Abs(cor->min) > 1.e-7 ||
362 TMath::Abs(cor->max) > 1.e-7) {
368 #include "St_pidCorrectionC.h"
369 MakeChairInstance2(pidCorrection,
St_pidCorrectionC,dEdxModel/PiDC/pidCorrection);
371 Double_t St_pidCorrectionC::CalcCorrection(Int_t i, Double_t x, Double_t z, Int_t NparMax)
const {
372 pidCorrection_st *cor = ((St_pidCorrection *) Table())->GetTable() + i;
373 return SumSeries(cor, x, z, NparMax);
376 Double_t St_pidCorrectionC::SumSeries(pidCorrection_st *cor, Double_t x, Double_t z, Int_t NparMax)
const {
378 if (! cor)
return Sum;
379 Int_t N = TMath::Abs(cor->npar)%100;
380 if (N == 0)
return Sum;
381 if (NparMax > 0) N = NparMax;
383 if (X < cor->min)
return Sum;
384 if (X > cor->max)
return Sum;
388 if (cor->min < cor->max) X = -1 + 2*TMath::Max(0.,TMath::Min(1.,(X - cor->min)/( cor->max - cor->min)));
394 for (
int n = 2; n <= N; n++) {
402 if (cor->min < cor->max) X = TMath::Max(0.,TMath::Min(1.,(X - cor->min)/( cor->max - cor->min)));
408 for (
int n = 2; n <= N; n++) {
409 T2 = 2*(2*X - 1)*T1 - T0;
417 for (
int n = N-2; n>=0; n--) Sum = X*Sum + cor->a[n];
423 Int_t St_pidCorrectionC::IsActiveChair()
const {
424 const St_pidCorrection *tableC = (
const St_pidCorrection *) Table();
426 if (! tableC)
return npar;
427 pidCorrection_st *cor = tableC->GetTable();
433 for (Int_t i = 0; i < N; i++, cor++) {
434 if (cor->nrows == 0 && cor->idx == 0)
continue;
435 if (TMath::Abs(cor->npar) > 0 ||
436 TMath::Abs(cor->OffSet) > 1.e-7 ||
437 TMath::Abs(cor->min) > 1.e-7 ||
438 TMath::Abs(cor->max) > 1.e-7) {
445 Double_t St_pidCorrectionC::Correction(Double_t X, Int_t part, Int_t det, Int_t charge, Int_t pull, Int_t varT) {
447 Double_t Correction = 0;
448 for (Int_t l = 0; l < N; l++) {
449 pidCorrection_st *row = Struct(l);
450 if (part != row->particle)
continue;
451 if (det != row->det)
continue;
452 if (pull != row->pull)
continue;
453 if (varT != row->var)
continue;
454 if (row->charge != 0 && charge != row->charge)
continue;
455 if (row->min < row->max && (X < row->min || X > row->max))
continue;
457 Correction += SumSeries(row, X);
459 return TMath::Exp(Correction);
462 Double_t St_pidCorrectionC::func(Double_t *x, Double_t *p) {
468 return TMath::Log(St_pidCorrectionC::instance()->Correction(x[0],part,det,charge,pull,varT));
471 TF1 *St_pidCorrectionC::Func(Int_t part, Int_t det, Int_t charge, Int_t pull, Int_t varT) {
472 TString fName(Form(
"pidCor_p%i_d%i_c%i_p%i_v%i",part,det,charge,pull,varT));
473 TF1 *f = (TF1 *) gROOT->GetListOfFunctions()->FindObject(fName);
475 f =
new TF1(fName, St_pidCorrectionC::func, -1.2, 0.9, 5);
477 f->GetXaxis()->SetTitle(
"log_{10} P [GeV/c]");
479 f->GetXaxis()->SetTitle(
"log_{10} P/M");
480 f->FixParameter(0, part);
481 f->FixParameter(1, det);
482 f->FixParameter(2, charge);
483 f->FixParameter(3, pull);
484 f->FixParameter(4, varT);
488 #include "St_TpcRowQC.h"
489 MakeChairInstance2(tpcCorrection,
St_TpcRowQC,Calibrations/tpc/TpcRowQ);
490 #include "St_TpcDriftDistOxygenC.h"
492 #include "St_TpcMultiplicityC.h"
494 #include "St_TpcZCorrectionBC.h"
496 #include "St_TpcZCorrectionCC.h"
498 #include "St_TpcdXCorrectionBC.h"
500 #include "St_TpcEtaCorrectionC.h"
502 #include "St_TpcEtaCorrectionBC.h"
504 #include "St_tpcPressureBC.h"
505 MakeChairInstance2(tpcCorrection,
St_tpcPressureBC,Calibrations/tpc/tpcPressureB);
507 #include "St_TpcPadPedRMSC.h"
508 MakeChairInstance2(tpcCorrection,
St_TpcPadPedRMSC,Calibrations/tpc/TpcPadPedRMS);
509 #include "St_TpcEdgeC.h"
510 MakeChairInstance2(tpcCorrection,
St_TpcEdgeC,Calibrations/tpc/TpcEdge);
511 #include "St_TpcAdcCorrectionBC.h"
513 #include "St_TpcAdcCorrectionCC.h"
515 #include "St_TpcAdcCorrectionMDF.h"
517 #include "St_TpcAdcCorrection3MDF.h"
519 #include "St_TpcAdcCorrection4MDF.h"
521 #include "St_TpcAdcCorrection5MDF.h"
523 #include "St_TpcAdcCorrection6MDF.h"
525 #include "St_tpcMethaneInC.h"
526 MakeChairInstance2(tpcCorrection,
St_tpcMethaneInC,Calibrations/tpc/tpcMethaneIn);
527 #include "St_tpcTimeBucketCorC.h"
529 #include "St_tpcGasTemperatureC.h"
531 #include "St_tpcWaterOutC.h"
532 MakeChairInstance2(tpcCorrection,
St_tpcWaterOutC,Calibrations/tpc/tpcWaterOut);
533 #include "St_tpcTimeDependenceC.h"
535 #include "St_TpcdChargeC.h"
536 MakeChairOptionalInstance2(tpcCorrection,
St_TpcdChargeC,Calibrations/tpc/TpcdCharge);
537 #include "St_TpcrChargeC.h"
538 MakeChairOptionalInstance2(tpcCorrection,
St_TpcrChargeC,Calibrations/tpc/TpcrCharge);
539 #include "St_TpcTanLC.h"
540 MakeChairInstance2(tpcCorrection,
St_TpcTanLC,Calibrations/tpc/TpcTanL);
541 #include "St_TpcAdcIC.h"
542 MakeChairInstance2(tpcCorrection,
St_TpcAdcIC,Calibrations/tpc/TpcAdcI);
543 #include "St_TpcnPadC.h"
544 MakeChairInstance2(tpcCorrection,
St_TpcnPadC,Calibrations/tpc/TpcnPad);
545 #include "St_TpcnTbkC.h"
546 MakeChairInstance2(tpcCorrection,
St_TpcnTbkC,Calibrations/tpc/TpcnTbk);
547 #include "St_TpcdZdYC.h"
548 MakeChairInstance2(tpcCorrection,
St_TpcdZdYC,Calibrations/tpc/TpcdZdY);
549 #include "St_TpcdXdYC.h"
550 MakeChairInstance2(tpcCorrection,
St_TpcdXdYC,Calibrations/tpc/TpcdXdY);
551 #include "St_GatingGridC.h"
552 MakeChairInstance2(GatingGrid,
St_GatingGridC,Calibrations/tpc/GatingGrid);
554 Double_t St_GatingGridC::CalcCorrection(Int_t i, Double_t x) {
555 Double_t value = -10;
556 GatingGrid_st *cor = ((St_GatingGrid *) Table())->GetTable() + i;
557 if (x <= cor->t0)
return value;
558 Double_t corD = 1. - TMath::Exp(-(x-cor->t0)/(cor->settingTime/4.6));
559 if (corD < 1e-4)
return value;
560 return TMath::Log(corD);
562 #include "St_GatingGridBC.h"
563 MakeChairInstance2(tpcCorrection,
St_GatingGridBC,Calibrations/tpc/GatingGridB);
565 Double_t St_GatingGridBC::CalcCorrection(Int_t i, Double_t x) {
566 const tpcCorrection_st *s = Struct(i);
567 Double_t T0 = s->a[0];
568 Double_t SettingTime = s->a[1];
570 Double_t tau = (x - T0)/(SettingTime/4.6);
571 if (tau > 10)
return 0;
573 Double_t corD = 1. - TMath::Exp(-tau);
574 return TMath::Log(corD);
579 #include "St_TpcCurrentCorrectionC.h"
584 if (fgInstance)
return fgInstance;
585 St_tpcCorrection *table = (St_tpcCorrection *) StMaker::GetChain()->GetDataBase(
"Calibrations/tpc/TpcCurrentCorrectionX");
586 if (! table) table = (St_tpcCorrection *) StMaker::GetChain()->GetDataBase(
"Calibrations/tpc/TpcCurrentCorrection");
587 assert(table); DEBUGTABLE(tpcCorrection);
591 #include "St_TpcZDCC.h"
592 MakeChairInstance2(tpcCorrection,
St_TpcZDCC,Calibrations/tpc/TpcZDC);
593 #include "St_TpcSpaceChargeC.h"
595 #include "St_TpcPhiDirectionC.h"
597 #include "St_TpcdEdxCorC.h"
598 MakeChairInstance2(tpcCorrection,
St_TpcdEdxCorC,Calibrations/tpc/TpcdEdxCor);
599 #include "St_TpcLengthCorrectionBC.h"
601 #include "St_TpcDriftVelRowCorC.h"
603 #include "St_TpcAccumulatedQC.h"
605 #include "St_TpcLengthCorrectionMDF.h"
607 #include "St_TpcLengthCorrectionMD2.h"
609 #include "St_TpcLengthCorrectionMDN.h"
611 #include "St_TpcPadCorrectionMDF.h"
613 #include "St_TpcPadCorrectionMDC.h"
618 St_MDFCorrectionC::St_MDFCorrectionC(St_MDFCorrection *table) :
TChair(table), fFunc(0) {
619 UInt_t N = table->GetNRows();
621 memset(fFunc, 0, N*
sizeof(TF1*));
624 St_MDFCorrectionC::~St_MDFCorrectionC() {
626 for (UInt_t i = 0; i < N; i++) {SafeDelete(fFunc[i]);}
630 Double_t St_MDFCorrectionC::MDFunc(Double_t *x, Double_t *p) {
636 assert(k >= 0 && k < fgMDFCorrectionC->getNumRows());
637 Double_t returnValue = fgMDFCorrectionC->DMean(k);
640 for (i = 0; i < fgMDFCorrectionC->NCoefficients(k); i++) {
642 term = fgMDFCorrectionC->Coefficients(k)[i];
643 for (j = 0; j < fgMDFCorrectionC->NVariables(k); j++) {
645 Int_t p = fgMDFCorrectionC->Powers(k)[i * fgMDFCorrectionC->NVariables(k) + j];
646 Double_t y = 1 + 2. / (fgMDFCorrectionC->XMax(k)[j] - fgMDFCorrectionC->XMin(k)[j])
647 * (x[j] - fgMDFCorrectionC->XMax(k)[j]);
648 term *= fgMDFCorrectionC->EvalFactor(k,p,y);
657 Double_t St_MDFCorrectionC::Eval(Int_t k, Double_t x0, Double_t x1)
const {
658 Double_t x[2] = {x0, x1};
662 Double_t St_MDFCorrectionC::Eval(Int_t k, Double_t *x)
const {
670 MDFCorrection_st *corK = fgMDFCorrectionC->Struct(k);
671 cout << Table()->GetName() <<
" k = " << k <<
" Idx = " << (Int_t) corK->idx <<
" Nvar = " << corK->NVariables <<
" type = " << corK->PolyType;
672 for (Int_t v = 0; v < corK->NVariables; v++) {
673 cout <<
"\t" << v <<
" min = " << corK->XMin[v] <<
" max = " << corK->XMax[v];
677 if (NVariables(k) <= 0) {
679 }
else if (NVariables(k) == 1) {
680 fFunc[k] =
new TF1(Form(
"%s_%i",Table()->GetName(),k),St_MDFCorrectionC::MDFunc,
681 XMin(k)[0],XMax(k)[0],1);
682 fFunc[k]->SetParameter(0,k);
683 fFunc[k]->Save(XMin(k)[0],XMax(k)[0],0,0,0,0);
684 }
else if (NVariables(k) == 2) {
685 fFunc[k] =
new TF2(Form(
"%s_%i",Table()->GetName(),k),St_MDFCorrectionC::MDFunc,
686 XMin(k)[0],XMax(k)[0],XMin(k)[1],XMax(k)[1],1);
687 fFunc[k]->SetParameter(0,k);
688 ((TF2 *) fFunc[k])->Save(XMin(k)[0],XMax(k)[0],XMin(k)[1],XMax(k)[1],0,0);
689 }
else if (NVariables(k) == 3) {
690 fFunc[k] =
new TF3(Form(
"%s_%i",Table()->GetName(),k),St_MDFCorrectionC::MDFunc,
691 XMin(k)[0],XMax(k)[0],XMin(k)[1],XMax(k)[1],XMin(k)[2],XMax(k)[2],1);
692 fFunc[k]->SetParameter(0,k);
693 ((TF3 *) fFunc[k])->Save(XMin(k)[0],XMax(k)[0],XMin(k)[1],XMax(k)[1],XMin(k)[2],XMax(k)[2]);
697 for (Int_t v = 0; v < NVariables(k); v++) {
698 xx[v] = TMath::Max(XMin(k)[v], TMath::Min(XMin(k)[v]+0.999*(XMax(k)[v]-XMin(k)[v]), x[v]));
700 Double_t returnValue = fFunc[k]->GetSave(xx);
704 Double_t St_MDFCorrectionC::EvalError(Int_t k, Double_t *x)
const {
709 Double_t returnValue = 0;
712 for (i = 0; i < NCoefficients(k); i++) {
714 term = CoefficientsRMS(k)[i];
715 for (j = 0; j < NVariables(k); j++) {
717 Int_t p = Powers(k)[i * NVariables(k) + j];
718 Double_t y = 1 + 2. / (XMax(k)[j] - XMin(k)[j])
719 * (x[j] - XMax(k)[j]);
720 term *= EvalFactor(p,y);
723 returnValue += term*term;
725 returnValue = TMath::Sqrt(returnValue);
729 Double_t St_MDFCorrectionC::EvalFactor(Int_t k, Int_t p, Double_t x)
const {
746 for (i = 3; i <= p; i++) {
748 if (PolyType(k) == kLegendre)
749 p3 = ((2 * i - 3) * p2 * x - (i - 2) * p1) / (i - 1);
750 else if (PolyType(k) == kChebyshev)
751 p3 = 2 * x * p2 - p1;
760 Int_t St_MDFCorrectionC::IsActiveChair()
const {
762 const St_MDFCorrection *tableMDF = (
const St_MDFCorrection *) Table();
763 if (! tableMDF)
return npar;
764 MDFCorrection_st *corMDF = tableMDF->GetTable();
766 if (! corMDF || ! N) {
769 for (Int_t i = 0; i < N; i++, corMDF++) {
770 if (corMDF->nrows == 0 && corMDF->idx == 0)
continue;
780 St_MDFCorrection3C::St_MDFCorrection3C(St_MDFCorrection3 *table) :
TChair(table), fFunc(0) {
781 UInt_t N = table->GetNRows();
783 memset(fFunc, 0, N*
sizeof(TF1*));
786 St_MDFCorrection3C::~St_MDFCorrection3C() {
788 for (UInt_t i = 0; i < N; i++) {SafeDelete(fFunc[i]);}
792 Double_t St_MDFCorrection3C::MDFunc(Double_t *x, Double_t *p) {
798 assert(k >= 0 && k < fgMDFCorrection3C->getNumRows());
799 Double_t returnValue = fgMDFCorrection3C->DMean(k);
802 for (i = 0; i < fgMDFCorrection3C->NCoefficients(k); i++) {
804 term = fgMDFCorrection3C->Coefficients(k)[i];
805 for (j = 0; j < fgMDFCorrection3C->NVariables(k); j++) {
807 Int_t p = fgMDFCorrection3C->Powers(k)[i * fgMDFCorrection3C->NVariables(k) + j];
808 Double_t y = 1 + 2. / (fgMDFCorrection3C->XMax(k)[j] - fgMDFCorrection3C->XMin(k)[j])
809 * (x[j] - fgMDFCorrection3C->XMax(k)[j]);
810 term *= fgMDFCorrection3C->EvalFactor(k,p,y);
819 Double_t St_MDFCorrection3C::Eval(Int_t k, Double_t x0, Double_t x1, Double_t x2)
const {
820 Double_t x[3] = {x0, x1, x2};
824 Double_t St_MDFCorrection3C::Eval(Int_t k, Double_t *x)
const {
831 if (NVariables(k) <= 0) {
833 }
else if (NVariables(k) == 1) {
834 fFunc[k] =
new TF1(Form(
"%s_%i",Table()->GetName(),k),St_MDFCorrection3C::MDFunc,
835 XMin(k)[0],XMax(k)[0],1);
836 fFunc[k]->SetParameter(0,k);
837 fFunc[k]->Save(XMin(k)[0],XMax(k)[0],0,0,0,0);
838 }
else if (NVariables(k) == 2) {
839 fFunc[k] =
new TF2(Form(
"%s_%i",Table()->GetName(),k),St_MDFCorrection3C::MDFunc,
840 XMin(k)[0],XMax(k)[0],XMin(k)[1],XMax(k)[1],1);
841 fFunc[k]->SetParameter(0,k);
842 ((TF2 *) fFunc[k])->Save(XMin(k)[0],XMax(k)[0],XMin(k)[1],XMax(k)[1],0,0);
843 }
else if (NVariables(k) == 3) {
844 fFunc[k] =
new TF3(Form(
"%s_%i",Table()->GetName(),k),St_MDFCorrection3C::MDFunc,
845 XMin(k)[0],XMax(k)[0],XMin(k)[1],XMax(k)[1],XMin(k)[2],XMax(k)[2],1);
846 fFunc[k]->SetParameter(0,k);
847 ((TF3 *) fFunc[k])->Save(XMin(k)[0],XMax(k)[0],XMin(k)[1],XMax(k)[1],XMin(k)[2],XMax(k)[2]);
851 for (Int_t v = 0; v < NVariables(k); v++) {
852 xx[v] = TMath::Max(XMin(k)[v], TMath::Min(XMin(k)[v]+0.999*(XMax(k)[v]-XMin(k)[v]), x[v]));
854 Double_t returnValue = fFunc[k]->GetSave(xx);
858 Double_t St_MDFCorrection3C::EvalError(Int_t k, Double_t *x)
const {
863 Double_t returnValue = 0;
866 for (i = 0; i < NCoefficients(k); i++) {
868 term = CoefficientsRMS(k)[i];
869 for (j = 0; j < NVariables(k); j++) {
871 Int_t p = Powers(k)[i * NVariables(k) + j];
872 Double_t y = 1 + 2. / (XMax(k)[j] - XMin(k)[j])
873 * (x[j] - XMax(k)[j]);
874 term *= EvalFactor(p,y);
877 returnValue += term*term;
879 returnValue = TMath::Sqrt(returnValue);
883 Double_t St_MDFCorrection3C::EvalFactor(Int_t k, Int_t p, Double_t x)
const {
900 for (i = 3; i <= p; i++) {
902 if (PolyType(k) == kLegendre)
903 p3 = ((2 * i - 3) * p2 * x - (i - 2) * p1) / (i - 1);
904 else if (PolyType(k) == kChebyshev)
905 p3 = 2 * x * p2 - p1;
914 Int_t St_MDFCorrection3C::IsActiveChair()
const {
916 const St_MDFCorrection3 *tableMDF = (
const St_MDFCorrection3 *) Table();
917 if (! tableMDF)
return npar;
918 MDFCorrection3_st *corMDF = tableMDF->GetTable();
920 if (! corMDF || ! N) {
923 for (Int_t i = 0; i < N; i++, corMDF++) {
924 if (corMDF->nrows == 0 && corMDF->idx == 0)
continue;
934 St_MDFCorrection4C::St_MDFCorrection4C(St_MDFCorrection4 *table) :
TChair(table), fFunc(0) {
935 UInt_t N = table->GetNRows();
937 memset(fFunc, 0, N*
sizeof(TF1*));
940 St_MDFCorrection4C::~St_MDFCorrection4C() {
942 for (UInt_t i = 0; i < N; i++) {SafeDelete(fFunc[i]);}
946 Double_t St_MDFCorrection4C::MDFunc(Double_t *x, Double_t *p) {
952 assert(k >= 0 && k < fgMDFCorrection4C->getNumRows());
953 Double_t returnValue = fgMDFCorrection4C->DMean(k);
956 for (i = 0; i < fgMDFCorrection4C->NCoefficients(k); i++) {
958 term = fgMDFCorrection4C->Coefficients(k)[i];
959 for (j = 0; j < fgMDFCorrection4C->NVariables(k); j++) {
961 Int_t p = fgMDFCorrection4C->Powers(k)[i * fgMDFCorrection4C->NVariables(k) + j];
962 Double_t y = 1 + 2. / (fgMDFCorrection4C->XMax(k)[j] - fgMDFCorrection4C->XMin(k)[j])
963 * (x[j] - fgMDFCorrection4C->XMax(k)[j]);
964 term *= fgMDFCorrection4C->EvalFactor(k,p,y);
973 Double_t St_MDFCorrection4C::Eval(Int_t k, Double_t x0, Double_t x1, Double_t x2, Double_t x3)
const {
974 Double_t x[4] = {x0, x1, x2, x3};
978 Double_t St_MDFCorrection4C::Eval(Int_t k, Double_t *x)
const {
984 for (Int_t v = 0; v < NVariables(k); v++) {
985 xx[v] = TMath::Max(XMin(k)[v], TMath::Min(XMin(k)[v]+0.999*(XMax(k)[v]-XMin(k)[v]), x[v]));
987 Double_t returnValue = 0;
989 if (NVariables(k) <= 3) {
991 if (NVariables(k) <= 0) {
993 }
else if (NVariables(k) == 1) {
994 fFunc[k] =
new TF1(Form(
"%s_%i",Table()->GetName(),k),St_MDFCorrection4C::MDFunc,
995 XMin(k)[0],XMax(k)[0],1);
996 fFunc[k]->SetParameter(0,k);
997 fFunc[k]->Save(XMin(k)[0],XMax(k)[0],0,0,0,0);
998 }
else if (NVariables(k) == 2) {
999 fFunc[k] =
new TF2(Form(
"%s_%i",Table()->GetName(),k),St_MDFCorrection4C::MDFunc,
1000 XMin(k)[0],XMax(k)[0],XMin(k)[1],XMax(k)[1],1);
1001 fFunc[k]->SetParameter(0,k);
1002 ((TF2 *) fFunc[k])->Save(XMin(k)[0],XMax(k)[0],XMin(k)[1],XMax(k)[1],0,0);
1003 }
else if (NVariables(k) == 3) {
1004 fFunc[k] =
new TF3(Form(
"%s_%i",Table()->GetName(),k),St_MDFCorrection4C::MDFunc,
1005 XMin(k)[0],XMax(k)[0],XMin(k)[1],XMax(k)[1],XMin(k)[2],XMax(k)[2],1);
1006 fFunc[k]->SetParameter(0,k);
1007 ((TF3 *) fFunc[k])->Save(XMin(k)[0],XMax(k)[0],XMin(k)[1],XMax(k)[1],XMin(k)[2],XMax(k)[2]);
1010 returnValue = fFunc[k]->GetSave(xx);
1012 Double_t par[1] = {(Double_t) k};
1013 returnValue = St_MDFCorrection4C::MDFunc(xx,par);
1018 Double_t St_MDFCorrection4C::EvalError(Int_t k, Double_t *x)
const {
1023 Double_t returnValue = 0;
1026 for (i = 0; i < NCoefficients(k); i++) {
1028 term = CoefficientsRMS(k)[i];
1029 for (j = 0; j < NVariables(k); j++) {
1031 Int_t p = Powers(k)[i * NVariables(k) + j];
1032 Double_t y = 1 + 2. / (XMax(k)[j] - XMin(k)[j])
1033 * (x[j] - XMax(k)[j]);
1034 term *= EvalFactor(p,y);
1037 returnValue += term*term;
1039 returnValue = TMath::Sqrt(returnValue);
1043 Double_t St_MDFCorrection4C::EvalFactor(Int_t k, Int_t p, Double_t x)
const {
1060 for (i = 3; i <= p; i++) {
1062 if (PolyType(k) == kLegendre)
1063 p3 = ((2 * i - 3) * p2 * x - (i - 2) * p1) / (i - 1);
1064 else if (PolyType(k) == kChebyshev)
1065 p3 = 2 * x * p2 - p1;
1074 Int_t St_MDFCorrection4C::IsActiveChair()
const {
1076 const St_MDFCorrection4 *tableMDF = (
const St_MDFCorrection4 *) Table();
1077 if (! tableMDF)
return npar;
1078 MDFCorrection4_st *corMDF = tableMDF->GetTable();
1080 if (! corMDF || ! N) {
1083 for (Int_t i = 0; i < N; i++, corMDF++) {
1084 if (corMDF->nrows == 0 && corMDF->idx == 0)
continue;
1090 #include "St_tpcEffectiveGeomC.h"
1091 MakeChairAltInstance(tpcEffectiveGeom,Calibrations/tpc/tpcEffectiveGeom,Calibrations/tpc/tpcEffectiveGeomB,gEnv->GetValue(
"NewTpcAlignment",0));
1092 #include "St_tpcElectronicsC.h"
1093 MakeChairAltInstance(tpcElectronics,Calibrations/tpc/tpcElectronics,Calibrations/tpc/tpcElectronicsB,gEnv->GetValue(
"NewTpcAlignment",0));
1094 #include "St_tpcPedestalC.h"
1095 MakeChairInstance(tpcPedestal,Calibrations/tpc/tpcPedestal);
1096 #include "St_tpcPadResponseC.h"
1097 MakeChairInstance(tpcPadResponse,Calibrations/tpc/tpcPadResponse);
1098 #include "St_tpcSlowControlSimC.h"
1099 MakeChairInstance(tpcSlowControlSim,Calibrations/tpc/tpcSlowControlSim);
1100 #include "St_tpcGainMonitorC.h"
1101 MakeChairInstance(tpcGainMonitor,Calibrations/tpc/tpcGainMonitor);
1102 #include "St_tpcHighVoltagesC.h"
1103 MakeChairInstance(tpcHighVoltages,Calibrations/tpc/tpcHighVoltages);
1104 #include "St_tpcPadrowT0C.h"
1105 MakeChairAltInstance(tpcPadrowT0,Calibrations/tpc/tpcPadrowT0,Calibrations/tpc/tpcPadrowT0B,gEnv->GetValue(
"NewTpcAlignment",0));
1106 #include "St_tpcSectorT0offsetC.h"
1107 MakeChairInstance(tpcSectorT0offset,Calibrations/tpc/tpcSectorT0offset);
1108 #include "St_tpcAltroParamsC.h"
1109 MakeChairInstance(tpcAltroParams,Calibrations/tpc/tpcAltroParams);
1110 #include "St_asic_thresholdsC.h"
1111 MakeChairInstance(asic_thresholds,Calibrations/tpc/asic_thresholds);
1112 #include "St_asic_thresholds_tpxC.h"
1113 MakeChairInstance(asic_thresholds_tpx,Calibrations/tpc/asic_thresholds_tpx);
1114 #include "St_tpcAnodeHVC.h"
1115 MakeChairInstance(tpcAnodeHV,Calibrations/tpc/tpcAnodeHV);
1116 #include "St_tpcPadPlanesC.h"
1117 #include "St_itpcPadPlanesC.h"
1118 #include "St_tpcPadConfigC.h"
1119 tpcPadConfig_st *St_tpcPadConfigC::Struct(Int_t i) {
return ((St_tpcPadConfig*) Table())->GetTable(i);}
1120 UInt_t St_tpcPadConfigC::getNumRows() {
return GetNRows();}
1121 UChar_t St_tpcPadConfigC::iTpc(Int_t sector) {UChar_t iTPC = Struct()->itpc[sector-1];
return iTPC;}
1122 Int_t St_tpcPadConfigC::padRows(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->padRows() :St_itpcPadPlanesC::instance()->padRows();}
1123 Int_t St_tpcPadConfigC::innerPadRows(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->innerPadRows() :St_itpcPadPlanesC::instance()->innerPadRows();}
1124 Int_t St_tpcPadConfigC::innerPadRows48(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->innerPadRows48() :St_itpcPadPlanesC::instance()->innerPadRows48();}
1125 Int_t St_tpcPadConfigC::innerPadRows52(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->innerPadRows52() :St_itpcPadPlanesC::instance()->innerPadRows52();}
1126 Int_t St_tpcPadConfigC::outerPadRows(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->outerPadRows() :St_itpcPadPlanesC::instance()->outerPadRows();}
1127 Int_t St_tpcPadConfigC::superInnerPadRows(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->superInnerPadRows() :St_itpcPadPlanesC::instance()->superInnerPadRows();}
1128 Int_t St_tpcPadConfigC::superOuterPadRows(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->superOuterPadRows() :St_itpcPadPlanesC::instance()->superOuterPadRows();}
1129 Double_t St_tpcPadConfigC::innerSectorPadWidth(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->innerSectorPadWidth() :St_itpcPadPlanesC::instance()->innerSectorPadWidth();}
1130 Double_t St_tpcPadConfigC::innerSectorPadLength(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->innerSectorPadLength() :St_itpcPadPlanesC::instance()->innerSectorPadLength();}
1131 Double_t St_tpcPadConfigC::innerSectorPadPitch(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->innerSectorPadPitch() :St_itpcPadPlanesC::instance()->innerSectorPadPitch();}
1132 Double_t St_tpcPadConfigC::innerSectorRowPitch1(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->innerSectorRowPitch1() :St_itpcPadPlanesC::instance()->innerSectorRowPitch1();}
1133 Double_t St_tpcPadConfigC::innerSectorRowPitch2(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->innerSectorRowPitch2() :St_itpcPadPlanesC::instance()->innerSectorRowPitch2();}
1134 Double_t St_tpcPadConfigC::firstPadRow(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->firstPadRow() :St_itpcPadPlanesC::instance()->firstPadRow();}
1135 Double_t St_tpcPadConfigC::firstOuterSectorPadRow(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->firstOuterSectorPadRow():St_itpcPadPlanesC::instance()->firstOuterSectorPadRow();}
1136 Double_t St_tpcPadConfigC::lastOuterSectorPadRow(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->lastOuterSectorPadRow() :St_itpcPadPlanesC::instance()->lastOuterSectorPadRow();}
1137 Double_t St_tpcPadConfigC::firstRowWidth(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->firstRowWidth() :St_itpcPadPlanesC::instance()->firstRowWidth();}
1138 Double_t St_tpcPadConfigC::lastRowWidth(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->lastRowWidth() :St_itpcPadPlanesC::instance()->lastRowWidth();}
1139 Double_t St_tpcPadConfigC::outerSectorPadWidth(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->outerSectorPadWidth() :St_itpcPadPlanesC::instance()->outerSectorPadWidth();}
1140 Double_t St_tpcPadConfigC::outerSectorPadLength(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->outerSectorPadLength() :St_itpcPadPlanesC::instance()->outerSectorPadLength();}
1141 Double_t St_tpcPadConfigC::outerSectorPadPitch(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->outerSectorPadPitch() :St_itpcPadPlanesC::instance()->outerSectorPadPitch();}
1142 Double_t St_tpcPadConfigC::outerSectorRowPitch(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->outerSectorRowPitch() :St_itpcPadPlanesC::instance()->outerSectorRowPitch();}
1143 Double_t St_tpcPadConfigC::outerSectorLength(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->outerSectorLength() :St_itpcPadPlanesC::instance()->outerSectorLength();}
1144 Double_t St_tpcPadConfigC::ioSectorSeparation(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->ioSectorSeparation() :St_itpcPadPlanesC::instance()->ioSectorSeparation();}
1145 Double_t St_tpcPadConfigC::innerSectorEdge(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->innerSectorEdge() :St_itpcPadPlanesC::instance()->innerSectorEdge();}
1146 Double_t St_tpcPadConfigC::outerSectorEdge(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->outerSectorEdge() :St_itpcPadPlanesC::instance()->outerSectorEdge();}
1147 Double_t St_tpcPadConfigC::innerSectorPadPlaneZ(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->innerSectorPadPlaneZ() :St_itpcPadPlanesC::instance()->innerSectorPadPlaneZ();}
1148 Double_t St_tpcPadConfigC::outerSectorPadPlaneZ(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->outerSectorPadPlaneZ() :St_itpcPadPlanesC::instance()->outerSectorPadPlaneZ();}
1149 Int_t* St_tpcPadConfigC::innerPadsPerRow(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->innerPadsPerRow() :St_itpcPadPlanesC::instance()->innerPadsPerRow();}
1150 Int_t* St_tpcPadConfigC::outerPadsPerRow(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->outerPadsPerRow() :St_tpcPadPlanesC::instance()->outerPadsPerRow();}
1151 Int_t St_tpcPadConfigC::padsPerRow(Int_t sector, Int_t row) {
1152 Int_t Ninner = innerPadRows(sector);
1153 return (row <= Ninner) ?
1154 innerPadsPerRow(sector)[row-1] :
1155 outerPadsPerRow(sector)[row-1-Ninner];
1157 Double_t* St_tpcPadConfigC::innerRowRadii(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->innerRowRadii() :St_itpcPadPlanesC::instance()->innerRowRadii();}
1158 Double_t* St_tpcPadConfigC::outerRowRadii(Int_t sector) {
return (! iTpc(sector)) ? St_tpcPadPlanesC::instance()->outerRowRadii() :St_itpcPadPlanesC::instance()->outerRowRadii();}
1160 Int_t St_tpcPadConfigC::numberOfRows(Int_t sector) {
return padRows(sector);}
1161 Int_t St_tpcPadConfigC::numberOfInnerRows(Int_t sector) {
return innerPadRows(sector);}
1162 Int_t St_tpcPadConfigC::numberOfInnerRows48(Int_t sector) {
return innerPadRows48(sector);}
1163 Int_t St_tpcPadConfigC::numberOfInnerRows52(Int_t sector) {
return innerPadRows52(sector);}
1164 Int_t St_tpcPadConfigC::numberOfOuterRows(Int_t sector) {
return outerPadRows(sector);}
1165 Bool_t St_tpcPadConfigC::isRowInRange(Int_t sector, Int_t row) {
return (row >= 1 && row<=numberOfRows(sector)) ? kTRUE: kFALSE;}
1166 Double_t St_tpcPadConfigC::radialDistanceAtRow(Int_t sector, Int_t row) {
1167 if (! isRowInRange(sector,row))
return 0;
1168 Int_t Ninner = innerPadRows(sector);
1169 if ( row<=Ninner )
return innerRowRadii(sector)[row-1];
1170 else return outerRowRadii(sector)[row-1-Ninner];
1172 Int_t St_tpcPadConfigC::numberOfPadsAtRow(Int_t sector, Int_t row) {
1173 if (! isRowInRange(sector, row))
return 0;
1174 Int_t Ninner = innerPadRows(sector);
1175 if ( row<=Ninner )
return innerPadsPerRow(sector)[row-1];
1176 return outerPadsPerRow(sector)[row-1-Ninner];
1178 Double_t St_tpcPadConfigC::PadWidthAtRow(Int_t sector, Int_t row) {
1179 if (! isRowInRange(sector,row))
return 0;
1180 Int_t Ninner = innerPadRows(sector);
1181 if ( row<=Ninner)
return innerSectorPadWidth(sector);
1182 return outerSectorPadWidth(sector);
1184 Double_t St_tpcPadConfigC::PadLengthAtRow(Int_t sector, Int_t row) {
1185 if (! isRowInRange(sector,row))
return 0;
1186 Int_t Ninner = innerPadRows(sector);
1187 if ( row<=Ninner)
return innerSectorPadLength(sector);
1188 return outerSectorPadLength(sector);
1190 Double_t St_tpcPadConfigC::PadPitchAtRow(Int_t sector, Int_t row) {
1191 if (! isRowInRange(sector,row))
return 0;
1192 Int_t Ninner = innerPadRows(sector);
1193 if ( row<=Ninner)
return innerSectorPadPitch(sector);
1194 return outerSectorPadPitch(sector);
1196 Double_t St_tpcPadConfigC::RowPitchAtRow(Int_t sector, Int_t row) {
1197 if (! isRowInRange(sector,row))
return 0;
1198 Int_t Ninner = innerPadRows(sector);
1199 if ( row<=numberOfInnerRows48(sector) )
return innerSectorRowPitch1(sector);
1200 else if (row>numberOfInnerRows48(sector)&&row<=Ninner)
return innerSectorRowPitch2(sector);
1201 return outerSectorRowPitch(sector);
1203 Int_t St_tpcPadConfigC::indexForRowPad(Int_t sector, Int_t row, Int_t pad) {
1204 if (pad >numberOfPadsAtRow(sector,row))
return -1;
1206 Int_t Ninner = innerPadRows(sector);
1207 if (row>0 && row<=Ninner )
for (Int_t i=1;i<row;i++) index += numberOfPadsAtRow(sector,i);
1209 if (row>Ninner&&row<=numberOfRows(sector))
for (Int_t i=Ninner+1;i<row;i++) index += numberOfPadsAtRow(sector,i);
1213 #include "St_TpcAvgPowerSupplyC.h"
1215 void St_tpcAnodeHVC::sockets(Int_t sector, Int_t padrow, Int_t &e1, Int_t &e2, Float_t &f2) {
1222 if (! St_tpcPadConfigC::instance()->iTPC(sector)) {
1224 case 1: e1+= 1; e2+= 2; f2 = 0.00197;
break;
1225 case 2: e1+= 2;
break;
1226 case 3: e1+= 3; e2+= 2; f2 = 0.04547;
break;
1227 case 4: e1+= 3;
break;
1228 case 5: e1+= 4;
break;
1229 case 6: e1+= 4; e2+= 5; f2 = 0.00007;
break;
1230 case 7: e1+= 5;
break;
1231 case 8: e1+= 6; e2+= 5; f2 = 0.04547;
break;
1232 case 9: e1+= 6;
break;
1233 case 10: e1+= 7;
break;
1234 case 11: e1+= 8; e2+= 7; f2 = 0.33523;
break;
1235 case 12: e1+= 8;
break;
1236 case 13: e1+=17;
break;
1237 case 14: e1+= 9; e2+=18; f2 = 0.00312;
break;
1239 case 16: e1+= 9;
break;
1240 case 17: e1+= 9; e2+=10; f2 = 0.40250;
break;
1243 case 20: e1+=10;
break;
1244 case 21: e1+=10; e2+=11; f2 = 0.40250;
break;
1247 case 24: e1+=11;
break;
1248 case 25: e1+=11; e2+=12; f2 = 0.40250;
break;
1251 case 28: e1+=12;
break;
1252 case 29: e1+=12; e2+=13; f2 = 0.40250;
break;
1255 case 32: e1+=13;
break;
1256 case 33: e1+=13; e2+=14; f2 = 0.40250;
break;
1259 case 36: e1+=14;
break;
1260 case 37: e1+=14; e2+=15; f2 = 0.40250;
break;
1263 case 40: e1+=15;
break;
1264 case 41: e1+=15; e2+=16; f2 = 0.40250;
break;
1267 case 44: e1+=16;
break;
1268 case 45: e1+=16; e2+=19; f2 = 0.40250;
break;
1269 default: e1 = 0; e2 = 0; f2 = 0;
1275 case 3: e1+= 1; e2+= 1;
break;
1276 case 4: e1+= 1; e2+= 2;
break;
1280 case 8: e1+= 2; e2+= 2;
break;
1281 case 9: e1+= 2; e2+= 3;
break;
1285 case 13: e1+= 3; e2+= 3;
break;
1286 case 14: e1+= 3; e2+= 4;
break;
1290 case 18: e1+= 4; e2+= 4;
break;
1291 case 19: e1+= 4; e2+= 5;
break;
1295 case 23: e1+= 5; e2+= 5;
break;
1296 case 24: e1+= 5; e2+= 6;
break;
1300 case 28: e1+= 6; e2+= 6;
break;
1301 case 29: e1+= 6; e2+= 7;
break;
1305 case 33: e1+= 7; e2+= 7;
break;
1306 case 34: e1+= 7; e2+= 8;
break;
1310 case 38: e1+= 8; e2+= 8;
break;
1312 case 40: e1+=17; e2+=17;
break;
1313 case 41: e1+= 9; e2+=18;
break;
1315 case 43: e1+= 9;
break;
1316 case 44: e1+= 9; e2+=10;
break;
1319 case 47: e1+=10;
break;
1320 case 48: e1+=10; e2+=11;
break;
1323 case 51: e1+=11;
break;
1324 case 52: e1+=11; e2+=12; f2 = 0.40250;
break;
1327 case 55: e1+=12;
break;
1328 case 56: e1+=12; e2+=13; f2 = 0.40250;
break;
1331 case 59: e1+=13;
break;
1332 case 60: e1+=13; e2+=14; f2 = 0.40250;
break;
1335 case 63: e1+=14;
break;
1336 case 64: e1+=14; e2+=15; f2 = 0.40250;
break;
1339 case 67: e1+=15;
break;
1340 case 68: e1+=15; e2+=16; f2 = 0.40250;
break;
1343 case 71: e1+=16;
break;
1344 case 72: e1+=16; e2+=19; f2 = 0.40250;
break;
1345 default: e1 = 0; e2 = 0; f2 = 0;
1350 Float_t St_tpcAnodeHVC::voltage(Int_t i)
const {
1351 if (! St_TpcAvgPowerSupplyC::instance()->Table()->IsMarked()) {
1352 LOG_ERROR <<
"St_tpcAnodeHVC::voltage(" << i <<
" is called but the valid St_TpcAvgPowerSupplyC::instance() exists" << endm;
1354 return Struct(i)->voltage;
1357 Float_t St_tpcAnodeHVC::voltagePadrow(Int_t sector, Int_t padrow)
const {
1358 if (! St_TpcAvgPowerSupplyC::instance()->Table()->IsMarked()) {
1359 return St_TpcAvgPowerSupplyC::instance()->voltagePadrow(sector,padrow);
1361 Int_t e1 = 0, e2 = 0;
1363 St_tpcAnodeHVC::sockets(sector, padrow, e1, e2, f2);
1364 if (e1==0)
return -99;
1365 Float_t v1=voltage(e1-1);
1366 if (f2 < 0.1)
return v1;
1367 Float_t v2=voltage(e2-1);
1368 if (TMath::Abs(v2 - v1) > 40)
return -99;
1369 if (TMath::Abs(v2 - v1) < 1)
return v1;
1372 Float_t B = (padrow <= St_tpcPadConfigC::instance()->innerPadRows(sector) ? 13.05e-3 : 10.26e-3);
1373 Float_t v_eff = TMath::Log((1.0-f2)*TMath::Exp(B*v1) + f2*TMath::Exp(B*v2)) / B;
1376 MakeChairOptionalInstance(TpcAvgPowerSupply,Calibrations/tpc/TpcAvgPowerSupply);
1378 Float_t St_TpcAvgPowerSupplyC::voltagePadrow(Int_t sector, Int_t padrow)
const {
1379 Int_t e1 = 0, e2 = 0;
1381 St_tpcAnodeHVC::sockets(sector, padrow, e1, e2, f2);
1382 if (e1==0)
return -99;
1383 Int_t ch1 = St_TpcAvgCurrentC::ChannelFromSocket((e1-1)%19+1);
1384 Float_t v1=Voltage()[8*(sector-1)+ch1-1] ;
1385 if (f2==0)
return v1;
1386 Int_t ch2 = St_TpcAvgCurrentC::ChannelFromSocket((e2-1)%19 + 1);
1387 if (ch1 == ch2)
return v1;
1388 Float_t v2=Voltage()[8*(sector-1)+ch2-1] ;
1389 if (v2==v1)
return v1;
1392 Float_t B = (padrow <= St_tpcPadConfigC::instance()->innerPadRows(sector) ? 13.05e-3 : 10.26e-3);
1393 Float_t v_eff = TMath::Log((1.0-f2)*TMath::Exp(B*v1) + f2*TMath::Exp(B*v2)) / B;
1397 Float_t St_TpcAvgPowerSupplyC::AcChargeL(Int_t sector, Int_t channel) {
1401 static Float_t Length[8] = {
1411 return AcCharge(sector,channel)/Length[channel-1];
1414 void St_TpcAvgPowerSupplyC::PrintC()
const {
1415 const St_TpcAvgPowerSupply *TpcAvgPowerSupply = (St_TpcAvgPowerSupply *) GetThisTable();
1416 const TpcAvgPowerSupply_st &avgC = *TpcAvgPowerSupply->GetTable();
1417 Double_t AcCharge[2] = {0, 0};
1418 cout <<
"TpcAvgPowerSupply for run = " << avgC.run << endl;
1419 for (Int_t sec = 1; sec <= 24; sec++) {
1420 cout <<
"Voltage " << sec;
1421 for (Int_t socket = 1; socket <= 8; socket++) cout <<
"\t" << Form(
"%10.3f",avgC.Voltage[8*(sec-1)+socket-1]);
1424 for (Int_t sec = 1; sec <= 24; sec++) {
1425 cout <<
"Current " << sec;
1426 for (Int_t socket = 1; socket <= 8; socket++) cout <<
"\t" << Form(
"%10.5f",avgC.Current[8*(sec-1)+socket-1]);
1429 for (Int_t sec = 1; sec <= 24; sec++) {
1430 cout <<
"Charge " << sec;
1431 for (Int_t socket = 1; socket <= 8; socket++) {
1432 cout <<
"\t" << Form(
"%10.3f",avgC.Charge[8*(sec-1)+socket-1]);
1434 if (socket > 4) io = 1;
1435 AcCharge[io] += avgC.Charge[8*(sec-1)+socket-1];
1439 cout <<
"Run " << avgC.run <<
" Accumulated charge Inner = " << AcCharge[0] <<
" (C), Outer = " << AcCharge[1] <<
"(C)" << endl;
1441 #include "St_tpcAnodeHVavgC.h"
1442 MakeChairInstance(tpcAnodeHVavg,Calibrations/tpc/tpcAnodeHVavg);
1444 Float_t St_tpcAnodeHVavgC::voltage(Int_t i)
const {
1445 if (! St_TpcAvgPowerSupplyC::instance()->Table()->IsMarked()) {
1446 LOG_ERROR <<
"St_tpcAnodeHVavgC::voltage(" << i <<
" is called but the valid St_TpcAvgPowerSupplyC::instance() exists" << endm;
1448 return Struct(i)->voltage;
1451 Bool_t St_tpcAnodeHVavgC::tripped(Int_t sector, Int_t padrow)
const {
1452 if (! St_TpcAvgPowerSupplyC::instance()->Table()->IsMarked()) {
1453 return St_TpcAvgPowerSupplyC::instance()->tripped(sector,padrow);
1455 return (voltage() < -100);
1458 Float_t St_tpcAnodeHVavgC::voltagePadrow(Int_t sector, Int_t padrow)
const {
1459 if (! St_TpcAvgPowerSupplyC::instance()->Table()->IsMarked()) {
1460 return St_TpcAvgPowerSupplyC::instance()->voltagePadrow(sector,padrow);
1462 Int_t e1 = 0, e2 = 0;
1464 St_tpcAnodeHVC::sockets(sector, padrow, e1, e2, f2);
1465 if (e1==0)
return -99;
1466 Float_t v1=voltage(e1-1);
1467 if (f2==0)
return v1;
1468 Float_t v2=voltage(e2-1);
1469 if (v2==v1)
return v1;
1472 Float_t B = (padrow <= St_tpcPadConfigC::instance()->innerPadRows(sector) ? 13.05e-3 : 10.26e-3);
1473 Float_t v_eff = TMath::Log((1.0-f2)*TMath::Exp(B*v1) + f2*TMath::Exp(B*v2)) / B;
1477 #include "St_tpcRDOMasksC.h"
1482 if (fgInstance)
return fgInstance;
1483 St_tpcRDOMasks *table = (St_tpcRDOMasks *) StMaker::GetChain()->GetDataBase(
"RunLog/onl/tpcRDOMasks");
1485 LOG_WARN <<
"St_tpcRDOMasksC::instance RunLog/onl/tpcRDOMasks was not found" << endm;
1487 assert(table->GetNRows() == 12);
1489 DEBUGTABLE(tpcRDOMasks);
1491 Bool_t needReorder = kFALSE;
1492 tpcRDOMasks_st *row = table->GetTable();
1494 UInt_t N = table->GetNRows();
1496 needReorder = kTRUE;
1497 LOG_WARN <<
"St_tpcRDOMasksC::instance RunLog/onl/tpcRDOMasks has NRows = " << N <<
" =! 12" << endm;
1499 for (UInt_t i = 0; i < N; i++) {
1500 if ((row+i)->sector == 2*i + 1)
continue;
1501 needReorder = kTRUE;
1506 LOG_WARN <<
"St_tpcRDOMasksC::instance RunLog/onl/tpcRDOMasks has to be reordered" << endm;
1507 tpcRDOMasks_st rows[12] = {0};
1509 for (UInt_t i = 0; i < N; i++) {
1510 if ((row+i)->sector == 2*i + 1) {
1512 if ((row+i)->runNumber > 0 && OldRun < 0) OldRun = (row+i)->runNumber;
1515 if ((row+i)->sector > 0 && (row+i)->sector <= 24) {
1516 if ((row+i)->runNumber > 0 && OldRun < 0) OldRun = (row+i)->runNumber;
1517 Int_t j = ((row+i)->sector-1)/2;
1518 if (rows[j].sector != 0) {
1519 LOG_ERROR <<
"St_tpcRDOMasksC::instance RunLog/onl/tpcRDOMasks has duplicated rows\t" << i <<
"\tand " << j << endm;
1526 if (Nactive != 12) {
1528 table =
new St_tpcRDOMasks(
"tpcRDOMasks", 12);
1530 for (Int_t i = 0; i < 12; i++) {
1531 if (rows[i].sector == 0) {
1532 rows[i].sector = 2*i + 1;
1533 rows[i].runNumber = OldRun;
1534 if (St_tpcPadConfigC::instance()->iTpc(rows[i].sector)) {
1535 rows[i].mask = 65535;
1537 rows[i].mask = 4095;
1542 for (Int_t i = 0; i < 12; i++) {
1543 table->AddAt(&rows[i],i);
1548 if (StDetectorDbMaker::instance()) {
1549 fgInstance->SetName(
"tpcRDOMasksC");
1550 StDetectorDbMaker::instance()->AddConst(fgInstance);
1555 UInt_t St_tpcRDOMasksC::getSectorMask(UInt_t sec) {
1556 static UInt_t Sector = 0;
1557 static UInt_t Mask = 0;
1558 if (Sector == sec) {
1561 UInt_t MASK = 0x0000;
1563 if(sec < 1 || sec > 24 || getNumRows() == 0){
1564 LOG_WARN <<
"St_tpcRDOMasksC:: getSectorMask : return default mask for "
1565 <<
"sector= " << sec <<
" getNumRows()=" << getNumRows() << endm;
1571 tpcRDOMasks_st *row = Struct((sec-1)/2);
1573 Int_t run = row->runNumber;
1574 if (! St_tpcPadConfigC::instance()->iTpc(sec)) {
1575 if (sec == 16 && MASK == 0 && run > 8181000 && run < 9181000) MASK = 4095;
1581 }
else if (run < 20000000 && sec == 20) {
1595 Bool_t St_tpcRDOMasksC::isOn(Int_t sector,Int_t rdo) {
1596 static Int_t Sector = -1;
1597 static Int_t Rdo = -1;
1598 static Bool_t Mask = kFALSE;
1599 if (Sector == sector && Rdo == rdo) {
1605 if(sector < 1 || sector > 24 || rdo < 1 || rdo > 8) {
1609 tpcRDOMasks_st *row = Struct((sector-1)/2);
1610 assert(row->sector == (UInt_t) 2*((sector-1)/2) + 1);
1611 UInt_t MASK = getSectorMask(sector);
1612 MASK = MASK >> (rdo - 1);
1618 void St_tpcRDOMasksC::setSectorRDOMaskOff(UInt_t sector,Int_t rdo) {
1619 if(sector < 1 || sector > 24 || rdo < 1 || rdo > 8)
return;
1620 if (isOn(sector,rdo)) {
1621 tpcRDOMasks_st *row = Struct((sector-1)/2);
1622 assert(row->sector == 2*((sector-1)/2) + 1);
1623 if (! St_tpcPadConfigC::instance()->iTpc(sector)) {
1624 row->mask &= ~(1 << (6*((sector-1)%2) + rdo - 1));
1626 row->mask &= ~(1 << (8*((sector-1)%2) + rdo - 1));
1629 LOG_WARN <<
"St_tpcRDOMasksC::setSectorRDOMaskOff(" << sector <<
"," << rdo <<
") = " << isOn(sector,rdo) << endm;
1633 #include "St_tpcExtraGainCorrectionC.h"
1634 MakeChairInstance(tpcExtraGainCorrection,Calibrations/tpc/tpcExtraGainCorrection);
1636 #include "St_tpcPadGainT0C.h"
1641 if (fgInstance)
return fgInstance;
1642 St_tpcPadGainT0 *table = (St_tpcPadGainT0 *) StMaker::GetChain()->GetDataBase(
"Calibrations/tpc/tpcPadGainT0");
1644 LOG_WARN <<
"St_tpcPadGainT0C::instance Calibrations/tpc/tpcPadGainT0\twas not found" << endm;
1648 if (StDetectorDbMaker::instance()) {
1649 fgInstance->SetName(
"tpcPadGainT0C");
1650 StDetectorDbMaker::instance()->AddConst(fgInstance);
1655 Int_t nrows = extra->nrows();
1656 for (Int_t i = 0; i < nrows; i++) {
1657 if (extra->idx(i) <= 0)
continue;
1658 Int_t runMin = extra->runMin(i);
1659 Int_t runMax = extra->runMax(i);
1660 if (run < runMin || run > runMax)
continue;
1661 Int_t sector = extra->sector(i);
1662 if (sector < 0 || sector > 24)
continue;
1663 Int_t row = extra->row(i);
1664 if (row > 72) row = -1;
1665 Int_t padMin = extra->padMin(i);
1666 Int_t padMax = extra->padMax(i);
1667 Int_t RDO = extra->RDO(i);
1668 Int_t FEE = extra->FEE(i);
1669 Int_t status = extra->status(i);
1670 if (status)
continue;
1671 if (padMin < padMax && row > 0) {
1673 if (St_tpcPadConfigC::instance()->iTPC(sector)) {
1674 if (row <= 40)
continue;
1677 LOG_WARN <<
"St_tpcPadGainT0C::instance found extra correction for run = " << run <<
" in [" << runMin <<
"," << runMax <<
"]"
1678 << Form(
" with sec = %2i, row = %2i, padMin/Max = %3i/%3i, RDO = %2i, FEE = %2i, status = %i",
1679 sector, r, padMin, padMax, RDO, FEE, status) << endm;
1680 Float_t *gains = St_tpcPadGainT0C::instance()->Gains(sector, r);
1681 for (Int_t p = padMin; p <= padMax; p++) {
1682 if (gains[p-1] > 0) {
1683 LOG_WARN <<
"St_tpcPadGainT0C::instance reset gain[" << sector-1 <<
"][" << r - 1 <<
"][" << p-1 <<
"] = " << gains[p-1] <<
" to zero" << endm;
1687 }
else if (FEE > 0) {
1688 }
else if (RDO > 0) {
1689 LOG_WARN <<
"St_tpcPadGainT0C::instance found extra correction for run = " << run <<
" in [" << runMin <<
"," << runMax <<
"]"
1690 << Form(
" reset tpcRDOMasks for sector = %i and RDO = %i to zero with sec = %2i, row = %2i, padMin/Max = %3i/%3i, RDO = %2i, FEE = %2i, status = %i",
1691 sector, RDO, sector, row, padMin, padMax, RDO, FEE, status) << endm;
1692 St_tpcRDOMasksC::instance()->setSectorRDOMaskOff(sector,RDO);
1694 LOG_WARN <<
"St_tpcPadGainT0C::instance found extra correction for run = " << run <<
" in [" << runMin <<
"," << runMax <<
"]"
1695 << Form(
" with sec = %2i, row = %2i, padMin/Max = %3i/%3i, RDO = %2i, FEE = %2i, status = %i => whole sector is marker as DEAD",
1696 sector, row, padMin, padMax, RDO, FEE, status) << endm;
1699 if (! St_tpcPadConfigC::instance()->iTPC(sector)) {rdoMin = 5; rdoMax = 8;}
1700 for (Int_t rdoD = rdoMin; rdoD <= rdoMax; rdoD++) {
1701 St_tpcRDOMasksC::instance()->setSectorRDOMaskOff(sector,rdoD);
1708 #include "St_itpcDeadFEEC.h"
1709 MakeChairInstance(itpcDeadFEE,Calibrations/tpc/itpcDeadFEE);
1710 #include "St_itpcPadGainT0C.h"
1718 { 1, 27, 52, 55, 1},
1720 { 2, 28, 54, 55, 1},
1722 { 3, 23, 28, 54, 1},
1723 { 3, 29, 34, 55, 1},
1724 { 3, 35, 56, 53, 1},
1726 { 4, 25, 29, 54, 1},
1727 { 4, 30, 34, 55, 1},
1728 { 4, 35, 58, 53, 1},
1730 { 5, 11, 20, 49, 1},
1731 { 5, 21, 40, 50, 1},
1732 { 5, 41, 50, 51, 1},
1733 { 5, 51, 60, 53, 1},
1735 { 6, 22, 41, 50, 1},
1736 { 6, 42, 54, 51, 1},
1737 { 6, 55, 62, 53, 1},
1740 { 7, 26, 37, 50, 1},
1741 { 7, 38, 59, 51, 1},
1743 { 7, 60, 62, 48, 1},
1745 { 8, 27, 38, 50, 1},
1746 { 8, 39, 57, 51, 1},
1747 { 8, 58, 64, 48, 1},
1750 { 9, 26, 41, 47, 1},
1751 { 9, 42, 66, 48, 1},
1753 {10, 26, 43, 47, 1},
1754 {10, 44, 68, 48, 1},
1757 {11, 28, 43, 47, 1},
1758 {11, 44, 70, 45, 2},
1761 {12, 30, 43, 47, 1},
1762 {12, 44, 72, 45, 2},
1765 {13, 23, 52, 44, 2},
1767 {13, 53, 70, 42, 2},
1768 {13, 71, 74, 45, 2},
1770 {14, 23, 52, 44, 2},
1771 {14, 53, 74, 42, 2},
1773 {15, 23, 54, 41, 2},
1774 {15, 55, 68, 42, 2},
1775 {15, 69, 76, 39, 2},
1778 {16, 14, 23, 40, 2},
1779 {16, 24, 55, 41, 2},
1780 {16, 56, 65, 42, 2},
1781 {16, 66, 78, 39, 2},
1783 {17, 25, 40, 37, 2},
1784 {17, 41, 56, 38, 2},
1785 {17, 57, 80, 39, 2},
1787 {18, 20, 41, 37, 2},
1788 {18, 42, 63, 38, 2},
1789 {18, 64, 82, 39, 2},
1791 {19, 27, 42, 37, 2},
1792 {19, 43, 58, 38, 2},
1793 {19, 59, 84, 35, 2},
1795 {20, 23, 33, 33, 2},
1796 {20, 34, 43, 37, 2},
1797 {20, 44, 53, 38, 2},
1798 {20, 54, 64, 34, 2},
1799 {20, 65, 86, 35, 2},
1802 {21, 25, 43, 33, 2},
1803 {21, 44, 62, 34, 2},
1805 {21, 63, 82, 31, 4},
1806 {21, 83, 86, 35, 2},
1809 {22, 26, 44, 33, 2},
1810 {22, 45, 63, 34, 2},
1811 {22, 64, 80, 31, 4},
1812 {22, 81, 88, 35, 2},
1816 {23, 11, 18, 24, 3},
1817 {23, 19, 36, 29, 3},
1818 {23, 37, 45, 33, 2},
1819 {23, 46, 54, 34, 2},
1820 {23, 55, 72, 30, 4},
1821 {23, 73, 80, 27, 4},
1822 {23, 81, 90, 31, 4},
1825 {24, 16, 26, 24, 3},
1826 {24, 27, 44, 29, 3},
1827 {24, 45, 46, 33, 2},
1828 {24, 47, 48, 34, 2},
1829 {24, 49, 66, 30, 4},
1830 {24, 67, 77, 27, 4},
1831 {24, 78, 92, 31, 4},
1834 {25, 21, 29, 29, 3},
1835 {25, 30, 47, 25, 3},
1836 {25, 48, 65, 26, 4},
1837 {25, 66, 74, 30, 4},
1838 {25, 75, 94, 27, 4},
1841 {26, 22, 35, 29, 3},
1842 {26, 36, 48, 25, 3},
1843 {26, 49, 61, 26, 4},
1844 {26, 62, 75, 30, 4},
1845 {26, 76, 96, 27, 4},
1848 {27, 25, 32, 20, 3},
1849 {27, 33, 42, 25, 3},
1850 {27, 43, 56, 21, 3},
1851 {27, 57, 66, 26, 4},
1852 {27, 67, 74, 22, 4},
1853 {27, 75, 98, 23, 4},
1856 {28, 17, 24, 20, 3},
1857 {28, 25, 42, 25, 3},
1858 {28, 43, 56, 21, 3},
1859 {28, 57, 74, 26, 4},
1860 {28, 75, 82, 22, 4},
1861 {28, 83, 98, 23, 4},
1864 {29, 13, 20, 19, 3},
1865 {29, 21, 42, 20, 3},
1866 {29, 43, 58, 21, 3},
1867 {29, 59, 80, 22, 4},
1868 {29, 81, 88, 23, 4},
1869 {29, 89,100, 18, 4},
1872 {30, 22, 43, 20, 3},
1873 {30, 44, 59, 21, 3},
1874 {30, 60, 81, 22, 4},
1876 {30, 82, 97, 23, 4},
1877 {30, 98,102, 18, 4},
1880 {31, 21, 40, 13, 3},
1881 {31, 41, 42, 20, 3},
1882 {31, 43, 62, 14, 4},
1883 {31, 63, 64, 22, 4},
1884 {31, 65, 84, 15, 4},
1885 {31, 85,104, 18, 4},
1888 {32, 28, 43, 13, 3},
1889 {32, 44, 63, 14, 4},
1890 {32, 64, 79, 15, 4},
1891 {32, 80,106, 18, 4},
1894 {33, 33, 43, 13, 3},
1895 {33, 44, 49, 14, 4},
1897 {33, 60, 65, 14, 4},
1898 {33, 66, 76, 15, 4},
1899 {33, 77,108, 16, 4},
1902 {34, 29, 44, 13, 3},
1903 {34, 45, 49, 14, 4},
1905 {34, 62, 66, 14, 4},
1906 {34, 67, 82, 15, 4},
1907 {34, 83,110, 16, 4},
1912 {35, 67, 91, 10, 4},
1913 {35, 92,110, 11, 4},
1916 {36, 21, 24, 12, 3},
1919 {36, 67, 88, 10, 4},
1920 {36, 89, 92, 16, 4},
1921 {36, 93,112, 11, 4},
1930 {37, 70, 76, 10, 4},
1932 {37, 89,101, 11, 4},
1941 {38, 71, 80, 10, 4},
1943 {38, 93,104, 11, 4},
1959 Int_t St_itpcPadGainT0C::NCrowpadFEE =
sizeof(St_itpcPadGainT0C::rowpadFEE)/
sizeof(
rowpadFEEmap_t);
1962 if (fgInstance)
return fgInstance;
1963 St_itpcPadGainT0 *table = (St_itpcPadGainT0 *) StMaker::GetChain()->GetDataBase(
"Calibrations/tpc/itpcPadGainT0");
1965 LOG_WARN <<
"St_itpcPadGainT0C::instance Calibrations/tpc/itpcPadGainT0\twas not found" << endm;
1969 if (StDetectorDbMaker::instance()) {
1970 fgInstance->SetName(
"itpcPadGainT0C");
1971 StDetectorDbMaker::instance()->AddConst(fgInstance);
1976 Int_t nrows = extra->nrows();
1977 for (Int_t i = 0; i < nrows; i++) {
1978 if (extra->idx(i) <= 0)
continue;
1979 Int_t runMin = extra->runMin(i);
1980 Int_t runMax = extra->runMax(i);
1981 if (run < runMin || run > runMax)
continue;
1982 Int_t sector = extra->sector(i);
1983 if (sector < 0 || sector > 24)
continue;
1984 Int_t row = extra->row(i);
1985 if (row > 40)
continue;
1986 Int_t padMin = extra->padMin(i);
1987 Int_t padMax = extra->padMax(i);
1988 Int_t RDO = extra->RDO(i);
1989 Int_t FEE = extra->FEE(i);
1990 Int_t status = extra->status(i);
1991 if (status)
continue;
1992 if (padMin < padMax && row > 0) {
1994 LOG_WARN <<
"St_itpcPadGainT0C::instance found extra correction for run = " << run <<
" in [" << runMin <<
"," << runMax <<
"]"
1995 << Form(
" with sec = %2i, row = %2i, padMin/Max = %3i/%3i, RDO = %2i, FEE = %2i, status = %i",
1996 sector, r, padMin, padMax, RDO, FEE, status) << endm;
1997 Float_t *gains = St_itpcPadGainT0C::instance()->Gains(sector, r);
1998 for (Int_t p = padMin; p <= padMax; p++) {
1999 if (gains[p-1] > 0) {
2000 LOG_WARN <<
"St_itpcPadGainT0C::instance reset gain[" << sector-1 <<
"][" << r - 1 <<
"][" << p-1 <<
"] = " << gains[p-1] <<
" to zero" << endm;
2004 }
else if (FEE > 0) {
2005 for (Int_t j = 0; j < St_itpcPadGainT0C::NCrowpadFEE; j++) {
2006 if (St_itpcPadGainT0C::rowpadFEE[j].fee != FEE)
continue;
2007 Int_t r = St_itpcPadGainT0C::rowpadFEE[j].row;
2008 padMin = St_itpcPadGainT0C::rowpadFEE[j].padMin;
2009 padMax = St_itpcPadGainT0C::rowpadFEE[j].padMax;
2010 LOG_WARN <<
"St_itpcPadGainT0C::instance found extra correction for run = " << run <<
" in [" << runMin <<
"," << runMax <<
"]"
2011 << Form(
" with sec = %2i, row = %2i, padMin/Max = %3i/%3i, RDO = %2i, FEE = %2i, status = %i",
2012 sector, r, padMin, padMax, RDO, FEE, status) << endm;
2013 Float_t *gains = St_itpcPadGainT0C::instance()->Gains(sector, r);
2014 for (Int_t p = padMin; p <= padMax; p++) {
2015 if (gains[p-1] > 0) {
2016 LOG_WARN <<
"St_itpcPadGainT0C::instance reset gain[" << sector-1 <<
"][" << r - 1 <<
"][" << p-1 <<
"] = " << gains[p-1] <<
" to zero" << endm;
2021 }
else if (RDO > 0) {
2022 LOG_WARN <<
"St_itpcPadGainT0C::instance found extra correction for run = " << run <<
" in [" << runMin <<
"," << runMax <<
"]"
2023 << Form(
" reset tpcRDOMasks for sector = %i and RDO = %i to zero with sec = %2i, row = %2i, padMin/Max = %3i/%3i, RDO = %2i, FEE = %2i, status = %i",
2024 sector, RDO, sector, row, padMin, padMax, RDO, FEE, status) << endm;
2025 St_tpcRDOMasksC::instance()->setSectorRDOMaskOff(sector,RDO);
2027 LOG_WARN <<
"St_itpcPadGainT0C::instance found extra correction for run = " << run <<
" in [" << runMin <<
"," << runMax <<
"]"
2028 << Form(
" with sec = %2i, row = %2i, padMin/Max = %3i/%3i, RDO = %2i, FEE = %2i, status = %i => whole sector is marker as DEAD",
2029 sector, row, padMin, padMax, RDO, FEE, status) << endm;
2030 for (Int_t rdoD = 1; rdoD <= 4; rdoD++) {
2031 St_tpcRDOMasksC::instance()->setSectorRDOMaskOff(sector,rdoD);
2038 #include "St_tpcPadGainT0BC.h"
2046 Float_t St_tpcPadGainT0BC::Gain(Int_t sector, Int_t row, Int_t pad)
const {
2048 if (St_tpcPadConfigC::instance()->iTPC(sector)) {
2050 gain = St_itpcPadGainT0C::instance()->Gain(sector,row,pad);
2052 gain = St_tpcPadGainT0C::instance()->Gain(sector,row-40+13,pad);
2055 gain = St_tpcPadGainT0C::instance()->Gain(sector,row,pad);
2060 Float_t *St_tpcPadGainT0BC::Gains(Int_t sector, Int_t row) {
2062 if (St_tpcPadConfigC::instance()->iTPC(sector)) {
2064 gains = St_itpcPadGainT0C::instance()->Gains(sector,row);
2066 gains = St_tpcPadGainT0C::instance()->Gains(sector,row-40+13);
2069 gains = St_tpcPadGainT0C::instance()->Gains(sector,row);
2074 Float_t St_tpcPadGainT0BC::T0(Int_t sector, Int_t row, Int_t pad)
const {
2076 if (St_tpcPadConfigC::instance()->iTPC(sector)) {
2078 T0 = St_itpcPadGainT0C::instance()->T0(sector,row,pad);
2080 T0 = St_tpcPadGainT0C::instance()->T0(sector,row-40+13,pad);
2082 T0 = St_tpcPadGainT0C::instance()->T0(sector,row,pad);
2087 Bool_t St_tpcPadGainT0BC::livePadrow(Int_t sector, Int_t row)
const {
2088 if (St_tpcPadConfigC::instance()->iTPC(sector)) {
2090 return St_itpcPadGainT0C::instance()->livePadrow(sector,row);
2092 return St_tpcPadGainT0C::instance()->livePadrow(sector,row-40+13);
2094 return St_tpcPadGainT0C::instance()->livePadrow(sector,row);
2096 #include "StPath2tpxGain.h"
2097 MakeChairInstance2(FilePath,
StPath2tpxGain,Calibrations/tpc/Path2tpxGain);
2098 #include "StPath2itpcGain.h"
2099 MakeChairInstance2(FilePath,
StPath2itpcGain,Calibrations/tpc/Path2itpcGain);
2101 const Char_t * St_FilePathC::GetPath(
const Char_t *prepend) {
2102 static TString path;
2105 gSystem->ExpandPathName(path);
2109 #include "St_tpcSlewingC.h"
2110 MakeChairInstance(tpcSlewing,Calibrations/tpc/tpcSlewing);
2111 #include "St_tpcAcChargeC.h"
2112 MakeChairInstance(tpcAcCharge,Calibrations/tpc/tpcAcCharge);
2113 #include "St_tpcAvCurrentC.h"
2114 MakeChairInstance(tpcAvCurrent,Calibrations/tpc/tpcAvCurrent);
2115 #include "St_TpcResponseSimulatorC.h"
2116 MakeChairInstance(TpcResponseSimulator,Calibrations/tpc/TpcResponseSimulator);
2117 #include "St_TpcPadCorrectionC.h"
2118 #include "TPolynomial.h"
2119 MakeChairInstance(TpcPadCorrection,Calibrations/tpc/TpcPadCorrection);
2120 St_TpcPadCorrectionC::St_TpcPadCorrectionC(St_TpcPadCorrection *table) :
TChair(table), fFunc(0) {
2121 Int_t nrows = GetNRows();
2123 fFunc =
new TF1*[nrows]; memset(fFunc, 0, nrows*
sizeof(TF1*));
2124 for (Int_t i = 0; i < nrows; i++) {
2125 Short_t io = Struct(i)->InOut;
2126 Short_t np = Struct(i)->npads;
2127 Short_t MuOrSigma = -1;
2128 if (Struct(i)->R == 8) MuOrSigma = 0;
2129 if (Struct(i)->R == 7) MuOrSigma = 1;
2130 if ((io < 1 || io > 2) ||
2131 (np < 1 || np > 7) ||
2132 (MuOrSigma < 0 || MuOrSigma > 1))
continue;
2133 Int_t indx = 2*(7*(io-1) + np-1)+MuOrSigma;
2134 assert(indx < nrows);
2135 fFunc[indx] = TPolynomial::MakePoly(Form(
"%s_%i_%i",Struct(i)->Type,np,io),Struct(i)->N-1,Struct(i)->R);
2136 fFunc[indx]->SetParameters(&Struct(i)->a0);
2140 St_TpcPadCorrectionC::~St_TpcPadCorrectionC() {
2143 Int_t nrows = GetNRows();
2144 for (Int_t i = 0; i < nrows; i++)
2145 SafeDelete(fFunc[i]);
2149 #include "St_tpcGainCorrectionC.h"
2151 #include "StTpcHitErrors.h"
2155 StMaker::GetChain()->GetDataBase(
"Calibrations/tpc/TpcHitErrors");
2156 LOG_INFO <<
"StTpcHitErrors have been instantiated with\n"
2157 <<
"StTpcHitErrors fnXZ(" << fgInstance->fXZ <<
"," << fgInstance->fSec <<
"," << fgInstance->fRow <<
","
2158 << fgInstance->fMS <<
"," << fgInstance->fPrompt <<
") = " << fgInstance->fNxz << endm;
2162 Double_t StTpcHitErrors::calcError(Int_t iXZ, Int_t sec, Int_t row, Double_t _z, Double_t _eta, Double_t _tanl, Int_t Npads, Int_t Ntmbks, Double_t AdcL, Double_t xPad) {
2163 const static Double_t PitchLog[3] = {TMath::Log(0.335), TMath::Log(0.675), TMath::Log(5.78602945878541108e-01)};
2173 Int_t s = 0, r = 0, p = 0;
2174 if (sec > 12) s = 1;
2175 if (row > St_tpcPadConfigC::instance()->innerPadRows(sec)) r = 1;
2178 Double_t Vars[7] = {
2187 Vars[3] = - Vars[3];
2188 Vars[4] = - Vars[4];
2190 if (Vars[3] > 195) p = 1;
2193 Double_t valueLog = mdf->Eval(Vars);
2194 return TMath::Exp(2*(valueLog + PitchLog[pitch]));
2196 #include "St_tpcStatusC.h"
2197 MakeChairInstance(tpcStatus,Calibrations/tpc/tpcStatus);
2198 #include "St_TpcAvgCurrentC.h"
2199 MakeChairInstance(TpcAvgCurrent,Calibrations/tpc/TpcAvgCurrent);
2201 Int_t St_TpcAvgCurrentC::ChannelFromRow(Int_t sector, Int_t row) {
2202 if (row < 1 || row > St_tpcPadConfigC::instance()->padRows(sector))
return -1;
2203 if (! St_tpcPadConfigC::instance()->iTPC(sector)) {
2204 if (row < 3)
return 1;
2205 if (row < 7)
return 2;
2206 if (row < 10)
return 3;
2207 if (row < 14)
return 4;
2208 if (row < 22)
return 5;
2209 if (row < 30)
return 6;
2210 if (row < 38)
return 7;
2214 if (row < 10)
return 1;
2215 if (row < 20)
return 2;
2216 if (row < 30)
return 3;
2217 if (row < 14 - 13 + 40)
return 4;
2218 if (row < 22 - 13 + 40)
return 5;
2219 if (row < 30 - 13 + 40)
return 6;
2220 if (row < 38 - 13 + 40)
return 7;
2226 Int_t St_TpcAvgCurrentC::ChannelFromSocket(Int_t socket) {
2230 case 2 : channel = 1;
break;
2232 case 4: channel = 2;
break;
2234 case 6: channel = 3;
break;
2237 case 17: channel = 4;
break;
2240 case 18: channel = 5;
break;
2242 case 12: channel = 6;
break;
2244 case 14: channel = 7;
break;
2247 case 19: channel = 8;
break;
2253 Float_t St_TpcAvgCurrentC::AcChargeL(Int_t sector, Int_t channel) {
2254 if (! St_TpcAvgPowerSupplyC::instance()->Table()->IsMarked()) {
2255 return St_TpcAvgPowerSupplyC::instance()->AcChargeL(sector,channel);
2260 static Float_t Length[8] = {
2269 return AcCharge(sector,channel)/Length[channel-1];
2272 Float_t St_TpcAvgCurrentC::AvCurrent(Int_t sector, Int_t channel) {
2273 if (! St_TpcAvgPowerSupplyC::instance()->Table()->IsMarked()) {
2274 return St_TpcAvgPowerSupplyC::instance()->AvCurrent(sector,channel);
2276 return (sector > 0 && sector <= 24 && channel > 0 && channel <= 8) ?
2277 Struct()->AvCurrent[8*(sector-1)+channel-1] : 0;
2280 Float_t St_TpcAvgCurrentC::AcCharge(Int_t sector, Int_t channel) {
2281 if (! St_TpcAvgPowerSupplyC::instance()->Table()->IsMarked()) {
2282 return St_TpcAvgPowerSupplyC::instance()->AcCharge(sector,channel);
2284 return (sector > 0 && sector <= 24 && channel > 0 && channel <= 8) ?
2285 Struct()->AcCharge[8*(sector-1)+channel-1] : 0;
2287 #include "St_itpcRDOMapC.h"
2288 MakeChairInstance2(tpcRDOMap,
St_itpcRDOMapC,Calibrations/tpc/itpcRDOMap);
2290 Int_t St_itpcRDOMapC::rdo(Int_t padrow, Int_t pad)
const {
2293 for (Int_t i = 0; i < N; i++) {
2294 if (padrow != row(i))
continue;
2295 if (pad < padMin(i) || pad > padMax(i))
continue;
2302 #include "St_tpcRDOMapC.h"
2303 MakeChairInstance(tpcRDOMap,Calibrations/tpc/tpcRDOMap);
2305 Int_t St_tpcRDOMapC::rdo(Int_t padrow, Int_t pad)
const {
2308 for (Int_t i = 0; i < N; i++) {
2309 if (padrow != row(i))
continue;
2310 if (pad < padMin(i) || pad > padMax(i))
continue;
2318 Int_t St_tpcRDOMapC::rdo(Int_t sector, Int_t padrow, Int_t pad)
const {
2319 if (St_tpcPadConfigC::instance()->iTpc(sector)) {
2320 Int_t N40 = St_tpcPadConfigC::instance()->innerPadRows(sector);
2321 if (padrow <= N40) {
2322 return St_itpcRDOMapC::instance()->rdo(padrow,pad);
2324 return St_tpcRDOMapC::instance()->rdo(padrow-N40+13,pad) + 2;
2326 return rdo(padrow, pad);
2328 #include "St_tpcRDOT0offsetC.h"
2329 MakeChairInstance(tpcRDOT0offset,Calibrations/tpc/tpcRDOT0offset);
2330 Float_t St_tpcRDOT0offsetC::T0(Int_t sector, Int_t padrow, Int_t pad)
const {
2332 if (! IsShfited(sector))
return t0;
2333 if (St_tpcPadConfigC::instance()->iTPC(sector) && padrow <= 40)
return t0;
2334 Int_t rdo = St_tpcRDOMapC::instance()->rdo(padrow,pad);
2335 if (!rdo)
return t0;
2336 t0 = Struct()->t0[sector-1][rdo-1];
2340 #include "St_tpcBXT0CorrEPDC.h"
2341 MakeChairInstance2(tpcBXT0Corr,
StTpcBXT0CorrEPDC,Calibrations/tpc/tpcBXT0CorrEPD);
2342 double StTpcBXT0CorrEPDC::getCorrection (
double epdTAC,
double driftVelocity,
double timeBinWidth) {
2343 double timeBucketShiftScale = 500000/(driftVelocity*timeBinWidth);
2344 double generalOffset = a(0)[0];
2346 if (epdTAC == -1)
return timeBucketShiftScale*generalOffset;
2347 else return timeBucketShiftScale*(generalOffset + a(0)[1] + a(0)[2]*epdTAC);
2349 #include "St_tpcT0BXC.h"
2350 MakeChairInstance(tpcT0BX,Calibrations/tpc/tpcT0BX);
2351 Double_t St_tpcT0BXC::getT0(Double_t values[7])
const {
2353 Double_t T0W = 0, T0WW = 0;
2354 static Int_t __debug = 0;
2356 if (__debug > 1) Table()->
Print(0,10);
2357 LOG_INFO <<
"St_tpcT0BXC::getT0:";
2359 for (Int_t i = 0; i < 7; i++) {
2360 if (values[i] < xmin(i) || values[i] > xmax(i))
continue;
2361 if (detId(i) < 0)
continue;
2363 if (detId(i) != i+1) {
2364 LOG_WARN <<
"St_tpcT0BXC::getT0 : table is unsorted detId(" << i <<
") != " << i+1 <<
" Skip entry" << endl;
2367 Double_t t0 = toff(i) + slope(i)*(values[i] - vMean(i));
2368 Double_t w = dtoff(i)* dtoff(i) + dslope(i)*(values[i] - vMean(i)) * dslope(i)*(values[i] - vMean(i));
2369 if (w < 1e-14)
continue;
2373 LOG_INFO << Form(
"%s = %7.2f -> %7.2f +/- %7.2f nsec ",name(i),values[i], 1e3*t0, 1e3*TMath::Sqrt(w));
2379 LOG_INFO << Form(
" : T0 = %7.2f +/- %7.2f nsec", 1e3*T0, 1e3/TMath::Sqrt(T0WW)) << endm;
2384 #include "St_starTriggerDelayC.h"
2385 MakeChairOptionalInstance2(starTriggerDelay,
St_starTriggerDelayC,Calibrations/tpc/starTriggerDelay);
2387 Float_t St_starTriggerDelayC::TrigT0(Int_t i)
const {
2388 return clocks(i)/(1e-6*St_starClockOnlC::instance()->CurrentFrequency()) + tZero(i);
2391 Float_t St_starTriggerDelayC::TrigT0GG(Int_t io, Int_t i)
const {
2392 Float_t delay = TrigT0(i);
2394 if (! io) delay += -0.123;
2395 else delay += -0.502;
2399 #include "St_defaultTrgLvlC.h"
2400 MakeChairInstance(defaultTrgLvl,Calibrations/trg/defaultTrgLvl);
2401 #include "St_trigDetSumsC.h"
2404 St_trigDetSumsC::~St_trigDetSumsC() {
2411 static trigDetSums_st *sOld = 0;
2412 static Int_t iBreak = 0;
2414 St_trigDetSums *table = (St_trigDetSums *) fgInstance->Table();
2415 trigDetSums_st *s = table->GetTable();
2417 LOG_QA <<
"new trigDetSums" << endm;
2418 DEBUGTABLE(
"trigDetSums");
2426 St_trigDetSums *table = (St_trigDetSums *) StMaker::GetChain()->GetDataSet(
"inputStream_DAQ/trigDetSums");
2427 if (! table) table = (St_trigDetSums *) StMaker::GetChain()->GetDataSet(
"StEvent/trigDetSums");
2429 static Int_t iBreak = 0;
2431 LOG_QA <<
"get trigDetSums from GetDataSet" << endm;
2435 StMaker::GetChain()->
AddData(fgInstance);
2438 table = (St_trigDetSums *) StMaker::GetChain()->GetDataBase(
"Calibrations/rich/trigDetSums");
2440 LOG_QA <<
"get trigDetSums from GetDataBase" << endm;
2442 fgInstance->SetName(
"trigDetSumsC");
2443 StMaker::GetChain()->AddConst(fgInstance);
2447 #include "St_EbyET0C.h"
2448 MakeChairInstance(EbyET0,Calibrations/trg/EbyET0);
2449 Double_t St_EbyET0C::time(Int_t i, Double_t x) {
2450 Double_t* pars = par(i);
2455 for (Int_t n=2; n>=0; n--) t += x*t + pars[n];
2461 #include "St_tss_tssparC.h"
2462 MakeChairInstance(tss_tsspar,tpc/tsspars/tsspar);
2464 Float_t St_tss_tssparC::gain(Int_t sector, Int_t row) {
2466 Double_t V_nominal = 1390;
2469 if (row <= St_tpcPadConfigC::instance()->innerPadRows(sector)) {l = 1; V_nominal = 1170;}
2471 Int_t NRows = gC->GetNRows();
2472 if (l >= NRows)
return gain;
2473 V = St_tpcAnodeHVavgC::instance()->voltagePadrow(sector,row);
2475 Double_t v = V - V_nominal;
2478 if ( gC->min(l) > -1 && v > -100 && v < 0) {
2483 if (v < gC->min(l) || v > gC->max(l))
return gain;
2484 if (gC->min(l) < -450) {
2486 gain = TMath::Exp(gC->CalcCorrection(l,v, 0., 2));
2488 gain = TMath::Exp(gC->CalcCorrection(l,v));
2494 #include "St_tpcMaxHitsC.h"
2495 MakeChairInstance(tpcMaxHits,Calibrations/tracker/tpcMaxHits);
2497 #include "St_richvoltagesC.h"
2498 MakeChairInstance(richvoltages,Calibrations/rich/richvoltages);
2499 #include "St_y1MultC.h"
2500 MakeChairInstance(y1Mult,Calibrations/rich/y1Mult);
2501 #include "St_spaceChargeCorC.h"
2506 #include "St_MagFactorC.h"
2507 MakeChairInstance(MagFactor,RunLog/MagFactor);
2509 MakeChairInstance(starClockOnl,RunLog/onl/starClockOnl);
2511 starClockOnl_st *St_starClockOnlC::Struct(Int_t i) {
2512 starClockOnl_st *s = ((St_starClockOnl* ) instance()->Table())->GetTable();
2513 Int_t N = getNumRows();
2514 if (i >= 0 && i < N)
return s + i;
2515 for (Int_t j = 0; j < N; j++, s++)
if (s->frequency > 0)
break;
2516 assert(s->frequency > 0 && s->frequency < 1e7);
2519 #include "St_starMagOnlC.h"
2520 MakeChairInstance(starMagOnl,RunLog/onl/starMagOnl);
2521 #include "St_starMagAvgC.h"
2522 MakeChairOptionalInstance(starMagAvg,RunLog/onl/starMagAvg);
2523 #include "St_beamInfoC.h"
2524 MakeChairInstance(beamInfo,RunLog/onl/beamInfo);
2525 static Double_t kuAtomicMassUnit = 931.4940054e-3;
2526 static Double_t kProtonMass = kuAtomicMassUnit*1.00727646662;
2528 Bool_t St_beamInfoC::IsFixedTarget() {
2529 Bool_t isFixTag = kFALSE;
2530 Float_t MaxIntensity = TMath::Max(blueIntensity(), yellowIntensity());
2531 Float_t MinIntensity = TMath::Min(blueIntensity(), yellowIntensity());
2532 if (MaxIntensity > 0.5) {
2533 if (MaxIntensity > 1000*MinIntensity) isFixTag = kTRUE;
2534 }
else if (yellowIntensity() < 0.5) {
2536 if ((runNumber() >= 20181040 && runNumber() <= 20181045) ||
2537 (runNumber() >= 20182006 && runNumber() <= 20182018) ||
2538 runNumber() == 22121022 ||
2539 runNumber() == 22158035 ||
2540 runNumber() == 22166031
2546 Float_t St_beamInfoC::GammaYellow() {
2548 Int_t N = TMath::Nint(getYellowMassNumber());
2550 Double_t E = N*getYellowEnergy();
2551 Double_t M = kuAtomicMassUnit*N;
2556 Float_t St_beamInfoC::GammaBlue() {
2558 if (! IsFixedTarget()) {
2559 Int_t N = TMath::Nint(getBlueMassNumber());
2561 Double_t E = N*getBlueEnergy();
2562 Double_t M = kuAtomicMassUnit*N;
2569 Float_t St_beamInfoC::GammaCMS() {
2570 Double_t eBlue = kProtonMass*GammaBlue();
2571 Double_t eYellow = kProtonMass*GammaYellow();
2572 Double_t Etot = eBlue + eYellow;
2573 Double_t Ecm = SqrtS();
2574 Double_t gammaCM = Etot/Ecm;
2578 Float_t St_beamInfoC::BetaBlue() {
2579 Float_t gamma = GammaBlue();
2580 return TMath::Sqrt(1 - 1./(gamma*gamma));
2583 Float_t St_beamInfoC::BetaYellow() {
2584 Float_t gamma = GammaYellow();
2585 return -TMath::Sqrt(1 - 1./(gamma*gamma));
2588 Float_t St_beamInfoC::BetaCMS() {
2589 Double_t eBlue = kProtonMass*GammaBlue();
2590 Double_t eYellow = kProtonMass*GammaYellow();
2591 Double_t Etot = eBlue + eYellow;
2592 Double_t betaCM = (eBlue*BetaBlue() + eYellow*BetaYellow())/Etot;
2596 Float_t St_beamInfoC::SqrtS() {
2597 static Double_t mP = kuAtomicMassUnit*1.00727646662;
2598 Double_t eBlue = mP*GammaBlue();
2599 Double_t eYellow = mP*GammaYellow();
2600 return TMath::Sqrt(2*mP*mP + 2*eBlue*eYellow*(1 - BetaBlue()*BetaYellow()));
2603 Float_t St_beamInfoC::Ycms() {
2604 Double_t gammaCM = GammaCMS();
2605 Double_t betaCM = BetaCMS();
2606 Double_t yCM = TMath::Log(gammaCM*(1 + betaCM));
2610 Float_t St_beamInfoC::Frequency() {
2611 static Double_t l = 3833.845*9.99999253982746361e-01;
2612 static Double_t NB = 120;
2613 Double_t frequency = 1e-6*NB*BetaYellow()*TMath::C()/l;
2614 return TMath::Abs(frequency);
2617 #include "St_triggerInfoC.h"
2618 MakeChairInstance(triggerInfo,RunLog/onl/triggerInfo);
2619 #include "St_triggerIDC.h"
2620 MakeChairInstance(triggerID,RunLog/onl/triggerID);
2622 #include "St_trigPrescalesC.h"
2623 MakeChairOptionalInstance(trigPrescales,RunLog/onl/trigPrescales);
2625 #include "St_L0TriggerInfoC.h"
2626 MakeChairInstance(L0TriggerInfo,RunLog/onl/L0TriggerInfo);
2627 #include "St_trigL3ExpandedC.h"
2628 MakeChairOptionalInstance(trigL3Expanded,RunLog/onl/trigL3Expanded);
2629 #include "St_dsmPrescalesC.h"
2630 MakeChairOptionalInstance(dsmPrescales,RunLog/onl/dsmPrescales);
2631 #include "St_additionalTriggerIDC.h"
2632 MakeChairOptionalInstance(additionalTriggerID,RunLog/onl/additionalTriggerID);
2633 #include "StDetectorDbTriggerID.h"
2637 map<Int_t,Float_t> value;
2640 Int_t trgId = getDsmPrescalesTrgId(irow);
2641 value[trgId] = Float_t(getDsmPrescalesDsmPrescale(irow));
2645 Int_t trgId = getL0OfflineTrgId(irow);
2646 map<Int_t,Float_t>::iterator p=value.find(trgId);
2647 if (p != value.end()) {
2648 (*p).second *= Float_t(getPsL0(irow));
2651 value[trgId] = Float_t(getPsL0(irow));
2656 UInt_t idxTrigger = getIdxTrigger(irow);
2659 if (idxTrigger == getIdxTrg(jrow)) {
2660 trgId = getOfflineTrgId(jrow);
2664 map<Int_t,Float_t>::iterator p=value.find(trgId);
2666 if (p != value.end()) {
2667 (*p).second *= Float_t(getPs(irow));
2670 value[trgId] = Float_t(getPs(irow));
2676 Int_t oldtid = getTrigL3ExpandedL3TrgId(irow);
2677 Int_t newtid = getTrigL3ExpandedL3ExpandedTrgId(irow);
2678 Float_t l2ps = getTrigL3ExpandedL2Ps(irow);
2680 map<Int_t,Float_t>::iterator p = value.find(oldtid);
2681 if (p!= value.end()) {
2682 value[newtid] = ((*p).second)*l2ps;
2685 value[newtid] = l2ps;
2694 map<Int_t,Float_t>::const_iterator p = theMap.find(trgId);
2695 if (p != theMap.end()) {
2703 #include "StDetectorDbIntegratedTriggerID.h"
2706 #include "St_trgTimeOffsetC.h"
2707 MakeChairAltInstance(trgTimeOffset,Conditions/trg/trgTimeOffset,Conditions/trg/trgTimeOffsetB,gEnv->GetValue(
"NewTpcAlignment",0));
2709 #include "St_tpcDimensionsC.h"
2710 MakeChairInstance(tpcDimensions,Geometry/tpc/tpcDimensions);
2711 #include "St_tpcWirePlanesC.h"
2712 MakeChairInstance(tpcWirePlanes,Geometry/tpc/tpcWirePlanes);
2713 #include "St_tpcSectorPositionC.h"
2716 St_tpcSectorPosition *St_tpcSectorPositionC::fgTables[24] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
2718 if (fgInstance)
return fgInstance;
2719 TDataSet *tpc = StMaker::GetChain()->GetDataBase(
"Geometry/tpc");
2721 for (Int_t sec = 1; sec <= 24; sec++) {
2722 TString path = Form(
"Sector_%02i/tpcSectorPosition",sec);
2723 fgTables[sec-1] = (St_tpcSectorPosition *) tpc->
Find(path.Data());
2724 if (! fgTables[sec-1]) {
2725 LOG_WARN <<
"St_tpcSectorPositionC::instance " << tpc->GetTitle() <<
"/" << path.Data()
2726 <<
"\twas not found" << endm;
2727 assert(fgTables[sec-1]);
2731 St_db_Maker::GetValidity(fgTables[sec-1],t);
2732 Int_t Nrows = fgTables[sec-1]->GetNRows();
2733 LOG_WARN <<
"St_tpcSectorPositionC::instance found table " << fgTables[sec-1]->GetName()
2734 <<
" with NRows = " << Nrows <<
" in db"
2735 << Form(
"\tValidity:%08i.%06i --- %08i.%06i",t[0].GetDate(),t[0].GetTime(),t[1].GetDate(),t[1].GetTime()) << endm;
2736 fgTables[sec-1]->Print(0,1);
2742 #include "St_tpcFieldCageC.h"
2743 MakeChairInstance(tpcFieldCage,Geometry/tpc/tpcFieldCage);
2744 MakeChairInstance(tpcPadPlanes,Geometry/tpc/tpcPadPlanes);
2745 MakeChairInstance(itpcPadPlanes,Geometry/tpc/itpcPadPlanes);
2746 MakeChairInstance(tpcPadConfig,Geometry/tpc/tpcPadConfig);
2747 #include "St_tpcGlobalPositionC.h"
2748 MakeChairInstance(tpcGlobalPosition,Geometry/tpc/tpcGlobalPosition);
2749 #include "St_tpcFieldCageShortC.h"
2750 MakeChairInstance(tpcFieldCageShort,Geometry/tpc/tpcFieldCageShort);
2751 #include "St_tpcHVPlanesC.h"
2752 MakeChairInstance(tpcHVPlanes,Geometry/tpc/tpcHVPlanes);
2753 #include "St_SurveyC.h"
2755 #include "StSvtSurveyC.h"
2756 MakeChairInstance2(Survey,
StSvtOnGlobal,Geometry/svt/SvtOnGlobal);
2761 #include "StSsdSurveyC.h"
2762 MakeChairInstance2(Survey,
StSsdOnGlobal,Geometry/ssd/SsdOnGlobal);
2766 #include "StSstSurveyC.h"
2767 MakeChairInstance2(Survey,
StoscOnTpc,Geometry/sst/oscOnTpc);
2768 MakeChairInstance2(Survey,
StsstOnOsc,Geometry/sst/sstOnOsc);
2771 #include "StTpcSurveyC.h"
2772 MakeChairAltInstance2(Survey,
StTpcInnerSectorPosition,Geometry/tpc/TpcInnerSectorPosition,Geometry/tpc/TpcInnerSectorPositionB,gEnv->GetValue(
"NewTpcAlignment",0));
2773 MakeChairAltInstance2(Survey,
StTpcOuterSectorPosition,Geometry/tpc/TpcOuterSectorPosition,Geometry/tpc/TpcOuterSectorPositionB,gEnv->GetValue(
"NewTpcAlignment",0));
2774 MakeChairAltInstance2(Survey,
StTpcSuperSectorPosition,Geometry/tpc/TpcSuperSectorPosition,Geometry/tpc/TpcSuperSectorPositionB,gEnv->GetValue(
"NewTpcAlignment",0));
2776 MakeChairInstance2(Survey,
StTpcPosition,Geometry/tpc/TpcPosition);
2777 #include "St_iTPCSurveyC.h"
2778 MakeChairInstance(iTPCSurvey,Geometry/tpc/iTPCSurvey);
2780 #include "StGmtSurveyC.h"
2781 MakeChairInstance2(Survey,
StGmtOnTpc,Geometry/gmt/GmtOnTpc);
2782 MakeChairInstance2(Survey,
StGmtOnModule,Geometry/gmt/GmtOnModule);
2784 #include "StIstSurveyC.h"
2785 MakeChairInstance2(Survey,
StidsOnTpc,Geometry/ist/idsOnTpc);
2786 MakeChairInstance2(Survey,
StpstOnIds,Geometry/ist/pstOnIds);
2787 MakeChairInstance2(Survey,
StistOnPst,Geometry/ist/istOnPst);
2788 MakeChairInstance2(Survey,
StLadderOnIst,Geometry/ist/istLadderOnIst);
2791 #include "StPxlSurveyC.h"
2792 MakeChairInstance2(Survey,
StPxlpstOnIds,Geometry/pxl/pstOnIds);
2793 MakeChairInstance2(Survey,
StpxlOnPst,Geometry/pxl/pxlOnPst);
2794 MakeChairInstance2(Survey,
StpxlHalfOnPxl,Geometry/pxl/pxlHalfOnPxl);
2798 #include "St_pxlControlC.h"
2799 MakeChairInstance(pxlControl,Geometry/pxl/pxlControl);
2800 #include "St_pxlSensorTpsC.h"
2801 MakeChairInstance(pxlSensorTps,Geometry/pxl/pxlSensorTps);
2803 St_SurveyC::St_SurveyC(St_Survey *table) :
TChair(table), fRotations(0) {
2804 UInt_t N = getNumRows();
2805 fRotations =
new TGeoHMatrix*[N];
2806 for (UInt_t i = 0; i < N; i++) {
2807 fRotations[i] =
new TGeoHMatrix;
2808 TGeoHMatrix &rot = *fRotations[i];
2809 if (N == 1) rot.SetName(Table()->GetName());
2810 else rot.SetName(Form(
"%s_%i",Table()->GetName(),i+1));
2811 rot.SetRotation(Rotation(i));
2812 rot.SetTranslation(Translation(i));
2814 assert(TMath::Abs(rot.Determinant())-1 < 1.e-3);
2818 St_SurveyC::~St_SurveyC() {
2820 for (UInt_t i = 0; i < getNumRows(); i++) {
2821 SafeDelete(fRotations[0]);
2823 SafeDelete(fRotations);
2827 Double_t St_SurveyC::IsOrtogonal(
const Double_t *r) {
2831 for (Int_t i=0; i<2; i++) {
2832 for (Int_t j=i+1; j<3; j++) {
2834 cij = TMath::Abs(r[i]*r[j]+r[i+3]*r[j+3]+r[i+6]*r[j+6]);
2835 if (cij>1E-4) cmax = cij;
2837 cij = TMath::Abs(r[3*i]*r[3*j]+r[3*i+1]*r[3*j+1]+r[3*i+2]*r[3*j+2]);
2838 if (cij>cmax) cmax = cij;
2844 void St_SurveyC::Normalize(TGeoHMatrix &R) {
2846 Double_t det = R.Determinant();
2847 Double_t ort = IsOrtogonal(R.GetRotationMatrix());
2848 static Double_t eps = 1e-7;
2849 if ( TMath::Abs(TMath::Abs(det) - 1) < eps && ort < eps)
return;
2850 LOG_INFO <<
"St_SurveyC::Normalize matrix " << R.GetName()
2851 << Form(
" has determinant-1 = %10.7f\tortoganality %10.7f",TMath::Abs(det)-1,ort) << endm;
2852 cout <<
"Old\t"; R.Print();
2853 const Double_t *r = R.GetRotationMatrix();
2854 SMatrix<double,3,3> A(r,9);
2855 SMatrix<double,3,3> B = A;
2861 SMatrix<double,3,3> Qn1;
2862 SMatrix<double,3,3> Qn2;
2863 SMatrix<double,3,3> M = B;
2864 SMatrix<double,3,3> Qn = M;
2867 Qn.Det(det);
if (_debug) {LOG_INFO <<
"N " << N <<
"\tQn Determinant - 1: " << Form(
"%15.5g",det-1) << endm;}
2869 while (TMath::Abs(TMath::Abs(det) - 1) > eps) {
2870 SMatrix<double,3> QnInv = Qn.Inverse(ifail);
2872 LOG_ERROR <<
"St_SurveyC::Normalize:: Qn inversion failed" << endm;
2875 SMatrix<double,3,3> C1 = QnInv * M;
2876 SMatrix<double,3,3> C2 = Transpose(M) * Qn;
2877 SMatrix<double,3,3> C = C1 + C2;
2878 SMatrix<double,3,3> CInv = C.Inverse(ifail);
2880 LOG_ERROR <<
"St_SurveyC::Normalize:: C inversion failed" << endm;
2886 Qn2.Det(det);
if (_debug) {LOG_INFO <<
"N " << N <<
"\tQn2 Determinant - 1: " << Form(
"%15.5g",det-1) << endm;}
2889 if (_debug) {LOG_INFO <<
"Qn:" << endl << Qn << endm;}
2891 R.SetRotation(Qn.Array()); cout <<
"New\t"; R.Print();
2894 LOG_INFO <<
"Matrix:" << endm; R.Print(
"");
2895 LOG_INFO <<
"Determinant-1 = " << R.Determinant()-1 << endm;
2896 const Double_t *rr = R.GetRotationMatrix();
2897 LOG_INFO <<
"Ortogonality " << IsOrtogonal(rr) << endm;
2902 const TGeoHMatrix &St_SurveyC::GetMatrix(Int_t i) {
2903 assert(fRotations || fRotations[i]);
2904 assert(TMath::Abs(fRotations[i]->Determinant())-1 < 1.e-3);
2905 return *fRotations[i];
2908 const TGeoHMatrix &St_SurveyC::GetMatrix4Id(Int_t
id) {
2909 for (UInt_t i = 0; i < getNumRows(); i++) {
2911 return GetMatrix(i);
2914 LOG_INFO <<
"St_SurveyC::GetMatrix4Id(" <<
id <<
") entry has not been found" << endm;
2915 const TTable *table = Table();
2917 table->
Print(0,Nrows);
2919 return GetMatrix(0);
2922 const TGeoHMatrix &St_SurveyC::GetMatrixR(Int_t i) {
2923 static TGeoHMatrix rot;
2924 Double_t rotations[9] = {
2928 rot.SetName(Form(
"%s_%i",Table()->GetName(),i));
2929 rot.SetRotation(rotations);
2930 rot.SetTranslation(Translation(i));
2934 void St_SurveyC::GetAngles(Double_t &phi, Double_t &the, Double_t &psi, Int_t i) {
2935 phi = the = psi = 0;
2936 Double_t cosDelta = (r00(i) + r11(i) + r22(i) - 1)/2;
2937 Double_t Delta = TMath::ACos(cosDelta);
2938 if (Delta < 0) Delta += 2*TMath::Pi();
2939 Double_t sinDelta2 = TMath::Sin(Delta/2);
2940 if (TMath::Abs(sinDelta2) < 1.e-7)
return;
2942 (r21(i) - r12(i))/(2*sinDelta2),
2943 (r02(i) - r20(i))/(2*sinDelta2),
2944 (r10(i) - r01(i))/(2*sinDelta2)
2946 Double_t u = TMath::ATan2(c[0],c[1]);
2947 Double_t v = TMath::ATan(c[2]*TMath::Tan(Delta/2));
2948 phi = (v - u)/2 - TMath::Pi()/2;
2949 psi = (v + u)/2 - TMath::Pi()/2;
2950 the = 2*TMath::ATan2(c[0]*TMath::Sin(v),c[2]*TMath::Sin(u));
2951 Double_t raddeg = 180./TMath::Pi();
2957 St_SurveyC *St_SurveyC::instance(
const Char_t *name) {
2959 if (Name ==
"SvtOnGlobal")
return (
St_SurveyC *) StSvtOnGlobal::instance();
2960 if (Name ==
"ShellOnGlobal")
return (
St_SurveyC *) StSvtShellOnGlobal::instance();
2961 if (Name ==
"LadderOnSurvey")
return (
St_SurveyC *) StSvtLadderOnSurvey::instance();
2962 if (Name ==
"LadderOnShell")
return (
St_SurveyC *) StSvtLadderOnShell::instance();
2963 if (Name ==
"WaferOnLadder")
return (
St_SurveyC *) StSvtWaferOnLadder::instance();
2964 if (Name ==
"SsdOnGlobal")
return (
St_SurveyC *) StSsdOnGlobal::instance();
2965 if (Name ==
"SsdSectorsOnGlobal")
return (
St_SurveyC *) StSsdSectorsOnGlobal::instance();
2966 if (Name ==
"SsdLaddersOnSectors")
return (
St_SurveyC *) StSsdLaddersOnSectors::instance();
2967 if (Name ==
"SsdWafersOnLadders")
return (
St_SurveyC *) StSsdWafersOnLadders::instance();
2968 if (Name ==
"TpcInnerSectorPosition")
return (
St_SurveyC *) StTpcInnerSectorPosition::instance();
2969 if (Name ==
"TpcOuterSectorPosition")
return (
St_SurveyC *) StTpcOuterSectorPosition::instance();
2970 if (Name ==
"TpcSuperSectorPosition")
return (
St_SurveyC *) StTpcSuperSectorPosition::instance();
2971 if (Name ==
"TpcHalfPosition")
return (
St_SurveyC *) StTpcHalfPosition::instance();
2972 if (Name ==
"idsOnTpc")
return (
St_SurveyC *) StidsOnTpc::instance();
2973 if (Name ==
"pstOnIds")
return (
St_SurveyC *) StpstOnIds::instance();
2974 if (Name ==
"istOnPst")
return (
St_SurveyC *) StistOnPst::instance();
2975 if (Name ==
"LadderOnIst")
return (
St_SurveyC *) StLadderOnIst::instance();
2976 if (Name ==
"LadderOnShell")
return (
St_SurveyC *) StSvtLadderOnShell::instance();
2977 if (Name ==
"istSensorOnLadder")
return (
St_SurveyC *) StistSensorOnLadder::instance();
2981 #include "St_vertexSeedC.h"
2982 MakeChairInstance(vertexSeed,Calibrations/rhic/vertexSeed);
2984 #include "St_tofCorrC.h"
2986 St_tofCorrC::St_tofCorrC(
TTable *table) :
TChair(table), mCalibType(NOTSET) {
2988 if (table) N = getNumRows();
2989 mCalibType = calibtype(N);
2994 Float_t St_tofCorrC::Correction(Int_t N, Float_t *xArray, Float_t x, Float_t *yArray, Short_t &NN) {
2995 Float_t dcorr = -9999;
2997 if (N <= 0 || ! xArray || ! yArray)
return dcorr;
2999 Bool_t IsSorted = kTRUE;
3001 for (Int_t bin = N-1; bin >= 0; bin--) {
3002 if (! nonzero && TMath::Abs(xArray[bin]) < 1e-7 && TMath::Abs(yArray[bin]) < 1e-7) {
3004 if (! IsSorted)
break;
3008 if (bin > 0 && xArray[bin] < xArray[bin-1]) IsSorted = kFALSE;
3011 LOG_ERROR <<
" St_tofCorrC::Correction xArray[" << (Int_t ) NN <<
"] is empty" << endm;
3015 LOG_WARN <<
" St_tofCorrC::Correction xArray[" << (Int_t ) NN <<
"] has not been sorted" << endm;
3017 TMath::Sort((Int_t) NN,xArray,Indx.GetArray(),0);
3018 TArrayF X(NN,xArray);
3019 TArrayF Y(NN,yArray);
3020 for (Int_t i = 0; i < NN; i++) {
3021 xArray[i] = X[Indx[i]];
3022 yArray[i] = Y[Indx[i]];
3024 LOG_WARN <<
" St_tofCorrC::Correction xArray[" << (Int_t ) NN <<
"] is sorted now" << endm;
3027 if (NN == 1) {
return yArray[NN-1];}
3028 if (x < xArray[0] || x > xArray[NN-1]) {
3029 if (TMath::Abs(x) < 1e-7) dcorr = 0;
3032 Int_t bin = TMath::BinarySearch(NN, xArray, x);
3033 if (bin >= 0 && bin < NN) {
3034 if (bin == NN) bin--;
3035 Double_t x1 = xArray[bin];
3036 Double_t x2 = xArray[bin+1];
3037 Double_t y1 = yArray[bin];
3038 Double_t y2 = yArray[bin+1];
3039 dcorr = y1 + (x-x1)*(y2-y1)/(x2-x1);
3044 Int_t St_tofCorrC::Index(Int_t tray, Int_t module, Int_t cell) {
3045 assert( tray && module );
3047 switch (mCalibType) {
3048 case CELLCALIB: assert(cell); i = cell - 1 + mNCell*(module - 1 + mNModule*(tray - 1)) ;
break;
3049 case MODULECALIB: i = module - 1 + mNModule*(tray - 1) ;
break;
3050 case BOARDCALIB: i = (module - 1 + mNModule*(tray - 1))/4;
break;
3051 default: assert(0);
break;
3055 #include "St_tofTotbCorrC.h"
3056 MakeChairInstance(tofTotbCorr,Calibrations/
tof/tofTotbCorr);
3057 St_tofTotbCorrC::St_tofTotbCorrC(St_tofTotbCorr *table) :
St_tofCorrC(table) {
3059 if (table) N = getNumRows();
3060 for (Int_t i = 0; i < N; i++) {
3061 Int_t j = Index(trayId(i), moduleId(i), cellId(i));
3063 Table()->Print(i,1);
3064 LOG_INFO <<
"i = " << i <<
"\ttray = " << trayId(i) <<
"\tmodule = " << moduleId(i) <<
"\tcellId = " << cellId(i) <<
"\tindex = " << j << endm;
3067 if (! mIndxArray[j]) mIndxArray[j] = i;
3069 Int_t m = mIndxArray[j];
3070 LOG_ERROR <<
"St_tofTotbCorrC duplicated rows "
3071 << m <<
" tray:" << trayId(m) <<
" module:" << moduleId(m)
3072 <<
" cell:" << cellId(m) <<
" tot[0] = " << tot(m)[0] <<
" corr[0] = " << corr(m)[0] <<
" and \n"
3074 << i <<
" tray:" << trayId(i) <<
" module:" << moduleId(i)
3075 <<
" cell:" << cellId(i) <<
" tot[0] = " << tot(i)[0] <<
" corr[0] = " << corr(i)[0] << endm;
3081 Float_t St_tofTotbCorrC::Corr(Int_t tray, Int_t module, Int_t cell, Float_t x) {
3082 Int_t idx = Index(tray,module,cell);
3083 Int_t i = mIndxArray[idx];
3084 if (i < 0)
return 0;
3085 Int_t Tray = trayId(i);
3086 Int_t Module = moduleId(i);
3087 Int_t Cell = cellId(i);
3088 assert(i >= 0 && Tray == tray && Module == module && Cell == cell);
3089 Float_t dcorr = St_tofCorrC::Correction(mNBinMax, tot(i), x, corr(i),mNusedArray[idx]);
3090 if (dcorr <= -9999.0) {
3091 LOG_ERROR <<
"St_tofTotbCorrC::Corr(" << tray <<
"," << module <<
"," << cell <<
"," << x <<
") is rejected.";
3092 if (x < tot(i)[0] || x > tot(i)[mNusedArray[idx]-1]) LOG_ERROR <<
" Out of the range [" << tot(i)[0] <<
"," << tot(i)[mNusedArray[idx]-1] <<
"].";
3097 #include "St_tofZbCorrC.h"
3098 MakeChairInstance(tofZbCorr,Calibrations/
tof/tofZbCorr);
3099 St_tofZbCorrC::St_tofZbCorrC(St_tofZbCorr *table) :
St_tofCorrC(table) {
3101 if (table) N = getNumRows();
3102 for (Int_t i = 0; i < N; i++) {
3103 Int_t j = Index(trayId(i), moduleId(i), cellId(i));
3105 if (! mIndxArray[j]) mIndxArray[j] = i;
3107 Int_t m = mIndxArray[j];
3108 LOG_ERROR <<
"St_tofZbCorrC duplicated rows "
3109 << m <<
" tray:" << trayId(m) <<
" module:" << moduleId(m)
3110 <<
" cell:" << cellId(m) <<
" z[0] = " << z(m)[0] <<
" corr[0] = " << corr(m)[0] <<
" and \n"
3112 << i <<
" tray:" << trayId(i) <<
" module:" << moduleId(i)
3113 <<
" cell:" << cellId(i) <<
" z[0] = " << z(i)[0] <<
" corr[0] = " << corr(i)[0] << endm;
3119 Float_t St_tofZbCorrC::Corr(Int_t tray, Int_t module, Int_t cell, Float_t x) {
3120 Int_t idx = Index(tray,module,cell);
3121 Int_t i = mIndxArray[idx];
3122 if (i < 0)
return 0;
3123 Int_t Tray = trayId(i);
3124 Int_t Module = moduleId(i);
3125 Int_t Cell = cellId(i);
3126 assert(i >= 0 && Tray == tray && Module == module && Cell == cell);
3127 Float_t dcorr = St_tofCorrC::Correction(mNBinMax, z(i), x, corr(i),mNusedArray[idx]);
3128 if (dcorr <= -9999.0) {
3129 LOG_ERROR <<
"tofZbCorrC::Corr(" << tray <<
"," << module <<
"," << cell <<
"," << x <<
") is rejected.";
3130 if (x < z(i)[0] || x > z(i)[mNusedArray[idx]-1]) {LOG_ERROR <<
" Out of the range [" << z(i)[0] <<
"," << z(i)[mNusedArray[idx]-1] <<
"].";}
3136 #include "St_tofGeomAlignC.h"
3137 MakeChairInstance(tofGeomAlign,Calibrations/
tof/tofGeomAlign);
3138 #include "St_tofStatusC.h"
3139 MakeChairInstance(tofStatus,Calibrations/
tof/tofStatus);
3140 #include "St_pvpdStrobeDefC.h"
3141 MakeChairInstance(pvpdStrobeDef,Calibrations/
tof/pvpdStrobeDef);
3142 #include "St_tofCamacDaqMapC.h"
3143 MakeChairInstance(tofCamacDaqMap,Calibrations/
tof/tofCamacDaqMap);
3144 #include "St_tofDaqMapC.h"
3145 MakeChairInstance(tofDaqMap,Calibrations/
tof/tofDaqMap);
3146 #include "St_tofTrayConfigC.h"
3147 MakeChairInstance(tofTrayConfig,Calibrations/
tof/tofTrayConfig);
3148 #include "St_tofINLCorrC.h"
3149 MakeChairInstance(tofINLCorr,Calibrations/
tof/tofINLCorr);
3150 #include "St_tofINLSCorrC.h"
3151 MakeChairInstance(tofINLSCorr,Calibrations/
tof/tofINLSCorr);
3152 #include "St_tofModuleConfigC.h"
3153 MakeChairInstance(tofModuleConfig,Calibrations/
tof/tofModuleConfig);
3154 #include "St_tofPedestalC.h"
3155 MakeChairInstance(tofPedestal,Calibrations/
tof/tofPedestal);
3156 #include "St_tofr5MaptableC.h"
3157 MakeChairInstance(tofr5Maptable,Calibrations/
tof/tofr5Maptable);
3158 #include "St_tofTDIGOnTrayC.h"
3159 MakeChairInstance(tofTDIGOnTray,Calibrations/
tof/tofTDIGOnTray);
3160 #include "St_tofTOffsetC.h"
3161 MakeChairInstance(tofTOffset,Calibrations/
tof/tofTOffset);
3162 Float_t St_tofTOffsetC::t0(Int_t tray, Int_t module, Int_t cell)
const {
3164 Int_t j = cell - 1 + mNCell*(module - 1);
3165 return T0(tray-1)[j];
3167 #include "St_tofTrgWindowC.h"
3168 MakeChairInstance(tofTrgWindow,Calibrations/
tof/tofTrgWindow);
3169 #include "St_tofTzeroC.h"
3170 MakeChairInstance(tofTzero,Calibrations/
tof/tofTzero);
3171 #include "St_tofSimResParamsC.h"
3174 Double_t St_tofSimResParamsC::params[120][192] = {0};
3175 Double_t St_tofSimResParamsC::mAverageTimeResTof = 0;
3178 if (fgInstance)
return fgInstance;
3179 St_tofSimResParams *table = (St_tofSimResParams *) StMaker::GetChain()->GetDataBase(
"Calibrations/tof/tofSimResParams");
3181 LOG_WARN <<
"St_tofSimResParamsC::instance Calibrations/tof/tofSimResParams was not found" << endm;
3184 DEBUGTABLE(tofSimResParams);
3186 mAverageTimeResTof=0;
3187 const tofSimResParams_st *row = fgInstance->Struct(0);
3188 for ( Int_t i = 0; i < 120; i++ ){
3189 for ( Int_t j = 0; j < 192; j++ ){
3190 Int_t index = i * 120 + j;
3191 params[i][j] = row->resolution[index];
3192 mAverageTimeResTof +=
params[i][j];
3195 LOG_DEBUG <<
"tray:" << i <<
", mod cell:" << j <<
" = " << row->resolution[index] <<
" == " <<
params[i][j] << endm;
3200 mAverageTimeResTof=mAverageTimeResTof/(120*192);
3201 LOG_INFO <<
"Loaded tofSimResParams. Average = " << mAverageTimeResTof << endm;
3203 if (StDetectorDbMaker::instance()) {
3204 fgInstance->SetName(
"tofSimResParamsC");
3205 StDetectorDbMaker::instance()->AddConst(fgInstance);
3210 Double_t St_tofSimResParamsC::timeres_tof(UInt_t itray, UInt_t imodule, UInt_t icell) {
3215 Double_t result = 8.5e-11;
3216 if ( itray > 120 || imodule > 32 || icell > 6 )
return result;
3217 return params[ itray ][ imodule * 6 + icell ];
3219 #include "St_vpdDelayC.h"
3220 MakeChairInstance(vpdDelay,Calibrations/
tof/vpdDelay);
3221 #include "St_vpdTotCorrC.h"
3222 MakeChairInstance(vpdTotCorr,Calibrations/
tof/vpdTotCorr);
3223 Float_t St_vpdTotCorrC::Corr(Int_t i, Float_t x) {
3224 assert(tubeId(i) == i + 1);
3226 Float_t dcorr = St_tofCorrC::Correction(128, tot(i), x, corr(i),mNusedArray[idx]);
3227 if (dcorr <= -9999.0) {
3228 LOG_ERROR <<
"St_vpdTotCorrC::Corr(" << i <<
"," << x <<
") is rejected.";
3229 if (x < tot(i)[0] || x > tot(i)[mNusedArray[idx]-1]) {LOG_ERROR <<
" Out of the range [" << tot(i)[0] <<
"," << tot(i)[mNusedArray[idx]-1] <<
"].";}
3234 #include "St_vpdSimParamsC.h"
3235 MakeChairInstance(vpdSimParams,Calibrations/
tof/vpdSimParams);
3237 #include "St_emcPedC.h"
3238 MakeChairInstance2(emcPed,
St_bemcPedC,Calibrations/emc/y3bemc/bemcPed);
3239 MakeChairInstance2(emcPed,
St_bprsPedC,Calibrations/emc/y3bprs/bprsPed);
3240 #include "St_emcStatusC.h"
3241 MakeChairInstance2(emcStatus,
St_bemcStatusC,Calibrations/emc/y3bemc/bemcStatus);
3242 MakeChairInstance2(emcStatus,
St_bprsStatusC,Calibrations/emc/y3bprs/bprsStatus);
3243 #include "St_emcCalibC.h"
3244 MakeChairInstance2(emcCalib,
St_bemcCalibC,Calibrations/emc/y3bemc/bemcCalib);
3245 MakeChairInstance2(emcCalib,
St_bprsCalibC,Calibrations/emc/y3bprs/bprsCalib);
3246 #include "St_emcGainC.h"
3247 MakeChairInstance2(emcGain,
St_bemcGainC,Calibrations/emc/y3bemc/bemcGain);
3248 MakeChairInstance2(emcGain,
St_bprsGainC,Calibrations/emc/y3bprs/bprsGain);
3250 #include "St_smdPedC.h"
3251 MakeChairInstance2(smdPed,
St_bsmdePedC,Calibrations/smd/y3bsmde/bsmdePed);
3252 MakeChairInstance2(smdPed,
St_bsmdpPedC,Calibrations/smd/y3bsmdp/bsmdpPed);
3253 #include "St_smdStatusC.h"
3254 MakeChairInstance2(smdStatus,
St_bsmdeStatusC,Calibrations/smd/y3bsmde/bsmdeStatus);
3255 MakeChairInstance2(smdStatus,
St_bsmdpStatusC,Calibrations/smd/y3bsmdp/bsmdpStatus);
3256 #include "St_smdCalibC.h"
3257 MakeChairInstance2(smdCalib,
St_bsmdeCalibC,Calibrations/smd/y3bsmde/bsmdeCalib);
3258 MakeChairInstance2(smdCalib,
St_bsmdpCalibC,Calibrations/smd/y3bsmdp/bsmdpCalib);
3259 #include "St_smdGainC.h"
3260 MakeChairInstance2(smdGain,
St_bsmdeGainC,Calibrations/smd/y3bsmde/bsmdeGain);
3261 MakeChairInstance2(smdGain,
St_bsmdpGainC,Calibrations/smd/y3bsmdp/bsmdpGain);
3262 #include "St_emcTriggerStatusC.h"
3263 MakeChairInstance2(emcTriggerStatus,
St_bemcTriggerStatusC,Calibrations/emc/trigger/bemcTriggerStatus);
3264 #include "St_emcTriggerPedC.h"
3265 MakeChairInstance2(emcTriggerPed,
St_bemcTriggerPedC,Calibrations/emc/trigger/bemcTriggerPed);
3266 #include "St_emcTriggerLUTC.h"
3267 MakeChairInstance2(emcTriggerLUT,
St_bemcTriggerLUTC,Calibrations/emc/trigger/bemcTriggerLUT);
3268 #include "St_bemcMapC.h"
3269 MakeChairInstance(bemcMap,Calibrations/emc/map/bemcMap);
3270 #include "St_bprsMapC.h"
3271 MakeChairInstance(bprsMap,Calibrations/prs/map/bprsMap);
3272 #include "St_bsmdeMapC.h"
3273 MakeChairInstance(bsmdeMap,Calibrations/smde/map/bsmdeMap);
3274 #include "St_bsmdpMapC.h"
3275 MakeChairInstance(bsmdpMap,Calibrations/smdp/map/bsmdpMap);
3277 #include "St_istPedNoiseC.h"
3278 MakeChairInstance(istPedNoise,Calibrations/ist/istPedNoise);
3279 #include "St_istChipConfigC.h"
3280 MakeChairInstance(istChipConfig,Calibrations/ist/istChipConfig);
3281 #include "St_istControlC.h"
3282 MakeChairInstance(istControl,Calibrations/ist/istControl);
3283 #include "St_istGainC.h"
3284 MakeChairInstance(istGain,Calibrations/ist/istGain);
3285 #include "St_istMappingC.h"
3286 MakeChairInstance(istMapping,Calibrations/ist/istMapping);
3287 #include "St_istSimParC.h"
3288 MakeChairInstance(istSimPar,Calibrations/ist/istSimPar);
3290 #include "St_pxlHotPixelsC.h"
3293 map<UInt_t,Short_t> St_pxlHotPixelsC::mMapHotPixels;
3296 St_pxlHotPixels *table = (St_pxlHotPixels *) StMaker::GetChain()->GetDataBase(
"Calibrations/pxl/pxlHotPixels");
3298 LOG_WARN <<
"St_pxlHotPixelsC::instance Calibrations/pxl/pxlHotPixels\twas not found" << endm;
3301 DEBUGTABLE(pxlHotPixels);
3304 mMapHotPixels.clear();
3305 for(Int_t i=0; i<10000; i++){
3306 if(fgInstance->hotPixel()[i]>0){
3307 mMapHotPixels.insert ( std::pair<UInt_t, Short_t>(fgInstance->hotPixel()[i],i) );
3311 LOG_INFO <<
"St_pxlHotPixelsC have been instantiated with " << mMapHotPixels.size() << endm;
3316 Int_t St_pxlHotPixelsC::pixelHot(Int_t sector, Int_t ladder, Int_t sensor, Int_t row, Int_t
column)
const {
3317 map<UInt_t,Short_t>::const_iterator got;
3318 got = mMapHotPixels.find(1000000*((sector-1)*40+(ladder-1)*10+sensor) + 1000*row + column);
3319 if ( got == mMapHotPixels.end() ) {
3327 #include "St_pxlRowColumnStatusC.h"
3328 MakeChairInstance(pxlRowColumnStatus,Calibrations/pxl/pxlRowColumnStatus);
3329 #include "St_pxlBadRowColumnsC.h"
3330 MakeChairInstance(pxlBadRowColumns,Calibrations/pxl/pxlBadRowColumns);
3331 #include "St_pxlSensorStatusC.h"
3332 MakeChairInstance(pxlSensorStatus,Calibrations/pxl/pxlSensorStatus);
map< Int_t, Float_t > getTotalPrescales()
UInt_t getDsmPrescalesNumRows()
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
Accessor to the database for trigger id information.
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
virtual Int_t GetRunNumber() const
Returns the current RunNumber.
Float_t getTotalPrescaleByTrgId(Int_t trgId)
UInt_t getTrigL3ExpandedNumRows()
virtual Char_t * Print(Char_t *buf, Int_t n) const
Create IDL table defintion (to be used for XDF I/O)
virtual TDataSet * Find(const char *path) const