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):
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2007
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MMcEvt
|
---|
28 | //
|
---|
29 | // This class handles and contains the MonteCarlo information
|
---|
30 | // with which the events have been generated
|
---|
31 | // This information exists for each event.
|
---|
32 | //
|
---|
33 | // Note: All the azimuth Phi angles in this and other MC classes follow
|
---|
34 | // the convention in the Corsika program (see Corsika manual). There, phi
|
---|
35 | // is the azimuth of the momentum vector of particles, and is measured
|
---|
36 | // from the north direction, anticlockwise (i.e, west is phi=90 degrees).
|
---|
37 | // When it refers to the telescope orientation, it is the azimuth of a
|
---|
38 | // vector along the telescope axis, going from the camera to the mirror.
|
---|
39 | // So, fTelescopeTheta=90, fTelescopePhi = 0 means the telescope is
|
---|
40 | // pointing horizontally towards South. For an explanation, see also
|
---|
41 | // TDAS 02-11.
|
---|
42 | //
|
---|
43 | // Version 4:
|
---|
44 | // - Added member fFadcTimeJitter
|
---|
45 | //
|
---|
46 | // Version 5:
|
---|
47 | // - removed fPartId, fEnergy, fImpact, fTelescopeTheta, fTelescopePhi
|
---|
48 | // - derives now from MMcEvtBasic which contains all these values
|
---|
49 | // - moved ParticleId_t to base class MMcEvtBasic
|
---|
50 | //
|
---|
51 | // Version 6:
|
---|
52 | // - added fEventReuse
|
---|
53 | //
|
---|
54 | // Version 7:
|
---|
55 | // - moved fPhi to MMcEvtBasic
|
---|
56 | // - moved fTheta to MmcEvtBasic
|
---|
57 | //
|
---|
58 | // Version 8:
|
---|
59 | // - added fRunNumber
|
---|
60 | //
|
---|
61 | /////////////////////////////////////////////////////////////////////////////
|
---|
62 | #include "MMcEvt.hxx"
|
---|
63 |
|
---|
64 | #include "fits.h"
|
---|
65 |
|
---|
66 | #include <TMath.h>
|
---|
67 |
|
---|
68 | #include "MLog.h"
|
---|
69 | #include "MLogManip.h"
|
---|
70 |
|
---|
71 | #include "MString.h"
|
---|
72 |
|
---|
73 | ClassImp(MMcEvt);
|
---|
74 |
|
---|
75 | using namespace std;
|
---|
76 |
|
---|
77 | // --------------------------------------------------------------------------
|
---|
78 | //
|
---|
79 | // Default constructor. Calls Clear()
|
---|
80 | //
|
---|
81 | MMcEvt::MMcEvt()
|
---|
82 | {
|
---|
83 | fName = "MMcEvt";
|
---|
84 | fTitle = "Event info from Monte Carlo";
|
---|
85 |
|
---|
86 | Clear();
|
---|
87 | }
|
---|
88 |
|
---|
89 | // --------------------------------------------------------------------------
|
---|
90 | //
|
---|
91 | // Constructor. Use this to set all data members
|
---|
92 | //
|
---|
93 | // THIS FUNCTION IS FOR THE SIMULATION OLNY.
|
---|
94 | // DON'T USE THIS MEMBERFUNCTION IN THE ANALYSIS.
|
---|
95 | //
|
---|
96 | MMcEvt::MMcEvt(UInt_t fEvtNum, ParticleId_t usPId, Float_t fEner,
|
---|
97 | Float_t fThi0, Float_t fFirTar, Float_t fzFirInt,
|
---|
98 | Float_t fThet, Float_t fPhii, Float_t fCorD,
|
---|
99 | Float_t fCorX, Float_t fCorY, Float_t fImpa,
|
---|
100 | Float_t fTPhii, Float_t fTThet, Float_t fTFirst,
|
---|
101 | Float_t fTLast, Float_t fL_Nmax, Float_t fL_t0,
|
---|
102 | Float_t fL_tmax, Float_t fL_a, Float_t fL_b,
|
---|
103 | Float_t fL_c, Float_t fL_chi2, UInt_t uiPin,
|
---|
104 | UInt_t uiPat, UInt_t uiPre, UInt_t uiPco,
|
---|
105 | UInt_t uiPelS, UInt_t uiPelC, Float_t elec,
|
---|
106 | Float_t muon, Float_t other, Float_t fadc_jitter,
|
---|
107 | Int_t reuse) : fRunNumber(0)
|
---|
108 | {
|
---|
109 | fName = "MMcEvt";
|
---|
110 | fTitle = "Event info from Monte Carlo";
|
---|
111 |
|
---|
112 | Fill(fEvtNum, usPId, fEner, fThi0, fFirTar, fzFirInt, fThet,
|
---|
113 | fPhii, fCorD, fCorX, fCorY, fImpa, fTPhii, fTThet, fTFirst,
|
---|
114 | fTLast, fL_Nmax, fL_t0, fL_tmax, fL_a, fL_b, fL_c, fL_chi2,
|
---|
115 | uiPin, uiPat, uiPre, uiPco, uiPelS, uiPelC, elec, muon, other,
|
---|
116 | fadc_jitter, reuse);
|
---|
117 | }
|
---|
118 |
|
---|
119 | // --------------------------------------------------------------------------
|
---|
120 | //
|
---|
121 | // reset all values to values as nonsense as possible
|
---|
122 | //
|
---|
123 | void MMcEvt::Clear(Option_t *opt)
|
---|
124 | {
|
---|
125 | fPartId = kUNDEFINED;
|
---|
126 | fEnergy = -1;
|
---|
127 |
|
---|
128 | fCoreD = 0;
|
---|
129 | fCoreX = 0;
|
---|
130 | fCoreY = 0;
|
---|
131 | fImpact = -1;
|
---|
132 |
|
---|
133 | fPhotIni = 0;
|
---|
134 | fPassPhotAtm = 0;
|
---|
135 | fPassPhotRef = 0;
|
---|
136 | fPassPhotCone = 0;
|
---|
137 | fPhotElfromShower = 0;
|
---|
138 | fPhotElinCamera = 0;
|
---|
139 |
|
---|
140 | fElecCphFraction=0;
|
---|
141 | fMuonCphFraction=0;
|
---|
142 | fOtherCphFraction=0;
|
---|
143 |
|
---|
144 | fEventReuse = 0;
|
---|
145 | }
|
---|
146 |
|
---|
147 | // --------------------------------------------------------------------------
|
---|
148 | //
|
---|
149 | // Use this to set all data members
|
---|
150 | //
|
---|
151 | // THIS FUNCTION IS FOR THE SIMULATION OLNY.
|
---|
152 | // DON'T USE THIS MEMBERFUNCTION IN THE ANALYSIS.
|
---|
153 | //
|
---|
154 | void MMcEvt::Fill( UInt_t fEvtNum, ParticleId_t usPId, Float_t fEner,
|
---|
155 | Float_t fThi0, Float_t fFirTar, Float_t fzFirInt,
|
---|
156 | Float_t fThet, Float_t fPhii, Float_t fCorD,
|
---|
157 | Float_t fCorX, Float_t fCorY, Float_t fImpa,
|
---|
158 | Float_t fTPhii, Float_t fTThet, Float_t fTFirst,
|
---|
159 | Float_t fTLast, Float_t fL_Nmax, Float_t fL_t0,
|
---|
160 | Float_t fL_tmax, Float_t fL_a, Float_t fL_b,
|
---|
161 | Float_t fL_c, Float_t fL_chi2, UInt_t uiPin,
|
---|
162 | UInt_t uiPat, UInt_t uiPre, UInt_t uiPco,
|
---|
163 | UInt_t uiPelS, UInt_t uiPelC, Float_t elec,
|
---|
164 | Float_t muon, Float_t other, Float_t fadc_jitter,
|
---|
165 | Int_t reuse)
|
---|
166 | {
|
---|
167 | //
|
---|
168 | // All datamembers are filled with the correspondin parameters.
|
---|
169 | //
|
---|
170 | // Don't use this memberfunction in analysis
|
---|
171 | //
|
---|
172 | fEvtNumber = fEvtNum;
|
---|
173 | fPartId = usPId ;
|
---|
174 | fEnergy = fEner ;
|
---|
175 | fThick0 = fThi0;
|
---|
176 | fFirstTarget = fFirTar;
|
---|
177 | fZFirstInteraction = fzFirInt;
|
---|
178 |
|
---|
179 | fTheta = fThet ;
|
---|
180 | fPhi = fPhii ;
|
---|
181 |
|
---|
182 | fCoreD = fCorD ;
|
---|
183 | fCoreX = fCorX ;
|
---|
184 | fCoreY = fCorY ;
|
---|
185 | fImpact = fImpa ;
|
---|
186 |
|
---|
187 | fTelescopePhi = fTPhii;
|
---|
188 | fTelescopeTheta = fTThet;
|
---|
189 | fTimeFirst = fTFirst;
|
---|
190 | fTimeLast = fTLast;
|
---|
191 | fLongiNmax = fL_Nmax;
|
---|
192 | fLongit0 = fL_t0;
|
---|
193 | fLongitmax = fL_tmax;
|
---|
194 | fLongia = fL_a;
|
---|
195 | fLongib = fL_b;
|
---|
196 | fLongic = fL_c;
|
---|
197 | fLongichi2 = fL_chi2;
|
---|
198 |
|
---|
199 | fPhotIni = uiPin ;
|
---|
200 | fPassPhotAtm = fPhotIni-uiPat ;
|
---|
201 | fPassPhotRef = fPassPhotAtm-uiPre ;
|
---|
202 | fPassPhotCone = uiPco ;
|
---|
203 | fPhotElfromShower = uiPelS ;
|
---|
204 | fPhotElinCamera = uiPelC ;
|
---|
205 |
|
---|
206 | fElecCphFraction=elec;
|
---|
207 | fMuonCphFraction=muon;
|
---|
208 | fOtherCphFraction=other;
|
---|
209 |
|
---|
210 | fFadcTimeJitter = fadc_jitter;
|
---|
211 |
|
---|
212 | fEventReuse = reuse;
|
---|
213 | }
|
---|
214 |
|
---|
215 | // --------------------------------------------------------------------------
|
---|
216 | //
|
---|
217 | // Print the contents of the container.
|
---|
218 | //
|
---|
219 | // if you specify an option only the requested data members are printed:
|
---|
220 | // allowed options are:
|
---|
221 | // id, energy, impact
|
---|
222 | //
|
---|
223 | void MMcEvt::Print(Option_t *opt) const
|
---|
224 | {
|
---|
225 | MMcEvtBasic::Print(opt);
|
---|
226 |
|
---|
227 | TString str(opt);
|
---|
228 | if (str.IsNull())
|
---|
229 | *fLog << " Photoelectrons: " << fPhotElfromShower << endl;
|
---|
230 | }
|
---|
231 |
|
---|
232 | // --------------------------------------------------------------------------
|
---|
233 | //
|
---|
234 | // Return a proper description of the monte carlo event
|
---|
235 | //
|
---|
236 | TString MMcEvt::GetDescription(const TString &s) const
|
---|
237 | {
|
---|
238 | TString txt("#splitline{");
|
---|
239 |
|
---|
240 | txt += GetParticleName();
|
---|
241 | txt += " ";
|
---|
242 | txt += s;
|
---|
243 | txt += "}{ E=";
|
---|
244 | txt += GetEnergyStr();
|
---|
245 | txt += " r=";
|
---|
246 | txt += TMath::Nint(GetImpact()/100);
|
---|
247 | txt += "m Zd=";
|
---|
248 | txt += MString::Format("%.1f", GetTelescopeTheta()*TMath::RadToDeg());
|
---|
249 | txt += "\\circ ";
|
---|
250 | if (GetPhotElfromShower()>=10000)
|
---|
251 | txt += MString::Format("%dk", TMath::Nint(GetPhotElfromShower()/1000.));
|
---|
252 | else
|
---|
253 | if (GetPhotElfromShower()>=1000)
|
---|
254 | txt += MString::Format("%.1fk", GetPhotElfromShower()/1000.);
|
---|
255 | else
|
---|
256 | txt += GetPhotElfromShower();
|
---|
257 | txt += "PhEl}";
|
---|
258 |
|
---|
259 | return txt;
|
---|
260 | }
|
---|
261 |
|
---|
262 | Bool_t MMcEvt::SetupFits(fits &fin)
|
---|
263 | {
|
---|
264 | if (fName!="MMcEvt")
|
---|
265 | {
|
---|
266 | *fLog << err << "ERROR - SetupFits only supported if name equals MMcEvt." << endl;
|
---|
267 | return kFALSE;
|
---|
268 | }
|
---|
269 |
|
---|
270 | if (!fin.SetRefAddress("MMcEvt.fEvtNumber", fEvtNumber )) return kFALSE;
|
---|
271 | if (!fin.SetRefAddress("MMcEvt.fThick0", fThick0 )) return kFALSE;
|
---|
272 | if (!fin.SetRefAddress("MMcEvt.fFirstTarget", fFirstTarget )) return kFALSE;
|
---|
273 | if (!fin.SetRefAddress("MMcEvt.fZFirstInteraction", fZFirstInteraction)) return kFALSE;
|
---|
274 | if (!fin.SetRefAddress("MMcEvt.fCoreD", fCoreD )) return kFALSE;
|
---|
275 | if (!fin.SetRefAddress("MMcEvt.fCoreX", fCoreX )) return kFALSE;
|
---|
276 | if (!fin.SetRefAddress("MMcEvt.fCoreY", fCoreY )) return kFALSE;
|
---|
277 | if (!fin.SetRefAddress("MMcEvt.fTimeFirst", fTimeFirst )) return kFALSE;
|
---|
278 | if (!fin.SetRefAddress("MMcEvt.fTimeLast", fTimeLast )) return kFALSE;
|
---|
279 | if (!fin.SetRefAddress("MMcEvt.fLongiNmax", fLongiNmax )) return kFALSE;
|
---|
280 | if (!fin.SetRefAddress("MMcEvt.fLongit0", fLongit0 )) return kFALSE;
|
---|
281 | if (!fin.SetRefAddress("MMcEvt.fLongitmax", fLongitmax )) return kFALSE;
|
---|
282 | if (!fin.SetRefAddress("MMcEvt.fLongia", fLongia )) return kFALSE;
|
---|
283 | if (!fin.SetRefAddress("MMcEvt.fLongib", fLongib )) return kFALSE;
|
---|
284 | if (!fin.SetRefAddress("MMcEvt.fLongic", fLongic )) return kFALSE;
|
---|
285 | if (!fin.SetRefAddress("MMcEvt.fLongichi2", fLongichi2 )) return kFALSE;
|
---|
286 | if (!fin.SetRefAddress("MMcEvt.fPhotIni", fPhotIni )) return kFALSE;
|
---|
287 | if (!fin.SetRefAddress("MMcEvt.fPassPhotAtm", fPassPhotAtm )) return kFALSE;
|
---|
288 | if (!fin.SetRefAddress("MMcEvt.fPassPhotRef", fPassPhotRef )) return kFALSE;
|
---|
289 | if (!fin.SetRefAddress("MMcEvt.fPassPhotCone", fPassPhotCone )) return kFALSE;
|
---|
290 | if (!fin.SetRefAddress("MMcEvt.fPhotElfromShower", fPhotElfromShower )) return kFALSE;
|
---|
291 | if (!fin.SetRefAddress("MMcEvt.fPhotElinCamera", fPhotElinCamera )) return kFALSE;
|
---|
292 | if (!fin.SetRefAddress("MMcEvt.fElecCphFraction", fElecCphFraction )) return kFALSE;
|
---|
293 | if (!fin.SetRefAddress("MMcEvt.fMuonCphFraction", fMuonCphFraction )) return kFALSE;
|
---|
294 | if (!fin.SetRefAddress("MMcEvt.fOtherCphFraction", fOtherCphFraction )) return kFALSE;
|
---|
295 | if (!fin.SetRefAddress("MMcEvt.fFadcTimeJitter", fFadcTimeJitter )) return kFALSE;
|
---|
296 | if (!fin.SetRefAddress("MMcEvt.fEventReuse", fEventReuse )) return kFALSE;
|
---|
297 |
|
---|
298 | return MMcEvtBasic::SetupFits(fin);
|
---|
299 | }
|
---|