Changeset 14625 for fact/tools/marsmacros
- Timestamp:
- 11/15/12 13:43:07 (12 years ago)
- Location:
- fact/tools/marsmacros/mc2csv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/marsmacros/mc2csv/MonteCarlo.C
r14610 r14625 17 17 18 18 OpenRootFile(); 19 if ( !mRootFileOpend ) return; 19 20 20 21 LoadEventTree( "Events"); … … 36 37 37 38 OpenRootFile(); 39 if ( !mRootFileOpend ) return; 38 40 39 41 LoadEventTree( evtsTreeName); … … 56 58 57 59 OpenRootFile(); 60 if ( !mRootFileOpend ) return; 58 61 59 62 LoadEventTree( evtsTreeName); … … 84 87 // source file 85 88 mpRootFile = NULL; 89 mRootFileOpend = false; 86 90 87 91 // Trees … … 141 145 { 142 146 cout << "ERROR - Could not find file " << mFileName << endl; 147 mRootFileOpend =false; 143 148 return ; 144 149 } 150 mRootFileOpend = true; 145 151 146 152 return; … … 192 198 } 193 199 200 // ======================================================================= 194 201 //Set Adresses to Branches in RunHeader-Tree 202 203 // ----------------------------------------------------------------------- 204 205 // MGeomCam 195 206 if ( mpHeaderTree->GetBranchStatus("MGeomCam.") ) 196 207 { … … 198 209 mpHeaderTree->SetBranchAddress("MGeomCam.", &mpGeomCam); 199 210 } 211 212 // ----------------------------------------------------------------------- 213 214 // IntendedPulsePos 200 215 if ( mpHeaderTree->GetBranchStatus("IntendedPulsePos.") ) 201 216 { … … 203 218 mpHeaderTree->SetBranchAddress("IntendedPulsePos.", &mpIntendedPulsePos); 204 219 } 220 221 // ----------------------------------------------------------------------- 222 223 // MMcRunHeader 205 224 if ( mpHeaderTree->GetBranchStatus("MMcRunHeader.") ) 206 225 { … … 208 227 mpHeaderTree->SetBranchAddress("MMcRunHeader.", &mpMcRunHeader); 209 228 } 229 230 // ----------------------------------------------------------------------- 231 232 // ElectronicNoise 210 233 if ( mpHeaderTree->GetBranchStatus("ElectronicNoise.") ) 211 234 { … … 213 236 mpHeaderTree->SetBranchAddress("ElectronicNoise.", &mpElectronicNoise); 214 237 } 238 239 // ----------------------------------------------------------------------- 240 241 // MRawRunHeader 215 242 if ( mpHeaderTree->GetBranchStatus("MRawRunHeader.") ) 216 243 { … … 218 245 mpHeaderTree->SetBranchAddress("MRawRunHeader.", &mpRawRunHeader); 219 246 } 247 248 // ----------------------------------------------------------------------- 249 250 // MCorsikaRunHeader 220 251 if ( mpHeaderTree->GetBranchStatus("MCorsikaRunHeader.") ) 221 252 { … … 224 255 } 225 256 257 // ======================================================================= 258 226 259 return; 227 260 } … … 237 270 mpHeaderTree->GetEntry(); //This causes problems 238 271 272 // ----------------------------------------------------------------------- 239 273 240 274 //Get values from "MGeomCam" Branch 241 275 //Getter functions from "MGeomCamFACT.h" 242 mCamDist = mpGeomCam->GetCameraDist(); 243 mNumberOfPixels = mpGeomCam->GetNumPixels(); 244 mNumberOfSectors = mpGeomCam->GetNumSectors(); 245 mNumberOfAreas = mpGeomCam->GetNumAreas(); 276 if ( mpGeomCam != NULL) 277 { 278 mCamDist = mpGeomCam->GetCameraDist(); 279 mNumberOfPixels = mpGeomCam->GetNumPixels(); 280 mNumberOfSectors = mpGeomCam->GetNumSectors(); 281 mNumberOfAreas = mpGeomCam->GetNumAreas(); 282 } 283 else if (mVerbosityLvl > 2) 284 cout << "...could not read data from: MGeomCam" << endl; 285 286 // ----------------------------------------------------------------------- 246 287 247 288 //Get values from "IntendedPulsePos" Branch 248 mIntendedPulsePos = mpIntendedPulsePos->GetVal(); 289 if ( mpIntendedPulsePos != NULL) 290 { 291 mIntendedPulsePos = mpIntendedPulsePos->GetVal(); 292 } 293 else if (mVerbosityLvl > 2) 294 cout << "...could not read data from: IntendedPulsePos" << endl; 295 296 // ----------------------------------------------------------------------- 249 297 250 298 //Get values from "MMcRunHeader" Branch from event Tree 251 mNumSimulatedShowers = mpMcRunHeader->GetNumSimulatedShowers(); 299 if ( mpMcRunHeader != NULL) 300 { 301 mNumSimulatedShowers = mpMcRunHeader->GetNumSimulatedShowers(); 302 } 303 else if (mVerbosityLvl > 2) 304 cout << "...could not read data from: MMcRunHeader" << endl; 305 306 // ----------------------------------------------------------------------- 252 307 253 308 //Get number of Events from event Tree 254 mNumberOfEntries = mpEventTree->GetEntries(); 309 if ( mpEventTree != NULL) 310 { 311 mNumberOfEntries = mpEventTree->GetEntries(); 312 } 313 else if (mVerbosityLvl > 2) 314 cout << "...could not read number of Events from event Tree" << endl; 315 255 316 if (mVerbosityLvl > 0) 256 317 cout << "Event Tree has " << mNumberOfEntries << " entries" << endl; 257 318 319 // ----------------------------------------------------------------------- 320 258 321 //Get values from "MRawRunHeader" Branch 259 mNumberOfEvents = mpRawRunHeader->GetNumEvents(); // couses problems 260 mNumberOfEventsRead = mpRawRunHeader->GetNumEventsRead(); 261 mSamplingFrequency = mpRawRunHeader->GetFreqSampling(); 262 mSourceName = mpRawRunHeader->GetSourceName(); 263 mFileNumber = mpRawRunHeader->GetFileNumber(); 264 mNumberOfSamples = mpRawRunHeader->GetNumSamplesHiGain(); 265 mNumberOfBytes = mpRawRunHeader->GetNumBytesPerSample(); 266 mRunNumber = mpRawRunHeader->GetRunNumber(); 267 mRunType = mpRawRunHeader->GetRunType(); 268 322 if ( mpRawRunHeader != NULL) 323 { 324 mNumberOfEvents = mpRawRunHeader->GetNumEvents(); // couses problems 325 mNumberOfEventsRead = mpRawRunHeader->GetNumEventsRead(); 326 mSamplingFrequency = mpRawRunHeader->GetFreqSampling(); 327 mSourceName = mpRawRunHeader->GetSourceName(); 328 mFileNumber = mpRawRunHeader->GetFileNumber(); 329 mNumberOfSamples = mpRawRunHeader->GetNumSamplesHiGain(); 330 mNumberOfBytes = mpRawRunHeader->GetNumBytesPerSample(); 331 mRunNumber = mpRawRunHeader->GetRunNumber(); 332 mRunType = mpRawRunHeader->GetRunType(); 333 } 334 else if (mVerbosityLvl > 2) 335 cout << "...could not read data from: MRawRunHeader" << endl; 336 337 // ----------------------------------------------------------------------- 269 338 270 339 //Get values from "MCorsikaRunHeader" Branch 271 mSlopeSpectrum = mpCorsikaRunHeader->GetSlopeSpectrum(); 272 mEnergyMin = mpCorsikaRunHeader->GetEnergyMin(); 273 mEnergyMax = mpCorsikaRunHeader->GetEnergyMax(); 274 mZdMin = mpCorsikaRunHeader->GetZdMin(); 275 mZdMax = mpCorsikaRunHeader->GetZdMax(); 276 mAzMin = mpCorsikaRunHeader->GetAzMin(); 277 mAzMax = mpCorsikaRunHeader->GetAzMax(); 340 if ( mpCorsikaRunHeader != NULL) 341 { 342 mSlopeSpectrum = mpCorsikaRunHeader->GetSlopeSpectrum(); 343 mEnergyMin = mpCorsikaRunHeader->GetEnergyMin(); 344 mEnergyMax = mpCorsikaRunHeader->GetEnergyMax(); 345 mZdMin = mpCorsikaRunHeader->GetZdMin(); 346 mZdMax = mpCorsikaRunHeader->GetZdMax(); 347 mAzMin = mpCorsikaRunHeader->GetAzMin(); 348 mAzMax = mpCorsikaRunHeader->GetAzMax(); 349 } 350 else if (mVerbosityLvl > 2) 351 cout << "...could not read data from: MCorsikaRunHeader" << endl; 278 352 279 353 return; … … 293 367 } 294 368 295 369 // ======================================================================= 296 370 //Set Adresses to Branches in Events-Tree 371 297 372 if (mVerbosityLvl > 1) cout << "...SetBranchAddresses:" << endl; 298 373 374 // ----------------------------------------------------------------------- 375 376 // MRawEvtData 299 377 if ( mpEventTree->GetBranchStatus("MRawEvtData.") != -1 ) 300 378 { … … 302 380 mpEventTree->SetBranchAddress("MRawEvtData.", &mpRawEventData); 303 381 } 382 else cout << "...could not load branch: MRawEvtData" << endl; 383 384 // ----------------------------------------------------------------------- 385 386 // IncidentAngle 304 387 if ( mpEventTree->GetBranchStatus("IncidentAngle.") ) 305 388 { … … 309 392 mpEventTree->SetBranchAddress("IncidentAngle.", &mpIncidentAngle); 310 393 } 394 else cout << "...could not load branch: IncidentAngle" << endl; 395 396 // ----------------------------------------------------------------------- 397 398 // MMcEvt 311 399 if ( mpEventTree->GetBranchStatus("MMcEvt.") ) 312 400 { … … 314 402 mpEventTree->SetBranchAddress("MMcEvt.", &mpMcEventMetaData); 315 403 } 404 else cout << "...could not load branch: McEvt" << endl; 405 406 // ----------------------------------------------------------------------- 407 408 // MRawEvtHeader 316 409 if ( mpEventTree->GetBranchStatus("MRawEvtHeader.") ) 317 410 { … … 319 412 mpEventTree->SetBranchAddress("MRawEvtHeader.", &mpRawEventHeader); 320 413 } 414 else cout << "...could not load branch: MRawEvtHeader" << endl; 415 416 // ----------------------------------------------------------------------- 417 418 // MCorsikaEvtHeader 321 419 if ( mpEventTree->GetBranchStatus("MCorsikaEvtHeader.") ) 322 420 { … … 324 422 mpEventTree->SetBranchAddress("MCorsikaEvtHeader.", &mpCorsikaEvtHeader); 325 423 } 424 else cout << "...could not load branch: MCorsikaEvtHeader" << endl; 425 426 // ======================================================================= 326 427 327 428 return; … … 331 432 MonteCarlo::ReadEventMetaData() 332 433 { 333 if (mVerbosityLvl > 1) cout << "...reading event header" << endl; 434 if (mVerbosityLvl > 1) 435 cout << "...reading event header" << endl; 334 436 335 437 //Get values from "MGeomCamFACT" Branch 336 mIncidentAngle = mpIncidentAngle->GetVal(); 438 if ( mpIncidentAngle != NULL) 439 { 440 mIncidentAngle = mpIncidentAngle->GetVal(); 441 } 442 else if (mVerbosityLvl > 2) 443 cout << "...could not read data from: MGeomCamFACT" << endl; 444 445 // ----------------------------------------------------------------------- 337 446 338 447 //Get values from "MMcEvt" Branch 448 if ( mpMcEventMetaData != NULL) 449 { 339 450 //The following Getter Functions can be found in MMcEvt.h 340 mCorsikaEventNumber = mpMcEventMetaData->GetEvtNumber(); 341 mPhotElFromShower = mpMcEventMetaData->GetPhotElfromShower(); 342 mPhotElinCamera = mpMcEventMetaData->GetPhotElinCamera(); 343 //The following Getter Functions can be found in MMcEvtBasic.h 344 mPartId = mpMcEventMetaData->GetPartId(); 345 mPartName = mpMcEventMetaData->GetParticleName(mPartId); 346 mPartSymbol = mpMcEventMetaData->GetParticleSymbol(mPartId); 347 mEnergy = mpMcEventMetaData->GetEnergy(); 348 mImpact = mpMcEventMetaData->GetImpact(); 349 mTelescopePhi = mpMcEventMetaData->GetTelescopePhi(); 350 mTelescopeTheta = mpMcEventMetaData->GetTelescopeTheta(); 351 mPhi = mpMcEventMetaData->GetParticlePhi(); 352 mTheta = mpMcEventMetaData->GetParticleTheta(); 451 mCorsikaEventNumber = mpMcEventMetaData->GetEvtNumber(); 452 mPhotElFromShower = mpMcEventMetaData->GetPhotElfromShower(); 453 mPhotElinCamera = mpMcEventMetaData->GetPhotElinCamera(); 454 //The following Getter Functions can be found in MMcEvtBasic.h 455 mPartId = mpMcEventMetaData->GetPartId(); 456 mPartName = mpMcEventMetaData->GetParticleName(mPartId); 457 mPartSymbol = mpMcEventMetaData->GetParticleSymbol(mPartId); 458 mEnergy = mpMcEventMetaData->GetEnergy(); 459 mImpact = mpMcEventMetaData->GetImpact(); 460 mTelescopePhi = mpMcEventMetaData->GetTelescopePhi(); 461 mTelescopeTheta = mpMcEventMetaData->GetTelescopeTheta(); 462 mPhi = mpMcEventMetaData->GetParticlePhi(); 463 mTheta = mpMcEventMetaData->GetParticleTheta(); 464 } 465 else if (mVerbosityLvl > 2) 466 cout << "...could not read data from: MMcEvt" << endl; 467 468 // ----------------------------------------------------------------------- 353 469 354 470 //Get values from "MRawEventHeader" Branch 355 mEventNumber = mpRawEventHeader->GetDAQEvtNumber(); 356 mNumTriggerLvl1 = mpRawEventHeader->GetNumTrigLvl1(); 357 mNumTriggerLvl2 = mpRawEventHeader->GetNumTrigLvl2(); 471 if ( mpRawEventHeader != NULL) 472 { 473 mEventNumber = mpRawEventHeader->GetDAQEvtNumber(); 474 mNumTriggerLvl1 = mpRawEventHeader->GetNumTrigLvl1(); 475 mNumTriggerLvl2 = mpRawEventHeader->GetNumTrigLvl2(); 476 } 477 else if (mVerbosityLvl > 2) 478 cout << "...could not read data from: MRawEventHeader" << endl; 479 480 // ----------------------------------------------------------------------- 358 481 359 482 //Get values from "MCorsikaEvtHeader" Branch 360 mFirstInteractionHeight = mpCorsikaEvtHeader->GetFirstInteractionHeight(); 361 mEvtReuse = mpCorsikaEvtHeader->GetNumReuse(); 362 mMomentumX = mpCorsikaEvtHeader->GetMomentum().X(); 363 mMomentumY = mpCorsikaEvtHeader->GetMomentum().Y(); 364 mMomentumZ = mpCorsikaEvtHeader->GetMomentum().Z(); 365 mZd = mpCorsikaEvtHeader->GetZd(); 366 mAz = mpCorsikaEvtHeader->GetAz(); 367 mX = mpCorsikaEvtHeader->GetX(); 368 mY = mpCorsikaEvtHeader->GetY(); 369 370 // mWeightedNumPhotons = mpCorsikaEvtHeader->Get; 483 if ( mpCorsikaEvtHeader != NULL) 484 { 485 mFirstInteractionHeight = mpCorsikaEvtHeader->GetFirstInteractionHeight(); 486 mEvtReuse = mpCorsikaEvtHeader->GetNumReuse(); 487 mMomentumX = mpCorsikaEvtHeader->GetMomentum().X(); 488 mMomentumY = mpCorsikaEvtHeader->GetMomentum().Y(); 489 mMomentumZ = mpCorsikaEvtHeader->GetMomentum().Z(); 490 mZd = mpCorsikaEvtHeader->GetZd(); 491 mAz = mpCorsikaEvtHeader->GetAz(); 492 mX = mpCorsikaEvtHeader->GetX(); 493 mY = mpCorsikaEvtHeader->GetY(); 494 } 495 else if (mVerbosityLvl > 2) 496 cout << "...could not read data from: MCorsikaEvtHeader" << endl; 497 498 // ----------------------------------------------------------------------- 499 500 // mWeightedNumPhotons = mpCorsikaEvtHeader->Get; 371 501 // no getter function, no idea how to extract information 372 502 … … 378 508 { 379 509 if (mVerbosityLvl > 1) cout << "...reading event raw data" << endl; 510 511 // ----------------------------------------------------------------------- 380 512 381 513 // delete Pixel Array before you set refferences for a new one … … 386 518 mpPixel = new pixel_t[mNumberOfPixels]; 387 519 520 // ----------------------------------------------------------------------- 521 522 if ( mpRawEventData == NULL) 523 { 524 cout << "ERROR: cannot read event data" << endl; 525 return; 526 } 527 388 528 mpRawEventData->InitRead(mpRawRunHeader); 389 529 … … 391 531 // int pix_last_sample; 392 532 533 // ----------------------------------------------------------------------- 534 393 535 unsigned short* all_raw_data = NULL; 394 536 395 all_raw_data = (unsigned short*) mpRawEventData->GetSamples(); 537 if ( mpRawEventData != NULL) 538 { 539 all_raw_data = (unsigned short*) mpRawEventData->GetSamples(); 540 } 541 else cout << "...cannot read event raw data" << endl; 542 543 // ----------------------------------------------------------------------- 396 544 397 545 if (mVerbosityLvl > 1) … … 407 555 } 408 556 409 410 mpPixel[i].pedestal = mpElectronicNoise[0][i].GetPedestal(); 411 mpPixel[i].SoftId = mpRawEventData->GetPixelIds()[i]; 557 // Read Pedestal Offset 558 if ( mpElectronicNoise != NULL) 559 { 560 mpPixel[i].pedestal = mpElectronicNoise[0][i].GetPedestal(); 561 } 562 else cout << "...cannot read pedestal offset" << endl; 563 564 // Read Pixel SoftId 565 if ( mpRawEventData != NULL) 566 { 567 mpPixel[i].SoftId = mpRawEventData->GetPixelIds()[i]; 568 } 569 else cout << "...cannot read pixel id" << endl; 412 570 413 571 pix_first_sample = i*mNumberOfSamples; … … 415 573 // point beginning of pixel's rawdata array to address 416 574 // of pixel's first sample's adress 417 418 575 mpPixel[i].rawData = &(all_raw_data[pix_first_sample]); 419 420 // for (int j = pix_first_sample; j < pix_last_sample; j++)421 // {422 // cout << mpPixel[i].rawData[j] << " ";423 // }424 // cout << endl;425 426 // // this could be improved by427 // DONE BUT NOT TESTED428 // for (int j = i*mSampleSize; j < (i+1)*mSampleSize; j++)429 // {430 // }431 576 } 432 577 … … 459 604 MonteCarlo::WriteMc2Csv(TString filename) 460 605 { 606 if ( !mRootFileOpend ){ 607 cout << "ERROR - no rootfile loaded, no data loaded, cannot write csv" 608 << endl; 609 return; 610 } 611 461 612 cout << "...writing mc to csv: " << filename << endl; 462 613 cout << "...processing " << mNumberOfEntries << "Events" << endl; -
fact/tools/marsmacros/mc2csv/MonteCarlo.h
r14605 r14625 142 142 private: 143 143 int mVerbosityLvl; 144 bool mRootFileOpend; 144 145 145 146 TString mCsvFileName;
Note:
See TracChangeset
for help on using the changeset viewer.