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