source: trunk/MagicSoft/include-Classes/MMcFormat/MMcEvtBasic.cc@ 9584

Last change on this file since 9584 was 9313, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 6.3 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/////////////////////////////////////////////////////////////////////////////
52#include "MMcEvtBasic.h"
53
54#include "MString.h"
55
56#include "MLog.h"
57#include "MLogManip.h"
58
59ClassImp(MMcEvtBasic);
60
61using namespace std;
62
63// --------------------------------------------------------------------------
64//
65// Default constructor. Calls Clear()
66//
67MMcEvtBasic::MMcEvtBasic()
68{
69 fName = "MMcEvtBasic";
70 fTitle = "Basic event info from Monte Carlo";
71
72 Clear();
73}
74
75// --------------------------------------------------------------------------
76//
77// Constructor. Use this to set all data members
78//
79// THIS FUNCTION IS FOR THE SIMULATION OLNY.
80// DON'T USE THIS MEMBERFUNCTION IN THE ANALYSIS.
81//
82MMcEvtBasic::MMcEvtBasic(ParticleId_t usPId, Float_t fEner,
83 Float_t fImpa, Float_t fTPhii, Float_t fTThet)
84{
85 fName = "MMcEvtBasic";
86 fTitle = "Basic event info from Monte Carlo";
87
88 Fill(usPId, fEner, fImpa, fTPhii, fTThet);
89}
90
91// --------------------------------------------------------------------------
92//
93// Copy operator. Copy all data members
94//
95void MMcEvtBasic::operator=(const MMcEvtBasic &evt)
96{
97 fPartId = evt.fPartId;
98 fEnergy = evt.fEnergy;
99 fImpact = evt.fImpact;
100 fTelescopePhi = evt.fTelescopePhi;
101 fTelescopeTheta = evt.fTelescopeTheta;
102}
103
104// --------------------------------------------------------------------------
105//
106// Reset all values: Fill(kUNDEFINED, -1, -1, 0, 0)
107//
108void MMcEvtBasic::Clear(Option_t *opt)
109{
110 Fill(kUNDEFINED, -1, -1, 0, 0);
111}
112
113// --------------------------------------------------------------------------
114//
115// Fill all data members
116//
117void MMcEvtBasic::Fill(ParticleId_t usPId, Float_t fEner,
118 Float_t fImpa, Float_t fTPhii, Float_t fTThet)
119{
120 fPartId = usPId;
121
122 fEnergy = fEner;
123 fImpact = fImpa;
124
125 fTelescopePhi = fTPhii;
126 fTelescopeTheta = fTThet;
127}
128
129TString MMcEvtBasic::GetParticleName(Int_t id)
130{
131 switch (id)
132 {
133 case kUNDEFINED: return "Undefined";
134 case kGAMMA: return "Gamma";
135 case kPOSITRON: return "Positron";
136 case kELECTRON: return "Electron";
137 case kANTIMUON: return "Anti-Muon";
138 case kMUON: return "Muon";
139 case kPI0: return "Pi-0";
140 case kNEUTRON: return "Neutron";
141 case kPROTON: return "Proton";
142 case kHELIUM: return "Helium";
143 case kOXYGEN: return "Oxygen";
144 case kIRON: return "Iron";
145 case kArtificial: return "Artificial";
146 case kNightSky: return "NightSky";
147 }
148
149 return MString::Format("Id:%d", id);
150}
151
152TString MMcEvtBasic::GetParticleSymbol(Int_t id)
153{
154 switch (id)
155 {
156 case kUNDEFINED:return "N/A";
157 case kGAMMA: return "\\gamma";
158 case kPOSITRON: return "e^{+}";
159 case kELECTRON: return "e^{-}";
160 case kANTIMUON: return "\\mu^{+}";
161 case kMUON: return "\\mu^{-}";
162 case kPI0: return "\\pi^{0}";
163 case kNEUTRON: return "n";
164 case kPROTON: return "p";
165 case kHELIUM: return "He";
166 case kOXYGEN: return "O";
167 case kIRON: return "Fe";
168 case kNightSky: return "\\gamma_{NSB}";
169 }
170
171 return MString::Format("Id:%d", id);
172}
173
174TString MMcEvtBasic::GetEnergyStr(Float_t e)
175{
176 if (e>=1000)
177 return MString::Format("%.1fTeV", e/1000);
178
179 if (e>=10)
180 return MString::Format("%dGeV", (Int_t)(e+.5));
181
182 if (e>=1)
183 return MString::Format("%.1fGeV", e);
184
185 return MString::Format("%dMeV", (Int_t)(e*1000+.5));
186}
187
188
189// --------------------------------------------------------------------------
190//
191// Print the contents of the container.
192//
193// if you specify an option only the requested data members are printed:
194// allowed options are: id, energy, impact
195//
196void MMcEvtBasic::Print(Option_t *opt) const
197{
198 //
199 // print out the data member on screen
200 //
201 TString str(opt);
202 if (str.IsNull())
203 {
204 *fLog << all << endl;
205 *fLog << "Monte Carlo output:" << endl;
206 *fLog << " Particle Id: " << GetParticleName() << endl;
207 *fLog << " Energy: " << fEnergy << "GeV" << endl;
208 *fLog << " Impactparam.: " << fImpact/100 << "m" << endl;
209 *fLog << endl;
210 return;
211 }
212 if (str.Contains("id", TString::kIgnoreCase))
213 *fLog << "Particle: " << GetParticleName() << endl;
214 if (str.Contains("energy", TString::kIgnoreCase))
215 *fLog << "Energy: " << fEnergy << "GeV" << endl;
216 if (str.Contains("impact", TString::kIgnoreCase))
217 *fLog << "Impact: " << fImpact << "cm" << endl;
218}
Note: See TracBrowser for help on using the repository browser.