]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/programs/tpcbeamtestdisplay.cxx
Splitting raw data libs
[u/mrichter/AliRoot.git] / HLT / programs / tpcbeamtestdisplay.cxx
CommitLineData
de3c3890 1// $Id$
2
3#include "AliL3StandardIncludes.h"
4#include "AliL3RootTypes.h"
5#include "AliLevel3.h"
6#include "AliL3Transform.h"
7#include "AliL3RawDataFileHandler.h"
8#include "AliL3SpacePointData.h"
9#include "AliL3ClustFinderNew.h"
10#include "AliL3ConfMapper.h"
11#include "AliL3Vertex.h"
12#include "AliL3MemHandler.h"
13#include "AliL3Logging.h"
14#include "AliL3TrackArray.h"
15#include "AliL3Track.h"
16#include <TCanvas.h>
17#include <TH2.h>
18#include <TView.h>
19#include <TApplication.h>
20#include <TColor.h>
21#include <TPaletteAxis.h>
22#include <TStyle.h>
23#include <TFormula.h>
24#include <TF1.h>
25#include <TLine.h>
26#include <TAttLine.h>
27#if __GNUC__== 3
28using namespace std;
29#else
30#include <stream.h>
31#include <string.h>
32#include <stdlib.h>
33#endif
34
35//This program does the clusterfinding and the tracking.
36int main(Int_t argc,Char_t **argv){
37
38 //Display all clusters.
39
40 Char_t cfile[1024];
41 Char_t path[1024];
42 Char_t fname[1024];
43
44 if(argc<3){
45 cout<<"Usage: tpcbeamtestdisplay filename path_to_files"<<endl;
46 return -1;
47 }
48 if (argc>2) {
49 sprintf(cfile,"%s",argv[1]);
50 sprintf(path,"%s",argv[2]);
51 }
52
53 //displaying the tracks:
54 UInt_t fNcl;
55 AliL3MemHandler *clusterfile = new AliL3MemHandler();
56 sprintf(fname,"%s/%s-points_0_-1.raw",path,cfile);
57 cout<<"file: "<<fname<<endl;
58 if(!clusterfile->SetBinaryInput(fname)){
59 cout<<"file: "<<fname<<" can not be set as binary input!"<<endl;
60 LOG(AliL3Log::kError,"AliL3Evaluation::Setup","File Open")
61 <<"Inputfile "<<fname<<" does not exist"<<ENDLOG;
62 delete clusterfile;
63 clusterfile = 0;
64 }
65 clusterfile->SetBinaryInput(fname);
66 AliL3SpacePointData *fClusters = new AliL3SpacePointData();
67 memset(fClusters,0,sizeof(AliL3SpacePointData*));
68 fClusters = (AliL3SpacePointData*)clusterfile->Allocate();
69 clusterfile->Binary2Memory(fNcl,fClusters);
70 clusterfile->CloseBinaryInput();
71 TApplication theApp("App", &argc, argv);
72 TCanvas *c1 = new TCanvas("c1","",900,700);
73 c1->cd();
74
75 c1->Clear();
76 c1->SetFillColor(1);
77
78 AliL3SpacePointData *points = fClusters;
79 TH2F *clusters = new TH2F("clusters","",65,-1,64,77,17,94);
80 if(!points)
81 cout<<"no points"<<endl;
82 Int_t npoints = fNcl;
83 // cout<<"number of points: "<<npoints<<endl;
84 for(Int_t i=0; i<npoints; i++){
85 float x_tmp = points[i].fX;
86 float y_tmp = points[i].fY;
87 // cout<<"x: "<<x_tmp<<" y: "<<y_tmp<<endl;
88 clusters->Fill(x_tmp,y_tmp,1);
89 }
90 TH2F *nothing = new TH2F(cfile,"",65,-1,64,77,17,94);
91// nothing->SetName("Test");
92 //Adding a regression method to calculate the line parameters.
93 float *x=new float[npoints];
94 float *y=new float[npoints];
95 float xyParamA=0;
96 float xyParamB=0;
97
98 Int_t numofXYPoints=npoints;
99
100 float sumX=0;
101 float sumY=0;
102
103 float sumXtimesY=0;
104 float sumXsquare=0;
105 float sumYsquare=0;
106
107
108 for(Int_t i=0; i<npoints; i++){
109 x[i] = points[i].fX;
110 y[i] = points[i].fY;
111 sumX+=x[i];
112 sumY+=y[i];
113 sumXtimesY+=x[i]*y[i];
114 sumXsquare+=x[i]*x[i];
115 sumYsquare+=y[i]*y[i];
116 }
117
118
119
120 if(numofXYPoints*sumXsquare-sumX*sumX!=0)
121 xyParamB=(numofXYPoints*sumXtimesY-sumX*sumY)/(numofXYPoints*sumXsquare-sumX*sumX);
122 else
123 cout<<"Divident is zero calculating the xParamB, numofXYPoints*sumXsquare-sumX*sumX=0"<<endl;
124 if(numofXYPoints!=0)
125 xyParamA=(sumY-xyParamB*sumX)/numofXYPoints;
126 else
127 cout<<"Divident is zero calculating the xParamA, numofXYPoints=0"<<endl;
128
129 //cout<<"y= a + bx : "<<"y= "<<xyParamA<<" + "<<xyParamB<<" x"<<endl;
130
131 TF1 *line = new TF1("line","[0]+[1]*x",0,63);
132 line->SetParameters(xyParamA,xyParamB);
133 TLine *leftline= new TLine(0,(0-AliL3Transform::GetNPads(0)/2+55),0,AliL3Transform::GetNPads(0)-(AliL3Transform::GetNPads(0)/2)+55);
134 TLine *rightline=new TLine(63,(0-AliL3Transform::GetNPads(63)/2+55),63,AliL3Transform::GetNPads(63)-(AliL3Transform::GetNPads(63)/2)+55);
135 TLine *upperline=new TLine(0,(AliL3Transform::GetNPads(0)-AliL3Transform::GetNPads(0)/2+55),63,AliL3Transform::GetNPads(63)-(AliL3Transform::GetNPads(63)/2)+55);
136 TLine *underline=new TLine(0,(0-AliL3Transform::GetNPads(0)/2+55),63,0-(AliL3Transform::GetNPads(63)/2)+55);
137
138 nothing->Draw("colz");
139 nothing->SetXTitle("Padrows");
140 nothing->SetYTitle("Pads");
141 clusters->SetMarkerStyle(22);
142 clusters->Draw("same");
143
144 line->Draw("same");
145 line->SetLineColor(2);
146 leftline->Draw("same");
147 leftline->SetLineWidth(2);
148 rightline->Draw("same");
149 rightline->SetLineWidth(2);
150 upperline->Draw("same");
151 upperline->SetLineWidth(2);
152 underline->Draw("same");
153 underline->SetLineWidth(2);
154
155
156 c1->SetFillColor(10);
157 c1->Update();
158 c1->Draw();
159 while(1){
160
161 }
162}