]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Some changes resulting from last week work. The mc stuff has been removed.
authorvestbo <vestbo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 4 Oct 2002 14:05:24 +0000 (14:05 +0000)
committervestbo <vestbo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 4 Oct 2002 14:05:24 +0000 (14:05 +0000)
Added possibility to not save the width when compressing file; this is one
by setting the flag AliL3Compress::fWriteShape.

The status of the code is that it seems to be more or less working. The
efficiency drops a little bit when running it through offline, but this
is mainly because overlapping clusters are not deconvoluted, and 2 clusters
found by the offline cluster finder will be 1 cluster after compressing/
decompressing. The only way to get rid of this, is to include some
deconvolution in the AliL3Modeller::FindClusters.

HLT/comp/AliL3Compress.cxx
HLT/comp/AliL3Compress.h
HLT/comp/AliL3ModelTrack.cxx
HLT/comp/AliL3ModelTrack.h
HLT/comp/AliL3Modeller.cxx
HLT/comp/AliL3Modeller.h

index 325ec9b883da10f3b80270dc6ece485dfc00a601..a9892cad60ae00302f19ee84e19ce21bd99fdad4 100644 (file)
@@ -35,9 +35,10 @@ AliL3Compress::AliL3Compress()
   fPatch=0;
   fDigits=0;
   fDPt=0;
+  fWriteShape=kFALSE;
 }
 
-AliL3Compress::AliL3Compress(Int_t slice,Int_t patch,Char_t *path)
+AliL3Compress::AliL3Compress(Int_t slice,Int_t patch,Char_t *path,Bool_t writeshape)
 {
   fSlice=slice;
   fPatch=patch;
@@ -46,6 +47,7 @@ AliL3Compress::AliL3Compress(Int_t slice,Int_t patch,Char_t *path)
   fDigits=0;
   fDPt=0;
   sprintf(fPath,"%s",path);
+  fWriteShape=writeshape;
 }
 
 AliL3Compress::~AliL3Compress()
@@ -69,8 +71,13 @@ void AliL3Compress::SetBitNumbers(Int_t pad,Int_t time,Int_t charge,Int_t shape)
 void AliL3Compress::WriteFile(AliL3TrackArray *tracks)
 {
   Char_t fname[100];
-  sprintf(fname,"%s/tracks_m_%d_%d.raw",fPath,fSlice,fPatch);
+  sprintf(fname,"%s/comp/tracks_m_%d_%d.raw",fPath,fSlice,fPatch);
   FILE *file = fopen(fname,"w");
+  if(!file)
+    {
+      cerr<<"AliL3Compress::WriteFile : Error opening file "<<fname<<endl;
+      return;
+    }
   Short_t ntracks = tracks->GetNTracks();
   //cout<<"Writing "<<ntracks<<" tracks to file"<<endl;
     
@@ -83,8 +90,8 @@ void AliL3Compress::WriteFile(AliL3TrackArray *tracks)
       if(!track) continue;
       
       //Do not save useless tracks or clusters:
-      //if(track->CheckClustersQuality(2) == 0) 
-      //continue;
+      if(track->GetNPresentClusters() == 0)
+       continue;
       
       track->FillModel();
       model = track->GetModel();
@@ -108,9 +115,9 @@ void AliL3Compress::ReadFile(Char_t which)
 
   Char_t fname[100];
   if(which == 'm')
-    sprintf(fname,"%s/tracks_m_%d_%d.raw",fPath,fSlice,fPatch);
+    sprintf(fname,"%s/comp/tracks_m_%d_%d.raw",fPath,fSlice,fPatch);
   else if(which == 'u')
-    sprintf(fname,"%s/tracks_u_%d_%d.raw",fPath,fSlice,fPatch);
+    sprintf(fname,"%s/comp/tracks_u_%d_%d.raw",fPath,fSlice,fPatch);
   else
     {
       cerr<<"AliL3Compress::ReadFile() : Wrong option"<<endl;
@@ -120,7 +127,7 @@ void AliL3Compress::ReadFile(Char_t which)
   FILE *file = fopen(fname,"r");
   if(!file)
     {
-      cerr<<"Cannot open file "<<fname<<endl;
+      cerr<<"AliL3Compress::ReadFile : Cannot open file "<<fname<<endl;
       return;
     }
 
@@ -135,13 +142,9 @@ void AliL3Compress::ReadFile(Char_t which)
       track->Init(fSlice,fPatch);
       AliL3TrackModel *model = track->GetModel();
       AliL3ClusterModel *clusters = track->GetClusters();
-      //cout<<"Reading model "<<(int)model<<endl;
       if(fread(model,sizeof(AliL3TrackModel),1,file)!=1) break;
-      //cout<<"Reading clusters "<<(int)clusters<<endl;
       if(fread(clusters,(model->fNClusters)*sizeof(AliL3ClusterModel),1,file)!=1) break;
-      //cout<<"Filling track"<<endl;
       track->FillTrack();
-      //track->Print();
     }
 
   fTracks->RemoveLast();
@@ -158,10 +161,10 @@ void AliL3Compress::CompressFile()
     }
   
   Char_t fname[100];
-  sprintf(fname,"%s/tracks_c_%d_%d.raw",fPath,fSlice,fPatch);
+  sprintf(fname,"%s/comp/tracks_c_%d_%d.raw",fPath,fSlice,fPatch);
   BIT_FILE *output = OpenOutputBitFile(fname);
   
-  sprintf(fname,"%s/tracks_m_%d_%d.raw",fPath,fSlice,fPatch);
+  sprintf(fname,"%s/comp/tracks_m_%d_%d.raw",fPath,fSlice,fPatch);
   FILE *input = fopen(fname,"r");
   if(!input)
     {
@@ -172,7 +175,7 @@ void AliL3Compress::CompressFile()
   AliL3TrackModel track;
   AliL3ClusterModel cluster;
   Int_t temp;
-  Short_t power;
+  Int_t power;
   
   Int_t timeo,pado,chargeo,shapeo;
   timeo=pado=chargeo=shapeo=0;
@@ -230,44 +233,43 @@ void AliL3Compress::CompressFile()
          
          //Write charge information:
          temp = (Int_t)cluster.fDCharge;
-         if(temp<0)
-           OutputBit(output,0);
-         else
-           OutputBit(output,1);
-         power = 1<<(fNumChargeBits-1);
+         power = 1<<(fNumChargeBits);
          if(abs(temp)>=power)
            {
              chargeo++;
              temp=power - 1;
            }
-         OutputBits(output,abs(temp),(fNumChargeBits-1));
-                 
-         //Write shape information:
-         temp = (Int_t)cluster.fDSigmaY2;
-         if(temp<0)
-           OutputBit(output,0);
-         else
-           OutputBit(output,1);
-         power = 1<<(fNumShapeBits-1);
-         if(abs(temp) >= power)
-           {
-             shapeo++;
-             temp = power - 1;
-           }
-         OutputBits(output,abs(temp),(fNumShapeBits-1));
+         OutputBits(output,abs(temp),(fNumChargeBits));
          
-         temp = (Int_t)cluster.fDSigmaZ2;
-         if(temp<0)
-           OutputBit(output,0);
-         else
-           OutputBit(output,1);
-         power = 1<<(fNumShapeBits-1);
-         if(abs(temp) >= power)
+         if(fWriteShape)
            {
-             shapeo++;
-             temp=power - 1;
+             //Write shape information:
+             temp = (Int_t)cluster.fDSigmaY2;
+             if(temp<0)
+               OutputBit(output,0);
+             else
+               OutputBit(output,1);
+             power = 1<<(fNumShapeBits-1);
+             if(abs(temp) >= power)
+               {
+                 shapeo++;
+                 temp = power - 1;
+               }
+             OutputBits(output,abs(temp),(fNumShapeBits-1));
+             
+             temp = (Int_t)cluster.fDSigmaZ2;
+             if(temp<0)
+               OutputBit(output,0);
+             else
+               OutputBit(output,1);
+             power = 1<<(fNumShapeBits-1);
+             if(abs(temp) >= power)
+               {
+                 shapeo++;
+                 temp=power - 1;
+               }
+             OutputBits(output,abs(temp),(fNumShapeBits-1));
            }
-         OutputBits(output,abs(temp),(fNumShapeBits-1));
        }
     }
   
@@ -290,10 +292,10 @@ void AliL3Compress::ExpandFile()
     }
   
   Char_t fname[100];
-  sprintf(fname,"%s/tracks_c_%d_%d.raw",fPath,fSlice,fPatch);
+  sprintf(fname,"%s/comp/tracks_c_%d_%d.raw",fPath,fSlice,fPatch);
   BIT_FILE *input = OpenInputBitFile(fname);
   
-  sprintf(fname,"%s/tracks_u_%d_%d.raw",fPath,fSlice,fPatch);
+  sprintf(fname,"%s/comp/tracks_u_%d_%d.raw",fPath,fSlice,fPatch);
   FILE *output = fopen(fname,"w");
   if(!output)
     {
@@ -313,7 +315,8 @@ void AliL3Compress::ExpandFile()
       //Read and write track:
       if(fread(&trackmodel,sizeof(AliL3TrackModel),1,input->file)!=1) break;
       fwrite(&trackmodel,sizeof(AliL3TrackModel),1,output);
-      
+
+      memset(clusters,0,AliL3Transform::GetNRows(fPatch)*sizeof(AliL3ClusterModel));
       for(Int_t i=0; i<AliL3Transform::GetNRows(fPatch); i++)
        {
          Int_t temp,sign;
@@ -342,27 +345,25 @@ void AliL3Compress::ExpandFile()
          clusters[i].fDPad = temp;
          
          //Read charge information:
-         sign = InputBit(input);
-         temp=InputBits(input,(fNumChargeBits-1));
-         if(!sign)
-           temp*=-1;
+         temp=InputBits(input,(fNumChargeBits));
          clusters[i].fDCharge = temp;
          
-         //Read shape information:
-         sign = InputBit(input);
-         temp = InputBits(input,(fNumShapeBits-1));
-         if(!sign)
-           temp*=-1;
-         clusters[i].fDSigmaY2 = temp;
-         
-         sign = InputBit(input);
-         temp = InputBits(input,(fNumShapeBits-1));
-         if(!sign)
-           temp*=-1;
-         clusters[i].fDSigmaZ2 = temp;
+         if(fWriteShape)
+           {
+             //Read shape information:
+             sign = InputBit(input);
+             temp = InputBits(input,(fNumShapeBits-1));
+             if(!sign)
+               temp*=-1;
+             clusters[i].fDSigmaY2 = temp;
+             
+             sign = InputBit(input);
+             temp = InputBits(input,(fNumShapeBits-1));
+             if(!sign)
+               temp*=-1;
+             clusters[i].fDSigmaZ2 = temp;
+           }
        }
-      
-
       count++;
       fwrite(clusters,(trackmodel.fNClusters)*sizeof(AliL3ClusterModel),1,output);
       
@@ -390,6 +391,11 @@ void AliL3Compress::RestoreData(Char_t which)
   //which == u : restore compressed data
   //which == m : restore uncompressed data
   
+  if(!fWriteShape)
+    {
+      cerr<<"AliL3Compress::RestoreData : Not implemented without shape info "<<endl;
+      return;
+    }
 
   ReadFile(which);
   
@@ -437,11 +443,11 @@ void AliL3Compress::PrintDigits(Int_t padrow)
 
 void AliL3Compress::WriteRestoredData()
 {
-  Char_t fname[100];
+    Char_t fname[100];
   
   //Get the remaining raw data array:
   AliL3MemHandler *mem = new AliL3MemHandler();
-  sprintf(fname,"%s/remains_%d_%d.raw",fPath,fSlice,fPatch);
+  sprintf(fname,"%s/comp/remains_%d_%d.raw",fPath,fSlice,fPatch);
   mem->SetBinaryInput(fname);
   UInt_t numdigits;
   AliL3DigitRowData *origRow = mem->CompBinary2Memory(numdigits);
@@ -527,7 +533,7 @@ void AliL3Compress::WriteRestoredData()
     cerr<<"AliL3Compress::WriteRestoredData() : Written rows: "<<row_counter<<" total rows "<<AliL3Transform::GetNRows(fPatch)<<endl;
   
   mem->Free();  
-  sprintf(fname,"%s/restored_%d_%d.raw",fPath,fSlice,fPatch);
+  sprintf(fname,"%s/comp/restored_%d_%d.raw",fPath,fSlice,fPatch);
   mem->SetBinaryOutput(fname);
   mem->Memory2CompBinary((UInt_t)AliL3Transform::GetNRows(fPatch),(AliL3DigitRowData*)data);
   mem->CloseBinaryOutput();
@@ -625,7 +631,7 @@ void AliL3Compress::CreateDigits(Int_t row,Int_t npads,Float_t pad,Float_t time,
 void AliL3Compress::PrintCompRatio()
 {
   Char_t fname[100];
-  sprintf(fname,"%s/remains_%d_%d.raw",fPath,fSlice,fPatch);
+  sprintf(fname,"%s/comp/remains_%d_%d.raw",fPath,fSlice,fPatch);
   AliL3MemHandler *mem = new AliL3MemHandler();
   if(!mem->SetBinaryInput(fname))
     {
@@ -644,7 +650,7 @@ void AliL3Compress::PrintCompRatio()
     }
   delete mem;
   
-  sprintf(fname,"%s/tracks_c_%d_%d.raw",fPath,fSlice,fPatch);
+  sprintf(fname,"%s/comp/tracks_c_%d_%d.raw",fPath,fSlice,fPatch);
   FILE *file1 = fopen(fname,"r");
   if(!file1)
     {
@@ -722,13 +728,13 @@ void AliL3Compress::WriteRootFile(Char_t *newrootfile)
 #ifdef use_aliroot
   Char_t fname[100];
   AliL3MemHandler *mem = new AliL3MemHandler();
-  sprintf(fname,"%s/restored_%d_%d.raw",fPath,fSlice,fPatch);
+  sprintf(fname,"%s/comp/restored_%d_%d.raw",fPath,fSlice,fPatch);
   mem->SetBinaryInput(fname);
   UInt_t ndigits;
   AliL3DigitRowData *rowPt = (AliL3DigitRowData*)mem->CompBinary2Memory(ndigits);
   mem->CloseBinaryInput();
   
-  sprintf(fname,"%s/digitfile",fPath);
+  sprintf(fname,"%s/digitfile.root",fPath);
   
   AliL3FileHandler *file = new AliL3FileHandler();
   if(!file->SetAliInput(fname))
index 725d630e908477a988cf3d147fe604d98e36401c..ea75aa07bdc84ca70248f9bb897e758d46c4af55 100644 (file)
@@ -24,7 +24,8 @@ class AliL3Compress {
   Int_t fSlice;
   Int_t fPatch;
   Char_t fPath[100];
-
+  Bool_t fWriteShape;
+  
   void CreateDigitArray(Int_t maxnumber);
   void CreateDigits(Int_t row,Int_t npads,Float_t pad,Float_t time,Int_t charge,Float_t ywidth,Float_t zwidth);
   void QSort(AliL3RandomDigitData **a, Int_t first, Int_t last);
@@ -33,7 +34,7 @@ class AliL3Compress {
 
  public:
   AliL3Compress();
-  AliL3Compress(Int_t slice,Int_t patch,Char_t *path="./");
+  AliL3Compress(Int_t slice,Int_t patch,Char_t *path="./",Bool_t writeshape=kFALSE);
   virtual ~AliL3Compress();
   
   void SetBitNumbers(Int_t pad,Int_t time,Int_t charge,Int_t shape);
index 1430f69efc57e442d12264cffa1c7577a56fc08a..46d41e835b73090158113bb57767766b02ac2f50 100644 (file)
@@ -65,10 +65,7 @@ void AliL3ModelTrack::Init(Int_t slice,Int_t patch)
   memset(fTrackModel,0,sizeof(AliL3TrackModel));
   for(Int_t i=0; i<nrows; i++)
     fOverlap[i]=-1;
-#ifdef do_mc
-  for(Int_t i=0; i<nrows; i++)
-    fClusters[i].fTrackID[0]=fClusters[i].fTrackID[1]=fClusters[i].fTrackID[2]=-2;
-#endif
+
   fClusterCharge = 100;
   
   // 100 micrometers:
@@ -92,14 +89,17 @@ void AliL3ModelTrack::SetCluster(Int_t row,Float_t fpad,Float_t ftime,Float_t ch
       return;
     }
   AliL3ClusterModel *cl = GetClusterModel(row);
-  if(!charge)
+  
+  //Do not save the cluster if there were no charge found, or only 1 pad is present.
+  //In the latter case it is most probably noise.
+  if(!charge || npads == 1)
     cl->fPresent = kFALSE;
   else
     {
       cl->fPresent = kTRUE;
       cl->fDTime = (ftime - GetTimeHit(row))/fXYResidualQ;
       cl->fDPad = (fpad - GetPadHit(row))/fZResidualQ;
-      cl->fDCharge = charge - fClusterCharge;
+      cl->fDCharge = charge;// - fClusterCharge;
       cl->fDSigmaY2 = (sigmaY2 - GetParSigmaY2(row))/fXYWidthQ;
       cl->fDSigmaZ2 = (sigmaZ2 - GetParSigmaZ2(row))/fZWidthQ;
       cl->fNPads = npads;
@@ -108,24 +108,20 @@ void AliL3ModelTrack::SetCluster(Int_t row,Float_t fpad,Float_t ftime,Float_t ch
   fNClusters++;
 }
 
-Int_t AliL3ModelTrack::CheckClustersQuality(UInt_t npads)
+Int_t AliL3ModelTrack::GetNPresentClusters()
 {
-
-  //Check the quality of clusters,- remove clusters with less than
-  //npads. 
-  //Returns the number of good clusters left.
-
+  //Return the number of assigned clusters to the track.
+  //Differs from fNClusters, which should be equal to the 
+  //number of padrows in the present patch.
+  
   Int_t count=0;
 
   for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++)
     {
       AliL3ClusterModel *cl = GetClusterModel(i);
-      if(cl->fNPads < npads)
-       cl->fPresent = kFALSE;
       if(cl->fPresent)
        count++;
     }
-  
   return count;
 }
 
@@ -186,19 +182,6 @@ void AliL3ModelTrack::FillTrack()
 }
 
 
-void AliL3ModelTrack::SetTrackID(Int_t row,Int_t *trackID)
-{
-#ifdef do_mc
-  AliL3ClusterModel *cluster = GetClusterModel(row);
-  cluster->fTrackID[0] = trackID[0];
-  cluster->fTrackID[1] = trackID[1];
-  cluster->fTrackID[2] = trackID[2];
-  return;
-#endif
-  cerr<<"AliL3ModelTrack::SetTrackID : Compile with do_mc flag"<<endl;
-}
-
-
 void AliL3ModelTrack::SetPadHit(Int_t row,Float_t pad)
 {
   Int_t index = row-AliL3Transform::GetFirstRow(fPatch);
@@ -234,17 +217,6 @@ void AliL3ModelTrack::SetOverlap(Int_t row,Int_t id)
 }
 
 
-Int_t AliL3ModelTrack::GetTrackID(Int_t row,Int_t index)
-{
-  
-#ifdef do_mc
-  AliL3ClusterModel *cl = GetClusterModel(row);
-  return cl->fTrackID[index];
-#endif
-  cerr<<"AliL3ModelTrack::GetTrackID : Compile with do_mc flag"<<endl;
-}
-
-
 Int_t AliL3ModelTrack::GetNPads(Int_t row)
 {
   AliL3ClusterModel *cl = GetClusterModel(row);
@@ -273,7 +245,7 @@ Bool_t AliL3ModelTrack::GetTime(Int_t row,Float_t &time)
 Bool_t AliL3ModelTrack::GetClusterCharge(Int_t row,Int_t &charge)
 {
   AliL3ClusterModel *cl = GetClusterModel(row);
-  charge = (Int_t)cl->fDCharge + fClusterCharge;
+  charge = (Int_t)cl->fDCharge;// + fClusterCharge;
   
   return (Bool_t)cl->fPresent;
 }
@@ -282,7 +254,7 @@ Bool_t AliL3ModelTrack::GetXYWidth(Int_t row,Float_t &width)
 {
   AliL3ClusterModel *cl = GetClusterModel(row);
   width = cl->fDSigmaY2*fXYWidthQ + GetParSigmaY2(row);
-  
+
   return (Bool_t)cl->fPresent;
 }
 
@@ -290,7 +262,7 @@ Bool_t AliL3ModelTrack::GetZWidth(Int_t row,Float_t &width)
 {
   AliL3ClusterModel *cl = GetClusterModel(row);
   width = cl->fDSigmaZ2*fZWidthQ + GetParSigmaZ2(row);
-  
+
   return (Bool_t)cl->fPresent;
 }
 
@@ -390,9 +362,9 @@ void AliL3ModelTrack::Print()
          cout<<i<<" Dpad "<<cl->fDPad<<" Dtime "<<cl->fDTime<<" Dcharge "<<cl->fDCharge;
          cout<<" DsigmaY2 "<<cl->fDSigmaY2<<" DsigmaZ2 "<<cl->fDSigmaZ2;
          cout<<" Padcrossing "<<GetPadHit(i)<<" Timecrossing "<<GetTimeHit(i)<<" ";
-         cout<<"Number of pads "<<GetNPads(i)<<endl;
+         cout<<"Number of pads "<<GetNPads(i)<<" Overlapping index "<<GetOverlap(i);
        }
-      cout<<"Overlapping index "<<GetOverlap(i)<<endl;
+      cout<<endl;
     }
 }
 
@@ -418,7 +390,7 @@ Double_t AliL3ModelTrack::GetParSigmaY2(Int_t row)
   
   Double_t prf = AliL3Transform::GetPRFSigma(fPatch);
   Double_t diffT = AliL3Transform::GetDiffT();
-  Double_t padlength = AliL3Transform::GetPadLength(fPatch);
+  Double_t padlength = AliL3Transform::GetPadLength(row);
   Double_t anode = AliL3Transform::GetAnodeWireSpacing();
   Double_t beta = GetCrossingAngle(row);
   
@@ -451,69 +423,15 @@ Double_t AliL3ModelTrack::GetParSigmaZ2(Int_t row)
   
   Double_t sigma0 = AliL3Transform::GetTimeSigma();
   Double_t diffL = AliL3Transform::GetDiffL();
-  Double_t padlength = AliL3Transform::GetPadLength(fPatch);
+  Double_t padlength = AliL3Transform::GetPadLength(row);
   Double_t tanl = GetTgl();
   
   Double_t sigmaZ2 = sigma0*sigma0 + diffL*diffL*drift + padlength*padlength * tanl*tanl/12;
   
   //Convert back to raw coodinates:
   sigmaZ2 = sigmaZ2/pow(AliL3Transform::GetZWidth(),2);
+  
   return sigmaZ2;
   
 }
 
-void AliL3ModelTrack::AssignTrackID(Float_t wrong)
-{
-  //Assign a track ID to the track, corresponding to the MC TParticle ID.
-  //Can only be done if you compiled with do_mc flag, of course.
-  //The function loops over the assigned clusters, and finds the label (ID)
-  //of each clusters, and assigns the ID with the most hits to the track.
-  //If there are more than wrong% clusters of a different ID, the track is
-  //considered to be fake, and label will be assigned as negative.
-  
-#ifdef do_mc
-  Int_t *lb = new Int_t[GetNClusters()];
-  Int_t *mx = new Int_t[GetNClusters()];
-
-  Int_t i,j;
-  for(Int_t i=0; i<GetNClusters(); i++) 
-    lb[i]=mx[i]=0;
-  
-  Int_t lab=123456789;
-  
-  for(i=0; i<GetNClusters(); i++) 
-    {
-      lab = abs(GetTrackID(i,0));
-      for (j=0; j<GetNClusters(); j++) 
-       if (lb[j]==lab || mx[j]==0) break;
-      lb[j]=lab;
-      (mx[j])++;
-    }
-  
-  Int_t max=0;
-  for (i=0; i<GetNClusters(); i++) 
-    {
-      if(mx[i] > max) 
-       {
-         max=mx[i]; 
-         lab=lb[i];
-       }
-    }
-  
-  for (i=0; i<GetNClusters(); i++) 
-    {
-      if(abs(GetTrackID(i,1)) == lab ||
-        abs(GetTrackID(i,2)) == lab)
-       max++;
-    }
-
-  if ((1.- Float_t(max)/GetNClusters()) > wrong) lab=-lab;
-
-  SetLabel(lab);
-
-  delete[] lb;
-  delete[] mx;
-  return;
-#endif
-  cerr<<"AliL3ModelTrack::AssignTrackID : Compile with do_mc flag"<<endl;
-}
index 6bd40b2f3c356eaa5419dc1027c6da6df71f4372..1ecafb2f605c097cdebe825c75862ac41c540296 100644 (file)
@@ -36,19 +36,15 @@ class AliL3ModelTrack : public AliL3Track {
   void FillModel();
   void FillTrack();
   void Print();
-  void AssignTrackID(Float_t wrong=0.10);
   
-  void SetTrackID(Int_t row,Int_t *trackID);
   void SetPadHit(Int_t row,Float_t f);
   void SetTimeHit(Int_t row,Float_t f);
   void SetOverlap(Int_t row,Int_t id);
   void SetXYResolution(Float_t f) {fXYResolution=f;}
   void SetZResolution(Float_t f) {fZResolution=f;}
   void SetLabel(Int_t i) {fLabel = i;}
-  Int_t CheckClustersQuality(UInt_t npads=3);
-  
+  Int_t GetNPresentClusters();
 
-  Int_t GetTrackID(Int_t row,Int_t idindex);
   AliL3ClusterModel *GetClusters() {return fClusters;}
   AliL3TrackModel *GetModel() {return fTrackModel;}
   AliL3ClusterModel *GetClusterModel(Int_t row);
index 4f2a8472204e827a240108d80e2a67111efe4d45..1d068273cc92d478ef23f9d47fa0549ec7f6d52c 100644 (file)
@@ -37,8 +37,8 @@ AliL3Modeller::AliL3Modeller()
   fTracks=0;
   fTrackThreshold=0;
   fPadOverlap=0;
-  fTimeOverlap=0;
-  fRowData=0;
+  SetOverlap();
+  SetTrackThreshold();
 }
 
 
@@ -54,13 +54,9 @@ void AliL3Modeller::Init(Int_t slice,Int_t patch,Char_t *trackdata,Char_t *path,
 {
   fSlice = slice;
   fPatch = patch;
-  fPadOverlap=6;
-  fTimeOverlap=8;
-  
+
   sprintf(fPath,"%s",path);
   
-  AliL3Transform::Init(fPath);
-  
   fTracks = new AliL3TrackArray("AliL3ModelTrack");
   
   Char_t fname[100];
@@ -99,21 +95,32 @@ void AliL3Modeller::Init(Int_t slice,Int_t patch,Char_t *trackdata,Char_t *path,
   
   CalculateCrossingPoints();
   
-  if(!houghtracks)
-    CheckForOverlaps();
-
+  CheckForOverlaps();
+  
   UInt_t ndigits=0;
   AliL3DigitRowData *digits=0;
 #ifdef use_aliroot
   fMemHandler = new AliL3FileHandler();
+  fMemHandler->Init(slice,patch);
   if(binary == kFALSE)
     {
-      sprintf(fname,"%s/digitfile",fPath);
+      sprintf(fname,"%s/digitfile.root",fPath);
       fMemHandler->SetAliInput(fname);
       digits = fMemHandler->AliDigits2Memory(ndigits);
     }
+  else
+    {
+      sprintf(fname,"%sdigits_%d_%d.raw",fPath,fSlice,fPatch);
+      if(!fMemHandler->SetBinaryInput(fname))
+       {
+         cerr<<"AliL3Modeller::Init : Error opening file "<<fname<<endl;
+         return;
+       }
+      digits=(AliL3DigitRowData*)fMemHandler->CompBinary2Memory(ndigits);
+    }
 #else
   fMemHandler = new AliL3MemHandler();
+  fMemHandler->Init(slice,patch);
   if(binary == kFALSE)
     {
       cerr<<"AliL3Modeller::Init : Compile with AliROOT if you want rootfile as input"<<endl;
@@ -166,6 +173,7 @@ void AliL3Modeller::FindClusters()
       fCurrentPadRow = i;
       memset((void*)row,0,ntimes*npads*sizeof(Digit));
       digPt = (AliL3DigitData*)rowPt->fDigitData;
+      //cout<<"Loading row "<<i<<" with "<<(Int_t)rowPt->fNDigit<<" digits"<<endl;
       for(UInt_t j=0; j<rowPt->fNDigit; j++)
        {
          pad = digPt[j].fPad;
@@ -180,7 +188,6 @@ void AliL3Modeller::FindClusters()
        {
          AliL3ModelTrack *track = (AliL3ModelTrack*)fTracks->GetCheckedTrack(k);
          if(!track) continue;
-         //if(track->GetOverlap(i)>=0) continue;//Track is overlapping
          
          if(track->GetPadHit(i)<0 || track->GetTimeHit(i)<0 || track->GetOverlap(i)>=0)
            {
@@ -222,46 +229,45 @@ void AliL3Modeller::FindClusters()
                      break;
                    }
                  
-                 /*
-                 if(row[index].fUsed == kTRUE)//Only use the digits once....
-                   charge = 0;
-                 else
-                   charge = row[index].fCharge;
-                 */
-                 
                  charge = row[index].fCharge;
-                 if(charge==0 && timesign==-1)
+                 if(charge==0 && timesign==-1) //zero charge on this timebin, perform checks:
                    {
-                     if(seq_charge==0 && abs(time-hittime) <= fTimeOverlap/2)
+                     if(seq_charge==0 && abs(time-hittime) <= fTimeOverlap) //No charge found on this pad, look further.
                        {
                          time--;
                          continue;
                        }
-                     else
+                     else //Boundary reached, or we have found one end of the sequence,->start looking in the other time direction
                        {
                          time = hittime+1;
                          timesign=1;
                          continue;
                        }
                    }
-                 else if(charge==0 && timesign==1)
+                 else if(charge==0 && timesign==1)//zero charge on this timebin, perform checks:
                    {
-                     if(seq_charge==0 && abs(time-hittime) <= fTimeOverlap/2)
+                     if(seq_charge==0 && abs(time-hittime) <= fTimeOverlap)//No charge found on this pad, look further
                        {
                          time++;
                          continue;
                        }
-                     else
+                     else //Boundary reached, or we have found the other end of the sequence, stop looking on this pad.
                        {
-                         //cerr<<"Breaking off at pad "<<pad<<" and time "<<time<<endl;
+                         //if(fCurrentPadRow==31)
+                         //   cerr<<"Breaking off at pad "<<pad<<" and time "<<time<<endl;
                          break;
                        }
                    }
                  
-                 //cout<<"Doing pad "<<pad<<" time "<<time<<" charge "<<charge<<endl;
+                 if(row[ntimes*pad+time].fUsed==kTRUE) //Don't use digits several times. This leads to mult. rec.tracks.
+                   {
+                     time += timesign;
+                     continue;
+                   }
                  
                  seq_charge += charge;
-                                                 
+                 
+                 //Update the cluster parameters with this timebin
                  cluster.fTime += time*charge;
                  cluster.fPad += pad*charge;
                  cluster.fCharge += charge;
@@ -273,7 +279,7 @@ void AliL3Modeller::FindClusters()
                }
              
              
-             if(seq_charge)//There was something on this pad.
+             if(seq_charge)//There was something on this pad, so keep looking on the neighbouring pad
                {
                  pad += padsign;
                  npads++;
@@ -282,7 +288,7 @@ void AliL3Modeller::FindClusters()
                {
                  if(padsign==-1) 
                    {
-                     if(cluster.fCharge==0 && abs(pad-hitpad) <= fPadOverlap/2 && pad > 0)
+                     if(cluster.fCharge==0 && abs(pad-hitpad) <= fPadOverlap && pad > 0)
                        {
                          pad--; //In this case, we haven't found anything yet, 
                        }        //so we will try to expand our search within the natural boundaries.
@@ -296,20 +302,22 @@ void AliL3Modeller::FindClusters()
                  
                  else if(padsign==1)
                    {
-                     if(cluster.fCharge==0 && abs(pad-hitpad) <= fPadOverlap/2 && pad < AliL3Transform::GetNPads(i)-2)
+                     if(cluster.fCharge==0 && abs(pad-hitpad) <= fPadOverlap && pad < AliL3Transform::GetNPads(i)-2)
                        {
                          pad++;     //In this case, we haven't found anything yet, 
                          continue;  //so we will try to expand our search within the natural boundaries.
                        }
                      else //We are out of range, or cluster if finished.
                        {
-                         //cout<<"Outof range; charge "<<cluster.fCharge<<" paddiff "<<abs(pad-hitpad)<<endl;
+                         //if(fCurrentPadRow==31)
+                         //cout<<"Out of range; charge "<<cluster.fCharge<<" paddiff "<<abs(pad-hitpad)<<endl;
                          FillCluster(track,&cluster,i,npads);
                          break;
                        }
                    }
                  else //Nothing more in this cluster
                    {
+                     //if(fCurrentPadRow==31)
                      //cout<<"Filling final cluster"<<endl;
                      FillCluster(track,&cluster,i,npads);
                      break;
@@ -318,7 +326,6 @@ void AliL3Modeller::FindClusters()
            }
          //cout<<"done"<<endl;
        }
-      
       FillZeros(rowPt,row);
       fMemHandler->UpdateRowPointer(rowPt);
     }
@@ -350,44 +357,7 @@ void AliL3Modeller::FillCluster(AliL3ModelTrack *track,Cluster *cluster,Int_t ro
   Float_t sigmaY2,sigmaZ2;
   CalcClusterWidth(cluster,sigmaY2,sigmaZ2);
   track->SetCluster(row,fpad,ftime,fcharge,sigmaY2,sigmaZ2,npads);
-#ifdef do_mc
-  Int_t trackID[3];
-  GetTrackID((Int_t)rint(fpad),(Int_t)rint(ftime),trackID);
-  track->SetTrackID(fCurrentPadRow,trackID);
-#endif
-}
-
-#ifdef do_mc
-void AliL3Modeller::GetTrackID(Int_t pad,Int_t time,Int_t *trackID)
-{
-
-  AliL3DigitRowData *rowPt = (AliL3DigitRowData*)fRowData;
-  
-  trackID[0]=trackID[1]=trackID[2]=-2;
-
-  for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++)
-    {
-      if(rowPt->fRow < (UInt_t)fCurrentPadRow)
-       {
-         AliL3MemHandler::UpdateRowPointer(rowPt);
-         continue;
-       }
-      AliL3DigitData *digPt = (AliL3DigitData*)rowPt->fDigitData;
-      for(UInt_t j=0; j<rowPt->fNDigit; j++)
-       {
-         Int_t cpad = digPt[j].fPad;
-         Int_t ctime = digPt[j].fTime;
-         if(cpad != pad) continue;
-         if(ctime != time) continue;
-         trackID[0] = digPt[j].fTrackID[0];
-         trackID[1] = digPt[j].fTrackID[1];
-         trackID[2] = digPt[j].fTrackID[2];
-         break;
-       }
-      break;
-    }
 }
-#endif
 
 void AliL3Modeller::FillZeros(AliL3DigitRowData *rowPt,Digit *row)
 {
@@ -466,7 +436,7 @@ void AliL3Modeller::WriteRemaining()
 
   Char_t fname[100];
   AliL3MemHandler *mem = new AliL3MemHandler();
-  sprintf(fname,"%s/remains_%d_%d.raw",fPath,fSlice,fPatch);
+  sprintf(fname,"%s/comp/remains_%d_%d.raw",fPath,fSlice,fPatch);
   mem->SetBinaryOutput(fname);
   mem->Memory2CompBinary((UInt_t)AliL3Transform::GetNRows(fPatch),(AliL3DigitRowData*)data);
   mem->CloseBinaryOutput();
@@ -485,21 +455,6 @@ void AliL3Modeller::CalculateCrossingPoints()
     }
   Float_t hit[3];
   
-  
-  //Remove tracks which are no good:
-  for(Int_t i=0; i<fTracks->GetNTracks(); i++)
-    {
-      AliL3ModelTrack *track = (AliL3ModelTrack*)fTracks->GetCheckedTrack(i);
-      if(!track) continue;
-      if(track->GetFirstPointX() > AliL3Transform::Row2X(AliL3Transform::GetLastRow(fPatch)) || track->GetPt()<0.1)
-       fTracks->Remove(i);
-      if(track->GetNHits() < fTrackThreshold)
-       {
-         fTracks->Remove(i);
-         continue;
-       }
-    }
-  
   Int_t sector,row;
   for(Int_t i=AliL3Transform::GetLastRow(fPatch); i>=AliL3Transform::GetFirstRow(fPatch); i--)
     {
@@ -518,10 +473,11 @@ void AliL3Modeller::CalculateCrossingPoints()
              fTracks->Remove(j);
              continue;
            }
-         //cout<<" x "<<track->GetPointX()<<" y "<<track->GetPointY()<<" z "<<track->GetPointZ()<<endl;
+         //cout<<"X "<<hit[0]<<" Y "<<hit[1]<<" Z "<<hit[2]<<" tgl "<<track->GetTgl()<<endl;
          
          AliL3Transform::Slice2Sector(fSlice,i,sector,row);
          AliL3Transform::Local2Raw(hit,sector,row);
+         //cout<<"Pad "<<hit[1]<<" time "<<hit[2]<<" in sector "<<sector<<" row "<<row<<endl;
          if(hit[1]<0 || hit[1]>AliL3Transform::GetNPads(i) ||
             hit[2]<0 || hit[2]>AliL3Transform::GetNTimeBins())
            {//Track is leaving the patch, so flag the track hits (<0)
@@ -549,7 +505,7 @@ void AliL3Modeller::CheckForOverlaps()
   //Flag the tracks that overlap
   
   cout<<"Checking for overlaps...";
-  
+  Int_t counter=0;
   for(Int_t i=0; i<fTracks->GetNTracks(); i++)
     {
       AliL3ModelTrack *track1 = (AliL3ModelTrack*)fTracks->GetCheckedTrack(i);
@@ -563,16 +519,20 @@ void AliL3Modeller::CheckForOverlaps()
              if(track1->GetPadHit(k)<0 || track1->GetTimeHit(k)<0 ||
                 track2->GetPadHit(k)<0 || track2->GetTimeHit(k)<0)
                continue;
-             if(fabs(track1->GetPadHit(k)-track2->GetPadHit(k)) <= fPadOverlap &&
-                fabs(track1->GetTimeHit(k)-track2->GetTimeHit(k)) <= fTimeOverlap)
+             
+             if(track1->GetOverlap(k)>=0 || track2->GetOverlap(k)>=0) continue;
+             
+             if(abs((Int_t)rint(track1->GetPadHit(k))-(Int_t)rint(track2->GetPadHit(k))) <= fPadOverlap &&
+                abs((Int_t)rint(track1->GetTimeHit(k))-(Int_t)rint(track2->GetTimeHit(k))) <= fTimeOverlap)
                {
                  track2->SetOverlap(k,i);
-                 track1->SetOverlap(k,j);
+                 //track1->SetOverlap(k,j);
+                 counter++;
                }
            }
        }
     }
-  cout<<"done"<<endl;
+  cout<<"found "<<counter<<" done"<<endl;
 }
 
 
index e2210eb27b2089c0f9d17cf42337b3de2a00a53a..fb3e7594cc3f14ea6e786c7e076c3a978b6104ce 100644 (file)
@@ -45,9 +45,6 @@ class AliL3Modeller {
   void FillCluster(AliL3ModelTrack *track,Cluster *cluster,Int_t row,Int_t npads);
   void CalcClusterWidth(Cluster *cl,Float_t &sigmaY2,Float_t &sigmaZ2);
   void FillZeros(AliL3DigitRowData *digPt,Digit *row);
-#ifdef do_mc
-  void GetTrackID(Int_t pad,Int_t time,Int_t *trackID);
-#endif
     
  public:
   
@@ -61,8 +58,9 @@ class AliL3Modeller {
   void WriteRemaining();
   
   void SetInputData(AliL3DigitRowData *digits) {fRowData = digits;}
-  void SetTrackThreshold(Int_t i) {fTrackThreshold=i;}
-
+  void SetTrackThreshold(Int_t i=0) {fTrackThreshold=i;}
+  void SetOverlap(Int_t p=6,Int_t t=8) {fPadOverlap=p;fTimeOverlap=t;}
+  
   AliL3TrackArray *GetTracks() {return fTracks;}
     
   ClassDef(AliL3Modeller,1) //Modeller class