source: fact/tools/marsmacros/mc2csv/MonteCarlo.h@ 14727

Last change on this file since 14727 was 14725, checked in by Jens Buss, 12 years ago
added doxygen comments
  • Property svn:executable set to *
File size: 12.4 KB
Line 
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
65using namespace std;
66using namespace TMath;
67
68struct 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
76class MonteCarlo
77{
78public:
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
127private:
128 /*! Initiate all pointer Variables to NULL*/
129 void InitVariables();
130
131public:
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 the verbosity level for verbosity cout on cmd-line
181 * \param verbLvl Votrbosity Level
182 */
183 void SetVerbosityLevel(int verbLvl);
184
185 /*! Get the verbosity level for verbosity cout on cmd-line
186 */
187 int GetVerbosityLevel();
188
189 /*! Open the mars-root-file produced with ceres
190 */
191 void OpenRootFile();
192
193 /*! Close the mars-root-file produced with ceres
194 */
195 void CloseRootFile();
196
197 /*! Open csv-file to which data will be written
198 * \param fileName Filename of the csv-file e.g. "mc20120605.csv"
199 */
200 void OpenCsvFile( TString fileName);
201
202 /*! Close csv-file to which data was be written
203 */
204 void CloseCsvFile();
205
206 /*! set according pointers to tree containing event information and its branches
207 * \param treeName Name of TTree containing event information
208 */
209 void LoadEventTree( TString treeName);
210
211 /*! set according pointers to tree containing run information and its branches
212 * \param treeName Name of TTree containing run information
213 */
214 void LoadHeaderTree(TString treeName);
215
216 /*! set values of members to according leafs in TTree for run meta data
217 */
218 void ReadRunHeader();
219
220 /*! set values of members to according leafs in TTree for event raw data
221 */
222 void ReadEventRawData();
223
224 /*! set values of members to according leafs in TTree for event meta data
225 */
226 void ReadEventMetaData();
227
228 /*! call ReadEventRawData() and ReadEventMetaData() for given event
229 * \param Event Event ID to read data
230 */
231 void ReadEvent(int Event);
232
233// INQUIRY
234private:
235 /*! Verbostiy Level */
236 int mVerbosityLvl;
237 /*! Whether the rootfile is open */
238 bool mRootFileOpend;
239
240 /*! filename of output csv file */
241 TString mCsvFileName;
242 /*! steam into csv output file */
243 ofstream mCsv;
244 /*! filename of input root file */
245 TString mFileName;
246 /*! pointer to input root file */
247 TFile* mpRootFile;
248 /*! Array for pixels' raw data */
249 pixel_t* mpPixel;
250
251 /*! pointer to event tree */
252 TTree* mpEventTree;
253 /*! pointer to run header tree */
254 TTree* mpHeaderTree;
255
256 //run header tree branches
257 /*! mars class pointer to branch with same name in TTree */
258 MParameterD* mpIntendedPulsePos;
259 /*! mars class pointer to branch with same name in TTree */
260 MMcRunHeader* mpMcRunHeader;
261 /*! mars class pointer to branch with same name in TTree */
262 MGeomCamFACT* mpGeomCam;
263 /*! mars class pointer to branch with same name in TTree */
264 MRawRunHeader* mpRawRunHeader;
265 /*! mars class pointer to branch with same name in TTree */
266 MCorsikaRunHeader* mpCorsikaRunHeader;
267
268 //Event tree branches
269 /*! mars class pointer to branch with same name in TTree */
270 MPedestalCam* mpElectronicNoise;
271 /*! mars class pointer to branch with same name in TTree */
272 MRawEvtData* mpRawEventData;
273 /*! mars class pointer to branch with same name in TTree */
274 MParameterD* mpIncidentAngle;
275 /*! mars class pointer to branch "MMcEvt" in TTree */
276 MMcEvt* mpMcEventMetaData;
277 /*! mars class pointer to branch with same name in TTree */
278 MRawEvtHeader* mpRawEventHeader;
279 /*! mars class pointer to branch with same name in TTree */
280 MCorsikaEvtHeader* mpCorsikaEvtHeader;
281
282// /*! array with MC events raw data */
283// unsigned short * mpSamples; // array with MC events raw data
284 /*! coulumn seperator in csv file */
285 TString mSeparator;
286
287 //Run Meta Data
288 /*! number of entries(events) in event tree */
289 int mNumberOfEntries;
290 /*! number of events in file NOT WORKING WITH CURRENT CERES VERSION */
291 int mNumberOfEvents;
292 /*! position (slice) of simulated cherenkov pulse in pixel */
293 float mIntendedPulsePos;
294 /*! number of showers simulated by corsika*/
295 int mNumSimulatedShowers;
296 /*! total number of simulated camera pixels */
297 int mNumberOfPixels;
298 /*! ??? */
299 int mNumberOfSectors;
300 /*! ??? */
301 int mNumberOfAreas;
302 /*! number of Samples (slices) -> simulated Region of interest */
303 float mNumberOfSamples;
304 /*! simulated sampling frequency */
305 float mSamplingFrequency;
306 /*! ??? */
307 int mNumberOfEventsRead;
308 /*! ??? */
309 float mCamDist;
310 /*! name of simulated source */
311 const char* mSourceName;
312 /*! slope of simulated spectrum */
313 float mSlopeSpectrum;
314 /*! minimum of simulated spectrum */
315 float mEnergyMin;
316 /*! maximum of simulated spectrum */
317 float mEnergyMax;
318 /*! minimum Zenidth of simulated showers */
319 float mZdMin;
320 /*! maximum Zenidth of simulated showers */
321 float mZdMax;
322 /*! minimum Azimuth of simulated showers */
323 float mAzMin;
324 /*! maximum Azimuth of simulated showers */
325 float mAzMax;
326 /*! file number from raw run header */
327 unsigned int mFileNumber;
328 /*! corsika run number */
329 int mRunNumber;
330 /*! runtype: e.g. Pedestal, data, calibration run,... */
331 int mRunType;
332 /*! number of bytes per sample */
333 int mNumberOfBytes;
334
335 //Event Meta Data
336 /*! Incident Angle */
337 float mIncidentAngle;
338 /*! id of primary particle of shower */
339 int mPartId;
340 /*! energy of primary particle of shower */
341 float mEnergy;
342 /*! impact parameter of primary particle of shower */
343 float mImpact;
344 /*! Telescope Phi of shower */
345 float mTelescopePhi;
346 /*! Telescope Theta of shower */
347 float mTelescopeTheta;
348 /*! Phi of shower */
349 float mPhi;
350 /*! Theta of shower */
351 float mTheta;
352 /*! name of primary particle of shower */
353 TString mPartName;
354 /*! symbol of primary particle of shower */
355 TString mPartSymbol;
356 /*! corsika event number */
357 unsigned int mCorsikaEventNumber;
358 /*! Passed qe, coming from the shower */
359 unsigned int mPhotElFromShower;
360 /*! usPhotElfromShower + mean of phe from NSB */
361 unsigned int mPhotElinCamera;
362 /*! Number running from 0 to N-1, being N the number
363 * of times a Corsika event has been reused, by
364 * orienting the telescope in different ways or by
365 * setting it at a different location on the ground. */
366 int mEvtReuse;
367 /*! Number of Events from DAQ */
368 int mEventNumber;
369 /*! Number of 1st level tiggers between 2 events Used in MSimTrigger for the index of the trigger channel */
370 float mNumTriggerLvl1;
371 /*! Number of 2nd level tiggers between 2 events */
372 float mNumTriggerLvl2;
373 /*! [cm] z coordinate, first intercation height */
374 float mFirstInteractionHeight;
375 /*! [GeV/c] "+west" "-east" */
376 float mMomentumX;
377 /*! [GeV/c] "+south" "-north"
378 * (north denotes the magnet north which is defined to be in the geografic north!)
379 */
380 float mMomentumY;
381 /*! [GeV/c] "+upwards" "-downwards" */
382 float mMomentumZ;
383 /*! [rad] Zenith distance */
384 float mZd;
385 /*! [rad] Azimuth (north=0; east=90)
386 * (north denotes the magnet north which is defined to be in the geografic north!)
387 */
388 float mAz;
389 /*! [cm] Position of telescope on ground x / - impact parameter x */
390 float mX;
391 /*! [cm] Position of telescope on gorund y / - impact parameter y */
392 float mY;
393 /*! weighted number of photons arriving at observation level */
394// int mWeightedNumPhotons;
395
396
397
398
399protected:
400
401};
402
403// INLINE METHODS
404//
405
406// EXTERNAL REFERENCES
407//
408
409#endif // MONTECARLO_H
410
Note: See TracBrowser for help on using the repository browser.