Changeset 8946 for trunk/MagicSoft/Mars/mraw
- Timestamp:
- 06/12/08 17:56:54 (17 years ago)
- Location:
- trunk/MagicSoft/Mars/mraw
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mraw/MRawRunHeader.cc
r8941 r8946 18 18 ! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 720 ! Copyright: MAGIC Software Development, 2000-2008 21 21 ! 22 22 ! … … 32 32 // RAW DATA FORMAT VERSION 33 33 // ======================= 34 // 35 // Format Version 11: 36 // ----------------- 37 // * all variables got four bytes 38 // * header sizes allow to make the format backward compatible 39 // + fHeaderSizeRun 40 // + fHeaderSizeEvt 41 // + fHeaderSizeCrate 42 // + fFileNumber 43 // + fNumSamplesRemovedHead 44 // + fNumSamplesRemovedTail 45 // 46 // Format Version 10: 47 // ----------------- 48 // ? 34 49 // 35 50 // Format Version 9: … … 81 96 // MRawRunHeader CLASS VERSION 82 97 // =========================== 98 // 99 // Format Version 10: 100 // ----------------- 101 // - added fHeaderSizeRun 102 // - added fHeaderSizeEvt 103 // - added fHeaderSizeCrate 104 // - added fFileNumber 105 // - increased fSourceEpochChar 83 106 // 84 107 // Format Version 7: … … 127 150 #include <iomanip> 128 151 152 #include <TArrayC.h> 153 129 154 #include "MLog.h" 130 155 #include "MLogManip.h" … … 137 162 138 163 const UShort_t MRawRunHeader::kMagicNumber = 0xc0c0; 139 const Byte_t MRawRunHeader::kMaxFormatVersion = 9;164 const Byte_t MRawRunHeader::kMaxFormatVersion = 11; 140 165 141 166 // -------------------------------------------------------------------------- … … 162 187 fRunType=kRTNone; // use 0xffff for invalidation, 0 means: Data run 163 188 fRunNumber=0; 189 fFileNumber=0; 164 190 memset(fProjectName, 0, 101); 165 191 memset(fSourceName, 0, 81); … … 329 355 // "corrected" also in the signal. Hence signal swapped since 99354 330 356 // 331 // --------------------------------------------------------------------------332 333 357 Bool_t MRawRunHeader::FixAssignment() 334 358 { … … 374 398 // -------------------------------------------------------------------------- 375 399 // 376 // Read in one run header from the binary file 377 // 378 Bool_t MRawRunHeader::ReadEvt(istream& fin) 379 { 380 // 381 // read one RUN HEADER from the input stream 382 // 383 fMagicNumber = 0; 384 385 fin.read((char*)&fMagicNumber, 2); // Total=2 386 387 // 388 // check whether the the file has the right file type or not 389 // 390 if (fMagicNumber != kMagicNumber && fMagicNumber != kMagicNumber+1) 391 { 392 *fLog << err << "ERROR - Wrong Magic Number (0x" << hex << fMagicNumber << "): Not a Magic File!" << endl; 393 return kFALSE; 394 } 395 396 if (fMagicNumber == kMagicNumber+1) 397 *fLog << warn << "WARNING - This file maybe broken (0xc0c1) - DAQ didn't close it correctly!" << endl; 398 399 Byte_t dummy[16]; 400 401 // ----- File format version ----- 402 fin.read((char*)&fFormatVersion, 2); // Total=4 403 if (fFormatVersion>kMaxFormatVersion) 404 { 405 *fLog << err << "ERROR - File format V" << fFormatVersion << " not implemented!" << endl; 406 return kFALSE; 407 } 408 400 // Reading function to read/interpret the file formats 1-10 401 // 402 Bool_t MRawRunHeader::ReadEvtOld(istream& fin) 403 { 409 404 if (fFormatVersion==7) 410 405 { … … 477 472 fin.read((char*)&fNumSamplesHiGain, 2); // MUX: Number of samples per pixel 478 473 474 char dummy[16]; 479 475 if (fFormatVersion>8) 480 fin.read( (char*)dummy, 4); // 2xU16 (NumSamplesRemovedHead and NumSamplesRemovedTail)476 fin.read(dummy, 4); // 2xU16 (NumSamplesRemovedHead and NumSamplesRemovedTail) 481 477 482 478 // ----- Number of events ----- … … 526 522 527 523 if (fFormatVersion<7) 528 fin.read((char*)&dummy, 16); 524 fin.read(dummy, 16); 525 526 return FixAssignment(); 527 } 528 529 // -------------------------------------------------------------------------- 530 // 531 // Read in one run header from the binary file 532 // 533 Bool_t MRawRunHeader::ReadEvt(istream& fin) 534 { 535 // 536 // read one RUN HEADER from the input stream 537 // 538 fMagicNumber = 0; 539 540 fin.read((char*)&fMagicNumber, 2); // Total=2 541 542 // 543 // check whether the the file has the right file type or not 544 // 545 if (fMagicNumber != kMagicNumber && fMagicNumber != kMagicNumber+1) 546 { 547 *fLog << err << "ERROR - Wrong Magic Number (0x" << hex << fMagicNumber << "): Not a Magic File!" << endl; 548 return kFALSE; 549 } 550 551 if (fMagicNumber == kMagicNumber+1) 552 *fLog << warn << "WARNING - This file maybe broken (0xc0c1) - DAQ didn't close it correctly!" << endl; 553 554 // ----- File format version ----- 555 fin.read((char*)&fFormatVersion, 2); // Total=4 556 if (fFormatVersion==10 || fFormatVersion>kMaxFormatVersion) 557 { 558 *fLog << err << "ERROR - File format V" << fFormatVersion << " not implemented!" << endl; 559 return kFALSE; 560 } 561 562 // ----- Process old file formats ----- 563 if (fFormatVersion<10) 564 return ReadEvtOld(fin); 565 566 // ----- Overwrite format version for format 11 ----- 567 fin.read((char*)&fFormatVersion, 4); 568 if (fFormatVersion<11) 569 { 570 *fLog << err << "ERROR - Format Version <11." << endl; 571 return kFALSE; 572 } 573 574 // ----- Read Header by size as written in the header ----- 575 fin.read((char*)&fHeaderSizeRun, 4); 576 if (fHeaderSizeRun<346) 577 { 578 *fLog << err << "ERROR - Event header too small (<388b)." << endl; 579 return kFALSE; 580 } 581 582 TArrayC h(fHeaderSizeRun-12); 583 fin.read(h.GetArray(), h.GetSize()); 584 if (!fin) 585 return kFALSE; 586 587 // ----- convert ----- 588 const Byte_t *Char = reinterpret_cast<Byte_t* >(h.GetArray()); 589 const UInt_t *Int = reinterpret_cast<UInt_t* >(h.GetArray()); 590 //const Float_t *Float = reinterpret_cast<Float_t*>(h.GetArray()); 591 592 // ----- Start interpretation ----- 593 594 fHeaderSizeEvt = Int[0]; 595 fHeaderSizeCrate = Int[1]; 596 fSoftVersion = Int[2]; 597 fFadcType = Int[3]; 598 fCameraVersion = Int[4]; 599 fTelescopeNumber = Int[5]; 600 fRunType = Int[6]; 601 fRunNumber = Int[7]; 602 fFileNumber = Int[8]; 603 604 memcpy(fProjectName, Char+ 36, 100); // 25 605 memcpy(fSourceName, Char+136, 80); // 20 606 memcpy(fObservationMode, Char+216, 60); // 15 607 608 //F32 fSourceRA = Float[69]; 609 //F32 fSourceDEC = Float[70]; 610 //F32 fTelescopeRA = Float[71]; 611 //F32 fTelescopeDEC = Float[72]; 612 613 memcpy(fSourceEpochChar, Char+232, 4); 614 615 fSourceEpochDate = Int[74]; 616 fNumCrates = Int[75]; 617 fNumPixInCrate = Int[76]; 618 fNumSamplesHiGain = Int[77]; 619 fNumSamplesLoGain = 0; 620 621 //fNumSamplesRemovedHead = Int[78]; 622 //fNumSamplesRemovedTail = Int[79]; 623 624 fNumEvents = Int[80]; 625 fNumEventsRead = Int[81]; 626 fNumBytesPerSample = Int[82]; 627 fSamplingFrequency = Int[83]; 628 fFadcResolution = Int[84]; 629 630 fRunStart.SetBinary(Int+85); 631 fRunStop.SetBinary(Int+91); 632 633 // ----- 388 bytes so far ----- 634 635 const UInt_t n = fNumCrates*fNumPixInCrate; 636 if (fHeaderSizeRun<388+n*4) 637 { 638 *fLog << err << "ERROR - Event header too small to contain pix assignment." << endl; 639 return kFALSE; 640 } 641 642 // ----- Pixel Assignment ----- 643 fPixAssignment->Set(n); 644 645 for (UInt_t i=0; i<n; i++) 646 (*fPixAssignment)[i] = Int[97+i]; 529 647 530 648 return FixAssignment(); … … 578 696 *fLog << "Camera=" << fCameraVersion; 579 697 *fLog << endl; 698 if (fFormatVersion>10) 699 *fLog << "Header sizes: " << fHeaderSizeRun << "b (run), " << fHeaderSizeEvt << "b (evt), " << fHeaderSizeCrate << "b (crate)" << endl; 580 700 if (fFormatVersion>5) 581 701 *fLog << "Telescope: " << fTelescopeNumber << endl; -
trunk/MagicSoft/Mars/mraw/MRawRunHeader.h
r8892 r8946 39 39 /* ---- Run Header Informations ---- */ 40 40 UShort_t fMagicNumber; // File type identifier 41 42 UInt_t fHeaderSizeRun; // Size of run header 43 UInt_t fHeaderSizeEvt; // Size of evt header 44 UInt_t fHeaderSizeCrate; // Size of crate header 45 41 46 UShort_t fFormatVersion; // File format version 42 47 UShort_t fSoftVersion; // DAQ software version … … 46 51 UShort_t fRunType; // Run Type 47 52 UInt_t fRunNumber; // Run number 53 UInt_t fFileNumber; // File number 48 54 Char_t fProjectName[101]; // Project name 49 55 Char_t fSourceName[81]; // Source name 50 56 Char_t fObservationMode[61]; // observation mode 51 Char_t fSourceEpochChar[ 2]; // epoch char of the source57 Char_t fSourceEpochChar[4]; // epoch char of the source 52 58 UShort_t fSourceEpochDate; // epoch date of the source 53 59 UShort_t fNumCrates; // number of electronic boards … … 66 72 Bool_t SwapAssignment(Short_t id0, Short_t id1); 67 73 Bool_t FixAssignment(); 74 Bool_t ReadEvtOld(istream& fin); 68 75 69 76 public: … … 90 97 // This is to get the numbers... 91 98 UShort_t GetMagicNumber() const { return fMagicNumber; } 99 UInt_t GetHeaderSizeEvt() const { return fHeaderSizeEvt; } 100 UInt_t GetHeaderSizeCrate() const { return fHeaderSizeCrate; } 92 101 UShort_t GetFormatVersion() const { return fFormatVersion; } 93 102 UShort_t GetSoftVersion() const { return fSoftVersion; } … … 136 145 Bool_t ReadEvt(istream& fin); 137 146 138 ClassDef(MRawRunHeader, 9) // storage container for general info147 ClassDef(MRawRunHeader, 10) // storage container for general info 139 148 }; 140 149 #endif
Note:
See TracChangeset
for help on using the changeset viewer.