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