Changeset 2574 for trunk/MagicSoft
- Timestamp:
- 11/28/03 08:08:53 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 4 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2573 r2574 4 4 5 5 -*-*- END OF LINE -*-*- 6 7 8 9 2003/11/27: Wolfgang Wittek 10 11 * mfilter/MFEventSelector2.cc 12 - if number of requested events is too high 13 reduce it to the maximum number possible 14 - introduce the flag 'fUseOrigDistribution'; 15 if it is set to kTRUE (by SetOrigDistribution()) the original 16 distribution will be used as the nominal distribution 17 - add the member functions SetUseOrigDistribution() 18 GetHistOrig() 19 20 * mfilter/MFRandomSplit.[h,cc] 21 - a filter which gives fResult = kTRUE with a certain probability 22 23 * mfilter/MFAntiFilter.[h,cc] 24 - a filter which checks the result of a given filter and returns 25 the opposite result; 26 Thomas : could you please add a code which puts the filter whose 27 result is checked into the task list ? 28 29 * mfilter/Makefile 30 FilterLinkDef.h 31 - add MFRandomSplit and MFAntiFilter 32 33 * manalysis/MCT1FindSupercuts.[h,cc] 34 - in 'DefineTrainMatrix', 'DefineTestMatrix', and 35 'DefineTrainTestMatrix()' : 36 replace call to 'MFEventSelector' by call to 'MFEventSelector2' 37 - add member function SetUseOrigDistribution(Bool_t b); 38 if b = kTRUE the events for the training and test samples are 39 selected randomnly from the input file 40 41 42 6 43 2003/11/27: Abelardo Moralejo 7 44 … … 11 48 where the parameter containers for each telescope are tagged 12 49 with a ';' followed by the telescope number. 50 13 51 14 52 2003/11/26: Thomas Bretz -
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; } -
trunk/MagicSoft/Mars/mfilter/FilterLinkDef.h
r2521 r2574 24 24 25 25 #pragma link C++ class MFEnergySlope+; 26 #pragma link C++ class MFRandomSplit+; 27 #pragma link C++ class MFAntiFilter+; 26 28 27 29 #endif -
trunk/MagicSoft/Mars/mfilter/MFEventSelector2.cc
r2357 r2574 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz, 01/2002 <mailto:tbretz@astro.uni-wuerzburg.de> 18 ! Author(s): Thomas Bretz, 01/2002 <mailto:tbretz@astro.uni-wuerzburg.de> 19 ! Wolfgang Wittek 11/2003 <mailto:wittek@mppmu.mpg.de> 19 20 ! 20 21 ! Copyright: MAGIC Software Development, 2000-2003 … … 135 136 // would result in redistributing cos(Theta). 136 137 // 138 // If 'fUseOrigDistribution' is set to kTRUE (by SetUseOrigDistribution()) 139 // the original distribution will be used as the nominal distribution; 140 // note that also in this case a dummy nominal distribution has to be 141 // provided in the first argument (the dummy distribution defines the 142 // variable(s) of interest and the binnings) 143 // 144 137 145 MFEventSelector2::MFEventSelector2(MH3 &hist, const char *name, const char *title) 138 146 : fHistOrig(NULL), fHistNom(&hist), fHistRes(NULL), … … 142 150 fName = name ? (TString)name : gsDefName; 143 151 fTitle = title ? (TString)title : gsDefTitle; 144 } 145 146 // -------------------------------------------------------------------------- 147 // 148 // Destructor. Deletes fHistRes if allocated. 152 153 fUseOrigDistribution = kFALSE; 154 } 155 156 // -------------------------------------------------------------------------- 157 // 158 // 149 159 // 150 160 MFEventSelector2::~MFEventSelector2() 151 161 { 152 if (fHistRes) 153 delete fHistRes; 154 } 155 156 // -------------------------------------------------------------------------- 162 if (fHistRes) 163 delete fHistRes; 164 } 165 166 // -------------------------------------------------------------------------- 167 // 168 // 169 // 170 void MFEventSelector2::SetUseOrigDistribution(Bool_t b) 171 { 172 fUseOrigDistribution = b; 173 174 *fLog << "MFEventSelector2 : use the distribution from the input file as the target distribution" 175 << endl; 176 } 177 178 //--------------------------------------------------------------------------- 157 179 // 158 180 // Recreate a MH3 from fHistNom used as a template. Copy the Binning … … 189 211 190 212 *fLog << "-------------------------" << endl; 191 *fLog << "MFEventSelector2::ReadDistribution; read input file to generate the original distribution" << endl; 213 *fLog << "MFEventSelector2 : Start of eventloop to generate the original distribution" 214 << endl; 192 215 193 216 MEvtLoop run(GetName()); … … 214 237 if (!run.Eventloop()) 215 238 { 216 *fLog << err << dbginf << "Evtloop failed." << endl;239 *fLog << err << dbginf << "Evtloop in MFEventSelector2::ReadDistribution failed." << endl; 217 240 return kFALSE; 218 241 } … … 222 245 *fLog << "MFEventSelector2::ReadDistribution; Original distribution has " 223 246 << fHistOrig->GetHist().GetEntries() << " entries" << endl; 247 *fLog << "MFEventSelector2 : End of eventloop to generate the original distribution" 248 << endl; 224 249 *fLog << "-------------------------" << endl; 225 250 … … 229 254 // -------------------------------------------------------------------------- 230 255 // 231 // After reading the histograms andarrays used for the random event256 // After reading the histograms the arrays used for the random event 232 257 // selction are created. If a MStatusDisplay is set the histograms are 233 258 // displayed there. … … 236 261 { 237 262 TH1 &ho = fHistOrig->GetHist(); 238 TH1 &hn = fHistNom->GetHist(); 239 240 fHistNom->SetTitle("Users Nominal Distribution"); 241 fHistRes->SetTitle("Resulting Distribution"); 263 264 //------------------- 265 // if requested 266 // set the nominal distribution equal to the original distribution 267 268 TH1 *hnp; 269 if (fUseOrigDistribution) 270 hnp = (TH1*)(fHistOrig->GetHist()).Clone(); 271 else 272 hnp = &fHistNom->GetHist(); 273 274 TH1 &hn = *hnp; 275 //-------------------- 242 276 243 277 // normalize to number of counts in primary distribution … … 268 302 if (fNumMax>0) 269 303 { 270 *fLog << "MFEventSelector2::PrepareHistograms; SCALE : fNumMax = " 271 << fNumMax << ", hn.Integral() = " << hn.Integral() 272 << ", fNumMax/hn.Integral() = " << fNumMax/hn.Integral() 273 << endl; 274 275 hn.Scale(fNumMax/hn.Integral()); 304 *fLog << "MFEventSelector2::PrepareHistograms; requested no.of events = " 305 << fNumMax << ", maximum no.of events possible = " 306 << hn.Integral() << endl; 307 308 if (fNumMax > hn.Integral()) 309 { 310 *fLog << "MFEventSelector2::PrepareHistograms; requested no.of events (" 311 << fNumMax << ") is too high" << endl; 312 *fLog << " reduce it to " 313 << hn.Integral() << endl; 314 } 315 316 else 317 hn.Scale(fNumMax/hn.Integral()); 276 318 } 277 319 … … 297 339 fNom[i] = (Long_t)(hn.GetBinContent(i+1)+0.5); 298 340 } 341 342 if (fUseOrigDistribution) 343 delete hnp; 299 344 } 300 345 … … 362 407 InitHistogram(fHistRes); 363 408 409 fHistNom->SetTitle("Users Nominal Distribution"); 364 410 fHistOrig->SetTitle("Primary Distribution"); 411 fHistRes->SetTitle("Resulting Distribution"); 365 412 366 413 // Initialize online display if requested … … 369 416 fHistOrig->Draw(); 370 417 371 // Readprimary distribution418 // Generate primary distribution 372 419 if (!ReadDistribution(*read)) 373 420 return kFALSE; … … 467 514 return kTRUE; 468 515 } 516 517 518 519 520 521 522 523 524 -
trunk/MagicSoft/Mars/mfilter/MFEventSelector2.h
r2357 r2574 41 41 TCanvas *fCanvas; //! canvas for online display 42 42 43 Bool_t fUseOrigDistribution; 44 43 45 Bool_t fResult; 44 46 Int_t fErrors[2]; … … 57 59 ~MFEventSelector2(); 58 60 61 void SetUseOrigDistribution(Bool_t b=kTRUE); 62 MH3 *GetHistOrig() { return fHistOrig; } 63 59 64 void SetNumMax(Long_t max=-1) { fNumMax = max; } 60 65 Bool_t IsExpressionTrue() const { return fResult; } … … 64 69 65 70 #endif 71 72 73 -
trunk/MagicSoft/Mars/mfilter/Makefile
r2521 r2574 48 48 MFCT1SelStandard.cc \ 49 49 MFCT1SelFinal.cc \ 50 MFEnergySlope.cc 50 MFEnergySlope.cc \ 51 MFRandomSplit.cc \ 52 MFAntiFilter.cc 51 53 52 54 SRCS = $(SRCFILES)
Note:
See TracChangeset
for help on using the changeset viewer.