- Timestamp:
- 04/25/02 11:21:46 (23 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r1299 r1300 1 1 -*-*- END -*-*- 2 2002/04/25: Thomas Bretz 3 4 * mmontecarlo/MMcCollectionAreaCalc.[h,cc]: 5 - counts now the number of simulated showers 6 - implemented some sanity checks (corsika version, etc) 7 8 * mhist/MMcCollectionArea.[h,cc]: 9 - added a first implementation of a calculation using only triggered 10 events 11 12 * mhist/MH.[h,cc]: 13 - changed the first argument in SetBinning (according to the number 14 of axis) to TH2 or TH3 15 16 * mhist/MH2.cc: 17 - changed the first argument in SetBinning (according to the number 18 of axis) to TH2 or TH3 19 20 21 2 22 2002/04/24: Thomas Bretz 3 23 -
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); -
trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.cc
r1108 r1300 33 33 #include "MMcEvt.hxx" 34 34 #include "MMcTrig.hxx" 35 #include "MMcRunHeader.hxx" 35 36 36 37 #include "MHMcCollectionArea.h" … … 73 74 return kFALSE; 74 75 76 77 fTotalNumSimulatedShowers = 0; 78 fCorsikaVersion = 0; 79 fAllEvtsTriggered = kFALSE; 80 81 return kTRUE; 82 } 83 84 Bool_t MMcCollectionAreaCalc::ReInit(MParList *plist) 85 { 86 MMcRunHeader *runheader = (MMcRunHeader*)plist->FindObject("MMcRunHeader"); 87 if (!runheader) 88 { 89 *fLog << err << dbginf << "Error - MMcRunHeader not found... exit." << endl; 90 return kFALSE; 91 } 92 93 fTotalNumSimulatedShowers += runheader->GetNumSimulatedShowers(); 94 95 *fLog << inf << "Total Number of Simulated showers: " << fTotalNumSimulatedShowers << endl; 96 97 if (fTheta>=0 && fTheta!=runheader->GetTelesTheta()) 98 *fLog << warn << dbginf << "Warning - Read files have different TelesTheta... exit." << endl; 99 100 fTheta = runheader->GetTelesTheta(); 101 102 if (fCorsikaVersion!=0 && fCorsikaVersion!=runheader->GetCorsikaVersion()) 103 *fLog << warn << dbginf << "Warning - Read files have different Corsika versions... exit." << endl; 104 105 fCorsikaVersion = runheader->GetCorsikaVersion(); 106 107 fAllEvtsTriggered |= runheader->GetAllEvtsTriggered(); 108 109 *fLog << inf << "Only triggered events avail: " << (fAllEvtsTriggered?"yes":"no") << endl; 110 75 111 return kTRUE; 76 112 } … … 81 117 const Float_t impact = fMcEvt->GetImpact()/100.; 82 118 83 fCollArea->FillAll(energy, impact); 119 if (!fAllEvtsTriggered) 120 fCollArea->FillAll(energy, impact); 84 121 85 122 if (fMcTrig->GetFirstLevel() <= 0) … … 96 133 // do the calculation of the effectiv area 97 134 // 98 fCollArea->CalcEfficiency(); 135 *fLog << inf << "Calculation Collection Area..." << endl; 136 137 if (!fAllEvtsTriggered) 138 fCollArea->CalcEfficiency(); 139 else 140 { 141 *fLog << inf << "Total number of showers: " << fTotalNumSimulatedShowers << endl; 142 fCollArea->CalcEfficiency(fTotalNumSimulatedShowers, 143 fCorsikaVersion == 5200 ? fTheta : 0); 144 } 99 145 100 146 return kTRUE; 101 147 } 148 -
trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.h
r1016 r1300 21 21 TString fObjName; 22 22 23 UInt_t fTotalNumSimulatedShowers; 24 UInt_t fCorsikaVersion; 25 Float_t fTheta; 26 27 Bool_t fAllEvtsTriggered; 28 23 29 public: 24 30 MMcCollectionAreaCalc(const char *input=NULL, 25 31 const char *name=NULL, const char *title=NULL); 32 33 Bool_t ReInit(MParList *plist); 26 34 27 35 Bool_t PreProcess(MParList *pList);
Note:
See TracChangeset
for help on using the changeset viewer.