]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONHit.cxx
Pre-allocate right amount of memory when used for de,manu storage (Laurent)
[u/mrichter/AliRoot.git] / MUON / AliMUONHit.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 // MUON class for MonteCarlo Hits, inherited from AliHit for the 
19 // In addition to the ALiHit data member fX, fY, fZ and fTrack, AliMUONHit contains some info about the particle crossing the chamber:
20 // Impulsion: fPtot, fPx, fPy and fPz
21 // Reference position at the center of the chamber (wire plane) fXref, fYref and fZref
22 // Cumulated path along the active volume fTlength for spliting of hits for very inclined tracks 
23 // Energy loss of the particle inside the gas active volume.
24 // Incident fTheta and fPhi angle with respect of the wire plane of the chamber.
25 //
26
27 #include "AliMUONHit.h"
28 #include "AliMpDEManager.h"
29
30 #include "AliLog.h"
31
32 #include <Riostream.h>
33 #include <TMath.h>
34 #include <TString.h>
35
36 /// \cond CLASSIMP
37 ClassImp(AliMUONHit)
38 /// \endcond
39  
40 //___________________________________________
41 AliMUONHit::AliMUONHit()
42   : AliHit(), 
43     fDetElemId(0),
44     fParticle(0),
45     fTheta(0),
46     fPhi(0),
47     fTlength(0),
48     fEloss(0),
49     fAge(0),
50     fPHfirst(0),
51     fPHlast(0),
52     fPTot(0),
53     fPx(0),
54     fPy(0),
55     fPz(0),
56     fXref(0),
57     fYref(0),
58     fZref(0)
59 {
60 /// Default constructor
61 }
62
63 //___________________________________________
64 AliMUONHit::AliMUONHit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits)
65   : AliHit(shunt, track),
66     fDetElemId(vol[0]),
67     fParticle(hits[0]),
68     fTheta(hits[4]),
69     fPhi(hits[5]),
70     fTlength(hits[6]),
71     fEloss(hits[7]),
72     fAge(hits[14]),
73     fPHfirst((Int_t)hits[8]),
74     fPHlast((Int_t)hits[9]),
75     fPTot(hits[10]),
76     fPx(hits[11]),
77     fPy(hits[12]),
78     fPz(hits[13]),
79     fXref(0),
80     fYref(0),
81     fZref(0)
82 {
83 /// Constructor
84    
85     fX         = hits[1];
86     fY         = hits[2];
87     fZ         = hits[3];
88 }
89
90 //___________________________________________
91 AliMUONHit::AliMUONHit(Int_t shunt, Int_t track, Int_t detElemId, Int_t idpart, 
92                        Float_t X, Float_t Y, Float_t Z, Float_t tof, Float_t momentum, 
93                        Float_t theta, Float_t phi, Float_t length, Float_t destep)
94   : AliHit(shunt, track),
95     fDetElemId(detElemId),
96     fParticle(idpart),
97     fTheta(theta),
98     fPhi(phi),
99     fTlength(length),
100     fEloss(destep),
101     fAge(tof),
102     fPHfirst(0),
103     fPHlast(0),
104     fPTot(momentum),
105     fPx(momentum * TMath::Sin(theta) * TMath::Cos(phi)),
106     fPy(momentum * TMath::Sin(theta) * TMath::Sin(phi)),
107     fPz(momentum * TMath::Cos(theta)),
108     fXref(0),
109     fYref(0),
110     fZref(0)
111 {
112 /// Constructor
113     fX         = X;
114     fY         = Y;
115     fZ         = Z;
116 }
117
118 //-----------------------------------------------------------------------------------------------
119 AliMUONHit::AliMUONHit(Int_t shunt, Int_t track, Int_t detElemId, Int_t idpart, 
120                        Float_t X, Float_t Y, Float_t Z, Float_t tof, Float_t momentum, 
121                        Float_t theta, Float_t phi, Float_t length, Float_t destep,
122                        Float_t Xref,Float_t Yref,Float_t Zref)
123   : AliHit(shunt, track),
124     fDetElemId(detElemId),
125     fParticle(idpart),
126     fTheta(theta),
127     fPhi(phi),
128     fTlength(length),
129     fEloss(destep),
130     fAge(tof),
131     fPHfirst(0),
132     fPHlast(0),
133     fPTot(momentum),
134     fPx(momentum * TMath::Sin(theta) * TMath::Cos(phi)),
135     fPy(momentum * TMath::Sin(theta) * TMath::Sin(phi)),
136     fPz(momentum * TMath::Cos(theta)),
137     fXref(Xref),
138     fYref(Yref),
139     fZref(Zref)
140 {
141 /// Constructor
142
143     fX         = X;
144     fY         = Y;
145     fZ         = Z;
146 }
147
148 //-----------------------------------------------------------------------------------------------
149 AliMUONHit::~AliMUONHit()
150 {
151 /// Dectructor
152 }
153
154 //-----------------------------------------------------------------------------------------------
155 Int_t  AliMUONHit::Chamber()  const
156 {  
157 /// Return chamber ID
158
159   return AliMpDEManager::GetChamberId(fDetElemId) + 1;  
160 }
161
162 //-----------------------------------------------------------------------------------------------
163 void AliMUONHit::Print(Option_t* opt) const
164 {
165 /// Printing hit information 
166 /// "full" option for printing all the information about the hit
167
168   TString sopt(opt);
169   sopt.ToUpper();
170  
171   if ( sopt.Contains("FULL") ) { 
172     cout <<"<AliMUONHit>: Geant track="   << setw(4)  << Track() <<
173       ", DetEle="        << setw(4)  << DetElemId() <<  
174       ", (x,y,z)=(" << setw(7) << setprecision(5) << X() << "," << setw(7) << setprecision(5) << Y() <<  "," << setw(7) << setprecision(5) << Z() << 
175       " )cm, Delta E=" << setw(8) << setprecision(3) << Eloss() << " GeV" << endl;
176   }
177   else {
178     cout << "<AliMUONHit>: DetEle="        << setw(4)  << DetElemId() << 
179       ", (x,y,z)=(" << setw(7) << setprecision(5) << X() << "," << setw(7) << setprecision(5) << Y() <<  "," << setw(7) << setprecision(5) << Z() << 
180       " ) cm" <<endl;
181   }
182     
183 }