]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDHit.cxx
Coding conventions (Christian)
[u/mrichter/AliRoot.git] / FMD / AliFMDHit.cxx
1 /**************************************************************************
2  * Copyright(c) 2004, 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 /* $Id$ */
16 /** @file    AliFMDHit.cxx
17     @author  Christian Holm Christensen <cholm@nbi.dk>
18     @date    Mon Mar 27 12:41:58 2006
19     @brief   Hit in the FMD
20     @ingroup FMD_sim
21 */
22 //____________________________________________________________________
23 //
24 //  Hits in the FMD 
25 //  Contains information on:
26 //      Position of hit
27 //      Momentum of track
28 //      PID of track
29 //      Energy loss of track
30 //      Track #
31 //      Track path length
32 //      Track stopping status. 
33 //  Latest changes by Christian Holm Christensen
34 //
35 #include "AliFMDHit.h"          // ALIFMDHIT_H
36 // #include "AliLog.h"          // ALILOG_H
37 #include "Riostream.h"          // ROOT_Riostream
38 #include <TDatabasePDG.h>
39 // #include <TMath.h>
40 #include <TString.h>
41
42 //____________________________________________________________________
43 ClassImp(AliFMDHit)
44 #if 0
45   ; // This is here to keep Emacs for indenting the next line
46 #endif
47
48
49 //____________________________________________________________________
50 AliFMDHit::AliFMDHit()
51   : fDetector(0), 
52     fRing(0), 
53     fSector(0), 
54     fStrip('\0'), 
55     fPx(0),
56     fPy(0),
57     fPz(0),
58     fPdg(0),
59     fEdep(0), 
60     fTime(0), 
61     fLength(0), 
62     fStop(0)
63 {
64   // Default CTOR
65   fX = fY = fZ = 0;
66 }
67   
68
69 //____________________________________________________________________
70 AliFMDHit::AliFMDHit(Int_t    shunt, 
71                      Int_t    track, 
72                      UShort_t detector, 
73                      Char_t   ring, 
74                      UShort_t sector, 
75                      UShort_t strip, 
76                      Float_t  x, 
77                      Float_t  y, 
78                      Float_t  z,
79                      Float_t  px, 
80                      Float_t  py, 
81                      Float_t  pz,
82                      Float_t  edep,
83                      Int_t    pdg,
84                      Float_t  t, 
85                      Float_t  l, 
86                      Bool_t   stop)
87   : AliHit(shunt, track),
88     fDetector(detector), 
89     fRing(ring), 
90     fSector(sector), 
91     fStrip(strip), 
92     fPx(px),
93     fPy(py),
94     fPz(pz),
95     fPdg(pdg),
96     fEdep(edep), 
97     fTime(t), 
98     fLength(l), 
99     fStop(stop)
100 {
101   // Normal FMD hit ctor
102   // 
103   // Parameters:
104   // 
105   //    shunt     ???
106   //    track     Track #
107   //    detector  Detector # (1, 2, or 3)                      
108   //    ring      Ring ID ('I' or 'O')
109   //    sector    Sector # (For inner/outer rings: 0-19/0-39)
110   //    strip     Strip # (For inner/outer rings: 0-511/0-255)
111   //    x         Track's X-coordinate at hit
112   //    y         Track's Y-coordinate at hit
113   //    z         Track's Z-coordinate at hit
114   //    px        X-component of track's momentum 
115   //    py        Y-component of track's momentum
116   //    pz        Z-component of track's momentum
117   //    edep      Energy deposited by track
118   //    pdg       Track's particle Id #
119   //    t         Time when the track hit 
120   // 
121   fX = x;
122   fY = y;
123   fZ = z;
124 }
125
126 //____________________________________________________________________
127 const char*
128 AliFMDHit::GetName() const 
129
130   // Get the name 
131   static TString n;
132   n = Form("FMD%d%c[%2d,%3d]", fDetector,fRing,fSector,fStrip);
133   return n.Data();
134 }
135
136 //____________________________________________________________________
137 const char*
138 AliFMDHit::GetTitle() const 
139
140   // Get the title 
141   static TString t;
142   TDatabasePDG* pdgDB = TDatabasePDG::Instance();
143   TParticlePDG* pdg   = pdgDB->GetParticle(fPdg);
144   t = Form("%s (%d): %f MeV / %f cm", (pdg ? pdg->GetName() : "?"), 
145            fTrack, fEdep, fLength);
146   return t.Data();
147 }
148
149 //____________________________________________________________________
150 Float_t
151 AliFMDHit::P() const 
152 {
153   // Get the momentum of the particle of the particle that made this
154   // hit. 
155   return TMath::Sqrt(fPx * fPx + fPy * fPy + fPz * fPz);
156 }
157
158 //____________________________________________________________________
159 Float_t
160 AliFMDHit::M() const 
161 {
162   // Get the mass of the particle that made this hit. 
163   TDatabasePDG* pdgDB = TDatabasePDG::Instance();
164   TParticlePDG* pdg   = pdgDB->GetParticle(fPdg);
165   return (pdg ? pdg->Mass() : -1);
166 }
167
168 //____________________________________________________________________
169 Float_t
170 AliFMDHit::Q() const
171 {
172   // Get the charge of the particle that made this hit. 
173   TDatabasePDG* pdgDB = TDatabasePDG::Instance();
174   TParticlePDG* pdg   = pdgDB->GetParticle(fPdg);
175   return (pdg ? pdg->Charge() : 0);
176 }
177
178
179 //____________________________________________________________________
180 void
181 AliFMDHit::Print(Option_t* option) const 
182 {
183   // Print Hit to standard out 
184   cout << "AliFMDHit: FMD" 
185        << fDetector << fRing << "[" 
186        << setw(3) << fSector << ","
187        << setw(3) << fStrip << "] = " 
188        << fEdep << endl;
189   TString opt(option);
190   if (opt.Contains("D", TString::kIgnoreCase)) {
191     TDatabasePDG* pdgDB = TDatabasePDG::Instance();
192     TParticlePDG* pdg   = pdgDB->GetParticle(fPdg);
193     cout << "\tPDG:\t" << fPdg << " " << (pdg ? pdg->GetName() : "?") << "\n"
194          << "\tP:\t(" << fPx << "," << fPy << "," << fPz << ") "<<P() << "\n" 
195          << "\tX:\t" << fX << "," << fY << "," << fZ << "\n" 
196          << "\tTrack #:\t" << fTrack << "\tLength:\t" 
197          << fLength << "cm\t" << (IsStop() ? "stopped" : "") << std::endl;
198   }
199 }
200
201 //____________________________________________________________________
202 //
203 // EOF
204 //