Cleanup of collisions geometries and headers.
[u/mrichter/AliRoot.git] / PHOS / AliPHOSClusterizerv2.cxx
CommitLineData
0bc3b8ed 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 **************************************************************************/
0bc3b8ed 15
803d1ab0 16/* $Id$ */
17
0bc3b8ed 18//////////////////////////////////////////////////////////////////////////////
19// Clusterization class for IHEP reconstruction.
20// Performs clusterization (collects neighbouring active cells)
21// It differs from AliPHOSClusterizerv1 in neighbour definition only
803d1ab0 22//*-- Author: Boris Polichtchouk, IHEP
0bc3b8ed 23
cbd576a6 24// --- ROOT system ---
25#include "TBenchmark.h"
cbd576a6 26
27// --- Standard library ---
cbd576a6 28
29// --- AliRoot header files ---
351dd634 30#include "AliLog.h"
cbd576a6 31#include "AliPHOSClusterizerv2.h"
cbd576a6 32#include "AliPHOSEvalRecPoint.h"
33#include "AliPHOSRecCpvManager.h"
34#include "AliPHOSRecEmcManager.h"
e957fea8 35#include "AliPHOSGeometry.h"
9a2cdbdf 36#include "AliPHOSDigit.h"
cbd576a6 37
38ClassImp(AliPHOSClusterizerv2)
39
88cb7938 40//____________________________________________________________________________
cbd576a6 41AliPHOSClusterizerv2::AliPHOSClusterizerv2() : AliPHOSClusterizerv1()
42{}
43
88cb7938 44//____________________________________________________________________________
9a2cdbdf 45AliPHOSClusterizerv2::AliPHOSClusterizerv2(AliPHOSGeometry *geom):
46AliPHOSClusterizerv1(geom)
88cb7938 47{}
48
49//____________________________________________________________________________
cbd576a6 50void AliPHOSClusterizerv2::GetNumberOfClustersFound(int* numb) const
51{
0bc3b8ed 52 // Returns the number of found EMC and CPV rec.points
cbd576a6 53
9a2cdbdf 54 numb[0] = fEMCRecPoints->GetEntries();
55 numb[1] = fCPVRecPoints->GetEntries();
cbd576a6 56}
57
88cb7938 58//____________________________________________________________________________
9a2cdbdf 59void AliPHOSClusterizerv2::Digits2Clusters(Option_t* option)
cbd576a6 60{
0bc3b8ed 61 // Steering method
cbd576a6 62
63 if(strstr(option,"tim"))
64 gBenchmark->Start("PHOSClusterizer");
65
66 if(strstr(option,"print"))
88cb7938 67 Print() ;
9a2cdbdf 68}
69// AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
cbd576a6 70
9a2cdbdf 71// TFolder* wPoolF = gime->PhosLoader()->GetDetectorDataFolder();
fbf811ec 72
9a2cdbdf 73// TObjArray* wPool = new TObjArray(400);
74// wPool->SetName("SmartPoints");
75// wPoolF->Add(wPool);
76// wPoolF->Add(this);
cbd576a6 77
9a2cdbdf 78// Int_t nevents = gime->MaxEvent() ;
79// Int_t ievent ;
cbd576a6 80
9a2cdbdf 81// for(ievent = 0; ievent<nevents; ievent++) {
cbd576a6 82
9a2cdbdf 83// gime->Event(ievent,"D") ;
cbd576a6 84
9a2cdbdf 85// AliInfo(Form("MakeClusters invoked..")) ;
86// MakeClusters() ;
87// AliInfo(Form("MakeClusters done.")) ;
cbd576a6 88
89
9a2cdbdf 90// //SmartRecPoints will communicate with wPool.
cbd576a6 91
9a2cdbdf 92// AliPHOSEvalRecPoint* rp=0;
cbd576a6 93
9a2cdbdf 94// // CPV reconstruction
cbd576a6 95
9a2cdbdf 96// AliPHOSRecCpvManager* recCpv = new AliPHOSRecCpvManager();
97// wPoolF->Add(recCpv);
cbd576a6 98
9a2cdbdf 99// Int_t iPoint; //loop variable
c9eeb00e 100
9a2cdbdf 101// for(iPoint=0; iPoint<gime->CpvRecPoints()->GetEntriesFast(); iPoint++) {
102// rp = new AliPHOSEvalRecPoint(iPoint, kTRUE);
103// rp->MakeJob();
104// }
cbd576a6 105
9a2cdbdf 106// AliPHOSEvalRecPoint pt;
107// pt.UpdateWorkingPool();
cbd576a6 108
9a2cdbdf 109// TObjArray * cpvRecPoints = gime->CpvRecPoints() ;
110// Int_t nOldCpv = cpvRecPoints->GetEntries();
111// cpvRecPoints->Delete();
112// cpvRecPoints->Compress();
cbd576a6 113
9a2cdbdf 114// Int_t i; //loop variable
c9eeb00e 115
9a2cdbdf 116// for(i=0; i<wPool->GetEntries(); i++)
117// cpvRecPoints->Add(wPool->At(i));
cbd576a6 118
9a2cdbdf 119// wPool->Clear();
120// wPool->Compress();
cbd576a6 121
9a2cdbdf 122// wPoolF->Remove(recCpv);
123// delete recCpv;
cbd576a6 124
9a2cdbdf 125// AliInfo(Form(" %d", gime->CpvRecPoints()->GetEntries() )) ;
126// AliInfo(Form(" %d cpvRecPoints", cpvRecPoints->GetEntries() )) ;
cbd576a6 127
128
9a2cdbdf 129// // Now Emc reconstruction
cbd576a6 130
9a2cdbdf 131// AliPHOSRecEmcManager* recEmc = new AliPHOSRecEmcManager();
132// wPoolF->Add(recEmc);
cbd576a6 133
9a2cdbdf 134// for(iPoint=0; iPoint<gime->EmcRecPoints()->GetEntriesFast(); iPoint++) {
135// rp = new AliPHOSEvalRecPoint(iPoint, kFALSE);
136// rp->MakeJob();
137// }
cbd576a6 138
9a2cdbdf 139// pt.UpdateWorkingPool();
cbd576a6 140
9a2cdbdf 141// TObjArray * emcRecPoints = gime->EmcRecPoints() ;
142// Int_t nOldEmc = emcRecPoints->GetEntries();
143// emcRecPoints->Delete();
144// emcRecPoints->Compress();
cbd576a6 145
9a2cdbdf 146// for(i=0; i<wPool->GetEntries(); i++)
147// emcRecPoints->Add(wPool->At(i));
cbd576a6 148
9a2cdbdf 149// wPool->Clear();
150// wPool->Compress();
cbd576a6 151
9a2cdbdf 152// wPoolF->Remove(recEmc);
153// delete recEmc;
cbd576a6 154
9a2cdbdf 155// TString message ;
156// message = " %d OLD cpvRecPoints\n" ;
157// message += " %d\n" ;
158// message += " %d cpvRecPoints\n" ;
cbd576a6 159
9a2cdbdf 160// message += " %d OLD emcRecPoints " ;
161// message += " %d\n" ;
162// message += " %d emcRecPoints\n" ;
21cd0c07 163
9a2cdbdf 164// AliInfo(Form("%s", message.Data(),
165// nOldCpv,
166// gime->CpvRecPoints()->GetEntries(),cpvRecPoints->GetEntries(),
167// nOldEmc,
168// gime->EmcRecPoints()->GetEntries(), emcRecPoints->GetEntries() ));
ddd1a39c 169
cbd576a6 170
9a2cdbdf 171// WriteRecPoints();
cbd576a6 172
173
9a2cdbdf 174// } // loop over events
cbd576a6 175
9a2cdbdf 176// if(strstr(option,"tim")) {
177// gBenchmark->Stop("PHOSClusterizer");
178// AliInfo(Form("took %f seconds for Clusterizing", gBenchmark->GetCpuTime("PHOSClusterizer") )) ;
179// }
180// }
88cb7938 181
182//____________________________________________________________________________
cbd576a6 183Int_t AliPHOSClusterizerv2::AreNeighbours(AliPHOSDigit* d1, AliPHOSDigit* d2) const
184{
185 // Points are neighbours if they have common edge.
186 // Points with common vertex are NOT neighbours.
187 // This treatment of neighbourship is the part of
188 // IHEP algorithm of clusterization.
189
190 // Gives the neighbourness of two digits = 0 are not neighbour but continue searching
191 // = 1 are neighbour
192 // = 2 are not neighbour but do not continue searching
193 // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster
194 // which is compared to a digit (d2) not yet in a cluster
195
cbd576a6 196 Int_t rv = 0 ;
197
198 Int_t relid1[4] ;
9a2cdbdf 199 fGeom->AbsToRelNumbering(d1->GetId(), relid1) ;
cbd576a6 200
201 Int_t relid2[4] ;
9a2cdbdf 202 fGeom->AbsToRelNumbering(d2->GetId(), relid2) ;
cbd576a6 203
204 if ( (relid1[0] == relid2[0]) && (relid1[1]==relid2[1]) ) { // inside the same PHOS module and the same PPSD Module
205 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
206 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
207
208 if ( ( (coldiff < 1) && (rowdiff <= 1) ) || ( ( coldiff <= 1 ) && ( rowdiff < 1 ) ) ){
209 rv = 1 ;
210 }
211 else {
212 if((relid2[2] > relid1[2]) && (relid2[3] > relid1[3]+1))
213 rv = 2; // Difference in row numbers is too large to look further
214 }
215
216 }
217 else {
218
219 if( (relid1[0] < relid2[0]) || (relid1[1] < relid2[1]) )
220 rv=2 ;
221
222 }
223
cbd576a6 224 return rv ;
225
226}