Changeset 8047 for trunk/MagicSoft/Mars/mhflux
- Timestamp:
- 10/11/06 08:55:36 (18 years ago)
- Location:
- trunk/MagicSoft/Mars/mhflux
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhflux/MHCollectionArea.cc
r7684 r8047 64 64 // 65 65 MHCollectionArea::MHCollectionArea(const char *name, const char *title) 66 : fMcEvt(0), /*fEnergy(0),*/ fMcAreaRadius(300.), fIsExtern(kFALSE)66 : fMcEvt(0), fMcAreaRadius(-1), fIsExtern(kFALSE) 67 67 { 68 68 // initialize the histogram for the distribution r vs E … … 82 82 fHistSel.SetDirectory(NULL); 83 83 fHistSel.UseCurrentStyle(); 84 fHistSel.SetLineColor(kBlue); 84 85 85 86 fHistAll.SetName("AllEvts"); … … 105 106 MH::SetBinning(&fHistSel, &binst, &binse); 106 107 MH::SetBinning(&fHistAll, &binst, &binse); 108 109 // For some unknown reasons this must be called after 110 // the binning has been initialized at least once 111 fHistSel.Sumw2(); 112 fHistAll.Sumw2(); 113 fHEnergy.Sumw2(); 107 114 } 108 115 … … 114 121 void MHCollectionArea::CalcEfficiency() 115 122 { 116 TH1D *hsel = fHistSel.ProjectionY(); 117 TH1D *hall = fHistAll.ProjectionY(); 118 119 const Int_t nbinx = hsel->GetNbinsX(); 120 121 // ----------------------------------------------------------- 122 // 123 // Impact parameter range: TO BE FIXED! Impact parameter shoud be 124 // read from run header, but it is not yet in!! 123 TH1D *hsel = fHistSel.ProjectionY("Spy", -1, 9999, "E");; 124 TH1D *hall = fHistAll.ProjectionY("Apy", -1, 9999, "E"); 125 126 // 127 // Impact parameter range. 125 128 // 126 129 const Float_t totalarea = GetCollectionAreaAbs();//TMath::Pi() * (r2*r2 - r1*r1); 127 130 128 for (Int_t ix=1; ix<=nbinx; ix++) 129 { 130 const Float_t Na = hall->GetBinContent(ix); 131 132 if (Na <= 0) 133 continue; 134 135 const Float_t Ns = hsel->GetBinContent(ix); 136 137 // Since Na is an estimate of the total number of showers generated 138 // in the energy bin, it may happen that Ns (triggered showers) is 139 // larger than Na. In that case, the bin is skipped: 140 141 if (Na < Ns) 142 continue; 143 144 const Double_t eff = Ns/Na; 145 const Double_t efferr = TMath::Sqrt((1.-eff)*Ns)/Na; 146 147 const Float_t colarea = eff * totalarea; 148 const Float_t colareaerror = efferr * totalarea; 149 150 fHEnergy.SetBinContent(ix, colarea); 151 fHEnergy.SetBinError(ix, colareaerror); 152 } 131 // "b" option: calculate binomial errors 132 fHEnergy.Divide(hsel, hall, totalarea, 1, "b"); 133 #if ROOT_VERSION_CODE < ROOT_VERSION(5,13,04) 134 MH::SetBinomialErrors(fHEnergy, *hsel, *hall, totalarea, 1); 135 #endif 153 136 154 137 delete hsel; 155 138 delete hall; 156 139 } 140 157 141 158 142 Bool_t MHCollectionArea::SetupFill(const MParList *pl) … … 196 180 MH::SetBinning(&fHistAll, &binst, &binse); 197 181 182 fMcAreaRadius = -1; 183 198 184 return kTRUE; 199 185 } … … 201 187 Bool_t MHCollectionArea::ReInit(MParList *plist) 202 188 { 189 MMcRunHeader *runheader = (MMcRunHeader*)plist->FindObject("MMcRunHeader"); 190 if (!runheader) 191 { 192 *fLog << err << "MMcRunHeader not found... abort." << endl; 193 return kFALSE; 194 } 195 196 // FIXME: Does this need some weighting with the number of produced events? 197 if (runheader->GetImpactMax()>fMcAreaRadius*100) 198 { 199 fMcAreaRadius = 0.01*runheader->GetImpactMax(); // cm->m 200 *fLog << inf << "Maximum simulated impact: " << fMcAreaRadius << "m" << endl; 201 } 202 203 203 if (fIsExtern) 204 204 return kTRUE; 205 205 206 MMcRunHeader *runheader = (MMcRunHeader*)plist->FindObject("MMcRunHeader");207 if (!runheader)208 {209 *fLog << err << "MMcRunHeader not found... abort." << endl;210 return kFALSE;211 }212 213 206 fTotalNumSimulatedShowers += runheader->GetNumSimulatedShowers(); 214 207 *fLog << inf << "Total Number of Simulated showers: " << fTotalNumSimulatedShowers << endl; 215 208 216 /*217 if (fTheta>=0 && fTheta!=runheader->GetTelesTheta())218 {219 *fLog << warn << "Warning - Read files have different TelesTheta (";220 *fLog << fTheta << ", " << runheader->GetTelesTheta() << ")..." << endl;221 }222 fTheta = runheader->GetTelesTheta();223 */224 209 if (fCorsikaVersion!=0 && fCorsikaVersion!=runheader->GetCorsikaVersion()) 225 210 *fLog << warn << "Warning - Read files have different Corsika versions..." << endl; … … 352 337 if (h1 && h2 && h) 353 338 { 354 h->Divide(h2, h1); 355 h->SetMinimum(0); 339 h->Divide(h2, h1, 1, 1, "b"); 340 #if ROOT_VERSION_CODE < ROOT_VERSION(5,13,04) 341 MH::SetBinomialErrors(*h, *h2, *h1); 342 #endif 343 h->SetMinimum(0); 356 344 } 357 345 … … 433 421 gPad->SetLogx(); 434 422 h = h2->DrawCopy(); 435 h->Divide(h1); 423 h->Divide(h2, h1, 1, 1, "b"); 424 #if ROOT_VERSION_CODE < ROOT_VERSION(5,13,04) 425 MH::SetBinomialErrors(*h, *h2, *h1); 426 #endif 436 427 h->SetNameTitle("Efficiency", "Combined cut and trigger efficiency"); 437 428 h->SetDirectory(NULL); … … 456 447 Bool_t MHCollectionArea::Fill(const MParContainer *par, const Stat_t weight) 457 448 { 458 const Double_t energy = fMcEvt->GetEnergy() /*fEnergy->GetVal()*/;449 const Double_t energy = fMcEvt->GetEnergy(); 459 450 const Double_t theta = fMcEvt->GetTelescopeTheta()*TMath::RadToDeg(); 460 451 461 //*fLog << energy << " " << theta << endl;462 463 452 fHistSel.Fill(theta, energy, weight); 464 453 -
trunk/MagicSoft/Mars/mhflux/MHCollectionArea.h
r7683 r8047 60 60 Double_t GetCollectionAreaAbs() const { return TMath::Pi()*fMcAreaRadius*fMcAreaRadius; } 61 61 62 /*63 void DrawAll(Option_t *option="");64 void DrawSel(Option_t *option="");65 66 const TH1D *GetHist() { return fHistCol; }67 const TH1D *GetHist() const { return fHistCol; }68 69 70 71 void CalcEfficiency();72 void CalcEfficiency2();73 74 void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);75 void Calc(const MHMcEfficiency &heff);76 */77 62 void SetMcAreaRadius(Float_t x) { fMcAreaRadius = x; } 78 63 -
trunk/MagicSoft/Mars/mhflux/MHEnergyEst.cc
r8021 r8047 94 94 fHImpact.SetYTitle("E_{est}/E_{mc}-1"); 95 95 96 fHEnergy.Sumw2();97 fHImpact.Sumw2();98 fHResolution.Sumw2();99 100 96 MBinning binsi, binse, binst, binsr; 101 97 binse.SetEdgesLog(25, 10, 1000000); … … 107 103 SetBinning(&fHImpact, &binsi, &binsr); 108 104 SetBinning(&fHResolution, &binse, &binse, &binsr); 105 106 // For some unknown reasons this must be called after 107 // the binning has been initialized at least once 108 fHEnergy.Sumw2(); 109 fHResolution.Sumw2(); 110 fHImpact.Sumw2(); 109 111 } 110 112 … … 243 245 { 244 246 // Project into EnergyEst_ey 247 // the "e" ensures that errors are calculated 245 248 TH1D *h1 = (TH1D*)fHEnergy.Project3D("rtlprmft_ex"); // E_Est 246 249 TH1D *h2 = (TH1D*)fHEnergy.Project3D("rtlprmft_ey"); // E_mc -
trunk/MagicSoft/Mars/mhflux/MHThreshold.cc
r7715 r8047 79 79 fHEnergy.SetDirectory(NULL); 80 80 fHEnergy.UseCurrentStyle(); 81 fHEnergy.Sumw2();82 81 83 82 MBinning binse(50, 20, 50000, "", "log"); 84 83 binse.Apply(fHEnergy); 84 85 fHEnergy.Sumw2(); 85 86 } 86 87 -
trunk/MagicSoft/Mars/mhflux/MMcSpectrumWeight.cc
r8036 r8047 443 443 Int_t MMcSpectrumWeight::Process() 444 444 { 445 const Double_t e = fMcEvt->GetEnergy();446 447 445 Double_t w = 1; 448 446 … … 459 457 } 460 458 459 const Double_t e = fMcEvt->GetEnergy(); 461 460 fWeight->SetVal(fFunc->Eval(e)*w); 462 461
Note:
See TracChangeset
for help on using the changeset viewer.