Changeset 2574 for trunk/MagicSoft/Mars/manalysis
- Timestamp:
- 11/28/03 08:08:53 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/manalysis
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/manalysis/MCT1FindSupercuts.cc
r2408 r2574 58 58 #include "MFillH.h" 59 59 //#include "MGeomCamCT1Daniel.h" 60 #include "MFRandomSplit.h" 60 61 #include "MGeomCamCT1.h" 61 62 #include "MH3.h" … … 246 247 fTitle = title ? title : "Optimizer of the supercuts"; 247 248 249 fUseOrigDistribution = kFALSE; 250 248 251 //--------------------------- 249 252 // camera geometry is needed for conversion mm ==> degree … … 277 280 } 278 281 282 283 // -------------------------------------------------------------------------- 284 // 285 // 286 // 287 void MCT1FindSupercuts::SetUseOrigDistribution(Bool_t b) 288 { 289 fUseOrigDistribution = b; 290 291 *fLog << "MCT1FindSupercuts : when defining training and test matrices use the original distribution" 292 << endl; 293 } 294 279 295 // -------------------------------------------------------------------------- 280 296 // … … 285 301 // 286 302 // 287 Bool_t MCT1FindSupercuts::DefineTrainMatrix( const TString &nametrain,288 const Int_t howmanytrain, MH3 &hreftrain,289 303 Bool_t MCT1FindSupercuts::DefineTrainMatrix( 304 const TString &nametrain, MH3 &hreftrain, 305 const Int_t howmanytrain, const TString &filetrain) 290 306 { 291 307 if (nametrain.IsNull() || howmanytrain <= 0) … … 295 311 *fLog << "fill training matrix from file '" << nametrain 296 312 << "', select " << howmanytrain 297 << " events according to a distribution given by the MH3 object '" 298 << hreftrain.GetName() << "'" << endl; 313 << " events " << endl; 314 if (!fUseOrigDistribution) 315 { 316 *fLog << " according to a distribution given by the MH3 object '" 317 << hreftrain.GetName() << "'" << endl; 318 } 319 else 320 { 321 *fLog << " randomly" << endl; 322 } 299 323 300 324 … … 305 329 read.DisableAutoScheme(); 306 330 307 //MFEventSelector2 seltrain(hreftrain); 308 //seltrain.SetNumMax(howmanytrain); 309 MFEventSelector seltrain; 310 seltrain.SetNumSelectEvts(howmanytrain); 331 MFEventSelector2 seltrain(hreftrain); 332 seltrain.SetNumMax(howmanytrain); 333 seltrain.SetName("selectTrain"); 334 if (fUseOrigDistribution) 335 seltrain.SetUseOrigDistribution(kTRUE); 311 336 312 337 MFillH filltrain(fMatrixTrain); 313 338 filltrain.SetFilter(&seltrain); 339 filltrain.SetName("fillMatrixTrain"); 314 340 315 341 //****************************** … … 379 405 // 380 406 // 381 Bool_t MCT1FindSupercuts::DefineTestMatrix( const TString &nametest,382 const Int_t howmanytest, MH3 &hreftest,383 407 Bool_t MCT1FindSupercuts::DefineTestMatrix( 408 const TString &nametest, MH3 &hreftest, 409 const Int_t howmanytest, const TString &filetest) 384 410 { 385 411 if (nametest.IsNull() || howmanytest<=0) … … 389 415 *fLog << "fill test matrix from file '" << nametest 390 416 << "', select " << howmanytest 391 << " events according to a distribution given by the MH3 object '" 392 << hreftest.GetName() << "'" << endl; 417 << " events " << endl; 418 if (!fUseOrigDistribution) 419 { 420 *fLog << " according to a distribution given by the MH3 object '" 421 << hreftest.GetName() << "'" << endl; 422 } 423 else 424 { 425 *fLog << " randomly" << endl; 426 } 393 427 394 428 … … 399 433 read.DisableAutoScheme(); 400 434 401 //MFEventSelector2 seltest(hreftest); 402 //seltest.SetNumMax(howmanytest); 403 MFEventSelector seltest; 404 seltest.SetNumSelectEvts(howmanytest); 405 435 MFEventSelector2 seltest(hreftest); 436 seltest.SetNumMax(howmanytest); 437 seltest.SetName("selectTest"); 438 if (fUseOrigDistribution) 439 seltest.SetUseOrigDistribution(kTRUE); 440 406 441 MFillH filltest(fMatrixTest); 407 442 filltest.SetFilter(&seltest); … … 471 506 // 472 507 Bool_t MCT1FindSupercuts::DefineTrainTestMatrix( 473 const TString &name, 474 const Int_t howmanytrain, MH3 &hreftrain, 475 const Int_t howmanytest, MH3 &hreftest, 508 const TString &name, MH3 &href, 509 const Int_t howmanytrain, const Int_t howmanytest, 476 510 const TString &filetrain, const TString &filetest) 477 511 { 478 512 *fLog << "=============================================" << endl; 479 *fLog << "fill training matrix from file '" << name 480 << "', select " << howmanytrain 481 << " events for the training according to a distribution given by the MH3 object '" 482 << hreftrain.GetName() << "'" << endl; 483 484 *fLog << "fill test matrix from the same file '" << name 485 << "', select " << howmanytest 486 << " events for the training according to a distribution given by the MH3 object '" 487 << hreftest.GetName() << "'" << endl; 513 *fLog << "fill training and test matrix from file '" << name 514 << "', select " << howmanytrain 515 << " training and " << howmanytest << " test events " << endl; 516 if (!fUseOrigDistribution) 517 { 518 *fLog << " according to a distribution given by the MH3 object '" 519 << href.GetName() << "'" << endl; 520 } 521 else 522 { 523 *fLog << " randomly" << endl; 524 } 488 525 489 526 … … 494 531 read.DisableAutoScheme(); 495 532 496 //MFEventSelector2 seltrain(hreftrain); 497 //seltrain.SetNumMax(howmanytrain); 498 MFEventSelector seltrain; 499 seltrain.SetName("SelTrain"); 500 seltrain.SetNumSelectEvts(howmanytrain); 533 MFEventSelector2 selector(href); 534 selector.SetNumMax(howmanytrain+howmanytest); 535 selector.SetName("selectTrainTest"); 536 selector.SetInverted(); 537 if (fUseOrigDistribution) 538 selector.SetUseOrigDistribution(kTRUE); 539 540 MContinue cont(&selector); 541 cont.SetName("ContTrainTest"); 542 543 Double_t prob = ( (Double_t) howmanytrain ) 544 / ( (Double_t)(howmanytrain+howmanytest) ); 545 MFRandomSplit split(prob); 501 546 502 547 MFillH filltrain(fMatrixTrain); 548 filltrain.SetFilter(&split); 503 549 filltrain.SetName("fillMatrixTrain"); 504 filltrain.SetFilter(&seltrain); 550 505 551 506 552 // consider this event as candidate for a test event 507 553 // only if event was not accepted as a training event 508 MContinue cont(&seltrain); 509 510 const Float_t fcorr = (Float_t)read.GetEntries() / (read.GetEntries()-howmanytrain); 511 512 *fLog << "entries, howmanytrain, fcorr = " << read.GetEntries() 513 << ", " << howmanytrain << ", " << fcorr << endl; 514 515 //MFEventSelector2 seltest(hreftest); 516 //seltrain.SetNumMax(howmanytest*fcorr); 517 MFEventSelector seltest; 518 seltest.SetName("SelTest"); 519 seltest.SetNumSelectEvts((Int_t)(fcorr*howmanytest)); 554 555 MContinue conttrain(&split); 556 conttrain.SetName("ContTrain"); 520 557 521 558 MFillH filltest(fMatrixTest); 522 559 filltest.SetName("fillMatrixTest"); 523 filltest.SetFilter(&seltest); 560 524 561 525 562 //****************************** … … 535 572 536 573 tlist.AddToList(&read); 537 tlist.AddToList(&seltrain); 574 tlist.AddToList(&cont); 575 576 tlist.AddToList(&split); 538 577 tlist.AddToList(&filltrain); 539 540 tlist.AddToList(&cont); 541 542 tlist.AddToList(&seltest); 578 tlist.AddToList(&conttrain); 579 543 580 tlist.AddToList(&filltest); 544 581 -
trunk/MagicSoft/Mars/manalysis/MCT1FindSupercuts.h
r2357 r2574 37 37 Int_t fHowManyTrain; 38 38 Int_t fHowManyTest; 39 40 Bool_t fUseOrigDistribution; 39 41 40 42 TString fFilenameParam; … … 88 90 void SetMatrixFilter(MFilter *filter) {fMatrixFilter = filter;} 89 91 90 Bool_t DefineTrainMatrix(const TString &name, const Int_t howmany,91 MH3 &href, const TString &filetrain);92 Bool_t DefineTrainMatrix(const TString &name, MH3 &href, 93 const Int_t howmany, const TString &filetrain); 92 94 93 Bool_t DefineTestMatrix(const TString &name, const Int_t howmany,94 MH3 &href,const TString &filetest);95 Bool_t DefineTestMatrix(const TString &name, MH3 &href, 96 const Int_t howmany, const TString &filetest); 95 97 96 Bool_t DefineTrainTestMatrix(const TString &name, 97 const Int_t howmanytrain, MH3 &hreftrain, 98 const Int_t howmanytest, MH3 &hreftest, 98 Bool_t DefineTrainTestMatrix(const TString &name, MH3 &href, 99 const Int_t howmanytrain, const Int_t howmanytest, 99 100 const TString &filetrain, const TString &filetest); 101 102 void SetUseOrigDistribution(Bool_t b); 100 103 101 104 MHMatrix *GetMatrixTrain() { return fMatrixTrain; }
Note:
See TracChangeset
for help on using the changeset viewer.