Changeset 14062 for fact/tools/rootmacros/PulseTemplates
- Timestamp:
- 06/04/12 18:51:02 (12 years ago)
- Location:
- fact/tools/rootmacros/PulseTemplates
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/PulseTemplates/templateextractors.C
r13854 r14062 429 429 return 0; 430 430 } 431 432 void 433 FitMaxPropabilityPuls( 434 TH1F* hMaximumTemp, 435 int verbosityLevel 436 ) 437 { 438 if (verbosityLevel > 2) cout << "...fit Landau in histograms" ; 439 if (verbosityLevel > 2) cout << "\t...calculating Landaufit" ; 440 hMaximumTemp->Fit("landau", "", "", -50, 250); 441 if (verbosityLevel > 2) cout << "...done" << endl; 442 } 443 444 void 445 FitFallingEdge( 446 TString name, 447 TH1F* histo, 448 double xMin, 449 double xMax, 450 double* parameters 451 ) 452 { 453 TF1* polExpFit = new TF1(name, PolExp, xMin, xMax, 3 ); 454 polExpFit->SetParNames("Pol0", "Slope", "Shift"); 455 polExpFit->SetLineColor(kRed); 456 histo->Fit(polExpFit, "RWM"); 457 polExpFit->GetParameters(parameters); 458 } 459 460 void 461 FitRisingEdge( 462 TString name, 463 TH1F* histo, 464 double xMin, 465 double xMax, 466 double* parameters 467 ) 468 { 469 TF1* polExpFit = new TF1(name, NegPolExp, xMin, xMax, 3 ); 470 polExpFit->SetParNames("Pol0", "Slope", "Shift"); 471 polExpFit->SetLineColor(kRed); 472 histo->Fit(polExpFit, "RWM"); 473 polExpFit->GetParameters(parameters); 474 } 475 476 double 477 NegPolExp( 478 double* x, 479 double* par 480 ) 481 { 482 return par[0]+(-1)*TMath::Exp(par[1]+par[2]*x[0]); 483 } 484 485 double 486 PolExp( 487 double* x, 488 double* par 489 ) 490 { 491 return par[0]+TMath::Exp(par[1]+par[2]*x[0]); 492 } 493 494 double 495 ChargeDiode( 496 double* time, 497 double* chargeVoltage, 498 double* impedance, 499 double* capacity, 500 ) 501 { 502 return chargeVoltage*(1 - TMath::Exp(time/(impedance*capacity))); 503 } 504 505 double 506 UnChargeDiode( 507 double* time, 508 double* chargeVoltage, 509 double* impedance, 510 double* capacity, 511 ) 512 { 513 return chargeVoltage*(TMath::Exp(time/(impedance*capacity))); 514 } 515 516 double 517 template_function( 518 double* input_x, 519 double* par) 520 { 521 double returnval = 0.0; 522 523 // I introduce a few names 524 // double shift = par[0]; 525 double bsl = par[0]; 526 double beginOfRisingEdge = par[1]; 527 double p0RisingEdge = par[6]; 528 double p1RisingEdge = par[7]; 529 double p2RisingEdge = par[8]; 530 double p3RisingEdge = par[9]; 531 double endOfRisingEdge = par[2]; 532 // double pOFallingEdge = par[3]; 533 // double expPar1FallingEdge = par[4]; 534 // double expPar1FallingEdge = par[5]; 535 /* 536 bool couted_once = false; 537 if not couted_once 538 { 539 couted_once = true; 540 cout << "shift:" << shift << endl; 541 cout << "bsl:" << bsl << endl; 542 cout << "expars:" << endl; 543 cout << "\t factor:" << exppar[0] << endl; 544 cout << "\t tau:" << exppar[1] << endl; 545 cout << "\t t0:" << exppar[2] << endl; 546 cout << "pol3pars:" << endl; 547 cout << "p[0] + x p[1] + x^2 p[2] + x^3 p[3]" << endl; 548 cout << pol3par[0] << "\t" << pol3par[1] << "\t" << pol3par[2] << "\t" << pol3par[3] << endl; 549 cout << "ranges:" << endl; 550 cout << "begin of pol3: " << range[0] << endl; 551 cout << "begin of exp: " << range[1] << endl; 552 } 553 */ 554 double x = input_x[0]; 555 556 // the baseline is added everywhere. 557 returnval += bsl; 558 559 if ( (x > beginOfRisingEdge) && (x <= endOfRisingEdge) ) 560 { 561 // from this point on the pol3 is added 562 returnval += p0RisingEdge; 563 returnval += p1RisingEdge * x; 564 returnval += p2RisingEdge * x*x; 565 returnval += p3RisingEdge * x*x*x; 566 } 567 else if ( x > endOfRisingEdge ) 568 { 569 // from this point on the exp-func is added 570 // returnval += exppar[0] * TMath::Exp( exppar[1] * ( x - exppar[2] ) ); 571 returnval += PolExp(input_x, par+3); 572 } 573 574 return returnval; 575 } -
fact/tools/rootmacros/PulseTemplates/templateextractors.h
r13786 r14062 8 8 #include <TH1I.h> 9 9 #include <TH1F.h> 10 #include <TF1.h> 10 11 #include <TString.h> 11 12 #include <TSystem.h> … … 87 88 ); 88 89 90 void 91 FitMaxPropabilityPuls( 92 TH1F* hMaximumTemp, 93 int verbosityLevel 94 ); 95 96 double 97 PolExp( 98 double* x, 99 double* par 100 ); 101 102 void 103 FitFallingEdge( 104 TString name, 105 TH1F* histo, 106 double xMin, 107 double xMax, 108 double* parameters 109 ); 110 111 double 112 template_function( 113 double* input_x, 114 double* par); 115 116 double 117 NegPolExp( 118 double* x, 119 double* par 120 ); 121 122 void 123 FitRisingEdge( 124 TString name, 125 TH1F* histo, 126 double xMin, 127 double xMax, 128 double* parameters 129 ); 130 131 double 132 ChargeDiode( 133 double* time, 134 double* chargeVoltage, 135 double* impedance, 136 double* capacity, 137 ); 138 139 double 140 UnChargeDiode( 141 double* time, 142 double* chargeVoltage, 143 double* impedance, 144 double* capacity, 145 ); 146 147 89 148 #endif // TEMPLATEEXTRACTORS_H 90 149
Note:
See TracChangeset
for help on using the changeset viewer.