FairRoot/PandaRoot
trapmap_disc.C
Go to the documentation of this file.
1 // ***************************************************************
2 //
3 // Create a new map for the trapping fraction of the DISC DIRC
4 //
5 // Results will be stored in trapfrac_disc.root which has to be
6 // copied to pandaroot/fsim and is then read in by PndFsmDrcDisc
7 //
8 // execute in CINT like:
9 //
10 // .x trapmap_disc.C+(#bins, #photons, pmax, H)
11 //
12 // #bins = number of bins in p and theta
13 // #photons = number of generated photons to determine fraction
14 // (1000 -> accuracy = 0.001)
15 // pmax = upper momentum limit
16 // H = magnetic field strength used
17 //
18 // default theta range: 0 < theta < 25
19 //
20 // ***************************************************************
21 
22 
23 #include <iostream>
24 #include "TH1F.h"
25 #include "TH2F.h"
26 #include "TCanvas.h"
27 #include "TVector3.h"
28 #include "TBox.h"
29 #include "TFile.h"
30 #include <math.h>
31 
32 using std::cout;
33 using std::endl;
34 
35 void config_histo(TH1 *h, TString tx, TString ty,double offy=1.65)
36 {
37  h->SetLineWidth(1);
38  h->SetLineColor(1);
39  h->SetFillColor(3);
40  //h->Sumw2();
41 
42  h->GetXaxis()->SetTitleOffset(1.3);
43  h->GetXaxis()->SetTitleColor(1);
44  h->GetXaxis()->SetTitleFont(42);
45  h->GetXaxis()->SetLabelSize(0.045);
46  h->GetXaxis()->SetTitleSize(0.045);
47  //h->GetXaxis()->SetNdivisions(510);
48 
49  h->GetYaxis()->SetTitleOffset(offy);
50  h->GetYaxis()->SetTitleFont(42);
51  h->GetYaxis()->SetLabelSize(0.045);
52  h->GetYaxis()->SetTitleSize(0.045);
53 
54  h->SetXTitle(tx);
55  h->SetYTitle(ty);
56 
57 }
58 
59 int trapmap_disc(double steps=100, double phst=500, double pmax=6.0, double H=2)
60 {
61  double mass[5]={0.000511,0.10566,0.13957,0.493677,0.938272};
62 
63  TString title[5];
64  title[0]="Electrons";
65  title[1]="Muons";
66  title[2]="Pions";
67  title[3]="Kaons";
68  title[4]="Protons";
69 
70  TCanvas *c1=new TCanvas("c1","c1",800,600);
71  c1->Divide(3,2);
72 
73  int i;
74 
75  double Pi=3.141592653589793;
76 
77  double n=1.472;
78 
79  double thtmin=0,thtmax=25;
80  double pmin=0;
81  double thtsteps=steps;
82  double phisteps=phst;
83  double psteps=steps;
84 
85  double pbin=(pmax-pmin)/psteps;
86  double thtbin=(thtmax-thtmin)/thtsteps;
87 
88  TH1F *hftht2=new TH1F("hftht2","part total refl no curvature",(int)thtsteps+1,thtmin-0.5*thtbin,thtmax+0.5*thtbin);
89  hftht2->SetLineColor(2);
90 
91  TH2F *hacc[5];
92  for (i=0;i<5;i++)
93  {
94  char tmp[20];
95  sprintf(tmp,"hacc%d",i);
96  hacc[i]=new TH2F(tmp,title[i],(int)psteps+1,pmin-0.5*pbin,pmax+0.5*pbin,(int)thtsteps+1,thtmin-0.5*thtbin,thtmax+0.5*thtbin);
97  hacc[i]->SetMaximum(1);
98  config_histo(hacc[i],"p[GeV/c^{2}]","#theta [deg]");
99  }
100 
101 
102  double tht_tref=asin(1./n);
103  cout <<tht_tref/3.1416*180<<endl;
104 
105  double phi=0;
106 
107 
108  int pid=0;
109  int ip=0;
110 
111  for (pid=0;pid<5;pid++){
112  cout <<"pid="<<pid<<endl;
113  for (ip=0;ip<=psteps;ip++)
114  {
115  double p=pmin+ip*pbin;
116  double thetac=0;
117  double cthetac=sqrt(mass[pid]*mass[pid]+p*p)/(p*n);
118 
119 
120  if (cthetac<=1) thetac=acos(cthetac);
121 
122  double tht;//=theta/180.*3.1416;
123  double thc=thetac;// /180.*3.1416;
124 
125  if (thc>0)
126  for (double itht=thtmin;itht<=thtmax;itht+=thtbin)
127  {
128  tht=itht/180.*Pi;
129 
130 
131  double phistsize=Pi*2/phisteps;
132 
133  double count=0;
134 
135 
136  for( phi=0;phi<2*Pi;phi+=phistsize)
137  {
138  TVector3 v1(1,sin(phi)*tan(thc),cos(phi)*tan(thc));
139 
140  v1.RotateY(tht);
141 
142  TVector3 v2(1,0,0);
143 
144  double ang=v1.Angle(v2);
145 
146  if (ang>Pi/2) ang=fabs(ang-Pi);
147 
148  if (ang>=tht_tref) ++count;
149  }
150  hacc[pid]->Fill(p,itht,count/phisteps);
151  }
152  }
153  }
154 
155  TString opt("surf1");
156 
157  for (pid=0;pid<5;pid++)
158  {
159  c1->cd(pid+1);
160  hacc[pid]->Draw(opt);
161  }
162  c1->cd();
163 
164  TFile *f=new TFile("trapfrac_disc.root","recreate");
165  for (pid=0;pid<5;pid++)
166  hacc[pid]->Write();
167  f->Close();
168  return 0;
169 }
friend F32vec4 acos(const F32vec4 &a)
Definition: P4_F32vec4.h:113
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:112
Int_t i
Definition: run_full.C:25
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
void config_histo(TH1 *h, TString tx, TString ty, double offy=1.65)
Definition: trapmap_disc.C:35
friend F32vec4 sin(const F32vec4 &a)
Definition: P4_F32vec4.h:111
int trapmap_disc(double steps=100, double phst=500, double pmax=6.0, double H=2)
Definition: trapmap_disc.C:59
int n
int pid()
Double_t p
Definition: anasim.C:58
vTop Write()
TString tht(TString pts, TString exts="px py pz")
Definition: invexp.C:168
TFile * f
Definition: bump_analys.C:12
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
c1
Definition: plot_dirc.C:35
TVector3 v1
Definition: bump_analys.C:40
TVector3 v2
Definition: bump_analys.C:40
int count
Double_t Pi