StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTpcdEdxCorrection.cxx
1 
7 #include "StMaker.h"
8 #include "StTpcdEdxCorrection.h"
9 #include "StTpcDb/StTpcDb.h"
10 #include "StBichsel/Bichsel.h"
11 #include "StMessMgr.h"
12 #include "St_db_Maker/St_db_Maker.h"
13 #include "TUnixTime.h"
14 #include "Stiostream.h"
15 #include "StDetectorDbMaker/St_tss_tssparC.h"
16 #include "StDetectorDbMaker/St_TpcEdgeC.h"
17 #include "StDetectorDbMaker/St_TpcAdcCorrectionBC.h"
18 #include "StDetectorDbMaker/St_TpcAdcCorrectionCC.h"
19 #include "StDetectorDbMaker/St_TpcAdcCorrectionMDF.h"
20 #include "StDetectorDbMaker/St_TpcAdcCorrection3MDF.h"
21 #include "StDetectorDbMaker/St_TpcAdcCorrection4MDF.h"
22 #include "StDetectorDbMaker/St_TpcAdcCorrection5MDF.h"
23 #include "StDetectorDbMaker/St_TpcAdcCorrection6MDF.h"
24 #include "StDetectorDbMaker/St_TpcdChargeC.h"
25 #include "StDetectorDbMaker/St_TpcrChargeC.h"
26 #include "StDetectorDbMaker/St_TpcCurrentCorrectionC.h"
27 #include "StDetectorDbMaker/St_TpcRowQC.h"
28 #include "StDetectorDbMaker/St_TpcAccumulatedQC.h"
29 #include "StDetectorDbMaker/St_TpcSecRowBC.h"
30 #include "StDetectorDbMaker/St_TpcSecRowCC.h"
31 #include "StDetectorDbMaker/St_tpcPressureBC.h"
32 #include "StDetectorDbMaker/St_TpcDriftDistOxygenC.h"
33 #include "StDetectorDbMaker/St_TpcMultiplicityC.h"
34 #include "StDetectorDbMaker/St_TpcZCorrectionBC.h"
35 #include "StDetectorDbMaker/St_TpcZCorrectionCC.h"
36 #include "StDetectorDbMaker/St_tpcMethaneInC.h"
37 #include "StDetectorDbMaker/St_tpcGasTemperatureC.h"
38 #include "StDetectorDbMaker/St_tpcWaterOutC.h"
39 #include "StDetectorDbMaker/St_TpcSpaceChargeC.h"
40 #include "StDetectorDbMaker/St_TpcPhiDirectionC.h"
41 #include "StDetectorDbMaker/St_TpcTanLC.h"
42 #include "StDetectorDbMaker/St_TpcAdcIC.h"
43 #include "StDetectorDbMaker/St_TpcnPadC.h"
44 #include "StDetectorDbMaker/St_TpcnTbkC.h"
45 #include "StDetectorDbMaker/St_TpcdZdYC.h"
46 #include "StDetectorDbMaker/St_TpcdXdYC.h"
47 #include "StDetectorDbMaker/St_TpcdXCorrectionBC.h"
48 #include "StDetectorDbMaker/St_TpcEtaCorrectionC.h"
49 #include "StDetectorDbMaker/St_TpcEtaCorrectionBC.h"
50 #include "StDetectorDbMaker/St_TpcEffectivedXC.h"
51 #include "StDetectorDbMaker/St_TpcZDCC.h"
52 #include "StDetectorDbMaker/St_TpcLengthCorrectionBC.h"
53 #include "StDetectorDbMaker/St_TpcLengthCorrectionMDF.h"
54 #include "StDetectorDbMaker/St_TpcLengthCorrectionMD2.h"
55 #include "StDetectorDbMaker/St_TpcLengthCorrectionMDN.h"
56 #include "StDetectorDbMaker/St_TpcPadCorrectionMDF.h"
57 #include "StDetectorDbMaker/St_TpcPadCorrectionMDC.h"
58 #include "StDetectorDbMaker/St_TpcdEdxCorC.h"
59 #include "StDetectorDbMaker/St_tpcAnodeHVavgC.h"
60 #include "StDetectorDbMaker/St_TpcAvgCurrentC.h"
61 #include "StDetectorDbMaker/St_TpcAvgPowerSupplyC.h"
62 #include "StDetectorDbMaker/St_tpcTimeDependenceC.h"
63 #include "StDetectorDbMaker/St_trigDetSumsC.h"
64 #include "StDetectorDbMaker/St_beamInfoC.h"
65 #include "StDetectorDbMaker/St_starTriggerDelayC.h"
66 //________________________________________________________________________________
67 StTpcdEdxCorrection::StTpcdEdxCorrection(Int_t option, Int_t debug) :
68  m_Mask(option), m_tpcGas(0),// m_trigDetSums(0), m_trig(0),
69  m_Debug(debug), m_IsSimulation(kFALSE)
70 {
71  assert(gStTpcDb);
72  if (!m_Mask) m_Mask = -1;
73  static const Char_t *FXTtables[] = {"TpcAdcCorrectionB",
74  "TpcAdcCorrectionC",
75  "TpcEdge",
76  // "TpcAdcCorrectionMDF",
77  "TpcAdcCorrection6MDF",
78  "TpcAdcCorrection5MDF",
79  "TpcAdcCorrection4MDF",
80  "TpcAdcCorrection3MDF",
81  "TpcdCharge",
82  // "TpcrCharge",
83  "TpcCurrentCorrection",
84  "TpcRowQ",
85  "TpcAccumulatedQ",
86  "TpcSecRowB",
87  // "TpcSecRowC",
88  "tpcPressureB",
89  // "tpcTime",
90  "TpcDriftDistOxygen",
91  "TpcMultiplicity",
92  "TpcZCorrectionC",
93  "TpcZCorrectionB",
94  "tpcMethaneIn",
95  "tpcGasTemperature",
96  "tpcWaterOut",
97  // "TpcSpaceCharge",
98  "TpcPhiDirection",
99  "TpcTanL",
100  "TpcdXCorrectionB",
101  "TpcEtaCorrectionB",
102  "TpcEffectivedX",
103  // "TpcPadTBins",
104  "TpcZDC",
105  "TpcPadCorrectionMDF",
106  "TpcPadCorrectionMDC",
107  // "TpcAdcI",
108  // "TpcnPad",
109  // "TpcnTbk",
110  // "TpcdZdY",
111  // "TpcdXdY",
112  "TpcLengthCorrectionB",
113  "TpcLengthCorrectionMDF",
114  "TpcLengthCorrectionMD2",
115  "TpcLengthCorrectionMDN",
116  "TpcdEdxCor"};
117  static Int_t NT = sizeof(FXTtables)/sizeof(const Char_t *);
118  m_isFixedTarget = St_beamInfoC::instance()->IsFixedTarget();
119  TString flavor("sim+ofl");
120 #ifdef __TFG__VERSION__
121  flavor += "+TFG";
122 #endif
123  if (m_isFixedTarget) flavor += "+FXT";
124  St_db_Maker *dbMk = (St_db_Maker *) StMaker::GetTopChain()->Maker("db");
125  for (Int_t i = 0; i < NT; i++) {
126  dbMk->SetFlavor(flavor, FXTtables[i]);
127  }
128  ReSetCorrections();
129 }
130 //________________________________________________________________________________
131 void StTpcdEdxCorrection::ReSetCorrections() {
132  St_tpcGas *tpcGas = (St_tpcGas *) St_tpcGasC::instance()->Table(); //
133  // St_tpcGas *tpcGas = (St_tpcGas *) StMaker::GetChain()->GetDataBase("Calibrations/tpc/tpcGas");
134  if (!tpcGas || ! tpcGas->GetNRows()) {
135  LOG_ERROR << "=== tpcGas is missing ===" << endm;
136  assert(tpcGas);
137  }
138  SettpcGas(tpcGas);
139  mTimeBinWidth = 1./StTpcDb::instance()->Electronics()->samplingFrequency();
140  mInnerSectorzOffset = StTpcDb::instance()->Dimensions()->zInnerOffset();
141  mOuterSectorzOffset = StTpcDb::instance()->Dimensions()->zOuterOffset();
142  Double_t trigT0 = 0, elecT0 = 0;
143  if (! St_starTriggerDelayC::instance()->Table()->IsMarked()) {// new scheme: offset = clocks*timebin + t0
144  trigT0 = St_starTriggerDelayC::instance()->clocks()*mTimeBinWidth;
145  elecT0 = St_starTriggerDelayC::instance()->tZero();
146  } else { // old scheme
147  trigT0 = StTpcDb::instance()->triggerTimeOffset()*1e6; // units are us
148  elecT0 = StTpcDb::instance()->Electronics()->tZero(); // units are us
149  }
150  m_TrigT0 = trigT0 + elecT0;
151  // Chairs
152  m_Corrections[kUncorrected ] = dEdxCorrection_t("UnCorrected" ,"" ,0);
153  m_Corrections[kAdcCorrection ] = dEdxCorrection_t("TpcAdcCorrectionB" ,"ADC/Clustering nonlinearity correction" ,St_TpcAdcCorrectionBC::instance());
154  m_Corrections[kAdcCorrectionC ] = dEdxCorrection_t("TpcAdcCorrectionC" ,"alternative ADC/Clustering nonlinearity correction" ,St_TpcAdcCorrectionCC::instance());
155  m_Corrections[kEdge ] = dEdxCorrection_t("TpcEdge" ,"Gain on distance from Chamber edge" ,St_TpcEdgeC::instance());
156  m_Corrections[kAdcCorrectionMDF ] = dEdxCorrection_t("TpcAdcCorrectionMDF" ,"ADC/Clustering nonlinearity correction MDF" ,St_TpcAdcCorrectionMDF::instance());
157  /* used only for tests
158  m_Corrections[kAdcCorrection3MDF ] = dEdxCorrection_t("TpcAdcCorrection3MDF","ADC/Clustering nonlinearity correction MDF 3D" ,St_TpcAdcCorrection3MDF::instance());
159  m_Corrections[kAdcCorrection4MDF ] = dEdxCorrection_t("TpcAdcCorrection4MDF","ADC/Clustering nonlinearity correction MDF 4D" ,St_TpcAdcCorrection4MDF::instance());
160  m_Corrections[kAdcCorrection5MDF ] = dEdxCorrection_t("TpcAdcCorrection5MDF","ADC/Clustering nonlinearity correction MDF+4D" ,St_TpcAdcCorrection5MDF::instance());
161  */
162  m_Corrections[kAdcCorrection6MDF ] = dEdxCorrection_t("TpcAdcCorrection6MDF","alternative ADC/Clustering nonlinearity correction MDF+4D" ,St_TpcAdcCorrection6MDF::instance());
163  m_Corrections[kTpcdCharge ] = dEdxCorrection_t("TpcdCharge" ,"ADC/Clustering undershoot correction" ,St_TpcdChargeC::instance());
164  /*
165  m_Corrections[kTpcrCharge ] = dEdxCorrection_t("TpcrCharge" ,"ADC/Clustering rounding correction" ,St_TpcrChargeC::instance());
166  */
167  m_Corrections[kTpcCurrentCorrection ] = dEdxCorrection_t("TpcCurrentCorrection","Correction due to sagg of Voltage due to anode current" ,St_TpcCurrentCorrectionC::instance());
168  m_Corrections[kTpcRowQ ] = dEdxCorrection_t("TpcRowQ" ,"Gas gain correction for row versus accumulated charge," ,St_TpcRowQC::instance());
169  m_Corrections[kTpcAccumulatedQ ] = dEdxCorrection_t("TpcAccumulatedQ" ,"Gas gain correction for HV channel versus accumulated charge," ,St_TpcAccumulatedQC::instance());
170  m_Corrections[kTpcSecRowB ] = dEdxCorrection_t("TpcSecRowB" ,"Gas gain correction for sector/row" ,St_TpcSecRowBC::instance());
171  /*
172  m_Corrections[kTpcSecRowC ] = dEdxCorrection_t("TpcSecRowC" ,"Additional Gas gain correction for sector/row" ,St_TpcSecRowCC::instance());
173  */
174  m_Corrections[ktpcPressure ] = dEdxCorrection_t("tpcPressureB" ,"Gain on Gas Density due to Pressure" ,St_tpcPressureBC::instance());
175  m_Corrections[ktpcTime ] = dEdxCorrection_t("tpcTime" ,"Unregognized time dependce" ,St_tpcTimeDependenceC::instance());
176  m_Corrections[kDrift ] = dEdxCorrection_t("TpcDriftDistOxygen" ,"Correction for Electron Attachment due to O2" ,St_TpcDriftDistOxygenC::instance());
177  m_Corrections[kMultiplicity ] = dEdxCorrection_t("TpcMultiplicity" ,"Global track multiplicity dependence" ,St_TpcMultiplicityC::instance());
178  m_Corrections[kzCorrectionC ] = dEdxCorrection_t("TpcZCorrectionC" ,"Variation on drift distance with Gating Grid one" ,St_TpcZCorrectionCC::instance());
179  m_Corrections[kzCorrection ] = dEdxCorrection_t("TpcZCorrectionB" ,"Variation on drift distance without Gating Gird one" ,St_TpcZCorrectionBC::instance());
180  /* Deactivated
181  m_Corrections[ktpcMethaneIn ] = dEdxCorrection_t("tpcMethaneIn" ,"Gain on Methane content" ,St_tpcMethaneInC::instance());
182  */
183  m_Corrections[ktpcGasTemperature ] = dEdxCorrection_t("tpcGasTemperature" ,"Gain on Gas Dens. due to Output (T5) Temperature" ,St_tpcGasTemperatureC::instance());
184  /* Deactivated
185  m_Corrections[ktpcWaterOut ] = dEdxCorrection_t("tpcWaterOut" ,"Gain on Water content" ,St_tpcWaterOutC::instance());
186  m_Corrections[kSpaceCharge ] = dEdxCorrection_t("TpcSpaceCharge" ,"Gain on space charge near the wire" ,St_TpcSpaceChargeC::instance());
187  */
188  m_Corrections[kPhiDirection ] = dEdxCorrection_t("TpcPhiDirection" ,"Gain on interception angle" ,St_TpcPhiDirectionC::instance());
189  m_Corrections[kTanL ] = dEdxCorrection_t("TpcTanL" ,"Gain on Tan(lambda)" ,St_TpcTanLC::instance());
190  m_Corrections[kdXCorrection ] = dEdxCorrection_t("TpcdXCorrectionB" ,"dX correction" ,St_TpcdXCorrectionBC::instance());
191  m_Corrections[kEtaCorrection ] = dEdxCorrection_t("TpcEtaCorrection" ,"Eta correction MC" ,St_TpcEtaCorrectionC::instance());
192  m_Corrections[kEtaCorrectionB ] = dEdxCorrection_t("TpcEtaCorrectionB" ,"Eta correction RC" ,St_TpcEtaCorrectionBC::instance());
193  m_Corrections[kTpcEffectivedX ] = dEdxCorrection_t("TpcEffectivedX" ,"dEdx correction wrt Bichsel parameterization" ,St_TpcEffectivedXC::instance());
194  m_Corrections[kTpcPadTBins ] = dEdxCorrection_t("TpcPadTBins" ,"Variation on cluster size" ,0);
195  m_Corrections[kTpcZDC ] = dEdxCorrection_t("TpcZDC" ,"Gain on Zdc CoincidenceRate" ,St_TpcZDCC::instance());
196  m_Corrections[kTpcPadMDF ] = dEdxCorrection_t("TpcPadCorrectionMDF" ,"Gain Variation along the anode wire" ,St_TpcPadCorrectionMDF::instance());
197  m_Corrections[kTpcPadMDC ] = dEdxCorrection_t("TpcPadCorrectionMDC" ,"Gain Variation along the anode wire with track curvature" ,St_TpcPadCorrectionMDC::instance());
198  /*
199  m_Corrections[kAdcI ] = dEdxCorrection_t("TpcAdcI" ,"Gain on Accumulated Adc on a socket)" ,St_TpcAdcIC::instance());
200  */
201  m_Corrections[knPad ] = dEdxCorrection_t("TpcnPad" ,"Gain on cluster length in pads" ,St_TpcnPadC::instance());
202  m_Corrections[knTbk ] = dEdxCorrection_t("TpcnTbk" ,"Gain on cluster length in time buckets" ,St_TpcnTbkC::instance());
203  /*
204  m_Corrections[kdZdY ] = dEdxCorrection_t("TpcdZdY" ,"Gain on track dZ/dY" ,St_TpcdZdYC::instance());
205  m_Corrections[kdXdY ] = dEdxCorrection_t("TpcdXdY" ,"Gain on track dX/dY" ,St_TpcdXdYC::instance());
206  */
207  m_Corrections[kTpcLast ] = dEdxCorrection_t("Final" ,"" ,0);
208  m_Corrections[kTpcLengthCorrection ] = dEdxCorrection_t("TpcLengthCorrectionB" ,"Variation vs Track length and relative error in Ionization" ,St_TpcLengthCorrectionBC::instance());
209  m_Corrections[kTpcLengthCorrectionMDF] = dEdxCorrection_t("TpcLengthCorrectionMDF","Variation vs Track length and <log2(dX)> and rel. error in dE/dx" ,St_TpcLengthCorrectionMDF::instance());
210  m_Corrections[kTpcLengthCorrectionMD2] = dEdxCorrection_t("TpcLengthCorrectionMD2","Variation vs Track length and <log2(dX)> for pred. with fixed dx2",St_TpcLengthCorrectionMD2::instance());
211  m_Corrections[kTpcLengthCorrectionMDN] = dEdxCorrection_t("TpcLengthCorrectionMDN","Variation vs Track length and <log2(dX)> for pred. with fixed dx2",St_TpcLengthCorrectionMDN::instance());
212  m_Corrections[kTpcNoAnodeVGainC ] = dEdxCorrection_t("TpcNoAnodeVGainC" ,"Remove tpc Anode Voltage gain correction" ,0);
213  m_Corrections[kTpcdEdxCor ] = dEdxCorrection_t("TpcdEdxCor" ,"dEdx correction wrt Bichsel parameterization" ,St_TpcdEdxCorC::instance());
214  const St_tpcCorrectionC *chair = 0;
215  const St_MDFCorrectionC *chairMDF = 0;
216  const St_MDFCorrection3C *chair3MDF = 0;
217  const St_MDFCorrection4C *chair4MDF = 0;
218  const St_TpcSecRowCorC *chairSecRow = 0;
219  const St_TpcEffectivedXC *chairEffectivedX = 0;
220  const TTable *table = 0;
221  TDatime t[2];
222  Int_t k = 0;
223  TString CommentLine;
224  for (k = kUncorrected+1; k < kTpcAllCorrections; k++) {
225  if (! m_Corrections[k].Chair) continue;
226  CommentLine = Form("StTpcdEdxCorrection: %24s/%66s",m_Corrections[k].Name,m_Corrections[k].Title);
227  table = m_Corrections[k].Chair->Table();
228  if (! table) continue;
229  if (Debug() > 2) table->Print(0,10);
230  if (! TESTBIT(m_Mask,k) || m_Corrections[k].Chair->Table()->IsMarked()) {
231  CommentLine += " \tis missing";
232  CLRBIT(m_Mask,k);
233  SafeDelete(m_Corrections[k].Chair);
234  if (Debug()) {
235  LOG_WARN << CommentLine.Data() << endm;
236  }
237  continue;
238  }
239  if (St_db_Maker::GetValidity(table,t) > 0) {
240  CommentLine += Form("\tValidity:%08i.%06i --- %08i.%06i",t[0].GetDate(),t[0].GetTime(),t[1].GetDate(),t[1].GetTime());
241  }
242  chair = dynamic_cast<const St_tpcCorrectionC *>(m_Corrections[k].Chair);
243  chairMDF = dynamic_cast<const St_MDFCorrectionC *>(m_Corrections[k].Chair);
244  chair3MDF = dynamic_cast<const St_MDFCorrection3C *>(m_Corrections[k].Chair);
245  chair4MDF = dynamic_cast<const St_MDFCorrection4C *>(m_Corrections[k].Chair);
246  Int_t npar = 0;
247  if (chair ) { npar = chair ->IsActiveChair();
248  } else if (chairMDF ) { npar = chairMDF ->IsActiveChair();
249  } else if (chair3MDF) { npar = chair3MDF->IsActiveChair();
250  } else if (chair4MDF) { npar = chair4MDF->IsActiveChair();
251  } else {
252  chairSecRow = dynamic_cast<const St_TpcSecRowCorC *>(m_Corrections[k].Chair);
253  chairEffectivedX = dynamic_cast<const St_TpcEffectivedXC *>(m_Corrections[k].Chair);
254  if (! chairSecRow && ! chairEffectivedX) {
255  CommentLine += "\tis not tpcCorrection, MDFCorrection, TpcEffectivedX, TpcEffectivedX, or TpcSecRowCor types";
256  }
257  // if (Debug()) {
258  LOG_WARN << CommentLine.Data() << endm;
259  // }
260  continue;
261  }
262  if (! npar ) {
263  CommentLine += " \thas no significant corrections => switch it off \tIt is cleaned";
264  CLRBIT(m_Mask,k);
265  SafeDelete(m_Corrections[k].Chair);
266  if (Debug()) {
267  LOG_WARN << CommentLine.Data() << endm;
268  }
269  continue;
270  }
271  LOG_WARN << CommentLine.Data() << endm;
272  }
273  // Check consistency of active chairs
274  if ( m_Corrections[kzCorrectionC].Chair) { // if kzCorrectionC is already active
275  vector<Int_t> kvect = {kzCorrection}; // , kGatingGrid};
276  for (auto k : kvect) {
277  if (m_Corrections[k].Chair) {
278  LOG_WARN << m_Corrections[kzCorrectionC].Name << " is already active => disable " << m_Corrections[k].Name << endm;
279  CLRBIT(m_Mask,k);
280  SafeDelete(m_Corrections[k].Chair);
281  }
282  }
283  }
284  // Use only one set of ADC correction
285  Int_t PriorityList[] = { kAdcCorrection6MDF, kAdcCorrection5MDF, kAdcCorrection4MDF, kAdcCorrection3MDF, kAdcCorrectionMDF, kAdcCorrectionC, kAdcCorrection};
286  Int_t i = 0;
287  for (auto k : PriorityList) {
288  i++;
289  if (! m_Corrections[k].Chair) continue;
290  Int_t j = 0;
291  for (auto x : PriorityList) {
292  j++;
293  if (j <= i) continue;
294  if (! m_Corrections[x].Chair) continue;
295  if (x == k) continue;
296  if (k == kAdcCorrection6MDF && x == kAdcCorrectionC) {
297  assert(m_Corrections[x].Chair);
298  continue;
299  }
300  LOG_WARN << "With" << m_Corrections[k].Name << " activated => Deactivate " << m_Corrections[x].Name << endm;
301  CLRBIT(m_Mask,x);
302  SafeDelete(m_Corrections[x].Chair);
303  }
304  }
305  // Use only TpcLengthCorrection
306  Int_t PriorityListL[] = {kTpcLengthCorrectionMDN,kTpcLengthCorrectionMD2, kTpcLengthCorrectionMDF, kTpcLengthCorrection};
307  i = 0;
308  for (auto k : PriorityListL) {
309  i++;
310  if (! m_Corrections[k].Chair) continue;
311  Int_t j = 0;
312  for (auto x : PriorityListL) {
313  j++;
314  if (j <= i) continue;
315  if (! m_Corrections[x].Chair) continue;
316  if (x == k) continue;
317  LOG_WARN << "With " << m_Corrections[k].Name << " activated => Deactivate " << m_Corrections[x].Name << endm;
318  CLRBIT(m_Mask,x);
319  SafeDelete(m_Corrections[x].Chair);
320  }
321  }
322  // Use only TpcPadCorrection
323  Int_t PriorityListP[] = {kTpcPadMDC, kTpcPadMDF};
324  i = 0;
325  for (auto k : PriorityListP) {
326  i++;
327  if (! m_Corrections[k].Chair) continue;
328  Int_t j = 0;
329  for (auto x : PriorityListP) {
330  j++;
331  if (j <= i) continue;
332  if (! m_Corrections[x].Chair) continue;
333  if (x == k) continue;
334  LOG_WARN << "With " << m_Corrections[k].Name << " activated => Deactivate " << m_Corrections[x].Name << endm;
335  CLRBIT(m_Mask,x);
336  SafeDelete(m_Corrections[x].Chair);
337  }
338  }
339 }
340 //________________________________________________________________________________
341 StTpcdEdxCorrection::~StTpcdEdxCorrection() {
342  // Can't delete because the chairs are also used in StTpcRSMaker
343  // for (Int_t k = 0; k < kTpcAllCorrections; k++) SafeDelete(m_Corrections[k].Chair);
344 }
345 //________________________________________________________________________________
346 Int_t StTpcdEdxCorrection::dEdxCorrection(dEdxY2_t &CdEdx, Bool_t doIT) {
347  // static const Double_t Degree2Rad = TMath::Pi()/180.;
348  mdEdx = &CdEdx;
349  if (CdEdx.F.dE <= 0.) CdEdx.F.dE = 1;
350  Double_t dEU = CdEdx.F.dE;
351  Double_t dE = dEU;
352  Int_t sector = CdEdx.sector;
353  Int_t row = CdEdx.row;
354  Double_t dxC = CdEdx.F.dx;
355  Int_t qB = CdEdx.qB;
356  Double_t adcCF = CdEdx.adc;
357  Int_t iok = 0;
358  if (dxC <= 0 || (dEU <= 0 && adcCF <= 0)) {
359  iok = 1;
360  return iok;
361  }
362  Int_t channel = St_TpcAvgPowerSupplyC::instance()->ChannelFromRow(sector,row);
363  CdEdx.channel = channel;
364 
365  CdEdx.Voltage = St_tpcAnodeHVavgC::instance()->voltagePadrow(sector,row);
366  CdEdx.Crow = St_TpcAvgCurrentC::instance()->AvCurrRow(sector,row);
367  Double_t Qcm = St_TpcAvgCurrentC::instance()->AcChargeRowL(sector,row); // C/cm
368  CdEdx.Qcm = 1e6*Qcm; // uC/cm
369  TUnixTime u(StMaker::GetChain()->GetDateTime(), kTRUE); // GMT
370  if (! St_trigDetSumsC::GetInstance()) {
371  StMaker::GetChain()->AddData(St_trigDetSumsC::instance());
372  }
373 #if 0
374  if ( ! St_trigDetSumsC::instance() ) {LOG_ERROR << "StTpcdEdxCorrection::dEdxCorrection Cannot find trigDetSums" << endm;}
375  else {
376  if (!St_trigDetSumsC::instance()->GetNRows()) {LOG_ERROR << "StTpcdEdxCorrection::dEdxCorrection trigDetSums has not data" << endm;}
377  else {
378  TUnixTime u2(St_trigDetSumsC::instance()->timeOffset());
379  if (u() + 30 < u2()) {
380  LOG_ERROR << "StTpcdEdxCorrection::dEdxCorrection Illegal time for scalers = "
381  << u2() << "/" << u()
382  << " Run " << St_trigDetSumsC::instance()->runNumber() << "/" << StMaker::GetChain()->GetRunNumber() << endm;
383  // St_trigDetSumsC::instance()->Table()->Print(0,10);
384  }
385  }
386  }
387 #if 0
388  // Check that we have valid time for Power Suppliers
389  if (St_TpcAvgPowerSupplyC::instance()->run() > 0) {
390  TUnixTime u2(St_trigDetSumsC::instance()->timeOffset()+5*3600); // EDT => GMT
391  if (u2() < u() + 30) {
392  LOG_ERROR << "StTpcdEdxCorrection::dEdxCorrection Illegal TpcAvgPowerSupply stop time = " << u2() << " GMT from local " << u2.GetGString()
393  << " < event time = " << u() << " GMT\t=" << StMaker::GetChain()->GetDateTime().AsString() << endm;
394  iok = 1;
395  return iok;
396  }
397  }
398 #endif
399 #endif
400  Double_t ZdriftDistance = CdEdx.ZdriftDistance;
401  ESector kTpcOutIn = kTpcOuter;
402  Float_t gasGain = 1;
403  Float_t gainNominal = 0;
404  St_tss_tssparC *tsspar = St_tss_tssparC::instance();
405  if (row <= St_tpcPadConfigC::instance()->innerPadRows(sector)) {
406  kTpcOutIn = kTpcInner;
407  gainNominal = tsspar->gain_in()*tsspar->wire_coupling_in();
408  gasGain = tsspar->gain_in(sector,row) *tsspar->wire_coupling_in();
409  } else {
410  kTpcOutIn = kTpcOuter;
411  gainNominal = tsspar->gain_out()*tsspar->wire_coupling_out();
412  gasGain = tsspar->gain_out(sector,row)*tsspar->wire_coupling_out();
413  }
414  if (St_tpcPadConfigC::instance()->iTpc(sector) && row <= St_tpcPadConfigC::instance()->innerPadRows(sector)) kTpcOutIn = kiTpc;
415  if (gasGain <= 0.0) {
416  iok = 1;
417  return iok;
418  }
419  CdEdx.driftTime = ZdriftDistance/gStTpcDb->DriftVelocity(sector)*1e6 - m_TrigT0;// musec
420  // Double_t gainAVcorr = gasGain/gainNominal;
421  mAdc2GeV = tsspar->ave_ion_pot() * tsspar->scale()/gainNominal;
422  Double_t Adc2GeVReal = tsspar->ave_ion_pot() * tsspar->scale()/gasGain;
423  tpcGas_st *gas = m_tpcGas->GetTable();
424  Double_t ZdriftDistanceO2 = ZdriftDistance*(*m_tpcGas)[0].ppmOxygenIn;
425  Double_t ZdriftDistanceO2W = ZdriftDistanceO2*(*m_tpcGas)[0].ppmWaterOut;
426  CdEdx.ZdriftDistanceO2 = ZdriftDistanceO2;
427  CdEdx.ZdriftDistanceO2W = ZdriftDistanceO2W;
428  Double_t gc, ADC = 0, xL2, dXCorr;//, gcRMS;
429  Double_t slope = 0;
430  Int_t nrows = 0;
431  Double_t VarXs[kTpcLast] = {-999.};
432  VarXs[kAdcCorrection] = adcCF;
433  VarXs[kEdge] = TMath::Abs(CdEdx.edge);
434  VarXs[kAdcCorrectionMDF] = adcCF;
435  VarXs[kTpcrCharge] = CdEdx.rCharge;
436  VarXs[kTpcCurrentCorrection] = CdEdx.Crow;
437  VarXs[kTpcRowQ] = CdEdx.Qcm;
438  VarXs[kTpcAccumulatedQ] = CdEdx.Qcm;
439  VarXs[ktpcPressure] = TMath::Log(gas->barometricPressure);
440  VarXs[ktpcTime] = CdEdx.tpcTime;
441  VarXs[kDrift] = ZdriftDistanceO2; // Blair correction
442  VarXs[kMultiplicity] = CdEdx.QRatio;
443  VarXs[kGatingGrid] = CdEdx.driftTime;
444  VarXs[kzCorrectionC] = ZdriftDistance;
445  VarXs[kzCorrection] = ZdriftDistance;
446  VarXs[ktpcMethaneIn] = gas->percentMethaneIn*1000./gas->barometricPressure;
447  VarXs[ktpcGasTemperature] = gas->outputGasTemperature;
448  VarXs[ktpcWaterOut] = gas->ppmWaterOut;
449  VarXs[kPhiDirection] = (TMath::Abs(CdEdx.xyzD[0]) > 1.e-7) ? TMath::Abs(CdEdx.xyzD[1]/CdEdx.xyzD[0]) : 999.;
450  VarXs[kTanL] = CdEdx.TanL;
451  VarXs[kTpcPadTBins] = CdEdx.Npads*CdEdx.Ntbks;
452  VarXs[kTpcZDC] = (CdEdx.Zdc > 0) ? TMath::Log10(CdEdx.Zdc) : 0;
453  VarXs[kAdcI] = CdEdx.AdcI;
454  VarXs[knPad] = CdEdx.Npads;
455  VarXs[knTbk] = CdEdx.Ntbks;
456  VarXs[kdZdY] = CdEdx.dZdY;
457  VarXs[kdXdY] = CdEdx.dXdY;
458  VarXs[kEtaCorrection] = CdEdx.etaG*CdEdx.etaG;
459  VarXs[kEtaCorrectionB] = CdEdx.etaG;
460  Int_t NLoops = 0;
461  Int_t m = 0;
462  for (Int_t k = kUncorrected; k <= kTpcLast; k++) {
463  Int_t l = 0;
464  tpcCorrection_st *cor = 0;
465  tpcCorrection_st *corl = 0;
466  const St_tpcCorrectionC *chairC;
467  if (CdEdx.lSimulated) {
468  if (k == kAdcCorrection) dE *= 2.116;// 1.75; // 1.25 is in Trs already <<<< !!!!!!
469  goto ENDL;
470  }
471  if (! TESTBIT(m_Mask, k)) goto ENDL;
472  if (! m_Corrections[k].Chair) goto ENDL;
473  chairC = dynamic_cast<const St_tpcCorrectionC *>(m_Corrections[k].Chair);
474  if (k == kTpcSecRowB || k == kTpcSecRowC ) {
475  const St_TpcSecRowCor *table = (const St_TpcSecRowCor *) m_Corrections[k].Chair->Table();
476  if (! table) goto ENDL;
477  const TpcSecRowCor_st *gain = table->GetTable() + sector - 1;
478  gc = gain->GainScale[row-1];
479  // gcRMS = gain->GainRms[row-1];1
480  // if (gc <= 0.0 || gcRMS <= 0.0) {
481  if (gc <= 0.0) {
482  return k;
483  }
484  dE *= gc;
485  CdEdx.Weight = 1;
486  if (gain->GainRms[row-1] > 0.1) CdEdx.Weight = 1./(gain->GainRms[row-1]*gain->GainRms[row-1]);
487  goto ENDL;
488  } else if (k == kTpcEffectivedX) {
489  if (kTpcOutIn == kTpcOuter) dxC *= ((const St_TpcEffectivedXC* ) m_Corrections[k].Chair)->scaleOuter();
490  else if (kTpcOutIn == kTpcInner ||
491  kTpcOutIn == kiTpc ) dxC *= ((const St_TpcEffectivedXC* ) m_Corrections[k].Chair)->scaleInner();
492  goto ENDL;
493  } else if (k == kTpcPadMDF) {
494  l = 2*(sector-1);
495  if (row <= St_tpcPadConfigC::instance()->innerPadRows(sector)) l += kTpcInner; // for both tpc and iTPC inner sectors
496  dE *= TMath::Exp(-((St_MDFCorrectionC *)m_Corrections[k].Chair)->Eval(l,CdEdx.yrow,CdEdx.xpad));
497  goto ENDL;
498  } else if (k == kTpcPadMDC) {
499  Int_t nrows = ((St_MDFCorrectionC *) m_Corrections[k].Chair)->nrows();
500  l = 2*(sector-1);
501  if (nrows > 48 && qB) l += 48*qB;
502  if (row <= St_tpcPadConfigC::instance()->innerPadRows(sector)) l += kTpcInner; // for both tpc and iTPC inner sectors
503  dE *= TMath::Exp(-((St_MDFCorrectionC *)m_Corrections[k].Chair)->Eval(l,CdEdx.yrow+24*qB,CdEdx.xpadR));
504  goto ENDL;
505  } else if (k == kAdcCorrectionMDF) {
506  ADC = adcCF;
507  if (ADC <= 0) {
508  return k;
509  }
510  l = kTpcOutIn;
511  Int_t nrows = ((St_MDFCorrectionC *) m_Corrections[k].Chair)->nrows();
512  if (l >= nrows) l = nrows - 1;
513  Double_t xx[2] = {TMath::Log(ADC), (Double_t)(CdEdx.Npads+CdEdx.Ntbks)};
514  Double_t Cor = ((St_MDFCorrectionC *) m_Corrections[k].Chair)->Eval(l,xx);
515  dE = ADC*Adc2GeVReal*TMath::Exp(Cor);
516  goto ENDL;
517  } else if (k == kAdcCorrection3MDF) {
518  ADC = adcCF;
519  if (ADC <= 0) {
520  return k;
521  }
522  l = kTpcOutIn;
523  Int_t nrows = ((St_MDFCorrection3C *) m_Corrections[k].Chair)->nrows();
524  if (l >= nrows) l = nrows - 1;
525  Double_t xx[3] = {(Double_t) CdEdx.Ntbks, TMath::Abs(CdEdx.zG), TMath::Log(ADC)};
526  Double_t Cor = ((St_MDFCorrection3C *) m_Corrections[k].Chair)->Eval(l,xx);
527  dE = ADC*Adc2GeVReal*TMath::Exp(Cor);
528  goto ENDL;
529  } else if (k == kAdcCorrection4MDF) {
530  ADC = adcCF;
531  if (ADC <= 0) {
532  return k;
533  }
534  l = kTpcOutIn;
535  Int_t nrows = ((St_TpcAdcCorrection4MDF *) m_Corrections[k].Chair)->nrows();
536  if (l >= nrows) l = nrows - 1;
537  Double_t xx[4] = {(Double_t) CdEdx.Ntbks, (Double_t) CdEdx.Npads, TMath::Abs(CdEdx.zG), TMath::Log(ADC)};
538  Double_t Cor = ((St_TpcAdcCorrection4MDF *) m_Corrections[k].Chair)->Eval(l,xx);
539  dE = ADC*Adc2GeVReal*TMath::Exp(Cor);
540  goto ENDL;
541  } else if (k == kAdcCorrection5MDF) {
542  l = kTpcOutIn;
543  Int_t nrows = ((St_TpcAdcCorrection5MDF *) m_Corrections[k].Chair)->nrows();
544  if (l >= nrows) l = nrows - 1;
545  Double_t xx[4] = {(Double_t) CdEdx.Ntbks, (Double_t) CdEdx.Npads, TMath::Abs(CdEdx.zG), TMath::Log(ADC)};
546  Double_t Cor = ((St_TpcAdcCorrection5MDF *) m_Corrections[k].Chair)->Eval(l,xx);
547  dE *= TMath::Exp(Cor);
548  goto ENDL;
549  } else if (k == kAdcCorrection6MDF) {
550  goto ENDL; // kAdcCorrection6MDF is in kAdcCorrectionC
551  }
552  cor = ((St_tpcCorrection *) m_Corrections[k].Chair->Table())->GetTable();
553  if (! cor) goto ENDL;
554  NLoops = cor->type/100000 + 1;
555  nrows = cor->nrows/NLoops;
556  if (nrows <= 3) {
557  l = TMath::Min(nrows-1, kTpcOutIn);
558  } else {
559  if (nrows == St_tpcPadConfigC::instance()->numberOfRows(sector)) l = row - 1;
560  else if (nrows == 192) {l = 8*(sector-1) + channel - 1; assert(l == (cor+l)->idx-1);}
561  else if (nrows == 8) {l = channel - 1; assert(l == (cor+l)->idx-1);}
562  else if (nrows == 48) {l = 2*(sector-1) + kTpcOutIn;}
563  else if (nrows == 6) {l = kTpcOutIn; if (sector > 12) l+= 3;}
564  else if (nrows == 4) {l = TMath::Min(kTpcOutIn, 1); if (sector > 12) l+= 2;}
565  }
566  if (NLoops == 1) {
567  corl = cor + l;
568  if (k == kAdcCorrection) {
569  ADC = adcCF;
570  if (ADC <= 0) {
571  return k;
572  }
573  if (corl->type == 12)
574  dE = Adc2GeVReal*chairC->CalcCorrection(l,ADC,VarXs[kTanL]);
575  else
576  dE = Adc2GeVReal*chairC->CalcCorrection(l,ADC,TMath::Abs(CdEdx.zG));
577  if (dE <= 0) {
578  return k;
579  }
580  goto ENDL;
581  } else if (k == kAdcCorrection6MDF) {
582  goto ENDL; // kAdcCorrection6MDF is in kAdcCorrectionC
583  } else if (k == kAdcCorrectionC) {
584  ADC = adcCF;
585  if (adcCF <= 0) {
586  return k;
587  }
588  ADC = chairC->CalcCorrection(l,adcCF);
589  if (m_Corrections[kAdcCorrection6MDF].Chair) {
590  Double_t xx[4] = {(Double_t) CdEdx.Ntbks, (Double_t) CdEdx.Npads, TMath::Abs(CdEdx.zG), TMath::Log(adcCF)};
591  ADC += ((St_MDFCorrection4C *)m_Corrections[kAdcCorrection6MDF].Chair)->Eval(l,xx);// * TMath::Exp(chairC->a(l)[0]);
592  }
593  dE = Adc2GeVReal*ADC;
594  goto ENDL;
595  } else if (k == kTpcdCharge) {
596  if (l > 2) l = 1;
597  slope = chairC->CalcCorrection(l,row+0.5);
598  dE *= TMath::Exp(-slope*CdEdx.dCharge);
599  dE *= TMath::Exp(-chairC->CalcCorrection(2+l,CdEdx.dCharge));
600  goto ENDL;
601  } else if (k == kdXCorrection) {
602  xL2 = TMath::Log2(dxC);
603  dXCorr = chairC->CalcCorrection(l,xL2);
604  if (TMath::Abs(dXCorr) > 10) {
605  return k;
606  }
607  if (nrows == 7) {// old schema without iTPC
608  dXCorr += chairC->CalcCorrection(2,xL2);
609  dXCorr += chairC->CalcCorrection(5+kTpcOutIn,xL2);
610  }
611  dxC = TMath::Exp(dXCorr)*CdEdx.F.dx;
612  CdEdx.dxC = dxC;
613  dE *= TMath::Exp(-dXCorr); // Check !!!!!!
614  goto ENDL;
615  } else if (k == kSpaceCharge) {
616  if (cor[2*l ].min <= CdEdx.QRatio && CdEdx.QRatio <= cor[2*l ].max &&
617  cor[2*l+1].min <= CdEdx.DeltaZ && CdEdx.DeltaZ <= cor[2*l+1].max)
618  dE *= TMath::Exp(-chairC->CalcCorrection(2*l ,CdEdx.QRatio)
619  -chairC->CalcCorrection(2*l+1,CdEdx.DeltaZ));
620  goto ENDL;
621  } else if (k == ktpcTime) { // use the correction if you have xmin < xmax && xmin <= x <= xmax
622  if (corl->min >= corl->max || corl->min > VarXs[ktpcTime] || VarXs[ktpcTime] > corl->max) goto ENDL;
623  Double_t xx = VarXs[ktpcTime];
624  dE *= TMath::Exp(-chairC->CalcCorrection(l,xx));
625  goto ENDL;
626  }
627  if (k == kzCorrection || k == kzCorrectionC) {
628  // Take care about prompt hits and Gating Grid region in Simulation
629  if ((corl->min < corl->max) && (corl->min > VarXs[k] || VarXs[k] > corl->max)) {
630  if (! IsSimulation()) {
631  return k;
632  }
633  }
634  if (ZdriftDistance < -0.6) {// prompt hits after cathode wire plane
635  dE *= TMath::Exp(1.2);
636  goto ENDL;
637  } else if (VarXs[k] < 0.0) {// hits after Gating Grid and before cathode wire plane
638  return k;
639  }
640  if (k == kzCorrectionC && corl->type == 20) {
641  Int_t np = TMath::Abs(corl->npar)%100;
642  if (TMath::Abs(corl->a[np]) > 1e-7) {// extra exponent
643  Double_t dEcor = corl->a[np]*TMath::Exp( corl->a[np+1]*VarXs[k]);
644  if (dEcor < -9.9) {
645  return k;
646  }
647  dE *= TMath::Exp(-dEcor);
648  }
649  }
650  }
651  if (corl->type == 200 && (corl->min < corl->max) && ! IsSimulation() ) {// cut out the range
652  if ((corl->min > VarXs[k] || corl->max < VarXs[k])) {
653  return k;
654  }
655  }
656  if (corl->type == 300 && (corl->min < corl->max)) {
657  VarXs[k] = TMath::Min(corl->max, TMath::Max( corl->min, VarXs[k]));
658  }
659  if (TMath::Abs(corl->npar) >= 100) {
660  iok = 2;
661  if (corl->min >= corl->max) {
662  iok = 0;
663  } else {
664  if (corl->min <= VarXs[k] && VarXs[k] <= corl->max) {
665  iok = 0;
666  }
667  }
668  if (iok) {
669  return k;
670  }
671  }
672  if (corl->npar%100) {
673  Double_t dECor = TMath::Exp(-chairC->CalcCorrection(l,VarXs[k]));
674  dE *= dECor;
675  }
676  } else { // repeatable
677  for (m = 0; m < NLoops; m++, l += nrows) {
678  corl = cor + l;
679  if (corl->min < corl->max && corl->min <= VarXs[k] && VarXs[k] < corl->max) {
680  dE *= TMath::Exp(-chairC->CalcCorrection(l,VarXs[k]));
681  break;
682  }
683  }
684  }
685  ENDL:
686  CdEdx.C[k].dE = dE;
687  CdEdx.C[k].dx = dxC;
688  CdEdx.C[k].dEdx = CdEdx.C[k].dE/CdEdx.C[k].dx;
689  CdEdx.C[k].dEdxL = TMath::Log(CdEdx.C[k].dEdx);
690  if (! k) CdEdx.C[k].ddEdxL = 0;
691  else CdEdx.C[k].ddEdxL = CdEdx.C[k].dEdxL - CdEdx.C[k-1].dEdxL;
692 #if 0
693  if (m_Debug) {
694  cout << m_Corrections[k].Name; CdEdx.C[k].Print();
695  }
696 #endif
697  }
698 #if 0
699  if (TMath::IsNaN(CdEdx.C[kTpcLast].dE)) {
700  static Int_t iBreak = 0;
701  iBreak++;
702  }
703 #endif
704  CdEdx.F = CdEdx.C[kTpcLast];
705  // memcpy (&CdEdx.dE, &CdEdx.C[kTpcLast].dE, sizeof(dE_t));
706  return iok;
707 }
708 //________________________________________________________________________________
709 Int_t StTpcdEdxCorrection::dEdxTrackCorrection(Int_t type, dst_dedx_st &dedx, Double_t etaG) {
710  Int_t ok = 0;
711  if (m_Corrections[kTpcLengthCorrectionMDN].Chair) ok = dEdxTrackCorrection(kTpcLengthCorrectionMDN,type,dedx, etaG);
712  else if (m_Corrections[kTpcLengthCorrectionMD2].Chair) ok = dEdxTrackCorrection(kTpcLengthCorrectionMD2,type,dedx);
713  else if (m_Corrections[kTpcLengthCorrectionMDF].Chair) ok = dEdxTrackCorrection(kTpcLengthCorrectionMDF,type,dedx);
714  else if (m_Corrections[kTpcLengthCorrection ].Chair) ok = dEdxTrackCorrection(kTpcLengthCorrection ,type,dedx);
715  if (m_Corrections[kTpcdEdxCor].Chair) ok = dEdxTrackCorrection(kTpcdEdxCor ,type,dedx);
716  return ok;
717 }
718 //________________________________________________________________________________
719 Int_t StTpcdEdxCorrection::dEdxTrackCorrection(EOptions opt, Int_t type, dst_dedx_st &dedx, Double_t etaG) {
720  Double_t xx[2] = {0};
721  Double_t LogTrackLength = TMath::Log((Double_t) (dedx.ndedx/100));
722  if (opt != kTpcLengthCorrectionMDN) {
723  Double_t dxLog2 = dedx.dedx[2];
724  xx[0] = LogTrackLength;
725  xx[1] = dxLog2;
726  } else {
727  Double_t LogNodEdx = TMath::Log((Double_t) (dedx.ndedx%100));
728  xx[0] = LogNodEdx;
729  xx[1] = etaG;
730  }
731  Double_t I70L;
732  Int_t k = opt;
733  if (! m_Corrections[k].Chair) return 0;
734  Int_t l = 2*type;
735  Int_t nrows = 0;
736  Double_t dEdxError = 0;
737  const St_tpcCorrectionC *chairC = dynamic_cast<const St_tpcCorrectionC *>(m_Corrections[k].Chair);
738  switch (k) {
739  case kTpcLengthCorrection:
740  nrows = chairC->nrows(l);
741  switch (type) {
742  case 0: // I70
743  case 1: // dNdx
744  case 2: // fit
745  if (nrows > l+1) {
746  dedx.dedx[0] *= TMath::Exp(-chairC->CalcCorrection( l,LogTrackLength));
747  dEdxError = chairC->CalcCorrection(l+1,LogTrackLength);
748  if (dEdxError > 0) dedx.dedx[1] = dEdxError;
749  }
750  if (nrows > l+6) {
751  dedx.dedx[0] *= TMath::Exp(-chairC->CalcCorrection(l+6,LogTrackLength));
752  }
753  break;
754  default:
755  break;
756  }
757  break;
758  case kTpcLengthCorrectionMDF:
759  case kTpcLengthCorrectionMD2:
760  case kTpcLengthCorrectionMDN:
761  nrows = ((St_MDFCorrectionC *) m_Corrections[k].Chair)->nrows(l);
762  if (dedx.det_id > 100 && nrows > l+6) l += 6;
763  switch (type) {
764  case 0: // I70
765  case 1: // dNdx
766  case 2: // fit
767  if (nrows > l+1) {
768  dedx.dedx[0] *= TMath::Exp(-((St_MDFCorrectionC *)m_Corrections[k].Chair)->Eval( l,xx));
769  dEdxError = ((St_MDFCorrectionC *)m_Corrections[k].Chair)->Eval(l+1,xx);
770  if (dEdxError > 0) dedx.dedx[1] = dEdxError;
771  }
772  break;
773  default:
774  break;
775  }
776  break;
777  case kTpcdEdxCor:
778  I70L = TMath::Log(1.e6*dedx.dedx[0]);
779  if (I70L > 0) dedx.dedx[0] *= TMath::Exp(-chairC->SumSeries(0,I70L));
780  break;
781  default:
782  break;
783  }
784  return 0;
785 }
786 //________________________________________________________________________________
787 void StTpcdEdxCorrection::Print(Option_t *opt) const {
788  if (! mdEdx) return;
789  cout << "StTpcdEdxCorrection:: Sector/row/pad " << mdEdx->sector << "/" << mdEdx->row << "/" << mdEdx->pad << endl;
790  cout << "Npads/Ntbks " << mdEdx->Npads << "/" << mdEdx->Ntbks
791  << "\tdrift distance / O2 / O2W " << mdEdx->ZdriftDistance << "/" << mdEdx->ZdriftDistanceO2 << "/" << mdEdx->ZdriftDistanceO2W << endl;
792  cout << "Local xyz " << mdEdx->xyz[0] << "\t" << mdEdx->xyz[1] << "\t" << mdEdx->xyz[2] << endl;
793  cout << "Local xyzD " << mdEdx->xyzD[0] << "\t" << mdEdx->xyzD[1] << "\t" << mdEdx->xyzD[2] << endl;
794  TString Line;
795  for (Int_t k = (Int_t)kUncorrected; k <= ((Int_t)kTpcLast); k++) {
796  Line = Form("%2i",k);
797  static Double_t log10keV = TMath::Log10(1e6);
798  if (k <= (Int_t) kTpcLast) {
799  Line += Form("\tdE %10.5g keV", 1e6*mdEdx->C[k].dE);
800  Line += Form("\tdx %10.5g cm",mdEdx->C[k].dx);
801  Line += Form("\tdE/dx %10.5g keV/cm", 1e6*mdEdx->C[k].dEdx);
802  Line += Form("\tlog(dE/dx) %10.5g",mdEdx->C[k].dEdxL + log10keV);
803  Line += Form("\tdlog(dE/dx) %10.5g",mdEdx->C[k].ddEdxL);
804  Line += "\t"; Line += TString(m_Corrections[k].Name); Line += "\t"; Line += TString(m_Corrections[k].Title);
805  } else {
806  Line += Form("\tdE %10.5g",mdEdx->F.dE);
807  Line += Form("\tdx %10.5g",mdEdx->F.dx);
808  Line += Form("\tdE/dx %10.5g",mdEdx->F.dEdx);
809  Line += Form("\tlog(dE/dx) %10.5g",mdEdx->F.dEdxL);
810  Line += "\tFinal \t ";
811  }
812  cout << Line.Data() << endl;
813  }
814 }
STAR includes.
Definition: Line.hh:23
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
Definition: StMaker.cxx:332
virtual Int_t GetRunNumber() const
Returns the current RunNumber.
Definition: StMaker.cxx:1054
Definition: TTable.h:48
virtual Char_t * Print(Char_t *buf, Int_t n) const
Create IDL table defintion (to be used for XDF I/O)
Definition: TTable.cxx:1548