]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSHit.cxx
negative indexes allowed
[u/mrichter/AliRoot.git] / PHOS / AliPHOSHit.cxx
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 //  Hits class for PHOS     
20 //  A hit in PHOS is the sum of all hits in a single crystal
21 //*--
22 //*-- Author: Maxime Volkov (RRC KI) & Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
23
24 // --- ROOT system ---
25
26 // --- Standard library ---
27 #include <string.h>
28 #include <stdlib.h>
29
30 // --- AliRoot header files ---
31 #include "AliPHOSHit.h"
32 #include "AliRun.h"
33 #include "AliConst.h"
34 #include "AliPHOSLoader.h"
35 #include "AliPHOSGeometry.h"
36 #include "AliPHOS.h"
37
38 ClassImp(AliPHOSHit)
39   
40   //____________________________________________________________________________
41   AliPHOSHit::AliPHOSHit(const AliPHOSHit & hit) : AliHit(hit)
42 {
43   // copy ctor
44   fX       = hit.fX ; 
45   fY       = hit.fY ; 
46   fZ       = hit.fZ ; 
47   fId      = hit.fId ; 
48   fELOS    = hit.fELOS ;
49   fPrimary = hit.fPrimary ; 
50   fTrack   = hit.fTrack ; 
51   fTime    = hit.fTime  ;
52   
53
54
55 //____________________________________________________________________________
56 AliPHOSHit::AliPHOSHit(Int_t shunt, Int_t primary, Int_t track, Int_t id, Float_t *hits): AliHit(shunt, track)
57 {
58   //
59   // Create a CPV hit object
60   //
61   
62   fX          = hits[0] ;
63   fY          = hits[1] ;
64   fZ          = hits[2] ;
65   fTime       = hits[3] ;
66   fId         = id ;
67   fELOS       = hits[4] ;
68   fPrimary    = primary ;
69 }
70 //____________________________________________________________________________
71 Float_t AliPHOSHit::X() const
72 {
73   //  if(fX < -1000.){
74     TVector3  pos ;
75     AliPHOS * phos = static_cast<AliPHOS*> (gAlice->GetDetector("PHOS")) ;
76     phos->GetGeometry() ->RelPosInAlice(GetId(),  pos) ;
77     return pos.X() ;
78     //    fX = pos.X() ;
79     //    fY = pos.Y() ;
80     //    fZ = pos.Z() ;
81     //  }
82     //  return fX;
83 }
84 //____________________________________________________________________________
85 Float_t AliPHOSHit::Y() const
86 {
87   //  if(fY < -1000.){
88     TVector3  pos ;
89     AliPHOS * phos = static_cast<AliPHOS*> (gAlice->GetDetector("PHOS")) ;
90     phos->GetGeometry() ->RelPosInAlice(GetId(),  pos) ;
91     return pos.Y(); 
92     //    fX = pos.X() ;
93     //    fY = pos.Y() ;
94     //    fZ = pos.Z() ;
95     //  }
96     //  return fY;
97 }
98 //____________________________________________________________________________
99 Float_t AliPHOSHit::Z() const
100 {
101   //  if(fY < -1000.){
102     TVector3  pos ;
103     AliPHOS * phos = static_cast<AliPHOS*> (gAlice->GetDetector("PHOS")) ;
104     phos->GetGeometry() ->RelPosInAlice(GetId(),  pos) ;
105     return pos.Z() ;
106     //    fX = pos.X() ;
107     //    fY = pos.Y() ;
108     //    fZ = pos.Z() ;
109     //  }
110     //  return fZ;
111 }
112 //____________________________________________________________________________
113 Bool_t AliPHOSHit::operator==(AliPHOSHit const &rValue) const
114
115   // Two hits are identical if they have the same Id and originate from the same primary 
116
117   Bool_t rv = kFALSE ; 
118
119   if ( (fId == rValue.GetId()) && ( fPrimary == rValue.GetPrimary() ) )
120     rv = kTRUE;
121   
122   return rv;
123 }
124
125 //____________________________________________________________________________
126 AliPHOSHit AliPHOSHit::operator+(const AliPHOSHit &rValue)
127 {
128   // Add the energy of the hit
129   
130   fELOS += rValue.GetEnergy() ;
131
132   if(rValue.GetTime() < fTime)
133     fTime = rValue.GetTime() ;
134     
135    return *this;
136
137 }
138
139 //____________________________________________________________________________
140 // Commented out by Yu.Kharlov 4.09.2003
141 // ostream& operator << (ostream& out, const AliPHOSHit& hit) 
142 // {
143 //   // Print out Id and energy 
144   
145 //   //out << "AliPHOSHit = " << hit.GetId() << " " << hit.GetEnergy() << "  " << hit.GetTime() << endl ;
146 //   Warning("operator <<", "Implement differently") ; 
147 //   return out ;
148 // }
149
150
151