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