Changeset 8047 for trunk/MagicSoft/Mars/mjobs
- Timestamp:
- 10/11/06 08:55:36 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
r7650 r8047 176 176 fLog->Separator("Initialize energy weighting"); 177 177 178 // Read Resources 178 179 if (!CheckEnv(w)) 179 180 { … … 182 183 } 183 184 185 // Read the first corsika RunHeader from the MC files 184 186 TChain chain("RunHeaders"); 185 187 set.AddFilesOn(chain); … … 195 197 } 196 198 199 // Propagate the run header to MMcSpectrumWeight 197 200 if (!w.Set(*h)) 198 201 { … … 201 204 } 202 205 206 // Print new setup of MMcSpectrumWeight 203 207 w.Print(); 204 208 return kTRUE; … … 266 270 fLog->Separator("Compiling original MC distribution"); 267 271 272 // The name of the input container is MMcEvtBasic 268 273 weight.SetNameMcEvt("MMcEvtBasic"); 274 // Get the corresponding rule for the weights 269 275 const TString w(weight.GetFormulaWeights()); 276 // Set back to MMcEvt 270 277 weight.SetNameMcEvt(); 271 278 … … 282 289 // Prepare histogram 283 290 h.Reset(); 291 h.Sumw2(); 284 292 285 293 // Fill histogram from chain … … 331 339 gPad->SetBorderMode(0); 332 340 temp2.SetName("NVsTheta"); 333 temp2.DrawCopy( );341 temp2.DrawCopy("hist"); 334 342 335 343 c.cd(4); … … 349 357 temp1.SetYTitle("Probability"); 350 358 if (fDisplay) 351 temp1.DrawCopy( );359 temp1.DrawCopy("hist"); 352 360 353 361 return kTRUE; … … 580 588 case 0: 581 589 { 582 const TString fmt0 = Form("(%%%sf#pm%%%sf)\\bullet10^{%%d}", 590 const TString fmt0 = Form("(%%%sf#pm%%%sf)\\bullet10^{%%d}", f1, f1); 583 591 const TString fmt1 = Form("(\\frac{E}{TeV})^{%%%sf#pm%%%sf}", f0, f0); 584 592 … … 638 646 TArrayD MJSpectrum::DisplaySpectrum(MHCollectionArea &area, TH1D &excess, MHEnergyEst &hest, Double_t ontime) const 639 647 { 648 // Create copies of the histograms 640 649 TH1D collarea(area.GetHEnergy()); 641 650 TH1D spectrum(excess); 642 651 TH1D weights; 652 653 // Get spill-over corrections from energy estimation 643 654 hest.GetWeights(weights); 644 655 656 // Print effective on-time 645 657 cout << "Effective On time: " << ontime << "s" << endl; 646 658 659 // Setup spectrum plot 660 spectrum.SetNameTitle("Preliminary", "N/sm^{2} versus Energy (before unfolding)"); 661 spectrum.SetYTitle("N/sm^{2}"); 647 662 spectrum.SetDirectory(NULL); 648 663 spectrum.SetBit(kCanDelete); 664 665 // Divide by collection are and on-time 649 666 spectrum.Scale(1./ontime); 650 667 spectrum.Divide(&collarea); 651 spectrum.SetNameTitle("Preliminary", "N/sm^{2} versus Energy (before unfolding)"); 652 spectrum.SetYTitle("N/sm^{2}"); 653 668 669 // Draw spectrum before applying spill-over corrections 654 670 TCanvas &c1 = fDisplay->AddTab("Spectrum"); 655 671 c1.Divide(2,2); … … 679 695 weights.DrawCopy(); 680 696 697 // Apply spill-over correction (done't take the errors into account) 698 // They are supposed to be identical with the errors of the 699 // collection area and cancel out. 681 700 //spectrum.Multiply(&weights); 682 701 spectrum.SetNameTitle("Flux", "Spectrum (after unfolding)"); … … 840 859 841 860 //h2->Scale(1./ontime); //h2->Integral()); 842 h3->Scale(scale); //h3->Integral());861 h3->Scale(scale); //h3->Integral()); 843 862 844 863 h2->SetMaximum(1.05*TMath::Max(h2->GetMaximum(), h3->GetMaximum())); … … 1001 1020 plist.AddToList(&bins2); 1002 1021 1022 // Initialize weighting to a new spectru 1023 // m as defined in the resource file 1003 1024 MMcSpectrumWeight weight; 1004 1025 if (!InitWeighting(set, weight)) 1005 1026 return kFALSE; 1006 1027 1028 // Print the setup of the MAlphaFitter 1007 1029 PrintSetup(fit); 1008 1030 bins3.SetEdges(temp1, 'x'); 1009 1031 1032 // Read the MC distribution as produced by corsika into 1033 // temp2 (1D) and apply the weights previously determined 1010 1034 TH1D temp2(temp1); 1011 1035 if (!ReadOrigMCDistribution(set, temp2, weight)) 1012 1036 return kFALSE; 1013 1037 1038 // Calculate the weights according to the zenith angle distribution 1039 // of the raw-data which have to be applied to the MC events 1014 1040 if (!GetThetaDistribution(temp1, temp2)) 1015 1041 return kFALSE; 1016 1042 1043 // Tell the weighting task about the ZA-weights 1017 1044 if (!fNoThetaWeights) 1018 1045 weight.SetWeightsZd(&temp1); 1019 1046 1047 // Refill excess histogram to determin the excess events 1020 1048 TH1D excess; 1021 1049 if (!Refill(plist, excess)) … … 1026 1054 if (fSimpleMode) 1027 1055 { 1056 // Now we read the MC distribution as produced by corsika again 1057 // with the spectral weights applied into a histogram vs. 1058 // zenith angle and energy 1028 1059 hist.UseCurrentStyle(); 1029 1060 MH::SetBinning(&hist, &bins3/*temp1.GetXaxis()*/, &bins2/*excess.GetXaxis()*/); … … 1031 1062 return kFALSE; 1032 1063 1064 // No we apply the the zenith-angle-weights to the corsika produced 1065 // MC distribution. Unfortunately this must be done manually 1066 // because we are multiplying column by column 1033 1067 if (!fRawMc) 1034 1068 { 1035 1069 for (int y=0; y<hist.GetNbinsY(); y++) 1036 1070 for (int x=0; x<hist.GetNbinsX(); x++) 1071 { 1037 1072 hist.SetBinContent(x, y, hist.GetBinContent(x, y)*temp1.GetBinContent(x)); 1038 //hist.SetEntries(hist.Integral()); 1073 hist.SetBinError(x, y, hist.GetBinError(x, y) *temp1.GetBinContent(x)); 1074 } 1039 1075 } 1040 1076 } 1041 1077 else 1042 1078 { 1079 // This rereads the original MC spectrumand aaplies both 1080 // weights spectral weights and ZA-weights. 1043 1081 weight.SetNameMcEvt("MMcEvtBasic"); 1044 1082 if (!IntermediateLoop(plist, mh1, temp1, set, weight)) … … 1146 1184 1147 1185 tlist2.AddToList(&read); 1186 // If no weighting should be applied but the events should 1187 // be thrown away according to the theta distribution 1188 // it is enabled here 1148 1189 if (!fRawMc && fNoThetaWeights) 1149 1190 tlist2.AddToList(&contsel);
Note:
See TracChangeset
for help on using the changeset viewer.