]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSMultReconstructor.cxx
Added protection, fixed dynamic cast
[u/mrichter/AliRoot.git] / ITS / AliITSMultReconstructor.cxx
index b6a3c139c896747c94f4a5b9b2408d652b47ebf9..b05ee436d4d4388f4f4b18226ee20e47f7024fe8 100644 (file)
@@ -58,6 +58,7 @@
 //     - RS: Clusters are sorted in Z in roder to have the same numbering as in the ITS reco
 //     - RS: Clusters used by ESDtrack are flagged, this information is passed to AliMulitiplicity object 
 //           when storing the tracklets and single cluster info
+//     - MN: first MC label of single clusters stored  
 //_________________________________________________________________________
 
 #include <TClonesArray.h>
@@ -349,17 +350,7 @@ AliITSMultReconstructor::~AliITSMultReconstructor(){
 
 //____________________________________________________________________
 void AliITSMultReconstructor::Reconstruct(AliESDEvent* esd, TTree* treeRP) 
-{
-  //
-  // - calls LoadClusterArrays that finds the position of the clusters
-  //   (in global coord) 
-  // - convert the cluster coordinates to theta, phi (seen from the
-  //   interaction vertex). 
-  // - makes an array of tracklets 
-  //   
-  // After this method has been called, the clusters of the two layers
-  // and the tracklets can be retrieved by calling the Get'er methods.
-
+{  
   if (!treeRP) { AliError(" Invalid ITS cluster tree !\n"); return; }
   if (!esd) {AliError("ESDEvent is not available, use old reconstructor"); return;}
   // reset counters
@@ -405,15 +396,7 @@ void AliITSMultReconstructor::Reconstruct(AliESDEvent* esd, TTree* treeRP)
 void AliITSMultReconstructor::Reconstruct(TTree* clusterTree, Float_t* vtx, Float_t* /* vtxRes*/) {
   //
   // RS NOTE - this is old reconstructor invocation, to be used from VertexFinder
-  //
-  // - calls LoadClusterArray that finds the position of the clusters
-  //   (in global coord) 
-  // - convert the cluster coordinates to theta, phi (seen from the
-  //   interaction vertex). 
-  // - makes an array of tracklets 
-  //   
-  // After this method has been called, the clusters of the two layers
-  // and the tracklets can be retrieved by calling the Get'er methods.
+
   if (fMult) delete fMult; fMult = 0;
   fNClustersLay1 = 0;
   fNClustersLay2 = 0;
@@ -432,6 +415,17 @@ void AliITSMultReconstructor::Reconstruct(TTree* clusterTree, Float_t* vtx, Floa
 //____________________________________________________________________
 void AliITSMultReconstructor::FindTracklets(const Float_t *vtx) 
 {
+
+  // - calls LoadClusterArrays that finds the position of the clusters
+  //   (in global coord) 
+  // - convert the cluster coordinates to theta, phi (seen from the
+  //   interaction vertex). 
+  // - makes an array of tracklets 
+  //   
+  // After this method has been called, the clusters of the two layers
+  // and the tracklets can be retrieved by calling the Get'er methods.
+
+
   // Find tracklets converging to vertex
   //
   LoadClusterArrays(fTreeRP);
@@ -521,8 +515,8 @@ void AliITSMultReconstructor::FindTracklets(const Float_t *vtx)
     // Loop on layer 1 
     for (Int_t iC1=0; iC1<fNClustersLay1; iC1++) {    
 
-      // already used or in the overlap ?
-      if (associatedLay1[iC1] != 0 || fOverlapFlagClustersLay1[iC1]) continue;
+      // already used ?
+      if (associatedLay1[iC1] != 0) continue; 
 
       found++;
 
@@ -534,8 +528,6 @@ void AliITSMultReconstructor::FindTracklets(const Float_t *vtx)
       // Loop on layer 2 
       for (Int_t iC2=0; iC2<fNClustersLay2; iC2++) {      
 
-        // in the overlap ?
-        if (fOverlapFlagClustersLay2[iC2]) continue;
        float* clPar2 = GetClusterLayer2(iC2);
 
         if (blacklist[iC1]) {
@@ -550,7 +542,7 @@ void AliITSMultReconstructor::FindTracklets(const Float_t *vtx)
         }
 
        // find the difference in angles
-       Double_t dTheta = TMath::Abs(clPar2[kClTh] - clPar1[kClTh]);
+       Double_t dTheta = TMath::Abs(clPar2[kClTh] - clPar1[kClTh]);  
        Double_t dPhi   = TMath::Abs(clPar2[kClPh] - clPar1[kClPh]);
         // take into account boundary condition
         if (dPhi>pi) dPhi=2.*pi-dPhi;
@@ -697,6 +689,7 @@ void AliITSMultReconstructor::FindTracklets(const Float_t *vtx)
       fSClusters[fNSingleCluster] = new Float_t[kClNPar];
       fSClusters[fNSingleCluster][kSCTh] = clPar1[kClTh];
       fSClusters[fNSingleCluster][kSCPh] = clPar1[kClPh];
+      fSClusters[fNSingleCluster][kSCLab] = clPar1[kClMC0]; 
       fSClusters[fNSingleCluster][kSCID] = iC1;
       AliDebug(1,Form(" Adding a single cluster %d (cluster %d  of layer 1)",
                 fNSingleCluster, iC1));
@@ -734,7 +727,7 @@ void AliITSMultReconstructor::CreateMultiplicityObject()
   //
   for (int i=fNTracklets;i--;)  {
     float* tlInfo = fTracklets[i];
-    fMult->SetTrackletData(i,tlInfo, fUsedClusLay1[int(tlInfo[kClID1])]|fUsedClusLay2[int(tlInfo[kClID2])]);
+    fMult->SetTrackletData(i,tlInfo, fUsedClusLay1[int(tlInfo[kClID1])],fUsedClusLay2[int(tlInfo[kClID2])]);
   }
   //  
   for (int i=fNSingleCluster;i--;) {
@@ -755,7 +748,7 @@ void AliITSMultReconstructor::LoadClusterArrays(TTree* itsClusterTree)
   // - store them in the internal arrays
   // - count the number of cluster-fired chips
   //
-  // RS: This method was strongly modified wrt original by Jan Fiete. In order to have the same numbering
+  // RS: This method was strongly modified wrt original. In order to have the same numbering 
   // of clusters as in the ITS reco I had to introduce sorting in Z
   // Also note that now the clusters data are stored not in float[6] attached to float**, but in 1-D array
   
@@ -803,7 +796,7 @@ void AliITSMultReconstructor::LoadClusterArrays(TTree* itsClusterTree)
     Float_t*   clustersLay              = new Float_t[nclLayer*kClNPar];
     Int_t*     detectorIndexClustersLay = new Int_t[nclLayer];
     Bool_t*    overlapFlagClustersLay   = new Bool_t[nclLayer];
-    Char_t*    usedClusLay              = new Char_t[nclLayer];
+    UInt_t*    usedClusLay              = new UInt_t[nclLayer];
     //
     for (int ic=0;ic<nclLayer;ic++) {
       AliITSRecPoint* cluster = (AliITSRecPoint*)clArr[index[ic]];
@@ -847,7 +840,7 @@ void AliITSMultReconstructor::LoadClusterArrays(TTree* itsClusterTree)
 //____________________________________________________________________
 void
 AliITSMultReconstructor::LoadClusterFiredChips(TTree* itsClusterTree) {
-  // This method
+  // This method    
   // - gets the clusters from the cluster tree 
   // - counts the number of (cluster)fired chips
   
@@ -856,7 +849,7 @@ AliITSMultReconstructor::LoadClusterFiredChips(TTree* itsClusterTree) {
   fNFiredChips[0] = 0;
   fNFiredChips[1] = 0;
   
-  AliITSsegmentationSPD seg;
+  AliITSsegmentationSPD seg;   
   AliITSRecPointContainer* rpcont=AliITSRecPointContainer::Instance();
   TClonesArray* itsClusters=rpcont->FetchClusters(0,itsClusterTree);
   if(!rpcont->IsSPDActive()){
@@ -1020,7 +1013,7 @@ void AliITSMultReconstructor::ProcessESDTracks()
   for(Int_t itr=0; itr<ntracks; itr++) {
     AliESDtrack* track = fESDEvent->GetTrack(itr);
     if (!track->IsOn(AliESDtrack::kITSin)) continue; // use only tracks propagated in ITS to vtx
-    FlagTrackClusters(track);
+    FlagTrackClusters(itr);
     FlagIfSecondary(track,vtx);
   }
   FlagV0s(vtx);
@@ -1028,21 +1021,39 @@ void AliITSMultReconstructor::ProcessESDTracks()
 }
 
 //____________________________________________________________________
-void AliITSMultReconstructor::FlagTrackClusters(const AliESDtrack* track)
+void AliITSMultReconstructor::FlagTrackClusters(Int_t id)
 {
   // RS: flag the SPD clusters of the track if it is useful for the multiplicity estimation
   //
+  const UInt_t   kMaskL = 0x0000ffff;
+  const UInt_t   kMaskH = 0xffff0000;
+  const UInt_t   kMaxTrID = kMaskL - 1; // max possible track id
+  if (UInt_t(id)>kMaxTrID) return;
+  const AliESDtrack* track = fESDEvent->GetTrack(id);
   Int_t idx[12];
   if ( track->GetITSclusters(idx)<3 ) return; // at least 3 clusters must be used in the fit
+  UInt_t *uClus[2] = {fUsedClusLay1,fUsedClusLay2};
+  //
+  UInt_t mark = id+1;
+  if (track->IsOn(AliESDtrack::kITSpureSA)) mark <<= 16;
   //
-  char mark = track->IsOn(AliESDtrack::kITSpureSA) ? kITSSAPBit : kITSTPCBit;
-  char *uClus[2] = {fUsedClusLay1,fUsedClusLay2};
   for (int i=AliESDfriendTrack::kMaxITScluster;i--;) {
     // note: i>=6 is for extra clusters
     if (idx[i]<0) continue;
     int layID= (idx[i] & 0xf0000000) >> 28; 
     if (layID>1) continue; // SPD only
     int clID = (idx[i] & 0x0fffffff);
+    //
+    if ( track->IsOn(AliESDtrack::kITSpureSA) ) {
+      if (uClus[layID][clID]&kMaskH) {
+       AliWarning(Form("Tracks %5d and %5d share cluster %6d of lr%d",id,int(uClus[layID][clID]>>16)-1,clID,layID));
+       uClus[layID][clID] &= kMaskL;
+      }
+    }
+    else if (uClus[layID][clID]&kMaskL) {
+      AliWarning(Form("Tracks %5d and %5d share cluster %6d of lr%d",id,int(uClus[layID][clID]&kMaskL)-1,clID,layID));
+      uClus[layID][clID] &= kMaskH;
+    }
     uClus[layID][clID] |= mark;
   }
   //