]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/AliClusterMap.cxx
Temporary fix to compile if Root is compiled without XML support. More general soluti...
[u/mrichter/AliRoot.git] / ANALYSIS / AliClusterMap.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////
19 //
20 // class AliClusterMap
21 // class that describes cluster occupation at TPC
22 // Each padraw has a corresponding bit in fPadRawMap
23 // more info: http://aliweb.cern.ch/people/skowron/analyzer/index.html
24 // Piotr.Skowronski@cern.ch
25 //
26 ///////////////////////////////////////////////////////////////////////////
27
28 #include <TString.h>
29
30 #include "AliClusterMap.h"
31 #include "AliESDtrack.h"
32 #include "AliLog.h"
33 #include "AliTPCtrack.h"
34
35 const Int_t AliClusterMap::fgkNPadRows = 159;
36
37 ClassImp(AliClusterMap)
38
39 AliClusterMap::AliClusterMap():
40  fPadRawMap(fgkNPadRows)
41 {
42 //ctor
43
44 }
45 /***********************************************************************/
46 AliClusterMap::AliClusterMap(AliESDtrack* track):
47  fPadRawMap( (track)?track->GetTPCClusterMap():fgkNPadRows )
48 {
49  //ctor
50  
51  StdoutToAliDebug(3,Print());
52
53
54 /***********************************************************************/
55
56 AliClusterMap::AliClusterMap(AliTPCtrack* track):
57  fPadRawMap(fgkNPadRows)
58 {
59  //ctor
60  
61  AliDebug(10,"#####################################################################"); 
62  if (track == 0x0)
63   {
64     Error("AliClusterMap","Pointer to TPC track is NULL");
65     return;
66   }
67  Int_t prevrow = -1;
68  Int_t i = 0;
69  for ( ; i < track->GetNumberOfClusters(); i++)
70   {
71     Int_t idx = track->GetClusterIndex(i);
72     Int_t sect = (idx&0xff000000)>>24;
73     Int_t row = (idx&0x00ff0000)>>16;
74     if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
75     AliDebug(9,Form("Cl.idx is %d, sect %d, row %d",idx,sect,row));
76       
77     fPadRawMap.SetBitNumber(row,kTRUE);
78     
79     //Fill the gap between previous row and this row with 0 bits
80     if (prevrow < 0) 
81      {
82        prevrow = row;//if previous bit was not assigned yet == this is the first one
83      }
84     else
85      { //we don't know the order (inner to outer or reverse)
86        //just to be save in case it is going to change
87        Int_t n = 0, m = 0;
88        if (prevrow < row)
89         {
90           n = prevrow;
91           m = row;
92         }
93        else
94         {
95           n = row;
96           m = prevrow;
97         }
98        for (Int_t j = n+1; j < m; j++)
99         {
100           fPadRawMap.SetBitNumber(j,kFALSE);
101         }
102        prevrow = row; 
103      }
104   }
105   
106  StdoutToAliDebug(3,Print());
107
108 }
109 /***********************************************************************/
110
111 void AliClusterMap::Print() const
112 {
113 //Prints the bit map 
114   TString msg;
115   for ( Int_t i = 0; i < fgkNPadRows; i++)
116    {
117      if ( fPadRawMap.TestBitNumber(i) )
118       {
119         msg+="1";
120       }
121      else
122       {
123         msg+="0";
124       }
125    }
126   Info("AliClusterMap","BitMap is\n  %s",msg.Data());
127   
128 }
129
130 /***********************************************************************/
131
132 Float_t AliClusterMap::GetOverlapFactor(const AliClusterMap& clmap) const
133 {
134   //Returns quality factor FQ = Sum(An)/Sum(clusters)
135   //      | -1; if both tracks have a cluster on padrow n
136   //An = <  0; if neither track has a cluster on padrow n
137   //     |  1; if only one trackhas a cluster on padrow n
138   // Returned value ranges between 
139   //  -0.5 (low probability that these tracks are a split track)
140   //  and
141   //   1.0 (high probability that these tracks are a split track)
142   
143   Int_t nh = 0;
144   Int_t an = 0;
145   for ( Int_t i = 0; i < fgkNPadRows; i++)
146    {
147      Bool_t x = HasClAtPadRow(i);
148      Bool_t y = clmap.HasClAtPadRow(i);
149      
150      if (x && y)//both have clasters
151       {
152        an--;
153        nh+=2;
154       }
155      else 
156       {
157        
158        if (x || y)//only one have cluters
159         {
160           an++;
161           nh++;
162         }
163       }
164    }
165   
166   
167   Float_t retval = 0.0;
168   if (nh > 0) retval = ((Float_t)an)/((Float_t)nh);
169   else Warning("GetOverlapFactor","Number of counted cluters is 0.");
170   
171   return retval;
172 }