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