]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSRecPoint.cxx
Minor changes to the Digitizer procedure
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRecPoint.cxx
CommitLineData
d15a28e7 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 **************************************************************************/
b2a60966 15/* $Id$ */
d15a28e7 16//_________________________________________________________________________
b2a60966 17// Base Class for PHOS Reconstructed Points
2f04ed65 18// Why should I put meaningless comments
19// just to satisfy
20// the code checker
b2a60966 21//*-- Author: Gines Martinez (SUBATECH)
d15a28e7 22
23// --- ROOT system ---
9f616d61 24#include "TPad.h"
2731cd1e 25#include "TClonesArray.h"
d15a28e7 26
27// --- Standard library ---
de9ec31b 28#include <iostream.h>
29#include <stdio.h>
d15a28e7 30
31// --- AliRoot header files ---
32
33#include "AliPHOSGeometry.h"
34#include "AliPHOSDigit.h"
35#include "AliPHOSRecPoint.h"
7b7c1533 36#include "AliPHOSGetter.h"
9f616d61 37
d15a28e7 38ClassImp(AliPHOSRecPoint)
39
40
41//____________________________________________________________________________
42AliPHOSRecPoint::AliPHOSRecPoint()
43 : AliRecPoint()
44{
b2a60966 45 // ctor
46
baef0810 47 fMaxTrack = 200 ;
d15a28e7 48 fPHOSMod = 0;
7b7c1533 49 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
50 fGeom = (AliPHOSGeometry*)gime->PHOSGeometry();
d15a28e7 51}
52
9f616d61 53//____________________________________________________________________________
54Int_t AliPHOSRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
55{
b2a60966 56 // Compute distance from point px,py to a AliPHOSRecPoint considered as a Tmarker
57 // Compute the closest distance of approach from point px,py to this marker.
58 // The distance is computed in pixels units.
59
60 TVector3 pos(0.,0.,0.) ;
61 GetLocalPosition( pos) ;
62 Float_t x = pos.X() ;
63 Float_t y = pos.Z() ;
64 const Int_t kMaxDiff = 10;
65 Int_t pxm = gPad->XtoAbsPixel(x);
66 Int_t pym = gPad->YtoAbsPixel(y);
67 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
68
69 if (dist > kMaxDiff) return 9999;
70 return dist;
9f616d61 71}
6ad0bfa0 72
9f616d61 73//___________________________________________________________________________
74 void AliPHOSRecPoint::Draw(Option_t *option)
75 {
6ad0bfa0 76 // Draw this AliPHOSRecPoint with its current attributes
77
78 AppendPad(option);
9f616d61 79 }
80
81//______________________________________________________________________________
82void AliPHOSRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py)
83{
6ad0bfa0 84 // Execute action corresponding to one event
85 // This member function is called when a AliPHOSRecPoint is clicked with the locator
86 //
87 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
88 // and switched off when the mouse button is released.
9f616d61 89
90 // static Int_t pxold, pyold;
91
b2a60966 92 static TGraph * digitgraph = 0 ;
93 static TPaveText* clustertext = 0 ;
94
95 if (!gPad->IsEditable()) return;
9f616d61 96
b2a60966 97 switch (event) {
98
99
100 case kButton1Down:{
101 AliPHOSDigit * digit ;
7b7c1533 102 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
103 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
104
b2a60966 105 Int_t iDigit;
106 Int_t relid[4] ;
31aa6d6c 107
88714635 108 const Int_t kMulDigit=AliPHOSRecPoint::GetDigitsMultiplicity() ;
109 Float_t * xi = new Float_t [kMulDigit] ;
110 Float_t * zi = new Float_t [kMulDigit] ;
b2a60966 111
88714635 112 for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
b2a60966 113 digit = (AliPHOSDigit *) fDigitsList[iDigit];
114 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
115 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]) ;
116 }
117
118 if (!digitgraph) {
119 digitgraph = new TGraph(fMulDigit,xi,zi);
120 digitgraph-> SetMarkerStyle(5) ;
121 digitgraph-> SetMarkerSize(1.) ;
122 digitgraph-> SetMarkerColor(1) ;
123 digitgraph-> Draw("P") ;
124 }
125 if (!clustertext) {
126
127 TVector3 pos(0.,0.,0.) ;
128 GetLocalPosition(pos) ;
129 clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
130 Text_t line1[40] ;
131 Text_t line2[40] ;
132 sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
133 sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
134 clustertext ->AddText(line1) ;
135 clustertext ->AddText(line2) ;
136 clustertext ->Draw("");
137 }
138 gPad->Update() ;
139 Print() ;
31aa6d6c 140 delete[] xi ;
141 delete[] zi ;
142 }
b2a60966 143
31aa6d6c 144break;
b2a60966 145
146 case kButton1Up:
147 if (digitgraph) {
148 delete digitgraph ;
149 digitgraph = 0 ;
150 }
151 if (clustertext) {
152 delete clustertext ;
153 clustertext = 0 ;
154 }
155
156 break;
157
9f616d61 158 }
9f616d61 159}
ad8cfaf4 160//____________________________________________________________________________
2731cd1e 161void AliPHOSRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits) {
ad8cfaf4 162 //evaluates (if necessary) all RecPoint data members
9f616d61 163
2731cd1e 164 EvalPrimaries(digits) ;
ad8cfaf4 165}
d15a28e7 166//____________________________________________________________________________
2731cd1e 167void AliPHOSRecPoint::EvalPHOSMod(AliPHOSDigit * digit)
b2a60966 168{
169 // Returns the PHOS module in which the RecPoint is found
83974468 170
2731cd1e 171 if( fPHOSMod == 0){
ad8cfaf4 172 Int_t relid[4] ;
83974468 173
7b7c1533 174 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
175 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
d15a28e7 176
92862013 177 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
d15a28e7 178 fPHOSMod = relid[0];
2731cd1e 179 }
d15a28e7 180}
6ad0bfa0 181
cf239357 182//______________________________________________________________________________
2731cd1e 183void AliPHOSRecPoint::EvalPrimaries(TClonesArray * digits)
cf239357 184{
2731cd1e 185 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
b2a60966 186
cf239357 187 AliPHOSDigit * digit ;
2731cd1e 188 Int_t * tempo = new Int_t[fMaxTrack] ;
189
190 Int_t index ;
cf239357 191 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
2731cd1e 192 digit = (AliPHOSDigit *) digits->At( fDigitsList[index] ) ;
cf239357 193 Int_t nprimaries = digit->GetNprimary() ;
26d4b141 194 Int_t * newprimaryarray = new Int_t[nprimaries] ;
195 Int_t ii ;
196 for ( ii = 0 ; ii < nprimaries ; ii++)
197 newprimaryarray[ii] = digit->GetPrimary(ii+1) ;
2731cd1e 198
cf239357 199 Int_t jndex ;
200 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
2731cd1e 201 if ( fMulTrack > fMaxTrack ) {
202 fMulTrack = - 1 ;
203 cout << "AliPHOSRecPoint::GetNprimaries ERROR > increase fMaxTrack " << endl ;
cf239357 204 break ;
205 }
206 Int_t newprimary = newprimaryarray[jndex] ;
cf239357 207 Int_t kndex ;
208 Bool_t already = kFALSE ;
2731cd1e 209 for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored
cf239357 210 if ( newprimary == tempo[kndex] ){
211 already = kTRUE ;
212 break ;
213 }
214 } // end of check
b2a60966 215 if ( !already) { // store it
2731cd1e 216 tempo[fMulTrack] = newprimary ;
217 fMulTrack++ ;
cf239357 218 } // store it
219 } // all primaries in digit
26d4b141 220 delete newprimaryarray ;
cf239357 221 } // all digits
222
2731cd1e 223
224 fTracksList = new Int_t[fMulTrack] ;
225 for(index = 0; index < fMulTrack; index++)
226 fTracksList[index] = tempo[index] ;
227
228 delete tempo ;
229
cf239357 230}
231
9f616d61 232//______________________________________________________________________________
233void AliPHOSRecPoint::Paint(Option_t *)
234{
b2a60966 235 // Paint this ALiRecPoint as a TMarker with its current attributes
236
237 TVector3 pos(0.,0.,0.) ;
238 GetLocalPosition(pos) ;
239 Coord_t x = pos.X() ;
240 Coord_t y = pos.Z() ;
241 Color_t markercolor = 1 ;
242 Size_t markersize = 1. ;
243 Style_t markerstyle = 5 ;
244
245 if (!gPad->IsBatch()) {
246 gVirtualX->SetMarkerColor(markercolor) ;
247 gVirtualX->SetMarkerSize (markersize) ;
248 gVirtualX->SetMarkerStyle(markerstyle) ;
249 }
250 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
251 gPad->PaintPolyMarker(1,&x,&y,"") ;
9f616d61 252}