1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //////////////////////////////////////////////////////////////////////////
18 // Container for calibration parameters for AliTRDseedV1::AttachClusters()
19 // .... Longer description of content ...
21 // For calibration procedure check AliTRDtrackleOflHelper::CalibrateAttach()
22 // .... some reference to the calibration procedure .........
25 // Alex Bercuci <a.bercuci@gsi.de> //
27 //////////////////////////////////////////////////////////////////////////
33 #include "TGraphErrors.h"
34 #include "TObjArray.h"
38 #include "AliTRDcalibDB.h"
39 #include "AliTRDgeometry.h"
40 #include "AliTRDCalTrkAttach.h"
42 ClassImp(AliTRDCalTrkAttach)
44 //______________________________________________________________________________
45 AliTRDCalTrkAttach::AliTRDCalTrkAttach()
46 :TNamed("AliTRDCalTrkAttach", "Calibration of AliTRDseedV1::AttachClusters")
51 // Default constructor
53 fNsgmDy[0] = 5; fNsgmDy[1] = 7;
54 fLikeMinRelDecrease[0] = .2; fLikeMinRelDecrease[1] = .3;
57 //______________________________________________________________________________
58 AliTRDCalTrkAttach::~AliTRDCalTrkAttach()
61 if(fLike) delete fLike;
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
68 // Calculate likelihood for a segment to belong to a tracklet
69 // Based on calibrated values
72 AliDebug(4, Form("Failed basic cut[s] : n[%d] ...", n));
75 //check likelihood array
76 if (!fLike || fLike->GetEntries() != AliTRDgeometry::kNlayer*kNcharge*kNcalib) {
77 AliError("No usable AttachClusters calib object.");
80 Int_t offset(ly*kNcalib*kNcharge); // offset for layer
81 TGraphErrors *g(NULL);
82 if(!(g = (TGraphErrors*)fLike->At(offset+Int_t(kResPos)*kNcharge+Int_t(chg)))){
83 AliError("Failed retrieving AttachClusters graph.");
87 Int_t npts(g->GetN()), ip(0), jp(-1);
88 Double_t x0, y0, x1, y1, dd(0.), invdx(0.), f[4]={0., 0., 0., 0.};
89 for(Int_t kp(0); kp<npts; kp++){
90 g->GetPoint(kp, x1, y1);
91 if(x1>=pt){jp=kp; break;}
93 Bool_t boundary(kFALSE);
96 g->GetPoint(jp, x1, y1);
104 g->GetPoint(ip, x0, y0);
107 // process pt dependences
109 Double_t dym = boundary?y1:((pt*(y0-y1) + (x0*y1-x1*y0))*invdx),
110 sym = 0.5*(g->GetErrorY(ip)+g->GetErrorY(jp));
111 dd = (dyr - dym)/sym; dd*=dd;
112 f[0] = TMath::Exp(-0.5*dd);
114 if(!(g = (TGraphErrors*)fLike->At(offset+Int_t(kResAng)*kNcharge+Int_t(chg)))){
115 AliError("Failed retrieving AttachClusters graph.");
118 g->GetPoint(ip, x0, y0);g->GetPoint(jp, x1, y1);
119 Double_t dpm = boundary?y1:((pt*(y0-y1) + (x0*y1-x1*y0))*invdx),
120 spm = 0.5*(g->GetErrorY(ip)+g->GetErrorY(jp));
121 dd = (dphi - dpm)/spm; dd*=dd;
122 f[1] = TMath::Exp(-0.5*dd);
123 // +++ process no of clusters
124 if(!(g = (TGraphErrors*)fLike->At(offset+Int_t(kNclMean)*kNcharge+Int_t(chg)))){
125 AliError("Failed retrieving AttachClusters graph.");
128 g->GetPoint(ip, x0, y0);g->GetPoint(jp, x1, y1);
129 Double_t nm = boundary?y1:((pt*(y0-y1) + (x0*y1-x1*y0))*invdx);
130 f[2] = (nm-TMath::Abs(n-nm))/nm;
132 // process phi dependences
134 if(!(g = (TGraphErrors*)fLike->At(offset+Int_t(kSigma)*kNcharge+Int_t(chg)))){
135 AliError("Failed retrieving AttachClusters graph.");
138 // Interpolate phi [deg]
139 npts=g->GetN(); jp=-1;
140 for(Int_t kp(0); kp<npts; kp++){
141 g->GetPoint(kp, x1, y1);
142 if(x1>=phiTrk){jp=kp; break;}
146 g->GetPoint(jp, x1, y1);
154 g->GetPoint(ip, x0, y0);
158 Double_t sm = boundary?y1:((phiTrk*(y0-y1) + (x0*y1-x1*y0))*invdx),
159 ssm = 0.5*(g->GetErrorY(ip)+g->GetErrorY(jp));
160 dd = (sr - sm)/ssm; dd*=dd;
161 f[3] = 1.;//TMath::Exp(-0.5*dd);
163 // Calculate likelihood
164 Double_t length = f[0]*f[0]+f[1]*f[1]+f[2]*f[2]+f[3]*f[3];
165 length = TMath::Sqrt(length);
166 Double_t cosTht = f[0]+f[1]+f[2]+f[3];
167 cosTht /= (4.*length);
168 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]));
179 //______________________________________________________________________________
180 void AliTRDCalTrkAttach::Help()
182 // Display help message
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");
193 //______________________________________________________________________________
194 void AliTRDCalTrkAttach::Draw(Option_t* opt)
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
200 // "p" - angular (deflection) roads
201 // "n" - number of clusters
202 // "s" - cluster spread
203 if (!fLike || fLike->GetEntries() != AliTRDgeometry::kNlayer*kNcharge*kNcalib) {
204 AliError("No likelihood distributions stored");
211 Int_t ly(-1); Char_t cly[] = {'0','1','2','3','4','5'};
212 for(Int_t ily(0); ily<AliTRDgeometry::kNlayer; ily++){
213 if(opt[0] == cly[ily]){
221 Int_t typ(-1); const Char_t ctyp[] = {'y', 'p', 's', 'n'};
222 for(Int_t it(0); it<kNcalib; it++){
223 if(opt[1] == ctyp[it]){
231 Int_t offset(ly*kNcalib*kNcharge+typ*kNcharge); // offset for layer and type
232 TGraphErrors *g[2]={(TGraphErrors*)fLike->At(offset), (TGraphErrors*)fLike->At(offset+1)};
234 AliError(Form("Failed retrieving graphs for Ly[%d] Typ[%c]", ly, ctyp[typ]));
239 const Char_t *ttyp[] = {"#Deltay [cm]", "#Delta#phi [deg]", "#Delta#sigma/<#sigma>", "n_{cl}^{tracklet}"};
240 g[0]->Draw("apl"); g[0]->SetLineColor(kBlue); g[0]->SetMarkerColor(kBlue);
241 g[1]->Draw("pl"); g[1]->SetLineColor(kRed); g[1]->SetMarkerColor(kRed);
242 TH1 *h=g[0]->GetHistogram();
243 h->GetYaxis()->SetTitle(ttyp[typ]);
244 h->GetYaxis()->SetLabelFont(52);
245 h->GetYaxis()->SetTitleFont(62);
246 h->GetXaxis()->SetTitle("p_{t} [GeV/c]");
247 h->GetXaxis()->SetLabelFont(52);
248 h->GetXaxis()->SetTitleFont(62);
251 //______________________________________________________________________________
252 Bool_t AliTRDCalTrkAttach::LoadReferences(const Char_t *file)
254 // Load calibration data from file
256 if(!file || !TFile::Open(file)){
257 AliError("Parametrization file missing or unreadable.");
260 TGraphErrors *g(NULL);
261 Char_t co[kNcalib] = {'y', 'p', 's', 'n'},
264 if(fLike) fLike->Clear();
265 else fLike = new TObjArray(AliTRDgeometry::kNlayer*kNcharge*kNcalib);
266 for(Int_t ily(0); ily<AliTRDgeometry::kNlayer; ily++){
267 for(Int_t icalib(0); icalib<kNcalib; icalib++){
268 for(Int_t isgn(0); isgn<kNcharge; isgn++){
269 if(!(g = (TGraphErrors*)gFile->Get(Form("%c%c%d", co[icalib], cs[isgn], ily)))) return kFALSE;
270 fLike->AddAt(g, kNcharge*(ily*kNcalib+icalib)+isgn);