StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
St_spline3C.cxx
1 #include "Riostream.h"
2 #include "St_spline3C.h"
3 #include "TString.h"
4 #include "TInterpreter.h"
5 #include "TSystem.h"
6 //________________________________________________________________________________
7 St_spline3 *St_spline3C::Open(const Char_t *path) {
8  St_spline3 *table = 0;
9  TString PATH(path);
10  TString Dir(gSystem->DirName(PATH));
11  TString File(gSystem->BaseName(PATH));
12  File += ".C";
13  TString pathF(".:./StarDb/"); pathF += Dir + ":$STAR/StarDb/" + Dir;
14  Char_t *file = gSystem->Which(pathF,File,kReadPermission);
15  if (! file) {
16  std::cout << Form("Fatal::St_spline3C::Open \tFile %s has not been found in path %s",File.Data(),pathF.Data()) << std::endl;
17  return table;
18  } else {
19  std::cout << Form("Warning::St_spline3C::Open \tFile %s has been found as %s",File.Data(),file) << std::endl;
20  }
21  TString command(".L "); command += file; TInterpreter::EErrorCode ee;
22  gInterpreter->ProcessLine(command,&ee);
23  if (ee) { //assert(!ee);
24  std::cout << Form("Fatal::St_spline3C::Open has failed to read \tFile %s",file) << std::endl;
25  delete [] file;
26  return table;
27  }
28  table = (St_spline3 *) gInterpreter->Calc("CreateTable()",&ee);
29  if (! table) {//assert(table);
30  std::cout << Form("Fatal::St_spline3C::Open has failed to load \tFile %s",file) << std::endl;
31  delete [] file;
32  return table;
33  }
34  table->Print(0,1);
35  command.ReplaceAll(".L ",".U ");
36  gInterpreter->ProcessLine(command,&ee);
37  if (ee) { // assert(!ee);
38  std::cout << Form("Fatal::St_spline3C::Open has failed to unload \tFile %s",file) << std::endl;
39  delete [] file;
40  SafeDelete(table);
41  return table;
42  }
43  return table;
44 }
45 //________________________________________________________________________________
46 St_spline3C::St_spline3C(St_spline3 *table) : TChair(table), fSpline(0), fFunc(0), fValid(kTRUE) {
47  if (table) {
48  fSpline = new TSpline3("Spline3", Xknots(), Yknots(), nknots(), option(), ValBeg(), ValEnd());
49  fSpline->SetLineColor(2);
50  fXmin = Xknots()[0] - 0.1;
51  fXmax = Xknots()[nknots()-1] + 0.1;
52  fFunc = new TF1(GetName(), this, fXmin, fXmax, 0, "St_spline3C");
53  fFunc->SetNpx(100);
54  fFunc->Save(Xknots()[0], Xknots()[nknots()-1], 0., 0., 0., 0.);
55  } else {
56  fValid = kFALSE;
57  }
58 }
59 #define MakeChairInstance3(CLASS,PATH) \
60  ClassImp(CLASS); \
61  CLASS *CLASS::fgInstance = 0; \
62  CLASS *CLASS::instance() { \
63  if (fgInstance && ! fgInstance->IsValid()) return 0; \
64  if (fgInstance) return fgInstance; \
65  St_spline3 *table = St_spline3C::Open(# PATH); \
66  fgInstance = new CLASS(table); \
67  return fgInstance; \
68  }
69 //________________________________________________________________________________
70 MakeChairInstance3(Stspline3LndNdxL10,dEdxModel/spline3LndNdxL10);
71 MakeChairInstance3(StElectonsDEV_dEdx,dEdxModel/ElectonsDEV_dEdx);
72 MakeChairInstance3(StPionDEV_dEdx,dEdxModel/PionDEV_dEdx);
73 MakeChairInstance3(StProtonDEV_dEdx,dEdxModel/ProtonDEV_dEdx);
Definition: TChair.h:27
C++ wrapper for &lt;spline3&gt; StAF table.
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