]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/qaRec/AliTRDtrackingResolution.cxx
updates for studying the drift cell structure
[u/mrichter/AliRoot.git] / TRD / qaRec / AliTRDtrackingResolution.cxx
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-commercialf 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 /* $Id: AliTRDtrackingResolution.cxx 27496 2008-07-22 08:35:45Z cblume $ */
17
18 ////////////////////////////////////////////////////////////////////////////
19 //                                                                        //
20 //  TRD tracking resolution                                               //
21 //
22 // The class performs resolution and residual studies 
23 // of the TRD tracks for the following quantities :
24 //   - spatial position (y, [z])
25 //   - angular (phi) tracklet
26 //   - momentum at the track level
27 // 
28 // The class has to be used for regular detector performance checks using the official macros:
29 //   - $ALICE_ROOT/TRD/qaRec/run.C
30 //   - $ALICE_ROOT/TRD/qaRec/makeResults.C
31 // 
32 // For stand alone usage please refer to the following example: 
33 // {  
34 //   gSystem->Load("libANALYSIS.so");
35 //   gSystem->Load("libTRDqaRec.so");
36 //   AliTRDtrackingResolution *res = new AliTRDtrackingResolution();
37 //   //res->SetMCdata();
38 //   //res->SetVerbose();
39 //   //res->SetVisual();
40 //   res->Load("TRD.TaskResolution.root");
41 //   if(!res->PostProcess()) return;
42 //   res->GetRefFigure(0);
43 // }  
44 //
45 //  Authors:                                                              //
46 //    Alexandru Bercuci <A.Bercuci@gsi.de>                                //
47 //    Markus Fasel <M.Fasel@gsi.de>                                       //
48 //                                                                        //
49 ////////////////////////////////////////////////////////////////////////////
50
51 #include <cstring>
52
53 #include <TROOT.h>
54 #include <TSystem.h>
55 #include <TPDGCode.h>
56 #include <TObjArray.h>
57 #include <TH2.h>
58 #include <TH1.h>
59 #include <TF1.h>
60 #include <TCanvas.h>
61 #include <TBox.h>
62 #include <TProfile.h>
63 #include <TGraphErrors.h>
64 #include <TMath.h>
65 #include "TTreeStream.h"
66 #include "TGeoManager.h"
67
68 #include "AliAnalysisManager.h"
69 #include "AliTrackReference.h"
70 #include "AliTrackPointArray.h"
71 #include "AliCDBManager.h"
72
73 #include "AliTRDSimParam.h"
74 #include "AliTRDgeometry.h"
75 #include "AliTRDpadPlane.h"
76 #include "AliTRDcluster.h"
77 #include "AliTRDseedV1.h"
78 #include "AliTRDtrackV1.h"
79 #include "AliTRDtrackerV1.h"
80 #include "AliTRDReconstructor.h"
81 #include "AliTRDrecoParam.h"
82
83 #include "AliTRDtrackInfo/AliTRDclusterInfo.h"
84 #include "AliTRDtrackInfo/AliTRDtrackInfo.h"
85 #include "AliTRDtrackingResolution.h"
86
87 ClassImp(AliTRDtrackingResolution)
88
89 //________________________________________________________
90 AliTRDtrackingResolution::AliTRDtrackingResolution()
91   :AliTRDrecoTask("Resolution", "Tracking Resolution")
92   ,fStatus(0)
93   ,fReconstructor(0x0)
94   ,fGeo(0x0)
95   ,fGraphS(0x0)
96   ,fGraphM(0x0)
97   ,fCl(0x0)
98   ,fTrklt(0x0)
99   ,fMCcl(0x0)
100   ,fMCtrklt(0x0)
101 {
102   fReconstructor = new AliTRDReconstructor();
103   fReconstructor->SetRecoParam(AliTRDrecoParam::GetLowFluxParam());
104   fGeo = new AliTRDgeometry();
105
106   InitFunctorList();
107
108   DefineOutput(1, TObjArray::Class()); // cluster2track
109   DefineOutput(2, TObjArray::Class()); // tracklet2track
110   DefineOutput(3, TObjArray::Class()); // cluster2mc
111   DefineOutput(4, TObjArray::Class()); // tracklet2mc
112 }
113
114 //________________________________________________________
115 AliTRDtrackingResolution::~AliTRDtrackingResolution()
116 {
117   if(fGraphS){fGraphS->Delete(); delete fGraphS;}
118   if(fGraphM){fGraphM->Delete(); delete fGraphM;}
119   delete fGeo;
120   delete fReconstructor;
121   if(gGeoManager) delete gGeoManager;
122   if(fCl){fCl->Delete(); delete fCl;}
123   if(fTrklt){fTrklt->Delete(); delete fTrklt;}
124   if(fMCcl){fMCcl->Delete(); delete fMCcl;}
125   if(fMCtrklt){fMCtrklt->Delete(); delete fMCtrklt;}
126 }
127
128
129 //________________________________________________________
130 void AliTRDtrackingResolution::CreateOutputObjects()
131 {
132   // spatial resolution
133   OpenFile(0, "RECREATE");
134
135   fContainer = Histos();
136
137   fCl = new TObjArray();
138   fCl->SetOwner(kTRUE);
139   fTrklt = new TObjArray();
140   fTrklt->SetOwner(kTRUE);
141   fMCcl = new TObjArray();
142   fMCcl->SetOwner(kTRUE);
143   fMCtrklt = new TObjArray();
144   fMCtrklt->SetOwner(kTRUE);
145 }
146
147 //________________________________________________________
148 void AliTRDtrackingResolution::Exec(Option_t *opt)
149 {
150   fCl->Delete();
151   fTrklt->Delete();
152   fMCcl->Delete();
153   fMCtrklt->Delete();
154
155   AliTRDrecoTask::Exec(opt);
156
157   PostData(1, fCl);
158   PostData(2, fTrklt);
159   PostData(3, fMCcl);
160   PostData(4, fMCtrklt);
161 }
162
163 //________________________________________________________
164 TH1* AliTRDtrackingResolution::PlotCluster(const AliTRDtrackV1 *track)
165 {
166   if(track) fTrack = track;
167   if(!fTrack){
168     AliWarning("No Track defined.");
169     return 0x0;
170   }
171   TH1 *h = 0x0;
172   if(!(h = ((TH2I*)fContainer->At(kCluster)))){
173     AliWarning("No output histogram defined.");
174     return 0x0;
175   }
176
177   Double_t cov[3];
178   Float_t x0, y0, z0, dy, dydx, dzdx;
179   AliTRDseedV1 *fTracklet = 0x0;  
180   for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
181     if(!(fTracklet = fTrack->GetTracklet(ily))) continue;
182     if(!fTracklet->IsOK()) continue;
183     x0 = fTracklet->GetX0();
184
185     // retrive the track angle with the chamber
186     y0   = fTracklet->GetYref(0);
187     z0   = fTracklet->GetZref(0);
188     dydx = fTracklet->GetYref(1);
189     dzdx = fTracklet->GetZref(1);
190     fTracklet->GetCovRef(cov);
191     Float_t tilt = fTracklet->GetTilt();
192     AliTRDcluster *c = 0x0;
193     fTracklet->ResetClusterIter(kFALSE);
194     while((c = fTracklet->PrevCluster())){
195       Float_t xc = c->GetX();
196       Float_t yc = c->GetY();
197       Float_t zc = c->GetZ();
198       Float_t dx = x0 - xc; 
199       Float_t yt = y0 - dx*dydx;
200       Float_t zt = z0 - dx*dzdx; 
201       yc -= tilt*(zc-zt); // tilt correction
202       dy = yt - yc;
203
204       h->Fill(dydx, dy/TMath::Sqrt(cov[0] + c->GetSigmaY2()));
205   
206       if(fDebugLevel>=1){
207         // Get z-position with respect to anode wire
208         AliTRDSimParam    *simParam    = AliTRDSimParam::Instance();
209         Int_t istk = fGeo->GetStack(c->GetDetector());
210         AliTRDpadPlane *pp = fGeo->GetPadPlane(ily, istk);
211         Float_t row0 = pp->GetRow0();
212         Float_t d  =  row0 - zt + simParam->GetAnodeWireOffset();
213         d -= ((Int_t)(2 * d)) / 2.0;
214         if (d > 0.25) d  = 0.5 - d;
215
216 /*        AliTRDclusterInfo *clInfo = new AliTRDclusterInfo;
217         fCl->Add(clInfo);
218         clInfo->SetCluster(c);
219         clInfo->SetGlobalPosition(yt, zt, dydx, dzdx);
220         clInfo->SetResolution(dy);
221         clInfo->SetAnisochronity(d);
222         clInfo->SetDriftLength(dx);
223         (*fDebugStream) << "ClusterResiduals"
224           <<"clInfo.=" << clInfo
225           << "\n";*/
226       }
227     }
228   }
229   return h;
230 }
231
232
233 //________________________________________________________
234 TH1* AliTRDtrackingResolution::PlotTracklet(const AliTRDtrackV1 *track)
235 {
236   if(track) fTrack = track;
237   if(!fTrack){
238     AliWarning("No Track defined.");
239     return 0x0;
240   }
241   TH1 *h = 0x0;
242   if(!(h = ((TH2I*)fContainer->At(kTrackletY)))){
243     AliWarning("No output histogram defined.");
244     return 0x0;
245   }
246
247   Double_t cov[3], covR[3];
248   Float_t xref, y0, dx, dy, dydx;
249   AliTRDseedV1 *fTracklet = 0x0;  
250   for(Int_t il=AliTRDgeometry::kNlayer; il--;){
251     if(!(fTracklet = fTrack->GetTracklet(il))) continue;
252     if(!fTracklet->IsOK()) continue;
253     y0   = fTracklet->GetYref(0);
254     dydx = fTracklet->GetYref(1);
255     xref = fTracklet->GetXref();
256     dx   = fTracklet->GetX0() - xref;
257     dy   = y0-dx*dydx - fTracklet->GetYat(xref);
258     fTracklet->GetCovAt(xref, cov);
259     fTracklet->GetCovRef(covR);
260     h->Fill(dydx, dy/TMath::Sqrt(cov[0] + covR[0]));
261   }
262   return h;
263 }
264
265 //________________________________________________________
266 TH1* AliTRDtrackingResolution::PlotTrackletPhi(const AliTRDtrackV1 *track)
267 {
268   if(track) fTrack = track;
269   if(!fTrack){
270     AliWarning("No Track defined.");
271     return 0x0;
272   }
273   TH1 *h = 0x0;
274   if(!(h = ((TH2I*)fContainer->At(kTrackletPhi)))){
275     AliWarning("No output histogram defined.");
276     return 0x0;
277   }
278
279   AliTRDseedV1 *tracklet = 0x0;
280   for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++){
281     if(!(tracklet = fTrack->GetTracklet(il))) continue;
282     if(!tracklet->IsOK()) continue;
283     h->Fill(tracklet->GetYref(1), TMath::ATan(tracklet->GetYref(1))-TMath::ATan(tracklet->GetYfit(1)));
284   }
285   return h;
286 }
287
288
289 //________________________________________________________
290 TH1* AliTRDtrackingResolution::PlotResolution(const AliTRDtrackV1 *track)
291 {
292   if(!HasMCdata()){ 
293     AliWarning("No MC defined. Results will not be available.");
294     return 0x0;
295   }
296   if(track) fTrack = track;
297   if(!fTrack){
298     AliWarning("No Track defined.");
299     return 0x0;
300   }
301   TH1 *h = 0x0;
302   UChar_t s;
303   Int_t pdg = fMC->GetPDG(), det=-1;
304   Int_t label = fMC->GetLabel();
305   Float_t p, pt, x0, y0, z0, dx, dy, dz, dydx, dzdx;
306
307   if(fDebugLevel>=1){
308     Double_t DX[12], DY[12], DZ[12], DPt[12], COV[12][15];
309     fMC->PropagateKalman(DX, DY, DZ, DPt, COV);
310     (*fDebugStream) << "MCkalman"
311       << "pdg="  << pdg
312       << "dx0="  << DX[0]
313       << "dx1="  << DX[1]
314       << "dx2="  << DX[2]
315       << "dy0="  << DY[0]
316       << "dy1="  << DY[1]
317       << "dy2="  << DY[2]
318       << "dz0="  << DZ[0]
319       << "dz1="  << DZ[1]
320       << "dz2="  << DZ[2]
321       << "dpt0=" << DPt[0]
322       << "dpt1=" << DPt[1]
323       << "dpt2=" << DPt[2]
324       << "\n";
325   }
326
327   AliTRDseedV1 *fTracklet = 0x0;  
328   for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
329     if(!(fTracklet = fTrack->GetTracklet(ily)) ||
330        !fTracklet->IsOK()) continue;
331
332     det = fTracklet->GetDetector();
333     x0  = fTracklet->GetX0();
334     //radial shift with respect to the MC reference (radial position of the pad plane)
335     dx  = x0 - fTracklet->GetXref();
336     if(!fMC->GetDirections(x0, y0, z0, dydx, dzdx, pt, s)) continue; 
337     // MC track position at reference radial position
338     Float_t yt = y0 - dx*dydx;
339     Float_t zt = z0 - dx*dzdx;
340     p = pt*(1.+dzdx*dzdx); // pt -> p
341
342     // add Kalman residuals for y, z and pt
343     Float_t dxr= fTracklet->GetX0() - x0 + dx; 
344     Float_t yr = fTracklet->GetYref(0) - dxr*fTracklet->GetYref(1);
345     dy = yt - yr;
346     Float_t zr = fTracklet->GetZref(0) - dxr*fTracklet->GetZref(1);
347     dz = zt - zr;
348     Float_t tgl = fTracklet->GetTgl();
349     Float_t ptr = fTracklet->GetMomentum()/(1.+tgl*tgl);
350
351     ((TH2I*)fContainer->At(kMCtrackY))->Fill(dydx, dy);
352     ((TH2I*)fContainer->At(kMCtrackZ))->Fill(dzdx, dz);
353     if(pdg!=kElectron && pdg!=kPositron) ((TH2I*)fContainer->At(kMCtrackPt))->Fill(1./pt, ptr-pt);
354     // Fill Debug stream for Kalman track
355     if(fDebugLevel>=1){
356       Float_t dydxr = fTracklet->GetYref(1);
357       (*fDebugStream) << "MCtrack"
358         << "det="     << det
359         << "pdg="     << pdg
360         << "pt="      << pt
361         << "yt="      << yt
362         << "zt="      << zt
363         << "dydx="    << dydx
364         << "dzdx="    << dzdx
365         << "ptr="     << ptr
366         << "dy="      << dy
367         << "dz="      << dz
368         << "dydxr="   << dydxr
369         << "dzdxr="   << tgl
370         << "\n";
371     }
372
373     // recalculate tracklet based on the MC info
374     AliTRDseedV1 tt(*fTracklet);
375     tt.SetZref(0, z0);
376     tt.SetZref(1, dzdx); 
377     if(!tt.Fit(kTRUE)) continue;
378
379     // add tracklet residuals for y and dydx
380     Float_t yf = tt.GetYfit(0) - dxr*tt.GetYfit(1);
381     dy = yt - yf;
382     Float_t dphi   = (tt.GetYfit(1) - dydx);
383     dphi /= 1.- tt.GetYfit(1)*dydx;
384     ((TH2I*)fContainer->At(kMCtrackletY))->Fill(dydx, dy);
385     ((TH2I*)fContainer->At(kMCtrackletPhi))->Fill(dydx, dphi*TMath::RadToDeg());
386
387     Float_t dz = 100.;
388     Bool_t rc = fTracklet->IsRowCross(); 
389     if(rc){
390       // add tracklet residuals for z
391       Double_t *xyz = tt.GetCrossXYZ();
392       dz = xyz[2] - (z0 - (x0 - xyz[0])*dzdx) ;
393       ((TH2I*)fContainer->At(kMCtrackletZ))->Fill(dzdx, dz);
394     }
395   
396     // Fill Debug stream for tracklet
397     if(fDebugLevel>=1){
398       (*fDebugStream) << "MCtracklet"
399         << "det="     << det
400         << "pdg="     << pdg
401         << "p="       << p
402         << "yt="      << yt
403         << "zt="      << zt
404         << "dydx="    << dydx
405         << "dzdx="    << dzdx
406         << "rowc="    << rc
407         << "dy="      << dy
408         << "dz="      << dz
409         << "dphi="    << dphi
410         << "\n";
411     }
412
413     Int_t istk = AliTRDgeometry::GetStack(det); 
414     AliTRDpadPlane *pp = fGeo->GetPadPlane(ily, istk);
415     Float_t zr0 = pp->GetRow0() + AliTRDSimParam::Instance()->GetAnodeWireOffset();
416     Float_t tilt = fTracklet->GetTilt();
417
418     Double_t x,y;
419     AliTRDcluster *c = 0x0;
420     fTracklet->ResetClusterIter(kFALSE);
421     while((c = fTracklet->PrevCluster())){
422       Float_t  q = TMath::Abs(c->GetQ());
423       //AliTRDseedV1::GetClusterXY(c,x,y);
424       x = c->GetX(); y = c->GetY();
425       Float_t xc = x;
426       Float_t yc = y;
427       Float_t zc = c->GetZ();
428       dx = x0 - xc; 
429       Float_t yt = y0 - dx*dydx;
430       Float_t zt = z0 - dx*dzdx; 
431       dy = yt - (yc - tilt*(zc-zt));
432
433       // Fill Histograms
434       if(q>20. && q<250.) ((TH2I*)fContainer->At(kMCcluster))->Fill(dydx, dy);
435
436       // Fill calibration container
437       Float_t d = zr0 - zt;
438       d -= ((Int_t)(2 * d)) / 2.0;
439       if (d > 0.25) d  = 0.5 - d;
440       AliTRDclusterInfo *clInfo = new AliTRDclusterInfo;
441       fMCcl->Add(clInfo);
442       clInfo->SetCluster(c);
443       clInfo->SetMC(pdg, label);
444       clInfo->SetGlobalPosition(yt, zt, dydx, dzdx);
445       clInfo->SetResolution(dy);
446       clInfo->SetAnisochronity(d);
447       clInfo->SetDriftLength(dx);
448       clInfo->SetTilt(tilt);
449
450       // Fill Debug Tree
451       if(fDebugLevel>=2){
452         //clInfo->Print();
453         (*fDebugStream) << "MCcluster"
454           <<"clInfo.=" << clInfo
455           << "\n";
456       }
457     }
458   }
459   return h;
460 }
461
462
463 //________________________________________________________
464 Bool_t AliTRDtrackingResolution::GetRefFigure(Int_t ifig)
465 {
466   Float_t y[2] = {0., 0.};
467   TBox *b = 0x0;
468   TAxis *ax = 0x0;
469   TGraphErrors *g = 0x0;
470   switch(ifig){
471   case kCluster:
472     if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
473     g->Draw("apl");
474     ax = g->GetHistogram()->GetYaxis();
475     y[0] = -0.5; y[1] = 2.5;
476     ax->SetRangeUser(y[0], y[1]);
477     ax->SetTitle("Cluster-Track Pools #sigma/#mu [mm]");
478     ax = g->GetHistogram()->GetXaxis();
479     ax->SetTitle("tg(#phi)");
480     if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
481     g->Draw("pl");
482     b = new TBox(-.15, y[0], .15, y[1]);
483     b->SetFillStyle(3002);b->SetFillColor(kGreen);
484     b->SetLineColor(0); b->Draw();
485     return kTRUE;
486   case kTrackletY:
487     if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
488     g->Draw("apl");
489     ax = g->GetHistogram()->GetYaxis();
490     ax->SetRangeUser(-.5, 3.);
491     ax->SetTitle("Tracklet-Track Y-Pools #sigma/#mu [mm]");
492     ax = g->GetHistogram()->GetXaxis();
493     ax->SetTitle("tg(#phi)");
494     if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
495     g->Draw("pl");
496     b = new TBox(-.15, y[0], .15, y[1]);
497     b->SetFillStyle(3002);b->SetFillColor(kGreen);
498     b->SetLineColor(0); b->Draw();
499     return kTRUE;
500   case kTrackletPhi:
501     if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
502     g->Draw("apl");
503     ax = g->GetHistogram()->GetYaxis();
504     ax->SetRangeUser(-.5, 2.);
505     ax->SetTitle("Tracklet-Track Phi-Residuals #sigma/#mu [rad]");
506     ax = g->GetHistogram()->GetXaxis();
507     ax->SetTitle("tg(#phi)");
508     if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
509     g->Draw("pl");
510     b = new TBox(-.15, y[0], .15, y[1]);
511     b->SetFillStyle(3002);b->SetFillColor(kGreen);
512     b->SetLineColor(0); b->Draw();
513     return kTRUE;
514   case kMCcluster:
515     if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
516     ax = g->GetHistogram()->GetYaxis();
517     y[0] = -.1; y[1] = 1.5;
518     ax->SetRangeUser(y[0], y[1]);
519     ax->SetTitle("Y_{cluster} #sigma/#mu [mm]");
520     ax = g->GetHistogram()->GetXaxis();
521     ax->SetTitle("tg(#phi)");
522     g->Draw("apl");
523     if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
524     g->Draw("pl");
525     b = new TBox(-.15, y[0], .15, y[1]);
526     b->SetFillStyle(3002);b->SetFillColor(kBlue);
527     b->SetLineColor(0); b->Draw();
528     return kTRUE;
529   case kMCtrackletY:
530     if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
531     ax = g->GetHistogram()->GetYaxis();
532     y[0] = -.05; y[1] = 0.3;
533     ax->SetRangeUser(y[0], y[1]);
534     ax->SetTitle("Y_{tracklet} #sigma/#mu [mm]");
535     ax = g->GetHistogram()->GetXaxis();
536     ax->SetTitle("tg(#phi)");
537     g->Draw("apl");
538     if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
539     g->Draw("pl");
540     b = new TBox(-.15, y[0], .15, y[1]);
541     b->SetFillStyle(3002);b->SetFillColor(kBlue);
542     b->SetLineColor(0); b->Draw();
543     return kTRUE;
544   case kMCtrackletZ:
545     if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
546     ax = g->GetHistogram()->GetYaxis();
547     ax->SetRangeUser(-.5, 1.);
548     ax->SetTitle("Z_{tracklet} #sigma/#mu [mm]");
549     ax = g->GetHistogram()->GetXaxis();
550     ax->SetTitle("tg(#theta)");
551     g->Draw("apl");
552     if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
553     g->Draw("pl");
554     return kTRUE;
555   case kMCtrackletPhi:
556     if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
557     ax = g->GetHistogram()->GetYaxis();
558     y[0] = -.05; y[1] = .2;
559     ax->SetRangeUser(y[0], y[1]);
560     ax->SetTitle("#Phi_{tracklet} #sigma/#mu [deg]");
561     ax = g->GetHistogram()->GetXaxis();
562     ax->SetTitle("tg(#phi)");
563     g->Draw("apl");
564     if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
565     g->Draw("pl");
566     return kTRUE;
567   case kMCtrackY:
568     if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
569     ax = g->GetHistogram()->GetYaxis();
570     y[0] = -.05; y[1] = 0.2;
571     ax->SetRangeUser(y[0], y[1]);
572     ax->SetTitle("Y_{track} #sigma/#mu [mm]");
573     ax = g->GetHistogram()->GetXaxis();
574     ax->SetTitle("tg(#phi)");
575     g->Draw("apl");
576     if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
577     g->Draw("pl");
578     b = new TBox(-.15, y[0], .15, y[1]);
579     b->SetFillStyle(3002);b->SetFillColor(kBlue);
580     b->SetLineColor(0); b->Draw();
581     return kTRUE;
582   case kMCtrackZ:
583     if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
584     ax = g->GetHistogram()->GetYaxis();
585     ax->SetRangeUser(-.5, 2.);
586     ax->SetTitle("Z_{track} #sigma/#mu [mm]");
587     ax = g->GetHistogram()->GetXaxis();
588     ax->SetTitle("tg(#theta)");
589     g->Draw("apl");
590     if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
591     g->Draw("pl");
592     return kTRUE;
593   case kMCtrackPt:
594     if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
595     ax = g->GetHistogram()->GetYaxis();
596     ax->SetRangeUser(-.5, 2.);
597     ax->SetTitle("#epsilon_{P_{t}}^{track} / #mu [%]");
598     ax = g->GetHistogram()->GetXaxis();
599     ax->SetTitle("1/p_{t}");
600     g->Draw("apl");
601     if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
602     g->Draw("pl");
603     return kTRUE;
604   }
605   AliInfo(Form("Reference plot [%d] missing result", ifig));
606   return kFALSE;
607 }
608
609
610 //________________________________________________________
611 Bool_t AliTRDtrackingResolution::PostProcess()
612 {
613   //fContainer = dynamic_cast<TObjArray*>(GetOutputData(0));
614   if (!fContainer) {
615     Printf("ERROR: list not available");
616     return kFALSE;
617   }
618   fNRefFigures = fContainer->GetEntriesFast();
619   TGraphErrors *gm = 0x0, *gs = 0x0;
620   if(!fGraphS){ 
621     fGraphS = new TObjArray(fNRefFigures);
622     fGraphS->SetOwner();
623     for(Int_t ig=0; ig<fNRefFigures; ig++){
624       gs = new TGraphErrors();
625       gs->SetLineColor(kRed);
626       gs->SetMarkerStyle(23);
627       gs->SetMarkerColor(kRed);
628       gs->SetNameTitle(Form("s_%d", ig), "");
629       fGraphS->AddAt(gs, ig);
630     }
631   }
632   if(!fGraphM){ 
633     fGraphM = new TObjArray(fNRefFigures);
634     fGraphM->SetOwner();
635     for(Int_t ig=0; ig<fNRefFigures; ig++){
636       gm = new TGraphErrors();
637       gm->SetLineColor(kBlue);
638       gm->SetMarkerStyle(7);
639       gm->SetMarkerColor(kBlue);
640       gm->SetNameTitle(Form("m_%d", ig), "");
641       fGraphM->AddAt(gm, ig);
642     }
643   }
644
645   TH2I *h2 = 0x0;
646   TH1D *h = 0x0;
647
648   // define models
649   TF1 f("f1", "gaus", -.5, .5);  
650
651   TF1 fb("fb", "[0]*exp(-0.5*((x-[1])/[2])**2)+[3]", -.5, .5);
652
653   TF1 fc("fc", "[0]*exp(-0.5*((x-[1])/[2])**2)+[3]*exp(-0.5*((x-[4])/[5])**2)", -.5, .5);
654
655   TCanvas *c = 0x0;
656   if(IsVisual()) c = new TCanvas("c", Form("%s Visual", GetName()), 500, 500);
657   char opt[5];
658   sprintf(opt, "%c%c", IsVerbose() ? ' ' : 'Q', IsVisual() ? ' ': 'N');
659
660
661   //PROCESS RESIDUAL DISTRIBUTIONS
662
663   // Clusters residuals
664   h2 = (TH2I *)(fContainer->At(kCluster));
665   gm = (TGraphErrors*)fGraphM->At(kCluster);
666   gs = (TGraphErrors*)fGraphS->At(kCluster);
667   for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
668     Double_t phi = h2->GetXaxis()->GetBinCenter(ibin);
669     h = h2->ProjectionY("py", ibin, ibin);
670     if(h->GetEntries()<100) continue;
671     AdjustF1(h, &f);
672
673     if(IsVisual()){c->cd(); c->SetLogy();}
674     h->Fit(&f, opt, "", -0.5, 0.5);
675     if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
676     
677     Int_t ip = gm->GetN();
678     gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
679     gm->SetPointError(ip, 0., 10.*f.GetParError(1));
680     gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
681     gs->SetPointError(ip, 0., 10.*f.GetParError(2));
682   }
683
684   // Tracklet y residuals
685   h2 = (TH2I *)(fContainer->At(kTrackletY));
686   gm = (TGraphErrors*)fGraphM->At(kTrackletY);
687   gs = (TGraphErrors*)fGraphS->At(kTrackletY);
688   for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
689     Double_t phi = h2->GetXaxis()->GetBinCenter(ibin);
690     h = h2->ProjectionY("py", ibin, ibin);
691     if(h->GetEntries()<100) continue;
692     AdjustF1(h, &f);
693
694     if(IsVisual()){c->cd(); c->SetLogy();}
695     h->Fit(&f, opt, "", -0.5, 0.5);
696     if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
697     
698     Int_t ip = gm->GetN();
699     gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
700     gm->SetPointError(ip, 0., 10.*f.GetParError(1));
701     gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
702     gs->SetPointError(ip, 0., 10.*f.GetParError(2));
703   }
704
705   // Tracklet phi residuals
706   h2 = (TH2I *)(fContainer->At(kTrackletPhi));
707   gm = (TGraphErrors*)fGraphM->At(kTrackletPhi);
708   gs = (TGraphErrors*)fGraphS->At(kTrackletPhi);
709   for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
710     Double_t phi = h2->GetXaxis()->GetBinCenter(ibin);
711     h = h2->ProjectionY("py", ibin, ibin);
712     if(h->GetEntries()<100) continue;
713     AdjustF1(h, &f);
714
715     if(IsVisual()){c->cd(); c->SetLogy();}
716     h->Fit(&f, opt, "", -0.5, 0.5);
717     if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
718     
719     Int_t ip = gm->GetN();
720     gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
721     gm->SetPointError(ip, 0., 10.*f.GetParError(1));
722     gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
723     gs->SetPointError(ip, 0., 10.*f.GetParError(2));
724   }
725
726   if(!HasMCdata()){
727     if(c) delete c;
728     return kTRUE;
729   }
730
731   //PROCESS MC RESIDUAL DISTRIBUTIONS
732
733   // cluster y resolution
734   h2 = (TH2I*)fContainer->At(kMCcluster);
735   gm = (TGraphErrors*)fGraphM->At(kMCcluster);
736   gs = (TGraphErrors*)fGraphS->At(kMCcluster);
737   for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
738     h = h2->ProjectionY("py", iphi, iphi);
739     if(h->GetEntries()<100) continue;
740     AdjustF1(h, &f);
741
742     if(IsVisual()){c->cd(); c->SetLogy();}
743     h->Fit(&f, opt, "", -0.5, 0.5);
744     if(IsVerbose()){
745       printf("phi[%d] mean[%e] sigma[%e]\n\n", iphi, 10.*f.GetParameter(1), 10.*f.GetParameter(2));
746     }
747     if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
748
749     Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
750     Int_t ip = gm->GetN();
751     gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
752     gm->SetPointError(ip, 0., 10.*f.GetParError(1));
753     gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
754     gs->SetPointError(ip, 0., 10.*f.GetParError(2));
755   }
756
757   // tracklet y resolution
758   h2 = (TH2I*)fContainer->At(kMCtrackletY);
759   gm = (TGraphErrors*)fGraphM->At(kMCtrackletY);
760   gs = (TGraphErrors*)fGraphS->At(kMCtrackletY);
761   for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
762     h = h2->ProjectionY("py", iphi, iphi);
763     if(h->GetEntries()<100) continue;
764     AdjustF1(h, &f);
765
766     if(IsVisual()){c->cd(); c->SetLogy();}
767     h->Fit(&f, opt, "", -0.5, 0.5);
768     if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
769
770     Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
771     Int_t ip = gm->GetN();
772     gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
773     gm->SetPointError(ip, 0., 10.*f.GetParError(1));
774     gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
775     gs->SetPointError(ip, 0., 10.*f.GetParError(2));
776   }
777
778   // tracklet z resolution
779   h2 = (TH2I*)fContainer->At(kMCtrackletZ);
780   gm = (TGraphErrors*)fGraphM->At(kMCtrackletZ);
781   gs = (TGraphErrors*)fGraphS->At(kMCtrackletZ);
782   for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
783     h = h2->ProjectionY("py", iphi, iphi);
784     if(h->GetEntries()<100) continue;
785     AdjustF1(h, &fb);
786
787     if(IsVisual()){c->cd(); c->SetLogy();}
788     h->Fit(&fb, opt, "", -0.5, 0.5);
789     if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
790
791     Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
792     Int_t ip = gm->GetN();
793     gm->SetPoint(ip, phi, 10.*fb.GetParameter(1));
794     gm->SetPointError(ip, 0., 10.*fb.GetParError(1));
795     gs->SetPoint(ip, phi, 10.*fb.GetParameter(2));
796     gs->SetPointError(ip, 0., 10.*fb.GetParError(2));
797   }
798
799   //tracklet phi resolution
800   h2 = (TH2I*)fContainer->At(kMCtrackletPhi);
801   gm = (TGraphErrors*)fGraphM->At(kMCtrackletPhi);
802   gs = (TGraphErrors*)fGraphS->At(kMCtrackletPhi);
803   for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
804     h = h2->ProjectionY("py", iphi, iphi);
805     if(h->GetEntries()<100) continue;
806
807     if(IsVisual()){c->cd(); c->SetLogy();}
808     h->Fit(&f, opt, "", -0.5, 0.5);
809     if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
810
811     Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
812     Int_t ip = gm->GetN();
813     gm->SetPoint(ip, phi, f.GetParameter(1));
814     gm->SetPointError(ip, 0., f.GetParError(1));
815     gs->SetPoint(ip, phi, f.GetParameter(2));
816     gs->SetPointError(ip, 0., f.GetParError(2));
817   }
818
819   // track y resolution
820   h2 = (TH2I*)fContainer->At(kMCtrackY);
821   gm = (TGraphErrors*)fGraphM->At(kMCtrackY);
822   gs = (TGraphErrors*)fGraphS->At(kMCtrackY);
823   for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
824     h = h2->ProjectionY("py", iphi, iphi);
825     if(h->GetEntries()<100) continue;
826     AdjustF1(h, &f);
827
828     if(IsVisual()){c->cd(); c->SetLogy();}
829     h->Fit(&f, opt, "", -0.5, 0.5);
830     if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
831
832     Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
833     Int_t ip = gm->GetN();
834     gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
835     gm->SetPointError(ip, 0., 10.*f.GetParError(1));
836     gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
837     gs->SetPointError(ip, 0., 10.*f.GetParError(2));
838   }
839
840   // track z resolution
841   h2 = (TH2I*)fContainer->At(kMCtrackZ);
842   gm = (TGraphErrors*)fGraphM->At(kMCtrackZ);
843   gs = (TGraphErrors*)fGraphS->At(kMCtrackZ);
844   for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
845     h = h2->ProjectionY("pz", iphi, iphi);
846     if(h->GetEntries()<70) continue;
847     AdjustF1(h, &f);
848
849     if(IsVisual()){c->cd(); c->SetLogy();}
850     h->Fit(&f, opt, "", -0.5, 0.5);
851     if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
852
853     Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
854     Int_t ip = gm->GetN();
855     gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
856     gm->SetPointError(ip, 0., 10.*f.GetParError(1));
857     gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
858     gs->SetPointError(ip, 0., 10.*f.GetParError(2));
859   }
860
861   // track Pt resolution
862   h2 = (TH2I*)fContainer->At(kMCtrackPt);
863   TAxis *ax = h2->GetXaxis();
864   gm = (TGraphErrors*)fGraphM->At(kMCtrackPt);
865   gs = (TGraphErrors*)fGraphS->At(kMCtrackPt);
866   TF1 fg("fg", "gaus", -1.5, 1.5);
867   TF1 fl("fl", "landau", -4., 15.);
868   TF1 fgl("fgl", "gaus(0)+landau(3)", -5., 20.);
869   for(Int_t ip=1; ip<=ax->GetNbins(); ip++){
870     h = h2->ProjectionY("ppt", ip, ip);
871     if(h->GetEntries()<70) continue;
872
873     h->Fit(&fg, "QN", "", -1.5, 1.5);
874     fgl.SetParameter(0, fg.GetParameter(0));
875     fgl.SetParameter(1, fg.GetParameter(1));
876     fgl.SetParameter(2, fg.GetParameter(2));
877     h->Fit(&fl, "QN", "", -4., 15.);
878     fgl.SetParameter(3, fl.GetParameter(0));
879     fgl.SetParameter(4, fl.GetParameter(1));
880     fgl.SetParameter(5, fl.GetParameter(2));
881
882     if(IsVisual()){c->cd(); c->SetLogy();}
883     h->Fit(&fgl, opt, "", -5., 20.);
884     if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
885
886     Float_t invpt = ax->GetBinCenter(ip);
887     Int_t ip = gm->GetN();
888     gm->SetPoint(ip, invpt, fgl.GetParameter(1));
889     gm->SetPointError(ip, 0., fgl.GetParError(1));
890     gs->SetPoint(ip, invpt, fgl.GetParameter(2)*invpt);
891     gs->SetPointError(ip, 0., fgl.GetParError(2));
892     // fgl.GetParameter(4) // Landau MPV
893     // fgl.GetParameter(5) // Landau Sigma
894   }
895
896
897   if(c) delete c;
898   return kTRUE;
899 }
900
901
902 //________________________________________________________
903 void AliTRDtrackingResolution::Terminate(Option_t *)
904 {
905   if(fDebugStream){ 
906     delete fDebugStream;
907     fDebugStream = 0x0;
908     fDebugLevel = 0;
909   }
910   if(HasPostProcess()) PostProcess();
911 }
912
913 //________________________________________________________
914 void AliTRDtrackingResolution::AdjustF1(TH1 *h, TF1 *f)
915 {
916 // Helper function to avoid duplication of code
917 // Make first guesses on the fit parameters
918
919   // find the intial parameters of the fit !! (thanks George)
920   Int_t nbinsy = Int_t(.5*h->GetNbinsX());
921   Double_t sum = 0.;
922   for(Int_t jbin=nbinsy-4; jbin<=nbinsy+4; jbin++) sum+=h->GetBinContent(jbin); sum/=9.;
923   f->SetParLimits(0, 0., 3.*sum);
924   f->SetParameter(0, .9*sum);
925
926   f->SetParLimits(1, -.2, .2);
927   f->SetParameter(1, -0.1);
928
929   f->SetParLimits(2, 0., 4.e-1);
930   f->SetParameter(2, 2.e-2);
931   if(f->GetNpar() <= 4) return;
932
933   f->SetParLimits(3, 0., sum);
934   f->SetParameter(3, .1*sum);
935
936   f->SetParLimits(4, -.3, .3);
937   f->SetParameter(4, 0.);
938
939   f->SetParLimits(5, 0., 1.e2);
940   f->SetParameter(5, 2.e-1);
941 }
942
943 //________________________________________________________
944 TObjArray* AliTRDtrackingResolution::Histos()
945 {
946   if(fContainer) return fContainer;
947
948   fContainer  = new TObjArray(10);
949   //fContainer->SetOwner(kTRUE);
950
951   TH1 *h = 0x0;
952   // cluster to tracklet residuals [2]
953   if(!(h = (TH2I*)gROOT->FindObject("hCl"))){
954     h = new TH2I("hCl", "Clusters-Track Residuals", 21, -.33, .33, 100, -.5, .5);
955     h->GetXaxis()->SetTitle("tg(#phi)");
956     h->GetYaxis()->SetTitle("#Delta y [cm]");
957     h->GetZaxis()->SetTitle("entries");
958   } else h->Reset();
959   fContainer->AddAt(h, kCluster);
960
961   // tracklet to track residuals [2]
962   if(!(h = (TH2I*)gROOT->FindObject("hTrkltY"))){
963     h = new TH2I("hTrkltY", "Tracklets-Track Residuals (Y)", 21, -.33, .33, 100, -.5, .5);
964     h->GetXaxis()->SetTitle("tg(#phi)");
965     h->GetYaxis()->SetTitle("#Delta y [cm]");
966     h->GetZaxis()->SetTitle("entries");
967   } else h->Reset();
968   fContainer->AddAt(h, kTrackletY);
969
970   // tracklet to track residuals angular [2]
971   if(!(h = (TH2I*)gROOT->FindObject("hTrkltPhi"))){
972     h = new TH2I("hTrkltPhi", "Tracklets-Track Residuals (#Phi)", 21, -.33, .33, 100, -.5, .5);
973     h->GetXaxis()->SetTitle("tg(#phi)");
974     h->GetYaxis()->SetTitle("#Delta phi [#circ]");
975     h->GetZaxis()->SetTitle("entries");
976   } else h->Reset();
977   fContainer->AddAt(h, kTrackletPhi);
978
979
980   // Resolution histos
981   if(!HasMCdata()) return fContainer;
982
983   // cluster y resolution [0]
984   if(!(h = (TH2I*)gROOT->FindObject("hMCcl"))){
985     h = new TH2I("hMCcl", "Cluster Resolution", 31, -.48, .48, 100, -.5, .5);
986     h->GetXaxis()->SetTitle("tg(#phi)");
987     h->GetYaxis()->SetTitle("#Delta y [cm]");
988     h->GetZaxis()->SetTitle("entries");
989   } else h->Reset();
990   fContainer->AddAt(h, kMCcluster);
991
992   // tracklet y resolution [0]
993   if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltY"))){
994     h = new TH2I("hMCtrkltY", "Tracklet Resolution (Y)", 31, -.48, .48, 100, -.5, .5);
995     h->GetXaxis()->SetTitle("tg(#phi)");
996     h->GetYaxis()->SetTitle("#Delta y [cm]");
997     h->GetZaxis()->SetTitle("entries");
998   } else h->Reset();
999   fContainer->AddAt(h, kMCtrackletY);
1000
1001   // tracklet y resolution [0]
1002   if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltZ"))){
1003     h = new TH2I("hMCtrkltZ", "Tracklet Resolution (Z)", 31, -.48, .48, 100, -.5, .5);
1004     h->GetXaxis()->SetTitle("tg(#theta)");
1005     h->GetYaxis()->SetTitle("#Delta z [cm]");
1006     h->GetZaxis()->SetTitle("entries");
1007   } else h->Reset();
1008   fContainer->AddAt(h, kMCtrackletZ);
1009
1010   // tracklet angular resolution [1]
1011   if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltPhi"))){
1012     h = new TH2I("hMCtrkltPhi", "Tracklet Resolution (#Phi)", 31, -.48, .48, 100, -10., 10.);
1013     h->GetXaxis()->SetTitle("tg(#phi)");
1014     h->GetYaxis()->SetTitle("#Delta #phi [deg]");
1015     h->GetZaxis()->SetTitle("entries");
1016   } else h->Reset();
1017   fContainer->AddAt(h, kMCtrackletPhi);
1018
1019   // Kalman track y resolution
1020   if(!(h = (TH2I*)gROOT->FindObject("hMCtrkY"))){
1021     h = new TH2I("hMCtrkY", "Kalman Track Resolution (Y)", 31, -.48, .48, 100, -.5, .5);
1022     h->GetXaxis()->SetTitle("tg(#phi)");
1023     h->GetYaxis()->SetTitle("#Delta y [cm]");
1024     h->GetZaxis()->SetTitle("entries");
1025   } else h->Reset();
1026   fContainer->AddAt(h, kMCtrackY);
1027
1028   // Kalman track Z resolution
1029   if(!(h = (TH2I*)gROOT->FindObject("hMCtrkZ"))){
1030     h = new TH2I("hMCtrkZ", "Kalman Track Resolution (Z)", 20, -1., 1., 100, -1.5, 1.5);
1031     h->GetXaxis()->SetTitle("tg(#theta)");
1032     h->GetYaxis()->SetTitle("#Delta z [cm]");
1033     h->GetZaxis()->SetTitle("entries");
1034   } else h->Reset();
1035   fContainer->AddAt(h, kMCtrackZ);
1036
1037   // Kalman track Pt resolution
1038   if(!(h = (TH2I*)gROOT->FindObject("hMCtrkPt"))){
1039     h = new TH2I("hMCtrkPt", "Kalman Track Resolution (Pt)", 100, 0., 2., 150, -5., 20.);
1040     h->GetXaxis()->SetTitle("1/p_{t}");
1041     h->GetYaxis()->SetTitle("#Delta p_{t} [GeV/c]");
1042     h->GetZaxis()->SetTitle("entries");
1043   } else h->Reset();
1044   fContainer->AddAt(h, kMCtrackPt);
1045
1046   return fContainer;
1047 }
1048
1049
1050 //________________________________________________________
1051 void AliTRDtrackingResolution::SetRecoParam(AliTRDrecoParam *r)
1052 {
1053
1054   fReconstructor->SetRecoParam(r);
1055 }