Changeset 1415 for trunk/MagicSoft/Mars
- Timestamp:
- 07/16/02 15:35:15 (22 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/HistLinkDef.h
r1336 r1415 18 18 #pragma link C++ class MHEnergyTime+; 19 19 #pragma link C++ class MHEnergyTheta+; 20 #pragma link C++ class MHAlphaEnergyTime; 21 #pragma link C++ class MHAlphaEnergyTheta; 22 #pragma link C++ class MHEffOnTimeTime+; 23 #pragma link C++ class MHEffOnTimeTheta+; 20 #pragma link C++ class MHAlphaEnergyTime+; 21 #pragma link C++ class MHAlphaEnergyTheta+; 22 #pragma link C++ class MHGamma+; 23 #pragma link C++ class MHEffOnTime+; 24 24 25 #pragma link C++ class MHTimeDiffTime+; 25 26 #pragma link C++ class MHTimeDiffTheta+; … … 40 41 #pragma link C++ class MHMcCollectionArea+; 41 42 #pragma link C++ class MHMcEnergyMigration+; 43 #pragma link C++ class MHFlux; 42 44 43 #pragma link C++ class MHCompProb+;44 #pragma link C++ class MHHadroness+;45 45 46 46 #endif -
trunk/MagicSoft/Mars/mhist/MHAlphaEnergyTheta.cc
r1330 r1415 66 66 fHist.SetTitle("3D-plot of alpha, E-est, Theta"); 67 67 fHist.SetXTitle("\\alpha [\\circ]"); 68 fHist.SetYTitle("E _{est} [GeV]");68 fHist.SetYTitle("E-est [GeV] "); 69 69 fHist.SetZTitle("\\Theta [\\circ]"); 70 70 } … … 79 79 if (!fEnergy) 80 80 { 81 *fLog << err << dbginf << "M EnergyEst not found... aborting." << endl;81 *fLog << err << dbginf << "MHAlphaEnergyTheta : MEnergyEst not found... aborting." << endl; 82 82 return kFALSE; 83 83 } … … 86 86 if (!fMcEvt) 87 87 { 88 *fLog << err << dbginf << "M McEvt not found... aborting." << endl;88 *fLog << err << dbginf << "MHAlphaEnergyTheta : MMcEvt not found... aborting." << endl; 89 89 return kFALSE; 90 90 } 91 91 92 92 MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE"); 93 MBinning* binsalpha = (MBinning*)plist->FindObject("BinningAlpha");93 MBinning* binsalphaflux = (MBinning*)plist->FindObject("BinningAlphaFlux"); 94 94 MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta"); 95 if (!binsenergy || !binsalpha || !binstheta)95 if (!binsenergy || !binsalphaflux || !binstheta) 96 96 { 97 *fLog << err << dbginf << " At least one MBinning not found... aborting." << endl;97 *fLog << err << dbginf << "MHAlphaEnergyTheta : At least one MBinning not found... aborting." << endl; 98 98 return kFALSE; 99 99 } 100 100 101 SetBinning(&fHist, binsalpha , binsenergy, binstheta);101 SetBinning(&fHist, binsalphaflux, binsenergy, binstheta); 102 102 103 103 fHist.Sumw2(); 104 104 105 fHist.Sumw2(); 106 105 107 return kTRUE; 106 108 } … … 114 116 MHillasSrc &hil = *(MHillasSrc*)par; 115 117 116 fHist.Fill( hil.GetAlpha(), fEnergy->GetEnergy(), fMcEvt->GetTheta()*kRad2Deg);118 fHist.Fill(fabs(hil.GetAlpha()), fEnergy->GetEnergy(), fMcEvt->GetTheta()*kRad2Deg); 117 119 118 120 return kTRUE; … … 146 148 147 149 h->SetTitle("Distribution of E-est [GeV]"); 148 h->SetXTitle("E _{est} [GeV]");150 h->SetXTitle("E-est [GeV] "); 149 151 h->SetYTitle("Counts"); 150 152 … … 223 225 } 224 226 225 // --------------------------------------------------------------------------226 //227 // Calculate the histogram as the difference of two histograms :228 // fHist(gamma) = h1(source) - h2(antisource)229 //230 void MHAlphaEnergyTheta::Subtract(const TH3D *h1, const TH3D *h2)231 {232 // MH::SetBinning(&fHist, (TH1*)h1);233 234 // fHist.Sumw2();235 fHist.Add((TH1*)h1, (TH1*)h2, 1, -1); // Root: FIXME236 }237 238 239 // --------------------------------------------------------------------------240 //241 // Integrate fHist(gamma) in the alpha range (lo, up)242 //243 TH2D *MHAlphaEnergyTheta::GetAlphaProjection(Axis_t lo, Axis_t up)244 {245 if (up < lo)246 {247 *fLog << err << fName << ": Alpha projection not possible: lo=" << lo << " up=" << up << endl;248 return NULL;249 }250 251 TAxis &axe = *fHist.GetXaxis();252 253 Int_t ilo = axe.FindFixBin(lo);254 Int_t iup = axe.FindFixBin(up);255 256 const Double_t epslo1 = lo-axe.GetBinLowEdge(ilo);257 const Double_t epslo2 = axe.GetBinUpEdge(ilo)-lo;258 259 const Double_t epsup1 = up-axe.GetBinLowEdge(iup);260 const Double_t epsup2 = axe.GetBinUpEdge(iup)-up;261 262 const Double_t epslo = epslo1<epslo2 ? epslo1 : epslo2;263 const Double_t epsup = epsup1<epsup2 ? epsup1 : epsup2;264 265 if (epslo1>epslo2)266 ilo++;267 268 if (epsup1<epsup2)269 iup--;270 271 if (epslo>0.01*axe.GetBinWidth(ilo) || epsup>0.01*axe.GetBinWidth(iup))272 {273 *fLog << err << fName << ": binning is not adequate for the requested projection:" << endl;274 *fLog << "Please specify a lower or upper limit which is not more than 1% away from a bin edge" << endl;275 *fLog << " epslo = " << epslo << endl;276 *fLog << " epsup = " << epsup << endl;277 *fLog << " dwl = " << axe.GetBinWidth(ilo) << endl;278 *fLog << " dwu = " << axe.GetBinWidth(iup) << endl;279 return NULL;280 }281 282 axe.SetRange(ilo, iup);283 284 TH2D &h2D = *(TH2D *)fHist.Project3D("ezypro");285 286 h2D.SetTitle("2D-plot of Theta vs. E-est");287 h2D.SetXTitle("E-est [GeV] ");288 h2D.SetYTitle("\\Theta [\\circ]");289 290 return &h2D;291 }292 293 // --------------------------------------------------------------------------294 //295 // Draw the integrated histogram296 //297 TH2D *MHAlphaEnergyTheta::DrawAlphaProjection(Axis_t lo, Axis_t up, Option_t *opt)298 {299 TH2D *h2D = GetAlphaProjection(lo, up);300 301 if (!h2D)302 return NULL;303 304 char txt[100];305 sprintf(txt, "No.of Gammas vs. E-est and Theta (%.1f < alpha < %.1f deg)", lo, up);306 307 // TCanvas *c = MakeDefCanvas("AlphaEnergyTheta", "2D histogram of gamma signal in energy and theta");308 TCanvas &c = *MakeDefCanvas("AlphaEnergyTheta", txt);309 310 c.Divide(2, 2);311 312 gROOT->SetSelectedPad(NULL);313 314 TH1 *h;315 316 c.cd(1);317 h = h2D->ProjectionX("Eest", -1, 9999, "E");318 h->SetTitle("Distribution of E-est [GeV]");319 h->SetXTitle("E-est [GeV] ");320 h->SetYTitle("Counts");321 322 h->Draw(opt);323 h->SetBit(kCanDelete);324 gPad->SetLogx();325 326 c.cd(2);327 h = h2D->ProjectionY("theta", -1, 9999, "E");328 h->SetTitle("Distribution of \\Theta [\\circ]");329 h->SetXTitle("\\Theta [\\circ]");330 h->SetYTitle("Counts");331 332 h->Draw(opt);333 h->SetBit(kCanDelete);334 335 c.cd(3);336 337 h2D->DrawCopy(opt);338 gPad->SetLogx();339 340 c.Modified();341 c.Update();342 343 return h2D;344 }345 346 347 348 349 350 351 352 353 354 355 356 -
trunk/MagicSoft/Mars/mhist/MHAlphaEnergyTheta.h
r1292 r1415 42 42 TObject *DrawClone(Option_t *option="") const; 43 43 44 void Subtract(const TH3D *h1, const TH3D *h2);45 void Subtract(const MHAlphaEnergyTheta *h1, const MHAlphaEnergyTheta *h2)46 {47 Subtract(h1->GetHist(), h2->GetHist());48 }49 50 TH2D *DrawAlphaProjection(Axis_t lo, Axis_t up, Option_t *opt="");51 TH2D *GetAlphaProjection(Axis_t lo, Axis_t up);52 53 44 ClassDef(MHAlphaEnergyTheta, 1) //3D-histogram in alpha, Energy and theta 54 45 }; -
trunk/MagicSoft/Mars/mhist/MHAlphaEnergyTime.cc
r1330 r1415 68 68 fHist.SetTitle("3D-plot of alpha, E-est, time"); 69 69 fHist.SetXTitle("\\alpha [\\circ]"); 70 fHist.SetYTitle("E _{est} [GeV]");70 fHist.SetYTitle("E-est [GeV] "); 71 71 fHist.SetZTitle("time [s]"); 72 72 } … … 81 81 if (!fEnergy) 82 82 { 83 *fLog << err << dbginf << "M EnergyEst not found... aborting." << endl;83 *fLog << err << dbginf << "MHAlphaEnergyTime : MEnergyEst not found... aborting." << endl; 84 84 return kFALSE; 85 85 } … … 88 88 if (!fTime) 89 89 { 90 *fLog << err << dbginf << "M Time not found... aborting." << endl;90 *fLog << err << dbginf << "MHAlphaEnergyTime : MTime not found... aborting." << endl; 91 91 return kFALSE; 92 92 } 93 93 94 94 MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE"); 95 MBinning* binsalpha = (MBinning*)plist->FindObject("BinningAlpha");95 MBinning* binsalphaflux = (MBinning*)plist->FindObject("BinningAlphaFlux"); 96 96 MBinning* binstime = (MBinning*)plist->FindObject("BinningTime"); 97 if (!binsenergy || !binsalpha || !binstime)97 if (!binsenergy || !binsalphaflux || !binstime) 98 98 { 99 *fLog << err << dbginf << " At least one MBinning not found... aborting." << endl;99 *fLog << err << dbginf << "MHAlphaEnergyTime : At least one MBinning not found... aborting." << endl; 100 100 return kFALSE; 101 101 } 102 102 103 SetBinning(&fHist, binsalpha , binsenergy, binstime);103 SetBinning(&fHist, binsalphaflux, binsenergy, binstime); 104 104 105 105 fHist.Sumw2(); … … 116 116 MHillasSrc &hil = *(MHillasSrc*)par; 117 117 118 fHist.Fill( hil.GetAlpha(), fEnergy->GetEnergy(), 0.0001*fTime->GetTimeLo());118 fHist.Fill(fabs(hil.GetAlpha()), fEnergy->GetEnergy(), 0.0001*fTime->GetTimeLo()); 119 119 return kTRUE; 120 120 } … … 147 147 148 148 h->SetTitle("Distribution of E-est [GeV]"); 149 h->SetXTitle("E _{est} [GeV]");149 h->SetXTitle("E-est [GeV] "); 150 150 h->SetYTitle("Counts"); 151 151 … … 226 226 } 227 227 228 // -------------------------------------------------------------------------- 229 // 230 // Calculate the histogram as the difference of two histograms : 231 // fHist(gamma) = h1(source) - h2(antisource) 232 // 233 void MHAlphaEnergyTime::Subtract(const TH3D *h1, const TH3D *h2) 234 { 235 // MH::SetBinning(&fHist, (TH1*)h1); 236 237 // fHist.Sumw2(); 238 fHist.Add((TH1*)h1, (TH1*)h2, 1, -1); // ROOT: FIXME! 239 } 240 241 // -------------------------------------------------------------------------- 242 // 243 // Integrate fHist(gamma) in the alpha range (lo, up) 244 // 245 TH2D *MHAlphaEnergyTime::GetAlphaProjection(Axis_t lo, Axis_t up) 246 { 247 if (up < lo) 228 229 // -------------------------------------------------------------------------- 230 // 231 // Integrate fHist (Alpha,E-est,Time) over the Time to get 232 // fAlphaEest(Alpha,E-est) 233 // 234 TH2D *MHAlphaEnergyTime::IntegrateTime(const char *title, Bool_t draw) 235 { 236 Int_t nzbins = fHist.GetNbinsZ(); 237 TAxis &axez = *fHist.GetZaxis(); 238 axez.SetRange(1,nzbins); 239 240 TH2D &fAlphaEest = *(TH2D *)fHist.Project3D("exy"); 241 242 fAlphaEest.SetTitle(title); 243 fAlphaEest.SetXTitle("E-est [GeV] "); 244 fAlphaEest.SetYTitle("\\alpha [ \\circ]"); 245 246 if (draw == kTRUE) 248 247 { 249 *fLog << err << fName << ": Alpha projection not possible: lo=" << lo << " up=" << up << endl; 250 return NULL; 248 TCanvas &c = *MakeDefCanvas(title, title); 249 250 gROOT->SetSelectedPad(NULL); 251 252 fAlphaEest.DrawCopy(); 253 gPad->SetLogx(); 254 255 c.Modified(); 256 c.Update(); 251 257 } 252 258 253 TAxis &axe = *fHist.GetXaxis();254 255 Int_t ilo = axe.FindFixBin(lo); 256 Int_t iup = axe.FindFixBin(up); 257 258 const Double_t epslo1 = lo-axe.GetBinLowEdge(ilo); 259 const Double_t epslo2 = axe.GetBinUpEdge(ilo)-lo; 260 261 const Double_t epsup1 = up-axe.GetBinLowEdge(iup); 262 const Double_t epsup2 = axe.GetBinUpEdge(iup)-up; 263 264 const Double_t epslo = epslo1<epslo2 ? epslo1 : epslo2;265 const Double_t epsup = epsup1<epsup2 ? epsup1 : epsup2;266 267 if (epslo1>epslo2)268 ilo++; 269 270 if (epsup1<epsup2)271 iup--;272 273 if ( epslo>0.01*axe.GetBinWidth(ilo) || epsup>0.01*axe.GetBinWidth(iup))259 return &fAlphaEest; 260 } 261 262 // -------------------------------------------------------------------------- 263 // 264 // Integrate fHist (Alpha,E-est,Time) over E-est to get 265 // fAlphaTime(Alpha,Time) 266 // 267 TH2D *MHAlphaEnergyTime::IntegrateEest(const char *title, Bool_t draw) 268 { 269 Int_t nybins = fHist.GetNbinsY(); 270 TAxis &axey = *fHist.GetYaxis(); 271 axey.SetRange(1,nybins); 272 273 TH2D &fAlphaTime = *(TH2D *)fHist.Project3D("exz"); 274 275 fAlphaTime.SetTitle(title); 276 fAlphaTime.SetXTitle("Time [s]"); 277 fAlphaTime.SetYTitle("\\alpha [ \\circ]"); 278 279 if (draw == kTRUE) 274 280 { 275 *fLog << err << fName << ": binning is not adequate for the requested projection:" << endl; 276 *fLog << "Please specify a lower or upper limit which is not more than 1% away from a bin edge" << endl; 277 *fLog << " epslo = " << epslo << endl; 278 *fLog << " epsup = " << epsup << endl; 279 *fLog << " dwl = " << axe.GetBinWidth(ilo) << endl; 280 *fLog << " dwu = " << axe.GetBinWidth(iup) << endl; 281 return NULL; 281 TCanvas &c = *MakeDefCanvas(title, title); 282 283 gROOT->SetSelectedPad(NULL); 284 285 fAlphaTime.DrawCopy(); 286 287 c.Modified(); 288 c.Update(); 282 289 } 283 290 284 axe.SetRange(ilo, iup); 285 286 TH2D &h2D = *(TH2D *)fHist.Project3D("ezy"); 287 288 h2D.SetTitle("2D-plot of time vs. E-est"); 289 h2D.SetXTitle("E-est [GeV] "); 290 h2D.SetYTitle("time [s]"); 291 292 return &h2D; 293 } 294 295 //--------------------------------------------------------- 296 // 297 // Draw the projected histogram 298 // 299 TH2D *MHAlphaEnergyTime::DrawAlphaProjection(Axis_t lo, Axis_t up, Option_t *opt) 300 { 301 TH2D *h2D = GetAlphaProjection(lo, up); 302 303 if (!h2D) 304 return NULL; 305 306 char txt[100]; 307 sprintf(txt, "No.of Gammas vs. E-est and Time (%.1f < alpha < %.1f deg)", lo, up); 308 309 // TCanvas *c = MakeDefCanvas("AlphaEnergyTime", "2D histogram of gamma signal in energy and time"); 310 TCanvas &c = *MakeDefCanvas("AlphaEnergyTime", txt); 311 312 c.Divide(2, 2); 313 314 gROOT->SetSelectedPad(NULL); 315 316 TH1 *h; 317 318 c.cd(1); 319 h = h2D->ProjectionX("Eest", -1, 9999, "E"); 320 h->SetTitle("Distribution of E-est [GeV]"); 321 h->SetXTitle("E-est [GeV] "); 322 h->SetYTitle("Counts"); 323 324 h->Draw(opt); 325 h->SetBit(kCanDelete); 326 gPad->SetLogx(); 327 328 c.cd(2); 329 h = h2D->ProjectionY("time", -1, 9999, "E"); 330 h->SetTitle("Distribution of time [s]"); 331 h->SetXTitle("time [s]"); 332 h->SetYTitle("Counts"); 333 334 h->Draw(opt); 335 h->SetBit(kCanDelete); 336 337 c.cd(3); 338 339 h2D->DrawCopy(opt); 340 gPad->SetLogx(); 341 342 c.Modified(); 343 c.Update(); 344 345 return h2D; 346 } 347 291 return &fAlphaTime; 292 } 293 294 // -------------------------------------------------------------------------- 295 // 296 // Integrate fHist (Alpha,E-est,Time) over Eest and Time to get 297 // fAlpha(Alpha) 298 // 299 TH1D *MHAlphaEnergyTime::IntegrateEestTime(const char *title, Bool_t draw) 300 { 301 Int_t nybins = fHist.GetNbinsY(); 302 TAxis &axey = *fHist.GetYaxis(); 303 axey.SetRange(1,nybins); 304 305 Int_t nzbins = fHist.GetNbinsZ(); 306 TAxis &axez = *fHist.GetZaxis(); 307 axez.SetRange(1,nzbins); 308 309 TH1D &fAlpha = *(TH1D *)fHist.Project3D("ex"); 310 311 fAlpha.SetTitle(title); 312 fAlpha.SetXTitle("\\alpha [ \\circ]"); 313 fAlpha.SetYTitle("Counts"); 314 315 if (draw == kTRUE) 316 { 317 TCanvas &c = *MakeDefCanvas(title, title); 318 319 gROOT->SetSelectedPad(NULL); 320 321 fAlpha.DrawCopy(); 322 323 c.Modified(); 324 c.Update(); 325 } 326 327 return &fAlpha; 328 } 329 330 331 332 333 334 335 -
trunk/MagicSoft/Mars/mhist/Makefile
r1336 r1415 44 44 MHAlphaEnergyTime.cc \ 45 45 MHAlphaEnergyTheta.cc \ 46 MHEffOnTimeTime.cc \ 47 MHEffOnTimeTheta.cc \ 46 MHEffOnTime.cc \ 48 47 MHTimeDiffTime.cc \ 49 48 MHTimeDiffTheta.cc \ … … 55 54 MHMcEfficiencyEnergy.cc \ 56 55 MHMcEnergyImpact.cc \ 56 MHMcRate.cc \ 57 MHThetabarTime.cc \ 58 MHThetabarTheta.cc \ 57 59 MHMcEnergyMigration.cc \ 58 MHThetabarTime.cc \ 59 MHMcRate.cc \ 60 MHMcIntRate.cc \ 61 MHMcDifRate.cc 62 60 MHGamma.cc \ 61 MHFlux.cc 62 63 63 64 64 SRCS = $(SRCFILES) … … 77 77 78 78 # @endcode 79 80 81 82 83 84 85 86 87 88
Note:
See TracChangeset
for help on using the changeset viewer.