]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HBTAN/AliHBTClusterMap.cxx
New cuts added on pair open angles
[u/mrichter/AliRoot.git] / HBTAN / AliHBTClusterMap.cxx
1 #include "AliHBTClusterMap.h"
2
3 //_________________________________________________
4 ///////////////////////////////////////////////////
5 //
6 // class AliHBTClusterMap
7 //
8 // class that describes cluster occupation at TPC
9 // Each padraw has a corresponding bit in fPadRawMap
10 // 
11 //
12 // more info: http://aliweb.cern.ch/people/skowron/analyzer/index.html
13 // Piotr.Skowronski@cern.ch
14 //
15 ///////////////////////////////////////////////////////////////////////////
16
17
18 #include "AliESDtrack.h"
19 #include "AliTPCtrack.h"
20 #include "AliHBTParticle.h"
21 #include <TString.h>
22 const Int_t AliHBTClusterMap::fNPadRows = 159;
23
24 AliHBTClusterMap::AliHBTClusterMap():
25  fPadRawMap(fNPadRows)
26 {
27 //ctor
28
29 }
30 /***********************************************************************/
31 AliHBTClusterMap::AliHBTClusterMap(AliESDtrack* track):
32  fPadRawMap( (track)?track->GetTPCClusterMap():fNPadRows )
33 {
34  //ctor
35  
36  if (AliHBTParticle::GetDebug() > 2)
37   { 
38     Info("AliHBTClusterMap(AliESDtrack*)","");
39     Print();
40   } 
41
42 /***********************************************************************/
43
44 AliHBTClusterMap::AliHBTClusterMap(AliTPCtrack* track):
45  fPadRawMap(fNPadRows)
46 {
47  //ctor
48  
49  //Does not work since indeces in the claster index array 
50  //in the TPC track does not correspond to the padraw segmatation
51  if (AliHBTParticle::GetDebug() > 9) 
52    Info("AliHBTClusterMap",
53       "#####################################################################"); 
54  if (track == 0x0)
55   {
56     Error("AliHBTClusterMap","Pointer to TPC track is NULL");
57     return;
58   }
59  Int_t prevrow = -1;
60  Int_t i = 0;
61  for ( ; i < track->GetNumberOfClusters(); i++)
62   {
63     Int_t idx = track->GetClusterIndex(i);
64     Int_t sect = (idx&0xff000000)>>24;
65     Int_t row = (idx&0x00ff0000)>>16;
66     if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
67     if (AliHBTParticle::GetDebug() > 9)  
68       Info("AliHBTClusterMap","Cl.idx is %d, sect %d, row %d",idx,sect,row);
69       
70     fPadRawMap.SetBitNumber(row,kTRUE);
71     
72     //Fill the gap between previous row and this row with 0 bits
73     if (prevrow < 0) 
74      {
75        prevrow = row;//if previous bit was not assigned yet == this is the first one
76      }
77     else
78      { //we don't know the order (inner to outer or reverse)
79        //just to be save in case it is going to change
80        Int_t n = 0, m = 0;
81        if (prevrow < row)
82         {
83           n = prevrow;
84           m = row;
85         }
86        else
87         {
88           n = row;
89           m = prevrow;
90         }
91        for (Int_t j = n+1; j < m; j++)
92         {
93           fPadRawMap.SetBitNumber(j,kFALSE);
94         }
95        prevrow = row; 
96      }
97   }
98   
99  if (AliHBTParticle::GetDebug() > 2)
100   { 
101     Info("AliHBTClusterMap(AliTPCtrack*)","");
102     Print();
103   } 
104 }
105 /***********************************************************************/
106
107 void AliHBTClusterMap::Print() const
108 {
109 //Prints the bit map 
110   TString msg;
111   for ( Int_t i = 0; i < fNPadRows; i++)
112    {
113      if ( fPadRawMap.TestBitNumber(i) )
114       {
115         msg+="1";
116       }
117      else
118       {
119         msg+="0";
120       }
121    }
122   Info("AliHBTClusterMap","BitMap is\n  %s",msg.Data());
123   
124 }
125
126 /***********************************************************************/
127
128 Float_t AliHBTClusterMap::GetOverlapFactor(const AliHBTClusterMap& clmap) const
129 {
130   //Returns quality factor FQ = Sum(An)/Sum(clusters)
131   //      | -1; if both tracks have a cluster on padrow n
132   //An = <  0; if neither track has a cluster on padrow n
133   //     |  1; if only one trackhas a cluster on padrow n
134   // Returned value ranges between 
135   //  -0.5 (low probability that these tracks are a split track)
136   //  and
137   //   1.0 (high probability that these tracks are a split track)
138   TString msg1;
139   TString msg2;
140   
141   Int_t nh = 0;
142   Int_t an = 0;
143   for ( Int_t i = 0; i < fNPadRows; i++)
144    {
145      Bool_t x = HasClAtPadRow(i);
146      Bool_t y = clmap.HasClAtPadRow(i);
147      
148      if (x) msg1+="1";else msg1+="0";
149      if (y) msg2+="1";else msg2+="0";
150      
151      if (x && y)//both have clasters
152       {
153        an--;
154        nh+=2;
155       }
156      else 
157       {
158        
159        if (x || y)//only one have cluters
160         {
161           an++;
162           nh++;
163         }
164       }
165    }
166   
167   
168   Float_t retval = 0.0;
169   if (nh > 0) retval = ((Float_t)an)/((Float_t)nh);
170   else Warning("GetOverlapFactor","Number of counted cluters is 0.");
171   
172   if (AliHBTParticle::GetDebug() > 2)
173    {
174      Info("GetOverlapFactor","Splitting Quality Factor is %f. SumAn = %d, SumClusters %d",retval,an,nh); 
175      if (retval == 1.0) 
176       { 
177         Print();
178         Info("AliHBTClusterMap","BitMap is\n  %s\n",msg1.Data());
179         clmap.Print(); 
180         Info("AliHBTClusterMap","BitMap is\n  %s\n\n\n\n",msg2.Data());
181       }
182      if (retval == -.5) 
183       { 
184         Print();
185         Info("AliHBTClusterMap","BitMap is\n  %s\n",msg1.Data());
186         clmap.Print(); 
187         Info("AliHBTClusterMap","BitMap is\n  %s\n\n\n\n",msg2.Data());
188       }
189    } 
190  
191   return retval;
192 }