- Timestamp:
- 05/24/12 02:03:58 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/PulseTemplates/FCalcPulseTemplate.C
r13790 r13851 42 42 #include "pixelsum.h" 43 43 #include "templateextractors.h" 44 #include "configfile.h" 44 45 45 46 //---------------------------------------------------------------------------- … … 88 89 TString OutputRootFileName = "test.root", 89 90 TString OutPutPath = "analysis/FPulseTemplate/20120309_018/", 91 int firstpixel = 0, 92 int npixel = -1, 93 int pixelSetSize = 200, 94 int maxPulseOrder = 3, 95 TString histoOptions = "SRM", 90 96 bool ProduceGraphic = true, 97 bool stats = true, 98 bool saveResults = true, 91 99 // bool fitdata = false, 92 bool stats = false,93 100 bool debugPixel = false, 94 int pixelSetSize = 40,95 int maxPulseOrder = 3,96 101 // int refresh_rate = 500, //refresh rate for canvases 97 int verbosityLevel = 5, // different verbosity levels can be implemented here 98 int firstpixel = 0, 99 int npixel = 2 102 int verbosityLevel = 2 // different verbosity levels can be implemented here 100 103 ) 101 104 { … … 104 107 OutPutPath = SetHostsPaths(true, OutPutPath ); 105 108 109 TString outFile = OutPutPath; 110 outFile += OutputRootFileName; 111 106 112 //---------------------------------------------------------------------------- 107 113 // Open-Root-File Settings … … 113 119 114 120 TFile * inputRootFile 115 = OpenRootFile( InputPath, InRootFileName, verbosityLevel ); 121 = LoadRootFile( InputPath, InRootFileName, verbosityLevel ); 122 123 if (inputRootFile == NULL) 124 { 125 cerr << "input file not readable, check file path!!!" << endl; 126 return(0); 127 } 128 if (saveResults) 129 { 130 CreateRootFile( outFile, true, verbosityLevel ); 131 } 116 132 117 133 TFile * outputRootFile … … 266 282 pixelID++ ) 267 283 { 268 284 if (verbosityLevel >= 0) 285 { 286 cout << "------------------------------------------------" 287 << endl 288 << "...processing Pixel: " 289 << pixelID << "/" 290 << firstPixelOfSet + pixelSetSize - 1 291 << endl; 292 } 269 293 if (verbosityLevel > 1) 270 294 { … … 298 322 -1, ///TODO: get it from the root file 299 323 9, ///TODO: get it from the root file 300 inputRootFile 324 inputRootFile, 325 outputRootFile 301 326 ); 302 327 … … 379 404 ); 380 405 381 WritePixelTemplateToCsv( 382 pixel[pixelID], 383 OutPutPath, 384 "Maximum", 385 pulse_order, 386 verbosityLevel 387 ); 388 389 WritePixelTemplateToCsv( 390 pixel[pixelID], 391 OutPutPath, 392 "Edge", 393 pulse_order, 394 verbosityLevel 395 ); 396 397 if (ProduceGraphic) 406 if ( saveResults ) 407 { 408 WritePixelTemplateToCsv( 409 pixel[pixelID], 410 OutPutPath, 411 "Maximum", 412 pulse_order, 413 verbosityLevel 414 ); 415 416 WritePixelTemplateToCsv( 417 pixel[pixelID], 418 OutPutPath, 419 "Edge", 420 pulse_order, 421 verbosityLevel 422 ); 423 } 424 425 if (ProduceGraphic && debugPixel) 398 426 { 399 427 pixel[pixelID]->DrawTemplateHistograms( … … 439 467 // End of Loop over pulsorder of current Pixel 440 468 441 if (ProduceGraphic )469 if (ProduceGraphic && debugPixel) 442 470 { 443 471 UpdateCanvases( … … 461 489 } 462 490 } 463 464 491 if ( saveResults ) 492 { 493 pixel[pixelID]->SavePixelHistograms( 494 outFile, 495 saveResults 496 ); 497 } 465 498 466 499 //deleteCurrent Pixel from Heap … … 528 561 verbosityLevel 529 562 ); 530 WritePixelTemplateToCsv( 531 wholeCamera, 532 OutPutPath, 533 "Maximum", 534 pulse_order, 535 verbosityLevel 536 ); 563 if ( saveResults ) 564 { 565 WritePixelTemplateToCsv( 566 wholeCamera, 567 OutPutPath, 568 "Maximum", 569 pulse_order, 570 verbosityLevel 571 ); 572 } 537 573 538 574 //from Edge Overlay … … 543 579 verbosityLevel 544 580 ); 545 WritePixelTemplateToCsv( 546 wholeCamera, 547 OutPutPath, 548 "Edge", 549 pulse_order, 550 verbosityLevel 551 ); 552 553 // wholeCamera->DrawTemplateHistograms( 554 // cgpPixelPulses, 555 // PixelCanvasFrameNrs 556 // ); 557 558 // wholeCamera->DrawEdgeTemplateHistograms( 559 // cgpPixelPulses, 560 // PixelCanvasFrameNrs 561 // ); 581 if ( saveResults ) 582 { 583 WritePixelTemplateToCsv( 584 wholeCamera, 585 OutPutPath, 586 "Edge", 587 pulse_order, 588 verbosityLevel 589 ); 590 } 591 592 if (ProduceGraphic) 593 { 594 wholeCamera->DrawTemplateHistograms( 595 cgpPixelPulses, 596 AllpixelCanvasFrameNrs 597 ); 598 599 wholeCamera->DrawEdgeTemplateHistograms( 600 cgpPixelPulses, 601 AllpixelCanvasFrameNrs 602 ); 603 } 562 604 } //EOF: Draw All Pixel Histograms 563 605 … … 566 608 // Save All Pixel Histograms 567 609 //------------------------------------- 568 569 // SaveHistograms( //save histograms of all pixel into output root file 570 // OutInRootFileName, 571 // CreateSubDirName("All"), 572 // hAllPixelList, 573 // verbosityLevel 574 // ); 575 576 // SaveHistograms( //save histograms of generell results into output root file 577 // OutInRootFileName, 578 // "root", 579 // hRootList, 580 // verbosityLevel 581 // ); 582 583 // if (ProduceGraphic) 584 // { 585 // UpdateCanvases( 586 // verbosityLevel, 587 // MAX_PULS_ORDER, 588 // false 589 // ); 590 // } 610 if ( saveResults ) 611 { 612 wholeCamera->SavePixelHistograms( 613 outFile, 614 saveResults 615 ); 616 } 617 618 if (ProduceGraphic) 619 { 620 UpdateCanvases( 621 verbosityLevel, 622 MAX_PULS_ORDER, 623 false 624 ); 625 626 //Process gui events asynchronously during input 627 cout << endl; 628 TTimer timer("gSystem->ProcessEvents();", 50, kFALSE); 629 timer.TurnOn(); 630 TString input = Getline("press <return> to exit: "); 631 timer.TurnOff(); 632 if (input=="q\n") 633 { 634 break; 635 } 636 } 591 637 592 638 //------------------------------------- … … 671 717 //----------------------------------------------------------------------------- 672 718 673 int main( )719 int main(int argc,char *argv[]) 674 720 { 675 FCalcPulseTemplate(); 721 // Int_t index; 722 TString test; 723 TString rcFileName; 724 TString processType = "template"; 725 bool rcFileNameCmdSet = false; 726 int verbLevel = 0; // different verbosity levels can be implemented here 727 bool verbLevelCmdSet = false; 728 bool save = false; 729 bool produceGraphic = false; 730 731 // TString inputRootFile = "test.root"; 732 // TString inputPath = ""; 733 // TString outputRootFile = "test.root"; 734 // TString outPutPath = ""; 735 // int firstPixel = 0; 736 // int nPixel = -1; 737 // int pixelSetSize = 40; 738 // int maxOrder = 3; 739 // bool dbgPixel = false; 740 // bool fitdata = false; 741 // bool printStats = false; 742 743 // decode arguments 744 if(argc < 2) 745 { 746 printf("no arguements given, using standard arguments\n"); 747 } 748 749 // set conditions for functions arguments 750 for (int i=1;i<argc;i++) 751 { 752 test = argv[i]; 753 754 if (test.Contains("--config-file") || test.Contains("-c")) 755 { 756 cout << "RC-File: \"" << argv[i + 1] << "\"" << endl; 757 rcFileName = argv[i + 1]; 758 rcFileNameCmdSet = true; 759 continue; 760 } 761 762 if (test.Contains("--verbosity") || test.Contains("-v")) 763 { 764 cout << "Verbosity Level: \"" << argv[i + 1] << "\"" << endl; 765 verbLevel = atoi(argv[i + 1]); 766 continue; 767 } 768 769 if (test.Contains("--save") || test.Contains("-s")) 770 { 771 cout << "will save results" << endl; 772 save = true; 773 continue; 774 } 775 776 if (test.Contains("--graphics") || test.Contains("-g")) 777 { 778 cout << "will produce graphics" << endl; 779 produceGraphic = true; 780 continue; 781 } 782 } 783 784 // reading rc-File: 785 if (rcFileNameCmdSet) 786 { 787 configfile rcfile( rcFileName, processType ); 788 789 if (save) 790 { 791 rcfile.mSave = save; 792 } 793 794 if (verbLevelCmdSet) 795 { 796 rcfile.mVerbLevel = verbLevel; 797 } 798 799 if (produceGraphic) 800 { 801 rcfile.mProduceGraphic = produceGraphic; 802 } 803 804 // 805 FCalcPulseTemplate( 806 rcfile.mInputFile, 807 rcfile.mInputPath, 808 rcfile.mOutputFile, 809 rcfile.mOutputPath, 810 rcfile.mFirstPixel, 811 rcfile.mNumPixel, 812 rcfile.mPixelSetSize, 813 rcfile.mMaxOrder, 814 rcfile.mHistoOptions, 815 rcfile.mProduceGraphic, 816 rcfile.mPrintStats, 817 rcfile.mSave, 818 rcfile.mDbgPixel, 819 rcfile.mVerbLevel 820 ); 821 } 822 else 823 { 824 cout << "user: check if configfile is set correctly in cmd" << endl; 825 } 826 676 827 return 0; 677 828 }
Note:
See TracChangeset
for help on using the changeset viewer.