1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of CheObs, the Modular 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 appears 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): Thomas Bretz, 2/2009 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: CheObs Software Development, 2000-2009
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | //////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MSimMMCS
|
---|
28 | //
|
---|
29 | // Task to copy the Mars CheObs MC headers to the old Mars style
|
---|
30 | //
|
---|
31 | //////////////////////////////////////////////////////////////////////////////
|
---|
32 | #include "MSimMMCS.h"
|
---|
33 |
|
---|
34 | #include "MLog.h"
|
---|
35 | #include "MLogManip.h"
|
---|
36 |
|
---|
37 | #include "MParList.h"
|
---|
38 |
|
---|
39 | #include "MMcEvt.hxx"
|
---|
40 |
|
---|
41 | #include "MRawRunHeader.h"
|
---|
42 |
|
---|
43 | #include "MCorsikaRunHeader.h"
|
---|
44 | #include "MCorsikaEvtHeader.h"
|
---|
45 |
|
---|
46 | #include "MMcRunHeader.hxx"
|
---|
47 | #include "MMcCorsikaRunHeader.h"
|
---|
48 |
|
---|
49 | #include "MPointingPos.h"
|
---|
50 |
|
---|
51 | ClassImp(MSimMMCS);
|
---|
52 |
|
---|
53 | using namespace std;
|
---|
54 |
|
---|
55 | // --------------------------------------------------------------------------
|
---|
56 | //
|
---|
57 | // Default Constructor.
|
---|
58 | //
|
---|
59 | MSimMMCS::MSimMMCS(const char* name, const char *title)
|
---|
60 | {
|
---|
61 | fName = name ? name : "MSimMMCS";
|
---|
62 | fTitle = title ? title : "Task to copy the Mars CheObs MC headers to the old Mars style";
|
---|
63 | }
|
---|
64 |
|
---|
65 | // --------------------------------------------------------------------------
|
---|
66 | //
|
---|
67 | Int_t MSimMMCS::PreProcess(MParList *plist)
|
---|
68 | {
|
---|
69 | fMcRunHeader = (MMcRunHeader*)plist->FindCreateObj("MMcRunHeader");
|
---|
70 | if (!fMcRunHeader)
|
---|
71 | return kFALSE;
|
---|
72 |
|
---|
73 | if (!plist->FindCreateObj("MMcCorsikaRunHeader"))
|
---|
74 | return kFALSE;
|
---|
75 |
|
---|
76 | if (!plist->FindCreateObj("MRawRunHeader"))
|
---|
77 | return kFALSE;
|
---|
78 |
|
---|
79 | fMcEvtBasic = (MMcEvtBasic*)plist->FindCreateObj("MMcEvtBasic");
|
---|
80 | if (!fMcEvtBasic)
|
---|
81 | return kFALSE;
|
---|
82 |
|
---|
83 | fMcEvt = (MMcEvt*)plist->FindCreateObj("MMcEvt");
|
---|
84 | if (!fMcEvt)
|
---|
85 | return kFALSE;
|
---|
86 |
|
---|
87 | fPointingTel = (MPointingPos*)plist->FindObject("MPointingPos");
|
---|
88 | if (!fPointingTel)
|
---|
89 | {
|
---|
90 | *fLog << err << "MPointingPos not found... aborting." << endl;
|
---|
91 | return kFALSE;
|
---|
92 | }
|
---|
93 |
|
---|
94 | fEvtHeader = (MCorsikaEvtHeader*)plist->FindObject("MCorsikaEvtHeader");
|
---|
95 | if (!fEvtHeader)
|
---|
96 | {
|
---|
97 | *fLog << err << "MCorsikaEvtHeader not found... aborting." << endl;
|
---|
98 | return kFALSE;
|
---|
99 | }
|
---|
100 |
|
---|
101 | fRunHeader = (MCorsikaRunHeader*)plist->FindObject("MCorsikaRunHeader");
|
---|
102 | if (!fRunHeader)
|
---|
103 | {
|
---|
104 | *fLog << err << "MCorsikaRunHeader not found... aborting." << endl;
|
---|
105 | return kFALSE;
|
---|
106 | }
|
---|
107 |
|
---|
108 | return kTRUE;
|
---|
109 | }
|
---|
110 |
|
---|
111 | // --------------------------------------------------------------------------
|
---|
112 | //
|
---|
113 | Bool_t MSimMMCS::ReInit(MParList *plist)
|
---|
114 | {
|
---|
115 | MMcCorsikaRunHeader *mch = (MMcCorsikaRunHeader*)plist->FindObject("MMcCorsikaRunHeader");
|
---|
116 | if (!mch)
|
---|
117 | {
|
---|
118 | *fLog << err << "MMcCorsikaRunHeader not found... aborting." << endl;
|
---|
119 | return kFALSE;
|
---|
120 | }
|
---|
121 |
|
---|
122 | mch->SetSpectrum(fRunHeader->GetSlopeSpectrum(),
|
---|
123 | fRunHeader->GetEnergyMin(), fRunHeader->GetEnergyMax());
|
---|
124 | mch->SetViewCone(fRunHeader->GetViewConeInnerAngle(),
|
---|
125 | fRunHeader->GetViewConeOuterAngle());
|
---|
126 | mch->SetReadyToSave();
|
---|
127 |
|
---|
128 | // ----------------------------------------------------
|
---|
129 |
|
---|
130 | // fNumPheFromDNSB MMcPedestalNSBAdd // Number of phe/ns from diffuse NSB
|
---|
131 |
|
---|
132 | // FIXME: Is there a way to write them as LAST entry in the file?
|
---|
133 | fMcRunHeader->SetNumSimulatedShowers(fRunHeader->GetNumEvents());
|
---|
134 | fMcRunHeader->SetCorsikaVersion(TMath::Nint(fRunHeader->GetProgramVersion()*100));
|
---|
135 |
|
---|
136 | if (fRunHeader->GetImpactMax()>0)
|
---|
137 | fMcRunHeader->SetImpactMax(fRunHeader->GetImpactMax());
|
---|
138 |
|
---|
139 | // ----------------------------------------------------
|
---|
140 |
|
---|
141 | MRawRunHeader *rh = (MRawRunHeader*)plist->FindObject("MRawRunHeader");
|
---|
142 | if (!rh)
|
---|
143 | {
|
---|
144 | *fLog << err << "MRawRunHeader not found... aborting." << endl;
|
---|
145 | return kFALSE;
|
---|
146 | }
|
---|
147 |
|
---|
148 | const UInt_t id = fRunHeader->GetParticleID();
|
---|
149 |
|
---|
150 | // FIXME: Is there a way to write them as LAST entry in the file?
|
---|
151 | rh->SetFileNumber(fRunHeader->GetRunNumber()%1000);
|
---|
152 | rh->SetSourceInfo(MMcEvtBasic::GetParticleName(id));
|
---|
153 | rh->SetReadyToSave();
|
---|
154 |
|
---|
155 | // ----------------------------------------------------
|
---|
156 |
|
---|
157 | fMcEvtBasic->SetPartId(MMcEvtBasic::ParticleId_t(id));
|
---|
158 |
|
---|
159 | return kTRUE;
|
---|
160 | }
|
---|
161 |
|
---|
162 | // --------------------------------------------------------------------------
|
---|
163 | //
|
---|
164 | // We have two scenarios for the ponting:
|
---|
165 | //
|
---|
166 | // 1) Diffuse flux (view cone option)
|
---|
167 | //
|
---|
168 | // Azimuth and Zenith angle are fixed values (min==max).
|
---|
169 | // The diffuse flux is produced in a cone around this angle.
|
---|
170 | //
|
---|
171 | // That means that the telescope orientation is aligned and fixed
|
---|
172 | // along the cone axis.
|
---|
173 | //
|
---|
174 | // To analyse a diffuse flux the source position should be fixed to
|
---|
175 | // the camera center.
|
---|
176 | // In some cases (e.g. training of RF) the source depending parameters
|
---|
177 | // might be needed w.r.t. the real origin of the primary particle.
|
---|
178 | // In this case the primary shower direction is needed.
|
---|
179 | //
|
---|
180 | // 2) Directed flux
|
---|
181 | //
|
---|
182 | // Particles are produced between a min and max Azimuth and Zenith angle.
|
---|
183 | // The telescope axis is either parallel (on source) or off axis
|
---|
184 | // (wobble) to the primary particle direction.
|
---|
185 | // This is used to "fake" the trajectory of the source.
|
---|
186 | //
|
---|
187 | // 3) Flux along a trajectory
|
---|
188 | //
|
---|
189 | // [...]
|
---|
190 | //
|
---|
191 | Int_t MSimMMCS::Process()
|
---|
192 | {
|
---|
193 | fMcEvtBasic->SetEnergy(fEvtHeader->GetTotalEnergy());
|
---|
194 | fMcEvtBasic->SetImpact(fEvtHeader->GetImpact());
|
---|
195 |
|
---|
196 | // Pointing direction of the telescope (telescope axis)
|
---|
197 | fMcEvtBasic->SetTelescopeTheta(fPointingTel->GetZdRad());
|
---|
198 | fMcEvtBasic->SetTelescopePhi(fPointingTel->GetAzRad());
|
---|
199 |
|
---|
200 | // Direction of primary particle
|
---|
201 | // Convert from corsika frame to telescope frame, taking
|
---|
202 | // the magnetic field into account: tel = corsika+offset
|
---|
203 | fMcEvtBasic->SetParticleTheta(fEvtHeader->GetZd());
|
---|
204 | fMcEvtBasic->SetParticlePhi(fEvtHeader->GetAz()+fRunHeader->GetMagneticFieldAz());
|
---|
205 |
|
---|
206 | fMcEvtBasic->SetReadyToSave();
|
---|
207 |
|
---|
208 |
|
---|
209 | static_cast<MMcEvtBasic&>(*fMcEvt) = *fMcEvtBasic;
|
---|
210 |
|
---|
211 |
|
---|
212 | fMcEvt->SetEvtNumber(fEvtHeader->GetEvtNumber());
|
---|
213 | fMcEvt->SetPhotElfromShower(0);
|
---|
214 |
|
---|
215 | if (fRunHeader->GetImpactMax()<0 &&
|
---|
216 | fEvtHeader->GetImpact()>fMcRunHeader->GetImpactMax())
|
---|
217 | fMcRunHeader->SetImpactMax(fEvtHeader->GetImpact());
|
---|
218 |
|
---|
219 | return kTRUE;
|
---|
220 | }
|
---|