]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSclustererV2.cxx
Fix bug in digitization of multiple events
[u/mrichter/AliRoot.git] / ITS / AliITSclustererV2.cxx
index 5b7e0f058d2c3ad6d3adb62cf9b8eddc9ccdf689..2cafb669215d0cf0cb1936e08686d691713e38ed 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "AliITSclustererV2.h"
 #include "AliITSclusterV2.h"
+#include "AliITSDetTypeRec.h"
 #include "AliRawReader.h"
 #include "AliITSRawStreamSPD.h"
 #include "AliITSRawStreamSDD.h"
@@ -91,6 +92,7 @@ AliITSclustererV2::AliITSclustererV2(const AliITSgeom *geom) {
   fHlSSD=2.00;
   fTanP=0.0275;
   fTanN=0.0075;
+
 }
 
 
@@ -118,6 +120,10 @@ Int_t AliITSclustererV2::Digits2Clusters(TTree *dTree, TTree *cTree) {
   else branch->SetAddress(&clusters);
 
   Int_t mmax=(Int_t)dTree->GetEntries();
+  if (mmax!=fNModules) {
+    Error("Digits2Clusters","Number of entries != number of modules !");
+    return 1;
+  }
 
   for (fI=0; fI<mmax; fI++) {
     dTree->GetEvent(fI);
@@ -219,13 +225,13 @@ void AliITSclustererV2::Digits2Clusters(AliRawReader* rawReader) {
 //**** Fast clusters *******************************
 #include "TParticle.h"
 
-#include "AliITS.h"
+//#include "AliITS.h"
 #include "AliITSmodule.h"
 #include "AliITSRecPoint.h"
 #include "AliITSsimulationFastPoints.h"
 #include "AliITSRecPoint.h"
 
-/*
+
 static void CheckLabels(Int_t lab[3]) {
   //------------------------------------------------------------
   // Tries to find mother's labels
@@ -252,7 +258,8 @@ static void CheckLabels(Int_t lab[3]) {
         else ;//cerr<<"CheckLabels : No empty labels !\n";
     }
 }
-*/
+
+/*
 static void CheckLabels(Int_t lab[3]) {
   //------------------------------------------------------------
   // Tries to find mother's labels
@@ -279,7 +286,7 @@ static void CheckLabels(Int_t lab[3]) {
   }
   
 }
-
+*/
 static void CheckLabels2(Int_t lab[10]) {
   //------------------------------------------------------------
   // Tries to find mother's labels
@@ -375,9 +382,9 @@ void AliITSclustererV2::RecPoints2Clusters
   for (Int_t i=0; i<ncl; i++) {
     AliITSRecPoint *p = (AliITSRecPoint *)points->UncheckedAt(i);
     Float_t lp[5];
-    lp[0]=-(-p->GetX()+fYshift[idx]); if (idx<=fLastSPD1) lp[0]*=-1; //SPD1
+    lp[0]=-(-p->GetDetLocalX()+fYshift[idx]); if (idx<=fLastSPD1) lp[0]*=-1; //SPD1
     lp[1]=  -p->GetZ()+fZshift[idx];
-    lp[2]=p->GetSigmaX2();
+    lp[2]=p->GetSigmaDetLocX2();
     lp[3]=p->GetSigmaZ2();
     lp[4]=p->GetQ()*36./23333.;  //electrons -> ADC
     Int_t lab[4]; 
@@ -389,55 +396,6 @@ void AliITSclustererV2::RecPoints2Clusters
   }  
 } 
 
-Int_t AliITSclustererV2::Hits2Clusters(TTree *hTree, TTree *cTree) {
-  //------------------------------------------------------------
-  // This function creates ITS clusters
-  //------------------------------------------------------------
-  if (!gAlice) {
-     Error("Hits2Clusters","gAlice==0 !");
-     return 1;
-  }
-
-  AliITS *its  = (AliITS*)gAlice->GetModule("ITS");
-  if (!its) { 
-     Error("Hits2Clusters","Can't find the ITS !"); 
-     return 2; 
-  }
-  AliITSgeom *geom=its->GetITSgeom();
-  Int_t mmax=geom->GetIndexMax();
-
-  its->InitModules(-1,mmax);
-  its->FillModules(hTree,0);
-
-  TClonesArray *clusters=new TClonesArray("AliITSclusterV2",1000);
-  TBranch *branch=cTree->GetBranch("Clusters");
-  if (!branch) cTree->Branch("Clusters",&clusters);
-  else branch->SetAddress(&clusters);
-
-  static TClonesArray *points=its->RecPoints();
-  AliITSsimulationFastPoints sim;
-  Int_t ncl=0;
-  for (Int_t m=0; m<mmax; m++) {
-    AliITSmodule *mod=its->GetModule(m);      
-    sim.CreateFastRecPoints(mod,m,gRandom);      
-
-    RecPoints2Clusters(points, m, clusters);
-    its->ResetRecPoints();
-
-    ncl+=clusters->GetEntriesFast();
-    cTree->Fill();
-    clusters->Clear();
-  }
-
-  Info("Hits2Clusters","Number of found fast clusters : %d",ncl);
-
-  //cTree->Write();
-
-  delete clusters;
-
-  return 0;
-}
-
 //***********************************
 
 #ifndef V1
@@ -582,7 +540,9 @@ void AliITSclustererV2::FindClustersSPD(AliITSRawStream* input,
   Int_t kNzBins = fNzSPD + 2;
   Int_t kNyBins = fNySPD + 2;
   Int_t kMaxBin = kNzBins * kNyBins;
-  AliBin* bins = NULL;
+  AliBin *binsSPD = new AliBin[kMaxBin];
+  AliBin *binsSPDInit = new AliBin[kMaxBin];
+  AliBin *bins = NULL;
 
   // read raw data input stream
   while (kTRUE) {
@@ -670,11 +630,12 @@ void AliITSclustererV2::FindClustersSPD(AliITSRawStream* input,
        }
 
        nClustersSPD += nClusters;
-       delete bins;
+       bins = NULL;
       }
 
       if (!next) break;
-      bins = new AliBin[kMaxBin];
+      bins = binsSPD;
+      memcpy(binsSPD,binsSPDInit,sizeof(AliBin)*kMaxBin);
     }
 
     // fill the current digit into the bins array
@@ -684,6 +645,9 @@ void AliITSclustererV2::FindClustersSPD(AliITSRawStream* input,
     bins[index].SetQ(1);
   }
 
+  delete [] binsSPDInit;
+  delete [] binsSPD;
+
   Info("FindClustersSPD", "found clusters in ITS SPD: %d", nClustersSPD);
 }
 
@@ -962,7 +926,10 @@ void AliITSclustererV2::FindClustersSDD(AliITSRawStream* input,
   Int_t nClustersSDD = 0;
   Int_t kNzBins = fNzSDD + 2;
   Int_t kMaxBin = kNzBins * (fNySDD+2);
-  AliBin* bins[2] = {NULL, NULL};
+  AliBin *binsSDDInit = new AliBin[kMaxBin];
+  AliBin *binsSDD1 = new AliBin[kMaxBin];
+  AliBin *binsSDD2 = new AliBin[kMaxBin];
+  AliBin *bins[2] = {NULL, NULL};
 
   // read raw data input stream
   while (kTRUE) {
@@ -977,13 +944,14 @@ void AliITSclustererV2::FindClustersSDD(AliITSRawStream* input,
        FindClustersSDD(bins, kMaxBin, kNzBins, NULL, clusters[iModule]);
        Int_t nClusters = clusters[iModule]->GetEntriesFast();
        nClustersSDD += nClusters;
-       delete[] bins[0];
-       delete[] bins[1];
+       bins[0] = bins[1] = NULL;
       }
 
       if (!next) break;
-      bins[0] = new AliBin[kMaxBin];
-      bins[1] = new AliBin[kMaxBin];
+      bins[0]=binsSDD1;
+      bins[1]=binsSDD2;
+      memcpy(binsSDD1,binsSDDInit,sizeof(AliBin)*kMaxBin);
+      memcpy(binsSDD2,binsSDDInit,sizeof(AliBin)*kMaxBin);
     }
 
     // fill the current digit into the bins array
@@ -998,6 +966,10 @@ void AliITSclustererV2::FindClustersSDD(AliITSRawStream* input,
     }
   }
 
+  delete[] binsSDD1;
+  delete[] binsSDD2;
+  delete[] binsSDDInit;
+
   Info("FindClustersSDD", "found clusters in ITS SDD: %d", nClustersSDD);
 }
 
@@ -1025,6 +997,7 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
   Int_t cused2[3000];
   for (Int_t i=0;i<3000;i++) {cnegative[i]=0; cused1[i]=0;}
   for (Int_t i=0;i<3000;i++) {cpositive[i]=0; cused2[i]=0;}
+  for (Int_t i=0;i<30000;i++){negativepair[i]=positivepair[i]=0;}
   static Short_t pairs[1000][1000];
   memset(pairs,0,sizeof(Short_t)*1000000);
 //   Short_t ** pairs = new Short_t*[1000];
@@ -1687,7 +1660,7 @@ void AliITSclustererV2::FindClustersSSD(AliITSRawStream* input,
 #else   //V1
 
 #include "AliITSDetType.h"
-
+#include "AliITS.h"
 #include "AliITSsegmentationSPD.h"
 #include "AliITSClusterFinderSPD.h"