1 #include "AliTRDclusterResolution.h"
2 #include "AliTRDtrackInfo/AliTRDclusterInfo.h"
3 #include "AliTRDgeometry.h"
4 #include "AliTRDpadPlane.h"
11 #include "TGraphErrors.h"
15 ClassImp(AliTRDclusterResolution)
18 //_______________________________________________________
19 AliTRDclusterResolution::AliTRDclusterResolution()
20 : AliTRDrecoTask("ClErrParam", "Cluster Error Parametrization")
27 fAt = new TAxis(kNTB, -0.075, (kNTB-.5)*.15);
28 fAd = new TAxis(kND, 0., .25);
31 //_______________________________________________________
32 AliTRDclusterResolution::~AliTRDclusterResolution()
42 //_______________________________________________________
43 void AliTRDclusterResolution::ConnectInputData(Option_t *)
45 fInfo = dynamic_cast<TObjArray *>(GetInputData(0));
48 //_______________________________________________________
49 void AliTRDclusterResolution::CreateOutputObjects()
51 OpenFile(0, "RECREATE");
52 fContainer = Histos();
55 //_______________________________________________________
56 void AliTRDclusterResolution::GetRefFigure(Int_t ifig)
58 if(!fResults) return /*kFALSE*/;
62 TGraphErrors *gm(0x0), *gs(0x0);
65 if(!(arr = (TObjArray*)fResults->At(kQRes))) break;
66 if(!(gm = (TGraphErrors*)arr->At(0))) break;
67 if(!(gs = (TGraphErrors*)arr->At(1))) break;
69 gs->GetHistogram()->SetXTitle("Log(Q) [a.u.]");
70 gs->GetHistogram()->SetYTitle("#sigma_{y}^{2} [mm^{2}] [a.u.]");
73 if(!(arr = (TObjArray*)fResults->At(kYRes))) break;
74 if(!(gm = (TGraphErrors*)arr->At(0))) break;
75 if(!(gs = (TGraphErrors*)arr->At(1))) break;
77 gs->GetHistogram()->SetXTitle("y [w]");
78 gs->GetHistogram()->SetYTitle("#sigma_{y}^{2} [mm^{2}] [a.u.]");
81 if(!(h2 = (TH2F*)fResults->At(kSXRes))) break;
85 if(!(h2 = (TH2F*)fResults->At(kSYRes))) break;
95 //_______________________________________________________
96 TObjArray* AliTRDclusterResolution::Histos()
98 if(fContainer) return fContainer;
99 fContainer = new TObjArray(3);
100 //fContainer->SetOwner(kTRUE);
103 TObjArray *arr = 0x0;
105 fContainer->AddAt(h2 = new TH2I("h_q", "", 50, 2.2, 7.5, 100, -.5, .5), kQRes);
106 h2->SetXTitle("log(q) [a.u.]");
107 h2->SetYTitle("#Delta y[cm]");
108 h2->SetZTitle("entries");
112 fContainer->AddAt(arr = new TObjArray(AliTRDgeometry::kNlayer), kYRes);
113 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
114 w = .5*geo.GetPadPlane(ily, 2)->GetWidthIPad();
115 arr->AddAt(h2 = new TH2I(Form("h_y%d", ily), Form("Ly[%d]", ily), 50, -w, w, 100, -.5, .5), ily);
116 h2->SetXTitle("y_{w} [w]");
117 h2->SetYTitle("#Delta y[cm]");
118 h2->SetZTitle("entries");
121 fContainer->AddAt(arr = new TObjArray(kN), kSXRes);
123 for(Int_t id=1; id<=fAd->GetNbins(); id++){
124 for(Int_t it=1; it<=fAt->GetNbins(); it++){
125 arr->AddAt(h2 = new TH2I(Form("h_d%02dt%02d", id, it), Form("d_{wire}(%3.1f-%3.1f)[mm] x_{drift}(%5.2f-%5.2f)[mm]", 10.*fAd->GetBinCenter(id)- 5.*fAd->GetBinWidth(id), 10.*fAd->GetBinCenter(id)+ 5.*fAd->GetBinWidth(id), 10.*fAt->GetBinCenter(it)- 5.*fAt->GetBinWidth(it), 10.*fAt->GetBinCenter(it)+ 5.*fAt->GetBinWidth(it)), 30, -.15, .15, 100, -.5, .5), ih++);
126 h2->SetXTitle("tg#phi");
127 h2->SetYTitle("#Delta y[cm]");
128 h2->SetZTitle("entries");
134 //_______________________________________________________
135 void AliTRDclusterResolution::Exec(Option_t *)
138 Float_t x, y, z, q, dy, dydx, dzdx, cov[3], covcl[3];
141 TObjArray *arr0 = (TObjArray*)fContainer->At(kYRes);
142 TObjArray *arr1 = (TObjArray*)fContainer->At(kSXRes);
144 const AliTRDclusterInfo *cli = 0x0;
145 TIterator *iter=fInfo->MakeIterator();
146 while((cli=dynamic_cast<AliTRDclusterInfo*>((*iter)()))){
147 dy = cli->GetResolution();
148 Int_t it = fAt->FindBin(cli->GetDriftLength());
149 if(it==0 || it == fAt->GetNbins()+1){
150 AliWarning(Form("Drift length %f outside allowed range", cli->GetDriftLength()));
153 Int_t id = fAd->FindBin(cli->GetAnisochronity());
154 if(id==0 || id == fAd->GetNbins()+1){
155 AliWarning(Form("Distance to anode %f outside allowed range", cli->GetAnisochronity()));
158 if(!(h2 = (TH2I*)arr1->At((id-1)*kNTB+it-1))){
159 AliWarning(Form("Missing histo at index idx[%3d] [id[%2d] it[%2d]] xd[%f] d[%f]\n", (id-1)*kNTB+it-1, id, it, cli->GetDriftLength(), cli->GetAnisochronity()));
163 cli->GetGlobalPosition(y, z, dydx, dzdx, &cov[0]);
164 h2->Fill(dydx, cov[0]!=0. ? dy/TMath::Sqrt(cov[0]) : dy);
166 // resolution as a function of:
167 // - cluster charge and
169 // only for phi equal exB
170 if(TMath::Abs(dydx-fExB)<.01){
171 cli->GetCluster(det, x, y, z, q, t, covcl);
172 h2 = (TH2I*)fContainer->At(kQRes);
173 h2->Fill(TMath::Log(q), dy);
175 h2 = (TH2I*)arr0->At(AliTRDgeometry::GetLayer(det));
176 h2->Fill(cli->GetYDisplacement(), dy);
179 PostData(0, fContainer);
183 //_______________________________________________________
184 Bool_t AliTRDclusterResolution::PostProcess()
186 if(!fContainer) return kFALSE;
188 TObjArray *arr = 0x0;
191 TGraphErrors *g = 0x0;
192 fResults = new TObjArray(4);
193 fResults->SetOwner();
194 fResults->AddAt(arr = new TObjArray(2), kQRes);
196 arr->AddAt(g = new TGraphErrors(), 0);
197 g->SetLineColor(kBlue); g->SetMarkerColor(kBlue);
198 g->SetMarkerStyle(7);
199 arr->AddAt(g = new TGraphErrors(), 1);
200 g->SetLineColor(kRed); g->SetMarkerColor(kRed);
201 g->SetMarkerStyle(23);
203 fResults->AddAt(arr = new TObjArray(2), kYRes);
205 arr->AddAt(g = new TGraphErrors(), 0);
206 g->SetLineColor(kBlue); g->SetMarkerColor(kBlue);
207 g->SetMarkerStyle(7);
208 arr->AddAt(g = new TGraphErrors(), 1);
209 g->SetLineColor(kRed); g->SetMarkerColor(kRed);
210 g->SetMarkerStyle(23);
212 fResults->AddAt(h2 = new TH2F("hSX", "",
213 fAd->GetNbins(), fAd->GetXmin(), fAd->GetXmax(),
214 fAt->GetNbins(), fAt->GetXmin(), fAt->GetXmax()), kSXRes);
215 h2->SetXTitle("d [mm]");
216 h2->SetYTitle("x [mm]");
217 h2->SetZTitle("#sigma_{x}^{2} [mm^{2}]");
218 fResults->AddAt(h2 = (TH2F*)h2->Clone("hSY"), kSYRes);
219 h2->SetZTitle("#sigma_{y}^{2} [mm^{2}]");
222 TIterator *iter=fResults->MakeIterator();
223 while((o=((*iter)()))) o->Clear(); // maybe it is wrong but we should never reach this point
226 TF1 f("f", "gaus", -.5, .5);
227 TF1 sig("sig", "pol1", 0., .0225);
232 // process resolution dependency on charge
233 if((h2 = (TH2I*)fContainer->At(kQRes))) {
234 TObjArray *arr = (TObjArray*)fResults->At(kQRes);
235 TGraphErrors *gqm = (TGraphErrors*)arr->At(0);
236 TGraphErrors *gqs = (TGraphErrors*)arr->At(1);
238 for(Int_t ix=1; ix<=ax->GetNbins(); ix++){
239 Float_t logq = ax->GetBinCenter(ix);
240 h1 = h2->ProjectionY("py", ix, ix);
241 if(h1->GetEntries() < 50) continue;
245 // Fill sy^2 = f(log(q))
246 Int_t ip = gqm->GetN();
247 gqm->SetPoint(ip, logq, 10.*f.GetParameter(1));
248 gqm->SetPointError(ip, 0., 10.*f.GetParError(1));
249 gqs->SetPoint(ip, logq, 1.e2*f.GetParameter(2)*f.GetParameter(2));
250 gqs->SetPointError(ip, 0., 2.e2*f.GetParameter(2)*f.GetParError(2));
252 } else AliWarning("Missing dy=f(Q) histo");
254 // process resolution dependency on y displacement
255 if((arr = (TObjArray*)fContainer->At(kYRes))) {
256 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
257 if(!(h2 = (TH2I*)arr->At(ily))) continue;
258 TObjArray *arrg = (TObjArray*)fResults->At(kYRes);
259 TGraphErrors *gym = (TGraphErrors*)arrg->At(0);
260 TGraphErrors *gys = (TGraphErrors*)arrg->At(1);
262 for(Int_t ix=1; ix<=ax->GetNbins(); ix++){
263 Float_t yd = ax->GetBinCenter(ix);
264 h1 = h2->ProjectionY("py", ix, ix);
265 if(h1->GetEntries() < 50) continue;
269 // Fill sy^2 = f(log(q))
270 Int_t ip = gym->GetN();
271 gym->SetPoint(ip, yd, 10.*f.GetParameter(1));
272 gym->SetPointError(ip, 0., 10.*f.GetParError(1));
273 gys->SetPoint(ip, yd, 1.e2*f.GetParameter(2)*f.GetParameter(2));
274 gys->SetPointError(ip, 0., 2.e2*f.GetParameter(2)*f.GetParError(2));
277 } else AliWarning("Missing dy=f(y_d) container");
279 // process resolution dependency on drift legth and drift cell width
280 TGraphErrors *gm = new TGraphErrors(), *gs = new TGraphErrors();
281 Float_t d(0.), x(0.);
282 TH2F *hsx = (TH2F*)fResults->At(kSXRes);
283 TH2F *hsy = (TH2F*)fResults->At(kSYRes);
284 if((arr = (TObjArray*)fContainer->At(kSXRes))) {
285 for(Int_t id=1; id<=fAd->GetNbins(); id++){
286 d = fAd->GetBinCenter(id); //[mm]
287 printf("Doing d=%f[mm]\n", d);
288 for(Int_t it=1; it<=fAt->GetNbins(); it++){
289 x = fAt->GetBinCenter(it); //[mm]
290 printf("Doing x=%f[mm]\n", x);
291 Int_t idx = (id-1)*kNTB+it-1;
292 if(!(h2 = (TH2I*)arr->At(idx))) {
293 AliWarning(Form("Missing histo at index idx[%3d] [id[%2d] it[%2d]] xd[%f] d[%f]\n", idx, id, it, x, d));
299 for(Int_t ix=1; ix<=ax->GetNbins(); ix++){
300 Float_t dydx = ax->GetBinCenter(ix) - fExB;
301 if(dydx<0.) continue;
302 h1 = h2->ProjectionY("py", ix, ix);
303 if(h1->GetEntries() < 50) continue;
305 h1->Fit(&f, "Q", "", -.2, .2);
307 // Fill sy^2 = f(tg_phi^2)
308 gm->SetPoint(ip, dydx, 10.*f.GetParameter(1));
309 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
310 gs->SetPoint(ip, dydx*dydx, 1.e2*f.GetParameter(2)*f.GetParameter(2));
311 gs->SetPointError(ip, 0., 2.e2*f.GetParameter(2)*f.GetParError(2));
314 for(;ip<gm->GetN(); ip++){
315 gm->RemovePoint(ip);gs->RemovePoint(ip);
318 hsx->SetBinContent(id, it, sig.GetParameter(1));
319 hsx->SetBinError(id, it, sig.GetParError(1));
320 hsy->SetBinContent(id, it, sig.GetParameter(0));
321 hsy->SetBinError(id, it, sig.GetParError(0));
324 } else AliWarning("Missing dy=f(x_d, d_wire) container");
325 delete gm; delete gs;