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