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