source: trunk/Mars/mmc/MMcEvtBasic.cc@ 13642

Last change on this file since 13642 was 9596, checked in by tbretz, 14 years ago
*** empty log message ***
File size: 6.7 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Abelardo Moralejo, 02/2005 <mailto:moralejo@pd.infn.it>
19!
20! Copyright: MAGIC Software Development, 2000-2005
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MMcEvtBasic
28//
29// This class contains the most basic MonteCarlo information
30// with which an event has been generated
31//
32// Note: The azimuth fTelescopePhi angle in this and other MC classes
33// follow the convention in the Corsika program (see Corsika manual and
34// TDAS 02-11). There, phi is the azimuth of the momentum vector of
35// particles, and is measured from the north direction, anticlockwise
36// (i.e, west is phi=90 degrees). When it refers to the telescope
37// orientation, it is the azimuth of a vector along the telescope axis,
38// going from the camera to the mirror. So, fTelescopeTheta=90,
39// fTelescopePhi = 0 means the telescope is pointing horizontally towards
40// South.
41//
42//
43// Version 1:
44// New container to keep the very basic informations on the
45// original MC events produced by Corsika
46//
47// Version 2:
48// - added typedef for ParticleId_t from MMcEvt
49// - replaced MMcEvt::ParticleId_t by ParticleId_t
50//
51// Version 3:
52// - moved fPhi from MMcEvt
53// - moved fTheta from MmcEvt
54//
55/////////////////////////////////////////////////////////////////////////////
56#include "MMcEvtBasic.h"
57
58#include "MString.h"
59
60#include "MLog.h"
61#include "MLogManip.h"
62
63ClassImp(MMcEvtBasic);
64
65using namespace std;
66
67// --------------------------------------------------------------------------
68//
69// Default constructor. Calls Clear()
70//
71MMcEvtBasic::MMcEvtBasic()
72{
73 fName = "MMcEvtBasic";
74 fTitle = "Basic event info from Monte Carlo";
75
76 Clear();
77}
78
79// --------------------------------------------------------------------------
80//
81// Constructor. Use this to set all data members
82//
83// THIS FUNCTION IS FOR THE SIMULATION OLNY.
84// DON'T USE THIS MEMBERFUNCTION IN THE ANALYSIS.
85//
86MMcEvtBasic::MMcEvtBasic(ParticleId_t usPId, Float_t fEner,
87 Float_t fImpa, Float_t fTPhii, Float_t fTThet)
88 : fPartId(usPId), fEnergy(fEner), fImpact(fImpa),
89 fTelescopePhi(fTPhii), fTelescopeTheta(fTThet), fTheta(0), fPhi(0)
90{
91 fName = "MMcEvtBasic";
92 fTitle = "Basic event info from Monte Carlo";
93}
94
95// --------------------------------------------------------------------------
96//
97// Copy operator. Copy all data members
98//
99void MMcEvtBasic::operator=(const MMcEvtBasic &evt)
100{
101 fPartId = evt.fPartId;
102 fEnergy = evt.fEnergy;
103 fImpact = evt.fImpact;
104 fTelescopePhi = evt.fTelescopePhi;
105 fTelescopeTheta = evt.fTelescopeTheta;
106 fPhi = evt.fPhi;
107 fTheta = evt.fTheta;
108}
109
110// --------------------------------------------------------------------------
111//
112// Reset all values.
113//
114void MMcEvtBasic::Clear(Option_t *opt)
115{
116 fPartId = kUNDEFINED;
117
118 fEnergy = -1;
119 fImpact = -1;
120
121 fTelescopePhi = 0;
122 fTelescopeTheta = 0;
123
124 fTheta = 0;
125 fPhi = 0;
126}
127
128// --------------------------------------------------------------------------
129//
130// Fill all data members
131//
132void MMcEvtBasic::Fill(ParticleId_t usPId, Float_t fEner,
133 Float_t fImpa, Float_t fTPhii, Float_t fTThet)
134{
135 fPartId = usPId;
136
137 fEnergy = fEner;
138 fImpact = fImpa;
139
140 fTelescopePhi = fTPhii;
141 fTelescopeTheta = fTThet;
142}
143
144TString MMcEvtBasic::GetParticleName(Int_t id)
145{
146 switch (id)
147 {
148 case kUNDEFINED: return "Undefined";
149 case kGAMMA: return "Gamma";
150 case kPOSITRON: return "Positron";
151 case kELECTRON: return "Electron";
152 case kANTIMUON: return "Anti-Muon";
153 case kMUON: return "Muon";
154 case kPI0: return "Pi-0";
155 case kNEUTRON: return "Neutron";
156 case kPROTON: return "Proton";
157 case kHELIUM: return "Helium";
158 case kOXYGEN: return "Oxygen";
159 case kIRON: return "Iron";
160 case kArtificial: return "Artificial";
161 case kNightSky: return "NightSky";
162 }
163
164 return MString::Format("Id:%d", id);
165}
166
167TString MMcEvtBasic::GetParticleSymbol(Int_t id)
168{
169 switch (id)
170 {
171 case kUNDEFINED:return "N/A";
172 case kGAMMA: return "\\gamma";
173 case kPOSITRON: return "e^{+}";
174 case kELECTRON: return "e^{-}";
175 case kANTIMUON: return "\\mu^{+}";
176 case kMUON: return "\\mu^{-}";
177 case kPI0: return "\\pi^{0}";
178 case kNEUTRON: return "n";
179 case kPROTON: return "p";
180 case kHELIUM: return "He";
181 case kOXYGEN: return "O";
182 case kIRON: return "Fe";
183 case kNightSky: return "\\gamma_{NSB}";
184 }
185
186 return MString::Format("Id:%d", id);
187}
188
189TString MMcEvtBasic::GetEnergyStr(Float_t e)
190{
191 if (e>=1000)
192 return MString::Format("%.1fTeV", e/1000);
193
194 if (e>=10)
195 return MString::Format("%dGeV", (Int_t)(e+.5));
196
197 if (e>=1)
198 return MString::Format("%.1fGeV", e);
199
200 return MString::Format("%dMeV", (Int_t)(e*1000+.5));
201}
202
203
204// --------------------------------------------------------------------------
205//
206// Print the contents of the container.
207//
208// if you specify an option only the requested data members are printed:
209// allowed options are: id, energy, impact
210//
211void MMcEvtBasic::Print(Option_t *opt) const
212{
213 //
214 // print out the data member on screen
215 //
216 TString str(opt);
217 if (str.IsNull())
218 {
219 *fLog << all << endl;
220 *fLog << "Monte Carlo output:" << endl;
221 *fLog << " Particle Id: " << GetParticleName() << endl;
222 *fLog << " Energy: " << fEnergy << "GeV" << endl;
223 *fLog << " Impactparam.: " << fImpact/100 << "m" << endl;
224 *fLog << endl;
225 return;
226 }
227 if (str.Contains("id", TString::kIgnoreCase))
228 *fLog << "Particle: " << GetParticleName() << endl;
229 if (str.Contains("energy", TString::kIgnoreCase))
230 *fLog << "Energy: " << fEnergy << "GeV" << endl;
231 if (str.Contains("impact", TString::kIgnoreCase))
232 *fLog << "Impact: " << fImpact << "cm" << endl;
233}
Note: See TracBrowser for help on using the repository browser.