Moved to hlt-cern branch, containing fixes since August 03 and upcoming changes for...
authorloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 22 Sep 2003 14:07:50 +0000 (14:07 +0000)
committerloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 22 Sep 2003 14:07:50 +0000 (14:07 +0000)
44 files changed:
HLT/Makefile.rules
HLT/comp/AliL3CompLinkDef.h
HLT/comp/AliL3Compress.cxx
HLT/comp/AliL3DataCompressor.cxx
HLT/comp/AliL3DataCompressor.h
HLT/comp/AliL3ModelTrack.cxx
HLT/comp/AliL3Models.h
HLT/comp/AliL3OfflineDataCompressor.cxx [new file with mode: 0644]
HLT/comp/AliL3OfflineDataCompressor.h [new file with mode: 0644]
HLT/comp/Makefile
HLT/doc/changelog.comp
HLT/doc/changelog.doc
HLT/doc/changelog.exa
HLT/doc/changelog.hough
HLT/doc/changelog.kalman
HLT/doc/changelog.src
HLT/doc/changelog.top
HLT/exa/rootlogon.C
HLT/hough/AliL3Histogram.cxx
HLT/hough/AliL3Histogram.h
HLT/hough/AliL3HistogramAdaptive.cxx
HLT/hough/AliL3HistogramAdaptive.h
HLT/hough/AliL3HoughIntMerger.cxx
HLT/hough/AliL3HoughMerger.cxx
HLT/kalman/AliL3Kalman.cxx
HLT/kalman/AliL3Kalman.h
HLT/kalman/AliL3KalmanLinkDef.h [new file with mode: 0644]
HLT/kalman/AliL3KalmanTrack.cxx
HLT/kalman/AliL3KalmanTrack.h
HLT/kalman/Makefile [new file with mode: 0644]
HLT/src/AliL3ConfMapper.cxx
HLT/src/AliL3ConfMapper.h
HLT/src/AliL3Display.cxx
HLT/src/AliL3Display.h
HLT/src/AliL3Fitter.cxx
HLT/src/AliL3Fitter.h
HLT/src/AliL3GlobalMerger.cxx
HLT/src/AliL3GlobalMerger.h
HLT/src/AliL3InterMerger.cxx
HLT/src/AliL3Merger.cxx
HLT/src/AliL3Merger.h
HLT/src/AliL3TrackMerger.cxx
HLT/src/AliLevel3.cxx
HLT/src/AliLevel3.h

index cc7e1b8811720e5d122f28b7b56c7b00d154bdf7..21be933a0376e6101467422f08b522bd8ecdf460 100644 (file)
@@ -13,7 +13,7 @@
 
 DEFSTR = -Dno_root
 OBJDIR = lib_alone
-INCLUDES = -I$(ALIHLT_TOPDIR)/hough -I$(ALIHLT_TOPDIR)/src -I$(ALIHLT_TOPDIR)/comp -I$(ALIHLT_TOPDIR)/misc -I$(ALIHLT_TOPDIR)/trigger
+INCLUDES = -I$(ALIHLT_TOPDIR)/hough -I$(ALIHLT_TOPDIR)/src -I$(ALIHLT_TOPDIR)/comp -I$(ALIHLT_TOPDIR)/misc -I$(ALIHLT_TOPDIR)/trigger -I$(ALIHLT_TOPDIR)/kalman
 
 ifeq ($(ALIHLT_USEPACKAGE),ROOT) 
 INCLUDES += -I$(ROOTSYS)/include 
index 26e2bd205e10200dba9ffbe0dd22dfa4c9a03773..69530250bb6830e63fa19242f766fa973fcc4104 100644 (file)
@@ -12,5 +12,9 @@
 #pragma link C++ class AliL3ClusterFitter; 
 #pragma link C++ class AliL3DataCompressor; 
 
+#ifdef use_aliroot
+#pragma link C++ class AliL3OfflineDataCompressor; 
+#endif
+
 #endif
 
index f7142b743534819498db53b39df3067e6de4107a..b842b70ea7f45a6cb85f43b766dc38f0386f3d7d 100644 (file)
@@ -98,10 +98,11 @@ Bool_t AliL3Compress::WriteFile(AliL3TrackArray *tracks,Char_t *filename)
       
       track->FillModel();
       model = track->GetModel();
-      if(model->fNClusters==0) continue;
+      //if(model->fNClusters==0) continue;
       clusters = track->GetClusters();
       if(fwrite(model,sizeof(AliL3TrackModel),1,file)!=1) break;
-      if(fwrite(clusters,model->fNClusters*sizeof(AliL3ClusterModel),1,file)!=1) break;
+      //if(fwrite(clusters,model->fNClusters*sizeof(AliL3ClusterModel),1,file)!=1) break;
+      if(fwrite(clusters,AliL3Transform::GetNRows(fPatch)*sizeof(AliL3ClusterModel),1,file)!=1) break;
       count++;
       
     }
@@ -157,7 +158,8 @@ Bool_t AliL3Compress::ReadFile(Char_t which,Char_t *filename)
       AliL3TrackModel *model = track->GetModel();
       AliL3ClusterModel *clusters = track->GetClusters();
       if(fread(model,sizeof(AliL3TrackModel),1,file)!=1) break;
-      if(fread(clusters,model->fNClusters*sizeof(AliL3ClusterModel),1,file)!=1) break;
+      //if(fread(clusters,model->fNClusters*sizeof(AliL3ClusterModel),1,file)!=1) break;
+      if(fread(clusters,AliL3Transform::GetNRows(fPatch)*sizeof(AliL3ClusterModel),1,file)!=1) break;
       track->FillTrack();
     }
 
@@ -211,7 +213,7 @@ Bool_t AliL3Compress::CompressFile()
       fwrite(&track,sizeof(AliL3TrackModel),1,output->file);
       
       Int_t origslice=-1,slice,clustercount=0;
-      for(Int_t i=0; i<track.fNClusters; i++)
+      for(Int_t i=0; i<AliL3Transform::GetNRows(fPatch); i++)
        {
          if(fread(&cluster,sizeof(AliL3ClusterModel),1,input)!=1) break;
          
@@ -365,7 +367,7 @@ Bool_t AliL3Compress::ExpandFile()
 
       memset(clusters,0,AliL3Transform::GetNRows(fPatch)*sizeof(AliL3ClusterModel));
       Int_t origslice=-1,clustercount=0;
-      for(Int_t i=0; i<trackmodel.fNClusters; i++)
+      for(Int_t i=0; i<AliL3Transform::GetNRows(fPatch); i++)
        {
          Int_t temp,sign;
          
@@ -434,8 +436,8 @@ Bool_t AliL3Compress::ExpandFile()
          clustercount++;
        }
       count++;
-      fwrite(clusters,(trackmodel.fNClusters)*sizeof(AliL3ClusterModel),1,output);
-      
+      //fwrite(clusters,(trackmodel.fNClusters)*sizeof(AliL3ClusterModel),1,output);
+      fwrite(clusters,AliL3Transform::GetNRows(fPatch)*sizeof(AliL3ClusterModel),1,output);
     }
   
   delete [] clusters;
@@ -477,8 +479,8 @@ void AliL3Compress::PrintCompRatio(ofstream *outfile)
   
   if(digit_size==0)
     {
-      cerr<<"AliL3Compress::PrintCompRatio : Zero digit size "<<endl;
-      exit(5);
+      cerr<<"AliL3Compress::PrintCompRatio : Zero digit size, not able to obtain comp. ratios!"<<endl;
+      return;
     }
   
   Float_t compratio = (Float_t)(compress_size + remain_size)/(Float_t)digit_size;
index 372074c9be257bb4c063a9ac5d0f4159fb2573bf..ffba8f77340d47c85e9c8d816cd2d8e5eb951f9c 100644 (file)
 
 #ifdef use_aliroot
 #include "AliL3FileHandler.h"
-
-#include <AliKalmanTrack.h>
-#include <AliTPCtracker.h>
 #include <AliTPCcluster.h>
 #include <AliTPCParamSR.h>
 #include <AliTPCDigitsArray.h>
 #include <AliTPCClustersArray.h>
-#include <AliTPCcluster.h>
 #include <AliTPCClustersRow.h>
 #include <AliSimDigits.h>
 #include <AliTPC.h>
@@ -61,8 +57,12 @@ Int_t AliL3DataCompressor::fNumTimeBits = 12;
 Int_t AliL3DataCompressor::fNumPadBits = 12;
 Int_t AliL3DataCompressor::fNumChargeBits = 14;
 Int_t AliL3DataCompressor::fNumShapeBits = 14;
-Float_t AliL3DataCompressor::fXYResidualStep = 0.03;
-Float_t AliL3DataCompressor::fZResidualStep = 0.05;
+Float_t AliL3DataCompressor::fXYResidualStep1 = 0.03;
+Float_t AliL3DataCompressor::fXYResidualStep2 = 0.03;
+Float_t AliL3DataCompressor::fXYResidualStep3 = 0.03;
+Float_t AliL3DataCompressor::fZResidualStep1 = 0.05;
+Float_t AliL3DataCompressor::fZResidualStep2 = 0.05;
+Float_t AliL3DataCompressor::fZResidualStep3 = 0.05;
 Float_t AliL3DataCompressor::fXYWidthStep = 0.005;
 Float_t AliL3DataCompressor::fZWidthStep = 0.005;
 Int_t AliL3DataCompressor::fClusterCharge = 100;
@@ -126,13 +126,50 @@ void AliL3DataCompressor::SetBitNumbers(Int_t pad,Int_t time,Int_t charge,Int_t
   fNumShapeBits = shape;
 }
 
-void AliL3DataCompressor::SetResolutions(Float_t xyresidual,Float_t zresidual,Int_t clustercharge,Float_t xywidth,Float_t zwidth)
+void AliL3DataCompressor::SetTransverseResolutions(Float_t res1,Float_t res2,Float_t res3,Float_t width)
+{
+  fXYResidualStep1 = res1;
+  fXYResidualStep2 = res2;
+  fXYResidualStep3 = res3;
+  fXYWidthStep = width;
+}
+
+void AliL3DataCompressor::SetLongitudinalResolutions(Float_t res1,Float_t res2,Float_t res3,Float_t width)
+{
+  fZResidualStep1 = res1;
+  fZResidualStep2 = res2;
+  fZResidualStep3 = res3;
+  fZWidthStep = width;
+}
+
+const Float_t AliL3DataCompressor::GetXYResidualStep(Int_t row) 
 {
-  fXYResidualStep = xyresidual;
-  fZResidualStep = zresidual;
-  fXYWidthStep = xywidth;
-  fZWidthStep = zwidth;
-  fClusterCharge = clustercharge;
+  if(row < AliL3Transform::GetNRowLow())
+    return fXYResidualStep1;
+  else if(row < AliL3Transform::GetNRowLow() + AliL3Transform::GetNRowUp1())
+    return fXYResidualStep2;
+  else if(row < AliL3Transform::GetNRowLow() + AliL3Transform::GetNRowUp1() + AliL3Transform::GetNRowUp2())
+    return fXYResidualStep3;
+  else
+    {
+      cerr<<"AliL3DataCompressor::GetXYResidualStep : Wrong row number "<<row<<endl;
+      return -1;
+    }
+}
+
+const Float_t AliL3DataCompressor::GetZResidualStep(Int_t row) 
+{
+  if(row < AliL3Transform::GetNRowLow())
+    return fZResidualStep1;
+  else if(row < AliL3Transform::GetNRowLow() + AliL3Transform::GetNRowUp1())
+    return fZResidualStep2;
+  else if(row < AliL3Transform::GetNRowLow() + AliL3Transform::GetNRowUp1() + AliL3Transform::GetNRowUp2())
+    return fZResidualStep3;
+  else
+    {
+      cerr<<"AliL3DataCompressor::GetXYResidualStep : Wrong row number "<<row<<endl;
+      return -1;
+    }
 }
 
 void AliL3DataCompressor::OpenOutputFile()
@@ -271,8 +308,9 @@ void AliL3DataCompressor::FillData(Int_t min_hits,Bool_t expand)
          if(!intrack->CalculateReferencePoint(angle,AliL3Transform::Row2X(padrow)))
            {
              cerr<<"AliL3DataCompressor::FillData : Error in crossing point calc on slice "<<slice<<" row "<<padrow<<endl;
-             outtrack->Print(kFALSE);
-             exit(5);
+             break;
+             //outtrack->Print(kFALSE);
+             //exit(5);
            }
          
          Float_t xyz_cross[3] = {intrack->GetPointX(),intrack->GetPointY(),intrack->GetPointZ()};
@@ -380,11 +418,11 @@ void AliL3DataCompressor::ExpandTrackData(AliL3TrackArray *tracks)
              AliL3Transform::Global2Local(xyz,last_slice,kTRUE);
              
              //Check for overflow:
-             Int_t temp = (Int_t)rint((xyz_cross[1]-xyz[1])/GetXYResidualStep());
+             Int_t temp = (Int_t)rint((xyz_cross[1]-xyz[1])/GetXYResidualStep(padrow));
              if( abs(temp) > 1<<(GetNPadBits()-1))
                continue;
              
-             temp = (Int_t)rint((xyz_cross[2]-xyz[2])/GetZResidualStep());
+             temp = (Int_t)rint((xyz_cross[2]-xyz[2])/GetZResidualStep(padrow));
              if( abs(temp) > 1<<(GetNTimeBits()-1))
                continue;
              
@@ -546,7 +584,17 @@ void AliL3DataCompressor::WriteRemaining(Bool_t select)
 void AliL3DataCompressor::SelectRemainingClusters()
 {
   //Select which remaining clusters to write in addition to the compressed data.
-
+  //In particular one can here make sure that "important" clusters are not missed:
+  //The offline track finder perform seed finding in the outer padrows;
+  //the first seeding is using pair of points on outermost padrow and 
+  //0.125*nrows more rows towards the vertex. The second seeding uses pair
+  //of points on the outermost padrow-0.5*0.125*nrows and 0.125*nrows + 0.5*0.125*nrows
+  //more rows towards the vertex. In order to evaluate the seeds, the track offline
+  //track finder checks whether a certain amount of possible clusters (padrows) is 
+  //attached to the track, and then the kalman filtering starts.
+  //To ensure a minimal loss off efficiency, all clusters in this region should be
+  //intact.....
+  
   cout<<"Cleaning up clusters"<<endl;
   Int_t nrows = AliL3Transform::GetNRows();
   Int_t gap=(Int_t)(0.125*nrows), shift=(Int_t)(0.5*gap);
@@ -565,12 +613,13 @@ void AliL3DataCompressor::SelectRemainingClusters()
          AliL3Transform::Slice2Sector(slice,padrow,sector,row);
          AliL3Transform::Global2Raw(xyz,sector,row);
          
-         if(padrow >= nrows-1-gap-shift) continue;
+         if(padrow >= nrows-1-gap-shift) continue;//save all the clusters in this region
+         
          //if(padrow >= nrows-1-shift) continue;
 
          //Save the clusters at the borders:
-         if(xyz[1] < 3 || xyz[1] >= AliL3Transform::GetNPads(padrow)-4)
-           continue;
+         //if(xyz[1] < 3 || xyz[1] >= AliL3Transform::GetNPads(padrow)-4)
+         // continue;
 
          //Save clusters on padrows used for offline seeding:
          if(padrow == nrows - 1 || padrow == nrows - 1 - gap ||                 //First seeding
@@ -596,7 +645,7 @@ void AliL3DataCompressor::CompressAndExpand()
 }
 
 
-void AliL3DataCompressor::RestoreData()
+void AliL3DataCompressor::RestoreData(Bool_t remaining_only)
 {
   //Restore the uncompressed data together with the remaining clusters,
   //and write to a final cluster file which serves as an input to the
@@ -618,7 +667,8 @@ void AliL3DataCompressor::RestoreData()
       clusters[i] = new TempCluster[maxpoints];
     }
   
-  ReadUncompressedData(clusters,ncl,maxpoints);
+  if(!remaining_only)
+    ReadUncompressedData(clusters,ncl,maxpoints);
   
   if(fKeepRemaining)
     ReadRemaining(clusters,ncl,maxpoints);
@@ -941,193 +991,3 @@ Int_t AliL3DataCompressor::Compare(TempCluster *a,TempCluster *b)
   return 1;
 }
 
-void AliL3DataCompressor::LoadOfflineData(Int_t event)
-{
-  //Take offline reconstructed tracks as an input.
-  //In this case, no remaining clusters are written.
-  
-#ifndef use_aliroot
-   LOG(AliL3Log::kError,"AliL3DataCompressor::LoadOfflineData","Version")
-     <<"You have to compile with use_aliroot flag in order to use this function"<<ENDLOG;
-#else
-
-  char filename[1024];
-  
-  AliKalmanTrack::SetConvConst(1000/0.299792458/AliL3Transform::GetSolenoidField());
-  sprintf(filename,"%s/offline/AliTPCclusters.root",fPath);
-
-  TFile *in = TFile::Open(filename);
-  AliTPCParam *param=(AliTPCParam*)in->Get("75x40_100x60_150x60");
-  
-  AliTPCtracker *tracker = new AliTPCtracker(param);
-  tracker->SetEventNumber(event);
-  tracker->LoadClusters();
-  
-  const Int_t MAX=20000;
-  Int_t nentr=0,i=0; TObjArray tarray(MAX);
-  sprintf(filename,"%s/offline/AliTPCtracks.root",fPath);
-  TFile *tf=TFile::Open(filename);
-  
-  char tname[100]; sprintf(tname,"TreeT_TPC_%d",event);
-  TTree *tracktree=(TTree*)tf->Get(tname);
-  
-  TBranch *tbranch=tracktree->GetBranch("tracks");
-  nentr=(Int_t)tracktree->GetEntries();
-  AliTPCtrack *iotrack=0;
-
-  for (i=0; i<nentr; i++) {
-    iotrack=new AliTPCtrack;
-    tbranch->SetAddress(&iotrack);
-    tracktree->GetEvent(i);
-    tarray.AddLast(iotrack);
-  }   
-  delete tracktree; 
-  tf->Close();
-  
-  AliL3TrackArray *comptracks = new AliL3TrackArray("AliL3ModelTrack");
-  cout<<"Loaded "<<nentr<<" offline tracks"<<endl;
-  Int_t slice,padrow;
-  Int_t totcounter=0;
-  for(i=0; i<nentr; i++)
-    {
-      
-      AliTPCtrack *track=(AliTPCtrack*)tarray.UncheckedAt(i);
-      Int_t nhits = track->GetNumberOfClusters();
-      Int_t idx = track->GetClusterIndex(nhits-1);
-      Int_t sec=(idx&0xff000000)>>24, row=(idx&0x00ff0000)>>16;
-      
-      if(sec >= 18)
-       sec += 18;
-      
-      AliL3Transform::Sector2Slice(slice,padrow,sec,row);
-      Double_t par[5],xk=AliL3Transform::Row2X(padrow);
-      track->PropagateTo(xk);
-      track->GetExternalParameters(xk,par);
-      Double_t psi = TMath::ASin(par[2]) + track->GetAlpha();
-      if (psi<-TMath::Pi()) psi+=2*TMath::Pi();
-      if (psi>=TMath::Pi()) psi-=2*TMath::Pi();
-      Float_t pt_1=TMath::Abs(par[4]);
-      Int_t charge = 1;
-      if(par[4] > 0)
-       charge=-1;
-
-      Float_t first[3];
-      AliCluster *fcl = tracker->GetCluster(idx);
-      first[0] = xk;
-      first[1] = fcl->GetY();
-      first[2] = fcl->GetZ();
-
-      AliL3Transform::Local2Global(first,slice);
-      
-      AliL3ModelTrack *outtrack = (AliL3ModelTrack*)comptracks->NextTrack();
-      outtrack->SetNHits(nhits);
-      outtrack->SetFirstPoint(first[0],first[1],first[2]);
-      outtrack->SetPt(1/pt_1);
-      outtrack->SetPsi(psi);
-      outtrack->SetTgl(par[3]);
-      outtrack->SetCharge(charge);
-      outtrack->CalculateHelix();
-      outtrack->Init(0,-1);
-
-      //for(int j=0; j<nhits; j++)
-      for(int j=nhits-1; j>=0; j--)
-       {
-         Int_t index = track->GetClusterIndex(j);
-         
-         Float_t xyz[3];
-         Int_t clustercharge =0;
-         
-         AliTPCcluster *cluster = (AliTPCcluster*)tracker->GetCluster(index);
-         xyz[1] = cluster->GetY();
-         xyz[2] = cluster->GetZ();
-         clustercharge = (Int_t)cluster->GetQ();
-         
-         cluster->SetQ(-clustercharge);//Set as used
-         
-         sec=(index&0xff000000)>>24; row=(index&0x00ff0000)>>16;
-         
-         //This we do because the sector numbering of course are different internally
-         //in the fucked up AliTPCtracker class. 
-         if(sec >= 18)
-           sec += 18;
-         
-         if(xyz[2] < 0)
-           sec += 18;
-
-         //cout<<"sector "<<sec<<" row "<<row<<endl;
-         if(!AliL3Transform::Sector2Slice(slice,padrow,sec,row))
-           exit(5);
-         xyz[0] = AliL3Transform::Row2X(padrow);
-         
-         //cout<<"Hit in slice "<<slice<<" padrow "<<padrow<<" y "<<cluster->GetY()<<" z "<<cluster->GetZ()<<endl;
-         AliL3Transform::Local2Raw(xyz,sec,row);
-         //cout<<"slice "<<slice<<" padrow "<<padrow<<" pad "<<xyz[1]<<" time "<<xyz[2]<<endl;
-         
-         if(xyz[1] < -1 || xyz[1] > AliL3Transform::GetNPads(padrow) ||
-            xyz[2] < -1 || xyz[2] > AliL3Transform::GetNTimeBins())
-           {
-             cerr<<"AliL3DataCompressor::FillOfflineData : Wrong time "<<xyz[2]<<" in slice "
-                 <<slice<<" padrow "<<padrow<<endl;
-             cout<<"sector "<<sec<<" row "<<row<<endl;
-             //cout<<"Hit in slice "<<slice<<" padrow "<<padrow<<" y "<<cluster->GetY()<<" z "<<cluster->GetZ()<<endl;
-             cout<<"Track hit "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
-             exit(5);
-           }
-         
-         Float_t angle = 0;
-         AliL3Transform::Local2GlobalAngle(&angle,slice);
-         if(!outtrack->CalculateReferencePoint(angle,AliL3Transform::Row2X(padrow)))
-           {
-             cerr<<"AliL3DataCompressor::FillOfflineData : Error in crossing point calc on slice "
-                 <<slice<<" row "<<padrow<<endl;
-             exit(5);
-           }
-         Float_t xyz_cross[3] = {outtrack->GetPointX(),outtrack->GetPointY(),outtrack->GetPointZ()};
-         AliL3Transform::Global2Raw(xyz_cross,sec,row);
-         /*
-           if(fabs(xyz_cross[1] - xyz[1]) > 10 ||
-           fabs(xyz_cross[2] - xyz[2]) > 10)
-           {
-           cout<<"AliL3DataCompressor::FillOfflineData : Wrong crossing slice "<<slice<<" padrow "
-           <<padrow<<" pad "<<xyz[1]<<" padhit "<<xyz_cross[1]<<" time "<<xyz[2]<<" timehit "<<xyz_cross[2]<<endl;
-           outtrack->Print();
-           exit(5);
-           }
-         */
-         //cout<<" crossing "<<xyz_cross[0]<<" "<<xyz_cross[1]<<" "<<xyz_cross[2]<<endl;
-         outtrack->SetPadHit(padrow,xyz_cross[1]);
-         outtrack->SetTimeHit(padrow,xyz_cross[2]);
-         
-         if(fWriteClusterShape)
-           {
-             Float_t angle = outtrack->GetCrossingAngle(padrow,slice);
-             outtrack->SetCrossingAngleLUT(padrow,angle);
-             outtrack->CalculateClusterWidths(padrow,kTRUE);
-             Int_t patch = AliL3Transform::GetPatch(padrow);
-             Float_t sigmaY2 = cluster->GetSigmaY2() / pow(AliL3Transform::GetPadPitchWidth(patch),2);
-             Float_t sigmaZ2 = cluster->GetSigmaZ2() / pow(AliL3Transform::GetZWidth(),2);
-             outtrack->SetCluster(padrow,xyz[1],xyz[2],clustercharge,sigmaY2,sigmaZ2,3);
-           }
-         else
-           outtrack->SetCluster(padrow,xyz[1],xyz[2],clustercharge,0,0,3);
-         totcounter++;
-         outtrack->GetClusterModel(padrow)->fSlice = slice;
-       }
-      /*
-      int label = track->GetLabel();
-      if(label == 10019 || label==6281 || label== 5326 || label==3054 || label==1366 || label==1005)
-       outtrack->Print();
-      */
-    }
-  
-  tracker->UnloadClusters();
-  
-  cout<<"AliL3DataCompressor::FillOfflineData : Wrote "<<totcounter<<" clusters"<<endl;
-  //Write tracks to file
-  AliL3Compress *comp = new AliL3Compress(-1,-1,fPath,fWriteClusterShape,fEvent);
-  comp->WriteFile(comptracks);
-  delete comp;
-  delete comptracks;
-  delete tracker;
-#endif
-}
index c149078b6486a20083eabc7e91017e63ee2b973c..de73de4e072df87a99026b1d9b5ecd29cf19344e 100644 (file)
@@ -34,21 +34,20 @@ class AliL3DataCompressor {
 #else
   FILE *fOutputFile;
 #endif
-  Char_t fPath[1024];            //!
   
   UInt_t fNcl[36][6];
-  Bool_t fKeepRemaining;
-  Bool_t fWriteClusterShape;
-  Int_t fEvent;
-  Bool_t fSinglePatch;
   
   static Int_t fNumPadBits;
   static Int_t fNumTimeBits;
   static Int_t fNumChargeBits;
   static Int_t fNumShapeBits;
   
-  static Float_t fXYResidualStep;
-  static Float_t fZResidualStep;
+  static Float_t fXYResidualStep1;
+  static Float_t fXYResidualStep2;
+  static Float_t fXYResidualStep3;
+  static Float_t fZResidualStep1;
+  static Float_t fZResidualStep2;
+  static Float_t fZResidualStep3;
   static Float_t fXYWidthStep;
   static Float_t fZWidthStep;
   static Int_t fClusterCharge;
@@ -61,32 +60,41 @@ class AliL3DataCompressor {
   Int_t Compare(TempCluster *a,TempCluster *b);
   void OpenOutputFile();
   void CloseOutputFile();
-
+  
+ protected:
+  Char_t fPath[1024];            //!
+  Int_t fEvent;
+  
+  Bool_t fWriteClusterShape;
+  Bool_t fKeepRemaining;
+  Bool_t fSinglePatch;
+  
  public:
   AliL3DataCompressor();
   AliL3DataCompressor(Char_t *path,Bool_t keep,Bool_t writeshape);
   virtual ~AliL3DataCompressor();
   
-  void LoadData(Int_t event,Bool_t sp=kTRUE);
-  void FillData(Int_t minhits,Bool_t expand);
-  void LoadOfflineData(Int_t event);
+  virtual void LoadData(Int_t event,Bool_t sp=kTRUE);
+  virtual void FillData(Int_t minhits,Bool_t expand);
+  virtual void WriteRemaining(Bool_t select);
   void CompressAndExpand();
-  void WriteRemaining(Bool_t select);
-  void RestoreData();
+  void RestoreData(Bool_t remaining_only=kFALSE);
   void DoBench(Char_t *fname="benchmark");
   
   void SetBitNumbers(Int_t pad,Int_t time,Int_t charge,Int_t shape);
-  void SetResolutions(Float_t xyresidual,Float_t zresidual,Int_t clustercharge,Float_t xywidth=0.005,Float_t zwidth=0.005);
+  void SetTransverseResolutions(Float_t res1,Float_t res2,Float_t res3,Float_t width=0.005);
+  void SetLongitudinalResolutions(Float_t res1,Float_t res2,Float_t res3,Float_t width=0.005);
   
   static const Int_t GetNPadBits() {return fNumPadBits;}
   static const Int_t GetNTimeBits() {return fNumTimeBits;}
   static const Int_t GetNChargeBits() {return fNumChargeBits;}
   static const Int_t GetNShapeBits() {return fNumShapeBits;}
-  static const Float_t GetXYResidualStep() {return fXYResidualStep;}
-  static const Float_t GetZResidualStep() {return fZResidualStep;}
   static const Float_t GetXYWidthStep() {return fXYWidthStep;}
   static const Float_t GetZWidthStep() {return fZWidthStep;}
   static const Int_t GetClusterCharge() {return fClusterCharge;}
+  static const Float_t GetXYResidualStep(Int_t row);
+  static const Float_t GetZResidualStep(Int_t row);
+
 
   ClassDef(AliL3DataCompressor,1) 
 
index 45914ccd849544471d00c726c1fd8e7faf8c17aa..a75e4c3b64e97b6829d22285e5e218733cb771d1 100644 (file)
@@ -61,7 +61,6 @@ AliL3ModelTrack::~AliL3ModelTrack()
        delete [] fOverlap[i];
       delete [] fOverlap;
     }
-
 }
 
 void AliL3ModelTrack::Init(Int_t slice,Int_t patch)
@@ -154,8 +153,8 @@ void AliL3ModelTrack::SetCluster(Int_t row,Float_t fpad,Float_t ftime,Float_t ch
   else
     {
       cl->fPresent|=0x1;//set first bit to true
-      cl->fDTime = (ftime - GetTimeHit(row))/(AliL3DataCompressor::GetZResidualStep()/AliL3Transform::GetZWidth());   
-      cl->fDPad = (fpad - GetPadHit(row))/(AliL3DataCompressor::GetXYResidualStep()/AliL3Transform::GetPadPitchWidth(patch));
+      cl->fDTime = (ftime - GetTimeHit(row))/(AliL3DataCompressor::GetZResidualStep(row)/AliL3Transform::GetZWidth());   
+      cl->fDPad = (fpad - GetPadHit(row))/(AliL3DataCompressor::GetXYResidualStep(row)/AliL3Transform::GetPadPitchWidth(patch));
       cl->fDCharge = charge;// - AliL3DataCompressor::GetClusterCharge();
       //cl->fSlice = fSlice;
       if(sigmaY2==0 && sigmaZ2==0)
@@ -242,8 +241,8 @@ void AliL3ModelTrack::FillModel()
   fTrackModel->fFirstPointZ = GetFirstPointZ();
   fTrackModel->fTgl = GetTgl();
   fTrackModel->fPsi = GetPsi();
-  fTrackModel->fLength = (Short_t)GetLength();
-  fTrackModel->fNClusters = fNClusters;
+  //fTrackModel->fLength = (Short_t)GetLength();
+  //fTrackModel->fNClusters = fNClusters;
 }
 
 void AliL3ModelTrack::FillTrack()
@@ -260,8 +259,8 @@ void AliL3ModelTrack::FillTrack()
   SetFirstPoint(fTrackModel->fFirstPointX,fTrackModel->fFirstPointY,fTrackModel->fFirstPointZ);
   SetTgl(fTrackModel->fTgl);
   SetPsi(fTrackModel->fPsi);
-  SetLength(fTrackModel->fLength);
-  fNClusters = fTrackModel->fNClusters;
+  //SetLength(fTrackModel->fLength);
+  fNClusters = AliL3Transform::GetNRows(fPatch);//fTrackModel->fNClusters;
   SetPt((AliL3Transform::GetBFact()*AliL3Transform::GetBField())/fabs(GetKappa()));
     
   CalculateHelix();
@@ -386,7 +385,7 @@ Bool_t AliL3ModelTrack::GetPad(Int_t row,Float_t &pad)
 
   AliL3ClusterModel *cl = GetClusterModel(row);
   Int_t patch = AliL3Transform::GetPatch(row);
-  pad = cl->fDPad*(AliL3DataCompressor::GetXYResidualStep()/AliL3Transform::GetPadPitchWidth(patch)) + GetPadHit(row);
+  pad = cl->fDPad*(AliL3DataCompressor::GetXYResidualStep(row)/AliL3Transform::GetPadPitchWidth(patch)) + GetPadHit(row);
   
   return IsPresent(row);
 }
@@ -394,7 +393,7 @@ Bool_t AliL3ModelTrack::GetPad(Int_t row,Float_t &pad)
 Bool_t AliL3ModelTrack::GetTime(Int_t row,Float_t &time)
 {
   AliL3ClusterModel *cl = GetClusterModel(row);
-  time = cl->fDTime*(AliL3DataCompressor::GetZResidualStep()/AliL3Transform::GetZWidth()) + GetTimeHit(row);
+  time = cl->fDTime*(AliL3DataCompressor::GetZResidualStep(row)/AliL3Transform::GetZWidth()) + GetTimeHit(row);
   
   return IsPresent(row);
 }
index 235bffb1d2442ceeca084b735c6352743ce28361..6c6b04ce78f6d0234698420913fd2431be72cdf4 100644 (file)
@@ -45,8 +45,6 @@ struct AliL3TrackModel {
   Float_t fFirstPointZ;
   Float_t fTgl;
   Float_t fPsi;
-  Short_t fLength;
-  Short_t fNClusters;
 };
 typedef struct AliL3TrackModel AliL3TrackModel;
 
diff --git a/HLT/comp/AliL3OfflineDataCompressor.cxx b/HLT/comp/AliL3OfflineDataCompressor.cxx
new file mode 100644 (file)
index 0000000..ee12c0c
--- /dev/null
@@ -0,0 +1,445 @@
+// @(#) $Id$
+
+// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
+//*-- Copyright &copy ALICE HLT Group
+
+#include "AliL3StandardIncludes.h"
+
+#include "AliL3Transform.h"
+#include "AliL3ModelTrack.h"
+#include "AliL3Compress.h"
+#include "AliL3TrackArray.h"
+
+#include <AliKalmanTrack.h>
+#include <AliTPCtracker.h>
+#include <AliTPCtrackerMI.h>
+#include <AliTPCcluster.h>
+#include <AliTPCclusterMI.h>
+#include <AliTPCParamSR.h>
+#include <AliTPCClustersArray.h>
+#include <AliTPCcluster.h>
+#include <AliTPCClustersRow.h>
+#include <AliTPC.h>
+#include <AliTPCv2.h>
+#include <AliRun.h>
+
+#include <TTree.h>
+#include <TFile.h>
+#include <TMath.h>
+#include <TDirectory.h>
+#include <TSystem.h>
+#include <TH2F.h>
+
+
+#include "AliL3OfflineDataCompressor.h"
+
+#if GCCVERSION == 3
+using namespace std;
+#endif
+
+//_____________________________________________________________
+//
+//  AliL3OfflineDataCompression
+//
+
+
+ClassImp(AliL3OfflineDataCompressor)
+
+AliL3OfflineDataCompressor::AliL3OfflineDataCompressor()
+{
+  fMarian = kFALSE;
+  fTracker=0;
+}
+
+AliL3OfflineDataCompressor::AliL3OfflineDataCompressor(Char_t *path,Bool_t keep,Bool_t writeshape,Bool_t MI) 
+  : AliL3DataCompressor(path,keep,writeshape)
+{
+  fMarian = MI;
+  fTracker=0;
+}
+
+AliL3OfflineDataCompressor::~AliL3OfflineDataCompressor()
+{
+  if(fTracker)
+    {
+      fTracker->UnloadClusters();
+      delete fTracker;
+    }
+}
+
+
+void AliL3OfflineDataCompressor::LoadData(Int_t event,Bool_t sp)
+{
+  //Take offline reconstructed tracks as an input.
+  //In this case, no remaining clusters are written.
+  
+  fSinglePatch = sp;
+  
+  char filename[1024];
+  AliKalmanTrack::SetConvConst(1000/0.299792458/AliL3Transform::GetSolenoidField());
+  if(fMarian==kFALSE)
+    sprintf(filename,"%s/offline/AliTPCclusters.root",fPath);
+  else
+    sprintf(filename,"%s/offline/AliTPCclustersMI.root",fPath);
+  
+  TFile *in = TFile::Open(filename);
+  AliTPCParam *param=(AliTPCParam*)in->Get("75x40_100x60_150x60");
+
+  if(fMarian==kFALSE)
+    fTracker = new AliTPCtracker(param);
+  else
+    fTracker = new AliTPCtrackerMI(param);
+  fTracker->SetEventNumber(event);
+  //Problems:
+  //fTracker->LoadClusters();
+  
+  if(fMarian==kTRUE)
+    {
+      AliTPCtrackerMI *mitracker = (AliTPCtrackerMI*)fTracker;
+      mitracker->LoadInnerSectors();
+      mitracker->LoadOuterSectors();
+    }
+  
+  const Int_t MAX=20000;
+  Int_t nentr=0,i=0; TObjArray tarray(MAX);
+  if(fMarian==kFALSE)
+    sprintf(filename,"%s/offline/AliTPCtracks.root",fPath);
+  else
+    sprintf(filename,"%s/offline/AliTPCtracksMI.root",fPath);
+  TFile *tf=TFile::Open(filename);
+  
+  char tname[100]; sprintf(tname,"TreeT_TPC_%d",event);
+  TTree *tracktree=(TTree*)tf->Get(tname);
+  
+  TBranch *tbranch=tracktree->GetBranch("tracks");
+  nentr=(Int_t)tracktree->GetEntries();
+  AliTPCtrack *iotrack=0;
+
+  for (i=0; i<nentr; i++) {
+    iotrack=new AliTPCtrack;
+    tbranch->SetAddress(&iotrack);
+    tracktree->GetEvent(i);
+    tarray.AddLast(iotrack);
+  }   
+  delete tracktree; 
+  tf->Close();
+  
+  AliL3TrackArray *comptracks = new AliL3TrackArray("AliL3ModelTrack");
+  cout<<"Loaded "<<nentr<<" offline tracks"<<endl;
+  Int_t slice,padrow;
+  Int_t totcounter=0;
+  for(i=0; i<nentr; i++)
+    {
+      
+      AliTPCtrack *track=(AliTPCtrack*)tarray.UncheckedAt(i);
+      Int_t nhits = track->GetNumberOfClusters();
+      Int_t idx = track->GetClusterIndex(nhits-1);
+      Int_t sec=(idx&0xff000000)>>24, row=(idx&0x00ff0000)>>16;
+      
+      /*
+       TPC sector numbering within the AliTPCtracker class:
+       There are in total 18 inner sectors and 18 outer sectors.
+       This means that one sector includes _both_ sides of the TPC.
+       Example: sec=0 -> sector 0 and 18.
+                sec=18 -> sector 36 and 54
+      */
+      
+      if(fMarian==kFALSE)
+       if(sec >= 18)
+         sec += 18;
+      
+      AliL3Transform::Sector2Slice(slice,padrow,sec,row);
+      Double_t par[5],xk=AliL3Transform::Row2X(padrow);
+      track->PropagateTo(xk);
+      track->GetExternalParameters(xk,par);
+      Double_t psi = TMath::ASin(par[2]) + track->GetAlpha();
+      if (psi<-TMath::Pi()) psi+=2*TMath::Pi();
+      if (psi>=TMath::Pi()) psi-=2*TMath::Pi();
+      Float_t pt_1=TMath::Abs(par[4]);
+      Int_t charge = 1;
+      if(par[4] > 0)
+       charge=-1;
+
+      Float_t first[3];
+      AliCluster *fcl=0;
+      if(fMarian==kFALSE)
+       fcl= fTracker->GetCluster(idx);
+      else
+       {
+         AliTPCtrackerMI *mitracker = (AliTPCtrackerMI*)fTracker;
+         fcl = mitracker->GetClusterMI(idx);
+       }
+      first[0] = xk;
+      first[1] = fcl->GetY();
+      first[2] = fcl->GetZ();
+
+      AliL3Transform::Local2Global(first,slice);
+      
+      AliL3ModelTrack *outtrack = (AliL3ModelTrack*)comptracks->NextTrack();
+      outtrack->SetNHits(nhits);
+      outtrack->SetFirstPoint(first[0],first[1],first[2]);
+      outtrack->SetPt(1/pt_1);
+      outtrack->SetPsi(psi);
+      outtrack->SetTgl(par[3]);
+      outtrack->SetCharge(charge);
+      outtrack->CalculateHelix();
+      outtrack->Init(0,-1);
+      
+      //cout<<"Loading track with "<<nhits<<" hits"<<endl;
+      for(int j=nhits-1; j>=0; j--)
+       {
+
+         Int_t index = track->GetClusterIndex(j);
+         if(index == 0)
+           continue;
+
+         Float_t xyz[3];
+         Int_t clustercharge =0;
+
+         //AliTPCcluster *cluster = (AliTPCcluster*)tracker->GetCluster(index);
+         AliCluster *cluster=0;
+         
+         if(fMarian==kFALSE)
+           cluster = fTracker->GetCluster(index);
+         else
+           {
+             AliTPCtrackerMI *mitracker = (AliTPCtrackerMI*)fTracker;
+             cluster = mitracker->GetClusterMI(index);
+           }
+
+         xyz[1] = cluster->GetY();
+         xyz[2] = cluster->GetZ();
+         if(fMarian==kFALSE)
+           {
+             AliTPCcluster *cl = (AliTPCcluster*)cluster;
+             clustercharge = (Int_t)cl->GetQ();
+           }
+         else
+           {
+             AliTPCclusterMI *cl = (AliTPCclusterMI*)cluster;
+             clustercharge = (Int_t)cl->GetQ();
+           }
+
+         cluster->Use();
+         
+         sec=(index&0xff000000)>>24; row=(index&0x00ff0000)>>16;
+         
+         if(fMarian==kFALSE)
+           {
+             if(sec >= 18)
+               sec += 18;
+             
+             if(xyz[2] < 0)
+               sec += 18;
+           }
+           
+         //cout<<"sector "<<sec<<" row "<<row<<endl;
+         if(!AliL3Transform::Sector2Slice(slice,padrow,sec,row))
+           exit(5);
+         xyz[0] = AliL3Transform::Row2X(padrow);
+         
+         //cout<<"Hit in slice "<<slice<<" padrow "<<padrow<<" index "<<index<<" y "<<cluster->GetY()<<" z "<<cluster->GetZ()<<endl;
+         AliL3Transform::Local2Raw(xyz,sec,row);
+         //cout<<"slice "<<slice<<" padrow "<<padrow<<" pad "<<xyz[1]<<" time "<<xyz[2]<<endl;
+         
+         if(xyz[1] < -1 || xyz[1] > AliL3Transform::GetNPads(padrow) ||
+            xyz[2] < -1 || xyz[2] > AliL3Transform::GetNTimeBins())
+           {
+             cerr<<"AliL3DataCompressor::FillOfflineData : Wrong time "<<xyz[2]<<" in slice "
+                 <<slice<<" padrow "<<padrow<<endl;
+             cout<<"sector "<<sec<<" row "<<row<<endl;
+             //cout<<"Hit in slice "<<slice<<" padrow "<<padrow<<" y "<<cluster->GetY()<<" z "<<cluster->GetZ()<<endl;
+             cout<<"Track hit "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
+             exit(5);
+           }
+         
+         Float_t angle = 0;
+         AliL3Transform::Local2GlobalAngle(&angle,slice);
+         if(!outtrack->CalculateReferencePoint(angle,AliL3Transform::Row2X(padrow)))
+           {
+             cerr<<"AliL3DataCompressor::FillOfflineData : Error in crossing point calc on slice "
+                 <<slice<<" row "<<padrow<<endl;
+             exit(5);
+           }
+         Float_t xyz_cross[3] = {outtrack->GetPointX(),outtrack->GetPointY(),outtrack->GetPointZ()};
+         AliL3Transform::Global2Raw(xyz_cross,sec,row);
+         /*
+           if(fabs(xyz_cross[1] - xyz[1]) > 10 ||
+           fabs(xyz_cross[2] - xyz[2]) > 10)
+           {
+           cout<<"AliL3DataCompressor::FillOfflineData : Wrong crossing slice "<<slice<<" padrow "
+           <<padrow<<" pad "<<xyz[1]<<" padhit "<<xyz_cross[1]<<" time "<<xyz[2]<<" timehit "<<xyz_cross[2]<<endl;
+           outtrack->Print();
+           exit(5);
+           }
+         */
+         //cout<<" crossing "<<xyz_cross[0]<<" "<<xyz_cross[1]<<" "<<xyz_cross[2]<<endl;
+         outtrack->SetPadHit(padrow,xyz_cross[1]);
+         outtrack->SetTimeHit(padrow,xyz_cross[2]);
+         
+         if(fWriteClusterShape)
+           {
+             Float_t angle = outtrack->GetCrossingAngle(padrow,slice);
+             outtrack->SetCrossingAngleLUT(padrow,angle);
+             outtrack->CalculateClusterWidths(padrow,kTRUE);
+             Int_t patch = AliL3Transform::GetPatch(padrow);
+             Float_t sigmaY2 = cluster->GetSigmaY2() / pow(AliL3Transform::GetPadPitchWidth(patch),2);
+             Float_t sigmaZ2 = cluster->GetSigmaZ2() / pow(AliL3Transform::GetZWidth(),2);
+             outtrack->SetCluster(padrow,xyz[1],xyz[2],clustercharge,sigmaY2,sigmaZ2,3);
+           }
+         else
+           outtrack->SetCluster(padrow,xyz[1],xyz[2],clustercharge,0,0,3);
+         totcounter++;
+         outtrack->GetClusterModel(padrow)->fSlice = slice;
+       }
+    }
+  
+  cout<<"AliL3DataCompressor::FillOfflineData : Wrote "<<totcounter<<" clusters"<<endl;
+  //Write tracks to file
+  AliL3Compress *comp = new AliL3Compress(-1,-1,fPath,fWriteClusterShape,fEvent);
+  comp->WriteFile(comptracks);
+  delete comp;
+  delete comptracks;
+
+}
+
+void AliL3OfflineDataCompressor::WriteRemaining(Bool_t select)
+{
+  //Write remaining clusters (not assigned to any tracks) to file
+  
+  if(!fKeepRemaining)
+    return;
+  
+  if(select)
+    SelectRemainingClusters();
+  
+  Char_t filename[1024];
+  
+  if(!fSinglePatch)
+    {
+      cerr<<"AliL3OfflineDataCompressor::WriteRemaining : You have to modify this function when not running singlepatch"<<endl;
+      return;
+    }
+
+  cout<<"Writing remaining clusters "<<endl;
+  Int_t nrows = AliL3Transform::GetNRows(),sector,row,sec;
+  AliTPCtracker *tracker = (AliTPCtracker*)fTracker;
+  for(Int_t slice=0; slice<=35; slice++)
+    {
+      sprintf(filename,"%s/comp/remains_%d_%d_%d.raw",fPath,fEvent,slice,-1);
+      FILE *outfile = fopen(filename,"w");
+      if(!outfile)
+       {
+         cerr<<"AliL3OfflineDataCompressor::WriteRemaining : Cannot open file "<<filename<<endl;
+         exit(5);
+       }
+      
+      for(Int_t padrow=0; padrow < nrows; padrow++)
+       {
+         AliL3Transform::Slice2Sector(slice,padrow,sector,row);
+         sec=sector;
+         
+         if(fMarian == kFALSE)
+           {
+             if(slice >= 18)
+               sec -= 18;
+             if(sec >= 18)
+               sec -= 18;
+           }
+         //cout<<"Getting clusters in sector "<<sec<<" row "<<row<<endl;
+         // Problems:
+         Int_t ncl = 0;//tracker->GetNClusters(sec,row);
+                 
+         Int_t counter=0;
+         Int_t j;
+         for(j=0; j<ncl; j++)
+           {
+             AliTPCcluster *cluster;// = (AliTPCcluster*)tracker->GetCluster(sec,row,j);
+             if(cluster->GetZ() < 0 && slice < 18) continue;
+             if(cluster->GetZ() > 0 && slice > 17) continue;
+             if(cluster->IsUsed())
+               continue;
+             counter++;
+           }
+
+         Int_t size = sizeof(AliL3RemainingRow) + counter*sizeof(AliL3RemainingCluster);
+         Byte_t *data = new Byte_t[size];
+         AliL3RemainingRow *tempPt = (AliL3RemainingRow*)data;
+         
+         tempPt->fPadRow = padrow;
+         tempPt->fNClusters = counter;
+         //cout<<"Found "<<counter<<" unused out of "<<ncl<<" clusters on slice "<<slice<<" padrow "<<padrow<<endl;
+         Int_t local_counter=0;
+         for(j=0; j<ncl; j++)
+           {
+             //Problems:
+             AliTPCcluster *cluster;// = (AliTPCcluster*)tracker->GetCluster(sec,row,j);
+             if(cluster->GetZ() < 0 && slice < 18) continue;
+             if(cluster->GetZ() > 0 && slice > 17) continue;
+             if(cluster->IsUsed())
+               continue;
+
+             if(local_counter > counter)
+               {
+                 cerr<<"AliL3OfflineDataCompressor::WriterRemaining : array out of range "<<local_counter<<" "<<counter<<endl;
+                 return;
+               }
+             Float_t xyz[3] = {AliL3Transform::Row2X(padrow),cluster->GetY(),cluster->GetZ()};
+             AliL3Transform::Local2Raw(xyz,sector,row);
+             //cout<<"y "<<cluster->GetY()<<" z "<<cluster->GetZ()<<" pad "<<xyz[1]<<" time "<<xyz[2]<<endl;
+             tempPt->fClusters[local_counter].fY = cluster->GetY();
+             tempPt->fClusters[local_counter].fZ = cluster->GetZ();
+             tempPt->fClusters[local_counter].fCharge = (UShort_t)cluster->GetQ();
+             tempPt->fClusters[local_counter].fSigmaY2 = cluster->GetSigmaY2();
+             tempPt->fClusters[local_counter].fSigmaZ2 = cluster->GetSigmaZ2();
+             local_counter++;
+           }
+         
+         fwrite(tempPt,size,1,outfile);
+         delete [] data;
+       }
+      fclose(outfile);
+    }
+}
+
+void AliL3OfflineDataCompressor::SelectRemainingClusters()
+{
+  
+  cout<<"Cleaning up clusters"<<endl;
+  Int_t nrows = AliL3Transform::GetNRows();
+  Int_t gap=(Int_t)(0.125*nrows), shift=(Int_t)(0.5*gap);
+  
+  Int_t sector,row,sec;
+  AliTPCtracker *tracker = (AliTPCtracker*)fTracker;
+  for(Int_t slice=0; slice<36; slice++)
+    {
+      for(Int_t padrow=0; padrow < nrows; padrow++)
+       {
+         if(padrow >= nrows-1-gap-shift) continue;//save all the clusters in this region
+         
+         AliL3Transform::Slice2Sector(slice,padrow,sector,row);
+         sec=sector;
+         
+         if(fMarian == kFALSE)
+           {
+             if(slice >= 18)
+               sec -= 18;
+             if(sec >= 18)
+               sec -= 18;
+           }
+         //Problems:
+         Int_t ncl = 0;//tracker->GetNClusters(sec,row);
+         for(Int_t j=0; j<ncl; j++)
+           {
+             AliTPCcluster *cluster;// = (AliTPCcluster*)tracker->GetCluster(sec,row,j);
+             if(cluster->GetZ() < 0 && slice < 18) continue;
+             if(cluster->GetZ() > 0 && slice > 17) continue;
+             if(cluster->IsUsed())
+               continue;
+             
+             cluster->Use();
+           }
+       }
+      
+    }
+}
diff --git a/HLT/comp/AliL3OfflineDataCompressor.h b/HLT/comp/AliL3OfflineDataCompressor.h
new file mode 100644 (file)
index 0000000..97e48f4
--- /dev/null
@@ -0,0 +1,31 @@
+// @(#) $Id$
+
+#ifndef AliL3_OfflineDataCompressor
+#define AliL3_OfflineDataCompressor
+
+#include "AliL3DataCompressor.h"
+
+class AliTracker;
+
+class AliL3OfflineDataCompressor : public AliL3DataCompressor {
+  
+ private:
+  Bool_t fMarian;
+  AliTracker *fTracker;  //!
+  
+  void SelectRemainingClusters();
+  
+ public:
+  AliL3OfflineDataCompressor();
+  AliL3OfflineDataCompressor(Char_t *path,Bool_t keep,Bool_t writeshape,Bool_t MI=kFALSE);
+  virtual ~AliL3OfflineDataCompressor();
+  
+  void LoadData(Int_t event,Bool_t sp=kTRUE);
+  void FillData(Int_t minhits,Bool_t expand) {return;};
+  void WriteRemaining(Bool_t select);
+
+  ClassDef(AliL3OfflineDataCompressor,1) 
+
+};
+
+#endif
index c349de06d04a4fced6689b0e58841e420838dfed..ff26a5922546ff99d86379f771e7cc21825dbc27 100644 (file)
@@ -25,6 +25,7 @@ OBJS = $(patsubst %.cxx,$(OBJDIR)/%.o,$(SRCS)) $(ADD_C_OBJS) $(DICTO)
 endif
 
 ifeq ($(ALIHLT_USEPACKAGE),ALIROOT)
+SRCS += AliL3OfflineDataCompressor.cxx
 HDRS = $(SRCS:.cxx=.h) $(MODNAME)LinkDef.h
 OBJS = $(patsubst %.cxx,$(OBJDIR)/%.o,$(SRCS)) $(ADD_C_OBJS) $(DICTO)
 endif
index 90023671daadc5ec13c5b2cbb90ca5c734ae1f2a..d6095afbf7dade94e13c93406d8f5e08b0d3f9a4 100644 (file)
@@ -1,3 +1,24 @@
+2003-09-18  Constantin Loizides  <loizides@hansa00>
+
+       * /cvs/hltcvs/level3code/comp/AliL3OfflineDataCompressor.cxx:
+       Commented compile breaking due to aliroot changes.
+
+2003-08-22  Anders Strand Vestbo  <vestbo@hansa00>
+
+       * /cvs/hltcvs/level3code/comp/AliL3Compress.cxx, /cvs/hltcvs/level3code/comp/AliL3Models.h, /cvs/hltcvs/level3code/comp/AliL3ModelTrack.cxx:
+       - Removed field fNClusters from AliL3TrackModel. The reason is the new scheme
+       were the number of clusters is _not_ written for every track. Instead, we assume
+       a potential number of clusters which is equal to the number of padrows in the
+       patch/slice (this number then needs not to written). Then we denote whether a
+       cluster is present or not by writing 1 bit for every padrow.
+       - The residual quantization (stored in AliL3DataCompressor) is now specified
+       for the three different pad sizes.
+
+       * /cvs/hltcvs/level3code/comp/AliL3CompLinkDef.h, /cvs/hltcvs/level3code/comp/AliL3DataCompressor.cxx, /cvs/hltcvs/level3code/comp/AliL3DataCompressor.h, /cvs/hltcvs/level3code/comp/AliL3OfflineDataCompressor.cxx, /cvs/hltcvs/level3code/comp/AliL3OfflineDataCompressor.h, /cvs/hltcvs/level3code/comp/Makefile:
+       Splitted handling of offline-data compression and HLT-data compression.
+       For offline-data input the new class AliL3OfflineDataCompressor is used.
+       This class is a child of AliL3DataCompressor, and has the exact same interface.
+
 2003-07-26  Constantin Loizides  <loizides@hansa00>
 
        * /cvs/hltcvs/level3code/comp/AliL3ClusterFitter.cxx, /cvs/hltcvs/level3code/comp/AliL3CompLinkDef.h, /cvs/hltcvs/level3code/comp/AliL3Compress.cxx, /cvs/hltcvs/level3code/comp/AliL3Compress.h, /cvs/hltcvs/level3code/comp/AliL3DataCompressor.cxx, /cvs/hltcvs/level3code/comp/AliL3DataCompressor.h, /cvs/hltcvs/level3code/comp/AliL3Modeller.cxx:
index 6c0bc9a7eeeee9d0b6247a26ec18a30992f604bd..aa272c8c10f8560d2c4e15c1fb6b262b9c532e07 100644 (file)
@@ -1,3 +1,7 @@
+2003-09-18  Constantin Loizides  <loizides@hansa00>
+
+       * /cvs/hltcvs/level3code/doc/taginfo: Added branch info.
+
 2003-08-04  Constantin Loizides  <loizides@hansa00>
 
        * /cvs/hltcvs/level3code/doc/alice-062003.geo, /cvs/hltcvs/level3code/doc/l3transform-062003.config, /cvs/hltcvs/level3code/doc/l3transform-cosmic-022003.config:
index 123b91705c9dfca5e5723155aab12ee4d0cb6b09..e4d22e5d9f5ee653413b1f90c70d3caef478132b 100644 (file)
@@ -1,3 +1,8 @@
+2003-08-07  Constantin Loizides  <loizides@hansa00>
+
+       * /cvs/hltcvs/level3code/exa/rootlogon.C:
+       Changes to have a working rootlogging for VMC and MC root versions as well as aliroot releases before and after 3-09-Release.
+
 2003-08-04  Constantin Loizides  <loizides@hansa00>
 
        * /cvs/hltcvs/level3code/exa/binary.C: Moved L3 to HLT in the comment.
index 6b359149d601b7ef701dc23657217af49775c831..536db6418e694bf9c634fe1f07e828b7824424ea 100644 (file)
@@ -1,3 +1,19 @@
+2003-08-19  Anders Strand Vestbo  <vestbo@hansa00>
+
+       * /cvs/hltcvs/level3code/hough/AliL3HistogramAdaptive.cxx, /cvs/hltcvs/level3code/hough/AliL3HistogramAdaptive.h, /cvs/hltcvs/level3code/hough/AliL3Histogram.cxx, /cvs/hltcvs/level3code/hough/AliL3Histogram.h:
+       Bugfix from last changes of AliL3HistogramAdaptive. Also some minor
+       changes in AliL3Histogram class.
+
+2003-08-17  Anders Strand Vestbo  <vestbo@hansa00>
+
+       * /cvs/hltcvs/level3code/hough/AliL3HistogramAdaptive.cxx, /cvs/hltcvs/level3code/hough/AliL3HistogramAdaptive.h:
+       Added a LUT in order to speed up retrieval of bin numbers.
+
+2003-08-12  Anders Strand Vestbo  <vestbo@hansa00>
+
+       * /cvs/hltcvs/level3code/hough/AliL3HoughIntMerger.cxx, /cvs/hltcvs/level3code/hough/AliL3HoughMerger.cxx:
+       Follow change in base class AliL3Merger.
+
 2003-07-28  Constantin Loizides  <loizides@hansa00>
 
        * /cvs/hltcvs/level3code/hough/AliL3HistogramAdaptive.cxx:
index 40c124cafd1f108139a7db1bbbb4ba9e76ea9837..39489f87c4faa4dcec35d2b20dc8c6c6eda1207a 100644 (file)
@@ -1,3 +1,29 @@
+2003-09-22  Thomas Vik  <tvik@hansa00>
+
+       * /cvs/hltcvs/level3code/kalman/AliL3KalmanTrack.cxx, /cvs/hltcvs/level3code/kalman/AliL3KalmanTrack.h:
+       Changed Init to do filtering without seed making.
+
+       * /cvs/hltcvs/level3code/kalman/AliL3Kalman.h, /cvs/hltcvs/level3code/kalman/AliL3Kalman.cxx:
+       Changes in make seeds.
+
+       * /cvs/hltcvs/level3code/kalman/Makefile:
+       Changed to the new makefile strategy.
+
+2003-09-02  Thomas Vik  <tvik@hansa00>
+
+       * /cvs/hltcvs/level3code/kalman/AliL3KalmanLinkDef.h:
+       Removed link to obsolete class.
+
+       * /cvs/hltcvs/level3code/kalman/AliL3KalmanTrack.h, /cvs/hltcvs/level3code/kalman/AliL3KalmanTrack.cxx, /cvs/hltcvs/level3code/kalman/AliL3Kalman.h, /cvs/hltcvs/level3code/kalman/AliL3Kalman.cxx:
+       Lots of changes and cleaned up.
+
+2003-08-05  Thomas Vik  <tvik@hansa00>
+
+       * /cvs/hltcvs/level3code/kalman/Makefile: Added makefile.
+
+       * /cvs/hltcvs/level3code/kalman/AliL3KalmanLinkDef.h:
+       *** empty log message ***
+
 2003-07-22  Constantin Loizides  <loizides@hansa00>
 
        * /cvs/hltcvs/level3code/kalman/AliL3Kalman.h, /cvs/hltcvs/level3code/kalman/AliL3KalmanTrack.h:
index 1e48618b650e915c92974741d247743990485f8c..b3756f8648b48444a2b3254c3c7a6154f0d902b2 100644 (file)
@@ -1,3 +1,43 @@
+2003-08-20  Anders Strand Vestbo  <vestbo@hansa00>
+
+       * /cvs/hltcvs/level3code/src/AliL3Fitter.cxx, /cvs/hltcvs/level3code/src/AliL3Fitter.h, /cvs/hltcvs/level3code/src/AliLevel3.cxx:
+       Added function AliL3Fitter::UpdateTrack. This function should be called
+       after a global track fit has been done (as is done in
+       AliLevel3::FitGlobalTracks), in order to update the track parameters
+       to the first point of the track.
+
+2003-08-12  Anders Strand Vestbo  <vestbo@hansa00>
+
+       * /cvs/hltcvs/level3code/src/AliL3ConfMapper.cxx, /cvs/hltcvs/level3code/src/AliL3ConfMapper.h, /cvs/hltcvs/level3code/src/AliLevel3.cxx:
+       When doing nonvertex tracking, check whether the parameters has been set
+       properly. If they are not set explicitely (by doing a designated
+       AliLevel3::SetTrackerParam with vertexconstraint=kFALSE), no secondaries
+       will be found since the cut values are not defined.
+
+2003-08-06  Anders Strand Vestbo  <vestbo@hansa00>
+
+       * /cvs/hltcvs/level3code/src/AliL3GlobalMerger.cxx, /cvs/hltcvs/level3code/src/AliL3GlobalMerger.h, /cvs/hltcvs/level3code/src/AliL3InterMerger.cxx, /cvs/hltcvs/level3code/src/AliL3Merger.cxx, /cvs/hltcvs/level3code/src/AliL3Merger.h, /cvs/hltcvs/level3code/src/AliL3TrackMerger.cxx, /cvs/hltcvs/level3code/src/AliLevel3.cxx, /cvs/hltcvs/level3code/src/AliLevel3.h:
+       Some structural changes with respect to the merging classes and how they
+       are used in AliLevel3 class. The main reason for doing this was to enable
+       to set parameters for the global track merging externally by introducing
+       the function AliLevel3::SetMergerParameters. If this function is not
+       being called default parameters will be used, so for the moment nothing
+       has changed for the normal user of the AliLevel3 class.
+
+       * /cvs/hltcvs/level3code/src/AliL3GlobalMerger.cxx, /cvs/hltcvs/level3code/src/AliL3GlobalMerger.h, /cvs/hltcvs/level3code/src/AliL3Merger.cxx:
+       Multiple bugfix (only the important ones reported here):
+       - There biggest was a problem of merging tracks between slice
+       17 and 0 and 35 and 18 in the former version. The problem was actually
+       that they were not merged at all. Slice 17 was trying to merge with slice 18,
+       which are on different sides of the TPC. This was a mistake done in both SlowMerge
+       and Merge.
+       - Also in CheckTracks (called from SlowMerge) did not check if the two tracks
+       had different signs. Some tracks was therefore merged wrongly.
+
+       * /cvs/hltcvs/level3code/src/AliL3Display.cxx, /cvs/hltcvs/level3code/src/AliL3Display.h:
+       Changed the default path to the file containing the geometry of the
+       TPC. It now looks in $ALIHLT_BASEDIR/geo for the file alice.geom.
+
 2003-08-04  Constantin Loizides  <loizides@hansa00>
 
        * /cvs/hltcvs/level3code/src/AliL3MemHandler.cxx, /cvs/hltcvs/level3code/src/AliL3MemHandler.h:
index 5b410a2d1b2a0fb1ba3b89ca4018d7916c7903ca..40c4692dbd4aab6720b72f440f603713d8eed317 100644 (file)
@@ -1,3 +1,7 @@
+2003-08-18  Anders Strand Vestbo  <vestbo@hansa00>
+
+       * /cvs/hltcvs/level3code/Makefile.rules: Added kalman to INCLUDES
+
 2003-07-29  Constantin Loizides  <loizides@hansa00>
 
        * /cvs/hltcvs/level3code/Makefile.conf, /cvs/hltcvs/level3code/Makefile.rules:
index 7530bdea71933ab5fdc01d1cf14738ce076c8634..0ea3a1dce5b8a5b834d35f9127def11e51a88287 100644 (file)
@@ -5,7 +5,14 @@
 
   gSystem->Load("$(ROOTSYS)/lib/libPhysics");
   gSystem->Load("$(ROOTSYS)/lib/libEG");
-  gSystem->Load("$(ROOTSYS)/lib/libMC");
+
+  Int_t saveErrIgLevel=gErrorIgnoreLevel;
+  gErrorIgnoreLevel=kFatal; //dont report errors
+  if(gSystem->Load("$(ROOTSYS)/lib/libMC")==-1){
+    gSystem->Load("$(ROOTSYS)/lib/libGeom");
+    gSystem->Load("$(ROOTSYS)/lib/libVMC");
+  }
+  gErrorIgnoreLevel=saveErrIgLevel;
 
   if(1)
     {
         gSystem->Load("$(ALIHLT_BASEDIR)/lib_$(USER)/libAliL3Comp");
       }
       cout<<"HLT libraries loaded"<<endl;
-    }
 
-  //gSystem->Load("MakePileup_C.so");
-  //gSystem->Load("Read_C.so");
+      if(strcmp("false",getenv("ALIHLT_NOLOGGING"))==0){
+       AliL3Logger gLogger;
+       gLogger.UseStream();
+      }
 
-  if(strcmp("true",getenv("ALIHLT_DOMC"))==0) gSystem->SetIncludePath(" -Ddo_mc");
-  gSystem->SetIncludePath(" -I$ALIHLT_TOPDIR/hough -I$ALIHLT_TOPDIR/src -I$ALIHLT_TOPDIR/comp -I$ALIHLT_TOPDIR/misc -I$ALICE_ROOT/include/ -I$ALICE_ROOT/TPC -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER ");
-  if(strcmp("false",getenv("ALIHLT_NOLOGGING"))==0){
-    AliL3Logger gLogger;
-    gLogger.UseStream();
-  }
+      if(getenv("ALIHLT_TRANSFORMFILE")){
+       cout << "Loading config \"" << getenv("ALIHLT_TRANSFORMFILE") << "\": " << flush;
+       if(AliL3Transform::Init(getenv("ALIHLT_TRANSFORMFILE")))
+         cout << "Ok!" << endl;
+       else cout << "Failed!" << endl;
+      }
 
-/*
-  if(getenv("ALIHLT_TRANSFORMFILE")){
-    cout << "Try to load config from \"" << getenv("ALIHLT_TRANSFORMFILE") << "\" path" << endl;
-    AliL3Transform::Init(getenv("ALIHLT_TRANSFORMFILE"));
-  }
-*/
+      Int_t saveErrIgLevel=gErrorIgnoreLevel;
+      gErrorIgnoreLevel=kFatal; //dont report errors
+      gSystem->Load("MakePileup_C.so");
+      gSystem->Load("Read_C.so");
+      gErrorIgnoreLevel=saveErrIgLevel;
+
+      if(strcmp("true",getenv("ALIHLT_DOMC"))==0) gSystem->SetIncludePath(" -Ddo_mc");
+      gSystem->SetIncludePath(" -I$ALIHLT_TOPDIR/hough -I$ALIHLT_TOPDIR/src -I$ALIHLT_TOPDIR/comp -I$ALIHLT_TOPDIR/misc -I$ALICE_ROOT/include/ -I$ALICE_ROOT/TPC -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER ");
+    }
 
   gStyle->SetStatColor(10);
   gStyle->SetStatBorderSize(1);
index 35eab6f3f69ebd895c518f36546f850a362738f4..cb3868e598170aedec6d6a95fd481a3b38ede52d 100644 (file)
@@ -122,19 +122,10 @@ Int_t AliL3Histogram::FindYbin(Double_t y)
 
 Int_t AliL3Histogram::GetBin(Int_t xbin,Int_t ybin)
 {
-  if(xbin < 0 || xbin > GetLastXbin())
-    {
-      LOG(AliL3Log::kError,"AliL3Histogram::GetBin","array")<<AliL3Log::kDec<<
-       "xbin out of range "<<xbin<<ENDLOG;
-      return 0;
-    }
-
-  if(ybin < 0 || ybin > GetLastYbin())
-    {
-      LOG(AliL3Log::kError,"AliL3Histogram::Getbin","array")<<AliL3Log::kDec<<
-       "ybin out of range "<<xbin<<ENDLOG;
-      return 0;
-    }
+  if(xbin < fFirstXbin || xbin > fLastXbin)
+    return 0;
+  if(ybin < fFirstYbin || ybin > fLastYbin)
+    return 0;
     
   return xbin + ybin*(fNxbins+2);
 }
@@ -231,12 +222,24 @@ void AliL3Histogram::Add(AliL3Histogram *h1,Double_t weight)
 
 Double_t AliL3Histogram::GetBinCenterX(Int_t xbin)
 {
+  if(xbin < fFirstXbin || xbin > fLastXbin)
+    {
+      LOG(AliL3Log::kError,"AliL3Histogram::GetBinCenterX","xbin")
+       <<"Bin-value out of range "<<xbin<<ENDLOG;
+      return -1;
+    }
   //  return fXmin + (xbin-1) * fBinwidthX + 0.5*fBinwidthX;
   return fXmin + (xbin-0.5) * fBinwidthX;
 }
 
 Double_t AliL3Histogram::GetBinCenterY(Int_t ybin)
 {
+  if(ybin < fFirstYbin || ybin > fLastYbin)
+    {
+      LOG(AliL3Log::kError,"AliL3Histogram::GetBinCenterY","ybin")
+       <<"Bin-value out of range "<<ybin<<ENDLOG;
+      return -1;
+    }
   //  return fYmin + (ybin-1) * fBinwidthY + 0.5*fBinwidthY;
   return fYmin + (ybin-0.5) * fBinwidthY;
 }
index 28ee9f76525b191d28eab76fb917d220ec852f8c..3253a75199ff88c4e1bd81196fd7ae695e68e99e 100644 (file)
 
 class AliL3Histogram {
   
- protected:
+ private:
+  Double_t fBinwidthX;
+  Double_t fBinwidthY;
   
+ protected:
   Int_t *fContent; //!
   Char_t fName[100];
-  //Char_t fID[100]; //not used 
   Int_t fNxbins;
   Int_t fNybins;
   Int_t fNcells;
@@ -30,8 +32,6 @@ class AliL3Histogram {
   Double_t fYmin;
   Double_t fXmax;
   Double_t fYmax;
-  Double_t fBinwidthX;
-  Double_t fBinwidthY;
 
 #ifdef use_root
   TH2F *fRootHisto;
index 6504db8dda58330241e46dd1dc43aece6da77333..0c72686a419fca64b20571ce4511c23166ad75b9 100644 (file)
@@ -16,13 +16,16 @@ using namespace std;
 //_____________________________________________________________
 // AliL3HistogramAdaptive
 //
-// 2D histogram class
+// 2D histogram class adapted for kappa and psi as used in the Circle Hough Transform.
+// The bins in kappa is not linear, but has a width which is specified by argument
+// ptres in the constructor. This gives the relative pt resolution which should
+// be kept throughout the kappa range. 
 
 ClassImp(AliL3HistogramAdaptive)
 
 AliL3HistogramAdaptive::AliL3HistogramAdaptive() : AliL3Histogram()
 {
-  
+  fKappaBins=0;
 }
 
   
@@ -37,10 +40,9 @@ AliL3HistogramAdaptive::AliL3HistogramAdaptive(Char_t *name,Double_t minpt,Doubl
 
   fMinPt = minpt;
   fMaxPt = maxpt;
-  fNxbins = InitPtBins();
-  //cout<<"Setting "<<fNxbins<<" bins on x"<<endl;
-  
+  fNxbins = InitKappaBins();
   fNybins = nybins;
+  
   fYmin = ymin;
   fYmax = ymax;
   fFirstXbin=1;
@@ -48,7 +50,7 @@ AliL3HistogramAdaptive::AliL3HistogramAdaptive(Char_t *name,Double_t minpt,Doubl
   fLastXbin = fNxbins;
   fLastYbin = fNybins;
   fNcells = (fNxbins+2)*(fNybins+2);
-  
+
   fThreshold=0;
   fContent = new Int_t[fNcells];
   Reset();
@@ -56,25 +58,40 @@ AliL3HistogramAdaptive::AliL3HistogramAdaptive(Char_t *name,Double_t minpt,Doubl
 
 AliL3HistogramAdaptive::~AliL3HistogramAdaptive()
 {
-  
+  if(fKappaBins)
+    delete [] fKappaBins;
 }
 
-Int_t AliL3HistogramAdaptive::InitPtBins()
+Int_t AliL3HistogramAdaptive::InitKappaBins()
 {
+  //Here a LUT for the kappa values created. This has to be done since
+  //the binwidth in kappa is not constant, but change according to the
+  //set relative resolution in pt.
+  //Since the kappa values are symmetric about origo, the size of the
+  //LUT is half of the total number of bins in kappa direction.
   
   Double_t pt = fMinPt,delta_pt,local_pt;
   Int_t bin=0;
-
+  
   while(pt < fMaxPt)
     {
       local_pt = pt;
-            
       delta_pt = fPtres*local_pt;
       pt += delta_pt;
       bin++;
-      //cout<<"Setting "<<bin<<" at step "<<local_pt<<" "<<pt<<" interval "<<delta_pt<<endl;
     }
-
+  fKappaBins = new Double_t[bin+1];
+  pt=fMinPt;
+  bin=0;
+  fKappaBins[bin] = AliL3Transform::GetBFact()*AliL3Transform::GetBField()/fMinPt; 
+  while(pt < fMaxPt)
+    {
+      local_pt = pt;
+      delta_pt = fPtres*local_pt;
+      pt += delta_pt;
+      bin++;
+      fKappaBins[bin] = AliL3Transform::GetBFact()*AliL3Transform::GetBField()/pt;
+    }
   return (bin+1)*2; //Both negative and positive kappa.
 }
 
@@ -101,37 +118,26 @@ Int_t AliL3HistogramAdaptive::FindBin(Double_t x,Double_t y)
 
 Int_t AliL3HistogramAdaptive::FindXbin(Double_t x)
 {
+
+  if(x < fXmin || x > fXmax || fabs(x) < fKappaBins[(fNxbins/2-1)])
+    return -1;
   
-  Double_t ptfind = fabs(AliL3Transform::GetBFact()*AliL3Transform::GetBField()/x);
-  if(ptfind < fMinPt || ptfind > fMaxPt) return -1;
-  //cout<<"Looking for pt "<<ptfind<<endl;
-  Double_t pt = fMinPt;
-  Double_t delta_pt,local_pt;
+  //Remember that kappa value is decreasing with bin number!
+  //Also, the bin numbering starts at 1 and ends at fNxbins,
+  //so the corresponding elements in the LUT is bin - 1.
+
   Int_t bin=0;
-  while(pt < fMaxPt)
+  while(bin < fNxbins/2)
     {
-      local_pt = pt;
-      delta_pt = fPtres*local_pt;
-      pt += delta_pt;
-      
-      if(ptfind >= local_pt && ptfind < pt)
-       {
-         //      cout<<"Found in range "<<local_pt<<" "<<pt<<endl;
-         break;
-       }
+      if(fabs(x) <= fKappaBins[bin] && fabs(x) > fKappaBins[bin+1])
+       break;
       bin++;
     }
-  if(bin >= fNxbins/2)
-    cerr<<"AliL3HistogramAdaptive::FindXbin : Bin out of range : "<<bin<<endl;
-  
-  //cout<<"Found xbin "<<bin<<" and x is "<<x<<endl;
   if(x < 0)
-    {
-      //        cout<<"returning xbin "<<bin<<endl;
-      return bin;
-    }
-  else
-    return fNxbins - 1 - bin;
+    return bin + 1;
+  else 
+    return fNxbins - bin;
+  
 }
 
 Int_t AliL3HistogramAdaptive::FindYbin(Double_t y)
@@ -140,47 +146,51 @@ Int_t AliL3HistogramAdaptive::FindYbin(Double_t y)
     return 0;
   
   return 1 + (Int_t)(fNybins*(y-fYmin)/(fYmax-fYmin));
-
 }
 
 Double_t AliL3HistogramAdaptive::GetBinCenterX(Int_t xbin)
 {
-  //cout<<"Looking for bin "<<xbin<<endl;
-  if(xbin < 0 || xbin > fNxbins)
+  if(xbin < fFirstXbin || xbin > fLastXbin)
     {
-      cerr<<"AliL3HistogramAdaptive::GetBinCenterX : Xbin out of range "<<xbin<<endl;
+      LOG(AliL3Log::kWarning,"AliL3HistogramAdaptive::GetBinCenterX","Bin-value")
+       <<"XBinvalue out of range "<<xbin<<ENDLOG;
       return 0;
     }
-  Double_t pt = fMinPt;
-  Double_t delta_pt=0,local_pt=0;
-  Int_t bin=0;
-  while(pt < fMaxPt)
-    {
-      local_pt = pt;
-      delta_pt = fPtres*local_pt;
-      pt += delta_pt;
-      if(xbin == bin || xbin == fNxbins - 1 - bin)
-       break;
-      bin++;
-    }
-  //cout<<"get center at ptinterval "<<local_pt<<" "<<pt;
   
-  Double_t kappa = AliL3Transform::GetBFact()*AliL3Transform::GetBField()/(local_pt + 0.5*delta_pt);
-  //cout<<" found pt "<<local_pt+delta_pt*0.5<<" kappa "<<kappa<<" xbin "<<xbin<<" fNxbins/2-1 "<<fNxbins/2-1<<endl;
-  if(xbin == bin)
+  //The bin numbers go from 1 to fNxbins, so the corresponding
+  //element in the LUT is xbin - 1. This is the reason why we 
+  //substract a 1 here:
+  
+  Int_t bin = xbin;
+  bin -= 1;
+  if(bin >= fNxbins/2)
+    bin = fNxbins - 1 - bin;
+  
+  //Remember again that the kappa-values are _decreasing_ with bin number.
+  
+  Double_t binwidth = fKappaBins[bin] - fKappaBins[bin+1];
+  Double_t kappa = fKappaBins[bin] - 0.5*binwidth;
+  if(xbin < fNxbins/2)
     return -1.*kappa;
   else
     return kappa;
+
 }
 
 Double_t AliL3HistogramAdaptive::GetBinCenterY(Int_t ybin)
 {
-  
+  if(ybin < fFirstYbin || ybin > fLastYbin)
+    {
+      LOG(AliL3Log::kError,"AliL3HistogramAdaptive::GetBinCenterY","ybin")
+       <<"Bin-value out of range "<<ybin<<ENDLOG;
+      return -1;
+    }
   Double_t binwidth = (fYmax - fYmin) / fNybins;
-  return fYmin + (ybin-1) * binwidth + 0.5*binwidth;
-  
+  return fYmin + (ybin-0.5) * binwidth;
+
 }
 
+
 void AliL3HistogramAdaptive::Draw(Char_t *option)
 {
 #ifdef use_root
@@ -189,10 +199,10 @@ void AliL3HistogramAdaptive::Draw(Char_t *option)
   
   Double_t kappa,psi;
   Int_t content,bin;
-  for(Int_t i=0; i<fNxbins; i++)
+  for(Int_t i=fFirstXbin; i<=fLastXbin; i++)
     {
       kappa = GetBinCenterX(i);
-      for(Int_t j=0; j<fNybins; j++)
+      for(Int_t j=fFirstYbin; j<=fLastYbin; j++)
        {
          psi = GetBinCenterY(j);
          bin = GetBin(i,j);
index 1a504446588bdea0ffdf03111586848924111a9d..22926cbc729fb3a6521a5dfa92d14e5f9ad40b20 100644 (file)
@@ -12,8 +12,9 @@ class AliL3HistogramAdaptive : public AliL3Histogram {
   Double_t fPtres;
   Double_t fMinPt;
   Double_t fMaxPt;
+  Double_t *fKappaBins; //!
   
-  Int_t InitPtBins();
+  Int_t InitKappaBins();
   
  public:
   AliL3HistogramAdaptive();
@@ -24,13 +25,13 @@ class AliL3HistogramAdaptive : public AliL3Histogram {
   void Fill(Double_t x,Double_t y,Int_t weight=1);
   Int_t FindBin(Double_t x,Double_t y);
   Int_t FindXbin(Double_t x);
-  Int_t FindYbin(Double_t y);
+  Int_t FindYbin(Double_t x);
   void Draw(Char_t *option = "hist");
   void Print();
 
   Double_t GetBinCenterX(Int_t xbin);
   Double_t GetBinCenterY(Int_t ybin);
-  
+
   ClassDef(AliL3HistogramAdaptive,1) //2D histogram class
     
 };
index d9cab0b6bfa3586527f23ba7fc3a2bce1e223e1e..7010277a1df3a11f384357bea394b20145afa6b8 100644 (file)
@@ -22,9 +22,10 @@ using namespace std;
 
 ClassImp(AliL3HoughIntMerger)
 
-AliL3HoughIntMerger::AliL3HoughIntMerger() : AliL3Merger(1,"AliL3HoughTrack")
+AliL3HoughIntMerger::AliL3HoughIntMerger()
 {
   //Default constructor
+  InitMerger(1,"AliL3HoughTrack");
   fRowMax = fRowMin = 0;
   SetParameters(0.001,0.05,10);
   Is2Global(kFALSE);
index 07645f8953c061111c0befd5a7e846fc4a998c5e..57b841960cab2b01a3a965479222645c7b0d870b 100644 (file)
@@ -30,9 +30,10 @@ AliL3HoughMerger::AliL3HoughMerger()
 }
 
 
-AliL3HoughMerger::AliL3HoughMerger(Int_t nsubsectors) : AliL3Merger(nsubsectors,"AliL3HoughTrack")
+AliL3HoughMerger::AliL3HoughMerger(Int_t nsubsectors) 
 {
   //Constructor
+  InitMerger(nsubsectors,"AliL3HoughTrack");
   Is2Global(kFALSE);
   SetParameters(0.001,0.1,0.05);
 }
index 0e1e146debce69285cbf1bb111c857828d14b5bd..45a59de3aec9ef8524864d89fc3dcea89a35a7ba 100644 (file)
@@ -16,6 +16,9 @@
 #include "AliL3TrackArray.h"
 #include "AliL3Track.h"
 #include "AliL3KalmanTrack.h"
+#include "AliL3TrackSegmentData.h"
+#include "AliL3InterMerger.h"
+#include "AliL3TrackMerger.h"
 
 #include "TNtuple.h"
 
 
 ClassImp(AliL3Kalman)
 
-AliL3Kalman::AliL3Kalman(Char_t *datapath, Int_t *slice, Int_t min_clusters = 0)
-{
+AliL3Kalman::AliL3Kalman(Char_t *datapath, Int_t *slice, Int_t min_clusters = 0){
   // Constructor
 
+  Int_t fEvent = 0;
+
   if (slice)
     {
       fMinSlice = slice[0];
@@ -49,7 +53,7 @@ AliL3Kalman::AliL3Kalman(Char_t *datapath, Int_t *slice, Int_t min_clusters = 0)
   // later on. ?? Maybe better also to put it in an Init-function
   fRow[0][0] = 0;
   fRow[0][1] = AliL3Transform::GetLastRow(-1);
-
+  fWriteOut = kTRUE;
   fBenchmark = 0;
 }  
 
@@ -66,15 +70,14 @@ void AliL3Kalman::Init()
 
 void AliL3Kalman::LoadTracks(Int_t event, Bool_t sp)
 {
-  // Load tracks from conformal tracker
+  // Load space points and tracks from conformal tracker
   // Must also be possible to take seeds (and clusters) from Hough-transform??
 
-  // Load spacepoints into clusterfile
-
   Double_t initTime,cpuTime;
   initTime = GetCpuTime();
   fBenchmark->Start("Load tracks");
 
+  // Load space points
   Char_t fname[1024];
   AliL3FileHandler *clusterfile[36][6];
   for(Int_t s=fMinSlice; s<=fMaxSlice; s++)
@@ -124,7 +127,7 @@ void AliL3Kalman::LoadTracks(Int_t event, Bool_t sp)
   tfile->Binary2TrackArray(fTracks);
   tfile->CloseBinaryInput();
   delete tfile;
-  cout << "Number of loaded tracks " << fTracks->GetNTracks() << endl;
+  //cout << "Number of loaded tracks " << fTracks->GetNTracks() << endl;
   fBenchmark->Stop("Load tracks");
   cpuTime = GetCpuTime() - initTime;
   LOG(AliL3Log::kInformational,"AliL3Kalman::LoadTracks()","Timing")
@@ -134,26 +137,31 @@ void AliL3Kalman::LoadTracks(Int_t event, Bool_t sp)
 
 void AliL3Kalman::ProcessTracks()
 {
+  // Run the Kalman filter algorithm on the loaded tracks. 
+  // If the track is OK, the loaded track is saved in file kalmantracks_0.raw
+  // The kalman filter variables (that is the state vector, covariance matrix 
+  // and chi2) is written to root-file kalmantracks.root. 
 
   Double_t initTime,cpuTime;
   initTime = GetCpuTime();
 
   fBenchmark->Start("Process tracks");
 
-  Int_t fEvent = 0;
   fTracks->QSort();
 
   fKalmanTracks = new AliL3TrackArray();
 
   // Make a ntuple to store state vector, covariance matrix and chisquare
+  // Will eventually not need a TTree??
   TNtuple *kalmanTree = new TNtuple("kalmanTree","kalmantracks","x0:x1:x2:x3:x4:c0:c1:c2:c3:c4:c5:c6:c7:c8:c9:c10:c11:c12:c13:c14:chisq");
   Float_t meas[21];
-
+  
   // Go through the tracks from conformal or hough tracker
   for (Int_t iTrack = 0; iTrack < fTracks->GetNTracks(); iTrack++)
     {
       AliL3KalmanTrack *kalmantrack = new AliL3KalmanTrack();
       kalmantrack->Init();
+
       AliL3Track *track = (AliL3Track*)fTracks->GetCheckedTrack(iTrack);
       if (!track) continue;
       if (track->GetNumberOfPoints() < fMinPointsOnTrack) continue;    
@@ -198,23 +206,11 @@ void AliL3Kalman::ProcessTracks()
        meas[18] = c[13];
        meas[19] = c[14];
        meas[20] = chisq;
-       //cout << "Chisq = " << chisq << endl;
-       /*cout << "track " << iTrack << endl; 
-       cout << "x = " << meas[0] << ", " << meas[1] << ", " << meas[2] 
-            << ", " << meas[3] << ", " << meas[4] << ", " << endl;
-       cout << "c = " << endl 
-            << meas[5] << endl
-            << meas[6] << " " << meas[7] << endl
-            << meas[8] << " " << meas[9] << " " << meas[10] << endl 
-            << meas[11] << " " << meas[12] << " " << meas[13] 
-            << " " << meas[14] << endl
-            << meas[15] << " " << meas[16] << " " << meas[17] << " " 
-            << meas[18] << " " << meas[19] << endl;
-            cout << "chisq = " << meas[20] << endl;*/ 
-       //cout << endl;
+
        // Add the track to the trackarray      
-       fKalmanTracks->AddLast(kalmantrack);
-       
+       AliL3Track *outtrack = (AliL3Track*)fKalmanTracks->NextTrack();
+       outtrack->Set(track);
+
        // Fill the ntuple with the state vector, covariance matrix and
        // chisquare
        kalmanTree->Fill(meas);
@@ -222,14 +218,15 @@ void AliL3Kalman::ProcessTracks()
 
       delete track;
       delete kalmantrack;
+
     }
 
+  //WriteKalmanTracks();
   fBenchmark->Stop("Process tracks");
   cpuTime = GetCpuTime() - initTime;
   LOG(AliL3Log::kInformational,"AliL3Kalman::ProcessTracks()","Timing")
     <<"Process tracks in "<<cpuTime*1000<<" ms"<<ENDLOG;
-
-  // Write tracks to binary file
+  
   if (fWriteOut)
     {
       Char_t tname[80];
@@ -240,117 +237,78 @@ void AliL3Kalman::ProcessTracks()
       mem->CloseBinaryOutput();
       delete mem;
     }
-  
-  TFile *out = new TFile("out.root","recreate");      
+
+  // This will be removed??
+  TFile *out = new TFile("kalmantracks.root","recreate");      
   kalmanTree->Write();
   out->Close();
 
   delete kalmanTree;
+  
 }
 
 Int_t AliL3Kalman::MakeSeed(AliL3KalmanTrack *kalmantrack, AliL3Track *track)
 {  
-  // Makes a rough state vector and covariance matrix based on the first
-  // space point in the outmost row
+  // Makes a rough state vector and covariance matrix based on three
+  // space points of the loaded track 
  
-  /*Double_t initTime,cpuTime;
-  initTime = GetCpuTime();
-
-  fBenchmark->Start("Make seed");*/
-
   UInt_t *hitnum = track->GetHitNumbers();
   UInt_t id1, id2, id3;
 
-  // Should do something to make sure that points1 2 and 3 are really not empty
   id1 = hitnum[0];
   Int_t slice1 = (id1>>25) & 0x7f;
   Int_t patch1 = (id1>>22) & 0x7;      
   UInt_t pos1 = id1&0x3fffff;
   AliL3SpacePointData *points1 = fClusters[slice1][patch1];
   
-  id2 = hitnum[1];
+  id2 = hitnum[Int_t(track->GetNHits()/2)];
   Int_t slice2 = (id2>>25) & 0x7f;
   Int_t patch2 = (id2>>22) & 0x7;      
   UInt_t pos2 = id2&0x3fffff;
   AliL3SpacePointData *points2 = fClusters[slice2][patch2];
-  if (!points2) return 0;
 
-  id3 = hitnum[2];
+  id3 = hitnum[track->GetNHits()-1];
   Int_t slice3 = (id3>>25) & 0x7f;
   Int_t patch3 = (id3>>22) & 0x7;      
   UInt_t pos3 = id3&0x3fffff;
   AliL3SpacePointData *points3 = fClusters[slice3][patch3];
 
-  /*fBenchmark->Stop("Make seed");
-  cpuTime = GetCpuTime() - initTime;
-  LOG(AliL3Log::kInformational,"AliL3Kalman::MakeSeed()","Timing")
-  <<"Make seeds in "<<cpuTime*1000<<" ms"<<ENDLOG;*/
-
-  return   kalmantrack->MakeTrackSeed(points1,pos1,points2,pos2,points3,pos3);
+  return kalmantrack->MakeTrackSeed(points1,pos1,points2,pos2,points3,pos3);
 
 }
 
 Int_t AliL3Kalman::Propagate(AliL3KalmanTrack *kalmantrack, AliL3Track *track)
 {
-  // This function should propagte the track to the next layer thera's a 
-  // cluster.
-  // Must do the following steps,
-  // 1. Go to next spacepoint
-  // 2. Must find the layer position (old and new), predict new state vector,
-  //    and covariance matrix (See AliTPCtrack::PropagateTo
-  // 3. Call Update function
-  /*Double_t initTime,cpuTime;
-  initTime = GetCpuTime();
-  fBenchmark->Start("Propagate");*/
+  // This function propagtes the kalmantrack to the next cluster of the loaded 
+  // track 
 
   Int_t num_of_clusters = track->GetNumberOfPoints();
   
   UInt_t *hitnum = track->GetHitNumbers();
   UInt_t id;
+  UInt_t badpoint = 0;
 
   for (Int_t icl = 1; icl < num_of_clusters; icl++)
     {
+
       id = hitnum[icl];
       Int_t slice = (id>>25) & 0x7f;
       Int_t patch = (id>>22) & 0x7;    
       UInt_t pos = id&0x3fffff;
       AliL3SpacePointData *points = fClusters[slice][patch];
       if (!points) continue;
-      if (kalmantrack->Propagate(points,pos) == 0) return 0;
-    }
-
-  /*fBenchmark->Stop("Propagate");
-  cpuTime = GetCpuTime() - initTime;
-  LOG(AliL3Log::kInformational,"AliL3Kalman::Propagate()","Timing")
-    <<"Propagate in "<<cpuTime*1000<<" ms"<<ENDLOG;*/
-
-  return 1;
-}
-
-void AliL3Kalman::WriteKalmanTrack(AliL3KalmanTrack *kalman)
-{
-  /*  AliL3MemHandler *memory = new AliL3MemHandler();
-  memory->SetBinaryOutput(filename);
-  if(opt=='a'||opt=='i'){  //add intracks
-    for(Int_t i=0;i<merger->GetNIn();i++){
-      AliL3TrackArray *tr=merger->GetInTracks(i);
-      memory->TrackArray2Binary(tr);
+      // Go to next cluster, but don't update track!!??
+      // But if there are several clusters that are no good: return 0;
+      if (kalmantrack->Propagate(points,pos) == 0) 
+       {
+         badpoint++;
+         continue;
+       }
+      //if (kalmantrack->Propagate(points,pos) == 0) return 0;
     }
-  }
-
-  if(opt=='o'||opt=='a'){
-    AliL3TrackArray *tr=merger->GetOutTracks();
-    memory->TrackArray2Binary(tr);
-  }
 
-  memory->CloseBinaryOutput();
-
-  return 1;*/
-}
-
-void Display()
-{
-  
+  if (badpoint >= UInt_t(num_of_clusters/2)) return 0;
+  else return 1;
 }
 
 Double_t AliL3Kalman::GetCpuTime()
index 74b7723cf48fb18c30da093843e6329c18709631..ec94bcad4d299e5a0a67d945ec977236804310ab 100644 (file)
@@ -10,6 +10,7 @@
 class AliL3SpacePointData;
 class AliL3TrackArray;
 class AliL3Benchmark;
+class AliL3TrackSegmentData;
 
 class AliL3Kalman {
 
@@ -29,6 +30,7 @@ class AliL3Kalman {
   Int_t fRow[6][2];
   Char_t fWriteOutPath[256];
   Bool_t fWriteOut;
+  Int_t fEvent;
 
  public:
 
@@ -37,16 +39,12 @@ class AliL3Kalman {
   void Init();
   void LoadTracks(Int_t event, Bool_t sp);
   void ProcessTracks();
-  //Int_t MakeSeed(AliL3SpacePointData *points, UInt_t pos, AliL3KalmanTrack *kalmantrack);
   Int_t MakeSeed(AliL3KalmanTrack *kalmantrack, AliL3Track *track);
-  //Int_t Propagate(AliL3SpacePointData *points, UInt_t pos, AliL3KalmanTrack *kalmantrack);
   Int_t Propagate(AliL3KalmanTrack *kalmantrack, AliL3Track *track);
   Int_t Update(AliL3SpacePointData *points, UInt_t pos, AliL3KalmanTrack *kalmantrack);
-  //Int_t Update(AliL3SpacePointData *points, UInt_t pos, UInt_t slice, UInt_t patch, AliL3KalmanTrack *kalmantrack);
-  void WriteKalmanTrack(AliL3KalmanTrack *kalmantrack);
-  void Dispay();
-  void WriteFiles(Char_t *path="./"){fWriteOut = kTRUE; sprintf(fWriteOutPath,"%s",path);}
+  void WriteFiles(Char_t *path="data"){fWriteOut = kTRUE; sprintf(fWriteOutPath,"%s",path);}
   Double_t GetCpuTime();
+  AliL3TrackArray *GetTracks() {return fKalmanTracks;}
 };
 
 #endif
diff --git a/HLT/kalman/AliL3KalmanLinkDef.h b/HLT/kalman/AliL3KalmanLinkDef.h
new file mode 100644 (file)
index 0000000..1b16c6b
--- /dev/null
@@ -0,0 +1,10 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class AliL3Kalman;
+#pragma link C++ class AliL3KalmanTrack;
+
+#endif
index 3706bdb9d19de75ffeb3ddee3ed70f33dfd896ea..8788dad8492628e4a5c7b56c2e6205a3ea90e3ff 100644 (file)
@@ -1,6 +1,7 @@
 #include "TMath.h"
 #include "AliL3KalmanTrack.h"
 #include "AliL3SpacePointData.h"
+#include "AliL3Logging.h"
 ClassImp(AliL3KalmanTrack)
 
 // Class for kalman tracks
@@ -32,12 +33,7 @@ void AliL3KalmanTrack::Init()
 
 Int_t AliL3KalmanTrack::MakeTrackSeed(AliL3SpacePointData *points1, UInt_t pos1, AliL3SpacePointData *points2, UInt_t pos2, AliL3SpacePointData *points3, UInt_t pos3)
 {
-  // Make track seed based on three outermost clusters of the track
-  // NB! The offline tracking uses two hits as seed, where a third hit
-  // is calculated?? Check. Offline don't have found tracks to begin with. 
-  // For HLT purpose it is maybe best to use first hits on found tracks.
-  // It depends on if we want to be able to discover previously not found
-  // tracks, timeconsuming.??
+  // Make track seed based on three clusters 
   fX = points1[pos1].fX;
 
   fP0 = points1[pos1].fY; 
@@ -49,19 +45,13 @@ Int_t AliL3KalmanTrack::MakeTrackSeed(AliL3SpacePointData *points1, UInt_t pos1,
   //Float_t alpha = TMath::ATan((fX2-fX)/(fY2-fP0));
   //Float_t X2 = XX2*TMath::Cos(alpha) + YY2*TMath::Sin(alpha); 
 
-  /*Float_t X3 = points3[pos3].fX;
+  Float_t X3 = points3[pos3].fX;
   Float_t Y3 = points3[pos3].fY;
-  Float_t Z3 = points3[pos3].fZ;*/
-  Float_t X3 = 0;
-  Float_t Y3 = 0;
-  Float_t Z3 = 0;
+  Float_t Z3 = points3[pos3].fZ;
 
-  /*printf("x1=%f , x2=%f , x3=%f\n
-y1=%f , y2=%f , y3=%f\n
-z1=%f , z2=%f , z3=%f\n",fX,X2,X3,fP0,Y2,Y3,fP1,Y3,Z3);*/
+  Float_t ZZ = fP1 - ((fP1 - Z3)/(fX-X3))*(fX-X2);
+  if (TMath::Abs(ZZ - Z2) > 10) return 0; //What's this?? (fP1 - Z3)/(fX-X3)*(fX-X2) is an angle
 
-  Float_t ZZ = fP1 - (fP1 - Z3)/(fX-X3)*(fX-X2);
-  if (TMath::Abs(ZZ - Z2) > 5) return 0; //What's this??
   // It may make no difference. Check on a big event??.
   if ((X2-fX)*(0-Y2)-(0-X2)*(Y2-fP0) == 0) return 0; //Straight seed
 
@@ -106,25 +96,21 @@ z1=%f , z2=%f , z3=%f\n",fX,X2,X3,fP0,Y2,Y3,fP1,Y3,Z3);*/
   fC43 = f30*sy1*f40+f32*sy2*f42; 
   fC44 = f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
   
-  /*printf("---------------------MAKE SEED------------\n");
-    printf("Make seed, %f, %f, %f, %f, %f\n",fP0,fP1,fP2,fP3,fP4);*/
-
   return 1;
 }
 
 Int_t AliL3KalmanTrack::Propagate(AliL3SpacePointData *points, UInt_t pos)
 {
   // Propagetes track to the plane of the next found cluster
-  //printf("line 118\n");
+
   Float_t Xold = fX; // X position for previous space point
   Float_t Xnew = points[pos].fX; // X position of current space point
   Float_t dx = Xnew - Xold;
   Float_t Yold = fP0; // Y position of old point
   Float_t Zold = fP1; // Z position of old point
-  //printf("%f %f %f\n",fP4,fP2,Xnew);
 
   if (TMath::Abs(fP4*Xnew - fP2) >= 0.9) // What's this??
-    { // In AliTPCtrack Xnew is xk?? a reference plane.
+    {
       return 0;
     }
 
@@ -139,15 +125,13 @@ Int_t AliL3KalmanTrack::Propagate(AliL3SpacePointData *points, UInt_t pos)
   // Prediction of the y- and z- coordinate in the next plane
   fP0 += dx*(Cold+Cnew)/(Rold+Rnew);
   fP1 += dx*(Cold+Cnew)/(Cold*Rnew + Cnew*Rold)*fP3; 
-  //printf("line 142\n");
 
   // f = F - 1 //What is this??
   // Must be the f-matrix for the prediction, as in eq 1 in ALICE Kalman paper
   Float_t RR = Rold + Rnew;
   Float_t CC = Cold + Cnew;
   Float_t XX = Xold + Xnew;
-  //printf("Line 149\n");
-  //printf("%f, %f, %f\n",RR,CC,XX);
+
   Float_t f02 = -dx*(2*RR + CC*(Cold/Rold + Cnew/Rnew))/(RR*RR);
   Float_t f04 = dx*(RR*XX + CC*(Cold*Xold/Rold + Cnew*Xnew/Rnew))/(RR*RR);
   Float_t CR = Cold*Rnew + Cnew*Rold;
@@ -166,18 +150,14 @@ Int_t AliL3KalmanTrack::Propagate(AliL3SpacePointData *points, UInt_t pos)
   Float_t b31=f12*fC32 + f14*fC43 + f13*fC33;
   Float_t b40=f02*fC42 + f04*fC44;
   Float_t b41=f12*fC42 + f14*fC44 + f13*fC43;
-  //printf("LIne 169\n");
-  //printf("%f %f %f\n",fC22,fC43,fC32);
 
   //a = f*b = f*C*ft
   Float_t a00 = f02*b20 + f04*b40;
   Float_t a01 = f02*b21 + f04*b41;
   Float_t a11 = f12*b21 + f14*b41+f13*b31;
-  //printf("%f\n",f04*b40);
 
   //F*C*Ft = C + (a + b + bt) /This is the covariance matrix, the samll t 
   // means transform. Then F must be df/dx 
-  //printf("line 180\n");
   fC00 += a00 + 2*b00;
   fC10 += a01 + b01 + b10;
   fC20 += b20;
@@ -187,9 +167,7 @@ Int_t AliL3KalmanTrack::Propagate(AliL3SpacePointData *points, UInt_t pos)
   fC21 += b21;
   fC31 += b31;
   fC41 += b41;
-  //printf("Propagate: %f %f %f\n",fC00,fC10,fC11);
 
-  //printf("line 192\n");
   // Multiple scattering (from AliTPCtrack::PropagateTo)
   Float_t d = TMath::Sqrt((Xold-Xnew)*(Xold-Xnew)+(Yold-fP0)*(Yold-fP0)+(Zold-fP1)*(Zold-fP1));
   Float_t Pt = (1e-9*TMath::Abs(fP4)/fP4 + fP4 * (1000/0.299792458/4));
@@ -197,8 +175,6 @@ Int_t AliL3KalmanTrack::Propagate(AliL3SpacePointData *points, UInt_t pos)
     return 0;
   }
   if (TMath::Abs(Pt) < 0.01) return 0;
-  // If Pt gets too small beta2 is 1 and that gives seg. violation in
-  // the calculation of dE.
 
   Float_t p2 = (1+fP3*fP3)/(Pt*Pt);
   Float_t beta2 = p2/(p2 +0.14*0.14);
@@ -209,7 +185,6 @@ Int_t AliL3KalmanTrack::Propagate(AliL3SpacePointData *points, UInt_t pos)
   Float_t xz=fP4*ez;
   Float_t zz1=ez*ez+1;
   Float_t xy=fP2+ey;
-  //printf("Line 209\n");
 
   fC22 += (2*ey*ez*ez*fP2+1-ey*ey+ez*ez+fP2*fP2*ez*ez)*theta2;
   fC32 += ez*zz1*xy*theta2;
@@ -218,20 +193,16 @@ Int_t AliL3KalmanTrack::Propagate(AliL3SpacePointData *points, UInt_t pos)
   fC43 += xz*zz1*theta2;
   fC44 += xz*xz*theta2;
   if (TMath::Abs(beta2) >= 1) printf("%f %f\n",beta2,Pt);
-  //printf("Line 218\n");
+
   // Energy loss
   Float_t dE = 0.153e-3/beta2*(log(5940*beta2/(1-beta2))-beta2)*d*0.9e-3;
   if (Xold < Xnew) dE = -dE;
   CC = fP4;
-  //printf("Propagate: %f, %f\n",dE,Pt);
   fP4 *= (1 - TMath::Sqrt(p2+0.14*0.14)/p2*dE);
   fP2 += Xnew*(fP4-CC);
-  //printf("Propagate, %f %f %f %f\n",dE,CC,fP4,fP2);
-  //   // Maybe calculate multilpe scattering and dE also
-  //printf("line 228\n");
+
   // Update the track parameters with the measured values of the new point
   UpdateTrack(points, pos);
-  //printf("Line 231\n");
 
   return 1;
 }
@@ -255,7 +226,6 @@ Int_t AliL3KalmanTrack::UpdateTrack(AliL3SpacePointData *points, UInt_t pos)
   sigmaY2 = sigmaZ2/det;
   sigmaZ2 = tmp/det;
   sigmaYZ = -sigmaYZ/det;
-  //printf("%f %f %f\n",fC00,fC11,fC10);
 
   // What's this?? Must be the Kalman gain matrix
   Float_t k00 = fC00*sigmaY2 + fC10*sigmaYZ;
@@ -268,7 +238,6 @@ Int_t AliL3KalmanTrack::UpdateTrack(AliL3SpacePointData *points, UInt_t pos)
   Float_t k31 = fC30*sigmaYZ + fC31*sigmaZ2;
   Float_t k40 = fC40*sigmaY2 + fC41*sigmaYZ;
   Float_t k41 = fC40*sigmaYZ + fC41*sigmaZ2;
-  //printf("%f, %f\n",k11,sigmaZ2);
 
   // Deviation between the predicted and measured values of y and z 
   Float_t dy = points[pos].fY-fP0;
@@ -287,7 +256,6 @@ Int_t AliL3KalmanTrack::UpdateTrack(AliL3SpacePointData *points, UInt_t pos)
   fP2 = eta;
   fP3 += k30*dy + k31*dz;
   fP4 = cur;
-  //printf("Update %f %f %f %f %f\n",fP0,fP1,fP2,fP3,fP4);
 
   Float_t c10 = fC10;
   Float_t c20 = fC20;
@@ -311,16 +279,16 @@ Int_t AliL3KalmanTrack::UpdateTrack(AliL3SpacePointData *points, UInt_t pos)
   fC40 -= k00*c40 + k01*c41;
   fC41 -= k10*c40 + k11*c41;
   fC42 -= k20*c40 + k21*c41;
-  fC43 -= k40*c30 + k41*c31; // Like this in AliTPCtrack::Update. WHY??
+  fC43 -= k40*c30 + k41*c31;
   fC44 -= k40*c40 + k41*c41;
-  //printf("Update: %f %f %f\n",fC00,fC10,fC11);
 
   sigmaY2 = sigmaY2*det;
   sigmaZ2 = sigmaZ2*det;
   sigmaYZ = sigmaYZ*det;
+
   // Calculate increase of chisquare
   fChisq = GetChisq() + (dy*sigmaY2*dy + 2*sigmaYZ*dy*dz + dz*sigmaZ2*dz) / (sigmaY2*sigmaZ2 - sigmaYZ*sigmaYZ);
-  //printf("%f\n",fChisq);
+  // Must at some point make an cut on chisq. Here?
 
   return 1;
 } 
@@ -370,3 +338,32 @@ Float_t AliL3KalmanTrack::f4(Float_t x1,Float_t y1,
 
   return -xr*yr/sqrt(xr*xr+yr*yr);
 }
+
+void AliL3KalmanTrack::Set(AliL3KalmanTrack *track)
+{
+
+  AliL3KalmanTrack *tpt = (AliL3KalmanTrack*)track;
+  SetX0(tpt->GetX0());
+  SetX1(tpt->GetX1());
+  SetX2(tpt->GetX2());
+  SetX3(tpt->GetX3());
+  SetX4(tpt->GetX4());
+
+  SetC0(tpt->GetC0());
+  SetC1(tpt->GetC1());
+  SetC2(tpt->GetC2());
+  SetC3(tpt->GetC3());
+  SetC4(tpt->GetC4());
+  SetC5(tpt->GetC5());
+  SetC6(tpt->GetC6());
+  SetC7(tpt->GetC7());
+  SetC8(tpt->GetC8());
+  SetC9(tpt->GetC9());
+  SetC10(tpt->GetC10());
+  SetC11(tpt->GetC11());
+  SetC12(tpt->GetC12());
+  SetC13(tpt->GetC13());
+  SetC14(tpt->GetC14());
+
+  SetNHits(tpt->GetNHits());
+}
index 2fbfc6b7c5307528ec0768a4874d5ee39ea298f2..226ff675656ba06a9fcc6d7cc3020a5b0353fb7b 100644 (file)
@@ -47,6 +47,8 @@ class AliL3KalmanTrack : public AliL3Track {
 
   Float_t fX;
 
+  Int_t fNHits;
+
  public:
 
   AliL3KalmanTrack();
@@ -64,6 +66,51 @@ class AliL3KalmanTrack : public AliL3Track {
     xx[3] = fP3;
     xx[4] = fP4;
   }
+
+  Float_t GetX0() {return fP0;}
+  Float_t GetX1() {return fP1;}
+  Float_t GetX2() {return fP2;}
+  Float_t GetX3() {return fP3;}
+  Float_t GetX4() {return fP4;}
+
+  Float_t GetC0() {return fC00;}
+  Float_t GetC1() {return fC10;}
+  Float_t GetC2() {return fC11;}
+  Float_t GetC3() {return fC20;}
+  Float_t GetC4() {return fC21;}
+  Float_t GetC5() {return fC22;}
+  Float_t GetC6() {return fC30;}
+  Float_t GetC7() {return fC31;}
+  Float_t GetC8() {return fC32;}
+  Float_t GetC9() {return fC33;}
+  Float_t GetC10() {return fC40;}
+  Float_t GetC11() {return fC41;}
+  Float_t GetC12() {return fC42;}
+  Float_t GetC13() {return fC43;}
+  Float_t GetC14() {return fC44;}
+
+  void SetX0(Float_t f) {fP0 = f;}
+  void SetX1(Float_t f) {fP1 = f;}
+  void SetX2(Float_t f) {fP2 = f;}
+  void SetX3(Float_t f) {fP3 = f;}
+  void SetX4(Float_t f) {fP4 = f;}
+
+  void SetC0(Float_t f) {fC00 = f;}
+  void SetC1(Float_t f) {fC10 = f;}
+  void SetC2(Float_t f) {fC11 = f;}
+  void SetC3(Float_t f) {fC20 = f;}
+  void SetC4(Float_t f) {fC21 = f;}
+  void SetC5(Float_t f) {fC22 = f;}
+  void SetC6(Float_t f) {fC30 = f;}
+  void SetC7(Float_t f) {fC31 = f;}
+  void SetC8(Float_t f) {fC32 = f;}
+  void SetC9(Float_t f) {fC33 = f;}
+  void SetC10(Float_t f) {fC40 = f;}
+  void SetC11(Float_t f) {fC41 = f;}
+  void SetC12(Float_t f) {fC42 = f;}
+  void SetC13(Float_t f) {fC43 = f;} 
+  void SetC14(Float_t f) {fC44 = f;}
+
   Float_t GetCovariance(Float_t cc[15]) const {
     cc[0 ]=fC00;
     cc[1 ]=fC10;  cc[2 ]=fC11;
@@ -82,9 +129,15 @@ class AliL3KalmanTrack : public AliL3Track {
   fC44 = f[14];}
   void SetChisq(Float_t f) {fChisq = f;}
 
-   Float_t f2(Float_t x1,Float_t y1, Float_t x2,Float_t y2, Float_t x3,Float_t y3);
-   Float_t f3(Float_t x1,Float_t y1, Float_t x2,Float_t y2, Float_t z1,Float_t z2);
-   Float_t f4(Float_t x1,Float_t y1, Float_t x2,Float_t y2, Float_t x3,Float_t y3);
+  Float_t f2(Float_t x1,Float_t y1, Float_t x2,Float_t y2, Float_t x3,Float_t y3);
+  Float_t f3(Float_t x1,Float_t y1, Float_t x2,Float_t y2, Float_t z1,Float_t z2);
+  Float_t f4(Float_t x1,Float_t y1, Float_t x2,Float_t y2, Float_t x3,Float_t y3);
+  void Set(AliL3KalmanTrack *track);
+
+  Int_t GetNHits() const {return fNHits;}
+  void SetNHits(Int_t f) {fNHits = f;}
+
 };
 
 #endif
diff --git a/HLT/kalman/Makefile b/HLT/kalman/Makefile
new file mode 100644 (file)
index 0000000..19fd89e
--- /dev/null
@@ -0,0 +1,97 @@
+#$Id$
+###########################
+# Makefile for HLT code.  #
+#                         #
+# Author: Anders Vestbo   #                    
+# changes by C. Loizides  #
+###########################
+
+
+ifndef TOPDIR
+TOPDIR = $(shell pwd)/..
+endif
+
+include $(TOPDIR)/Makefile.conf
+
+DEFSTR = -Dno_root
+OBJDIR = lib_alone
+INCLUDES = -I$(TOPDIR)/hough -I$(TOPDIR)/src -I$(TOPDIR)/comp -I$(TOPDIR)/misc -I$(TOPDIR)/kalman
+
+ifeq ($(USEPACKAGE),ROOT) 
+INCLUDES = -I$(ROOTSYS)/include -I$(TOPDIR)/hough -I$(TOPDIR)/src -I$(TOPDIR)/comp -I$(TOPDIR)/misc -I$(TOPDIR)/kalman
+DEFSTR = -Duse_root
+OBJDIR = lib_ROOT
+endif
+
+ifeq ($(USEPACKAGE),ALIROOT)
+INCLUDES = -I$(ROOTSYS)/include -I$(TOPDIR)/hough -I$(TOPDIR)/src -I$(TOPDIR)/comp -I$(TOPDIR)/misc -I$(TOPDIR)/kalman -I$(ALICE_ROOT)/include/ -I$(ALICE_ROOT)/TPC -I$(ALICE_ROOT)/CONTAINERS -I$(ALICE_ROOT)/STEER 
+DEFSTR = -Duse_aliroot -Duse_root
+OBJDIR = lib
+endif
+
+#Save the particle id's
+ifdef DO_MC
+DEFSTR += -Ddo_mc
+endif
+
+#Use logging classes
+ifndef NOLOGGING
+DEFSTR += -Duse_logging
+endif
+
+DEFSTR += $(EXTRADEF)
+
+ifdef MLUCDIR
+INCLUDES += -I$(MLUCDIR)/include
+else
+INCLUDES += -I/prog/alice/level3/kip/MLUC/include
+endif
+
+SRCS = AliL3Kalman.cxx AliL3KalmanTrack.cxx AliL3KalmanDisplay.cxx
+DICT  = AliL3KalmanCint-$(USEPACKAGE).cxx
+DICTH = AliL3KalmanCint-$(USEPACKAGE).h
+DICTO = $(OBJDIR)/AliL3KalmanCint-$(USEPACKAGE).o
+
+ifeq ($(OBJDIR),lib_alone)
+HDRS = $(SRCS:.cxx=.h) 
+OBJS = $(patsubst %.cxx,$(OBJDIR)/%.o,$(SRCS))
+endif
+
+ifeq ($(USEPACKAGE),ROOT)
+HDRS = $(SRCS:.cxx=.h) AliL3KalmanLinkDef.h
+OBJS = $(patsubst %.cxx,$(OBJDIR)/%.o,$(SRCS)) $(DICTO)
+endif
+
+ifeq ($(USEPACKAGE),ALIROOT)
+HDRS = $(SRCS:.cxx=.h) AliL3KalmanLinkDef.h
+OBJS = $(patsubst %.cxx,$(OBJDIR)/%.o,$(SRCS)) $(DICTO)
+endif
+
+
+LEVELSO = $(LIBDIR)/libAliL3Kalman.so
+
+all : $(OBJDIR) $(LIBDIR) $(LEVELSO)
+
+$(LEVELSO) : $(OBJS)
+       $(LD) $(SOFLAGS) $(LDFLAGS) $^ -o $@
+
+$(DICT) : $(HDRS)
+       @echo "Generating dictionary..."
+       @rootcint -f $(DICT) -c $(INCLUDES) -DGCCVERSION=$(GCCVERSION) $(DEFS) -include AliL3StandardIncludes.h $(HDRS)
+
+$(OBJDIR)/%.o : %.cxx 
+       $(CXX) $(CXXFLAGS) $(DEFSTR) -c $(INCLUDES) -o $@ $<
+
+$(OBJDIR) : 
+       test ! -e $(OBJDIR) && mkdir -p $(OBJDIR)
+
+$(LIBDIR) :
+       test ! -e $(LIBDIR) && mkdir -p $(LIBDIR)
+
+clean :
+       rm -f $(OBJDIR)/*.o
+       rm -f $(LIBDIR)/libAliL3Kalman.so
+       rm -f $(DICT) $(DICTH) 
+
+so: 
+       rm -f $(LIBDIR)/libAliL3Kalman.so
index 73624abf40ee949c02e1c9cff907f18aecc21242..aa68550f2d5101b0b613b79ff02cba08060762fe 100644 (file)
@@ -39,8 +39,9 @@ AliL3ConfMapper::AliL3ConfMapper()
   fVolume = NULL;
   fRow = NULL;
   fBench = (Bool_t)true;
-  fParamSet = (Bool_t)false;
   fVertexConstraint = (Bool_t)true;
+  fParamSet[0]=0;
+  fParamSet[1]=0;
 }
 
 
@@ -246,7 +247,7 @@ void AliL3ConfMapper::MainVertexTracking_a()
 {
   //Tracking with vertex constraint.
 
-  if(!fParamSet)
+  if(!fParamSet[(Int_t)kTRUE])
     {
       LOG(AliL3Log::kError,"AliL3ConfMapper::MainVertexTracking","Parameters")<<AliL3Log::kDec<<
        "Tracking parameters not set!"<<ENDLOG;
@@ -269,7 +270,7 @@ void AliL3ConfMapper::MainVertexTracking_b()
 {
   //Tracking with vertex constraint.
 
-  if(!fParamSet)
+  if(!fParamSet[(Int_t)kTRUE])
     {
       LOG(AliL3Log::kError,"AliL3ConfMapper::MainVertexTracking","Parameters")<<AliL3Log::kDec<<
        "Tracking parameters not set!"<<ENDLOG;
@@ -290,7 +291,7 @@ void AliL3ConfMapper::MainVertexTracking()
 {
   //Tracking with vertex constraint.
 
-  if(!fParamSet)
+  if(!fParamSet[(Int_t)kTRUE])
     {
       LOG(AliL3Log::kError,"AliL3ConfMapper::MainVertexTracking","Parameters")<<AliL3Log::kDec<<
        "Tracking parameters not set!"<<ENDLOG;
@@ -319,7 +320,14 @@ void AliL3ConfMapper::NonVertexTracking()
   //in order to do tracking on the remaining clusters.
   //The conformal mapping is now done with respect to the first cluster
   //assosciated with this track.
-
+  
+  if(!fParamSet[(Int_t)kFALSE])
+    {
+      LOG(AliL3Log::kError,"AliL3ConfMapper::NonVertexTracking","Parameters")<<AliL3Log::kDec<<
+       "Tracking parameters not set!"<<ENDLOG;
+      return;
+    }
+  
   SetVertexConstraint(false);
   ClusterLoop();
   LOG(AliL3Log::kInformational,"AliL3ConfMapper::NonVertexTracking","ntracks")<<AliL3Log::kDec<<
@@ -343,6 +351,7 @@ void AliL3ConfMapper::MainVertexSettings(Int_t trackletlength, Int_t tracklength
   SetMinPoints(tracklength,(Bool_t)true);
   fMaxPhi=maxphi;
   fMaxEta=maxeta;
+  SetParamDone(kTRUE);
 }
 
 void AliL3ConfMapper::NonVertexSettings(Int_t trackletlength, Int_t tracklength,
@@ -352,6 +361,7 @@ void AliL3ConfMapper::NonVertexSettings(Int_t trackletlength, Int_t tracklength,
   SetRowScopeTracklet(rowscopetracklet, (Bool_t)false);
   SetRowScopeTrack(rowscopetrack, (Bool_t)false);
   SetMinPoints(tracklength,(Bool_t)false);
+  SetParamDone(kFALSE);
 }
 
 void AliL3ConfMapper::SetTrackCuts(Double_t hitChi2Cut, Double_t goodHitChi2, Double_t trackChi2Cut,Int_t maxdist,Bool_t vertexconstraint)
@@ -594,8 +604,8 @@ AliL3ConfMapPoint *AliL3ConfMapper::GetNextNeighbor(AliL3ConfMapPoint *start_hit
     }
 
   //make a smart loop
-  Int_t loop_eta[9] = {0,0,0,-1,-1,-1,1,1,1};
-  Int_t loop_phi[9] = {0,-1,1,0,-1,1,0,-1,1};
+  Int_t loop_eta[25] = {0,0,0,-1,-1,-1,1,1,1, 0,0,-1,-1,1,1,-2,-2,-2,-2,-2,2,2,2,2,2};
+  Int_t loop_phi[25] = {0,-1,1,0,-1,1,0,-1,1, -2,2,-2,2,-2,2,-2,-1,0,1,2,-2,-1,0,1,2};
   
   if(min_row < fRowMin)
     min_row = fRowMin;
@@ -612,12 +622,15 @@ AliL3ConfMapPoint *AliL3ConfMapper::GetNextNeighbor(AliL3ConfMapPoint *start_hit
            {
              sub_phi_segm = start_hit->phiIndex + loop_phi[i];
              
-             if(sub_phi_segm<0)
+             if(sub_phi_segm < 0 || sub_phi_segm >= fNumPhiSegment)
+               continue;
+             /*
+               if(sub_phi_segm<0)
                sub_phi_segm += fNumPhiSegment;
-             
-             else if(sub_phi_segm >=fNumPhiSegment)
+               
+               else if(sub_phi_segm >=fNumPhiSegment)
                sub_phi_segm -= fNumPhiSegment;
-             
+             */
              //loop over sub eta segments
              
              sub_eta_segm = start_hit->etaIndex + loop_eta[i];
index 12f2bfda8755a481086f4a7a7f440f5d978e42f7..1b435ac7734ccda98e441279b17e1dbcb723928b 100644 (file)
@@ -30,7 +30,7 @@ class AliL3ConfMapper {
 
   //  AliTPCParam *fParam;   
   AliL3Vertex *fVertex; //!
-  Bool_t fParamSet;
+  Bool_t fParamSet[2];
   Bool_t fVertexFinder;  //Include vertexfinding or not (latter case vertex=(0,0,0))
 
   AliL3ConfMapPoint *fHit;  //!
@@ -99,7 +99,9 @@ class AliL3ConfMapper {
 
   void SetPointers();
   Double_t CpuTime();
-
+  void SetParamDone(Bool_t vertex_constraint) {fParamSet[(Int_t)vertex_constraint] = kTRUE;}
+  
+  
  public:
 
   AliL3ConfMapper();
@@ -138,7 +140,6 @@ class AliL3ConfMapper {
   void SetTrackCuts(Double_t hitChi2Cut, Double_t goodHitChi2, Double_t trackChi2Cut, Int_t maxdist,Bool_t vertexconstraint); 
   void SetTrackletCuts(Double_t maxangle,Double_t goodDist,Bool_t vertex_constraint);   //Set cut of tracklet for the given vertex_constraint
   void SetNSegments(Int_t f,Int_t g) {fNumPhiSegment=f,fNumEtaSegment=g;} //Set number of subvolumes (#segments in (phi,eta)
-  void SetParamDone(Bool_t f) {fParamSet = (Bool_t)f;}
   void SetMaxDca(Double_t f) {fMaxDca = f;}
 
   ClassDef(AliL3ConfMapper,1) //Base class for conformal mapping tracking
index def309f71ade2fdf85f677a3cf9f706b6adc889c..71cafb52f8c2f3a7bd9fe2fcd2efc8cc431ee045 100644 (file)
@@ -55,11 +55,13 @@ AliL3Display::AliL3Display(Int_t *slice,Char_t *gfile)
 {
   //Ctor. Specify which slices you want to look at.
 
-  TFile *file = new TFile(gfile);
-  if(!file) printf("NO FILE\n");
-  if(!file->IsOpen())
-    LOG(AliL3Log::kError,"AliL3Display::AliL3Display","File Open")
-      <<"Geometry file " << gfile << " does not exist"<<ENDLOG;
+  TFile *file = TFile::Open(gfile);
+  if(!file)
+    {
+      LOG(AliL3Log::kError,"AliL3Display::AliL3Display","File Open")
+       <<"Geometry file " << gfile << " does not exist!"<<ENDLOG;
+      return;
+    }
   
   fGeom = (TGeometry*)file->Get("AliceGeom");
   fMinSlice = slice[0];
index 35aff333b24f42e190da4deebb79972adb72d266..f070b693b21b009b62b5ab684da9b5ff60059688 100644 (file)
@@ -24,7 +24,7 @@ class AliL3Display : public TObject {
   
  public:
   AliL3Display();
-  AliL3Display(Int_t *slice, Char_t *gfile="$(LEVEL3)/GEO/alice.geom");
+  AliL3Display(Int_t *slice, Char_t *gfile="$(ALIHLT_BASEDIR)/geo/alice.geom");
   virtual ~AliL3Display();
 
   void Setup(Char_t *trackfile,Char_t *path,Int_t event=-1,Bool_t sp=kFALSE);
index 3f3946890a0ba8e06ca3c2818b8ff415a376135e..a227998d168772a246836cc75feff6035d204664 100644 (file)
 
 ClassImp(AliL3Fitter)
 
-AliL3Fitter::AliL3Fitter(AliL3Vertex *vertex)
+
+AliL3Fitter::AliL3Fitter()
+{
+  fTrack=0;
+  fVertex=0;
+  memset(fClusters,0,36*6*sizeof(AliL3SpacePointData*));
+}
+
+AliL3Fitter::AliL3Fitter(AliL3Vertex *vertex,Bool_t vertexconstraint)
 {
   //constructor
   fTrack=0;
   fVertex = vertex;
-  fVertexConstraint=kTRUE;
+  fVertexConstraint=vertexconstraint;
   memset(fClusters,0,36*6*sizeof(AliL3SpacePointData*));
 }
 
@@ -79,6 +87,70 @@ void AliL3Fitter::LoadClusters(Char_t *path,Int_t event,Bool_t sp)
     }
 }
 
+void AliL3Fitter::SortTrackClusters(AliL3Track *track)
+{
+  //Sort the internal cluster list in each track with respect to row numbering.
+  //This may be necessary when no conventional track follower has been
+  //applied, in which the cluster list has been maintained in a more
+  //arbitrary fashion.
+
+  Int_t nhits = track->GetNHits();
+  Int_t *ids = (Int_t*)track->GetHitNumbers();
+  Int_t *origids = new Int_t[nhits];
+  Int_t *mk = new Int_t[nhits];
+  Int_t k;
+
+  for(k=0; k<nhits; k++) {origids[k] = ids[k]; mk[k] = -1;}
+  
+  Int_t slice,patch,id,padrow,maxrow,maxk;
+  UInt_t pos;
+  for(Int_t j=0; j<nhits; j++)
+    {
+      maxrow=-1;
+      maxk=200;
+      for(k=0; k<nhits; k++)
+       {
+         id=ids[k];
+         if(id < 0) continue;
+         slice = (id>>25) & 0x7f;
+         patch = (id>>22) & 0x7;
+         pos = id&0x3fffff;          
+         AliL3SpacePointData *points = fClusters[slice][patch];
+         padrow = points[pos].fPadRow;
+         if(padrow > maxrow)
+           {
+             maxrow = padrow;
+             maxk=k;
+           }
+       }
+      mk[j]=maxk;
+      ids[maxk]=-1;
+    }
+    
+  for(k=0; k<nhits; k++)
+    ids[k] = origids[mk[k]];
+  delete [] origids;
+  delete [] mk;
+}
+
+void AliL3Fitter::UpdateTrack(AliL3Track *track)
+{
+  //Update the track parameters to the first point on the track.
+  //This function should be called after the track fit has been
+  //done, in order to calculate the track parameters at the 
+  //first point on the track. 
+  
+  UInt_t *ids = track->GetHitNumbers();
+  Int_t nhits = track->GetNHits();
+  UInt_t id=ids[nhits-1];
+  Int_t slice = (id>>25) & 0x7f;
+  Int_t patch = (id>>22) & 0x7;
+  UInt_t pos = id&0x3fffff;          
+  AliL3SpacePointData *points = fClusters[slice][patch];
+  track->SetFirstPoint(points[pos].fX,points[pos].fY,track->GetZ0());
+  track->UpdateToFirstPoint();
+}
+
 Int_t AliL3Fitter::FitHelix(AliL3Track *track)
 {
   fTrack = track;
@@ -497,9 +569,8 @@ Int_t AliL3Fitter::FitLine ( )
       AliL3SpacePointData *pointsl = fClusters[slice][patch];
       dx = pointsf[posf].fX - pointsl[posl].fX;
       dy = pointsf[posf].fY - pointsl[posl].fY;
-      
     }
-  
+
   Double_t localPsi = 0.5F * sqrt ( dx*dx + dy*dy ) / radius ;
   Double_t total_s ;
   
@@ -533,6 +604,8 @@ Int_t AliL3Fitter::FitLine ( )
          dx = points[pos].fX -lastpoints[lastpos].fX;
          dy = points[pos].fY -lastpoints[lastpos].fY;
          dpsi = 0.5 * (Double_t)sqrt ( dx*dx + dy*dy ) / radius ;
+         if(fabs(dpsi) > 1)
+           return 1;
          fTrack->SetPsierr(dpsi);
          s = fS[i-1] - 2.0 * radius * (Double_t)asin ( dpsi ) ;
          fS[i]=s;
index f5b41ddfb8df2bc49ebdf0837e5339fb93b95cf9..73a75f6c8272f6b5ccc6f1717b2441c4c70e7a0e 100644 (file)
@@ -17,12 +17,15 @@ class AliL3Fitter {
   Bool_t fVertexConstraint;
   AliL3SpacePointData *fClusters[36][6]; //!
   UInt_t fNcl[36][6];
-
+  
  public:
-  AliL3Fitter(AliL3Vertex *vertex);
+  AliL3Fitter();
+  AliL3Fitter(AliL3Vertex *vertex,Bool_t vertexconstraint=kTRUE);
   virtual ~AliL3Fitter();
   
   void LoadClusters(Char_t *path,Int_t event=0,Bool_t sp=kFALSE);
+  void SortTrackClusters(AliL3Track *track);
+  void UpdateTrack(AliL3Track *track);
   Int_t FitHelix(AliL3Track *track);
   Int_t FitCircle();
   Int_t FitLine();
index 46805086f70fcb75257c1c819b104f2456d63aad..00dfa4764ef3ae14be048f6629e1704a23eded2b 100644 (file)
 
 ClassImp(AliL3GlobalMerger)
 
-AliL3GlobalMerger::AliL3GlobalMerger(){
-  //Default constructor
+AliL3GlobalMerger::AliL3GlobalMerger()
+{
+  //Default constructor. Use Setup to specify and setup the necessary parameters and arrays.
   Is2Global(kTRUE);
-  SetParameter(2,2,0.001,0.05,0.1);
+  SetParameter(0,0,0,0,0);
+  fNSlices=0;
+  fFirst=0;
+  fLast=0;
 }
 
 
-AliL3GlobalMerger::AliL3GlobalMerger(Int_t first,Int_t last):AliL3Merger(last-first+1){
-  //Constructor.
+AliL3GlobalMerger::~AliL3GlobalMerger()
+{
+  //Destructor
+}
+
+void AliL3GlobalMerger::Setup(Int_t first,Int_t last)
+{
+  //Used to setup the arrays and everything
+  
   fNSlices = last-first+1;
   fFirst = first;
   fLast = last;
-  Is2Global(kTRUE);
-  SetParameter(2,2,0.001,0.05,0.1);
-}
-
-AliL3GlobalMerger::~AliL3GlobalMerger(){
-  //Destructor
+  InitMerger(last-first+1);
 }
 
-void AliL3GlobalMerger::InitSlice(Int_t slice){
+void AliL3GlobalMerger::InitSlice(Int_t slice)
+{
   // 
   // Select Sector The following FillTracks call will 
   // fill this Sector
@@ -58,8 +65,9 @@ Double_t AliL3GlobalMerger::CheckTracks(AliL3Track *innertrack,AliL3Track *outer
   //of the innermost track. This plane is defined by the padrow plane where these points
   //are.
   
+  if(innertrack->GetCharge()!=outertrack->GetCharge()) return -1;
   
-  Float_t angle = PI/36;//5 degrees = perpendicular to padrowplane (in local system)
+  Float_t angle = 0;//perpendicular to the padrowplane (in local system)
   AliL3Transform::Local2GlobalAngle(&angle,slice);
   Double_t dx[2],dy[2],dz[2];
   Double_t diff =-1;
@@ -94,178 +102,235 @@ Double_t AliL3GlobalMerger::CheckTracks(AliL3Track *innertrack,AliL3Track *outer
   dy[1] = fabs(outertrack->GetPointY()-innertrack->GetFirstPointY());
   dz[1] = fabs(outertrack->GetPointZ()-innertrack->GetFirstPointZ());
   
+  diff=0;//This was a tough bug to find....
   for(Int_t i=0; i<2; i++)
     diff += sqrt(dx[i]*dx[i] + dy[i]*dy[i] + dz[i]*dz[i]);
   return diff;
 }
 
-void AliL3GlobalMerger::SlowMerge(){
+void AliL3GlobalMerger::SlowMerge(Char_t *path)
+{
+  //Tuning of parameters. This matches _all_ tracks between two neighbouring
+  //slices, and merges the ones which are closest in space. The difference
+  //is written to a ntuppel, which can be used as a input for the SetParameters
+  //when using normal Merge function.
+  
+  
   void* ntuple=GetNtuple();
   AliL3Track *track[2];
   AliL3TrackArray *tout = GetOutTracks();
-  if(fNSlices<2){
-    LOG(AliL3Log::kWarning,"AliL3GlobalMerger::SlowMerge","Slice Number")
-    <<"Need more than one Slice!"<<ENDLOG;
-    return;
-  }
-  for(Int_t i=0; i<fNSlices; i++){
-    if(fNSlices!=18 && i+1 == fNSlices) continue; //full cicle == 18 slices
-    Int_t slice = fFirst + i;
-    AliL3TrackArray *ttt0=GetInTracks(i);
-    Int_t slice2 = i+1;
-    if(slice2==fNSlices) slice2 =0; 
-    AliL3TrackArray *ttt1=GetInTracks(slice2);
-    Float_t angle = PI/18.; //10 degrees -> the border of the slices
-    AliL3Transform::Local2GlobalAngle(&angle,slice);
-    if(i==0)
-      ttt0->QSort();
-    ttt1->QSort();
-    for(Int_t s0=0;s0<ttt0->GetNTracks();s0++){
-      AliL3Track *track0=ttt0->GetCheckedTrack(s0);
-      if(!track0) continue;
-      track0->CalculateHelix();
-      track0->CalculateEdgePoint(angle);
-      //      if(track0->IsPoint()) AddTrack(tout,track0);
+  if(fNSlices<2)
+    {
+      LOG(AliL3Log::kWarning,"AliL3GlobalMerger::SlowMerge","Slice Number")
+       <<"Need more than one Slice!"<<ENDLOG;
+      return;
     }
-    for(Int_t s1=0;s1<ttt1->GetNTracks();s1++){
-      AliL3Track *track1=ttt1->GetCheckedTrack(s1);
-      if(!track1) continue;
-      track1->CalculateHelix();
-      track1->CalculateEdgePoint(angle);
-      //      if(track1->IsPoint())  AddTrack(tout,track1); 
-    }
-    Bool_t merge = kTRUE;
-    while(merge){
-      Int_t min0=-1,min1=-1;
-      Double_t min=10;
-      for(Int_t s0=0;s0<ttt0->GetNTracks();s0++){
-        AliL3Track *track0=ttt0->GetCheckedTrack(s0);
-        if(!track0) continue;
-        if(!track0->IsPoint()) continue;
-        for(Int_t s1=0;s1<ttt1->GetNTracks();s1++){
-          AliL3Track *track1=ttt1->GetCheckedTrack(s1);
-          if(!track1) continue;
-          if(!track1->IsPoint()) continue;
-         
-          //Double_t diff = TrackDiff(track0,track1,angle);
-         Double_t diff = CheckTracks(track0,track1,slice);
-         //PrintDiff(track0,track1);
-         if(diff>=0&&diff<min){
-            min=diff;
-            min0=s0;
-            min1=s1;
-          }
-        }
-      }
-      if(min0>=0&&min1>=0){
-        AliL3Track *track0=ttt0->GetTrack(min0);
-        AliL3Track *track1=ttt1->GetTrack(min1);
-       track[0] = track0;
-        track[1] = track1;
-        SortGlobalTracks(track,2);
-       track1->CalculateEdgePoint((angle+PI/9));
-       if(track1->IsPoint())//Check if the track will cross the boundary of yet another slice.
-         MultiMerge(ttt1,track,2);
-       else
-         MultiMerge(tout,track,2); 
-        track0->CalculateReferencePoint(angle);
-        track1->CalculateReferencePoint(angle);
-       //PrintDiff(track0,track1);
-        FillNtuple(ntuple,track0,track1);
-        ttt0->Remove(min0);
-        ttt1->Remove(min1);
-       
-      }
-      else merge = kFALSE;
+  
+  for(Int_t i=0; i<fNSlices; i++)
+    {
+      //if(fNSlices!=18 && i+1 == fNSlices) continue; 
+      Int_t slice = fFirst + i;
+      AliL3TrackArray *ttt0=GetInTracks(i);
+      Int_t slice2 = i+1;
+      //if(slice2==fNSlices) slice2 =0; 
+      
+      //Make sure slices are on the same side of the TPC
+      if(slice2 == 18) slice2=0;
+      else if(slice2 == 36) slice2=18;
+      AliL3TrackArray *ttt1=GetInTracks(slice2);
+      Float_t angle = PI/18.; //10 degrees -> the border of the slices in local coordinates
+      AliL3Transform::Local2GlobalAngle(&angle,slice);
+      
+      //In the two following cases, the angle is 2*pi, so set it back to 0 in order for
+      //the calculation of crossing points to be correct.
+      if(slice==17 || slice==35) 
+       angle=0;
+      if(i==0)
+       ttt0->QSort();
+      ttt1->QSort();
+      for(Int_t s0=0;s0<ttt0->GetNTracks();s0++)
+       {
+         AliL3Track *track0=ttt0->GetCheckedTrack(s0);
+         if(!track0) continue;
+         track0->CalculateHelix();
+         track0->CalculateEdgePoint(angle);
+         //      if(track0->IsPoint()) AddTrack(tout,track0);
+       }
+      for(Int_t s1=0;s1<ttt1->GetNTracks();s1++)
+       {
+         AliL3Track *track1=ttt1->GetCheckedTrack(s1);
+         if(!track1) continue;
+         track1->CalculateHelix();
+         track1->CalculateEdgePoint(angle);
+         //      if(track1->IsPoint())  AddTrack(tout,track1); 
+       }
+      Bool_t merge = kTRUE;
+      while(merge)
+       {
+         Int_t min0=-1,min1=-1;
+         Double_t min=5;
+         Int_t n0=ttt0->GetNTracks(),n1=ttt1->GetNTracks();
+         for(Int_t s0=0;s0<n0;s0++)
+           {
+             AliL3Track *track0=ttt0->GetCheckedTrack(s0);
+             if(!track0) continue;
+             if(!track0->IsPoint()) continue;
+             for(Int_t s1=0;s1<n1;s1++)
+               {
+                 AliL3Track *track1=ttt1->GetCheckedTrack(s1);
+                 if(!track1) continue;
+                 if(!track1->IsPoint()) continue;
+                 
+                 //Double_t diff = TrackDiff(track0,track1,angle);
+                 Double_t diff = CheckTracks(track0,track1,slice);
+                 //PrintDiff(track0,track1);
+                 if(diff>=0&&diff<min)
+                   {
+                     min=diff;
+                     min0=s0;
+                     min1=s1;
+                   }
+               }
+           }
+         if(min0>=0&&min1>=0)
+           {
+             AliL3Track *track0=ttt0->GetTrack(min0);
+             AliL3Track *track1=ttt1->GetTrack(min1);
+             track[0] = track0;
+             track[1] = track1;
+             SortGlobalTracks(track,2);
+             track1->CalculateEdgePoint((angle+PI/9));
+             if(track1->IsPoint())//Check if the track will cross the boundary of yet another slice.
+               MultiMerge(ttt1,track,2);
+             else
+               MultiMerge(tout,track,2); 
+             track0->CalculateReferencePoint(angle);
+             track1->CalculateReferencePoint(angle);
+             //PrintDiff(track0,track1);
+             FillNtuple(ntuple,track0,track1);
+             ttt0->Remove(min0);
+             ttt1->Remove(min1);
+             
+           }
+         else merge = kFALSE;
+       }
+      ttt0->Compress();
+      ttt1->Compress();
+      LOG(AliL3Log::kInformational,"AliL3GlobalMerger::SlowMerge","Result")
+       <<AliL3Log::kDec<<"Merged Tracks: "<<tout->GetNTracks()<<" at:"
+       <<angle<<ENDLOG;
     }
-    ttt0->Compress();
-    ttt1->Compress();
-  LOG(AliL3Log::kInformational,"AliL3GlobalMerger::SlowMerge","Result")
-  <<AliL3Log::kDec<<"Merged Tracks: "<<tout->GetNTracks()<<" at:"
-  <<angle<<ENDLOG;
-  }
-  WriteNtuple("ntuple_s.root",ntuple);
+  Char_t fname[1024];
+  sprintf(fname,"%s/merge_parameters.root",path);
+  WriteNtuple(fname,ntuple);
 }
 
-void AliL3GlobalMerger::Merge(){
+void AliL3GlobalMerger::Merge()
+{
+  //Normal merging procedure. Matches tracks which are within limits
+  //set by SetParameters. Parameters can be tuned by SlowMerge.
+  
   AliL3Track *track[2];
   AliL3TrackArray *tout = GetOutTracks();
-  if(fNSlices<2){
-  LOG(AliL3Log::kWarning,"AliL3GlobalMerger::Merge","Slice Number")
-    <<"Need more than one Slice!"<<ENDLOG;
-    return;
-  }
-  for(Int_t i=0; i<fNSlices; i++){
-    if(fNSlices!=18 && i+1 == fNSlices) continue; //full cicle == 18 slices
-    Int_t slice = fFirst + i;
-    AliL3TrackArray *ttt0=GetInTracks(i);
-    Int_t slice2 = i+1;
-    if(slice2==fNSlices) slice2 =0;
-    AliL3TrackArray *ttt1=GetInTracks(slice2);
-    Float_t angle = PI/18.; //10 degrees -> the border of the slices
-    AliL3Transform::Local2GlobalAngle(&angle,slice);
-    if(i==0)
-      ttt0->QSort();
-    ttt1->QSort();
-    Bool_t *ismatched0  = new Bool_t[ttt0->GetNTracks()];
-    Bool_t *ismatched1  = new Bool_t[ttt1->GetNTracks()];
-    Int_t n0=0,n1=0;
-    for(Int_t s0=0;s0<ttt0->GetNTracks();s0++){
-      ismatched0[s0]=kFALSE;
-      AliL3Track *track0=ttt0->GetCheckedTrack(s0);
-      if(!track0) continue;
-      track0->CalculateHelix();
-      track0->CalculateEdgePoint(angle);
-      if(track0->IsPoint()) {n0++;track0->CalculateReferencePoint(angle);}
-    }
-    for(Int_t s1=0;s1<ttt1->GetNTracks();s1++){
-      ismatched1[s1]=kFALSE;
-      AliL3Track *track1=ttt1->GetCheckedTrack(s1);
-      if(!track1) continue;
-      track1->CalculateHelix();
-      track1->CalculateEdgePoint(angle);
-      if(track1->IsPoint()) {n1++;track1->CalculateReferencePoint(angle);}
+  if(fNSlices<2)
+    {
+      LOG(AliL3Log::kWarning,"AliL3GlobalMerger::Merge","Slice Number")
+       <<"Need more than one Slice!"<<ENDLOG;
+      return;
     }
-    for(Int_t s0=0;s0<ttt0->GetNTracks();s0++){
-      if(ismatched0[s0]) continue;
-      AliL3Track *track0=ttt0->GetCheckedTrack(s0);
-      if(!track0) continue;
-      if(!track0->IsPoint()) continue;
-      for(Int_t s1=0;s1<ttt1->GetNTracks();s1++){
-        if(ismatched1[s1]) continue;
-        AliL3Track *track1=ttt1->GetCheckedTrack(s1);
-        if(!track1) continue;
-        if(!track1->IsPoint()) continue;
-        if(IsRTrack(track0,track1)){
-          track[0] = track0;
-          track[1] = track1;
-          SortGlobalTracks(track,2);
-          Double_t r0 = pow(track[0]->GetLastPointX(),2)+
-                        pow(track[0]->GetLastPointY(),2);
-          Double_t r1 = pow(track[1]->GetFirstPointX(),2)+
-                        pow(track[1]->GetFirstPointY(),2);
-          if(r0<r1){
-            MultiMerge(tout,track,2); 
-            ismatched0[s0]=kTRUE;
-           ismatched1[s1]=kTRUE;
-            ttt0->Remove(s0);
-            ttt1->Remove(s1);
-           break;
-           /*
-             The track is merged, so we will _not_ look for more matches.
-             Because there could easily be more matches, if a track is being
-             split within the sector.
-             This bug was brought to you by Dr.Frankenfeld, and fixed 2 years
-             later by ASV....
-           */
-          }
-        }
-      }
+  for(Int_t i=0; i<fNSlices; i++)
+    {
+      //if(fNSlices!=18 && i+1 == fNSlices) continue; 
+      Int_t slice = fFirst + i;
+      AliL3TrackArray *ttt0=GetInTracks(i);
+      Int_t slice2 = i+1;
+      //if(slice2==fNSlices) slice2 =0;
+      
+      //Make sure slices are on the same side of the TPC
+      if(slice2 == 18) slice2=0;
+      else if(slice2 == 36) slice2=18;
+      AliL3TrackArray *ttt1=GetInTracks(slice2);
+      Float_t angle = PI/18.; //10 degrees -> the border of the slices in local coordinates
+      AliL3Transform::Local2GlobalAngle(&angle,slice);
+      
+      //In the two following cases, the angle is 2*pi, so set it back to 0 in order for
+      //the calculation of crossing points to be correct.
+      if(slice==17 || slice==35)
+       angle=0;
+      if(i==0)
+       ttt0->QSort();
+      ttt1->QSort();
+      Bool_t *ismatched0  = new Bool_t[ttt0->GetNTracks()];
+      Bool_t *ismatched1  = new Bool_t[ttt1->GetNTracks()];
+      Int_t n0=0,n1=0;
+      for(Int_t s0=0;s0<ttt0->GetNTracks();s0++)
+       {
+         ismatched0[s0]=kFALSE;
+         AliL3Track *track0=ttt0->GetCheckedTrack(s0);
+         if(!track0) continue;
+         track0->CalculateHelix();
+         track0->CalculateEdgePoint(angle);
+         if(track0->IsPoint()) 
+           {
+             n0++;
+             track0->CalculateReferencePoint(angle);
+           }
+       }
+      for(Int_t s1=0;s1<ttt1->GetNTracks();s1++)
+       {
+         ismatched1[s1]=kFALSE;
+         AliL3Track *track1=ttt1->GetCheckedTrack(s1);
+         if(!track1) continue;
+         track1->CalculateHelix();
+         track1->CalculateEdgePoint(angle);
+         if(track1->IsPoint()) 
+           {
+             n1++;
+             track1->CalculateReferencePoint(angle);
+           }
+       }
+      for(Int_t s0=0;s0<ttt0->GetNTracks();s0++)
+       {
+         if(ismatched0[s0]) continue;
+         AliL3Track *track0=ttt0->GetCheckedTrack(s0);
+         if(!track0) continue;
+         if(!track0->IsPoint()) continue;
+         for(Int_t s1=0;s1<ttt1->GetNTracks();s1++)
+           {
+             if(ismatched1[s1]) continue;
+             AliL3Track *track1=ttt1->GetCheckedTrack(s1);
+             if(!track1) continue;
+             if(!track1->IsPoint()) continue;
+             if(IsRTrack(track0,track1))
+               {
+                 track[0] = track0;
+                 track[1] = track1;
+                 SortGlobalTracks(track,2);
+                 Double_t r0 = pow(track[0]->GetLastPointX(),2)+
+                   pow(track[0]->GetLastPointY(),2);
+                 Double_t r1 = pow(track[1]->GetFirstPointX(),2)+
+                   pow(track[1]->GetFirstPointY(),2);
+                 if(r0<r1)
+                   {
+                     MultiMerge(tout,track,2); 
+                     ismatched0[s0]=kTRUE;
+                     ismatched1[s1]=kTRUE;
+                     ttt0->Remove(s0);
+                     ttt1->Remove(s1);
+                     break;
+                     /*
+                       The track is merged, so we will _not_ look for more matches.
+                       Because there could easily be more matches, if a track is being
+                       split within the sector....
+                     */
+                   }
+               }
+           }
+       }
+      LOG(AliL3Log::kInformational,"AliL3GlobalMerger::Merge","Result")
+       <<AliL3Log::kDec<<"slice0: "<<n0<<" slice1: "<<n1
+       <<" Merged Tracks: "<<tout->GetNTracks()<<ENDLOG;
+      delete [] ismatched0;
+      delete [] ismatched1;
     }
-    LOG(AliL3Log::kInformational,"AliL3GlobalMerger::Merge","Result")
-      <<AliL3Log::kDec<<"slice0: "<<n0<<" slice1: "<<n1
-      <<" Merged Tracks: "<<tout->GetNTracks()<<ENDLOG;
-    delete [] ismatched0;
-    delete [] ismatched1;
-  }
 }
index ad338f8dbf783241a8fcb92070db6bb7bb12032d..61cf25e55f51d1e68e0b129c0b4d5672addd568b 100644 (file)
@@ -18,11 +18,11 @@ class AliL3GlobalMerger : public AliL3Merger{
   
  public:
   AliL3GlobalMerger();
-  AliL3GlobalMerger(Int_t first,Int_t last);
   virtual ~AliL3GlobalMerger();
-
+  
+  void Setup(Int_t first,Int_t last);
   void InitSlice(Int_t slice);
-  void SlowMerge();
+  void SlowMerge(Char_t *path="./");
   void Merge();  //Loop over tracks from different sectors
 
   ClassDef(AliL3GlobalMerger,1) //Slice merger
index 415e1ed5868b65cc9571b3d0f1fd7740b27b7942..f912d6166d0d99c36d263a929bd7834b253c7a0a 100644 (file)
 
 ClassImp(AliL3InterMerger)
 
-AliL3InterMerger::AliL3InterMerger():AliL3Merger(1){
+AliL3InterMerger::AliL3InterMerger()
+{
   //Default constructor
+  InitMerger(1);
   Is2Global(kFALSE);
 //  SetParameter(2,2,.3,.3,.3);
   SetParameter(1,0.5,0.0005,0.05,0.1);
index b6967e8df707303302d45faf7727e0a19a216137..b2c698660174f9b6fe869630adfe66b7afa438ee 100644 (file)
 
 ClassImp(AliL3Merger)
 
-AliL3Merger::AliL3Merger(){
+AliL3Merger::AliL3Merger()
+{
   //Default constructor
-  SetArray(0);
+  fInTrack=0;
+  fOutTrack=0;
+  fCurrentTracks=0;
+  fNIn=0;
 }
 
+AliL3Merger::~AliL3Merger()
+{
+  //Destructor
+  DeleteArray();
+}
 
-AliL3Merger::AliL3Merger(Int_t ntrackarrays,Char_t *tracktype){
-  //Constructor.
+void AliL3Merger::InitMerger(Int_t ntrackarrays,Char_t *tracktype)
+{
+  //Used to setup all arrays
   
   if(strcmp(tracktype,"AliL3Track")==0) fTrackType='t';
   else if(strcmp(tracktype,"AliL3ConfMapTrack")==0) fTrackType='c';
@@ -50,117 +60,139 @@ AliL3Merger::AliL3Merger(Int_t ntrackarrays,Char_t *tracktype){
 
 }
 
-AliL3Merger::~AliL3Merger(){
-  //Destructor
-  DeleteArray();
-}
-
-void AliL3Merger::DeleteArray(){
+void AliL3Merger::DeleteArray()
+{
   for(Int_t i=0; i<fNIn;i++)
-    delete fInTrack[i];
-  delete[] (Byte_t*) fInTrack;
-  delete fOutTrack;
+    {
+      if(!fInTrack[i]) continue;
+      delete fInTrack[i];
+      fInTrack[i]=0;
+    }
+  if(fInTrack)
+    delete[] fInTrack;
+  if(fOutTrack)
+    delete fOutTrack;
+  fInTrack=0;
+  fOutTrack=0;
 }
 
-void AliL3Merger::SetArray(Int_t nin){
+void AliL3Merger::SetArray(Int_t nin)
+{
+  DeleteArray();//Make sure arrays are cleaned 
+  
   fNIn = nin;
-  fInTrack = (AliL3TrackArray **) new Byte_t[fNIn*sizeof(AliL3TrackArray *)];
-  for(Int_t i=0; i<fNIn;i++){
-    if(fTrackType=='h')
-      fInTrack[i] = new AliL3TrackArray("AliL3HoughTrack");
-    else
-      fInTrack[i] = new AliL3TrackArray("AliL3Track");
-    
-  }
+  fInTrack = new AliL3TrackArray*[fNIn];
+  for(Int_t i=0; i<fNIn;i++)
+    {
+      if(fTrackType=='h')
+       fInTrack[i] = new AliL3TrackArray("AliL3HoughTrack");
+      else
+       fInTrack[i] = new AliL3TrackArray("AliL3Track");
+      
+    }
   if(fTrackType=='h')
     fOutTrack= new AliL3TrackArray("AliL3HoughTrack");
   else
     fOutTrack= new AliL3TrackArray("AliL3Track");
 }
 
-void AliL3Merger::Reset(){
-  for(Int_t i=0; i<fNIn;i++){
-    fInTrack[i]->Reset();
-  }
+void AliL3Merger::Reset()
+{
+  for(Int_t i=0; i<fNIn;i++)
+    {
+      fInTrack[i]->Reset();
+    }
   fOutTrack->Reset();
 }
 
-void AliL3Merger::FillTracks(Int_t ntracks, AliL3TrackSegmentData* tr){
+void AliL3Merger::FillTracks(Int_t ntracks, AliL3TrackSegmentData* tr)
+{
   //Read tracks from shared memory (or memory)
+
   AliL3TrackArray *destination = GetInTracks(fCurrentTracks);
   if(Is2Global())
     destination->FillTracks(ntracks, tr, fSlice);
-    //destination->FillTracks(ntracks, tr, fSlice, fTransformer);
   else
     destination->FillTracks(ntracks, tr);
 }
 
-void AliL3Merger::AddAllTracks(){
-  for(Int_t i=0; i<GetNIn();i++){
-    AliL3TrackArray *in = GetInTracks(i);
-    AliL3TrackArray *out = GetOutTracks();
-    out->AddTracks(in);
-  }
+void AliL3Merger::AddAllTracks()
+{
+  for(Int_t i=0; i<GetNIn();i++)
+    {
+      AliL3TrackArray *in = GetInTracks(i);
+      AliL3TrackArray *out = GetOutTracks();
+      out->AddTracks(in);
+    }
 }
 
-void AliL3Merger::SortGlobalTracks(AliL3Track **tracks, Int_t ntrack){
+void AliL3Merger::SortGlobalTracks(AliL3Track **tracks, Int_t ntrack)
+{
   AliL3Track **tmp = new AliL3Track*[ntrack]; 
   for(Int_t i=0;i<ntrack;i++) tmp[i] = tracks[i];
   Int_t *t = new Int_t[ntrack];
   for(Int_t i=0;i<ntrack;i++) t[i]=-1;
-
-  for(Int_t j=0;j<ntrack;j++){
-    Double_t minr=300;
-    Int_t    mini=0;
-    for(Int_t i=0;i<ntrack;i++){
-     if(!tracks[i]) continue;
-       Double_t rr=pow(tracks[i]->GetFirstPointX(),2)+pow(tracks[i]->GetFirstPointY(),2);
-       Double_t r=sqrt(rr);
-       if(r<minr){
-         minr=r;
-         mini=i;
-       }
+  
+  for(Int_t j=0;j<ntrack;j++)
+    {
+      Double_t minr=300;
+      Int_t    mini=0;
+      for(Int_t i=0;i<ntrack;i++)
+       {
+         if(!tracks[i]) continue;
+         Double_t rr=pow(tracks[i]->GetFirstPointX(),2)+pow(tracks[i]->GetFirstPointY(),2);
+         Double_t r=sqrt(rr);
+         if(r<minr){
+           minr=r;
+           mini=i;
+         }
+       }
+      t[j]=mini;
+      tracks[mini]=0;
     }
-    t[j]=mini;
-    tracks[mini]=0;
-  }
   for(Int_t i=0;i<ntrack;i++) tracks[i] = tmp[t[i]];
   delete[] t;
   delete[] tmp;
 }
 
 
-void AliL3Merger::SortTracks(AliL3Track **tracks, Int_t ntrack){
+void AliL3Merger::SortTracks(AliL3Track **tracks, Int_t ntrack)
+{
   AliL3Track **tmp = new  AliL3Track*[ntrack];
   for(Int_t i=0;i<ntrack;i++) tmp[i] = tracks[i];
   Int_t *t = new Int_t[ntrack];
   for(Int_t i=0;i<ntrack;i++) t[i]=-1;
-
-  for(Int_t j=0;j<ntrack;j++){
-    Double_t minx=300; 
-    Int_t    mini=0;
-    for(Int_t i=0;i<ntrack;i++){
-     if(!tracks[i]) continue;
-       if(tracks[i]->GetFirstPointX()<minx){
-         minx=tracks[i]->GetFirstPointX();
-         mini=i;
-       }     
+  
+  for(Int_t j=0;j<ntrack;j++)
+    {
+      Double_t minx=300; 
+      Int_t    mini=0;
+      for(Int_t i=0;i<ntrack;i++)
+       {
+         if(!tracks[i]) continue;
+         if(tracks[i]->GetFirstPointX()<minx)
+           {
+             minx=tracks[i]->GetFirstPointX();
+             mini=i;
+           }     
+       }
+      t[j]=mini;  
+      tracks[mini]=0;
     }
-    t[j]=mini;  
-    tracks[mini]=0;
-  }
   for(Int_t i=0;i<ntrack;i++) tracks[i] = tmp[t[i]];
   delete[] t;
   delete[] tmp;
 }
 
-void AliL3Merger::AddTrack(AliL3TrackArray *mergedtrack,AliL3Track *track){
+void AliL3Merger::AddTrack(AliL3TrackArray *mergedtrack,AliL3Track *track)
+{
   AliL3Track *t[1];
   t[0] = track;
   MultiMerge(mergedtrack,t,1);
 }
 
-AliL3Track * AliL3Merger::MergeTracks(AliL3TrackArray *mergedtrack,AliL3Track *t0,AliL3Track *t1){
+AliL3Track * AliL3Merger::MergeTracks(AliL3TrackArray *mergedtrack,AliL3Track *t0,AliL3Track *t1)
+{
   AliL3Track *t[2];
   t[0] = t0; 
   t[1] = t1;
@@ -168,31 +200,35 @@ AliL3Track * AliL3Merger::MergeTracks(AliL3TrackArray *mergedtrack,AliL3Track *t
   return MultiMerge(mergedtrack,t,2);
 }
 
-AliL3Track * AliL3Merger::MultiMerge(AliL3TrackArray *mergedtracks,AliL3Track **tracks, Int_t ntrack){
-// merge the tracks!!
-
-//check npoints
+AliL3Track * AliL3Merger::MultiMerge(AliL3TrackArray *mergedtracks,AliL3Track **tracks, Int_t ntrack)
+{
+  // merge the tracks!!
+  
+  //check npoints
   Int_t nps = 0;
-  for(Int_t i=0;i<ntrack;i++){
-    nps+=tracks[i]->GetNHits();
-  }
-  if(nps>AliL3Transform::GetNRows()){
-    LOG(AliL3Log::kWarning,"AliL3Merger::MultiMerge","Adding Points")
-    <<AliL3Log::kDec<<"Too many Points: "<<nps<<ENDLOG;
-    return 0;
-  }
-
+  for(Int_t i=0;i<ntrack;i++)
+    {
+      nps+=tracks[i]->GetNHits();
+    }
+  if(nps>AliL3Transform::GetNRows())
+    {
+      LOG(AliL3Log::kWarning,"AliL3Merger::MultiMerge","Adding Points")
+       <<AliL3Log::kDec<<"Too many Points: "<<nps<<ENDLOG;
+      return 0;
+    }
+  
   //create new track
   AliL3Track *newtrack = mergedtracks->NextTrack();
   //copy points
   UInt_t nn[AliL3Transform::GetNRows()];
   nps = 0;
-
-//  for(Int_t i=0;i<ntrack;i++){
-  for(Int_t i=ntrack-1;i>=0;i--){
-    memcpy(&nn[nps],tracks[i]->GetHitNumbers(),tracks[i]->GetNHits()*sizeof(UInt_t));
-    nps+=tracks[i]->GetNHits();
-  }
+  
+  //  for(Int_t i=0;i<ntrack;i++){
+  for(Int_t i=ntrack-1;i>=0;i--)
+    {
+      memcpy(&nn[nps],tracks[i]->GetHitNumbers(),tracks[i]->GetNHits()*sizeof(UInt_t));
+      nps+=tracks[i]->GetNHits();
+    }
   AliL3Track *tpf=tracks[0];
   AliL3Track *tpl=tracks[ntrack-1];
   AliL3Track *best = tpf;
@@ -210,7 +246,8 @@ AliL3Track * AliL3Merger::MultiMerge(AliL3TrackArray *mergedtracks,AliL3Track **
   return newtrack;
 }
 
-void* AliL3Merger::GetNtuple(char *varlist){
+void* AliL3Merger::GetNtuple(char *varlist)
+{
 #ifdef use_root
   TNtuple* nt = new TNtuple("ntuple","ntuple",varlist);
   return (void*) nt;
@@ -219,7 +256,8 @@ void* AliL3Merger::GetNtuple(char *varlist){
 #endif
 }
 
-void* AliL3Merger::GetNtuple(){
+void* AliL3Merger::GetNtuple()
+{
 #ifdef use_root
   TNtuple* nt = new TNtuple("ntuple","ntuple",
                            "dx:dy:dz:dk:dpsi:dtgl:dq:disx:disy:disz:dis:n0:n1:diff:drx:dry:drz");
@@ -229,7 +267,8 @@ void* AliL3Merger::GetNtuple(){
 #endif
 }
 
-Bool_t AliL3Merger::WriteNtuple(char *filename, void* nt){
+Bool_t AliL3Merger::WriteNtuple(char *filename, void* nt)
+{
 #ifdef use_root
   TNtuple *ntuple=(TNtuple *) nt;
   TFile *f = new TFile(filename,"RECREATE");
@@ -242,51 +281,56 @@ Bool_t AliL3Merger::WriteNtuple(char *filename, void* nt){
 #endif
 }
 
-void AliL3Merger::FillNtuple(void *nt,AliL3Track *innertrack,AliL3Track *outertrack){
+void AliL3Merger::FillNtuple(void *nt,AliL3Track *innertrack,AliL3Track *outertrack)
+{
   Float_t data[17];
-  if(outertrack->IsPoint()&&innertrack->IsPoint()){
-    data[0] =Float_t(innertrack->GetPointX()-outertrack->GetPointX());
-    data[1] =Float_t(innertrack->GetPointY()-outertrack->GetPointY());
-    data[2] =Float_t(innertrack->GetPointZ()-outertrack->GetPointZ());
-    data[3] =Float_t(innertrack->GetKappa()-outertrack->GetKappa());
-    Double_t psi= innertrack->GetPointPsi() - outertrack->GetPointPsi();
-    if(psi>PI) psi-=2*PI;
-    if(psi<-PI)psi+=2*PI;
-    data[4] =Float_t(psi);
-    data[5] =Float_t(innertrack->GetTgl()-outertrack->GetTgl());
-    data[6] =Float_t(innertrack->GetCharge()-outertrack->GetCharge());
-    data[7] =Float_t(innertrack->GetLastPointX()-outertrack->GetFirstPointX());
-    data[8] =Float_t(innertrack->GetLastPointY()-outertrack->GetFirstPointY());
-    data[9] =Float_t(innertrack->GetLastPointZ()-outertrack->GetFirstPointZ());
-    data[10] =sqrt(pow(data[7],2)+pow(data[8],2)+pow(data[9],2));
-    data[11]= outertrack->GetNHits();
-    data[12]= innertrack->GetNHits();
-    data[13] = Float_t(TrackDiff(innertrack,outertrack));
-    data[14]=0;
-    data[15]=0;
-    data[16]=0;
+  if(outertrack->IsPoint()&&innertrack->IsPoint())
+    {
+      data[0] =Float_t(innertrack->GetPointX()-outertrack->GetPointX());
+      data[1] =Float_t(innertrack->GetPointY()-outertrack->GetPointY());
+      data[2] =Float_t(innertrack->GetPointZ()-outertrack->GetPointZ());
+      data[3] =Float_t(innertrack->GetKappa()-outertrack->GetKappa());
+      Double_t psi= innertrack->GetPointPsi() - outertrack->GetPointPsi();
+      if(psi>PI) psi-=2*PI;
+      if(psi<-PI)psi+=2*PI;
+      data[4] =Float_t(psi);
+      data[5] =Float_t(innertrack->GetTgl()-outertrack->GetTgl());
+      data[6] =Float_t(innertrack->GetCharge()-outertrack->GetCharge());
+      data[7] =Float_t(innertrack->GetLastPointX()-outertrack->GetFirstPointX());
+      data[8] =Float_t(innertrack->GetLastPointY()-outertrack->GetFirstPointY());
+      data[9] =Float_t(innertrack->GetLastPointZ()-outertrack->GetFirstPointZ());
+      data[10] =sqrt(pow(data[7],2)+pow(data[8],2)+pow(data[9],2));
+      data[11]= outertrack->GetNHits();
+      data[12]= innertrack->GetNHits();
+      data[13] = Float_t(TrackDiff(innertrack,outertrack));
+      data[14]=0;
+      data[15]=0;
+      data[16]=0;
 #ifdef use_root
-    TNtuple *ntuple = (TNtuple *) nt;
-    ntuple->Fill(data);
+      TNtuple *ntuple = (TNtuple *) nt;
+      ntuple->Fill(data);
 #endif
-  }
+    }
 }
 
-void AliL3Merger::FillNtuple(void *nt,Float_t *data){
+void AliL3Merger::FillNtuple(void *nt,Float_t *data)
+{
 #ifdef use_root
-    TNtuple *ntuple = (TNtuple *) nt;
-    ntuple->Fill(data);
+  TNtuple *ntuple = (TNtuple *) nt;
+  ntuple->Fill(data);
 #endif
 }
 
-Double_t AliL3Merger::GetAngle(Double_t a1,Double_t a2){
+Double_t AliL3Merger::GetAngle(Double_t a1,Double_t a2)
+{
   Double_t da = a1 - a2 +4*PI;
   da = fmod(da,2*PI);
   if(da>PI) da = 2*PI -da;
   return da;
 }
 
-void AliL3Merger::SetParameter(Double_t maxy, Double_t maxz, Double_t maxkappa, Double_t maxpsi, Double_t maxtgl){
+void AliL3Merger::SetParameter(Double_t maxy, Double_t maxz, Double_t maxkappa, Double_t maxpsi, Double_t maxtgl)
+{
   fMaxY = maxy;
   fMaxZ = maxz;
   fMaxKappa = maxkappa;
@@ -294,12 +338,13 @@ void AliL3Merger::SetParameter(Double_t maxy, Double_t maxz, Double_t maxkappa,
   fMaxTgl = maxtgl;
 }
 
-Bool_t AliL3Merger::IsTrack(AliL3Track *innertrack,AliL3Track *outertrack){
-
+Bool_t AliL3Merger::IsTrack(AliL3Track *innertrack,AliL3Track *outertrack)
+{
+  
   if(innertrack->GetCharge()!=outertrack->GetCharge()) return kFALSE;
   if( (!innertrack->IsPoint()) || (!outertrack->IsPoint()) )  return kFALSE; 
   if(innertrack->GetNHits()+outertrack->GetNHits()>AliL3Transform::GetNRows()) return kFALSE;
-
+  
   if(fabs(innertrack->GetPointY()-outertrack->GetPointY()) >fMaxY) return kFALSE;
   if(fabs(innertrack->GetPointZ()-outertrack->GetPointZ()) >fMaxZ) return kFALSE;
   if(fabs(innertrack->GetKappa()-outertrack->GetKappa())   >fMaxKappa) return kFALSE;
@@ -309,15 +354,17 @@ Bool_t AliL3Merger::IsTrack(AliL3Track *innertrack,AliL3Track *outertrack){
   return kTRUE;
 }
 
-Bool_t AliL3Merger::IsRTrack(AliL3Track *innertrack,AliL3Track *outertrack){
+Bool_t AliL3Merger::IsRTrack(AliL3Track *innertrack,AliL3Track *outertrack)
+{
   return IsTrack(innertrack,outertrack);
 }
 
-Double_t AliL3Merger::TrackDiff(AliL3Track *innertrack,AliL3Track *outertrack){
+Double_t AliL3Merger::TrackDiff(AliL3Track *innertrack,AliL3Track *outertrack)
+{
   Double_t diff =-1;
   Double_t x[4],y[4],z[4],dy[4],dz[4];
   AliL3Track *tracks[2]; 
-
+  
   tracks[0] = innertrack;
   tracks[1] = outertrack;
   SortGlobalTracks(tracks,2);
@@ -328,7 +375,7 @@ Double_t AliL3Merger::TrackDiff(AliL3Track *innertrack,AliL3Track *outertrack){
   x[1] = innertrack->GetLastPointX();
   x[2] = outertrack->GetFirstPointX();
   x[3] = outertrack->GetLastPointX();
-
+  
   y[0] = innertrack->GetFirstPointY();
   y[1] = innertrack->GetLastPointY();
   y[2] = outertrack->GetFirstPointY();
@@ -368,13 +415,14 @@ Double_t AliL3Merger::TrackDiff(AliL3Track *innertrack,AliL3Track *outertrack){
 
 void AliL3Merger::PrintDiff(AliL3Track *innertrack,AliL3Track *outertrack)
 {
-  if(!innertrack->IsPoint()||!outertrack->IsPoint()){
-    LOG(AliL3Log::kInformational,"AliL3Merger::PrintDiff","No Points")<<ENDLOG;
-    //cerr<<"AliL3Merger::PrintDiff: No Points"<<endl;
-    //cerr<<"---------------------------"<<endl;
-    return;
-  } 
-
+  if(!innertrack->IsPoint()||!outertrack->IsPoint())
+    {
+      LOG(AliL3Log::kInformational,"AliL3Merger::PrintDiff","No Points")<<ENDLOG;
+      //cerr<<"AliL3Merger::PrintDiff: No Points"<<endl;
+      //cerr<<"---------------------------"<<endl;
+      return;
+    } 
+  
   Double_t dx = innertrack->GetPointX()-outertrack->GetPointX();
   Double_t dy = innertrack->GetPointY()-outertrack->GetPointY();
   Double_t dz = innertrack->GetPointZ()-outertrack->GetPointZ();
@@ -385,56 +433,61 @@ void AliL3Merger::PrintDiff(AliL3Track *innertrack,AliL3Track *outertrack)
   //Double_t dpsi = GetAngle(innertrack->GetPointPsi(),outertrack->GetPointPsi());
   Double_t dtgl= innertrack->GetTgl()-outertrack->GetTgl();
   Double_t dq =innertrack->GetCharge()-outertrack->GetCharge();
-
+  
   LOG(AliL3Log::kInformational,"AliL3Merger::PrintDiff","Points") <<"dx: "<<dx<<" dy: "<<dy<<" dz: "<<dz<<" dk: "<<dk<<" dpsi: "<<dpsi<<" dtgl: "<<dtgl<<" dq: "<<dq<<ENDLOG;
   //fprintf(stderr,"dx: %4f dy: %4f dz: %4f dk: %4f dpsi: %4f dtgl: %4f dq: %4f\n",dx,dy,dz,dk,dpsi,dtgl,dq);
   //cerr<<"---------------------------"<<endl;
   
 }
 
-void AliL3Merger::Print(){
+void AliL3Merger::Print()
+{
   // print some infos
-  for(Int_t i=0; i<fNIn; i++){
-    AliL3TrackArray *ttt= GetInTracks(i);
-    for(Int_t j =0;j<ttt->GetNTracks();j++){
-      AliL3Track *track=ttt->GetCheckedTrack(j);
-      if(!track) continue;
-      track->CalculateHelix();
-//      Double_t angle = atan2(track->GetLastPointY(),track->GetLastPointX());
-//      if(angle<0) angle+=PI;
-      if(track->CalculatePoint(135))
-//      if(!track->CalculateEdgePoint(angle)) cerr<<"**************"<<endl;     
-//      if(track->CalculatePoint(track->GetLastPointX()))
-//      if(track->CalculatePoint(0))
-      {
-//      PrintTrack(track);
-//      track->CalculateReferencePoint(PI/180.);
-      track->CalculateReferencePoint(0.001);
-      Float_t dx=(float)track->GetPointX()-track->GetPointX();
-      Float_t dy=(float)track->GetPointY()-track->GetPointY();
-      Float_t dz=(float)track->GetPointZ()-track->GetPointZ();
-      LOG(AliL3Log::kInformational,"AliL3Merger::Print","RefPoint") <<"npt: "<<track->GetNHits()<<" dx: "<<dx<<" dy: "<<dy<<" dz: "<<dz<<ENDLOG;
-
-      //fprintf(stderr,"npt: %3d dx: %8.5f dy: %8.5f dz: %8.5f\n",track->GetNHits(),dx,dy,dz);
-      //cerr<<"---------------------------"<<endl;
-      }
-    }  
-  }
+  for(Int_t i=0; i<fNIn; i++)
+    {
+      AliL3TrackArray *ttt= GetInTracks(i);
+      for(Int_t j =0;j<ttt->GetNTracks();j++)
+       {
+         AliL3Track *track=ttt->GetCheckedTrack(j);
+         if(!track) continue;
+         track->CalculateHelix();
+         //      Double_t angle = atan2(track->GetLastPointY(),track->GetLastPointX());
+         //      if(angle<0) angle+=PI;
+         if(track->CalculatePoint(135))
+           //      if(!track->CalculateEdgePoint(angle)) cerr<<"**************"<<endl;     
+           //      if(track->CalculatePoint(track->GetLastPointX()))
+           //      if(track->CalculatePoint(0))
+           {
+             //      PrintTrack(track);
+             //      track->CalculateReferencePoint(PI/180.);
+             track->CalculateReferencePoint(0.001);
+             Float_t dx=(float)track->GetPointX()-track->GetPointX();
+             Float_t dy=(float)track->GetPointY()-track->GetPointY();
+             Float_t dz=(float)track->GetPointZ()-track->GetPointZ();
+             LOG(AliL3Log::kInformational,"AliL3Merger::Print","RefPoint") <<"npt: "<<track->GetNHits()<<" dx: "<<dx<<" dy: "<<dy<<" dz: "<<dz<<ENDLOG;
+             
+             //fprintf(stderr,"npt: %3d dx: %8.5f dy: %8.5f dz: %8.5f\n",track->GetNHits(),dx,dy,dz);
+             //cerr<<"---------------------------"<<endl;
+           }
+       }  
+    }
 }
 
-void AliL3Merger::PrintTrack(AliL3Track *track){
+void AliL3Merger::PrintTrack(AliL3Track *track)
+{
   fprintf(stderr,"npt: %3d pt: %.2f psi: %.2f tgl: %5.2f q: %2d\n",
-    track->GetNHits(),track->GetPt(),track->GetPsi(),
-    track->GetTgl(),track->GetCharge());
+         track->GetNHits(),track->GetPt(),track->GetPsi(),
+         track->GetTgl(),track->GetCharge());
   fprintf(stderr,
-    "x1: %6.2f y1: %6.2f z1: %6.2f xl: %6.2f yl: %6.2f zl: %6.2f\n",
-    track->GetFirstPointX(),track->GetFirstPointY(),track->GetFirstPointZ(),
-    track->GetLastPointX(),track->GetLastPointY(),track->GetLastPointZ());
-  if(track->IsPoint()){
-    fprintf(stderr,
-      "R: %.2f Xc: %.2f Yc: %.2f Xp: %.2f Yp: %.2f Zp: %.2f Psip: %.2f\n",
-      track->GetRadius(),track->GetCenterX(),track->GetCenterY(),
-      track->GetPointX(),track->GetPointY(),track->GetPointZ(),
-      track->GetPointPsi());
-  }
+         "x1: %6.2f y1: %6.2f z1: %6.2f xl: %6.2f yl: %6.2f zl: %6.2f\n",
+         track->GetFirstPointX(),track->GetFirstPointY(),track->GetFirstPointZ(),
+         track->GetLastPointX(),track->GetLastPointY(),track->GetLastPointZ());
+  if(track->IsPoint())
+    {
+      fprintf(stderr,
+             "R: %.2f Xc: %.2f Yc: %.2f Xp: %.2f Yp: %.2f Zp: %.2f Psip: %.2f\n",
+             track->GetRadius(),track->GetCenterX(),track->GetCenterY(),
+             track->GetPointX(),track->GetPointY(),track->GetPointZ(),
+             track->GetPointPsi());
+    }
 }
index 690d51e3d2245728d3240eae0885646e9bb07e17..208d5ba2c92aecc8152dde72bcdf6a3115d56847 100644 (file)
@@ -32,10 +32,10 @@ class AliL3Merger {
   AliL3Vertex *fVertex;//!
   Bool_t f2Global;
   Bool_t Is2Global(Bool_t is){f2Global=is;return f2Global;}
-
+  void InitMerger(Int_t ntrackarrays,Char_t *tracktype="AliL3Track");
+  
  public:
   AliL3Merger();
-  AliL3Merger(Int_t ntrackarrays,Char_t *tracktype="AliL3Track");
   virtual ~AliL3Merger();
 
   Int_t GetNIn(){return fNIn;}
index 339e168e44782382696901da8d2348422e62a5a1..c58c6b547cf1f1f937fbec7062d0408a2a67d352 100644 (file)
@@ -34,14 +34,17 @@ AliL3TrackMerger::AliL3TrackMerger(){
 }
 
 
-AliL3TrackMerger::AliL3TrackMerger(Int_t nsubsectors):AliL3Merger(nsubsectors){
+AliL3TrackMerger::AliL3TrackMerger(Int_t nsubsectors) : AliL3Merger()
+{
   //Constructor.
+  InitMerger(nsubsectors);
   fNSubSector = nsubsectors;
   Is2Global(kFALSE);
   fSlow = kFALSE;
   SetParameter();
   fRowMin = new Int_t[nsubsectors];
   fRowMax = new Int_t[nsubsectors];
+  
 }
 
 AliL3TrackMerger::~AliL3TrackMerger(){
index 9a5212762519c6cc9ed05032afb9852a1118282c..95675e7422e48b6ebad772323bc85ded8ed1dc7f 100644 (file)
@@ -128,7 +128,6 @@ void AliLevel3::Init(Char_t *path,Bool_t binary,Int_t npatches)
   fNoCF=kFALSE;
   fUseBinary = binary;
   SetPath(path);
-  fGlobalMerger = 0;
   
   fDoRoi = kFALSE;
   fDoNonVertex = kFALSE;
@@ -179,6 +178,8 @@ void AliLevel3::Init(Char_t *path,Bool_t binary,Int_t npatches)
   fTracker = new AliL3ConfMapper();
   fTrackMerger = new AliL3TrackMerger(fNPatch);
   fInterMerger = new AliL3InterMerger();
+  fGlobalMerger = new AliL3GlobalMerger();
+  SetMergerParameters();//Set default merger parameters
 #ifdef use_aliroot
   fFileHandler = new AliL3FileHandler();
   fFileHandler->SetAliInput(fInputFile);
@@ -209,6 +210,7 @@ AliLevel3::~AliLevel3(){
   if(fTrackMerger) delete fTrackMerger;
   if(fInterMerger) delete fInterMerger;
   if(fFileHandler) delete fFileHandler;
+  if(fGlobalMerger) delete fGlobalMerger;
 }
 
 void AliLevel3::SetClusterFinderParam(Float_t fXYError, Float_t fZError, Bool_t deconv)
@@ -237,17 +239,21 @@ void AliLevel3::SetTrackerParam(Int_t phi_segments, Int_t eta_segments,
     fTracker->MainVertexSettings(trackletlength,tracklength,rowscopetracklet,rowscopetrack,maxphi,maxeta);
   else
     fTracker->NonVertexSettings(trackletlength,tracklength,rowscopetracklet,rowscopetrack);
-  
-  fTracker->SetParamDone(true);
   fTracker->InitVolumes();
 }
 
+void AliLevel3::SetMergerParameters(Double_t maxy,Double_t maxz,Double_t maxkappa,Double_t maxpsi,Double_t maxtgl)
+{
+  fGlobalMerger->SetParameter(maxy,maxz,maxkappa,maxpsi,maxtgl);
+}
+
 void AliLevel3::ProcessEvent(Int_t first,Int_t last,Int_t event){
   //Do tracking on all slices in region [first,last]
   //Slices numbering in TPC goes from 0-35, which means that one slice
   //corresponds to inner+outer sector.E.g. slice 2 corresponds to
   //inner=2 + outer=38.
-  fGlobalMerger= new AliL3GlobalMerger(first,last);  
+
+  fGlobalMerger->Setup(first,last);
   fEvent=event;
   for(Int_t i=first; i<=last; i++){
     ProcessSlice(i);
@@ -260,15 +266,13 @@ void AliLevel3::ProcessEvent(Int_t first,Int_t last,Int_t event){
   }
   fBenchmark->Start("Global track merger");
   //fGlobalMerger->AddAllTracks();
-  fGlobalMerger->SetParameter(1.2,1.6,0.003,0.02,0.03);
   fGlobalMerger->Merge();
-  //fGlobalMerger->SlowMerge();
+  //fGlobalMerger->SlowMerge(fWriteOutPath);
   fBenchmark->Stop("Global track merger");
   
   FitGlobalTracks();
   
   if(fWriteOut) WriteResults(); 
-  delete fGlobalMerger; fGlobalMerger = 0;
   fFileHandler->FreeDigitsTree();
 }
 
@@ -581,7 +585,7 @@ void AliLevel3::FitGlobalTracks()
       AliL3Track *tr = tracks->GetCheckedTrack(i);
       if(!tr) continue;
       fitter->FitHelix(tr);
-      tr->UpdateToFirstPoint();
+      fitter->UpdateTrack(tr);
     }
   fBenchmark->Stop("Global track fitter");
   delete fitter;
index 96cd189333e30d607213bf4013609f6a38d75984..70f4cf849198196a02c42a6b50eae03681b58856 100644 (file)
@@ -100,8 +100,10 @@ class AliLevel3 : public TObject {
   AliLevel3(TFile *in);
 #endif
   virtual ~AliLevel3();
-  
+
   void Init(Char_t *path,Bool_t binary=kTRUE,Int_t npatches=6);
+  void SetMergerParameters(Double_t maxy=1.2,Double_t maxz=1.6,Double_t maxkappa=0.003,
+                          Double_t maxpsi=0.02,Double_t maxtgl=0.03);
   void SetTrackerParam(Int_t phi_segments=50,Int_t eta_segments=100,
                       Int_t trackletlength=3,Int_t tracklength=5,
                       Int_t rowscopetracklet=2,Int_t rowscopetrack=3,