- Timestamp:
- 08/24/10 12:41:43 (14 years ago)
- Location:
- trunk/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/Changelog
r9886 r9889 18 18 19 19 -*-*- END OF LINE -*-*- 20 21 2010/08/24 Reiner Rohlfs 22 23 * mcorsika/MCorsikaFormat.[h,cc] 24 - in method MCorsikaFormatEventIO::SeekEvtEnd() the RUNE block 25 is first searched at the end of the file. It it is not found 26 the whole file is scanned for the RUNE block. Once it is 27 found it can be accessed directly at the next call of this 28 function. 29 20 30 21 31 2010/08/20 Daniela Dorner -
trunk/Mars/mcorsika/MCorsikaFormat.cc
r9616 r9889 233 233 234 234 unsigned short fileType = blockHeader[1] & 0xFFFF; 235 if (/*memcmp(blockHeader+5, id, 4) == 0 && */ 236 type == fileType ) 237 { 238 //*fLog << all << "found " << id << " type: " << type << endl; 235 if (type == fileType ) 239 236 break; 240 }241 237 242 238 if (type == 1202 && fileType == 1210) … … 248 244 // a unknown block, we jump to the next one 249 245 //*fLog << "unknown: " << id << " type: " << fileType << " sub-blocks: " << (blockHeader[3]>>29); 250 //*fLog << " length: " << (blockHeader[3] & 0x3fffffff) << endl;246 //*fLog << " length: " << (blockHeader[3] & 0x3fffffff) << " pos: " << fIn->tellg() << endl; 251 247 int length = blockHeader[3] & 0x3fffffff; 252 fIn->seekg(length - 2 * sizeof(int), ios::cur); 248 249 fIn->seekg(length - 2 * (Int_t)(sizeof(int)), ios::cur); 253 250 } 254 251 … … 261 258 void MCorsikaFormatEventIO::UnreadLastHeader() 262 259 { 263 fIn->seekg( (int)(-6 *sizeof(int)), ios::cur);260 fIn->seekg( -6 * (Int_t)(sizeof(int)), ios::cur); 264 261 } 265 262 … … 268 265 Bool_t MCorsikaFormatEventIO::SeekEvtEnd() 269 266 { 270 if ( SeekNextBlock("RUNE", 1210))271 {272 UnreadLastHeader();267 if (fRunePos != 0) 268 { 269 fIn->seekg(fRunePos, ios::beg); 273 270 return kTRUE; 274 } 275 271 } 272 else 273 { 274 // it is the first time we are looking for the RUNE block 275 276 // is the RUNE block at the very end of the file? 277 std::streampos currentPos = fIn->tellg(); 278 279 fIn->seekg(-32, ios::end); 280 unsigned int blockHeader[4]; 281 fIn->read((char*)blockHeader, 4 * sizeof(int)); 282 if ( blockHeader[0] == 0xd41f8a37 && 283 (blockHeader[1] & 0xffff) == 1210 && 284 (blockHeader[3] & 0x3fffffff) == 16) 285 { 286 // this seams to be a RUNE (1210) block 287 fIn->seekg( -4 * (Int_t)(sizeof(int)), ios::cur); 288 fRunePos = fIn->tellg(); 289 return kTRUE; 290 } 291 292 // we do not find a RUNE block at the end of the file 293 // we have to search in the file 294 fIn->seekg(currentPos, ios::beg); 295 if (SeekNextBlock("RUNE", 1210)) 296 { 297 UnreadLastHeader(); 298 fRunePos = fIn->tellg(); 299 return kTRUE; 300 } 301 } 276 302 return kFALSE; 277 303 } … … 328 354 return kTRUE; 329 355 } 330 331 356 // -------------------------------------------------------------------------- 332 357 // … … 357 382 unsigned short fileType = blockHeader[1] & 0xFFFF; 358 383 if (fileType == 1204) 359 {360 *fLog << all << "found new top level block 1204" << endl;361 384 return kTRUE; 362 } 385 363 386 if (fileType == 1209) 364 387 { 365 388 // we found an eventEnd block, reset file pointer 366 fIn->seekg( (Int_t)(-4 *sizeof(Int_t)), ios::cur);389 fIn->seekg( -4 * (Int_t)(sizeof(Int_t)), ios::cur); 367 390 length = 0; 368 391 return kFALSE; … … 371 394 372 395 // a unknown block, we jump to the next one 373 *fLog << all << "found block " << fileType << endl;374 396 fIn->seekg(length, ios::cur); 375 397 } -
trunk/Mars/mcorsika/MCorsikaFormat.h
r9616 r9889 24 24 public: 25 25 MCorsikaFormat(MLog * log, std::istream * in) 26 : fIn(in) {fLog = log; }26 : fIn(in) {fLog = log; } 27 27 virtual ~MCorsikaFormat(); 28 28 … … 69 69 { 70 70 private: 71 std::streampos fRunePos; // file position of the RUNE block 71 72 72 73 public: 73 74 MCorsikaFormatEventIO(MLog * log, std::istream * in) 74 : MCorsikaFormat(log, in) { }75 : MCorsikaFormat(log, in) {fRunePos = 0;} 75 76 76 77 Bool_t SeekNextBlock(const char * id, unsigned short type);
Note:
See TracChangeset
for help on using the changeset viewer.