]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Bug fix - Teminate - as virtula function
authormarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 9 May 2008 14:21:33 +0000 (14:21 +0000)
committermarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 9 May 2008 14:21:33 +0000 (14:21 +0000)
In alignment - use the hyperplanes fit

(Marian)

TPC/AliTPCAnalysisTaskcalib.cxx
TPC/AliTPCTracklet.cxx
TPC/AliTPCcalibAlign.cxx
TPC/AliTPCcalibAlign.h
TPC/AliTPCcalibBase.h

index e5f7b88ae1507999218330c3c7e65d63b27608b2..02866fc9684fba61f5ea0c4a5155ad207ad4f342 100644 (file)
@@ -103,10 +103,14 @@ void AliTPCAnalysisTaskcalib::CreateOutputObjects() {
   //
 }
 void AliTPCAnalysisTaskcalib::Terminate(Option_t */*option*/) {
+  //
+  //
+  //
   TIterator *i=fCalibJobs.MakeIterator();
   AliTPCcalibBase *job;
-  while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
+  while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next()))){
     job->Terminate();
+  }
 }
 
 // we could have been living inside a master class...
index fa26cf603803f79b8a3124862fe65ec887e7c969..50945116103f589ecb929e10e712281e78665f90 100755 (executable)
@@ -239,7 +239,7 @@ void AliTPCTracklet::FitKalman(const AliTPCseed *track,Int_t sector) {
       fPrimary=new AliExternalTrackParam(*primarySeed);
     delete primarySeed;
     // for better comparison one does not want to have alpha changed...
-    if (!fPrimary->Rotate(fInner->GetAlpha())) {
+    if (fPrimary) if (!fPrimary->Rotate(fInner->GetAlpha())) {
       delete fPrimary;
       fPrimary=0;
     }
index f5c44ea4f00f31893e7a4407ff255659efd02cba..6e1cfa6aa211f3ccabfaf1257c920f75c32a9b06 100644 (file)
@@ -33,7 +33,9 @@
 #include "AliExternalTrackParam.h"
 #include "AliTPCTracklet.h"
 #include "TH1D.h"
+#include "TVectorD.h"
 #include "TTreeStream.h"
+#include "TFile.h"
 
 #include <iostream>
 #include <sstream>
@@ -118,71 +120,79 @@ void AliTPCcalibAlign::Process(AliTPCseed *seed) {
   
 }
 
+void AliTPCcalibAlign::Analyze(){
+  //
+  // Analyze function 
+  //
+  EvalFitters();
+}
+
+
+void AliTPCcalibAlign::Terminate(){
+  //
+  // Terminate function
+  // call base terminate + Eval of fitters
+  //
+  if (GetDebugLevel()>0) Info("AliTPCcalibAlign","Teminate");
+  EvalFitters();
+  AliTPCcalibBase::Terminate();
+}
+
+
+
+
 void AliTPCcalibAlign::ProcessTracklets(const AliExternalTrackParam &tp1,
                                        const AliExternalTrackParam &tp2,
                                        Int_t s1,Int_t s2) {
 
-  if (fStreamLevel>1){
-    TTreeSRedirector *cstream = GetDebugStreamer();
-    if (cstream){
-      AliExternalTrackParam *p1 = &((AliExternalTrackParam&)tp1);
-      AliExternalTrackParam *p2 = &((AliExternalTrackParam&)tp2);
-      (*cstream)<<"Tracklet"<<
-       "tp1.="<<p1<<
-       "tp2.="<<p2<<
-       "s1="<<s1<<
-       "s2="<<s2<<
-       "\n";
-    }
-  }
 
   if (s2-s1==36) {//only inner-outer
-    if (!fDphiHistArray[s1*72+s2]) {
+    if (!fDphiHistArray[GetIndex(s1,s2)]) {
       stringstream name;
       stringstream title;
       name<<"hist_phi_"<<s1<<"_"<<s2;
       title<<"Phi Missalignment for sectors "<<s1<<" and "<<s2;
-      fDphiHistArray[s1*72+s2]=new TH1D(name.str().c_str(),title.str().c_str(),1024,-0.01,0.01); // +/- 10 mrad
-      ((TH1D*)fDphiHistArray[s1*72+s2])->SetDirectory(0);
+      fDphiHistArray[GetIndex(s1,s2)]=new TH1D(name.str().c_str(),title.str().c_str(),512,-0.01,0.01); // +/- 10 mrad
+      ((TH1D*)fDphiHistArray[GetIndex(s1,s2)])->SetDirectory(0);
     }
-    if (!fDthetaHistArray[s1*72+s2]) {
+    if (!fDthetaHistArray[GetIndex(s1,s2)]) {
       stringstream name;
       stringstream title;
       name<<"hist_theta_"<<s1<<"_"<<s2;
       title<<"Theta Missalignment for sectors "<<s1<<" and "<<s2;
-      fDthetaHistArray[s1*72+s2]=new TH1D(name.str().c_str(),title.str().c_str(),1024,-0.01,0.01); // +/- 10 mrad
-      ((TH1D*)fDthetaHistArray[s1*72+s2])->SetDirectory(0);
+      fDthetaHistArray[GetIndex(s1,s2)]=new TH1D(name.str().c_str(),title.str().c_str(),512,-0.01,0.01); // +/- 10 mrad
+      ((TH1D*)fDthetaHistArray[GetIndex(s1,s2)])->SetDirectory(0);
     }
-    if (!fDyHistArray[s1*72+s2]) {
+    if (!fDyHistArray[GetIndex(s1,s2)]) {
       stringstream name;
       stringstream title;
       name<<"hist_y_"<<s1<<"_"<<s2;
       title<<"Y Missalignment for sectors "<<s1<<" and "<<s2;
-      fDyHistArray[s1*72+s2]=new TH1D(name.str().c_str(),title.str().c_str(),1024,-0.3,0.3); // +/- 3 mm
-      ((TH1D*)fDyHistArray[s1*72+s2])->SetDirectory(0);
+      fDyHistArray[GetIndex(s1,s2)]=new TH1D(name.str().c_str(),title.str().c_str(),512,-0.3,0.3); // +/- 3 mm
+      ((TH1D*)fDyHistArray[GetIndex(s1,s2)])->SetDirectory(0);
     }
-    if (!fDzHistArray[s1*72+s2]) {
+    if (!fDzHistArray[GetIndex(s1,s2)]) {
       stringstream name;
       stringstream title;
       name<<"hist_z_"<<s1<<"_"<<s2;
       title<<"Z Missalignment for sectors "<<s1<<" and "<<s2;
-      fDzHistArray[s1*72+s2]=new TH1D(name.str().c_str(),title.str().c_str(),1024,-0.3,0.3); // +/- 3 mm
-      ((TH1D*)fDzHistArray[s1*72+s2])->SetDirectory(0);
+      fDzHistArray[GetIndex(s1,s2)]=new TH1D(name.str().c_str(),title.str().c_str(),512,-0.3,0.3); // +/- 3 mm
+      ((TH1D*)fDzHistArray[GetIndex(s1,s2)])->SetDirectory(0);
     }
-    static_cast<TH1D*>(fDphiHistArray[s1*72+s2])
+    static_cast<TH1D*>(fDphiHistArray[GetIndex(s1,s2)])
       ->Fill(TMath::ASin(tp1.GetSnp())
             -TMath::ASin(tp2.GetSnp()));
-    static_cast<TH1D*>(fDthetaHistArray[s1*72+s2])
+    static_cast<TH1D*>(fDthetaHistArray[GetIndex(s1,s2)])
       ->Fill(TMath::ATan(tp1.GetTgl())
             -TMath::ATan(tp2.GetTgl()));
-    static_cast<TH1D*>(fDyHistArray[s1*72+s2])
+    static_cast<TH1D*>(fDyHistArray[GetIndex(s1,s2)])
       ->Fill(tp1.GetY()
             -tp2.GetY());
-    static_cast<TH1D*>(fDzHistArray[s1*72+s2])
+    static_cast<TH1D*>(fDzHistArray[GetIndex(s1,s2)])
       ->Fill(tp1.GetZ()
             -tp2.GetZ());
   }
-  return;
+  
 
 
 
@@ -191,7 +201,7 @@ void AliTPCcalibAlign::ProcessTracklets(const AliExternalTrackParam &tp1,
   //
   Double_t t1[5],t2[5];
   Double_t &x1=t1[0], &y1=t1[1], &z1=t1[2], &dydx1=t1[3], &dzdx1=t1[4];
-  Double_t /*&x2=t2[0],*/ &y2=t2[1], &z2=t2[2], &dydx2=t2[3]/*, &dzdx2=t2[4]*/;
+  Double_t &x2=t2[0], &y2=t2[1], &z2=t2[2], &dydx2=t2[3], &dzdx2=t2[4];
   x1   =tp1.GetX();
   y1   =tp1.GetY();
   z1   =tp1.GetZ();
@@ -199,23 +209,45 @@ void AliTPCcalibAlign::ProcessTracklets(const AliExternalTrackParam &tp1,
   dydx1=snp1/TMath::Sqrt(1.-snp1*snp1);
   Double_t tgl1=tp1.GetTgl();
   // dz/dx = 1/(cos(theta)*cos(phi))
-  dzdx1=1./TMath::Sqrt((1.+tgl1*tgl1)*(1.-snp1*snp1));
-  //  x2  =tp1->GetX();
+  dzdx1=tgl1/TMath::Sqrt(1.-snp1*snp1);
+  x2   =tp2.GetX();
   y2   =tp2.GetY();
   z2   =tp2.GetZ();
   Double_t snp2=tp2.GetSnp();
   dydx2=snp2/TMath::Sqrt(1.-snp2*snp2);
   Double_t tgl2=tp2.GetTgl();
-  dzdx1=1./TMath::Sqrt((1.+tgl2*tgl2)*(1.-snp2*snp2));
+  dzdx2=tgl2/TMath::Sqrt(1.-snp2*snp2);
 
+  //
+  //
+  //
+  if (fStreamLevel>1){
+    TTreeSRedirector *cstream = GetDebugStreamer();
+    if (cstream){
+      static TVectorD vec1(5);
+      static TVectorD vec2(5);
+      vec1.SetElements(t1);
+      vec2.SetElements(t2);
+      AliExternalTrackParam *p1 = &((AliExternalTrackParam&)tp1);
+      AliExternalTrackParam *p2 = &((AliExternalTrackParam&)tp2);
+      (*cstream)<<"Tracklet"<<
+       "tp1.="<<p1<<
+       "tp2.="<<p2<<
+       "v1.="<<&vec1<<
+       "v2.="<<&vec2<<
+       "s1="<<s1<<
+       "s2="<<s2<<
+       "\n";
+    }
+  }
   Process12(t1,t2,GetOrMakeFitter12(s1,s2));
-  Process9(t1,t2,GetOrMakeFitter12(s1,s2));
-  Process6(t1,t2,GetOrMakeFitter12(s1,s2));
+  Process9(t1,t2,GetOrMakeFitter9(s1,s2));
+  Process6(t1,t2,GetOrMakeFitter6(s1,s2));
   ++fPoints[72*s1+s2];
 }
 
-void AliTPCcalibAlign::Process12(Double_t *t1,
-                                Double_t *t2,
+void AliTPCcalibAlign::Process12(const Double_t *t1,
+                                const Double_t *t2,
                                 TLinearFitter *fitter) {
   // x2    =  a00*x1 + a01*y1 + a02*z1 + a03
   // y2    =  a10*x1 + a11*y1 + a12*z1 + a13
@@ -226,14 +258,14 @@ void AliTPCcalibAlign::Process12(Double_t *t1,
   //       a00  a01 a02  a03     p[0]   p[1]  p[2]  p[9]
   //       a10  a11 a12  a13 ==> p[3]   p[4]  p[5]  p[10]
   //       a20  a21 a22  a23     p[6]   p[7]  p[8]  p[11] 
-  Double_t &x1=t1[0], &y1=t1[1], &z1=t1[2], &dydx1=t1[3], &dzdx1=t1[4];
-  Double_t /*&x2=t2[0],*/ &y2=t2[1], &z2=t2[2], &dydx2=t2[3], &dzdx2=t2[4];
+  const Double_t &x1=t1[0], &y1=t1[1], &z1=t1[2], &dydx1=t1[3], &dzdx1=t1[4];
+  const Double_t /*&x2=t2[0],*/ &y2=t2[1], &z2=t2[2], &dydx2=t2[3], &dzdx2=t2[4];
 
   // TODO:
-  Double_t sy    = 1.;
-  Double_t sz    = 1.;
-  Double_t sdydx = 1.;
-  Double_t sdzdx = 1.;
+  Double_t sy    = 0.1;
+  Double_t sz    = 0.1;
+  Double_t sdydx = 0.001;
+  Double_t sdzdx = 0.001;
 
   Double_t p[12];
   Double_t value;
@@ -384,10 +416,10 @@ void AliTPCcalibAlign::Process6(Double_t *t1,
   Double_t /*&x2=t2[0],*/ &y2=t2[1], &z2=t2[2], &dydx2=t2[3], &dzdx2=t2[4];
 
   // TODO:
-  Double_t sy    = 1.;
-  Double_t sz    = 1.;
-  Double_t sdydx = 1.;
-  Double_t sdzdx = 1.;
+  Double_t sy    = 0.1;
+  Double_t sz    = 0.1;
+  Double_t sdydx = 0.001;
+  Double_t sdzdx = 0.001;
 
   Double_t p[12];
   Double_t value;
@@ -445,16 +477,46 @@ void AliTPCcalibAlign::Process6(Double_t *t1,
   fitter->AddPoint(p,value,sdzdx);
 }
 
-void AliTPCcalibAlign::Eval() {
+
+
+
+void AliTPCcalibAlign::EvalFitters() {
+  //
+  // Analyze function 
+  // 
+  // Perform the fitting using linear fitters
+  //
+  Int_t kMinPoints =50;
   TLinearFitter *f;
+  TFile fff("alignDebug.root","recreate");
   for (Int_t s1=0;s1<72;++s1)
-    for (Int_t s2=0;s2<72;++s2)
-      if ((f=GetFitter12(s1,s2))&&fPoints[72*s1+s2]>12) {
+    for (Int_t s2=0;s2<72;++s2){
+      if ((f=GetFitter12(s1,s2))&&fPoints[72*s1+s2]>kMinPoints) {
        //      cerr<<s1<<","<<s2<<": "<<fPoints[72*s1+s2]<<endl;
        if (!f->Eval()) {
          cerr<<"Evaluation failed for "<<s1<<","<<s2<<endl;
+         f->Write(Form("f12_%d_%d",s1,s2));
+       }else{
+         f->Write(Form("f12_%d_%d",s1,s2));
        }
       }
+      if ((f=GetFitter9(s1,s2))&&fPoints[72*s1+s2]>kMinPoints) {
+       //      cerr<<s1<<","<<s2<<": "<<fPoints[72*s1+s2]<<endl;
+       if (!f->Eval()) {
+         cerr<<"Evaluation failed for "<<s1<<","<<s2<<endl;
+       }else{
+         f->Write(Form("f9_%d_%d",s1,s2));
+       }
+      }
+      if ((f=GetFitter6(s1,s2))&&fPoints[72*s1+s2]>kMinPoints) {
+       //      cerr<<s1<<","<<s2<<": "<<fPoints[72*s1+s2]<<endl;
+       if (!f->Eval()) {
+         cerr<<"Evaluation failed for "<<s1<<","<<s2<<endl;
+       }else{
+         f->Write(Form("f6_%d_%d",s1,s2));
+       }
+      }
+    }
   /*
                    
   fitter->Eval();
index 398b4d25e3125e9541e95bd1de161382b96b0fd5..3657c7d6c93bbeba69bf7099ad3bbac9c1111bdf 100644 (file)
@@ -25,19 +25,22 @@ public:
   virtual ~AliTPCcalibAlign();
 
   virtual void Process(AliTPCseed *track);
-
+  virtual void Analyze();
+  virtual void Terminate();  
+  //
+  virtual void EvalFitters();
   void ProcessTracklets(const AliExternalTrackParam &t1,
                        const AliExternalTrackParam &t2,
                        Int_t s1,Int_t s2);
-  void Eval();
+  inline Int_t GetIndex(Int_t s1,Int_t s2){return s1*72+s2;}
   TLinearFitter* GetFitter12(Int_t s1,Int_t s2) {
-    return static_cast<TLinearFitter*>(fFitterArray12[s1*72+s2]);
+    return static_cast<TLinearFitter*>(fFitterArray12[GetIndex(s1,s2)]);
   }
   TLinearFitter* GetFitter9(Int_t s1,Int_t s2) {
-    return static_cast<TLinearFitter*>(fFitterArray9[s1*72+s2]);
+    return static_cast<TLinearFitter*>(fFitterArray9[GetIndex(s1,s2)]);
   }
   TLinearFitter* GetFitter6(Int_t s1,Int_t s2) {
-    return static_cast<TLinearFitter*>(fFitterArray6[s1*72+s2]);
+    return static_cast<TLinearFitter*>(fFitterArray6[GetIndex(s1,s2)]);
   }
   Bool_t GetTransformation12(Int_t s1,Int_t s2,TMatrixD &a);
   Bool_t GetTransformation9(Int_t s1,Int_t s2,TMatrixD &a);
@@ -49,8 +52,8 @@ public:
   TObjArray fDzHistArray;
 
 private:
-  void Process12(Double_t *t1,
-                Double_t *t2,
+  void Process12(const Double_t *t1,
+                const Double_t *t2,
                 TLinearFitter *fitter);
   void Process9(Double_t *t1,
                Double_t *t2,
@@ -61,7 +64,8 @@ private:
   TLinearFitter* GetOrMakeFitter12(Int_t s1,Int_t s2) {
     //get or make fitter
     if (!fFitterArray12[s1*72+s2])
-      fFitterArray12[s1*72+s2]=new TLinearFitter(12,"x0++x1++x2++x3++x4++x5++x6++x7++x8++x9++x10++x11");
+ //      fFitterArray12[s1*72+s2]=new TLinearFitter(12,"x[0]++x[1]++x[2]++x[3]++x[4]++x[5]++x[6]++x[7]++x[8]++x[9]++x[10]++x[11]");
+      fFitterArray12[s1*72+s2]=new TLinearFitter(13,"hyp12");
     return GetFitter12(s1,s2);
   }
   TLinearFitter* GetOrMakeFitter9(Int_t s1,Int_t s2) {
@@ -76,9 +80,9 @@ private:
       fFitterArray6[s1*72+s2]=new TLinearFitter(6,"x0++x1++x2++x3++x4++x5");
     return GetFitter6(s1,s2);
   }
-  TObjArray fFitterArray12;
-  TObjArray fFitterArray9;
-  TObjArray fFitterArray6;
+  TObjArray fFitterArray12;  // array of fitters
+  TObjArray fFitterArray9;   // array of fitters
+  TObjArray fFitterArray6;   // array of fitters
   Int_t fPoints[72*72];
 
   ClassDef(AliTPCcalibAlign,1)
index 922465906d2f0a737bbde663e9113b453bd8b927..cf15022cfc4f3975db0f4664e216281abdf945f0 100644 (file)
@@ -24,7 +24,7 @@ public:
   virtual void     Process(AliTPCseed */*track*/){return;}
   virtual Long64_t Merge(TCollection */*li*/){return 0;}
   virtual void     Analyze(){return;}
-  void             Terminate();
+  virtual void     Terminate();
   //
   // debug streamer support
   TTreeSRedirector *GetDebugStreamer();