Fix Coverity
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALHit.cxx
CommitLineData
fdebddeb 1 /**************************************************************************
b13bbe81 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 EMCAL
19a2fe5a 20// A hit in EMCAL is the sum of all hits in a tower
21// from a single entering particle
b13bbe81 22//*-- Author: Sahal Yacoob (LBL / UCT)
23// Based on AliPHOSHit
24
25// --- Standard library ---
70479d0e 26#include <Riostream.h>
b13bbe81 27
28// --- ROOT system ---
b13bbe81 29
30// --- AliRoot header files ---
31#include "AliEMCALHit.h"
b13bbe81 32
33ClassImp(AliEMCALHit)
34
35//______________________________________________________________________
18a21c7c 36AliEMCALHit::AliEMCALHit()
37 : fId(0),
38 fELOS(0.),
39 fPrimary(0),
40 fPx(0.),
41 fPy(0.),
42 fPz(0.),
43 fPe(0.),
44 fIparent(0),
45 fIenergy(0.),
46 fTime(0.)
47{
b13bbe81 48 // Default ctor
b13bbe81 49}
18a21c7c 50
b13bbe81 51//______________________________________________________________________
18a21c7c 52AliEMCALHit::AliEMCALHit(const AliEMCALHit & hit)
53 : AliHit(hit),
54 fId(hit.fId),
55 fELOS(hit.fELOS),
56 fPrimary(hit.fPrimary),
57 fPx(hit.fPx),
58 fPy(hit.fPy),
59 fPz(hit.fPz),
60 fPe(hit.fPe),
61 fIparent(hit.fIparent),
62 fIenergy(hit.fIenergy),
63 fTime(hit.fTime)
64{
b13bbe81 65 // copy ctor
b13bbe81 66}
f1d9131f 67//_____________________________________________________________________
68AliEMCALHit& AliEMCALHit::operator = (const AliEMCALHit &source)
69{ // assignment operator; use copy ctor
70 if (&source == this) return *this;
18a21c7c 71
f1d9131f 72 new (this) AliEMCALHit(source);
73 return *this;
74}
b13bbe81 75//______________________________________________________________________
61e0abb5 76AliEMCALHit::AliEMCALHit(Int_t shunt, Int_t primary, Int_t track,Int_t iparent, Float_t ienergy, Int_t id,
18a21c7c 77 Float_t *hits,Float_t *p)
78 : AliHit(shunt, track),
79 fId(id),
80 fELOS(0.),
81 fPrimary(primary),
82 fPx(0.),
83 fPy(0.),
84 fPz(0.),
85 fPe(0.),
86 fIparent(iparent),
87 fIenergy(ienergy),
88 fTime(0.)
89{
b13bbe81 90 //
ffa6d63b 91 // Create an EMCAL hit object
b13bbe81 92 //
b13bbe81 93 fX = hits[0];
94 fY = hits[1];
95 fZ = hits[2];
773f6f3f 96 fTime = hits[3] ;
773f6f3f 97 fELOS = hits[4];
61e0abb5 98 fPx = p[0];
99 fPy = p[1];
100 fPz = p[2];
101 fPe = p[3];
b13bbe81 102}
4c35d512 103
104//______________________________________________________________________
b13bbe81 105Bool_t AliEMCALHit::operator==(AliEMCALHit const &rValue) const{
106 // Two hits are identical if they have the same Id and originat
ffa6d63b 107 // from the same enterring Particle
b13bbe81 108 Bool_t rv = kFALSE;
109
fdebddeb 110 if ( (fId == rValue.GetId()) && ( fIparent == rValue.GetIparent()))
b13bbe81 111 rv = kTRUE;
112
113 return rv;
114}
115//______________________________________________________________________
116AliEMCALHit AliEMCALHit::operator+(const AliEMCALHit &rValue){
117 // Add the energy of the hit
118
119 fELOS += rValue.GetEnergy() ;
773f6f3f 120
121 if(rValue.GetTime() < fTime)
122 fTime = rValue.GetTime() ;
123
b13bbe81 124 return *this;
125
126}
127//______________________________________________________________________
128ostream& operator << (ostream& out,AliEMCALHit& hit){
129 // Print out Id and energy
130
131 out << "AliEMCALHit:";
132 out << "id=" << hit.GetId();
133 out << ", Eloss=" << hit.GetEnergy();
773f6f3f 134 out << ", Time=" << hit.GetTime();
b13bbe81 135 out << "GeV , Track no.=" << hit.GetPrimary();
136 out << ", (xyz)=(" << hit.X()<< ","<< hit.Y()<< ","<<hit.Z()<<") cm";
137 out << ", fTrack=" << hit.GetTrack();
61e0abb5 138 out << ", P=(" << hit.GetPx() << "," << hit.GetPy() << "," << hit.GetPz()
139 << "," <<hit.GetPe() << ") GeV" ;
140 out << ", Enterring particle ID" << hit.GetIparent();
141 out << ", Enterring particle initial energy = " << hit.GetIenergy() << " GeV" ;
b13bbe81 142 out << endl;
143
144 return out;
145}