Changeset 6978
- Timestamp:
- 04/25/05 15:37:35 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r6976 r6978 21 21 22 22 -*-*- END OF LINE -*-*- 23 24 2005/04/25 Thomas Bretz 25 26 * ganymed.cc: 27 - changed policy of writing the resulting events to the result file 28 29 * sponde.cc: 30 - added commandline option to use all monte carlos 31 - added command line option to read the MCs more accurate 32 33 * sponde.rc: 34 - added 35 36 * mbase/MStatusDisplay.[h,cc]: 37 - added some code to get Tab by name 38 - fixed a typo in a status line output 39 40 * mhbase/MH.[h,cc], mhbase/MH3.[h,cc], mhflux/MHFalseSource.h, 41 mhist/MHCamEvent.[h,cc], mhist/MHCamEventRot.h, 42 mhist/MHEvent.h, mhist/MHStarMap.h, mhist/MHTriggerLvl0.[h,cc], 43 mhistmc/MHMcTriggerLvl2.[h,cc], mhvstime/MHPixVsTime.[h,cc], 44 mhvstime/MHSectorVsTime.[h,cc], mimage/MHHillas.[h,cc], 45 mimage/MHHillasExt.[h,cc], mimage/MHHillasSrc.[h,cc], 46 mimage/MHImagePar.[h,cc], mimage/MHNewImagePar.[h,cc]: 47 - changed GetHistByName to be const-qualified to be compatible 48 with FindObject 49 - added some FindObject function to call GetHistByName 50 51 * mhflux/MHAlpha.[h,cc]: 52 - changed such, that it can be forced to display the excess 53 events versus size 54 55 * mjobs/MJCut.[h,cc]: 56 - display number of excess events versus Size per default 57 - removed energy estimator 58 59 * mjobs/MJOptimize.cc: 60 - display number of excess events verss size after optimization 61 62 * mjobs/MJSpectrum.[h,cc]: 63 - implemented setting up energy estimator 64 - replaced some gLog by fLog 65 - display comparison of image parameters 66 67 23 68 24 69 2005/04/22 Thomas Bretz -
trunk/MagicSoft/Mars/NEWS
r6964 r6978 21 21 - Changed the default paths for calibrated data and image files. 22 22 (The implemented access to these files doesn't yet exist) 23 24 - ganymed (MJCut and MJOptimize) now displayes the number of 25 excess events versus size. The energy estimation is done in 26 MJSpectrum (sponde) 23 27 24 28 -
trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
r6954 r6978 178 178 // -------------------------------------------------------------------------- 179 179 180 TGCompositeFrame *MStatusDisplay::GetTabContainer(const char *name) const 181 { 182 #if ROOT_VERSION_CODE < ROOT_VERSION(4,03,05) 183 if (!fTab) 184 return 0; 185 186 TGFrameElement *el; 187 TGTabElement *tab = 0; 188 TGCompositeFrame *comp = 0; 189 190 TIter next(fTab->GetList()); 191 next(); // skip first container 192 193 while ((el = (TGFrameElement *) next())) { 194 el = (TGFrameElement *) next(); 195 comp = (TGCompositeFrame *) el->fFrame; 196 next(); 197 tab = (TGTabElement *)el->fFrame; 198 if (name == tab->GetText()->GetString()) { 199 return comp; 200 } 201 } 202 203 return 0; 204 #else 205 return fTab ? fTab->GetTabContainer(name) : 0; 206 #endif 207 } 208 209 TGTabElement *MStatusDisplay::GetTabTab(const char *name) const 210 { 211 #if ROOT_VERSION_CODE < ROOT_VERSION(4,03,05) 212 if (!fTab) 213 return 0; 214 215 TGFrameElement *el; 216 TGTabElement *tab = 0; 217 218 TIter next(fTab->GetList()); 219 next(); // skip first container 220 221 while ((el = (TGFrameElement *) next())) { 222 next(); 223 tab = (TGTabElement *)el->fFrame; 224 if (name == tab->GetText()->GetString()) { 225 return tab; 226 } 227 } 228 229 return 0; 230 #else 231 return fTab ? fTab->GetTabTab(name) : 0; 232 #endif 233 } 234 // -------------------------------------------------------------------------- 235 236 180 237 // -------------------------------------------------------------------------- 181 238 // … … 1341 1398 1342 1399 case kLogAppend: 1343 SetStatusLine1("Appending log g...");1400 SetStatusLine1("Appending log..."); 1344 1401 SetStatusLine2(""); 1345 1402 *fLog << inf << "Appending log... " << flush; -
trunk/MagicSoft/Mars/mbase/MStatusDisplay.h
r6938 r6978 30 30 class TGTextView; 31 31 class TGStatusBar; 32 class TGTabElement; 32 33 class TGProgressBar; 33 34 class TGHProgressBar; … … 122 123 Bool_t HandleEvent(Event_t *event); 123 124 125 TGCompositeFrame *GetTabContainer(const char *name) const; 126 TGTabElement *GetTabTab(const char *name) const; 127 124 128 Bool_t HandleTimer(TTimer *timer=NULL); 125 129 void UpdateTab(TGCompositeFrame *f); -
trunk/MagicSoft/Mars/mhbase/MFillH.cc
r6947 r6978 543 543 */ 544 544 545 TVirtualPad *save = gPad;546 if (fCanvas)547 fCanvas->cd();545 // TVirtualPad *save = gPad; 546 // if (fCanvas) 547 // fCanvas->cd(); 548 548 549 549 const Bool_t rc = fH->Fill(fParContainer, fWeight?fWeight->GetVal():1); 550 550 fH->SetNumExecutions(GetNumExecutions()+1); 551 551 552 if (save && fCanvas)553 save->cd();552 // if (save && fCanvas) 553 // save->cd(); 554 554 return rc; 555 555 } -
trunk/MagicSoft/Mars/mhbase/MH.cc
r6949 r6978 117 117 // a pointer to a root histogram from the MH-derived class. 118 118 // 119 TH1 *MH::GetHistByName(const TString name) 119 TH1 *MH::GetHistByName(const TString name) const 120 120 { 121 121 *fLog << warn << GetDescriptor() << ": GetHistByName not overloaded! Can't be used!" << endl; -
trunk/MagicSoft/Mars/mhbase/MH.h
r6948 r6978 49 49 virtual TString GetDataMember() const { return ""; } 50 50 51 virtual TH1 *GetHistByName(const TString name) ;51 virtual TH1 *GetHistByName(const TString name) const; 52 52 53 53 static TCanvas *MakeDefCanvas(TString name="", const char *title="", -
trunk/MagicSoft/Mars/mhbase/MH3.h
r5620 r6978 72 72 const TH1 &GetHist() const { return *fHist; } 73 73 74 TH1 *GetHistByName(const TString name="") { return fHist; } 74 TH1 *GetHistByName(const TString name="") const { return fHist; } 75 TObject *FindObject(const TObject *obj) const { return 0; } 76 TObject *FindObject(const char *name) const 77 { 78 return (TObject*)GetHistByName(name); 79 } 75 80 76 81 void SetColors() const; -
trunk/MagicSoft/Mars/mhflux/MHFalseSource.h
r5957 r6978 59 59 MHFalseSource(const char *name=NULL, const char *title=NULL); 60 60 61 TH1 *GetHistByName(const TString name) { return &fHist; }62 63 61 void FitSignificance(Float_t sigint=10, Float_t sigmax=75, Float_t bgmin=45, Float_t bgmax=85, Byte_t polynom=2); //*MENU* 64 62 void FitSignificanceStd() { FitSignificance(); } //*MENU* -
trunk/MagicSoft/Mars/mjobs/MJCut.cc
r6958 r6978 48 48 #include "MPrint.h" 49 49 #include "MContinue.h" 50 #include "MEnergyEstimate.h"50 //#include "MEnergyEstimate.h" 51 51 #include "MTaskEnv.h" 52 52 #include "MSrcPosCalc.h" … … 56 56 57 57 #include "../mhflux/MAlphaFitter.h" 58 #include "../mhflux/MHAlpha.h" 59 58 60 #include "MH3.h" 59 61 #include "MBinning.h" … … 71 73 // Default constructor. Set defaults for fStoreSummary, fStoreresult, 72 74 // fWriteOnly, fIsWobble and fFullDisplay to kFALSE and initialize 73 // fEstimateEnergy andfCalcHadronness with NULL.75 // /*fEstimateEnergy and*/ fCalcHadronness with NULL. 74 76 // 75 77 MJCut::MJCut(const char *name, const char *title) 76 : fStoreSummary(kFALSE), fStoreResult(k FALSE), fWriteOnly(kFALSE),78 : fStoreSummary(kFALSE), fStoreResult(kTRUE), fWriteOnly(kFALSE), 77 79 fIsWobble(kFALSE), fIsMonteCarlo(kFALSE), fFullDisplay(kFALSE), /*fSubstraction(kFALSE),*/ 78 fEstimateEnergy(0),fCalcHadronness(0)80 /*fEstimateEnergy(0),*/ fCalcHadronness(0) 79 81 { 80 82 fName = name ? name : "MJCut"; … … 88 90 MJCut::~MJCut() 89 91 { 90 if (fEstimateEnergy)91 delete fEstimateEnergy;92 //if (fEstimateEnergy) 93 // delete fEstimateEnergy; 92 94 if (fCalcHadronness) 93 95 delete fCalcHadronness; … … 132 134 // Setup a task estimating the energy. The given task is cloned. 133 135 // 136 /* 134 137 void MJCut::SetEnergyEstimator(const MTask *task) 135 138 { … … 138 141 fEstimateEnergy = task ? (MTask*)task->Clone() : 0; 139 142 } 143 */ 140 144 141 145 // -------------------------------------------------------------------------- … … 246 250 TObjArray arr; 247 251 252 // Save all MBinnings 248 253 TIter Next(plist); 249 254 TObject *o=0; … … 252 257 arr.Add(o); 253 258 259 // Save also the result, not only the setup 260 const MHAlpha *halpha = (MHAlpha*)plist.FindObject("MHAlpha"); 261 if (halpha) 262 arr.Add((TObject*)(&halpha->GetAlphaFitter())); 263 254 264 const TString fname(GetOutputFile(num)); 255 265 266 // If requested, write to already open output file 256 267 if (fNameResult.IsNull() && fStoreResult) 257 268 { … … 413 424 fit.SetScaleMode(MAlphaFitter::kNone); 414 425 426 MHAlpha halphaoff("MHAlphaOff"); 427 halphaoff.ForceUsingSize(); 428 plist.AddToList(&halphaoff); 429 415 430 MFillH falpha("MHAlphaOff [MHAlpha]", "MHillasSrc", "FillAlpha"); 416 431 MFillH ffs("MHFalseSourceOff [MHFalseSource]", "MHillas", "FillFS"); … … 452 467 SetupWriter(write1, "WriteAfterCut3"); 453 468 454 469 /* 455 470 MEnergyEstimate est; 456 471 457 472 MTaskEnv taskenv1("EstimateEnergy"); 458 473 taskenv1.SetDefault(fEstimateEnergy ? fEstimateEnergy : &est); 459 474 */ 460 475 MTaskEnv taskenv2("CalcHadronness"); 461 476 taskenv2.SetDefault(fCalcHadronness); … … 495 510 if (fIsWobble) 496 511 tlist2.AddToList(&hcalc2); 497 tlist2.AddToList(&taskenv1);512 //tlist2.AddToList(&taskenv1); 498 513 tlist2.AddToList(&taskenv2); 499 514 tlist2.AddToList(&cont0); … … 539 554 540 555 TObjArray cont; 541 cont.Add(&fit);542 556 cont.Add(&cont0); 543 557 cont.Add(&cont1); 544 558 cont.Add(&cont2); 545 559 cont.Add(&cont3); 546 if (taskenv1.GetTask())547 cont.Add(taskenv1.GetTask());560 //if (taskenv1.GetTask()) 561 // cont.Add(taskenv1.GetTask()); 548 562 if (taskenv2.GetTask()) 549 563 cont.Add(taskenv2.GetTask()); … … 641 655 } 642 656 */ 657 MHAlpha halphaon("MHAlpha"); 658 halphaon.ForceUsingSize(); 659 plist.AddToList(&halphaon); 660 643 661 MFillH falpha2("MHAlpha", "MHillasSrc", "FillAlpha"); 644 662 MFillH ffs2("MHFalseSource", "MHillas", "FillFS"); -
trunk/MagicSoft/Mars/mjobs/MJCut.h
r6949 r6978 26 26 TString fNameOutput; 27 27 28 MTask *fEstimateEnergy;28 //MTask *fEstimateEnergy; 29 29 MTask *fCalcHadronness; 30 30 … … 57 57 void SetNameOutFile(const char *name="") { fNameOutput=name; } 58 58 59 void SetEnergyEstimator(const MTask *task=0);59 //void SetEnergyEstimator(const MTask *task=0); 60 60 void SetHadronnessCalculator(const MTask *task=0); 61 61 -
trunk/MagicSoft/Mars/mjobs/MJOptimize.cc
r6965 r6978 914 914 histof.SkipHistTheta(); 915 915 //histof.SkipHistEnergy(); 916 histon.InitMapping(&m, 0); 917 histof.InitMapping(&m, 0); 916 histon.ForceUsingSize(); 917 histof.ForceUsingSize(); 918 histon.InitMapping(&m, 1); 919 histof.InitMapping(&m, 1); 918 920 919 921 if (filter && filter->InheritsFrom(MFMagicCuts::Class())) -
trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
r6966 r6978 68 68 #include "MFEventSelector2.h" 69 69 #include "MFDataMember.h" 70 #include "MEnergyEstimate.h" 71 #include "MTaskEnv.h" 70 72 #include "MFillH.h" 71 73 #include "MHillasCalc.h" … … 79 81 MJSpectrum::MJSpectrum(const char *name, const char *title) 80 82 : fCut0(0),fCut1(0), fCut2(0), fCut3(0), fEstimateEnergy(0), 81 fRefill(kFALSE), fSimpleMode(kTRUE) 83 fRefill(kFALSE), fSimpleMode(kTRUE), fRawMc(kFALSE) 82 84 { 83 85 fName = name ? name : "MJSpectrum"; … … 99 101 } 100 102 103 // -------------------------------------------------------------------------- 104 // 105 // Setup a task estimating the energy. The given task is cloned. 106 // 107 void MJSpectrum::SetEnergyEstimator(const MTask *task) 108 { 109 if (fEstimateEnergy) 110 delete fEstimateEnergy; 111 fEstimateEnergy = task ? (MTask*)task->Clone() : 0; 112 } 113 101 114 Bool_t MJSpectrum::ReadTask(MTask* &task, const char *name) const 102 115 { … … 125 138 } 126 139 127 Bool_t MJSpectrum::ReadInput(const MParList &plist) 128 { 129 const TString fname = fPathIn; 130 131 *fLog << inf << "Reading from file: " << fname << endl; 132 133 TFile file(fname, "READ"); 140 void MJSpectrum::PrintSetup(const MAlphaFitter &fit) const 141 { 142 fLog->Separator("Alpha Fitter"); 143 *fLog << all; 144 fit.Print(); 145 146 fLog->Separator("Used Cuts"); 147 fCut0->Print(); 148 fCut1->Print(); 149 fCut2->Print(); 150 fCut3->Print(); 151 152 //gLog.Separator("Energy Estimator"); 153 //fEstimateEnergy->Print(); 154 } 155 156 Float_t MJSpectrum::ReadInput(MParList &plist, TH1D &h1, TH1D &h2) 157 { 158 *fLog << inf << "Reading from file: " << fPathIn << endl; 159 160 TFile file(fPathIn, "READ"); 134 161 if (!file.IsOpen()) 135 162 { 136 *fLog << err << dbginf << "ERROR - Could not open file " << fname << endl; 137 return kFALSE; 138 } 163 *fLog << err << dbginf << "ERROR - Could not open file " << fPathIn << endl; 164 return -1; 165 } 166 167 MStatusArray arr; 168 if (arr.Read()<=0) 169 { 170 *fLog << "MStatusDisplay not found in file... abort." << endl; 171 return -1; 172 } 173 174 TH1D *vstime = (TH1D*)arr.FindObjectInCanvas("Theta", "TH1D", "OnTime"); 175 TH1D *size = (TH1D*)arr.FindObjectInCanvas("Excess", "TH1D", "MHAlpha"); 176 if (!vstime || !size) 177 return -1; 178 179 vstime->Copy(h1); 180 size->Copy(h2); 181 h1.SetDirectory(0); 182 h2.SetDirectory(0); 183 184 if (fDisplay) 185 arr.DisplayIn(*fDisplay, "MHAlpha"); 139 186 140 187 if (!ReadTask(fCut0, "Cut0")) 141 return kFALSE;188 return -1; 142 189 if (!ReadTask(fCut1, "Cut1")) 143 return kFALSE;190 return -1; 144 191 if (!ReadTask(fCut2, "Cut2")) 145 return kFALSE;192 return -1; 146 193 if (!ReadTask(fCut3, "Cut3")) 147 return kFALSE; 148 149 if (!ReadTask(fEstimateEnergy, "EstimateEnergy")) 150 return kFALSE; 151 152 TObjArray arr; 194 return -1; 195 196 TObjArray arrread; 153 197 154 198 TIter Next(plist); … … 156 200 while ((o=Next())) 157 201 if (o->InheritsFrom(MBinning::Class())) 158 arr.Add(o); 159 160 arr.Add(plist.FindObject("MAlphaFitter")); 161 162 return ReadContainer(arr); 163 } 164 165 void MJSpectrum::PrintSetup(const MAlphaFitter &fit) const 166 { 167 gLog.Separator("Alpha Fitter"); 168 *fLog << all; 169 fit.Print(); 170 171 gLog.Separator("Used Cuts"); 172 fCut0->Print(); 173 fCut1->Print(); 174 fCut2->Print(); 175 fCut3->Print(); 176 177 gLog.Separator("Energy Estimator"); 178 fEstimateEnergy->Print(); 179 } 180 181 Float_t MJSpectrum::ReadHistograms(TH1D &h1, TH1D &h2) const 182 { 183 TFile file(fPathIn, "READ"); 184 if (!file.IsOpen()) 185 { 186 *fLog << err << dbginf << "ERROR - Could not open file " << fPathIn << endl; 202 arrread.Add(o); 203 204 arrread.Add(plist.FindObject("MAlphaFitter")); 205 206 if (!ReadContainer(arrread)) 187 207 return -1; 188 }189 190 MStatusArray *arr = (MStatusArray*)file.Get("MStatusDisplay");191 if (!arr)192 {193 gLog << "MStatusDisplay not found in file... abort." << endl;194 return -1;195 }196 197 TH1D *vstime = (TH1D*)arr->FindObjectInCanvas("Theta", "TH1D", "OnTime");198 TH1D *excen = (TH1D*)arr->FindObjectInCanvas("ExcessEnergy", "TH1D", "MHAlpha");199 if (!vstime || !excen)200 return -1;201 202 vstime->Copy(h1);203 excen->Copy(h2);204 h1.SetDirectory(0);205 h2.SetDirectory(0);206 207 if (fDisplay)208 arr->DisplayIn(*fDisplay, "MHAlpha");209 210 delete arr;211 208 212 209 return vstime->Integral(); … … 303 300 void MJSpectrum::DisplayResult(const TH2D &h2) const 304 301 { 305 if (!fDisplay ->CdCanvas("ZdDist"))302 if (!fDisplay || !fDisplay->CdCanvas("ZdDist")) 306 303 return; 307 304 … … 342 339 read.AddFile(fPathIn); 343 340 344 MFillH fill1("MHAlphaOff [MHAlpha]", "MHillasSrc", "FillAlpha"); 345 MFillH fill2("MHAlpha", "MHillasSrc", "FillAlpha"); 341 MEnergyEstimate est; 342 MTaskEnv taskenv1("EstimateEnergy"); 343 taskenv1.SetDefault(fEstimateEnergy ? fEstimateEnergy : &est); 344 345 MFillH fill1("MHAlphaOff [MHAlpha]", "MHillasSrc", "FillAlphaOff"); 346 MFillH fill2("MHAlpha", "MHillasSrc", "FillAlphaOn"); 346 347 347 348 MFDataMember f0("DataType.fVal", '<', 0.5, "FilterOffData"); … … 352 353 353 354 tlist.AddToList(&read); 354 tlist.AddToList( fEstimateEnergy);355 tlist.AddToList(&taskenv1); 355 356 tlist.AddToList(&f0); 356 357 tlist.AddToList(&f1); … … 389 390 halpha->GetHEnergy().Copy(h2); 390 391 h2.SetDirectory(0); 392 393 return kTRUE; 394 } 395 396 Bool_t MJSpectrum::IntermediateLoop(MParList &plist, MH3 &mh1, TH1D &temp1, const MDataSet &set) const 397 { 398 MTaskList tlist1; 399 plist.Replace(&tlist1); 400 401 MReadMarsFile readmc("OriginalMC"); 402 //readmc.DisableAutoScheme(); 403 set.AddFilesOn(readmc); 404 readmc.EnableBranch("MMcEvtBasic.fTelescopeTheta"); 405 readmc.EnableBranch("MMcEvtBasic.fEnergy"); 406 407 mh1.SetLogy(); 408 mh1.SetLogz(); 409 mh1.SetName("ThetaE"); 410 411 MFillH fill0(&mh1); 412 //fill0.SetDrawOption("projx only"); 413 414 MBinning *bins2 = (MBinning*)plist.FindObject("BinningEnergyEst"); 415 MBinning *bins3 = (MBinning*)plist.FindObject("BinningTheta"); 416 if (bins2 && bins3) 417 { 418 bins2->SetName("BinningThetaEY"); 419 bins3->SetName("BinningThetaEX"); 420 } 421 tlist1.AddToList(&readmc); 422 423 temp1.SetXTitle("MMcEvtBasic.fTelescopeTheta*kRad2Deg"); 424 MH3 mh3mc(temp1); 425 426 MFEventSelector2 sel1(mh3mc); 427 sel1.SetHistIsProbability(); 428 429 fill0.SetFilter(&sel1); 430 431 if (!fRawMc) 432 tlist1.AddToList(&sel1); 433 tlist1.AddToList(&fill0); 434 435 MEvtLoop loop1(fName); 436 loop1.SetParList(&plist); 437 loop1.SetLogStream(fLog); 438 loop1.SetDisplay(fDisplay); 439 440 if (!SetupEnv(loop1)) 441 return kFALSE; 442 443 if (!loop1.Eventloop(fMaxEvents)) 444 { 445 *fLog << err << GetDescriptor() << ": Processing of MC-data failed." << endl; 446 return kFALSE; 447 } 448 449 tlist1.PrintStatistics(); 450 451 if (!loop1.GetDisplay()) 452 { 453 *fLog << err << GetDescriptor() << ": Execution stopped by user." << endl; 454 return kFALSE; 455 } 456 457 if (bins2 && bins3) 458 { 459 bins2->SetName("BinningEnergyEst"); 460 bins3->SetName("BinningTheta"); 461 } 462 return kTRUE; 463 } 464 465 void MJSpectrum::DisplaySpectrum(MHCollectionArea &area, TH1D &excess, MHEnergyEst &hest, Double_t ontime) const 466 { 467 TH1D collarea(area.GetHEnergy()); 468 TH1D spectrum(excess); 469 TH1D weights; 470 hest.GetWeights(weights); 471 472 cout << "Effective On time: " << ontime << "s" << endl; 473 474 spectrum.SetDirectory(NULL); 475 spectrum.SetBit(kCanDelete); 476 spectrum.Scale(1./ontime); 477 spectrum.Divide(&collarea); 478 spectrum.SetNameTitle("Preliminary", "N/sm^{2} versus Energy (before unfolding)"); 479 spectrum.SetYTitle("N/sm^{2}"); 480 481 TCanvas &c1 = fDisplay->AddTab("Spectrum"); 482 c1.Divide(2,2); 483 c1.cd(1); 484 gPad->SetBorderMode(0); 485 gPad->SetLogx(); 486 gPad->SetLogy(); 487 gPad->SetGridx(); 488 gPad->SetGridy(); 489 collarea.DrawCopy(); 490 491 c1.cd(2); 492 gPad->SetBorderMode(0); 493 gPad->SetLogx(); 494 gPad->SetLogy(); 495 gPad->SetGridx(); 496 gPad->SetGridy(); 497 spectrum.DrawCopy(); 498 499 c1.cd(3); 500 gPad->SetBorderMode(0); 501 gPad->SetLogx(); 502 gPad->SetLogy(); 503 gPad->SetGridx(); 504 gPad->SetGridy(); 505 weights.DrawCopy(); 506 507 //spectrum.Divide(&weights); 508 spectrum.Multiply(&weights); 509 spectrum.SetNameTitle("Flux", "N/TeVsm^{2} versus Energy (after unfolding)"); 510 511 for (int i=0; i<excess.GetNbinsX(); i++) 512 { 513 spectrum.SetBinContent(i+1, spectrum.GetBinContent(i+1)/spectrum.GetBinWidth(i+1)*1000); 514 spectrum.SetBinError(i+1, spectrum.GetBinError(i+1)/ spectrum.GetBinWidth(i+1)*1000); 515 } 516 517 c1.cd(4); 518 gPad->SetBorderMode(0); 519 gPad->SetLogx(); 520 gPad->SetLogy(); 521 gPad->SetGridx(); 522 gPad->SetGridy(); 523 spectrum.SetXTitle("E [GeV]"); 524 spectrum.SetYTitle("N/TeVsm^{2}"); 525 spectrum.DrawCopy(); 526 527 TF1 f("f", "[1]*(x/1e3)^[0]", 50, 3e4); 528 f.SetParameter(0, -2.87); 529 f.SetParameter(1, 1.9e-6); 530 f.SetLineColor(kGreen); 531 spectrum.Fit(&f, "NI", "", 55, 2e4); 532 f.DrawCopy("same"); 533 534 /* 535 TString str; 536 str += "(1.68#pm0.15)10^{-7}"; 537 str += "(\\frac{E}{TeV})^{-2.59#pm0.06}"; 538 str += "\\frac{ph}{TeVm^{2}s}"; 539 540 TLatex tex; 541 tex.DrawLatex(2e2, 7e-5, str); 542 */ 543 } 544 545 Bool_t MJSpectrum::PlotSame(MStatusArray &arr, MParList &plist, const char *name, const char *tab, const char *plot) const 546 { 547 cout << name << endl; 548 TString same(name); 549 same += "Same"; 550 551 TH1 *h1 = (TH1*)arr.FindObjectInCanvas(name, "TH1F", tab); 552 TH1 *h2 = (TH1*)arr.FindObjectInCanvas(same, "TH1F", tab); 553 if (!h1 || !h2) 554 return kFALSE; 555 556 TObject *obj = plist.FindObject(plot); 557 if (!obj) 558 { 559 *fLog << warn << plot << " not in parameter list... skipping." << endl; 560 return kFALSE; 561 } 562 563 TH1 *h3 = (TH1*)obj->FindObject(name); 564 if (!h3) 565 { 566 *fLog << warn << name << " not found in " << plot << "... skipping." << endl; 567 return kFALSE; 568 } 569 570 571 const MAlphaFitter *fit = (MAlphaFitter*)plist.FindObject("MAlphaFitter"); 572 const Double_t scale = fit ? fit->GetScaleFactor() : 1; 573 574 gPad->SetBorderMode(0); 575 h2->SetLineColor(kBlack); 576 h3->SetLineColor(kBlue); 577 h2->Add(h1, -scale); 578 579 h2->Scale(1./h2->Integral()); 580 h3->Scale(1./h3->Integral()); 581 582 h2->SetMaximum(1.05*TMath::Max(h2->GetMaximum(), h3->GetMaximum())); 583 584 h2 = h2->DrawCopy(); 585 h3 = h3->DrawCopy("same"); 586 587 // Don't do this on the original object! 588 h2->SetStats(kFALSE); 589 h3->SetStats(kFALSE); 590 591 return kTRUE; 592 } 593 594 Bool_t MJSpectrum::DisplaySize(MParList &plist) const 595 { 596 *fLog << inf << "Reading from file: " << fPathIn << endl; 597 598 cout << "Opening..." << endl; 599 TFile file(fPathIn, "READ"); 600 if (!file.IsOpen()) 601 { 602 *fLog << err << dbginf << "ERROR - Could not open file " << fPathIn << endl; 603 return kFALSE; 604 } 605 606 cout << "Reading..." << endl; 607 file.cd(); 608 MStatusArray arr; 609 if (arr.Read()<=0) 610 { 611 *fLog << "MStatusDisplay not found in file... abort." << endl; 612 return kFALSE; 613 } 614 615 cout << "Searching..." << endl; 616 617 TH1D *excess = (TH1D*)arr.FindObjectInCanvas("Excess", "TH1D", "MHAlpha"); 618 if (!excess) 619 return kFALSE; 620 621 cout << "Displaying..." << endl; 622 623 // ------------------- Plot excess versus size ------------------- 624 625 TCanvas &c = fDisplay->AddTab("Excess"); 626 c.Divide(3,2); 627 c.cd(1); 628 gPad->SetBorderMode(0); 629 gPad->SetLogx(); 630 gPad->SetLogy(); 631 gPad->SetGridx(); 632 gPad->SetGridy(); 633 634 excess->SetTitle("Number of excess events vs Size (data, mc/blue)"); 635 excess->SetStats(kFALSE); 636 excess->Scale(1./excess->Integral()); 637 excess->DrawCopy(); 638 639 TObject *o=0; 640 if ((o=plist.FindObject("ExcessSize"))) 641 { 642 TH1F *histsel = (TH1F*)o->FindObject(""); 643 histsel->SetStats(kFALSE); 644 histsel->Scale(1./histsel->Integral()); 645 histsel->SetLineColor(kBlue); 646 histsel->SetBit(kCanDelete); 647 histsel->DrawCopy("same"); 648 } 649 650 // -------------- Comparison of Image Parameters -------------- 651 c.cd(2); 652 PlotSame(arr, plist, "Dist", "HilSrc", "MHHilSrcMCPost"); 653 654 c.cd(3); 655 PlotSame(arr, plist, "Length", "PostCut", "MHHillasMCPost"); 656 657 c.cd(4); 658 PlotSame(arr, plist, "M3l", "HilExt", "MHHilExtMCPost"); 659 660 c.cd(5); 661 PlotSame(arr, plist, "Conc1", "NewPar", "MHNewParMCPost"); 662 663 c.cd(6); 664 PlotSame(arr, plist, "Width", "PostCut", "MHHillasMCPost"); 391 665 392 666 return kTRUE; … … 432 706 plist.AddToList(&fit); 433 707 434 if (!ReadInput(plist)) 435 return kFALSE; 708 TH1D temp1, size; 709 const Float_t ontime = ReadInput(plist, temp1, size); 710 if (ontime<0) 711 { 712 *fLog << err << GetDescriptor() << ": Could not determin effective on time..." << endl; 713 return kFALSE; 714 } 436 715 437 716 PrintSetup(fit); 438 439 TH1D temp1, excess; 440 const Float_t ontime = ReadHistograms(temp1, excess); 441 if (ontime<0) 442 { 443 *fLog << err << GetDescriptor() << ": Could not determin effective on time..." << endl; 444 return kFALSE; 445 } 717 bins3.SetEdges(temp1, 'x'); 446 718 447 719 TH1D temp2(temp1); … … 452 724 return kFALSE; 453 725 454 if (fRefill && !Refill(plist, temp2)) 726 TH1D excess; 727 if (!Refill(plist, excess)) 455 728 return kFALSE; 456 729 … … 460 733 { 461 734 hist.UseCurrentStyle(); 462 MH::SetBinning(&hist, temp1.GetXaxis(), excess.GetXaxis());735 MH::SetBinning(&hist, &bins3/*temp1.GetXaxis()*/, &bins2/*excess.GetXaxis()*/); 463 736 if (!ReadOrigMCDistribution(set, hist)) 464 737 return kFALSE; 465 738 466 for (int y=0; y<hist.GetNbinsY(); y++) 467 for (int x=0; x<hist.GetNbinsX(); x++) 468 hist.SetBinContent(x, y, hist.GetBinContent(x, y)*temp1.GetBinContent(x)); 739 if (!fRawMc) 740 { 741 for (int y=0; y<hist.GetNbinsY(); y++) 742 for (int x=0; x<hist.GetNbinsX(); x++) 743 hist.SetBinContent(x, y, hist.GetBinContent(x, y)*temp1.GetBinContent(x)); 744 } 469 745 } 470 746 else 471 { 472 MTaskList tlist1; 473 plist.Replace(&tlist1); 474 475 MReadMarsFile readmc("OriginalMC"); 476 //readmc.DisableAutoScheme(); 477 set.AddFilesOn(readmc); 478 readmc.EnableBranch("MMcEvtBasic.fTelescopeTheta"); 479 readmc.EnableBranch("MMcEvtBasic.fEnergy"); 480 481 mh1.SetLogy(); 482 mh1.SetLogz(); 483 mh1.SetName("ThetaE"); 484 485 MFillH fill0(&mh1); 486 //fill0.SetDrawOption("projx only"); 487 488 MBinning binsx(bins3, "BinningThetaEX"); 489 MBinning binsy(bins2, "BinningThetaEY"); 490 plist.AddToList(&binsx); 491 plist.AddToList(&binsy); 492 tlist1.AddToList(&readmc); 493 494 temp1.SetXTitle("MMcEvtBasic.fTelescopeTheta*kRad2Deg"); 495 MH3 mh3mc(temp1); 496 497 MFEventSelector2 sel1(mh3mc); 498 sel1.SetHistIsProbability(); 499 500 fill0.SetFilter(&sel1); 501 502 tlist1.AddToList(&sel1); 503 tlist1.AddToList(&fill0); 504 505 MEvtLoop loop1(fName); 506 loop1.SetParList(&plist); 507 loop1.SetLogStream(fLog); 508 loop1.SetDisplay(fDisplay); 509 510 if (!SetupEnv(loop1)) 747 if (!IntermediateLoop(plist, mh1, temp1, set)) 511 748 return kFALSE; 512 513 if (!loop1.Eventloop(fMaxEvents))514 {515 *fLog << err << GetDescriptor() << ": Processing of MC-data failed." << endl;516 return kFALSE;517 }518 519 tlist1.PrintStatistics();520 521 if (!loop1.GetDisplay())522 {523 *fLog << err << GetDescriptor() << ": Execution stopped by user." << endl;524 return kFALSE;525 }526 }527 749 528 750 DisplayResult(fSimpleMode ? hist : (TH2D&)mh1.GetHist()); … … 572 794 MFillH fill4(&hest, "", "FillEnergyEst"); 573 795 796 MH3 hsize("MHillas.fSize"); 797 //MH3 henergy("MEnergyEst.fVal"); 798 hsize.SetName("ExcessSize"); 799 //henergy.SetName("EnergyEst"); 800 MBinning bins(size, "BinningExcessSize"); 801 plist.AddToList(&hsize); 802 //plist.AddToList(&henergy); 803 plist.AddToList(&bins); 804 574 805 MFillH fill1a("MHHillasMCPre [MHHillas]", "MHillas", "FillHillasPre"); 575 806 MFillH fill2a("MHHillasMCPost [MHHillas]", "MHillas", "FillHillasPost"); … … 579 810 MFillH fill6a("MHImgParMCPost [MHImagePar]", "MImagePar", "FillImgParPost"); 580 811 MFillH fill7a("MHNewParMCPost [MHNewImagePar]", "MNewImagePar", "FillNewParPost"); 812 MFillH fill8a("ExcessSize [MH3]", "", "FillExcessSize"); 813 //MFillH fill9a("EnergyEst [MH3]", "", "FillExcessEEst"); 581 814 fill1a.SetNameTab("PreCut"); 582 815 fill2a.SetNameTab("PostCut"); … … 586 819 fill6a.SetNameTab("ImgPar"); 587 820 fill7a.SetNameTab("NewPar"); 821 fill8a.SetBit(MFillH::kDoNotDisplay); 822 //fill9a.SetBit(MFillH::kDoNotDisplay); 823 824 MEnergyEstimate est; 825 MTaskEnv taskenv1("EstimateEnergy"); 826 taskenv1.SetDefault(fEstimateEnergy ? fEstimateEnergy : &est); 588 827 589 828 tlist2.AddToList(&read); 590 tlist2.AddToList(&contsel); 829 if (!fRawMc) 830 tlist2.AddToList(&contsel); 591 831 tlist2.AddToList(&calc); 592 832 tlist2.AddToList(&hcalc1); … … 597 837 tlist2.AddToList(fCut2); 598 838 tlist2.AddToList(fCut3); 599 tlist2.AddToList( fEstimateEnergy);839 tlist2.AddToList(&taskenv1); 600 840 tlist2.AddToList(&fill3); 601 841 tlist2.AddToList(&fill4); … … 606 846 tlist2.AddToList(&fill6a); 607 847 tlist2.AddToList(&fill7a); 848 tlist2.AddToList(&fill8a); 849 //tlist2.AddToList(&fill9a); 608 850 609 851 MEvtLoop loop2(fName); … … 631 873 // -------------------------- Spectrum ---------------------------- 632 874 633 TH1D collarea(area.GetHEnergy()); 634 TH1D weights; 635 hest.GetWeights(weights); 636 637 cout << "Effective On time: " << ontime << "s" << endl; 638 639 excess.SetDirectory(NULL); 640 excess.SetBit(kCanDelete); 641 excess.Scale(1./ontime); 642 excess.Divide(&collarea); 643 excess.SetNameTitle("Preliminary", "N/sm^{2} versus Energy (before unfolding)"); 644 excess.SetYTitle("N/sm^{2}"); 645 646 TCanvas &c = fDisplay->AddTab("Spectrum"); 647 c.Divide(2,2); 648 c.cd(1); 649 gPad->SetBorderMode(0); 650 gPad->SetLogx(); 651 gPad->SetLogy(); 652 gPad->SetGridx(); 653 gPad->SetGridy(); 654 collarea.DrawCopy(); 655 656 c.cd(2); 657 gPad->SetBorderMode(0); 658 gPad->SetLogx(); 659 gPad->SetLogy(); 660 gPad->SetGridx(); 661 gPad->SetGridy(); 662 excess.DrawCopy(); 663 664 c.cd(3); 665 gPad->SetBorderMode(0); 666 gPad->SetLogx(); 667 gPad->SetLogy(); 668 gPad->SetGridx(); 669 gPad->SetGridy(); 670 weights.DrawCopy(); 671 672 excess.Divide(&weights); 673 //excess.Multiply(&weights); 674 excess.SetNameTitle("Flux", "N/TeVsm^{2} versus Energy (after unfolding)"); 675 676 for (int i=0; i<excess.GetNbinsX(); i++) 677 { 678 excess.SetBinContent(i+1, excess.GetBinContent(i+1)/excess.GetBinWidth(i+1)*1000); 679 excess.SetBinError(i+1, excess.GetBinError(i+1)/ excess.GetBinWidth(i+1)*1000); 680 } 681 682 excess.SetYTitle("N/TeVsm^{2}"); 683 684 c.cd(4); 685 gPad->SetBorderMode(0); 686 gPad->SetLogx(); 687 gPad->SetLogy(); 688 gPad->SetGridx(); 689 gPad->SetGridy(); 690 excess.DrawCopy(); 691 692 TF1 f("f", "[1]*(x/1e3)^[0]", 50, 3e4); 693 f.SetParameter(0, -2.87); 694 f.SetParameter(1, 1.9e-6); 695 f.SetLineColor(kGreen); 696 excess.Fit(&f, "NI", "", 55, 2e4); 697 f.DrawCopy("same"); 875 DisplaySpectrum(area, excess, hest, ontime); 876 DisplaySize(plist); 698 877 699 878 if (!fPathOut.IsNull()) 700 879 fDisplay->SaveAsRoot(fPathOut); 701 880 702 /*703 TString str;704 str += "(1.68#pm0.15)10^{-7}";705 str += "(\\frac{E}{TeV})^{-2.59#pm0.06}";706 str += "\\frac{ph}{TeVm^{2}s}";707 708 TLatex tex;709 tex.DrawLatex(2e2, 7e-5, str);710 */711 712 881 return kTRUE; 713 882 } -
trunk/MagicSoft/Mars/mjobs/MJSpectrum.h
r6966 r6978 14 14 class MParList; 15 15 class MDataSet; 16 class MHEnergyEst; 16 17 class MAlphaFitter; 18 class MStatusArray; 19 class MHCollectionArea; 17 20 18 21 class MJSpectrum : public MJob … … 27 30 Bool_t fRefill; 28 31 Bool_t fSimpleMode; 32 Bool_t fRawMc; 29 33 34 // Read Input 30 35 Bool_t ReadTask(MTask* &task, const char *name) const; 31 Bool_t ReadInput(const MParList &plist); 32 void PrintSetup(const MAlphaFitter &fit) const; 33 Float_t ReadHistograms(TH1D &h1, TH1D &h2) const; 36 Float_t ReadInput(MParList &plist, TH1D &h1, TH1D &size); 34 37 Bool_t ReadOrigMCDistribution(const MDataSet &set, TH1 &h) const; 35 38 Bool_t GetThetaDistribution(TH1D &temp1, TH1D &temp2) const; 39 Bool_t Refill(MParList &plist, TH1D &h) const; 40 41 // Display Output 42 void PrintSetup(const MAlphaFitter &fit) const; 36 43 void DisplayResult(const TH2D &mh1) const; 37 Bool_t Refill(MParList &plist, TH1D &h) const; 44 Bool_t IntermediateLoop(MParList &plist, MH3 &h1, TH1D &temp1, const MDataSet &set) const; 45 void DisplaySpectrum(MHCollectionArea &area, TH1D &excess, MHEnergyEst &hest, Double_t ontime) const; 46 Bool_t DisplaySize(MParList &plist) const; 47 Bool_t PlotSame(MStatusArray &arr, MParList &plist, const char *name, const char *tab, const char *plot) const; 38 48 39 49 public: … … 45 55 void EnableRefilling(Bool_t b=kTRUE) { fRefill=b; } 46 56 void EnableSimpleMode(Bool_t b=kTRUE) { fSimpleMode=b; } 57 void EnableRawMc(Bool_t b=kTRUE) { fRawMc=b; } 58 59 void SetEnergyEstimator(const MTask *task); 47 60 48 61 ClassDef(MJSpectrum, 0) // Proh'gram to calculate spectrum
Note:
See TracChangeset
for help on using the changeset viewer.