Changeset 10165 for trunk/Mars/mcorsika
- Timestamp:
- 02/21/11 08:24:37 (14 years ago)
- Location:
- trunk/Mars/mcorsika
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcorsika/MCorsikaRead.cc
r10147 r10165 390 390 return kFALSE; 391 391 392 gLog << "Next fBlock: type=" << fBlockType << " version=" << fBlockVersion;393 gLog << " identifier=" << fBlockIdentifier << " length=" << fBlockLength;394 gLog << " readState= " << fReadState << endl;392 // gLog << "Next fBlock: type=" << fBlockType << " version=" << fBlockVersion; 393 // gLog << " identifier=" << fBlockIdentifier << " length=" << fBlockLength; 394 // gLog << " readState= " << fReadState << endl; 395 395 396 396 if (fReadState == 3 && fBlockType != 1210) … … 665 665 } 666 666 667 // --------------------------------------------------------------------------668 //669 // The Process reads one event from the binary file:670 // - The event header is read671 // - the run header is read672 // - all crate information is read673 // - the raw data information of one event is read674 //675 Int_t MCorsikaRead::Process_Old()676 {677 678 if (fReadState == 11)679 {680 // we are currently saving the events of the raw format in the root file681 if (fEvtHeader->GetNumReuse() == fRunHeader->GetNumReuse())682 {683 // all data are saved684 fRawEvemtBuffer.resize(0);685 fReadState = 3;686 }687 else688 {689 fEvtHeader->InitXY();690 Int_t rc = fEvent->ReadCorsikaEvt(&fRawEvemtBuffer[0],691 fRawEvemtBuffer.size() / 7,692 fEvtHeader->GetNumReuse()+1);693 fEvtHeader->IncNumReuse();694 return rc;695 }696 }697 698 while (1)699 {700 if (fInFormat)701 {702 703 while (fInFormat->NextBlock(fReadState == 4, fBlockType, fBlockVersion,704 fBlockIdentifier, fBlockLength))705 {706 gLog << "Next fBlock: type=" << fBlockType << " version=" << fBlockVersion;707 gLog << " identifier=" << fBlockIdentifier << " length=" << fBlockLength << endl;708 709 710 if (fReadState == 4)711 {712 fTopBlockLength -= fBlockLength + 12;713 if (fTopBlockLength <= 0)714 // all data of a top block are read, go back to normal state715 fReadState = 3;716 }717 718 Int_t status = kTRUE;719 switch (fBlockType)720 {721 case 1200: // the run header722 status = fRunHeader->ReadEvt(fInFormat);723 fReadState = 1; // RUNH is read724 break;725 726 case 1201: // telescope position727 status = ReadTelescopePosition();728 sleep(5);729 break;730 731 case 1202: // the event header732 Float_t buffer[272];733 if (!fInFormat->Read(buffer, 272 * sizeof(Float_t)))734 return kFALSE;735 736 if (fReadState == 1) // first event after RUN header737 {738 fRunHeader->ReadEventHeader(buffer);739 fRunHeader->Print();740 }741 742 status = fEvtHeader->ReadEvt(buffer);743 if (fArrayIdx >= (Int_t)fEvtHeader->GetTotReuse())744 {745 *fLog << err << "ERROR - Requested array index " << fArrayIdx <<746 " exceeds number of arrays " << fEvtHeader->GetTotReuse() <<747 " in file." << endl;748 return kERROR;749 }750 751 752 fReadState = 2;753 break;754 755 case 1204:756 if (fArrayIdx < 0 || fArrayIdx == fBlockIdentifier)757 {758 fReadState = 4;759 fTopBlockLength = fBlockLength;760 }761 else762 // skip this array of telescopes763 fInFormat->Seek(fBlockLength);764 765 break;766 767 case 1205:768 {769 Int_t telIdx = fBlockIdentifier % 1000;770 if (fBlockVersion == 0 &&771 (fTelescopeIdx < 0 || fTelescopeIdx == telIdx) )772 {773 status = fEvent->ReadEventIoEvt(fInFormat);774 775 Int_t arrayIdx = fBlockIdentifier / 1000;776 Float_t xArrOff, yArrOff;777 fEvtHeader->GetArrayOffset(arrayIdx, xArrOff, yArrOff);778 fEvtHeader->SetTelescopeOffset(arrayIdx,779 xArrOff + fTelescopeY[telIdx],780 yArrOff - fTelescopeX[telIdx] );781 fEvent->AddXY(xArrOff + fTelescopeY[telIdx],782 yArrOff - fTelescopeX[telIdx]);783 fEvent->SimWavelength(fRunHeader->GetWavelengthMin(),784 fRunHeader->GetWavelengthMax());785 786 if (status == kTRUE)787 // end of reading for one telescope in one array ==788 // end of this Process - step789 return status;790 }791 else792 // skip this telescope793 fInFormat->Seek(fBlockLength);794 }795 break;796 797 case 1209: // the event end798 status = fEvtHeader->ReadEvtEnd(fInFormat);799 if (fReadState == 10 || fReadState == 2)800 {801 // all particles of this event are read, now save them802 fReadState = 11;803 fEvtHeader->ResetNumReuse();804 805 fEvtHeader->InitXY();806 Int_t rc = fEvent->ReadCorsikaEvt(&fRawEvemtBuffer[0],807 fRawEvemtBuffer.size() / 7,808 fEvtHeader->GetNumReuse()+1);809 fEvtHeader->IncNumReuse();810 return rc;811 }812 else813 fReadState = 3; // event closed, run still open814 break;815 816 case 1210: // the run end817 status = fRunHeader->ReadEvtEnd(fInFormat, kTRUE);818 fNumEvents += fRunHeader->GetNumEvents();819 fRunHeader->SetReadyToSave();820 fReadState = 5; // back to starting point821 return status;822 break;823 824 case 1105: // event block of raw format825 if (fReadState == 2 || fReadState == 10)826 {827 Int_t oldSize = fRawEvemtBuffer.size();828 fRawEvemtBuffer.resize(oldSize + fBlockLength / sizeof(Float_t));829 status = fInFormat->Read(&fRawEvemtBuffer[oldSize], fBlockLength);830 fReadState = 10;831 }832 else833 fInFormat->Seek(fBlockLength);834 break;835 836 default:837 // unknown block, we skip it838 fInFormat->Seek(fBlockLength);839 840 }841 842 if (status != kTRUE)843 return status;844 845 }846 847 }848 849 //850 // If an event could not be read from file try to open new file851 //852 const Int_t rc = OpenNextFile();853 if (rc!=kTRUE)854 return rc;855 }856 return kTRUE;857 }858 667 859 668 // -------------------------------------------------------------------------- -
trunk/Mars/mcorsika/MCorsikaRead.h
r10147 r10165 76 76 Int_t PreProcess(MParList *pList); 77 77 Int_t Process(); 78 Int_t Process_Old();79 78 Int_t PostProcess(); 80 79
Note:
See TracChangeset
for help on using the changeset viewer.