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