1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //_________________________________________________________________________
19 // Implementation version 1 of the clusterization algorithm
21 //*-- Author: Yves Schutz (SUBATECH)
22 //////////////////////////////////////////////////////////////////////////////
24 // --- ROOT system ---
28 // --- Standard library ---
32 // --- AliRoot header files ---
34 #include "AliPHOSClusterizerv1.h"
35 #include "AliPHOSDigit.h"
36 #include "AliPHOSEmcRecPoint.h"
37 #include "AliPHOSPpsdRecPoint.h"
38 #include "AliPHOSv0.h"
41 ClassImp(AliPHOSClusterizerv1)
43 //____________________________________________________________________________
44 AliPHOSClusterizerv1::AliPHOSClusterizerv1()
46 // default ctor (to be used)
50 fNumberOfEmcClusters = 0 ;
51 fNumberOfPpsdClusters = 0 ;
52 fEmcClusteringThreshold = 0.1;
53 fEmcEnergyThreshold = 0.01;
54 fPpsdClusteringThreshold = 0.00000015;
55 fPpsdEnergyThreshold = 0.0000001;
60 //____________________________________________________________________________
61 Int_t AliPHOSClusterizerv1::AreNeighbours(AliPHOSDigit * d1, AliPHOSDigit * d2)
63 // Gives the neighbourness of two digits = 0 are not neighbour but continue searching
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
72 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;
75 geom->AbsToRelNumbering(d1->GetId(), relid1) ;
78 geom->AbsToRelNumbering(d2->GetId(), relid2) ;
80 if ( (relid1[0] == relid2[0]) && (relid1[1]==relid2[1]) ) { // inside the same PHOS module and the same PPSD Module
81 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
82 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
84 if (( coldiff <= 1 ) && ( rowdiff <= 1 )){
88 if((relid2[2] > relid1[2]) && (relid2[3] > relid1[3]+1))
89 rv = 2; // Difference in row numbers is too large to look further
95 if( (relid1[0] < relid2[0]) || (relid1[1] < relid2[1]) )
103 //____________________________________________________________________________
104 void AliPHOSClusterizerv1::FillandSort(const DigitsList * dl, TObjArray * tl)
106 // Copies the digits with energy above thershold and sorts the list
107 // according to increasing Id number
109 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;
113 AliPHOSDigit * digit ;
118 while ( (digit = (AliPHOSDigit *)next()) ) {
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 ;
126 Int_t id = digit->GetId() ;
127 Float_t ene = Calibrate(digit->GetAmp()) ;
128 geom->AbsToRelNumbering(id, relid) ;
129 if(relid[1]==0){ // EMC
130 if ( ene > fEmcEnergyThreshold )
135 if ( ene > fPpsdEnergyThreshold )
143 //____________________________________________________________________________
144 void AliPHOSClusterizerv1:: GetNumberOfClustersFound(Int_t * numb)
146 // Fills numb with the number of EMC (numb[0]) clusters found
147 // PPSD (numb[1]) clusters found
149 numb[0] = fNumberOfEmcClusters ;
150 numb[1] = fNumberOfPpsdClusters ;
153 //____________________________________________________________________________
154 Bool_t AliPHOSClusterizerv1::IsInEmc(AliPHOSDigit * digit)
156 // Tells if (true) or not (false) the digit is in a PHOS-EMC module
160 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;
163 geom->AbsToRelNumbering(digit->GetId(), relid) ;
171 //____________________________________________________________________________
172 void AliPHOSClusterizerv1::MakeClusters(const DigitsList * dl,
173 AliPHOSRecPoint::RecPointsList * emcl,
174 AliPHOSRecPoint::RecPointsList * ppsdl)
176 // Steering method to construct the clusters stored in a list of Reconstructed Points
177 // A cluster is defined as a list of neighbour digits
179 // Fill and sort the working digits list
180 TObjArray tempodigitslist( dl->GetEntries() ) ;
181 FillandSort(dl, &tempodigitslist) ;
183 // Clusterization starts
184 TIter nextdigit(&tempodigitslist) ;
185 AliPHOSDigit * digit ;
186 Bool_t notremoved = kTRUE ;
188 while ( (digit = (AliPHOSDigit *)nextdigit()) ) { // scan over the list of digits
189 AliPHOSRecPoint * clu ;
191 AliPHOSDigit ** clusterdigitslist = new AliPHOSDigit*[dl->GetEntries()] ;
193 if (( ( IsInEmc(digit) ) && ( Calibrate(digit->GetAmp() ) > fEmcClusteringThreshold ) ) ||
194 ( ( !IsInEmc(digit) ) && ( Calibrate(digit->GetAmp() ) > fPpsdClusteringThreshold ) ) ) {
196 Int_t iDigitInCluster = 0 ;
198 if ( IsInEmc(digit) ) {
199 // start a new EMC RecPoint
200 // new ((*emcl)[fNumberOfEmcClusters]) AliPHOSEmcRecPoint(fW0, fLocMaxCut) ; if TClonesArray
201 (*emcl)[fNumberOfEmcClusters] = new AliPHOSEmcRecPoint(fW0, fLocMaxCut) ;
203 clu = (AliPHOSEmcRecPoint *) (*emcl)[fNumberOfEmcClusters] ;
204 fNumberOfEmcClusters++ ;
205 clu->AddDigit(*digit, Calibrate(digit->GetAmp())) ;
207 clusterdigitslist[iDigitInCluster] = digit ;
209 tempodigitslist.Remove(digit) ;
216 // start a new PPSD cluster
217 // new ((*ppsdl)[fNumberOfPpsdClusters]) AliPHOSPpsdRecPoint() ; if TClonesArray
218 (*ppsdl)[fNumberOfPpsdClusters] = new AliPHOSPpsdRecPoint() ;
220 clu = (AliPHOSPpsdRecPoint *) ppsdl->At(fNumberOfPpsdClusters) ;
221 fNumberOfPpsdClusters++ ;
222 clu->AddDigit(*digit, Calibrate(digit->GetAmp()) ) ;
223 clusterdigitslist[iDigitInCluster] = digit ;
225 tempodigitslist.Remove(digit) ;
228 // Here we remove resting EMC digits, which cannot make cluster
232 while( ( digit = (AliPHOSDigit *)nextdigit() ) ) {
235 tempodigitslist.Remove(digit) ;
247 AliPHOSDigit * digitN ;
249 while (index < iDigitInCluster){ // scan over digits already in cluster
250 digit = clusterdigitslist[index] ;
252 while ( (digitN = (AliPHOSDigit *)nextdigit()) ) { // scan over the reduced list of digits
253 Int_t ineb = AreNeighbours(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
255 case 0 : // not a neighbour
257 case 1 : // are neighbours
258 clu->AddDigit(*digitN, Calibrate( digitN->GetAmp() ) ) ;
259 clusterdigitslist[iDigitInCluster] = digitN ;
261 tempodigitslist.Remove(digitN) ;
263 case 2 : // too far from each other
272 } // loop over cluster
274 } //below energy theshold
276 delete[] clusterdigitslist ;
280 tempodigitslist.Clear() ;
284 //____________________________________________________________________________
285 void AliPHOSClusterizerv1::PrintParameters()
287 // Print the energy thresholds
289 cout << "PHOS Clusterizer version 1 :" << endl
290 << " EMC Clustering threshold = " << fEmcClusteringThreshold << endl
291 << " EMC Energy threshold = " << fEmcEnergyThreshold << endl
292 << " PPSD Clustering threshold = " << fPpsdClusteringThreshold << endl
293 << " PPSD Energy threshold = " << fPpsdEnergyThreshold << endl ;