Changeset 14732
- Timestamp:
- 12/05/12 11:16:10 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/marsmacros/mc2csv/MonteCarlo.C
r14730 r14732 129 129 // mpSamples = NULL; 130 130 131 132 131 return; 133 132 } … … 178 177 mpRootFile = new TFile(mFileName, "READ"); 179 178 179 //check if root file could be opened 180 180 if (!mpRootFile->IsOpen()) 181 181 { … … 185 185 } 186 186 mRootFileOpend = true; 187 188 187 return 1; 189 188 } 190 189 190 191 191 void 192 192 MonteCarlo::CloseRootFile() 193 193 { 194 194 if (mVerbosityLvl > 0) cout << "...closing root file: " << mFileName << endl; 195 196 // close root file 197 // If option == "R", all TProcessIDs referenced by this file are deleted. 195 198 mpRootFile->Close("R"); 199 196 200 mpRootFile=NULL; 197 201 … … 199 203 } 200 204 205 201 206 void 202 207 MonteCarlo::LoadHeaderTree(TString treeName) … … 206 211 mpHeaderTree = (TTree*)mpRootFile->Get(treeName); 207 212 213 //check if mpHeaderTree exists 208 214 if (mpHeaderTree->IsZombie()) 209 215 { … … 280 286 } 281 287 288 282 289 void 283 290 MonteCarlo::ReadRunHeader() 284 291 { 292 // Read Values from RunHeader-Tree 293 285 294 if (mVerbosityLvl > 0) 286 295 cout << "...reading run header " << mpHeaderTree << endl; 287 296 288 //Read Values from RunHeader-Tree 289 290 mpHeaderTree->GetEntry(); //This causes problems 297 //Get first and only entry 298 mpHeaderTree->GetEntry(); 291 299 292 300 // ----------------------------------------------------------------------- 293 301 294 302 //Get values from "MGeomCam" Branch 303 if ( mpGeomCam != NULL) 304 { 295 305 //Getter functions from "MGeomCamFACT.h" 296 if ( mpGeomCam != NULL)297 {298 306 mCamDist = mpGeomCam->GetCameraDist(); 299 307 mNumberOfPixels = mpGeomCam->GetNumPixels(); … … 319 327 if ( mpMcRunHeader != NULL) 320 328 { 329 //Getter functions from "MMcRunHeader.hxx" 321 330 mNumSimulatedShowers = mpMcRunHeader->GetNumSimulatedShowers(); 322 331 } … … 342 351 if ( mpRawRunHeader != NULL) 343 352 { 344 mNumberOfEvents = mpRawRunHeader->GetNumEvents(); // couses problems 353 //Getter functions from "MRawRunHeader.h" 354 mNumberOfEvents = mpRawRunHeader->GetNumEvents(); 345 355 mNumberOfEventsRead = mpRawRunHeader->GetNumEventsRead(); 346 356 mSamplingFrequency = mpRawRunHeader->GetFreqSampling(); … … 360 370 if ( mpCorsikaRunHeader != NULL) 361 371 { 372 //Getter functions from "MCorsikaRunHeader.h" 362 373 mSlopeSpectrum = mpCorsikaRunHeader->GetSlopeSpectrum(); 363 374 mEnergyMin = mpCorsikaRunHeader->GetEnergyMin(); … … 374 385 375 386 // delete Pixel Array before you set refferences for a new one 387 // in case it is existing 376 388 if (mpPixel != NULL) 377 389 { … … 387 399 if (mVerbosityLvl > 1) cout << " ...reading pedestal offsets" << endl; 388 400 389 // Read Pedestal Offset401 // Loop over all pixel: Read Pedestal Offset 390 402 for ( int i = 0; i < mNumberOfPixels; i++ ) 391 403 { 404 // check if array entry exists 392 405 if ( &(mpElectronicNoise[0][i]) != NULL) 406 { 407 //tricky stuff!!! 408 // mpElectronicNoise is a MPedestalCam Array 409 // individual pixel pedestals are stored in a MPedestalPix array 410 // the [] operator is overloaded in MPedestalCam 411 // and returning a MPedestalPix at position [i] 412 // MPedestalPix hast a Getter called GetPedestal() 393 413 mpPixel[i].pedestal = mpElectronicNoise[0][i].GetPedestal(); 414 } 394 415 else if (mVerbosityLvl > 2) 416 { 395 417 cout << " ...cannot read pedestal offset" << endl; 418 } 396 419 } 397 420 } … … 486 509 if ( mpIncidentAngle != NULL) 487 510 { 511 //Getter functions from "MGeomCamFACT.h" 488 512 mIncidentAngle = mpIncidentAngle->GetVal(); 489 513 } … … 519 543 if ( mpRawEventHeader != NULL) 520 544 { 545 //Getter functions from "MRawEventHeader.h" 521 546 mEventNumber = mpRawEventHeader->GetDAQEvtNumber(); 522 547 mNumTriggerLvl1 = mpRawEventHeader->GetNumTrigLvl1(); … … 531 556 if ( mpCorsikaEvtHeader != NULL) 532 557 { 558 //Getter functions from "MCorsikaEvtHeader.h" 533 559 mFirstInteractionHeight = mpCorsikaEvtHeader->GetFirstInteractionHeight(); 534 560 mEvtReuse = mpCorsikaEvtHeader->GetNumReuse(); … … 560 586 561 587 // delete Pixel Array before you set refferences for a new one 588 // in case it is existing 562 589 if (mpPixel != NULL) 563 590 { … … 574 601 } 575 602 603 // you have to set this before you can read information 604 // from a magic binary file 576 605 mpRawEventData->InitRead(mpRawRunHeader); 577 606 … … 580 609 // ----------------------------------------------------------------------- 581 610 611 //array to contain alle samples of all pixel of a event 582 612 unsigned short* all_raw_data = NULL; 583 613 584 614 if ( mpRawEventData != NULL) 585 615 { 616 // point raw data array to RawEventData Array in Event Tree 586 617 all_raw_data = (unsigned short*) mpRawEventData->GetSamples(); 618 /* 587 619 // FADC samples (hi gain) of all pixels 588 620 // This is an array of Byte_t variables. The value of a FADC sample has a … … 593 625 // i-th FADC sample of the j-th pixel are stored in the n consecutive 594 626 // positions of this array, starting from fHiGainFadcSamples[j*n*m+i*n] 627 */ 595 628 } 596 629 else cout << "...cannot read event raw data" << endl; … … 601 634 cout << "...pixel progress: "; 602 635 636 //Loop over all camera pixel and read eEvent raw data, pixel ID and pedestal offset 603 637 for ( int i = 0; i < mNumberOfPixels; i++ ) 604 638 { … … 610 644 } 611 645 612 // Read Pedestal Offset 646 // Read Pedestal Offset and store it in classes pixel_t array 613 647 if ( mpElectronicNoise != NULL) 614 648 { … … 617 651 else cout << "...cannot read pedestal offset" << endl; 618 652 619 // Read Pixel SoftId 653 // Read Pixel SoftId and store it in classes pixel_t array 620 654 if ( mpRawEventData != NULL) 621 655 { … … 626 660 pix_first_sample = i*mNumberOfSamples; 627 661 628 // point beginning of pixel's rawdata array toaddress629 // of pixel's first sample's adress 662 // point beginning of class' pixel_t array to the address 663 // of pixel's first sample's adress in TTree 630 664 mpPixel[i].rawData = &(all_raw_data[pix_first_sample]); 631 665 … … 650 684 mpEventTree->GetEntry(Event); 651 685 686 //Get Event header data from TTree 652 687 ReadEventMetaData(); 688 689 //Get Event raw data from TTree 653 690 ReadEventRawData(); 654 691 … … 707 744 WriteEventDataInfo2Csv(); 708 745 709 // for (int evt = 0; evt < mNumberOfEvents; evt++) 746 // loop over all events from tree and write content to csv 747 // for (int evt = 0; evt < mNumberOfEvents; evt++) 710 748 for (int evt = 0; evt < mNumberOfEntries; evt++) 711 749 { … … 884 922 mCsv << "pixelID" << mSeparator; 885 923 // mCsv << "pixelPedestal" << mSeparator; 924 925 // Loop over number of all samples in pixel 886 926 for (int i = 0; i < mNumberOfSamples; i++) 887 927 { … … 898 938 if (mVerbosityLvl > 0) cout << "...writing event data to csv" << endl; 899 939 900 // Loop over pixels and write pixeldata to csv940 // Loop over all pixels and write pixeldata to csv 901 941 for (int i = 0; i < mNumberOfPixels; i++) 902 942 { … … 915 955 // mCsv << mpPixel[pixelID].pedestal << mSeparator; 916 956 957 // Loop over number of all samples in pixel and write samples content to csv 917 958 for (int i = 0; i < mNumberOfSamples; i++) 918 959 { … … 938 979 if (mVerbosityLvl > 3) cout << "...writing pedestal info to csv" << endl; 939 980 981 // Loop over all pixels and write pixel pedestal to csv 940 982 for (int pixelID = 0; pixelID < mNumberOfPixels; pixelID++) 941 983 {
Note:
See TracChangeset
for help on using the changeset viewer.