1 | #include "MonteCarlo.h"
|
---|
2 |
|
---|
3 | MonteCarlo::MonteCarlo()
|
---|
4 | {
|
---|
5 | InitVariables();
|
---|
6 |
|
---|
7 | return;
|
---|
8 | }
|
---|
9 |
|
---|
10 | MonteCarlo::MonteCarlo(
|
---|
11 | TString filename
|
---|
12 | )
|
---|
13 | {
|
---|
14 | InitVariables();
|
---|
15 |
|
---|
16 | mFileName = filename;
|
---|
17 |
|
---|
18 | OpenRootFile();
|
---|
19 |
|
---|
20 | LoadEventTree( "Events");
|
---|
21 | LoadHeaderTree( "RunHeaders");
|
---|
22 |
|
---|
23 | ReadRunHeader();
|
---|
24 |
|
---|
25 | return;
|
---|
26 | }
|
---|
27 |
|
---|
28 | MonteCarlo::MonteCarlo(
|
---|
29 | TString filename,
|
---|
30 | TString evtsTreeName
|
---|
31 | )
|
---|
32 | {
|
---|
33 | InitVariables();
|
---|
34 |
|
---|
35 | mFileName = filename;
|
---|
36 |
|
---|
37 | OpenRootFile();
|
---|
38 |
|
---|
39 | LoadEventTree( evtsTreeName);
|
---|
40 | LoadHeaderTree( "RunHeaders");
|
---|
41 |
|
---|
42 | ReadRunHeader();
|
---|
43 |
|
---|
44 | return;
|
---|
45 | }
|
---|
46 |
|
---|
47 | MonteCarlo::MonteCarlo(
|
---|
48 | TString filename,
|
---|
49 | TString evtsTreeName,
|
---|
50 | TString headerTreeName
|
---|
51 | )
|
---|
52 | {
|
---|
53 | InitVariables();
|
---|
54 |
|
---|
55 | mFileName = filename;
|
---|
56 |
|
---|
57 | OpenRootFile();
|
---|
58 |
|
---|
59 | LoadEventTree( evtsTreeName);
|
---|
60 | LoadHeaderTree( headerTreeName);
|
---|
61 |
|
---|
62 | ReadRunHeader();
|
---|
63 |
|
---|
64 | return;
|
---|
65 | }
|
---|
66 |
|
---|
67 | MonteCarlo::~MonteCarlo(void)
|
---|
68 | {
|
---|
69 | delete[] mpPixel;
|
---|
70 |
|
---|
71 | CloseRootFile();
|
---|
72 |
|
---|
73 | delete mpRootFile;
|
---|
74 |
|
---|
75 | return;
|
---|
76 | }
|
---|
77 |
|
---|
78 | void
|
---|
79 | MonteCarlo::InitVariables()
|
---|
80 | {
|
---|
81 | mFileName = "";
|
---|
82 | mSeparator = " ";
|
---|
83 |
|
---|
84 | // Änderung !!!
|
---|
85 | mpRootFile = NULL;
|
---|
86 | // Änderung zuende
|
---|
87 |
|
---|
88 | mpEventTree = NULL;
|
---|
89 | mpHeaderTree = NULL;
|
---|
90 | mpPixel = NULL;
|
---|
91 |
|
---|
92 | // Änderung !!!
|
---|
93 | mpIntendedPulsePos = NULL;
|
---|
94 | mpMcRunHeader = NULL;
|
---|
95 | mpGeomCam = NULL;
|
---|
96 | mpRawRunHeader = NULL;
|
---|
97 | mpCorsikaRunHeader = NULL;
|
---|
98 |
|
---|
99 | mpElectronicNoise = NULL;
|
---|
100 | mpRawEventData = NULL;
|
---|
101 | mpIncidentAngle = NULL;
|
---|
102 | mpMcEventMetaData = NULL;
|
---|
103 | mpRawEventHeader = NULL;
|
---|
104 | mpCorsikaEvtHeader = NULL;
|
---|
105 | // Änderung zuende
|
---|
106 |
|
---|
107 | mpSamples = NULL;
|
---|
108 | mEventNumber = 0;
|
---|
109 | mNumberOfEvents = 2;
|
---|
110 |
|
---|
111 | mVerbosityLvl = 0;
|
---|
112 |
|
---|
113 | return;
|
---|
114 | }
|
---|
115 |
|
---|
116 | void
|
---|
117 | MonteCarlo::SetVerbosityLevel(int verbLvl)
|
---|
118 | {
|
---|
119 | mVerbosityLvl = verbLvl;
|
---|
120 |
|
---|
121 | return;
|
---|
122 | }
|
---|
123 |
|
---|
124 | int
|
---|
125 | MonteCarlo::GetVerbosityLevel()
|
---|
126 | {
|
---|
127 | return mVerbosityLvl;
|
---|
128 | }
|
---|
129 |
|
---|
130 | void
|
---|
131 | MonteCarlo::OpenRootFile()
|
---|
132 | {
|
---|
133 | if (mVerbosityLvl > 0) cout << "...opening root file: " << mFileName << endl;
|
---|
134 |
|
---|
135 | mpRootFile = new TFile(mFileName, "READ");
|
---|
136 |
|
---|
137 | if (!mpRootFile->IsOpen())
|
---|
138 | {
|
---|
139 | cout << "ERROR - Could not find file " << mFileName << endl;
|
---|
140 | return ;
|
---|
141 | }
|
---|
142 |
|
---|
143 | return;
|
---|
144 | }
|
---|
145 |
|
---|
146 | void
|
---|
147 | MonteCarlo::CloseRootFile()
|
---|
148 | {
|
---|
149 | if (mVerbosityLvl > 0) cout << "...closing root file: " << mFileName << endl;
|
---|
150 | mpRootFile->Close("R");
|
---|
151 |
|
---|
152 | return;
|
---|
153 | }
|
---|
154 |
|
---|
155 | void
|
---|
156 | MonteCarlo::OpenCsvFile(TString fileName)
|
---|
157 | {
|
---|
158 | mCsvFileName = fileName;
|
---|
159 |
|
---|
160 | if (mVerbosityLvl > 0) cout << "...opening csv file: " << mCsvFileName << endl;
|
---|
161 |
|
---|
162 | mCsv.open( mCsvFileName );
|
---|
163 |
|
---|
164 | return;
|
---|
165 | }
|
---|
166 |
|
---|
167 | void
|
---|
168 | MonteCarlo::CloseCsvFile()
|
---|
169 | {
|
---|
170 | if (mVerbosityLvl > 0) cout << "...closing csv file: " << mCsvFileName << endl;
|
---|
171 |
|
---|
172 | mCsv.close();
|
---|
173 |
|
---|
174 | return;
|
---|
175 | }
|
---|
176 |
|
---|
177 | void
|
---|
178 | MonteCarlo::LoadHeaderTree(TString treeName)
|
---|
179 | {
|
---|
180 | if (mVerbosityLvl > 0) cout << "...loading run header tree" << endl;
|
---|
181 |
|
---|
182 | mpHeaderTree = (TTree*)mpRootFile->Get(treeName);
|
---|
183 |
|
---|
184 | if (mpHeaderTree->IsZombie())
|
---|
185 | {
|
---|
186 | cout << "...could not load tree" << endl;
|
---|
187 | return;
|
---|
188 | }
|
---|
189 |
|
---|
190 |
|
---|
191 |
|
---|
192 | //Set Adresses to Branches in RunHeader-Tree
|
---|
193 | mpHeaderTree->SetBranchAddress("MGeomCam.", &mpGeomCam);
|
---|
194 | mpHeaderTree->SetBranchAddress("IntendedPulsePos.", &mpIntendedPulsePos);
|
---|
195 | mpHeaderTree->SetBranchAddress("MMcRunHeader.", &mpMcRunHeader);
|
---|
196 | mpHeaderTree->SetBranchAddress("ElectronicNoise.", &mpElectronicNoise);
|
---|
197 | mpHeaderTree->SetBranchAddress("MRawRunHeader.", &mpRawRunHeader);
|
---|
198 | mpHeaderTree->SetBranchAddress("MCorsikaRunHeader.",&mpCorsikaRunHeader);
|
---|
199 | return;
|
---|
200 | }
|
---|
201 |
|
---|
202 | void
|
---|
203 | MonteCarlo::ReadRunHeader()
|
---|
204 | {
|
---|
205 | if (mVerbosityLvl > 0)
|
---|
206 | cout << "...reading run header " << mpHeaderTree << endl;
|
---|
207 |
|
---|
208 | //Read Values from RunHeader-Tree
|
---|
209 |
|
---|
210 | mpHeaderTree->GetEntry(); //This causes problems
|
---|
211 |
|
---|
212 |
|
---|
213 | //Get values from "MGeomCam" Branch
|
---|
214 | //Getter functions from "MGeomCamFACT.h"
|
---|
215 | mCamDist = mpGeomCam->GetCameraDist();
|
---|
216 | mNumberOfPixels = mpGeomCam->GetNumPixels();
|
---|
217 | mNumberOfSectors = mpGeomCam->GetNumSectors();
|
---|
218 | mNumberOfAreas = mpGeomCam->GetNumAreas();
|
---|
219 |
|
---|
220 | //Get values from "IntendedPulsePos" Branch
|
---|
221 | mIntendedPulsePos = mpIntendedPulsePos->GetVal();
|
---|
222 |
|
---|
223 | //Get values from "MMcRunHeader" Branch from event Tree
|
---|
224 | mNumSimulatedShowers = mpMcRunHeader->GetNumSimulatedShowers();
|
---|
225 |
|
---|
226 | //Get number of Events from event Tree
|
---|
227 | mNumberOfEntries = mpEventTree->GetEntries();
|
---|
228 | if (mVerbosityLvl > 0)
|
---|
229 | cout << "Event Tree has " << mNumberOfEntries << " entries" << endl;
|
---|
230 |
|
---|
231 | //Get values from "MRawRunHeader" Branch
|
---|
232 | mNumberOfEvents = mpRawRunHeader->GetNumEvents(); // couses problems
|
---|
233 | mNumberOfEventsRead = mpRawRunHeader->GetNumEventsRead();
|
---|
234 | mSamplingFrequency = mpRawRunHeader->GetFreqSampling();
|
---|
235 | mSourceName = mpRawRunHeader->GetSourceName();
|
---|
236 | mFileNumber = mpRawRunHeader->GetFileNumber();
|
---|
237 | mNumberOfSamples = mpRawRunHeader->GetNumSamplesHiGain();
|
---|
238 | mNumberOfBytes = mpRawRunHeader->GetNumBytesPerSample();
|
---|
239 | mRunNumber = mpRawRunHeader->GetRunNumber();
|
---|
240 | mRunType = mpRawRunHeader->GetRunType();
|
---|
241 |
|
---|
242 |
|
---|
243 | //Get values from "MCorsikaRunHeader" Branch
|
---|
244 | mSlopeSpectrum = mpCorsikaRunHeader->GetSlopeSpectrum();
|
---|
245 | mEnergyMin = mpCorsikaRunHeader->GetEnergyMin();
|
---|
246 | mEnergyMax = mpCorsikaRunHeader->GetEnergyMax();
|
---|
247 | mZdMin = mpCorsikaRunHeader->GetZdMin();
|
---|
248 | mZdMax = mpCorsikaRunHeader->GetZdMax();
|
---|
249 | mAzMin = mpCorsikaRunHeader->GetAzMin();
|
---|
250 | mAzMax = mpCorsikaRunHeader->GetAzMax();
|
---|
251 |
|
---|
252 | return;
|
---|
253 | }
|
---|
254 |
|
---|
255 | void
|
---|
256 | MonteCarlo::LoadEventTree(TString treeName)
|
---|
257 | {
|
---|
258 | if (mVerbosityLvl > 0) cout << "...loading event tree" << endl;
|
---|
259 |
|
---|
260 | mpEventTree = (TTree*)mpRootFile->Get(treeName);
|
---|
261 |
|
---|
262 | if (mpEventTree->IsZombie())
|
---|
263 | {
|
---|
264 | cout << "...could not load tree" << endl;
|
---|
265 | return;
|
---|
266 | }
|
---|
267 |
|
---|
268 | //Set Adresses to Branches in Events-Tree
|
---|
269 | mpEventTree->SetBranchAddress("MRawEvtData.", &mpRawEventData);
|
---|
270 | mpEventTree->SetBranchAddress("IncidentAngle.", &mpIncidentAngle);
|
---|
271 | mpEventTree->SetBranchAddress("MMcEvt.", &mpMcEventMetaData);
|
---|
272 | mpEventTree->SetBranchAddress("MRawEvtHeader.", &mpRawEventHeader);
|
---|
273 | mpEventTree->SetBranchAddress("MCorsikaEvtHeader.", &mpCorsikaEvtHeader);
|
---|
274 |
|
---|
275 | return;
|
---|
276 | }
|
---|
277 |
|
---|
278 | void
|
---|
279 | MonteCarlo::ReadEventMetaData()
|
---|
280 | {
|
---|
281 | if (mVerbosityLvl > 1) cout << "...reading event header" << endl;
|
---|
282 |
|
---|
283 | //Get values from "MGeomCamFACT" Branch
|
---|
284 | mIncidentAngle = mpIncidentAngle->GetVal();
|
---|
285 |
|
---|
286 | //Get values from "MMcEvt" Branch
|
---|
287 | //The following Getter Functions can be found in MMcEvt.h
|
---|
288 | mCorsikaEventNumber = mpMcEventMetaData->GetEvtNumber();
|
---|
289 | mPhotElFromShower = mpMcEventMetaData->GetPhotElfromShower();
|
---|
290 | mPhotElinCamera = mpMcEventMetaData->GetPhotElinCamera();
|
---|
291 | //The following Getter Functions can be found in MMcEvtBasic.h
|
---|
292 | mPartId = mpMcEventMetaData->GetPartId();
|
---|
293 | mPartName = mpMcEventMetaData->GetParticleName(mPartId);
|
---|
294 | mPartSymbol = mpMcEventMetaData->GetParticleSymbol(mPartId);
|
---|
295 | mEnergy = mpMcEventMetaData->GetEnergy();
|
---|
296 | mImpact = mpMcEventMetaData->GetImpact();
|
---|
297 | mTelescopePhi = mpMcEventMetaData->GetTelescopePhi();
|
---|
298 | mTelescopeTheta = mpMcEventMetaData->GetTelescopeTheta();
|
---|
299 | mPhi = mpMcEventMetaData->GetParticlePhi();
|
---|
300 | mTheta = mpMcEventMetaData->GetParticleTheta();
|
---|
301 |
|
---|
302 | //Get values from "MRawEventHeader" Branch
|
---|
303 | mEventNumber = mpRawEventHeader->GetDAQEvtNumber();
|
---|
304 | mNumTriggerLvl1 = mpRawEventHeader->GetNumTrigLvl1();
|
---|
305 | mNumTriggerLvl2 = mpRawEventHeader->GetNumTrigLvl2();
|
---|
306 |
|
---|
307 | //Get values from "MCorsikaEvtHeader" Branch
|
---|
308 | mFirstInteractionHeight = mpCorsikaEvtHeader->GetFirstInteractionHeight();
|
---|
309 | mEvtReuse = mpCorsikaEvtHeader->GetNumReuse();
|
---|
310 | mMomentumX = mpCorsikaEvtHeader->GetMomentum().X();
|
---|
311 | mMomentumY = mpCorsikaEvtHeader->GetMomentum().Y();
|
---|
312 | mMomentumZ = mpCorsikaEvtHeader->GetMomentum().Z();
|
---|
313 | mZd = mpCorsikaEvtHeader->GetZd();
|
---|
314 | mAz = mpCorsikaEvtHeader->GetAz();
|
---|
315 | mX = mpCorsikaEvtHeader->GetX();
|
---|
316 | mY = mpCorsikaEvtHeader->GetY();
|
---|
317 |
|
---|
318 | // mWeightedNumPhotons = mpCorsikaEvtHeader->Get;
|
---|
319 | // no getter function, no idea how to extract information
|
---|
320 |
|
---|
321 | return;
|
---|
322 | }
|
---|
323 |
|
---|
324 | void
|
---|
325 | MonteCarlo::ReadEventRawData()
|
---|
326 | {
|
---|
327 | if (mVerbosityLvl > 1) cout << "...reading event raw data" << endl;
|
---|
328 |
|
---|
329 | // delete Pixel Array before you set refferences for a new one
|
---|
330 | if (mpPixel != NULL)
|
---|
331 | {
|
---|
332 | delete[] mpPixel;
|
---|
333 | }
|
---|
334 | mpPixel = new pixel_t[mNumberOfPixels];
|
---|
335 |
|
---|
336 | mpRawEventData->InitRead(mpRawRunHeader);
|
---|
337 |
|
---|
338 | int pix_first_sample;
|
---|
339 | // int pix_last_sample;
|
---|
340 |
|
---|
341 | unsigned short* all_raw_data = NULL;
|
---|
342 |
|
---|
343 | all_raw_data = (unsigned short*) mpRawEventData->GetSamples();
|
---|
344 |
|
---|
345 | if (mVerbosityLvl > 1)
|
---|
346 | cout << "...pixel progress: ";
|
---|
347 |
|
---|
348 | for ( int i = 0; i < mNumberOfPixels; i++ )
|
---|
349 | {
|
---|
350 | if (mVerbosityLvl > 1){
|
---|
351 | if ( !(i%(mNumberOfPixels/10) ))
|
---|
352 | cout << i/(mNumberOfPixels*1.0)*100 << "%.." ;
|
---|
353 | if ( i == mNumberOfPixels-1)
|
---|
354 | cout << "100% " ;
|
---|
355 | }
|
---|
356 |
|
---|
357 |
|
---|
358 | mpPixel[i].pedestal = mpElectronicNoise[0][i].GetPedestal();
|
---|
359 | mpPixel[i].SoftId = mpRawEventData->GetPixelIds()[i];
|
---|
360 |
|
---|
361 | pix_first_sample = i*mNumberOfSamples;
|
---|
362 |
|
---|
363 | // point beginning of pixel's rawdata array to address
|
---|
364 | // of pixel's first sample's adress
|
---|
365 |
|
---|
366 | mpPixel[i].rawData = &(all_raw_data[pix_first_sample]);
|
---|
367 |
|
---|
368 | // for (int j = pix_first_sample; j < pix_last_sample; j++)
|
---|
369 | // {
|
---|
370 | // cout << mpPixel[i].rawData[j] << " ";
|
---|
371 | // }
|
---|
372 | // cout << endl;
|
---|
373 |
|
---|
374 | // // this could be improved by
|
---|
375 | // DONE BUT NOT TESTED
|
---|
376 | // for (int j = i*mSampleSize; j < (i+1)*mSampleSize; j++)
|
---|
377 | // {
|
---|
378 | // }
|
---|
379 | }
|
---|
380 |
|
---|
381 | if (mVerbosityLvl > 1)
|
---|
382 | cout << endl;
|
---|
383 |
|
---|
384 | return;
|
---|
385 | }
|
---|
386 |
|
---|
387 | void
|
---|
388 | MonteCarlo::ReadEvent(int Event)
|
---|
389 | {
|
---|
390 | if (mVerbosityLvl > 0) cout << endl
|
---|
391 | << "====================" << endl
|
---|
392 | << "...reading Event: " << Event << endl
|
---|
393 | << "====================" << endl;
|
---|
394 |
|
---|
395 |
|
---|
396 | //load certain event from tree
|
---|
397 | mpEventTree->GetEntry(Event);
|
---|
398 |
|
---|
399 | ReadEventMetaData();
|
---|
400 | ReadEventRawData();
|
---|
401 |
|
---|
402 | return;
|
---|
403 | }
|
---|
404 |
|
---|
405 |
|
---|
406 | void
|
---|
407 | MonteCarlo::WriteMc2Csv(TString filename)
|
---|
408 | {
|
---|
409 | cout << "...writing mc to csv: " << filename << endl;
|
---|
410 | cout << "...processing " << mNumberOfEntries << "Events" << endl;
|
---|
411 |
|
---|
412 | mCsvFileName = filename;
|
---|
413 | OpenCsvFile(mCsvFileName);
|
---|
414 |
|
---|
415 | WriteFileHeader2Csv();
|
---|
416 | WriteRunHeaderNames2Csv();
|
---|
417 | WriteRunHeader2Csv();
|
---|
418 | WriteEventHeaderNames2Csv();
|
---|
419 | WriteEventDataNames2Csv();
|
---|
420 |
|
---|
421 | // for (int evt = 0; evt < mNumberOfEvents; evt++)
|
---|
422 | for (int evt = 0; evt < mNumberOfEntries; evt++)
|
---|
423 | {
|
---|
424 | ReadEvent(evt);
|
---|
425 | WriteEventHeader2Csv();
|
---|
426 | WriteEventData2Csv();
|
---|
427 | }
|
---|
428 |
|
---|
429 | cout << endl << "...conversion done " << endl;
|
---|
430 |
|
---|
431 | CloseCsvFile();
|
---|
432 | return;
|
---|
433 | }
|
---|
434 |
|
---|
435 |
|
---|
436 | void
|
---|
437 | MonteCarlo::WritePixelData2Csv(int pixelID)
|
---|
438 | {
|
---|
439 | if (mVerbosityLvl > 3) cout << "...writing pixel data to csv" << endl;
|
---|
440 | mCsv << mEventNumber << mSeparator;
|
---|
441 | mCsv << mpPixel[pixelID].SoftId << mSeparator;
|
---|
442 | mCsv << mpPixel[pixelID].pedestal << mSeparator;
|
---|
443 |
|
---|
444 | for (int i = 0; i < mNumberOfSamples; i++)
|
---|
445 | {
|
---|
446 | mCsv << mpPixel[pixelID].rawData[i] << mSeparator;
|
---|
447 | }
|
---|
448 | mCsv << endl;
|
---|
449 |
|
---|
450 | return;
|
---|
451 | }
|
---|
452 |
|
---|
453 | void
|
---|
454 | MonteCarlo::WriteEventData2Csv()
|
---|
455 | {
|
---|
456 | if (mVerbosityLvl > 0) cout << "...writing event data to csv" << endl;
|
---|
457 |
|
---|
458 | for (int i = 0; i < mNumberOfPixels; i++)
|
---|
459 | {
|
---|
460 | WritePixelData2Csv(i);
|
---|
461 | }
|
---|
462 |
|
---|
463 | return;
|
---|
464 | }
|
---|
465 |
|
---|
466 | void
|
---|
467 | MonteCarlo::WriteEventDataNames2Csv()
|
---|
468 | {
|
---|
469 | if (mVerbosityLvl > 0) cout << "...writing event categories to csv" << endl;
|
---|
470 |
|
---|
471 | mCsv << "### [RawData]" << endl;
|
---|
472 | mCsv << "# mEventNumber" << mSeparator;
|
---|
473 | mCsv << "pixelID" << mSeparator;
|
---|
474 | mCsv << "pixelPedestal" << mSeparator;
|
---|
475 | for (int i = 0; i < mNumberOfSamples; i++)
|
---|
476 | {
|
---|
477 | mCsv << "Raw_" << i << mSeparator;
|
---|
478 | }
|
---|
479 | mCsv << endl;
|
---|
480 |
|
---|
481 | return;
|
---|
482 | }
|
---|
483 |
|
---|
484 | void
|
---|
485 | MonteCarlo::WriteEventHeaderNames2Csv()
|
---|
486 | {
|
---|
487 | if (mVerbosityLvl > 0) cout << "...writing event header names to csv" << endl;
|
---|
488 |
|
---|
489 | mCsv << "### [EventHeader]" << endl;
|
---|
490 |
|
---|
491 | mCsv << "# mEventNumber" << mSeparator;
|
---|
492 | mCsv << "mNumberOfBytes" << mSeparator;
|
---|
493 | mCsv << "mIncidentAngle" << mSeparator;
|
---|
494 | mCsv << "mPartId" << mSeparator;
|
---|
495 | mCsv << "mEnergy" << mSeparator;
|
---|
496 | mCsv << "mImpact" << mSeparator;
|
---|
497 | mCsv << "mTelescopePhi" << mSeparator;
|
---|
498 | mCsv << "mTelescopeTheta" << mSeparator;
|
---|
499 | mCsv << "mPhi" << mSeparator;
|
---|
500 | mCsv << "mTheta" << mSeparator;
|
---|
501 | mCsv << "mCorsikaEventNumber" << mSeparator;
|
---|
502 | mCsv << "mPhotElFromShower" << mSeparator;
|
---|
503 | mCsv << "mEvtReuse" << mSeparator;
|
---|
504 | mCsv << "mNumTriggerLvl1" << mSeparator;
|
---|
505 | mCsv << "mFirstInteractionHeight" << mSeparator;
|
---|
506 | mCsv << "mMomentumX" << mSeparator;
|
---|
507 | mCsv << "mMomentumY" << mSeparator;
|
---|
508 | mCsv << "mMomentumZ" << mSeparator;
|
---|
509 | mCsv << "mZd" << mSeparator;
|
---|
510 | mCsv << "mAz" << mSeparator;
|
---|
511 | mCsv << "mX" << mSeparator;
|
---|
512 | mCsv << "mY" << mSeparator;
|
---|
513 | // mCsv << "mWeightedNumPhotons" ;
|
---|
514 | mCsv << endl;
|
---|
515 |
|
---|
516 | return;
|
---|
517 | }
|
---|
518 |
|
---|
519 |
|
---|
520 | void
|
---|
521 | MonteCarlo::WriteEventHeader2Csv()
|
---|
522 | {
|
---|
523 | if (mVerbosityLvl > 0) cout << "...writing event header to csv" << endl;
|
---|
524 |
|
---|
525 | mCsv << mEventNumber << mSeparator;
|
---|
526 | mCsv << mNumberOfBytes << mSeparator;
|
---|
527 | mCsv << mIncidentAngle << mSeparator;
|
---|
528 | mCsv << mPartId << mSeparator;
|
---|
529 | mCsv << mEnergy << mSeparator;
|
---|
530 | mCsv << mImpact << mSeparator;
|
---|
531 | mCsv << mTelescopePhi << mSeparator;
|
---|
532 | mCsv << mTelescopeTheta << mSeparator;
|
---|
533 | mCsv << mPhi << mSeparator;
|
---|
534 | mCsv << mTheta << mSeparator;
|
---|
535 | mCsv << mCorsikaEventNumber << mSeparator;
|
---|
536 | mCsv << mPhotElFromShower << mSeparator;
|
---|
537 | mCsv << mEvtReuse << mSeparator;
|
---|
538 | mCsv << mNumTriggerLvl1 << mSeparator;
|
---|
539 | mCsv << mFirstInteractionHeight << mSeparator;
|
---|
540 | mCsv << mMomentumX << mSeparator;
|
---|
541 | mCsv << mMomentumY << mSeparator;
|
---|
542 | mCsv << mMomentumZ << mSeparator;
|
---|
543 | mCsv << mZd << mSeparator;
|
---|
544 | mCsv << mAz << mSeparator;
|
---|
545 | mCsv << mX << mSeparator;
|
---|
546 | mCsv << mY << mSeparator;
|
---|
547 | // mCsv << mWeightedNumPhotons ;
|
---|
548 | mCsv << endl;
|
---|
549 |
|
---|
550 | return;
|
---|
551 | }
|
---|
552 |
|
---|
553 | void
|
---|
554 | MonteCarlo::WriteRunHeaderNames2Csv()
|
---|
555 | {
|
---|
556 | if (mVerbosityLvl > 0) cout << "...writing run header names to csv" << endl;
|
---|
557 |
|
---|
558 | mCsv << "### [RunHeader]" << endl;
|
---|
559 |
|
---|
560 | mCsv << "# mNumberOfEntries" << mSeparator;
|
---|
561 | mCsv << "mIntendedPulsePos" << mSeparator;
|
---|
562 | // Csv << "mPedestalOffset" << mSeparator;
|
---|
563 | mCsv << "mNumSimulatedShowers" << mSeparator;
|
---|
564 | mCsv << "mNumberOfPixels" << mSeparator;
|
---|
565 | mCsv << "mNumberOfSamples" << mSeparator;
|
---|
566 | // mCsv << "mSampleSize" << mSeparator;
|
---|
567 | mCsv << "mCamDist" << mSeparator;
|
---|
568 | mCsv << "mSourceName" << mSeparator;
|
---|
569 | mCsv << "mSlopeSpectrum" << mSeparator;
|
---|
570 | mCsv << "mEnergyMin" << mSeparator;
|
---|
571 | mCsv << "mEnergyMax" << mSeparator;
|
---|
572 | mCsv << "mZdMin" << mSeparator;
|
---|
573 | mCsv << "mZdMax" << mSeparator;
|
---|
574 | mCsv << "mAzMin" << mSeparator;
|
---|
575 | mCsv << "mAzMax" << mSeparator;
|
---|
576 | mCsv << "mFileNumber" << mSeparator;
|
---|
577 | mCsv << "mRunnumber" << mSeparator;
|
---|
578 | mCsv << "mRunType" << endl;
|
---|
579 |
|
---|
580 | return;
|
---|
581 | }
|
---|
582 |
|
---|
583 |
|
---|
584 | void
|
---|
585 | MonteCarlo::WriteRunHeader2Csv()
|
---|
586 | {
|
---|
587 | if (mVerbosityLvl > 0) cout << "...writing run header to csv" << endl;
|
---|
588 |
|
---|
589 | mCsv << mNumberOfEntries << mSeparator;
|
---|
590 | mCsv << mIntendedPulsePos << mSeparator;
|
---|
591 | // mCsv << mPedestalOffset << mSeparator;
|
---|
592 | mCsv << mNumSimulatedShowers << mSeparator;
|
---|
593 | mCsv << mNumberOfPixels << mSeparator;
|
---|
594 | mCsv << mNumberOfSamples << mSeparator;
|
---|
595 | // mCsv << mSampleSize << mSeparator;
|
---|
596 | mCsv << mCamDist << mSeparator;
|
---|
597 | mCsv << mSourceName << mSeparator;
|
---|
598 | mCsv << mSlopeSpectrum << mSeparator;
|
---|
599 | mCsv << mEnergyMin << mSeparator;
|
---|
600 | mCsv << mEnergyMax << mSeparator;
|
---|
601 | mCsv << mZdMin << mSeparator;
|
---|
602 | mCsv << mZdMax << mSeparator;
|
---|
603 | mCsv << mAzMin << mSeparator;
|
---|
604 | mCsv << mAzMax << mSeparator;
|
---|
605 | mCsv << mFileNumber << mSeparator;
|
---|
606 | mCsv << mRunNumber << mSeparator;
|
---|
607 | mCsv << mRunType << endl;
|
---|
608 |
|
---|
609 | return;
|
---|
610 | }
|
---|
611 |
|
---|
612 | void
|
---|
613 | MonteCarlo::WriteFileHeader2Csv()
|
---|
614 | {
|
---|
615 | if (mVerbosityLvl > 0) cout << "...writing file header to csv" << endl;
|
---|
616 |
|
---|
617 | mCsv << "### ==========================================================="
|
---|
618 | << endl;
|
---|
619 | mCsv << "### = FACT Monte Carlo ="
|
---|
620 | << endl;
|
---|
621 | mCsv << "### ==========================================================="
|
---|
622 | << endl;
|
---|
623 | mCsv << "### = FileInfo: "
|
---|
624 | << endl;
|
---|
625 | mCsv << "### = "
|
---|
626 | << endl;
|
---|
627 | mCsv << "### = Source Name: " << mSourceName << endl;
|
---|
628 | mCsv << "### = Number of Entries: " << mNumberOfEntries << endl;
|
---|
629 | mCsv << "### = Run Number: " << mRunNumber << endl;
|
---|
630 | mCsv << "### = Run Type : " << mRunType << endl;
|
---|
631 | mCsv << "### = File Number: " << mFileNumber << endl;
|
---|
632 | mCsv << "### ==========================================================="
|
---|
633 | << endl ;
|
---|
634 | mCsv << "###"
|
---|
635 | << endl ;
|
---|
636 |
|
---|
637 | return;
|
---|
638 | }
|
---|
639 |
|
---|
640 |
|
---|
641 |
|
---|
642 | //--------------------------------------------------------------------------------
|
---|
643 | //
|
---|
644 | //
|
---|
645 | //
|
---|
646 |
|
---|
647 |
|
---|
648 | // FADC samples (hi gain) of all pixels
|
---|
649 | // This is an array of Byte_t variables. The value of a FADC sample has a
|
---|
650 | // size of n=fNumBytesPerSample bytes. Therefore, a FADC sample value will
|
---|
651 | // occupy n consecutive elements of this array (little endian ordering, i.e,
|
---|
652 | // less significant bits (and bytes) go first.
|
---|
653 | // If m = GetNumHiGainSamples(), the n bytes corresponding to the value of the
|
---|
654 | // i-th FADC sample of the j-th pixel are stored in the n consecutive
|
---|
655 | // positions of this array, starting from fHiGainFadcSamples[j*n*m+i*n]
|
---|
656 |
|
---|
657 |
|
---|
658 | /*
|
---|
659 | int extractMC()
|
---|
660 | {
|
---|
661 |
|
---|
662 | TTree *tree = (TTree*)f.Get("Events");
|
---|
663 |
|
---|
664 | // MArrayB *array = NULL;
|
---|
665 |
|
---|
666 | const float dconv = 2000/4096;
|
---|
667 |
|
---|
668 | unsigned short *short_array;
|
---|
669 | TH1F histo("histo", "histo", 150, 0, 150);
|
---|
670 |
|
---|
671 | TCanvas *canvas = new TCanvas("canvas", "canvas", 0, 0, 400, 400 );
|
---|
672 | canvas->cd();
|
---|
673 | tree->SetBranchAddress("MRawEvtData.", &branch1);
|
---|
674 |
|
---|
675 | tree->GetEntry(22);
|
---|
676 |
|
---|
677 | cout << "Branch1 " << branch1 << endl;
|
---|
678 |
|
---|
679 | array = branch1->GetSamples();
|
---|
680 |
|
---|
681 |
|
---|
682 | for(int i = 0; i < 150; i++){
|
---|
683 | cout << "i_" << i << "\t 1. " << short_array[i] ;
|
---|
684 | short_array[i] = le16toh(short_array[i]);
|
---|
685 |
|
---|
686 | // uint16_t htobe16(uint16_t host_16bits);
|
---|
687 | // uint16_t htole16(uint16_t host_16bits);
|
---|
688 | // uint16_t be16toh(uint16_t big_endian_16bits);
|
---|
689 |
|
---|
690 |
|
---|
691 | cout << "\t 2. " << short_array[i] ;
|
---|
692 | cout << "\t arr. " << (int)array[2*i] << " " << (int)array[2*i+1] << endl;
|
---|
693 |
|
---|
694 | histo.SetBinContent(i, short_array[i]-1000);
|
---|
695 | }
|
---|
696 | histo.DrawCopy();
|
---|
697 | canvas->Modified();
|
---|
698 | canvas->Update();
|
---|
699 |
|
---|
700 | // int m = branch1->GetNumHiGainSamples();
|
---|
701 | // int n = branch1->GetNumBytesPerSample();
|
---|
702 |
|
---|
703 | cout << "GetNumHiGainSamples " << branch1->GetNumHiGainSamples()
|
---|
704 | << " GetNumBytesPerSample " << branch1->GetNumBytesPerSample() << endl;
|
---|
705 |
|
---|
706 | // tree->GetEntry(2);
|
---|
707 |
|
---|
708 | // array = branch1->GetSamples();
|
---|
709 |
|
---|
710 | // cout << "Branch2 " << branch1 << endl;
|
---|
711 |
|
---|
712 | //// for(int i = 1439; i < 1441; i++){
|
---|
713 | //// cout << "Pixel: " << i << endl;
|
---|
714 |
|
---|
715 | // for(int j = 431950; j < 432020; j++){
|
---|
716 | // cout << "Sl: " << j << "\t" ;
|
---|
717 | // cout << (unsigned short) array[j] << "\t";
|
---|
718 | // if ( j%5 == 0 ) cout <<endl;
|
---|
719 |
|
---|
720 | // }
|
---|
721 | // cout << endl;
|
---|
722 | //// }
|
---|
723 |
|
---|
724 | //// tree->SetBranchAddress("MRawEvtData.fHiGainFadcSamples.fArray", array);
|
---|
725 |
|
---|
726 | }
|
---|
727 |
|
---|
728 | */
|
---|
729 |
|
---|
730 |
|
---|
731 |
|
---|
732 |
|
---|