Changeset 9942
- Timestamp:
- 09/24/10 15:36:45 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/msim/MPhotonEvent.cc
r9937 r9942 452 452 { 453 453 const UInt_t n = GetNumPhotons(); 454 if (n==0) 455 return 0; 454 456 455 457 Double_t mean = 0; … … 463 465 { 464 466 const UInt_t n = GetNumPhotons(); 467 if (n==0) 468 return 0; 465 469 466 470 Double_t mean = 0; … … 471 475 } 472 476 477 Double_t MPhotonEvent::GetMeanT() const 478 { 479 const UInt_t n = GetNumPhotons(); 480 if (n==0) 481 return 0; 482 483 Double_t mean = 0; 484 for (UInt_t i=0; i<n; i++) 485 mean += operator[](i).GetTime(); 486 487 return mean / n; 488 } 489 490 void MPhotonEvent::AddXY(Double_t x, Double_t y) 491 { 492 const UInt_t n = GetNumPhotons(); 493 494 for (UInt_t i=0; i<n; i++) 495 { 496 MPhotonData &p = operator[](i); 497 p.SetPosition(p.GetPosX()+x, p.GetPosY()+y); 498 } 499 } 500 501 void MPhotonEvent::SimWavelength(Float_t wmin, Float_t wmax) 502 { 503 const UInt_t n = GetNumPhotons(); 504 505 for (UInt_t i=0; i<n; i++) 506 operator[](i).SimWavelength(wmin, wmax); 507 } 508 473 509 // -------------------------------------------------------------------------- 474 510 // 475 511 // Read the Event section from the file 476 512 // 477 Int_t MPhotonEvent::ReadCorsikaEvt(MCorsikaFormat *fInFormat, Int_t i )513 Int_t MPhotonEvent::ReadCorsikaEvt(MCorsikaFormat *fInFormat, Int_t id) 478 514 { 479 515 Int_t n = 0; … … 505 541 // 1.06GB/ 3s CPU 506 542 // 1.06GB/22s REAL 507 Bool_t readError = kFALSE; 508 Float_t * buffer; 509 510 if ( fInFormat->IsEventioFormat() ) 543 Float_t *buffer = 0; 544 545 if (fInFormat->IsEventioFormat()) 546 { 547 while (1) 511 548 { 512 while (fInFormat->GetNextEvent(&buffer, readError)) 513 { 514 515 const Int_t rc = Add(n).FillEventIO(buffer); 516 switch (rc) 549 const Int_t rc = fInFormat->GetNextEvent(&buffer, id); 550 if (rc==kERROR) 551 return kERROR; 552 if (rc==kFALSE) 553 break; 554 555 // Loop over number of photons in bunch 556 while (Add(n).FillEventIO(buffer)) 557 n++; 558 } 559 } 560 else 561 { 562 while (1) 563 { 564 const Int_t rc1 = fInFormat->GetNextEvent(&buffer); 565 if (rc1==kERROR) 566 return kERROR; 567 if (rc1==kFALSE) 568 break; 569 570 const Int_t rc2 = Add(n).FillCorsika(buffer, id); 571 switch (rc2) 517 572 { 518 573 case kCONTINUE: continue; // No data in this bunch... skip it. … … 524 579 // Increase the counter by one 525 580 n++; 526 }527 581 } 528 else 529 { 530 while (fInFormat->GetNextEvent(&buffer, readError)) 531 { 532 533 const Int_t rc = Add(n).FillCorsika(buffer, i); 534 switch (rc) 535 { 536 case kCONTINUE: continue; // No data in this bunch... skip it. 537 case kERROR: return kERROR; // Error occured 538 //case kFALSE: return kFALSE; // End of stream 539 } 540 541 // This is a photon we would like to keep later. 542 // Increase the counter by one 543 n++; 544 } 545 } 546 if (readError) return kFALSE; 582 } 547 583 548 584 /*
Note:
See TracChangeset
for help on using the changeset viewer.