Changeset 9212 for trunk/MagicSoft/Mars/mraw
- Timestamp:
- 01/06/09 13:07:00 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/mraw
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mraw/MRawEvtData.cc
r8938 r9212 91 91 #include "MArrayS.h" 92 92 #include "MArrayB.h" 93 #include "MArrayI.h" 93 94 #include "MGeomCam.h" 94 95 … … 396 397 // The parameters are the pixelnumber and the FADC_SLICES values of ADCs 397 398 // 398 void MRawEvtData::AddPixel(UShort_t nOfPixel, TArrayC *data)399 void MRawEvtData::AddPixel(UShort_t nOfPixel, const TArrayC &data) 399 400 { 400 401 const Int_t n = fRunHeader->GetNumSamples(); 401 if (data ->GetSize()!=n)402 if (data.GetSize()!=n) 402 403 { 403 404 *fLog << err << "RawEvtData::AddPixel: Error, number of samples in "; 404 *fLog << "TArrayC " << data ->GetSize() << " doesn't match current number " << n << endl;405 *fLog << "TArrayC " << data.GetSize() << " doesn't match current number " << n << endl; 405 406 return; 406 407 } … … 424 425 // add the new slices as last entries to array 425 426 // 426 fHiGainFadcSamples->AddAt((Byte_t*)data->GetArray(), fHiGainFadcSamples->GetSize()-n, n); 427 } 427 fHiGainFadcSamples->AddAt((Byte_t*)data.GetArray(), fHiGainFadcSamples->GetSize()-n, n); 428 } 429 430 // -------------------------------------------------------------------------- 431 // 432 // Add the contents of the MArrayI to the fHiGainFadcSamples 433 // One Integer is added to one sample in the array. 434 // 435 void MRawEvtData::Set(const MArrayI &data) 436 { 437 const UInt_t n = fRunHeader->GetNumSamples()*fConnectedPixels; 438 439 Byte_t *dest = fHiGainFadcSamples->GetArray(); 440 441 UInt_t *src = reinterpret_cast<UInt_t*>(data.GetArray()); 442 UInt_t *end = reinterpret_cast<UInt_t*>(data.GetArray()) + n; 443 444 switch (fNumBytesPerSample) 445 { 446 case 1: 447 { 448 Byte_t *ptr = reinterpret_cast<Byte_t*>(dest); 449 while (src<end) 450 *ptr++ = *src++; 451 } 452 return; 453 454 case 2: 455 { 456 UShort_t *ptr = reinterpret_cast<UShort_t*>(dest); 457 while (src<end) 458 *ptr++ = *src++; 459 } 460 return; 461 462 case 4: 463 memcpy(dest, data.GetArray(), n*4); 464 return; 465 } 466 } 467 428 468 /* 429 469 void MRawEvtData::AddPixel(UShort_t nOfPixel, TArrayC *data, Bool_t lflag) -
trunk/MagicSoft/Mars/mraw/MRawEvtData.h
r8938 r9212 19 19 class MArrayS; 20 20 class MArrayB; 21 class MArrayI; 21 22 22 23 class MRawEvtData : public MParContainer, public MCamEvent … … 51 52 case 1: return reinterpret_cast<const Byte_t*>(ptr)[n]; 52 53 case 2: return reinterpret_cast<const UShort_t*>(ptr)[n]; 53 case 3: return reinterpret_cast<const UInt_t*>(ptr)[n];54 case 4: return reinterpret_cast<const UInt_t*>(ptr)[n]; 54 55 } 55 56 return 0; … … 74 75 75 76 void ResetPixels(UShort_t npix, UShort_t maxid); 76 void AddPixel(UShort_t nOfPixel, TArrayC *data); 77 void AddPixel(UShort_t nOfPixel, const TArrayC &data); 78 void Set(const MArrayI &data); 77 79 78 80 UShort_t GetNumHiGainSamples() const; -
trunk/MagicSoft/Mars/mraw/MRawRunHeader.cc
r9180 r9212 181 181 // the default. Do not mix files with and without a value if the 182 182 // files with the value do not match the default! 183 fFormatVersion= 0;183 fFormatVersion=11; 184 184 fSoftVersion=0; 185 185 fTelescopeNumber=1; … … 351 351 } 352 352 return kTRUE; 353 } 354 355 void MRawRunHeader::FixRunNumbers() 356 { 357 if (fFormatVersion<11 || fTelescopeNumber!=1) 358 return; 359 360 // Map 1:1001349 to 47:1001395 361 if (fRunNumber<48 && 362 fRunStart.GetMjd()>54674.5 && fRunStart.GetMjd()<56476.5) 363 { 364 fRunNumber += 1001348; 365 *fLog << warn << "Format >V10: Wrong run number increased by 1001348 to " << fRunNumber << "." << endl; 366 } 367 368 // Map 1001916:1001922 to 1002349:1002355 369 if (fRunNumber>1001915 && fRunNumber<1001923 && 370 fRunStart.GetMjd()>54710.5 && fRunStart.GetMjd()<54711.5) 371 { 372 fRunNumber += 433; 373 *fLog << warn << "Format >V10: Wrong run number increased by 434 to " << fRunNumber << "." << endl; 374 } 375 376 // Map 10000342:1000343 to 10000351:1000351 377 if (fRunNumber>10000342 && fRunNumber<10000352 && 378 fRunStart.GetMjd()>54254.5 && fRunStart.GetMjd()<54255.5) 379 { 380 fRunNumber -= 9000000; 381 *fLog << warn << "Format >V10: Wrong run number decreased by 9000000 to " << fRunNumber << "." << endl; 382 } 383 384 if (fRunNumber==1000382 && 385 fRunStart.GetMjd()>54256.5 && fRunStart.GetMjd()<54257.5 && 386 !strcmp(fSourceName, "GRB080605-2347")) 387 { 388 fFileNumber += 99; 389 *fLog << warn << "Format >V10: Ambiguous file number increased by 99 to " << fFileNumber << "." << endl; 390 } 353 391 } 354 392 … … 492 530 Bool_t MRawRunHeader::Fixes() 493 531 { 532 FixRunNumbers(); 533 494 534 if (fFormatVersion>8 && fRunNumber>326152 && fTelescopeNumber==1) 495 535 { … … 497 537 fNumEventsRead--; 498 538 *fLog << inf << "Format >V8 and Run>M1:326152: Stored number of events decreased by 1." << endl; 499 }500 501 if (fFormatVersion>10 && fRunNumber<48 &&502 fRunStart.GetMjd()>54674.5 && fRunStart.GetMjd()<56476.5)503 {504 fRunNumber += 1001348;505 *fLog << warn << "Format >V10: Wrong run number increased by 1001348 to " << fRunNumber << "." << endl;506 539 } 507 540 … … 760 793 return IsConsistent(); 761 794 } 762 795 /* 796 Bool_t MRawRunHeader::WriteEvt(ostream& out) const 797 { 798 // 799 // write one RUN HEADER from the input stream 800 // 801 const UInt_t n = fNumCrates*fNumPixInCrate; 802 803 const UShort_t magicnumber = kMagicNumber; 804 const UInt_t formatversion = 11; 805 const UInt_t headersizerun = (97+n)*4; //??? 806 807 // FIXME: Write fixed number (c0c0) 808 out.write((char*)&magicnumber, 2); // Total=2 809 out.write((char*)&formatversion, 2); // Total=4 810 out.write((char*)&formatversion, 4); 811 out.write((char*)&headersizerun, 4); 812 813 TArrayC h(headersizerun-12); 814 815 // ----- convert ----- 816 Byte_t *Char = reinterpret_cast<Byte_t* >(h.GetArray()); 817 UInt_t *Int = reinterpret_cast<UInt_t* >(h.GetArray()); 818 //const Float_t *Float = reinterpret_cast<Float_t*>(h.GetArray()); 819 820 // ----- Start interpretation ----- 821 822 Int[0] = 0; // fHeaderSizeEvt; 823 Int[1] = 0; // fHeaderSizeCrate; 824 Int[2] = 0; // fSoftVersion; 825 Int[3] = fFadcType; 826 Int[4] = fCameraVersion; 827 Int[5] = fTelescopeNumber; 828 Int[5] = fRunType; 829 Int[6] = fRunNumber; 830 Int[7] = fFileNumber; 831 832 memcpy(Char+ 36, fProjectName, 100); // 25 833 memcpy(Char+136, fSourceName, 80); // 20 834 memcpy(Char+216, fObservationMode, 60); // 15 835 836 //F32 fSourceRA = Float[69]; 837 //F32 fSourceDEC = Float[70]; 838 //F32 fTelescopeRA = Float[71]; 839 //F32 fTelescopeDEC = Float[72]; 840 841 memcpy(Char+232, fSourceEpochChar, 4); 842 843 Int[74] = fSourceEpochDate; 844 Int[75] = fNumCrates; 845 Int[76] = fNumPixInCrate; 846 Int[77] = fNumSamplesHiGain; 847 848 //fNumSamplesRemovedHead = Int[78]; 849 //fNumSamplesRemovedTail = Int[79]; 850 851 Int[80] = fNumEvents; 852 Int[81] = fNumEvents; //fNumEventsRead; 853 Int[82] = fNumBytesPerSample; 854 Int[83] = fSamplingFrequency; 855 Int[84] = fFadcResolution; 856 857 fRunStart.GetBinary(Int+85); 858 fRunStop.GetBinary(Int+91); 859 860 // ----- 388 bytes so far ----- 861 862 //const UInt_t n = fNumCrates*fNumPixInCrate; 863 //if (fHeaderSizeRun<(97+n)*4) 864 //{ 865 // *fLog << err << "ERROR - Event header too small to contain pix assignment." << endl; 866 // return kFALSE; 867 //} 868 869 // ----- Pixel Assignment ----- 870 for (UInt_t i=0; i<n; i++) 871 Int[97+i] = (*fPixAssignment)[i]; 872 873 out.write(h.GetArray(), h.GetSize()); 874 875 return out; 876 } 877 */ 763 878 // -------------------------------------------------------------------------- 764 879 // … … 990 1105 return 0; 991 1106 } 1107 1108 // -------------------------------------------------------------------------- 1109 // 1110 // Monte Carlo Interface 1111 // 1112 // This is a (prelimiary) way to setup an existing FADC system. 1113 // 1114 // 1: Siegen FADCs 1115 // 2: MUX FADCs 1116 // 1117 void MRawRunHeader::InitFadcType(UShort_t type) 1118 { 1119 switch (type) 1120 { 1121 case 1: 1122 fNumSamplesLoGain = 15; 1123 fNumSamplesHiGain = 15; 1124 fNumBytesPerSample = 1; // number of bytes per sample 1125 fSamplingFrequency = 300; // Sampling Frequency [MHz] 1126 fFadcResolution = 8; // number of significant bits 1127 break; 1128 case 2: 1129 fNumSamplesLoGain = 0; 1130 fNumSamplesHiGain = 50; 1131 fNumBytesPerSample = 2; // number of bytes per sample 1132 fSamplingFrequency = 2000; // Sampling Frequency [MHz] 1133 fFadcResolution = 12; // number of significant bits 1134 break; 1135 } 1136 1137 fFadcType = type; 1138 } 1139 1140 // -------------------------------------------------------------------------- 1141 // 1142 // Monte Carlo Interface 1143 // 1144 // Init a camera 1145 // 1146 void MRawRunHeader::InitCamera(UShort_t type) 1147 { 1148 switch (type) 1149 { 1150 case 1: 1151 fNumCrates = 1; 1152 fNumPixInCrate = 577; 1153 break; 1154 } 1155 1156 fCameraVersion = type; 1157 1158 const Int_t n = fNumCrates*fNumPixInCrate; 1159 1160 fPixAssignment->Set(n); 1161 1162 for (int i=0; i<n; i++) 1163 (*fPixAssignment)[i] = i; 1164 } 1165 1166 // -------------------------------------------------------------------------- 1167 // 1168 // Monte Carlo Interface 1169 // 1170 // Set run-type, telescope number, run-number and file-number 1171 // 1172 void MRawRunHeader::SetRunInfo(UShort_t type, UShort_t tel, UInt_t run, UInt_t file) 1173 { 1174 fRunType = type; 1175 fTelescopeNumber = tel; 1176 fRunNumber = run; 1177 fFileNumber = file; 1178 } 1179 1180 // -------------------------------------------------------------------------- 1181 // 1182 // Monte Carlo Interface 1183 // 1184 // Set source-name, epoch (default J) and date (default 2000) 1185 // 1186 void MRawRunHeader::SetSourceInfo(const char src[80], char epoch, UShort_t date) 1187 { 1188 memcpy(fSourceName, src, 80); 1189 1190 fSourceEpochChar[0] = epoch; // epoch char of the source 1191 fSourceEpochChar[1] = 0; // epoch char of the source 1192 1193 fSourceEpochDate = date; // epoch date of the source 1194 } 1195 1196 // -------------------------------------------------------------------------- 1197 // 1198 // Monte Carlo Interface 1199 // 1200 // Set run-start and -stop time 1201 // 1202 void MRawRunHeader::SetRunTime(const MTime &start, const MTime &end) 1203 { 1204 fRunStart = start; 1205 fRunStop = end; 1206 } 1207 1208 // -------------------------------------------------------------------------- 1209 // 1210 // Monte Carlo Interface 1211 // 1212 // Set project name and observation mode 1213 // 1214 void MRawRunHeader::SetObservation(const char mode[60], const char proj[100]) 1215 { 1216 memcpy(fProjectName, proj, 100); 1217 memcpy(fObservationMode, mode, 60); 1218 } 1219 1220 // -------------------------------------------------------------------------- 1221 // 1222 // Monte Carlo Interface 1223 // 1224 // Set number of events in file. 1225 // 1226 void MRawRunHeader::SetNumEvents(UInt_t num) 1227 { 1228 fNumEvents = num; 1229 fNumEventsRead = num; 1230 } -
trunk/MagicSoft/Mars/mraw/MRawRunHeader.h
r9180 r9212 72 72 73 73 Bool_t SwapAssignment(Short_t id0, Short_t id1); 74 void FixRunNumbers(); 74 75 Bool_t FixAssignment(); 75 76 Bool_t Fixes(); … … 83 84 84 85 // This is to be used in the MC chain only! 86 /* 85 87 void SetMagicNumber(UShort_t a) { fMagicNumber=a; } 86 88 void SetFormatVersion(UShort_t a) { fFormatVersion=a; } … … 96 98 void SetNumCrates(UShort_t a) { fNumCrates=a; } 97 99 void SetNumPixInCrate(UShort_t a) { fNumPixInCrate=a; } 98 void SetRunTime(Float_t start, Float_t stop) 99 { fRunStart.SetMjd(start); fRunStop.SetMjd(stop); } 100 */ 101 void InitFadcType(UShort_t type); 102 void InitCamera(UShort_t type); 103 void SetRunInfo(UShort_t type, UShort_t tel, UInt_t run, UInt_t file=0); 104 void SetSourceInfo(const char src[80], char epoch='J', UShort_t date=2000); 105 void SetRunTime(const MTime &start, const MTime &end); 106 void SetRunTimeMjd(Float_t start, Float_t stop) { fRunStart.SetMjd(start); fRunStop.SetMjd(stop); } 107 void SetObservation(const char mode[60], const char proj[100]); 108 void SetNumEvents(UInt_t num); 100 109 101 110 // This is to get the numbers... … … 153 162 154 163 Bool_t ReadEvt(istream& fin); 164 //Bool_t WriteEvt(ostream& fout) const; 155 165 156 166 ClassDef(MRawRunHeader, 10) // storage container for general info
Note:
See TracChangeset
for help on using the changeset viewer.