Changeset 9937 for trunk/Mars/mcorsika
- Timestamp:
- 09/22/10 15:25:55 (14 years ago)
- Location:
- trunk/Mars/mcorsika
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcorsika/MCorsikaEvtHeader.cc
r9616 r9937 32 32 // 33 33 // 34 // Class Version 3: 35 // ---------------- 36 // - UInt_t fNumReuse 37 // 38 // 34 39 ///////////////////////////////////////////////////////////////////////////// 35 40 #include "MCorsikaEvtHeader.h" … … 55 60 // 56 61 MCorsikaEvtHeader::MCorsikaEvtHeader(const char *name, const char *title) 57 : f X(0), fY(0)62 : fNumReuse((UInt_t)-1), fX(0), fY(0) 58 63 { 59 64 fName = name ? name : "MCorsikaEvtHeader"; … … 104 109 { 105 110 *fLog << all; 106 *fLog << "Event Number: " << dec << fEvtNumber << endl;111 *fLog << "Event Number: " << dec << fEvtNumber << " (reused=" << fNumReuse << ")" << endl; 107 112 // *fLog << "Particle ID: " << MMcEvt::GetParticleName(fParticleID) << endl; 108 113 *fLog << "Energy: " << fTotalEnergy << "GeV" << endl; … … 122 127 // return FALSE if there is no header anymore, else TRUE 123 128 // 124 Int_t MCorsikaEvtHeader::ReadEvt(MCorsikaFormat * 129 Int_t MCorsikaEvtHeader::ReadEvt(MCorsikaFormat *fInFormat) 125 130 { 126 127 131 if (!fInFormat->SeekNextBlock("EVTH", 1202)) 128 132 return kFALSE; … … 151 155 fMomentumZ = -f[8]; // Does this minus make sense?! 152 156 153 // FIXME: Correct for direction of magnetic field!154 157 fZd = f[9]; 155 158 fAz = TMath::Pi()-f[10]; 156 159 157 const Int_t n = TMath::Nint(f[96]); 158 if (n!=1) 159 { 160 *fLog << err << "ERROR - Currently only one impact parameter per event is supported." << endl; 161 *fLog << warn << "WARNING - This error is replaced by a warning." << endl; 162 } 160 // f[96] // Number of reuse of event [max=20] 163 161 164 fX = f[117]; //fX = f[97]; 165 fY = -f[97]; //fY = f[117]; 162 // FIXME: Check fNumReuse<20 163 fX = f[117 + fNumReuse]; 164 fY = -f[ 97 + fNumReuse]; 165 166 fWeightedNumPhotons = 0; 166 167 167 168 return !fInFormat->Eof(); … … 171 172 // this member function is for reading the event end block 172 173 173 Bool_t MCorsikaEvtHeader::ReadEvtEnd(MCorsikaFormat * fInFormat)174 Int_t MCorsikaEvtHeader::ReadEvtEnd(MCorsikaFormat * fInFormat) 174 175 { 175 176 176 if (!fInFormat->SeekNextBlock("EVTE", 1209)) 177 177 return kFALSE; … … 192 192 } 193 193 194 // FIXME: What's the meaning of this if in case of reusing the event this number 195 // exists only once? 194 196 fWeightedNumPhotons = f[1]; 195 197 196 198 return !fInFormat->Eof(); 197 199 } 198 -
trunk/Mars/mcorsika/MCorsikaEvtHeader.h
r9616 r9937 20 20 private: 21 21 UInt_t fEvtNumber; // Event number 22 UInt_t fNumReuse; // Counter of the reuse of the same shower 22 23 // UInt_t fParticleID; // Particle ID (see MMcEvtBasic or CORSIKA manual) 23 24 Float_t fTotalEnergy; // [GeV] … … 46 47 47 48 UInt_t GetEvtNumber() const { return fEvtNumber; } 49 UInt_t GetNumReuse() const { return fNumReuse; } 48 50 // UInt_t GetParticleID() const { return fParticleID; } 49 51 … … 62 64 Double_t GetImpact() const; 63 65 64 Int_t ReadEvt(MCorsikaFormat * fInFormat); // read in event header block65 Bool_t ReadEvtEnd(MCorsikaFormat * fInFormat); // read in event end block66 void IncNumReuse() { fNumReuse++; } 67 void ResetNumReuse() { fNumReuse=(UInt_t)-1; } 66 68 67 ClassDef(MCorsikaEvtHeader, 1) // Parameter Conatiner for raw EVENT HEADER 69 Int_t ReadEvt(MCorsikaFormat *informat); // read in event header block 70 Int_t ReadEvtEnd(MCorsikaFormat *informat); // read in event end block 71 72 ClassDef(MCorsikaEvtHeader, 3) // Parameter Conatiner for raw EVENT HEADER 68 73 }; 69 74 -
trunk/Mars/mcorsika/MCorsikaRead.cc
r9616 r9937 319 319 } 320 320 321 fNumTotalEvents += fRunHeader->GetNumEvents() ;321 fNumTotalEvents += fRunHeader->GetNumEvents()*fRunHeader->GetNumReuse(); 322 322 continue; 323 323 } … … 393 393 // Read a single event from the stream 394 394 // 395 Bool_t MCorsikaRead::ReadEvent() 396 { 397 // 398 // Read in the next EVENT HEADER (see specification), 399 // if there is no next event anymore stop eventloop 400 // 401 Int_t rc = fEvtHeader->ReadEvt(fInFormat); //read event header block 402 if (!rc) 403 return kFALSE; 404 405 rc = fEvent->ReadCorsikaEvt(fInFormat); 406 407 /* 408 // Check if we are allowed to stop reading in the middle of the data 409 if (rc==kFALSE && !fForce) 410 { 411 *fLog << err; 412 *fLog << "ERROR - End of file in the middle of the data stream!" << endl; 413 *fLog << " Set the force-option to force processing." << endl; 414 return kERROR; 415 } 416 */ 417 418 return rc==kTRUE ? fEvtHeader->ReadEvtEnd(fInFormat) : rc; 395 Int_t MCorsikaRead::ReadEvent() 396 { 397 // Store the position to re-read a single event several times 398 // FIXME: Does this work with EventIO, too? 399 if (fEvtHeader->GetNumReuse()>=fRunHeader->GetNumReuse()-1) 400 { 401 fInFormat->StorePos(); 402 fEvtHeader->ResetNumReuse(); 403 } 404 else 405 fInFormat->ResetPos(); 406 407 fEvtHeader->IncNumReuse(); 408 409 // Read the event header 410 const Int_t rc1 = fEvtHeader->ReadEvt(fInFormat); 411 if (rc1!=kTRUE) 412 return rc1; 413 414 // Check if reusage number should be reset and increase it 415 // Note, that the trick here is that after reset it is set to -1 416 417 // Read the photons corresponding to the i-th core location 418 const Int_t rc2 = fEvent->ReadCorsikaEvt(fInFormat, fEvtHeader->GetNumReuse()+1); 419 if (rc2!=kTRUE) 420 return rc2; 421 422 // read event end 423 return fEvtHeader->ReadEvtEnd(fInFormat); 419 424 } 420 425 … … 434 439 { 435 440 // Read a single event from file 436 const Bool_t rc = ReadEvent();441 const Int_t rc = ReadEvent(); 437 442 438 443 // kFALSE means: end of file (try next one) … … 465 470 Int_t MCorsikaRead::PostProcess() 466 471 { 472 const UInt_t n = fNumEvents*fRunHeader->GetNumReuse(); 473 467 474 // 468 475 // Sanity check for the number of events 469 476 // 470 if ( fNumEvents==GetNumExecutions()-1 || GetNumExecutions()==0)477 if (n==GetNumExecutions()-1 || GetNumExecutions()==0) 471 478 return kTRUE; 472 479 … … 474 481 *fLog << "Warning - number of read events (" << GetNumExecutions()-1; 475 482 *fLog << ") doesn't match number in run header(s) ("; 476 *fLog << f NumEvents<< ")." << endl;483 *fLog << fRunHeader->GetNumReuse() << "*" << fNumEvents << "=" << n << ")." << endl; 477 484 478 485 return kTRUE; -
trunk/Mars/mcorsika/MCorsikaRead.h
r9616 r9937 29 29 UInt_t fNumTotalEvents; //! total number of events in all files 30 30 31 ifstream *fIn;//! input stream (file to read from)32 MCorsikaFormat *fInFormat; //! access to input corsika data31 ifstream *fIn; //! input stream (file to read from) 32 MCorsikaFormat *fInFormat; //! access to input corsika data 33 33 34 34 MParList *fParList; //! tasklist to call ReInit from … … 42 42 Int_t OpenNextFile(Bool_t print=kTRUE); 43 43 Bool_t CalcNumTotalEvents(); 44 Bool_tReadEvent();44 Int_t ReadEvent(); 45 45 46 46 Int_t PreProcess(MParList *pList); -
trunk/Mars/mcorsika/MCorsikaRunHeader.cc
r9616 r9937 42 42 // + Float_t fAtmosphericCoeffC[5] 43 43 // + UInt_t fCerenkovFlag 44 // 45 // Class Version 3: 46 // ---------------- 47 // + UInt_t fNumReuse 44 48 // 45 49 //////////////////////////////////////////////////////////////////////////// … … 164 168 fInFormat->UnreadLastHeader(); 165 169 166 const Int_t n= TMath::Nint(g[96]); // Number i of uses of each cherenkov event167 if ( n!=1)170 fNumReuse = TMath::Nint(g[96]); // Number i of uses of each cherenkov event 171 if (fNumReuse!=1) 168 172 { 169 173 *fLog << err << "ERROR - Currently only one impact parameter per event is supported." << endl; … … 269 273 *fLog << "Particle ID: " << MMcEvt::GetParticleName(fParticleID) << endl; 270 274 if (fNumEvents>0) 271 *fLog << "Num Events: " << fNumEvents << endl;275 *fLog << "Num Events: " << fNumEvents << " (reuse " << fNumReuse << " times)" << endl; 272 276 *fLog << "Obs Level: "; 273 277 for (Byte_t i=0; i<fNumObsLevel; i++) -
trunk/Mars/mcorsika/MCorsikaRunHeader.h
r9616 r9937 33 33 34 34 UInt_t fRunNumber; // Run number 35 UInt_t fNumReuse; // Number of how many times the same shower is used 35 36 UInt_t fParticleID; // Particle ID (see MMcEvtBasic or CORSIKA manual) 36 37 UInt_t fNumEvents; // Number of events … … 76 77 UInt_t GetParticleID() const { return fParticleID; } 77 78 UInt_t GetNumEvents() const { return fNumEvents; } 79 UInt_t GetNumReuse() const { return fNumReuse; } 78 80 79 81 const MTime &GetRunStart() const { return fRunStart; } … … 128 130 void Print(Option_t *t=NULL) const; 129 131 130 ClassDef(MCorsikaRunHeader, 2) // storage container for general info132 ClassDef(MCorsikaRunHeader, 3) // storage container for general info 131 133 }; 132 134 #endif
Note:
See TracChangeset
for help on using the changeset viewer.