Changeset 7094 for trunk/MagicSoft/Mars
- Timestamp:
- 05/27/05 09:46:22 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 added
- 6 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r7091 r7094 29 29 - implement usage of extractor resolution (only if UseExtractorRes 30 30 is set). 31 32 33 2005/05/27 Thomas Bretz 34 35 * Makefile: 36 - removed mmontecarlo directory 37 38 * mmontecarlo/MMcEnergyEst.[h,cc], 39 mmontecarlo/MMcTimeGenerate.[h,cc], 40 mmontecarlo/MMcWeightEnergySpecCalc.[h,cc]: 41 - removed 42 43 * sponde.rc: 44 - added new line for weighted spectral index 45 46 * mbadpixels/MBadPixelsCalc.[h,cc]: 47 - added an option to perform the checks also in PostProcess 48 49 * mhbase/MFillH.h: 50 - added default argument to SetWeight 51 52 * mhbase/MH3.h: 53 - added Sumw2() member function 54 55 * mhflux/MHCollectionArea.[h,cc]: 56 - added TLatex output to plots 57 - added some Getter 58 59 * mjobs/MJSpectrum.[h,cc]: 60 - implemented the possibility to weight the monte carlo spectrum 61 to a new index or function. More details can be found 62 in MMcSpectrumWeight 63 - slightly changed the plot comparing the size distributions 64 - scale the comparsison plots by the resulting spectrum 65 66 * mjobs/MJob.[h,cc]: 67 - added a member function to check ReadEnv of a single 68 container 69 70 * mjobs/Makefile: 71 - added -I../mmc 72 73 * mmc/MMcEvt.[hxx,cxx], mmc/McEvtBasic.[hxx,cxx]: 74 - changed the inheritance: MMcEvt now derives from MMcEvtBasic 75 so that both classes are interchangable 76 - increased both class versions 77 - chaged the default partictle in MMcEvtBasic from 78 kGAMMA to kUNDEFINED 79 - added new particle type: kUNDEFINED 80 81 * mhflux/MMcSpectrumWeight.[h,cc]: 82 - added 31 83 32 84 -
trunk/MagicSoft/Mars/Makefile
r6979 r7094 56 56 msql \ 57 57 mimage \ 58 mmontecarlo \59 58 mhft \ 60 59 mmc \ -
trunk/MagicSoft/Mars/NEWS
r7082 r7094 2 2 3 3 *** Version <cvs> 4 5 - general: MMcEvt now derived from MMcEvtBasic which should 6 have no influence on compatibility with older camera files 7 8 - sponde: The input MC spectrum can now be weighted to fake a 9 different spectrum. This is done via MMcSpectrumWeight. For 10 more details see the class description and sponde.rc 11 12 - sponde: The paremetr comparsion plots are not scaled by 13 their entries anymore. Instead the MC plot is scaled by using 14 the result spectrum of the analysis. If the input MC spectrum 15 and the result spectrum has different slopes the absolut 16 normalization is normally wrong. 4 17 5 18 -
trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCalc.cc
r7035 r7094 86 86 // 87 87 MBadPixelsCalc::MBadPixelsCalc(const char *name, const char *title) 88 : fPedestalLevel(3), fPedestalLevelVariance(5), fNamePedPhotCam("MPedPhotCam") 88 : fPedestalLevel(3), fPedestalLevelVariance(5), fNamePedPhotCam("MPedPhotCam"), 89 fCheckInProcess(kTRUE), fCheckInPostProcess(kFALSE) 89 90 { 90 91 fName = name ? name : gsDefName.Data(); … … 129 130 // -------------------------------------------------------------------------- 130 131 // 131 // Check the pedestal RMS of every pixel with respect to the mean pedestal RMS132 // of the camera (Sigmabar).133 //134 // The pixels can be set as blind if the pedestalRMS is too big or 0.135 //136 // If you don't want to use this option set the PedestalLevel<=0;137 //138 // MBadPixelsCalc calc;139 // calc.SetPedestalLevel(-1);140 /*141 void MBadPixelsCalc::CheckPedestalRMS() const142 {143 const Int_t entries = fPedPhotCam->GetSize();144 145 const Float_t meanPedRMS = fSigmabar->GetSigmabar();146 147 for (Int_t i=0; i<entries; i++)148 {149 //150 // get pixel as entry from list151 //152 const Double_t nratio = fGeomCam->GetPixRatio(i);153 const Double_t pixPedRms = (*fPedPhotCam)[i].GetRms();154 155 if (pixPedRms*nratio > fPedestalLevel * meanPedRMS || pixPedRms == 0)156 (*fBadPixels)[i].SetUnsuitable(MBadPixelsPix::kUnsuitableEvt);157 }158 }159 */160 161 // --------------------------------------------------------------------------162 //163 132 // Check the pedestal Rms of the pixels: compute with 2 iterations the mean 164 133 // for inner and outer pixels. Set as blind the pixels with too small or 165 134 // too high pedestal Rms with respect to the mean. 166 135 // 167 Bool_t MBadPixelsCalc::CheckPedestalRms() const 168 { 136 Bool_t MBadPixelsCalc::CheckPedestalRms(MBadPixelsPix::UnsuitableType_t type) const 137 { 138 if (fPedestalLevel<=0 && fPedestalLevelVariance<=0) 139 return kTRUE; 140 169 141 const Int_t entries = fPedPhotCam->GetSize(); 170 142 … … 266 238 continue; 267 239 268 (*fBadPixels)[i].SetUnsuitable(MBadPixelsPix::kUnsuitableEvt); 240 (*fBadPixels)[i].SetUnsuitable(type); 241 if (type==MBadPixelsPix::kUnsuitableRun) 242 (*fBadPixels)[i].SetUncalibrated(MBadPixelsPix::kDeadPedestalRms); 243 269 244 bads++; 270 245 } … … 281 256 } 282 257 283 284 258 // -------------------------------------------------------------------------- 285 259 // … … 287 261 Int_t MBadPixelsCalc::Process() 288 262 { 289 if (fPedestalLevel>0 || fPedestalLevelVariance>0) 290 CheckPedestalRms(); 291 292 return kTRUE; 263 return fCheckInProcess ? CheckPedestalRms(MBadPixelsPix::kUnsuitableEvt) : kTRUE; 264 } 265 266 // -------------------------------------------------------------------------- 267 // 268 // 269 Int_t MBadPixelsCalc::PostProcess() 270 { 271 return fCheckInPostProcess ? CheckPedestalRms(MBadPixelsPix::kUnsuitableRun) : kTRUE; 293 272 } 294 273 -
trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCalc.h
r5777 r7094 4 4 #ifndef MARS_MTask 5 5 #include "MTask.h" 6 #endif 7 #ifndef MARS_MBadPixelsPix 8 #include "MBadPixelsPix.h" 6 9 #endif 7 10 … … 21 24 22 25 TString fNamePedPhotCam; // name of the 'MPedPhotCam' container 23 24 // void CheckPedestalRMS() const;25 Bool_t CheckPedestalRms() const;26 26 27 Bool_t fCheckInProcess; 28 Bool_t fCheckInPostProcess; 29 30 // MBadPixelsCalc 31 Bool_t CheckPedestalRms(MBadPixelsPix::UnsuitableType_t t) const; 32 33 // MTask 27 34 Int_t PreProcess(MParList *pList); 28 35 Int_t Process(); 36 Int_t PostProcess(); 37 38 // MParContainer 29 39 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print); 30 40 … … 32 42 MBadPixelsCalc(const char *name=NULL, const char *title=NULL); 33 43 44 // Setter 34 45 void SetPedestalLevel(Float_t f) { fPedestalLevel=f; } 35 46 void SetPedestalLevelVariance(Float_t f) { fPedestalLevelVariance=f; } 36 47 void SetNamePedPhotCam(const char *name) { fNamePedPhotCam = name; } 48 49 void EnableCheckInProcess(Bool_t b=kTRUE) { fCheckInProcess = b; } 50 void EnableCheckInPostProcess(Bool_t b=kTRUE) { fCheckInPostProcess = b; } 37 51 38 52 ClassDef(MBadPixelsCalc, 1) // Task to find bad pixels (star, broken pixels, etc) -
trunk/MagicSoft/Mars/mhbase/MFillH.h
r6915 r7094 63 63 64 64 void SetWeight(MParameterD *w) { fWeight = w; } 65 void SetWeight(const char *name ) { fWeightName = name; }65 void SetWeight(const char *name="MWeight") { fWeightName = name; } 66 66 67 67 void SetDrawOption(Option_t *option=""); -
trunk/MagicSoft/Mars/mhbase/MH3.h
r6978 r7094 26 26 Double_t fScale[3]; // Scale for the three axis (eg unit) 27 27 28 // TString fNameProfX; //! This should make sure, that gROOT doen't confuse the profile with something else29 // TString fNameProfY; //! This should make sure, that gROOT doen't confuse the profile with something else30 31 28 void StreamPrimitive(ofstream &out) const; 32 29 … … 36 33 kIsLogz = BIT(19) 37 34 }; 38 39 // Int_t DistancetoPrimitive(Int_t px, Int_t py);40 // void ExecuteEvent(Int_t event, Int_t px, Int_t py);41 35 42 36 public: … … 48 42 ~MH3(); 49 43 44 // Setter 50 45 void SetScaleX(Double_t scale) { fScale[0] = scale; } 51 46 void SetScaleY(Double_t scale) { fScale[1] = scale; } … … 56 51 void SetLogz(Bool_t b=kTRUE) { b ? fHist->SetBit(kIsLogz) : fHist->ResetBit(kIsLogz); } 57 52 53 void Sumw2() const { if (fHist) fHist->Sumw2(); } 54 55 // Getter 58 56 Int_t GetDimension() const { return fDimension; } 59 57 Int_t GetNbins() const; 60 58 Int_t FindFixBin(Double_t x, Double_t y=0, Double_t z=0) const; 61 59 62 void SetName(const char *name); 63 void SetTitle(const char *title); 64 65 Bool_t SetupFill(const MParList *pList); 66 Bool_t Fill(const MParContainer *par, const Stat_t w=1); 60 TH1 &GetHist() { return *fHist; } 61 const TH1 &GetHist() const { return *fHist; } 67 62 68 63 TString GetDataMember() const; 69 64 TString GetRule(const Char_t axis='x') const; 70 65 71 TH1 &GetHist() { return *fHist; } 72 const TH1 &GetHist() const { return *fHist; } 66 // MH 67 Bool_t SetupFill(const MParList *pList); 68 Bool_t Fill(const MParContainer *par, const Stat_t w=1); 73 69 74 70 TH1 *GetHistByName(const TString name="") const { return fHist; } … … 79 75 } 80 76 77 // MParContainer 78 MParContainer *New() const; 79 80 // TObject 81 void SetName(const char *name); 82 void SetTitle(const char *title); 83 81 84 void SetColors() const; 82 85 void Draw(Option_t *opt=NULL); 83 86 void Paint(Option_t *opt=""); 84 85 MParContainer *New() const;86 87 87 88 ClassDef(MH3, 1) // Generalized 1/2/3D-histogram for Mars variables -
trunk/MagicSoft/Mars/mhflux/MHCollectionArea.cc
r6976 r7094 31 31 #include "MHCollectionArea.h" 32 32 33 #include <TLatex.h> 33 34 #include <TCanvas.h> 34 35 #include <TPaveStats.h> … … 81 82 fHistAll.SetTitle("Number of events produced"); 82 83 fHistAll.SetXTitle("\\Theta [deg]"); 83 fHistAll.SetYTitle("E [GeV]");84 fHistAll.SetYTitle("E_{mc} [GeV]"); 84 85 fHistAll.SetDirectory(NULL); 85 86 fHistAll.UseCurrentStyle(); 86 87 87 88 fHEnergy.SetName("CollEnergy"); 88 fHEnergy.SetTitle("Collection Area vs Energy");89 fHEnergy.SetTitle("Collection Area"); 89 90 fHEnergy.SetXTitle("E [GeV]"); 90 fHEnergy.SetYTitle("A [m^{2}]");91 fHEnergy.SetYTitle("A_{eff} [m^{2}]"); 91 92 fHEnergy.SetDirectory(NULL); 92 93 fHEnergy.UseCurrentStyle(); … … 119 120 // read from run header, but it is not yet in!! 120 121 // 121 const Float_t r1 = 0; 122 const Float_t r2 = fMcAreaRadius; 123 124 //*fLog << warn << endl << dbginf << "WARNING! I will assume a maximum impact parameter of " << fMCAreaRadius << " meters for the MC events. Check that this is the true one!" <<endl<<endl; 125 const Float_t total_area = TMath::Pi() * (r2*r2 - r1*r1); 122 const Float_t totalarea = GetCollectionAreaAbs();//TMath::Pi() * (r2*r2 - r1*r1); 126 123 127 124 for (Int_t ix=1; ix<=nbinx; ix++) … … 141 138 continue; 142 139 143 const Double_t eff = Ns/Na; 144 145 const Double_t efferr = TMath::Sqrt((1.-eff)*Ns)/Na; 140 const Double_t eff = Ns/Na; 141 const Double_t efferr = TMath::Sqrt((1.-eff)*Ns)/Na; 146 142 147 const Float_t col _area = eff * total_area;148 const Float_t col _area_error = efferr * total_area;149 150 fHEnergy.SetBinContent(ix, col _area);151 fHEnergy.SetBinError(ix, col_area_error);143 const Float_t colarea = eff * totalarea; 144 const Float_t colareaerror = efferr * totalarea; 145 146 fHEnergy.SetBinContent(ix, colarea); 147 fHEnergy.SetBinError(ix, colareaerror); 152 148 } 153 149 … … 275 271 void MHCollectionArea::Paint(Option_t *option) 276 272 { 273 if (TString(option)=="paint3") 274 { 275 /* 276 TH1 *h = dynamic_cast<TH1*>(gPad->FindObject("Efficiency")); 277 if (h) 278 { 279 const TString txt = Form("N/N_{0}=%.2f", 280 GetCollectionAreaEff(), 281 GetCollectionAreaAbs(), fMcAreaRadius); 282 283 TLatex text(0.31, 0.95, txt); 284 text.SetBit(TLatex::kTextNDC); 285 text.SetTextSize(0.04); 286 text.Paint();*/ 287 return; 288 } 289 if (TString(option)=="paint4") 290 { 291 const TString txt = Form("A_{eff}=%.0fm^{2} A_{abs}=%.0fm^{2} r=%.0fm", 292 GetCollectionAreaEff(), 293 GetCollectionAreaAbs(), fMcAreaRadius); 294 295 TLatex text(0.31, 0.95, txt); 296 text.SetBit(TLatex::kTextNDC); 297 text.SetTextSize(0.04); 298 text.Paint(); 299 return; 300 } 301 277 302 TVirtualPad *pad; 278 303 … … 405 430 h->SetNameTitle("Efficiency", "Combined cut and trigger efficiency"); 406 431 h->SetDirectory(NULL); 432 AppendPad("paint3"); 407 433 } 408 434 else … … 416 442 gPad->SetGridy(); 417 443 fHEnergy.Draw(); 444 AppendPad("paint4"); 418 445 } 419 446 else … … 428 455 //*fLog << energy << " " << theta << endl; 429 456 430 fHistSel.Fill(theta, energy );457 fHistSel.Fill(theta, energy, weight); 431 458 432 459 return kTRUE; -
trunk/MagicSoft/Mars/mhflux/MHCollectionArea.h
r6976 r7094 56 56 const TH1D &GetHEnergy() const { return fHEnergy; } 57 57 58 Double_t GetEntries() const { return fHistAll.Integral(); } 59 Double_t GetCollectionAreaEff() const { return fHEnergy.Integral(); } 60 Double_t GetCollectionAreaAbs() const { return TMath::Pi()*fMcAreaRadius*fMcAreaRadius; } 61 58 62 /* 59 63 void DrawAll(Option_t *option=""); -
trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
r7071 r7094 52 52 #include "MBinning.h" 53 53 #include "MDataSet.h" 54 #include "MMcCorsikaRunHeader.h" 54 55 55 56 // Spectrum … … 58 59 #include "../mhflux/MHCollectionArea.h" 59 60 #include "../mhflux/MHEnergyEst.h" 61 #include "../mhflux/MMcSpectrumWeight.h" 60 62 61 63 // Eventloop … … 155 157 } 156 158 159 // -------------------------------------------------------------------------- 160 // 161 // Read the first MMcCorsikaRunHeader from the RunHeaders tree in 162 // the dataset. 163 // The simulated energy range and spectral slope is initialized from 164 // there. 165 // In the following eventloops the forced check in MMcSpectrumWeight 166 // ensures, that the spectral slope and energy range doesn't change. 167 // 168 Bool_t MJSpectrum::InitWeighting(const MDataSet &set, MMcSpectrumWeight &w) const 169 { 170 fLog->Separator("Initialize energy weighting"); 171 172 MParList l; 173 l.AddToList(&w); 174 if (!CheckEnv(l)) 175 { 176 *fLog << err << "ERROR - Reading resources for MMcSpectrumWeight failed." << endl; 177 return kFALSE; 178 } 179 180 TChain chain("RunHeaders"); 181 set.AddFilesOn(chain); 182 183 MMcCorsikaRunHeader *h=0; 184 chain.SetBranchAddress("MMcCorsikaRunHeader.", &h); 185 chain.GetEntry(1); 186 187 if (!h) 188 { 189 *fLog << err << "ERROR - Couldn't read MMcCorsikaRunHeader from DataSet." << endl; 190 return kFALSE; 191 } 192 193 if (!w.Set(*h)) 194 { 195 *fLog << err << "ERROR - Initializing MMcSpectrumWeight failed." << endl; 196 return kFALSE; 197 } 198 199 w.Print(); 200 return kTRUE; 201 } 202 157 203 Float_t MJSpectrum::ReadInput(MParList &plist, TH1D &h1, TH1D &h2) 158 204 { … … 211 257 } 212 258 213 Bool_t MJSpectrum::ReadOrigMCDistribution(const MDataSet &set, TH1 &h ) const259 Bool_t MJSpectrum::ReadOrigMCDistribution(const MDataSet &set, TH1 &h, MMcSpectrumWeight &weight) const 214 260 { 215 261 // Some debug output 216 262 fLog->Separator("Compiling original MC distribution"); 217 263 218 *fLog << inf << "Please stand by, this may take a while..." << flush; 264 weight.SetNameMcEvt("MMcEvtBasic"); 265 const TString w(weight.GetFormulaWeights()); 266 weight.SetNameMcEvt(); 267 268 *fLog << inf << "Using weights: " << w << endl; 269 *fLog << "Please stand by, this may take a while..." << flush; 219 270 220 271 if (fDisplay) … … 236 287 h.SetYTitle("E [GeV]"); 237 288 h.SetZTitle("Counts"); 238 chain.Draw("MMcEvtBasic.fEnergy:MMcEvtBasic.fTelescopeTheta*TMath::RadToDeg()>>ThetaEMC", "", "goff");289 chain.Draw("MMcEvtBasic.fEnergy:MMcEvtBasic.fTelescopeTheta*TMath::RadToDeg()>>ThetaEMC", w, "goff"); 239 290 } 240 291 else … … 243 294 h.SetXTitle("\\Theta [\\circ]"); 244 295 h.SetYTitle("Counts"); 245 chain.Draw("MMcEvtBasic.fTelescopeTheta*TMath::RadToDeg()>>ThetaMC", "", "goff");296 chain.Draw("MMcEvtBasic.fTelescopeTheta*TMath::RadToDeg()>>ThetaMC", w, "goff"); 246 297 } 247 298 h.SetDirectory(0); … … 413 464 } 414 465 415 Bool_t MJSpectrum::IntermediateLoop(MParList &plist, MH3 &mh1, TH1D &temp1, const MDataSet &set ) const466 Bool_t MJSpectrum::IntermediateLoop(MParList &plist, MH3 &mh1, TH1D &temp1, const MDataSet &set, MMcSpectrumWeight &weight) const 416 467 { 417 468 MTaskList tlist1; … … 439 490 } 440 491 tlist1.AddToList(&readmc); 492 tlist1.AddToList(&weight); 441 493 442 494 temp1.SetXTitle("MMcEvtBasic.fTelescopeTheta*kRad2Deg"); … … 477 529 bins3->SetName("BinningTheta"); 478 530 } 531 479 532 return kTRUE; 480 533 } 481 534 482 voidMJSpectrum::DisplaySpectrum(MHCollectionArea &area, TH1D &excess, MHEnergyEst &hest, Double_t ontime) const535 TArrayD MJSpectrum::DisplaySpectrum(MHCollectionArea &area, TH1D &excess, MHEnergyEst &hest, Double_t ontime) const 483 536 { 484 537 TH1D collarea(area.GetHEnergy()); … … 546 599 f.SetParameter(1, 1.9e-6); 547 600 f.SetLineColor(kGreen); 548 spectrum.Fit(&f, "NI ", "", 55, 2e4);601 spectrum.Fit(&f, "NIM", "", 55, 2e4); 549 602 f.DrawCopy("same"); 550 603 … … 558 611 tex.DrawLatex(2e2, 7e-5, str); 559 612 */ 560 } 561 562 Bool_t MJSpectrum::PlotSame(MStatusArray &arr, MParList &plist, const char *name, const char *tab, const char *plot) const 563 { 564 cout << name << endl; 613 614 TArrayD res(2); 615 res[0] = f.GetParameter(0); 616 res[1] = f.GetParameter(1); 617 return res; 618 } 619 620 Bool_t MJSpectrum::PlotSame(MStatusArray &arr, MParList &plist, const char *name, const char *tab, const char *plot, Double_t scale) const 621 { 565 622 TString same(name); 566 623 same += "Same"; … … 587 644 588 645 const MAlphaFitter *fit = (MAlphaFitter*)plist.FindObject("MAlphaFitter"); 589 const Double_t scale = fit ? fit->GetScaleFactor() : 1;646 const Double_t ascale = fit ? fit->GetScaleFactor() : 1; 590 647 591 648 gPad->SetBorderMode(0); 592 649 h2->SetLineColor(kBlack); 593 650 h3->SetLineColor(kBlue); 594 h2->Add(h1, - scale);595 596 h2->Scale(1./h2->Integral());597 h3->Scale( 1./h3->Integral());651 h2->Add(h1, -ascale); 652 653 //h2->Scale(1./ontime); //h2->Integral()); 654 h3->Scale(scale); //h3->Integral()); 598 655 599 656 h2->SetMaximum(1.05*TMath::Max(h2->GetMaximum(), h3->GetMaximum())); … … 609 666 } 610 667 611 Bool_t MJSpectrum::DisplaySize(MParList &plist ) const668 Bool_t MJSpectrum::DisplaySize(MParList &plist, Double_t scale) const 612 669 { 613 670 *fLog << inf << "Reading from file: " << fPathIn << endl; … … 644 701 645 702 excess->SetTitle("Number of excess events vs Size (data, mc/blue)"); 646 excess->Scale(1./excess->Integral()); 647 excess = excess->DrawCopy(); 703 excess = excess->DrawCopy("E2"); 648 704 // Don't do this on the original object! 649 705 excess->SetStats(kFALSE); 706 excess->SetMarkerStyle(kFullDotMedium); 707 excess->SetFillColor(kBlack); 708 excess->SetFillStyle(0); 709 excess->SetName("Excess "); 710 excess->SetDirectory(0); 650 711 651 712 TObject *o=0; 652 if ((o=plist.FindObject("Excess Size")))713 if ((o=plist.FindObject("ExcessMC"))) 653 714 { 654 715 TH1 *histsel = (TH1F*)o->FindObject(""); 655 716 if (histsel) 656 717 { 657 histsel->Scale(1./histsel->Integral()); 718 if (scale<0) 719 scale = excess->Integral()/histsel->Integral(); 720 721 histsel->Scale(scale); 658 722 histsel->SetLineColor(kBlue); 659 723 histsel->SetBit(kCanDelete); 660 histsel = histsel->DrawCopy(" same");724 histsel = histsel->DrawCopy("E1 same"); 661 725 // Don't do this on the original object! 662 726 histsel->SetStats(kFALSE); 727 728 fLog->Separator("Kolmogorov Test"); 729 histsel->KolmogorovTest(excess, "DX"); 730 fLog->Separator("Chi^2 Test"); 731 histsel->Chi2Test(excess, "P"); 663 732 } 664 733 } … … 666 735 // -------------- Comparison of Image Parameters -------------- 667 736 c.cd(2); 668 PlotSame(arr, plist, "Dist", "HilSrc", "MHHilSrcMCPost" );737 PlotSame(arr, plist, "Dist", "HilSrc", "MHHilSrcMCPost", scale); 669 738 670 739 c.cd(3); 671 PlotSame(arr, plist, "Length", "PostCut", "MHHillasMCPost" );740 PlotSame(arr, plist, "Length", "PostCut", "MHHillasMCPost", scale); 672 741 673 742 c.cd(4); 674 PlotSame(arr, plist, "M3l", "HilExt", "MHHilExtMCPost" );743 PlotSame(arr, plist, "M3l", "HilExt", "MHHilExtMCPost", scale); 675 744 676 745 c.cd(5); 677 PlotSame(arr, plist, "Conc1", "NewPar", "MHNewParMCPost" );746 PlotSame(arr, plist, "Conc1", "NewPar", "MHNewParMCPost", scale); 678 747 679 748 c.cd(6); 680 PlotSame(arr, plist, "Width", "PostCut", "MHHillasMCPost" );749 PlotSame(arr, plist, "Width", "PostCut", "MHHillasMCPost", scale); 681 750 682 751 return kTRUE; … … 734 803 } 735 804 805 MMcSpectrumWeight weight; 806 if (!InitWeighting(set, weight)) 807 return kFALSE; 808 736 809 PrintSetup(fit); 737 810 bins3.SetEdges(temp1, 'x'); 738 811 739 812 TH1D temp2(temp1); 740 if (!ReadOrigMCDistribution(set, temp2 ))813 if (!ReadOrigMCDistribution(set, temp2, weight)) 741 814 return kFALSE; 742 815 … … 754 827 hist.UseCurrentStyle(); 755 828 MH::SetBinning(&hist, &bins3/*temp1.GetXaxis()*/, &bins2/*excess.GetXaxis()*/); 756 if (!ReadOrigMCDistribution(set, hist ))829 if (!ReadOrigMCDistribution(set, hist, weight)) 757 830 return kFALSE; 758 831 … … 762 835 for (int x=0; x<hist.GetNbinsX(); x++) 763 836 hist.SetBinContent(x, y, hist.GetBinContent(x, y)*temp1.GetBinContent(x)); 837 //hist.SetEntries(hist.Integral()); 764 838 } 765 839 } 766 840 else 767 if (!IntermediateLoop(plist, mh1, temp1, set)) 841 { 842 weight.SetNameMcEvt("MMcEvtBasic"); 843 if (!IntermediateLoop(plist, mh1, temp1, set, weight)) 768 844 return kFALSE; 845 weight.SetNameMcEvt(); 846 } 769 847 770 848 DisplayResult(fSimpleMode ? hist : (TH2D&)mh1.GetHist()); … … 813 891 MFillH fill3(&area, "", "FillCollectionArea"); 814 892 MFillH fill4(&hest, "", "FillEnergyEst"); 893 fill3.SetWeight(); 894 fill4.SetWeight(); 815 895 816 896 MH3 hsize("MHillas.fSize"); 817 //MH3 henergy("MEnergyEst.fVal");818 hsize.S etName("ExcessSize");819 //henergy.SetName("EnergyEst"); 820 MBinning bins(size, "BinningExcess Size");897 hsize.SetName("ExcessMC"); 898 hsize.Sumw2(); 899 900 MBinning bins(size, "BinningExcessMC"); 821 901 plist.AddToList(&hsize); 822 //plist.AddToList(&henergy);823 902 plist.AddToList(&bins); 824 903 … … 830 909 MFillH fill6a("MHImgParMCPost [MHImagePar]", "MImagePar", "FillImgParPost"); 831 910 MFillH fill7a("MHNewParMCPost [MHNewImagePar]", "MNewImagePar", "FillNewParPost"); 832 MFillH fill8a("ExcessSize [MH3]", "", "FillExcessSize"); 833 //MFillH fill9a("EnergyEst [MH3]", "", "FillExcessEEst"); 911 MFillH fill8a("ExcessMC [MH3]", "", "FillExcessMC"); 834 912 fill1a.SetNameTab("PreCut"); 835 913 fill2a.SetNameTab("PostCut"); … … 840 918 fill7a.SetNameTab("NewPar"); 841 919 fill8a.SetBit(MFillH::kDoNotDisplay); 842 //fill9a.SetBit(MFillH::kDoNotDisplay); 920 fill1a.SetWeight(); 921 fill2a.SetWeight(); 922 fill3a.SetWeight(); 923 fill4a.SetWeight(); 924 fill5a.SetWeight(); 925 fill6a.SetWeight(); 926 fill7a.SetWeight(); 927 fill8a.SetWeight(); 843 928 844 929 MEnergyEstimate est; … … 852 937 tlist2.AddToList(&hcalc1); 853 938 tlist2.AddToList(&hcalc2); 939 tlist2.AddToList(&weight); 854 940 tlist2.AddToList(&fill1a); 855 941 tlist2.AddToList(fCut0); … … 891 977 // -------------------------- Spectrum ---------------------------- 892 978 893 DisplaySpectrum(area, excess, hest, ontime); 894 DisplaySize(plist); 895 979 // Calculate and display spectrum (N/TeVsm^2 at 1TeV) 980 TArrayD res(DisplaySpectrum(area, excess, hest, ontime)); 981 982 // Spectrum fitted (convert res[1] from TeV to GeV) 983 TF1 flx("flx", Form("%e*pow(x/1000, %f)", res[1]/1000, res[0])); 984 985 // Number of events this spectrum would produce per s and m^2 986 Double_t n = flx.Integral(weight.GetEnergyMin(), weight.GetEnergyMax()); 987 988 // scale with effective collection area to get the event rate (N/s) 989 // scale with the effective observation time to absolute observed events 990 n *= area.GetCollectionAreaAbs()*ontime; // N 991 992 // Now calculate the scale factor from the number of events 993 // produced and the number of events which should have been 994 // observed with our telescope in the time ontime 995 const Double_t scale = n/area.GetEntries(); 996 997 // Print normalization constant 998 cout << "MC normalization factor: " << scale << endl; 999 1000 // Overlay normalized plots 1001 DisplaySize(plist, scale); 1002 1003 // check if output should be written 896 1004 if (!fPathOut.IsNull()) 897 1005 fDisplay->SaveAsRoot(fPathOut); -
trunk/MagicSoft/Mars/mjobs/MJSpectrum.h
r6978 r7094 18 18 class MStatusArray; 19 19 class MHCollectionArea; 20 class MMcSpectrumWeight; 20 21 21 22 class MJSpectrum : public MJob … … 35 36 Bool_t ReadTask(MTask* &task, const char *name) const; 36 37 Float_t ReadInput(MParList &plist, TH1D &h1, TH1D &size); 37 Bool_t ReadOrigMCDistribution(const MDataSet &set, TH1 &h ) const;38 Bool_t ReadOrigMCDistribution(const MDataSet &set, TH1 &h, MMcSpectrumWeight &w) const; 38 39 Bool_t GetThetaDistribution(TH1D &temp1, TH1D &temp2) const; 39 40 Bool_t Refill(MParList &plist, TH1D &h) const; 41 Bool_t InitWeighting(const MDataSet &set, MMcSpectrumWeight &w) const; 40 42 41 43 // Display Output 42 44 void PrintSetup(const MAlphaFitter &fit) const; 43 45 void DisplayResult(const TH2D &mh1) const; 44 Bool_t IntermediateLoop(MParList &plist, MH3 &h1, TH1D &temp1, const MDataSet &set ) const;45 voidDisplaySpectrum(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;46 Bool_t IntermediateLoop(MParList &plist, MH3 &h1, TH1D &temp1, const MDataSet &set, MMcSpectrumWeight &w) const; 47 TArrayD DisplaySpectrum(MHCollectionArea &area, TH1D &excess, MHEnergyEst &hest, Double_t ontime) const; 48 Bool_t DisplaySize(MParList &plist, Double_t scale) const; 49 Bool_t PlotSame(MStatusArray &arr, MParList &plist, const char *name, const char *tab, const char *plot, Double_t scale) const; 48 50 49 51 public: -
trunk/MagicSoft/Mars/sponde.rc
r6977 r7094 1 1 EstimateEnergy.Rule: (0.380075+(MPointingPos.fZd*MPointingPos.fZd*0.00109028))*pow(MHillas.fSize,0.892462) 2 3 #MMcSpectrumWeight.NewSlope: -2.26
Note:
See TracChangeset
for help on using the changeset viewer.