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