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