]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDseedV1.cxx
Speed increase (mainly for offline), at least factor 2 for whole TRD offline reconstr...
[u/mrichter/AliRoot.git] / TRD / AliTRDseedV1.cxx
index 876be636461e27a7c4e6d900681072fd64359a91..97237408a037ea48c0bf552ee45f412c39f319a9 100644 (file)
@@ -53,7 +53,6 @@
 #include "AliTRDchamberTimeBin.h"
 #include "AliTRDtrackingChamber.h"
 #include "AliTRDtrackerV1.h"
-#include "AliTRDReconstructor.h"
 #include "AliTRDrecoParam.h"
 #include "AliTRDCommonParam.h"
 
@@ -63,6 +62,9 @@
 
 ClassImp(AliTRDseedV1)
 
+TLinearFitter *AliTRDseedV1::fgFitterY = 0x0;
+TLinearFitter *AliTRDseedV1::fgFitterZ = 0x0;
+
 //____________________________________________________________________
 AliTRDseedV1::AliTRDseedV1(Int_t det) 
   :AliTRDtrackletBase()
@@ -91,7 +93,7 @@ AliTRDseedV1::AliTRDseedV1(Int_t det)
   //
   // Constructor
   //
-  for(Int_t ic=kNclusters; ic--;) fIndexes[ic] = -1;
+  memset(fIndexes,0xFF,kNclusters*sizeof(fIndexes[0]));
   memset(fClusters, 0, kNclusters*sizeof(AliTRDcluster*));
   memset(fPad, 0, 3*sizeof(Float_t));
   fYref[0] = 0.; fYref[1] = 0.; 
@@ -558,10 +560,15 @@ Bool_t AliTRDseedV1::CookPID()
 // Output
 //   returns pointer to the probability array and 0x0 if missing DB access 
 //
-// Detailed description
+// Retrieve PID probabilities for e+-, mu+-, K+-, pi+- and p+- from the DB according to tracklet information:
+// - estimated momentum at tracklet reference point 
+// - dE/dx measurements
+// - tracklet length
+// - TRD layer
+// According to the steering settings specified in the reconstruction one of the following methods are used
+// - Neural Network [default] - option "nn"  
+// - 2D Likelihood - option "!nn"  
 
-  
-  // retrive calibration db
   AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
   if (!calibration) {
     AliError("No access to calibration data");
@@ -589,10 +596,17 @@ Bool_t AliTRDseedV1::CookPID()
   CookdEdx(fReconstructor->GetNdEdxSlices());
   
   // Sets the a priori probabilities
-  for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) {
-    fProb[ispec] = pd->GetProbability(ispec, GetMomentum(), &fdEdx[0], length, GetPlane());    
+  if(fReconstructor->IsHLT()){
+    // this can be done here, because in HLT we have another NN
+    // don't run HLT with the normal NN because here we assume that the NN was trained with only two output neurons!
+    memset(fProb,0,AliPID::kSPECIES*sizeof(fProb[0]));
+    fProb[AliPID::kElectron] = pd->GetProbability(AliPID::kElectron, GetMomentum(), &fdEdx[0], length, GetPlane());
+    fProb[AliPID::kPion] = 1 - fProb[AliPID::kElectron];
   }
-
+  else
+    for(int ispec=0; ispec<AliPID::kSPECIES; ispec++)
+      fProb[ispec] = pd->GetProbability(ispec, GetMomentum(), &fdEdx[0], length, GetPlane());
+  
   return kTRUE;
 }
 
@@ -759,6 +773,21 @@ UShort_t AliTRDseedV1::GetVolumeId() const
   return fClusters[ic] ? fClusters[ic]->GetVolumeId() : 0;
 }
 
+//____________________________________________________________________
+TLinearFitter* AliTRDseedV1::GetFitterY()
+{
+  if(!fgFitterY) fgFitterY = new TLinearFitter(1, "pol1");
+  fgFitterY->ClearPoints();
+  return fgFitterY;
+}
+
+//____________________________________________________________________
+TLinearFitter* AliTRDseedV1::GetFitterZ()
+{
+  if(!fgFitterZ) fgFitterZ = new TLinearFitter(1, "pol1");
+  fgFitterZ->ClearPoints();
+  return fgFitterZ;
+}
 
 //____________________________________________________________________
 void AliTRDseedV1::Calibrate()
@@ -864,7 +893,8 @@ Bool_t      AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *chamber, Bool_t tilt)
 // r_{z} = 1.5*L_{pad}
 // END_LATEX
 // 
-// Author Alexandru Bercuci <A.Bercuci@gsi.de>
+// Author : Alexandru Bercuci <A.Bercuci@gsi.de>
+// Debug  : level >3
 
   Bool_t kPRINT = kFALSE;
   if(!fReconstructor->GetRecoParam() ){
@@ -887,24 +917,26 @@ Bool_t    AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *chamber, Bool_t tilt)
   // 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(fReconstructor->IsHLT())cp.SetRPhiMethod(AliTRDcluster::kCOG);
   Calibrate();
 
   if(kPRINT) printf("AttachClusters() sy[%f] road[%f]\n", syRef, kroady);
 
   // working variables
   const Int_t kNrows = 16;
-  AliTRDcluster *clst[kNrows][kNclusters];
-  Double_t cond[4], dx, dy, yt, zt,
-    yres[kNrows][kNclusters];
-  Int_t idxs[kNrows][kNclusters], ncl[kNrows], ncls = 0;
+  const Int_t kNcls  = 3*kNclusters; // buffer size
+  AliTRDcluster *clst[kNrows][kNcls];
+  Double_t cond[4], dx, dy, yt, zt, yres[kNrows][kNcls];
+  Int_t idxs[kNrows][kNcls], ncl[kNrows], ncls = 0;
   memset(ncl, 0, kNrows*sizeof(Int_t));
-  memset(clst, 0, kNrows*kNclusters*sizeof(AliTRDcluster*));
+  memset(yres, 0, kNrows*kNcls*sizeof(Double_t));
+  memset(clst, 0, kNrows*kNcls*sizeof(AliTRDcluster*));
 
   // Do cluster projection
   AliTRDcluster *c = 0x0;
   AliTRDchamberTimeBin *layer = 0x0;
   Bool_t kBUFFER = kFALSE;
-  for (Int_t it = 0; it < AliTRDtrackerV1::GetNTimeBins(); it++) {
+  for (Int_t it = 0; it < kNtb; it++) {
     if(!(layer = chamber->GetTB(it))) continue;
     if(!Int_t(*layer)) continue;
     // get track projection at layers position
@@ -941,8 +973,8 @@ Bool_t      AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *chamber, Bool_t tilt)
       yres[r][ncl[r]] = dy;
       ncl[r]++; ncls++;
 
-      if(ncl[r] >= kNclusters) {
-        AliWarning(Form("Cluster candidates reached limit %d. Some may be lost.", kNclusters));
+      if(ncl[r] >= kNcls) {
+        AliWarning(Form("Cluster candidates reached buffer limit %d. Some may be lost.", kNcls));
         kBUFFER = kTRUE;
         break;
       }
@@ -968,6 +1000,23 @@ Bool_t    AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *chamber, Bool_t tilt)
       continue;
     } 
 
+    if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) > 3){
+      TTreeSRedirector &cstreamer = *fReconstructor->GetDebugStream(AliTRDReconstructor::kTracker);
+      TVectorD vdy(ncl[ir], yres[ir]);
+      UChar_t stat(0);
+      if(IsKink()) SETBIT(stat, 0);
+      if(IsStandAlone()) SETBIT(stat, 1);
+      cstreamer << "AttachClusters"
+          << "stat="   << stat
+          << "det="    << fDet
+          << "pt="     << fPt
+          << "s2y="    << s2yTrk
+          << "dy="     << &vdy
+          << "m="      << mean
+          << "s="      << syDis
+          << "\n";
+    }
+
     // TODO check mean and sigma agains cluster resolution !!
     if(kPRINT) printf("\tr[%2d] m[%f %5.3fsigma] s[%f]\n", ir, mean, TMath::Abs(mean/syDis), syDis);
     // select clusters on a 3 sigmaDistr level
@@ -1195,9 +1244,9 @@ Bool_t AliTRDseedV1::Fit(Bool_t tilt, Bool_t zcorr)
   Double_t yt, zt;
 
   //AliTRDtrackerV1::AliTRDLeastSquare fitterZ;
-  TLinearFitter  fitterY(1, "pol1");
-  TLinearFitter  fitterZ(1, "pol1");
-  
+  TLinearFitter& fitterY=*GetFitterY();
+  TLinearFitter& fitterZ=*GetFitterZ();
+
   // book cluster information
   Double_t qc[kNclusters], xc[kNclusters], yc[kNclusters], zc[kNclusters], sy[kNclusters];