Changeset 1300 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 04/25/02 11:21:46 (23 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MH.cc
r1283 r1300 50 50 51 51 #include <TH1.h> 52 #include <TH2.h> 53 #include <TH3.h> 52 54 #include <TCanvas.h> 53 55 … … 136 138 } 137 139 138 void MH::SetBinning(TH 1*h, const MBinning *binsx, const MBinning *binsy)140 void MH::SetBinning(TH2 *h, const MBinning *binsx, const MBinning *binsy) 139 141 { 140 142 TAxis &x = *h->GetXaxis(); … … 169 171 } 170 172 171 void MH::SetBinning(TH 1*h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz)173 void MH::SetBinning(TH3 *h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz) 172 174 { 173 175 // … … 214 216 } 215 217 216 void MH::SetBinning(TH 1*h, const TArrayD *binsx, const TArrayD *binsy)218 void MH::SetBinning(TH2 *h, const TArrayD *binsx, const TArrayD *binsy) 217 219 { 218 220 MBinning bx; … … 223 225 } 224 226 225 void MH::SetBinning(TH 1*h, const TArrayD *binsx, const TArrayD *binsy, const TArrayD *binsz)227 void MH::SetBinning(TH3 *h, const TArrayD *binsx, const TArrayD *binsy, const TArrayD *binsz) 226 228 { 227 229 MBinning bx; … … 245 247 } 246 248 247 void MH::SetBinning(TH 1*h, const TAxis *binsx, const TAxis *binsy)249 void MH::SetBinning(TH2 *h, const TAxis *binsx, const TAxis *binsy) 248 250 { 249 251 const Int_t nx = binsx->GetNbins(); … … 260 262 } 261 263 262 void MH::SetBinning(TH 1*h, const TAxis *binsx, const TAxis *binsy, const TAxis *binsz)264 void MH::SetBinning(TH3 *h, const TAxis *binsx, const TAxis *binsy, const TAxis *binsz) 263 265 { 264 266 const Int_t nx = binsx->GetNbins(); … … 281 283 void MH::SetBinning(TH1 *h, TH1 *x) 282 284 { 283 SetBinning(h, x->GetXaxis(), x->GetYaxis(), x->GetZaxis()); 284 } 285 if (h->InheritsFrom(TH3::Class()) && x->InheritsFrom(TH3::Class())) 286 { 287 SetBinning((TH3*)h, x->GetXaxis(), x->GetYaxis(), x->GetZaxis()); 288 return; 289 } 290 if (h->InheritsFrom(TH2::Class()) && x->InheritsFrom(TH2::Class())) 291 { 292 SetBinning((TH2*)h, x->GetXaxis(), x->GetYaxis()); 293 return; 294 } 295 if (h->InheritsFrom(TH1::Class()) && x->InheritsFrom(TH1::Class())) 296 { 297 SetBinning(h, x->GetXaxis()); 298 return; 299 } 300 } -
trunk/MagicSoft/Mars/mhist/MH.h
r1283 r1300 7 7 8 8 class TH1; 9 class TH2; 10 class TH3; 9 11 class TAxis; 10 12 class TArrayD; … … 28 30 29 31 static void SetBinning(TH1 *h, const MBinning *binsx); 30 static void SetBinning(TH 1*h, const MBinning *binsx, const MBinning *binsy);31 static void SetBinning(TH 1*h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz);32 static void SetBinning(TH2 *h, const MBinning *binsx, const MBinning *binsy); 33 static void SetBinning(TH3 *h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz); 32 34 33 35 static void SetBinning(TH1 *h, const TArrayD *binsx); 34 static void SetBinning(TH 1*h, const TArrayD *binsx, const TArrayD *binsy);35 static void SetBinning(TH 1*h, const TArrayD *binsx, const TArrayD *binsy, const TArrayD *binsz);36 static void SetBinning(TH2 *h, const TArrayD *binsx, const TArrayD *binsy); 37 static void SetBinning(TH3 *h, const TArrayD *binsx, const TArrayD *binsy, const TArrayD *binsz); 36 38 37 39 static void SetBinning(TH1 *h, const TAxis *binsx); 38 static void SetBinning(TH 1*h, const TAxis *binsx, const TAxis *binsy);39 static void SetBinning(TH 1*h, const TAxis *binsx, const TAxis *binsy, const TAxis *binsz);40 static void SetBinning(TH2 *h, const TAxis *binsx, const TAxis *binsy); 41 static void SetBinning(TH3 *h, const TAxis *binsx, const TAxis *binsy, const TAxis *binsz); 40 42 41 43 static void SetBinning(TH1 *h, TH1 *x); -
trunk/MagicSoft/Mars/mhist/MH3.cc
r1299 r1300 229 229 case 2: 230 230 fHist->SetTitle(title+" (2D)"); 231 SetBinning( fHist, binsx, binsy);231 SetBinning((TH2*)fHist, binsx, binsy); 232 232 return kTRUE; 233 233 case 3: 234 234 fHist->SetTitle(title+" (3D)"); 235 SetBinning( fHist, binsx, binsy, binsz);235 SetBinning((TH3*)fHist, binsx, binsy, binsz); 236 236 return kTRUE; 237 237 } -
trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.cc
r1228 r1300 196 196 } 197 197 198 // -------------------------------------------------------------------------- 199 // 200 // Calculate the Efficiency (collection area) and set the 'ReadyToSave' 201 // flag 202 // 203 void MHMcCollectionArea::CalcEfficiency() 204 { 205 MHMcEfficiency heff; 206 heff.Calc(*fHistSel, *fHistAll); 207 208 Calc(heff); 209 } 210 211 void MHMcCollectionArea::CalcEfficiency(UInt_t numevts, Float_t angle) 212 { 213 // Here we estimate the total number of showers in each energy bin 214 // known the energy range and spectral index of the generated showers 215 // (set now by hand since the info is not available in the header!) 216 217 TH1D &histsel = *fHistSel->ProjectionX(); 218 219 TH1D histall; 220 221 TAxis &xaxis = *histsel.GetXaxis(); 222 223 MH::SetBinning(&histall, &xaxis); 224 MH::SetBinning(fHistCol, &xaxis); 225 226 const Float_t emin = 10.; 227 const Float_t emax = 30000.; // Energies in GeV. 228 const Float_t index = 2.6; // Differential spectral Index. 229 230 const Float_t expo = 1.-index; 231 232 const Float_t k = (Float_t)numevts / (pow(emax,expo) - pow(emin,expo)); 233 234 const Int_t nbinx = xaxis.GetNbins(); 235 236 for (Int_t i=1; i<=nbinx; i++) 237 { 238 const Float_t e1 = histall.GetBinLowEdge(i); 239 const Float_t e2 = histall.GetBinLowEdge(i+1); 240 241 if (e1 < emin || e2 > emax) 242 continue; 243 244 const Float_t events = k * (pow(e2, expo) - pow(e1, expo)); 245 246 histall.SetBinContent(i, events); 247 histall.SetBinError(i, sqrt(events)); 248 249 } 250 251 // ----------------------------------------------------------- 252 253 // Impact parameter range: 254 const Float_t r1 = 0; 255 const Float_t r2 = 400; 256 257 const Float_t dr = TMath::Pi() * (r2*r2 - r1*r1); 258 259 angle *= TMath::Pi()/180; 260 261 for (Int_t ix=1; ix<=nbinx; ix++) 262 { 263 const Float_t Na = histall.GetBinContent(ix); 264 265 if (Na <= 0) 266 continue; 267 268 const Float_t Ns = histsel.GetBinContent(ix); 269 270 // Since Na is an estimate of the total number of showers generated 271 // in the energy bin, it may happen that Ns (triggered showers) is 272 // larger than Na. In that case, the bin is skipped: 273 274 if (Na < Ns) 275 continue; 276 277 const Double_t eff = Ns/Na; 278 279 const Double_t err = sqrt((1.-eff)*Ns)/Na; 280 281 const Float_t area = dr * cos(angle); 282 283 fHistCol->SetBinContent(ix, eff*area); 284 fHistCol->SetBinError(ix, err*area); 285 } 286 287 delete &histsel; 288 289 SetReadyToSave(); 290 } 291 292 void MHMcCollectionArea::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall) 293 { 294 MHMcEfficiency heff; 295 heff.Calc(*mcsel.GetHist(), *mcall.GetHist()); 296 297 Calc(heff); 298 } 299 198 300 void MHMcCollectionArea::Calc(const MHMcEfficiency &heff) 199 301 { … … 242 344 // flag 243 345 // 244 void MHMcCollectionArea::CalcEfficiency() 245 { 246 MHMcEfficiency heff; 247 heff.Calc(*fHistSel, *fHistAll); 248 249 Calc(heff); 250 } 251 252 void MHMcCollectionArea::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall) 253 { 254 MHMcEfficiency heff; 255 heff.Calc(*mcsel.GetHist(), *mcall.GetHist()); 256 257 Calc(heff); 258 } 346 /* 347 void MHMcCollectionArea::Calc(MHMcEnergyImpact &mcsel, UInt_t numevents, Float_t angle) 348 { 349 } 350 */ -
trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.h
r1228 r1300 38 38 39 39 void CalcEfficiency(); 40 void CalcEfficiency(UInt_t allevts, Float_t theta); 40 41 41 42 void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
Note:
See TracChangeset
for help on using the changeset viewer.