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

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