]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
new tracking for PbPb and pp (Alex)
authorabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 25 Feb 2011 17:04:04 +0000 (17:04 +0000)
committerabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 25 Feb 2011 17:04:04 +0000 (17:04 +0000)
new 1D PID (Markus)
new tail cancellation (Ionut)

29 files changed:
OCDB/TRD/Calib/PIDLQ1D/Run0_999999999_v0_s0.root [new file with mode: 0644]
OCDB/TRD/Calib/RecoParam/Run95352_999999999_v0_s1.root
OCDB/TRD/Calib/TrkAttach/Run95352_999999999_v0_s0.root [new file with mode: 0644]
PWG1/TRD/AliTRDresolution.cxx
PWG1/TRD/AliTRDresolution.h
PWG1/TRD/macros/AddTRDresolution.C
TRD/AliTRDReconstructor.cxx
TRD/AliTRDcalibDB.cxx
TRD/AliTRDcalibDB.h
TRD/AliTRDcluster.h
TRD/AliTRDclusterizer.cxx
TRD/AliTRDclusterizer.h
TRD/AliTRDrecoParam.cxx
TRD/AliTRDrecoParam.h
TRD/AliTRDseedV1.cxx
TRD/AliTRDseedV1.h
TRD/AliTRDtrackV1.cxx
TRD/AliTRDtrackV1.h
TRD/AliTRDtrackerV1.cxx
TRD/AliTRDtrackerV1.h
TRD/AliTRDtransform.cxx
TRD/AliTRDtransform.h
TRD/CMakelibTRDbase.pkg
TRD/CMakelibTRDrec.pkg
TRD/Cal/AliTRDCreateOCDBPIDLQ.C [new file with mode: 0644]
TRD/Cal/AliTRDmakeRecoParamFirstPhysics.C
TRD/Cal/AliTRDmakeTrkDB.C [new file with mode: 0644]
TRD/TRDbaseLinkDef.h
TRD/TRDrecLinkDef.h

diff --git a/OCDB/TRD/Calib/PIDLQ1D/Run0_999999999_v0_s0.root b/OCDB/TRD/Calib/PIDLQ1D/Run0_999999999_v0_s0.root
new file mode 100644 (file)
index 0000000..4e73c5b
Binary files /dev/null and b/OCDB/TRD/Calib/PIDLQ1D/Run0_999999999_v0_s0.root differ
index c8b5e37bc07b2d8e601c528efadf782e6c404341..88fed71d3c4d97972777f494107025e95681ecbd 100644 (file)
Binary files a/OCDB/TRD/Calib/RecoParam/Run95352_999999999_v0_s1.root and b/OCDB/TRD/Calib/RecoParam/Run95352_999999999_v0_s1.root differ
diff --git a/OCDB/TRD/Calib/TrkAttach/Run95352_999999999_v0_s0.root b/OCDB/TRD/Calib/TrkAttach/Run95352_999999999_v0_s0.root
new file mode 100644 (file)
index 0000000..1d1bf37
Binary files /dev/null and b/OCDB/TRD/Calib/TrkAttach/Run95352_999999999_v0_s0.root differ
index b5b62ffad758a6b411ddb099963010ef1791002c..dc51e274e170c14a3cb61e18ceb71b4852888d26 100644 (file)
@@ -130,7 +130,7 @@ AliTRDresolution::AliTRDresolution()
   ,fIdxPlot(0)
   ,fIdxFrame(0)
   ,fPtThreshold(1.)
-  ,fDyRange(1.5)
+  ,fDyRange(0.75)
   ,fDBPDG(NULL)
   ,fGraphS(NULL)
   ,fGraphM(NULL)
@@ -154,7 +154,7 @@ AliTRDresolution::AliTRDresolution(char* name)
   ,fIdxPlot(0)
   ,fIdxFrame(0)
   ,fPtThreshold(1.)
-  ,fDyRange(1.5)
+  ,fDyRange(0.75)
   ,fDBPDG(NULL)
   ,fGraphS(NULL)
   ,fGraphM(NULL)
@@ -242,6 +242,8 @@ Bool_t AliTRDresolution::Pulls(Double_t dyz[2], Double_t cov[3], Double_t tilt)
 // Uses functionality defined by AliTRDseedV1.
 
   Double_t t2(tilt*tilt);
+  // exit door until a bug fix is found for AliTRDseedV1::GetCovSqrt
+  return kTRUE;
 
   // rotate along pad
   Double_t cc[3];
@@ -402,9 +404,9 @@ TH1* AliTRDresolution::PlotCluster(const AliTRDtrackV1 *track)
       y0   = par[1] + dydx * (x0 - par[0]);//param[1] + dydx * (x0 - param[0]);
       z0   = param[2] + dzdx * (x0 - param[0]);
     } else {
-      y0   = fTracklet->GetYref(0);
+      y0   = fTracklet->GetYfit(0);//fTracklet->GetYref(0);
       z0   = fTracklet->GetZref(0);
-      dydx = fTracklet->GetYref(1);
+      dydx = fTracklet->GetYfit(1);//fTracklet->GetYref(1);
       dzdx = fTracklet->GetZref(1);
     }
     /*printf("RC[%c] Primary[%c]\n"
@@ -430,7 +432,7 @@ TH1* AliTRDresolution::PlotCluster(const AliTRDtrackV1 *track)
       // rotate along pad
       dy[1] = cost*(dy[0] - dz[0]*tilt);
       dz[1] = cost*(dz[0] + dy[0]*tilt);
-      if(pt>fPtThreshold && c->IsInChamber()) ((TH3S*)arr->At(0))->Fill(dydx, dy[1], sgm[fSegmentLevel]);
+      if(pt>fPtThreshold && c->IsInChamber()) ((TH3S*)arr->At(0))->Fill(fTracklet->GetYref(1), dy[0], sgm[fSegmentLevel]);
 
       // tilt rotation of covariance for clusters
       Double_t sy2(c->GetSigmaY2()), sz2(c->GetSigmaZ2());
@@ -535,7 +537,7 @@ TH1* AliTRDresolution::PlotTracklet(const AliTRDtrackV1 *track)
     dy[1]= cost*(dy[0] - dz[0]*tilt);
     dz[1]= cost*(dz[0] + dy[0]*tilt);
     ((TH3S*)arr->At(0))->Fill(phi, dy[1], sgm[fSegmentLevel]+rc*fgkNresYsegm[fSegmentLevel]);
-    ((TH3S*)arr->At(2))->Fill(tht, dz[1], rc);
+    if(rc) ((TH2S*)arr->At(2))->Fill(tht, dz[1]);
 
     // compute covariance matrix
     fTracklet->GetCovAt(x, cov);
@@ -546,9 +548,12 @@ TH1* AliTRDresolution::PlotTracklet(const AliTRDtrackV1 *track)
     ((TH3S*)arr->At(1))->Fill(sgm[fSegmentLevel], dyz[0], dyz[1]);
     ((TH3S*)arr->At(3))->Fill(tht, dyz[1], rc);
 
-    Double_t dphi((phi-fTracklet->GetYfit(1))/(1-phi*fTracklet->GetYfit(1)));
+    // calculate angular residuals and correct for tilt
+    Double_t phiTrklt = fTracklet->GetYfit(1);
+    phiTrklt += tilt*tht;
+    Double_t dphi((phi-phiTrklt)/(1-phi*phiTrklt));
     Double_t dtht((tht-fTracklet->GetZfit(1))/(1-tht*fTracklet->GetZfit(1)));
-    ((TH2I*)arr->At(4))->Fill(phi, TMath::ATan(dphi));
+    ((TH3S*)arr->At(4))->Fill(phi, TMath::ATan(dphi), sgm[fSegmentLevel]);
 
     if(DebugLevel()>=1){
       UChar_t err(fTracklet->GetErrorMsg());
@@ -610,7 +615,7 @@ TH1* AliTRDresolution::PlotTrackIn(const AliTRDtrackV1 *track)
     break;
   }
   if(!fTracklet || TMath::Abs(x-fTracklet->GetX())>1.e-3){
-    AliWarning("Tracklet did not match Track.");
+    AliDebug(1, "Tracklet did not match Track.");
     return NULL;
   }
   Int_t sgm[3];
@@ -785,7 +790,7 @@ TH1* AliTRDresolution::PlotTrackOut(const AliTRDtrackV1 *track)
     break;
   }
   if(!fTracklet || TMath::Abs(x-fTracklet->GetX())>1.e-3){
-    AliWarning("Tracklet did not match Track position.");
+    AliDebug(1, "Tracklet did not match Track position.");
     return NULL;
   }
   Int_t sgm[3];
@@ -2273,7 +2278,7 @@ void AliTRDresolution::AdjustF1(TH1 *h, TF1 *f)
 }
 
 //________________________________________________________
-TObjArray* AliTRDresolution::BuildMonitorContainerCluster(const char* name, Bool_t expand)
+TObjArray* AliTRDresolution::BuildMonitorContainerCluster(const char* name, Bool_t expand, Float_t range)
 {
 // Build performance histograms for AliTRDcluster.vs TRD track or MC
 //  - y reziduals/pulls
@@ -2285,12 +2290,13 @@ TObjArray* AliTRDresolution::BuildMonitorContainerCluster(const char* name, Bool
   // tracklet resolution/pull in y direction
   snprintf(hname, 100, "%s_%s_Y", GetNameId(), name);
   snprintf(htitle, 300, "Y res for \"%s\" @ %s;tg(#phi);#Delta y [cm];%s", GetNameId(), name, fgkResYsegmName[fSegmentLevel]);
+  Float_t rr = range<0.?fDyRange:range;
   if(!(h = (TH3S*)gROOT->FindObject(hname))){
     Int_t nybins=fgkNresYsegm[fSegmentLevel];
     if(expand) nybins*=2;
     h = new TH3S(hname, htitle, 
                  48, -.48, .48,            // phi
-                 60, -fDyRange, fDyRange,  // dy
+                 60, -rr, rr,              // dy
                  nybins, -0.5, nybins-0.5);// segment
   } else h->Reset();
   arr->AddAt(h, 0);
@@ -2311,15 +2317,15 @@ TObjArray* AliTRDresolution::BuildMonitorContainerTracklet(const char* name, Boo
 //  - y reziduals/pulls
 //  - z reziduals/pulls
 //  - phi reziduals
-  TObjArray *arr = BuildMonitorContainerCluster(name, expand); 
+  TObjArray *arr = BuildMonitorContainerCluster(name, expand, 0.05); 
   arr->Expand(5);
   TH1 *h(NULL); char hname[100], htitle[300];
 
   // tracklet resolution/pull in z direction
   snprintf(hname, 100, "%s_%s_Z", GetNameId(), name);
-  snprintf(htitle, 300, "Z res for \"%s\" @ %s;tg(#theta);#Delta z [cm];row cross", GetNameId(), name);
-  if(!(h = (TH3S*)gROOT->FindObject(hname))){
-    h = new TH3S(hname, htitle, 50, -1., 1., 100, -1.5, 1.5, 2, -0.5, 1.5);
+  snprintf(htitle, 300, "Z res for \"%s\" @ %s;tg(#theta);#Delta z [cm]", GetNameId(), name);
+  if(!(h = (TH2S*)gROOT->FindObject(hname))){
+    h = new TH2S(hname, htitle, 50, -1., 1., 100, -.05, .05);
   } else h->Reset();
   arr->AddAt(h, 2);
   snprintf(hname, 100, "%s_%s_Zpull", GetNameId(), name);
@@ -2333,9 +2339,10 @@ TObjArray* AliTRDresolution::BuildMonitorContainerTracklet(const char* name, Boo
 
   // tracklet to track phi resolution
   snprintf(hname, 100, "%s_%s_PHI", GetNameId(), name);
-  snprintf(htitle, 300, "#Phi res for \"%s\" @ %s;tg(#phi);#Delta #phi [rad];entries", GetNameId(), name);
-  if(!(h = (TH2I*)gROOT->FindObject(hname))){
-    h = new TH2I(hname, htitle, 21, -.33, .33, 100, -.5, .5);
+  snprintf(htitle, 300, "#Phi res for \"%s\" @ %s;tg(#phi);#Delta #phi [rad];%s", GetNameId(), name, fgkResYsegmName[fSegmentLevel]);
+  Int_t nsgms=fgkNresYsegm[fSegmentLevel];
+  if(!(h = (TH3S*)gROOT->FindObject(hname))){
+    h = new TH3S(hname, htitle, 48, -.48, .48, 100, -.5, .5, nsgms, -0.5, nsgms-0.5);
   } else h->Reset();
   arr->AddAt(h, 4);
 
index 73df3f1d501b9d5903ccaf09bf3b8e138d12e279..c3bcb6a37bb1ac63323525b5a543f385494b7dba 100644 (file)
@@ -60,6 +60,11 @@ public:
     ,kTrkltToMC  = 5
     ,kNOutSlots  = 4
   };
+  enum ETRDresolutionSegmentation {
+     kSector    = 0
+    ,kStack
+    ,kDetector
+  };
 
   AliTRDresolution();
   AliTRDresolution(char* name);
@@ -114,7 +119,7 @@ private:
   AliTRDresolution& operator=(const AliTRDresolution&);
 
   void    AdjustF1(TH1 *h, TF1 *f);
-  TObjArray*  BuildMonitorContainerCluster(const char* name, Bool_t expand=kFALSE);
+  TObjArray*  BuildMonitorContainerCluster(const char* name, Bool_t expand=kFALSE, Float_t range=-1.);
   TObjArray*  BuildMonitorContainerTracklet(const char* name, Bool_t expand=kFALSE);
   TObjArray*  BuildMonitorContainerTrack(const char* name);
   void    GetLandauMpvFwhm(TF1 * const f, Float_t &mpv, Float_t &xm, Float_t &xM);
index db53a00a22a7ffb5f813ed8f767ad1de380bb773..b74a56e19e9abbb45862baec8dda389f826f2684 100644 (file)
@@ -25,7 +25,7 @@ void AddTRDresolution(AliAnalysisManager *mgr, Int_t map, AliAnalysisDataContain
     res->SetMCdata(mgr->GetMCtruthEventHandler());
     res->SetPostProcess(kFALSE);
     res->SetDebugLevel(0);
-    //if(itq==0) res->SetSegmentationLevel(1);
+    if(itq==0) res->SetSegmentationLevel(AliTRDresolution::kDetector);
     // use these settings if you know what you are doing !
     //res->SetTrackRefit(); 
     //res->SetPtThreshold(0.);
index 1fdacd4252965edd11f9feed29619eb6a25f2aa8..26fe457ce3259704fcbb5f6d5481f2245bd1b131 100644 (file)
@@ -95,7 +95,7 @@ AliTRDReconstructor::AliTRDReconstructor()
   // write clusters [cw]
   SETFLG(fSteerParam, kWriteClusters);
   // track seeding (stand alone tracking) [sa]
-  SETFLG(fSteerParam, kSeeding);
+  //SETFLG(fSteerParam, kSeeding);
   // Cluster radial correction during reconstruction [cc]
   //SETFLG(fSteerParam, kClRadialCorr);
   memset(fDebugStream, 0, sizeof(TTreeSRedirector *) * AliTRDrecoParam::kTRDreconstructionTasks);
index 4e136e899a005b98c7313f12fa9415da3996935e..1f50533b946f4bcaceefd18bfbbef0dccbaf2de1 100644 (file)
@@ -47,6 +47,7 @@
 #include "Cal/AliTRDCalChamberStatus.h"
 #include "Cal/AliTRDCalPadStatus.h"
 #include "Cal/AliTRDCalSingleChamberStatus.h"
+#include "Cal/AliTRDCalTrkAttach.h"
 
 ClassImp(AliTRDcalibDB)
 
@@ -102,6 +103,7 @@ AliTRDcalibDB::AliTRDcalibDB()
   ,fPRFhi(0)
   ,fPRFwid(0)
   ,fPRFpad(0)
+  ,fPIDResponse(NULL)
 {
   //
   // Default constructor
@@ -131,6 +133,7 @@ AliTRDcalibDB::AliTRDcalibDB(const AliTRDcalibDB &c)
   ,fPRFhi(0)
   ,fPRFwid(0)
   ,fPRFpad(0)
+  ,fPIDResponse(NULL)
 {
   //
   // Copy constructor (not that it make any sense for a singleton...)
@@ -172,6 +175,7 @@ AliTRDcalibDB::~AliTRDcalibDB()
     delete [] fPRFsmp;
     fPRFsmp = 0;
   }
+  if(fPIDResponse) delete fPIDResponse;
 
   Invalidate();
 
@@ -256,10 +260,15 @@ const TObject *AliTRDcalibDB::GetCachedCDBObject(Int_t id)
     case kIDPIDLQ : 
       return CacheCDBEntry(kIDPIDLQ             ,"TRD/Calib/PIDLQ"); 
       break;
+    case kIDPIDLQ1D:
+      return CacheCDBEntry(kIDPIDLQ1D           ,"TRD/Calib/PIDLQ1D");
+      break;
     case kIDRecoParam : 
-      return CacheCDBEntry(kIDRecoParam             ,"TRD/Calib/RecoParam"); 
+      return CacheCDBEntry(kIDRecoParam         ,"TRD/Calib/RecoParam"); 
+      break;
+    case kIDAttach : 
+      return CacheCDBEntry(kIDAttach            ,"TRD/Calib/TrkAttach"); 
       break;
-
   }
 
   return 0;
@@ -1148,6 +1157,27 @@ const AliTRDCalPID *AliTRDcalibDB::GetPIDObject(AliTRDpidUtil::ETRDPIDMethod met
 
 }
 
+//_____________________________________________________________________________
+AliTRDPIDResponse *AliTRDcalibDB::GetPIDResponse(AliTRDPIDResponse::ETRDPIDMethod method){
+  if(!fPIDResponse){
+    fPIDResponse = new AliTRDPIDResponse;
+    // Load Reference Histos from OCDB
+    fPIDResponse->SetPIDmethod(method);
+    fPIDResponse->Load(dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDPIDLQ1D)));
+  }
+  return fPIDResponse;
+}
+
+//_____________________________________________________________________________
+const AliTRDCalTrkAttach* AliTRDcalibDB::GetAttachObject()
+{
+  //
+  // Returns the object storing likelihood distributions for cluster to track attachment
+  //
+  return dynamic_cast<const AliTRDCalTrkAttach*>(GetCachedCDBObject(kIDAttach));
+}
+
+
 //_____________________________________________________________________________
 const AliTRDCalMonitoring *AliTRDcalibDB::GetMonitoringObject()
 {
index 8b6cd8bf4db34fd77ac061a91f4a96163da6b927..25d7f660466952cd0537a77a822762c0d8c5bf62 100644 (file)
 #include "AliTRDpidUtil.h"
 #endif
 
+#ifndef ALITRDPIDRESPONSE_H
+#include "AliTRDPIDResponse.h"
+#endif
+
 class AliCDBEntry;
 
 class AliTRDrecoParam;
+class AliTRDCalTrkAttach;
 class AliTRDCalPID;
 class AliTRDCalMonitoring;
 class AliTRDCalROC;
@@ -80,6 +85,7 @@ class AliTRDcalibDB : public TObject {
   Char_t                              GetPadStatus(Int_t det, Int_t col, Int_t row);
   AliTRDCalSingleChamberStatus       *GetPadStatusROC(Int_t det);
   AliTRDrecoParam*                    GetRecoParam(Int_t *eventtype);
+  AliTRDPIDResponse                  *GetPIDResponse(AliTRDPIDResponse::ETRDPIDMethod m);
 
   Char_t                              GetChamberStatus(Int_t det);
 
@@ -94,6 +100,7 @@ class AliTRDcalibDB : public TObject {
 
   const AliTRDCalMonitoring          *GetMonitoringObject();
   const AliTRDCalPID                 *GetPIDObject(AliTRDpidUtil::ETRDPIDMethod m);
+  const AliTRDCalTrkAttach           *GetAttachObject();
 
   // Related functions, these depend on calibration data
          Int_t                        PadResponse(Double_t signal, Double_t dist
@@ -117,11 +124,13 @@ class AliTRDcalibDB : public TObject {
        , kIDSuperModulePos
        , kIDPIDNN
        , kIDPIDLQ
+       , kIDPIDLQ1D
        , kIDRecoParam
        , kIDMonitoringData
        , kIDChamberStatus
        , kIDPadStatus
        , kIDDCS
+       , kIDAttach
        , kCDBCacheSize };         // IDs of cached objects
 
   const TObject *GetCachedCDBObject(Int_t id);
@@ -146,6 +155,7 @@ class AliTRDcalibDB : public TObject {
   Float_t               fPRFhi;                     //  Higher boundary of the PRF
   Float_t               fPRFwid;                    //  Bin width of the sampled PRF
   Int_t                 fPRFpad;                    //  Distance to next pad in PRF
+  AliTRDPIDResponse    *fPIDResponse;               //  TRD PID Response function
   
  private:
 
@@ -154,7 +164,7 @@ class AliTRDcalibDB : public TObject {
   AliTRDcalibDB &operator=(const AliTRDcalibDB &c); 
   virtual ~AliTRDcalibDB();
 
-  ClassDef(AliTRDcalibDB, 4)                         //  Provides central access to the CDB
+  ClassDef(AliTRDcalibDB, 5)                         //  Provides central access to the CDB
 
 };
 
index 6373fc462b9a478ba31db8b0534f05ae9b10c1cd..244497d81e414a43ab043fa663e46c3b039cfa9a 100644 (file)
@@ -17,6 +17,7 @@ class AliTRDtrackletWord;
 
 class AliTRDcluster : public AliCluster {
   friend class AliHLTTRDCluster;
+  friend class AliTRDtrackletOflHelper;
 
 public:
   enum ETRDclusterStatus { 
@@ -115,6 +116,8 @@ protected:
   Float_t fQ;              //  Amplitude 
   Float_t fCenter;         //  Center of the cluster relative to the pad 
 
+  inline void Update(Short_t adc[7]);
+
 private:
 
          Float_t   GetDYcog(const Double_t *const y1=0x0, const Double_t *const y2=0x0);
@@ -129,6 +132,15 @@ private:
 
 };
 
+//___________________________________________________
+inline void AliTRDcluster::Update(Short_t adc[7]) 
+{
+  memcpy(fSignals, adc, 7*sizeof(Short_t));
+  fQ = Float_t(adc[2]+adc[3]+adc[4]);
+  if(IsRPhiMethod(AliTRDcluster::kLUT)) GetDYlut();
+  else GetDYcog();
+}
+
 //________________________________________________
 inline Bool_t AliTRDcluster::IsRPhiMethod(ETRDclusterStatus m) const
 {
index 6801e09b41e8ef002f0a65f8be2dbd4478237ec3..60bad65c4d9d82b9b0264682e782f03a56491e3a 100644 (file)
@@ -587,9 +587,9 @@ Bool_t AliTRDclusterizer::Raw2ClustersChamber(AliRawReader *rawReader)
   else
     fRawStream->SetReader(rawReader);
 
-  if(fReconstructor->IsHLT()){
+  //if(fReconstructor->IsHLT()){
     fRawStream->DisableErrorStorage();
-  }
+  //}
 
   // register tracklet array for output
   if (fReconstructor->IsProcessingTracklets())
@@ -1185,14 +1185,78 @@ void AliTRDclusterizer::TailCancelation(const AliTRDrecoParam* const recoParam)
       }
       
       // Apply the tail cancelation via the digital filter
-      DeConvExp(fDigits->GetDataAddress(iRow,iCol),fTimeTotal,nexp);
-      
+      //DeConvExp(fDigits->GetDataAddress(iRow,iCol),fTimeTotal,nexp);
+      ApplyTCTM(fDigits->GetDataAddress(iRow,iCol),fTimeTotal,nexp);
     } // while irow icol
 
   return;
 
 }
 
+
+//_____________________________________________________________________________
+void AliTRDclusterizer::ApplyTCTM(Short_t *const arr, const Int_t nTime, const Int_t nexp) 
+{
+  //
+  // Steer tail cancellation
+  //
+
+
+  switch(nexp) {
+  case 1:
+  case 2:
+    DeConvExp(arr,nTime,nexp);
+    break;
+  case -1:
+    ConvExp(arr,nTime);
+    break;
+  case -2:
+    DeConvExp(arr,nTime,1);
+    ConvExp(arr,nTime);
+    break;
+  default:
+    break;
+  }
+}
+
+
+//_____________________________________________________________________________
+void AliTRDclusterizer::ConvExp(Short_t *const arr, const Int_t nTime)
+{
+  //
+  // Tail maker
+  //
+
+  // Initialization (coefficient = alpha, rates = lambda)
+  Float_t slope = 1.0;
+  Float_t coeff = 0.5;
+  Float_t rate;
+
+  Double_t par[4];
+  fReconstructor->GetRecoParam()->GetTCParams(par);
+  slope = par[1];
+  coeff = par[3];  
+
+  Double_t dt = 0.1;
+
+  rate = TMath::Exp(-dt/(slope));
+   
+  Float_t reminder =  .0;
+  Float_t correction = 0.0;
+  Float_t result     = 0.0;
+
+  for (int i = nTime-1; i >= 0; i--) {
+
+    result = arr[i] + correction - fBaseline;    // No rescaling
+    arr[i] = (Short_t)(result + fBaseline + 0.5f);
+
+    correction = 0.0;
+    
+    correction += reminder = rate * (reminder + coeff * result);
+  }
+}
+
+
 //_____________________________________________________________________________
 void AliTRDclusterizer::DeConvExp(Short_t *const arr, const Int_t nTime, const Int_t nexp)
 {
index 7a9414b6f76792502abe440734b2187a88f290e8..83ff093c05a35c64f02e3e304878e1bd60bab7b2 100644 (file)
@@ -111,7 +111,9 @@ class AliTRDclusterizer : public TNamed
 
 protected:
 
+  void             ApplyTCTM(Short_t *const arr, const Int_t nTime, const Int_t nexp);
   void             DeConvExp (Short_t *const arr, const Int_t nTime, const Int_t nexp);
+  void             ConvExp(Short_t *const arr, const Int_t nTime);
   void             TailCancelation(const AliTRDrecoParam* const recoParam);
 
   Float_t          Unfold(Double_t eps, Int_t layer, const Double_t *const padSignal) const;
index 9ff9cd06c37a64b88250afac104485032ff04484..97af520c86c655da68209df24db29ce9e2f78768 100644 (file)
@@ -61,7 +61,7 @@ AliTRDrecoParam::AliTRDrecoParam()
   ,fkTrackLikelihood(-15.)
   ,fNumberOfConfigs(3)
   ,fFlags(0)
-  ,fRawStreamVersion("REAL")
+  ,fRawStreamVersion("DEFAULT")
   ,fMinMaxCutSigma(4.)
   ,fMinLeftRightCutSigma(8.)
   ,fClusMaxThresh(4.5)
@@ -94,7 +94,7 @@ AliTRDrecoParam::AliTRDrecoParam()
   memset(fPIDThreshold, 0, AliTRDCalPID::kNMom*sizeof(Double_t));
   memset(fStreamLevel, 0, kTRDreconstructionTasks * sizeof(Int_t));
 
-  SetPIDNeuralNetwork();
+  SetPIDmethod(AliTRDPIDResponse::kLQ1D);
   SetEightSlices();
   SetImproveTracklets();
   SetLUT();
index a12b902b3c316da904a617c712e3de0a4fb67f72..86325b1f1d1075cbd867b45a613b6434f640415e 100644 (file)
 #ifndef ALIDETECTORRECOPARAM_H
 #include "AliDetectorRecoParam.h"
 #endif
+
 #ifndef ALITRDCALPID_H
 #include "Cal/AliTRDCalPID.h"
 #endif
 
+#ifndef ALITRDPIDRESPONSE_H
+#include "AliTRDPIDResponse.h"
+#endif
+
 class TString;
 
 class AliTRDrecoParam : public AliDetectorRecoParam
@@ -57,6 +62,7 @@ public:
   Double_t GetNSigmaClusters() const        { return fkNSigmaClusters; }
   Double_t GetFindableClusters() const      { return fkFindable; }
   inline Int_t    GetPIDLQslices() const;
+  inline AliTRDPIDResponse::ETRDPIDMethod GetPIDmethod() const;
   Double_t GetMaxTheta() const              { return fkMaxTheta; }
   Double_t GetMaxPhi() const                { return fkMaxPhi;   }
   Double_t GetPlaneQualityThreshold() const { return fkPlaneQualityThreshold; }
@@ -109,6 +115,7 @@ public:
   void     SetLUT(Bool_t b=kTRUE)                             {if(b) SETBIT(fFlags, kLUT); else CLRBIT(fFlags, kLUT);}
   void     SetGAUS(Bool_t b=kTRUE)                            {if(b) SETBIT(fFlags, kGAUS); else CLRBIT(fFlags, kGAUS);}
   void     SetPIDNeuralNetwork(Bool_t b=kTRUE)                {if(b) SETBIT(fFlags, kSteerPID); else CLRBIT(fFlags, kSteerPID);}
+  inline void  SetPIDmethod(AliTRDPIDResponse::ETRDPIDMethod method);
   void     SetPIDLQslices(Int_t s);
   void     SetTailCancelation(Bool_t b=kTRUE)                 {if(b) SETBIT(fFlags, kTailCancelation); else CLRBIT(fFlags, kTailCancelation);}
   void     SetXenon(Bool_t b = kTRUE)                         {if(b) CLRBIT(fFlags, kDriftGas); else SETBIT(fFlags, kDriftGas);}
@@ -177,7 +184,7 @@ private:
   // Reconstruction Options for TRD reconstruction
   Int_t     fStreamLevel[kTRDreconstructionTasks]; // Stream Level
   Long64_t  fFlags;                  // option Flags
-  
+
   // Raw Reader Params
   TString   fRawStreamVersion;       // Raw Reader version
 
@@ -253,4 +260,32 @@ inline Int_t AliTRDrecoParam::GetPIDLQslices() const
   return TESTBIT(fFlags, kLQ2D) ? 2 : 1;
 }
 
+//___________________________________________________
+inline AliTRDPIDResponse::ETRDPIDMethod AliTRDrecoParam::GetPIDmethod() const
+{
+  AliTRDPIDResponse::ETRDPIDMethod method = AliTRDPIDResponse::kLQ1D;
+  if(IsPIDNeuralNetwork()) method = AliTRDPIDResponse::kNN;
+  else if(TESTBIT(fFlags, kLQ2D)) method = AliTRDPIDResponse::kLQ2D;
+  return method;
+}
+
+//___________________________________________________
+inline void  AliTRDrecoParam::SetPIDmethod(AliTRDPIDResponse::ETRDPIDMethod method)
+{
+  switch(method){
+  case AliTRDPIDResponse::kLQ2D:
+    CLRBIT(fFlags, kSteerPID); 
+    SETBIT(fFlags, kLQ2D);
+    break;
+  case AliTRDPIDResponse::kNN:
+    SETBIT(fFlags, kSteerPID); 
+    break;
+  case AliTRDPIDResponse::kLQ1D:
+  default:
+    CLRBIT(fFlags, kSteerPID); 
+    CLRBIT(fFlags, kLQ2D);
+    break;
+  }
+}
+
 #endif
index 3061dcd826838582246031483ba42f7c66ff596b..a15737840281a4351024fec1fe0b44c0d0db201b 100644 (file)
@@ -36,7 +36,8 @@
 ////////////////////////////////////////////////////////////////////////////
 
 #include "TMath.h"
-#include <TTreeStream.h>
+#include "TTreeStream.h"
+#include "TGraphErrors.h"
 
 #include "AliLog.h"
 #include "AliMathBase.h"
@@ -45,6 +46,7 @@
 
 #include "AliTRDReconstructor.h"
 #include "AliTRDpadPlane.h"
+#include "AliTRDtransform.h"
 #include "AliTRDcluster.h"
 #include "AliTRDseedV1.h"
 #include "AliTRDtrackV1.h"
@@ -54,7 +56,9 @@
 #include "AliTRDtrackerV1.h"
 #include "AliTRDrecoParam.h"
 #include "AliTRDCommonParam.h"
+#include "AliTRDtrackletOflHelper.h"
 
+#include "Cal/AliTRDCalTrkAttach.h"
 #include "Cal/AliTRDCalPID.h"
 #include "Cal/AliTRDCalROC.h"
 #include "Cal/AliTRDCalDet.h"
@@ -483,7 +487,7 @@ Float_t AliTRDseedV1::GetAnodeWireOffset(Float_t zt)
 
 
 //____________________________________________________________________
-Float_t AliTRDseedV1::GetCharge(Bool_t useOutliers)
+Float_t AliTRDseedV1::GetCharge(Bool_t useOutliers) const
 {
 // Computes total charge attached to tracklet. If "useOutliers" is set clusters 
 // which are not in chamber are also used (default false)
@@ -538,6 +542,15 @@ Bool_t AliTRDseedV1::GetEstimatedCrossPoint(Float_t &x, Float_t &z) const
   return kTRUE;
 }
 
+//____________________________________________________________________
+Float_t AliTRDseedV1::GetdQdl() const
+{
+// Calculate total charge / tracklet length for 1D PID
+//
+  Float_t Q = GetCharge(kTRUE);
+  return Q/TMath::Sqrt(1. + fYref[1]*fYref[1] + fZref[1]*fZref[1]);
+}
+
 //____________________________________________________________________
 Float_t AliTRDseedV1::GetdQdl(Int_t ic, Float_t *dl) const
 {
@@ -629,6 +642,7 @@ Float_t AliTRDseedV1::GetMomentum(Float_t *err) const
   return p;
 }
 
+
 //____________________________________________________________________
 Float_t AliTRDseedV1::GetOccupancyTB() const
 {
@@ -964,8 +978,9 @@ void AliTRDseedV1::SetPadPlane(AliTRDpadPlane * const p)
 }
 
 
+
 //____________________________________________________________________
-Bool_t AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *const chamber, Bool_t tilt)
+Bool_t  AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *const chamber, Bool_t tilt, Bool_t chgPos, Int_t ev)
 {
 //
 // Projective algorithm to attach clusters to seeding tracklets. The following steps are performed :
@@ -982,7 +997,7 @@ Bool_t      AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *const chamber, Bool_t
 //  - true    : if tracklet found successfully. Failure can happend because of the following:
 //      -
 // Detailed description
-//     
+//  
 // We start up by defining the track direction in the xy plane and roads. The roads are calculated based
 // on tracking information (variance in the r-phi direction) and estimated variance of the standard 
 // clusters (see AliTRDcluster::SetSigmaY2()) corrected for tilt (see GetCovAt()). From this the road is
@@ -992,7 +1007,9 @@ Bool_t     AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *const chamber, Bool_t
 // END_LATEX
 // 
 // Author : Alexandru Bercuci <A.Bercuci@gsi.de>
-// Debug  : level >3
+// Debug  : level = 2 for calibration
+//          level = 3 for visualization in the track SR
+//          level = 4 for full visualization including digit level
 
   const AliTRDrecoParam* const recoParam = fkReconstructor->GetRecoParam(); //the dynamic cast in GetRecoParam is slow, so caching the pointer to it
 
@@ -1000,43 +1017,74 @@ Bool_t  AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *const chamber, Bool_t
     AliError("Tracklets can not be used without a valid RecoParam.");
     return kFALSE;
   }
+  AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
+  if (!calibration) {
+    AliError("No access to calibration data");
+    return kFALSE;
+  }
+  // Retrieve the CDB container class with the parametric likelihood
+  const AliTRDCalTrkAttach *attach = calibration->GetAttachObject();
+  if (!attach) {
+    AliError("No usable AttachClusters calib object.");
+    return kFALSE;
+  }
+
   // Initialize reco params for this tracklet
   // 1. first time bin in the drift region
   Int_t t0 = 14;
   Int_t kClmin = Int_t(recoParam->GetFindableClusters()*AliTRDtrackerV1::GetNTimeBins());
+  Int_t kTBmin = 4;
 
-  Double_t sysCov[5]; recoParam->GetSysCovMatrix(sysCov);      
+  Double_t sysCov[5]; recoParam->GetSysCovMatrix(sysCov); 
   Double_t s2yTrk= fRefCov[0], 
            s2yCl = 0., 
            s2zCl = GetPadLength()*GetPadLength()/12., 
            syRef = TMath::Sqrt(s2yTrk),
            t2    = GetTilt()*GetTilt();
   //define roads
-  Double_t kroady = 1., //recoParam->GetRoad1y();
-           kroadz = GetPadLength() * recoParam->GetRoadzMultiplicator() + 1.;
+  const Double_t kroady = 3.; //recoParam->GetRoad1y();
+  const Double_t kroadz = GetPadLength() * recoParam->GetRoadzMultiplicator() + 1.;
   // define probing cluster (the perfect cluster) and default calibration
   Short_t sig[] = {0, 0, 10, 30, 10, 0,0};
   AliTRDcluster cp(fDet, 6, 75, 0, sig, 0);
   if(fkReconstructor->IsHLT()) cp.SetRPhiMethod(AliTRDcluster::kCOG);
   if(!IsCalibrated()) Calibrate();
 
-  AliDebug(4, "");
-  AliDebug(4, Form("syKalman[%f] rY[%f] rZ[%f]", syRef, kroady, kroadz));
+  Int_t kroadyShift(0);
+  Float_t bz(AliTrackerBase::GetBz());
+  if(TMath::Abs(bz)>2.){
+    if(bz<0.) kroadyShift = chgPos ? +1 : -1;
+    else kroadyShift = chgPos ? -1 : +1;
+  }
+  AliDebug(4, Form("\n       syTrk[cm]=%4.2f dydxTrk[deg]=%+6.2f rs[%d] Chg[%c] rY[cm]=%4.2f rZ[cm]=%5.2f TC[%c]", syRef, TMath::ATan(fYref[1])*TMath::RadToDeg(), kroadyShift, chgPos?'+':'-', kroady, kroadz, tilt?'y':'n'));
+  Double_t phiTrk(TMath::ATan(fYref[1])),
+           thtTrk(TMath::ATan(fZref[1]));
 
   // working variables
   const Int_t kNrows = 16;
   const Int_t kNcls  = 3*kNclusters; // buffer size
-  AliTRDcluster *clst[kNrows][kNcls];
+  TObjArray clst[kNrows];
   Bool_t blst[kNrows][kNcls];
-  Double_t cond[4], dx, dy, yt, zt, yres[kNrows][kNcls];
+  Double_t cond[4],
+           dx, dy, dz,
+           yt, zt,
+           zc[kNrows],
+           xres[kNrows][kNcls], yres[kNrows][kNcls], zres[kNrows][kNcls], s2y[kNrows][kNcls];
   Int_t idxs[kNrows][kNcls], ncl[kNrows], ncls = 0;
   memset(ncl, 0, kNrows*sizeof(Int_t));
+  memset(zc, 0, kNrows*sizeof(Double_t));
+  memset(idxs, 0, kNrows*kNcls*sizeof(Int_t));
+  memset(xres, 0, kNrows*kNcls*sizeof(Double_t));
   memset(yres, 0, kNrows*kNcls*sizeof(Double_t));
+  memset(zres, 0, kNrows*kNcls*sizeof(Double_t));
+  memset(s2y, 0, kNrows*kNcls*sizeof(Double_t));
   memset(blst, 0, kNrows*kNcls*sizeof(Bool_t));   //this is 8 times faster to memset than "memset(clst, 0, kNrows*kNcls*sizeof(AliTRDcluster*))"
 
-  // Do cluster projection
-  AliTRDcluster *c = NULL;
-  AliTRDchamberTimeBin *layer = NULL;
+  Double_t roady(0.), s2Mean(0.), sMean(0.); Int_t ns2Mean(0);
+
+  // Do cluster projection and pick up cluster candidates
+  AliTRDcluster *c(NULL);
+  AliTRDchamberTimeBin *layer(NULL);
   Bool_t kBUFFER = kFALSE;
   for (Int_t it = 0; it < kNtb; it++) {
     if(!(layer = chamber->GetTB(it))) continue;
@@ -1045,37 +1093,44 @@ Bool_t  AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *const chamber, Bool_t
     dx   = fX0 - layer->GetX();
     yt = fYref[0] - fYref[1] * dx;
     zt = fZref[0] - fZref[1] * dx;
-    // get standard cluster error corrected for tilt
+    // get standard cluster error corrected for tilt if selected
     cp.SetLocalTimeBin(it);
     cp.SetSigmaY2(0.02, fDiffT, fExB, dx, -1./*zt*/, fYref[1]);
-    s2yCl = (cp.GetSigmaY2() + sysCov[0] + t2*s2zCl)/(1.+t2);
-    // get estimated road
-    kroady = 3.*TMath::Sqrt(12.*(s2yTrk + s2yCl));
-
-    AliDebug(5, Form("  %2d x[%f] yt[%f] zt[%f]", it, dx, yt, zt));
-
-    AliDebug(5, Form("  syTrk[um]=%6.2f syCl[um]=%6.2f syClTlt[um]=%6.2f Ry[mm]=%f", 1.e4*TMath::Sqrt(s2yTrk), 1.e4*TMath::Sqrt(cp.GetSigmaY2()), 1.e4*TMath::Sqrt(s2yCl), 1.e1*kroady));
-
-    // select clusters
-    cond[0] = yt; cond[2] = kroady;
+    s2yCl = cp.GetSigmaY2() + sysCov[0]; if(!tilt) s2yCl = (s2yCl + t2*s2zCl)/(1.+t2);
+    if(TMath::Abs(it-12)<7){ s2Mean += cp.GetSigmaY2(); ns2Mean++;}
+    // get estimated road in r-phi direction
+    roady = TMath::Min(3.*TMath::Sqrt(12.*(s2yTrk + s2yCl)), kroady);
+
+    AliDebug(5, Form("\n"
+      "  %2d xd[cm]=%6.3f yt[cm]=%7.2f zt[cm]=%8.2f\n"
+      "      syTrk[um]=%6.2f syCl[um]=%6.2f syClTlt[um]=%6.2f\n"
+      "      Ry[mm]=%f"
+      , it, dx, yt, zt
+      , 1.e4*TMath::Sqrt(s2yTrk), 1.e4*TMath::Sqrt(cp.GetSigmaY2()+sysCov[0]), 1.e4*TMath::Sqrt(s2yCl)
+      , 1.e1*roady));
+
+    // get clusters from layer
+    cond[0] = yt/*+0.5*kroadyShift*kroady*/; cond[2] = roady;
     cond[1] = zt; cond[3] = kroadz;
-    Int_t n=0, idx[6];
-    layer->GetClusters(cond, idx, n, 6);
+    Int_t n=0, idx[6]; layer->GetClusters(cond, idx, n, 6);
     for(Int_t ic = n; ic--;){
       c  = (*layer)[idx[ic]];
-      dy = yt - c->GetY();
-      dy += tilt ? GetTilt() * (c->GetZ() - zt) : 0.;
-      // select clusters on a 3 sigmaKalman level
-/*      if(tilt && TMath::Abs(dy) > 3.*syRef){ 
-        printf("too large !!!\n");
-        continue;
-      }*/
+      dx = fX0 - c->GetX();
+      yt = fYref[0] - fYref[1] * dx;
+      zt = fZref[0] - fZref[1] * dx;
+      dz = zt - c->GetZ();
+      dy = yt - (c->GetY() + (tilt ? (GetTilt() * dz) : 0.));
       Int_t r = c->GetPadRow();
-      AliDebug(5, Form("   -> dy[%f] yc[%f] r[%d]", TMath::Abs(dy), c->GetY(), r));
-      clst[r][ncl[r]] = c;
+      clst[r].AddAtAndExpand(c, ncl[r]);
       blst[r][ncl[r]] = kTRUE;
       idxs[r][ncl[r]] = idx[ic];
+      zres[r][ncl[r]] = dz/GetPadLength();
       yres[r][ncl[r]] = dy;
+      xres[r][ncl[r]] = dx;
+      zc[r]           = c->GetZ();
+      // TODO temporary solution to avoid divercences in error parametrization
+      s2y[r][ncl[r]]  = TMath::Min(c->GetSigmaY2()+sysCov[0], 0.025); 
+      AliDebug(5, Form("   -> dy[cm]=%+7.4f yc[cm]=%7.2f row[%d] idx[%2d]", dy, c->GetY(), r, ncl[r]));
       ncl[r]++; ncls++;
 
       if(ncl[r] >= kNcls) {
@@ -1086,173 +1141,525 @@ Bool_t        AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *const chamber, Bool_t
     }
     if(kBUFFER) break;
   }
-  AliDebug(4, Form("Found %d clusters. Processing ...", ncls));
   if(ncls<kClmin){ 
     AliDebug(1, Form("CLUSTERS FOUND %d LESS THAN THRESHOLD %d.", ncls, kClmin));
     SetErrorMsg(kAttachClFound);
+    for(Int_t ir(kNrows);ir--;) clst[ir].Clear();
+    return kFALSE;
+  }
+  if(ns2Mean<kTBmin){
+    AliDebug(1, Form("CLUSTERS IN TimeBins %d LESS THAN THRESHOLD %d.", ns2Mean, kTBmin));
+    SetErrorMsg(kAttachClFound);
+    for(Int_t ir(kNrows);ir--;) clst[ir].Clear();
     return kFALSE;
   }
+  s2Mean /= ns2Mean; sMean = TMath::Sqrt(s2Mean);
+  //Double_t sRef(TMath::Sqrt(s2Mean+s2yTrk)); // reference error parameterization
+
+  // organize row candidates
+  Int_t idxRow[kNrows], nrc(0); Double_t zresRow[kNrows];
+  for(Int_t ir(0); ir<kNrows; ir++){
+    idxRow[ir]=-1; zresRow[ir] = 999.;
+    if(!ncl[ir]) continue;
+    // get mean z resolution
+    dz = 0.; for(Int_t ic = ncl[ir]; ic--;) dz += zres[ir][ic]; dz/=ncl[ir];
+    // insert row
+    idxRow[nrc] = ir; zresRow[nrc] = TMath::Abs(dz); nrc++;
+  }
+  AliDebug(4, Form("Found %d clusters in %d rows. Sorting ...", ncls, nrc));
+
+  // sort row candidates
+  if(nrc>=2){
+    if(nrc==2){
+      if(zresRow[0]>zresRow[1]){ // swap
+        Int_t itmp=idxRow[1]; idxRow[1] = idxRow[0]; idxRow[0] = itmp;
+        Double_t dtmp=zresRow[1]; zresRow[1] = zresRow[0]; zresRow[0] = dtmp;
+      }
+      if(TMath::Abs(idxRow[1] - idxRow[0]) != 1){
+        SetErrorMsg(kAttachRowGap);
+        AliDebug(2, Form("Rows attached not continuous. Select first candidate.\n"
+                    "       row[%2d] Ncl[%2d] <dz>[cm]=%+8.2f row[%2d] Ncl[%2d] <dz>[cm]=%+8.2f",
+                    idxRow[0], ncl[idxRow[0]], zresRow[0], idxRow[1], ncl[idxRow[1]], zresRow[1]));
+        nrc=1; idxRow[1] = -1; zresRow[1] = 999.;
+      }
+    } else {
+      Int_t idx0[kNrows];
+      TMath::Sort(nrc, zresRow, idx0, kFALSE);
+      nrc = 3; // select only maximum first 3 candidates
+      Int_t iatmp[] = {-1, -1, -1}; Double_t datmp[] = {999., 999., 999.};
+      for(Int_t irc(0); irc<nrc; irc++){
+        iatmp[irc] = idxRow[idx0[irc]];
+        datmp[irc] = zresRow[idx0[irc]];
+      }
+      idxRow[0] = iatmp[0]; zresRow[0] = datmp[0];
+      idxRow[1] = iatmp[1]; zresRow[1] = datmp[1];
+      idxRow[2] = iatmp[2]; zresRow[2] = datmp[2]; // temporary
+      if(TMath::Abs(idxRow[1] - idxRow[0]) != 1){
+        SetErrorMsg(kAttachRowGap);
+        AliDebug(2, Form("Rows attached not continuous. Turn on selection.\n"
+                    "row[%2d] Ncl[%2d] <dz>[cm]=%+8.2f\n"
+                    "row[%2d] Ncl[%2d] <dz>[cm]=%+8.2f\n"
+                    "row[%2d] Ncl[%2d] <dz>[cm]=%+8.2f",
+                    idxRow[0], ncl[idxRow[0]], zresRow[0],
+                    idxRow[1], ncl[idxRow[1]], zresRow[1],
+                    idxRow[2], ncl[idxRow[2]], zresRow[2]));
+        if(TMath::Abs(idxRow[0] - idxRow[2]) == 1){ // select second candidate
+          AliDebug(2, "Solved ! Remove second candidate.");
+          nrc = 2;
+          idxRow[1] = idxRow[2]; zresRow[1] = zresRow[2]; // swap
+          idxRow[2] = -1; zresRow[2] = 999.;              // remove
+        } else if(TMath::Abs(idxRow[1] - idxRow[2]) == 1){
+          if(ncl[idxRow[1]]+ncl[idxRow[2]] > ncl[idxRow[0]]){
+            AliDebug(2, "Solved ! Remove first candidate.");
+            nrc = 2;
+            idxRow[0] = idxRow[1]; zresRow[0] = zresRow[1]; // swap
+            idxRow[1] = idxRow[2]; zresRow[1] = zresRow[2]; // swap
+          } else {
+            AliDebug(2, "Solved ! Remove second and third candidate.");
+            nrc = 1;
+            idxRow[1] = -1; zresRow[1] = 999.; // remove
+            idxRow[2] = -1; zresRow[2] = 999.; // remove
+          }
+        } else {
+          AliDebug(2, "Unsolved !!! Remove second and third candidate.");
+          nrc = 1;
+          idxRow[1] = -1; zresRow[1] = 999.; // remove
+          idxRow[2] = -1; zresRow[2] = 999.; // remove
+        }
+      } else { // remove temporary candidate
+        nrc = 2;
+        idxRow[2] = -1; zresRow[2] = 999.;
+      }
+    }
+  }
+  AliDebug(4, Form("Sorted row candidates:\n"
+      "  row[%2d] Ncl[%2d] <dz>[cm]=%+8.2f row[%2d] Ncl[%2d] <dz>[cm]=%+8.2f"
+      , idxRow[0], ncl[idxRow[0]], zresRow[0], idxRow[1], ncl[idxRow[1]], zresRow[1]));
+
+  // initialize debug streamer
+  TTreeSRedirector *pstreamer(NULL);
+  if(recoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 3 && fkReconstructor->IsDebugStreaming()) pstreamer = fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker);
+  if(pstreamer){
+    // save config. for calibration
+    TVectorD vdy[2], vdx[2], vs2[2];
+    for(Int_t jr(0); jr<nrc; jr++){
+      Int_t ir(idxRow[jr]);
+      vdx[jr].ResizeTo(ncl[ir]); vdy[jr].ResizeTo(ncl[ir]); vs2[jr].ResizeTo(ncl[ir]);
+      for(Int_t ic(ncl[ir]); ic--;){
+        vdx[jr](ic) = xres[ir][ic];
+        vdy[jr](ic) = yres[ir][ic];
+        vs2[jr](ic) = s2y[ir][ic];
+      }
+    }
+    (*pstreamer) << "AttachClusters4"
+        << "r0="     << idxRow[0]
+        << "dz0="    << zresRow[0]
+        << "dx0="    << &vdx[0]
+        << "dy0="    << &vdy[0]
+        << "s20="    << &vs2[0]
+        << "r1="     << idxRow[1]
+        << "dz1="    << zresRow[1]
+        << "dx1="    << &vdx[1]
+        << "dy1="    << &vdy[1]
+        << "s21="    << &vs2[1]
+        << "\n";
+    vdx[0].Clear(); vdy[0].Clear(); vs2[0].Clear();
+    vdx[1].Clear(); vdy[1].Clear(); vs2[1].Clear();
+    if(recoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 4){    
+      Int_t idx(idxRow[1]);
+      if(idx<0){ 
+        for(Int_t ir(0); ir<kNrows; ir++){ 
+          if(clst[ir].GetEntries()>0) continue;
+          idx = ir;
+          break;
+        }
+      }
+      (*pstreamer) << "AttachClusters5"
+          << "c0.="    << &clst[idxRow[0]]
+          << "c1.="    << &clst[idx]
+          << "\n";
+    }
+  }
 
-  // analyze each row individualy
-  Bool_t kRowSelection(kFALSE);
-  Double_t mean[]={1.e3, 1.e3, 1.3}, syDis[]={1.e3, 1.e3, 1.3};
-  Int_t nrow[] = {0, 0, 0}, rowId[] = {-1, -1, -1}, nr = 0, lr=-1;
-  TVectorD vdy[3];
-  for(Int_t ir=0; ir<kNrows; ir++){
-    if(!(ncl[ir])) continue;
-    if(lr>0 && ir-lr != 1){ 
-      AliDebug(2, "Rows attached not continuous. Turn on selection."); 
-      kRowSelection=kTRUE;
+//=======================================================================================
+  // Analyse cluster topology
+  Double_t f[kNcls],     // likelihood factors for segments
+           r[2][kNcls],  // d(dydx) of tracklet candidate with respect to track
+           xm[2][kNcls], // mean <x>
+           ym[2][kNcls], // mean <y>
+           sm[2][kNcls], // mean <s_y>
+           s[2][kNcls],  // sigma_y
+           p[2][kNcls];  // prob of Gauss
+  memset(f, 0, kNcls*sizeof(Double_t));
+  Int_t index[2][kNcls], n[2][kNcls];
+  memset(n, 0, 2*kNcls*sizeof(Int_t));
+  Int_t mts(0), nts[2] = {0, 0};   // no of tracklet segments in row
+  AliTRDpadPlane *pp(AliTRDtransform::Geometry().GetPadPlane(fDet));
+  AliTRDtrackletOflHelper helper;
+  Int_t lyDet(AliTRDgeometry::GetLayer(fDet));
+  for(Int_t jr(0), n0(0); jr<nrc; jr++){
+    Int_t ir(idxRow[jr]);
+    // cluster segmentation
+    Bool_t kInit(kFALSE);
+    if(jr==0){ 
+      n0 = helper.Init(pp, &clst[ir]); kInit = kTRUE;
+      if(!n0 || (helper.ClassifyTopology() == AliTRDtrackletOflHelper::kNormal)){
+        nts[jr] = 1; memset(index[jr], 0, ncl[ir]*sizeof(Int_t));
+        n[jr][0] = ncl[ir];
+      }
+    }
+    if(!n[jr][0]){
+      nts[jr] = AliTRDtrackletOflHelper::Segmentation(ncl[ir], xres[ir], yres[ir], index[jr]);
+      for(Int_t ic(ncl[ir]);ic--;) n[jr][index[jr][ic]]++;
+    }
+    mts += nts[jr];
+    
+    // tracklet segment processing
+    for(Int_t its(0); its<nts[jr]; its++){
+      if(n[jr][its]<=2) {   // don't touch small segments
+        xm[jr][its] = 0.;ym[jr][its] = 0.;sm[jr][its] = 0.;
+        for(Int_t ic(ncl[ir]); ic--;){
+          if(its != index[jr][ic]) continue;
+          ym[jr][its] += yres[ir][ic];
+          xm[jr][its] += xres[ir][ic];
+          sm[jr][its] += TMath::Sqrt(s2y[ir][ic]);
+        }
+        if(n[jr][its]==2){ xm[jr][its] *= 0.5; ym[jr][its] *= 0.5; sm[jr][its] *= 0.5;}
+        xm[jr][its]= fX0 - xm[jr][its];
+        r[jr][its] = 0.;
+        s[jr][its] = 1.e-5;
+        p[jr][its] = 1.;
+        continue;
+      }
+      
+      // for longer tracklet segments
+      if(!kInit) n0 = helper.Init(pp, &clst[ir], index[jr], its);
+      Int_t n1 = helper.GetRMS(r[jr][its], ym[jr][its], s[jr][its], xm[jr][its]);
+      p[jr][its] = Double_t(n1)/n0;
+      sm[jr][its] = helper.GetSyMean();
+      
+      Double_t dxm= fX0 - xm[jr][its];
+      yt = fYref[0] - fYref[1]*dxm; 
+      zt = fZref[0] - fZref[1]*dxm;
+      // correct tracklet fit for tilt
+      ym[jr][its]+= GetTilt()*(zt - zc[ir]);
+      r[jr][its] += GetTilt() * fZref[1];
+      // correct tracklet fit for track position/inclination
+      ym[jr][its]= yt - ym[jr][its];
+      r[jr][its] = (r[jr][its] - fYref[1])/(1+r[jr][its]*fYref[1]);
+      // report inclination in radians
+      r[jr][its] = TMath::ATan(r[jr][its]);
+      if(jr) continue; // calculate only for first row likelihoods
+        
+      f[its] = attach->CookLikelihood(chgPos, lyDet, fPt, phiTrk, n[jr][its], ym[jr][its]/*sRef*/, r[jr][its]*TMath::RadToDeg(), s[jr][its]/sm[jr][its]);
+    }
+  }
+  AliDebug(4, Form("   Tracklet candidates: row[%2d] = %2d row[%2d] = %2d:", idxRow[0], nts[0], idxRow[1], nts[1]));
+  if(AliLog::GetDebugLevel("TRD", "AliTRDseedV1")>3){
+    for(Int_t jr(0); jr<nrc; jr++){
+      Int_t ir(idxRow[jr]);
+      for(Int_t its(0); its<nts[jr]; its++){
+        printf("  segId[%2d] row[%2d] Ncl[%2d] x[cm]=%7.2f dz[pu]=%4.2f dy[mm]=%+7.3f r[deg]=%+6.2f p[%%]=%6.2f s[um]=%7.2f\n",
+            its, ir, n[jr][its], xm[jr][its], zresRow[jr], 1.e1*ym[jr][its], r[jr][its]*TMath::RadToDeg(), 100.*p[jr][its], 1.e4*s[jr][its]);
+      }
+    }
+  }
+  if(!pstreamer && recoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 2 && fkReconstructor->IsDebugStreaming()) pstreamer = fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker);
+  if(pstreamer){
+    // save config. for calibration
+    TVectorD vidx, vn, vx, vy, vr, vs, vsm, vp, vf;
+    vidx.ResizeTo(ncl[idxRow[0]]+(idxRow[1]<0?0:ncl[idxRow[1]]));
+    vn.ResizeTo(mts);
+    vx.ResizeTo(mts);
+    vy.ResizeTo(mts);
+    vr.ResizeTo(mts);
+    vs.ResizeTo(mts);
+    vsm.ResizeTo(mts);
+    vp.ResizeTo(mts);
+    vf.ResizeTo(mts);
+    for(Int_t jr(0), jts(0), jc(0); jr<nrc; jr++){
+       Int_t ir(idxRow[jr]);
+       for(Int_t its(0); its<nts[jr]; its++, jts++){
+        vn[jts] = n[jr][its];
+        vx[jts] = xm[jr][its];
+        vy[jts] = ym[jr][its];
+        vr[jts] = r[jr][its];
+        vs[jts] = s[jr][its];
+        vsm[jts]= sm[jr][its];
+        vp[jts] = p[jr][its];
+        vf[jts] = jr?-1.:f[its];
+      }
+      for(Int_t ic(0); ic<ncl[ir]; ic++, jc++) vidx[jc] = index[jr][ic];
     }
+    (*pstreamer) << "AttachClusters3"
+        << "idx="    << &vidx
+        << "n="      << &vn
+        << "x="      << &vx
+        << "y="      << &vy
+        << "r="      << &vr
+        << "s="      << &vs
+        << "sm="     << &vsm
+        << "p="      << &vp
+        << "f="      << &vf
+        << "\n";
+  }
 
-    AliDebug(5, Form("  r[%d] n[%d]", ir, ncl[ir]));
-    // Evaluate truncated mean on the y direction
-    if(ncl[ir] < 4) continue;
-    AliMathBase::EvaluateUni(ncl[ir], yres[ir], mean[nr], syDis[nr], Int_t(ncl[ir]*.8));
-
-    // TODO check mean and sigma agains cluster resolution !!
-    AliDebug(4, Form("  m_%d[%+5.3f (%5.3fs)] s[%f]", nr, mean[nr], TMath::Abs(mean[nr]/syDis[nr]), syDis[nr]));
-    // remove outliers based on a 3 sigmaDistr level
-    Bool_t kFOUND = kFALSE;
-    for(Int_t ic = ncl[ir]; ic--;){
-      if(yres[ir][ic] - mean[nr] > 3. * syDis[nr]){ 
-        blst[ir][ic] = kFALSE; continue;
+//=========================================================
+  // Get seed tracklet segment
+  Int_t idx2[kNcls]; memset(idx2, 0, kNcls*sizeof(Int_t)); // seeding indexing
+  if(nts[0]>1) TMath::Sort(nts[0], f, idx2);
+  Int_t is(idx2[0]); // seed index
+  Int_t     idxTrklt[kNcls],
+            kts(0),
+            nTrklt(n[0][is]);
+  Double_t  fTrklt(f[is]),
+            rTrklt(r[0][is]), 
+            yTrklt(ym[0][is]), 
+            sTrklt(s[0][is]), 
+            smTrklt(sm[0][is]), 
+            xTrklt(xm[0][is]), 
+            pTrklt(p[0][is]);
+  memset(idxTrklt, 0, kNcls*sizeof(Int_t));
+  // check seed idx2[0] exit if not found
+  if(f[is]<1.e-2){
+    AliDebug(1, Form("Seed   seg[%d] row[%2d] n[%2d] f[%f]<0.01.", is, idxRow[0], n[0][is], f[is]));
+    SetErrorMsg(kAttachClAttach);
+    if(!pstreamer && recoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 1 && fkReconstructor->IsDebugStreaming()) pstreamer = fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker);
+    if(pstreamer){
+      UChar_t stat(0);
+      if(IsKink()) SETBIT(stat, 1);
+      if(IsStandAlone()) SETBIT(stat, 2);
+      if(IsRowCross()) SETBIT(stat, 3);
+      SETBIT(stat, 4); // set error bit
+      TVectorD vidx; vidx.ResizeTo(1); vidx[0] = is;
+      (*pstreamer) << "AttachClusters2"
+          << "stat="   << stat
+          << "ev="     << ev
+          << "chg="    << chgPos
+          << "det="    << fDet
+          << "x0="     << fX0
+          << "y0="     << fYref[0]
+          << "z0="     << fZref[0]
+          << "phi="    << phiTrk
+          << "tht="    << thtTrk
+          << "pt="     << fPt
+          << "s2Trk="  << s2yTrk
+          << "s2Cl="   << s2Mean
+          << "idx="    << &vidx
+          << "n="      << nTrklt
+          << "f="      << fTrklt
+          << "x="      << xTrklt
+          << "y="      << yTrklt
+          << "r="      << rTrklt
+          << "s="      << sTrklt
+          << "sm="     << smTrklt
+          << "p="      << pTrklt
+          << "\n";
+    }
+    return kFALSE;
+  }
+  AliDebug(2, Form("Seed   seg[%d] row[%2d] n[%2d] dy[%f] r[%+5.2f] s[%+5.2f] f[%5.3f]", is, idxRow[0], n[0][is], ym[0][is], r[0][is]*TMath::RadToDeg(), s[0][is]/sm[0][is], f[is]));
+
+  // save seeding segment in the helper
+  idxTrklt[kts++] = is;
+  helper.Init(pp, &clst[idxRow[0]], index[0], is);
+  AliTRDtrackletOflHelper test; // helper to test segment expantion
+  Float_t rcLikelihood(0.); SetBit(kRowCross, kFALSE);
+  Double_t dyRez[kNcls]; Int_t idx3[kNcls];
+  
+  //=========================================================
+  // Define filter parameters from OCDB
+  Int_t kNSgmDy[2]; attach->GetNsgmDy(kNSgmDy[0], kNSgmDy[1]);
+  Float_t kLikeMinRelDecrease[2]; attach->GetLikeMinRelDecrease(kLikeMinRelDecrease[0], kLikeMinRelDecrease[1]);
+  Float_t kRClikeLimit(attach->GetRClikeLimit());
+
+  //=========================================================
+  // Try attaching next segments from first row (if any)
+  if(nts[0]>1){
+    Int_t jr(0), ir(idxRow[jr]);
+    // organize  secondary sgms. in decreasing order of their distance from seed 
+    memset(dyRez, 0, nts[jr]*sizeof(Double_t));
+    for(Int_t jts(1); jts<nts[jr]; jts++) {
+      Int_t its(idx2[jts]);
+      Double_t rot(TMath::Tan(r[0][is]));
+      dyRez[its] = TMath::Abs(ym[0][is] - ym[jr][its] + rot*(xm[0][is]-xm[jr][its]));
+    }
+    TMath::Sort(nts[jr], dyRez, idx3, kFALSE);
+    for (Int_t jts(1); jts<nts[jr]; jts++) {
+      Int_t its(idx3[jts]);
+      if(dyRez[its] > kNSgmDy[jr]*smTrklt){
+        AliDebug(2, Form("Reject seg[%d] row[%2d] n[%2d] dy[%f] > %d*s[%f].", its, idxRow[jr], n[jr][its], dyRez[its], kNSgmDy[jr], kNSgmDy[jr]*smTrklt));
+        continue;
+      }
+      
+      test = helper;
+      Int_t n0 = test.Expand(&clst[ir], index[jr], its);
+      Double_t rt, dyt, st, xt, smt, pt, ft;
+      Int_t n1 = test.GetRMS(rt, dyt, st, xt);
+      pt = Double_t(n1)/n0;
+      smt = test.GetSyMean();
+      // correct position
+      Double_t dxm= fX0 - xt;
+      yt = fYref[0] - fYref[1]*dxm; 
+      zt = fZref[0] - fZref[1]*dxm;
+      // correct tracklet fit for tilt
+      dyt+= GetTilt()*(zt - zc[idxRow[0]]);
+      rt += GetTilt() * fZref[1];
+      // correct tracklet fit for track position/inclination
+      dyt= yt - dyt;
+      rt = (rt - fYref[1])/(1+rt*fYref[1]);
+      // report inclination in radians
+      rt = TMath::ATan(rt);
+        
+      ft = (n0>=2) ? attach->CookLikelihood(chgPos, lyDet, fPt, phiTrk, n0,  dyt/*sRef*/, rt*TMath::RadToDeg(), st/smt) : 0.;
+      Bool_t kAccept(ft>=fTrklt*(1.-kLikeMinRelDecrease[jr]));
+      
+      AliDebug(2, Form("%s seg[%d] row[%2d] n[%2d] dy[%f] r[%+5.2f] s[%+5.2f] f[%f] < %4.2f*F[%f].", 
+        (kAccept?"Adding":"Reject"), its, idxRow[jr], n0, dyt, rt*TMath::RadToDeg(), st/smt, ft, 1.-kLikeMinRelDecrease[jr], fTrklt*(1.-kLikeMinRelDecrease[jr])));
+      if(kAccept){
+        idxTrklt[kts++] = its;
+        nTrklt = n0;
+        fTrklt = ft;
+        rTrklt = rt;
+        yTrklt = dyt;
+        sTrklt = st;
+        smTrklt= smt;
+        xTrklt = xt;
+        pTrklt = pt;
+        helper.Expand(&clst[ir], index[jr], its);
       }
-      nrow[nr]++; rowId[nr]=ir; kFOUND = kTRUE;
     }
-    if(kFOUND){ 
-      vdy[nr].Use(nrow[nr], yres[ir]);
-      nr++; 
+  }
+  
+  //=========================================================
+  // Try attaching next segments from second row (if any)
+  if(nts[1] && (rcLikelihood = zresRow[0]/zresRow[1]) > kRClikeLimit){
+    // organize  secondaries in decreasing order of their distance from seed 
+    Int_t jr(1), ir(idxRow[jr]);
+    memset(dyRez, 0, nts[jr]*sizeof(Double_t));
+    Double_t rot(TMath::Tan(r[0][is]));
+    for(Int_t jts(0); jts<nts[jr]; jts++) {
+      dyRez[jts] = TMath::Abs(ym[0][is] - ym[jr][jts] + rot*(xm[0][is]-xm[jr][jts]));
+    }
+    TMath::Sort(nts[jr], dyRez, idx3, kFALSE);
+    for (Int_t jts(0); jts<nts[jr]; jts++) {
+      Int_t its(idx3[jts]);
+      if(dyRez[its] > kNSgmDy[jr]*smTrklt){
+        AliDebug(2, Form("Reject seg[%d] row[%2d] n[%2d] dy[%f] > %d*s[%f].", its, idxRow[jr], n[jr][its], dyRez[its], kNSgmDy[jr], kNSgmDy[jr]*smTrklt));
+        continue;
+      }
+      
+      test = helper;
+      Int_t n0 = test.Expand(&clst[ir], index[jr], its);
+      Double_t rt, dyt, st, xt, smt, pt, ft;
+      Int_t n1 = test.GetRMS(rt, dyt, st, xt);
+      pt = Double_t(n1)/n0;
+      smt = test.GetSyMean();
+      // correct position
+      Double_t dxm= fX0 - xt;
+      yt = fYref[0] - fYref[1]*dxm; 
+      zt = fZref[0] - fZref[1]*dxm;
+      // correct tracklet fit for tilt
+      dyt+= GetTilt()*(zt - zc[idxRow[0]]);
+      rt += GetTilt() * fZref[1];
+      // correct tracklet fit for track position/inclination
+      dyt= yt - dyt;
+      rt = (rt - fYref[1])/(1+rt*fYref[1]);
+      // report inclination in radians
+      rt = TMath::ATan(rt);
+        
+      ft = (n0>=2) ? attach->CookLikelihood(chgPos, lyDet, fPt, phiTrk, n0,  dyt/*sRef*/, rt*TMath::RadToDeg(), st/smt) : 0.;
+      Bool_t kAccept(ft>=fTrklt*(1.-kLikeMinRelDecrease[jr]));
+      
+      AliDebug(2, Form("%s seg[%d] row[%2d] n[%2d] dy[%f] r[%+5.2f] s[%+5.2f] f[%f] < %4.2f*F[%f].", 
+        (kAccept?"Adding":"Reject"), its, idxRow[jr], n0, dyt, rt*TMath::RadToDeg(), st/smt, ft, 1.-kLikeMinRelDecrease[jr], fTrklt*(1.-kLikeMinRelDecrease[jr])));
+      if(kAccept){
+        idxTrklt[kts++] = its;
+        nTrklt = n0;
+        fTrklt = ft;
+        rTrklt = rt;
+        yTrklt = dyt;
+        sTrklt = st;
+        smTrklt= smt;
+        xTrklt = xt;
+        pTrklt = pt;
+        helper.Expand(&clst[ir], index[jr], its);
+        SetBit(kRowCross, kTRUE); // mark pad row crossing
+      }
     }
-    lr = ir; if(nr>=3) break;
   }
-  if(recoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 3 && fkReconstructor->IsDebugStreaming()){
-    TTreeSRedirector &cstreamer = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker);
+  // clear local copy of clusters
+  for(Int_t ir(0); ir<kNrows; ir++) clst[ir].Clear();
+  
+  if(!pstreamer && recoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 1 && fkReconstructor->IsDebugStreaming()) pstreamer = fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker);
+  if(pstreamer){
     UChar_t stat(0);
     if(IsKink()) SETBIT(stat, 1);
     if(IsStandAlone()) SETBIT(stat, 2);
-    cstreamer << "AttachClusters"
+    if(IsRowCross()) SETBIT(stat, 3);
+    TVectorD vidx; vidx.ResizeTo(kts);
+    for(Int_t its(0); its<kts; its++) vidx[its] = idxTrklt[its];
+    (*pstreamer) << "AttachClusters2"
         << "stat="   << stat
+        << "ev="     << ev
+        << "chg="    << chgPos
         << "det="    << fDet
+        << "x0="     << fX0
+        << "y0="     << fYref[0]
+        << "z0="     << fZref[0]
+        << "phi="    << phiTrk
+        << "tht="    << thtTrk
         << "pt="     << fPt
-        << "s2y="    << s2yTrk
-        << "r0="     << rowId[0]
-        << "dy0="    << &vdy[0]
-        << "m0="     << mean[0]
-        << "s0="     << syDis[0]
-        << "r1="     << rowId[1]
-        << "dy1="    << &vdy[1]
-        << "m1="     << mean[1]
-        << "s1="     << syDis[1]
-        << "r2="     << rowId[2]
-        << "dy2="    << &vdy[2]
-        << "m2="     << mean[2]
-        << "s2="     << syDis[2]
+        << "s2Trk="  << s2yTrk
+        << "s2Cl="   << s2Mean
+        << "idx="    << &vidx
+        << "n="      << nTrklt
+        << "f="      << fTrklt
+        << "x="      << xTrklt
+        << "y="      << yTrklt
+        << "r="      << rTrklt
+        << "s="      << sTrklt
+        << "sm="     << smTrklt
+        << "p="      << pTrklt
         << "\n";
   }
-
-
-  // analyze gap in rows attached 
-  if(kRowSelection){
-    SetErrorMsg(kAttachRowGap);
-    Int_t rowRemove(-1); 
-    if(nr==2){ // select based on minimum distance to track projection
-      if(TMath::Abs(mean[0])<TMath::Abs(mean[1])){ 
-        if(nrow[1]>nrow[0]) AliDebug(2, Form("Conflicting mean[%f < %f] but ncl[%d < %d].", TMath::Abs(mean[0]), TMath::Abs(mean[1]), nrow[0], nrow[1]));
-      }else{
-        if(nrow[1]<nrow[0]) AliDebug(2, Form("Conflicting mean[%f > %f] but ncl[%d > %d].", TMath::Abs(mean[0]), TMath::Abs(mean[1]), nrow[0], nrow[1]));
-        Swap(nrow[0],nrow[1]); Swap(rowId[0],rowId[1]);
-        Swap(mean[0],mean[1]); Swap(syDis[0],syDis[1]);
-      }
-      rowRemove=1; nr=1; 
-    } else if(nr==3){ // select based on 2 consecutive rows
-      if(rowId[1]==rowId[0]+1 && rowId[1]!=rowId[2]-1){ 
-        nr=2;rowRemove=2;
-      } else if(rowId[1]!=rowId[0]+1 && rowId[1]==rowId[2]-1){ 
-        Swap(nrow[0],nrow[2]); Swap(rowId[0],rowId[2]);
-        Swap(mean[0],mean[2]); Swap(syDis[0],syDis[2]);
-        nr=2; rowRemove=2;
-      }
-    }
-    if(rowRemove>0){nrow[rowRemove]=0; rowId[rowRemove]=-1;}
-  }
-  AliDebug(4, Form("  Ncl[%d[%d] + %d[%d] + %d[%d]]", nrow[0], rowId[0],  nrow[1], rowId[1], nrow[2], rowId[2]));
-
-  if(nr==3){
-    SetBit(kRowCross, kTRUE); // mark pad row crossing
-    SetErrorMsg(kAttachRow);
-    const Float_t am[]={TMath::Abs(mean[0]), TMath::Abs(mean[1]), TMath::Abs(mean[2])};
-    AliDebug(4, Form("complex row configuration\n"
-      "  r[%d] n[%d] m[%6.3f] s[%6.3f]\n"
-      "  r[%d] n[%d] m[%6.3f] s[%6.3f]\n"
-      "  r[%d] n[%d] m[%6.3f] s[%6.3f]\n"
-      , rowId[0], nrow[0], am[0], syDis[0]
-      , rowId[1], nrow[1], am[1], syDis[1]
-      , rowId[2], nrow[2], am[2], syDis[2]));
-    Int_t id[]={0,1,2}; TMath::Sort(3, am, id, kFALSE);
-    // backup
-    Int_t rnn[3]; memcpy(rnn, nrow, 3*sizeof(Int_t));
-    Int_t rid[3]; memcpy(rid, rowId, 3*sizeof(Int_t));
-    Double_t rm[3]; memcpy(rm, mean, 3*sizeof(Double_t));
-    Double_t rs[3]; memcpy(rs, syDis, 3*sizeof(Double_t));
-    nrow[0]=rnn[id[0]]; rowId[0]=rid[id[0]]; mean[0]=rm[id[0]]; syDis[0]=rs[id[0]];
-    nrow[1]=rnn[id[1]]; rowId[1]=rid[id[1]]; mean[1]=rm[id[1]]; syDis[1]=rs[id[1]];
-    nrow[2]=0;          rowId[2]=-1; mean[2] = 1.e3; syDis[2] = 1.e3;
-    AliDebug(4, Form("solved configuration\n"
-      "  r[%d] n[%d] m[%+6.3f] s[%6.3f]\n"
-      "  r[%d] n[%d] m[%+6.3f] s[%6.3f]\n"
-      "  r[%d] n[%d] m[%+6.3f] s[%6.3f]\n"
-      , rowId[0], nrow[0], mean[0], syDis[0]
-      , rowId[1], nrow[1], mean[1], syDis[1]
-      , rowId[2], nrow[2], mean[2], syDis[2]));
-    nr=2;
-  } else if(nr==2) {
-    SetBit(kRowCross, kTRUE); // mark pad row crossing
-    if(nrow[1] > nrow[0]){ // swap row order
-      Swap(nrow[0],nrow[1]); Swap(rowId[0],rowId[1]);
-      Swap(mean[0],mean[1]); Swap(syDis[0],syDis[1]);
-    }
+  
+  
+  //=========================================================
+  // Store clusters
+  Int_t nselected(0), nc(0);
+  TObjArray *selected(helper.GetClusters());
+  if(!selected || !(nselected = selected->GetEntriesFast())){
+    AliError("Cluster candidates missing !!!");
+    SetErrorMsg(kAttachClAttach);
+    return kFALSE;
   }
-
-  // Select and store clusters 
-  // We should consider here :
-  //  1. How far is the chamber boundary
-  //  2. How big is the mean
-  Int_t n(0); Float_t dyc[kNclusters]; memset(dyc,0,kNclusters*sizeof(Float_t));
-  for (Int_t ir = 0; ir < nr; ir++) {
-    Int_t jr(rowId[ir]);
-    AliDebug(4, Form("  Attaching Ncl[%d]=%d ...", jr, ncl[jr]));
-    for (Int_t ic = 0; ic < ncl[jr]; ic++) {
-      if(!blst[jr][ic])continue;
-      c = clst[jr][ic];
-      Int_t it(c->GetPadTime());
-      Int_t idx(it+kNtb*ir);
-      if(fClusters[idx]){
-        AliDebug(4, Form("Many cluster candidates on row[%2d] tb[%2d].", jr, it));
-        // TODO should save also the information on where the multiplicity happened and its size
-        SetErrorMsg(kAttachMultipleCl);
-        // TODO should also compare with mean and sigma for this row
-        if(yres[jr][ic] > dyc[idx]) continue;
-      }
-
-      // TODO proper indexing of clusters !!
-      fIndexes[idx]  = chamber->GetTB(it)->GetGlobalIndex(idxs[jr][ic]);
-      fClusters[idx] = c;
-      dyc[idx]        = yres[jr][ic];
-      n++;
+  for(Int_t ic(0); ic<nselected; ic++){
+    if(!(c = (AliTRDcluster*)selected->At(ic))) continue;
+    Int_t it(c->GetPadTime()),
+          jr(Int_t(helper.GetRow() != c->GetPadRow())),
+          idx(it+kNtb*jr);
+    if(fClusters[idx]){
+      AliDebug(1, Form("Multiple clusters/tb for D[%03d] Tb[%02d] Row[%2d]", fDet, it, c->GetPadRow()));
+      continue; // already booked
     }
+    // TODO proper indexing of clusters !!
+    fIndexes[idx]  = chamber->GetTB(it)->GetGlobalIndex(idxs[idxRow[jr]][ic]);
+    fClusters[idx] = c;
+    nc++;
   }
-  SetN(n);
+  AliDebug(2, Form("Clusters Found[%2d] Attached[%2d] RC[%c]", nselected, nc, IsRowCross()?'y':'n'));
 
   // number of minimum numbers of clusters expected for the tracklet
-  if (GetN() < kClmin){
-    AliDebug(1, Form("NOT ENOUGH CLUSTERS %d ATTACHED TO THE TRACKLET [min %d] FROM FOUND %d.", GetN(), kClmin, n));
+  if (nc < kClmin){
+    AliDebug(1, Form("NOT ENOUGH CLUSTERS %d ATTACHED TO THE TRACKLET [min %d] FROM FOUND %d.", nc, kClmin, ncls));
     SetErrorMsg(kAttachClAttach);
     return kFALSE;
   }
+  SetN(nc);
 
   // Load calibration parameters for this tracklet  
-  Calibrate();
+  //Calibrate();
 
   // calculate dx for time bins in the drift region (calibration aware)
   Float_t x[2] = {0.,0.}; Int_t tb[2]={0,0};
@@ -1433,6 +1840,7 @@ Bool_t AliTRDseedV1::Fit(UChar_t opt)
   const Char_t *tcName[]={"NONE", "FULL", "HALF"};
   AliDebug(2, Form("Options : TC[%s] dzdx[%c]", tcName[opt], kDZDX?'Y':'N'));
 
+  
   for (Int_t ic=0; ic<kNclusters; ic++, ++jc) {
     xc[ic]  = -1.; yc[ic]  = 999.; zc[ic]  = 999.; sy[ic]  = 0.;
     if(!(c = (*jc))) continue;
@@ -1561,257 +1969,141 @@ Bool_t AliTRDseedV1::Fit(UChar_t opt)
 }
 
 
-/*
-//_____________________________________________________________________________
-void AliTRDseedV1::FitMI()
+//____________________________________________________________________
+Bool_t AliTRDseedV1::FitRobust(Bool_t chg)
 {
 //
-// Fit the seed.
-// Marian Ivanov's version 
+// Linear fit of the clusters attached to the tracklet
 //
-// linear fit on the y direction with respect to the reference direction. 
-// The residuals for each x (x = xc - x0) are deduced from:
-// dy = y - yt             (1)
-// the tilting correction is written :
-// y = yc + h*(zc-zt)      (2)
-// yt = y0+dy/dx*x         (3)
-// zt = z0+dz/dx*x         (4)
-// from (1),(2),(3) and (4)
-// dy = yc - y0 - (dy/dx + h*dz/dx)*x + h*(zc-z0)
-// the last term introduces the correction on y direction due to tilting pads. There are 2 ways to account for this:
-// 1. use tilting correction for calculating the y
-// 2. neglect tilting correction here and account for it in the error parametrization of the tracklet.
-  const Float_t kRatio  = 0.8;
-  const Int_t   kClmin  = 5;
-  const Float_t kmaxtan = 2;
-
-  if (TMath::Abs(fYref[1]) > kmaxtan){
-               //printf("Exit: Abs(fYref[1]) = %3.3f, kmaxtan = %3.3f\n", TMath::Abs(fYref[1]), kmaxtan);
-               return;              // Track inclined too much
-       }
-
-  Float_t  sigmaexp  = 0.05 + TMath::Abs(fYref[1] * 0.25); // Expected r.m.s in y direction
-  Float_t  ycrosscor = GetPadLength() * GetTilt() * 0.5;           // Y correction for crossing 
-  Int_t fNChange = 0;
-
-  Double_t sumw;
-  Double_t sumwx;
-  Double_t sumwx2;
-  Double_t sumwy;
-  Double_t sumwxy;
-  Double_t sumwz;
-  Double_t sumwxz;
-
-       // Buffering: Leave it constant fot Performance issues
-  Int_t    zints[kNtb];            // Histograming of the z coordinate 
-                                         // Get 1 and second max probable coodinates in z
-  Int_t    zouts[2*kNtb];       
-  Float_t  allowedz[kNtb];         // Allowed z for given time bin
-  Float_t  yres[kNtb];             // Residuals from reference
-  //Float_t  anglecor = GetTilt() * fZref[1];  // Correction to the angle
-  
-  Float_t pos[3*kNtb]; memset(pos, 0, 3*kNtb*sizeof(Float_t));
-  Float_t *fX = &pos[0], *fY = &pos[kNtb], *fZ = &pos[2*kNtb];
-  
-  Int_t fN  = 0; AliTRDcluster *c = 0x0; 
-  fN2 = 0;
-  for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins(); i++) {
-    yres[i] = 10000.0;
-    if (!(c = fClusters[i])) continue;
-    if(!c->IsInChamber()) continue;
-    // Residual y
-    //yres[i] = fY[i] - fYref[0] - (fYref[1] + anglecor) * fX[i] + GetTilt()*(fZ[i] - fZref[0]);
-    fX[i] = fX0 - c->GetX();
-    fY[i] = c->GetY();
-    fZ[i] = c->GetZ();
-    yres[i] = fY[i] - GetTilt()*(fZ[i] - (fZref[0] - fX[i]*fZref[1]));
-    zints[fN] = Int_t(fZ[i]);
-    fN++;
-  }
-
-  if (fN < kClmin){
-    //printf("Exit fN < kClmin: fN = %d\n", fN);
-    return; 
-  }
-  Int_t nz = AliTRDtrackerV1::Freq(fN, zints, zouts, kFALSE);
-  Float_t fZProb   = zouts[0];
-  if (nz <= 1) zouts[3] = 0;
-  if (zouts[1] + zouts[3] < kClmin) {
-    //printf("Exit zouts[1] = %d, zouts[3] = %d\n",zouts[1],zouts[3]);
-    return;
-  }
-  
-  // Z distance bigger than pad - length
-  if (TMath::Abs(zouts[0]-zouts[2]) > 12.0) zouts[3] = 0;
-  
-  Int_t  breaktime = -1;
-  Bool_t mbefore   = kFALSE;
-  Int_t  cumul[kNtb][2];
-  Int_t  counts[2] = { 0, 0 };
-  
-  if (zouts[3] >= 3) {
-
-    //
-    // Find the break time allowing one chage on pad-rows
-    // with maximal number of accepted clusters
-    //
-    fNChange = 1;
-    for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins(); i++) {
-      cumul[i][0] = counts[0];
-      cumul[i][1] = counts[1];
-      if (TMath::Abs(fZ[i]-zouts[0]) < 2) counts[0]++;
-      if (TMath::Abs(fZ[i]-zouts[2]) < 2) counts[1]++;
-    }
-    Int_t  maxcount = 0;
-    for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins(); i++) {
-      Int_t after  = cumul[AliTRDtrackerV1::GetNTimeBins()][0] - cumul[i][0];
-      Int_t before = cumul[i][1];
-      if (after + before > maxcount) { 
-        maxcount  = after + before; 
-        breaktime = i;
-        mbefore   = kFALSE;
-      }
-      after  = cumul[AliTRDtrackerV1::GetNTimeBins()-1][1] - cumul[i][1];
-      before = cumul[i][0];
-      if (after + before > maxcount) { 
-        maxcount  = after + before; 
-        breaktime = i;
-        mbefore   = kTRUE;
-      }
-    }
-    breaktime -= 1;
-  }
+// Author 
+// A.Bercuci <A.Bercuci@gsi.de>
 
-  for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins()+1; i++) {
-    if (i >  breaktime) allowedz[i] =   mbefore  ? zouts[2] : zouts[0];
-    if (i <= breaktime) allowedz[i] = (!mbefore) ? zouts[2] : zouts[0];
-  }  
+  TTreeSRedirector *pstreamer(NULL);
+  const AliTRDrecoParam* const recoParam = fkReconstructor->GetRecoParam();   if(recoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 3 && fkReconstructor->IsDebugStreaming()) pstreamer = fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker);
 
-  if (((allowedz[0] > allowedz[AliTRDtrackerV1::GetNTimeBins()]) && (fZref[1] < 0)) ||
-      ((allowedz[0] < allowedz[AliTRDtrackerV1::GetNTimeBins()]) && (fZref[1] > 0))) {
-    //
-    // Tracklet z-direction not in correspondance with track z direction 
-    //
-    fNChange = 0;
-    for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins()+1; i++) {
-      allowedz[i] = zouts[0];  // Only longest taken
-    } 
-  }
-  
-  if (fNChange > 0) {
-    //
-    // Cross pad -row tracklet  - take the step change into account
-    //
-    for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins()+1; i++) {
-      if (!fClusters[i]) continue; 
-      if(!fClusters[i]->IsInChamber()) continue;
-      if (TMath::Abs(fZ[i] - allowedz[i]) > 2) continue;
-      // Residual y
-      //yres[i] = fY[i] - fYref[0] - (fYref[1] + anglecor) * fX[i] + GetTilt()*(fZ[i] - fZref[0]);   
-      yres[i] = fY[i] - GetTilt()*(fZ[i] - (fZref[0] - fX[i]*fZref[1]));
-//       if (TMath::Abs(fZ[i] - fZProb) > 2) {
-//         if (fZ[i] > fZProb) yres[i] += GetTilt() * GetPadLength();
-//         if (fZ[i] < fZProb) yres[i] -= GetTilt() * GetPadLength();
-      }
+  // factor to scale y pulls.
+  // ideally if error parametrization correct this is 1.
+  //Float_t lyScaler = 1./(AliTRDgeometry::GetLayer(fDet)+1.);
+  Float_t kScalePulls = 1.; 
+  AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
+  if(!calibration){ 
+    AliWarning("No access to calibration data");
+  } else {
+    // Retrieve the CDB container class with the parametric likelihood
+    const AliTRDCalTrkAttach *attach = calibration->GetAttachObject();
+    if(!attach){ 
+      AliWarning("No usable AttachClusters calib object.");
+    } else { 
+      kScalePulls = attach->GetScaleCov();//*lyScaler;
     }
+  }  
+  Double_t xc[kNclusters], yc[kNclusters], sy[kNclusters];
+  Int_t n(0),           // clusters used in fit 
+        row[]={-1, 0}; // pad row spanned by the tracklet
+  AliTRDcluster *c(NULL), **jc = &fClusters[0];
+  for(Int_t ic=0; ic<kNtb; ic++, ++jc) {
+    if(!(c = (*jc))) continue;
+    if(!c->IsInChamber()) continue;
+    if(row[0]<0){ 
+      fZfit[0] = c->GetZ();
+      fZfit[1] = 0.;
+      row[0] = c->GetPadRow();
+    }
+    xc[n]  = fX0 - c->GetX();
+    yc[n]  = c->GetY();
+    sy[n]  = c->GetSigmaY2()>0?(TMath::Min(TMath::Sqrt(c->GetSigmaY2()), 0.08)):0.08;
+    n++;
   }
-  
-  Double_t yres2[kNtb];
-  Double_t mean;
-  Double_t sigma;
-  for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins()+1; i++) {
-    if (!fClusters[i]) continue;
-    if(!fClusters[i]->IsInChamber()) continue;
-    if (TMath::Abs(fZ[i] - allowedz[i]) > 2) continue;
-    yres2[fN2] = yres[i];
-    fN2++;
-  }
-  if (fN2 < kClmin) {
-               //printf("Exit fN2 < kClmin: fN2 = %d\n", fN2);
-    fN2 = 0;
-    return;
-  }
-  AliMathBase::EvaluateUni(fN2,yres2,mean,sigma, Int_t(fN2*kRatio-2.));
-  if (sigma < sigmaexp * 0.8) {
-    sigma = sigmaexp;
-  }
-  //Float_t fSigmaY = sigma;
-
-  // Reset sums
-  sumw   = 0; 
-  sumwx  = 0; 
-  sumwx2 = 0;
-  sumwy  = 0; 
-  sumwxy = 0; 
-  sumwz  = 0;
-  sumwxz = 0;
-
-  fN2    = 0;
-  Float_t fMeanz = 0;
-  Float_t fMPads = 0;
-  fUsable = 0;
-  for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins()+1; i++) {
-    if (!fClusters[i]) continue;
-    if (!fClusters[i]->IsInChamber()) continue;
-    if (TMath::Abs(fZ[i] - allowedz[i]) > 2){fClusters[i] = 0x0; continue;}
-    if (TMath::Abs(yres[i] - mean) > 4.0 * sigma){fClusters[i] = 0x0;  continue;}
-    SETBIT(fUsable,i);
-    fN2++;
-    fMPads += fClusters[i]->GetNPads();
-    Float_t weight = 1.0;
-    if (fClusters[i]->GetNPads() > 4) weight = 0.5;
-    if (fClusters[i]->GetNPads() > 5) weight = 0.2;
-   
-       
-    Double_t x = fX[i];
-    //printf("x = %7.3f dy = %7.3f fit %7.3f\n", x, yres[i], fY[i]-yres[i]);
-    
-    sumw   += weight; 
-    sumwx  += x * weight; 
-    sumwx2 += x*x * weight;
-    sumwy  += weight * yres[i];  
-    sumwxy += weight * (yres[i]) * x;
-    sumwz  += weight * fZ[i];    
-    sumwxz += weight * fZ[i] * x;
+  Double_t corr = fPad[2]*fPad[0];
 
+  for(Int_t ic=kNtb; ic<kNclusters; ic++, ++jc) {
+    if(!(c = (*jc))) continue;
+    if(!c->IsInChamber()) continue;
+    if(row[1]==0) row[1] = c->GetPadRow() - row[0];
+    xc[n]  = fX0 - c->GetX();
+    yc[n]  = c->GetY() + corr*row[1];
+    sy[n]  = c->GetSigmaY2()>0?(TMath::Min(TMath::Sqrt(c->GetSigmaY2()), 0.08)):0.08;
+    n++;
   }
-
-  if (fN2 < kClmin){
-               //printf("Exit fN2 < kClmin(2): fN2 = %d\n",fN2);
-    fN2 = 0;
-    return;
+  UChar_t status(0);
+  Double_t par[3] = {0.,0.,21122012.}, cov[3];
+  if(!AliTRDtrackletOflHelper::Fit(n, xc, yc, sy, par, 1.5, cov)){ 
+    AliDebug(1, Form("Tracklet fit failed D[%03d].", fDet));
+    SetErrorMsg(kFitCl);
+    return kFALSE; 
+  }
+  fYfit[0] = par[0];
+  fYfit[1] = -par[1];
+  // store covariance
+  fCov[0] = kScalePulls*cov[0]; // variance of y0
+  fCov[1] = kScalePulls*cov[2]; // covariance of y0, dydx
+  fCov[2] = kScalePulls*cov[1]; // variance of dydx
+  // the ref radial position is set at the minimum of 
+  // the y variance of the tracklet
+  fX   = -fCov[1]/fCov[2];
+  // check radial position
+  Float_t xs=fX+.5*AliTRDgeometry::CamHght();
+  if(xs < 0. || xs > AliTRDgeometry::CamHght()+AliTRDgeometry::CdrHght()){
+    AliDebug(1, Form("Ref radial position x[%5.2f] ouside D[%3d].", fX, fDet));
+    SetErrorMsg(kFitFailedY);
+    return kFALSE;
   }
-  fMeanz = sumwz / sumw;
-  Float_t correction = 0;
-  if (fNChange > 0) {
-    // Tracklet on boundary
-    if (fMeanz < fZProb) correction =  ycrosscor;
-    if (fMeanz > fZProb) correction = -ycrosscor;
+  fS2Y = fCov[0] + fX*fCov[1];
+  fS2Z = fPad[0]*fPad[0]/12.;
+  AliDebug(2, Form("[I]  x[cm]=%6.2f y[cm]=%+5.2f z[cm]=%+6.2f dydx[deg]=%+5.2f sy[um]=%6.2f sz[cm]=%6.2f", GetX(), GetY(), GetZ(), TMath::ATan(fYfit[1])*TMath::RadToDeg(), TMath::Sqrt(fS2Y)*1.e4, TMath::Sqrt(fS2Z)));
+  if(IsRowCross()){
+    Float_t x,z;
+    if(!GetEstimatedCrossPoint(x,z)){
+      AliDebug(2, Form("Failed getting crossing point D[%03d].", fDet));
+      SetErrorMsg(kFitFailedY);
+      return kTRUE;
+    }
+    fX   = fX0-x;
+    fS2Y = fCov[0] + fX*fCov[1];
+    fZfit[0] = z;
+    if(IsPrimary()){ 
+      fZfit[1] = z/x;
+      fS2Z     = 0.05+0.4*TMath::Abs(fZfit[1]); fS2Z *= fS2Z;
+    }
+    AliDebug(2, Form("[II] x[cm]=%6.2f y[cm]=%+5.2f z[cm]=%+6.2f dydx[deg]=%+5.2f sy[um]=%6.2f sz[um]=%6.2f dzdx[deg]=%+5.2f", GetX(), GetY(), GetZ(), TMath::ATan(fYfit[1])*TMath::RadToDeg(), TMath::Sqrt(fS2Y)*1.e4, TMath::Sqrt(fS2Z)*1.e4, TMath::ATan(fZfit[1])*TMath::RadToDeg()));
   }
-
-  Double_t det = sumw * sumwx2 - sumwx * sumwx;
-  fYfit[0]    = (sumwx2 * sumwy  - sumwx * sumwxy) / det;
-  fYfit[1]    = (sumw   * sumwxy - sumwx * sumwy)  / det;
-  
-  fS2Y = 0;
-  for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins()+1; i++) {
-    if (!TESTBIT(fUsable,i)) continue;
-    Float_t delta = yres[i] - fYfit[0] - fYfit[1] * fX[i];
-    fS2Y += delta*delta;
-  }
-  fS2Y = TMath::Sqrt(fS2Y / Float_t(fN2-2));
-       // TEMPORARY UNTIL covariance properly calculated
-       fS2Y = TMath::Max(fS2Y, Float_t(.1));
   
-  fZfit[0]   = (sumwx2 * sumwz  - sumwx * sumwxz) / det;
-  fZfit[1]   = (sumw   * sumwxz - sumwx * sumwz)  / det;
-//   fYfitR[0] += fYref[0] + correction;
-//   fYfitR[1] += fYref[1];
-//  fYfit[0]   = fYfitR[0];
-  fYfit[1]   = -fYfit[1];
-
-  UpdateUsed();
-}*/
+  if(pstreamer){
+    Float_t x= fX0 -fX,
+            y = GetY(),
+            yt = fYref[0]-fX*fYref[1];
+    SETBIT(status, 2);
+    TVectorD vcov(3); vcov[0]=cov[0];vcov[1]=cov[1];vcov[2]=cov[2];
+    Double_t sm(0.), chi2(0.), tmp, dy[kNclusters];
+    for(Int_t ic(0); ic<n; ic++){
+      sm   += sy[ic];
+      dy[ic] = yc[ic]-(fYfit[0]-xc[ic]*fYfit[1]); tmp = dy[ic]/sy[ic];
+      chi2 += tmp*tmp;
+    }
+    sm /= n; chi2 = TMath::Sqrt(chi2);
+    Double_t m(0.), s(0.);
+    AliMathBase::EvaluateUni(n, dy, m, s, 0);
+    (*pstreamer) << "FitRobust4"
+      << "stat=" << status
+      << "chg="  << chg
+      << "ncl="  << n
+      << "det="  << fDet
+      << "x0="   << fX0
+      << "y0="   << fYfit[0]
+      << "x="    << x
+      << "y="    << y
+      << "dydx=" << fYfit[1]
+      << "pt="   << fPt
+      << "yt="   << yt
+      << "dydxt="<< fYref[1]
+      << "cov="  << &vcov
+      << "chi2=" << chi2
+      << "sm="   << sm
+      << "ss="   << s
+      << "\n";
+  }
+  return kTRUE;
+}
 
 //___________________________________________________________________
 void AliTRDseedV1::Print(Option_t *o) const
index 62f796e349d85e6014b5fa0a51cd67d196e23787..d0d3a3a1e5fd42c448de852a217b1aa1de95f7f1 100644 (file)
@@ -84,13 +84,14 @@ public:
   AliTRDseedV1(const AliTRDseedV1 &ref);
   AliTRDseedV1& operator=(const AliTRDseedV1 &ref);
 
-  Bool_t    AttachClusters(AliTRDtrackingChamber *const chamber, Bool_t tilt = kFALSE);
+  Bool_t    AttachClusters(AliTRDtrackingChamber *const chamber, Bool_t tilt = kFALSE, Bool_t ChgPlus=kTRUE, Int_t ev=-1);
   void      Bootstrap(const AliTRDReconstructor *rec);
   void      Calibrate();
   void      CookdEdx(Int_t nslices);
   void      CookLabels();
   Bool_t    CookPID();
   Bool_t    Fit(UChar_t opt=0);
+  Bool_t    FitRobust(Bool_t ChgPlus=kTRUE);
   Bool_t    Init(AliTRDtrackV1 *track);
   void      Init(const AliRieman *fit);
   Bool_t    IsEqual(const TObject *inTracklet) const;
@@ -108,7 +109,7 @@ public:
 
   Float_t   GetAnodeWireOffset(Float_t zt);
   Float_t   GetC(Int_t typ=0) const    { return fC[typ]; }
-  Float_t   GetCharge(Bool_t useOutliers=kFALSE);
+  Float_t   GetCharge(Bool_t useOutliers=kFALSE) const;
   Float_t   GetChi2() const          { return fChi2; }
   inline Float_t   GetChi2Z() const;
   inline Float_t   GetChi2Y() const;
@@ -121,6 +122,7 @@ public:
   UChar_t   GetErrorMsg() const      { return fErrorMsg;}
   Float_t   GetdX() const            { return fdX;}
   const Float_t*  GetdEdx() const    { return &fdEdx[0];}
+  Float_t   GetdQdl() const;
   Float_t   GetdQdl(Int_t ic, Float_t *dx=NULL) const;
   Float_t   GetdYdX() const          { return fYfit[1];}
   Float_t   GetdZdX() const          { return fZfit[1];}
index c2d15bdeedc9177f7b9a3a6e6d77a43be43612f1..e5f2408959460e7c1289cf22486305af8e7b1d50 100644 (file)
@@ -23,6 +23,7 @@
 #include "AliTRDcluster.h"
 #include "AliTRDcalibDB.h"
 #include "AliTRDReconstructor.h"
+#include "AliTRDPIDResponse.h"
 #include "AliTRDrecoParam.h"
 
 ClassImp(AliTRDtrackV1)
@@ -346,29 +347,31 @@ Bool_t AliTRDtrackV1::CookPID()
 //<img src="TRD/trackPID.gif">
 //End_Html
 //
-  
-  /*Reset the a priori probabilities*/
-  Double_t pid = 1. / AliPID::kSPECIES;
-  for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) fPID[ispec] = pid; 
-
-  UChar_t fPIDquality = SetNumberOfTrackletsPID(kTRUE);
-  // no tracklet found for PID calculations
-  if(!fPIDquality) return kFALSE;
-  
-  // slot for PID calculation @ track level for bremsstrahlung TODO
-  
-  // normalize probabilities
-  Double_t probTotal = 0.0;
-  for (Int_t is = 0; is < AliPID::kSPECIES; is++) probTotal += fPID[is];
-  
-  
-  if (probTotal <= 0.0) {
-    AliWarning("The total probability over all species <= 0. This may be caused by some error in the reference data.");
+  const AliTRDPIDResponse *pidResponse = AliTRDcalibDB::Instance()->GetPIDResponse(fkReconstructor->GetRecoParam()->GetPIDmethod());
+  if(!pidResponse){
+    AliError("PID Response not available");
     return kFALSE;
   }
-  
-  for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) fPID[iSpecies] /= probTotal;
-  
+  Int_t nslices = pidResponse->GetNumberOfSlices();
+  Double_t dEdx[kNplane * (Int_t)AliTRDPIDResponse::kNslicesNN];
+  Float_t trackletP[kNplane];
+  memset(dEdx, 0, sizeof(Double_t) * kNplane * (Int_t)AliTRDPIDResponse::kNslicesNN);
+  memset(trackletP, 0, sizeof(Float_t)*kNplane);
+  for(Int_t iseed = 0; iseed < kNplane; iseed++){
+    if(!fTracklet[iseed]) continue;
+    trackletP[iseed] = fTracklet[iseed]->GetMomentum();
+    if(pidResponse->GetPIDmethod() == AliTRDPIDResponse::kLQ1D){
+      dEdx[iseed] = fTracklet[iseed]->GetdQdl();
+    } else {
+      fTracklet[iseed]->CookdEdx(nslices);
+      const Float_t *trackletdEdx = fTracklet[iseed]->GetdEdx();
+      for(Int_t islice = 0; islice < nslices; islice++){
+        dEdx[iseed*nslices + islice] = trackletdEdx[islice];
+      }
+      fTracklet[iseed]->SetPID();
+    }
+  }
+  pidResponse->GetResponse(nslices, dEdx, trackletP, fPID);
   return kTRUE;
 }
 
@@ -378,52 +381,15 @@ UChar_t AliTRDtrackV1::GetNumberOfTrackletsPID() const
 // Retrieve number of tracklets used for PID calculation. 
 
   UChar_t nPID = 0;
-  Float_t *prob = NULL;
   for(int ip=0; ip<kNplane; ip++){
     if(fTrackletIndex[ip]<0 || !fTracklet[ip]) continue;
     if(!fTracklet[ip]->IsOK()) continue;
-    if(!(prob = fTracklet[ip]->GetProbability(kFALSE))) continue;
-
-    Int_t nspec = 0; // quality check of tracklet dEdx
-    for(int ispec=0; ispec<AliPID::kSPECIES; ispec++){
-      if(prob[ispec] < 0.) continue;
-      nspec++;
-    }
-    if(!nspec) continue;
     
-    fTracklet[ip]->SetPID();
     nPID++;
   }
   return nPID;
 }
 
-//___________________________________________________________
-UChar_t AliTRDtrackV1::SetNumberOfTrackletsPID(Bool_t recalc)
-{
-// Retrieve number of tracklets used for PID calculation. // Recalculated PID at tracklet level by quering the PID DB.
-
-  UChar_t fPIDquality(0);
-  
-  // steer PID calculation @ tracklet level
-  Float_t *prob(NULL);
-  for(int ip=0; ip<kNplane; ip++){
-    if(fTrackletIndex[ip]<0 || !fTracklet[ip]) continue;
-    if(!fTracklet[ip]->IsOK()) continue;
-    if(!(prob = fTracklet[ip]->GetProbability(recalc))) return 0;
-
-    Int_t nspec = 0; // quality check of tracklet dEdx
-    for(int ispec=0; ispec<AliPID::kSPECIES; ispec++){
-      if(prob[ispec] < 0.) continue;
-      fPID[ispec] *= prob[ispec];
-      nspec++;
-    }
-    if(!nspec) continue;
-    
-    fPIDquality++;
-  }
-  return fPIDquality;
-}
-
 //_______________________________________________________________
 AliTRDcluster* AliTRDtrackV1::GetCluster(Int_t id)
 {
@@ -889,7 +855,7 @@ void AliTRDtrackV1::UpdateESDtrack(AliESDtrack *track)
   // Update the TRD PID information in the ESD track
   //
 
-  Int_t nslices = fkReconstructor->GetRecoParam()->IsEightSlices() ? (Int_t)AliTRDpidUtil::kNNslices : (Int_t)AliTRDpidUtil::kLQslices;
+  Int_t nslices = AliTRDcalibDB::Instance()->GetPIDResponse(fkReconstructor->GetRecoParam()->GetPIDmethod())->GetNumberOfSlices();
   // number of tracklets used for PID calculation
   UChar_t nPID = GetNumberOfTrackletsPID();
   // number of tracklets attached to the track
@@ -904,9 +870,13 @@ void AliTRDtrackV1::UpdateESDtrack(AliESDtrack *track)
     if(fTrackletIndex[ip]<0 || !fTracklet[ip]) continue;
     if(!fTracklet[ip]->HasPID()) continue;
     const Float_t *dedx = fTracklet[ip]->GetdEdx();
-    for (Int_t js = 0; js < nslices; js++, dedx++) track->SetTRDslice(*dedx, ip, js);
-    p = fTracklet[ip]->GetMomentum(&sp); spd = sp;
+    for (Int_t js = 0; js < nslices; js++, dedx++) track->SetTRDslice(*dedx, ip, js+1);
+    p = fTracklet[ip]->GetMomentum(&sp); 
+    // 04.01.11 A.Bercuci
+    // store global dQdl per tracklet instead of momentum error
+    spd = sp;
     track->SetTRDmomentum(p, ip, &spd);
+    track->SetTRDslice(fTracklet[ip]->GetdQdl(), ip, 0); // Set Summed dEdx into the first slice
   }
   // store PID probabilities
   track->SetTRDpid(fPID);
index 403539ae3a3c75ae5ce75048f94a94e815d66d77..88db8c3ddce70fc0ae35f2716a1504a30f1b730e 100644 (file)
@@ -123,7 +123,6 @@ public:
   void           SetKink(Bool_t k)        { SetBit(kKink, k);}
   void           SetPrimary(Bool_t k)     { SetBit(kPrimary, k);}
   void           SetNumberOfClusters();
-  UChar_t        SetNumberOfTrackletsPID(Bool_t recalc);
   void           SetOwner();
   void           SetPID(Short_t is, Double_t inPID){if (is >=0 && is < AliPID::kSPECIES) fPID[is]=inPID;};
   void           SetPIDquality(UChar_t /*inPIDquality*/) const {/*fPIDquality = inPIDquality*/;};
index c0203971f51c132cfcd4bac1779e19a276d96af5..6afdb846085661776859166e4fc839bec6df7c3e 100644 (file)
@@ -86,6 +86,7 @@ AliTRDtrackerV1::AliTRDtrackerV1(AliTRDReconstructor *rec)
   ,fTracks(NULL)
   ,fTracksESD(NULL)
   ,fSieveSeeding(0)
+  ,fEventInFile(-1)
 {
   //
   // Default constructor.
@@ -285,6 +286,7 @@ Int_t AliTRDtrackerV1::PropagateBack(AliESDEvent *event)
   
   Float_t *quality = NULL;
   Int_t   *index   = NULL;
+  fEventInFile  = event->GetEventNumberInFile();
   nSeeds   = event->GetNumberOfTracks();
   // Sort tracks according to quality 
   // (covariance in the yz plane)
@@ -877,12 +879,12 @@ Int_t AliTRDtrackerV1::FollowBackProlongation(AliTRDtrackV1 &t)
         AliDebug(4, "Failed Tracklet Init");
         break;
       }
-      if(!ptrTracklet->AttachClusters(chamber, kTRUE)){
+      if(!ptrTracklet->AttachClusters(chamber, kTRUE, t.Charge()>0?kTRUE:kFALSE, fEventInFile)){
         t.SetStatus(AliTRDtrackV1::kNoAttach, ily);
         if(debugLevel>3){
           AliTRDseedV1 trackletCp(*ptrTracklet);
           UChar_t status(t.GetStatusTRD(ily));
-          (*cstreamer)   << "FollowBackProlongation2"
+          (*cstreamer)   << "FollowBackProlongation4"
           <<"status="    << status
           <<"tracklet.=" << &trackletCp
           << "\n";
@@ -896,7 +898,7 @@ Int_t AliTRDtrackerV1::FollowBackProlongation(AliTRDtrackV1 &t)
         if(debugLevel>3){
           AliTRDseedV1 trackletCp(*ptrTracklet);
           UChar_t status(t.GetStatusTRD(ily));
-          (*cstreamer)   << "FollowBackProlongation2"
+          (*cstreamer)   << "FollowBackProlongation4"
           <<"status="    << status
           <<"tracklet.=" << &trackletCp
           << "\n";
@@ -912,7 +914,7 @@ Int_t AliTRDtrackerV1::FollowBackProlongation(AliTRDtrackV1 &t)
     // tilt correction options
     // 0 : no correction
     // 2 : pseudo tilt correction
-    if(!ptrTracklet->Fit(2)){
+    if(!ptrTracklet->FitRobust(t.Charge()>0?kTRUE:kFALSE)){
       t.SetStatus(AliTRDtrackV1::kNoFit, ily);
       AliDebug(4, "Failed Tracklet Fit");
       continue;
@@ -947,7 +949,7 @@ Int_t AliTRDtrackerV1::FollowBackProlongation(AliTRDtrackV1 &t)
         AliTRDseedV1  trackletCp(*ptrTracklet);
         AliTRDtrackV1 trackCp(t);
         trackCp.SetOwner();
-        (*cstreamer) << "FollowBackProlongation1"
+        (*cstreamer) << "FollowBackProlongation3"
             << "status="      << status
             << "tracklet.="   << &trackletCp
             << "track.="      << &trackCp
@@ -965,7 +967,7 @@ Int_t AliTRDtrackerV1::FollowBackProlongation(AliTRDtrackV1 &t)
           AliTRDseedV1  trackletCp(*ptrTracklet);
           AliTRDtrackV1 trackCp(t);
           trackCp.SetOwner();
-          (*cstreamer) << "FollowBackProlongation1"
+          (*cstreamer) << "FollowBackProlongation3"
               << "status="      << status
               << "tracklet.="   << &trackletCp
               << "track.="      << &trackCp
@@ -1003,13 +1005,12 @@ Int_t AliTRDtrackerV1::FollowBackProlongation(AliTRDtrackV1 &t)
   //printf("clusters[%d] chi2[%f] x[%f] status[%d ", n, t.GetChi2(), t.GetX(), t.GetStatusTRD());
   //for(int i=0; i<6; i++) printf("%d ", t.GetStatusTRD(i)); printf("]\n");
 
-  if(debugLevel > 1){
-    Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber();
+  if(n && debugLevel > 1){
+    //Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber();
     AliTRDtrackV1 track(t);
     track.SetOwner();
-    (*cstreamer) << "FollowBackProlongation0"
-        << "EventNumber=" << eventNumber
-        << "ncl="         << n
+    (*cstreamer) << "FollowBackProlongation2"
+        << "EventNumber=" << fEventInFile
         << "track.="      << &track
         << "\n";
   }
index 28e12c322cd815d215d8ffba3c16751c2771bc91..f782e329ab241c674401ed0f20946103191f9392 100644 (file)
@@ -217,6 +217,7 @@ private:
   Int_t                fSeedLayer[kMaxTracksStack];     //  Seed layer
   AliTRDchamberTimeBin *fSeedTB[kNSeedPlanes]; // seeding time bin planes
   Int_t                fSieveSeeding;                   //! Seeding iterator
+  Int_t                fEventInFile;                    //! event in file being tracked (debug purposes)
   
   static const Double_t fgkX0[kNPlanes];                // default values for the position of anode wire
   static Int_t         fgNTimeBins;                     // Timebins per plane in track prolongation 
@@ -224,7 +225,7 @@ private:
   static TLinearFitter *fgTiltedRiemanConstrained;      //  Fitter for the tilted Rieman fit with vertex constraint    
   static AliRieman     *fgRieman;                       //  Fitter for the untilted Rieman fit
   
-  ClassDef(AliTRDtrackerV1, 6)                          //  TRD tracker - tracklet based tracking
+  ClassDef(AliTRDtrackerV1, 7)                          //  TRD tracker - tracklet based tracking
 
 };
 #endif
index 4528a09a5bab5341631743a25e6901965f0f661d..6be6039c34bf6481ab1698fc136846fad0096c7a 100644 (file)
@@ -37,8 +37,6 @@
 
 ClassImp(AliTRDtransform)
 
-AliTRDgeometry* AliTRDtransform::fgGeo = NULL;
-
 //_____________________________________________________________________________
 AliTRDtransform::AliTRDtransform()
   :TObject()
@@ -61,13 +59,6 @@ AliTRDtransform::AliTRDtransform()
   // AliTRDtransform default constructor
   //
 
-  if(!fgGeo){
-    fgGeo = new AliTRDgeometry();
-    if (!fgGeo->CreateClusterMatrixArray()) {
-      AliError("Could not get transformation matrices\n");
-    }
-  }
-
   fParam             = AliTRDCommonParam::Instance();
   if (!fParam) {
     AliError("Could not get common parameters\n");
@@ -107,13 +98,6 @@ AliTRDtransform::AliTRDtransform(Int_t det)
   // AliTRDtransform constructor for a given detector
   //
 
-  if(!fgGeo){
-    fgGeo = new AliTRDgeometry();
-    if (!fgGeo->CreateClusterMatrixArray()) {
-      AliError("Could not get transformation matrices\n");
-    }
-  }
-
   fParam             = AliTRDCommonParam::Instance();
   if (!fParam) {
     AliError("Could not get common parameters\n");
@@ -224,6 +208,16 @@ void AliTRDtransform::Copy(TObject &t) const
 
 }
 
+//_____________________________________________________________________________
+AliTRDgeometry& AliTRDtransform::Geometry()
+{
+  static AliTRDgeometry g;
+  if (!g.CreateClusterMatrixArray()) {
+    AliErrorGeneral("AliTRDtransform::Geometry()", "Could not get transformation matrices\n");
+  }
+  return g;
+}
+
 //_____________________________________________________________________________
 void AliTRDtransform::SetDetector(Int_t det)
 {
@@ -244,13 +238,13 @@ void AliTRDtransform::SetDetector(Int_t det)
   fCalT0DetValue     = fkCalT0Det->GetValue(det);
 
   // Shift needed to define Z-position relative to middle of chamber
-  Int_t layer        = fgGeo->GetLayer(det);
-  Int_t stack        = fgGeo->GetStack(det);
-  fPadPlane          = fgGeo->GetPadPlane(layer,stack);
+  Int_t layer        = Geometry().GetLayer(det);
+  Int_t stack        = Geometry().GetStack(det);
+  fPadPlane          = Geometry().GetPadPlane(layer,stack);
   fZShiftIdeal       = 0.5 * (fPadPlane->GetRow0() + fPadPlane->GetRowEnd());
 
   // Get the current transformation matrix
-  fMatrix            = fgGeo->GetClusterMatrix(det);
+  fMatrix            = Geometry().GetClusterMatrix(det);
 
 }
 
index f3dcf8ce73ef73f33d498cc963bc641f909d1476..c3ccf11bd931f1de87a6e0102d392ffb9b40dd80 100644 (file)
@@ -39,10 +39,9 @@ class AliTRDtransform : public TObject {
   virtual void     Recalibrate(AliTRDcluster *c, Bool_t setDet = kTRUE);
 
           void     SetDetector(Int_t det);
+  static  AliTRDgeometry& Geometry(); 
 
-protected:
-
-  static AliTRDgeometry *fgGeo;              //  TRD geometry
+  protected:
   Int_t               fDetector;            //  Detector number
 
   AliTRDCommonParam  *fParam;               //  TRD common parameters
index 1fb90073a8ddbd2a5c21304f3dc94cc02212db1c..0cdd9b6e7df8c56bb466296a9535fd6354b3f871 100644 (file)
@@ -25,7 +25,7 @@
 # SHLIBS - Shared Libraries and objects for linking (Executables only)           #
 #--------------------------------------------------------------------------------#
 
-set ( SRCS  AliTRDarraySignal.cxx AliTRDarrayDictionary.cxx AliTRDarrayADC.cxx AliTRDSignalIndex.cxx AliTRDgeometry.cxx AliTRDdigit.cxx AliTRDdigitsManager.cxx AliTRDdigitsParam.cxx AliTRDrawData.cxx AliTRDpadPlane.cxx AliTRDrawStream.cxx AliTRDCommonParam.cxx AliTRDfeeParam.cxx AliTRDgtuParam.cxx AliTRDcalibDB.cxx Cal/AliTRDCalROC.cxx Cal/AliTRDCalPad.cxx Cal/AliTRDCalDet.cxx Cal/AliTRDCalDCS.cxx Cal/AliTRDCalDCSFEE.cxx Cal/AliTRDCalDCSv2.cxx Cal/AliTRDCalDCSFEEv2.cxx Cal/AliTRDCalDCSPTR.cxx Cal/AliTRDCalDCSGTUBoardInfo.cxx Cal/AliTRDCalDCSGTUCtpOpc.cxx Cal/AliTRDCalDCSGTUSegment.cxx Cal/AliTRDCalDCSGTUTgu.cxx Cal/AliTRDCalDCSGTUTmu.cxx Cal/AliTRDCalDCSGTU.cxx Cal/AliTRDCalMonitoring.cxx Cal/AliTRDCalChamberStatus.cxx Cal/AliTRDCalPadStatus.cxx Cal/AliTRDCalSingleChamberStatus.cxx Cal/AliTRDCalPID.cxx AliTRDCalibraFit.cxx AliTRDCalibraMode.cxx AliTRDCalibraVector.cxx AliTRDCalibraVdriftLinearFit.cxx AliTRDCalibPadStatus.cxx AliTRDCalibChamberStatus.cxx AliTRDCalibViewer.cxx AliTRDCalibViewerGUI.cxx AliTRDEntriesInfo.cxx AliTRDPhInfo.cxx AliTRDPrfInfo.cxx AliTRDUshortInfo.cxx AliTRDQAChecker.cxx AliTRDPreprocessor.cxx AliTRDSaxHandler.cxx AliTRDDataDCS.cxx AliTRDSensor.cxx AliTRDSensorArray.cxx AliTRDalignment.cxx AliTRDtrapConfig.cxx AliTRDmcmSim.cxx AliTRDltuParam.cxx AliTRDtrapConfigHandler.cxx AliTRDtrackGTU.cxx AliTRDtrackletBase.cxx AliTRDtrackletGTU.cxx AliTRDtrackletMCM.cxx AliTRDtrackletWord.cxx AliTRDgtuSim.cxx AliTRDgtuTMU.cxx AliTRDhit.cxx AliTRDrecoParam.cxx AliTRDSimParam.cxx)
+set ( SRCS  AliTRDarraySignal.cxx AliTRDarrayDictionary.cxx AliTRDarrayADC.cxx AliTRDSignalIndex.cxx AliTRDgeometry.cxx AliTRDdigit.cxx AliTRDdigitsManager.cxx AliTRDdigitsParam.cxx AliTRDrawData.cxx AliTRDpadPlane.cxx AliTRDrawStream.cxx AliTRDCommonParam.cxx AliTRDfeeParam.cxx AliTRDgtuParam.cxx AliTRDcalibDB.cxx Cal/AliTRDCalROC.cxx Cal/AliTRDCalPad.cxx Cal/AliTRDCalDet.cxx Cal/AliTRDCalDCS.cxx Cal/AliTRDCalDCSFEE.cxx Cal/AliTRDCalDCSv2.cxx Cal/AliTRDCalDCSFEEv2.cxx Cal/AliTRDCalDCSPTR.cxx Cal/AliTRDCalDCSGTUBoardInfo.cxx Cal/AliTRDCalDCSGTUCtpOpc.cxx Cal/AliTRDCalDCSGTUSegment.cxx Cal/AliTRDCalDCSGTUTgu.cxx Cal/AliTRDCalDCSGTUTmu.cxx Cal/AliTRDCalDCSGTU.cxx Cal/AliTRDCalMonitoring.cxx Cal/AliTRDCalChamberStatus.cxx Cal/AliTRDCalPadStatus.cxx Cal/AliTRDCalSingleChamberStatus.cxx Cal/AliTRDCalPID.cxx Cal/AliTRDCalTrkAttach.cxx AliTRDCalibraFit.cxx AliTRDCalibraMode.cxx AliTRDCalibraVector.cxx AliTRDCalibraVdriftLinearFit.cxx AliTRDCalibPadStatus.cxx AliTRDCalibChamberStatus.cxx AliTRDCalibViewer.cxx AliTRDCalibViewerGUI.cxx AliTRDEntriesInfo.cxx AliTRDPhInfo.cxx AliTRDPrfInfo.cxx AliTRDUshortInfo.cxx AliTRDQAChecker.cxx AliTRDPreprocessor.cxx AliTRDSaxHandler.cxx AliTRDDataDCS.cxx AliTRDSensor.cxx AliTRDSensorArray.cxx AliTRDalignment.cxx AliTRDtrapConfig.cxx AliTRDmcmSim.cxx AliTRDltuParam.cxx AliTRDtrapConfigHandler.cxx AliTRDtrackGTU.cxx AliTRDtrackletBase.cxx AliTRDtrackletGTU.cxx AliTRDtrackletMCM.cxx AliTRDtrackletWord.cxx AliTRDgtuSim.cxx AliTRDgtuTMU.cxx AliTRDhit.cxx AliTRDrecoParam.cxx AliTRDSimParam.cxx)
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
 
index 637296b9826c8aaad95951827ddb1e87c3872990..9630aa9715ac45e31acde8f0f27b47b7ca9724ba 100644 (file)
@@ -25,7 +25,7 @@
 # SHLIBS - Shared Libraries and objects for linking (Executables only)           #
 #--------------------------------------------------------------------------------#
 
-set ( SRCS  AliTRDcluster.cxx AliTRDclusterizer.cxx AliTRDtransform.cxx AliTRDtracklet.cxx AliTRDpidUtil.cxx AliTRDpidESD.cxx AliTRDReconstructor.cxx AliTRDseedV1.cxx AliTRDtrackV1.cxx AliTRDtrackerV1.cxx AliTRDtrackerDebug.cxx AliTRDtrackingSector.cxx AliTRDtrackingChamber.cxx AliTRDchamberTimeBin.cxx AliTRDQADataMakerRec.cxx AliTRDqaBuildReference.cxx AliTRDCalibraFillHisto.cxx Cal/AliTRDCalPIDLQ.cxx Cal/AliTRDCalPIDNN.cxx AliTRDqaRecPoints.cxx)
+set ( SRCS  AliTRDcluster.cxx AliTRDclusterizer.cxx AliTRDtransform.cxx AliTRDtracklet.cxx AliTRDtrackletOflHelper.cxx AliTRDpidUtil.cxx AliTRDpidESD.cxx AliTRDReconstructor.cxx AliTRDseedV1.cxx AliTRDtrackV1.cxx AliTRDtrackerV1.cxx AliTRDtrackerDebug.cxx AliTRDtrackingSector.cxx AliTRDtrackingChamber.cxx AliTRDchamberTimeBin.cxx AliTRDQADataMakerRec.cxx AliTRDqaBuildReference.cxx AliTRDCalibraFillHisto.cxx Cal/AliTRDCalPIDLQ.cxx Cal/AliTRDCalPIDNN.cxx AliTRDqaRecPoints.cxx)
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
 
diff --git a/TRD/Cal/AliTRDCreateOCDBPIDLQ.C b/TRD/Cal/AliTRDCreateOCDBPIDLQ.C
new file mode 100644 (file)
index 0000000..d450823
--- /dev/null
@@ -0,0 +1,31 @@
+void AliTRDCreateOCDBPIDLQ(const char *fn){
+
+  TObjArray *content = new TObjArray;
+  TFile *in = TFile::Open(fn);
+  TKey *key = NULL;
+  TObject *tmp = NULL;
+  TIter iter(in->GetListOfKeys());
+  while((key = (TKey *)iter())){
+    tmp = key->ReadObj();
+    printf("Putting %s into the OCDB\n", tmp->GetName());
+    content->Add(tmp);
+  }
+
+  AliCDBMetaData *metaData= new AliCDBMetaData(); 
+  metaData->SetObjectClassName("TObjArray");
+  metaData->SetResponsible("Markus Fasel");
+  metaData->SetBeamPeriod(1);
+  metaData->SetAliRootVersion("05-21-01"); //root version
+  metaData->SetComment("TRD PID Reference Histos for the 1D Likelihood method");
+  
+  AliCDBId id("TRD/Calib/PIDLQ1D", 0, AliCDBRunRange::Infinity()); 
+  AliCDBManager *man = AliCDBManager::Instance();
+  AliCDBStorage *gStorLoc = man->GetStorage("local:///u/mfasel/OCDB");//$ALICE_ROOT/OCDB");
+  if (!gStorLoc) {
+    return;
+  }
+  gStorLoc->Put(content, id, metaData); 
+  in->Close();
+
+  return;
+}
\ No newline at end of file
index 80590907958051a17ec115ed3cb2fd2643276a84..6b8d0030a4d6c39a041a433dfad7a36e8a3ebdcb 100644 (file)
@@ -33,6 +33,7 @@ TObjArray* CreateRecoParamObject()
   rec->SetNameTitle("Default", "TRD Default Reco Param");\r
   rec->SetNameTitle("LOW", "TRD Low Flux Reco Param");\r
   rec->SetRawStreamVersion("DEFAULT");\r
+  rec->SetPIDmethod(AliTRDPIDResponse::kLQ1D);\r
   rec->SetXenon();\r
   rec->SetVertexConstrained();\r
   rec->SetSysCovMatrix(cov);\r
@@ -45,7 +46,7 @@ TObjArray* CreateRecoParamObject()
   rec->SetNMeanClusters(12.89);\r
   rec->SetNSigmaClusters(2.095);\r
   rec->SetRoadzMultiplicator(3.);\r
-  rec->SetPtThreshold(100.);\r
+  rec->SetPtThreshold(0.2);//100.);\r
   rec->SetStreamLevel(AliTRDrecoParam::kTracker, 1);\r
   rec->SetAsDefault();\r
 \r
@@ -53,6 +54,7 @@ TObjArray* CreateRecoParamObject()
   rec->SetEventSpecie(AliRecoParam::kHighMult);\r
   rec->SetNameTitle("HIGH", "TRD High Flux Reco Param");\r
   rec->SetRawStreamVersion("DEFAULT");\r
+  rec->SetPIDmethod(AliTRDPIDResponse::kLQ1D);\r
   rec->SetXenon();\r
   rec->SetVertexConstrained();\r
   rec->SetSysCovMatrix(cov);\r
@@ -64,15 +66,16 @@ TObjArray* CreateRecoParamObject()
   rec->SetMaxPhi(2.7475);\r
   rec->SetNMeanClusters(12.89);\r
   rec->SetNSigmaClusters(2.095);\r
-  rec->SetPtThreshold(100.);\r
+  rec->SetPtThreshold(0.2);//100.);\r
   rec->SetStreamLevel(AliTRDrecoParam::kTracker, 1);\r
  \r
   recos->AddLast(rec = AliTRDrecoParam::GetCosmicTestParam());\r
   rec->SetEventSpecie(AliRecoParam::kCosmic);\r
   rec->SetNameTitle("COSMIC", "TRD Cosmic Reco Param");\r
   rec->SetRawStreamVersion("DEFAULT");\r
+  rec->SetPIDmethod(AliTRDPIDResponse::kLQ1D);\r
   rec->SetXenon();\r
-//  rec->SetPtThreshold(100.);\r
+  rec->SetPtThreshold(0.2);\r
   rec->SetStreamLevel(AliTRDrecoParam::kTracker, 1);\r
 \r
   recos->AddLast(rec = AliTRDrecoParam::GetCosmicTestParam());\r
@@ -80,8 +83,6 @@ TObjArray* CreateRecoParamObject()
   rec->SetNameTitle("CALIBRATION", "TRD Calibration Reco Param");\r
   rec->SetRawStreamVersion("DEFAULT");\r
   rec->SetXenon();\r
-//  rec->SetPtThreshold(100.);\r
-  rec->SetStreamLevel(AliTRDrecoParam::kTracker, 1);\r
 \r
   return recos;\r
 }\r
diff --git a/TRD/Cal/AliTRDmakeTrkDB.C b/TRD/Cal/AliTRDmakeTrkDB.C
new file mode 100644 (file)
index 0000000..665222d
--- /dev/null
@@ -0,0 +1,28 @@
+//____________________________________________________\r
+void AliTRDmakeTrkDB(const Char_t *file)\r
+{\r
+  AliCDBManager *man = AliCDBManager::Instance();\r
+  AliCDBStorage *gStorLoc = man->GetStorage("local://$ALICE_ROOT/OCDB");\r
+  if (!gStorLoc) return;\r
+  \r
+  // Attach clusters likelihoods\r
+  AliCDBMetaData *metaData= new AliCDBMetaData(); \r
+  metaData->SetObjectClassName("TObjArray");\r
+  metaData->SetResponsible("Alexandru Bercuci");\r
+  metaData->SetBeamPeriod(1);\r
+  metaData->SetAliRootVersion("05-27-06b"); //root version\r
+  metaData->SetComment(\r
+    "Likelihoods for Attach Cluster.\n"\r
+    " Tunned on Pb-Pb run 137161.");\r
+  AliCDBId id("TRD/Calib/TrkAttach", 95352, AliCDBRunRange::Infinity()); \r
+  AliTRDCalTrkAttach attach;\r
+  if(!attach.LoadReferences(file)) return;\r
+//   attach.SetNsgmDy(Int_t ns0, Int_t ns1);\r
+//   attach.SetLikeMinRelDecrease(Float_t p0, Float_t p1);\r
+//   attach.SetRClikeLimit(Float_t rc);\r
+  attach.SetScaleCov(5.);\r
+  gStorLoc->Put(&attach, id, metaData); \r
+\r
+  return;\r
+}\r
+\r
index 0c0d046c3357e3f27554bceb9ced8d4ea8d1ccec..47a1e05b2d4c817de1ccb213e4ced0cb043f6ab8 100644 (file)
@@ -56,6 +56,7 @@
 #pragma link C++ class  AliTRDCalPadStatus+;
 #pragma link C++ class  AliTRDCalSingleChamberStatus+;
 #pragma link C++ class  AliTRDCalPID+;
+#pragma link C++ class  AliTRDCalTrkAttach+;
 
 #pragma link C++ class  AliTRDalignment+;
 
index 2f09265c291a6c24128dcb3fa6116a116574ed1d..c74de77a89fdda5e3b116e8ce7e1e4db1a2da2ab 100644 (file)
@@ -18,6 +18,7 @@
 #pragma link C++ class  AliTRDReconstructor+;
 
 #pragma link C++ class  AliTRDtracklet+;
+#pragma link C++ class  AliTRDtrackletOflHelper+;
 #pragma link C++ class  AliTRDseedV1+;
 #pragma link C++ class  AliTRDtrackV1+;
 #pragma link C++ class  AliTRDtrackerV1+;