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