1 | #ifndef MONTECARLO_H
|
---|
2 | #define MONTECARLO_H
|
---|
3 |
|
---|
4 | /*! \class MonteCarlo
|
---|
5 | * \brief Monte Carlo class to handle MC-Data from mars-root-file produced with ceres.
|
---|
6 | *
|
---|
7 | * #include "MonteCarlo.h" <BR>
|
---|
8 | * -llib
|
---|
9 | *
|
---|
10 | * Class can be used in Mars to load Monte Carlo data from a root-file
|
---|
11 | * containing Mars classes that where produced by CERES
|
---|
12 | *
|
---|
13 | * @see something
|
---|
14 | */
|
---|
15 |
|
---|
16 |
|
---|
17 | // SYSTEM INCLUDES
|
---|
18 | #include <vector>
|
---|
19 | #include <fstream>
|
---|
20 | #include <endian.h>
|
---|
21 | #include <stdio.h>
|
---|
22 |
|
---|
23 | #include <TSystem.h>
|
---|
24 | #include <TString.h>
|
---|
25 | #include <TStyle.h>
|
---|
26 | #include <TCanvas.h>
|
---|
27 | #include <TMath.h>
|
---|
28 | #include <TFile.h>
|
---|
29 | #include <TH1.h>
|
---|
30 | #include <TH2F.h>
|
---|
31 | #include <TF1.h>
|
---|
32 | #include <TTree.h>
|
---|
33 | //
|
---|
34 |
|
---|
35 | // PROJECT INCLUDES
|
---|
36 | #include "MStatusDisplay.h"
|
---|
37 | #include "MStatusArray.h"
|
---|
38 | #include "MParContainer.h"
|
---|
39 |
|
---|
40 | #include "MParameters.h"
|
---|
41 | #include "MPedestalCam.h"
|
---|
42 | #include "MMcRunHeader.hxx"
|
---|
43 | #include "MGeomCamFACT.h"
|
---|
44 | #include "MRawRunHeader.h"
|
---|
45 | #include "MCorsikaRunHeader.h"
|
---|
46 |
|
---|
47 | //Evt data types
|
---|
48 | #include "MRawEvtData.h"
|
---|
49 | #include "MPedestalCam.h"
|
---|
50 | #include "MMcEvt.hxx"
|
---|
51 | #include "MMcEvtBasic.h"
|
---|
52 | #include "MRawEvtHeader.h"
|
---|
53 | #include "MCorsikaEvtHeader.h"
|
---|
54 |
|
---|
55 |
|
---|
56 |
|
---|
57 | //
|
---|
58 |
|
---|
59 | // LOCAL INCLUDES
|
---|
60 | //
|
---|
61 |
|
---|
62 | // FORWARD REFERENCES
|
---|
63 | //
|
---|
64 |
|
---|
65 | using namespace std;
|
---|
66 | using namespace TMath;
|
---|
67 |
|
---|
68 | struct pixel_t //struct gathering information of a camera pixel
|
---|
69 | {
|
---|
70 | int SoftId; //Mars Software ID of Pixel
|
---|
71 | // int ChId; //continous Hardware ID of Pixel
|
---|
72 | unsigned short* rawData; //array with raw data of slices* amplitudes
|
---|
73 | float pedestal; //amplitude of baseline
|
---|
74 | };
|
---|
75 |
|
---|
76 | class MonteCarlo
|
---|
77 | {
|
---|
78 | public:
|
---|
79 | // LIFECYCLE
|
---|
80 |
|
---|
81 | /** Default constructor.
|
---|
82 | */
|
---|
83 | MonteCarlo(); // Default constructor
|
---|
84 | /*! constructor
|
---|
85 | * \param filename name of mc data file that will to load
|
---|
86 | */
|
---|
87 | MonteCarlo( TString filename); // name of mc data file will to load
|
---|
88 | /*! constructor
|
---|
89 | * \param filename name of mc data file that will to load
|
---|
90 | * \param evtsTreeName name of tree containg events
|
---|
91 | */
|
---|
92 | MonteCarlo( TString filename, // name of mc data file will to load
|
---|
93 | TString evtsTreeName); // name of tree containg events
|
---|
94 | /*! constructor
|
---|
95 | * \param filename name of mc data file that will to load
|
---|
96 | * \param evtsTreeName name of tree containg events
|
---|
97 | * \param headerTreeName name of tree containg run meta data
|
---|
98 | */
|
---|
99 | MonteCarlo( TString filename, // name of mc data file will to load
|
---|
100 | TString evtsTreeName, // name of tree containg events
|
---|
101 | TString headerTreeName);// name of tree containg meta data
|
---|
102 |
|
---|
103 |
|
---|
104 | // /** Copy constructor.
|
---|
105 | // *
|
---|
106 | // * @param from The value to copy to this object.
|
---|
107 | // */
|
---|
108 | // MonteCarlo(const MonteCarlo& from);
|
---|
109 |
|
---|
110 |
|
---|
111 | /** Destructor.
|
---|
112 | */
|
---|
113 | ~MonteCarlo(void);
|
---|
114 |
|
---|
115 |
|
---|
116 | // OPERATORS
|
---|
117 |
|
---|
118 | // /** Assignment operator.
|
---|
119 | // *
|
---|
120 | // * @param from THe value to assign to this object.
|
---|
121 | // *
|
---|
122 | // * @return A reference to this object.
|
---|
123 | // */
|
---|
124 | // MonteCarlo& operator=(const XX& from);
|
---|
125 |
|
---|
126 | // OPERATIONS
|
---|
127 | private:
|
---|
128 | /*! Initiate all pointer Variables to NULL*/
|
---|
129 | void InitVariables();
|
---|
130 |
|
---|
131 | public:
|
---|
132 | /*! Write Monte Carlo Data into a Csv-file WriteMc2Csv(filename)
|
---|
133 | * \param filename The Filename of the CSV File to which data will be written
|
---|
134 | */
|
---|
135 | void WriteMc2Csv(TString filename );
|
---|
136 |
|
---|
137 | /*! write pixels' raw data for a given pixel into the given csv file
|
---|
138 | * \param pixelID Software ID of pixel
|
---|
139 | */
|
---|
140 | void WritePixelData2Csv(int pixelID);
|
---|
141 |
|
---|
142 | /*! loop over all pixels and call WritePixelData2Csv
|
---|
143 | */
|
---|
144 | void WriteEventData2Csv();
|
---|
145 |
|
---|
146 | /*! write table headings for coulums with pixels' raw data
|
---|
147 | */
|
---|
148 | void WriteEventDataInfo2Csv();
|
---|
149 |
|
---|
150 | /*! write table headings for coulums with event meta information
|
---|
151 | */
|
---|
152 | void WriteEventHeaderInfo2Csv();
|
---|
153 |
|
---|
154 | /*! write meta information of current event to csv
|
---|
155 | */
|
---|
156 | void WriteEventHeader2Csv();
|
---|
157 |
|
---|
158 | /*! write table headings for coulums with run meta information
|
---|
159 | */
|
---|
160 | void WriteRunHeaderInfo2Csv();
|
---|
161 |
|
---|
162 | /*! write meta information of current run to csv
|
---|
163 | */
|
---|
164 | void WriteRunHeader2Csv();
|
---|
165 |
|
---|
166 | /*! write the header of the csv file containing brief info about the converted mc file
|
---|
167 | */
|
---|
168 | void WriteFileInfo2Csv();
|
---|
169 |
|
---|
170 | /*! write table headings for coulums with pixels' pedestal amplitude
|
---|
171 | */
|
---|
172 | void WritePedestal2Csv();
|
---|
173 |
|
---|
174 | /*! write table headings for coulums with pixels' pedestal amplitude
|
---|
175 | */
|
---|
176 | void WritePedestalInfo2Csv();
|
---|
177 |
|
---|
178 |
|
---|
179 | // ACCESS
|
---|
180 | /*! set column seperator for csv
|
---|
181 | * \param sep column seperator for csv
|
---|
182 | */
|
---|
183 | void SetSeparator(char sep);
|
---|
184 |
|
---|
185 | /*! Get column seperator for csv
|
---|
186 | * \param sep column seperator for csv
|
---|
187 | */
|
---|
188 | TString GetSeparator();
|
---|
189 |
|
---|
190 | /*! set the verbosity level for verbosity cout on cmd-line
|
---|
191 | * \param verbLvl Votrbosity Level
|
---|
192 | */
|
---|
193 | void SetVerbosityLevel(int verbLvl);
|
---|
194 |
|
---|
195 | /*! Get the verbosity level for verbosity cout on cmd-line
|
---|
196 | */
|
---|
197 | int GetVerbosityLevel();
|
---|
198 |
|
---|
199 | /*! Open the mars-root-file produced with ceres
|
---|
200 | */
|
---|
201 | int OpenRootFile();
|
---|
202 |
|
---|
203 | /*! Close the mars-root-file produced with ceres
|
---|
204 | */
|
---|
205 | void CloseRootFile();
|
---|
206 |
|
---|
207 | /*! Open csv-file to which data will be written
|
---|
208 | * \param fileName Filename of the csv-file e.g. "mc20120605.csv"
|
---|
209 | */
|
---|
210 | void OpenCsvFile( TString fileName);
|
---|
211 |
|
---|
212 | /*! Close csv-file to which data was be written
|
---|
213 | */
|
---|
214 | void CloseCsvFile();
|
---|
215 |
|
---|
216 | /*! set according pointers to tree containing event information and its branches
|
---|
217 | * \param treeName Name of TTree containing event information
|
---|
218 | */
|
---|
219 | void LoadEventTree( TString treeName);
|
---|
220 |
|
---|
221 | /*! set according pointers to tree containing run information and its branches
|
---|
222 | * \param treeName Name of TTree containing run information
|
---|
223 | */
|
---|
224 | void LoadHeaderTree(TString treeName);
|
---|
225 |
|
---|
226 | /*! set values of members to according leafs in TTree for run meta data
|
---|
227 | */
|
---|
228 | void ReadRunHeader();
|
---|
229 |
|
---|
230 | /*! set values of members to according leafs in TTree for event raw data
|
---|
231 | */
|
---|
232 | void ReadEventRawData();
|
---|
233 |
|
---|
234 | /*! set values of members to according leafs in TTree for event meta data
|
---|
235 | */
|
---|
236 | void ReadEventMetaData();
|
---|
237 |
|
---|
238 | /*! call ReadEventRawData() and ReadEventMetaData() for given event
|
---|
239 | * \param Event Event ID to read data
|
---|
240 | */
|
---|
241 | void ReadEvent(int Event);
|
---|
242 |
|
---|
243 | // INQUIRY
|
---|
244 | private:
|
---|
245 | /*! Verbostiy Level */
|
---|
246 | int mVerbosityLvl;
|
---|
247 | /*! Whether the rootfile is open */
|
---|
248 | bool mRootFileOpend;
|
---|
249 |
|
---|
250 | /*! filename of output csv file */
|
---|
251 | TString mCsvFileName;
|
---|
252 | /*! steam into csv output file */
|
---|
253 | ofstream mCsv;
|
---|
254 | /*! filename of input root file */
|
---|
255 | TString mFileName;
|
---|
256 | /*! pointer to input root file */
|
---|
257 | TFile* mpRootFile;
|
---|
258 | /*! Array for pixels' raw data */
|
---|
259 | pixel_t* mpPixel;
|
---|
260 |
|
---|
261 | /*! pointer to event tree */
|
---|
262 | TTree* mpEventTree;
|
---|
263 | /*! pointer to run header tree */
|
---|
264 | TTree* mpHeaderTree;
|
---|
265 |
|
---|
266 | //run header tree branches
|
---|
267 | /*! mars class pointer to branch with same name in TTree */
|
---|
268 | MParameterD* mpIntendedPulsePos;
|
---|
269 | /*! mars class pointer to branch with same name in TTree */
|
---|
270 | MMcRunHeader* mpMcRunHeader;
|
---|
271 | /*! mars class pointer to branch with same name in TTree */
|
---|
272 | MGeomCamFACT* mpGeomCam;
|
---|
273 | /*! mars class pointer to branch with same name in TTree */
|
---|
274 | MRawRunHeader* mpRawRunHeader;
|
---|
275 | /*! mars class pointer to branch with same name in TTree */
|
---|
276 | MCorsikaRunHeader* mpCorsikaRunHeader;
|
---|
277 |
|
---|
278 | //Event tree branches
|
---|
279 | /*! mars class pointer to branch with same name in TTree */
|
---|
280 | MPedestalCam* mpElectronicNoise;
|
---|
281 | /*! mars class pointer to branch with same name in TTree */
|
---|
282 | MRawEvtData* mpRawEventData;
|
---|
283 | /*! mars class pointer to branch with same name in TTree */
|
---|
284 | MParameterD* mpIncidentAngle;
|
---|
285 | /*! mars class pointer to branch "MMcEvt" in TTree */
|
---|
286 | MMcEvt* mpMcEventMetaData;
|
---|
287 | /*! mars class pointer to branch with same name in TTree */
|
---|
288 | MRawEvtHeader* mpRawEventHeader;
|
---|
289 | /*! mars class pointer to branch with same name in TTree */
|
---|
290 | MCorsikaEvtHeader* mpCorsikaEvtHeader;
|
---|
291 |
|
---|
292 | // /*! array with MC events raw data */
|
---|
293 | // unsigned short * mpSamples; // array with MC events raw data
|
---|
294 | /*! coulumn seperator in csv file */
|
---|
295 | TString mSeparator;
|
---|
296 |
|
---|
297 | //Run Meta Data
|
---|
298 | /*! number of entries(events) in event tree */
|
---|
299 | int mNumberOfEntries;
|
---|
300 | /*! number of events in file NOT WORKING WITH CURRENT CERES VERSION */
|
---|
301 | int mNumberOfEvents;
|
---|
302 | /*! position (slice) of simulated cherenkov pulse in pixel */
|
---|
303 | float mIntendedPulsePos;
|
---|
304 | /*! number of showers simulated by corsika*/
|
---|
305 | int mNumSimulatedShowers;
|
---|
306 | /*! total number of simulated camera pixels */
|
---|
307 | int mNumberOfPixels;
|
---|
308 | /*! ??? */
|
---|
309 | int mNumberOfSectors;
|
---|
310 | /*! ??? */
|
---|
311 | int mNumberOfAreas;
|
---|
312 | /*! number of Samples (slices) -> simulated Region of interest */
|
---|
313 | float mNumberOfSamples;
|
---|
314 | /*! simulated sampling frequency */
|
---|
315 | float mSamplingFrequency;
|
---|
316 | /*! ??? */
|
---|
317 | int mNumberOfEventsRead;
|
---|
318 | /*! ??? */
|
---|
319 | float mCamDist;
|
---|
320 | /*! name of simulated source */
|
---|
321 | const char* mSourceName;
|
---|
322 | /*! slope of simulated spectrum */
|
---|
323 | float mSlopeSpectrum;
|
---|
324 | /*! minimum of simulated spectrum */
|
---|
325 | float mEnergyMin;
|
---|
326 | /*! maximum of simulated spectrum */
|
---|
327 | float mEnergyMax;
|
---|
328 | /*! minimum Zenidth of simulated showers */
|
---|
329 | float mZdMin;
|
---|
330 | /*! maximum Zenidth of simulated showers */
|
---|
331 | float mZdMax;
|
---|
332 | /*! minimum Azimuth of simulated showers */
|
---|
333 | float mAzMin;
|
---|
334 | /*! maximum Azimuth of simulated showers */
|
---|
335 | float mAzMax;
|
---|
336 | /*! file number from raw run header */
|
---|
337 | unsigned int mFileNumber;
|
---|
338 | /*! corsika run number */
|
---|
339 | int mRunNumber;
|
---|
340 | /*! runtype: e.g. Pedestal, data, calibration run,... */
|
---|
341 | int mRunType;
|
---|
342 | /*! number of bytes per sample */
|
---|
343 | int mNumberOfBytes;
|
---|
344 |
|
---|
345 | //Event Meta Data
|
---|
346 | /*! Incident Angle */
|
---|
347 | float mIncidentAngle;
|
---|
348 | /*! id of primary particle of shower */
|
---|
349 | int mPartId;
|
---|
350 | /*! energy of primary particle of shower */
|
---|
351 | float mEnergy;
|
---|
352 | /*! impact parameter of primary particle of shower */
|
---|
353 | float mImpact;
|
---|
354 | /*! Telescope Phi of shower */
|
---|
355 | float mTelescopePhi;
|
---|
356 | /*! Telescope Theta of shower */
|
---|
357 | float mTelescopeTheta;
|
---|
358 | /*! Phi of shower */
|
---|
359 | float mPhi;
|
---|
360 | /*! Theta of shower */
|
---|
361 | float mTheta;
|
---|
362 | /*! name of primary particle of shower */
|
---|
363 | TString mPartName;
|
---|
364 | /*! symbol of primary particle of shower */
|
---|
365 | TString mPartSymbol;
|
---|
366 | /*! corsika event number */
|
---|
367 | unsigned int mCorsikaEventNumber;
|
---|
368 | /*! Passed qe, coming from the shower */
|
---|
369 | unsigned int mPhotElFromShower;
|
---|
370 | /*! usPhotElfromShower + mean of phe from NSB */
|
---|
371 | unsigned int mPhotElinCamera;
|
---|
372 | /*! Number running from 0 to N-1, being N the number
|
---|
373 | * of times a Corsika event has been reused, by
|
---|
374 | * orienting the telescope in different ways or by
|
---|
375 | * setting it at a different location on the ground. */
|
---|
376 | int mEvtReuse;
|
---|
377 | /*! Number of Events from DAQ */
|
---|
378 | int mEventNumber;
|
---|
379 | /*! Number of 1st level tiggers between 2 events Used in MSimTrigger for the index of the trigger channel */
|
---|
380 | float mNumTriggerLvl1;
|
---|
381 | /*! Number of 2nd level tiggers between 2 events */
|
---|
382 | float mNumTriggerLvl2;
|
---|
383 | /*! [cm] z coordinate, first intercation height */
|
---|
384 | float mFirstInteractionHeight;
|
---|
385 | /*! [GeV/c] "+west" "-east" */
|
---|
386 | float mMomentumX;
|
---|
387 | /*! [GeV/c] "+south" "-north"
|
---|
388 | * (north denotes the magnet north which is defined to be in the geografic north!)
|
---|
389 | */
|
---|
390 | float mMomentumY;
|
---|
391 | /*! [GeV/c] "+upwards" "-downwards" */
|
---|
392 | float mMomentumZ;
|
---|
393 | /*! [rad] Zenith distance */
|
---|
394 | float mZd;
|
---|
395 | /*! [rad] Azimuth (north=0; east=90)
|
---|
396 | * (north denotes the magnet north which is defined to be in the geografic north!)
|
---|
397 | */
|
---|
398 | float mAz;
|
---|
399 | /*! [cm] Position of telescope on ground x / - impact parameter x */
|
---|
400 | float mX;
|
---|
401 | /*! [cm] Position of telescope on gorund y / - impact parameter y */
|
---|
402 | float mY;
|
---|
403 | /*! weighted number of photons arriving at observation level */
|
---|
404 | // int mWeightedNumPhotons;
|
---|
405 |
|
---|
406 |
|
---|
407 |
|
---|
408 |
|
---|
409 | protected:
|
---|
410 |
|
---|
411 | };
|
---|
412 |
|
---|
413 | // INLINE METHODS
|
---|
414 | //
|
---|
415 |
|
---|
416 | // EXTERNAL REFERENCES
|
---|
417 | //
|
---|
418 |
|
---|
419 | #endif // MONTECARLO_H
|
---|
420 |
|
---|