StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vertex.C
1 // $Id: vertex.C,v 1.3 2007/01/19 08:23:07 jcs Exp $
2 //
3 // $Log: vertex.C,v $
4 // Revision 1.3 2007/01/19 08:23:07 jcs
5 // replace true, false with kTRUE, kFALSE
6 //
7 // Revision 1.2 2006/03/15 15:14:06 jcs
8 // add lines for listing CVS update info
9 //
10 
11 // vertex-extrapolation (d.h. plot - program for new Tree-Structure !!!)
12 
13 struct HIT
14 {
15  Float_t x,y,z;
16  Float_t rad,phi;
17  Float_t raderror,phierror;
18 };
19 
20 struct CLUSTER
21 {
22  Float_t timepos,padpos,timesigma,padsigma;
23  Float_t peakheight, charge;
24  Int_t timebin,pad;
25  Int_t padlength,timelength;
26  Int_t row,sec;
27  Int_t flag;
28  Int_t numpeaks;
29 };
30 
31 struct EVENT
32 {
33  Float_t run;
34  Int_t nevent;
35 };
36 
37 struct TEVENT
38 {
39  Float_t run;
40  Int_t nevent;
41 };
42 
43 
44 struct TCLUSTER
45 {
46  Int_t row,sec, padlength, timelength;
47  Float_t peakheight, charge;
48  Int_t ntracks;
49  Float_t padpos, timepos;
50  Float_t padpossigma, timepossigma;
51 };
52 
53 struct THIT
54 {
55  Float_t x,y,z;
56  Float_t ex,ey,ez;
57  Float_t globResX,globResY,globResPhi,globResR;
58  Float_t primResX,primResY,primResPhi,primResR;
59 };
60 
61 struct TREVENT
62 {
63  Float_t run;
64  Int_t nevent;
65 };
66 
67 struct TRACK
68 {
69  Float_t px,py,pz;
70  Float_t eta,p,pt;
71  Int_t npoints;
72  Int_t charge;
73  Int_t type;
74  Int_t sec;
75 };
76 
77 struct MVERTEX
78 {
79  Float_t x,y,z;
80 };
81 
82 CLUSTER cluster;
83 HIT hit;
84 TCLUSTER tcluster;
85 THIT thit;
86 TRACK track;
87 EVENT event;
88 TEVENT tevent;
89 TREVENT trevent;
90 MVERTEX mvertex;
91 
92 
93 void vertex(TString eingabe,int evt)
94 {
95 
96  TBranch *bhit, *bevent, *bcluster;
97  TBranch *bthit, *btcluster, *btevent;
98  TBranch *btrevent, *btrack,*btrvertex;
99  TDirectory *histdir, *vertexdir;
100 
101  TTree *dtree;
102  TTree *dttree;
103  TTree *dtrtree;
104 
105  TStyle *plain = new TStyle("Plain","Plain Style (no colors/fill areas)");
106  plain->SetTitleOffset(1.25);
107  plain->SetCanvasBorderMode(0);
108  plain->SetPadBorderMode(0);
109  plain->SetPadColor(10);
110  plain->SetCanvasColor(10);
111  plain->SetTitleColor(0);
112  plain->SetStatColor(0);
113  plain->SetPalette(1);
114  plain->SetOptStat(11);
115  plain->SetOptFit();
116 
117  TString histoname;
118 
119  cout<<"Vertex Analysis started..."<<endl;
120  cout<<endl;
121 
122  TFile *f=new TFile(eingabe+".root");
123 
124  eingabe +="-vertex";
125  TPostScript *fps=new TPostScript(eingabe+".ps",112);
126 
127  // get trees in file !!!
128 
129  /*
130  dtree=(TTree*) f->Get("cl");
131  bhit=dtree->GetBranch("hit");
132  bhit->SetAddress(&hit);
133  bcluster=dtree->GetBranch("cluster");
134  bcluster->SetAddress(&cluster);
135  bevent=dtree->GetBranch("event");
136  bevent->SetAddress(&event);
137  */
138 
139  dtrtree=(TTree*) f->Get("tr");
140  btrevent=dtrtree->GetBranch("event");
141  btrevent->SetAddress(&trevent);
142  btrack=dtrtree->GetBranch("track");
143  btrack->SetAddress(&track);
144  btrvertex=dtrtree->GetBranch("vertex");
145  btrvertex->SetAddress(&mvertex);
146 
147  dttree=(TTree*) f->Get("clot");
148  btcluster=dttree->GetBranch("cluster");
149  btcluster->SetAddress(&tcluster);
150  bthit=dttree->GetBranch("hit");
151  bthit->SetAddress(&thit);
152  btevent=dttree->GetBranch("event");
153  btevent->SetAddress(&tevent);
154 
155  TCanvas *c1 = new TCanvas("vertex","vertex",100,10,800,600);
156  TH2F *hr = new TH2F("hr","",100,-275,275,100,0,30);
157  hr->SetTitle("Vertex Extrapolation (linear)");
158  hr->GetYaxis()->SetTitleOffset(1.1);
159  hr->GetYaxis()->SetTitle("rad");
160  hr->GetXaxis()->SetTitle("z");
161  hr->DrawCopy();
162 
163  TH1F *hvertex=new TH1F("hvertex","z-position of used vertex",201,-100,100);
164  TH1F *vertexeast=new TH1F("vertexeast","z-position of extrapolated vertex east",101,-50,50);
165  TH1F *vertexwest=new TH1F("vertexwest","z-position of extrapolated vertex west",101,-50,50);
166  TH1F *vertexall=new TH1F("vertexall","z-position of extrapolated vertex",101,-50,50);
167 
168  Int_t maxentries1 = (Int_t)btcluster->GetEntries();
169  cout<<"Process Cluster-on-Track-Tree with "<<maxentries1<<" clusters..."<<endl;
170 
171  cout<<endl;
172  cout<<"Investigate Event "<<evt<<"..."<<endl;
173  Float_t mean_vertex=0;
174  Float_t mean_vertex_west=0;
175  Float_t mean_vertex_east=0;
176 
177  Float_t radius[11],z[11];
178 
179  Bool_t EndOfEvent=kFALSE;
180  Int_t i=0;
181  Int_t ntracksold=0;
182  Int_t ntrack=0;
183  Int_t ntrackeast=0;
184  Int_t ntrackwest=0;
185 
186  TF1 *linfit=new TF1("linfit","[0]*x+[1]",-275,275);
187  linfit->SetParameters(1,10);
188  linfit->SetLineWidth(0.5);
189 
190  for (int k=0;k<=maxentries1;k++)
191  {
192  btcluster->GetEntry(k);
193  bthit->GetEntry(k);
194  btevent->GetEntry(k);
195 
196  if (EndOfEvent) break;
197  if (tevent.nevent > evt)
198  {
199  if (i==0) break;
200  tevent.nevent=evt;
201  EndOfEvent=kTRUE;
202  }
203  if (tevent.nevent==evt)
204  {
205  if (tcluster.ntracks != ntracksold)
206  {
207 
208  TGraph *ver=new TGraph(i,z,radius);
209  ver->SetMarkerStyle(22);
210  ver->SetMarkerSize(0.75);
211  ver->Draw("P");
212 
213  if (z[0]<0)
214  {
215  ntrackeast++;
216  ver->SetMarkerColor(2);
217  linfit->SetLineColor(2);
218  }
219  else
220  {
221  ntrackwest++;
222  ver->SetMarkerColor(3);
223  linfit->SetLineColor(3);
224  }
225 
226  ver->Fit(linfit,"QR+");
227 
228  cout<<"Event "<<tevent.nevent<<" Track "<<ntrack<<" Vertex = "<<-linfit->GetParameter(1)/linfit->GetParameter(0)<<endl;
229  ntrack++;
230  mean_vertex=(mean_vertex+(-linfit->GetParameter(1)/linfit->GetParameter(0)));
231  vertexall->Fill(-linfit->GetParameter(1)/linfit->GetParameter(0));
232  if (z[0]<0)
233  {
234  mean_vertex_east=mean_vertex_east+-linfit->GetParameter(1)/linfit->GetParameter(0);
235  vertexeast->Fill(-linfit->GetParameter(1)/linfit->GetParameter(0));
236  }
237  else
238  {
239  mean_vertex_west=mean_vertex_west+-linfit->GetParameter(1)/linfit->GetParameter(0);
240  vertexwest->Fill(-linfit->GetParameter(1)/linfit->GetParameter(0));
241  }
242  i=0;
243 
244  }
245  radius[i]=sqrt(thit.x*thit.x+thit.y*thit.y);
246  z[i]=thit.z;
247  cout<<"DEBUG: ntrack = "<<tcluster.ntracks<<" cluster "<<i<<" x,y,z = "<<thit.x<<" "<<thit.y<<" "<<thit.z<<" radius = "<<radius[i]<<endl;
248  i++;
249 
250  ntracksold=tcluster.ntracks;
251  }
252  }
253  cout<<"---------------------------"<<endl;
254  cout<<"Mean_vertex = "<<mean_vertex/ntrack<<endl;
255  cout<<"Mean_vertex_east = "<<mean_vertex_east/ntrackeast<<endl;
256  cout<<"Mean_vertex_west = "<<mean_vertex_west/ntrackwest<<endl;
257  cout<<"---------------------------"<<endl;
258 
259  TCanvas *c2 = new TCanvas("vertex2","vertex2",150,60,850,650);
260 
261  vertexall->DrawCopy();
262  vertexwest->SetLineColor(3);vertexwest->DrawCopy("same");
263  vertexeast->SetLineColor(2);vertexeast->DrawCopy("same");
264  TLegend *leg = new TLegend(0.7,0.6,0.95,0.8);
265  leg->SetFillColor(10);
266  leg->SetTextSize(0.03);
267  leg->AddEntry(vertexall,"vertex East&West","L");
268  leg->AddEntry(vertexeast,"vertex East","L");
269  leg->AddEntry(vertexwest,"vertex West","L");
270  leg->Draw();
271  //cout<<vertexwest->GetEntries()+ vertexeast->GetEntries()<<endl;
272  Int_t maxentries2 = (Int_t)btrack->GetEntries();
273  cout<<endl;
274  cout<<"Process Track-Tree with "<<maxentries2<<" Tracks..."<<endl;
275 
276  Int_t oldevent=0;
277  for (int k=0;k<=maxentries2;k++)
278  //for (int k=0;k<=1;k++)
279  {
280  btrack->GetEntry(k);
281  btrvertex->GetEntry(k);
282  btrevent->GetEntry(k);
283  if (trevent.nevent!=oldevent)
284  {
285  hvertex->Fill(mvertex.z);
286  if (trevent.nevent==evt)
287  {
288  cout<<"---------------------------"<<endl;
289  cout<<"Used Vertex (Event "<<evt<<") x = "<<mvertex.x<<" y = "<<mvertex.y<<" z = "<<mvertex.z<<endl;
290  cout<<"---------------------------"<<endl;
291  }
292  }
293  oldevent=trevent.nevent;
294  }
295 
296  cout<<endl;
297  //cout<<"Analyse beendet !"<<endl;
298  cout<<"Histograms in ROOT-file : "<<eingabe+".root"<<endl;
299 
300  //ana->Write();
301  //ana->Close();
302  //f->Close();
303 
304  //return 0;
305  //c1->Delete();
306 }
307