]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSMultReconstructor.cxx
typo fix
[u/mrichter/AliRoot.git] / ITS / AliITSMultReconstructor.cxx
index 61bc00778aeccb02363702f49baf5909e7e29268..17ebe5d57b640844557a1a91108e2cd4aa7bacbb 100644 (file)
@@ -100,6 +100,7 @@ fTracklets(0),
 fSClusters(0),
 fNTracklets(0),
 fNSingleCluster(0),
+fNSingleClusterSPD2(0),
 fDPhiWindow(0),
 fDThetaWindow(0),
 fPhiShift(0),
@@ -156,6 +157,7 @@ fhphiClustersLay1(0),
   fClustersLoaded(0),
   fRecoDone(0),
   fBuildRefs(kTRUE),
+  fStoreSPD2SingleCl(kFALSE),
   fSPDSeg()
 {
   // default c-tor
@@ -164,6 +166,7 @@ fhphiClustersLay1(0),
     fClArr[i] = 0;
     for (int j=0;j<2;j++) fUsedClusLay[i][j] = 0;
     fDetectorIndexClustersLay[i] = 0;
+    fClusterCopyIndex[i] = 0;
     fOverlapFlagClustersLay[i] = 0;
     fNClustersLay[i] = 0;
     fClustersLay[i] = 0;
@@ -184,6 +187,7 @@ fhphiClustersLay1(0),
     SetNStdDev(AliITSReconstructor::GetRecoParam()->GetTrackleterNStdDevCut());
     SetScaleDThetaBySin2T(AliITSReconstructor::GetRecoParam()->GetTrackleterScaleDThetaBySin2T());
     SetBuildRefs(AliITSReconstructor::GetRecoParam()->GetTrackleterBuildCl2TrkRefs());
+    SetStoreSPD2SingleCl(AliITSReconstructor::GetRecoParam()->GetTrackleterStoreSPD2SingleCl());
     //
     SetCutPxDrSPDin(AliITSReconstructor::GetRecoParam()->GetMultCutPxDrSPDin());
     SetCutPxDrSPDout(AliITSReconstructor::GetRecoParam()->GetMultCutPxDrSPDout());
@@ -271,6 +275,7 @@ fTracklets(0),
 fSClusters(0),
 fNTracklets(0),
 fNSingleCluster(0),
+fNSingleClusterSPD2(0),
 fDPhiWindow(0),
 fDThetaWindow(0),
 fPhiShift(0),
@@ -326,6 +331,7 @@ fCreateClustersCopy(0),
 fClustersLoaded(0),
 fRecoDone(0),
 fBuildRefs(kTRUE),
+fStoreSPD2SingleCl(kFALSE),
 fSPDSeg()
  {
   // Copy constructor :!!! RS ATTENTION: old c-tor reassigned the pointers instead of creating a new copy -> would crash on delete
@@ -367,6 +373,7 @@ AliITSMultReconstructor::~AliITSMultReconstructor(){
   for (int i=0;i<2;i++) {
     delete[] fClustersLay[i];
     delete[] fDetectorIndexClustersLay[i];
+    delete[] fClusterCopyIndex[i];
     delete[] fOverlapFlagClustersLay[i];
     delete   fClArr[i];
     for (int j=0;j<2;j++) delete fUsedClusLay[i][j];
@@ -391,6 +398,7 @@ void AliITSMultReconstructor::Reconstruct(AliESDEvent* esd, TTree* treeRP)
   fNClustersLay[1] = 0;
   fNTracklets = 0; 
   fNSingleCluster = 0;
+  fNSingleClusterSPD2 = 0;
   //
   fESDEvent = esd;
   fTreeRP = treeRP;
@@ -414,7 +422,7 @@ void AliITSMultReconstructor::Reconstruct(AliESDEvent* esd, TTree* treeRP)
     vtx = 0;
   }
   if(vtx){
-    float vtxf[3] = {vtx->GetX(),vtx->GetY(),vtx->GetZ()};
+    float vtxf[3] = {static_cast<float>(vtx->GetX()),static_cast<float>(vtx->GetY()),static_cast<float>(vtx->GetZ())};
     FindTracklets(vtxf);
   }
   else {
@@ -434,6 +442,7 @@ void AliITSMultReconstructor::Reconstruct(TTree* clusterTree, Float_t* vtx, Floa
   fNClustersLay[1] = 0;
   fNTracklets = 0; 
   fNSingleCluster = 0;
+  fNSingleClusterSPD2 = 0;
   //
   if (!clusterTree) { AliError(" Invalid ITS cluster tree !\n"); return; }
   //
@@ -456,6 +465,7 @@ void AliITSMultReconstructor::ReconstructMix(TTree* clusterTree, TTree* clusterT
   fNClustersLay[1] = 0;
   fNTracklets = 0; 
   fNSingleCluster = 0;
+  fNSingleClusterSPD2 = 0;
   //
   if (!clusterTree) { AliError(" Invalid ITS cluster tree !\n"); return; }
   if (!clusterTreeMix) { AliError(" Invalid ITS cluster tree 2nd event !\n"); return; }
@@ -510,7 +520,7 @@ void AliITSMultReconstructor::FindTracklets(const Float_t *vtx)
   // Step2: store tracklets; remove used clusters 
   for (Int_t iC2=0; iC2<fNClustersLay[1]; iC2++) StoreTrackletForL2Cluster(iC2);
   //
-  // store unused single clusters of L1
+  // store unused single clusters of L1 (optionally for L2 too)
   StoreL1Singles();
   //
   AliDebug(1,Form("%d tracklets found", fNTracklets));
@@ -529,6 +539,8 @@ void AliITSMultReconstructor::CreateMultiplicityObject()
   //
   fMult = new AliMultiplicity(fNTracklets,fNSingleCluster,fNFiredChips[0],fNFiredChips[1],fastOrFiredMap);
   fMult->SetMultTrackRefs( fBuildRefs );
+  fMult->SetSPD2SinglesStored(fStoreSPD2SingleCl);
+  fMult->SetNumberOfSingleClustersSPD2(fNSingleClusterSPD2);
   // store some details of reco:
   fMult->SetScaleDThetaBySin2T(fScaleDTBySin2T);
   fMult->SetDPhiWindow2(fDPhiWindow2);
@@ -574,15 +586,17 @@ void AliITSMultReconstructor::CreateMultiplicityObject()
     fMult->SetSingleClusterData(i,clInfo); 
     //
     if (!fBuildRefs) continue; // do we need references?
+    int ilr = i>=(fNSingleCluster-fNSingleClusterSPD2) ? 1:0;
     int clID = int(clInfo[kSCID]);
     for (int itp=0;itp<2;itp++) {
-      if (!fStoreRefs[0][itp]) continue;
-      int nref = fUsedClusLay[0][itp]->GetReferences(clID,shared,100);
+      if (!fStoreRefs[ilr][itp]) continue;
+      int nref = fUsedClusLay[ilr][itp]->GetReferences(clID,shared,100);
       if (!nref) continue;
       else if (nref==1) refsc[itp]->AddReference(i,shared[0]);
       else refsc[itp]->AddReferences(i,shared,nref);
     }
   }
+  //
   if (fBuildRefs) fMult->AttachCluster2TrackRefs(refsc[0],refsc[1]); 
   fMult->CompactBits();
   //
@@ -603,8 +617,9 @@ void AliITSMultReconstructor::LoadClusterArrays(TTree* tree, TTree* treeMix)
   memset(fTracklets,0,nmaxT*sizeof(Float_t*));
   //
   if (fSClusters) delete[] fSClusters;
-  fSClusters = new Float_t*[fNClustersLay[0]]; 
-  memset(fSClusters,0,fNClustersLay[0]*sizeof(Float_t*));
+  int nSlots = GetStoreSPD2SingleCl() ? fNClustersLay[0]+fNClustersLay[1] : fNClustersLay[0];
+  fSClusters = new Float_t*[nSlots]; 
+  memset(fSClusters,0,nSlots*sizeof(Float_t*));
   //
   AliDebug(1,Form("(clusters in layer 1 : %d,  layer 2: %d)",fNClustersLay[0],fNClustersLay[1]));
   AliDebug(1,Form("(cluster-fired chips in layer 1 : %d,  layer 2: %d)",fNFiredChips[0],fNFiredChips[1]));
@@ -648,6 +663,7 @@ void AliITSMultReconstructor::LoadClusterArrays(TTree* itsClusterTree, int il)
     branch = itsClusterTree->GetBranch("ITSRecPoints");
     branch->SetAddress(&itsClusters);
     if (!fClArr[il]) fClArr[il] = new TClonesArray("AliITSRecPoint",100);
+    delete[] fClusterCopyIndex[il];
   }    
   //
   // count clusters
@@ -679,6 +695,7 @@ void AliITSMultReconstructor::LoadClusterArrays(TTree* itsClusterTree, int il)
   Float_t*   clustersLay              = new Float_t[nclLayer*kClNPar];
   Int_t*     detectorIndexClustersLay = new Int_t[nclLayer];
   Bool_t*    overlapFlagClustersLay   = new Bool_t[nclLayer];
+  if (fCreateClustersCopy) fClusterCopyIndex[il] = new Int_t[nclLayer];
   //
   for (int ic=0;ic<nclLayer;ic++) {
     AliITSRecPoint* cluster = (AliITSRecPoint*)clArr[index[ic]];
@@ -688,6 +705,7 @@ void AliITSMultReconstructor::LoadClusterArrays(TTree* itsClusterTree, int il)
     detectorIndexClustersLay[ic] = cluster->GetDetectorIndex(); 
     overlapFlagClustersLay[ic]   = kFALSE;
     for (Int_t i=3;i--;) clPar[kClMC0+i] = cluster->GetLabel(i);
+    if (fCreateClustersCopy) fClusterCopyIndex[il][ic] = index[ic];
   }
   clArr.Clear();
   delete[] z;
@@ -795,8 +813,6 @@ void AliITSMultReconstructor::FlagClustersInOverlapRegions (Int_t iC1, Int_t iC2
 {
   // Flags clusters in the overlapping regions
   Float_t distClSameMod=0.;
-  Float_t distClSameModMin=0.;
-  Int_t   iClOverlap =0;
   Float_t meanRadiusLay1 = 3.99335; // average radius inner layer
   Float_t meanRadiusLay2 = 7.37935; // average radius outer layer;
 
@@ -823,23 +839,12 @@ void AliITSMultReconstructor::FlagClustersInOverlapRegions (Int_t iC1, Int_t iC2
         distClSameMod = TMath::Sqrt(TMath::Power(deZproj/fZetaOverlapCut,2)+TMath::Power(dePhi/fPhiOverlapCut,2));
         if (distClSameMod<=1.) fOverlapFlagClustersLay[0][iiC1]=kTRUE;
 
-//        if (distClSameMod<=1.) {
-//          if (distClSameModMin==0. || distClSameMod<distClSameModMin) {
-//            distClSameModMin=distClSameMod;
-//            iClOverlap=iiC1;
-//          } 
-//        }
-
-
       } // end adjacent modules
     } 
   } // end Loop on inner layer clusters
 
-//  if (distClSameModMin!=0.) fOverlapFlagClustersLay[0][iClOverlap]=kTRUE;
 
   distClSameMod=0.;
-  distClSameModMin=0.;
-  iClOverlap =0;
   // Loop on outer layer clusters
   for (Int_t iiC2=0; iiC2<fNClustersLay[1]; iiC2++) {
     if (!fOverlapFlagClustersLay[1][iiC2]) {
@@ -857,19 +862,10 @@ void AliITSMultReconstructor::FlagClustersInOverlapRegions (Int_t iC1, Int_t iC2
         distClSameMod = TMath::Sqrt(TMath::Power(deZproj/fZetaOverlapCut,2)+TMath::Power(dePhi/fPhiOverlapCut,2));
         if (distClSameMod<=1.) fOverlapFlagClustersLay[1][iiC2]=kTRUE;
 
-//        if (distClSameMod<=1.) {
-//          if (distClSameModMin==0. || distClSameMod<distClSameModMin) {
-//            distClSameModMin=distClSameMod;
-//            iClOverlap=iiC2;
-//          }
-//        }
-
       } // end adjacent modules
     }
   } // end Loop on outer layer clusters
 
-//  if (distClSameModMin!=0.) fOverlapFlagClustersLay[1][iClOverlap]=kTRUE;
-
 }
 
 //____________________________________________________________________
@@ -951,7 +947,7 @@ Int_t AliITSMultReconstructor::AssociateClusterOfL1(Int_t iC1)
       fhClustersDThetaAll->Fill(dTheta);    
       fhDPhiVsDThetaAll->Fill(dTheta, dPhi);
     }
-    Float_t d = CalcDist(dPhi,dTheta,clPar1[kClTh]);     // make "elliptical" cut in Phi and Theta! 
+    Float_t d = CalcDist(dPhi,clPar2[kClTh] - clPar1[kClTh],clPar1[kClTh]);     // make "elliptical" cut in Phi and Theta! 
     // look for the minimum distance: the minimum is in iC2WithBestDist
     if (d<fNStdDev && d<minDist) { minDist=d; iC2WithBestDist = iC2; }
   }
@@ -1068,6 +1064,23 @@ void AliITSMultReconstructor::StoreL1Singles()
     }
   }
   //
+  if (GetStoreSPD2SingleCl()) {
+    for (Int_t iC2=0; iC2<fNClustersLay[1]; iC2++) {
+      if (fPartners[iC2]<0 || (fOverlapFlagClustersLay[0][fPartners[iC2]] || fOverlapFlagClustersLay[1][iC2])) {
+       float* clPar2 = GetClusterLayer2(iC2);
+       fSClusters[fNSingleCluster] = new Float_t[kClNPar];
+       fSClusters[fNSingleCluster][kSCTh] = clPar2[kClTh];
+       fSClusters[fNSingleCluster][kSCPh] = clPar2[kClPh];
+       fSClusters[fNSingleCluster][kSCLab] = clPar2[kClMC0]; 
+       fSClusters[fNSingleCluster][kSCID] = iC2;
+       AliDebug(1,Form(" Adding a single cluster %d (cluster %d  of layer 2)",
+                       fNSingleCluster, iC2));
+       fNSingleCluster++;
+       fNSingleClusterSPD2++;
+      }
+    }
+  }
+  //
 }
 
 //____________________________________________________________________
@@ -1261,3 +1274,15 @@ Bool_t AliITSMultReconstructor::CanBeElectron(const AliESDtrack* trc) const
     pid[AliPID::kElectron]>fCutMinElectronProbESD;
   //
 }
+
+//____________________________________________________________________
+AliITSRecPoint* AliITSMultReconstructor::GetRecPoint(Int_t lr, Int_t n) const
+{
+  // return a cluster of lr corresponding to orderer cluster index n
+  if (fClArr[lr] && fClusterCopyIndex[lr] && n<fNClustersLay[lr]) 
+    return (AliITSRecPoint*) fClArr[lr]->At(fClusterCopyIndex[lr][n]);
+  else {
+    AliError("To access the clusters SetCreateClustersCopy should have been called");
+    return 0;
+  }
+}