Changeset 7665 for trunk/MagicSoft/Mars/mjtrain
- Timestamp:
- 04/30/06 14:50:22 (19 years ago)
- Location:
- trunk/MagicSoft/Mars/mjtrain
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjtrain/MJTrainSeparation.cc
r7664 r7665 34 34 #include <TChain.h> 35 35 #include <TGraph.h> 36 #include <TCanvas.h> 36 37 #include <TVirtualPad.h> 37 38 … … 80 81 void MJTrainSeparation::DisplayResult(MH3 &h31, MH3 &h32) 81 82 { 82 TH2 &g = (TH2&)h32.GetHist();83 TH2 &h = (TH2&)h31.GetHist();83 TH2D &g = (TH2D&)h32.GetHist(); 84 TH2D &h = (TH2D&)h31.GetHist(); 84 85 85 86 h.SetMarkerColor(kRed); … … 279 280 set.AddFilesOff(chain); 280 281 281 TH1F h; 282 h.SetDirectory(gROOT); 283 h.SetNameTitle("OnTime", "Effective on-time"); 284 chain.Draw("MEffectiveOnTime.fVal>>OnTime", "", "goff"); 285 h.SetDirectory(0); 286 287 if (h.Integral()<1) 282 chain.Draw("MEffectiveOnTime.fVal", "MEffectiveOnTime.fVal", "goff"); 283 284 TH1 *h = dynamic_cast<TH1*>(gROOT->FindObject("htemp")); 285 if (!h) 286 { 287 *fLog << err << "ERROR - Weird things are happening (htemp not found)!" << endl; 288 return -1; 289 } 290 291 const Double_t ontime = h->Integral(); 292 delete h; 293 294 if (ontime<1) 288 295 { 289 296 *fLog << err << "ERROR - Less than 1s of effective observation time found in Train-Data." << endl; … … 291 298 } 292 299 293 *fLog << inf << "Found " << num << " events in " << h.Integral(); 294 *fLog << "s (" << num/h.Integral() << "Hz)" << endl; 295 296 return num/h.Integral(); 297 } 298 299 /* 300 Scale: 301 302 303 TF1 fold("old", "x^(-2.6)", emin, emax); 304 TF1 fnew("new", "x^(-4.0)", emin, emax); 305 306 TF1 q("q", "new/old", emin, emax); 307 308 Double_t scale = 1./q.GetMaximum(emin, emax); 309 310 // Anzahl produzierter Events vor MFEnergySlope: 311 Double_t nold = fold.Integral(emin, emax); 312 313 // Anzahl produzierter Events nach MFEnergySlope: 314 Double_t nnew = fnew.Integral(emin, emax)*scale; 315 316 class MFSpectrum : MMcSpectrumWeight 317 { 318 Double_t fScale; 319 Bool_t fResult; 320 321 MFSpectrum::MFSpectrum(const char *name, const char *title) 322 { 323 fName = name ? name : "MMcSpectrumWeight"; 324 fTitle = title ? title : "Task to calculate weights to change the energy spectrum"; 325 326 Init(fName, fTitle); 327 328 } 329 330 Int_t PreProcess(MParList *pList) 331 { 332 Int_t rc = MFSpectrumWeight::PreProcess(pList); 333 if (rc!=kTRUE) 334 return rc; 335 336 fScale = fEval->GetMaximum(fEnergyMin, fEnergyMax); 337 338 return kTRUE; 339 } 340 341 Int_t Process() 342 { 343 const Double_t e = fMcEvt->GetEnergy(); 344 345 Double_t prob = fFunc->Eval(e)/fScale; 346 347 const Float_t Nexp = fN0 * pow(energy,fMcSlope-fNewSlope); 348 const Float_t Nrnd = ; 349 350 fResult = Nexp >= gRandom->Uniform(); 351 } 352 353 } 354 355 356 */ 300 *fLog << inf << "Found " << num << " background events in " << ontime << "s" << endl; 301 302 return num/ontime; 303 } 357 304 358 305 Bool_t MJTrainSeparation::AutoTrain() … … 366 313 // Target spectrum 367 314 TF1 flx("Flux", "[0]*(x/1000)^(-2.6)", min, max); 368 flx.SetParameter(0, 1e- 5);315 flx.SetParameter(0, 1e-7); 369 316 370 317 // Number n0 of events this spectrum would produce per s and m^2 … … 393 340 394 341 *fLog << "Calculated a total Monte Carlo observation time of " << T << "s" << endl; 395 *fLog << "For a data rate of " << r << "Hz this corresponds to " << n<< " data events." << endl;342 *fLog << "For a data rate of " << r << "Hz this corresponds to " << TMath::Nint(n) << " data events." << endl; 396 343 397 344 fNumTrainOn = (UInt_t)-1; … … 480 427 481 428 const Int_t numgammas = train.GetNumRows(); 429 if (numgammas==0) 430 { 431 *fLog << err << "ERROR - No gammas available for training... aborting." << endl; 432 return kFALSE; 433 } 482 434 483 435 // Set classifier for hadrons … … 490 442 491 443 const Int_t numbackgrnd = train.GetNumRows()-numgammas; 444 if (numbackgrnd==0) 445 { 446 *fLog << err << "ERROR - No background available for training... aborting." << endl; 447 return kFALSE; 448 } 492 449 493 450 // ------------------------ Train RF -------------------------- … … 513 470 MBinning b(2, -0.5, 1.5, "BinningHadronness", "lin"); 514 471 if (!rf.TrainSingleRF(train, b.GetEdgesD())) // classification 515 return ;472 return kFALSE; 516 473 } 517 474 -
trunk/MagicSoft/Mars/mjtrain/MJTrainSeparation.h
r7664 r7665 44 44 ds.Copy(fDataSetTrain); 45 45 46 fDataSet .SetNumAnalysis(1);46 fDataSetTrain.SetNumAnalysis(1); 47 47 48 48 fNumTrainOn = non; … … 53 53 ds.Copy(fDataSetTest); 54 54 55 fDataSet .SetNumAnalysis(1);55 fDataSetTest.SetNumAnalysis(1); 56 56 57 57 fNumTestOn = non;
Note:
See TracChangeset
for help on using the changeset viewer.