StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bichseldX.C
1 #include "Riostream.h"
2 class Bichsel;
3 Bichsel *m_Bichsel = 0;
4 const Int_t NMasses = 5;
5 const Double_t Masses[NMasses] = {0.93827231,
6  0.493677,
7  0.13956995,
8  0.51099907e-3,
9  1.87561339};
10 const Char_t *Names[NMasses] = {"p", "K","pi","e","d"};
11 const Int_t NF = 4;
12 const Char_t *FNames[5] = {"Girrf","Sirrf","Bz","B70","B60"};
13 const Int_t Nlog2dx = 3;
14 //const Double_t log2dx[5] = {0, 5.84962500721156187e-01, 1, 1.58496250072115630e+0, 2};
15 const Double_t log2dx[3] = {0, 1, 2};
16 //________________________________________________________________________________
17 Double_t gfunc(Double_t *x,Double_t *par) {
18  Double_t pove = x[0];
19  Double_t poverm = pove/par[0];
20  Int_t type = par[1];
21  Int_t k = 0;
22  if (type == 3) k = 1;
23  Int_t type = par[1];
24  Int_t k = 0;
25  if (type == 3) k = 1;
26  // Double_t Scale = BetheBloch::Sirrf(4.,par[2],k)/
27  // BetheBloch::Girrf(4.,par[4],k);
28  return BetheBloch::Girrf(poverm,par[4],k);
29 }
30 //________________________________________________________________________________
31 Double_t sifunc(Double_t *x,Double_t *par) {
32  Double_t pove = x[0];
33  Double_t poverm = pove/par[0];
34  Int_t type = par[1];
35  Int_t k = 0;
36  if (type == 3) k = 1;
37  return BetheBloch::Sirrf(poverm,par[2],k);
38 }
39 // Double_t bbfunc(Double_t *x,Double_t *par) {
40 // Double_t pove = x[0];
41 // Double_t poverm = pove/par[0];
42 // BetheBloch BB;
43 // Double_t value = 1.e6*BB(poverm);
44 // // printf("x : %f p: %f val : %f \n",x[0],poverm,value);
45 // return value;
46 // }
47 Double_t bichselZ(Double_t *x,Double_t *par) {
48  Double_t pove = x[0];
49  Double_t poverm = pove/par[0];
50  Int_t type = par[1];
51  Int_t k = 0;
52  if (type == 3) k = 1;
53  // Double_t Scale = BetheBloch::Sirrf(4.,par[2],k)/
54  // TMath::Exp(m_Bichsel->GetMostProbableZ(TMath::Log10(4),par[3]));
55  return TMath::Exp(m_Bichsel->GetMostProbableZ(TMath::Log10(poverm),par[3]));
56 }
57 Double_t bichsel70(Double_t *x,Double_t *par) {
58  Double_t pove = x[0];
59  Double_t poverm = pove/par[0];
60  Int_t type = par[1];
61  Int_t k = 0;
62  if (type == 3) k = 1;
63  // Double_t Scale = BetheBloch::Sirrf(4.,par[2],k)/
64  // TMath::Exp(m_Bichsel->GetI70(TMath::Log10(4),par[3]));
65  return m_Bichsel->GetI70(TMath::Log10(poverm),par[3]);
66 }
67 Double_t bichsel60(Double_t *x,Double_t *par) {
68  Double_t pove = x[0];
69  Double_t poverm = pove/par[0];
70  Int_t type = par[1];
71  Int_t k = 0;
72  if (type == 3) k = 1;
73  // Double_t Scale = BetheBloch::Sirrf(4.,par[2],k)/
74  // TMath::Exp(m_Bichsel->GetI60(TMath::Log10(4),par[3]));
75  return m_Bichsel->GetI60(TMath::Log10(poverm),par[3]);
76 }
77 void bichseldX() {
78  if (gClassTable->GetID("StBichsel") < 0) {
79  gSystem->Load("libTable");
80  gSystem->Load("St_base");
81  gSystem->Load("StarClassLibrary");
82  gSystem->Load("StBichsel");
83  }
84  if (!m_Bichsel) m_Bichsel = Bichsel::Instance();
85  TCanvas *c1 = new TCanvas("c1");
86  c1->SetLogx();
87  c1->SetLogy();
88  c1->SetGrid();
89  // TH1F *hr = c1->DrawFrame(2.e-2,1,1.e3,1.e2);
90  // TH1F *hr = c1->DrawFrame(1.e-2,1,1.e3,1.e2);
91  TH1F *hr = c1->DrawFrame(1.e-1,1,1.e2,2.e2);
92  // hr->SetXTitle("Momentum (GeV/c)");
93  hr->SetTitle("dE/dx predictions");
94  hr->SetXTitle("#beta #gamma");
95  hr->SetYTitle("dE/dx (keV/cm)");
96  hr->Draw();
97  // Mass Type Length log2(dx)
98  Double_t params[5] = { 1.0, 0., 60., 1., 1e-3};
99  TLegend *leg = new TLegend(0.4,0.7,0.9,0.9,"");//TLegend(0.79,0.91,0.89,0.89,"");
100  // for (Int_t h = 0; h < 4; h++) { // Masses
101  for (Int_t h = 2; h < 3; h++) { // Masses
102  params[0] = 1.; // Masses[h];
103  params[1] = h;
104  // for (Int_t f = 0; f < NF; f++) { // Functions
105  Int_t f = 3;
106  for (Int_t dx = 0; dx < Nlog2dx; dx++) {
107  params[3] = log2dx[dx];
108  Char_t *FunName = Form("%s%s%i",FNames[f],Names[h],(int)log2dx[dx]);
109  // cout << "Make " << FunName << endl;
110  TF1 *func = 0;
111  if (TString(FNames[f]) == "Sirrf") {
112  func = new TF1(FunName,sifunc,1.e-2,1.e3,5);
113  func->SetLineColor(2);
114  }
115  if (TString(FNames[f]) == "Girrf") {
116  func = new TF1(FunName,gfunc,1.e-2,1.e3,5);
117  params[4] = 1.e-3;
118  if (dx == 1) params[4] = 1.e-2;
119  if (dx == 2) params[4] = 1.e-3;
120  if (dx == 3) params[4] = 1.e-4;
121  func->SetLineColor(3);
122  }
123  else {if (TString(FNames[f]) == "Bz") {
124  func = new TF1(FunName,bichselZ,1.e-2,1.e3,5);
125  func->SetLineColor(4);
126  }
127  else {if (TString(FNames[f]) == "B70") {
128  func = new TF1(FunName,bichsel70,1.e-2,1.e3,5);
129  func->SetLineColor(6);
130  }
131  else {if (TString(FNames[f]) == "B60") {
132  func = new TF1(FunName,bichsel60,1.e-2,1.e3,5);
133  func->SetLineColor(7);
134  }}}}
135  if (! func) continue;
136  func->SetParameters(params);
137  func->SetLineColor(dx+1);
138  func->Draw("same");
139  if ( h == 2) {
140  TString name(FNames[f]);
141  name += ": Bichsel, 30% truncation";
142  name += Form(" dx = %3.1f cm",TMath::Power(2.,log2dx[dx]));
143  cout << name << endl;
144  leg->AddEntry(func,name.Data(),"L");
145  }
146  }
147  }
148  leg->Draw();
149 }