]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSClusterizerv1.cxx
New data member (cerenkov angle) in Cerenkov data structure.
[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
d15a28e7 186 while ( (digit = (AliPHOSDigit *)nextdigit()) ) { // scan over the list of digits
187 AliPHOSRecPoint * clu ;
9f616d61 188
83974468 189 AliPHOSDigit ** clusterdigitslist = new AliPHOSDigit*[dl->GetEntries()] ;
d15a28e7 190 Int_t index ;
9f616d61 191 if (( ( IsInEmc(digit) ) && ( Calibrate(digit->GetAmp() ) > fEmcClusteringThreshold ) ) ||
192 ( ( !IsInEmc(digit) ) && ( Calibrate(digit->GetAmp() ) > fPpsdClusteringThreshold ) ) ) {
d15a28e7 193
194 Int_t iDigitInCluster = 0 ;
195
6ad0bfa0 196 if ( IsInEmc(digit) ) {
83974468 197 // start a new EMC RecPoint
198 // new ((*emcl)[fNumberOfEmcClusters]) AliPHOSEmcRecPoint(fW0, fLocMaxCut) ; if TClonesArray
199 (*emcl)[fNumberOfEmcClusters] = new AliPHOSEmcRecPoint(fW0, fLocMaxCut) ;
200
9f616d61 201 clu = (AliPHOSEmcRecPoint *) (*emcl)[fNumberOfEmcClusters] ;
202 fNumberOfEmcClusters++ ;
203 clu->AddDigit(*digit, Calibrate(digit->GetAmp())) ;
d15a28e7 204
83974468 205 clusterdigitslist[iDigitInCluster] = digit ;
9f616d61 206 iDigitInCluster++ ;
92862013 207 tempodigitslist.Remove(digit) ;
ca77b032 208
209
d15a28e7 210 }
211
212 else {
83974468 213
214 // start a new PPSD cluster
215 // new ((*ppsdl)[fNumberOfPpsdClusters]) AliPHOSPpsdRecPoint() ; if TClonesArray
216 (*ppsdl)[fNumberOfPpsdClusters] = new AliPHOSPpsdRecPoint() ;
217
9f616d61 218 clu = (AliPHOSPpsdRecPoint *) ppsdl->At(fNumberOfPpsdClusters) ;
219 fNumberOfPpsdClusters++ ;
6ad0bfa0 220 clu->AddDigit(*digit, Calibrate(digit->GetAmp()) ) ;
83974468 221 clusterdigitslist[iDigitInCluster] = digit ;
9f616d61 222 iDigitInCluster++ ;
92862013 223 tempodigitslist.Remove(digit) ;
d15a28e7 224 nextdigit.Reset() ;
225
9f616d61 226 // Here we remove resting EMC digits, which cannot make cluster
227
92862013 228 if( notremoved ) {
d15a28e7 229
9f616d61 230 while( ( digit = (AliPHOSDigit *)nextdigit() ) ) {
d15a28e7 231
9f616d61 232 if( IsInEmc(digit) )
92862013 233 tempodigitslist.Remove(digit) ;
d15a28e7 234 else
235 break ;
9f616d61 236
237 } // while digit
d15a28e7 238
92862013 239 } // if notremoved
d15a28e7 240
241 } // else
242
243 nextdigit.Reset() ;
244
245 AliPHOSDigit * digitN ;
246 index = 0 ;
9f616d61 247 while (index < iDigitInCluster){ // scan over digits already in cluster
83974468 248 digit = clusterdigitslist[index] ;
9f616d61 249 index++ ;
d15a28e7 250 while ( (digitN = (AliPHOSDigit *)nextdigit()) ) { // scan over the reduced list of digits
251 Int_t ineb = AreNeighbours(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
252 switch (ineb ) {
9f616d61 253 case 0 : // not a neighbour
d15a28e7 254 break ;
9f616d61 255 case 1 : // are neighbours
83974468 256 clu->AddDigit(*digitN, Calibrate( digitN->GetAmp() ) ) ;
257 clusterdigitslist[iDigitInCluster] = digitN ;
9f616d61 258 iDigitInCluster++ ;
92862013 259 tempodigitslist.Remove(digitN) ;
d15a28e7 260 break ;
9f616d61 261 case 2 : // too far from each other
d15a28e7 262 goto endofloop;
263 } // switch
264
265 } // while digitN
266
267 endofloop: ;
268 nextdigit.Reset() ;
269
270 } // loop over cluster
271
272 } //below energy theshold
273
31aa6d6c 274 delete[] clusterdigitslist ;
275
d15a28e7 276 } // while digit
277
92862013 278 tempodigitslist.Clear() ;
83974468 279
d15a28e7 280}
281
282//____________________________________________________________________________
283void AliPHOSClusterizerv1::PrintParameters()
284{
b2a60966 285 // Print the energy thresholds
286
d15a28e7 287 cout << "PHOS Clusterizer version 1 :" << endl
288 << " EMC Clustering threshold = " << fEmcClusteringThreshold << endl
289 << " EMC Energy threshold = " << fEmcEnergyThreshold << endl
290 << " PPSD Clustering threshold = " << fPpsdClusteringThreshold << endl
291 << " PPSD Energy threshold = " << fPpsdEnergyThreshold << endl ;
292}