4de874d1 |
1 | #include <TClonesArray.h> |
2 | #include <TH2.h> |
3 | #include <TH1.h> |
4 | #include <TFile.h> |
5 | #include <AliRun.h> |
6 | #include <TParticle.h> |
7 | |
8 | #include "AliL3TrackArray.h" |
9 | #include "AliL3Transform.h" |
10 | #include "AliL3HoughTransformer.h" |
11 | #include "AliL3Defs.h" |
12 | #include "AliL3HoughTrack.h" |
13 | #include "AliL3HoughEval.h" |
14 | |
15 | ClassImp(AliL3HoughEval) |
16 | |
17 | |
18 | AliL3HoughEval::AliL3HoughEval() |
19 | { |
20 | //Default constructor |
21 | fTransform = new AliL3Transform(); |
22 | fHoughTransformer = NULL; |
23 | } |
24 | |
25 | |
26 | AliL3HoughEval::AliL3HoughEval(AliL3HoughTransformer *transformer) |
27 | { |
28 | //Constructor |
29 | fHoughTransformer = transformer; |
30 | fTransform = new AliL3Transform(); |
31 | } |
32 | |
33 | |
34 | AliL3HoughEval::~AliL3HoughEval() |
35 | { |
36 | //Destructor |
37 | if(fTransform) |
38 | delete fTransform; |
39 | |
40 | } |
41 | |
42 | |
43 | void AliL3HoughEval::LookInsideRoad(AliL3TrackArray *tracks,TH2F *hist,TH2F *fake) |
44 | { |
45 | //Look at rawdata along the road specified by the track candidates. |
46 | |
47 | if(!fHoughTransformer) |
48 | { |
49 | printf("AliL3HoughEval: No transformer object\n"); |
50 | return; |
51 | } |
52 | |
53 | AliL3Digits *pixel; |
54 | Int_t patch = fHoughTransformer->fPatch; |
55 | Int_t slice = fHoughTransformer->fSlice; |
56 | Int_t num_of_pads_to_look = 1; |
57 | Int_t rows_to_miss = 2; |
58 | |
59 | for(Int_t i=0; i<tracks->GetNTracks(); i++) |
60 | { |
61 | AliL3HoughTrack *track = (AliL3HoughTrack*)tracks->GetCheckedTrack(i); |
62 | if(!track) {printf("No track\n"); return;} |
63 | |
64 | Int_t nrow = 0; |
65 | |
66 | for(Int_t padrow = NRows[patch][0]; padrow <= NRows[patch][1]; padrow++) |
67 | { |
68 | |
69 | Float_t xyz[3]; |
70 | //Get the crossing point of the track and current padrow: |
71 | //if(!track->GetCrossingPoint(slice,padrow,xyz)) |
72 | if(!track->GetCrossingPoint(padrow,xyz)) |
73 | { |
74 | printf("AliL3HoughEval::LookInsideRoad : Track does not cross line!!\n"); |
75 | continue; |
76 | } |
77 | |
78 | if(fake) |
79 | fake->Fill(xyz[0],xyz[1],1); |
80 | Int_t npixs = 0; |
81 | |
82 | //Get the pixels along the track candidate |
83 | for(pixel=(AliL3Digits*)fHoughTransformer->fRowContainer[padrow].first; pixel!=0; pixel=(AliL3Digits*)pixel->nextRowPixel) |
84 | { |
85 | |
86 | Int_t sector,row; |
87 | Float_t xyz_pix[3]; |
88 | fTransform->Slice2Sector(slice,padrow,sector,row); |
89 | fTransform->Raw2Local(xyz_pix,sector,row,pixel->fPad,pixel->fTime); //y alone pad |
90 | |
91 | |
92 | //check if we are inside road |
93 | if(fabs(xyz_pix[1] - xyz[1]) > num_of_pads_to_look*fTransform->GetPadPitchWidthLow()) continue; |
94 | npixs++; |
95 | |
96 | if(hist) |
97 | { |
98 | //fTransform->Local2Global(xyz_pix,slice); |
99 | hist->Fill(xyz_pix[0],xyz_pix[1],pixel->fCharge); |
100 | } |
101 | |
102 | } |
103 | if(npixs > 0) |
104 | { |
105 | nrow++; |
106 | } |
107 | } |
108 | |
109 | if(nrow < NRows[patch][1]-NRows[patch][0]-rows_to_miss) |
110 | tracks->Remove(i); |
111 | |
112 | } |
113 | |
114 | tracks->Compress(); |
115 | |
116 | |
117 | } |
118 | |
119 | void AliL3HoughEval::DisplaySlice(TH2F *hist) |
120 | { |
121 | |
122 | AliL3Digits *pixel; |
123 | |
124 | for(Int_t padrow = 0; padrow < 174; padrow++) |
125 | { |
126 | |
127 | for(pixel=(AliL3Digits*)fHoughTransformer->fRowContainer[padrow].first; pixel!=0; pixel=(AliL3Digits*)pixel->nextRowPixel) |
128 | { |
129 | |
130 | Int_t sector,row; |
131 | Float_t xyz_pix[3]; |
132 | fTransform->Slice2Sector(fHoughTransformer->fSlice,padrow,sector,row); |
133 | fTransform->Raw2Local(xyz_pix,sector,row,pixel->fPad,pixel->fTime); //y alone pad |
134 | |
135 | if(hist) |
136 | { |
137 | hist->Fill(xyz_pix[0],xyz_pix[1],pixel->fCharge); |
138 | } |
139 | |
140 | } |
141 | } |
142 | |
143 | } |
144 | |
145 | |
146 | void AliL3HoughEval::CompareMC(Char_t *rootfile,AliL3TrackArray *merged_tracks,Float_t *eta) |
147 | { |
148 | |
149 | Int_t slice = fSlice; |
150 | |
151 | TFile *file = new TFile(rootfile); |
152 | file->cd(); |
153 | |
154 | AliRun *gAlice = (AliRun*)file->Get("gAlice"); |
155 | gAlice->GetEvent(0); |
156 | |
157 | TClonesArray *particles=gAlice->Particles(); |
158 | Int_t n=particles->GetEntriesFast(); |
159 | Float_t torad=TMath::Pi()/180; |
160 | Float_t phi_min = slice*20 - 10; |
161 | Float_t phi_max = slice*20 + 10; |
162 | |
163 | for (Int_t j=0; j<n; j++) { |
164 | TParticle *p=(TParticle*)particles->UncheckedAt(j); |
165 | if (p->GetFirstMother()>=0) continue; //secondary particle |
166 | if(p->Eta() < eta[0] || p->Eta() > eta[1]) continue; |
167 | Double_t ptg=p->Pt(),pxg=p->Px(),pyg=p->Py();//,pzg=p->Pz(); |
168 | Double_t phi_part = TMath::ATan2(pyg,pxg); |
169 | if (phi_part < 0) phi_part += 2*TMath::Pi(); |
170 | |
171 | if(phi_part < phi_min*torad || phi_part > phi_max*torad) {continue;} |
172 | if(ptg<0.100) continue; |
173 | |
174 | AliL3HoughTrack *sel_track=0; |
175 | |
176 | Double_t min_dist = 10000; |
177 | |
178 | for(Int_t t=0; t<merged_tracks->GetNTracks(); t++) |
179 | { |
180 | AliL3HoughTrack *track = (AliL3HoughTrack*)merged_tracks->GetCheckedTrack(t); |
181 | if(!track) {printf("AliL3HoughEval: NO TRACK\n"); continue;} |
182 | Float_t phi0[2] = {track->GetPhi0(),0}; |
183 | fTransform->Local2GlobalAngle(phi0,slice); |
184 | Double_t dPt = ptg - track->GetPt(); |
185 | Double_t dPhi0 = phi_part - phi0[0]; |
186 | Double_t distance = pow(dPt,2) + pow(dPhi0,2); |
187 | if(distance < min_dist) |
188 | { |
189 | min_dist = distance; |
190 | sel_track = track; |
191 | } |
192 | |
193 | } |
194 | if(sel_track) |
195 | sel_track->SetBestMCid(j,min_dist); |
196 | |
197 | Double_t dpt = fabs(ptg-sel_track->GetPt()); |
198 | Double_t dphi0 = fabs(phi_part-sel_track->GetPhi0()); |
199 | //printf("Found match, min_dist %f dPt %f dPhi0 %f\n",min_dist,dpt,dphi0); |
200 | } |
201 | file->Close(); |
202 | delete file; |
203 | |
204 | |
205 | } |