Changes imposed by HP-UX which ignores the new C++ standart
[u/mrichter/AliRoot.git] / PHOS / AliPHOSClusterizerv1.cxx
CommitLineData
d15a28e7 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
b2a60966 16/* $Id$ */
17
d15a28e7 18//_________________________________________________________________________
b2a60966 19// Implementation version 1 of the clusterization algorithm
20//
21//*-- Author: Yves Schutz (SUBATECH)
d15a28e7 22//////////////////////////////////////////////////////////////////////////////
23
24// --- ROOT system ---
25
26#include "TMath.h"
27
28// --- Standard library ---
29
de9ec31b 30#include <iostream.h>
d15a28e7 31
32// --- AliRoot header files ---
33
34#include "AliPHOSClusterizerv1.h"
35#include "AliPHOSDigit.h"
36#include "AliPHOSEmcRecPoint.h"
37#include "AliPHOSPpsdRecPoint.h"
38#include "AliPHOSv0.h"
39#include "AliRun.h"
40
41ClassImp(AliPHOSClusterizerv1)
42
43//____________________________________________________________________________
44AliPHOSClusterizerv1::AliPHOSClusterizerv1()
45{
b2a60966 46 // default ctor (to be used)
47
d15a28e7 48 fA = 0.;
49 fB = 0.01 ;
50 fNumberOfEmcClusters = 0 ;
51 fNumberOfPpsdClusters = 0 ;
52 fEmcClusteringThreshold = 0.1;
53 fEmcEnergyThreshold = 0.01;
54 fPpsdClusteringThreshold = 0.00000015;
55 fPpsdEnergyThreshold = 0.0000001;
56 fW0 = 4.5 ;
57 fLocMaxCut = 0.06 ;
58}
59
60//____________________________________________________________________________
61Int_t AliPHOSClusterizerv1::AreNeighbours(AliPHOSDigit * d1, AliPHOSDigit * d2)
62{
b2a60966 63 // Gives the neighbourness of two digits = 0 are not neighbour but continue searching
64 // = 1 are neighbour
65 // = 2 are not neighbour but do not continue searching
66 // neighbours are defined as digits having at least common vertex
67 // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster
68 // which is compared to a digit (d2) not yet in a cluster
69
d15a28e7 70 Int_t rv = 0 ;
71
72 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;
73
74 Int_t relid1[4] ;
75 geom->AbsToRelNumbering(d1->GetId(), relid1) ;
76
77 Int_t relid2[4] ;
78 geom->AbsToRelNumbering(d2->GetId(), relid2) ;
79
80 if ( (relid1[0] == relid2[0]) && (relid1[1]==relid2[1]) ) { // inside the same PHOS module and the same PPSD Module
92862013 81 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
82 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
d15a28e7 83
92862013 84 if (( coldiff <= 1 ) && ( rowdiff <= 1 )){
d15a28e7 85 rv = 1 ;
86 }
87 else {
88 if((relid2[2] > relid1[2]) && (relid2[3] > relid1[3]+1))
89 rv = 2; // Difference in row numbers is too large to look further
90 }
91
92 }
93 else {
94
95 if( (relid1[0] < relid2[0]) || (relid1[1] < relid2[1]) )
96 rv=2 ;
97
98 }
99
100 return rv ;
101}
102
103//____________________________________________________________________________
104void AliPHOSClusterizerv1::FillandSort(const DigitsList * dl, TObjArray * tl)
105{
b2a60966 106 // Copies the digits with energy above thershold and sorts the list
d15a28e7 107 // according to increasing Id number
108
d15a28e7 109 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;
110 Int_t relid[4] ;
111
112 TIter next(dl) ;
113 AliPHOSDigit * digit ;
114
6a3f1304 115
ca77b032 116
6a3f1304 117
d15a28e7 118 while ( (digit = (AliPHOSDigit *)next()) ) {
cf239357 119
120// cout << " clusterizerv1 " << endl ;
121// int nprim = digit->GetNprimary() ;
122// int * aprim = digit->GetPrimary() ;
123// for ( int ii = 0 ; ii < nprim ; ii++)
124// cout << ii << " prim = " << aprim[ii] << endl ;
125
d15a28e7 126 Int_t id = digit->GetId() ;
127 Float_t ene = Calibrate(digit->GetAmp()) ;
128 geom->AbsToRelNumbering(id, relid) ;
d15a28e7 129 if(relid[1]==0){ // EMC
6a3f1304 130 if ( ene > fEmcEnergyThreshold )
d15a28e7 131 tl->Add(digit) ;
132 }
133
134 else { //Ppsd
135 if ( ene > fPpsdEnergyThreshold )
6a3f1304 136 tl->Add(digit) ;
d15a28e7 137 }
138
139 }
140 tl->Sort() ;
141}
142
143//____________________________________________________________________________
144void AliPHOSClusterizerv1:: GetNumberOfClustersFound(Int_t * numb)
145{
b2a60966 146 // Fills numb with the number of EMC (numb[0]) clusters found
147 // PPSD (numb[1]) clusters found
148
149 numb[0] = fNumberOfEmcClusters ;
150 numb[1] = fNumberOfPpsdClusters ;
d15a28e7 151}
152
153//____________________________________________________________________________
154Bool_t AliPHOSClusterizerv1::IsInEmc(AliPHOSDigit * digit)
155{
b2a60966 156 // Tells if (true) or not (false) the digit is in a PHOS-EMC module
157
9f616d61 158 Bool_t rv = kFALSE ;
d15a28e7 159
160 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;
161
162 Int_t relid[4] ;
163 geom->AbsToRelNumbering(digit->GetId(), relid) ;
164
165 if ( relid[1] == 0 )
166 rv = kTRUE;
167
168 return rv ;
169}
170
171//____________________________________________________________________________
172void AliPHOSClusterizerv1::MakeClusters(const DigitsList * dl, RecPointsList * emcl, RecPointsList * ppsdl)
173{
b2a60966 174 // Steering method to construct the clusters stored in a list of Reconstructed Points
175 // A cluster is defined as a list of neighbour digits
ca77b032 176
d15a28e7 177 // Fill and sort the working digits list
92862013 178 TObjArray tempodigitslist( dl->GetEntries() ) ;
179 FillandSort(dl, &tempodigitslist) ;
d15a28e7 180
181 // Clusterization starts
92862013 182 TIter nextdigit(&tempodigitslist) ;
d15a28e7 183 AliPHOSDigit * digit ;
92862013 184 Bool_t notremoved = kTRUE ;
6ad0bfa0 185
ca77b032 186
d15a28e7 187 while ( (digit = (AliPHOSDigit *)nextdigit()) ) { // scan over the list of digits
188 AliPHOSRecPoint * clu ;
9f616d61 189
31aa6d6c 190 int ** clusterdigitslist = new int * [dl->GetEntries()] ;
d15a28e7 191 Int_t index ;
9f616d61 192 if (( ( IsInEmc(digit) ) && ( Calibrate(digit->GetAmp() ) > fEmcClusteringThreshold ) ) ||
193 ( ( !IsInEmc(digit) ) && ( Calibrate(digit->GetAmp() ) > fPpsdClusteringThreshold ) ) ) {
d15a28e7 194
195 Int_t iDigitInCluster = 0 ;
196
6ad0bfa0 197 if ( IsInEmc(digit) ) {
9f616d61 198 new ((*emcl)[fNumberOfEmcClusters]) AliPHOSEmcRecPoint(fW0, fLocMaxCut) ; // start a new EMC RecPoint
199 clu = (AliPHOSEmcRecPoint *) (*emcl)[fNumberOfEmcClusters] ;
200 fNumberOfEmcClusters++ ;
201 clu->AddDigit(*digit, Calibrate(digit->GetAmp())) ;
d15a28e7 202
92862013 203 clusterdigitslist[iDigitInCluster] = (int* ) digit ;
9f616d61 204 iDigitInCluster++ ;
92862013 205 tempodigitslist.Remove(digit) ;
ca77b032 206
207
d15a28e7 208 }
209
210 else {
9f616d61 211 new ((*ppsdl)[fNumberOfPpsdClusters]) AliPHOSPpsdRecPoint() ; // start a new PPSD cluster
212 clu = (AliPHOSPpsdRecPoint *) ppsdl->At(fNumberOfPpsdClusters) ;
213 fNumberOfPpsdClusters++ ;
6ad0bfa0 214 clu->AddDigit(*digit, Calibrate(digit->GetAmp()) ) ;
92862013 215 clusterdigitslist[iDigitInCluster] = (int* ) digit ;
9f616d61 216 iDigitInCluster++ ;
92862013 217 tempodigitslist.Remove(digit) ;
d15a28e7 218 nextdigit.Reset() ;
219
9f616d61 220 // Here we remove resting EMC digits, which cannot make cluster
221
92862013 222 if( notremoved ) {
d15a28e7 223
9f616d61 224 while( ( digit = (AliPHOSDigit *)nextdigit() ) ) {
d15a28e7 225
9f616d61 226 if( IsInEmc(digit) )
92862013 227 tempodigitslist.Remove(digit) ;
d15a28e7 228 else
229 break ;
9f616d61 230
231 } // while digit
d15a28e7 232
92862013 233 } // if notremoved
d15a28e7 234
235 } // else
236
237 nextdigit.Reset() ;
238
239 AliPHOSDigit * digitN ;
240 index = 0 ;
9f616d61 241 while (index < iDigitInCluster){ // scan over digits already in cluster
92862013 242 digit = (AliPHOSDigit *) clusterdigitslist[index] ;
9f616d61 243 index++ ;
d15a28e7 244 while ( (digitN = (AliPHOSDigit *)nextdigit()) ) { // scan over the reduced list of digits
245 Int_t ineb = AreNeighbours(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
246 switch (ineb ) {
9f616d61 247 case 0 : // not a neighbour
d15a28e7 248 break ;
9f616d61 249 case 1 : // are neighbours
250 clu->AddDigit( *digitN, Calibrate( digitN->GetAmp() ) ) ;
92862013 251 clusterdigitslist[iDigitInCluster] =(int*) digitN ;
9f616d61 252 iDigitInCluster++ ;
92862013 253 tempodigitslist.Remove(digitN) ;
d15a28e7 254 break ;
9f616d61 255 case 2 : // too far from each other
d15a28e7 256 goto endofloop;
257 } // switch
258
259 } // while digitN
260
261 endofloop: ;
262 nextdigit.Reset() ;
263
264 } // loop over cluster
265
266 } //below energy theshold
267
31aa6d6c 268 delete[] clusterdigitslist ;
269
d15a28e7 270 } // while digit
271
92862013 272 tempodigitslist.Clear() ;
d15a28e7 273}
274
275//____________________________________________________________________________
276void AliPHOSClusterizerv1::PrintParameters()
277{
b2a60966 278 // Print the energy thresholds
279
d15a28e7 280 cout << "PHOS Clusterizer version 1 :" << endl
281 << " EMC Clustering threshold = " << fEmcClusteringThreshold << endl
282 << " EMC Energy threshold = " << fEmcEnergyThreshold << endl
283 << " PPSD Clustering threshold = " << fPpsdClusteringThreshold << endl
284 << " PPSD Energy threshold = " << fPpsdEnergyThreshold << endl ;
285}