Redundant Print removed
[u/mrichter/AliRoot.git] / PHOS / AliPHOSCpvRecPoint.cxx
CommitLineData
458282ff 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/* $Id$ */
17
702ab87e 18/* History of cvs commits:
19 *
20 * $Log$
91daaf24 21 * Revision 1.24 2006/08/28 10:01:56 kharlov
22 * Effective C++ warnings fixed (Timur Pocheptsov)
23 *
3663622c 24 * Revision 1.23 2005/12/20 14:28:47 hristov
25 * Additional protection
26 *
f33a3764 27 * Revision 1.22 2005/05/28 14:19:04 schutz
28 * Compilation warnings fixed by T.P.
29 *
702ab87e 30 */
31
458282ff 32//_________________________________________________________________________
33// RecPoint implementation for PHOS-CPV
34// An CpvRecPoint is a cluster of digits
a3dfe79c 35//*-- Author: Yuri Kharlov
36// (after Dmitri Peressounko (RRC KI & SUBATECH))
37// 30 October 2000
458282ff 38
39// --- ROOT system ---
e957fea8 40
458282ff 41#include "TMath.h"
b5241d61 42#include "TClonesArray.h"
458282ff 43
44// --- Standard library ---
45
458282ff 46// --- AliRoot header files ---
351dd634 47#include "AliLog.h"
e957fea8 48#include "AliPHOSGeometry.h"
49#include "AliPHOSDigit.h"
458282ff 50#include "AliPHOSCpvRecPoint.h"
88cb7938 51#include "AliPHOSLoader.h"
e957fea8 52
458282ff 53ClassImp(AliPHOSCpvRecPoint)
54
55//____________________________________________________________________________
3663622c 56AliPHOSCpvRecPoint::AliPHOSCpvRecPoint() :
57 AliPHOSEmcRecPoint(),
58 fLengX(-1),
59 fLengZ(-1)
458282ff 60{
61 // ctor
458282ff 62}
63
64//____________________________________________________________________________
3663622c 65AliPHOSCpvRecPoint::AliPHOSCpvRecPoint(const char * opt) :
66 AliPHOSEmcRecPoint(opt),
67 fLengX(-1),
68 fLengZ(-1)
73a68ccb 69{
70 // ctor
3663622c 71}
73a68ccb 72
73//____________________________________________________________________________
458282ff 74AliPHOSCpvRecPoint::~AliPHOSCpvRecPoint()
75{
76 // dtor
458282ff 77}
78
458282ff 79//____________________________________________________________________________
ad8cfaf4 80Bool_t AliPHOSCpvRecPoint::AreNeighbours(AliPHOSDigit * digit1, AliPHOSDigit * digit2 ) const
458282ff 81{
82 // Tells if (true) or not (false) two digits are neighbors)
83
84 Bool_t aren = kFALSE ;
85
88cb7938 86 AliPHOSGeometry * phosgeom = AliPHOSLoader::GetPHOSGeometry();
ed652fe0 87
458282ff 88 Int_t relid1[4] ;
89 phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ;
90
91 Int_t relid2[4] ;
92 phosgeom->AbsToRelNumbering(digit2->GetId(), relid2) ;
93
94 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
95 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
96
97 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
98 aren = kTRUE ;
99
100 return aren ;
101}
102
103//____________________________________________________________________________
2a941f4e 104Int_t AliPHOSCpvRecPoint::Compare(const TObject * obj) const
458282ff 105{
106 // Compares two RecPoints according to their position in the PHOS modules
107
b5241d61 108 Float_t delta = 1 ; //Width of "Sorting row". If you changibg this
109 //value (what is senseless) change as vell delta in
110 //AliPHOSTrackSegmentMakerv* and other RecPoints...
111
458282ff 112 Int_t rv ;
113
9688c1dd 114 AliPHOSCpvRecPoint * clu = (AliPHOSCpvRecPoint *) obj ;
115
116 Int_t phosmod1 = GetPHOSMod() ;
117 Int_t phosmod2 = clu->GetPHOSMod() ;
118
119 TVector3 locpos1;
120 GetLocalPosition(locpos1) ;
121 TVector3 locpos2;
122 clu->GetLocalPosition(locpos2) ;
123
124 if(phosmod1 == phosmod2 ) {
125 Int_t rowdif = (Int_t)TMath::Ceil(locpos1.X()/delta)-(Int_t)TMath::Ceil(locpos2.X()/delta) ;
126 if (rowdif> 0)
127 rv = 1 ;
128 else if(rowdif < 0)
129 rv = -1 ;
130 else if(locpos1.Z()>locpos2.Z())
131 rv = -1 ;
132 else
133 rv = 1 ;
134 }
135
136 else {
137 if(phosmod1 < phosmod2 )
138 rv = -1 ;
139 else
140 rv = 1 ;
141 }
142
143 return rv ;
144
458282ff 145}
146
147//______________________________________________________________________________
702ab87e 148void AliPHOSCpvRecPoint::ExecuteEvent(Int_t, Int_t, Int_t ) /*const*/
458282ff 149{
b5241d61 150// // Execute action corresponding to one event
151// // This member function is called when a AliPHOSRecPoint is clicked with the locator
152// //
153// // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
154// // and switched off when the mouse button is released.
155// //
458282ff 156
b5241d61 157// // static Int_t pxold, pyold;
458282ff 158
88cb7938 159// AliPHOSLoader * gime = AliPHOSLoader::GetInstance() ;
458282ff 160
b5241d61 161// static TGraph * digitgraph = 0 ;
458282ff 162
b5241d61 163// if (!gPad->IsEditable()) return;
458282ff 164
b5241d61 165// TH2F * histo = 0 ;
166// TCanvas * histocanvas ;
458282ff 167
b5241d61 168// switch (event) {
458282ff 169
b5241d61 170// case kButton1Down: {
171// AliPHOSDigit * digit ;
172// AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
173// Int_t iDigit;
174// Int_t relid[4] ;
458282ff 175
b5241d61 176// const Int_t kMulDigit = AliPHOSCpvRecPoint::GetDigitsMultiplicity() ;
177// Float_t * xi = new Float_t[kMulDigit] ;
178// Float_t * zi = new Float_t[kMulDigit] ;
458282ff 179
b5241d61 180// // create the histogram for the single cluster
181// // 1. gets histogram boundaries
182// Float_t ximax = -999. ;
183// Float_t zimax = -999. ;
184// Float_t ximin = 999. ;
185// Float_t zimin = 999. ;
458282ff 186
b5241d61 187// for(iDigit=0; iDigit<kMulDigit; iDigit++) {
7b7c1533 188// digit = (AliPHOSDigit *) ( gime->Digit(fDigitsList[iDigit]) ) ;
b5241d61 189// phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
190// phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
191// if ( xi[iDigit] > ximax )
192// ximax = xi[iDigit] ;
193// if ( xi[iDigit] < ximin )
194// ximin = xi[iDigit] ;
195// if ( zi[iDigit] > zimax )
196// zimax = zi[iDigit] ;
197// if ( zi[iDigit] < zimin )
198// zimin = zi[iDigit] ;
199// }
200// ximax += phosgeom->GetCrystalSize(0) / 2. ;
201// zimax += phosgeom->GetCrystalSize(2) / 2. ;
202// ximin -= phosgeom->GetCrystalSize(0) / 2. ;
203// zimin -= phosgeom->GetCrystalSize(2) / 2. ;
204// Int_t xdim = (int)( (ximax - ximin ) / phosgeom->GetCrystalSize(0) + 0.5 ) ;
205// Int_t zdim = (int)( (zimax - zimin ) / phosgeom->GetCrystalSize(2) + 0.5 ) ;
458282ff 206
b5241d61 207// // 2. gets the histogram title
458282ff 208
b5241d61 209// Text_t title[100] ;
210// sprintf(title,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
458282ff 211
b5241d61 212// if (!histo) {
213// delete histo ;
214// histo = 0 ;
215// }
216// histo = new TH2F("cluster3D", title, xdim, ximin, ximax, zdim, zimin, zimax) ;
458282ff 217
b5241d61 218// Float_t x, z ;
219// for(iDigit=0; iDigit<kMulDigit; iDigit++) {
7b7c1533 220// digit = (AliPHOSDigit *) ( gime->Digit(fDigitsList[iDigit]) ) ;
b5241d61 221// phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
222// phosgeom->RelPosInModule(relid, x, z);
223// histo->Fill(x, z, fEnergyList[iDigit] ) ;
224// }
458282ff 225
b5241d61 226// if (!digitgraph) {
227// digitgraph = new TGraph(kMulDigit,xi,zi);
228// digitgraph-> SetMarkerStyle(5) ;
229// digitgraph-> SetMarkerSize(1.) ;
230// digitgraph-> SetMarkerColor(1) ;
231// digitgraph-> Paint("P") ;
232// }
458282ff 233
b5241d61 234// Print() ;
235// histocanvas = new TCanvas("cluser", "a single cluster", 600, 500) ;
236// histocanvas->Draw() ;
237// histo->Draw("lego1") ;
458282ff 238
b5241d61 239// delete[] xi ;
240// delete[] zi ;
458282ff 241
b5241d61 242// break;
243// }
458282ff 244
b5241d61 245// case kButton1Up:
246// if (digitgraph) {
247// delete digitgraph ;
248// digitgraph = 0 ;
249// }
250// break;
458282ff 251
b5241d61 252// }
458282ff 253}
254
255//____________________________________________________________________________
91daaf24 256void AliPHOSCpvRecPoint::EvalAll(Float_t logWeight, TClonesArray * digits)
a4e98857 257{
b5241d61 258 AliPHOSEmcRecPoint::EvalAll(logWeight,digits) ;
259 EvalClusterLengths(digits) ;
ad8cfaf4 260}
261//____________________________________________________________________________
91daaf24 262void AliPHOSCpvRecPoint::EvalAll(Float_t logWeight, TVector3 &vtx, TClonesArray * digits)
263{
264 // wraps other methods
265 AliPHOSEmcRecPoint::EvalAll(logWeight,vtx,digits) ;
266}
267//____________________________________________________________________________
268void AliPHOSCpvRecPoint::EvalLocalPosition(Float_t logWeight, TVector3 & /*vtx */, TClonesArray * digits)
ad8cfaf4 269{
270 // Calculates the center of gravity in the local PHOS-module coordinates
271
ad8cfaf4 272 Float_t wtot = 0. ;
273
274 Int_t relid[4] ;
275
276 Float_t x = 0. ;
277 Float_t z = 0. ;
278
279 AliPHOSDigit * digit ;
280
88cb7938 281 AliPHOSGeometry * phosgeom = AliPHOSLoader::GetPHOSGeometry();
282
ad8cfaf4 283 Int_t iDigit;
284
285 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
b5241d61 286 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]);
ad8cfaf4 287
288 Float_t xi ;
289 Float_t zi ;
290 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
291 phosgeom->RelPosInModule(relid, xi, zi);
f33a3764 292 if (fAmp>0 && fEnergyList[iDigit]>0) {
293 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
294 x += xi * w ;
295 z += zi * w ;
296 wtot += w ;
297 }
298 else
299 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
ad8cfaf4 300 }
301
302 if (wtot != 0) {
303 x /= wtot ;
304 z /= wtot ;
305 } else {
306 x = -1e6 ;
307 z = -1e6 ;
21cd0c07 308 if (fMulDigit != 0)
351dd634 309 AliWarning(Form("Too low log weight factor to evaluate cluster's center" )) ;
ad8cfaf4 310 }
311 fLocPos.SetX(x) ;
312 fLocPos.SetY(0.) ;
313 fLocPos.SetZ(z) ;
0d6c7a69 314 fLocPosM = 0 ;
ad8cfaf4 315
316}
317
318//____________________________________________________________________________
b5241d61 319void AliPHOSCpvRecPoint::EvalClusterLengths(TClonesArray * digits)
458282ff 320{
b5241d61 321 //Modified 15.03.2001 by Dmitri Peressounko
458282ff 322
458282ff 323 // Calculates the cluster lengths along X and Z axes
324 // These characteristics are needed for CPV to tune
325 // digitization+reconstruction to experimental data
326 // Yuri Kharlov. 24 October 2000
327
458282ff 328 Int_t relid[4] ;
329
330 AliPHOSDigit * digit ;
331
88cb7938 332 AliPHOSGeometry * phosgeom = AliPHOSLoader::GetPHOSGeometry();
458282ff 333
a3dfe79c 334 const Int_t kMaxLeng=20;
335 Int_t idX[kMaxLeng], idZ[kMaxLeng];
b5241d61 336 fLengX = 0;
337 fLengZ = 0;
458282ff 338 Bool_t dejavu;
339
340 for(Int_t iDigit=0; iDigit<fMulDigit; iDigit++) {
b5241d61 341 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
458282ff 342 Int_t absId = digit->GetId();
343 phosgeom->AbsToRelNumbering(absId, relid) ;
344
cd461ab8 345 Int_t i;
458282ff 346 dejavu=kFALSE;
b5241d61 347 for (i=0; i<fLengX; i++) if (relid[2]==idX[i]) { dejavu=kTRUE; break; }
458282ff 348 if (!dejavu) {
b5241d61 349 idX[fLengX]=relid[2];
350 fLengX++;
351 fLengX = TMath::Min(fLengX,kMaxLeng);
458282ff 352 }
353
354 dejavu=kFALSE;
b5241d61 355 for (i=0; i<fLengZ; i++) if (relid[3]==idZ[i]) { dejavu=kTRUE; break; }
458282ff 356 if (!dejavu) {
b5241d61 357 idZ[fLengZ]=relid[3];
358 fLengZ++;
359 fLengZ = TMath::Min(fLengZ,kMaxLeng);
458282ff 360 }
361 }
458282ff 362}
363
458282ff 364//____________________________________________________________________________
702ab87e 365void AliPHOSCpvRecPoint::Print(const Option_t *) const
458282ff 366{
367 // Print the list of digits belonging to the cluster
368
21cd0c07 369 TString message ;
370 message = "AliPHOSCpvRecPoint: " ;
371 message += "Digits # " ;
351dd634 372 AliInfo(Form(message.Data())) ;
21cd0c07 373
458282ff 374 Int_t iDigit;
458282ff 375
b5241d61 376 for(iDigit=0; iDigit<fMulDigit; iDigit++)
351dd634 377 printf(" %d \n", fDigitsList[iDigit]) ;
458282ff 378
351dd634 379 printf("Energies: \n") ;
b5241d61 380 for(iDigit=0; iDigit<fMulDigit; iDigit++)
351dd634 381 printf(" %f ", fEnergyList[iDigit]) ;
b5241d61 382
21cd0c07 383 message = " Multiplicity = %d\n" ;
384 message += " Cluster Energy = %f\n" ;
385 message += " Stored at position %d\n" ;
458282ff 386
351dd634 387 printf(message.Data(), fMulDigit, fAmp, GetIndexInList() ) ;
21cd0c07 388
458282ff 389}