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