Changeset 14749 for fact/tools/rootmacros/PulseTemplates
- Timestamp:
- 12/13/12 18:22:31 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/PulseTemplates/FCalcPulseTemplate.C
r14064 r14749 37 37 38 38 //---------------------------------------------------------------------------- 39 // rootmacros39 // Classes 40 40 //---------------------------------------------------------------------------- 41 41 #include "rootfilehandler.h" 42 42 #include "pixel.h" 43 43 #include "pixelsum.h" 44 #include "pulse.h" 44 45 #include "templateextractors.h" 45 46 #include "configfile.h" 47 #include "csv.h" 46 48 47 49 //---------------------------------------------------------------------------- … … 87 89 //---------------------------------------------------------------------------- 88 90 int FCalcPulseTemplate( 89 TString InRootFileName = "20120309_01 8.root",90 TString InputPath = "analysis/ FPulseTemplate/20120309_018/Overlay/",91 TString InRootFileName = "20120309_017.root", 92 TString InputPath = "analysis/analysis/FPulseTemplate/20120309_017/Overlay/", 91 93 TString OutputRootFileName = "test.root", 92 TString OutPutPath = "analysis/FPulseTemplate/20120309_01 8/",94 TString OutPutPath = "analysis/FPulseTemplate/20120309_017/", 93 95 int firstpixel = 0, 94 int npixel = -1,96 int npixel = 1, 95 97 int pixelSetSize = 200, 96 98 int maxPulseOrder = 1, … … 102 104 bool debugPixel = true, 103 105 // int refresh_rate = 500, //refresh rate for canvases 104 int verbosityLevel = 2// different verbosity levels can be implemented here106 int verbosityLevel = 4 // different verbosity levels can be implemented here 105 107 ) 106 108 { … … 230 232 231 233 cgpPixelPulses[pulse_order] 232 = new TCanvas(cName,cTitle, 0,pulse_order*20, 1400,1400);234 = new TCanvas(cName,cTitle, 0,pulse_order*20,800,800); 233 235 cgpPixelPulses[pulse_order]->Divide(4, 2); 234 236 } … … 263 265 bool first_pass = true; 264 266 267 //---------------------------------------------------------------------------- 268 // Initialize Outputfiles 269 //---------------------------------------------------------------------------- 270 271 Csv PixelCsv(OutPutPath, InRootFileName.Remove(12, 5), "SPn", verbosityLevel); 272 PixelCsv.WritePointSetHeader(); 273 Csv PixelModelCsv(OutPutPath, InRootFileName.Remove(12, 5), "SPModeln", verbosityLevel); 274 PixelModelCsv.WritePulseAttributesHeader(); 275 // Csv AllPixelCsv(OutPutPath, InRootFileName.Remove(12, 5), -1, verbosityLevel); 276 // Csv AllPixelModelCsv(OutPutPath, InRootFileName.Remove(12, 5), "AllPixelModel", verbosityLevel); 277 278 TCanvas pulses("Templates","Templates", 0,0,1200,600); 279 pulses.Divide(3,1); 265 280 //------------------------------------- 266 281 // Loop over Pixel Sets … … 411 426 ); 412 427 428 PixelCsv.WritePointSet( 429 pixel[pixelID], 430 "Maximum", 431 pulse_order 432 ); 433 434 PixelCsv.WritePointSet( 435 pixel[pixelID], 436 "Edge", 437 pulse_order 438 ); 439 413 440 if ( saveResults ) 414 441 { … … 436 463 300 437 464 ); 465 pixel[pixelID]->hPixelEdgeMean[pulse_order]->GetXaxis()->SetLimits( 466 0, 467 300 468 ); 469 pixel[pixelID]->hPixelEdgeMedian[pulse_order]->GetXaxis()->SetLimits( 470 0, 471 300 472 ); 473 pixel[pixelID]->hPixelMax[pulse_order]->GetXaxis()->SetLimits( 474 0, 475 300 476 ); 477 pixel[pixelID]->hPixelMean[pulse_order]->GetXaxis()->SetLimits( 478 0, 479 300 480 ); 481 pixel[pixelID]->hPixelMedian[pulse_order]->GetXaxis()->SetLimits( 482 0, 483 300 484 ); 485 486 pixel[pixelID]->hEdgeProfile[pulse_order]->GetXaxis()->SetLimits( 487 0, 488 300 489 ); 490 491 492 493 438 494 // pixel[pixelID]->ShiftHistoInY( 439 495 // pixel[pixelID]->hPixelEdgeMax[pulse_order], 440 // 2496 // 0.25 441 497 // ); 442 498 … … 458 514 //------------------------------------- 459 515 460 cgpPixelPulses[pulse_order]->cd(6); 461 462 double fit_parameters[3]; 463 FitFallingEdge( 464 "hugo1", 465 pixel[pixelID]->hPixelEdgeMax[pulse_order], 466 pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetMaximumBin(), 467 pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetXaxis()->GetLast(), 468 fit_parameters 469 ); 470 cout << "Parameters\t" << fit_parameters[0] << "\n" 471 << fit_parameters[1] << "\n" 472 << fit_parameters[2] << "\n" << endl; 516 517 // cgpPixelPulses[pulse_order]->cd(6); 518 519 pulses.cd(1); 520 Pulse pulse("EdgeMaxPulse", pixel[pixelID]->hPixelEdgeMax[pulse_order], 1); 521 // pixel[pixelID]->hPixelEdgeMax[pulse_order]->DrawCopy(); 522 pulses.cd(2); 523 Pulse pulse1("EdgeMedianPulse", pixel[pixelID]->hPixelEdgeMedian[pulse_order], 1); 524 pulses.cd(3); 525 Pulse pulse2("EdgeMeanPulse", pixel[pixelID]->hPixelEdgeMean[pulse_order], 1); 526 527 PixelModelCsv.WritePulseAttributes( 528 pixel[pixelID], 529 &pulse, 530 "2", 531 pulse_order 532 ); 533 534 PixelModelCsv.WritePulseAttributes( 535 pixel[pixelID], 536 &pulse1, 537 "2", 538 pulse_order 539 ); 540 541 cgpPixelPulses[pulse_order]->cd(8); 542 543 // pixel[pixelID]->hEdgeProfile[pulse_order]->SetLineColor(kBlack); 544 // Pulse pulseMean("PulseMean", pixel[pixelID]->hEdgeProfile[pulse_order], 0); 545 546 547 548 549 // double fit_parameters5[3]; 550 // fit_parameters5[0] = fit_parameters[0]; 551 // fit_parameters5[0] = fit_parameters[0]; 552 // FitPulse( 553 // "hugo3", 554 // pixel[pixelID]->hPixelEdgeMax[pulse_order], 555 // pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetMaximumBin()-12, 556 // pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetMaximumBin(), 557 // fit_parameters5 558 // ); 559 // cout << "Parameters\t" << fit_parameters[0] << "\n" 560 // << fit_parameters[1] << "\n" 561 // << fit_parameters[2] << "\n" << endl; 473 562 474 563 // TF1 *func = new TF1("func", template_function, 0, 300, 10); … … 489 578 // pixel[pixelID]->hPixelEdgeMax[pulse_order]->Fit(func); 490 579 491 TH1F* hTest = new TH1F(492 "hTest",493 "Test",494 pixel[pixelID]->mPixelOverlayXaxisLeft495 + pixel[pixelID]->mPixelOverlayXaxisRight ,496 (-1*pixel[pixelID]->mPixelOverlayXaxisLeft)-0.5,497 pixel[pixelID]->mPixelOverlayXaxisRight-0.5498 );499 500 hTest->GetXaxis()->SetLimits(501 0,502 300503 );504 505 for (int bin = 0;506 bin < pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetXaxis()->GetLast();507 bin++508 )509 {510 hTest->SetBinContent( bin, (-1)*(fit_parameters[0]+TMath::Exp(fit_parameters[1]+fit_parameters[2]*(bin))) );511 }512 513 hTest->Add(pixel[pixelID]->hPixelEdgeMax[pulse_order], 1);514 515 cgpPixelPulses[pulse_order]->cd(7);516 hTest->Draw();517 518 for (int bin = 0;519 bin < pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetXaxis()->GetLast();520 bin++521 )522 {523 hTest->SetBinContent( bin, (-1)*(hTest->GetBinContent(bin)) );524 }525 526 // pixel[pixelID]->hPixelEdgeMax[pulse_order]->Fit(func); 527 528 double fit_parameters2[3]; 529 FitFallingEdge( 530 "hugo2",531 hTest,532 hTest->GetXaxis()->GetFirst()+68,533 hTest->GetXaxis()->GetFirst()+80, 534 fit_parameters2 535 ); 536 537 cgpPixelPulses[pulse_order]->cd(8); 538 539 TH1F* hTest2 = new TH1F( 540 "hTest2",541 "Test", 542 pixel[pixelID]->mPixelOverlayXaxisLeft 543 + pixel[pixelID]->mPixelOverlayXaxisRight,544 (-1*pixel[pixelID]->mPixelOverlayXaxisLeft)-0.5, 545 pixel[pixelID]->mPixelOverlayXaxisRight-0.5 546 ); 547 548 hTest2->GetXaxis()->SetLimits( 549 0, 550 300 551 ); 552 553 for (int bin = 0;554 bin < pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetXaxis()->GetLast(); 555 bin++ 556 ) 557 { 558 hTest2->SetBinContent( bin, (-1)*(hTest->GetBinContent(bin)) ); 559 } 560 561 double fit_parameters3[3]; 562 FitRisingEdge( 563 "hugo3",564 hTest2,565 hTest2->GetXaxis()->GetFirst()+68,566 hTest2->GetXaxis()->GetFirst()+80, 567 fit_parameters3 568 ); 569 570 hTest2->Draw();580 // TH1F* hTest = new TH1F( 581 // "hTest", 582 // "Test", 583 // pixel[pixelID]->mPixelOverlayXaxisLeft 584 // + pixel[pixelID]->mPixelOverlayXaxisRight , 585 // (-1*pixel[pixelID]->mPixelOverlayXaxisLeft)-0.5, 586 // pixel[pixelID]->mPixelOverlayXaxisRight-0.5 587 // ); 588 589 // hTest->GetXaxis()->SetLimits( 590 // 0, 591 // 300 592 // ); 593 594 // for (int bin = 0; 595 // bin < pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetXaxis()->GetLast(); 596 // bin++ 597 // ) 598 // { 599 // hTest->SetBinContent( bin, (-1)*(fit_parameters[0]+TMath::Exp(fit_parameters[1]+fit_parameters[2]*(bin))) ); 600 // } 601 602 // hTest->Add(pixel[pixelID]->hPixelEdgeMax[pulse_order], 1); 603 604 // cgpPixelPulses[pulse_order]->cd(7); 605 // hTest->Draw(); 606 607 // for (int bin = 0; 608 // bin < pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetXaxis()->GetLast(); 609 // bin++ 610 // ) 611 // { 612 // hTest->SetBinContent( bin, (-1)*(hTest->GetBinContent(bin)) ); 613 // } 614 615 616 // double fit_parameters2[3]; 617 // FitFallingEdge( 618 // "hugo2", 619 // hTest, 620 // hTest->GetXaxis()->GetFirst()+68, 621 // hTest->GetXaxis()->GetFirst()+80, 622 // fit_parameters2 623 // ); 624 625 // cgpPixelPulses[pulse_order]->cd(8); 626 627 // TH1F* hTest2 = new TH1F( 628 // "hTest2", 629 // "Test", 630 // pixel[pixelID]->mPixelOverlayXaxisLeft 631 // + pixel[pixelID]->mPixelOverlayXaxisRight , 632 // (-1*pixel[pixelID]->mPixelOverlayXaxisLeft)-0.5, 633 // pixel[pixelID]->mPixelOverlayXaxisRight-0.5 634 // ); 635 636 // hTest2->GetXaxis()->SetLimits( 637 // 0, 638 // 300 639 // ); 640 641 // for (int bin = 0; 642 // bin < pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetXaxis()->GetLast(); 643 // bin++ 644 // ) 645 // { 646 // hTest2->SetBinContent( bin, (-1)*(hTest->GetBinContent(bin)) ); 647 // } 648 649 // double fit_parameters3[3]; 650 // FitRisingEdge( 651 // "hugo3", 652 // hTest2, 653 // hTest2->GetXaxis()->GetFirst()+68, 654 // hTest2->GetXaxis()->GetFirst()+80, 655 // fit_parameters3 656 // ); 657 658 659 // hTest2->Draw(); 571 660 572 661 … … 608 697 609 698 //chi2 test 610 float chi2 =611 pixel[pixelID]->hPixelEdgeMean[pulse_order]->Chi2Test(612 pixel[pixelID]->hPixelMean[pulse_order],613 "UUPCHI2"614 );615 cout << "p-Value :" << chi2 << endl;616 wholeCamera->hChi2EdgetoMax[pulse_order]->Fill(chi2);617 cgpDistributions[pulse_order]->cd();618 wholeCamera->hChi2EdgetoMax[pulse_order]->Draw();699 // float chi2 = 700 // pixel[pixelID]->hPixelEdgeMean[pulse_order]->Chi2Test( 701 // pixel[pixelID]->hPixelMean[pulse_order], 702 // "UUPCHI2" 703 // ); 704 // cout << "p-Value :" << chi2 << endl; 705 // wholeCamera->hChi2EdgetoMax[pulse_order]->Fill(chi2); 706 // cgpDistributions[pulse_order]->cd(); 707 // wholeCamera->hChi2EdgetoMax[pulse_order]->Draw(); 619 708 620 709 if (verbosityLevel > 2)
Note:
See TracChangeset
for help on using the changeset viewer.