Changeset 5429 for trunk/MagicSoft/Mars/mfbase
- Timestamp:
- 11/18/04 15:35:43 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mfbase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mfbase/MFEventSelector2.cc
r5366 r5429 150 150 // variable(s) of interest and the binnings) 151 151 // 152 153 152 MFEventSelector2::MFEventSelector2(MH3 &hist, const char *name, const char *title) 154 153 : fHistOrig(NULL), fHistNom(&hist), fHistRes(NULL), 155 154 fDataX(hist.GetRule('x')), fDataY(hist.GetRule('y')), 156 fDataZ(hist.GetRule('z')), fNumMax(-1) 155 fDataZ(hist.GetRule('z')), fNumMax(-1), fHistIsProbability(kFALSE) 157 156 { 158 157 fName = name ? (TString)name : gsDefName; … … 384 383 } 385 384 386 MRead *read = (MRead*)tasklist->FindObject("MRead");387 if (!read)388 {389 *fLog << err << "MRead not found... abort." << endl;390 return kFALSE;391 }392 393 385 if (!PreProcessData(parlist)) 394 386 return kFALSE; 387 388 fHistNom->SetTitle(fHistIsProbability ? "ProbabilityDistribution" : "Users Nominal Distribution"); 389 390 if (fHistIsProbability) 391 return kTRUE; 395 392 396 393 InitHistogram(fHistOrig); 397 394 InitHistogram(fHistRes); 398 395 399 fHistNom->SetTitle("Users Nominal Distribution");400 396 fHistOrig->SetTitle("Primary Distribution"); 401 397 fHistRes->SetTitle("Resulting Distribution"); … … 407 403 408 404 // Generate primary distribution 405 MRead *read = (MRead*)tasklist->FindObject("MRead"); 406 if (!read) 407 { 408 *fLog << err << "MRead not found... abort." << endl; 409 return kFALSE; 410 } 411 409 412 if (!ReadDistribution(*read)) 410 413 return kFALSE; … … 445 448 446 449 return rc; 450 } 451 452 Bool_t MFEventSelector2::SelectProb(Int_t ibin) const 453 { 454 // 455 // If value is outside histogram range, accept event 456 // 457 return ibin<0 ? kTRUE : fHistNom->GetHist().GetBinContent(ibin) > gRandom->Uniform(); 447 458 } 448 459 … … 462 473 const Double_t valz=fDataZ.GetValue(); 463 474 475 const Int_t ibin = fHistNom->FindFixBin(valx, valy, valz)-1; 476 464 477 // Get corresponding bin number and check 465 478 // whether a selection should be made 466 fResult = Select(fHistNom->FindFixBin(valx, valy, valz)-1);479 fResult = fHistIsProbability ? Select(ibin) : SelectProb(ibin); 467 480 468 481 fCounter[fResult ? 1 : 0]++; … … 481 494 if (GetNumExecutions()>0) 482 495 { 483 *fLog << inf << endl;484 *fLog << GetDescriptor() << " execution statistics:" << endl;485 *fLog << dec << setfill(' ');486 *fLog << " " << setw(7) << fCounter[1] << " (" << setw(3)487 << (int)(fCounter[0]*100/GetNumExecutions())488 << "%) Events not selected" << endl;489 490 *fLog << " " << fCounter[0] << " ("491 << (int)(fCounter[1]*100/GetNumExecutions())492 << "%) Events selected" << endl;493 *fLog << endl;496 *fLog << inf << endl; 497 *fLog << GetDescriptor() << " execution statistics:" << endl; 498 *fLog << dec << setfill(' '); 499 *fLog << " " << setw(7) << fCounter[1] << " (" << setw(3) 500 << (int)(fCounter[0]*100/GetNumExecutions()) 501 << "%) Events not selected" << endl; 502 503 *fLog << " " << fCounter[0] << " (" 504 << (int)(fCounter[1]*100/GetNumExecutions()) 505 << "%) Events selected" << endl; 506 *fLog << endl; 494 507 } 495 508 -
trunk/MagicSoft/Mars/mfbase/MFEventSelector2.h
r3330 r5429 42 42 43 43 Bool_t fResult; 44 Bool_t fHistIsProbability; 44 45 Int_t fCounter[2]; 45 46 … … 49 50 Bool_t PreProcessData(MParList *parlist); 50 51 Bool_t Select(Int_t bin); 52 Bool_t SelectProb(Int_t bin) const; 51 53 52 54 Int_t PreProcess(MParList *parlist); … … 61 63 62 64 void SetNumMax(Long_t max=-1) { fNumMax = max; } 65 void SetHistIsProbability(Bool_t b=kTRUE) { fHistIsProbability=b; } 63 66 Bool_t IsExpressionTrue() const { return fResult; } 64 67
Note:
See TracChangeset
for help on using the changeset viewer.