Line data Source code
1 : /**************************************************************************
2 : * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 : * *
4 : * Author: The ALICE Off-line Project. *
5 : * Contributors are mentioned in the code where appropriate. *
6 : * *
7 : * Permission to use, copy, modify and distribute this software and its *
8 : * documentation strictly for non-commercial purposes is hereby granted *
9 : * without fee, provided that the above copyright notice appears in all *
10 : * copies and that both the copyright notice and this permission notice *
11 : * appear in the supporting documentation. The authors make no claims *
12 : * about the suitability of this software for any purpose. It is *
13 : * provided "as is" without express or implied warranty. *
14 : **************************************************************************/
15 :
16 : //////////////////////////////////////////////////////////////////////////
17 : // //
18 : // Container for calibration parameters for AliTRDseedV1::AttachClusters()
19 : // .... Longer description of content ...
20 : //
21 : // For calibration procedure check AliTRDtrackleOflHelper::CalibrateAttach()
22 : // .... some reference to the calibration procedure .........
23 : // //
24 : // Authors: //
25 : // Alex Bercuci <a.bercuci@gsi.de> //
26 : // //
27 : //////////////////////////////////////////////////////////////////////////
28 :
29 : #include <TFile.h>
30 : #include <TROOT.h>
31 : #include <TMath.h>
32 : #include "TH1.h"
33 : #include "TGraphErrors.h"
34 : #include "TObjArray.h"
35 :
36 : #include "AliLog.h"
37 :
38 : #include "AliTRDcalibDB.h"
39 : #include "AliTRDgeometry.h"
40 : #include "AliTRDCalTrkAttach.h"
41 :
42 48 : ClassImp(AliTRDCalTrkAttach)
43 :
44 : //______________________________________________________________________________
45 : AliTRDCalTrkAttach::AliTRDCalTrkAttach()
46 2 : :TNamed("AliTRDCalTrkAttach", "Calibration of AliTRDseedV1::AttachClusters")
47 2 : ,fRClikeLimit(0.65)
48 2 : ,fScaleCov(2.)
49 2 : ,fLike(NULL)
50 10 : {
51 : // Default constructor
52 :
53 2 : fNsgmDy[0] = 5; fNsgmDy[1] = 7;
54 2 : fLikeMinRelDecrease[0] = .2; fLikeMinRelDecrease[1] = .3;
55 4 : }
56 :
57 : //______________________________________________________________________________
58 : AliTRDCalTrkAttach::~AliTRDCalTrkAttach()
59 0 : {
60 : // Destructor
61 0 : if(fLike) delete fLike;
62 0 : }
63 :
64 :
65 : //______________________________________________________________________________
66 : Double_t AliTRDCalTrkAttach::CookLikelihood(Bool_t chg, Int_t ly, Float_t pt, Float_t phiTrk, Int_t n, Double_t dyr, Double_t dphi, Double_t sr) const
67 : {
68 : // Calculate likelihood for a segment to belong to a tracklet
69 : // Based on calibrated values
70 :
71 292 : if(n<4){
72 12 : AliDebug(4, Form("Failed basic cut[s] : n[%d] ...", n));
73 4 : return 0.;
74 : }
75 : //check likelihood array
76 576 : if (!fLike || fLike->GetEntries() != AliTRDgeometry::kNlayer*kNcharge*kNcalib) {
77 0 : AliError("No usable AttachClusters calib object.");
78 0 : return 0.;
79 : }
80 288 : Int_t offset(ly*kNcalib*kNcharge); // offset for layer
81 : TGraphErrors *g(NULL);
82 288 : if(!(g = (TGraphErrors*)fLike->At(offset+Int_t(kResPos)*kNcharge+Int_t(chg)))){
83 0 : AliError("Failed retrieving AttachClusters graph.");
84 0 : return 0.;
85 : }
86 : // Interpolate p_t
87 288 : Int_t npts(g->GetN()), ip(0), jp(-1);
88 288 : Double_t x0, y0, x1, y1, dd(0.), invdx(0.), f[4]={0., 0., 0., 0.};
89 5782 : for(Int_t kp(0); kp<npts; kp++){
90 2891 : g->GetPoint(kp, x1, y1);
91 3179 : if(x1>=pt){jp=kp; break;}
92 : }
93 : Bool_t boundary(kFALSE);
94 288 : if(jp<0){
95 0 : jp = npts-1;
96 0 : g->GetPoint(jp, x1, y1);
97 : ip = npts-1;
98 : boundary = kTRUE;
99 288 : }else if(jp==0){
100 : ip = 0;
101 : boundary = kTRUE;
102 0 : }else{
103 288 : ip = jp-1;
104 288 : g->GetPoint(ip, x0, y0);
105 288 : invdx = 1./(x0-x1);
106 : }
107 : // process pt dependences
108 : // +++ process dy
109 864 : Double_t dym = boundary?y1:((pt*(y0-y1) + (x0*y1-x1*y0))*invdx),
110 288 : sym = 0.5*(g->GetErrorY(ip)+g->GetErrorY(jp));
111 288 : dd = (dyr - dym)/sym; dd*=dd;
112 288 : f[0] = TMath::Exp(-0.5*dd);
113 : // +++ process dphi
114 288 : if(!(g = (TGraphErrors*)fLike->At(offset+Int_t(kResAng)*kNcharge+Int_t(chg)))){
115 0 : AliError("Failed retrieving AttachClusters graph.");
116 0 : return 0.;
117 : }
118 288 : g->GetPoint(ip, x0, y0);g->GetPoint(jp, x1, y1);
119 864 : Double_t dpm = boundary?y1:((pt*(y0-y1) + (x0*y1-x1*y0))*invdx),
120 288 : spm = 0.5*(g->GetErrorY(ip)+g->GetErrorY(jp));
121 288 : dd = (dphi - dpm)/spm; dd*=dd;
122 288 : f[1] = TMath::Exp(-0.5*dd);
123 : // +++ process no of clusters
124 288 : if(!(g = (TGraphErrors*)fLike->At(offset+Int_t(kNclMean)*kNcharge+Int_t(chg)))){
125 0 : AliError("Failed retrieving AttachClusters graph.");
126 0 : return 0.;
127 : }
128 288 : g->GetPoint(ip, x0, y0);g->GetPoint(jp, x1, y1);
129 864 : Double_t nm = boundary?y1:((pt*(y0-y1) + (x0*y1-x1*y0))*invdx);
130 288 : f[2] = (nm-TMath::Abs(n-nm))/nm;
131 :
132 : // process phi dependences
133 : // +++ process <s>/s
134 288 : if(!(g = (TGraphErrors*)fLike->At(offset+Int_t(kSigma)*kNcharge+Int_t(chg)))){
135 0 : AliError("Failed retrieving AttachClusters graph.");
136 0 : return 0.;
137 : }
138 : // Interpolate phi [deg]
139 288 : npts=g->GetN(); jp=-1;
140 576 : for(Int_t kp(0); kp<npts; kp++){
141 288 : g->GetPoint(kp, x1, y1);
142 576 : if(x1>=phiTrk){jp=kp; break;}
143 : }
144 288 : if(jp<0){
145 0 : jp = npts-1;
146 0 : g->GetPoint(jp, x1, y1);
147 : ip = jp;
148 : boundary = kTRUE;
149 288 : }else if(jp==0){
150 : ip = jp;
151 : boundary = kTRUE;
152 288 : }else{
153 0 : ip = jp-1;
154 0 : g->GetPoint(ip, x0, y0);
155 0 : invdx = 1./(x0-x1);
156 : boundary = kFALSE;
157 : }
158 864 : Double_t sm = boundary?y1:((phiTrk*(y0-y1) + (x0*y1-x1*y0))*invdx),
159 288 : ssm = 0.5*(g->GetErrorY(ip)+g->GetErrorY(jp));
160 288 : dd = (sr - sm)/ssm; dd*=dd;
161 : f[3] = 1.;//TMath::Exp(-0.5*dd);
162 :
163 : // Calculate likelihood
164 288 : Double_t length = f[0]*f[0]+f[1]*f[1]+f[2]*f[2]+f[3]*f[3];
165 288 : length = TMath::Sqrt(length);
166 288 : Double_t cosTht = f[0]+f[1]+f[2]+f[3];
167 288 : cosTht /= (4.*length);
168 864 : AliDebug(2, Form("Like[%5.3f] ThtLike[%6.2f](deg)\n"
169 : " F_dy (%+6.2f)=%4.2f\n"
170 : " F_phi(%+6.2f)=%4.2f\n"
171 : " F_ncl(%+6d)=%4.2f\n"
172 : " F_<s>(%+6.2f)=%4.2f",
173 : length, TMath::ACos(cosTht)*TMath::RadToDeg(),
174 : dyr, f[0], dphi, f[1], n, f[2], sr, f[3]));
175 :
176 : return length;
177 580 : }
178 :
179 : //______________________________________________________________________________
180 : void AliTRDCalTrkAttach::Help()
181 : {
182 : // Display help message
183 0 : printf(
184 : "Draw likelihood distribution. Possible options are of the form \"lt\"\n"
185 : "where \"l\" is the layer number [0-5] and\n"
186 : " \"t\" is the type. This is one of the following\n"
187 : " \"y\" - r-phi roads\n"
188 : " \"p\" - angular (deflection) roads\n"
189 : " \"n\" - number of clusters\n"
190 : " \"s\" - cluster spread\n");
191 0 : }
192 :
193 : //______________________________________________________________________________
194 : void AliTRDCalTrkAttach::Draw(Option_t* opt)
195 : {
196 : // Draw likelihood distribution. Possible options are of the form "lt"
197 : // where "l" is the layer number [0-5] and
198 : // "t" is the type. This is one of the following
199 : // "y" - r-phi roads
200 : // "p" - angular (deflection) roads
201 : // "n" - number of clusters
202 : // "s" - cluster spread
203 0 : if (!fLike || fLike->GetEntries() != AliTRDgeometry::kNlayer*kNcharge*kNcalib) {
204 0 : AliError("No likelihood distributions stored");
205 0 : return;
206 : }
207 0 : if(!opt){
208 0 : Help();
209 0 : return;
210 : }
211 0 : Int_t ly(-1); Char_t cly[] = {'0','1','2','3','4','5'};
212 0 : for(Int_t ily(0); ily<AliTRDgeometry::kNlayer; ily++){
213 0 : if(opt[0] == cly[ily]){
214 0 : ly = ily; break;
215 : }
216 : }
217 0 : if(ly<0){
218 0 : Help();
219 0 : return;
220 : }
221 : Int_t typ(-1); const Char_t ctyp[] = {'y', 'p', 's', 'n'};
222 0 : for(Int_t it(0); it<kNcalib; it++){
223 0 : if(opt[1] == ctyp[it]){
224 0 : typ = it; break;
225 : }
226 : }
227 0 : if(typ<0){
228 0 : Help();
229 0 : return;
230 : }
231 0 : Int_t offset(ly*kNcalib*kNcharge+typ*kNcharge); // offset for layer and type
232 0 : TGraphErrors *g[2]={(TGraphErrors*)fLike->At(offset), (TGraphErrors*)fLike->At(offset+1)};
233 0 : if(!g[0] || !g[1]){
234 0 : AliError(Form("Failed retrieving graphs for Ly[%d] Typ[%c]", ly, ctyp[typ]));
235 0 : return;
236 : }
237 :
238 : // draw !!
239 0 : const Char_t *ttyp[] = {"#Deltay [cm]", "#Delta#phi [deg]", "#Delta#sigma/<#sigma>", "n_{cl}^{tracklet}"};
240 0 : g[0]->Draw("apl"); g[0]->SetLineColor(kBlue); g[0]->SetMarkerColor(kBlue);
241 0 : g[1]->Draw("pl"); g[1]->SetLineColor(kRed); g[1]->SetMarkerColor(kRed);
242 0 : TH1 *h=g[0]->GetHistogram();
243 0 : h->GetYaxis()->SetTitle(ttyp[typ]);
244 0 : h->GetYaxis()->SetLabelFont(52);
245 0 : h->GetYaxis()->SetTitleFont(62);
246 0 : h->GetXaxis()->SetTitle("p_{t} [GeV/c]");
247 0 : h->GetXaxis()->SetLabelFont(52);
248 0 : h->GetXaxis()->SetTitleFont(62);
249 0 : }
250 :
251 : //______________________________________________________________________________
252 : Bool_t AliTRDCalTrkAttach::LoadReferences(const Char_t *file)
253 : {
254 : // Load calibration data from file
255 :
256 0 : if(!file || !TFile::Open(file)){
257 0 : AliError("Parametrization file missing or unreadable.");
258 0 : return kFALSE;
259 : }
260 : TGraphErrors *g(NULL);
261 0 : Char_t co[kNcalib] = {'y', 'p', 's', 'n'},
262 0 : cs[2] = {'n', 'p'};
263 :
264 0 : if(fLike) fLike->Clear();
265 0 : else fLike = new TObjArray(AliTRDgeometry::kNlayer*kNcharge*kNcalib);
266 0 : for(Int_t ily(0); ily<AliTRDgeometry::kNlayer; ily++){
267 0 : for(Int_t icalib(0); icalib<kNcalib; icalib++){
268 0 : for(Int_t isgn(0); isgn<kNcharge; isgn++){
269 0 : if(!(g = (TGraphErrors*)gFile->Get(Form("%c%c%d", co[icalib], cs[isgn], ily)))) return kFALSE;
270 0 : fLike->AddAt(g, kNcharge*(ily*kNcalib+icalib)+isgn);
271 : }
272 : }
273 : }
274 0 : return kTRUE;
275 0 : }
|