Changeset 9616 for trunk/MagicSoft/Mars/msim
- Timestamp:
- 07/23/10 10:48:12 (14 years ago)
- Location:
- trunk/MagicSoft/Mars/msim
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/msim/MPhotonData.cc
r9348 r9616 245 245 // -------------------------------------------------------------------------- 246 246 // 247 // Set the data member according to the 8 floats read from a eventio-file. 248 // This function MUST reset all data-members, no matter whether these are 249 // contained in the input stream. 250 // 251 // Currently we exchange x and y and set y=-y to convert Corsikas coordinate 252 // system into our own. 253 // 254 Int_t MPhotonData::FillEventIO(Float_t f[8]) 255 { 256 fPosX = f[1]; // xpos relative to telescope [cm] 257 fPosY = -f[0]; // ypos relative to telescope [cm] 258 fCosU = f[3]; // cos to x 259 fCosV = -f[2]; // cos to y 260 fTime = f[4]; // a relative arival time [ns] 261 fProductionHeight = f[5]; // altitude of emission [cm] 262 fNumPhotons = f[6]; // photons in this bunch 263 fWavelength = f[7]; // so far always zeor = unspec. [nm] 264 265 266 // Now reset all data members which are not in the stream 267 fPrimary = MMcEvtBasic::kUNDEFINED; 268 fTag = -1; 269 fWeight = 1; 270 271 return kTRUE; 272 } 273 274 // -------------------------------------------------------------------------- 275 // 247 276 // Read seven floats from the stream and call FillCorsika for them. 248 277 // -
trunk/MagicSoft/Mars/msim/MPhotonData.h
r9370 r9616 133 133 134 134 Int_t FillCorsika(Float_t f[7]); 135 Int_t FillEventIO(Float_t f[7]); 135 136 Int_t FillRfl(Float_t f[8]); 136 137 -
trunk/MagicSoft/Mars/msim/MPhotonEvent.cc
r9349 r9616 121 121 122 122 #include "MPhotonData.h" 123 #include "MCorsikaFormat.h" 123 124 124 125 ClassImp(MPhotonEvent); … … 452 453 // Read the Event section from the file 453 454 // 454 Int_t MPhotonEvent::ReadCorsikaEvt( istream &fin)455 Int_t MPhotonEvent::ReadCorsikaEvt(MCorsikaFormat * fInFormat) 455 456 { 456 457 Int_t n = 0; … … 482 483 // 1.06GB/ 3s CPU 483 484 // 1.06GB/22s REAL 485 Bool_t readError = kFALSE; 486 Float_t * buffer; 487 488 if ( fInFormat->IsEventioFormat() ) 489 { 490 while (fInFormat->GetNextEvent(&buffer, readError)) 491 { 492 493 const Int_t rc = Add(n).FillEventIO(buffer); 494 switch (rc) 495 { 496 case kCONTINUE: continue; // No data in this bunch... skip it. 497 case kERROR: return kERROR; // Error occured 498 //case kFALSE: return kFALSE; // End of stream 499 } 500 501 // This is a photon we would like to keep later. 502 // Increase the counter by one 503 n++; 504 } 505 } 506 else 507 { 508 while (fInFormat->GetNextEvent(&buffer, readError)) 509 { 510 511 const Int_t rc = Add(n).FillCorsika(buffer); 512 switch (rc) 513 { 514 case kCONTINUE: continue; // No data in this bunch... skip it. 515 case kERROR: return kERROR; // Error occured 516 //case kFALSE: return kFALSE; // End of stream 517 } 518 519 // This is a photon we would like to keep later. 520 // Increase the counter by one 521 n++; 522 } 523 } 524 if (readError) return kFALSE; 525 526 /* 484 527 485 528 while (1) 486 529 { 487 // Stprage for one block 488 char c[273*4]; 489 490 // Read the first four byte to check whether the next block 491 // doen't belong to the event anymore 492 fin.read(c, 4); 493 if (!fin) 530 Float_t buffer[273]; 531 Float_t * ptr = buffer; 532 533 534 if (!fInFormat->ReadData(273, buffer)) 494 535 return kFALSE; 495 536 496 // Check if the event is finished 497 if (!memcmp(c, "EVTE", 4)) 537 if (!memcmp(ptr, "EVTE", 4)) 538 { 539 540 fInFormat->UnreadLastData(); 498 541 break; 499 500 // Now read the rest of the data 501 fin.read(c+4, 272*4); 502 503 Float_t *ptr = reinterpret_cast<Float_t*>(c); 542 } 543 504 544 Float_t *end = ptr + 273; 505 545 … … 525 565 } 526 566 } 567 568 */ 569 Resize(n); 570 fData.UnSort(); 571 572 SetReadyToSave(); 573 574 //*fLog << all << "Number of photon bunches: " << fData.GetEntriesFast() << endl; 575 return kTRUE; 576 577 } 578 579 Int_t MPhotonEvent::ReadCorsikaEvt(istream &fin) 580 { 581 Int_t n = 0; 582 583 // --- old I/O --- 584 // Read only + Reflector (no absorption) 585 // Muons: 1.06GB/115s = 9.2MB/s (100kEvs) 586 // Gammas: 1.57GB/275s = 5.7MB/s ( 1kEvs) 587 588 // Read only: 589 // Gammas: 1.57GB/158s = 9.9MB/s ( 1kEvs) 590 // Muons: 1.06GB/ 77s = 13.8MB/s (100kEvs) 591 592 // --- new I/O --- 593 // Read only (don't allocate storage space): 594 // Gammas: 1.57GB/143s = 11.0MB/s ( 1kEvs) 595 // Muons: 1.06GB/ 77s = 13.8MB/s (100kEvs) 596 597 // Read only in blocks (with storage allocation): 598 // Gammas: 1.57GB/28s = 56MB/s ( 1kEvs) 599 // Muons: 1.06GB/5.2s = 204MB/s (100kEvs) 600 601 // Read only in blocks (without storage allocation): 602 // similar to just copy 603 604 // Copy with cp 605 // 1.57GB/ 5s CPU 606 // 1.57GB/28s REAL 607 // 1.06GB/ 3s CPU 608 // 1.06GB/22s REAL 609 610 while (1) 611 { 612 // Stprage for one block 613 char c[273*4]; 614 615 // Read the first four byte to check whether the next block 616 // doen't belong to the event anymore 617 fin.read(c, 4); 618 if (!fin) 619 return kFALSE; 620 621 // Check if the event is finished 622 if (!memcmp(c, "EVTE", 4)) 623 break; 624 625 // Now read the rest of the data 626 fin.read(c+4, 272*4); 627 628 Float_t *ptr = reinterpret_cast<Float_t*>(c); 629 Float_t *end = ptr + 273; 630 631 // Loop over all sub-blocks (photons) in the block and if 632 // they contain valid data add them to the array 633 while (ptr<end) 634 { 635 // Get/Add the n-th entry from the array and 636 // fill it with the current 7 floats 637 const Int_t rc = Add(n).FillCorsika(ptr); 638 ptr += 7; 639 640 switch (rc) 641 { 642 case kCONTINUE: continue; // No data in this bunch... skip it. 643 case kERROR: return kERROR; // Error occured 644 //case kFALSE: return kFALSE; // End of stream 645 } 646 647 // This is a photon we would like to keep later. 648 // Increase the counter by one 649 n++; 650 } 651 } 527 652 /* 528 653 while (1) -
trunk/MagicSoft/Mars/msim/MPhotonEvent.h
r9349 r9616 16 16 class MPhotonData; 17 17 class MCorsikaRunHeader; 18 class MCorsikaFormat; 18 19 19 20 class MPhotonEvent : public MParContainer … … 52 53 53 54 // I/O 55 Int_t ReadCorsikaEvt(MCorsikaFormat * fInFormat); 54 56 Int_t ReadCorsikaEvt(istream &fin); 55 57 Int_t ReadRflEvt(istream &fin);
Note:
See TracChangeset
for help on using the changeset viewer.