Merged Bergen, mergen Cvetan TransformerRow and
authorloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 12 May 2004 11:51:27 +0000 (11:51 +0000)
committerloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 12 May 2004 11:51:27 +0000 (11:51 +0000)
merged with Changes for the PDC04, second
part.

89 files changed:
HLT/Makefile.rules
HLT/comp/AliL3CompLinkDef.h
HLT/comp/AliL3Compress.cxx
HLT/comp/AliL3Compress.h
HLT/comp/AliL3CompressAC.cxx [new file with mode: 0644]
HLT/comp/AliL3CompressAC.h [new file with mode: 0644]
HLT/comp/AliL3DataCompressor.cxx
HLT/comp/AliL3DataCompressor.h
HLT/comp/AliL3DataCompressorHelper.cxx
HLT/comp/AliL3DataCompressorHelper.h
HLT/comp/AliL3FitUtilities.c
HLT/comp/AliL3FitUtilities.h
HLT/comp/AliL3Modeller.cxx
HLT/comp/AliL3Models.h
HLT/comp/Makefile
HLT/comp/bitio.h
HLT/comp/errhand.h
HLT/doc/changelog.comp
HLT/doc/changelog.exa
HLT/doc/changelog.hough
HLT/doc/changelog.kalman
HLT/doc/changelog.misc
HLT/doc/changelog.programs
HLT/doc/changelog.src
HLT/doc/changelog.top
HLT/doc/changelog.trigger
HLT/exa/SetTrackingParameters_1000bf02.C
HLT/exa/SetTrackingParameters_1000bf04.C
HLT/exa/SetTrackingParameters_2000bf02.C
HLT/exa/SetTrackingParameters_2000bf04.C
HLT/exa/SetTrackingParameters_4000bf02.C
HLT/exa/SetTrackingParameters_4000bf04.C
HLT/exa/SetTrackingParameters_8000bf02.C
HLT/exa/SetTrackingParameters_8000bf04.C
HLT/exa/runtracker.C
HLT/hough/AliL3Histogram.cxx
HLT/hough/AliL3Histogram.h
HLT/hough/AliL3Hough.cxx
HLT/hough/AliL3Hough.h
HLT/hough/AliL3HoughBaseTransformer.h
HLT/hough/AliL3HoughMaxFinder.cxx
HLT/hough/AliL3HoughMaxFinder.h
HLT/hough/AliL3HoughTrack.cxx
HLT/hough/AliL3HoughTrack.h
HLT/hough/AliL3HoughTransformerRow.cxx
HLT/hough/AliL3HoughTransformerRow.h
HLT/kalman/AliL3Kalman.cxx
HLT/kalman/AliL3Kalman.h
HLT/kalman/AliL3KalmanTrack.cxx
HLT/kalman/AliL3KalmanTrack.h
HLT/misc/AliL3DDLDataFileHandler.cxx
HLT/misc/AliL3DDLRawReaderFile.cxx
HLT/programs/Makefile
HLT/programs/convcosmicsfile.cxx
HLT/programs/tpcbeamtestdisplay.cxx [new file with mode: 0644]
HLT/programs/tpcbeamtesttracker.cxx [new file with mode: 0644]
HLT/src/AliHLTReconstructor.cxx
HLT/src/AliHLTReconstructor.h
HLT/src/AliL3DigitData.h
HLT/src/AliL3Evaluate.cxx
HLT/src/AliL3Evaluate.h
HLT/src/AliL3FileHandler.cxx
HLT/src/AliL3FileHandler.h
HLT/src/AliL3MemHandler.cxx
HLT/src/AliL3MemHandler.h
HLT/src/AliL3Merger.cxx
HLT/src/AliL3RawDataFileHandler.cxx
HLT/src/AliL3RawDataFileHandler.h
HLT/src/AliL3SrcLinkDef.h
HLT/src/AliL3StandardIncludes.h
HLT/src/AliL3Track.cxx
HLT/src/AliL3Track.h
HLT/src/AliL3TrackArray.cxx
HLT/src/AliL3TrackSegmentData.h
HLT/src/AliL3Transform.cxx
HLT/src/AliL3VertexFinder.h
HLT/src/AliLevel3.cxx
HLT/src/AliLevel3.h
HLT/src/Makefile
HLT/trigger/AliBarrelRec_TPCparam.C [deleted file]
HLT/trigger/AliD0Trigger.C [deleted file]
HLT/trigger/AliD0Trigger.cxx
HLT/trigger/AliD0Trigger.h
HLT/trigger/AliD0vtxFinderBkg_pp_VTX.C [deleted file]
HLT/trigger/AliD0vtxFinderSgn_pp_VTX.C [deleted file]
HLT/trigger/AliITSFindClustersV2.C [deleted file]
HLT/trigger/AliL3TriggerLinkDef.h
HLT/trigger/Makefile
HLT/trigger/RunD0offline.C

index d201eef..de6e16b 100644 (file)
@@ -39,6 +39,9 @@ else
 ALIROOTSTR = "Unknown"
 endif
 DEFSTR += -DALIROOTVERSION=\"$(ALIROOTSTR)\"
+ifeq ($(ALIROOTST),HEAD)
+DEFSTR += -Duse_reconstruction
+endif
 endif
 
 ifeq ($(DOMC),1)
@@ -46,7 +49,7 @@ DEFSTR += -Ddo_mc
 endif
 
 ifeq ($(USEROWHOUGH),1)
-DEFSTR += -DROWHOUGH
+DEFSTR += -DROWHOUGHPARAMS
 endif
 
 ifneq ($(NOLOGGING),1)
index f812c49..629073c 100644 (file)
@@ -11,6 +11,7 @@
 #pragma link C++ class AliL3ModelTrack; 
 #endif
 #pragma link C++ class AliL3Compress; 
+#pragma link C++ class AliL3CompressAC; 
 #pragma link C++ class AliL3ClusterFitter; 
 #pragma link C++ class AliL3DataCompressor; 
 #pragma link C++ class AliL3ClusterModel; 
index f6d29d2..023140a 100644 (file)
@@ -653,8 +653,8 @@ void AliL3Compress::PrintCompRatio(ofstream *outfile)
     }
   
   Float_t compratio = (Float_t)(compress_size + remain_size)/(Float_t)digit_size;
-  Float_t entropy[2];
-  Int_t track_size = GetEntropy(entropy[0],entropy[1])*sizeof(AliL3TrackModel);
+  Float_t entropy[3];
+  Int_t track_size = GetEntropy(entropy[0],entropy[1],entropy[2])*sizeof(AliL3TrackModel);
   if(outfile)
     {
       ofstream &out = *outfile;
@@ -673,7 +673,7 @@ void AliL3Compress::PrintCompRatio(ofstream *outfile)
   cout<<"Entropy of residuals : "<<entropy[0]<<" "<<entropy[1]<<endl;
 }
 
-Int_t AliL3Compress::GetEntropy(Float_t &pad_entropy,Float_t &time_entropy)
+Int_t AliL3Compress::GetEntropy(Float_t &pad_entropy,Float_t &time_entropy,Float_t &charge_entropy)
 {
   //Calculate the entropy of the quantized residuals in both directions
   
@@ -682,8 +682,10 @@ Int_t AliL3Compress::GetEntropy(Float_t &pad_entropy,Float_t &time_entropy)
   const Int_t nmax=100000;
   Float_t pads[nmax];
   Float_t times[nmax];
+  Float_t charge[nmax];
   memset(&pads[0],0,nmax*sizeof(Float_t));
   memset(&times[0],0,nmax*sizeof(Float_t));
+  memset(&charge[0],0,nmax*sizeof(Float_t));
   Float_t counter=0;
 
   for(Int_t i=0; i<fTracks->GetNTracks(); i++)
@@ -695,26 +697,31 @@ Int_t AliL3Compress::GetEntropy(Float_t &pad_entropy,Float_t &time_entropy)
          if(!track->IsPresent(padrow)) continue;
          Int_t dpad = abs((Int_t)rint(track->GetClusterModel(padrow)->fDPad));
          Int_t dtime = abs((Int_t)rint(track->GetClusterModel(padrow)->fDTime));
-         if(dpad >= nmax || dtime >= nmax)
+         Int_t dcharge = (Int_t)track->GetClusterModel(padrow)->fDCharge;
+         if(dpad >= nmax || dtime >= nmax || dcharge >= nmax)
            {
-             cerr<<"AliL3Compress::GetEntropy : Quantization out of range: "<<dpad<<" "<<dtime<<endl;
+             cerr<<"AliL3Compress::GetEntropy : Quantization out of range: "<<dpad<<" "<<dtime<<" "<<dcharge<<endl;
              break;
            }
          pads[dpad]++;
          times[dtime]++;
+         charge[dcharge]++;
          counter++;
        }
     }
-  pad_entropy=time_entropy=0;
+  pad_entropy=time_entropy=charge_entropy=0;
   for(Int_t i=0; i<nmax; i++)
     {
       if(pads[i]>0)
        pad_entropy += (pads[i]/counter)*(log(pads[i]/counter)/log(2.0));
       if(times[i]>0)
        time_entropy += (times[i]/counter)*(log(times[i]/counter)/log(2.0));
+      if(charge[i]>0)
+       charge_entropy += (charge[i]/counter)*(log(charge[i]/counter)/log(2.0));
     }
   
   pad_entropy*=-1;
   time_entropy*=-1;
+  charge_entropy*=-1;
   return fTracks->GetNTracks();
 }
index b12442b..92dbee9 100644 (file)
@@ -9,14 +9,16 @@
 class AliL3Compress {
   
  private:
+  
+ protected:
   AliL3TrackArray *fTracks; //!
-
   Int_t fSlice;
   Int_t fPatch;
   Char_t fPath[100];
   Bool_t fWriteShape;
   Int_t fEvent;
 
+  
  public:
   AliL3Compress();
   AliL3Compress(Int_t slice,Int_t patch,Char_t *path="./",Bool_t writeshape=kFALSE,Int_t event=-1);
@@ -24,12 +26,12 @@ class AliL3Compress {
   
   Bool_t WriteFile(AliL3TrackArray *tracks,Char_t *filename=0);
   Bool_t ReadFile(Char_t which,Char_t *filename=0);
-  Bool_t CompressFile();
-  Bool_t ExpandFile();
+  virtual Bool_t CompressFile();
+  virtual Bool_t ExpandFile();
   void CompressRemaining(AliL3SpacePointData *points[36][6],UInt_t npoints[36][6]);
   void ExpandRemaining(TempCluster **clusters,Int_t *ncl,Int_t maxclusters);
-  void PrintCompRatio(ofstream *outfile=0);
-  Int_t GetEntropy(Float_t &pad_entropy,Float_t &time_entropy);
+  virtual void PrintCompRatio(STDOF *outfile=0);
+  Int_t GetEntropy(Float_t &pad_entropy,Float_t &time_entropy,Float_t &charge_entropy);
   
   AliL3TrackArray *GetTracks() {return fTracks;}
   
diff --git a/HLT/comp/AliL3CompressAC.cxx b/HLT/comp/AliL3CompressAC.cxx
new file mode 100644 (file)
index 0000000..aec14ba
--- /dev/null
@@ -0,0 +1,721 @@
+// @(#) $Id$
+
+// Author: Anders Vestbo <mailto:vestbo$fi.uib.no>
+//*-- Copyright &copy ALICE HLT Group
+
+#if __GNUC__ == 3
+using namespace std;
+#endif
+
+#include "AliL3StandardIncludes.h"
+#include "AliL3TrackArray.h"
+#include "AliL3ModelTrack.h"
+#include "AliL3Transform.h"
+#include "AliL3MemHandler.h"
+#include "AliL3Compress.h"
+#include "AliL3DataCompressorHelper.h"
+#include "AliL3CompressAC.h"
+
+
+//_____________________________________________________________
+//
+//  AliL3CompressAC
+//
+// Compression class which performs Arithmetic Coding of the quantized residuals.
+// The implemented algorithm is inspired by the examples in The Data Compression Book 
+// by Nelson & Gailly.
+
+ClassImp(AliL3CompressAC)
+
+AliL3CompressAC::AliL3CompressAC()
+{
+  fCount=0;
+  fTotals=0;
+  fMax=0;
+  fRange=0;
+  fLow=0;
+  fHigh=0;
+  fUnderflowBits=0;
+  fCode=0;
+}
+
+AliL3CompressAC::AliL3CompressAC(Int_t slice,Int_t patch,Char_t *path,Bool_t writeshape,Int_t event) :
+  AliL3Compress(slice,patch,path,writeshape,event)
+{
+  fCount=0;
+  fTotals=0;
+  fMax=0;
+  fRange=0;
+  fLow=0;
+  fHigh=0;
+  fUnderflowBits=0;
+  fCode=0;
+}
+
+AliL3CompressAC::~AliL3CompressAC()
+{
+  ClearArrays();
+}
+
+void AliL3CompressAC::ClearArrays()
+{
+  fMax=0;
+  if(fCount)
+    delete [] fCount;
+  if(fTotals)
+    delete [] fTotals;
+}
+
+void AliL3CompressAC::BuildModel(BIT_FILE *output)
+{
+  //Build the model from the input data, i.e. probability distributions of the quantized residuals.
+  
+  ClearArrays();
+  ReadFile('m');
+  
+  UInt_t nmax=10000,qres;
+  UInt_t temp[nmax];
+  memset(&temp[0],0,nmax*sizeof(UInt_t));
+
+  AliL3TrackArray *tracks = GetTracks();
+  for(Int_t t=0; t<tracks->GetNTracks(); t++)
+    {
+      AliL3ModelTrack *track = (AliL3ModelTrack*)tracks->GetCheckedTrack(t);
+      if(!track) continue;
+      for(Int_t padrow=0; padrow<AliL3Transform::GetNRows(); padrow++)
+       {
+         if(!track->IsPresent(padrow)) continue;
+         qres = abs((Int_t)rint(track->GetClusterModel(padrow)->fDPad));
+         if(qres >= nmax)
+           {
+             cerr<<"AliL3CompressAC::BuildModel() : Residual values seems way too big!"<<endl;
+             continue;
+           }
+         if(qres > fMax)
+           fMax=qres;
+         temp[qres]++;
+         qres = abs((Int_t)rint(track->GetClusterModel(padrow)->fDTime));
+         if(qres > fMax)
+           fMax = qres;
+         temp[qres]++;
+
+       }
+    }
+  
+  fCount = new UChar_t[fMax+1];
+  
+  //Find the highest counts in order to do scaling:
+  UInt_t i,max_count=0;
+  for(i=0; i<=fMax; i++)
+    {
+      if(temp[i] > max_count)
+       max_count=temp[i];
+    }
+
+  //Perform the scaling
+  UInt_t scale,total=1;
+  scale = max_count / 256 + 1;
+  for(i=0; i<=fMax; i++)
+    {
+      fCount[i] = (UChar_t)(temp[i]/scale);
+      if(fCount[i]==0 && temp[i]!=0)
+       fCount[i] = 1;
+      total += (UInt_t)fCount[i];
+    }
+  if(total > (32767 - 256))
+    scale=4;
+  else if(total > 16383)
+    scale=2;
+  else
+    scale=1;
+  if(scale > 1)
+    for(i=0; i<=fMax; i++)
+      fCount[i] /= scale;
+
+  cout<<"Writing "<<sizeof(UChar_t)*fMax+1<<" bytes with model information to compressed file"<<endl;
+  fwrite(&fMax,sizeof(UShort_t),1,output->file);
+  fwrite(fCount,sizeof(UChar_t),fMax+1,output->file);
+  
+  FillTotals();
+}
+
+void AliL3CompressAC::RebuildModel(BIT_FILE *input)
+{
+  //Rebuild the model from the counts written to the beginning of the compressed file.
+  
+  ClearArrays();
+  fread(&fMax,sizeof(UShort_t),1,input->file);
+  fCount = new UChar_t[fMax+1];
+  fread(fCount,sizeof(UChar_t),fMax+1,input->file);
+  FillTotals();
+}
+
+void AliL3CompressAC::FillTotals()
+{
+  //Fill the array of totals, which is actually the model being used during encoding/decoding.
+  if(fMax == 0)
+    cerr<<"AliL3CompressAC::FillTotals : max value is zero!"<<endl;
+
+  fTotals = new UInt_t[fMax+3];//up to max, and one reserved for endofstream symbol
+  
+  UInt_t i;
+  fTotals[0]=0;
+  for(i=0; i<=fMax; i++)
+    {
+      fTotals[i+1] = fTotals[i] + fCount[i];
+    }
+  fTotals[fMax+2] = fTotals[fMax+1]+1;//Used for the scale
+}
+
+void AliL3CompressAC::PrintTotals()
+{
+  cout<<"Totals:"<<endl;
+  for(UInt_t i=0; i<=fMax; i++)
+    {
+      cout<<"Totals "<<i<<" "<<fTotals[i]<<" count "<<(int)fCount[i]<<endl;
+    }
+}
+
+void AliL3CompressAC::InitEncoder()
+{
+  fLow = 0;
+  fHigh = 0xffff;
+  fUnderflowBits=0;
+}
+
+void AliL3CompressAC::InitDecoder(BIT_FILE *input)
+{
+  fCode=0;
+  for(Int_t i=0; i<16; i++)
+    {
+      fCode <<= 1;
+      fCode += InputBit(input);
+    }
+  fLow = 0;
+  fHigh = 0xffff;
+}
+
+void AliL3CompressAC::ConvertIntToSymbol(Int_t value)
+{
+  UInt_t range = fHigh - fLow + 1;
+  fHigh = fLow + (UShort_t)((range*fTotals[value+1])/fTotals[fMax+2] - 1);
+  fLow = fLow + (UShort_t)((range*fTotals[value])/fTotals[fMax+2]);
+}
+
+UInt_t AliL3CompressAC::ConvertSymbolToInt()
+{
+  UInt_t range = (UInt_t)(fHigh-fLow) + 1;
+  UShort_t count = (UShort_t)((((UInt_t)(fCode-fLow)+1)*fTotals[fMax+2] - 1)/range);
+  UInt_t j=fMax+1;
+  while(count < fTotals[j])
+    j--;
+  
+  return j;
+}
+
+void AliL3CompressAC::EncodeSymbol(BIT_FILE *output)
+{
+  while(1)
+    {
+      if( (fHigh & 0x8000) == (fLow & 0x8000) )
+       {
+         OutputBit(output,fHigh & 0x8000);
+         while(fUnderflowBits > 0)
+           {
+             OutputBit(output,~fHigh & 0x8000);
+             fUnderflowBits--;
+           }
+       }
+      else if( (fLow & 0x4000) && !(fHigh & 0x4000) )
+       {
+         fUnderflowBits++;
+         fLow &= 0x3fff;
+         fHigh |= 0x4000;
+       }
+      else
+       return;
+      fLow <<= 1;
+      fHigh <<= 1;
+      fHigh |= 1;
+    }
+}
+
+void AliL3CompressAC::RemoveSymbolFromStream(BIT_FILE *input,Int_t j)
+{
+  UInt_t range = (UInt_t)(fHigh-fLow)+1;
+  fHigh = fLow + (UShort_t)((range*fTotals[j+1])/fTotals[fMax+2]-1);
+  fLow = fLow + (UShort_t)((range*fTotals[j])/fTotals[fMax+2]);
+  while(1)
+    {
+      if( (fHigh & 0x8000)==(fLow & 0x8000) )
+       {}
+      else if((fLow & 0x4000) == 0x4000 && (fHigh & 0x4000)==0)
+       {
+         fCode ^= 0x4000;
+         fLow &= 0x3fff;
+         fHigh |= 0x4000;
+       }
+      else
+       return;
+      fLow <<= 1;
+      fHigh <<= 1;
+      fHigh |= 1;
+      fCode <<= 1;
+      fCode += InputBit(input);
+    }
+}
+
+void AliL3CompressAC::FlushEncoder(BIT_FILE *output)
+{
+  //Flush the encoder:
+  OutputBit(output,fLow & 0x4000);
+  fUnderflowBits++;
+  while(fUnderflowBits-- > 0)
+    OutputBit(output,~fLow & 0x4000);
+  
+}
+
+
+Bool_t AliL3CompressAC::CompressFile()
+{
+  Char_t fname[100];
+  if(fEvent<0)
+    sprintf(fname,"%s/comp/tracks_ac_%d_%d.raw",fPath,fSlice,fPatch);
+  else
+    sprintf(fname,"%s/comp/tracks_ac_%d_%d_%d.raw",fPath,fEvent,fSlice,fPatch);
+  BIT_FILE *output = OpenOutputBitFile(fname);
+  
+  if(fEvent<0)
+    sprintf(fname,"%s/comp/tracks_m_%d_%d.raw",fPath,fSlice,fPatch);
+  else
+    sprintf(fname,"%s/comp/tracks_m_%d_%d_%d.raw",fPath,fEvent,fSlice,fPatch);
+  
+  FILE *input = fopen(fname,"r");
+  if(!input)
+    {
+      cerr<<"AliL3CompressAC::CompressFileAC() : Error opening file: "<<fname<<endl;
+      return kFALSE;
+    }
+  
+  BuildModel(output);
+
+  AliL3TrackModel track;
+  Int_t temp,power,i,j;
+  
+  fseek(input,0,SEEK_END);
+  UInt_t size = ftell(input);
+  rewind(input);
+  Int_t trackcount = size/(sizeof(AliL3TrackModel) + sizeof(AliL3ClusterModel)*AliL3Transform::GetNRows(fPatch));
+  
+  //Write the number of tracks in the beginning of stream.
+  fwrite(&trackcount,sizeof(Int_t),1,output->file);
+  
+  AliL3ClusterModel **clusters = new AliL3ClusterModel*[trackcount];
+  Int_t *clustercount = new Int_t[trackcount];
+  i=0;
+  
+  //Read all the tracks from input file, and write them all to the outputfile.
+  //Store the clusters in memory for later encoding and storing.
+  while(!feof(input))
+    {
+      if(fread(&track,sizeof(AliL3TrackModel),1,input)!=1) break;
+      fwrite(&track,sizeof(AliL3TrackModel),1,output->file);
+      
+      clusters[i] = new AliL3ClusterModel[AliL3Transform::GetNRows()];
+      clustercount[i]=0;
+      
+      //Read in the clusters:
+      fread(clusters[i],sizeof(AliL3ClusterModel),AliL3Transform::GetNRows(fPatch),input);
+      i++;
+    }
+  if(i != trackcount)
+    {
+      cerr<<"AliL3CompressAC::CompressFile : Mismatching file size and trackcount "<<i<<" "<<trackcount<<endl;
+      exit(5);
+    }
+  fclose(input);
+  
+  //Write all the fixed size variables of the clusters:
+  for(i=0; i<trackcount; i++)
+    {
+      Int_t origslice=-1,slice;
+      for(j=0; j<AliL3Transform::GetNRows(fPatch); j++)
+       {
+         temp = (Int_t)clusters[i][j].fPresent;
+         OutputBit(output,temp);
+         if(!temp) continue;
+         
+         if(clusters[i][j].fSlice<0 || clusters[i][j].fSlice>35)
+           {
+             cerr<<"AliL3DataCompress::CompressFile : Fucked up slice number :"<<clusters[i][j].fSlice<<endl;
+             exit(5);
+           }
+         
+         //Write slice number of first point
+         if(clustercount[i]==0)
+           {
+             origslice = clusters[i][j].fSlice;
+             OutputBits(output,origslice,6); //Need 6 bits to encode slice number
+           }
+         else
+           {
+             slice = clusters[i][j].fSlice;
+             if(slice == origslice)
+               {
+                 OutputBit(output,0);  //No change of slice
+               }
+             else
+               {
+                 OutputBit(output,1);
+                 if(abs(slice - origslice)==1)
+                   {
+                     if(slice > origslice)
+                       OutputBit(output,1);
+                     else
+                       OutputBit(output,0);
+                   }
+                 else
+                   {
+                     if( (slice == 0 && origslice == 17) || (slice == 18 && origslice == 35) )
+                       OutputBit(output,1);
+                     else if( (slice == 17 && origslice == 0) || (slice == 35 && origslice == 18) )
+                       OutputBit(output,0);
+                   }
+                 origslice=slice;
+               }
+           }
+         
+         //Write charge information:
+         temp = (Int_t)clusters[i][j].fDCharge;
+         power = 1<<(AliL3DataCompressorHelper::GetNChargeBits());
+         if(abs(temp)>=power)
+           {
+             temp=power - 1;
+           }
+         OutputBits(output,abs(temp),(AliL3DataCompressorHelper::GetNChargeBits()));
+
+         //Write sign information of the residuals:
+         temp = (Int_t)rint(clusters[i][j].fDTime);
+         if(temp<0)
+           OutputBit(output,0);
+         else
+           OutputBit(output,1);
+         temp = (Int_t)rint(clusters[i][j].fDPad);
+         if(temp<0)
+           OutputBit(output,0);
+         else
+           OutputBit(output,1);
+
+         //Write shape information if requested:
+         if(fWriteShape)
+           {
+             temp = (Int_t)rint(clusters[i][j].fDSigmaY);
+             if(temp<0)
+               OutputBit(output,0);
+             else
+               OutputBit(output,1);
+             power = 1<<(AliL3DataCompressorHelper::GetNShapeBits()-1);
+             if(abs(temp) >= power)
+               {
+                 temp = power - 1;
+               }
+             OutputBits(output,abs(temp),(AliL3DataCompressorHelper::GetNShapeBits()-1));
+             
+             temp = (Int_t)rint(clusters[i][j].fDSigmaZ);
+             if(temp<0)
+               OutputBit(output,0);
+             else
+               OutputBit(output,1);
+             power = 1<<(AliL3DataCompressorHelper::GetNShapeBits()-1);
+             if(abs(temp) >= power)
+               {
+                 temp=power - 1;
+               }
+             OutputBits(output,abs(temp),(AliL3DataCompressorHelper::GetNShapeBits()-1));
+           }
+         clustercount[i]++;
+       }
+    }
+
+  InitEncoder();
+  
+  //Start the arithmetic coding of the residuals.
+  //All the residuals (both pad and time) are coded in one go,
+  //i.e. for all tracks and clusters in the input file.
+  for(i=0; i<trackcount; i++)
+    {
+      Int_t counter=0;
+      
+      for(j=0; j<AliL3Transform::GetNRows(fPatch); j++)
+       {
+         if(!clusters[i][j].fPresent) continue;
+         temp = abs((Int_t)rint(clusters[i][j].fDTime));
+         ConvertIntToSymbol(temp);
+         EncodeSymbol(output);
+
+         temp = abs((Int_t)rint(clusters[i][j].fDPad));
+         ConvertIntToSymbol(temp);
+         EncodeSymbol(output);
+         counter++;
+       }
+      if(counter != clustercount[i])
+       {
+         cerr<<"AliL3CompressAC::CompressFile : Mismatching clustercount "<<counter<<" "<<clustercount[i]<<endl;
+         exit(5);
+       }
+
+    }
+  
+  ConvertIntToSymbol(fMax+1);//End of stream symbol
+  EncodeSymbol(output);
+  FlushEncoder(output);
+  OutputBits(output,0,16);
+
+  for(i=0; i<trackcount; i++)
+    delete [] clusters[i];
+  delete [] clusters;
+  delete [] clustercount;
+  
+
+  CloseOutputBitFile(output);
+  
+  return kTRUE;
+}
+
+Bool_t AliL3CompressAC::ExpandFile()
+{
+  Char_t fname[100];
+  if(fEvent<0)
+    sprintf(fname,"%s/comp/tracks_ac_%d_%d.raw",fPath,fSlice,fPatch);
+  else
+    sprintf(fname,"%s/comp/tracks_ac_%d_%d_%d.raw",fPath,fEvent,fSlice,fPatch);
+  BIT_FILE *input = OpenInputBitFile(fname);
+  
+  if(fEvent<0)
+    sprintf(fname,"%s/comp/tracks_u_%d_%d.raw",fPath,fSlice,fPatch);
+  else
+    sprintf(fname,"%s/comp/tracks_u_%d_%d_%d.raw",fPath,fEvent,fSlice,fPatch);
+  FILE *output = fopen(fname,"w");
+  if(!output)
+    {
+      cerr<<"AliL3Compress::ExpandFile() : Error opening file: "<<fname<<endl;
+      return kFALSE;
+    }
+  
+  RebuildModel(input);
+
+  int trackcount,i,j;
+  fread(&trackcount,sizeof(Int_t),1,input->file);
+
+  AliL3TrackModel *trackmodels = new AliL3TrackModel[trackcount];
+  AliL3ClusterModel **clusters = new AliL3ClusterModel*[trackcount];
+  Int_t *clustercount = new Int_t[trackcount];
+
+  fread(trackmodels,sizeof(AliL3TrackModel),trackcount,input->file);
+  
+  for(i=0; i<trackcount; i++)
+    {
+      clusters[i] = new AliL3ClusterModel[AliL3Transform::GetNRows(fPatch)];
+      clustercount[i]=0;
+
+      //Read the fixed size variables:
+      Int_t origslice=-1;
+      Int_t temp,sign;
+      for(j=0; j<AliL3Transform::GetNRows(fPatch); j++)
+       {
+         //Read empty flag:
+         temp = InputBit(input);
+         if(!temp) 
+           {
+             clusters[i][j].fPresent=kFALSE;
+             continue;
+           }
+         clusters[i][j].fPresent=kTRUE;
+         
+         //Read slice information
+         if(clustercount[i]==0)
+           {
+             temp = InputBits(input,6);
+             clusters[i][j].fSlice = temp;
+             origslice = temp;
+           }
+         else
+           {
+             temp = InputBit(input);
+             if(!temp)//no change
+               clusters[i][j].fSlice = origslice;
+             else
+               {
+                 temp = InputBit(input);
+                 if(temp)
+                   {
+                     if(origslice == 17)
+                       origslice = 0;
+                     else if(origslice == 35)
+                       origslice = 18;
+                     else
+                       origslice++;
+                   }
+                 else
+                   {
+                     if(origslice == 0)
+                       origslice = 17;
+                     else if(origslice == 18)
+                       origslice = 35;
+                     else
+                       origslice--;
+                   }
+                 if(origslice < 0 || origslice > 35)
+                   {
+                     cerr<<"AliL3CompressAC::ExpandFile : Bad slice number "<<temp<<endl;
+                     exit(5);
+                   }
+                 clusters[i][j].fSlice = origslice;
+               }
+           }
+         
+         //Read charge information:
+         temp=InputBits(input,(AliL3DataCompressorHelper::GetNChargeBits()));
+         clusters[i][j].fDCharge = temp;
+         
+         //Read sign information of the residuals:
+         sign=InputBit(input);
+         if(!sign)
+           clusters[i][j].fDTime = -1;
+         else
+           clusters[i][j].fDTime = 1;
+         sign=InputBit(input);
+         if(!sign)
+           clusters[i][j].fDPad = -1;
+         else
+           clusters[i][j].fDPad = 1;
+         
+         //Read shape information if requested
+         if(fWriteShape)
+           {
+             sign = InputBit(input);
+             temp = InputBits(input,(AliL3DataCompressorHelper::GetNShapeBits()-1));
+             if(!sign)
+               temp*=-1;
+             clusters[i][j].fDSigmaY = temp;
+             
+             sign = InputBit(input);
+             temp = InputBits(input,(AliL3DataCompressorHelper::GetNShapeBits()-1));
+             if(!sign)
+               temp*=-1;
+             clusters[i][j].fDSigmaZ = temp;
+           }
+         clustercount[i]++;
+       }
+    }
+  
+  InitDecoder(input);
+  
+  Int_t temp;
+  for(i=0; i<trackcount; i++)
+    {
+      Int_t count=0;
+      for(j=0; j<AliL3Transform::GetNRows(fPatch); j++)
+       {
+         if(!clusters[i][j].fPresent) continue;
+           
+         temp = ConvertSymbolToInt();
+         RemoveSymbolFromStream(input,temp);
+         clusters[i][j].fDTime *= temp;
+         
+         temp = ConvertSymbolToInt();
+         RemoveSymbolFromStream(input,temp);
+         clusters[i][j].fDPad *= temp;
+         count++;
+       }
+
+      if(count != clustercount[i])
+       {
+         cerr<<"AliL3CompressAC::ExpandFile : Mismatching clustercount "<<index<<" "<<clustercount[i]<<endl;
+         exit(5);
+       }
+    }
+  
+  //Now there should be a endofstream indicator, if not something went wrong during encoding/decoding.
+  temp = ConvertSymbolToInt();
+  if((UShort_t)temp != fMax + 1)
+    cerr<<"AliL3CompressAC::ExpandFile : Missing the endofstream indicator!"<<endl;
+  
+  CloseInputBitFile(input);
+
+  //Write everything to the uncompressed outfile:
+  for(i=0; i<trackcount; i++)
+    {
+      fwrite(&trackmodels[i],sizeof(AliL3TrackModel),1,output);
+      fwrite(clusters[i],AliL3Transform::GetNRows(fPatch)*sizeof(AliL3ClusterModel),1,output);
+    }
+  
+  fclose(output);
+  
+  for(i=0; i<trackcount; i++)
+    delete [] clusters[i];
+  delete [] clusters;
+  delete [] trackmodels;
+  delete [] clustercount;
+  
+  return kTRUE;
+}
+
+void AliL3CompressAC::PrintCompRatio(ofstream *outfile)
+{
+  AliL3MemHandler *mem = new AliL3MemHandler();
+  Char_t fname[1024];
+  UInt_t remain_size=0,digit_size=0;
+  for(Int_t i=0; i<36; i++)
+    {
+      if(fEvent<0)
+       sprintf(fname,"%s/comp/remains_%d_%d.raw",fPath,i,-1);
+      else
+       sprintf(fname,"%s/comp/remains_%d_%d_%d.raw",fPath,fEvent,i,-1);
+      mem->SetBinaryInput(fname);
+      remain_size += mem->GetFileSize();
+      mem->CloseBinaryInput();
+
+      sprintf(fname,"%s/binaries/digits_c8_%d_%d_%d.raw",fPath,fEvent,i,-1);
+      mem->SetBinaryInput(fname);
+      digit_size += mem->GetFileSize();
+      mem->CloseBinaryInput();
+    }
+  
+  
+  if(fEvent<0)
+    sprintf(fname,"%s/comp/tracks_ac_%d_%d.raw",fPath,fSlice,fPatch);
+  else
+    sprintf(fname,"%s/comp/tracks_ac_%d_%d_%d.raw",fPath,fEvent,fSlice,fPatch);
+
+  mem->SetBinaryInput(fname);
+  UInt_t compress_size = mem->GetFileSize();
+  mem->CloseBinaryInput();
+  
+  if(digit_size==0)
+    {
+      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;
+  Float_t entropy[3];
+  Int_t track_size = GetEntropy(entropy[0],entropy[1],entropy[2])*sizeof(AliL3TrackModel);
+  if(outfile)
+    {
+      ofstream &out = *outfile;
+      out<<compress_size<<' '<<remain_size<<' '<<digit_size<<' '<<track_size<<' '<<entropy[0]<<' '<<entropy[1]<<endl;
+    }
+  
+  cout<<"=========================================="<<endl;
+  cout<<"Original digits size : "<<digit_size/1000<<" kByte ( 100 % )"<<endl;
+  cout<<"Compressed file size : "<<compress_size/1000<<" kByte ( "<<(Float_t)compress_size*100/(Float_t)digit_size<<" % )"<<endl;
+  cout<<"Remaining file size  : "<<remain_size/1000<<" kByte ( "<<(Float_t)remain_size*100/(Float_t)digit_size<<" % )"<<endl;
+  cout<<"Relative track size  : "<<track_size/1000<<" kByte ( "<<(Float_t)track_size*100/(Float_t)compress_size<<" % )"<<endl;
+  cout<<"Relative cluster size: "<<(compress_size-track_size)/1000<<" kByte ( "<<(Float_t)(compress_size-track_size)*100/(Float_t)compress_size<<" % )"<<endl;
+  cout<<"---------------------- "<<endl;
+  cout<<"Compression ratio    : "<<compratio*100<<" %"<<endl;
+  cout<<"=========================================="<<endl;
+  cout<<"Entropy of residual and charge : "<<entropy[0]<<" "<<entropy[1]<<" "<<entropy[2]<<endl;
+}
+
diff --git a/HLT/comp/AliL3CompressAC.h b/HLT/comp/AliL3CompressAC.h
new file mode 100644 (file)
index 0000000..3c597de
--- /dev/null
@@ -0,0 +1,50 @@
+// @(#) $Id$
+
+#ifndef AliL3_CompressAC
+#define AliL3_CompressAC
+
+#include "AliL3Compress.h"
+#include "bitio.h"
+
+class AliL3CompressAC : public AliL3Compress {
+  
+ private:
+  UChar_t *fCount;  //!
+  UInt_t *fTotals;  //!
+  UShort_t fMax;
+  UInt_t fScale;
+
+  UInt_t fRange;
+  UShort_t fLow;
+  UShort_t fHigh;
+  UShort_t fUnderflowBits;
+  UShort_t fCode;
+
+  void ClearArrays();
+  void BuildModel(BIT_FILE *output);
+  void RebuildModel(BIT_FILE *input);
+  void FillTotals();
+
+  void InitEncoder();
+  void InitDecoder(BIT_FILE *input);
+  void ConvertIntToSymbol(Int_t value);
+  UInt_t ConvertSymbolToInt();
+  void EncodeSymbol(BIT_FILE *output);
+  void RemoveSymbolFromStream(BIT_FILE *input,Int_t j);  
+  void FlushEncoder(BIT_FILE *output);
+  
+ public:
+  AliL3CompressAC();
+  AliL3CompressAC(Int_t slice,Int_t patch,Char_t *path="./",Bool_t writeshape=kFALSE,Int_t event=-1);
+  virtual ~AliL3CompressAC();
+  
+  Bool_t CompressFile();
+  Bool_t ExpandFile();
+  void PrintCompRatio(STDOF *outfile=0);
+  void PrintTotals();
+  
+  ClassDef(AliL3CompressAC,1) 
+
+};
+
+#endif
index 778a409..fa181f0 100644 (file)
@@ -10,7 +10,7 @@
 #include "AliL3Transform.h"
 #include "AliL3MemHandler.h"
 #include "AliL3SpacePointData.h"
-#include "AliL3Compress.h"
+#include "AliL3CompressAC.h"
 #include "AliL3TrackArray.h"
 #include "AliL3ModelTrack.h"
 #include "AliL3Benchmark.h"
@@ -31,7 +31,6 @@
 
 #ifdef use_root
 #include <TFile.h>
-#include <TMath.h>
 #include <TDirectory.h>
 #include <TSystem.h>
 #include <TH2F.h>
@@ -39,6 +38,7 @@
 
 #include "AliL3DataCompressorHelper.h"
 #include "AliL3DataCompressor.h"
+#include <math.h>
 
 #if __GNUC__ == 3
 using namespace std;
@@ -411,6 +411,8 @@ void AliL3DataCompressor::ExpandTrackData(AliL3TrackArray *tracks)
   
 }
 
+
+
 void AliL3DataCompressor::DetermineMinBits()
 {
   //Make a pass through the modelled data (after FillData has been done) to determine
@@ -434,11 +436,11 @@ void AliL3DataCompressor::DetermineMinBits()
       for(Int_t padrow=0; padrow<AliL3Transform::GetNRows(); padrow++)
        {
          if(!track->IsPresent(padrow)) continue;
-         dpad = TMath::Abs(TMath::Nint(track->GetClusterModel(padrow)->fDPad));
-         dtime = TMath::Abs(TMath::Nint(track->GetClusterModel(padrow)->fDTime));
-         charge = TMath::Abs((Int_t)track->GetClusterModel(padrow)->fDCharge);
-         dsigmaY = TMath::Abs(TMath::Nint(track->GetClusterModel(padrow)->fDSigmaY));
-         dsigmaZ = TMath::Abs(TMath::Nint(track->GetClusterModel(padrow)->fDSigmaZ));
+         dpad = AliL3DataCompressorHelper::Abs(AliL3DataCompressorHelper::Nint(track->GetClusterModel(padrow)->fDPad));
+         dtime = AliL3DataCompressorHelper::Abs(AliL3DataCompressorHelper::Nint(track->GetClusterModel(padrow)->fDTime));
+         charge = AliL3DataCompressorHelper::Abs((Int_t)track->GetClusterModel(padrow)->fDCharge);
+         dsigmaY = AliL3DataCompressorHelper::Abs(AliL3DataCompressorHelper::Nint(track->GetClusterModel(padrow)->fDSigmaY));
+         dsigmaZ = AliL3DataCompressorHelper::Abs(AliL3DataCompressorHelper::Nint(track->GetClusterModel(padrow)->fDSigmaZ));
          if(dpad > maxpad)
            maxpad=dpad;
          if(dtime > maxtime)
@@ -452,11 +454,11 @@ void AliL3DataCompressor::DetermineMinBits()
        }
     }
   cout<<"maxpad "<<maxpad<<" maxtime "<<maxtime<<" maxcharge "<<maxcharge<<endl;
-  npadbits = (Int_t)TMath::Ceil(TMath::Log(maxpad)/TMath::Log(2)) + 1; //need 1 extra bit to encode the sign
-  ntimebits = (Int_t)TMath::Ceil(TMath::Log(maxtime)/TMath::Log(2)) + 1;
-  nchargebits = (Int_t)TMath::Ceil(TMath::Log(maxcharge)/TMath::Log(2)); //Store as a absolute value
+  npadbits = (Int_t)ceil(log(Double_t(maxpad))/log(2.)) + 1; //need 1 extra bit to encode the sign
+  ntimebits = (Int_t)ceil(log(Double_t(maxtime))/log(2.)) + 1;
+  nchargebits = (Int_t)ceil(log(Double_t(maxcharge))/log(2.)); //Store as a absolute value
   if(fWriteClusterShape)
-    nshapebits = (Int_t)TMath::Ceil(TMath::Log(maxsigma)/TMath::Log(2)) + 1;
+    nshapebits = (Int_t)ceil(log(Double_t(maxsigma))/log(2.)) + 1;
   
   nchargebits = AliL3DataCompressorHelper::GetNChargeBits();
   cout<<"Updating bitnumbers; pad "<<npadbits<<" time "<<ntimebits<<" charge "<<nchargebits<<" shape "<<nshapebits<<endl;
@@ -649,14 +651,18 @@ void AliL3DataCompressor::SelectRemainingClusters()
   
 }
 
-void AliL3DataCompressor::CompressAndExpand()
+void AliL3DataCompressor::CompressAndExpand(Bool_t arithmetic_coding)
 {
   //Read tracks/clusters from file, compress data and uncompress it. Write compression rates to file.
   if(fNoCompression)
     return;
   
   cout<<"Compressing and expanding data"<<endl;
-  AliL3Compress *comp = new AliL3Compress(-1,-1,fPath,fWriteClusterShape,fEvent);
+  AliL3Compress *comp = 0;
+  if(arithmetic_coding)
+    comp = new AliL3CompressAC(-1,-1,fPath,fWriteClusterShape,fEvent);
+  else
+    comp = new AliL3Compress(-1,-1,fPath,fWriteClusterShape,fEvent);
   comp->CompressFile();
   comp->ExpandFile();
   comp->PrintCompRatio(fCompRatioFile);
@@ -698,7 +704,7 @@ void AliL3DataCompressor::RestoreData(Bool_t remaining_only)
   
   if(!remaining_only)
     ReadUncompressedData(clusters,ncl,maxpoints);
-  
+    
   if(fKeepRemaining)
     ReadRemaining(clusters,ncl,maxpoints);
   
@@ -762,8 +768,8 @@ void AliL3DataCompressor::RestoreData(Bool_t remaining_only)
              
              c->SetSigmaY2(clPt[counter]->sigmaY2*pow(AliL3Transform::GetPadPitchWidth(patch),2));
              c->SetSigmaZ2(clPt[counter]->sigmaZ2*pow(AliL3Transform::GetZWidth(),2));
-             Int_t pad = TMath::Nint(clPt[counter]->pad);
-             Int_t time = TMath::Nint(clPt[counter]->time);
+             Int_t pad = AliL3DataCompressorHelper::Nint(clPt[counter]->pad);
+             Int_t time = AliL3DataCompressorHelper::Nint(clPt[counter]->time);
              
              if(pad < 0)
                pad=0;
@@ -822,8 +828,7 @@ void AliL3DataCompressor::RestoreData(Bool_t remaining_only)
 
 void AliL3DataCompressor::ReadUncompressedData(TempCluster **clusters,Int_t *ncl,const Int_t maxpoints)
 {
-
-
+  
   AliL3Compress *comp = new AliL3Compress(-1,-1,fPath,fWriteClusterShape,fEvent);
   if(fNoCompression)
     {
@@ -838,6 +843,7 @@ void AliL3DataCompressor::ReadUncompressedData(TempCluster **clusters,Int_t *ncl
   
   AliL3TrackArray *tracks = comp->GetTracks();
   
+  //Float_t totcounter=0,pcounter=0,tcounter=0;
   Int_t charge;
   Float_t pad,time,sigmaY2,sigmaZ2;
   for(Int_t i=0; i<tracks->GetNTracks(); i++)
@@ -876,7 +882,6 @@ void AliL3DataCompressor::ReadUncompressedData(TempCluster **clusters,Int_t *ncl
          ncl[slice]++;
        }
     }
-
   delete comp;
 }
 
index 9ad3f00..47b20a1 100644 (file)
@@ -36,28 +36,8 @@ class AliL3DataCompressor {
 #else
   FILE *fOutputFile;
 #endif
-  
   UInt_t fNcl[36][6];
-  
-  /*
-  static Int_t fNumPadBits;
-  static Int_t fNumTimeBits;
-  static Int_t fNumChargeBits;
-  static Int_t fNumPadShapeBits;
-  static Int_t fNumTimeShapeBits;
-  
-  static Float_t fPadResidualStep1;
-  static Float_t fPadResidualStep2;
-  static Float_t fPadResidualStep3;
-  static Float_t fTimeResidualStep1;
-  static Float_t fTimeResidualStep2;
-  static Float_t fTimeResidualStep3;
-  static Float_t fPadSigma2Step1;
-  static Float_t fPadSigma2Step2;
-  static Float_t fTimeSigma2Step;
-  static Int_t fClusterCharge;
-  */
+   
   void SelectRemainingClusters();
   void ExpandTrackData(AliL3TrackArray *tracks);
   void ReadUncompressedData(TempCluster **clusters,Int_t *ncl,const Int_t maxpoints);
@@ -88,32 +68,14 @@ class AliL3DataCompressor {
   virtual void FillData(Int_t minhits,Bool_t expand);
   virtual void WriteRemaining(Bool_t select);
   void DetermineMinBits();
-  void CompressAndExpand();
+  void CompressAndExpand(Bool_t arithmetic_coding=kTRUE);
   void RestoreData(Bool_t remaining_only=kFALSE);
   void DoBench(Char_t *fname="benchmark");
   void DoNotCompress() {fNoCompression=kTRUE;}
 
-  /*
-  void SetBitNumbers(Int_t pad,Int_t time,Int_t charge,Int_t shapepad,Int_t shapetime);
-  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);
-  */
   Int_t GetNusedClusters() {return fNusedClusters;}
   Int_t GetNunusedClusters() {return fNunusedClusters;}
 
-  /*
-  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 GetNPadShapeBits() {return fNumPadShapeBits;}
-  static const Int_t GetNTimeShapeBits() {return fNumTimeShapeBits;}
-  static const Float_t GetPadSigma2Step(Int_t patch) {return patch < 2 ? fPadSigma2Step1 : fPadSigma2Step2;}
-  static const Float_t GetTimeSigma2Step() {return fTimeSigma2Step;}
-  static const Int_t GetClusterCharge() {return fClusterCharge;}
-  static const Float_t GetPadResidualStep(Int_t row);
-  static const Float_t GetTimeResidualStep(Int_t row);
-  */
-
   ClassDef(AliL3DataCompressor,1) 
 
 };
index 4c2e34d..98568bd 100644 (file)
@@ -142,3 +142,21 @@ const Float_t AliL3DataCompressorHelper::GetTimePrecisionFactor()
       return 1;
     }
 }
+
+
+Int_t AliL3DataCompressorHelper::Nint(Double_t x)
+{
+   // Round to nearest integer. Rounds half integers 
+   // to the nearest even integer.
+
+   Int_t i=0;
+   if (x >= 0) {
+      i = Int_t(x + 0.5);
+      if (x + 0.5 == Double_t(i) && i & 1) i--;
+   } else {
+      i = Int_t(x - 0.5);
+      if (x - 0.5 == Double_t(i) && i & 1) i++;
+
+   }
+   return i;
+}
index 9888f2f..b2b9124 100644 (file)
@@ -49,6 +49,13 @@ class AliL3DataCompressorHelper {
   static const Float_t GetPadPrecisionFactor();
   static const Float_t GetTimePrecisionFactor();
 
+  //taken from TMath
+  static Int_t Nint(Double_t x); 
+  inline static Int_t Abs(Int_t d)
+   { return (d > 0) ? d : -d; }
+  inline static Double_t Abs(Double_t d)
+   { return (d > 0) ? d : -d; }
+
   ClassDef(AliL3DataCompressorHelper,1) 
 
 };
index 912bde3..5287932 100644 (file)
@@ -1,3 +1,4 @@
+/* $Id$ */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -5,20 +6,19 @@
 #include <setjmp.h>
 #include "AliL3FitUtilities.h"
 
-
 jmp_buf env;
 
 DPOINT *plane;
 
 void f2gauss5(double x,double a[],double *y,double dyda[],int na)
 {
-  /* Function describing a sum of 2D gaussians with 5 parameters.
-     There number of gaussians is na/5.*/
+  //Function describing a sum of 2D gaussians with 5 parameters.
+  //There number of gaussians is na/5.
   
   int i,index;
   double fac,fac1,fac2,ex,ex1,ex2,arg1,arg2,u,v;
   
-  /*printf("fitting na %d, with pad %f time %f amplitude %f padwidth %f timewidth %f\n",na,a[2],a[4],a[1],a[3],a[5]);*/
+  //printf("fitting na %d, with pad %f time %f amplitude %f padwidth %f timewidth %f\n",na,a[2],a[4],a[1],a[3],a[5]);
         index = nint(x);
        if( index < 0 || index >=FIT_PTS )
        {
@@ -27,7 +27,7 @@ void f2gauss5(double x,double a[],double *y,double dyda[],int na)
        }
        u     = plane[index].u;
        v     = plane[index].v;
-       /*printf("u %f v %f\n",u,v);*/
+       //printf("u %f v %f\n",u,v);
        *y=0.0;
        for (i=1;i<=na-1;i+=5)
        {
@@ -50,11 +50,9 @@ void f2gauss5(double x,double a[],double *y,double dyda[],int na)
 
 void nrerror(char error_text[])
 /* Numerical Recipes standard error handler */
-{ 
-  /*
-    printf("%s\n",error_text);
-    exit(1);
-  */
+{
+  //printf("%s\n",error_text);
+  //exit(1);
 }
 
 void free_vector(double *v, long nl, long nh)
@@ -375,7 +373,7 @@ int lev_marq_fit( double x[], double y[], double sig[], int NPT, double a[], int
                return 0;
        }
        else {
-         /*if( control_g.print_fit_errors==2 )*/
+         //if( control_g.print_fit_errors==2 )
          fprintf( stderr, " runtime error\n" );
 
                free_matrix(alpha,1,MA,1,MA);
index 00be2f7..3b3d876 100644 (file)
@@ -1,10 +1,10 @@
-/* @(#) $Id$ */
+// @(#) $Id$
 
 #ifndef AliL3FitUtilities
 #define AliL3FitUtilities
 
-/* This we do because this file is read both with c and c++ compiler, 
-   and extern "C" is needed only in case of c++. */
+//This we do because this file is read both with c and c++ compiler, 
+//and extern "C" is needed only in case of c++.
 #ifdef __cplusplus
 extern "C" 
 #endif
@@ -30,6 +30,8 @@ int lev_marq_fit( double x[], double y[], double sig[], int NPT, double a[], int
 #define NR_END 1
 #define FREE_ARG char*
 #define EPSILON             1.0E-12
+//#define TRUE 1
+//#define FALSE 1
 #define FIT_PTS     2000
 #define  FIT_MAXPAR   41
 #define NUM_PARS 5
@@ -41,7 +43,7 @@ struct DPOINT {
 };
 typedef struct DPOINT DPOINT;
 
-extern  DPOINT *plane;
+extern  DPOINT *plane; //!
 
 typedef struct { 
                                        long   float_size;
index cb7d075..dd0a425 100644 (file)
@@ -471,8 +471,7 @@ void AliL3Modeller::WriteRemaining()
   AliL3DigitRowData *rowPt;
   rowPt = (AliL3DigitRowData*)fRowData;
   Int_t digitcount=0;
-  //  Int_t ndigits[(AliL3Transform::GetNRows(fPatch))];
-  Int_t * ndigits = new Int_t[(AliL3Transform::GetNRows(fPatch))];
+  Int_t *ndigits=new Int_t[(AliL3Transform::GetNRows(fPatch))];
   for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++)
     {
       AliL3DigitData *digPt = (AliL3DigitData*)rowPt->fDigitData;
index cf1d0d1..db30746 100644 (file)
@@ -34,11 +34,7 @@ typedef struct AliL3RemainingCluster AliL3RemainingCluster;
 struct AliL3RemainingRow {
   Byte_t fPadRow;       //1 byte
   UShort_t fNClusters;  //2 bytes
-#if defined(__HP_aCC) || defined(__DECCXX) || defined(__SUNPRO_CC)
-  AliL3RemainingCluster fClusters[1];
-#else
   AliL3RemainingCluster fClusters[0];
-#endif
 };
 typedef struct AliL3RemainingRow AliL3RemainingRow;
 
index 1031897..47d909a 100644 (file)
@@ -15,7 +15,7 @@ endif
 include $(ALIHLT_TOPDIR)/Makefile.conf
 
 SRCS =  AliL3Modeller.cxx AliL3ClusterFitter.cxx \
-        AliL3Compress.cxx  AliL3DataCompressor.cxx 
+        AliL3Compress.cxx  AliL3DataCompressor.cxx AliL3CompressAC.cxx
 
 ifneq ($(ARCH),Darwin)
 SRCS += AliL3DataCompressorHelper.cxx AliL3ModelTrack.cxx
index 2980526..5563794 100644 (file)
@@ -1,4 +1,4 @@
-/* @(#) $Id$ */
+// @(#) $Id$
 
 /************************** Start of BITIO.H *************************/
 
@@ -14,9 +14,10 @@ typedef struct bit_file {
     int pacifier_counter;
 } BIT_FILE;
 
+//#ifdef __STDC__
 
-/* The following we do because this file is read both by
-   C and C++ compiler. */
+//The following we do because this file is read both by
+//C and C++ compiler.
 #ifdef __cplusplus
 extern "C" BIT_FILE     *OpenInputBitFile( char *name );
 extern "C" BIT_FILE     *OpenOutputBitFile( char *name );
@@ -59,3 +60,5 @@ void          FilePrintBinary();
 #endif  /* _BITIO_H */
 
 /*************************** End of BITIO.H **************************/
+
+
index 017b0f0..b176809 100644 (file)
@@ -1,10 +1,12 @@
-/* @(#) $Id$ */
+// @(#) $Id$
 
 /************************* Start of ERRHAND.H ************************/
 
 #ifndef _ERRHAND_H
 #define _ERRHAND_H
 
+//#ifdef __STDC__
+
 void fatal_error( char *fmt, ... );
 /*
 #else
@@ -16,3 +18,4 @@ void fatal_error();
 #endif  /* _ERRHAND_H */
 
 /************************** End of ERRHAND.H *************************/
+
index f895837..b8e7d36 100644 (file)
@@ -1,3 +1,35 @@
+2004-05-12  Constantin Loizides  <loizides@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/comp/AliL3FitUtilities.c:
+       Removed further warnings (gcc-2).
+
+       * /alice/cvs/hltcvs/level3code/comp/AliL3Compress.cxx, /alice/cvs/hltcvs/level3code/comp/AliL3FitUtilities.c, /alice/cvs/hltcvs/level3code/comp/AliL3Modeller.cxx, /alice/cvs/hltcvs/level3code/comp/AliL3Modeller.h, /alice/cvs/hltcvs/level3code/comp/AliL3ModelTrack.cxx, /alice/cvs/hltcvs/level3code/comp/AliL3OfflineDataCompressor.h:
+       Removed warnings.
+
+2004-05-11  Constantin Loizides  <loizides@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/comp/AliL3CompressAC.cxx, /alice/cvs/hltcvs/level3code/comp/AliL3CompressAC.h, /alice/cvs/hltcvs/level3code/comp/AliL3Compress.h, /alice/cvs/hltcvs/level3code/comp/AliL3DataCompressor.cxx:
+       Changes to compile standalone.
+
+2004-05-10  Constantin Loizides  <loizides@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/comp/AliL3DataCompressor.cxx, /alice/cvs/hltcvs/level3code/comp/AliL3DataCompressorHelper.cxx, /alice/cvs/hltcvs/level3code/comp/AliL3DataCompressorHelper.h:
+       Removed every dependency to TMath, so that code compiles for STANDALONE version.
+
+2004-04-28  Anders Strand Vestbo  <vestbo@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/comp/AliL3CompLinkDef.h, /alice/cvs/hltcvs/level3code/comp/AliL3CompressAC.cxx, /alice/cvs/hltcvs/level3code/comp/AliL3CompressAC.h, /alice/cvs/hltcvs/level3code/comp/AliL3Compress.cxx, /alice/cvs/hltcvs/level3code/comp/AliL3Compress.h, /alice/cvs/hltcvs/level3code/comp/AliL3DataCompressor.cxx, /alice/cvs/hltcvs/level3code/comp/AliL3DataCompressor.h, /alice/cvs/hltcvs/level3code/comp/Makefile:
+       Included new class AliL3CompressAC in the library. This class is invoked
+       by default in the AliL3DataCompressor, and can be toggled by the argument
+       in AliL3DataCompressor::CompressAndExpand(bool).
+
+2004-04-26  Anders Strand Vestbo  <vestbo@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/comp/AliL3CompressAC.cxx, /alice/cvs/hltcvs/level3code/comp/AliL3CompressAC.h:
+       New class implementing aritmetic coding of the quantized residual
+       information in the data compression scheme. The class derives from
+       AliL3Compress, and is hence interfaced in the same way.
+
 2004-03-20  Constantin Loizides  <loizides@hansa00>
 
        * /alice/cvs/hltcvs/level3code/comp/AliL3ClusterFitter.cxx, /alice/cvs/hltcvs/level3code/comp/AliL3Compress.cxx, /alice/cvs/hltcvs/level3code/comp/AliL3DataCompressor.cxx, /alice/cvs/hltcvs/level3code/comp/AliL3DataCompressorHelper.cxx, /alice/cvs/hltcvs/level3code/comp/AliL3Modeller.cxx, /alice/cvs/hltcvs/level3code/comp/AliL3ModelTrack.cxx, /alice/cvs/hltcvs/level3code/comp/AliL3OfflineDataCompressor.cxx:
index fc87092..2b6f4b1 100644 (file)
@@ -1,3 +1,16 @@
+2004-05-11  Anders Strand Vestbo  <vestbo@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/exa/runtracker.C:
+       Added the option to run a second (nonvertex) tracking pass
+
+2004-05-08  Anders Strand Vestbo  <vestbo@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/exa/SetTrackingParameters_1000bf02.C, /alice/cvs/hltcvs/level3code/exa/SetTrackingParameters_1000bf04.C, /alice/cvs/hltcvs/level3code/exa/SetTrackingParameters_2000bf02.C, /alice/cvs/hltcvs/level3code/exa/SetTrackingParameters_2000bf04.C, /alice/cvs/hltcvs/level3code/exa/SetTrackingParameters_4000bf02.C, /alice/cvs/hltcvs/level3code/exa/SetTrackingParameters_4000bf04.C, /alice/cvs/hltcvs/level3code/exa/SetTrackingParameters_8000bf02.C, /alice/cvs/hltcvs/level3code/exa/SetTrackingParameters_8000bf04.C:
+       Added line to correctly set the parameters for the sector merger.
+       Until now default parameters has been used in AliLevel::SetMergerParameters,
+       but these are a little bit too strict. I was just simply not aware that I forgot
+       to update the macros before now...
+
 2004-03-30  Constantin Loizides  <loizides@hansa00>
 
        * /alice/cvs/hltcvs/level3code/exa/evaltracker.C: Make it compilable.
index b8b2d69..00164c8 100644 (file)
@@ -1,3 +1,56 @@
+2004-05-12  Constantin Loizides  <loizides@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/hough/AliL3HoughTransformerRow.cxx:
+       Added define for AliHLTReconstructor.
+
+       * /alice/cvs/hltcvs/level3code/hough/AliL3Hough.cxx, /alice/cvs/hltcvs/level3code/hough/AliL3Hough.h:
+       Added ifdefs for new_io runloader handling.
+
+       * /alice/cvs/hltcvs/level3code/hough/AliL3HoughMaxFinder.cxx:
+       changed abs to fabs.
+
+       * /alice/cvs/hltcvs/level3code/hough/AliL3HoughMaxFinder.cxx, /alice/cvs/hltcvs/level3code/hough/AliL3HoughTransformerRow.cxx:
+       Removed further compiler warnings.
+
+2004-05-11  Constantin Loizides  <loizides@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/hough/AliL3Histogram1D.cxx, /alice/cvs/hltcvs/level3code/hough/AliL3HoughBaseTransformer.cxx, /alice/cvs/hltcvs/level3code/hough/AliL3HoughBaseTransformer.h, /alice/cvs/hltcvs/level3code/hough/AliL3HoughClusterTransformer.cxx, /alice/cvs/hltcvs/level3code/hough/AliL3HoughClusterTransformer.h, /alice/cvs/hltcvs/level3code/hough/AliL3HoughEval.cxx, /alice/cvs/hltcvs/level3code/hough/AliL3HoughIntMerger.cxx, /alice/cvs/hltcvs/level3code/hough/AliL3HoughTest.cxx, /alice/cvs/hltcvs/level3code/hough/AliL3HoughTransformer.cxx, /alice/cvs/hltcvs/level3code/hough/AliL3HoughTransformerGlobal.cxx, /alice/cvs/hltcvs/level3code/hough/AliL3HoughTransformerLUT.cxx:
+       Removed compiler warnings.
+
+       * /alice/cvs/hltcvs/level3code/hough/AliL3HoughTrack.cxx:
+       Needed to compile standalone.
+
+       * /alice/cvs/hltcvs/level3code/hough/AliL3HoughTransformerRow.cxx, /alice/cvs/hltcvs/level3code/hough/AliL3HoughTransformerRow.h:
+       Newer, much faster and very efficient HT on rows (Cvetan).
+
+       * /alice/cvs/hltcvs/level3code/hough/AliL3HoughTrack.cxx, /alice/cvs/hltcvs/level3code/hough/AliL3HoughTrack.h:
+       Added binsizes and proper setting of most parameters.
+
+       * /alice/cvs/hltcvs/level3code/hough/AliL3HoughMaxFinder.cxx, /alice/cvs/hltcvs/level3code/hough/AliL3HoughMaxFinder.h:
+       Added Cvetans Peakfinder.
+
+       * /alice/cvs/hltcvs/level3code/hough/AliL3Hough.cxx:
+       Added support for runloader, and Cvetans Hough Transform and PeakFinder (version 4).
+
+       * /alice/cvs/hltcvs/level3code/hough/AliL3Hough.h:
+       Added support for runloader.
+
+       * /alice/cvs/hltcvs/level3code/hough/AliL3Histogram.cxx, /alice/cvs/hltcvs/level3code/hough/AliL3Histogram.h:
+       Take bin values at borders.
+
+       * /alice/cvs/hltcvs/level3code/hough/AliL3HoughTransformerVhdl.cxx, /alice/cvs/hltcvs/level3code/hough/AliL3HoughTransformerVhdl.h:
+       Removed gcc warning.
+
+2004-05-07  Constantin Loizides  <loizides@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/hough/AliL3Histogram.h:
+       Needed to compile in aliroot.
+
+2004-04-21  Anders Strand Vestbo  <vestbo@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/hough/AliL3HoughTransformerRow.cxx:
+       Make code compilable without specifying the ROWHOUGH compiling option
+
 2004-03-28  Constantin Loizides  <loizides@hansa00>
 
        * /alice/cvs/hltcvs/level3code/hough/AliL3HoughBaseTransformer.h:
index d1f1fc8..1f7bd0c 100644 (file)
@@ -1,3 +1,8 @@
+2004-05-03  Thomas Vik  <tvik@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/kalman/AliL3Kalman.h, /alice/cvs/hltcvs/level3code/kalman/AliL3Kalman.cxx, /alice/cvs/hltcvs/level3code/kalman/AliL3KalmanTrack.h, /alice/cvs/hltcvs/level3code/kalman/AliL3KalmanTrack.cxx:
+       Added MakeSeed function.
+
 2004-03-18  Thomas Vik  <tvik@hansa00>
 
        * /alice/cvs/hltcvs/level3code/kalman/AliL3KalmanTrack.cxx:
index e9b0a8f..6ce7083 100644 (file)
@@ -1,3 +1,8 @@
+2004-05-12  Constantin Loizides  <loizides@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/misc/AliL3DDLDataFileHandler.cxx, /alice/cvs/hltcvs/level3code/misc/AliL3DDLDataFileHandler.h, /alice/cvs/hltcvs/level3code/misc/AliL3DDLRawReaderFile.cxx, /alice/cvs/hltcvs/level3code/misc/AliL3VHDLClusterFinder.cxx:
+       Removed compiler warnings.
+
 2004-03-20  Constantin Loizides  <loizides@hansa00>
 
        * /alice/cvs/hltcvs/level3code/misc/AliL3DataHandler.cxx, /alice/cvs/hltcvs/level3code/misc/AliL3DDLDataFileHandler.cxx, /alice/cvs/hltcvs/level3code/misc/AliL3DDLRawReaderFile.cxx, /alice/cvs/hltcvs/level3code/misc/AliL3Stopwatch.cxx, /alice/cvs/hltcvs/level3code/misc/AliL3TPCMapping.cxx, /alice/cvs/hltcvs/level3code/misc/AliL3TransBit.cxx, /alice/cvs/hltcvs/level3code/misc/AliL3VHDLClusterFinder.cxx:
index 0ba3e60..58f0eaa 100644 (file)
@@ -1,3 +1,53 @@
+2004-05-10  Kenneth Aamodt  <kenneth@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/programs/Makefile, /alice/cvs/hltcvs/level3code/programs/tpcbeamtesttracker.cxx:
+       latest changes.
+
+2004-05-10  Constantin Loizides  <loizides@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/programs/tpcbeamtesttracker.cxx:
+       Reversed order to anticipated coming changes.
+
+       * /alice/cvs/hltcvs/level3code/programs/convcosmicsfile.cxx:
+       add file size for pub-sub filepublisher tests.
+
+       * /alice/cvs/hltcvs/level3code/programs/Makefile:
+       remove gmon.out when cleaning
+
+2004-05-09  Kenneth Aamodt  <kenneth@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/programs/tpcbeamtestdisplay.cxx:
+       This is the "final" update, only cosmetics left.
+
+       * /alice/cvs/hltcvs/level3code/programs/tpcbeamtestdisplay.cxx:
+       Now draw the clusters and the track.
+
+       * /alice/cvs/hltcvs/level3code/programs/tpcbeamtestdisplay.cxx:
+       TPC test displaying class.
+
+       * /alice/cvs/hltcvs/level3code/programs/tpcbeamtesttracker.cxx:
+       Removed slice and patch as possibility in constructor.
+
+       * /alice/cvs/hltcvs/level3code/programs/tpcbeamtesttracker.cxx:
+       Removed the tracking function, it does not work on straight tracks.
+
+2004-05-08  Kenneth Aamodt  <kenneth@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/programs/tpcbeamtesttracker.cxx:
+       Debugged and tested. Arguments: filename, path, [slice], [patch]
+
+       * /alice/cvs/hltcvs/level3code/programs/tpcbeamtesttracker.cxx:
+       Removed a given path in constructor.
+
+       * /alice/cvs/hltcvs/level3code/programs/tpcbeamtesttracker.cxx:
+       Removed all bugs. have'nt tested it yet.
+
+       * /alice/cvs/hltcvs/level3code/programs/Makefile:
+       Added new tpc test program.
+
+       * /alice/cvs/hltcvs/level3code/programs/tpcbeamtesttracker.cxx:
+       Added program for tpcbeamtest to work on raw altro data.
+
 2004-03-20  Constantin Loizides  <loizides@hansa00>
 
        * /alice/cvs/hltcvs/level3code/programs/ali2raw.cxx, /alice/cvs/hltcvs/level3code/programs/convcosmicsfile.cxx, /alice/cvs/hltcvs/level3code/programs/gettransform.cxx, /alice/cvs/hltcvs/level3code/programs/Makefile, /alice/cvs/hltcvs/level3code/programs/read.cxx, /alice/cvs/hltcvs/level3code/programs/runhough.cxx, /alice/cvs/hltcvs/level3code/programs/runit.cxx, /alice/cvs/hltcvs/level3code/programs/runtracker.cxx, /alice/cvs/hltcvs/level3code/programs/runvhdlcf.cxx, /alice/cvs/hltcvs/level3code/programs/runvhdlhough.cxx:
index 31e7a47..d6a8050 100644 (file)
@@ -1,3 +1,89 @@
+2004-05-12  Constantin Loizides  <loizides@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/src/AliHLTReconstructor.cxx, /alice/cvs/hltcvs/level3code/src/AliHLTReconstructor.h, /alice/cvs/hltcvs/level3code/src/AliL3SrcLinkDef.h:
+       Added define for AliHLTReconstructor.
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3FileHandler.cxx:
+       Bugfix for oldio.
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3Transform.cxx: Minor bugfix.
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3RawDataFileHandler.cxx, /alice/cvs/hltcvs/level3code/src/AliL3Transform.cxx:
+       Further compiler warning removed and flags for Sun/HP.
+
+2004-05-11  Constantin Loizides  <loizides@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3Fitter.cxx, /alice/cvs/hltcvs/level3code/src/AliL3Logger.cxx, /alice/cvs/hltcvs/level3code/src/AliL3Merger.cxx, /alice/cvs/hltcvs/level3code/src/AliL3RawDataFileHandler.cxx:
+       Removed compiler warnings.
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3TrackSegmentData.h:
+       Added extended information if using -dROWHOUGHPARAMS
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3Track.cxx, /alice/cvs/hltcvs/level3code/src/AliL3Track.h:
+       Added pid information and label (even though
+       label can be found with evaluate and not
+       necessarily has to be stored in the track,
+       it was necessary as we dont store clusters
+       during the data challenge.
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3Transform.cxx:
+       Added -DROWHOUGHPARAMS and removed compiler warnings.
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3MemHandler.h:
+       Removed compiler warnings and runloader added.
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3DigitData.h:
+       Workaround for Sun.
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3TrackArray.cxx:
+       Added params for row hough transform and physics data
+       challenge  reconstruction.
+
+       * /alice/cvs/hltcvs/level3code/src/AliLevel3.cxx, /alice/cvs/hltcvs/level3code/src/AliLevel3.h:
+       Added support for RunLoader input (newio).
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3Evaluate.cxx, /alice/cvs/hltcvs/level3code/src/AliL3Evaluate.h:
+       Added PID, even though it is not the most natural thing to
+       do it in the evaluation as this class is for MC.
+       The reason we put it here is, that we want to avoid opening
+       the cluster files another time, somewhere else in the
+       code during the pdc.
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3FileHandler.cxx, /alice/cvs/hltcvs/level3code/src/AliL3FileHandler.h:
+       Added userunloader to avoid deletion of deleted runloader object (newio) and solved bug for empty rows (thanks to Cvetan).
+
+       * /alice/cvs/hltcvs/level3code/src/AliHLTReconstructor.cxx, /alice/cvs/hltcvs/level3code/src/AliHLTReconstructor.h, /alice/cvs/hltcvs/level3code/src/AliL3SrcLinkDef.h, /alice/cvs/hltcvs/level3code/src/Makefile:
+       Nice reconstruction class to use with PDC (only for AliRoot).
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3MemHandler.cxx, /alice/cvs/hltcvs/level3code/src/AliL3MemHandler.h, /alice/cvs/hltcvs/level3code/src/AliL3RawDataFileHandler.cxx, /alice/cvs/hltcvs/level3code/src/AliL3RawDataFileHandler.h, /alice/cvs/hltcvs/level3code/src/AliL3StandardIncludes.h:
+       Changes to compile standalone.
+
+2004-05-10  Kenneth Aamodt  <kenneth@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3ConfMapper.cxx, /alice/cvs/hltcvs/level3code/src/AliL3Display.cxx, /alice/cvs/hltcvs/level3code/src/AliL3Display.h, /alice/cvs/hltcvs/level3code/src/AliLevel3.cxx:
+       (Partially) Inverted accidental last checkin done by Constantin and Kenneth in rush together with lots of beer.
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3ConfMapper.cxx, /alice/cvs/hltcvs/level3code/src/AliL3Display.cxx, /alice/cvs/hltcvs/level3code/src/AliL3Display.h, /alice/cvs/hltcvs/level3code/src/AliL3RawDataFileHandler.cxx, /alice/cvs/hltcvs/level3code/src/AliL3RawDataFileHandler.h, /alice/cvs/hltcvs/level3code/src/AliLevel3.cxx:
+       Changed pointer into const pointer.
+
+2004-05-10  Constantin Loizides  <loizides@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3RawDataFileHandler.cxx, /alice/cvs/hltcvs/level3code/src/AliL3RawDataFileHandler.h:
+       Added reading from pointer.
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3RawDataFileHandler.cxx, /alice/cvs/hltcvs/level3code/src/AliL3RawDataFileHandler.h:
+       Added fCharges.
+
+2004-05-07  Constantin Loizides  <loizides@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/src/AliLevel3.cxx:
+       Proper init of null pointer in default constructor.
+
+2004-04-01  Constantin Loizides  <loizides@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/src/AliL3Transform.cxx:
+       Bug fixed in GetZFast.
+
 2004-03-20  Constantin Loizides  <loizides@hansa00>
 
        * /alice/cvs/hltcvs/level3code/src/AliL3Transform.cxx:
index f5ab958..c7f6c43 100644 (file)
@@ -1,3 +1,11 @@
+2004-05-12  Constantin Loizides  <loizides@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/Makefile.rules:
+       Added define for AliHLTReconstructor.
+
+       * /alice/cvs/hltcvs/level3code/Makefile.rules:
+       Removed further compiler warnings.
+
 2004-03-20  Constantin Loizides  <loizides@hansa00>
 
        * /alice/cvs/hltcvs/level3code/Makefile.conf, /alice/cvs/hltcvs/level3code/Makefile.rules:
index 436cad3..f472dfa 100644 (file)
@@ -1,3 +1,13 @@
+2004-05-11  Gaute Ovrebekk  <ovrebekk@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/trigger/AliBarrelRec_TPCparam.C, /alice/cvs/hltcvs/level3code/trigger/AliD0Trigger.C, /alice/cvs/hltcvs/level3code/trigger/AliD0Trigger.cxx, /alice/cvs/hltcvs/level3code/trigger/AliD0Trigger.h, /alice/cvs/hltcvs/level3code/trigger/AliD0vtxFinderBkg_pp_VTX.C, /alice/cvs/hltcvs/level3code/trigger/AliD0vtxFinderSgn_pp_VTX.C, /alice/cvs/hltcvs/level3code/trigger/AliITSFindClustersV2.C, /alice/cvs/hltcvs/level3code/trigger/AliL3TriggerLinkDef.h, /alice/cvs/hltcvs/level3code/trigger/Makefile, /alice/cvs/hltcvs/level3code/trigger/RunD0offline.C:
+       removeing macros
+
+2004-05-04  Gaute Ovrebekk  <ovrebekk@hansa00>
+
+       * /alice/cvs/hltcvs/level3code/trigger/AliD0Trigger.cxx, /alice/cvs/hltcvs/level3code/trigger/AliD0Trigger.h, /alice/cvs/hltcvs/level3code/trigger/RunD0offline.C:
+       Option for makeing histograms etc.
+
 2004-03-12  Gaute Ovrebekk  <ovrebekk@hansa00>
 
        * /alice/cvs/hltcvs/level3code/trigger/RunD0Trigger.C: small chages
index 0a68f59..527bf19 100644 (file)
@@ -28,5 +28,5 @@ void SetTrackingParameters(AliLevel3 *tracker)
                           rowscopetracklet,rowscopetrack,
                           min_pt_fit,maxangle,goodDist,hitChi2Cut,
                           goodHitChi2,trackChi2Cut,50,maxphi,maxeta,kTRUE);
-  
+  tracker->SetMergerParameters(2,3,0.003,0.1,0.05);
 }
index 0a68f59..0994830 100644 (file)
@@ -29,4 +29,5 @@ void SetTrackingParameters(AliLevel3 *tracker)
                           min_pt_fit,maxangle,goodDist,hitChi2Cut,
                           goodHitChi2,trackChi2Cut,50,maxphi,maxeta,kTRUE);
   
+  tracker->SetMergerParameters(2,3,0.003,0.1,0.05);
 }
index 5675395..4b68418 100644 (file)
@@ -28,5 +28,5 @@ void SetTrackingParameters(AliLevel3 *tracker)
                           rowscopetracklet,rowscopetrack,
                           min_pt_fit,maxangle,goodDist,hitChi2Cut,
                           goodHitChi2,trackChi2Cut,50,maxphi,maxeta,kTRUE);
-  
+  tracker->SetMergerParameters(2,3,0.003,0.1,0.05);
 }
index 1cdc5f9..0cc02ee 100644 (file)
@@ -28,5 +28,5 @@ void SetTrackingParameters(AliLevel3 *tracker)
                           rowscopetracklet,rowscopetrack,
                           min_pt_fit,maxangle,goodDist,hitChi2Cut,
                           goodHitChi2,trackChi2Cut,50,maxphi,maxeta,kTRUE);
-  
+  tracker->SetMergerParameters(2,3,0.003,0.1,0.05);
 }
index 5a6b133..801a99b 100644 (file)
@@ -28,5 +28,5 @@ void SetTrackingParameters(AliLevel3 *tracker)
                           rowscopetracklet,rowscopetrack,
                           min_pt_fit,maxangle,goodDist,hitChi2Cut,
                           goodHitChi2,trackChi2Cut,50,maxphi,maxeta,kTRUE);
-  
+  tracker->SetMergerParameters(2,3,0.003,0.1,0.05);
 }
index ff39f11..900044c 100644 (file)
@@ -28,5 +28,5 @@ void SetTrackingParameters(AliLevel3 *tracker)
                           rowscopetracklet,rowscopetrack,
                           min_pt_fit,maxangle,goodDist,hitChi2Cut,
                           goodHitChi2,trackChi2Cut,50,maxphi,maxeta,kTRUE);
-  
+  tracker->SetMergerParameters(2,3,0.003,0.1,0.05);
 }
index 0112d78..e699ac7 100644 (file)
@@ -28,5 +28,5 @@ void SetTrackingParameters(AliLevel3 *tracker)
                           rowscopetracklet,rowscopetrack,
                           min_pt_fit,maxangle,goodDist,hitChi2Cut,
                           goodHitChi2,trackChi2Cut,50,maxphi,maxeta,kTRUE);
-  
+  tracker->SetMergerParameters(2,3,0.003,0.1,0.05);
 }
index 2cd1f84..1ab340b 100644 (file)
@@ -28,5 +28,5 @@ void SetTrackingParameters(AliLevel3 *tracker)
                           rowscopetracklet,rowscopetrack,
                           min_pt_fit,maxangle,goodDist,hitChi2Cut,
                           goodHitChi2,trackChi2Cut,50,maxphi,maxeta,kTRUE);
-  
+  tracker->SetMergerParameters(2,3,0.003,0.1,0.05);
 }
index ffd5af5..1382d77 100644 (file)
@@ -32,6 +32,7 @@ void runtracker(Int_t minslice=0,Int_t maxslice=35,Char_t* path="./",Int_t neven
   //Set your configuration here:
   AliLevel3::EFileType filetype=AliLevel3::kRoot; //Input is RLE binary files or rootfile.
   Bool_t pileup=kFALSE; //Assume input is pileup event = non RLE binary files.
+  Bool_t nonvertex = kFALSE; //Set this to true if a second nonvertex contrained tracking pass should be performed.
   Int_t npatches = 1;   //Options; 1, 2 and 6.
 #ifdef __CINT__
   Char_t trackparams[] = "SetTrackingParameters_4000bf04.C"; //Set this to correspond 
@@ -95,12 +96,25 @@ void runtracker(Int_t minslice=0,Int_t maxslice=35,Char_t* path="./",Int_t neven
                           rowscopetracklet,rowscopetrack,
                           min_pt_fit,maxangle,goodDist,hitChi2Cut,
                           goodHitChi2,trackChi2Cut,50,maxphi,maxeta,kTRUE);
+      
+      if(nonvertex)
+       {
+         //Set parameters for nonvertextracking
+         a->SetTrackerParam(phi_segments,eta_segments,trackletlength,tracklength,
+                            rowscopetracklet,rowscopetrack,
+                            min_pt_fit,maxangle,goodDist,hitChi2Cut,
+                            goodHitChi2,trackChi2Cut,50,maxphi,maxeta,kFALSE);
+       }
 #endif
 
       if(pileup)
        a->DoPileup();
       //a->DoRoi();    /*do region of interest*/
       //a->DoMc();     /*do monte carlo identification*/
+      
+      if(nonvertex)
+       a->DoNonVertexTracking(); /*2 tracking passes, last without vertex contraint.*/
+      
       a->WriteFiles(opath); /*enable output*/
       a->ProcessEvent(minslice,maxslice);
       Char_t bname[100];
index df7c720..73dec79 100644 (file)
@@ -306,7 +306,7 @@ Double_t AliL3Histogram::GetBinCenterY(Int_t ybin) const
 
 Double_t AliL3Histogram::GetPreciseBinCenterX(Float_t xbin) const
 {
-  if(xbin < fFirstXbin || xbin > fLastXbin)
+  if(xbin < (fFirstXbin-0.5) || xbin > (fLastXbin+0.5))
     {
       LOG(AliL3Log::kError,"AliL3Histogram::GetBinCenterX","xbin")
        <<"Bin-value out of range "<<xbin<<ENDLOG;
@@ -318,7 +318,7 @@ Double_t AliL3Histogram::GetPreciseBinCenterX(Float_t xbin) const
 
 Double_t AliL3Histogram::GetPreciseBinCenterY(Float_t ybin) const
 {
-  if(ybin < fFirstYbin || ybin > fLastYbin)
+  if(ybin < (fFirstYbin-0.5) || ybin > (fLastYbin+0.5))
     {
       LOG(AliL3Log::kError,"AliL3Histogram::GetBinCenterY","ybin")
        <<"Bin-value out of range "<<ybin<<ENDLOG;
index 9618a65..44d24b8 100644 (file)
@@ -3,6 +3,7 @@
 #ifndef ALIL3_HISTOGRAM
 #define ALIL3_HISTOGRAM
 
+#include "AliL3StandardIncludes.h"
 #include "AliL3RootTypes.h"
 #include "AliL3StandardIncludes.h"
 
index 5cb48ba..97e50b4 100644 (file)
@@ -96,6 +96,9 @@ AliL3Hough::AliL3Hough()
 #ifdef use_aliroot
   //just be sure that index is empty for new event
     AliL3FileHandler::CleanStaticIndex(); 
+#ifdef use_newio
+    fRunLoader = 0;
+#endif
 #endif
 }
 
@@ -128,6 +131,9 @@ AliL3Hough::AliL3Hough(Char_t *path,Bool_t binary,Int_t n_eta_segments,Bool_t bi
 #ifdef use_aliroot
   //just be sure that index is empty for new event
     AliL3FileHandler::CleanStaticIndex(); 
+#ifdef use_newio
+    fRunLoader = 0;
+#endif
 #endif
 }
 
@@ -243,7 +249,8 @@ void AliL3Hough::Init(Bool_t doit, Bool_t addhists)
        fHoughTransformer[i] = new AliL3HoughTransformer(0,i,fNEtaSegments,kFALSE,kFALSE);
       }
 
-      fHoughTransformer[i]->CreateHistograms(fNBinX[i],fLowPt[i],fNBinY[i],-fPhi[i],fPhi[i]);
+      //      fHoughTransformer[i]->CreateHistograms(fNBinX[i],fLowPt[i],fNBinY[i],-fPhi[i],fPhi[i]);
+      fHoughTransformer[i]->CreateHistograms(fNBinX[i],-fLowPt[i],fLowPt[i],fNBinY[i],-fPhi[i],fPhi[i]);
       //fHoughTransformer[i]->CreateHistograms(fLowPt[i],fUpperPt[i],fPtRes[i],fNBinY[i],fPhi[i]);
 
       fHoughTransformer[i]->SetLowerThreshold(fThreshold[i]);
@@ -264,9 +271,18 @@ void AliL3Hough::Init(Bool_t doit, Bool_t addhists)
              /* In case of reading digits file */
              fMemHandler[i] = new AliL3FileHandler(kTRUE); //use static index
              if(!fBinary) {
-               Char_t filename[1024];
-               sprintf(filename,"%s/digitfile.root",fPath);
-               fMemHandler[i]->SetAliInput(filename);
+#if use_newio
+               if(!fRunLoader) {
+#endif
+                 Char_t filename[1024];
+                 sprintf(filename,"%s/digitfile.root",fPath);
+                 fMemHandler[i]->SetAliInput(filename);
+#if use_newio
+               }
+               else {
+                 fMemHandler[i]->SetAliInput(fRunLoader);
+               }
+#endif
              }
            }
            else {
@@ -286,7 +302,7 @@ void AliL3Hough::Init(Bool_t doit, Bool_t addhists)
 #endif
     }
 
-  fPeakFinder = new AliL3HoughMaxFinder("KappaPhi",1000);
+  fPeakFinder = new AliL3HoughMaxFinder("KappaPhi",50000);
   fMerger = new AliL3HoughMerger(fNPatches);
   fInterMerger = new AliL3HoughIntMerger();
   fGlobalMerger = 0;
@@ -332,7 +348,7 @@ void AliL3Hough::SetTransformerParams(Float_t ptres,Float_t ptmin,Float_t ptmax,
   fNBinY[patch] = ny;
   fPhi[patch] = psi;
 }
-
+/*
 void AliL3Hough::SetTransformerParams(Int_t nx,Int_t ny,Float_t ptmin,Int_t patch)
 {
 
@@ -352,6 +368,36 @@ void AliL3Hough::SetTransformerParams(Int_t nx,Int_t ny,Float_t ptmin,Int_t patc
       i++;
     }
 }
+*/
+void AliL3Hough::SetTransformerParams(Int_t nx,Int_t ny,Float_t ptmin,Int_t patch)
+{
+
+
+  Int_t mrow=79;
+  Double_t lineradius = sqrt(pow(AliL3Transform::Row2X(mrow),2) + pow(AliL3Transform::GetMaxY(mrow),2));
+  Double_t alpha1 = AliL3Transform::GetMaxY(mrow)/pow(lineradius,2);
+  Double_t kappa = 1*AliL3Transform::GetBField()*AliL3Transform::GetBFact()/ptmin;
+  Double_t psi = AliL3Transform::Deg2Rad(10) - asin(lineradius*kappa/2);
+  cout<<"Calculated psi range "<<psi<<" in patch "<<patch<<endl;
+  AliL3HoughTrack track;
+  track.SetTrackParameters(kappa,psi,1);
+  Float_t hit[3];
+  Int_t mrow2 = 158;
+  track.GetCrossingPoint(mrow2,hit);
+  Double_t lineradius2 = sqrt(pow(AliL3Transform::Row2X(mrow2),2) + pow(AliL3Transform::GetMaxY(mrow2),2));
+  Double_t alpha2 = hit[1]/pow(lineradius2,2);
+  cout<<"Calculated alphas range "<<alpha1<<" "<<alpha2<<" in patch "<<patch<<endl;
+
+  Int_t i=0;
+  while(i < 6)
+    {
+      fLowPt[i] = 1.15*alpha1;
+      fNBinY[i] = ny;
+      fNBinX[i] = nx;
+      fPhi[i] = 1.15*alpha2;
+      i++;
+    }
+}
 
 void AliL3Hough::SetTransformerParams(Int_t nx,Int_t ny,Float_t lpt,Float_t phi)
 {
@@ -635,10 +681,15 @@ void AliL3Hough::AddAllHistogramsRows()
   initTime = GetCpuTime();
   fBenchmark->Start("Add HistogramsRows");
 
+  UChar_t *tracknrows = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetTrackNRows();
+  UChar_t *trackfirstrow = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetTrackFirstRow();
+  UChar_t *tracklastrow = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetTrackLastRow();
+
   for(Int_t i=0; i<fNEtaSegments; i++)
     {
       UChar_t *rowcount = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetRowCount(i);
       UChar_t *gapcount = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetGapCount(i);
+      UChar_t *currentrowcount = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetCurrentRowCount(i);
 
       AliL3Histogram *hist = fHoughTransformer[0]->GetHistogram(i);
       Int_t xmin = hist->GetFirstXbin();
@@ -651,9 +702,12 @@ void AliL3Hough::AddAllHistogramsRows()
          for(Int_t xbin=xmin; xbin<=xmax; xbin++)
            {
              Int_t bin = hist->GetBin(xbin,ybin);
-             if(gapcount[bin] < 3)
-               //              hist->AddBinContent(bin,rowcount[bin]);
-               hist->AddBinContent(bin,rowcount[bin]/gapcount[bin]);
+             if(tracklastrow[bin] > (currentrowcount[bin] + 1))
+                gapcount[bin]++;
+             if(gapcount[bin] < MAX_N_GAPS)
+               if(rowcount[bin] >= MIN_TRACK_LENGTH)
+                 if(((Int_t)rowcount[bin] + (Int_t)gapcount[bin])>=((Int_t)tracknrows[bin]-MAX_MISS_ROWS))
+                   hist->AddBinContent(bin,(rowcount[bin]+trackfirstrow[bin]+159-tracklastrow[bin]));
            }
        }
     }
@@ -685,10 +739,87 @@ void AliL3Hough::AddTracks()
   fGlobalTracks->AddTracks(fTracks[0],0,fCurrentSlice);
 }
 
-void AliL3Hough::FindTrackCandidates()
+void AliL3Hough::FindTrackCandidatesRow()
 {
+  if(fVersion != 4) {
+    LOG(AliL3Log::kError,"AliL3Hough::FindTrackCandidatesRow()","")
+      <<"Incompatible Peak Finder version!"<<ENDLOG;
+    return;
+  }
+
   //Look for peaks in histograms, and find the track candidates
+  Int_t n_patches;
+  if(fAddHistograms)
+    n_patches = 1; //Histograms have been added.
+  else
+    n_patches = fNPatches;
+  
+  Double_t initTime,cpuTime;
+  initTime = GetCpuTime();
+  fBenchmark->Start("Find Maxima");
+  for(Int_t i=0; i<n_patches; i++)
+    {
+      AliL3HoughBaseTransformer *tr = fHoughTransformer[i];
+      fTracks[i]->Reset();
+      fPeakFinder->Reset();
+      
+      for(Int_t j=0; j<fNEtaSegments; j++)
+       {
+         AliL3Histogram *hist = tr->GetHistogram(j);
+         if(hist->GetNEntries()==0) continue;
+         fPeakFinder->SetHistogram(hist);
+         fPeakFinder->SetEtaSlice(j);
+#ifdef do_mc
+         LOG(AliL3Log::kInformational,"AliL3Hough::FindTrackCandidates()","")
+           <<"Starting "<<j<<" etaslice"<<ENDLOG;
+#endif
+         fPeakFinder->SetThreshold(fPeakThreshold[i]);
+         fPeakFinder->FindAdaptedRowPeaks(1,0,0);//Maxima finder for HoughTransformerRow
+
+         //fPeakFinder->FindMaxima(fPeakThreshold[i]); //Simple maxima finder
+       }
   
+      for(Int_t k=0; k<fPeakFinder->GetEntries(); k++)
+       {
+         if(fPeakFinder->GetWeight(k) < 0) continue;
+         AliL3HoughTrack *track = (AliL3HoughTrack*)fTracks[i]->NextTrack();
+         Float_t psi = atan((fPeakFinder->GetXPeak(k)-fPeakFinder->GetYPeak(k))/(AliL3HoughTransformerRow::GetBeta1()-AliL3HoughTransformerRow::GetBeta2()));
+         Float_t kappa = 2.0*(fPeakFinder->GetXPeak(k)*cos(psi)-AliL3HoughTransformerRow::GetBeta1()*sin(psi));
+         //          track->SetTrackParameters(fPeakFinder->GetXPeak(k),fPeakFinder->GetYPeak(k),fPeakFinder->GetWeight(k));
+         track->SetTrackParameters(kappa,psi,fPeakFinder->GetWeight(k));
+         track->SetBinXY(fPeakFinder->GetXPeak(k),fPeakFinder->GetYPeak(k),fPeakFinder->GetXPeakSize(k),fPeakFinder->GetYPeakSize(k));
+         Int_t etaindex = (fPeakFinder->GetStartEta(k)+fPeakFinder->GetEndEta(k))/2;
+         track->SetEtaIndex(etaindex);
+         Float_t starteta = tr->GetEta(fPeakFinder->GetStartEta(k),fCurrentSlice);
+         Float_t endeta = tr->GetEta(fPeakFinder->GetEndEta(k),fCurrentSlice);
+         track->SetEta((starteta+endeta)/2.0);
+         track->SetRowRange(AliL3Transform::GetFirstRow(0),AliL3Transform::GetLastRow(5));
+         track->SetSector(fCurrentSlice);
+         track->SetSlice(fCurrentSlice);
+#ifdef do_mc
+         Int_t label = tr->GetTrackID(etaindex,fPeakFinder->GetXPeak(k),fPeakFinder->GetYPeak(k));
+         track->SetMCid(label);
+         //      cout<<"Track found with label "<<label<<" at "<<fPeakFinder->GetXPeak(k)<<" "<<fPeakFinder->GetYPeak(k)<<" with weight "<<fPeakFinder->GetWeight(k)<<endl; 
+#endif
+       }
+      LOG(AliL3Log::kInformational,"AliL3Hough::FindTrackCandidates()","")
+       <<"Found "<<fTracks[i]->GetNTracks()<<" tracks in patch "<<i<<ENDLOG;
+      fTracks[i]->QSort();
+    }
+  fBenchmark->Stop("Find Maxima");
+  cpuTime = GetCpuTime() - initTime;
+  LOG(AliL3Log::kInformational,"AliL3Hough::FindTrackCandidates()","Timing")
+    <<"Maxima finding done in "<<cpuTime*1000<<" ms"<<ENDLOG;
+}
+
+void AliL3Hough::FindTrackCandidates()
+{
+  if(fVersion == 4) {
+    LOG(AliL3Log::kError,"AliL3Hough::FindTrackCandidatesRow()","")
+      <<"Incompatible Peak Finder version!"<<ENDLOG;
+    return;
+  }
+
   Int_t n_patches;
   if(fAddHistograms)
     n_patches = 1; //Histograms have been added.
@@ -709,14 +840,11 @@ void AliL3Hough::FindTrackCandidates()
          if(hist->GetNEntries()==0) continue;
          fPeakFinder->Reset();
          fPeakFinder->SetHistogram(hist);
-
+#ifdef do_mc
+         cout<<"Starting "<<j<<" etaslice"<<endl;
+#endif
          fPeakFinder->SetThreshold(fPeakThreshold[i]);
-         if(fVersion != 4) {
-           fPeakFinder->FindAdaptedPeaks(fKappaSpread,fPeakRatio);
-           //fPeakFinder->FindMaxima(fPeakThreshold[i]); //Simple maxima finder
-         }
-         else /* row transformer needs different peak finder method */
-           fPeakFinder->FindAdaptedRowPeaks(1,2,0);
+         fPeakFinder->FindAdaptedPeaks(fKappaSpread,fPeakRatio);
          
          for(Int_t k=0; k<fPeakFinder->GetEntries(); k++)
            {
@@ -725,11 +853,6 @@ void AliL3Hough::FindTrackCandidates()
              track->SetEtaIndex(j);
              track->SetEta(tr->GetEta(j,fCurrentSlice));
              track->SetRowRange(AliL3Transform::GetFirstRow(0),AliL3Transform::GetLastRow(5));
-#ifdef do_mc
-             Int_t label = tr->GetTrackID(j,fPeakFinder->GetXPeak(k),fPeakFinder->GetYPeak(k));
-             track->SetMCid(label);
-             cout<<"Track found with label "<<label<<" at "<<fPeakFinder->GetXPeak(k)<<" "<<fPeakFinder->GetYPeak(k)<<" with weight "<<fPeakFinder->GetWeight(k)<<endl; 
-#endif
            }
        }
       cout<<"Found "<<fTracks[i]->GetNTracks()<<" tracks in patch "<<i<<endl;
index 519e3a0..924eb63 100644 (file)
@@ -17,6 +17,10 @@ class AliL3HoughIntMerger;
 class AliL3HoughGlobalMerger;
 class AliL3Benchmark;
 
+#ifdef use_newio
+#include <AliRunLoader.h>
+#endif
+
 class AliL3Hough {
   
  private:
@@ -61,6 +65,10 @@ class AliL3Hough {
   AliL3HoughGlobalMerger *fGlobalMerger; //!
   AliL3Benchmark *fBenchmark; //!
 
+#ifdef use_newio
+  AliRunLoader *fRunLoader;
+#endif
+
   void CleanUp();
   Double_t GetCpuTime();
   
@@ -69,7 +77,11 @@ class AliL3Hough {
   AliL3Hough(); 
   AliL3Hough(Char_t *path,Bool_t binary,Int_t n_eta_segments=100,Bool_t bit8=kFALSE,Int_t tv=0,Char_t *infile=0,Char_t *ptr=0);
   virtual ~AliL3Hough();
-  
+
+#ifdef use_newio  
+  void SetRunLoader(AliRunLoader *runloader) {fRunLoader = runloader;}
+#endif
+
   void Init(Char_t *path,Bool_t binary,Int_t n_eta_segments=100,Bool_t bit8=kFALSE,Int_t tv=0,Char_t *infile=0,Char_t *ptr=0,Float_t zvertex=0.0);
   void Init(Bool_t doit=kFALSE, Bool_t addhists=kFALSE);
 
@@ -83,6 +95,7 @@ class AliL3Hough {
   void MergeEtaSlices();
 
   void FindTrackCandidates();
+  void FindTrackCandidatesRow();
   void AddAllHistograms();
   void AddAllHistogramsRows();
   Int_t Evaluate(Int_t road_width=1,Int_t nrowstomiss=1);
index 58c6c2d..47902a3 100644 (file)
@@ -9,12 +9,8 @@
 const UInt_t MaxTrack=100;
 struct TrackIndex {
   Int_t fLabel[MaxTrack];
-#ifdef ROWHOUGH
   UChar_t fNHits[MaxTrack];
   UChar_t fCurrentRow[MaxTrack];
-#else
-  Int_t fNHits[MaxTrack];
-#endif
 };
 typedef struct TrackIndex TrackIndex;
 #endif
index c4b9c89..17ad2b5 100644 (file)
@@ -16,6 +16,8 @@
 #include "AliL3Histogram.h"
 #include "AliL3TrackArray.h"
 #include "AliL3HoughTrack.h"
+#include "AliL3Transform.h"
+#include "AliL3HoughTransformerRow.h"
 
 #if __GNUC__ == 3
 using namespace std;
@@ -38,10 +40,20 @@ AliL3HoughMaxFinder::AliL3HoughMaxFinder()
 {
   //Default constructor
   fThreshold = 0;
+  fCurrentEtaSlice = -1;
   fHistoType=0;
   fXPeaks=0;
   fYPeaks=0;
+  fWeight=0;
   fNPeaks=0;
+  fN1PeaksPrevEtaSlice=0;
+  fN2PeaksPrevEtaSlice=0;
+  fSTARTXPeaks=0;
+  fSTARTYPeaks=0;
+  fENDXPeaks=0;
+  fENDYPeaks=0;
+  fSTARTETAPeaks=0;
+  fENDETAPeaks=0;
   fNMax=0;
   fGradX=1;
   fGradY=1;
@@ -57,6 +69,8 @@ AliL3HoughMaxFinder::AliL3HoughMaxFinder(Char_t *histotype,Int_t nmax,AliL3Histo
   //fTracks = new AliL3TrackArray("AliL3HoughTrack");
   if(strcmp(histotype,"KappaPhi")==0) fHistoType='c';
   if(strcmp(histotype,"DPsi")==0) fHistoType='l';
+
+  fCurrentEtaSlice = -1;
   
   if(hist)
     fCurrentHisto = hist;
@@ -67,6 +81,12 @@ AliL3HoughMaxFinder::AliL3HoughMaxFinder(Char_t *histotype,Int_t nmax,AliL3Histo
   fXPeaks = new Float_t[fNMax];
   fYPeaks = new Float_t[fNMax];
   fWeight = new Int_t[fNMax];
+  fSTARTXPeaks = new Int_t[fNMax];
+  fSTARTYPeaks = new Int_t[fNMax];
+  fENDXPeaks = new Int_t[fNMax];
+  fENDYPeaks = new Int_t[fNMax];
+  fSTARTETAPeaks = new Int_t[fNMax];
+  fENDETAPeaks = new Int_t[fNMax];
 #ifndef no_root
   fNtuppel = 0;
 #endif
@@ -82,6 +102,18 @@ AliL3HoughMaxFinder::~AliL3HoughMaxFinder()
     delete [] fYPeaks;
   if(fWeight)
     delete [] fWeight;
+  if(fSTARTXPeaks)
+    delete [] fSTARTXPeaks;
+  if(fSTARTYPeaks)
+    delete [] fSTARTYPeaks;
+  if(fENDXPeaks)
+    delete [] fENDXPeaks;
+  if(fENDYPeaks)
+    delete [] fENDYPeaks;
+  if(fSTARTETAPeaks)
+    delete [] fSTARTETAPeaks;
+  if(fENDETAPeaks)
+    delete [] fENDETAPeaks;
 #ifndef no_root
   if(fNtuppel)
     delete fNtuppel;
@@ -95,8 +127,16 @@ void AliL3HoughMaxFinder::Reset()
       fXPeaks[i]=0;
       fYPeaks[i]=0;
       fWeight[i]=0;
+      fSTARTXPeaks[i]=0;
+      fSTARTYPeaks[i]=0;
+      fENDXPeaks[i]=0;
+      fENDYPeaks[i]=0;
+      fSTARTETAPeaks[i]=0;
+      fENDETAPeaks[i]=0;
     }
   fNPeaks=0;
+  fN1PeaksPrevEtaSlice=0;
+  fN2PeaksPrevEtaSlice=0;
 }
 
 void AliL3HoughMaxFinder::CreateNtuppel()
@@ -626,20 +666,27 @@ struct PreYPeak
 {
   Int_t start_position;
   Int_t end_position;
-  Int_t value;
+  Int_t min_value;
+  Int_t max_value;
   Int_t prev_value;
+  Int_t left_value;
+  Int_t right_value;
 };
 
-struct Pre2DPeak 
+struct Pre2DPeak
 {
-  Int_t start_x_position;
-  Int_t end_x_position;
-  Int_t start_y_position;
-  Int_t end_y_position;
-  Int_t value;
+  Float_t x;
+  Float_t y;
+  Float_t size_x;
+  Float_t size_y;
+  Int_t start_x;
+  Int_t start_y;
+  Int_t end_x;
+  Int_t end_y;
+  Float_t weight;
 };
 
-void AliL3HoughMaxFinder::FindAdaptedRowPeaks(Int_t kappawindow,Int_t /*xsize*/,Int_t ysize)
+void AliL3HoughMaxFinder::FindAdaptedRowPeaks(Int_t kappawindow,Int_t xsize,Int_t ysize)
 {
   
   AliL3Histogram *hist = fCurrentHisto;
@@ -663,8 +710,7 @@ void AliL3HoughMaxFinder::FindAdaptedRowPeaks(Int_t kappawindow,Int_t /*xsize*/,
   PreYPeak **local_maxima = new PreYPeak*[hist->GetNbinsY()];
   
   Short_t *nmaxs = new Short_t[hist->GetNbinsY()];
-  Int_t n2dmax = 0;
-  Int_t last_value,value;
+  Int_t last_value=0,value=0;
   for(Int_t ybin=ymin; ybin<=ymax; ybin++)
     {
       local_maxima[ybin-ymin] = new PreYPeak[hist->GetNbinsX()];
@@ -674,48 +720,55 @@ void AliL3HoughMaxFinder::FindAdaptedRowPeaks(Int_t kappawindow,Int_t /*xsize*/,
       for(Int_t xbin=xmin; xbin<=xmax; xbin++)
        {
          value = hist->GetBinContent(hist->GetBin(xbin,ybin));
-         if(value >= fThreshold)
+         if(value > 0)
            {
-             if(value > last_value)
-             //              if(value > (last_value + 1))
+             if(abs(value - last_value) > 1)
                {
+                 if(found) {
+                   local_maxima[ybin-ymin][nmaxs[ybin-ymin]].right_value = value;
+                   nmaxs[ybin-ymin]++;
+                 }
                  local_maxima[ybin-ymin][nmaxs[ybin-ymin]].start_position = xbin;
                  local_maxima[ybin-ymin][nmaxs[ybin-ymin]].end_position = xbin;
-                 local_maxima[ybin-ymin][nmaxs[ybin-ymin]].value = value;
+                 local_maxima[ybin-ymin][nmaxs[ybin-ymin]].min_value = value;
+                 local_maxima[ybin-ymin][nmaxs[ybin-ymin]].max_value = value;
                  local_maxima[ybin-ymin][nmaxs[ybin-ymin]].prev_value = 0;
+                 local_maxima[ybin-ymin][nmaxs[ybin-ymin]].left_value = last_value;
                  found = 1;
                }
-             if(value == last_value)
-               //            if(abs(value - last_value) <= 1)
-               if(found)
-                 local_maxima[ybin-ymin][nmaxs[ybin-ymin]].end_position = xbin;
-           }
-
-         if((value < fThreshold) || (value < last_value))
-           //    if((value < fThreshold) || (value < (last_value - 1)))
-           {
-             if(found)
+             if(abs(value - last_value) <= 1)
                {
-                 nmaxs[ybin-ymin]++;
-                 found = 0;
+                   local_maxima[ybin-ymin][nmaxs[ybin-ymin]].end_position = xbin;
+                   if(value>local_maxima[ybin-ymin][nmaxs[ybin-ymin]].max_value)
+                     local_maxima[ybin-ymin][nmaxs[ybin-ymin]].max_value = value;
+                   if(value<local_maxima[ybin-ymin][nmaxs[ybin-ymin]].min_value)
+                     local_maxima[ybin-ymin][nmaxs[ybin-ymin]].min_value = value;
                }
            }
          last_value = value;
              
        }
-      n2dmax += nmaxs[ybin-ymin];
+      if(found) {
+       local_maxima[ybin-ymin][nmaxs[ybin-ymin]].right_value = value;
+       nmaxs[ybin-ymin]++;
+      }
     }
   
-  //  Pre2DPeak *maxima = new Pre2DPeak[n2dmax];
+  Pre2DPeak maxima[500];
+  Int_t nmaxima = 0;
+
   for(Int_t ybin=ymax; ybin >= ymin; ybin--)
     {
       for(Int_t i=0; i<nmaxs[ybin-ymin]; i++)
        {
-         Int_t local_value = local_maxima[ybin-ymin][i].value;
+         Int_t local_min_value = local_maxima[ybin-ymin][i].min_value;
+         Int_t local_max_value = local_maxima[ybin-ymin][i].max_value;
          Int_t local_prev_value = local_maxima[ybin-ymin][i].prev_value;
          Int_t local_next_value = 0;
+         Int_t local_left_value = local_maxima[ybin-ymin][i].left_value;
+         Int_t local_right_value = local_maxima[ybin-ymin][i].right_value;
 
-         if(local_value<0)
+         if(local_min_value<0)
            continue; //already used
 
          //start expanding in the psi-direction:
@@ -726,69 +779,63 @@ void AliL3HoughMaxFinder::FindAdaptedRowPeaks(Int_t kappawindow,Int_t /*xsize*/,
          Int_t temp_x_end = local_maxima[ybin-ymin][i].end_position;
 
          Int_t local_y=ybin-1,nybins=1;
-         
+
          while(local_y >= ymin)
            {
              Bool_t found=0;
              for(Int_t j=0; j<nmaxs[local_y-ymin]; j++)
                {
-                 Int_t adapted_kappawindow;
-                 Float_t adapted_x,adapted_y;
-                 adapted_x = ((Float_t)local_x_start+(Float_t)local_x_end)/2.0;
-                 adapted_y = ((Float_t)ybin+(Float_t)(local_y+1))/2.0;
-                 //              if(adapted_y<(-0.46*adapted_x+86) && adapted_y>(-0.46*adapted_x+56) && adapted_y<(-0.215*adapted_x+68) && adapted_y>(-0.215*adapted_x+40))
-                 //              if(adapted_y<(-0.215*adapted_x+68) && adapted_y>(-0.215*adapted_x+40))
-                 //              if((adapted_y<(-0.46*adapted_x+86) && adapted_y>(-0.46*adapted_x+56)) && !(adapted_y<(-0.215*adapted_x+68) && adapted_y>(-0.215*adapted_x+40)))
-                 if(((adapted_y<(-0.46*adapted_x+86) && adapted_y>(-0.46*adapted_x+56)) && !(adapted_y<(-0.215*adapted_x+68) && adapted_y>(-0.215*adapted_x+40))) || 
-                    ((adapted_y<(-0.215*adapted_x+68) && adapted_y>(-0.215*adapted_x+40))&& !(adapted_y<(-0.46*adapted_x+86) && adapted_y>(-0.46*adapted_x+56))))
-                   adapted_kappawindow = 1;
-                 else
-                   adapted_kappawindow = 0;
-                 //temprorary here
-                 //              adapted_kappawindow = 0;
-                 
-                 if( (local_maxima[local_y-ymin][j].start_position <= (temp_x_end + kappawindow + adapted_kappawindow)) && (local_maxima[local_y-ymin][j].end_position >= temp_x_start)) 
+                 if( (local_maxima[local_y-ymin][j].start_position <= (temp_x_end + kappawindow)) && (local_maxima[local_y-ymin][j].end_position >= (temp_x_start - kappawindow))) 
                    {
-                     if( local_maxima[local_y-ymin][j].value == local_value )
+                     if(((local_maxima[local_y-ymin][j].min_value <= local_max_value) && (local_maxima[local_y-ymin][j].min_value >= local_min_value)) ||
+                        ((local_maxima[local_y-ymin][j].max_value >= local_min_value) && (local_maxima[local_y-ymin][j].max_value <= local_max_value)))
                        {
-                         local_x_end = local_maxima[local_y-ymin][j].end_position;
+                         if(local_maxima[local_y-ymin][j].end_position > local_x_end)
+                           local_x_end = local_maxima[local_y-ymin][j].end_position;
+                         if(local_maxima[local_y-ymin][j].start_position < local_x_start)
+                           local_x_start = local_maxima[local_y-ymin][j].start_position;
                          temp_x_start = local_maxima[local_y-ymin][j].start_position;
                          temp_x_end = local_maxima[local_y-ymin][j].end_position;
-                         local_maxima[local_y-ymin][j].value = -1;
+                         if(local_maxima[local_y-ymin][j].min_value < local_min_value)
+                           local_min_value = local_maxima[local_y-ymin][j].min_value;
+                         if(local_maxima[local_y-ymin][j].max_value > local_max_value)
+                           local_max_value = local_maxima[local_y-ymin][j].max_value;
+                         if(local_maxima[local_y-ymin][j].right_value > local_right_value)
+                           local_right_value = local_maxima[local_y-ymin][j].right_value;
+                         if(local_maxima[local_y-ymin][j].left_value > local_left_value)
+                           local_left_value = local_maxima[local_y-ymin][j].left_value;
+                         local_maxima[local_y-ymin][j].min_value = -1;
                          found = 1;
                          nybins++;
                          break;
                        }
                      else
                        {
-                         local_maxima[local_y-ymin][j].prev_value = local_value;
-                         local_next_value = local_maxima[local_y-ymin][j].value;
+                         if(local_max_value > local_maxima[local_y-ymin][j].prev_value)
+                           local_maxima[local_y-ymin][j].prev_value = local_max_value;
+                         if(local_maxima[local_y-ymin][j].max_value > local_next_value)
+                           local_next_value = local_maxima[local_y-ymin][j].max_value;
                        }
                    }
                }
              if(!found || local_y == ymin)//no more local maximas to be matched, so write the final peak and break the expansion:
                {
-                 Int_t adapted_xsize;
-                 Float_t adapted_x,adapted_y;
-                 adapted_x = ((Float_t)local_x_start+(Float_t)local_x_end)/2.0;
-                 adapted_y = ((Float_t)ybin+(Float_t)(local_y+1))/2.0;
-                 //              if(adapted_y<(-0.46*adapted_x+86) && adapted_y>(-0.46*adapted_x+56) && adapted_y<(-0.215*adapted_x+68) && adapted_y>(-0.215*adapted_x+40))
-                 //              if(adapted_y<(-0.215*adapted_x+68) && adapted_y>(-0.215*adapted_x+40))
-                 if((adapted_y<(-0.46*adapted_x+86) && adapted_y>(-0.46*adapted_x+56)) && !(adapted_y<(-0.215*adapted_x+68) && adapted_y>(-0.215*adapted_x+40)))
-                   adapted_xsize = 1;
-                 else
-                   adapted_xsize = 2;
-                 //temprorary here
-                 //              adapted_xsize = 1;
-                 if((nybins > ysize) && ((local_x_end-local_x_start+1) > adapted_xsize) && (local_value > local_prev_value) && (local_value > local_next_value))
+                 if((nybins > ysize) && ((local_x_end-local_x_start+1) > xsize) && (local_max_value > local_prev_value) && (local_max_value > local_next_value) && (local_max_value > local_left_value) && (local_max_value > local_right_value))
+                 //              if((nybins > ysize) && ((local_x_end-local_x_start+1) > xsize))
                    {
-                     fXPeaks[fNPeaks] = hist->GetPreciseBinCenterX(adapted_x);
-                     fYPeaks[fNPeaks] = hist->GetPreciseBinCenterY(adapted_y);
-                     fWeight[fNPeaks] = local_value;
+                     maxima[nmaxima].x = ((Float_t)local_x_start+(Float_t)local_x_end)/2.0;
+                     maxima[nmaxima].y = ((Float_t)ybin+(Float_t)(local_y+1))/2.0;
+                     maxima[nmaxima].size_x = local_x_end-local_x_start+1;
+                     maxima[nmaxima].size_y = nybins;
+                     maxima[nmaxima].weight = (local_min_value+local_max_value)/2;
+                     maxima[nmaxima].start_x = local_x_start;
+                     maxima[nmaxima].end_x = local_x_end;
+                     maxima[nmaxima].start_y = local_y +1;
+                     maxima[nmaxima].end_y = ybin;
 #ifdef do_mc
-                     cout<<"Peak found at: "<<((Float_t)local_x_start+(Float_t)local_x_end)/2.0<<" "<<((Float_t)ybin+(Float_t)(local_y+1))/2.0<<" "<<fXPeaks[fNPeaks]<<" "<<fYPeaks[fNPeaks]<<" with weight "<<fWeight[fNPeaks]<<" and size "<<local_x_end-local_x_start+1<<" by "<<nybins<<endl;
+                     //                      cout<<"Peak found at: "<<((Float_t)local_x_start+(Float_t)local_x_end)/2.0<<" "<<((Float_t)ybin+(Float_t)(local_y+1))/2.0<<" "<<local_min_value<<" "<<local_max_value<<" "<<" with weight "<<(local_min_value+local_max_value)/2<<" and size "<<local_x_end-local_x_start+1<<" by "<<nybins<<endl;
 #endif
-                     fNPeaks++;
+                     nmaxima++;
                    }
                  break;
                }
@@ -798,12 +845,154 @@ void AliL3HoughMaxFinder::FindAdaptedRowPeaks(Int_t kappawindow,Int_t /*xsize*/,
        }
     }
 
+  //remove fake tracks
+  Int_t nxbins = hist->GetNbinsX()+2;
+  
+  for(Int_t i = 0; i < (nmaxima - 1); i++)
+    {
+      if(maxima[i].weight < 0) continue;
+      for(Int_t j = i + 1; j < nmaxima; j++)
+       {
+         if(maxima[j].weight < 0) continue;
+         Int_t xtrack1=0,xtrack2=0,ytrack1=0,ytrack2=0;
+         Int_t deltax = 9999;
+         for(Int_t ix1 = maxima[i].start_x; ix1 <= maxima[i].end_x; ix1++) {
+           for(Int_t ix2 = maxima[j].start_x; ix2 <= maxima[j].end_x; ix2++) {
+             if(abs(ix1 - ix2) < deltax) {
+               deltax = abs(ix1 - ix2);
+               xtrack1 = ix1;
+               xtrack2 = ix2;
+             }
+           }
+         }
+         Int_t deltay = 9999;
+         for(Int_t iy1 = maxima[i].start_y; iy1 <= maxima[i].end_y; iy1++) {
+           for(Int_t iy2 = maxima[j].start_y; iy2 <= maxima[j].end_y; iy2++) {
+             if(abs(iy1 - iy2) < deltay) {
+               deltay = abs(iy1 - iy2);
+               ytrack1 = iy1;
+               ytrack2 = iy2;
+             }
+           }
+         }
+         Int_t firstrow1 = AliL3HoughTransformerRow::GetTrackFirstRow()[xtrack1 + nxbins*ytrack1];
+         Int_t lastrow1 = AliL3HoughTransformerRow::GetTrackLastRow()[xtrack1 + nxbins*ytrack1];
+         Int_t firstrow2 = AliL3HoughTransformerRow::GetTrackFirstRow()[xtrack1 + nxbins*ytrack1];
+         Int_t lastrow2 = AliL3HoughTransformerRow::GetTrackLastRow()[xtrack1 + nxbins*ytrack1];
+         Int_t firstrow,lastrow;
+         if(firstrow1 < firstrow2)
+           firstrow = firstrow2;
+         else
+           firstrow = firstrow1;
+
+         if(lastrow1 > lastrow2)
+           lastrow = lastrow2;
+         else
+           lastrow = lastrow1;
+        
+         AliL3HoughTrack track1;
+         Float_t x1 = hist->GetPreciseBinCenterX(xtrack1);
+         Float_t y1 = hist->GetPreciseBinCenterY(ytrack1);
+         Float_t psi1 = atan((x1-y1)/(AliL3HoughTransformerRow::GetBeta1()-AliL3HoughTransformerRow::GetBeta2()));
+         Float_t kappa1 = 2.0*(x1*cos(psi1)-AliL3HoughTransformerRow::GetBeta1()*sin(psi1));
+         track1.SetTrackParameters(kappa1,psi1,1);
+         Float_t firsthit1[3];
+         if(!track1.GetCrossingPoint(firstrow,firsthit1)) continue;
+         Float_t lasthit1[3];
+         if(!track1.GetCrossingPoint(lastrow,lasthit1)) continue;
+
+         AliL3HoughTrack track2;
+         Float_t x2 = hist->GetPreciseBinCenterX(xtrack2);
+         Float_t y2 = hist->GetPreciseBinCenterY(ytrack2);
+         Float_t psi2 = atan((x2-y2)/(AliL3HoughTransformerRow::GetBeta1()-AliL3HoughTransformerRow::GetBeta2()));
+         Float_t kappa2 = 2.0*(x2*cos(psi2)-AliL3HoughTransformerRow::GetBeta1()*sin(psi2));
+         track2.SetTrackParameters(kappa2,psi2,1);
+         Float_t firsthit2[3];
+         if(!track2.GetCrossingPoint(firstrow,firsthit2)) continue;
+         Float_t lasthit2[3];
+         if(!track2.GetCrossingPoint(lastrow,lasthit2)) continue;
+         
+         Float_t padpitchlow = AliL3Transform::GetPadPitchWidth(AliL3Transform::GetPatch(firstrow));
+         Float_t padpitchup = AliL3Transform::GetPadPitchWidth(AliL3Transform::GetPatch(lastrow));
+         // check the distance between tracks at the edges
+#ifdef do_mc
+         //      cout<<"DEBUG Merge peaks "<<i<<" "<<j<<" "<<firsthit1[1]<<" "<<firsthit2[1]<<"     "<<lasthit1[1]<<" "<<lasthit2[1]<<endl;
+#endif
+         //cvetan please check!!! I added a cast to Int_t
+         if((fabs(firsthit1[1]-firsthit2[1]) < 3.0*padpitchlow) && (fabs(lasthit1[1]-lasthit2[1]) < 3.0*padpitchup)) {
+           if(maxima[i].size_x*maxima[i].size_y > maxima[j].size_x*maxima[j].size_y)
+             maxima[j].weight = -maxima[j].weight;
+           if(maxima[i].size_x*maxima[i].size_y < maxima[j].size_x*maxima[j].size_y)
+             maxima[i].weight = -maxima[i].weight;
+#ifdef do_mc
+           //      cout<<"Merge peaks "<<i<<" "<<j<<" "<<maxima[i].weight<<" "<<maxima[j].weight<<endl;
+#endif
+         }
+       }
+    }
+
+  //merge tracks in neighbour eta slices
+  /*
+  for(Int_t i = 0; i < nmaxima; i++) {
+    if(maxima[i].weight > 0) {
+      fXPeaks[fNPeaks] = hist->GetPreciseBinCenterX(maxima[i].x);
+      fYPeaks[fNPeaks] = hist->GetPreciseBinCenterY(maxima[i].y);
+      fWeight[fNPeaks] = (Int_t)maxima[i].weight;
+#ifdef do_mc
+      cout<<"Final Peak found at: "<<maxima[i].x<<" "<<maxima[i].y<<" "<<" "<<fXPeaks[fNPeaks]<<" "<<fYPeaks[fNPeaks]<<" with weight "<<fWeight[fNPeaks]<<" and size "<<maxima[i].size_x<<" by "<<maxima[i].size_y<<endl;
+#endif
+      fNPeaks++;
+    }
+  }
+  */
+
+  Int_t currentnpeaks = fNPeaks;
+  for(Int_t i = 0; i < nmaxima; i++) {
+    if(maxima[i].weight < 0) continue;
+    Bool_t merged = kFALSE;
+    for(Int_t j = fN1PeaksPrevEtaSlice; j < fN2PeaksPrevEtaSlice; j++) {
+      if(fWeight[j] < 0) continue;
+      if((fENDETAPeaks[j]-fSTARTETAPeaks[j]) >= 1) continue;
+      if((maxima[i].start_x >= fSTARTXPeaks[j]-1 && maxima[i].start_x <= fENDXPeaks[j]+1) || (maxima[i].end_x <= fENDXPeaks[j]+1 && maxima[i].end_x >= fSTARTXPeaks[j]-1)) {
+       if((maxima[i].start_y >= fSTARTYPeaks[j]-1 && maxima[i].start_y <= fENDYPeaks[j]+1) || (maxima[i].end_y <= fENDYPeaks[j]+1 && maxima[i].end_y >= fSTARTYPeaks[j]-1)) {
+         //merge
+         merged = kTRUE;
+         fXPeaks[fNPeaks] = (hist->GetPreciseBinCenterX(maxima[i].x)+(fENDETAPeaks[j]-fSTARTETAPeaks[j]+1)*fXPeaks[j])/(fENDETAPeaks[j]-fSTARTETAPeaks[j]+2);
+         fYPeaks[fNPeaks] = (hist->GetPreciseBinCenterY(maxima[i].y)+(fENDETAPeaks[j]-fSTARTETAPeaks[j]+1)*fYPeaks[j])/(fENDETAPeaks[j]-fSTARTETAPeaks[j]+2);
+         fWeight[fNPeaks] = (Int_t)maxima[i].weight + fWeight[j];
+         fSTARTXPeaks[fNPeaks] = maxima[i].start_x;
+         fSTARTYPeaks[fNPeaks] = maxima[i].start_y;
+         fENDXPeaks[fNPeaks] = maxima[i].end_x;
+         fENDYPeaks[fNPeaks] = maxima[i].end_y;
+         fSTARTETAPeaks[fNPeaks] = fSTARTETAPeaks[j];
+         fENDETAPeaks[fNPeaks] = fCurrentEtaSlice;
+         fNPeaks++;
+         fWeight[j] = -fWeight[j];
+       }
+      }
+    }
+    fXPeaks[fNPeaks] = hist->GetPreciseBinCenterX(maxima[i].x);
+    fYPeaks[fNPeaks] = hist->GetPreciseBinCenterY(maxima[i].y);
+    if(!merged)
+      fWeight[fNPeaks] = (Int_t)maxima[i].weight;
+    else
+      fWeight[fNPeaks] = -(Int_t)maxima[i].weight;
+    fSTARTXPeaks[fNPeaks] = maxima[i].start_x;
+    fSTARTYPeaks[fNPeaks] = maxima[i].start_y;
+    fENDXPeaks[fNPeaks] = maxima[i].end_x;
+    fENDYPeaks[fNPeaks] = maxima[i].end_y;
+    fSTARTETAPeaks[fNPeaks] = fCurrentEtaSlice;
+    fENDETAPeaks[fNPeaks] = fCurrentEtaSlice;
+    fNPeaks++;
+  }  
+  fN1PeaksPrevEtaSlice = currentnpeaks;    
+  fN2PeaksPrevEtaSlice = fNPeaks;
+
   for(Int_t i=0; i<hist->GetNbinsY(); i++)
     delete local_maxima[i];
 
   delete [] local_maxima;
   delete [] nmaxs;
-  //delete [] maxima;
 }
 
 void AliL3HoughMaxFinder::FindPeak1(Int_t y_window,Int_t x_bin_sides)
@@ -1203,3 +1392,24 @@ void AliL3HoughMaxFinder::FindPeak(Int_t t1,Double_t t2,Int_t t3)
   //return track;
 }
 
+Float_t AliL3HoughMaxFinder::GetXPeakSize(Int_t i)
+{
+  if(i<0 || i>fNMax)
+    {
+      STDCERR<<"AliL3HoughMaxFinder::GetXPeakSize : Invalid index "<<i<<STDENDL;
+      return 0;
+    }
+  Float_t BinWidth = fCurrentHisto->GetBinWidthX();
+  return BinWidth*(fENDXPeaks[i]-fSTARTXPeaks[i]+1);
+}
+
+Float_t AliL3HoughMaxFinder::GetYPeakSize(Int_t i)
+{
+  if(i<0 || i>fNMax)
+    {
+      STDCERR<<"AliL3HoughMaxFinder::GetYPeak : Invalid index "<<i<<STDENDL;
+      return 0;
+    }
+  Float_t BinWidth = fCurrentHisto->GetBinWidthY();
+  return BinWidth*(fENDYPeaks[i]-fSTARTYPeaks[i]+1);
+}
index 40dca2d..b1ff64e 100644 (file)
@@ -24,13 +24,22 @@ class AliL3HoughMaxFinder {
  private:
 
   Int_t fThreshold;
+  Int_t fCurrentEtaSlice;
   AliL3Histogram *fCurrentHisto;  //!
   
   Float_t fGradX;
   Float_t fGradY;
   Float_t *fXPeaks; //!
   Float_t *fYPeaks; //!
+  Int_t *fSTARTXPeaks; //!
+  Int_t *fSTARTYPeaks; //!
+  Int_t *fENDXPeaks; //!
+  Int_t *fENDYPeaks; //!
+  Int_t *fSTARTETAPeaks; //!
+  Int_t *fENDETAPeaks; //!
   Int_t *fWeight;   //!
+  Int_t fN1PeaksPrevEtaSlice;
+  Int_t fN2PeaksPrevEtaSlice;
   Int_t fNPeaks;
   Int_t fNMax;
   
@@ -66,11 +75,16 @@ class AliL3HoughMaxFinder {
   void SetGradient(Float_t x,Float_t y) {fGradX=x; fGradY=y;}
   void SetThreshold(Int_t f) {fThreshold = f;}
   void SetHistogram(AliL3Histogram *hist) {fCurrentHisto = hist;}
+  void SetEtaSlice(Int_t etaslice) {fCurrentEtaSlice = etaslice;}
   
   //Getters:
   Float_t GetXPeak(Int_t i);
   Float_t GetYPeak(Int_t i);
+  Float_t GetXPeakSize(Int_t i);
+  Float_t GetYPeakSize(Int_t i);
   Int_t GetWeight(Int_t i);
+  Int_t GetStartEta(Int_t i);
+  Int_t GetEndEta(Int_t i);
   Int_t GetEntries() {return fNPeaks;}
 
   ClassDef(AliL3HoughMaxFinder,1) //Maximum finder class
@@ -108,5 +122,25 @@ inline Int_t AliL3HoughMaxFinder::GetWeight(Int_t i)
   return fWeight[i];
 }
 
+inline Int_t AliL3HoughMaxFinder::GetStartEta(Int_t i)
+{
+  if(i<0 || i>fNMax)
+    {
+      STDCERR<<"AliL3HoughMaxFinder::GetStartEta : Invalid index "<<i<<STDENDL;
+      return 0;
+    }
+  return fSTARTETAPeaks[i];
+}
+
+inline Int_t AliL3HoughMaxFinder::GetEndEta(Int_t i)
+{
+  if(i<0 || i>fNMax)
+    {
+      STDCERR<<"AliL3HoughMaxFinder::GetStartEta : Invalid index "<<i<<STDENDL;
+      return 0;
+    }
+  return fENDETAPeaks[i];
+}
+
 #endif
 
index 7fcc464..117b7f8 100644 (file)
@@ -6,6 +6,7 @@
 #include "AliL3StandardIncludes.h"
 
 #include "AliL3Logging.h"
+#include "AliL3Track.h"
 #include "AliL3HoughTrack.h"
 #include "AliL3Transform.h"
 
@@ -26,7 +27,7 @@ using namespace std;
 ClassImp(AliL3HoughTrack)
 
 
-AliL3HoughTrack::AliL3HoughTrack()
+    AliL3HoughTrack::AliL3HoughTrack() : AliL3Track()
 {
   //Constructor
   
@@ -37,6 +38,7 @@ AliL3HoughTrack::AliL3HoughTrack()
   fIsHelix = true;
   fEtaIndex = -1;
   fEta = 0;
+  ComesFromMainVertex(kTRUE);
 }
 
 AliL3HoughTrack::~AliL3HoughTrack()
@@ -59,17 +61,17 @@ void AliL3HoughTrack::Set(AliL3Track *track)
   SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
   SetSlice(tpt->GetSlice());
   SetHits(tpt->GetNHits(),(UInt_t *)tpt->GetHitNumbers());
-#ifdef ROWHOUGH
   SetMCid(tpt->GetMCid());
-#endif
-  /*
-    fWeight = tpt->GetWeight();
-    fDLine = tpt->GetDLine();
-    fPsiLine = tpt->GetPsiLine();
-    SetNHits(tpt->GetWeight());
-    SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
-    fIsHelix = false;
-  */
+  SetBinXY(tpt->GetBinX(),tpt->GetBinY(),tpt->GetSizeX(),tpt->GetSizeY());
+  SetSector(tpt->GetSector());
+  return;
+
+  fWeight = tpt->GetWeight();
+  fDLine = tpt->GetDLine();
+  fPsiLine = tpt->GetPsiLine();
+  SetNHits(tpt->GetWeight());
+  SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
+  fIsHelix = false;
 }
 
 Int_t AliL3HoughTrack::Compare(const AliL3Track *tpt) const
index 3198702..96483ce 100644 (file)
@@ -20,6 +20,8 @@ class AliL3HoughTrack : public AliL3Track {
  
   Bool_t fIsHelix;
 
+  Float_t fBinX,fBinY,fSizeX,fSizeY;
+
  public:
   AliL3HoughTrack(); 
   virtual ~AliL3HoughTrack();
@@ -40,6 +42,11 @@ class AliL3HoughTrack : public AliL3Track {
   Double_t GetEta() const {return fEta;}
   Int_t GetSlice()  const {return fSlice;}
   void GetLineCrossingPoint(Int_t padrow,Float_t *xy);
+
+  Float_t    GetBinX()   const {return fBinX;}
+  Float_t    GetBinY()   const {return fBinY;}
+  Float_t    GetSizeX()  const {return fSizeX;}
+  Float_t    GetSizeY()  const {return fSizeY;}
   
   void SetHelixTrue() {fIsHelix=kTRUE;}
   void SetSlice(Int_t slice) {fSlice=slice;}
@@ -50,6 +57,8 @@ class AliL3HoughTrack : public AliL3Track {
   void SetDLine(Double_t f) {fDLine=f;}
   void SetPsiLine(Double_t f) {fPsiLine=f;}
 
+  void SetBinXY(Float_t binx,Float_t biny,Float_t sizex,Float_t sizey) {fBinX = binx; fBinY = biny; fSizeX = sizex; fSizeY = sizey;}
+
   ClassDef(AliL3HoughTrack,1) //Track class for Hough tracklets
 
 };
index 3b543b5..327db71 100644 (file)
@@ -1,5 +1,6 @@
 // @(#) $Id$
 
+
 // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
 //*-- Copyright &copy ALICE HLT Group
 
 #include "AliL3Transform.h"
 #include "AliL3DigitData.h"
 #include "AliL3HistogramAdaptive.h"
+#include "AliL3HoughTrack.h"
 #include "AliL3HoughTransformerRow.h"
 
-#if __GNUC__ == 3
+#if GCCVERSION == 3
 using namespace std;
 #endif
 
@@ -30,7 +32,12 @@ UChar_t **AliL3HoughTransformerRow::fCurrentRowCount = 0;
 #ifdef do_mc
 TrackIndex **AliL3HoughTransformerRow::fTrackID = 0;
 #endif
+UChar_t *AliL3HoughTransformerRow::fTrackNRows = 0;
+UChar_t *AliL3HoughTransformerRow::fTrackFirstRow = 0;
+UChar_t *AliL3HoughTransformerRow::fTrackLastRow = 0;
 
+Float_t AliL3HoughTransformerRow::fBeta1 = AliL3Transform::Row2X(79)/pow(AliL3Transform::Row2X(79),2);
+Float_t AliL3HoughTransformerRow::fBeta2 = (AliL3Transform::Row2X(158)+6.0)/pow((AliL3Transform::Row2X(158)+6.0),2);
 
 AliL3HoughTransformerRow::AliL3HoughTransformerRow()
 {
@@ -38,11 +45,6 @@ AliL3HoughTransformerRow::AliL3HoughTransformerRow()
   fParamSpace = 0;
   fDoMC = kFALSE;;
 
-  fLUT2sinphi0up=0;
-  fLUT2sinphi0low=0;
-  fLUT2cosphi0up=0;
-  fLUT2cosphi0low=0;
-
   fLUTforwardZ=0;
   fLUTforwardZ2=0;
   fLUTbackwardZ=0;
@@ -59,11 +61,6 @@ AliL3HoughTransformerRow::AliL3HoughTransformerRow(Int_t slice,Int_t patch,Int_t
   fDoMC = kTRUE;
 #endif
 
-  fLUT2sinphi0up=0;
-  fLUT2sinphi0low=0;
-  fLUT2cosphi0up=0;
-  fLUT2cosphi0low=0;
-
   fLUTforwardZ=0;
   fLUTforwardZ2=0;
   fLUTbackwardZ=0;
@@ -116,20 +113,25 @@ AliL3HoughTransformerRow::~AliL3HoughTransformerRow()
       delete [] fCurrentRowCount;
       fCurrentRowCount = 0;
     }
+  if(fTrackNRows)
+    {
+      delete [] fTrackNRows;
+      fTrackNRows = 0;
+    }
+  if(fTrackFirstRow)
+    {
+      delete [] fTrackFirstRow;
+      fTrackFirstRow = 0;
+    }
+  if(fTrackLastRow)
+    {
+      delete [] fTrackLastRow;
+      fTrackLastRow = 0;
+    }
 }
 
 void AliL3HoughTransformerRow::DeleteHistograms()
 {
-  delete[] fLUT2sinphi0up;
-  delete[] fLUT2cosphi0up;
-  delete[] fLUT2sinphi0low;
-  delete[] fLUT2cosphi0low;
-
-  fLUT2sinphi0up=0;
-  fLUT2cosphi0up=0;
-  fLUT2sinphi0low=0;
-  fLUT2cosphi0low=0;
-
   delete[] fLUTforwardZ;
   delete[] fLUTforwardZ2;
   delete[] fLUTbackwardZ;
@@ -188,7 +190,8 @@ void AliL3HoughTransformerRow::CreateHistograms(Int_t nxbin,Float_t xmin,Float_t
       Int_t ncells = (hist->GetNbinsX()+2)*(hist->GetNbinsY()+2);
       if(!fTrackID)
        {
-         cout<<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(TrackIndex)<<" bytes to fTrackID"<<endl;
+         LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+           <<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(TrackIndex)<<" bytes to fTrackID"<<ENDLOG;
          fTrackID = new TrackIndex*[GetNEtaSegments()];
          for(Int_t i=0; i<GetNEtaSegments(); i++)
            fTrackID[i] = new TrackIndex[ncells];
@@ -199,40 +202,106 @@ void AliL3HoughTransformerRow::CreateHistograms(Int_t nxbin,Float_t xmin,Float_t
   Int_t ncells = (hist->GetNbinsX()+2)*(hist->GetNbinsY()+2);
   if(!fRowCount)
     {
-      cout<<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(UChar_t)<<" bytes to fRowCount"<<endl;
+      LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+       <<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(UChar_t)<<" bytes to fRowCount"<<ENDLOG;
       fRowCount = new UChar_t*[GetNEtaSegments()];
       for(Int_t i=0; i<GetNEtaSegments(); i++)
        fRowCount[i] = new UChar_t[ncells];
     }
   if(!fGapCount)
     {
-      cout<<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(UChar_t)<<" bytes to fGapCount"<<endl;
+      LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+       <<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(UChar_t)<<" bytes to fGapCount"<<ENDLOG;
       fGapCount = new UChar_t*[GetNEtaSegments()];
       for(Int_t i=0; i<GetNEtaSegments(); i++)
        fGapCount[i] = new UChar_t[ncells];
     }
   if(!fCurrentRowCount)
     {
-      cout<<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(UChar_t)<<" bytes to fCurrentRowCount"<<endl;
+      LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+       <<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(UChar_t)<<" bytes to fCurrentRowCount"<<ENDLOG;
       fCurrentRowCount = new UChar_t*[GetNEtaSegments()];
       for(Int_t i=0; i<GetNEtaSegments(); i++)
        fCurrentRowCount[i] = new UChar_t[ncells];
     }
 
-  //create lookup table for sin and cos
-  Int_t nbins = hist->GetNbinsY()+2;
-  fLUT2sinphi0up=new Float_t[nbins];
-  fLUT2cosphi0up=new Float_t[nbins];
-  fLUT2sinphi0low=new Float_t[nbins];
-  fLUT2cosphi0low=new Float_t[nbins];
-  Float_t hist_bin=hist->GetBinWidthY()/2.0;
-  for(Int_t i=hist->GetFirstYbin(); i<=hist->GetLastYbin(); i++){
-    Float_t phi0=hist->GetBinCenterY(i);
-    fLUT2sinphi0low[i]=2.*sin(phi0+hist_bin);
-    fLUT2cosphi0low[i]=2.*cos(phi0+hist_bin);
-    fLUT2sinphi0up[i]=2.*sin(phi0-hist_bin);
-    fLUT2cosphi0up[i]=2.*cos(phi0-hist_bin);
-  }  
+  if(!fTrackNRows)
+    {
+      LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+       <<"Transformer: Allocating "<<ncells*sizeof(UChar_t)<<" bytes to fTrackNRows"<<ENDLOG;
+      fTrackNRows = new UChar_t[ncells];
+      LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+       <<"Transformer: Allocating "<<ncells*sizeof(UChar_t)<<" bytes to fTrackFirstRow"<<ENDLOG;
+      fTrackFirstRow = new UChar_t[ncells];
+      LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+       <<"Transformer: Allocating "<<ncells*sizeof(UChar_t)<<" bytes to fTrackLastRow"<<ENDLOG;
+      fTrackLastRow = new UChar_t[ncells];
+
+      AliL3HoughTrack track;
+      Int_t xmin = hist->GetFirstXbin();
+      Int_t xmax = hist->GetLastXbin();
+      Int_t ymin = hist->GetFirstYbin();
+      Int_t ymax = hist->GetLastYbin();
+      Int_t nxbins = hist->GetNbinsX()+2;
+      for(Int_t ybin=ymin; ybin<=ymax; ybin++)
+       {
+         for(Int_t xbin=xmin; xbin<=xmax; xbin++)
+           {
+             //cvetan: we get strange warning on gcc-2.95
+             //warning: large integer implicitly truncated to unsigned type
+             fTrackNRows[xbin + ybin*nxbins] = 99999;
+             for(Int_t deltay = -1; deltay <= 1; deltay += 2) {
+               for(Int_t deltax = -1; deltax <= 1; deltax += 2) {
+               
+                 Float_t xtrack = hist->GetPreciseBinCenterX((Float_t)xbin+0.5*(Float_t)deltax);
+                 Float_t ytrack = hist->GetPreciseBinCenterY((Float_t)ybin+0.5*(Float_t)deltay);
+
+                 Float_t psi = atan((xtrack-ytrack)/(fBeta1-fBeta2));
+                 Float_t kappa = 2.0*(xtrack*cos(psi)-fBeta1*sin(psi));
+                 track.SetTrackParameters(kappa,psi,1);
+                 Bool_t first_row = kFALSE;
+                 UInt_t maxfirstrow = 0;
+                 UInt_t maxlastrow = 0;
+                 UInt_t curfirstrow = 0;
+                 UInt_t curlastrow = 0;
+                 for(Int_t j=AliL3Transform::GetFirstRow(0); j<=AliL3Transform::GetLastRow(5); j++)
+                   {
+                     Float_t hit[3];
+                     if(!track.GetCrossingPoint(j,hit)) continue;
+                     AliL3Transform::LocHLT2Raw(hit,0,j);
+                     if(hit[1]>=0 && hit[1]<AliL3Transform::GetNPads(j))
+                       {
+                         if(!first_row) {
+                           curfirstrow = j;
+                           first_row = kTRUE;
+                         }
+                         curlastrow = j;
+                       }
+                     else {
+                       if(first_row) {
+                         first_row = kFALSE;
+                         if((curlastrow-curfirstrow) >= (maxlastrow-maxfirstrow)) {
+                           maxfirstrow = curfirstrow;
+                           maxlastrow = curlastrow;
+                         }
+                       }
+                     }
+                   }
+                 if((curlastrow-curfirstrow) >= (maxlastrow-maxfirstrow)) {
+                   maxfirstrow = curfirstrow;
+                   maxlastrow = curlastrow;
+                 }
+                 if((maxlastrow-maxfirstrow) < fTrackNRows[xbin + ybin*nxbins]) {
+                   fTrackNRows[xbin + ybin*nxbins] = maxlastrow-maxfirstrow;
+                   fTrackFirstRow[xbin + ybin*nxbins] = maxfirstrow;
+                   fTrackLastRow[xbin + ybin*nxbins] = maxlastrow;
+                 }
+               }
+             }
+             //              cout<<" fTrackNRows "<<xbin<<" "<<ybin<<" "<<(Int_t)fTrackNRows[xbin + ybin*nxbins]<<" "<<endl;
+           }
+       }
+    }
 
   //create lookup table for z of the digits
   Int_t ntimebins = AliL3Transform::GetNTimeBins();
@@ -281,7 +350,8 @@ void AliL3HoughTransformerRow::Reset()
     {
       memset(fRowCount[i],0,ncells*sizeof(UChar_t));
       memset(fGapCount[i],1,ncells*sizeof(UChar_t));
-      memset(fCurrentRowCount[i],160,ncells*sizeof(UChar_t));
+      //      memset(fCurrentRowCount[i],160,ncells*sizeof(UChar_t));
+      memcpy(fCurrentRowCount[i],fTrackFirstRow,ncells*sizeof(UChar_t));
     }
 }
 
@@ -323,6 +393,10 @@ struct EtaRow {
 
 void AliL3HoughTransformerRow::TransformCircle()
 {
+  Float_t beta1 = fBeta1;
+  Float_t beta2 = fBeta2;
+  Float_t beta1_minus_beta2 = fBeta1 - fBeta2;
+
   Int_t n_eta_segments = GetNEtaSegments();
   Double_t eta_min = GetEtaMin();
   Double_t eta_slice = (GetEtaMax() - eta_min)/n_eta_segments;
@@ -331,6 +405,9 @@ void AliL3HoughTransformerRow::TransformCircle()
 
   //Assumes that all the etaslice histos are the same!
   AliL3Histogram *h = fParamSpace[0];
+  Float_t y_min = h->GetYmin();
+  //Float_t y_max = h->GetYmax();
+  Float_t hist_bin = h->GetBinWidthY();
   Int_t first_bin = h->GetFirstYbin();
   Int_t last_bin = h->GetLastYbin();
   Float_t x_min = h->GetXmin();
@@ -366,14 +443,6 @@ void AliL3HoughTransformerRow::TransformCircle()
     fLUTz2 = fLUTbackwardZ2;
   }
 
-  Int_t npads_in_patch = AliL3Transform::GetNPads(AliL3Transform::GetLastRow(ipatch))+2;
-  Bool_t **IsPrevRow = new Bool_t*[n_eta_segments];
-  Int_t nrows_in_patch = AliL3Transform::GetLastRow(ipatch)-AliL3Transform::GetFirstRow(ipatch)+2;
-  for(Int_t i=0; i<n_eta_segments; i++) {
-    IsPrevRow[i] = new Bool_t[npads_in_patch*nrows_in_patch];
-    memset(IsPrevRow[i],1,npads_in_patch*nrows_in_patch*sizeof(Bool_t));
-  }
-
   //Loop over the padrows:
   for(UChar_t i=AliL3Transform::GetFirstRow(ipatch); i<=AliL3Transform::GetLastRow(ipatch); i++)
     {
@@ -387,13 +456,12 @@ void AliL3HoughTransformerRow::TransformCircle()
       Float_t x2 = x*x;
       Float_t y=0,r2=0;
 
-      Int_t lrow = (i-AliL3Transform::GetFirstRow(ipatch))*npads_in_patch;
-
       //Get the data on this padrow:
       AliL3DigitData *digPt = tempPt->fDigitData;
       if((Int_t)i != (Int_t)tempPt->fRow)
        {
-         cerr<<"AliL3HoughTransform::TransformCircle : Mismatching padrow numbering "<<(Int_t)i<<" "<<(Int_t)tempPt->fRow<<endl;
+         LOG(AliL3Log::kError,"AliL3HoughTransformerRow::TransformCircle","Data")
+           <<"AliL3HoughTransform::TransformCircle : Mismatching padrow numbering "<<(Int_t)i<<" "<<(Int_t)tempPt->fRow<<ENDLOG;
          continue;
        }
       //      cout<<" Starting row "<<i<<endl;
@@ -405,6 +473,7 @@ void AliL3HoughTransformerRow::TransformCircle()
            continue;
          UChar_t pad = digPt[j].fPad;
          UShort_t time = digPt[j].fTime;
+
          if(pad != last_pad)
            {
              y = (pad-0.5*npads)*pad_pitch;
@@ -478,72 +547,74 @@ void AliL3HoughTransformerRow::TransformCircle()
                }
              else
                {
-
-                 Bool_t fill_cluster = kFALSE;
-                 Bool_t *IsPrevRow2 = &IsPrevRow[eta_index][lrow+eta_clust[eta_index].start_pad];
-                 for(Int_t ipad = 0; ipad <= (eta_clust[eta_index].end_pad - eta_clust[eta_index].start_pad + 2); ipad++)
-                   {
-                     if(*IsPrevRow2)
-                       {
-                         fill_cluster = kTRUE;
-                         break;
-                       }
-                     IsPrevRow2++;
-                   }
-
-                 //              if(eta_index == 51)
-                 //                cout<<" Cluster to fill:"<<" row "<<(Int_t)i<<" pads from "<<(Int_t)eta_clust[eta_index].start_pad<<"("<<eta_clust[eta_index].start_y<<") to "<<(Int_t)eta_clust[eta_index].end_pad<<"("<<(eta_clust[eta_index].end_pad-0.5*(npads-1))*pad_pitch<<") fill "<<fill_cluster<<endl;
-
+                 Bool_t fill_cluster = kTRUE;
                  if(fill_cluster) {
-                 //              cout<<" Cluster found at etaslice "<<eta_index<<" from pad "<<(Int_t)eta_clust[eta_index].start_pad<<" to pad "<<(Int_t)eta_clust[eta_index].end_pad<<endl;
-                 //              Bool_t fill_next_row = kFALSE;
 
                  UChar_t *nrows = fRowCount[eta_index];
                  UChar_t *ngaps = fGapCount[eta_index];
                  UChar_t *currentrow = fCurrentRowCount[eta_index];
+                 UChar_t *lastrow = fTrackLastRow;
 
                  //Do the transformation:
                  Float_t start_y = eta_clust[eta_index].start_y;
                  if(eta_clust[eta_index].start_pad == 0)
-                   start_y -= 3.0*pad_pitch;
+                   start_y -= 0.0*pad_pitch;
                  Float_t R1 = x2 + start_y*start_y;
                  Float_t x_over_R1 = x/R1;
                  Float_t start_y_over_R1 = start_y/R1;
                  Float_t end_y = (eta_clust[eta_index].end_pad-0.5*(npads-1))*pad_pitch;
                  if(eta_clust[eta_index].end_pad == npads)
-                   end_y += 3.0*pad_pitch;
+                   end_y += 0.0*pad_pitch;
                  Float_t R2 = x2 + end_y*end_y; 
                  Float_t x_over_R2 = x/R2;
                  Float_t end_y_over_R2 = end_y/R2;
+                 Float_t A1 = beta1_minus_beta2/(x_over_R1-beta2);
+                 Float_t B1 = (x_over_R1-beta1)/(x_over_R1-beta2);
+                 Float_t A2 = beta1_minus_beta2/(x_over_R2-beta2);
+                 Float_t B2 = (x_over_R2-beta1)/(x_over_R2-beta2);
+
+                 Float_t kappa1 = (A1*start_y_over_R1+B1*y_min-x_min)/x_bin;
+                 Float_t delta_kappa1 = B1*hist_bin/x_bin;
+                 if(B1<0)
+                   kappa1 += delta_kappa1;
+                 Float_t kappa2 = (A2*end_y_over_R2+B2*y_min-x_min)/x_bin;
+                 Float_t delta_kappa2 = B2*hist_bin/x_bin;
+                 if(B2>=0)
+                   kappa2 += delta_kappa2;
 
                  //Fill the histogram along the phirange
-                 for(Int_t b=first_bin; b<=last_bin; b++)
+                 for(Int_t b=first_bin; b<=last_bin; b++, kappa1 += delta_kappa1, kappa2 += delta_kappa2)
                    {
-                     Float_t kappa1 = start_y_over_R1*fLUT2cosphi0low[b]-x_over_R1*fLUT2sinphi0low[b];
-                     if(kappa1>x_max) continue;
-                     Float_t kappa2 = end_y_over_R2*fLUT2cosphi0up[b]-x_over_R2*fLUT2sinphi0up[b];
-                     if(kappa2<x_min) break;
-
-                     Int_t binx1 = 1 + (Int_t)((kappa1-x_min)/x_bin);
+                     Int_t binx1 = 1 + (Int_t)kappa1;
+                     if(binx1>last_binx) continue;
                      if(binx1<first_binx) binx1 = first_binx;
-                     Int_t binx2 = 1 + (Int_t)((kappa2-x_min)/x_bin);
+                     Int_t binx2 = 1 + (Int_t)kappa2;
+                     if(binx2<first_binx) continue;
                      if(binx2>last_binx) binx2 = last_binx;
-                     //                      if(eta_index == 51)
-                     //                        cout<<"     phi bin "<<b<<" kappa1 "<<kappa1<<" kappa2 "<<kappa2<<" from bin "<<binx1<<" to "<<binx2<<endl;
-                     Int_t temp_bin = b*nbinx + binx1;
+#ifdef do_mc
+                     if(binx2<binx1) {
+                       LOG(AliL3Log::kWarning,"AliL3HoughTransformerRow::TransformCircle()","")
+                         <<"Wrong filling "<<binx1<<" "<<binx2<<" "<<i<<" "<<x<<" "<<start_y<<" "<<end_y<<ENDLOG;
+                     }
+#endif
+                     Int_t temp_bin = b*nbinx;
                      UChar_t *nrows2 = nrows + temp_bin;
                      UChar_t *ngaps2 = ngaps + temp_bin;
                      UChar_t *currentrow2 = currentrow + temp_bin;
+                     UChar_t *lastrow2 = lastrow + temp_bin;
                      for(Int_t bin=binx1;bin<=binx2;bin++)
                        {
-                         //Assumes threshold about 32
-                         if(*ngaps2 < 3) {
-                           if(i != *currentrow2)
+                         if(ngaps2[bin] < MAX_N_GAPS) {
+                           if(i > (currentrow2[bin] + MAX_GAP_SIZE) && i < lastrow2[bin]) {
+                             ngaps2[bin] = MAX_N_GAPS;
+                             continue;
+                           }
+                           if(i > currentrow2[bin] && i < lastrow2[bin])
                              {
-                               (*nrows2)++;
-                               if(i > (*currentrow2 + 1))
-                                 (*ngaps2)++;
-                               *currentrow2=i;
+                               nrows2[bin]++;
+                               if(i > (currentrow2[bin] + 1))
+                                 ngaps2[bin]++;
+                               currentrow2[bin]=i;
                              }
 #ifdef do_mc
                            if(fDoMC)
@@ -567,25 +638,11 @@ void AliL3HoughTransformerRow::TransformCircle()
                              }
 #endif
                          }
-                         nrows2++;
-                         ngaps2++;
-                         currentrow2++;
                        }
                    }
                  //End of the transformation
 
-                 /*              if(!fill_next_row) {
-                   Bool_t *IsCurrentRow = &IsPrevRow[eta_index][lrow+npads_in_patch];
-                   memset(&IsCurrentRow[eta_clust[eta_index].start_pad + 1],0,eta_clust[eta_index].end_pad - eta_clust[eta_index].start_pad + 1);
-                   } */
                  }
-                 else {
-                   Bool_t *IsCurrentRow = &IsPrevRow[eta_index][lrow+npads_in_patch+eta_clust[eta_index].start_pad+1];
-                   memset(IsCurrentRow,0,eta_clust[eta_index].end_pad - eta_clust[eta_index].start_pad + 1);
-                 }
-
-                 Bool_t *IsCurrentRow = &IsPrevRow[eta_index][lrow+npads_in_patch+eta_clust[eta_index].end_pad+2];
-                 memset(IsCurrentRow,0,pad - eta_clust[eta_index].end_pad - 1);
 
                  eta_clust[eta_index].start_pad = pad;
                  eta_clust[eta_index].end_pad = pad;
@@ -622,48 +679,68 @@ void AliL3HoughTransformerRow::TransformCircle()
          UChar_t *nrows = fRowCount[eta_index];
          UChar_t *ngaps = fGapCount[eta_index];
          UChar_t *currentrow = fCurrentRowCount[eta_index];
+         UChar_t *lastrow = fTrackLastRow;
 
          //Do the transformation:
          Float_t start_y = eta_clust[eta_index].start_y;
          if(eta_clust[eta_index].start_pad == 0)
-           start_y -= 3.0*pad_pitch;
+           start_y -= 0.0*pad_pitch;
          Float_t R1 = x2 + start_y*start_y; 
          Float_t x_over_R1 = x/R1;
          Float_t start_y_over_R1 = start_y/R1;
          Float_t end_y = (eta_clust[eta_index].end_pad-0.5*(npads-1))*pad_pitch;
          if(eta_clust[eta_index].end_pad == npads)
-           end_y += 3.0*pad_pitch;
+           end_y += 0.0*pad_pitch;
          Float_t R2 = x2 + end_y*end_y; 
          Float_t x_over_R2 = x/R2;
          Float_t end_y_over_R2 = end_y/R2;
+         Float_t A1 = beta1_minus_beta2/(x_over_R1-beta2);
+         Float_t B1 = (x_over_R1-beta1)/(x_over_R1-beta2);
+         Float_t A2 = beta1_minus_beta2/(x_over_R2-beta2);
+         Float_t B2 = (x_over_R2-beta1)/(x_over_R2-beta2);
+
+         Float_t kappa1 = (A1*start_y_over_R1+B1*y_min-x_min)/x_bin;
+         Float_t delta_kappa1 = B1*hist_bin/x_bin;
+         if(B1<0)
+           kappa1 += delta_kappa1;
+         Float_t kappa2 = (A2*end_y_over_R2+B2*y_min-x_min)/x_bin;
+         Float_t delta_kappa2 = B2*hist_bin/x_bin;
+         if(B2>=0)
+           kappa2 += delta_kappa2;
 
          //Fill the histogram along the phirange
-         for(Int_t b=first_bin; b<=last_bin; b++)
+         for(Int_t b=first_bin; b<=last_bin; b++, kappa1 += delta_kappa1, kappa2 += delta_kappa2)
            {
-             Float_t kappa1 = start_y_over_R1*fLUT2cosphi0low[b]-x_over_R1*fLUT2sinphi0low[b];
-             if(kappa1>x_max) continue;
-             Float_t kappa2 = end_y_over_R2*fLUT2cosphi0up[b]-x_over_R2*fLUT2sinphi0up[b];
-             if(kappa2<x_min) break;
-
-             Int_t binx1 = 1 + (Int_t)((kappa1-x_min)/x_bin);
+             Int_t binx1 = 1 + (Int_t)kappa1;
+             if(binx1>last_binx) continue;
              if(binx1<first_binx) binx1 = first_binx;
-             Int_t binx2 = 1 + (Int_t)((kappa2-x_min)/x_bin);
+             Int_t binx2 = 1 + (Int_t)kappa2;
+             if(binx2<first_binx) continue;
              if(binx2>last_binx) binx2 = last_binx;
-
-             Int_t temp_bin = b*nbinx + binx1;
+#ifdef do_mc
+             if(binx2<binx1) {
+               LOG(AliL3Log::kWarning,"AliL3HoughTransformerRow::TransformCircle()","")
+                 <<"Wrong filling "<<binx1<<" "<<binx2<<" "<<i<<" "<<x<<" "<<start_y<<" "<<end_y<<ENDLOG;
+             }
+#endif
+             Int_t temp_bin = b*nbinx;
              UChar_t *nrows2 = nrows + temp_bin;
              UChar_t *ngaps2 = ngaps + temp_bin;
              UChar_t *currentrow2 = currentrow + temp_bin;
+             UChar_t *lastrow2 = lastrow + temp_bin;
              for(Int_t bin=binx1;bin<=binx2;bin++)
                {
-                 //Assumes threshold about 32
-                 if(*ngaps2 < 3) {
-                   if(i != *currentrow2)
+                 if(ngaps2[bin] < MAX_N_GAPS) {
+                   if(i > (currentrow2[bin] + MAX_GAP_SIZE) && i < lastrow2[bin]) {
+                     ngaps2[bin] = MAX_N_GAPS;
+                     continue;
+                   }
+                   if(i > currentrow2[bin] && i < lastrow2[bin])
                      {
-                       (*nrows2)++;
-                       if(i > (*currentrow2 + 1))
-                         (*ngaps2)++;
-                       *currentrow2=i;
+                       nrows2[bin]++;
+                       if(i > (currentrow2[bin] + 1))
+                         ngaps2[bin]++;
+                       currentrow2[bin]=i;
                      }
 #ifdef do_mc
                    if(fDoMC)
@@ -687,32 +764,16 @@ void AliL3HoughTransformerRow::TransformCircle()
                      }
 #endif
                  }
-                 nrows2++;
-                 ngaps2++;
-                 currentrow2++;
                }
            }
          //End of the transformation
 
-         if(eta_clust[eta_index].end_pad < npads)
-           {
-             Bool_t *IsCurrentRow = &IsPrevRow[eta_index][lrow+npads_in_patch+eta_clust[eta_index].end_pad+2];
-             memset(IsCurrentRow,0,npads - eta_clust[eta_index].end_pad);
-           }
-
        }
 
       //Move the data pointer to the next padrow:
       AliL3MemHandler::UpdateRowPointer(tempPt);
     }
 
-
-  for(Int_t i=0; i<n_eta_segments; i++)
-    {
-      delete [] IsPrevRow[i];
-    }
-  delete [] IsPrevRow;
-
   delete [] eta_clust;
 }
 
@@ -720,14 +781,16 @@ Int_t AliL3HoughTransformerRow::GetTrackID(Int_t eta_index,Double_t kappa,Double
 {
   if(!fDoMC)
     {
-      cerr<<"AliL3HoughTransformer::GetTrackID : Flag switched off"<<endl;
+      LOG(AliL3Log::kWarning,"AliL3HoughTransformerRow::GetTrackID","Data")
+       <<"Flag switched off"<<ENDLOG;
       return -1;
     }
   
 #ifdef do_mc
   if(eta_index < 0 || eta_index > GetNEtaSegments())
     {
-      cerr<<"AliL3HoughTransformer::GetTrackID : Wrong etaindex "<<eta_index<<endl;
+      LOG(AliL3Log::kWarning,"AliL3HoughTransformerRow::GetTrackID","Data")
+       <<"Wrong etaindex "<<eta_index<<ENDLOG;
       return -1;
     }
   AliL3Histogram *hist = fParamSpace[eta_index];
@@ -761,7 +824,8 @@ Int_t AliL3HoughTransformerRow::GetTrackID(Int_t eta_index,Double_t kappa,Double
   //  cout<<" TrackID label "<<label<<" max "<<max<<" label2 "<<label2<<" max2 "<<max2<<" "<<(Float_t)max2/(Float_t)max<<" "<<fTrackID[eta_index][bin].fLabel[MaxTrack-1]<<" "<<(Int_t)fTrackID[eta_index][bin].fNHits[MaxTrack-1]<<endl;
   return label;
 #endif
-  cout<<"AliL3HoughTransformer::GetTrackID : Compile with do_mc flag!"<<endl;
+  LOG(AliL3Log::kWarning,"AliL3HoughTransformerRow::GetTrackID()","")
+    <<"Compile with do_mc flag!"<<ENDLOG;
   return -1;
 }
 
@@ -774,3 +838,24 @@ UChar_t *AliL3HoughTransformerRow::GetGapCount(Int_t eta_index)
 {
   return fGapCount[eta_index];
 }
+
+UChar_t *AliL3HoughTransformerRow::GetCurrentRowCount(Int_t eta_index)
+{
+  return fCurrentRowCount[eta_index];
+}
+
+UChar_t *AliL3HoughTransformerRow::GetTrackNRows()
+{
+  return fTrackNRows;
+}
+
+
+UChar_t *AliL3HoughTransformerRow::GetTrackFirstRow()
+{
+  return fTrackFirstRow;
+}
+
+UChar_t *AliL3HoughTransformerRow::GetTrackLastRow()
+{
+  return fTrackLastRow;
+}
index 159bbaf..e2b890a 100644 (file)
@@ -6,6 +6,11 @@
 #include "AliL3RootTypes.h"
 #include "AliL3HoughBaseTransformer.h"
 
+#define MAX_N_GAPS 4
+#define MAX_GAP_SIZE 4
+#define MIN_TRACK_LENGTH 70
+#define MAX_MISS_ROWS 2
+
 class AliL3Histogram;
 
 class AliL3HoughTransformerRow : public AliL3HoughBaseTransformer {
@@ -25,16 +30,17 @@ class AliL3HoughTransformerRow : public AliL3HoughBaseTransformer {
   static UChar_t **fGapCount; //!
   static UChar_t **fCurrentRowCount; //!
 
-  Float_t *fLUT2sinphi0up; //!   
-  Float_t *fLUT2cosphi0up; //!
-  Float_t *fLUT2sinphi0low; //!   
-  Float_t *fLUT2cosphi0low; //!
+  static UChar_t *fTrackNRows; //!
+  static UChar_t *fTrackFirstRow; //!
+  static UChar_t *fTrackLastRow; //!
 
   Float_t *fLUTforwardZ; //!
   Float_t *fLUTforwardZ2; //!
   Float_t *fLUTbackwardZ; //!
   Float_t *fLUTbackwardZ2; //!
 
+  static Float_t fBeta1,fBeta2;
+
  public:
   AliL3HoughTransformerRow(); 
   AliL3HoughTransformerRow(Int_t slice,Int_t patch,Int_t n_eta_segments,Bool_t DoMC=kFALSE,Float_t zvertex=0.0);
@@ -53,6 +59,12 @@ class AliL3HoughTransformerRow : public AliL3HoughBaseTransformer {
   Int_t GetTrackID(Int_t eta_index,Double_t kappa,Double_t psi);
   UChar_t *GetRowCount(Int_t eta_index);
   UChar_t *GetGapCount(Int_t eta_index);
+  UChar_t *GetCurrentRowCount(Int_t eta_index);
+  static UChar_t *GetTrackNRows();
+  static UChar_t *GetTrackFirstRow();
+  static UChar_t *GetTrackLastRow();
+  static Float_t GetBeta1() {return fBeta1;}
+  static Float_t GetBeta2() {return fBeta2;}
 
   ClassDef(AliL3HoughTransformerRow,1) //TPC Rows Hough transformation class
 
index 6098508..8ff4c43 100644 (file)
@@ -23,6 +23,8 @@
 #include "TNtuple.h"
 #include "TTimer.h"
 
+#include "Riostream.h"
+
 /*
   AliL3Kalman
 */
@@ -113,6 +115,7 @@ void AliL3Kalman::LoadTracks(Int_t event, Bool_t sp)
     }
 
   // Load tracks
+  //sprintf(fname,"%s/kalmantracks_%d.raw",fPath,event);
   sprintf(fname,"%s/tracks_%d.raw",fPath,event);
   AliL3FileHandler *tfile = new AliL3FileHandler();
   if(!tfile->SetBinaryInput(fname)){
@@ -172,19 +175,24 @@ void AliL3Kalman::ProcessTracks()
 
       Bool_t save = kTRUE;
 
-      if (InitKalmanTrack(kalmantrack, track) == 0)
+      /*if (InitKalmanTrack(kalmantrack, track) == 0)
        {
          save = kFALSE;
          continue;
-       }
+         }*/
       
+      if (MakeKalmanSeed(kalmantrack,track) ==0)
+       {
+         save = kFALSE;
+         continue;
+       }
 
       if (Propagate(kalmantrack, track) == 0) 
        {
          save = kFALSE;
        }
-      
-      if (save) {
+
+      if (save) {// cout << track->GetPt() << endl;
        Float_t x[5]; 
        kalmantrack->GetStateVector(x);
        Float_t c[15]; 
@@ -215,6 +223,14 @@ void AliL3Kalman::ProcessTracks()
        // Add the track to the trackarray      
        AliL3Track *outtrack = (AliL3Track*)fKalmanTracks->NextTrack();
        outtrack->Set(track);
+       // SET THE PARAMETERS ACCORDING TO KALMAN FILTER
+       outtrack->SetTgl(x[3]);
+       // The factor 2 in the expression for Pt is not included in the similar offline expression. However
+       // it should be like this if I use a factor 1/2 in the calculation of par4??
+       //outtrack->SetPt(1/(2*TMath::Abs(1e-9*TMath::Abs(x[4])/x[4] + x[4])/(0.0029980*AliL3Transform::GetBField())));
+       //outtrack->SetPt(1/(TMath::Abs(x[4])/0.0029980*AliL3Transform::GetBField()));
+       outtrack->SetPsi(x[2]);
+       //outtrack->Set(track);
 
        // Fill the ntuple with the state vector, covariance matrix and
        // chisquare
@@ -255,6 +271,34 @@ void AliL3Kalman::ProcessTracks()
   
 }
 
+Int_t AliL3Kalman::MakeKalmanSeed(AliL3KalmanTrack *kalmantrack, AliL3Track *track)
+{
+  Int_t num_of_clusters = track->GetNumberOfPoints();
+
+  UInt_t *hitnum = track->GetHitNumbers();
+  UInt_t id;
+
+  id = hitnum[0];
+  Int_t slice0 = (id>>25) & 0x7f;
+  Int_t patch0 = (id>>22) & 0x7;       
+  UInt_t pos0 = id&0x3fffff;
+  AliL3SpacePointData *points0 = fClusters[slice0][patch0];
+
+  id = hitnum[Int_t(num_of_clusters/2)];
+  Int_t slice1 = (id>>25) & 0x7f;
+  Int_t patch1 = (id>>22) & 0x7;       
+  UInt_t pos1 = id&0x3fffff;
+  AliL3SpacePointData *points1 = fClusters[slice1][patch1];
+
+  id = hitnum[num_of_clusters-1];
+  Int_t slice2 = (id>>25) & 0x7f;
+  Int_t patch2 = (id>>22) & 0x7;       
+  UInt_t pos2 = id&0x3fffff;
+  AliL3SpacePointData *points2 = fClusters[slice2][patch2];
+
+  return kalmantrack->MakeSeed(track, points0, pos0, slice0, points1, pos1, slice1, points2, pos2, slice2);
+}
+
 Int_t AliL3Kalman::InitKalmanTrack(AliL3KalmanTrack *kalmantrack, AliL3Track *track)
 {
   UInt_t *hitnum = track->GetHitNumbers();
index 2d6f437..9e4ec5a 100644 (file)
@@ -39,6 +39,7 @@ class AliL3Kalman {
   void Init();
   void LoadTracks(Int_t event, Bool_t sp);
   void ProcessTracks();
+  Int_t MakeKalmanSeed(AliL3KalmanTrack *kalmantrack, AliL3Track *track);
   Int_t InitKalmanTrack(AliL3KalmanTrack *kalmantrack, AliL3Track *track);
   Int_t Propagate(AliL3KalmanTrack *kalmantrack, AliL3Track *track);
   Int_t Update(AliL3SpacePointData *points, UInt_t pos, AliL3KalmanTrack *kalmantrack);
index bfea605..10214fe 100644 (file)
@@ -20,7 +20,7 @@ AliL3KalmanTrack::AliL3KalmanTrack()
 {
   fX = 0;
 
-  fMaxChi2 = 12;
+  fMaxChi2 = 1000;
   // Constructor
 }
 
@@ -29,17 +29,76 @@ AliL3KalmanTrack::~AliL3KalmanTrack()
   // Destructor
 }
 
+Int_t AliL3KalmanTrack::MakeSeed(AliL3Track *track, AliL3SpacePointData *points0, UInt_t pos0, Int_t slice0, AliL3SpacePointData *points1, UInt_t pos1, Int_t slice1, AliL3SpacePointData *points2, UInt_t pos2, Int_t slice2)
+{
+  Float_t xyz[3];
+  xyz[0] = points0[pos0].fX;
+  xyz[1] = points0[pos0].fY;
+  AliL3Transform::Global2LocHLT(xyz,slice0);  
+  fX = xyz[0];
+  fP0 = xyz[1];
+  fP1 = points0[pos0].fZ; 
+
+  xyz[0] = points1[pos1].fX;
+  xyz[1] = points1[pos1].fY;
+  AliL3Transform::Global2LocHLT(xyz,slice1);
+  Float_t x2 = xyz[0];
+  Float_t y2 = xyz[1];
+  Float_t z2 = points1[pos1].fZ;
+
+  xyz[0] = points2[pos2].fX;
+  xyz[1] = points2[pos2].fY;
+  AliL3Transform::Global2LocHLT(xyz,slice2);
+  Float_t x3 = 0;//xyz[0];
+  Float_t y3 = 0;//xyz[1];
+  Float_t z3 = 0;//points2[pos2].fZ; 
+
+
+  fP2 = f2(fX,fP0,x2,y2,x3,y3);
+  fP3 = f3(fX,fP0,x2,y2,fP1,z2);
+  if (TMath::Abs(fP3) > 1.2) return 0;
+  fP4 = f4(fX,fP0,x2,y2,x3,y3);
+  if (TMath::Abs(fP4) >= 0.0066) return 0;
+
+  Float_t sy1=points0[pos0].fSigmaY2, sz1=points0[pos0].fSigmaZ2;
+  Float_t sy2=points2[pos2].fSigmaY2, sz2=points2[pos2].fSigmaZ2;
+  //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
+  Float_t sy3=25000*fP4*fP4+0.1, sy=0.1, sz=0.1;
+  
+  Float_t f40=(f4(fX,fP0+sy,x2,y2,x3,y3)-fP4)/sy;
+  Float_t f42=(f4(fX,fP0,x2,y2+sy,x3,y3)-fP4)/sy;
+  Float_t f43=(f4(fX,fP0,x2,y2,x3,y3+sy)-fP4)/sy;
+  Float_t f20=(f2(fX,fP0+sy,x2,y2,x3,y3)-fP2)/sy;
+  Float_t f22=(f2(fX,fP0,x2,y2+sy,x3,y3)-fP2)/sy;
+  Float_t f23=(f2(fX,fP0,x2,y2,x3,y3+sy)-fP2)/sy;
+  Float_t f30=(f3(fX,fP0+sy,x2,y2,fP1,z2)-fP3)/sy;
+  Float_t f31=(f3(fX,fP0,x2,y2,fP1+sz,z2)-fP3)/sz;
+  Float_t f32=(f3(fX,fP0,x2,y2+sy,fP1,z2)-fP3)/sy;
+  Float_t f34=(f3(fX,fP0,x2,y2,fP1,z2+sz)-fP3)/sz;
+
+  fC00=sy1;
+  fC10=0.;       fC11=sz1;
+  fC20=f20*sy1;  fC21=0.;       fC22=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
+  fC30=f30*sy1;  fC31=f31*sz1;  fC32=f30*sy1*f20+f32*sy2*f22;
+  fC33=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
+  fC40=f40*sy1; fC41=0.; fC42=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
+  fC43=f30*sy1*f40+f32*sy2*f42;
+  fC44=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
+
+  return 1;  
+} 
+
 Int_t AliL3KalmanTrack::Init(AliL3Track *track, AliL3SpacePointData *points, UInt_t pos, Int_t slice)
 {
 
-  Float_t xyz[3];
+  // Can also find seed for x4 by track->CalculateHelix() and fP4 = track->GetKappa()
+  // See if it's any difference in the time it takes. ??
+  //track->CalculateHelix();
 
+  Float_t xyz[3];
   xyz[0] = points[pos].fX;
   xyz[1] = points[pos].fY;
-
-  // NB! I think boolean variable in the command under is true if single slice.
-  // Better do a test if it is signle slice, and if so set it true.??.
-  AliL3Transform::Global2Local(xyz,slice);
+  AliL3Transform::Global2LocHLT(xyz,slice);
   
   fX = xyz[0];
 
@@ -47,43 +106,51 @@ Int_t AliL3KalmanTrack::Init(AliL3Track *track, AliL3SpacePointData *points, UIn
   fP1 = points[pos].fZ; 
   fP3 = track->GetTgl(); //cout << fP3; 
   if (TMath::Abs(fP3) > 1.2) return 0; //From AliTPCtrackerMI
-  fP4 = 0.5*(-track->GetCharge()*1./track->GetPt())*0.0029980*AliL3Transform::GetBField(); // Calculation of the curvature 
-  if (TMath::Abs(fP4) >= 0.0066) return 0; // From AliTPCtrackerMI
 
-
-  Float_t firstXY[2];
+  // The expression for fP4 is from ALICE internal note: ALICE/97-24, June 27, 1997
+  // Is this consistent with what's used in AliTPCtrack and AliTPCtracker ?? 
+  // Except for the factor 0.5, it is somewhat consistent with the calculation of Pt in AliTPCtrack.
+  // When I plot fP4, it is more consistent with offline if the factor 1/2 is included.
+  //fP4 = (-track->GetCharge()*1./(track->GetPt()/(0.0029980*AliL3Transform::GetBField()))); 
+  fP4 = 0.5*(-track->GetCharge()*1./(track->GetPt()/(0.0029980*AliL3Transform::GetBField()))); 
+  //cout << fP4 << endl;
+  //fP4 = 0.5*track->GetKappa();
+  if (TMath::Abs(fP4) >= 0.0066) return 0; // From AliTPCtrackerMI
+  
+  /*Float_t firstXY[2];
   firstXY[0] = track->GetFirstPointX();
   firstXY[1] = track->GetFirstPointY();
-
-  AliL3Transform::Global2Local(firstXY,slice);
-
-  //cout << firstXY[0] << endl;
-
+  AliL3Transform::Global2LocHLT(firstXY,slice);
+  */
   //Float_t centerX = track->GetFirstPointX() - ((track->GetPt()/(0.0029980*AliL3Transform::GetBField())) * TMath::Cos(track->GetPsi() + track->GetCharge() * 0.5 * 3.14159265358979323846));
-  Float_t centerX = firstXY[0] - ((track->GetPt()/(0.0029980*AliL3Transform::GetBField())) * TMath::Cos(track->GetPsi() + track->GetCharge() * 0.5 * 3.14159265358979323846));
-  //Float_t centerY = track->GetFirstPointY() - ((track->GetPt()/(0.0029980*AliL3Transform::GetBField())) * TMath::Sin(track->GetPsi() + track->GetCharge() * 0.5 * 3.14159265358979323846));
-
-  fP2 = fP4*centerX; // Curvature times center of curvature
+  //Float_t centerX = firstXY[0] - ((track->GetPt()/(0.0029980*AliL3Transform::GetBField())) * TMath::Cos(track->GetPsi() + track->GetCharge() * 0.5 * 3.14159265358979323846));
+  
+  //fP2 = fP4*centerX; // Curvature times center of curvature
+  // track->GetPointPsi() is almost always zero, why??. Still it's good for seed.
+  fP2 = TMath::Sin(track->GetPointPsi());  
 
+  //cout << track->GetPt() << endl;
   if (TMath::Abs(fP4*fX - fP2) >= 0.9) // What's this??
     {
       return 0;
     }
-  //cout << track->GetCharge() << endl; 
+
   //cout << "AliL3KalmanTrack::Init, " << fP0 << " " << fP1 << " " << fP2 << " " << fP3 << " " << fP4 << endl;
-  //cout << fP4 << endl;
   //Float_t num = 12;
 
-  fC00 = points[pos].fSigmaY2; 
+  fC00 = points[pos].fSigmaY2;
   fC10 = 0; fC11 = points[pos].fSigmaZ2;
   fC20 = 0; fC21 = 0; fC22 = 5e-05;
   fC30 = 0; fC31 = 0; fC32 = 0; fC33 = 5e-05;
   fC40 = 0; fC41 = 0; fC42 = 0; fC43 = 0; fC44 = 5e-09;
-  /*fC00 = points[pos].fSigmaY2;
+  /*Float_t num = 12;
+  fC00 = points[pos].fSigmaY2;
   fC10 = 0; fC11 = points[pos].fSigmaZ2;
-  fC20 = 0; fC21 = 0; fC22 = (0.1/TMath::Sqrt(num))*(0.1/TMath::Sqrt(num));
-  fC30 = 0; fC31 = -points[pos].fSigmaZ2; fC32 = 0; fC33 = 2*(points[pos].fSigmaZ2);
-  fC40 = -points[pos].fSigmaY2; fC41 = 0; fC42 = 0; fC43 = 0; fC44 = 2*(points[pos].fSigmaY2);*/
+  fC20 = 0.0005; fC21 = 0; fC22 = 5.5e-05;
+  fC30 = 0.0001; fC31 = 0.001;
+  fC32 = 5.5e-06; fC33 = 6.5e-05;
+  fC40 = 5e-06;
+  fC41 = 0; fC42 = 4e-07; fC43 = 4e-08; fC44 = 3e-09;*/
   //cout << "Init: errors " << fC00 << " " << fC11 << " " << fC22 << " " << fC33 << " " << fC44 << endl;
 
   fChisq = 0;
@@ -123,7 +190,8 @@ Int_t AliL3KalmanTrack::Propagate(AliL3SpacePointData *points, UInt_t pos, Int_t
   xyz[0] = points[pos].fX;
   xyz[1] = points[pos].fY;
 
-  AliL3Transform::Global2Local(xyz,slice);
+  //AliL3Transform::Global2Local(xyz,slice);
+  AliL3Transform::Global2LocHLT(xyz,slice);
   
   Float_t Xnew = xyz[0];
   Float_t dx = Xnew - Xold; //cout << Xnew << endl;
@@ -135,8 +203,8 @@ Int_t AliL3KalmanTrack::Propagate(AliL3SpacePointData *points, UInt_t pos, Int_t
     }
   
   // R must be approx. of the radius of the circle based on
-  // the old and new spacepoint. What then is Cod and Cnew??
-  // C has something to do with curvature at least.
+  // the old and new spacepoint. What then is Cold and Cnew??
+  // C has something to do with curvature at least (curvature times x).
 
   Float_t Cold = fP4*Xold - fP2; 
   //if (TMath::Abs(Cold) >= 1.0) Cold = 0.9;
@@ -175,7 +243,7 @@ Int_t AliL3KalmanTrack::Propagate(AliL3SpacePointData *points, UInt_t pos, Int_t
   Float_t f13 = dx*CC/CR;
   Float_t f14 = dx*fP3*(CR*XX-CC*(Rold*Xnew-Cnew*Cold*Xold/Rold + Rnew*Xold-Cold*Cnew*Xnew/Rnew))/(CR*CR);
 
-  // b = C*ft // This? 
+  // b = C*ft // This? MUST BE (f*C)t = Ct*ft??, that gives the expressions under at least.
   Float_t b00=f02*fC20 + f04*fC40;
   Float_t b01=f12*fC20 + f14*fC40 + f13*fC30;
   Float_t b10=f02*fC21 + f04*fC41;
@@ -192,7 +260,7 @@ Int_t AliL3KalmanTrack::Propagate(AliL3SpacePointData *points, UInt_t pos, Int_t
   Float_t a01 = f02*b21 + f04*b41;
   Float_t a11 = f12*b21 + f14*b41+f13*b31;
 
-  //F*C*Ft = C + (a + b + bt) /This is the covariance matrix, the samll t 
+  //F*C*Ft = C + (a + b + bt) , This is the covariance matrix, the samll t 
   // means transform. Then F must be df/dx 
   fC00 += a00 + 2*b00;
   fC10 += a01 + b01 + b10;
@@ -205,7 +273,7 @@ Int_t AliL3KalmanTrack::Propagate(AliL3SpacePointData *points, UInt_t pos, Int_t
   fC41 += b41;
 
   // Multiple scattering (from AliTPCtrack::PropagateTo)
-  // Shold this be included??
+  // Should this be included??
   /*
   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));
@@ -267,11 +335,11 @@ Int_t AliL3KalmanTrack::Propagate(AliL3SpacePointData *points, UInt_t pos, Int_t
       fC44 = oldfC44;
 
       return value;
-      }
+    }
   
   else 
     return value;
-  //return UpdateTrack(points, pos);
+  //return UpdateTrack(points, pos, slice);
 }
 
 Int_t AliL3KalmanTrack::UpdateTrack(AliL3SpacePointData *points, UInt_t pos, Int_t slice)
@@ -283,7 +351,8 @@ Int_t AliL3KalmanTrack::UpdateTrack(AliL3SpacePointData *points, UInt_t pos, Int
   xyz[0] = points[pos].fX;
   xyz[1] = points[pos].fY;
   
-  AliL3Transform::Global2Local(xyz,slice);
+  //AliL3Transform::Global2Local(xyz,slice);
+  AliL3Transform::Global2LocHLT(xyz,slice);
   
   //fX = points[pos].fX; 
   fX = xyz[0];
@@ -293,6 +362,15 @@ Int_t AliL3KalmanTrack::UpdateTrack(AliL3SpacePointData *points, UInt_t pos, Int
   Float_t sigmaZ2 = points[pos].fSigmaZ2;
   Float_t sigmaYZ = 0;
 
+  // points[pos].fSigmaY2 and Z2 is needed in calculation of chisq. 
+  // There use realSigmaZ2(z2), because sigmaY2(Z2) are changed underneath
+  // ANother possibility is to give realSigmaY2(Z2)(YZ) after += fC00(11)10 calculations. 
+  // After all it is these that are used in chisq calculation. 
+  // NB! In that case GetChisqIncrement must be changed so fC00(11)(10) are not added twice??. 
+  // Check if it's any change in timing.
+  Float_t realSigmaY2 = sigmaY2;
+  Float_t realSigmaZ2 = sigmaZ2;
+
   sigmaY2 += fC00;
   sigmaZ2 += fC11;
   sigmaYZ += fC10;
@@ -317,11 +395,11 @@ Int_t AliL3KalmanTrack::UpdateTrack(AliL3SpacePointData *points, UInt_t pos, Int
 
   // Deviation between the predicted and measured values of y and z 
   //Float_t dy = points[pos].fY-fP0; //cout << "dy = " << dy;
-  Float_t dy = xyz[1] - fP0; //cout << "dy = " << dy;
-  Float_t dz = points[pos].fZ-fP1; //cout << ", dz = " << dz << endl; 
+  Float_t dy = xyz[1] - fP0; //cout << dy << endl;;
+  Float_t dz = points[pos].fZ-fP1; //cout << dz << endl; 
   //cout << "Measured " << xyz[2] << " " << points[pos].fZ << endl;
 
-  // Prediction of fP2 and fP4
+  // Update of fP2 and fP4
   Float_t cur = fP4 + k40*dy + k41*dz; 
   Float_t eta = fP2 + k20*dy + k21*dz;
 
@@ -349,6 +427,7 @@ Int_t AliL3KalmanTrack::UpdateTrack(AliL3SpacePointData *points, UInt_t pos, Int
   Float_t c41 = fC41;
 
   // Filtered covariance matrix
+  // This is how it is in AliTPCtrack::Update
   fC00 -= k00*fC00 + k01*fC10;
   fC10 -= k00*c10 + k01*fC11;
   fC11 -= k10*c10 + k11*fC11;
@@ -364,19 +443,41 @@ Int_t AliL3KalmanTrack::UpdateTrack(AliL3SpacePointData *points, UInt_t pos, Int
   fC42 -= k20*c40 + k21*c41;
   fC43 -= k40*c30 + k41*c31;
   fC44 -= k40*c40 + k41*c41;
-  //cout << "AliL3KalmanTrack::Update, error " << fC00 << " " << fC11 << " " << fC22 << " " << fC33 << " " << fC44 << endl;
+  
+  // Alternative filtering
+  // This is how (I think) it should be from the Kalman filter equations, and the C-matrix in Propagate ??
+  /*Float_t c00 = fC00;
+  Float_t c11 = fC11;
+  fC00 -= k00*fC00 + k01*fC10;
+  fC10 -= k10*c00 + k11*fC10;
+  fC11 -= k10*c10 + k11*fC11;
+  fC20 -= k20*c00 + k21*c10;
+  fC21 -= k20*c10 + k21*c11;
+  fC22 -= k20*c20 + k21*c21;
+  fC30 -= k30*c00 + k31*c10;
+  fC31 -= k30*c10 + k31*c11;
+  fC32 -= k30*c20 + k31*c21;
+  fC33 -= k30*c30 + k31*c31;
+  fC40 -= k40*c00 + k41*c10;
+  fC41 -= k40*c10 + k41*c11;
+  fC42 -= k40*c20 + k41*c21;
+  fC43 -= k40*c30 + k41*c31;
+  fC44 -= k40*c40 + k41*c41;*/
 
-  sigmaY2 = sigmaY2*det;
+  /*  sigmaY2 = sigmaY2*det;
   sigmaZ2 = sigmaZ2*det;
-  sigmaYZ = sigmaYZ*det;
+  sigmaYZ = sigmaYZ*det;*/
   //cout << "AliL3KalmanTrack::Update, Chi2 = " << GetChisq() << endl;
   //cout << "AliKalmanTrack::Update, sigmaY2 = " << sigmaY2 << " sigmaZ2 = " << sigmaZ2 << " sigmaYZ = " << sigmaYZ << " dy = " << dy << " dz = " << dz << endl;
+
   // Calculate increase of chisquare
-  fChisq = GetChisq() + GetChisqIncrement(xyz[1],sigmaY2,points[pos].fZ,sigmaZ2);
-  //cout << "fChisq = " << fChisq << endl;
+  //fChisq = GetChisq() + GetChisqIncrement(xyz[1],sigmaY2,points[pos].fZ,sigmaZ2);
+  fChisq = GetChisq() + GetChisqIncrement(xyz[1],realSigmaY2,points[pos].fZ,realSigmaZ2);
+  //fChisq = GetChisq() + GetChisqIncrement(points[pos].fY,realSigmaY2,points[pos].fZ,realSigmaZ2);
+ //cout << "fChisq = " << fChisq << endl;
 //(dy*sigmaY2*dy + 2*sigmaYZ*dy*dz + dz*sigmaZ2*dz) / (sigmaY2*sigmaZ2 - sigmaYZ*sigmaYZ);
   // Must at some point make an cut on chisq. Here?
-  //if (fChisq > fMaxChi2) return 0;
+  //  if (fChisq > fMaxChi2) return 0;
 
   return 1;
 } 
@@ -399,7 +500,8 @@ Float_t AliL3KalmanTrack::GetChisqIncrement(Float_t y, Float_t error_y, Float_t
   Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
   
   Double_t dy=y - fP0, dz=z - fP1;
-  //cout << "AliTPCtrack::GetPredictedChi2, r00 = " << r00 << " r11 = " << r11 << " ro1 = " << r01 << " dy = " << dy << " dz = " << dz << endl;
+  //cout << det << endl;
+  //cout << "dy = " << dy << " , dz = " << dz << " , r00 = " << r00 << " , r01 = " << r01 << " r11 = " << r11 << endl;
   return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
 }
 
@@ -658,7 +760,7 @@ Int_t AliL3KalmanTrack::UpdateOfflineTrack(Double_t x, Double_t y, Double_t z, D
   Float_t k40 = fC40*sigmaY2 + fC41*sigmaYZ, k41 = fC40*sigmaYZ + fC41*sigmaZ2;
   //cout << "x = " << fX << endl;
   // Deviation between the predicted and measured values of y and z
-  Float_t dy = y-fP0; //cout << "dy = " << dy;
+  Float_t dy = y-fP0; //cout << dy << endl;
   Float_t dz = z-fP1; //cout << ", dz = " << dz << endl;
   //cout << "Measured " << points[pos].fY << " " << points[pos].fZ << endl;
   
index fbd722c..de3b124 100644 (file)
@@ -59,6 +59,7 @@ class AliL3KalmanTrack : public AliL3Track {
 
   AliL3KalmanTrack();
   virtual ~AliL3KalmanTrack();
+Int_t MakeSeed(AliL3Track *track, AliL3SpacePointData *points0, UInt_t pos0, Int_t slice0, AliL3SpacePointData *points1, UInt_t pos1, Int_t slice1, AliL3SpacePointData *points2, UInt_t pos2, Int_t slice2);
   Int_t Init(AliL3Track *track, AliL3SpacePointData *points, UInt_t pos,Int_t slice);
   Int_t Propagate(AliL3SpacePointData *points, UInt_t pos, Int_t slice);
   Int_t UpdateTrack(AliL3SpacePointData *points, UInt_t pos, Int_t slice);
@@ -150,6 +151,7 @@ class AliL3KalmanTrack : public AliL3Track {
   Int_t PropagateOfflineTrack(Double_t x, Double_t y, Double_t z, Double_t ey, Double_t ez);
   Int_t UpdateOfflineTrack(Double_t x, Double_t y, Double_t z, Double_t ey, Double_t ez);
   Float_t GetChisqIncrementOfflineTrack(Double_t y, Double_t z, Double_t ey, Double_t ez);
+  
 };
 
 #endif
index 72c9ac2..357c97d 100644 (file)
@@ -149,7 +149,6 @@ AliL3DigitRowData * AliL3DDLDataFileHandler::DDLData2Memory(UInt_t &nrow,Int_t e
   
   Int_t nrows=fRowMax-fRowMin+1;
   Int_t ndigitcount=0;
-  //  Int_t ndigits[nrows];
   Int_t * ndigits = new Int_t[nrows];
   UShort_t ***charges=new UShort_t**[nrows];
   for(Int_t r=fRowMin;r<=fRowMax;r++){
index 6d024d0..3090351 100644 (file)
@@ -3,6 +3,12 @@
 // Author: Constantin Loizides <mailto:loizides@ikf.uni-frankfurt.de>
 //*-- Copyright &copy ALICE HLT Group
 
+#ifdef use_root
+#include <Riostream.h>
+#else
+#include <iostream.h>
+#endif
+
 #include "AliL3RootTypes.h"
 #include "AliL3StandardIncludes.h"
 #include "AliL3Logging.h"
@@ -50,11 +56,7 @@ AliL3DDLRawReaderFile::AliL3DDLRawReaderFile(const Char_t* name, Bool_t addnum)
   strcpy(fFileName,name);
   if (!addnum) {
     fFileNumber = -1;
-#ifndef __DECCXX
     fStream = new fstream(fFileName, ios::binary|ios::in);
-#else
-    fStream = new fstream(fFileName, ios::in);
-#endif
   } else {
     fFileNumber = 0;
     fStream = NULL;
@@ -71,11 +73,7 @@ AliL3DDLRawReaderFile::~AliL3DDLRawReaderFile()
   if(fFileName) delete fFileName;
 
   if (fStream) {
-#if defined(__HP_aCC) || defined(__DECCXX)
-    if (fStream->rdbuf()->is_open()) fStream->close();
-#else
     if (fStream->is_open()) fStream->close();
-#endif
     delete fStream;
   }
   delete fMiniHeader;
@@ -85,11 +83,7 @@ AliL3DDLRawReaderFile::~AliL3DDLRawReaderFile()
 Bool_t AliL3DDLRawReaderFile::OpenNextFile()
 {
   if (fStream) {
-#if defined(__HP_aCC) || defined(__DECCXX)
-    if (fStream->rdbuf()->is_open()) fStream->close();
-#else
     if (fStream->is_open()) fStream->close();
-#endif
     delete fStream;
     fStream = NULL;
   }
@@ -103,16 +97,8 @@ Bool_t AliL3DDLRawReaderFile::OpenNextFile()
   Char_t fileName[1024];
   sprintf(fileName, "%s%d", fFileName, fFileNumber);
 
-#ifndef __DECCXX
   fStream = new fstream(fileName, ios::binary|ios::in);
-#else
-  fStream = new fstream(fileName, ios::in);
-#endif
-#if defined(__HP_aCC) || defined(__DECCXX)
-  return (fStream->rdbuf()->is_open());
-#else
   return (fStream->is_open());
-#endif
 }
 
 Bool_t AliL3DDLRawReaderFile::ReadMiniHeader()
@@ -177,11 +163,7 @@ Bool_t AliL3DDLRawReaderFile::Reset()
   // reset the current stream position to the beginning of the file
 
   if ((fFileNumber > 0) && fStream) {
-#if defined(__HP_aCC) || defined(__DECCXX)
-    if (fStream->rdbuf()->is_open()) fStream->close();
-#else
     if (fStream->is_open()) fStream->close();
-#endif
     delete fStream;
     fStream = NULL;
     fFileNumber = 0;
@@ -189,11 +171,7 @@ Bool_t AliL3DDLRawReaderFile::Reset()
 
   if (!fStream) {
     if (fFileNumber < 0) {
-#ifndef __DECCXX
       fStream = new fstream(fFileName, ios::binary|ios::in);
-#else
-      fStream = new fstream(fFileName, ios::in);
-#endif
     } else {
       if (!OpenNextFile()){
        LOG(AliL3Log::kError,"AliL3DDLRawReaderFile::Reset","Data")
index 4334179..a0baddb 100644 (file)
@@ -82,7 +82,8 @@ CXXFLAGS       = -O2 -Wall -ggdb $(CXXGCC3FLAGS) $(EXTRACXXFLAGS)
 LDFLAGS        = -O2 $(EXTRALDFLAGS) $(LIBS)
 STATICLDFLAGS  = -O2 $(PROFILEFLAGS) $(EXTRALDFLAGS) $(STATICLIBS)
 
-PRGS   = runit read runvhdlcf runhough runvhdlhough runtracker
+
+PRGS   =  runit read runvhdlcf runhough runvhdlhough runtracker tpcbeamtesttracker tpcbeamtestdisplay
 STPRGS = 
 UTILS   = ccfile gettransform
 STUTILS = gettransform_st runit_st
@@ -121,6 +122,14 @@ runit_st: runit.sto
 runtracker: runtracker.o
        $(LD) $< $(STATICLDFLAGS) -o $@
 
+#TPC Test cluster finder and tracker
+tpcbeamtesttracker: tpcbeamtesttracker.o
+       $(LD) $< $(LDFLAGS) -o $@
+
+#TPC Test display
+tpcbeamtestdisplay: tpcbeamtestdisplay.o
+       $(LD) $< $(LDFLAGS) -o $@
+
 #read l3 raw data, print it and convert to altro data
 read: read.o
        $(LD) $< $(LDFLAGS) -o $@
@@ -153,6 +162,5 @@ speedtest: speedtest.cxx
        $(CXX) $(PROFILEFLAGS) $(CXXFLAGS) $(DEFSTR) -c $(INCLUDES) -o $@ $<
 
 clean :
-       rm -f *.o *.sto $(PRGS) $(UTILS) $(STPRGS) $(STUTILS) $(UTILS_not_working)
-
+       rm -f *.o *.sto gmon.out $(PRGS) $(UTILS) $(STPRGS) $(STUTILS) $(UTILS_not_working)
 
index f6b4aef..1f888ad 100644 (file)
@@ -17,6 +17,14 @@ using namespace std;
 //#define DEBUG
 //#define NOCONV
 
+//this flag is for the cosmics/pubsub test
+//#define ADDFILESIZE
+
+#ifdef ADDFILESIZE
+#include <sys/stat.h>
+struct stat stat_results;
+#endif
+
 Int_t Convert4(Int_t i)
 { //BigEndian i0i1i2i3 -> LittleEndian i3i2i1i0
 #ifdef NOCONV
@@ -49,8 +57,6 @@ Short_t Convert2(Short_t s)
 #endif
 }
 
-
-
 int main(Int_t argc, Char_t **argv)
 {
   //p1 -> filename
@@ -72,9 +78,6 @@ int main(Int_t argc, Char_t **argv)
     islittle=1;
   }
 
-  Char_t sname[1024];
-  sprintf(sname,"%s.conv",fname);
-
   ifstream *in = new ifstream();
   in->open(fname,fstream::binary);
   if(!in->is_open()){
@@ -82,6 +85,12 @@ int main(Int_t argc, Char_t **argv)
     exit(1);
   }
 
+  Char_t sname[1024];
+#ifdef ADDFILESIZE
+  sprintf(sname,"%s.added",fname);
+#else
+  sprintf(sname,"%s.conv",fname);
+#endif
   ofstream *out = new ofstream();
   out->open(sname,fstream::in | fstream::out | fstream::binary | fstream::trunc);
   if(!in->is_open()){
@@ -89,8 +98,19 @@ int main(Int_t argc, Char_t **argv)
     exit(1);
   }
 
+
   Int_t dummy4;
   Short_t dummy2;
+#ifdef ADDFILESIZE
+  if (stat(fname, &stat_results) == 0){
+    dummy4=stat_results.st_size/4;
+    cout << "Add file size: " << dummy4 << endl;
+  } else {
+    cerr << "Error stating input file " << fname << endl;
+    exit(1);
+  }
+  out->write((Char_t*)&dummy4,sizeof(dummy4));
+#endif
 
   in->read((Char_t*)&dummy4,sizeof(dummy4));
   const Int_t knumofChannels = Convert4(dummy4);
diff --git a/HLT/programs/tpcbeamtestdisplay.cxx b/HLT/programs/tpcbeamtestdisplay.cxx
new file mode 100644 (file)
index 0000000..dd43680
--- /dev/null
@@ -0,0 +1,162 @@
+// $Id$
+
+#include "AliL3StandardIncludes.h"
+#include "AliL3RootTypes.h"
+#include "AliLevel3.h"
+#include "AliL3Transform.h"
+#include "AliL3RawDataFileHandler.h"
+#include "AliL3SpacePointData.h"
+#include "AliL3ClustFinderNew.h"
+#include "AliL3ConfMapper.h"
+#include "AliL3Vertex.h"
+#include "AliL3MemHandler.h"
+#include "AliL3Logging.h"
+#include "AliL3TrackArray.h"
+#include "AliL3Track.h"
+#include <TCanvas.h>
+#include <TH2.h>
+#include <TView.h>
+#include <TApplication.h>
+#include <TColor.h>
+#include <TPaletteAxis.h>
+#include <TStyle.h>
+#include <TFormula.h>
+#include <TF1.h>
+#include <TLine.h>
+#include <TAttLine.h>
+#if __GNUC__== 3
+using namespace std;
+#else
+#include <stream.h>
+#include <string.h>
+#include <stdlib.h>
+#endif
+
+//This program does the clusterfinding and the tracking.
+int main(Int_t argc,Char_t **argv){
+
+  //Display all clusters.
+    
+  Char_t cfile[1024];
+  Char_t path[1024];  
+  Char_t fname[1024];  
+
+  if(argc<3){
+    cout<<"Usage: tpcbeamtestdisplay filename path_to_files"<<endl;
+    return -1;
+  }
+  if (argc>2) {
+    sprintf(cfile,"%s",argv[1]);
+    sprintf(path,"%s",argv[2]);
+  }
+
+  //displaying the tracks:
+  UInt_t fNcl;
+  AliL3MemHandler *clusterfile = new AliL3MemHandler();
+  sprintf(fname,"%s/%s-points_0_-1.raw",path,cfile);
+  cout<<"file: "<<fname<<endl;
+  if(!clusterfile->SetBinaryInput(fname)){
+    cout<<"file: "<<fname<<" can not be set as binary input!"<<endl;
+    LOG(AliL3Log::kError,"AliL3Evaluation::Setup","File Open")
+      <<"Inputfile "<<fname<<" does not exist"<<ENDLOG; 
+    delete clusterfile;
+    clusterfile = 0; 
+  }
+  clusterfile->SetBinaryInput(fname);
+  AliL3SpacePointData *fClusters = new AliL3SpacePointData();
+  memset(fClusters,0,sizeof(AliL3SpacePointData*));
+  fClusters = (AliL3SpacePointData*)clusterfile->Allocate();
+  clusterfile->Binary2Memory(fNcl,fClusters);
+  clusterfile->CloseBinaryInput();
+  TApplication theApp("App", &argc, argv);
+  TCanvas *c1 = new TCanvas("c1","",900,700);
+  c1->cd();
+
+  c1->Clear();
+  c1->SetFillColor(1);
+  
+  AliL3SpacePointData *points = fClusters;
+  TH2F *clusters = new TH2F("clusters","",65,-1,64,77,17,94);
+  if(!points)
+    cout<<"no points"<<endl;
+  Int_t npoints = fNcl;
+  //  cout<<"number of points: "<<npoints<<endl;
+  for(Int_t i=0; i<npoints; i++){
+    float x_tmp = points[i].fX;
+    float y_tmp = points[i].fY;
+    //    cout<<"x: "<<x_tmp<<" y: "<<y_tmp<<endl;
+    clusters->Fill(x_tmp,y_tmp,1); 
+  }
+  TH2F *nothing = new TH2F(cfile,"",65,-1,64,77,17,94);
+//  nothing->SetName("Test");
+  //Adding a regression method to calculate the line parameters.
+  float *x=new float[npoints];
+  float *y=new float[npoints];
+  float xyParamA=0;
+  float xyParamB=0;
+  
+  Int_t numofXYPoints=npoints;
+
+  float sumX=0;
+  float sumY=0;
+
+  float sumXtimesY=0;
+  float sumXsquare=0;
+  float sumYsquare=0;
+
+
+  for(Int_t i=0; i<npoints; i++){
+    x[i] = points[i].fX;
+    y[i] = points[i].fY;
+    sumX+=x[i];
+    sumY+=y[i];
+    sumXtimesY+=x[i]*y[i];
+    sumXsquare+=x[i]*x[i];
+    sumYsquare+=y[i]*y[i];
+  }
+  
+
+
+  if(numofXYPoints*sumXsquare-sumX*sumX!=0)
+    xyParamB=(numofXYPoints*sumXtimesY-sumX*sumY)/(numofXYPoints*sumXsquare-sumX*sumX);
+  else
+    cout<<"Divident is zero calculating the xParamB, numofXYPoints*sumXsquare-sumX*sumX=0"<<endl;
+  if(numofXYPoints!=0)
+    xyParamA=(sumY-xyParamB*sumX)/numofXYPoints;
+  else
+    cout<<"Divident is zero calculating the xParamA, numofXYPoints=0"<<endl;
+  
+  //cout<<"y= a + bx : "<<"y= "<<xyParamA<<" + "<<xyParamB<<" x"<<endl;
+
+  TF1 *line = new TF1("line","[0]+[1]*x",0,63);
+  line->SetParameters(xyParamA,xyParamB);
+  TLine *leftline= new TLine(0,(0-AliL3Transform::GetNPads(0)/2+55),0,AliL3Transform::GetNPads(0)-(AliL3Transform::GetNPads(0)/2)+55);
+  TLine *rightline=new TLine(63,(0-AliL3Transform::GetNPads(63)/2+55),63,AliL3Transform::GetNPads(63)-(AliL3Transform::GetNPads(63)/2)+55);
+  TLine *upperline=new TLine(0,(AliL3Transform::GetNPads(0)-AliL3Transform::GetNPads(0)/2+55),63,AliL3Transform::GetNPads(63)-(AliL3Transform::GetNPads(63)/2)+55);
+  TLine *underline=new TLine(0,(0-AliL3Transform::GetNPads(0)/2+55),63,0-(AliL3Transform::GetNPads(63)/2)+55);
+  
+  nothing->Draw("colz");
+  nothing->SetXTitle("Padrows");
+  nothing->SetYTitle("Pads");
+  clusters->SetMarkerStyle(22);
+  clusters->Draw("same");
+
+  line->Draw("same");
+  line->SetLineColor(2);
+  leftline->Draw("same");
+  leftline->SetLineWidth(2);
+  rightline->Draw("same");
+  rightline->SetLineWidth(2);
+  upperline->Draw("same");
+  upperline->SetLineWidth(2);
+  underline->Draw("same");
+  underline->SetLineWidth(2);
+  
+
+  c1->SetFillColor(10);
+  c1->Update();
+  c1->Draw();
+  while(1){
+
+  }
+}
diff --git a/HLT/programs/tpcbeamtesttracker.cxx b/HLT/programs/tpcbeamtesttracker.cxx
new file mode 100644 (file)
index 0000000..5c83950
--- /dev/null
@@ -0,0 +1,118 @@
+// $Id$
+
+#include "AliL3StandardIncludes.h"
+#include "AliL3RootTypes.h"
+#include "AliLevel3.h"
+#include "AliL3Transform.h"
+#include "AliL3RawDataFileHandler.h"
+#include "AliL3SpacePointData.h"
+#include "AliL3ClustFinderNew.h"
+#include "AliL3ConfMapper.h"
+#include "AliL3Vertex.h"
+
+#if __GNUC__== 3
+using namespace std;
+#else
+#include <stream.h>
+#include <string.h>
+#include <stdlib.h>
+#endif
+
+
+#include <sys/stat.h>
+struct stat stat_results;
+
+
+//This program does the clusterfinding and the tracking.
+int main(Int_t argc,Char_t **argv)
+{
+
+  Char_t cfile[1024];
+  Char_t path[1024]; 
+  Int_t slice=0;
+  Int_t patch=-1;
+  
+  if(argc<3){
+    cout<<"Usage: tpcbeamtesttracker filename path_to_cosmics"<<endl;
+    return -1;
+  }
+  if (argc>2) {
+    sprintf(cfile,"%s",argv[1]);
+    sprintf(path,"%s",argv[2]);
+  }
+
+  AliL3Transform::Init("./l3-cosmics-transform.config");
+  AliL3Transform::SetZeroSup(5);
+  AliL3RawDataFileHandler *f=new AliL3RawDataFileHandler();
+
+  f->Init(slice,patch);
+  
+  f->SetMappingFile("remap.txt");
+  f->ReadMappingFile();
+
+  Char_t fname[1024];
+  Char_t pname[1024];
+
+  f->SetRawPedestalsInput("./pedout.out");
+  f->ReadRawPedestalsInput();
+  //f->SetPedVal(85);
+
+  sprintf(pname,"%s/%s",path,cfile);
+#if 0
+  f->SetRawInput(pname);
+  f->ReadRawInput();
+#else
+  if (stat(pname, &stat_results) != 0){
+    exit(1);
+  }
+  Char_t *t=new Char_t[stat_results.st_size];
+  ifstream *fin=new ifstream(pname,fstream::binary);
+  fin->read(t,stat_results.st_size);
+  delete fin;
+  f->ReadRawInputPointer(t);
+#endif
+
+  UInt_t nrows;
+  AliL3DigitRowData *data=(AliL3DigitRowData*)f->RawData2Memory(nrows);
+
+  AliL3MemHandler *out = new AliL3MemHandler();
+  sprintf(fname,"./%s-digits_%d_%d.raw",cfile,slice,patch);
+  out->SetBinaryOutput(fname);
+  out->Memory2Binary(nrows,data);
+  out->CloseBinaryOutput();
+  out->Free();
+
+  AliL3MemHandler *mem=new AliL3MemHandler();
+
+  UInt_t maxclusters=100000;
+  UInt_t pointsize = maxclusters*sizeof(AliL3SpacePointData);
+  AliL3SpacePointData *points = (AliL3SpacePointData*)mem->Allocate(pointsize);
+
+  Bool_t rawsp=kTRUE;
+  AliL3ClustFinderNew *cf = new AliL3ClustFinderNew();
+  cf->InitSlice(slice,patch,maxclusters);
+  cf->SetMatchWidth(10);
+  cf->SetSTDOutput(kTRUE);
+  cf->SetRawSP(rawsp);
+  cf->SetThreshold(10);
+  cf->SetDeconv(kFALSE);
+  cf->SetCalcErr(kTRUE);
+  cf->SetOutputArray(points);
+  cf->Read(nrows,data);
+  cf->ProcessDigits();
+  Int_t npoints = cf->GetNumberOfClusters();
+
+  sprintf(fname,"./%s-points_%d_%d.raw",cfile,slice,patch);
+  out->Transform(npoints,points,slice);
+  out->SetBinaryOutput(fname);
+  out->Memory2Binary(npoints,points);
+  out->CloseBinaryOutput();
+  out->Free();
+
+  delete out;
+  delete mem;
+  delete cf;
+  delete f;
+
+
+}
index e69de29..0860e17 100644 (file)
@@ -0,0 +1,243 @@
+// $Id$
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// class for HLT reconstruction                                              //
+// <Cvetan.Cheshkov@cern.ch>                                                 //
+///////////////////////////////////////////////////////////////////////////////
+
+// very ugly but it has to work fast
+#ifdef use_reconstruction
+
+#include <Riostream.h>
+#include <TSystem.h>
+#include <TArrayF.h>
+
+#include "AliL3StandardIncludes.h"
+#include "AliLevel3.h"
+#include "AliL3Evaluate.h"
+#include "AliHLTReconstructor.h"
+#include "AliL3Transform.h"
+#include "AliL3Hough.h"
+#include "AliL3FileHandler.h"
+#include "AliL3Track.h"
+#include "AliL3HoughTrack.h"
+#include "AliL3TrackArray.h"
+#include "AliRunLoader.h"
+#include "AliHeader.h"
+#include "AliGenEventHeader.h"
+#include "AliESD.h"
+#include "AliESDHLTtrack.h"
+
+#if __GNUC__== 3
+using namespace std;
+#endif
+
+
+ClassImp(AliHLTReconstructor)
+
+void AliHLTReconstructor::Reconstruct(AliRunLoader* runLoader) const
+{
+  gSystem->Exec("rm -rf hlt");
+  gSystem->MakeDirectory("hlt");
+  gSystem->Exec("rm -rf hough");
+  gSystem->MakeDirectory("hough");
+  gSystem->Exec("rm -f alirunfile.root");
+  gSystem->Exec("ln -s galice.root alirunfile.root");
+
+  Bool_t isinit=AliL3Transform::Init("./",kTRUE);
+  if(!isinit){
+    cerr << "Could not create transform settings, please check log for error messages!" << endl;
+    return;
+  }
+
+  Int_t nEvents = runLoader->GetNumberOfEvents();
+
+  for(Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
+    runLoader->GetEvent(iEvent);
+
+    ReconstructWithConformalMapping(runLoader,iEvent);
+    ReconstructWithHoughTransform(runLoader,iEvent);
+  }
+}
+
+void AliHLTReconstructor::ReconstructWithConformalMapping(AliRunLoader* runLoader,Int_t iEvent) const
+{
+  AliLevel3 *fHLT = new AliLevel3(runLoader);
+  fHLT->Init("./", AliLevel3::kRunLoader, 1);
+
+  Int_t phiSegments = 50;
+  Int_t etaSegments = 100;
+  Int_t trackletlength = 3;
+  Int_t tracklength = 10;
+  Int_t rowscopetracklet = 2;
+  Int_t rowscopetrack = 10;
+  Double_t minPtFit = 0;
+  Double_t maxangle = 0.1745;
+  Double_t goodDist = 5;
+  Double_t maxphi = 0.1;
+  Double_t maxeta = 0.1;
+  Double_t hitChi2Cut = 20;
+  Double_t goodHitChi2 = 5;
+  Double_t trackChi2Cut = 10;
+  Double_t xyerror = -1;
+  Double_t zerror =  -1;
+  
+  fHLT->SetClusterFinderParam(xyerror,zerror,kTRUE);
+  fHLT->SetTrackerParam(phiSegments, etaSegments, 
+                       trackletlength, tracklength,
+                       rowscopetracklet, rowscopetrack,
+                       minPtFit, maxangle, goodDist, hitChi2Cut,
+                       goodHitChi2, trackChi2Cut, 50, maxphi, maxeta, kTRUE);
+  fHLT->SetMergerParameters(2,3,0.003,0.1,0.05);
+  fHLT->DoMc();
+  fHLT->WriteFiles("./hlt/");  
+
+  fHLT->ProcessEvent(0, 35, iEvent);
+
+  char filename[256];
+  sprintf(filename, "confmap_%d",iEvent);
+  fHLT->DoBench(filename);
+
+  delete fHLT;
+
+}
+
+void AliHLTReconstructor::ReconstructWithHoughTransform(AliRunLoader* runLoader,Int_t iEvent) const
+{
+  Float_t ptmin = 0.1*AliL3Transform::GetSolenoidField();
+
+  Float_t zvertex = 0;
+  TArrayF mcVertex(3); 
+  runLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
+  zvertex = mcVertex[2];
+
+  cout<<" Hough Tranform will run with ptmin="<<ptmin<<" and zvertex="<<zvertex<<endl;
+
+  AliL3Hough *hough = new AliL3Hough();
+    
+  hough->SetThreshold(4);
+  hough->SetTransformerParams(76,140,ptmin,-1);
+  hough->SetPeakThreshold(70,-1);
+  hough->SetRunLoader(runLoader);
+  hough->Init("./", kFALSE, 100, kFALSE,4,0,0,zvertex);
+  hough->SetAddHistograms();
+
+  for(int slice=0; slice<=35; slice++)
+    {
+      //     cout<<"Processing slice "<<slice<<endl;
+      hough->ReadData(slice,iEvent);
+      hough->Transform();
+      hough->AddAllHistogramsRows();
+      hough->FindTrackCandidatesRow();
+      //     hough->WriteTracks(slice,"./hough");
+      hough->AddTracks();
+    }
+  hough->WriteTracks("./hough");
+  
+  char filename[256];
+  sprintf(filename, "hough_%d",iEvent);
+  hough->DoBench(filename);
+
+  delete hough;
+}
+
+void AliHLTReconstructor::FillESD(AliRunLoader* runLoader, 
+                                 AliESD* esd) const
+{
+  Int_t iEvent = runLoader->GetEventNumber();
+
+  FillESDforConformalMapping(esd,iEvent);
+  FillESDforHoughTransform(esd,iEvent);
+}
+
+void AliHLTReconstructor::FillESDforConformalMapping(AliESD* esd,Int_t iEvent) const
+{
+  //Assign MC labels for found tracks
+  int slicerange[2]={0,35};
+  int good = (int)(0.4*AliL3Transform::GetNRows());
+  int nclusters = (int)(0.4*AliL3Transform::GetNRows());
+  float ptmin = 0.;
+  float ptmax = 0.;
+  float maxfalseratio = 0.1;
+  
+  AliL3Evaluate *fHLTEval = new AliL3Evaluate("./hlt",nclusters,good,ptmin,ptmax,slicerange);
+  fHLTEval->SetMaxFalseClusters(maxfalseratio);
+
+  fHLTEval->LoadData(iEvent,kTRUE);
+  fHLTEval->AssignPIDs();
+  fHLTEval->AssignIDs();
+  AliL3TrackArray *fTracks = fHLTEval->GetTracks();
+  for(Int_t i=0; i<fTracks->GetNTracks(); i++)
+    {
+      AliL3Track *tpt = (AliL3Track *)fTracks->GetCheckedTrack(i);
+      if(!tpt) continue; 
+      
+      AliESDHLTtrack *esdtrack = new AliESDHLTtrack() ; 
+
+      esdtrack->SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
+      esdtrack->SetNHits(tpt->GetNHits());
+      esdtrack->SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
+      esdtrack->SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
+      esdtrack->SetPt(tpt->GetPt());
+      esdtrack->SetPsi(tpt->GetPsi());
+      esdtrack->SetTgl(tpt->GetTgl());
+      esdtrack->SetCharge(tpt->GetCharge());
+      esdtrack->SetMCid(tpt->GetMCid());
+      esdtrack->SetSector(tpt->GetSector());
+      esdtrack->SetPID(tpt->GetPID());
+      esdtrack->ComesFromMainVertex(tpt->ComesFromMainVertex());
+
+      esd->AddHLTConfMapTrack(esdtrack);
+      delete esdtrack;
+    }
+
+  delete fHLTEval;
+}
+
+void AliHLTReconstructor::FillESDforHoughTransform(AliESD* esd,Int_t iEvent) const
+{
+  char filename[256];
+  sprintf(filename,"./hough/tracks_%d.raw",iEvent);
+  
+  AliL3FileHandler *tfile = new AliL3FileHandler();
+  if(!tfile->SetBinaryInput(filename)){
+    Error("FillESD","Inputfile ",filename," does not exist");
+    return;
+  }
+  
+  AliL3TrackArray *fTracks = new AliL3TrackArray("AliL3HoughTrack");
+  tfile->Binary2TrackArray(fTracks);
+  tfile->CloseBinaryInput();
+  delete tfile;
+  
+  for(Int_t i=0; i<fTracks->GetNTracks(); i++)
+    {
+      AliL3HoughTrack *tpt = (AliL3HoughTrack *)fTracks->GetCheckedTrack(i);
+      if(!tpt) continue; 
+      
+      AliESDHLTtrack *esdtrack = new AliESDHLTtrack() ; 
+
+      esdtrack->SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
+      esdtrack->SetNHits(tpt->GetNHits());
+      esdtrack->SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
+      esdtrack->SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
+      esdtrack->SetPt(tpt->GetPt());
+      esdtrack->SetPsi(tpt->GetPsi());
+      esdtrack->SetTgl(tpt->GetTgl());
+      esdtrack->SetCharge(tpt->GetCharge());
+      esdtrack->SetMCid(tpt->GetMCid());
+      esdtrack->SetWeight(tpt->GetWeight());
+      esdtrack->SetSector(tpt->GetSector());
+      esdtrack->SetBinXY(tpt->GetBinX(),tpt->GetBinY(),tpt->GetSizeX(),tpt->GetSizeY());
+      esdtrack->SetPID(tpt->GetPID());
+      esdtrack->ComesFromMainVertex(tpt->ComesFromMainVertex());
+
+      esd->AddHLTHoughTrack(esdtrack);
+      delete esdtrack;
+    }
+
+  delete fTracks;
+}
+
+#endif
index e69de29..61992e6 100644 (file)
@@ -0,0 +1,27 @@
+#ifndef ALIHLTRECONSTRUCTOR_H
+#define ALIHLTRECONSTRUCTOR_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+#ifdef use_reconstruction
+#include "AliReconstructor.h"
+
+
+class AliHLTReconstructor: public AliReconstructor {
+public:
+  AliHLTReconstructor(): AliReconstructor() {};
+  virtual ~AliHLTReconstructor() {};
+  virtual void         Reconstruct(AliRunLoader* runLoader) const;
+  virtual void         FillESD(AliRunLoader* runLoader, AliESD* esd) const;
+
+private:
+  void ReconstructWithConformalMapping(AliRunLoader* runLoader,Int_t iEvent) const;
+  void ReconstructWithHoughTransform(AliRunLoader* runLoader,Int_t iEvent) const;
+  void FillESDforConformalMapping(AliESD* esd,Int_t iEvent) const;
+  void FillESDforHoughTransform(AliESD* esd,Int_t iEvent) const;
+
+  ClassDef(AliHLTReconstructor, 0)   // class for the TPC reconstruction
+};
+#endif
+
+#endif
index 32ce440..d1a4855 100644 (file)
@@ -13,6 +13,10 @@ struct AliL3DigitData
   UShort_t fCharge;
   UChar_t fPad;
   UShort_t fTime;
+#ifdef IA64
+  UChar_t dummy1;
+  UChar_t dummy2;
+#endif
 };
 typedef struct AliL3DigitData AliL3DigitData;
 
index d535b6f..ac054ba 100644 (file)
@@ -199,6 +199,23 @@ AliL3Evaluate::~AliL3Evaluate()
   if(fNtupleRes) delete fNtupleRes;
 }
 
+void AliL3Evaluate::AssignPIDs()
+{
+  fTracks->QSort();
+  LOG(AliL3Log::kDebug,"AliL3Evaluate::AssignPIDs","Track Loop")
+    <<"Assigning pid to the found tracks...."<<ENDLOG;
+  for(Int_t i=0; i<fTracks->GetNTracks(); i++)
+    {
+      AliL3Track *track = (AliL3Track*)fTracks->GetCheckedTrack(i);
+      if(!track) continue; 
+      if(track->GetNumberOfPoints() < fMinPointsOnTrack)
+       track->SetPID(0);
+      else {
+       Float_t pid = GetTrackPID(track);
+       track->SetPID(pid);
+      }
+    }
+}
   
 void AliL3Evaluate::AssignIDs()
 {
@@ -224,6 +241,60 @@ void AliL3Evaluate::AssignIDs()
   //cout<<"Found "<<fGoodFound<<" good tracks "<<endl;
 }
 
+Float_t AliL3Evaluate::GetTrackPID(AliL3Track *track)
+{
+  track->CalculateHelix();
+  // Track dEdx
+  Int_t nc=track->GetNHits();
+  UInt_t *hits = track->GetHitNumbers();
+  Float_t sampleDEdx[159];
+  for (Int_t iHit = 0; iHit < nc; iHit++) {
+    UInt_t hitID = hits[iHit];
+    Int_t iSector = (hitID>>25) & 0x7f;
+    Int_t patch = (hitID>>22) & 0x7;
+    UInt_t position = hitID&0x3fffff;
+    AliL3SpacePointData *points = fClusters[iSector][patch];
+    if(!points) continue; 
+    if(position>=fNcl[iSector][patch]) 
+      {
+       LOG(AliL3Log::kError,"AliL3Evaluate::GetMCTrackLabel","Clusterarray")
+         <<AliL3Log::kDec<<"ERROR"<<ENDLOG;
+       continue;
+      }
+    UChar_t padrow = points[position].fPadRow;
+    Float_t pWidth = AliL3Transform::GetPadPitchWidthLow();
+    if (padrow>63)
+      pWidth = AliL3Transform::GetPadPitchWidthUp(); 
+    Float_t corr=1.; if (padrow>63) corr=0.67;
+    sampleDEdx[iHit] = points[position].fCharge/pWidth*corr;
+    Double_t crossingangle = track->GetCrossingAngle(padrow,iSector);
+    Double_t s = sin(crossingangle);
+    Double_t t = track->GetTgl();
+    sampleDEdx[iHit] *= sqrt((1-s*s)/(1+t*t));
+  }
+
+  /* Cook dEdx */
+  Int_t i;
+  Int_t swap;//stupid sorting
+  do {
+    swap=0;
+    for (i=0; i<nc-1; i++) {
+      if (sampleDEdx[i]<=sampleDEdx[i+1]) continue;
+      Float_t tmp=sampleDEdx[i];
+      sampleDEdx[i]=sampleDEdx[i+1]; sampleDEdx[i+1]=tmp;
+      swap++;
+    }
+  } while (swap);
+
+  Double_t low=0.05; Double_t up=0.7;
+  Int_t nl=Int_t(low*nc), nu=Int_t(up*nc);
+  Float_t trackDEdx=0;
+  for (i=nl; i<=nu; i++) trackDEdx += sampleDEdx[i];
+  trackDEdx /= (nu-nl+1);
+
+  cout<<" PID: "<<nc<<" "<<nl<<" "<<nu<<" "<<trackDEdx<<endl;
+  return trackDEdx;
+}
 
 struct S {Int_t lab; Int_t max;};
 Int_t AliL3Evaluate::GetMCTrackLabel(AliL3Track *track){ 
index 2689c5c..3429722 100644 (file)
@@ -92,11 +92,13 @@ class AliL3Evaluate {
   void FillEffHistos();
   void FillEffHistosNAIVE();
   void CalcEffHistos();
+  void AssignPIDs();
   void AssignIDs();
   void GetGoodParticles(Char_t *particle_file,Int_t event=-1,Int_t *padrowrange=0);
   void GetFastClusterIDs(Char_t *path);
   void GetCFeff(Char_t *path,Char_t *outfile,Int_t nevent=0,Bool_t sp=kFALSE);
   Int_t GetMCTrackLabel(AliL3Track *track);
+  Float_t GetTrackPID(AliL3Track *track);
   void CalculateResiduals();
   void EvaluatePoints(Char_t *rootfile,Char_t *exactfile,Char_t *tofile,Int_t nevent=1,Bool_t offline=kFALSE,Bool_t sp=kFALSE);
   Float_t GetCrossingAngle(TParticle *part,Int_t slice,Int_t padrow,Float_t *xyz);
index 7375049..8328be8 100644 (file)
@@ -139,6 +139,9 @@ AliL3FileHandler::AliL3FileHandler(Bool_t b)
 {
   //Default constructor
   fInAli = 0;
+#ifdef use_newio
+  fUseRunLoader = kFALSE;
+#endif
   fParam = 0;
   fMC =0;
   fDigits=0;
@@ -276,6 +279,7 @@ Bool_t AliL3FileHandler::SetAliInput(Char_t *name)
 Bool_t AliL3FileHandler::SetAliInput(AliRunLoader *runLoader)
 {
   fInAli=runLoader;
+  fUseRunLoader = kTRUE;
   if(!fInAli){
     LOG(AliL3Log::kWarning,"AliL3FileHandler::SetAliInput","File Open")
     <<"Pointer to AliRunLoader = 0x0 "<<ENDLOG;
@@ -308,14 +312,18 @@ Bool_t AliL3FileHandler::SetAliInput(TFile *file)
 
 void AliL3FileHandler::CloseAliInput()
 {
+#ifdef use_newio
+  if(fUseRunLoader) return;
+#endif
   if(!fInAli){
-    LOG(AliL3Log::kWarning,"AliL3FileHandler::CloseAliInput","File Close")
+    LOG(AliL3Log::kWarning,"AliL3FileHandler::CloseAliInput","RunLoader")
       <<"Nothing to Close"<<ENDLOG;
     return;
   }
 #ifndef use_newio
   if(fInAli->IsOpen()) fInAli->Close();
 #endif
+
   delete fInAli;
   fInAli = 0;
 }
@@ -470,7 +478,6 @@ AliL3DigitRowData * AliL3FileHandler::AliDigits2Memory(UInt_t & nrow,Int_t event
   Int_t nrows=0;
   Int_t ndigitcount=0;
   Int_t entries = (Int_t)fDigitsTree->GetEntries();
-  //  Int_t ndigits[entries];
   Int_t * ndigits = new Int_t[entries];
   Float_t xyz[3];
 
@@ -535,7 +542,6 @@ AliL3DigitRowData * AliL3FileHandler::AliDigits2Memory(UInt_t & nrow,Int_t event
        continue;
       }
 
-      //tempPt->fRow = lrow;
       tempPt->fNDigit = ndigits[lrow];
 
       Int_t localcount=0;
@@ -626,7 +632,6 @@ AliL3DigitRowData * AliL3FileHandler::AliAltroDigits2Memory(UInt_t & nrow,Int_t
   Int_t nrows=0;
   Int_t ndigitcount=0;
   Int_t entries = (Int_t)fDigitsTree->GetEntries();
-  //  Int_t ndigits[entries];
   Int_t * ndigits = new Int_t[entries];
   Int_t lslice,lrow;
   Int_t zerosupval=AliL3Transform::GetZeroSup();
@@ -635,6 +640,8 @@ AliL3DigitRowData * AliL3FileHandler::AliAltroDigits2Memory(UInt_t & nrow,Int_t
   for(Int_t r=fRowMin;r<=fRowMax;r++){
     Int_t n=fIndex[fSlice][r];
 
+    ndigits[r] = 0;
+
     if(n!=-1){//data on that row
       fDigitsTree->GetEvent(n);
       fParam->AdjustSectorRow(fDigits->GetID(),sector,row);
@@ -646,7 +653,6 @@ AliL3DigitRowData * AliL3FileHandler::AliAltroDigits2Memory(UInt_t & nrow,Int_t
        continue;
       }
 
-      ndigits[lrow] = 0;
       fDigits->ExpandBuffer();
       fDigits->ExpandTrackBuffer();
       for(Int_t i=0; i<fDigits->GetNCols(); i++){
@@ -783,7 +789,6 @@ AliL3DigitRowData * AliL3FileHandler::AliAltroDigits2Memory(UInt_t & nrow,Int_t
        continue;
       }
 
-      //tempPt->fRow = lrow;
       tempPt->fNDigit = ndigits[lrow];
 
       Int_t localcount=0;
@@ -917,7 +922,7 @@ AliL3DigitRowData * AliL3FileHandler::AliAltroDigits2Memory(UInt_t & nrow,Int_t
     }
     Byte_t *tmp = (Byte_t*)tempPt;
     Int_t size = sizeof(AliL3DigitRowData)
-      + ndigits[lrow]*sizeof(AliL3DigitData);
+      + ndigits[r]*sizeof(AliL3DigitData);
     tmp += size;
     tempPt = (AliL3DigitRowData*)tmp;
   }
index 0b916b8..89eded6 100644 (file)
@@ -27,9 +27,11 @@ class AliL3FileHandler:public AliL3MemHandler{
  protected:
 #ifdef use_newio
   AliRunLoader *fInAli;
+  Bool_t fUseRunLoader;
 #else
   TFile *fInAli;
 #endif
+
   AliTPCParam *fParam;
   virtual Bool_t SetAliInput();
   AliSimDigits *fDigits;
index e8f5b77..d3a6208 100644 (file)
 #include "AliL3TrackArray.h"
 #include "AliL3MemHandler.h"
 
+#if __GNUC__ == 3
+using namespace std;
+#endif
+
 /** \class AliL3MemHandler 
 <pre>
 //_____________________________________________________________
@@ -125,7 +129,7 @@ void AliL3MemHandler::ResetROI()
     }
 }
 
-void AliL3MemHandler::SetROI(Float_t *eta,Int_t */*slice*/)
+void AliL3MemHandler::SetROI(Float_t *eta,Int_t *slice)
 {
   // Init the Look-up table for the Region of Interest mode.
   //   Here you can specify a certain etaregion, - all data
@@ -519,7 +523,7 @@ Bool_t AliL3MemHandler::Binary2Memory(UInt_t & nrow,AliL3DigitRowData *data)
 }
 
 void AliL3MemHandler::AddData(AliL3DigitData *data,UInt_t & ndata,
-                             UInt_t /*row*/,UShort_t pad,UShort_t time,UShort_t charge)
+                             UInt_t row,UShort_t pad,UShort_t time,UShort_t charge)
 {
   data[ndata].fPad = pad;
   data[ndata].fTime = time;
index 45b185a..4ba932e 100644 (file)
@@ -12,6 +12,10 @@ class AliL3TrackSegmentData;
 class AliL3TrackArray;
 class AliL3RandomPointData;
 
+#ifdef use_newio
+class AliRunLoader;
+#endif
+
 class AliL3MemHandler{
  private:
   
@@ -133,6 +137,9 @@ class AliL3MemHandler{
   //virtual functions:
   virtual void FreeDigitsTree() {return;}
   virtual Bool_t SetAliInput(char */*name*/){return 0;}
+#ifdef use_newio
+  virtual Bool_t SetAliInput(AliRunLoader */*runloader*/){return 0;}
+#endif
   virtual void CloseAliInput(){return;} 
   virtual Bool_t IsDigit(Int_t /*i*/=0){return 0;}
   virtual Bool_t SetMCOutput(char */*name*/){return 0;}
index 80dfc29..22f6e01 100644 (file)
@@ -220,7 +220,6 @@ AliL3Track * AliL3Merger::MultiMerge(AliL3TrackArray *mergedtracks,AliL3Track **
   //create new track
   AliL3Track *newtrack = mergedtracks->NextTrack();
   //copy points
-  //  UInt_t nn[AliL3Transform::GetNRows()];
   UInt_t * nn = new UInt_t[AliL3Transform::GetNRows()];
   nps = 0;
   
index 7413a0f..76ca82b 100644 (file)
@@ -29,6 +29,17 @@ ClassImp(AliL3RawDataFileHandler)
 
 AliL3RawDataFileHandler::AliL3RawDataFileHandler()
 {
+  fConvert=kTRUE;
+  fInRaw = 0;
+  fInRawPed = 0;
+  fMapping = 0;
+  fPedestals=0;
+  fCharges=0;
+  fOutRaw = 0;
+  fRow=0;
+  fPad=0;
+  fRowPad=0;
+
   FreeAll();
 
   if((sizeof(Int_t) != 4) || (sizeof(Short_t) != 2)){
@@ -53,17 +64,19 @@ void AliL3RawDataFileHandler::FreeAll()
     delete[] fRowPad;
   }
   if(fPedestals) delete[] fPedestals;
+  if(fCharges) delete[] fCharges;
   if(fOutRaw) CloseRawOutput();
-
   fConvert=kTRUE;
   fInRaw = 0;
   fInRawPed = 0;
-  fOutRaw = 0;
   fMapping = 0;
-  fNChannels=0;
+  fPedestals=0;
+  fCharges=0;
+  fOutRaw = 0;
   fRow=0;
   fPad=0;
   fRowPad=0;
+  fNChannels=0;
   fRowMinUsed=AliL3Transform::GetNRows();
   fRowMaxUsed=0;
   fPadMinUsed=255;
@@ -71,7 +84,6 @@ void AliL3RawDataFileHandler::FreeAll()
   fNTimeBins=0;
   for(Int_t i=0;i<AliL3Transform::GetNRows();i++) fNPads[i]=0;
   fPedVal=0;
-  fPedestals=0;
 }
 
 Bool_t AliL3RawDataFileHandler::SetRawInput(Char_t *name)
@@ -113,7 +125,6 @@ Bool_t AliL3RawDataFileHandler::SetRawInput(ifstream *file)
 
   //Open the raw data file with given file.
   fInRaw = file;
-
 #if defined(__HP_aCC) || defined(__DECCXX)
   if(!fInRaw->rdbuf()->is_open()){
 #else
@@ -251,7 +262,6 @@ Bool_t AliL3RawDataFileHandler::SetRawPedestalsInput(ifstream *file)
 
   //Open the raw data file with given file.
   fInRawPed = file;
-
 #if defined(__HP_aCC) || defined(__DECCXX)
   if(!fInRawPed->rdbuf()->is_open()){
 #else
@@ -373,6 +383,7 @@ Int_t AliL3RawDataFileHandler::ReadMappingFile()
     //cout << i << " " << row << " " << pad << endl;
   }
 
+  CloseMappingFile();
   return fNChannels;
 }
 
@@ -401,7 +412,6 @@ inline Short_t AliL3RawDataFileHandler::Convert2(Short_t s)
 Int_t AliL3RawDataFileHandler::ReadRawInput()
 {
   //Read data from cosmics file into memory
-
   if(!fInRaw){
     LOG(AliL3Log::kError,"AliL3RawDataFileHandler::ReadRawInput","File Open")
       <<"No Input avalible: no object ifstream"<<ENDLOG;
@@ -438,14 +448,14 @@ Int_t AliL3RawDataFileHandler::ReadRawInput()
     fInRaw->read((Char_t*)&dummy2,sizeof(dummy2));
     UShort_t channel = Convert2(dummy2);
     if(channel>fNChannels){
-    LOG(AliL3Log::kWarning,"AliL3RawDataFileHandler::ReadRawInput","Data Inconsistency")
-      <<AliL3Log::kDec<<"Channel number must be smaller then fNChannels "<<channel<<" "<<fNChannels<<ENDLOG;
-    return 0;
+      LOG(AliL3Log::kWarning,"AliL3RawDataFileHandler::ReadRawInput","Data Inconsistency")
+       <<AliL3Log::kDec<<"Channel number must be smaller then fNChannels "<<channel<<" "<<fNChannels<<ENDLOG;
+      return 0;
     }
   }
-
-  fInRaw->read((Char_t*)&dummy4,sizeof(dummy4));
-  Int_t numofChannelsTest = Convert4(dummy4);
+  
+   fInRaw->read((Char_t*)&dummy4,sizeof(dummy4));
+   Int_t numofChannelsTest = Convert4(dummy4);
 
   if (numofChannelsTest != (Int_t)fNChannels){
     LOG(AliL3Log::kWarning,"AliL3RawDataFileHandler::ReadRawInput","Data Inconsistency")
@@ -462,9 +472,99 @@ Int_t AliL3RawDataFileHandler::ReadRawInput()
       <<AliL3Log::kDec<<"fNTimeBins does not match AliL3Transformer, check AliL3Transform::Init() "<<fNTimeBins<<" "<<AliL3Transform::GetNTimeBins()<<ENDLOG;
   }
 
+  //assign array
+  if(fCharges) delete[] fCharges;
+  fCharges=new Short_t*[fNChannels];
+  for(UInt_t c=0;c<fNChannels;c++) fCharges[c]=new Short_t[fNTimeBins];
+
+  //read data
+  for(UInt_t channel = 0; channel < fNChannels; channel++){
+    for(Int_t timebin = 0 ; timebin < fNTimeBins ; timebin++){
+      Short_t dummy2;
+      fInRaw->read((Char_t*)&dummy2,sizeof(dummy2));//1024012));
+      Short_t charge = Convert2(dummy2);
+
+      //Pedestal substraction
+      if(fPedestals) charge-=fPedestals[channel][timebin];
+      else charge-=fPedVal;
+      if(charge<0) charge=0;
+
+      fCharges[channel][timebin]=charge;
+    }
+  }
+  return fNChannels;
+}
+
+Int_t AliL3RawDataFileHandler::ReadRawInputPointer(const Char_t *ptr)
+{
+  //Read data from cosmics pointer into memory
+  if(!ptr){
+    LOG(AliL3Log::kError,"AliL3RawDataFileHandler::ReadRawInputPointer","Pointer")
+      <<"Pointer equals 0x0!"<<ENDLOG;
+    return 0; 
+  }
+  Int_t dummy4;
+  Short_t dummy2;
+  dummy4=*(Int_t*)ptr; ptr+=sizeof(dummy4);
+  if(dummy4==(Int_t)fNChannels) fConvert=kFALSE;
+  else {
+    Int_t knumofChannels = Convert4(dummy4);    
+    if(knumofChannels!=(Int_t)fNChannels){
+      LOG(AliL3Log::kError,"AliL3RawDataFileHandler::ReadRawInputPointer","Data Inconsistency")
+       <<"Number of Channels should be equal to fNChannels "<<knumofChannels<<" "<<fNChannels<<ENDLOG;
+      return 0;
+    }
+  }
+  //read used altrochannels (for the moment
+  //this information is not really needed as
+  //all channels per FEC are used
+  for(UInt_t i = 0 ; i < fNChannels ; i++){
+    dummy2=*(Short_t*)ptr; ptr+=sizeof(dummy2);
+    UShort_t channel = Convert2(dummy2);
+    if(channel>fNChannels){
+      LOG(AliL3Log::kWarning,"AliL3RawDataFileHandler::ReadRawInputPointer","Data Inconsistency")
+       <<AliL3Log::kDec<<"Channel number must be smaller then fNChannels "<<channel<<" "<<fNChannels<<ENDLOG;
+      return 0;
+    }
+  }
+  dummy4=*(Int_t*)ptr; ptr+=sizeof(dummy4);
+  Int_t numofChannelsTest = Convert4(dummy4);
+  if (numofChannelsTest != (Int_t)fNChannels){
+    LOG(AliL3Log::kWarning,"AliL3RawDataFileHandler::ReadRawInputPointer","Data Inconsistency")
+      <<AliL3Log::kDec<<"Number of test channels should be equal to fNChannels "<<numofChannelsTest<<" "<<fNChannels<<ENDLOG;
+    return 0;
+  }
+  //Timebins
+  dummy4=*(Int_t*)ptr; ptr+=sizeof(Int_t);
+  fNTimeBins=Convert4(dummy4);
+  if(fNTimeBins!=AliL3Transform::GetNTimeBins()){
+    LOG(AliL3Log::kError,"AliL3RawDataFileHandler::ReadRawInputPointer","Data Inconsistency")
+      <<AliL3Log::kDec<<"fNTimeBins does not match AliL3Transformer, check AliL3Transform::Init() "<<fNTimeBins<<" "<<AliL3Transform::GetNTimeBins()<<ENDLOG;
+  }
+  //assign array
+  if(fCharges) delete[] fCharges;
+  fCharges=new Short_t*[fNChannels];
+  for(UInt_t c=0;c<fNChannels;c++) fCharges[c]=new Short_t[fNTimeBins];
+  //read data
+  for(UInt_t channel = 0; channel < fNChannels; channel++){
+    for(Int_t timebin = 0 ; timebin < fNTimeBins ; timebin++){
+      Short_t dummy2=*(Short_t*)ptr;
+      Short_t charge = Convert2(dummy2);
+
+      //Pedestal substraction
+      if(fPedestals) charge-=fPedestals[channel][timebin];
+      else charge-=fPedVal;
+      if(charge<0) charge=0;
+
+      fCharges[channel][timebin]=charge;
+      ptr+=sizeof(dummy2);
+    }
+  }
+  
   return fNChannels;
 }
 
+
 Short_t** AliL3RawDataFileHandler::GetRawData(Int_t &channels, Int_t &timebins)
 {
   Short_t **charges=0;
@@ -609,12 +709,12 @@ Int_t AliL3RawDataFileHandler::ReadRawPedestalsInput()
       fPedestals[channel][timebin]=charge;
     }
   }
-
+  CloseRawPedestalsInput();
   return fNChannels;
 }
 
-  AliL3DigitRowData * AliL3RawDataFileHandler::RawData2Memory(UInt_t &nrow,Int_t /*event*/)
-{                                           //event is not used
+AliL3DigitRowData * AliL3RawDataFileHandler::RawData2Memory(UInt_t &nrow,Int_t /*event*/)
+{
   AliL3DigitRowData *data = 0;
   nrow=0;
 
@@ -628,31 +728,11 @@ Int_t AliL3RawDataFileHandler::ReadRawPedestalsInput()
     }
   }
   
-  //Read the data
-  //  Short_t charges[fNChannels][fNTimeBins];
-  Short_t ** charges = new Short_t*[fNChannels];
-  for (UInt_t iii=0; iii<fNChannels; iii++)
-    charges[iii] = new Short_t[fNTimeBins];
-  for(UInt_t channel = 0; channel < fNChannels; channel++){
-    for(Int_t timebin = 0 ; timebin < fNTimeBins ; timebin++){
-      Short_t dummy2;
-      fInRaw->read((Char_t*)&dummy2,sizeof(dummy2));
-      Short_t charge = Convert2(dummy2);
-
-      //Pedestal substraction
-      if(fPedestals) charge-=fPedestals[channel][timebin];
-      else charge-=fPedVal;
-      if(charge<0) charge=0;
-
-      charges[channel][timebin]=charge;
-    }
-  }
 
   //get data size
   Int_t nrows=0;
   Int_t ndigitcount=0;
-  //  Int_t ndigits[AliL3Transform::GetNRows()];
-  Int_t * ndigits = new Int_t[AliL3Transform::GetNRows()];
+  Int_t *ndigits=new Int_t[AliL3Transform::GetNRows()];
   for(Int_t i=0;i<AliL3Transform::GetNRows();i++) ndigits[i]=0;
 
   //no need to search for slice/sector given by init
@@ -668,7 +748,7 @@ Int_t AliL3RawDataFileHandler::ReadRawPedestalsInput()
       if(channel==-1) continue; //no data on that channel;
 
       for(Int_t timebin = 0 ; timebin < fNTimeBins ; timebin++){
-       Int_t dig=charges[channel][timebin];
+       Int_t dig=fCharges[channel][timebin];
        
        if(dig <= AliL3Transform::GetZeroSup()) continue;
        if(dig >= AliL3Transform::GetADCSat())
@@ -689,7 +769,7 @@ Int_t AliL3RawDataFileHandler::ReadRawPedestalsInput()
     ndigitcounttest+=ndigits[slrow];
   if(ndigitcount!=ndigitcounttest)
     LOG(AliL3Log::kError,"AliL3RawDataFileHandler::RawData2Memory","Digits")
-    <<AliL3Log::kDec<<"Found Inconsistency "<<ndigitcount<<" != "<<ndigitcounttest<<ENDLOG;
+      <<AliL3Log::kDec<<"Found Inconsistency "<<ndigitcount<<" != "<<ndigitcounttest<<ENDLOG;
     
   Int_t size = sizeof(AliL3DigitData)*ndigitcount
     + nrows*sizeof(AliL3DigitRowData);
@@ -717,7 +797,7 @@ Int_t AliL3RawDataFileHandler::ReadRawPedestalsInput()
       if(channel==-1) continue; //no data on that channel;
 
       for(Int_t timebin = 0 ; timebin < fNTimeBins ; timebin++){
-       Int_t dig=charges[channel][timebin];
+       Int_t dig=fCharges[channel][timebin];
        
        if(dig <= AliL3Transform::GetZeroSup()) continue;
        if(dig >= AliL3Transform::GetADCSat())
@@ -727,15 +807,15 @@ Int_t AliL3RawDataFileHandler::ReadRawPedestalsInput()
        //AliL3Transform::Raw2Local(xyz,sector,row,pad,time);
        //if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2])) continue;
 
-        tempPt->fDigitData[localcount].fCharge=(UShort_t)dig;
-        tempPt->fDigitData[localcount].fPad=(UChar_t)pad;
-        tempPt->fDigitData[localcount].fTime=(UShort_t)timebin;
+       tempPt->fDigitData[localcount].fCharge=(UShort_t)dig;
+       tempPt->fDigitData[localcount].fPad=(UChar_t)pad;
+       tempPt->fDigitData[localcount].fTime=(UShort_t)timebin;
 #ifdef do_mc
        tempPt->fDigitData[localcount].fTrackID[0] = 0;
        tempPt->fDigitData[localcount].fTrackID[1] = 0;
        tempPt->fDigitData[localcount].fTrackID[2] = 0;
 #endif
-        localcount++;
+       localcount++;
        ndigitcounttest2++;
       } //time
     } //pad 
@@ -747,20 +827,16 @@ Int_t AliL3RawDataFileHandler::ReadRawPedestalsInput()
 
     Byte_t *tmp = (Byte_t*)tempPt;
     Int_t size = sizeof(AliL3DigitRowData)
-                                      + ndigits[slrow]*sizeof(AliL3DigitData);
+      + ndigits[slrow]*sizeof(AliL3DigitData);
     tmp += size;
     tempPt = (AliL3DigitRowData*)tmp;
   }//row
 
   if(ndigitcount!=ndigitcounttest2)
     LOG(AliL3Log::kError,"AliL3RawDataFileHandler::RawData2Memory","Digits")
-    <<AliL3Log::kDec<<"Found Inconsistency "<<ndigitcount<<" != "<<ndigitcounttest2<<ENDLOG;
+      <<AliL3Log::kDec<<"Found Inconsistency "<<ndigitcount<<" != "<<ndigitcounttest2<<ENDLOG;
 
   delete [] ndigits;
-  for (UInt_t iii=0; iii<fNChannels; iii++)
-    delete [] charges[iii];
-  delete [] charges;
-
   return data;
 }
 
index 6c0cc0b..b8e069e 100644 (file)
@@ -29,6 +29,8 @@ class AliL3RawDataFileHandler:public AliL3MemHandler{
   Short_t **fPedestals;//! pedestal values, if not used, fPedVal is used
   Short_t fPedVal;
 
+  Short_t **fCharges;//! charge values read from pointer or from file
+
   Bool_t fConvert;
   Int_t Convert4(Int_t i);     //big2little and vice versa
   Short_t Convert2(Short_t i); //big2little and vice versa
@@ -40,13 +42,16 @@ class AliL3RawDataFileHandler:public AliL3MemHandler{
   void FreeAll(); //like AliL3MemHandler::Free() or AliL3FileHandler::FreeDigitsTree
 
   Bool_t SetRawInput(Char_t *name);
-  Bool_t SetRawInput(ifstream *file);
+  Bool_t SetRawInput(STDIF *file);
   void CloseRawInput(); 
   Int_t ReadRawInput();
+
+  Int_t ReadRawInputPointer(Char_t const *ptr);
+
   Short_t** GetRawData(Int_t &channels, Int_t & timebins);
 
   Bool_t SetRawOutput(Char_t *name);
-  Bool_t SetRawOutput(ofstream *file);
+  Bool_t SetRawOutput(STDOF *file);
   void CloseRawOutput(); 
   Int_t StoreRawData(Short_t **charges);
 
@@ -56,7 +61,7 @@ class AliL3RawDataFileHandler:public AliL3MemHandler{
   Int_t ReadMappingFile();
   
   Bool_t SetRawPedestalsInput(Char_t *name);
-  Bool_t SetRawPedestalsInput(ifstream *file);
+  Bool_t SetRawPedestalsInput(STDIF *file);
   void CloseRawPedestalsInput(); 
   Int_t ReadRawPedestalsInput();
 
index 600d6d0..abff394 100644 (file)
 #pragma link C++ class AliL3Fitter;
 #pragma link C++ class AliL3RawDataFileHandler;
 
-#ifdef Darwin
-//new to solve dep problem
-#pragma link C++ class AliL3HoughTrack;
-#pragma link C++ class AliL3ModelTrack;
-#pragma link C++ class AliL3DataCompressorHelper;
-#pragma link C++ class AliL3DDLDataFileHandler;
-#pragma link C++ class AliL3DataHandler;
-#pragma link C++ class AliL3TransBit;
-#pragma link C++ class AliL3TransBit_v1; 
-#pragma link C++ class AliL3TransBit_v2; 
-#endif
-
 #ifdef use_aliroot
 #pragma link C++ class AliL3FileHandler;
 #pragma link C++ class AliL3Evaluate; 
+#ifdef use_reconstruction
+#pragma link C++ class AliHLTReconstructor;
+#endif
 #endif
 
 #endif
index 38fd91c..1dcc857 100644 (file)
@@ -4,8 +4,8 @@
 #define ALIL3STANDARDINCLUDESH
 
 #if __GNUC__ == 3
-#include <iostream>
 #include <fstream>
+#include <iostream>
 
 #include <cstdio>
 #include <cmath>
@@ -18,6 +18,8 @@ eg. in inline functions defined in header files */
 #define STDCOUT std::cout
 #define STDCERR std::cerr
 #define STDENDL std::endl
+#define STDIF   std::ifstream
+#define STDOF   std::ofstream
 
 #else
 #include <iostream.h>
@@ -34,6 +36,8 @@ eg. in inline functions defined in header files */
 #define STDCOUT cout
 #define STDCERR cerr
 #define STDENDL endl
+#define STDIF   ifstream
+#define STDOF   ofstream
 
 #endif //__GNUC__
 
index 90c895e..ed42649 100644 (file)
@@ -10,6 +10,7 @@
 #include "AliL3Track.h"
 #include "AliL3Transform.h"
 #include "AliL3Vertex.h"
+#include "AliL3SpacePointData.h"
 
 #if __GNUC__ == 3
 using namespace std;
@@ -55,6 +56,7 @@ AliL3Track::AliL3Track()
   SetFirstPoint(0,0,0);
   SetLastPoint(0,0,0);
   memset(fHitNumbers,0,159*sizeof(UInt_t));
+  fPID = 0;
 }
 
 void AliL3Track::Set(AliL3Track *tpt){
@@ -73,6 +75,8 @@ void AliL3Track::Set(AliL3Track *tpt){
 #ifdef do_mc
   SetMCid(tpt->GetMCid());
 #endif
+  SetPID(tpt->GetPID());
+  SetSector(tpt->GetSector());
 }
 
 Int_t AliL3Track::Compare(const AliL3Track *track) const
@@ -502,3 +506,4 @@ void AliL3Track::GetClosestPoint(AliL3Vertex *vertex,Double_t &closest_x,Double_
   
   closest_z = GetFirstPointZ() - s_tot*GetTgl();
 }
+
index aad2115..692faee 100644 (file)
@@ -8,6 +8,7 @@
 #include "AliL3RootTypes.h"
 
 class AliL3Vertex;
+class AliL3SpacePointData;
 
 class AliL3Track {
   
@@ -57,6 +58,7 @@ class AliL3Track {
 
   UInt_t fHitNumbers[159];  //Array of hit numbers for this track
 
+  Float_t fPID;
  public:
   
   AliL3Track();
@@ -75,6 +77,9 @@ class AliL3Track {
   Double_t GetDistance(Double_t x0,Double_t x1){return 0;}
   void UpdateToFirstPoint();
 
+  Float_t GetPID() {return fPID;}
+  void    SetPID(Float_t pid) {fPID=pid;}
+
   void GetClosestPoint(AliL3Vertex *vertex,Double_t &closest_x,Double_t &closest_y,Double_t &closest_z);
   void Rotate(Int_t slice,Bool_t tolocal=kFALSE);
   Bool_t IsLocal() {return fIsLocal;}
@@ -124,6 +129,7 @@ class AliL3Track {
 
   Int_t GetFirstRow() const {return fRowRange[0];}
   Int_t GetLastRow()  const {return fRowRange[1];}
+  Int_t GetSector()   const {return fSector;}
 
   UInt_t *GetHitNumbers() {return fHitNumbers;}
 
index 5ddcd85..48a2bb3 100644 (file)
@@ -199,11 +199,15 @@ void AliL3TrackArray::FillTracks(Int_t ntracks, AliL3TrackSegmentData* tr){
     track->SetFirstPoint(trs->fX,trs->fY,trs->fZ);
     track->SetLastPoint(trs->fLastX,trs->fLastY,trs->fLastZ);
     track->SetHits( trs->fNPoints, trs->fPointIDs );
-#ifdef ROWHOUGH
+#ifdef ROWHOUGHPARAMS
     if(GetTrackType()=='h') {
       ((AliL3HoughTrack *)track)->SetWeight(trs->fWeight);
-      track->SetMCid(trs->fTrackID);
+      ((AliL3HoughTrack *)track)->SetBinXY(trs->fBinX,trs->fBinY,trs->fBinXSize,trs->fBinYSize);
     }
+    track->SetMCid(trs->fTrackID);
+    track->SetRowRange(trs->fRowRange1,trs->fRowRange2);
+    track->SetSector(trs->fSector);
+    track->SetPID(trs->fPID);
 #endif
     UChar_t *tmpP = (UChar_t*)trs;
     tmpP += sizeof(AliL3TrackSegmentData)+trs->fNPoints*sizeof(UInt_t);
@@ -236,11 +240,15 @@ void AliL3TrackArray::FillTracks(Int_t ntracks, AliL3TrackSegmentData* tr,Int_t
     UChar_t *tmpP = (UChar_t*)trs;
     tmpP += sizeof(AliL3TrackSegmentData)+trs->fNPoints*sizeof(UInt_t);
     trs = (AliL3TrackSegmentData*)tmpP;
-#ifdef ROWHOUGH
+#ifdef ROWHOUGHPARAMS
     if(GetTrackType()=='h') {
       ((AliL3HoughTrack *)track)->SetWeight(trs->fWeight);
-      track->SetMCid(trs->fTrackID);
+      ((AliL3HoughTrack *)track)->SetBinXY(trs->fBinX,trs->fBinY,trs->fBinXSize,trs->fBinYSize);
     }
+    track->SetMCid(trs->fTrackID);
+    track->SetRowRange(trs->fRowRange1,trs->fRowRange2);
+    track->SetSector(slice);
+    track->SetPID(trs->fPID);
 #endif
   }
 }
@@ -282,11 +290,19 @@ UInt_t AliL3TrackArray::WriteTracks(AliL3TrackSegmentData* tr){
     tP->fTgl = track->GetTgl();
     tP->fCharge = track->GetCharge();
     tP->fNPoints = track->GetNHits();
-#ifdef ROWHOUGH
+#ifdef ROWHOUGHPARAMS
     if(GetTrackType()=='h') {
       tP->fWeight = ((AliL3HoughTrack *)track)->GetWeight();
-      tP->fTrackID = track->GetMCid();
+      tP->fBinX = ((AliL3HoughTrack *)track)->GetBinX();
+      tP->fBinY = ((AliL3HoughTrack *)track)->GetBinY();
+      tP->fBinXSize = ((AliL3HoughTrack *)track)->GetSizeX();
+      tP->fBinYSize = ((AliL3HoughTrack *)track)->GetSizeY();
     }
+    tP->fTrackID = track->GetMCid();
+    tP->fRowRange1 = track->GetFirstRow();
+    tP->fRowRange2 = track->GetLastRow();
+    tP->fSector = track->GetSector();
+    tP->fPID = track->GetPID();
 #endif
     pP = (UInt_t*)track->GetHitNumbers();
     for (UInt_t j=0;j<tP->fNPoints;j++){
@@ -327,6 +343,13 @@ UInt_t AliL3TrackArray::WriteConfMapTracks(AliL3TrackSegmentData* tr){
     tP->fPsi = track->GetPsi();
     tP->fTgl = track->GetTgl();
     tP->fCharge = track->GetCharge();
+#ifdef ROWHOUGHPARAMS
+    tP->fTrackID = track->GetMCid();
+    tP->fRowRange1 = track->GetFirstRow();
+    tP->fRowRange2 = track->GetLastRow();
+    tP->fSector = track->GetSector();
+    tP->fPID = track->GetPID();
+#endif
     tP->fNPoints = track->GetNHits();
     pP = (UInt_t*)track->GetHitNumbers();
     for (UInt_t j=0;j<tP->fNPoints;j++){
index 2f92423..321db7a 100644 (file)
@@ -17,9 +17,18 @@ struct AliL3TrackSegmentData
        Double_t fPsi;
         Double_t fTgl;
         Int_t fCharge;
-#ifdef ROWHOUGH
+#ifdef ROWHOUGHPARAMS
+      /* needed for PDC */
         UInt_t  fWeight;
         Int_t  fTrackID;
+        Int_t  fRowRange1;
+        Int_t  fRowRange2;
+        Int_t  fSector;
+        Float_t  fPID;
+        Float_t  fBinX;
+        Float_t  fBinY;
+        Float_t  fBinXSize;
+        Float_t  fBinYSize;
 #endif
        UInt_t  fNPoints;
 #if defined(__HP_aCC) || defined(__DECCXX) || defined(__SUNPRO_CC)
index a1dd9cd..5725f37 100644 (file)
@@ -1449,14 +1449,14 @@ Double_t AliL3Transform::Row2X(Int_t slicerow){
   return fX[slicerow];
 }
 
-Double_t AliL3Transform::GetZFast(Int_t slice, Int_t time, Float_t /*vertex*/)
+Double_t AliL3Transform::GetZFast(Int_t slice, Int_t time, Float_t vertex)
 {
-  Double_t ret=0;
+  Double_t z=fZWidth*time-fZOffset;
   if(slice < 18)
-    ret=fZLength-fZWidth*time+fZOffset;
+    z=fZLength-z-vertex;
   else
-    ret=fZWidth*time-fZOffset-fZLength;
-  return ret;
+    z=z-fZLength-vertex;
+  return z;
 }
 
 void AliL3Transform::Local2Global(Float_t *xyz,Int_t slice)
@@ -1739,10 +1739,10 @@ void AliL3Transform::PrintCompileOptions()
   cout << "NOT using Monte Carlo Info: -Ddo_mc was not given." << endl;
 #endif
 
-#ifdef ROWHOUGH
-  cout << "Using row transformer version: -DROWHOUGH was given." << endl;
+#ifdef ROWHOUGHPARAMS
+  cout << "Using extended AliL3TrackSegmentData: -DROWHOUGHPARAMS was given." << endl;
 #else
-  cout << "NOT using row transformer version: -DROWHOUGH was not given." << endl;
+  cout << "NOT using extended AliL3TrackSegmentData: -DROWHOUGHPARAMS was not given." << endl;
 #endif
 
 #ifdef use_newio
index a590041..1851c47 100644 (file)
@@ -25,8 +25,7 @@ class AliL3VertexFinder:public AliL3VertexArray{
 
   public:
     AliL3VertexFinder(); 
-    AliL3VertexFinder(AliL3VertexFinder&l3v):
-      AliL3VertexArray(l3v) {;}
+    AliL3VertexFinder(AliL3VertexFinder&){;}
     virtual ~AliL3VertexFinder();
 
     void Reset();
index 0407da1..4ed2796 100644 (file)
 #include <TStopwatch.h>
 #endif
 
+#ifdef use_newio
+#include <AliRunLoader.h>
+#endif
+
 #include "AliL3Logging.h"
 #include "AliLevel3.h"
 #include "AliL3ConfMapper.h"
@@ -63,7 +67,17 @@ AliLevel3::AliLevel3()
   //In that case the path to where the binary files are located has to be
   //passed to the AliLevel::Init function.
   
+  fVertexFinder=0;
+  fVertex=0;
+  fTracker=0;
+  fTrackMerger=0;
+  fInterMerger=0;
+  fFileHandler=0;
+  fGlobalMerger=0;
   fInputFile=0;
+#ifdef use_newio
+  fRunLoader=0;
+#endif
 }
 
 AliLevel3::AliLevel3(Char_t *infile)
@@ -71,17 +85,62 @@ AliLevel3::AliLevel3(Char_t *infile)
   //Constructor to use for when input is anything else but binary files,
   //meaning rootfiles or raw files.
   
+  fVertexFinder=0;
+  fVertex=0;
+  fTracker=0;
+  fTrackMerger=0;
+  fInterMerger=0;
+  fFileHandler=0;
+  fGlobalMerger=0;
   fInputFile = infile;
+#ifdef use_newio
+  fRunLoader=0;
+#endif
+}
+
+#ifdef use_newio
+AliLevel3::AliLevel3(AliRunLoader *rl)
+{
+  //Constructor to use when input is aliroot runloader
+  fVertexFinder=0;
+  fVertex=0;
+  fTracker=0;
+  fTrackMerger=0;
+  fInterMerger=0;
+  fFileHandler=0;
+  fGlobalMerger=0;
+  fInputFile=0;
+#ifdef use_newio
+  fRunLoader = rl;
+#endif
 }
+#endif
 
 void AliLevel3::Init(Char_t *path,EFileType filetype,Int_t npatches)
 {
-  if((filetype!=kBinary) && (filetype!=kDate) && !fInputFile)
+#ifndef use_newio
+  if (filetype==kRunLoader){
+    LOG(AliL3Log::kError,"AliLevel3::Init","Files")
+       <<"You have not supplied the input rootfile; if you want "
+       <<"to run with RunLoader use -Duse_newio for compiling!"<<ENDLOG;
+  }
+#endif
+
+  if((filetype!=kBinary) && (filetype!=kDate) 
+       && (!filetype!=kRunLoader)&& !fInputFile)
     {
       LOG(AliL3Log::kError,"AliLevel3::Init","Files")
        <<"You have not supplied the input rootfile; use the appropriate ctor!"<<ENDLOG;
       return;
     }
+#if use_newio
+  if((filetype==kRunLoader) && !fRunLoader)
+    {
+      LOG(AliL3Log::kError,"AliLevel3::Init","Files")
+       <<"You have not supplied the input runloader; use the appropriate ctor!"<<ENDLOG;
+      return;
+    }
+#endif
   
   fWriteOut = kFALSE;
   fPileUp = kFALSE;
@@ -153,7 +212,14 @@ void AliLevel3::Init(Char_t *path,EFileType filetype,Int_t npatches)
   }else if(filetype==kDate){
     fFileHandler = new AliL3DDLDataFileHandler();
     fFileHandler->SetReaderInput(fInputFile,-1);
-  }else{
+  }
+#if use_newio
+  else if(filetype==kRunLoader){
+    fFileHandler = new AliL3FileHandler(kTRUE); //static version
+    fFileHandler->SetAliInput(fRunLoader);
+  }
+#endif
+  else{
     fFileHandler = new AliL3MemHandler();
   }
 #else
index ad80b21..8a2d797 100644 (file)
@@ -8,6 +8,10 @@
 #include <TFile.h>
 #endif
 
+#ifdef use_newio
+class AliRunLoader;
+#endif
+
 #include "AliL3DigitData.h"
 #include "AliL3RootTypes.h"
 
@@ -55,7 +59,9 @@ class AliLevel3 : public TObject {
   Float_t fEta[2];
   
   Char_t *fInputFile;//!
-
+#ifdef use_newio
+  AliRunLoader *fRunLoader;
+#endif
   Char_t fPath[256];
   Char_t fWriteOutPath[256];
   
@@ -85,8 +91,11 @@ class AliLevel3 : public TObject {
  public:
   AliLevel3 ();
   AliLevel3(Char_t *infile);
+#ifdef use_newio
+  AliLevel3(AliRunLoader *rl);
+#endif
   virtual ~AliLevel3();
-  enum EFileType {kBinary, kBinary8, kRoot, kRaw, kDate};
+  enum EFileType {kBinary, kBinary8, kRoot, kRaw, kDate, kRunLoader};
   void Init(Char_t *path,EFileType filetype=kBinary,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);
index bfebc3a..4042a9d 100644 (file)
@@ -21,7 +21,7 @@ SRCS  = AliL3ConfMapper.cxx AliL3ConfMapPoint.cxx \
           AliL3Merger.cxx AliL3GlobalMerger.cxx AliL3ClustFinderNew.cxx \
           AliL3TrackArray.cxx AliL3InterMerger.cxx AliL3Logger.cxx \
           AliL3MemHandler.cxx AliLevel3.cxx AliL3Benchmark.cxx  \
-          AliL3Fitter.cxx AliL3RawDataFileHandler.cxx
+          AliL3Fitter.cxx AliL3RawDataFileHandler.cxx 
 
 ifeq ($(ARCH),Darwin)
 EXTRA_SRCS = AliL3HoughTrack.cxx AliL3ModelTrack.cxx \
@@ -38,9 +38,9 @@ OBJS = $(patsubst %.cxx,$(OBJDIR)/%.o,$(SRCS)) $(DICTO)
 endif
 
 ifeq ($(ALIHLT_USEPACKAGE),ALIROOT)
-SRCS += AliL3Display.cxx AliL3FileHandler.cxx AliL3Evaluate.cxx
+SRCS += AliL3Display.cxx AliL3FileHandler.cxx AliL3Evaluate.cxx AliHLTReconstructor.cxx
 HDRS = $(SRCS:.cxx=.h)  $(MODNAME)LinkDef.h
 OBJS = $(patsubst %.cxx,$(OBJDIR)/%.o,$(SRCS)) $(DICTO)
 endif
 
-include $(ALIHLT_TOPDIR)/Makefile.rules
\ No newline at end of file
+include $(ALIHLT_TOPDIR)/Makefile.rules
diff --git a/HLT/trigger/AliBarrelRec_TPCparam.C b/HLT/trigger/AliBarrelRec_TPCparam.C
deleted file mode 100644 (file)
index 2929005..0000000
+++ /dev/null
@@ -1,698 +0,0 @@
-/****************************************************************************
- * This macro performs track and vertex reconstruction in TPC and ITS.      *
- * The ITS Kalman tracker V2 is feeded "with" parameterized TPC tracks.     * 
- *                                                                          *
- * Reconstruction is performed in the following steps:                      *
- *             1) TPC tracking parameterization                             *
- *             2) ITS clusters: slow or fast                                *
- *             3) Primary vertex reconstruction                             *
- *                - read from event header for Pb-Pb events                 *
- *                - determined using points in pixels for pp/pA events      *
- *             4) ITS track finding V2                                      *
- *                - in pp/pA, redetermine the position of primary vertex    *
- *                  using the reconstructed tracks                          *
- *             5) Create a reference file with simulation info (p,PDG...)   *
- *                                                                          *
- * If mode='A' all 5 steps are executed                                     *
- * If mode='B' only steps 4-5 are executed                                  *
- *                                                                          *  
- *  Origin: A.Dainese, Padova,   andrea.dainese@pd.infn.it                  * 
- *  (from AliTPCtest.C & AliITStestV2.C by I.Belikov)                       *
- ****************************************************************************/
-
-// structure for track references
-typedef struct {
-  Int_t lab;
-  Int_t pdg;
-  Int_t mumlab;
-  Int_t mumpdg;
-  Float_t Vx,Vy,Vz;
-  Float_t Px,Py,Pz;
-} RECTRACK;
-
-//===== Functions definition ================================================= 
-
-void CopyVtx(const Char_t *inName,const Char_t *outName);
-
-void ITSFindClustersV2(Char_t SlowOrFast,Char_t* path[1024]);
-
-void ITSFindTracksV2(Int_t *skipEvt,Char_t* path[1024]);
-
-void ITSMakeRefFile(Int_t *skipEvt,Char_t* path[1024]);
-
-void MarkEvtsToSkip(const Char_t *evtsName,Int_t *skipEvt);
-
-void PrimaryVertex(const Char_t *outName,Char_t vtxMode,Char_t* path[1024]);
-
-void TPCParamTracks(Int_t coll,Double_t Bfield,Char_t* path[1024]);
-
-Int_t UpdateEvtsToSkip(const Char_t *logName,const Char_t *evtsName);
-
-void VtxFromHeader(const Char_t *outName,Bool_t smear,Char_t* path[1024]);
-
-void VtxFromTracks(const Char_t *outName,Char_t* path[1024]);
-
-void ZvtxFromSPD(const Char_t *outName,Char_t* path[1024]);
-
-//=============================================================================
-
-// number of events to be processed
-Int_t    gNevents;
-// magnetic field
-Double_t gBfieldValue;
-
-void AliBarrelRec_TPCparam(Int_t n=-1,Char_t mode='A',Char_t* path="./") {
-
-  //---------------------------------------------------------------------
-  //                    CONFIGURATION
-  //
-  // _Magnetic_field_
-  gBfieldValue = 0.4;
-  //
-  // _Type_of_collision_ (needed for TPC tracking parameterization) 
-  // Available choices:   !!! ONLY B = 0.4 TESLA !!!
-  //    collcode = 0  ->   PbPb6000 (HIJING with b<2fm) 
-  //    collcode = 1  ->   low multiplicity: pp or pA
-  Int_t collcode = 0;  
-  // 
-  // _ITS_clusters_reconstruction_
-  // Available choices:  (from AliITStestV2.C)
-  //    SlowOrFast = 's'    slow points
-  //    SlowOrFast = 'f'    fast points
-  Char_t SlowOrFast = 'f';
-  //
-  // _Primary_vertex_for_ITS_tracking_
-  // Available choices:
-  //    Vtx4Tracking = 'H'   from event Header
-  //    --- for Pb-Pb ---
-  //    Vtx4Tracking = 'S'   from event header + Smearing 
-  //                                           (x=15,y=15,z=10) micron
-  //    --- for pp/pA ---
-  //    Vtx4Tracking = 'P'   z from pixels, x,y in(0,0)
-  Char_t Vtx4Tracking = 'H';
-  // _Primary_vertex_for_analysis_ (AliITSVertex stored in tracks file)
-  // Available choices:
-  //    Vtx4Analysis = 'C'   Copy the same used for tracking
-  //    --- for pp/pA ---
-  //    Vtx4Analysis = 'T'   x,y,z from Tracks
-  Char_t Vtx4Analysis = 'C';
-  //
-  //                  END CONFIGURATION
-  //---------------------------------------------------------------------
-
-  const Char_t *name=" AliBarrelRec_TPCparam";
-  printf("\n %s\n",name);
-  gBenchmark->Start(name);
-
-  if(n==-1) { // read number of events to be processed from file
-    Char_t falice[1024];
-    sprintf(falice,"%s/galice.root",path);
-    TFile *f = new TFile(falice);
-    gAlice = (AliRun*)f->Get("gAlice");
-    n = gAlice->GetEventsPerRun();
-    delete gAlice; 
-    gAlice=0;
-    f->Close(); 
-    delete f;
-    printf(" All %d events in file will be processed\n",n);
-  }
-  gNevents = n;
-
-
-  // conversion constant for kalman tracks 
-  AliKalmanTrack::SetConvConst(100/0.299792458/gBfieldValue);
-
-  // Selection of execution mode
-  switch(mode) {
-  case 'A':
-    // Build TPC tracks with parameterization
-    TPCParamTracks(collcode,gBfieldValue,path);
-  
-    // ITS clusters
-    ITSFindClustersV2(SlowOrFast,path);
-
-    // Vertex for ITS tracking
-    Char_t fvertex[1024];
-    sprintf(fvertex,"%s/Vtx4Tracking.root",path);
-    PrimaryVertex(fvertex,Vtx4Tracking,path);
-
-    break;
-  
-  case 'B':
-    printf("       ---> only tracking in ITS <---\n");
-
-    // Update list of events to be skipped
-    if(!UpdateEvtsToSkip("itstracking.log","evtsToSkip.dat")) return;
-
-    break;
-  }
-
-  // Mark events that have to be skipped (if any)
-  Int_t *skipEvt = new Int_t[gNevents];
-  for(Int_t i=0; i<gNevents; i++) skipEvt[i] = 0;
-  if(!gSystem->AccessPathName("evtsToSkip.dat",kFileExists)) 
-    MarkEvtsToSkip("evtsToSkip.dat",skipEvt);
-    
-  // Tracking in ITS
-  ITSFindTracksV2(skipEvt,path); 
-
-  // Vertex for analysis 
-  Char_t ftrack[1024];
-  sprintf(ftrack,"%s/AliITStracksV2.root",path); 
-  PrimaryVertex(ftrack,Vtx4Analysis,path);
-
-  // Create ITS tracks reference file
-  ITSMakeRefFile(skipEvt,path);
-  delete [] skipEvt;
-
-  gBenchmark->Stop(name);
-  gBenchmark->Show(name);
-
-  return;
-}
-//-----------------------------------------------------------------------------
-void CopyVtx(const Char_t *inName,const Char_t *outName) {
-
-  // Open input and output files
-  TFile *inFile = new TFile(inName);
-  TFile *outFile = new TFile(outName,"update");
-
-  TDirectory *curdir;
-  Char_t vname[20];
-
-
-  for(Int_t ev=0; ev<gNevents; ev++) {
-    sprintf(vname,"Vertex_%d",ev);
-    AliITSVertex *vertex = (AliITSVertex*)inFile->Get(vname);
-    if(!vertex) continue;
-    curdir = gDirectory;
-    outFile->cd();
-    vertex->Write();
-    curdir->cd();
-    vertex = 0;
-  }
-
-  inFile->Close();
-  outFile->Close();
-  delete inFile;
-  delete outFile;
-
-  return;
-}
-//-----------------------------------------------------------------------------
-void ITSFindClustersV2(Char_t SlowOrFast,Char_t* path="./") {
-
-  printf("\n------------------------------------\n");
-
-  const Char_t *name="ITSFindClustersV2";
-  printf("\n %s\n",name);
-  gBenchmark->Start(name);
-
-  //---  taken from AliITStestV2.C--------------------------------------
-  //
-  if (SlowOrFast=='f') {
-    //cerr<<"Fast AliITSRecPoint(s) !\n";
-    //gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSHits2FastRecPoints.C");
-    //AliITSHits2FastRecPoints();
-  } else {
-    gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSHits2SDigits.C");
-    AliITSHits2SDigits();
-    gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSSDigits2Digits.C");
-    AliITSSDigits2Digits();
-    //gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSDigits2RecPoints.C");
-    //AliITSDigits2RecPoints();
-  }
-  gROOT->LoadMacro("./AliITSFindClustersV2.C");
-  AliITSFindClustersV2(SlowOrFast,gNevents,path);
-  //
-  //--------------------------------------------------------------------
-
-
-  gBenchmark->Stop(name);
-  gBenchmark->Show(name);
-
-   return;
-}
-//-----------------------------------------------------------------------------
-Int_t ITSFindTracksV2(Int_t *skipEvt,Char_t* path="./") {
-
-  printf("\n------------------------------------\n");
-  
-  const Char_t *name="ITSFindTracksV2";
-  printf("\n %s\n",name);
-  gBenchmark->Start(name);
-  Char_t ftrack[1024];
-  sprintf(ftrack,"%s/AliITStracksV2.root",path);
-  TFile *outFile     = new TFile(ftrack,"recreate");
-  Char_t fparam[1024];
-  sprintf(fparam,"%s/AliTPCtracksParam.root",path);
-  TFile *inTPCtrks   = new TFile(fparam);
-  Char_t fvertex[1024];
-  sprintf(fvertex,"%s/Vtx4Tracking.root",path);
-  TFile *inVertex    = new TFile(fvertex);
-  Char_t fcluster[1024];
-  sprintf(fcluster,"%s/AliITSclustersV2.root",path);
-  TFile *inClusters  = new TFile(fcluster);
-  
-  AliITSgeom *geom=(AliITSgeom*)inClusters->Get("AliITSgeom");
-  if(!geom) { printf("can't get ITS geometry !\n"); return;}
-  
-  Double_t vtx[3];
-  Int_t flag1stPass,flag2ndPass;
-  Char_t vname[20];
-
-  // open logfile for done events
-  FILE *logfile = fopen("itstracking.log","w");
-
-  // Instantiate AliITStrackerV2
-  AliITStrackerV2 tracker(geom);
-
-  // loop on events
-  for(Int_t ev=0; ev<gNevents; ev++){
-    // write to logfile of begun events
-    fprintf(logfile,"%d\n",ev);
-
-    if(skipEvt[ev]) continue;
-    printf(" --- Processing event %d ---\n",ev);
-
-    // pass event number to the tracker
-    tracker.SetEventNumber(ev);
-
-    // set position of primary vertex
-    sprintf(vname,"Vertex_%d",ev);
-    AliITSVertex *vertex = (AliITSVertex*)inVertex->Get(vname);
-    if(vertex) {
-      vertex->GetXYZ(vtx);
-      delete vertex;
-    } else {
-      printf(" AliITSVertex not found for event %d\n",ev);
-      printf(" Using (0,0,0) for ITS tracking\n");
-      vtx[0] = vtx[1] = vtx[2] = 0.;
-    }
-
-    flag1stPass=1; // vtx constraint
-    flag2ndPass=0; // no vtx constraint
-
-    // no vtx constraint if vertex not found
-    if(vtx[2]<-999.) {
-      flag1stPass=0;
-      vtx[2]=0.;
-    }
-
-    tracker.SetVertex(vtx);  
-
-    // setup vertex constraint in the two tracking passes
-    Int_t flags[2];
-    flags[0]=flag1stPass;
-    tracker.SetupFirstPass(flags);
-    flags[0]=flag2ndPass;
-    tracker.SetupSecondPass(flags);
-    
-    // find the tracks
-    tracker.Clusters2Tracks(inTPCtrks,outFile);
-
-  } // loop on events
-
-  fprintf(logfile,"%d\n",gNevents); //this means all evts are successfully completed
-  fclose(logfile);
-
-  delete geom;
-
-  inTPCtrks->Close();
-  inClusters->Close();
-  inVertex->Close();
-  outFile->Close();
-
-  gBenchmark->Stop(name);
-  gBenchmark->Show(name);
-  
-  return;
-}
-//-----------------------------------------------------------------------------
-void ITSMakeRefFile(Int_t *skipEvt,Char_t* path="./") {
-
-  printf("\n------------------------------------\n");
-
-  const Char_t *name="ITSMakeRefFile";
-  printf("\n %s\n",name);
-  gBenchmark->Start(name);
-  
-  Char_t fref[1024];
-  sprintf(fref,"%s/ITStracksRefFile.root",path);
-  TFile *out = TFile::Open(fref,"recreate");
-  Char_t ftrack[1024];
-  sprintf(ftrack,"%s/AliITStracksV2.root",path);
-  TFile *trk = TFile::Open(ftrack);
-  Char_t falice[1024];
-  sprintf(falice,"%s/galice.root",path);
-  TFile *kin = TFile::Open(falice);
-
-  
-  // Get gAlice object from file
-  gAlice=(AliRun*)kin->Get("gAlice");
-  
-  Int_t label;
-  TParticle *Part;  
-  TParticle *Mum;
-  RECTRACK rectrk;
-  
-
-  for(Int_t ev=0; ev<gNevents; ev++){
-    if(skipEvt[ev]) continue;
-    printf(" --- Processing event %d ---\n",ev);
-
-    gAlice->GetEvent(ev);  
-
-    trk->cd();
-
-    // Tree with ITS tracks
-    char tname[100];
-    sprintf(tname,"TreeT_ITS_%d",ev);
-
-    TTree *tracktree=(TTree*)trk->Get(tname);
-    if(!tracktree) continue;
-    AliITStrackV2 *itstrack=new AliITStrackV2; 
-    tracktree->SetBranchAddress("tracks",&itstrack);
-    Int_t nentr=(Int_t)tracktree->GetEntries();
-
-    // Tree for true track parameters
-    char ttname[100];
-    sprintf(ttname,"Tree_Ref_%d",ev);
-    TTree *reftree = new TTree(ttname,"Tree with true track params");
-    reftree->Branch("rectracks",&rectrk,"lab/I:pdg:mumlab:mumpdg:Vx/F:Vy:Vz:Px:Py:Pz");
-
-    for(Int_t i=0; i<nentr; i++) {
-      tracktree->GetEvent(i);
-      label = TMath::Abs(itstrack->GetLabel());
-
-      Part = (TParticle*)gAlice->Particle(label);
-      rectrk.lab=label;
-      rectrk.pdg=Part->GetPdgCode();
-      rectrk.mumlab = Part->GetFirstMother();
-      if(Part->GetFirstMother()>=0) {
-       Mum = (TParticle*)gAlice->Particle(Part->GetFirstMother());
-       rectrk.mumpdg=Mum->GetPdgCode();
-      } else {
-       rectrk.mumpdg=-1;
-      }
-      rectrk.Vx=Part->Vx();
-      rectrk.Vy=Part->Vy();
-      rectrk.Vz=Part->Vz();
-      rectrk.Px=Part->Px();
-      rectrk.Py=Part->Py();
-      rectrk.Pz=Part->Pz();
-      
-      reftree->Fill();
-    } // loop on tracks   
-
-    out->cd();
-    reftree->Write();
-
-    delete itstrack;
-    delete reftree;
-  } // loop on events
-
-  trk->Close();
-  kin->Close();
-  out->Close();
-  
-  gBenchmark->Stop(name);
-  gBenchmark->Show(name);
-  
-
-  return;
-}
-//-----------------------------------------------------------------------------
-void MarkEvtsToSkip(const Char_t *evtsName,Int_t *skipEvt) {
-
-  printf("\n------------------------------------\n");
-  printf("\nChecking for events to skip...\n");
-
-  Int_t evt,ncol;
-
-  FILE *f = fopen(evtsName,"r");
-  while(1) {
-    ncol = fscanf(f,"%d",&evt);
-    if(ncol<1) break;
-    skipEvt[evt] = 1;
-    printf(" event %d will be skipped\n",evt);
-  }
-  fclose(f);
-
-  return;
-}
-//-----------------------------------------------------------------------------
-void PrimaryVertex(const Char_t *outName,Char_t vtxMode,Char_t* path="./") {
-
-  printf("\n------------------------------------\n");
-
-  const Char_t *name="PrimaryVertex";
-  printf("\n %s\n",name);
-  gBenchmark->Start(name);
-
-  switch(vtxMode) {
-  case 'H':
-    printf(" ... from event header\n");
-    VtxFromHeader(outName,kFALSE,path);
-    break;
-  case 'S':
-    printf(" ... from event header + smearing\n");
-    VtxFromHeader(outName,kTRUE);
-    break;
-  case 'P':
-    printf(" ... z from pixels for pp/pA\n");
-    ZvtxFromSPD(outName);
-    break;
-  case 'T':
-    printf(" ... from tracks for pp/pA\n");
-    VtxFromTracks(outName);
-    break;
-  case 'C':
-    Char_t fvertex[1024];
-    sprintf(fvertex,"%s/Vtx4Tracking.root",path);
-    printf(" ... copied from Vtx4Tracking.root to AliITStracksV2.root\n");
-    CopyVtx(fvertex,outName);
-    break;
-  }
-
-  gBenchmark->Stop(name);
-  gBenchmark->Show(name);
-
-  return;
-}
-//-----------------------------------------------------------------------------
-void TPCParamTracks(Int_t coll,Double_t Bfield,Char_t* path="./") {
-
-  printf("\n------------------------------------\n");
-
-  const Char_t *name="TPCParamTracks";
-  printf("\n %s\n",name);
-  gBenchmark->Start(name);
-
-  Char_t fparam[1024];
-  sprintf(fparam,"%s/AliTPCtracksParam.root",path);
-  TFile *outFile=TFile::Open(fparam,"recreate");
-  Char_t falice[1024];
-  sprintf(falice,"%s/galice.root",path);
-  TFile *inFile =TFile::Open(falice);
-  AliTPCtrackerParam tracker(coll,Bfield,gNevents);
-  tracker.BuildTPCtracks(inFile,outFile);
-
-  delete gAlice; gAlice=0;
-
-  inFile->Close();
-  outFile->Close();
-
-  gBenchmark->Stop(name);
-  gBenchmark->Show(name);
-
-  return;
-}
-//-----------------------------------------------------------------------------
-Int_t UpdateEvtsToSkip(const Char_t *logName,const Char_t *evtsName) {
-
-    if(!gSystem->AccessPathName(logName,kFileExists)) { 
-      FILE *ifile = fopen(logName,"r");
-      Int_t lEvt=0,nCol=1;
-      while(nCol>0) {
-       nCol = fscanf(ifile,"%d",&lEvt);
-      }
-      fclose(ifile);
-      if(lEvt==gNevents) { 
-       printf(" All events already reconstructed\n"); 
-       return 0;  
-      } else {
-       FILE *ofile = fopen("evtsToSkip.dat","a");
-       fprintf(ofile,"%d\n",lEvt);
-       fclose(ofile);
-      }
-    } else { 
-      printf("File itstracking.log not found\n");
-    }
-
-    return 1;
-}
-//-----------------------------------------------------------------------------
-void VtxFromHeader(const Char_t *outName,Bool_t smear,Char_t* path="./") {
-
-  TDatime t;
-  UInt_t seed = t.Get();
-  gRandom->SetSeed(seed);
-
-  Char_t falice[1024];
-  sprintf(falice,"%s/galice.root",path);
-  TFile *galice  = new TFile(falice);  
-  TFile *outFile = new TFile(outName,"update");
-
-  TDirectory *curdir;
-  Double_t pos[3],sigma[3];
-  if(smear) {
-    sigma[0]=15.e-4;
-    sigma[1]=15.e-4;
-    sigma[2]=10.e-4;
-  } else {
-    sigma[0]=0.;
-    sigma[1]=0.;
-    sigma[2]=0.;
-  }
-  Char_t vname[20];
-
-  galice->cd();
-
-  for(Int_t ev=0; ev<gNevents; ev++){
-    printf(" event %d\n",ev);
-    sprintf(vname,"Vertex_%d",ev);
-    TArrayF o = 0;
-    o.Set(3);
-    AliHeader* header = 0;
-    TTree* treeE = (TTree*)gDirectory->Get("TE");
-    treeE->SetBranchAddress("Header",&header);
-    treeE->GetEntry(ev);
-    AliGenEventHeader* genHeader = header->GenEventHeader();
-    if(genHeader) {
-      // get primary vertex position
-      genHeader->PrimaryVertex(o);
-      pos[0] = (Double_t)o[0];
-      pos[1] = (Double_t)o[1];
-      pos[2] = (Double_t)o[2];
-
-      if(smear) {
-       pos[0] = gRandom->Gaus(pos[0],sigma[0]);
-       pos[1] = gRandom->Gaus(pos[1],sigma[1]);
-       pos[2] = gRandom->Gaus(pos[2],sigma[2]);
-      }
-      // create AliITSVertex
-      AliITSVertex *vertex = new AliITSVertex(pos,sigma,vname);
-    } else {
-      printf(" ! event header not found : setting vertex to (0,0,0) !");
-      pos[0] = 0.;
-      pos[1] = 0.;
-      pos[2] = 0.;
-      // create AliITSVertex
-      AliITSVertex *vertex = new AliITSVertex(pos,sigma,vname);
-    }    
-    delete header;
-    // write AliITSVertex to file
-    curdir = gDirectory;
-    outFile->cd();
-    if(smear) {
-      vertex->SetTitle("vertex from header, smeared");
-    } else {
-      vertex->SetTitle("vertex from header");
-    }
-    vertex->Write();
-    curdir->cd();
-    vertex = 0;
-  }
-
-  outFile->Close();
-  galice->Close();
-
-  delete outFile;
-  delete galice;
-
-  return;
-}
-//-----------------------------------------------------------------------------
-void VtxFromTracks(const Char_t *outName,Char_t* path="./") {
-
-  // Open input and output files
-  Char_t ftrack[1024];
-  sprintf(ftrack,"%s/AliITStracksV2.root",path);
-  TFile *inFile  = new TFile(ftrack);
-  TFile *outFile = new TFile(outName,"update");
-
-  // set AliRun object to 0
-  if(gAlice) gAlice = 0;
-
-  // Create vertexer
-  AliITSVertexerTracks *vertexer = 
-    new AliITSVertexerTracks(inFile,outFile,gBfieldValue);
-  vertexer->SetFirstEvent(0);
-  vertexer->SetLastEvent(gNevents-1);
-  vertexer->SetDebug(0);
-  vertexer->PrintStatus();
-  // Find vertices
-  vertexer->FindVertices();
-
-  delete vertexer;
-
-  inFile->Close();
-  outFile->Close();
-  delete inFile;
-  delete outFile;
-
-  return;
-}
-//-----------------------------------------------------------------------------
-void ZvtxFromSPD(const Char_t *outName,Char_t* path="./") {
-
-  // create fast RecPoints, which are used for vertex finding
-  cerr<<"Fast AliITSRecPoint(s) !\n";
-  gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSHits2FastRecPoints.C");
-  AliITSHits2FastRecPoints(0,gNevents-1);
-
-  // delphi ---> azimuthal range to accept tracklets
-  // window ---> window in Z around the peak of tracklets proj. in mm
-  Float_t delphi=0.05;
-  Float_t window=3.;
-  Float_t initx=0.;
-  Float_t inity=0.;
-
-  Char_t falice[1024];
-  sprintf(falice,"%s/galice.root",path);
-  TFile *infile = new TFile(falice);
-  TFile *outfile = new TFile(outName,"update");
-
-  AliITSVertexerPPZ *vertexer = new AliITSVertexerPPZ(infile,outfile,initx,inity);
-  vertexer->SetFirstEvent(0);
-  vertexer->SetLastEvent(gNevents-1);
-  vertexer->SetDebug(0);
-  vertexer->SetDiffPhiMax(delphi);
-  vertexer->SetWindow(window);
-  vertexer->PrintStatus();
-  vertexer->FindVertices();
-  delete vertexer;
-  vertexer=0;
-
-  outfile->Close();
-  infile->Close();
-  delete infile;
-  delete outfile;
-
-
-  return;
-}
-//-----------------------------------------------------------------------------
-
-
-
-
-
-
-
-
-
diff --git a/HLT/trigger/AliD0Trigger.C b/HLT/trigger/AliD0Trigger.C
deleted file mode 100644 (file)
index 7cf6778..0000000
+++ /dev/null
@@ -1,438 +0,0 @@
-/****************************************************************************
- *                                                                          *
- * This macro computes the position of the D0 decay vertex using            *
- * helix DCA minimization by J.Belikov                                      *
- *                                                                          *
- * Reconstructed D0 are stored in a tree as AliD0toKpi objects              *
- *                                                                          *
- ****************************************************************************/ 
-//#define __COMPILE__
-//#ifdef __COMPILE__
-#if !defined(__CINT__) || defined(__MAKECINT__)
-//-- --- standard headers------------- 
-#include <iostream.h>
-//--------Root headers ---------------
-#include <TSystem.h>
-#include <TFile.h>
-#include <TString.h>
-#include <TStopwatch.h>
-#include <TObject.h>
-#include <TVector3.h>
-#include <TTree.h>
-#include <TParticle.h>
-#include <TArray.h>
-//----- AliRoot headers ---------------
-#include "alles.h"
-#include "AliRun.h"
-#include "AliKalmanTrack.h"
-#include "AliITStrackV2.h"
-#include "AliHeader.h"
-#include "AliGenEventHeader.h"
-#include "AliV0vertex.h"
-#include "AliV0vertexer.h"
-#include "AliITSVertex.h"
-#include "AliITSVertexer.h"
-#include "AliITSVertexerTracks.h"
-#include "AliD0toKpi.h"
-#endif
-//-------------------------------------
-
-typedef struct {
-  Int_t lab;
-  Int_t pdg;
-  Int_t mumlab;
-  Int_t mumpdg;
-  Float_t Vx,Vy,Vz;
-  Float_t Px,Py,Pz;
-} RECTRACK;
-
-// field (T)
-const Double_t kBz = 0.4;
-
-// primary vertex
-Double_t gv1[3] = {0.,0.,0,};
-
-// sigle track cuts
-const Double_t kPtCut = 0.5;  // GeV/c
-const Double_t kd0Cut = 50.; // micron
-//const Double_t kPtCut = 0.;  // GeV/c
-//const Double_t kd0Cut = 0.; // micron
-
-// cuts on D0 candidate (to be passed to function AliD0toKpi::Select())
-//
-// cuts[0] = inv. mass half width [GeV]   
-// cuts[1] = dca [micron]
-// cuts[2] = cosThetaStar 
-// cuts[3] = pTK [GeV/c]
-// cuts[4] = pTPi [GeV/c]
-// cuts[5] = d0K [micron]   upper limit!
-// cuts[6] = d0Pi [micron]  upper limit!
-// cuts[7] = d0d0 [micron^2]
-// cuts[8] = cosThetaPoint
-const Double_t kD0cuts[9] = {0.012,
-                             500.,
-                            0.8,
-                            0.5,
-                            0.5,
-                            500.,
-                            500.,
-                           -5000.,
-                            0.8};
-const Double_t kD0cutsAll[9] = {.1,
-                               1.e5,
-                               1.1,
-                               0.,
-                               0.,
-                               1.e10,
-                               1.e10,
-                               1.e10,
-                               -1.1};
-// mass cut for 1st level rejection
-const Double_t kMassCut = 0.1; // GeV
-
-// this function ckecks files existence
-Bool_t GetInputFiles(char* path[1024]);
-
-// 1st level rejection based on inv. mass
-Bool_t SelectInvMass(const Double_t p[6]);
-
-// this function applies single track cuts
-Bool_t TrkCuts(const AliITStrackV2& trk);
-
-// this function creates TObjArrays with positive and negative tracks
-void   SelectTracks(TTree& itsTree,
-                     TObjArray& trksP,Int_t* itsEntryP,Int_t& nTrksP,
-                     TObjArray& trksN,Int_t* itsEntryN,Int_t& nTrksN);
-
-
-void   AliD0Trigger(Int_t evFirst=0,Int_t evLast=1,Char_t* path="./") {
-
-  const Char_t *name="AliD0Trigger";
-  cerr<<'\n'<<name<<"...\n";
-  gBenchmark->Start(name);  
-  TStopwatch timer;
-  AliKalmanTrack::SetConvConst(100/0.299792458/kBz);
-
-  // load library for D0 candidates class
-  //gSystem->Load("libD0toKpi.so");
-
-  // check existence of input files 
-  if(!GetInputFiles(path)) { cerr<<"No tracks file found"<<endl; return; }
-
-  Char_t fname[1024];
-  sprintf(fname,"%s/AliD0toKpiBkg.root",path);
-  TString outName(fname);
-
-  Int_t ev;
-  Int_t nD0rec=0,nD0rec1ev=0;
-  Double_t dca;
-  Double_t v2[3],mom[6],d0[2];
-  Int_t pdg[2],mum[2];
-  Double_t alphaP,alphaN,ptP,ptN,phiP,phiN;
-  Int_t iTrkP,iTrkN,itsEntries;
-  Int_t nTrksP=0,nTrksN=0;
-  Int_t okD0=0,okD0bar=0;
-  Char_t trksName[100],refsName[100],vtxName[100];
-  RECTRACK rectrk;  
-  AliITStrackV2 *postrack = 0;
-  AliITStrackV2 *negtrack = 0;
-
-  // create the AliITSVertexerTracks object
-  AliITSVertexerTracks *vertexer1 = new AliITSVertexerTracks;
-  //vertexer1->SetUseThrustFrame(1);
-  vertexer1->SetMinTracks(2);
-  vertexer1->SetDebug(0);
-  Int_t skipped[2];
-
-  // define the cuts for vertexing
-  Double_t vtxcuts[]={33., // max. allowed chi2
-                     0.0, // min. allowed negative daughter's impact param 
-                     0.0, // min. allowed positive daughter's impact param 
-                     1.0, // max. allowed DCA between the daughter tracks
-                    -1.0, // min. allowed cosine of V0's pointing angle
-                     0.0, // min. radius of the fiducial volume
-                     2.9};// max. radius of the fiducial volume
-  
-  // create the AliV0vertexer object
-  AliV0vertexer *vertexer2 = new AliV0vertexer(vtxcuts);
-
-
-  // Create tree for reconstructed D0s
-  TTree D0Tree("TreeD0","Tree with D0 candidates");
-  AliD0toKpi *ioD0toKpi=0;
-  D0Tree.Branch("D0toKpi","AliD0toKpi",&ioD0toKpi,200000,0);
-
-  // Open file with ITS tracks
-  Char_t fnameTrack[1024];
-  sprintf(fnameTrack,"%s/AliITStracksV2.root",path);
-  TFile* itstrks = TFile::Open(fnameTrack);
-
-  // Open file with ITS track references
-  Char_t fnameRef[1024];
-  sprintf(fnameRef,"%s/ITStracksRefFile.root",path);
-  TFile* itsrefs = TFile::Open(fnameRef);
-
-  // Open Primary Vertex File
-  Char_t fnameVertex[1024];
-  sprintf(fnameVertex,"%s/Vtx4Tracking.root",path);
-  TFile* vertexFile = TFile::Open(fnameVertex);
-
-  // loop on events in file
-  for(ev=evFirst; ev<=evLast; ev++) {
-    printf(" --- Processing event  %d ---\n",ev);
-    sprintf(vtxName,"VertexTracks_%d",ev);
-    sprintf(trksName,"TreeT_ITS_%d",ev);
-    sprintf(refsName,"Tree_Ref_%d",ev);
-
-
-    // tracks from ITS
-    TTree *itsTree=(TTree*)itstrks->Get(trksName);
-    if(!itsTree) continue;
-    itsEntries = (Int_t)itsTree->GetEntries();
-    printf("+++\n+++ Number of tracks in ITS: %d\n+++\n\n",itsEntries);
-    
-    // tree from reference file
-    TTree *refTree=(TTree*)itsrefs->Get(refsName);
-    refTree->SetBranchAddress("rectracks",&rectrk);
-    
-    //get the primary vertex from headerfile
-
-    AliITSVertex *vertex = vertexFile->Get("Vertex_0");
-    vertex->GetXYZ(gv1);
-
-    cout<<gv1[2]<<endl;
-    
-    // call function which applies sigle track selection and
-    // separetes positives and negatives
-    
-    TObjArray trksP(itsEntries/2);
-    Int_t *itsEntryP = new Int_t[itsEntries];
-    TObjArray trksN(itsEntries/2);
-    Int_t *itsEntryN = new Int_t[itsEntries];
-    SelectTracks(*itsTree,trksP,itsEntryP,nTrksP,trksN,itsEntryN,nTrksN);
-
-    nD0rec1ev = 0;
-
-    cout<<"NnegTracks: "<<nTrksN<<endl;
-
-    // loop on positive tracks
-    for(iTrkP=0; iTrkP<nTrksP; iTrkP++) {
-      //if(iTrkP % 10==0) cerr<<"--- Processing positive track number: "<<iTrkP<<" of "<<nTrksP<<"\r";
-         
-      // get track from track array
-      postrack = (AliITStrackV2*)trksP.At(iTrkP);
-
-      // get info on tracks PDG and mothers PDG from reference file
-      refTree->GetEvent(itsEntryP[iTrkP]);
-      pdg[0] = rectrk.pdg;
-      mum[0] = rectrk.mumpdg;
-
-      // loop on negative tracks 
-      for(iTrkN=0; iTrkN<nTrksN; iTrkN++) {
-       
-       // get track from track array
-       negtrack = (AliITStrackV2*)trksN.At(iTrkN);
-      
-       // get info on tracks PDG and mothers PDG from reference file
-       refTree->GetEvent(itsEntryN[iTrkN]);
-       pdg[1] = rectrk.pdg;
-       mum[1] = rectrk.mumpdg;
-       //
-       // ----------- DCA MINIMIZATION ------------------
-       //
-       // find the DCA and propagate the tracks to the DCA 
-       dca = vertexer2->PropagateToDCA(negtrack,postrack);
-
-       // define the AliV0vertex object
-       AliV0vertex *vertex2 = new AliV0vertex(*negtrack,*postrack);
-         
-       // get position of the vertex
-       vertex2->GetXYZ(v2[0],v2[1],v2[2]);
-       
-       delete vertex2;
-  
-       // momenta of the tracks at the vertex
-       ptP = 1./TMath::Abs(postrack->Get1Pt());
-       alphaP = postrack->GetAlpha();
-       phiP = alphaP+TMath::ASin(postrack->GetSnp());
-       mom[0] = ptP*TMath::Cos(phiP); 
-       mom[1] = ptP*TMath::Sin(phiP);
-       mom[2] = ptP*postrack->GetTgl();
-         
-       ptN = 1./TMath::Abs(negtrack->Get1Pt());
-       alphaN = negtrack->GetAlpha();
-       phiN = alphaN+TMath::ASin(negtrack->GetSnp());
-       mom[3] = ptN*TMath::Cos(phiN); 
-       mom[4] = ptN*TMath::Sin(phiN);
-       mom[5] = ptN*negtrack->GetTgl();
-         
-
-       Bool_t goodVtx = kFALSE;
-       // no vertexing if DeltaMass > kMassCut 
-       if(SelectInvMass(mom)) {
-         // primary vertex from other tracks in event
-         vertexer1->SetVtxStart(0.,0.);
-         skipped[0] = itsEntryP[iTrkP];
-         skipped[1] = itsEntryN[iTrkN];
-         vertexer1->SetSkipTracks(2,skipped);
-         // impact parameters of the tracks w.r.t. the smeared primary vertex
-         d0[0] =  10000.*postrack->GetD(gv1[0],gv1[1]);
-         d0[1] = -10000.*negtrack->GetD(gv1[0],gv1[1]);
-       }
-         
-       // create the object TD0rec and store it in the tree
-       AliD0toKpi theD0(kFALSE,ev,gv1,v2,dca,mom,d0,pdg,mum);
-
-       
-       // select D0s
-       if(goodVtx && theD0.Select(kD0cuts,okD0,okD0bar)) {
-             
-         // compute the weights
-         theD0.ComputeWgts();
-
-         // fill the tree
-         ioD0toKpi=&theD0;
-         D0Tree.Fill();
-
-         nD0rec++; nD0rec1ev++;
-         ioD0toKpi=0;  
-       }
-       
-       negtrack = 0;
-      } // loop on negative tracks
-      postrack = 0;
-    }   // loop on positive tracks
-
-    delete [] itsEntryP;
-    delete [] itsEntryN;
-    delete itsTree;
-    delete refTree;
-
-    printf("\n+++\n+++ Number of D0 candidates: %d\n+++\n",nD0rec1ev);
-    printf("----------------------------------------------------------\n");
-
-  }    // loop on events in file
-
-  printf("\n+++\n+++ Total number of D0 candidates: %d\n+++\n",nD0rec);
-
-  delete vertexer1;
-  delete vertexer2;
-
-  itstrks->Close();
-  itsrefs->Close();
-
-  // store tree in a file
-  TFile* outroot = new TFile(outName.Data(),"recreate");
-  D0Tree.Write();
-  outroot->Close();
-  delete outroot;
-
-  gBenchmark->Stop(name);
-  gBenchmark->Show(name);
-
-  return;
-}
-//___________________________________________________________________________
-Bool_t   GetInputFiles(Char_t* path2="./") {
-  Char_t fnameTrack[1024];
-  sprintf(fnameTrack,"%s/AliITStracksV2.root",path2);
-  TString itsName(fnameTrack);
-  Char_t fnameRef[1024];
-  sprintf(fnameRef,"%s/ITStracksRefFile.root",path2);
-  TString refName(fnameRef);
-
-  if(gSystem->AccessPathName(itsName.Data(),kFileExists) ||
-     gSystem->AccessPathName(refName.Data(),kFileExists)) return kFALSE;
-
-  return kTRUE;
-}
-//___________________________________________________________________________
-Bool_t SelectInvMass(const Double_t p[6]) {
-
-  Double_t mD0 = 1.8645;
-  Double_t mPi = 0.13957;
-  Double_t mKa = 0.49368;
-
-  Double_t energy[2];
-  Double_t mom2[2],momTot2;
-
-  mom2[0] = p[0]*p[0]+p[1]*p[1]+p[2]*p[2];
-  mom2[1] = p[3]*p[3]+p[4]*p[4]+p[5]*p[5];
-
-  momTot2 = (p[0]+p[3])*(p[0]+p[3])+
-            (p[1]+p[4])*(p[1]+p[4])+
-            (p[2]+p[5])*(p[2]+p[5]);
-
-  // D0 -> K- Pi+
-  energy[1] = TMath::Sqrt(mKa*mKa+mom2[1]);
-  energy[0] = TMath::Sqrt(mPi*mPi+mom2[0]);
-
-  Double_t minvD0 = TMath::Sqrt((energy[0]+energy[1])*(energy[0]+energy[1])-momTot2);
-    
-
-  // D0bar -> K+ Pi-
-  energy[0] = TMath::Sqrt(mKa*mKa+mom2[0]);
-  energy[1] = TMath::Sqrt(mPi*mPi+mom2[1]);
-
-  Double_t minvD0bar = TMath::Sqrt((energy[0]+energy[1])*(energy[0]+energy[1])-momTot2);
-
-  if(TMath::Abs(minvD0-mD0) < kMassCut)    return kTRUE;
-  if(TMath::Abs(minvD0bar-mD0) < kMassCut) return kTRUE;
-  return kFALSE;
-}
-//___________________________________________________________________________
-void   SelectTracks(TTree& itsTree,
-                   TObjArray& trksP,Int_t* itsEntryP,Int_t& nTrksP,
-                   TObjArray& trksN,Int_t* itsEntryN,Int_t& nTrksN) {
-//
-// this function creates two TObjArrays with positive and negative tracks
-//
-  nTrksP=0,nTrksN=0;
-
-  Int_t entr = (Int_t)itsTree.GetEntries();
-
-  // trasfer tracks from tree to arrays
-  for(Int_t i=0; i<entr; i++) {
-
-    AliITStrackV2 *itstrack = new AliITStrackV2; 
-    itsTree.SetBranchAddress("tracks",&itstrack);
-
-    itsTree.GetEvent(i);
-
-    // single track selection
-    if(!TrkCuts(*itstrack)) { delete itstrack; continue; }
-
-    if(itstrack->Get1Pt()>0.) { // negative track
-      trksN.AddLast(itstrack);
-      itsEntryN[nTrksN] = i;
-      nTrksN++;
-    } else {                    // positive track
-      trksP.AddLast(itstrack);
-      itsEntryP[nTrksP] = i;
-      nTrksP++;
-    }
-
-  }
-
-  return;
-}
-//____________________________________________________________________________
-Bool_t TrkCuts(const AliITStrackV2& trk) {
-// 
-// this function tells if track passes some kinematical cuts  
-//
-  if(TMath::Abs(1./trk.Get1Pt()) < kPtCut)                return kFALSE;
-  if(TMath::Abs(10000.*trk.GetD(gv1[0],gv1[1])) < kd0Cut) return kFALSE;
-
-  return kTRUE;
-}
-
-
-
-
-
-
-
-
index ff81e85..d6497c7 100644 (file)
@@ -86,6 +86,7 @@ bool AliD0Trigger::FindV0(){
   double V0[4]={0,0,0,0};
   bestV0[0]=0;  bestV0[1]=0;  bestV0[2]=0;
   
+  //Do not get right values
   Gxpos=posTrack->GetX()*cos(posTrack->GetAlpha())-posTrack->GetY()*sin(posTrack->GetAlpha());
   Gypos=posTrack->GetX()*sin(posTrack->GetAlpha())+posTrack->GetY()*cos(posTrack->GetAlpha());
   Gxneg=negTrack->GetX()*cos(negTrack->GetAlpha())-negTrack->GetY()*sin(negTrack->GetAlpha());
@@ -113,8 +114,8 @@ bool AliD0Trigger::FindV0(){
   Fc=pow(t,2)-(4*pow(q,2)*pow(r1,2))+(4*pow(q,2)*pow(b1,2));
   
   if(pow(Fb,2)-(4*Fa*Fc)>=0){
-    y1=(-Fb+(sqrt(pow(Fb,2)-(4*Fa*Fc))))/(2*Fa);  //noe feil her. floating point
-    y2=(-Fb-(sqrt(pow(Fb,2)-(4*Fa*Fc))))/(2*Fa);  //trolig negativ under rot 
+    y1=(-Fb+(sqrt(pow(Fb,2)-(4*Fa*Fc))))/(2*Fa);  
+    y2=(-Fb-(sqrt(pow(Fb,2)-(4*Fa*Fc))))/(2*Fa);  
     
     x1=sqrt(pow(r1,2)-pow((y1-b1),2))+a1;    
     x2=sqrt(pow(r1,2)-pow((y2-b1),2))+a1;    
@@ -165,6 +166,8 @@ bool AliD0Trigger::FindV0(){
 }
 void AliD0Trigger::FindMomentaAtVertex(){
 
+  //This method moves the momenta to the secondary vertex
+
   double r1=fabs(1/(AliL3Transform::GetBFact()*Bfield*posTrack->Get1Pt()));
   double r2=fabs(1/(AliL3Transform::GetBFact()*Bfield*negTrack->Get1Pt()));
   
@@ -216,12 +219,12 @@ void AliD0Trigger::FindMomentaAtVertex(){
 }
 Bool_t AliD0Trigger::PointingAngle(){
 
-  TVector3 mom(momenta[0]+momenta[3],momenta[1]+momenta[4],momenta[2]+momenta[5]);
+  TVector3 mom(Px(),Py(),Pz());
   TVector3 flight(bestV0[0]-primaryVertex[0],bestV0[1]-primaryVertex[1],bestV0[2]-primaryVertex[2]);
 
   double pta = mom.Angle(flight);
 
-  if(cos(pta)<cutPointAngle)
+  if(cos(pta)>cutPointAngle)
     return true;
   else
     return false;
@@ -318,11 +321,9 @@ bool AliD0Trigger::CosThetaStar()
 
   ctsD0bar = (qL2/gamma-beta*TMath::Sqrt(pStar*pStar+kMK*kMK))/pStar;
 
-  if(TMath::Abs(ctsD0) > cutCosThetaStar){
-    if(TMath::Abs(ctsD0bar) > cutCosThetaStar){
+  if(fabs(ctsD0) > cutCosThetaStar || fabs(ctsD0bar) > cutCosThetaStar){
       goodtheta=true;
     }
-  }
   return goodtheta;
 }
 bool AliD0Trigger::pTchild()
@@ -340,3 +341,9 @@ bool AliD0Trigger::pTchild()
   }
   return goodpT;
 }
+void AliD0Trigger::SetV0(double v[3])
+{
+  bestV0[0]=v[0];
+  bestV0[1]=v[1];
+  bestV0[2]=v[2];
+}
index 576d9f9..6644972 100644 (file)
@@ -2,6 +2,7 @@
 #define AliD0_Trigger
 
 #include "AliL3RootTypes.h"
+#include <math.h>
 
 class AliITStrackV2;
 
@@ -23,6 +24,7 @@ class AliD0Trigger {
   virtual ~AliD0Trigger();
 
   void SetTracks(AliITStrackV2 * posT, AliITStrackV2 * negT);
+  void SetV0(double v[3]);
   bool FindInvMass();
   bool FindV0();
   bool FindV0offline(double v[3]);
@@ -38,6 +40,8 @@ class AliD0Trigger {
   double Py(){return (momenta[1]+momenta[4]);}
   double Pz(){return (momenta[2]+momenta[5]);}
   double Energy();
+  //double Eta(){return atanh(cos(atan(Pt()/Pz())));}
+  double Eta(){return 0.5*(log((P()+Pz())/(P()-Pz())));}
   bool pTchild();
 
   ClassDef(AliD0Trigger,1) 
diff --git a/HLT/trigger/AliD0vtxFinderBkg_pp_VTX.C b/HLT/trigger/AliD0vtxFinderBkg_pp_VTX.C
deleted file mode 100644 (file)
index a03d273..0000000
+++ /dev/null
@@ -1,431 +0,0 @@
-/****************************************************************************
- *                                                                          *
- * This macro computes the position of the D0 decay vertex using            *
- * helix DCA minimization by J.Belikov                                      *
- *                                                                          *
- * Reconstructed D0 are stored in a tree as AliD0toKpi objects              *
- *                                                                          *
- ****************************************************************************/ 
-//#define __COMPILE__
-//#ifdef __COMPILE__
-#if !defined(__CINT__) || defined(__MAKECINT__)
-//-- --- standard headers------------- 
-#include <iostream.h>
-//--------Root headers ---------------
-#include <TSystem.h>
-#include <TFile.h>
-#include <TString.h>
-#include <TStopwatch.h>
-#include <TObject.h>
-#include <TVector3.h>
-#include <TTree.h>
-#include <TParticle.h>
-#include <TArray.h>
-//----- AliRoot headers ---------------
-#include "alles.h"
-#include "AliRun.h"
-#include "AliKalmanTrack.h"
-#include "AliITStrackV2.h"
-#include "AliHeader.h"
-#include "AliGenEventHeader.h"
-#include "AliV0vertex.h"
-#include "AliV0vertexer.h"
-#include "AliITSVertex.h"
-#include "AliITSVertexer.h"
-#include "AliITSVertexerTracks.h"
-#include "AliD0toKpi.h"
-#endif
-//-------------------------------------
-
-typedef struct {
-  Int_t lab;
-  Int_t pdg;
-  Int_t mumlab;
-  Int_t mumpdg;
-  Float_t Vx,Vy,Vz;
-  Float_t Px,Py,Pz;
-} RECTRACK;
-
-// field (T)
-const Double_t kBz = 0.4;
-
-// primary vertex
-Double_t gv1[3] = {0.,0.,0,};
-
-// sigle track cuts
-//const Double_t kPtCut = 0.5;  // GeV/c
-//const Double_t kd0Cut = 50.; // micron
-const Double_t kPtCut = 0.;  // GeV/c
-const Double_t kd0Cut = 0.; // micron
-
-// cuts on D0 candidate (to be passed to function AliD0toKpi::Select())
-//
-// cuts[0] = inv. mass half width [GeV]   
-// cuts[1] = dca [micron]
-// cuts[2] = cosThetaStar 
-// cuts[3] = pTK [GeV/c]
-// cuts[4] = pTPi [GeV/c]
-// cuts[5] = d0K [micron]   upper limit!
-// cuts[6] = d0Pi [micron]  upper limit!
-// cuts[7] = d0d0 [micron^2]
-// cuts[8] = cosThetaPoint
-const Double_t kD0cuts[9] = {0.012,
-                             500.,
-                            0.8,
-                            0.5,
-                            0.5,
-                            500.,
-                            500.,
-                           -5000.,
-                            0.8};
-const Double_t kD0cutsAll[9] = {.1,
-                               1.e5,
-                               1.1,
-                               0.,
-                               0.,
-                               1.e10,
-                               1.e10,
-                               1.e10,
-                               -1.1};
-// mass cut for 1st level rejection
-const Double_t kMassCut = 0.1; // GeV
-
-// this function ckecks files existence
-Bool_t GetInputFiles();
-
-// 1st level rejection based on inv. mass
-Bool_t SelectInvMass(const Double_t p[6]);
-
-// this function applies single track cuts
-Bool_t TrkCuts(const AliITStrackV2& trk);
-
-// this function creates TObjArrays with positive and negative tracks
-void   SelectTracks(TTree& itsTree,
-                     TObjArray& trksP,Int_t* itsEntryP,Int_t& nTrksP,
-                     TObjArray& trksN,Int_t* itsEntryN,Int_t& nTrksN);
-
-
-void   AliD0vtxFinderBkg_pp_VTX(Int_t evFirst=0,Int_t evLast=4999) {
-
-  const Char_t *name="AliD0vtxFinderBkg_pp_VTX";
-  cerr<<'\n'<<name<<"...\n";
-  gBenchmark->Start(name);  
-
-  AliKalmanTrack::SetConvConst(100/0.299792458/kBz);
-
-
-  // load library for D0 candidates class
-  gSystem->Load("libD0toKpi.so");
-
-  // check existence of input files 
-  if(!GetInputFiles()) { cerr<<"No tracks file found"<<endl; return; }
-
-  TString outName("AliD0toKpiBkg.root");
-  TString outName2("nTotEv.dat");
-
-  Int_t ev;
-  Int_t nTotEv=0,nD0rec=0,nD0rec1ev=0;
-  Double_t dca;
-  Double_t v2[3],mom[6],d0[2];
-  Int_t pdg[2],mum[2];
-  Double_t alphaP,alphaN,ptP,ptN,phiP,phiN;
-  Int_t iTrkP,iTrkN,itsEntries;
-  Int_t nTrksP=0,nTrksN=0;
-  Int_t okD0=0,okD0bar=0;
-  Char_t trksName[100],refsName[100],vtxName[100];
-  RECTRACK rectrk;  
-  AliITStrackV2 *postrack = 0;
-  AliITStrackV2 *negtrack = 0;
-
-  // create the AliITSVertexerTracks object
-  AliITSVertexerTracks *vertexer1 = new AliITSVertexerTracks;
-  //vertexer1->SetUseThrustFrame(1);
-  vertexer1->SetMinTracks(2);
-  vertexer1->SetDebug(0);
-  Int_t skipped[2];
-
-  // define the cuts for vertexing
-  Double_t vtxcuts[]={33., // max. allowed chi2
-                     0.0, // min. allowed negative daughter's impact param 
-                     0.0, // min. allowed positive daughter's impact param 
-                     1.0, // max. allowed DCA between the daughter tracks
-                    -1.0, // min. allowed cosine of V0's pointing angle
-                     0.0, // min. radius of the fiducial volume
-                     2.9};// max. radius of the fiducial volume
-  
-  // create the AliV0vertexer object
-  AliV0vertexer *vertexer2 = new AliV0vertexer(vtxcuts);
-
-
-  // Create tree for reconstructed D0s
-  TTree D0Tree("TreeD0","Tree with D0 candidates");
-  AliD0toKpi *ioD0toKpi=0;
-  D0Tree.Branch("D0toKpi","AliD0toKpi",&ioD0toKpi,200000,0);
-
-  // Open file with ITS tracks
-  TFile* itstrks = TFile::Open("AliITStracksV2.root");
-
-  // Open file with ITS track references
-  TFile* itsrefs = TFile::Open("ITStracksRefFile.root");
-
-  // loop on events in file
-  for(ev=evFirst; ev<=evLast; ev++) {
-    printf(" --- Processing event  %d ---\n",ev);
-    sprintf(vtxName,"VertexTracks_%d",ev);
-    sprintf(trksName,"TreeT_ITS_%d",ev);
-    sprintf(refsName,"Tree_Ref_%d",ev);
-
-
-    // tracks from ITS
-    TTree *itsTree=(TTree*)itstrks->Get(trksName);
-    if(!itsTree) continue;
-    itsEntries = (Int_t)itsTree->GetEntries();
-    printf("+++\n+++ Number of tracks in ITS: %d\n+++\n\n",itsEntries);
-    
-    // tree from reference file
-    TTree *refTree=(TTree*)itsrefs->Get(refsName);
-    refTree->SetBranchAddress("rectracks",&rectrk);
-    
-    // count the total number of events
-    nTotEv++;
-
-
-    // call function which applies sigle track selection and
-    // separetes positives and negatives
-    TObjArray trksP(itsEntries/2);
-    Int_t *itsEntryP = new Int_t[itsEntries];
-    TObjArray trksN(itsEntries/2);
-    Int_t *itsEntryN = new Int_t[itsEntries];
-    SelectTracks(*itsTree,trksP,itsEntryP,nTrksP,trksN,itsEntryN,nTrksN);
-      
-    nD0rec1ev = 0;
-    // loop on positive tracks
-    for(iTrkP=0; iTrkP<nTrksP; iTrkP++) {
-      //if(iTrkP % 10==0) cerr<<"--- Processing positive track number: "<<iTrkP<<" of "<<nTrksP<<"\r";
-         
-      // get track from track array
-      postrack = (AliITStrackV2*)trksP.At(iTrkP);
-
-      // get info on tracks PDG and mothers PDG from reference file
-      refTree->GetEvent(itsEntryP[iTrkP]);
-      pdg[0] = rectrk.pdg;
-      mum[0] = rectrk.mumpdg;
-
-      // loop on negative tracks 
-      for(iTrkN=0; iTrkN<nTrksN; iTrkN++) {
-       // get track from track array
-       negtrack = (AliITStrackV2*)trksN.At(iTrkN);
-      
-       // get info on tracks PDG and mothers PDG from reference file
-       refTree->GetEvent(itsEntryN[iTrkN]);
-       pdg[1] = rectrk.pdg;
-       mum[1] = rectrk.mumpdg;
-       //
-       // ----------- DCA MINIMIZATION ------------------
-       //
-       // find the DCA and propagate the tracks to the DCA 
-       dca = vertexer2->PropagateToDCA(negtrack,postrack);
-
-       // define the AliV0vertex object
-       AliV0vertex *vertex2 = new AliV0vertex(*negtrack,*postrack);
-         
-       // get position of the vertex
-       vertex2->GetXYZ(v2[0],v2[1],v2[2]);
-       
-       delete vertex2;
-  
-       // momenta of the tracks at the vertex
-       ptP = 1./TMath::Abs(postrack->Get1Pt());
-       alphaP = postrack->GetAlpha();
-       phiP = alphaP+TMath::ASin(postrack->GetSnp());
-       mom[0] = ptP*TMath::Cos(phiP); 
-       mom[1] = ptP*TMath::Sin(phiP);
-       mom[2] = ptP*postrack->GetTgl();
-         
-       ptN = 1./TMath::Abs(negtrack->Get1Pt());
-       alphaN = negtrack->GetAlpha();
-       phiN = alphaN+TMath::ASin(negtrack->GetSnp());
-       mom[3] = ptN*TMath::Cos(phiN); 
-       mom[4] = ptN*TMath::Sin(phiN);
-       mom[5] = ptN*negtrack->GetTgl();
-         
-
-       Bool_t goodVtx = kFALSE;
-       // no vertexing if DeltaMass > kMassCut 
-       if(SelectInvMass(mom)) {
-         // primary vertex from other tracks in event
-         vertexer1->SetVtxStart(0.,0.);
-         skipped[0] = itsEntryP[iTrkP];
-         skipped[1] = itsEntryN[iTrkN];
-         vertexer1->SetSkipTracks(2,skipped);
-         AliITSVertex *vertex1 = 
-           (AliITSVertex*)vertexer1->VertexOnTheFly(*itsTree); 
-         if(vertex1->GetNContributors()>0) goodVtx = kTRUE;
-         vertex1->GetXYZ(gv1);
-         // impact parameters of the tracks w.r.t. the smeared primary vertex
-         d0[0] =  10000.*postrack->GetD(gv1[0],gv1[1]);
-         d0[1] = -10000.*negtrack->GetD(gv1[0],gv1[1]);
-         //vertex1->PrintStatus();
-         delete vertex1;       
-       }
-         
-       // create the object TD0rec and store it in the tree
-       AliD0toKpi theD0(kFALSE,ev,gv1,v2,dca,mom,d0,pdg,mum);
-
-       
-       // select D0s
-       if(goodVtx && theD0.Select(kD0cutsAll,okD0,okD0bar)) {
-             
-         // compute the weights
-         theD0.ComputeWgts();
-
-         // fill the tree
-         ioD0toKpi=&theD0;
-         D0Tree.Fill();
-
-         nD0rec++; nD0rec1ev++;
-         ioD0toKpi=0;  
-       }
-       
-       negtrack = 0;
-      } // loop on negative tracks
-      postrack = 0;
-    }   // loop on positive tracks
-
-    delete [] itsEntryP;
-    delete [] itsEntryN;
-    delete itsTree;
-    delete refTree;
-
-    printf("\n+++\n+++ Number of D0 candidates: %d\n+++\n",nD0rec1ev);
-    printf("----------------------------------------------------------\n");
-
-  }    // loop on events in file
-
-
-  printf("\n+++\n+++ Total number of events: %d\n+++\n",nTotEv);
-  printf("\n+++\n+++ Total number of D0 candidates: %d\n+++\n",nD0rec);
-
-  delete vertexer1;
-  delete vertexer2;
-
-  itstrks->Close();
-  itsrefs->Close();
-
-  // store tree in a file
-  TFile* outroot = new TFile(outName.Data(),"recreate");
-  D0Tree.Write();
-  outroot->Close();
-  delete outroot;
-
-  // write to a file the total number of events
-  FILE* outdat = fopen(outName2.Data(),"w");
-  fprintf(outdat,"%d\n",nTotEv);
-  fclose(outdat);
-
-
-  gBenchmark->Stop(name);
-  gBenchmark->Show(name);
-
-  return;
-}
-//___________________________________________________________________________
-Bool_t   GetInputFiles() {
-  TString itsName("AliITStracksV2.root");
-  TString refName("ITStracksRefFile.root");
-
-  if(gSystem->AccessPathName(itsName.Data(),kFileExists) ||
-     gSystem->AccessPathName(refName.Data(),kFileExists)) return kFALSE;
-
-  return kTRUE;
-}
-//___________________________________________________________________________
-Bool_t SelectInvMass(const Double_t p[6]) {
-
-  Double_t mD0 = 1.8645;
-  Double_t mPi = 0.13957;
-  Double_t mKa = 0.49368;
-
-  Double_t energy[2];
-  Double_t mom2[2],momTot2;
-
-  mom2[0] = p[0]*p[0]+p[1]*p[1]+p[2]*p[2];
-  mom2[1] = p[3]*p[3]+p[4]*p[4]+p[5]*p[5];
-
-  momTot2 = (p[0]+p[3])*(p[0]+p[3])+
-            (p[1]+p[4])*(p[1]+p[4])+
-            (p[2]+p[5])*(p[2]+p[5]);
-
-  // D0 -> K- Pi+
-  energy[1] = TMath::Sqrt(mKa*mKa+mom2[1]);
-  energy[0] = TMath::Sqrt(mPi*mPi+mom2[0]);
-
-  Double_t minvD0 = TMath::Sqrt((energy[0]+energy[1])*(energy[0]+energy[1])-momTot2);
-    
-
-  // D0bar -> K+ Pi-
-  energy[0] = TMath::Sqrt(mKa*mKa+mom2[0]);
-  energy[1] = TMath::Sqrt(mPi*mPi+mom2[1]);
-
-  Double_t minvD0bar = TMath::Sqrt((energy[0]+energy[1])*(energy[0]+energy[1])-momTot2);
-
-  if(TMath::Abs(minvD0-mD0) < kMassCut)    return kTRUE;
-  if(TMath::Abs(minvD0bar-mD0) < kMassCut) return kTRUE;
-  return kFALSE;
-}
-//___________________________________________________________________________
-void   SelectTracks(TTree& itsTree,
-                   TObjArray& trksP,Int_t* itsEntryP,Int_t& nTrksP,
-                   TObjArray& trksN,Int_t* itsEntryN,Int_t& nTrksN) {
-//
-// this function creates two TObjArrays with positive and negative tracks
-//
-  nTrksP=0,nTrksN=0;
-
-  Int_t entr = (Int_t)itsTree.GetEntries();
-
-  // trasfer tracks from tree to arrays
-  for(Int_t i=0; i<entr; i++) {
-
-    AliITStrackV2 *itstrack = new AliITStrackV2; 
-    itsTree.SetBranchAddress("tracks",&itstrack);
-
-    itsTree.GetEvent(i);
-
-    // single track selection
-    if(!TrkCuts(*itstrack)) { delete itstrack; continue; }
-
-    if(itstrack->Get1Pt()>0.) { // negative track
-      trksN.AddLast(itstrack);
-      itsEntryN[nTrksN] = i;
-      nTrksN++;
-    } else {                    // positive track
-      trksP.AddLast(itstrack);
-      itsEntryP[nTrksP] = i;
-      nTrksP++;
-    }
-
-  }
-
-  return;
-}
-//____________________________________________________________________________
-Bool_t TrkCuts(const AliITStrackV2& trk) {
-// 
-// this function tells if track passes some kinematical cuts  
-//
-  if(TMath::Abs(1./trk.Get1Pt()) < kPtCut)                return kFALSE;
-  if(TMath::Abs(10000.*trk.GetD(gv1[0],gv1[1])) < kd0Cut) return kFALSE;
-
-  return kTRUE;
-}
-
-
-
-
-
-
-
-
diff --git a/HLT/trigger/AliD0vtxFinderSgn_pp_VTX.C b/HLT/trigger/AliD0vtxFinderSgn_pp_VTX.C
deleted file mode 100644 (file)
index f9eb527..0000000
+++ /dev/null
@@ -1,491 +0,0 @@
-/****************************************************************************
- *                                                                          *
- * This macro computes the position of the D0 decay vertex using            *
- * helix DCA minimization by J.Belikov                                      *
- *                                                                          *
- * Reconstructed D0 are stored in a tree as AliD0toKpi objects              *
- *                                                                          *
- ****************************************************************************/ 
-//#define __COMPILE__
-//#ifdef __COMPILE__
-#if !defined(__CINT__) || defined(__MAKECINT__)
-//-- --- standard headers------------- 
-#include <iostream.h>
-//--------Root headers ---------------
-#include <TSystem.h>
-#include <TFile.h>
-#include <TString.h>
-#include <TStopwatch.h>
-#include <TObject.h>
-#include <TVector3.h>
-#include <TTree.h>
-#include <TParticle.h>
-#include <TArray.h>
-//----- AliRoot headers ---------------
-#include "alles.h"
-#include "AliRun.h"
-#include "AliKalmanTrack.h"
-#include "AliITStrackV2.h"
-#include "AliHeader.h"
-#include "AliGenEventHeader.h"
-#include "AliV0vertex.h"
-#include "AliV0vertexer.h"
-#include "AliITSVertex.h"
-#include "AliITSVertexer.h"
-#include "AliITSVertexerTracks.h"
-#include "AliD0toKpi.h"
-#endif
-//-------------------------------------
-
-typedef struct {
-  Int_t lab;
-  Int_t pdg;
-  Int_t mumlab;
-  Int_t mumpdg;
-  Float_t Vx,Vy,Vz;
-  Float_t Px,Py,Pz;
-} RECTRACK;
-
-// field (T)
-const Double_t kBz = 0.4;
-
-// primary vertex
-Double_t gv1[3] = {0.,0.,0.};
-
-// sigle track cuts
-//const Double_t kPtCut = 0.5;  // GeV/c
-//const Double_t kd0Cut = 50.; // micron
-const Double_t kPtCut = 0.;  // GeV/c
-const Double_t kd0Cut = 0.; // micron
-
-// cuts on D0 candidate (to be passed to function AliD0toKpi::Select())
-//
-// cuts[0] = inv. mass half width [GeV]   
-// cuts[1] = dca [micron]
-// cuts[2] = cosThetaStar 
-// cuts[3] = pTK [GeV/c]
-// cuts[4] = pTPi [GeV/c]
-// cuts[5] = d0K [micron]   upper limit!
-// cuts[6] = d0Pi [micron]  upper limit!
-// cuts[7] = d0d0 [micron^2]
-// cuts[8] = cosThetaPoint
-const Double_t kD0cuts[9] = {0.012,
-                             500.,
-                            0.8,
-                            0.5,
-                            0.5,
-                            500.,
-                            500.,
-                           -5000.,
-                            0.8};
-const Double_t kD0cutsAll[9] = {.1,
-                               1.e5,
-                               1.1,
-                               0.,
-                               0.,
-                               1.e10,
-                               1.e10,
-                               1.e10,
-                               -1.1};
-// mass cut for 1st level rejection
-const Double_t kMassCut = 0.1; // GeV
-
-// this function ckecks files existence
-Bool_t GetInputFiles();
-
-// 1st level rejection based on inv. mass
-Bool_t SelectInvMass(const Double_t p[6]);
-
-// this function creates TObjArrays with positive and negative tracks
-void   SelectTracks(TTree& itsTree,
-                   TObjArray& trksP,Int_t* itsEntryP,Int_t& nTrksP,
-                   TObjArray& trksN,Int_t* itsEntryN,Int_t& nTrksN);
-
-// this function applies single track cuts
-Bool_t TrkCuts(const AliITStrackV2& trk);
-
-void   AliD0vtxFinderSgn_pp_VTX(Int_t evFirst=0,Int_t evLast=999) {
-
-  const Char_t *name="AliD0vtxFinderSgn_pp_VTX";
-  cerr<<'\n'<<name<<"...\n";
-  gBenchmark->Start(name);  
-
-  // load library for D0 candidates class
-  gSystem->Load("libD0toKpi.so");
-
-  // check existence of input files 
-  if(!GetInputFiles()) { cerr<<"No tracks file found"<<endl; return; }
-
-  TString outNameSgn("AliD0toKpiSgn.root");
-  TString outNameBkg("AliD0toKpiBkgS.root");
-
-  AliKalmanTrack::SetConvConst(100/0.299792458/kBz);
-
-  Bool_t isSignal;
-  Int_t ev;
-  Int_t nTotEv=0,nD0recSgn=0,nD0recBkgS=0,nD0recBkg=0,nD0rec1ev=0;
-  Double_t dca;
-  Double_t v2[3],mom[6],d0[2];
-  Int_t pdg[2],mum[2],mumlab[2];
-  Double_t alphaP,alphaN,ptP,ptN,phiP,phiN;
-  Int_t l,k,iTrkP,iTrkN,itsEntries;
-  Int_t mesonD0,mesonD0label[10];
-  Int_t nTrksP=0,nTrksN=0;
-  Int_t okD0=0,okD0bar=0;
-  Char_t vtxName[100],trksName[100],refsName[100];
-  RECTRACK rectrk;  
-  AliITStrackV2 *postrack = 0;
-  AliITStrackV2 *negtrack = 0;
-
-  // create the AliITSVertexerTracks object
-  AliITSVertexerTracks *vertexer1 = new AliITSVertexerTracks;
-  vertexer1->SetMinTracks(2);
-  vertexer1->SetDebug(0);
-  Int_t skipped[2];
-
-  // define the cuts for vertexing
-  Double_t vtxcuts[]={33., // max. allowed chi2
-                     0.0, // min. allowed negative daughter's impact param 
-                     0.0, // min. allowed positive daughter's impact param 
-                     1.0, // max. allowed DCA between the daughter tracks
-                    -1.0, // min. allowed cosine of V0's pointing angle
-                     0.0, // min. radius of the fiducial volume
-                     2.9};// max. radius of the fiducial volume
-  
-  // create the AliV0vertexer object
-  AliV0vertexer *vertexer2 = new AliV0vertexer(vtxcuts);
-
-
-  // Create trees for reconstructed D0s
-  AliD0toKpi *ioD0toKpi=0;
-  // Signal
-  TTree D0TreeSgn("TreeD0","Tree with D0 candidates");
-  D0TreeSgn.Branch("D0toKpi","AliD0toKpi",&ioD0toKpi,200000,0);
-  // Background
-  TTree D0TreeBkg("TreeD0","Tree with D0 candidates");
-  D0TreeBkg.Branch("D0toKpi","AliD0toKpi",&ioD0toKpi,200000,0);
-
-  // Open file with ITS tracks
-  TFile* itstrks = TFile::Open("AliITStracksV2.root");
-
-  // Open file with ITS track references
-  TFile* itsrefs = TFile::Open("ITStracksRefFile.root");
-
-
-
-  // loop on events in file
-  for(ev=evFirst; ev<=evLast; ev++) {
-    printf(" --- Processing event  %d ---\n",ev);
-    sprintf(trksName,"TreeT_ITS_%d",ev);
-    sprintf(refsName,"Tree_Ref_%d",ev);
-
-
-
-    // tracks from ITS
-    TTree *itsTree=(TTree*)itstrks->Get(trksName);
-    if(!itsTree) continue;
-    itsEntries = (Int_t)itsTree->GetEntries();
-    printf("+++\n+++ Number of tracks in ITS: %d\n+++\n\n",itsEntries);
-    
-    // tree from reference file
-    TTree *refTree=(TTree*)itsrefs->Get(refsName);
-    refTree->SetBranchAddress("rectracks",&rectrk);
-    
-    Int_t refEntries = (Int_t)refTree->GetEntries();
-    k=0;
-    for(l=0; l<10; l++) mesonD0label[l]=-1;
-    for(l=0; l<refEntries; l++) {
-      refTree->GetEvent(l);
-      if(TMath::Abs(rectrk.mumpdg)!=421) continue;
-      //cerr<<" pdg: "<<rectrk.pdg<<"  mumpdg: "<<rectrk.mumpdg<<" mumlabel: "<<rectrk.mumlab<<endl;
-      mesonD0label[k] = rectrk.mumlab;
-      k++;
-    }
-
-    mesonD0 = mesonD0label[0];
-    for(l=0; l<10; l++) {
-      if(mesonD0label[l]==-1) continue;
-      for(k=0; k<10; k++) {
-       if(k==l) continue;
-       if(mesonD0label[k] == mesonD0label[l]) mesonD0 = mesonD0label[k]; 
-      }
-    }
-    //cerr<<" mesonD0: "<<mesonD0<<endl;
-
-    Double_t *brWgt = new Double_t[refEntries];
-    for(l=0; l<refEntries; l++) {
-      refTree->GetEvent(l);
-      // normally tracks have weight = 1
-      brWgt[l] = 1.;
-      // decay products of non-good D0 weighted with D0->Kpi B.R.
-      if(TMath::Abs(rectrk.mumpdg)==421 && rectrk.mumlab!=mesonD0) 
-       brWgt[l]=0.038;
-      // decay products of D+ weighted with D+->Kpipi B.R.
-      if(TMath::Abs(rectrk.mumpdg)==411) 
-       brWgt[l]=0.09;
-    }
-
-    // count the total number of events
-    nTotEv++;
-
-    // call function which applies sigle track selection and
-    // separetes positives and negatives
-    TObjArray trksP(itsEntries/2);
-    Int_t *itsEntryP = new Int_t[itsEntries];
-    TObjArray trksN(itsEntries/2);
-    Int_t *itsEntryN = new Int_t[itsEntries];
-    SelectTracks(*itsTree,trksP,itsEntryP,nTrksP,trksN,itsEntryN,nTrksN);
-      
-    nD0rec1ev = 0;
-    // loop on positive tracks
-    for(iTrkP=0; iTrkP<nTrksP; iTrkP++) {
-      //if(iTrkP % 10==0) cerr<<"--- Processing positive track number: "<<iTrkP<<" of "<<nTrksP<<"\r";
-         
-      // get track from track array
-      postrack = (AliITStrackV2*)trksP.At(iTrkP);
-
-      // get info on tracks PDG and mothers PDG from reference file
-      refTree->GetEvent(itsEntryP[iTrkP]);
-      pdg[0] = rectrk.pdg;
-      mum[0] = rectrk.mumpdg;
-      mumlab[0] = rectrk.mumlab;
-
-      // loop on negative tracks 
-      for(iTrkN=0; iTrkN<nTrksN; iTrkN++) {
-       // get track from track array
-       negtrack = (AliITStrackV2*)trksN.At(iTrkN);
-      
-       // get info on tracks PDG and mothers PDG from reference file
-       refTree->GetEvent(itsEntryN[iTrkN]);
-       pdg[1] = rectrk.pdg;
-       mum[1] = rectrk.mumpdg;
-       mumlab[1] = rectrk.mumlab;
-       //
-       // ----------- DCA MINIMIZATION ------------------
-       //
-       // find the DCA and propagate the tracks to the DCA 
-       dca = vertexer2->PropagateToDCA(negtrack,postrack);
-
-       // define the AliV0vertex object
-       AliV0vertex *vertex2 = new AliV0vertex(*negtrack,*postrack);
-         
-       // get position of the vertex
-       vertex2->GetXYZ(v2[0],v2[1],v2[2]);
-
-       delete vertex2;
-         
-       // momenta of the tracks at the vertex
-       ptP = 1./TMath::Abs(postrack->Get1Pt());
-       alphaP = postrack->GetAlpha();
-       phiP = alphaP+TMath::ASin(postrack->GetSnp());
-       mom[0] = ptP*TMath::Cos(phiP); 
-       mom[1] = ptP*TMath::Sin(phiP);
-       mom[2] = ptP*postrack->GetTgl();
-         
-       ptN = 1./TMath::Abs(negtrack->Get1Pt());
-       alphaN = negtrack->GetAlpha();
-       phiN = alphaN+TMath::ASin(negtrack->GetSnp());
-       mom[3] = ptN*TMath::Cos(phiN); 
-       mom[4] = ptN*TMath::Sin(phiN);
-       mom[5] = ptN*negtrack->GetTgl();
-
-       Bool_t goodVtx = kFALSE;
-       // no vertexing if DeltaMass > kMassCut 
-       if(SelectInvMass(mom)) {
-         // primary vertex from other tracks in event
-         vertexer1->SetVtxStart(0.,0.);
-         skipped[0] = itsEntryP[iTrkP];
-         skipped[1] = itsEntryN[iTrkN];
-         vertexer1->SetSkipTracks(2,skipped);
-         AliITSVertex *vertex1 = 
-           (AliITSVertex*)vertexer1->VertexOnTheFly(*itsTree); 
-         if(vertex1->GetNContributors()>0) goodVtx = kTRUE;
-         vertex1->GetXYZ(gv1);
-         // impact parameters of the tracks w.r.t. the primary vertex
-         d0[0] =  10000.*postrack->GetD(gv1[0],gv1[1]);
-         d0[1] = -10000.*negtrack->GetD(gv1[0],gv1[1]);
-         //vertex1->PrintStatus();
-         delete vertex1;
-       }
-
-       isSignal = kFALSE;
-       if(mumlab[0]==mesonD0 && mumlab[1]==mesonD0) isSignal = kTRUE;    
-
-
-       // create the object TD0rec and store it in the tree
-       AliD0toKpi theD0(isSignal,ev,gv1,v2,dca,mom,d0,pdg,mum);
-
-       // select D0s
-       if(goodVtx && theD0.Select(kD0cutsAll,okD0,okD0bar)) {
-             
-         // compute the weights
-         theD0.ComputeWgts();
-         theD0.CorrectWgt4BR(brWgt[itsEntryN[iTrkN]]*brWgt[itsEntryP[iTrkP]]);
-
-         // fill the tree
-         ioD0toKpi=&theD0;
-         if(isSignal) { 
-           D0TreeSgn.Fill(); 
-           nD0recSgn++; 
-         } else { 
-           D0TreeBkg.Fill();
-           if(TMath::Abs(mum[0])==421 || TMath::Abs(mum[0])==411 ||
-              TMath::Abs(mum[1])==421 || TMath::Abs(mum[1])==411) {
-             nD0recBkgS++;
-           } else {
-             nD0recBkg++;
-           }  
-         }
-
-         nD0rec1ev++;
-
-         ioD0toKpi=0;
-       } // end if select
-
-       negtrack = 0;
-      } // loop on negative tracks
-      postrack = 0;
-    }   // loop on positive tracks
-
-    delete [] itsEntryP;
-    delete [] itsEntryN;
-    delete [] brWgt;
-    delete itsTree;
-    delete refTree;
-
-    printf("\n+++\n+++ Number of D0 candidates: %d\n+++\n",nD0rec1ev);
-    printf("----------------------------------------------------------\n");
-
-  }    // loop on events in file
-
-
-  printf("\n+++\n+++ Total number of events: %d\n+++\n",nTotEv);
-  printf("\n+++\n+++ Total number of D0 candidates:\n
-                 +++    Sgn:   %d\n
-                 +++    BkgS:  %d\n
-                 +++    Bkg:   %d\n+++\n",nD0recSgn,nD0recBkgS,nD0recBkg);
-
-  delete vertexer2;
-
-  itstrks->Close();
-  itsrefs->Close();
-
-  // store trees in files
-  TFile* outrootSgn = new TFile(outNameSgn.Data(),"recreate");
-  D0TreeSgn.Write();
-  outrootSgn->Close();
-  delete outrootSgn;
-  TFile* outrootBkg = new TFile(outNameBkg.Data(),"recreate");
-  D0TreeBkg.Write();
-  outrootBkg->Close();
-  delete outrootBkg;
-
-  gBenchmark->Stop(name);
-  gBenchmark->Show(name);
-
-  return;
-}
-//___________________________________________________________________________
-Bool_t   GetInputFiles() {
-  TString itsName("AliITStracksV2.root");
-  TString refName("ITStracksRefFile.root");
-
-  if(gSystem->AccessPathName(itsName.Data(),kFileExists) ||
-     gSystem->AccessPathName(refName.Data(),kFileExists)) return kFALSE;
-
-  return kTRUE;
-}
-//___________________________________________________________________________
-Bool_t SelectInvMass(const Double_t p[6]) {
-
-  Double_t mD0 = 1.8645;
-  Double_t mPi = 0.13957;
-  Double_t mKa = 0.49368;
-
-  Double_t energy[2];
-  Double_t mom2[2],momTot2;
-
-  mom2[0] = p[0]*p[0]+p[1]*p[1]+p[2]*p[2];
-  mom2[1] = p[3]*p[3]+p[4]*p[4]+p[5]*p[5];
-
-  momTot2 = (p[0]+p[3])*(p[0]+p[3])+
-            (p[1]+p[4])*(p[1]+p[4])+
-            (p[2]+p[5])*(p[2]+p[5]);
-
-  // D0 -> K- Pi+
-  energy[1] = TMath::Sqrt(mKa*mKa+mom2[1]);
-  energy[0] = TMath::Sqrt(mPi*mPi+mom2[0]);
-
-  Double_t minvD0 = TMath::Sqrt((energy[0]+energy[1])*(energy[0]+energy[1])-momTot2);
-    
-
-  // D0bar -> K+ Pi-
-  energy[0] = TMath::Sqrt(mKa*mKa+mom2[0]);
-  energy[1] = TMath::Sqrt(mPi*mPi+mom2[1]);
-
-  Double_t minvD0bar = TMath::Sqrt((energy[0]+energy[1])*(energy[0]+energy[1])-momTot2);
-
-  if(TMath::Abs(minvD0-mD0) < kMassCut)    return kTRUE;
-  if(TMath::Abs(minvD0bar-mD0) < kMassCut) return kTRUE;
-  return kFALSE;
-}
-//___________________________________________________________________________
-void   SelectTracks(TTree& itsTree,
-                   TObjArray& trksP,Int_t* itsEntryP,Int_t& nTrksP,
-                   TObjArray& trksN,Int_t* itsEntryN,Int_t& nTrksN) {
-//
-// this function creates two TObjArrays with positive and negative tracks
-//
-  nTrksP=0,nTrksN=0;
-
-  Int_t entr = (Int_t)itsTree.GetEntries();
-
-  // trasfer tracks from tree to arrays
-  for(Int_t i=0; i<entr; i++) {
-
-    AliITStrackV2 *itstrack = new AliITStrackV2; 
-    itsTree.SetBranchAddress("tracks",&itstrack);
-
-    itsTree.GetEvent(i);
-
-    // single track selection
-    if(!TrkCuts(*itstrack)) { delete itstrack; continue; }
-
-    if(itstrack->Get1Pt()>0.) { // negative track
-      trksN.AddLast(itstrack);
-      itsEntryN[nTrksN] = i;
-      nTrksN++;
-    } else {                    // positive track
-      trksP.AddLast(itstrack);
-      itsEntryP[nTrksP] = i;
-      nTrksP++;
-    }
-
-  }
-
-  return;
-}
-//____________________________________________________________________________
-Bool_t TrkCuts(const AliITStrackV2& trk) {
-// 
-// this function tells if track passes some kinematical cuts  
-//
-  if(TMath::Abs(1./trk.Get1Pt()) < kPtCut)                return kFALSE;
-  if(TMath::Abs(10000.*trk.GetD(gv1[0],gv1[1])) < kd0Cut) return kFALSE;
-
-  return kTRUE;
-}
-//____________________________________________________________________________
-
-
-
-
-
-
-
-
-
-
-
diff --git a/HLT/trigger/AliITSFindClustersV2.C b/HLT/trigger/AliITSFindClustersV2.C
deleted file mode 100644 (file)
index 4db61b9..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
- *           Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch                 *
- ****************************************************************************/
-
-#ifndef __CINT__
-  #include <iostream.h>
-
-  #include "AliRun.h"
-  #include "AliITS.h"
-  #include "AliITSgeom.h"
-  #include "AliITSclustererV2.h"
-
-  #include "TFile.h"
-  #include "TStopwatch.h"
-#endif
-
-Int_t AliITSFindClustersV2(Char_t SlowOrFast='f',Int_t eventn=1,Char_t* path="./") {
-
-   cerr<<"Looking for clusters...\n";
-
-   Char_t fname[1024];
-   sprintf(fname,"%s/galice.root",path);
-   TFile *in=TFile::Open(fname);
-   if (!in->IsOpen()) {cerr<<"Can't open galice.root !\n"; return 2;}
-   if (!(gAlice=(AliRun*)in->Get("gAlice"))) {
-      cerr<<"Can't find gAlice !\n";
-      return 2;
-   }
-   AliITS *ITS  = (AliITS*)gAlice->GetModule("ITS");
-   if (!ITS) { cerr<<"Can't find the ITS !\n"; return 3; }
-
-   AliITSgeom *geom=ITS->GetITSgeom();
-
-   Char_t fnameCluster[1024];
-   sprintf(fnameCluster,"%s/AliITSclustersV2.root",path);
-   TFile *out=TFile::Open(fnameCluster,"recreate");
-   if (!out->IsOpen()) {
-      cerr<<"Delete old AliITSclustersV2.root !\n"; return 1;}
-   geom->Write();
-
-   TStopwatch timer;
-   AliITSclustererV2 clusterer(geom);
-   for (Int_t i=0; i<eventn; i++) {
-       cerr<<"Processing event number: "<<i<<endl;
-       gAlice->GetEvent(i);
-       //ITS->MakeTreeC(); //To make the V1 cluster finders happy
-       clusterer.SetEvent(i);
-       if (SlowOrFast=='s') clusterer.Digits2Clusters(in,out);
-       else                 clusterer.Hits2Clusters(in,out);
-   }
-   timer.Stop(); timer.Print();
-
-   delete gAlice; gAlice=0;
-   out->Close();
-   in->Close();
-
-   return 0;
-}
-
-
-
index ee81c2d..bcd2a85 100644 (file)
@@ -7,6 +7,8 @@
 #pragma link off all functions;
 
 #pragma link C++ class AliD0toKpi;
+#pragma link C++ class AliD0Trigger;
 
+       
 #endif
 
index b1a1181..594b20d 100644 (file)
@@ -15,6 +15,8 @@ endif
 
 include $(ALIHLT_TOPDIR)/Makefile.conf
 
-SRCS   = AliD0toKpi.cxx
+SRCS   = AliD0toKpi.cxx AliD0Trigger.cxx 
 
 include $(ALIHLT_TOPDIR)/Makefile.rules
+
+INCLUDES += -I$(ALICE_ROOT)/ITS
index 83d5f7d..c064fa6 100644 (file)
 const Double_t kBz = 0.4;
 
 // primary vertex
-Double_t primaryvertex[3] = {0.,0.,0,};
+double primaryvertex[3]={0.,0.,0.};
 
 //sec. vertex
 double v2[3]={0,0,0};
 
 // sigle track cuts
-const Double_t kPtCut = 0.5;  // GeV/c
-const Double_t kd0Cut = 50.; // micron
-const Double_t kd0CutHigh = 200.; // micron
+const Double_t kPtCut = 0.5;        // 0.5 GeV/c
+const Double_t kd0Cut = 50.;        // 50  micron
+const Double_t kd0CutHigh = 400.;   // 200 micron
 
 
 //cuts for combined tracks
-const Double_t cuts[7] = {0.005,     // cuts[0] = lowest V0 cut  (cm)
-                         0.015,     // cuts[1] = highest V0 cut (cm)
-                         0.05,      // cuts[2] = inv. mass cut (diferense) (Gev/c)
-                         0.95,      // cuts[3] = max cosine value for pointing angle
-                         -5000,     // cuts[4] = d0d0
-                         0.8,       // cuts[5] = costhetastar
-                         0.5};      // cuts[6] = ptchild
+const Double_t cuts[7] = {0.005,    &nbs