Changeset 4920
- Timestamp:
- 09/10/04 14:06:46 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MTime.cc
r4889 r4920 570 570 } 571 571 572 void MTime::Plus1ns() 573 { 574 fNanoSec++; 575 576 if (fNanoSec<1000000) 577 return; 578 579 fNanoSec = 0; 580 fTime += 1; 581 582 if ((Long_t)fTime<(Long_t)kDay*13) 583 return; 584 585 fTime = 11*kDay; 586 fMjd++; 587 } 588 572 589 void MTime::Minus1ns() 573 590 { -
trunk/MagicSoft/Mars/mbase/MTime.h
r4889 r4920 128 128 void AddMilliSeconds(UInt_t ms); 129 129 void Minus1ns(); 130 void Plus1ns(); 130 131 void SetMean(const MTime &t0, const MTime &t1); 131 132 void SetMean(Double_t t0, Double_t t1); -
trunk/MagicSoft/Mars/mhbase/MBinning.cc
r4891 r4920 72 72 73 73 } 74 74 75 void MBinning::SetEdges(const TAxis &axe) 75 76 { 76 const TArrayD &arr = * ((TAxis&)axe).GetXbins();77 const TArrayD &arr = *axe.GetXbins(); 77 78 if (arr.GetSize()>0) 78 79 { … … 82 83 83 84 SetEdges(axe.GetNbins(), axe.GetXmin(), axe.GetXmax()); 85 } 86 87 void MBinning::AddEdge(Axis_t up) 88 { 89 const Int_t n = fEdges.GetSize(); 90 91 if (up<=fEdges[n-1]) 92 { 93 *fLog << warn << dbginf << "WARNING - New upper edge not greater than old upper edge... ignored." << endl; 94 return; 95 } 96 97 fEdges.Set(n+1); 98 fEdges[n] = up; 99 100 fType = kIsUserArray; 84 101 } 85 102 … … 111 128 void MBinning::SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up) 112 129 { 113 const Double_t binsize = (up-lo)/nbins;130 const Double_t binsize = nbins<=0 ? 0 : (up-lo)/nbins; 114 131 fEdges.Set(nbins+1); 115 132 for (int i=0; i<=nbins; i++) 116 133 fEdges[i] = binsize*i + lo; 117 134 118 135 fType = kIsLinear; -
trunk/MagicSoft/Mars/mhbase/MBinning.h
r4891 r4920 79 79 Double_t *GetEdges() const { return (Double_t*)fEdges.GetArray(); } 80 80 81 void AddEdge(Axis_t up); 82 81 83 Bool_t IsLinear() const { return fType==kIsLinear; } 82 84 Bool_t IsLogarithmic() const { return fType==kIsLogarithmic; } -
trunk/MagicSoft/Mars/mhist/HistLinkDef.h
r4841 r4920 15 15 #pragma link C++ class MHEnergyTime+; 16 16 #pragma link C++ class MHEnergyTheta+; 17 #pragma link C++ class MHEffectiveOnTime+; 17 18 #pragma link C++ class MHAlphaEnergyTime+; 18 19 #pragma link C++ class MHAlphaEnergyTheta+; -
trunk/MagicSoft/Mars/mhist/MHEffectiveOnTime.cc
r4906 r4920 63 63 // 64 64 MHEffectiveOnTime::MHEffectiveOnTime(const char *name, const char *title) 65 : fPointPos(0), fTime(0), fParam(0), fIsFinalized(kFALSE), fInterval(60), 66 fNameProjDeltaT(Form("DeltaT_%p", this)), fNameProjTheta(Form("Theta_%p", this)) 65 : fPointPos(0), fTime(0), fParam(0), fIsFinalized(kFALSE), 66 fNumEvents(200*60), fNameProjDeltaT(Form("DeltaT_%p", this)), 67 fNameProjTheta(Form("Theta_%p", this)) 67 68 { 68 69 // … … 73 74 74 75 // Main histogram 75 fHDeltaT.SetName("DeltaT"); 76 fHDeltaT.SetXTitle("\\Delta t [s]"); 77 fHDeltaT.SetYTitle("\\Theta [\\circ]"); 78 fHDeltaT.UseCurrentStyle(); 79 fHDeltaT.SetDirectory(NULL); 76 fH2DeltaT.SetName("DeltaT"); 77 fH2DeltaT.SetXTitle("\\Delta t [s]"); 78 fH2DeltaT.SetYTitle("\\Theta [\\circ]"); 79 fH2DeltaT.SetZTitle("Count"); 80 fH2DeltaT.UseCurrentStyle(); 81 fH2DeltaT.SetDirectory(NULL); 82 83 // Main histogram 84 fH1DeltaT.SetName("DeltaT"); 85 fH1DeltaT.SetXTitle("\\Delta t [s]"); 86 fH1DeltaT.SetYTitle("Counts"); 87 fH1DeltaT.UseCurrentStyle(); 88 fH1DeltaT.SetDirectory(NULL); 80 89 81 90 // effective on time versus theta 82 fHEffOnTheta.SetName("EffOnT ime");91 fHEffOnTheta.SetName("EffOnTheta"); 83 92 fHEffOnTheta.SetTitle("Effective On Time T_{eff}"); 84 93 fHEffOnTheta.SetXTitle("\\Theta [\\circ]"); … … 102 111 fHEffOnTime.Sumw2(); 103 112 104 // chi2/NDF versus theta105 fHChi2.SetName("Chi2/NDF");106 fHChi2.SetTitle("\\chi^{2}/NDF of Effective On Time Fit");107 fHChi2.SetXTitle("\\Theta [\\circ]");108 fHChi2.SetYTitle("\\chi^{2}/NDF");109 fHChi2.UseCurrentStyle();110 fHChi2.SetDirectory(NULL);111 fHChi2.GetYaxis()->SetTitleOffset(1.2);112 //fHChi2.Sumw2();113 114 113 // chi2 probability 115 fHProb.SetName("Prob"); 116 fHProb.SetTitle("\\chi^{2} Probability of Fit"); 117 fHProb.SetXTitle("\\Theta [\\circ]"); 118 fHProb.SetYTitle("p [%]"); 119 fHProb.UseCurrentStyle(); 120 fHProb.SetDirectory(NULL); 121 fHProb.GetYaxis()->SetTitleOffset(1.2); 122 fHProb.SetMaximum(101); 123 //fHChi2.Sumw2(); 114 fHProbTheta.SetName("ProbTheta"); 115 fHProbTheta.SetTitle("\\chi^{2} Probability of Fit"); 116 fHProbTheta.SetXTitle("\\Theta [\\circ]"); 117 fHProbTheta.SetYTitle("p [%]"); 118 fHProbTheta.UseCurrentStyle(); 119 fHProbTheta.SetDirectory(NULL); 120 fHProbTheta.GetYaxis()->SetTitleOffset(1.2); 121 fHProbTheta.SetMaximum(101); 122 123 // chi2 probability 124 fHProbTime.SetName("ProbTime"); 125 fHProbTime.SetTitle("\\chi^{2} Probability of Fit"); 126 fHProbTime.SetXTitle("Time"); 127 fHProbTime.SetYTitle("p [%]"); 128 fHProbTime.UseCurrentStyle(); 129 fHProbTime.SetDirectory(NULL); 130 fHProbTime.GetYaxis()->SetTitleOffset(1.2); 131 fHProbTime.GetXaxis()->SetLabelSize(0.033); 132 fHProbTime.GetXaxis()->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00 GMT"); 133 fHProbTime.GetXaxis()->SetTimeDisplay(1); 134 fHProbTime.SetMaximum(101); 124 135 125 136 // lambda versus theta … … 141 152 //fHN0del.Sumw2(); 142 153 154 // chi2/NDF versus theta 155 /* 156 fHChi2.SetName("Chi2/NDF"); 157 fHChi2.SetTitle("\\chi^{2}/NDF of Effective On Time Fit"); 158 fHChi2.SetXTitle("\\Theta [\\circ]"); 159 fHChi2.SetYTitle("\\chi^{2}/NDF"); 160 fHChi2.UseCurrentStyle(); 161 fHChi2.SetDirectory(NULL); 162 fHChi2.GetYaxis()->SetTitleOffset(1.2); 163 //fHChi2.Sumw2(); 164 */ 165 143 166 // setup binning 144 167 MBinning btheta("BinningTheta"); … … 148 171 btime.SetEdges(50, 0, 0.1); 149 172 150 MH::SetBinning(&fHDeltaT, &btime, &btheta); 173 MH::SetBinning(&fH2DeltaT, &btime, &btheta); 174 175 btime.Apply(fH1DeltaT); 151 176 152 177 btheta.Apply(fHEffOnTheta); 153 btheta.Apply(fHChi2);154 178 btheta.Apply(fHLambda); 155 179 btheta.Apply(fHN0); 156 btheta.Apply(fHProb); 180 btheta.Apply(fHProbTheta); 181 //btheta.Apply(fHChi2); 157 182 } 158 183 … … 180 205 const MBinning* binsdtime = (MBinning*)plist->FindObject("BinningDeltaT"); 181 206 const MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta"); 182 if ( !binstheta || !binsdtime)183 *fLog << warn << dbginf << "At least one MBinning not found... ignored." << endl;184 else207 if (binsdtime) 208 binsdtime->Apply(fH1DeltaT); 209 if (binstheta) 185 210 { 186 SetBinning(&fHDeltaT, binsdtime, binstheta);187 188 211 binstheta->Apply(fHEffOnTheta); 189 binstheta->Apply(fHChi2);190 212 binstheta->Apply(fHLambda); 191 213 binstheta->Apply(fHN0); 192 binstheta->Apply(fHProb); 214 binstheta->Apply(fHProbTheta); 215 //binstheta->Apply(fHChi2); 193 216 } 217 if (binstheta && binsdtime) 218 SetBinning(&fH2DeltaT, binsdtime, binstheta); 194 219 195 220 return kTRUE; 196 221 } 197 222 198 Bool_t MHEffectiveOnTime::Finalize() 199 { 200 FitThetaBins(); 201 Calc(); 202 203 fIsFinalized = kTRUE; 204 205 return kTRUE; 206 } 207 208 void MHEffectiveOnTime::FitThetaBins() 209 { 210 const TString name = Form("CalcTheta%d", (UInt_t)gRandom->Uniform(999999999)); 211 212 // nbins = number of Theta bins 213 const Int_t nbins = fHDeltaT.GetNbinsY(); 214 215 TH1D *h=0; 216 for (int i=1; i<=nbins; i++) 217 { 218 // TH1D &h = *hist->ProjectionX("Calc-theta", i, i); 219 h = fHDeltaT.ProjectionX(name, i, i, "E"); 220 221 Double_t res[7]; 222 if (!FitH(h, res)) 223 continue; 224 225 // the effective on time is Nm/lambda 226 fHEffOnTheta.SetBinContent(i, res[0]); 227 fHEffOnTheta.SetBinError (i, res[1]); 228 229 // plot chi2-probability of fit 230 fHProb.SetBinContent(i, res[2]); 231 232 // plot chi2/NDF of fit 233 fHChi2.SetBinContent(i, res[3]); 234 235 // lambda of fit 236 fHLambda.SetBinContent(i, res[4]); 237 fHLambda.SetBinError (i, res[5]); 238 239 // N0 of fit 240 fHN0.SetBinContent(i, res[6]); 241 242 // Rdead (from fit) is the fraction from real time lost by the dead time 243 //fHRdead.SetBinContent(i, Rdead); 244 //fHRdead.SetBinError (i,dRdead); 245 } 246 247 // Histogram is reused via gROOT->FindObject() 248 // Need to be deleted only once 249 if (h) 250 delete h; 251 } 252 253 Bool_t MHEffectiveOnTime::FitH(TH1D *h, Double_t *res) const 223 Bool_t MHEffectiveOnTime::FitH(TH1D *h, Double_t *res, Bool_t paint) const 254 224 { 255 225 const Double_t Nm = h->Integral(); … … 296 266 297 267 // was fit successful ? 298 if (NDF<=0 || chi2>=2.5*NDF) 268 const Bool_t ok = NDF>0 && chi2<2.5*NDF; 269 270 if (paint) 271 { 272 func.SetLineWidth(2); 273 func.SetLineColor(ok ? kGreen : kRed); 274 func.Paint("same"); 275 } 276 277 if (!ok) 299 278 return kFALSE; 300 279 … … 332 311 333 312 // plot chi2/NDF of fit 334 res[3] = NDF ? chi2/NDF : 0.0;313 //res[3] = NDF ? chi2/NDF : 0.0; 335 314 336 315 // lambda of fit 337 res[ 4] = lambda;338 res[ 5] = dl;316 res[3] = lambda; 317 res[4] = dl; 339 318 340 319 // N0 of fit 341 res[ 6] = N0;320 res[5] = N0; 342 321 343 322 // Rdead (from fit) is the fraction from real time lost by the dead time … … 348 327 } 349 328 329 void MHEffectiveOnTime::FitThetaBins() 330 { 331 const TString name = Form("CalcTheta%d", (UInt_t)gRandom->Uniform(999999999)); 332 333 // nbins = number of Theta bins 334 const Int_t nbins = fH2DeltaT.GetNbinsY(); 335 336 TH1D *h=0; 337 for (int i=1; i<=nbins; i++) 338 { 339 // TH1D &h = *hist->ProjectionX("Calc-theta", i, i); 340 h = fH2DeltaT.ProjectionX(name, i, i, "E"); 341 342 Double_t res[6]; 343 if (!FitH(h, res)) 344 continue; 345 346 // the effective on time is Nm/lambda 347 fHEffOnTheta.SetBinContent(i, res[0]); 348 fHEffOnTheta.SetBinError (i, res[1]); 349 350 // plot chi2-probability of fit 351 fHProbTheta.SetBinContent(i, res[2]); 352 353 // plot chi2/NDF of fit 354 //fHChi2.SetBinContent(i, res[3]); 355 356 // lambda of fit 357 fHLambda.SetBinContent(i, res[3]); 358 fHLambda.SetBinError (i, res[4]); 359 360 // N0 of fit 361 fHN0.SetBinContent(i, res[5]); 362 363 // Rdead (from fit) is the fraction from real time lost by the dead time 364 //fHRdead.SetBinContent(i, Rdead); 365 //fHRdead.SetBinError (i,dRdead); 366 } 367 368 // Histogram is reused via gROOT->FindObject() 369 // Need to be deleted only once 370 if (h) 371 delete h; 372 } 373 374 void MHEffectiveOnTime::FitTimeBin() 375 { 376 // 377 // Fit histogram 378 // 379 Double_t res[6]; 380 if (!FitH(&fH1DeltaT, res)) 381 return; 382 383 // Reset Histogram 384 fH1DeltaT.Reset(); 385 386 // 387 // Prepare Histogram 388 // 389 390 // Get x-axis 391 TAxis &x = *fHEffOnTime.GetXaxis(); 392 393 // Get number of bins 394 const Int_t n = x.GetNbins(); 395 396 // Enhance binning 397 MBinning bins; 398 bins.SetEdges(x); 399 bins.AddEdge(fLastTime.GetAxisTime()); 400 bins.Apply(fHEffOnTime); 401 bins.Apply(fHProbTime); 402 403 // 404 // Fill histogram 405 // 406 fHEffOnTime.SetBinContent(n, res[0]); 407 fHEffOnTime.SetBinError(n, res[1]); 408 409 fHProbTime.SetBinContent(n, res[2]); 410 411 // 412 // Now prepare output 413 // 414 fParam->SetVal(res[0], res[1]); 415 fParam->SetReadyToSave(); 416 417 *fTime = fLastTime; 418 419 // Include the current event 420 fTime->Plus1ns(); 421 422 *fLog << fLastTime << ": Val=" << res[0] << " Err=" << res[1] << endl; 423 } 424 425 // -------------------------------------------------------------------------- 426 // 427 // Fill the histogram 428 // 429 Bool_t MHEffectiveOnTime::Fill(const MParContainer *par, const Stat_t w) 430 { 431 const MTime *time = dynamic_cast<const MTime*>(par); 432 if (!time) 433 { 434 *fLog << err << "ERROR - MHEffectiveOnTime::Fill without argument or container doesn't inherit from MTime... abort." << endl; 435 return kFALSE; 436 } 437 438 if (fLastTime==MTime()) 439 { 440 MBinning bins; 441 bins.SetEdges(2, time->GetAxisTime()-fNumEvents/200, time->GetAxisTime()); 442 bins.Apply(fHEffOnTime); 443 bins.Apply(fHProbTime); 444 445 fParam->SetVal(0, 0); 446 fParam->SetReadyToSave(); 447 448 *fTime = *time; 449 450 // Make this 1ns before the first event! 451 fTime->Minus1ns(); 452 } 453 454 const Double_t dt = *time-fLastTime; 455 456 fH2DeltaT.Fill(dt, fPointPos->GetZd(), w); 457 fH1DeltaT.Fill(dt, w); 458 459 fLastTime = *time; 460 461 if (fH1DeltaT.GetEntries()>=fNumEvents) 462 FitTimeBin(); 463 464 return kTRUE; 465 } 466 467 Bool_t MHEffectiveOnTime::Finalize() 468 { 469 FitThetaBins(); 470 FitTimeBin(); 471 472 fIsFinalized = kTRUE; 473 474 return kTRUE; 475 } 476 477 void MHEffectiveOnTime::PaintText(Double_t val, Double_t error) const 478 { 479 TLatex text(0.45, 0.94, Form("T_{eff} = %.1fs \\pm %.1fs", val, error)); 480 text.SetBit(TLatex::kTextNDC); 481 text.SetTextSize(0.04); 482 text.Paint(); 483 } 484 350 485 void MHEffectiveOnTime::Paint(Option_t *opt) 351 486 { 352 T VirtualPad *padsave = gPad;487 TH1D *h=0; 353 488 354 489 TString o(opt); 355 490 if (o==(TString)"fit") 356 491 { 357 T H1D *h0=0;358 359 pad save->GetPad(1)->cd(1);360 if ((h 0= (TH1D*)gPad->FindObject(fNameProjDeltaT)))492 TVirtualPad *pad = gPad; 493 494 pad->GetPad(1)->cd(1); 495 if ((h = (TH1D*)gPad->FindObject(fNameProjDeltaT))) 361 496 { 362 h 0 = fHDeltaT.ProjectionX(fNameProjDeltaT, -1, 9999, "E");363 if (h 0->GetEntries()>0)497 h = fH2DeltaT.ProjectionX(fNameProjDeltaT, -1, 9999, "E"); 498 if (h->GetEntries()>0) 364 499 gPad->SetLogy(); 365 500 } 366 501 367 pad save->GetPad(2)->cd(1);368 if ((h 0= (TH1D*)gPad->FindObject(fNameProjTheta)))369 fH DeltaT.ProjectionY(fNameProjTheta, -1, 9999, "E");502 pad->GetPad(2)->cd(1); 503 if ((h = (TH1D*)gPad->FindObject(fNameProjTheta))) 504 fH2DeltaT.ProjectionY(fNameProjTheta, -1, 9999, "E"); 370 505 371 506 if (!fIsFinalized) 372 507 FitThetaBins(); 508 return; 373 509 } 374 375 TH1D *h=0; 510 if (o==(TString)"paint") 511 { 512 if ((h = (TH1D*)gPad->FindObject(fNameProjDeltaT))) 513 { 514 Double_t res[6]; 515 if (FitH(h, res, kTRUE)) 516 PaintText(res[0], res[1]); 517 } 518 return; 519 } 520 521 h=0; 376 522 if (o==(TString)"theta") 377 523 h = &fHEffOnTheta; … … 379 525 h = &fHEffOnTime; 380 526 381 if (h) 382 { 383 Double_t error = 0; 384 for (int i=0; i<h->GetXaxis()->GetNbins(); i++) 385 error += h->GetBinError(i); 386 387 TLatex text(0.45, 0.94, Form("T_{eff} = %.1fs \\pm %.1fs", h->Integral(), error)); 388 text.SetBit(TLatex::kTextNDC); 389 text.SetTextSize(0.04); 390 text.Paint(); 391 } 392 gPad = padsave; 527 if (!h) 528 return; 529 530 Double_t error = 0; 531 for (int i=0; i<h->GetXaxis()->GetNbins(); i++) 532 error += h->GetBinError(i); 533 534 PaintText(h->Integral(), error); 393 535 } 394 536 … … 410 552 pad->cd(1); 411 553 gPad->SetBorderMode(0); 412 gPad->Divide(1, 2, 0, 0);554 gPad->Divide(1, 3, 0, 0); 413 555 pad->GetPad(1)->cd(1); 414 556 gPad->SetBorderMode(0); 415 h = fH DeltaT.ProjectionX(fNameProjDeltaT, -1, 9999, "E");557 h = fH2DeltaT.ProjectionX(fNameProjDeltaT, -1, 9999, "E"); 416 558 h->SetTitle("Distribution of \\Delta t [s]"); 417 559 h->SetXTitle("\\Delta t [s]"); … … 421 563 h->SetBit(kCanDelete); 422 564 h->Draw(); 565 AppendPad("paint"); 423 566 424 567 pad->GetPad(1)->cd(2); 568 gPad->SetBorderMode(0); 569 fHProbTime.Draw(); 570 571 pad->GetPad(1)->cd(3); 425 572 gPad->SetBorderMode(0); 426 573 fHEffOnTime.Draw(); … … 433 580 pad->GetPad(2)->cd(1); 434 581 gPad->SetBorderMode(0); 435 h = fH DeltaT.ProjectionY(fNameProjTheta, -1, 9999, "E");582 h = fH2DeltaT.ProjectionY(fNameProjTheta, -1, 9999, "E"); 436 583 h->SetTitle("Distribution of \\Theta [\\circ]"); 437 584 h->SetXTitle("\\Theta [\\circ]"); … … 445 592 pad->GetPad(2)->cd(2); 446 593 gPad->SetBorderMode(0); 447 fHProb .Draw();594 fHProbTheta.Draw(); 448 595 449 596 pad->GetPad(2)->cd(3); … … 452 599 AppendPad("theta"); 453 600 } 454 455 void MHEffectiveOnTime::FillTimeBin(Double_t val, Double_t err)456 {457 // Get x-axis458 TAxis &x = *fHEffOnTime.GetXaxis();459 460 // Get number of bins461 const Int_t n = x.GetNbins();462 463 // Fill last bin with new values464 fHEffOnTime.SetBinContent(n, fParam->GetVal());465 fHEffOnTime.SetBinError(n, fParam->GetErr());466 467 // Get time range of histogram, get bin width468 const Double_t lo = fHEffOnTime.GetXaxis()->GetXmin();469 const Double_t up = fHEffOnTime.GetXaxis()->GetXmax();470 const Double_t w = fHEffOnTime.GetXaxis()->GetBinWidth(1);471 472 // Enhance histogram by one bin473 MBinning bins;474 bins.SetEdges(n+2, lo, up+w);475 bins.Apply(fHEffOnTime);476 477 // Transform overflow bin478 // fHEffOnTime.SetBinContent(n+2, fHEffOnTime.GetBinContent(n+1));479 // fHEffOnTime.SetBinError(n+2, fHEffOnTime.GetBinError(n+1));480 }481 482 void MHEffectiveOnTime::Calc()483 {484 TH1D *h = fHDeltaT.ProjectionX("", -1, 99999, "E");485 h->SetDirectory(0);486 487 Double_t res[7];488 Bool_t rc = FitH(h, res);489 delete h;490 491 if (!rc)492 return;493 494 const Double_t val = res[0];495 const Double_t error = res[1];496 497 fParam->SetVal(val>fEffOnTime0?val-fEffOnTime0:0, error-fEffOnErr0);498 fParam->SetReadyToSave();499 500 FillTimeBin(fParam->GetVal(), fParam->GetErr());501 502 fEffOnTime0 = val;503 fEffOnErr0 = error;504 505 MTime now(*fTime);506 now.AddMilliSeconds(fInterval*1000);507 508 *fLog <<all << now << " - ";// << fLastTime-fTime;509 *fLog << Form("T_{eff} = %.1fs \\pm %.1fs",510 fParam->GetVal(), fParam->GetErr());511 *fLog << Form(" %.1f %.1f",512 val, error) << endl;513 514 fTime->AddMilliSeconds(fInterval*1000);515 }516 517 // --------------------------------------------------------------------------518 //519 // Fill the histogram520 //521 Bool_t MHEffectiveOnTime::Fill(const MParContainer *par, const Stat_t w)522 {523 const MTime *time = dynamic_cast<const MTime*>(par);524 if (!time)525 {526 *fLog << err << "ERROR - MHEffectiveOnTime::Fill without argument or container doesn't inherit from MTime... abort." << endl;527 return kFALSE;528 }529 530 if (*fTime==MTime())531 {532 *fLog << all << *time << " - " << *fTime << " " << TMath::Floor(*time) << endl;533 fEffOnTime0 = 0;534 fEffOnErr0 = 0;535 536 fParam->SetVal(0, 0);537 fParam->SetReadyToSave();538 539 *fTime = *time;540 541 MBinning bins;542 bins.SetEdges(2, fTime->GetAxisTime(), fTime->GetAxisTime()+fInterval);543 bins.Apply(fHEffOnTime);544 545 // Make this just a ns before the first event546 fTime->Minus1ns();547 }548 549 if (*fTime+fInterval<*time)550 {551 FitThetaBins();552 Calc();553 }554 555 fHDeltaT.Fill(*time-fLastTime, fPointPos->GetZd(), w);556 fLastTime = *time;557 558 return kTRUE;559 }560 -
trunk/MagicSoft/Mars/mhist/MHEffectiveOnTime.h
r4907 r4920 27 27 MTime fLastTime; //! 28 28 29 Double_t fEffOnTime0; //!30 Double_t fEffOnErr0; //!31 32 29 MTime *fTime; //! 33 30 MParameterDerr *fParam; //! 34 31 35 TH2D fHDeltaT; 36 TH1D fHEffOnTheta; 37 TH1D fHEffOnTime; 38 TH1D fHChi2; 39 TH1D fHProb; 32 TH2D fH2DeltaT; // Counts vs Delta T and Theta 33 TH1D fH1DeltaT; //! Counts vs Delta T (for a time interval) 34 35 TH1D fHEffOnTheta; // Effective On time versus Theta 36 TH1D fHEffOnTime; // Effective On time versus Time 37 38 TH1D fHProbTheta; // Chisq prob fit of Effective On time versus Theta 39 TH1D fHProbTime; // Chisq prob fit of Effective On time versus Time 40 40 41 TH1D fHN0; 41 42 TH1D fHLambda; … … 43 44 Bool_t fIsFinalized; 44 45 45 Int_t f Interval;46 Int_t fNumEvents; 46 47 47 48 const TString fNameProjDeltaT; //! This should make sure, that gROOT doen't confuse the projection with something else 48 49 const TString fNameProjTheta; //! This should make sure, that gROOT doen't confuse the projection with something else 49 50 50 Bool_t FitH(TH1D *h, Double_t *res ) const;51 Bool_t FitH(TH1D *h, Double_t *res, Bool_t paint=kFALSE) const; 51 52 void FitThetaBins(); 52 void Fi llTimeBin(Double_t val, Double_t err);53 void Calc();53 void FitTimeBin(); 54 void PaintText(Double_t val, Double_t error) const; 54 55 55 56 public: 56 57 MHEffectiveOnTime(const char *name=NULL, const char *title=NULL); 57 58 58 void Set Interval(Int_t i) { fInterval=i; }59 void SetNumEvents(Int_t i) { fNumEvents=i; } 59 60 60 61 Bool_t SetupFill(const MParList *pList); 61 62 Bool_t Fill(const MParContainer *par, const Stat_t w=1); 62 63 Bool_t Finalize(); 63 64 const TH2D *GetHist() { return &fHDeltaT; }65 const TH2D *GetHist() const { return &fHDeltaT; }66 64 67 65 void Draw(Option_t *option=""); -
trunk/MagicSoft/Mars/mhist/Makefile
r4841 r4920 22 22 -I../mgui -I../mgeom -I../mdata -I../mfilter -I../mimage \ 23 23 -I../mmain -I../mmc -I../mreflector -I../mpointing \ 24 -I../mastro -I../mpedestal -I../m badpixels24 -I../mastro -I../mpedestal -I../msignal -I../mbadpixels 25 25 26 26 SRCFILES = MHEvent.cc \ … … 28 28 MHCamEvent.cc \ 29 29 MHCamEventRot.cc \ 30 MHEffectiveOnTime.cc \ 30 31 MHFadcPix.cc \ 31 32 MHFadcCam.cc \ -
trunk/MagicSoft/Mars/mjobs/MJStar.cc
r4906 r4920 188 188 plist.AddToList(&b1); 189 189 190 MHVsTime h2("MEffectiveOnTime.fVal", "MEffectiveOnTime.fErr");191 h2.SetTitle("Effective On-Time T_{eff} vs. Time;;T_{eff}");192 193 190 MFillH fill0(&evt0, "MCerPhotEvt", "FillCerPhotEvt"); 194 191 MFillH fill1("MHHillas", "MHillas", "FillHillas"); … … 201 198 MFillH fill8(&h1, "", "FillEventRate"); 202 199 MFillH fill9("MHEffectiveOnTime", "MTime", "FillEffOnTime"); 203 MFillH filla(&h2, "MTimeEffectiveOnTime", "FillEffOnTimeVsTime");204 200 //MFillH fillb(&h12, "", "FillEvtRate2"); 205 201 //MFillH fill9("MHCerPhot"); … … 258 254 tlist2.AddToList(&fill8); 259 255 tlist2.AddToList(&fill9); 260 tlist2.AddToList(&filla);261 256 } 262 257 //tlist2.AddToList(&fillb); -
trunk/MagicSoft/Mars/mjobs/MSequence.cc
r4801 r4920 158 158 iter.AddDirectory(d, n, 0); 159 159 } 160 160 161 return iter.GetNumEntries(); 161 162 }
Note:
See TracChangeset
for help on using the changeset viewer.