Changeset 13659 for fact/tools/rootmacros
- Timestamp:
- 05/11/12 23:14:49 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/PulseTemplates/pixel.C
r13646 r13659 1 1 #include <iostream> 2 #include "TObjArray.h"3 #include "TCanvas.h"4 2 5 3 #include "rootfilehandler.h" … … 11 9 //============================= LIFECYCLE ==================================== 12 10 13 Pixel::Pixel(14 TString pixelname,15 int maxPulsorder,16 int verbosityLevel,17 bool stats,18 TFile* filename19 )20 {21 mConstructorType = 1; //important for deletion 0 delete distribution 1 delete TemplateHistos22 mChid = -1;23 mName = pixelname;24 mStats = stats;25 mMaxPulseOrder = maxPulsorder;26 mVerbosityLevel = verbosityLevel;27 mRootFile = filename;28 29 hMaxOverlay = new TH2F*[mMaxPulseOrder];30 hEdgeOverlay = new TH2F*[mMaxPulseOrder];31 hMaxProfile = new TProfile*[mMaxPulseOrder];32 hEdgeProfile = new TProfile*[mMaxPulseOrder];33 34 hPixelMax = new TH1F*[mMaxPulseOrder];35 hPixelMedian = new TH1F*[mMaxPulseOrder];36 hPixelMean = new TH1F*[mMaxPulseOrder];37 38 hPixelEdgeMax = new TH1F*[mMaxPulseOrder];39 hPixelEdgeMedian = new TH1F*[mMaxPulseOrder];40 hPixelEdgeMean = new TH1F*[mMaxPulseOrder];41 42 hList = new TObjArray;43 44 BookPixelHistos();45 BookTemplateHistos();46 }47 11 48 12 Pixel::Pixel( … … 161 125 162 126 //============================= OPERATIONS =================================== 127 void 128 Pixel::DrawOverlayHistograms( 129 TCanvas** pixelCanvas, 130 int* histoFrameNr 131 ) 132 { 133 if (mVerbosityLevel > 2) cout << endl << "...drawing pulse histograms" ; 134 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++) 135 { 136 pixelCanvas[pulse_order]->cd( histoFrameNr[0] ); 137 hMaxOverlay[pulse_order]->Draw("COLZ"); 138 pixelCanvas[pulse_order]->cd( histoFrameNr[2] ); 139 hMaxProfile[pulse_order]->Draw(); 140 hEdgeProfile[pulse_order]->Draw("SAME"); 141 142 pixelCanvas[pulse_order]->cd( histoFrameNr[1] ); 143 hEdgeOverlay[pulse_order]->Draw("COLZ"); 144 } 145 } 146 // end of DrawOverlayHistograms 147 //---------------------------------------------------------------------------- 148 149 void 150 Pixel::DrawDistributionHistograms( 151 TCanvas** pixelCanvas, 152 int* histoFrameNr 153 ) 154 { 155 if (mVerbosityLevel > 2) cout << endl << "...drawing distribution histograms" ; 156 bool nothing_to_fill = true; 157 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++) 158 { 159 if (mOptions.Contains("S") ) 160 { 161 pixelCanvas[pulse_order]->cd( histoFrameNr[0] ); 162 hSlopeRisingEdge[pulse_order]->Draw(); 163 nothing_to_fill = false; 164 } 165 166 if (mOptions.Contains("R") ) 167 { 168 pixelCanvas[pulse_order]->cd( histoFrameNr[1] ); 169 hRisingEdgeToMax[pulse_order]->Draw(); 170 nothing_to_fill = false; 171 } 172 173 if (mOptions.Contains("M") ) 174 { 175 pixelCanvas[pulse_order]->cd( histoFrameNr[2] ); 176 hPosOfMax[pulse_order]->Draw(); 177 nothing_to_fill = false; 178 } 179 180 } 181 if (nothing_to_fill) 182 { 183 cout << endl << "there were NO DISTRIBUTION HISTOGRAMS to fill" << endl; 184 } 185 } 186 // end of DrawDistributionHistograms 187 //---------------------------------------------------------------------------- 188 189 void 190 Pixel::DrawTemplateHistograms( 191 TCanvas** pixelCanvas, 192 int* histoFrameNr 193 ) 194 { 195 if (mVerbosityLevel > 2) cout << endl << "...drawing Template histograms" ; 196 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++) 197 { 198 pixelCanvas[pulse_order]->cd( histoFrameNr[0] ); 199 hPixelMax[pulse_order]->Draw(); 200 201 pixelCanvas[pulse_order]->cd( histoFrameNr[1] ); 202 hPixelMedian[pulse_order]->Draw(); 203 204 pixelCanvas[pulse_order]->cd( histoFrameNr[2] ); 205 hPixelMean[pulse_order]->Draw(); 206 207 } 208 } 209 // end of DrawTemplateHistograms 210 //---------------------------------------------------------------------------- 211 212 void 213 Pixel::DrawEdgeTemplateHistograms( 214 TCanvas** pixelCanvas, 215 int* histoFrameNr 216 ) 217 { 218 if (mVerbosityLevel > 2) cout << endl << "...drawing Template histograms" ; 219 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++) 220 { 221 pixelCanvas[pulse_order]->cd( histoFrameNr[0] ); 222 hPixelEdgeMax[pulse_order]->Draw(); 223 224 pixelCanvas[pulse_order]->cd( histoFrameNr[1] ); 225 hPixelEdgeMedian[pulse_order]->Draw(); 226 227 pixelCanvas[pulse_order]->cd( histoFrameNr[2] ); 228 hPixelEdgeMean[pulse_order]->Draw(); 229 230 } 231 } 232 // end of DrawTemplateHistograms 233 //---------------------------------------------------------------------------- 234 235 236 237 238 void 239 Pixel::SavePixelHistograms( 240 TString outRootFileName, 241 bool saveResults 242 ) 243 { 244 if (mVerbosityLevel > 2) cout << endl << "Saving histograms of Pixel# " << mChid; 245 if (!saveResults) return; 246 SaveHistograms( 247 outRootFileName, 248 CreateSubDirName( mChid ), 249 hList, 250 saveResults, 251 mVerbosityLevel 252 ); 253 } 254 // end of SavePixelHistograms 255 //---------------------------------------------------------------------------- 256 257 258 259 TString 260 Pixel::HistoName( 261 TString histoname, 262 int order 263 ) 264 { 265 histoname += mChid; 266 histoname += "_"; 267 histoname += order; 268 return histoname; 269 } 270 271 TString 272 Pixel::HistoTitle( 273 TString histo_title, 274 int order 275 ) 276 { 277 histo_title += " [Pixel_Order] "; 278 histo_title += mChid; 279 histo_title += "_"; 280 histo_title += order; 281 return histo_title; 282 } 283 284 TString 285 Pixel::CsvFileName( 286 TString path, 287 TString overlayMethod, 288 int order 289 ) 290 { 291 path += "CSV/"; 292 path += overlayMethod; 293 path += "OverlayTemplate"; 294 path += "_"; 295 path += mChid; 296 path += "_"; 297 path += order; 298 path += ".csv"; 299 return path; 300 } 301 302 303 //============================= ACESS =================================== 304 //============================= INQUIRY =================================== 305 /////////////////////////////// PROTECTED /////////////////////////////////// 306 307 /////////////////////////////// PRIVATE /////////////////////////////////// 308 163 309 void 164 310 Pixel::BookPixelHistos() … … 492 638 //---------------------------------------------------------------------------- 493 639 494 495 void 496 Pixel::DrawOverlayHistograms( 497 TCanvas** pixelCanvas, 498 int* histoFrameNr 499 ) 500 { 501 if (mVerbosityLevel > 2) cout << endl << "...drawing pulse histograms" ; 502 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++) 503 { 504 pixelCanvas[pulse_order]->cd( histoFrameNr[0] ); 505 hMaxOverlay[pulse_order]->Draw("COLZ"); 506 pixelCanvas[pulse_order]->cd( histoFrameNr[2] ); 507 hMaxProfile[pulse_order]->Draw(); 508 hEdgeProfile[pulse_order]->Draw("SAME"); 509 510 pixelCanvas[pulse_order]->cd( histoFrameNr[1] ); 511 hEdgeOverlay[pulse_order]->Draw("COLZ"); 512 } 513 } 514 // end of DrawOverlayHistograms 515 //---------------------------------------------------------------------------- 516 517 void 518 Pixel::DrawDistributionHistograms( 519 TCanvas** pixelCanvas, 520 int* histoFrameNr 521 ) 522 { 523 if (mVerbosityLevel > 2) cout << endl << "...drawing distribution histograms" ; 524 bool nothing_to_fill = true; 525 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++) 526 { 527 if (mOptions.Contains("S") ) 528 { 529 pixelCanvas[pulse_order]->cd( histoFrameNr[0] ); 530 hSlopeRisingEdge[pulse_order]->Draw(); 531 nothing_to_fill = false; 532 } 533 534 if (mOptions.Contains("R") ) 535 { 536 pixelCanvas[pulse_order]->cd( histoFrameNr[1] ); 537 hRisingEdgeToMax[pulse_order]->Draw(); 538 nothing_to_fill = false; 539 } 540 541 if (mOptions.Contains("M") ) 542 { 543 pixelCanvas[pulse_order]->cd( histoFrameNr[2] ); 544 hPosOfMax[pulse_order]->Draw(); 545 nothing_to_fill = false; 546 } 547 548 } 549 if (nothing_to_fill) 550 { 551 cout << endl << "there were NO DISTRIBUTION HISTOGRAMS to fill" << endl; 552 } 553 } 554 // end of DrawDistributionHistograms 555 //---------------------------------------------------------------------------- 556 557 void 558 Pixel::DrawTemplateHistograms( 559 TCanvas** pixelCanvas, 560 int* histoFrameNr 561 ) 562 { 563 if (mVerbosityLevel > 2) cout << endl << "...drawing Template histograms" ; 564 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++) 565 { 566 pixelCanvas[pulse_order]->cd( histoFrameNr[0] ); 567 hPixelMax[pulse_order]->Draw(); 568 569 pixelCanvas[pulse_order]->cd( histoFrameNr[1] ); 570 hPixelMedian[pulse_order]->Draw(); 571 572 pixelCanvas[pulse_order]->cd( histoFrameNr[2] ); 573 hPixelMean[pulse_order]->Draw(); 574 575 } 576 } 577 // end of DrawTemplateHistograms 578 //---------------------------------------------------------------------------- 579 580 void 581 Pixel::DrawEdgeTemplateHistograms( 582 TCanvas** pixelCanvas, 583 int* histoFrameNr 584 ) 585 { 586 if (mVerbosityLevel > 2) cout << endl << "...drawing Template histograms" ; 587 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++) 588 { 589 pixelCanvas[pulse_order]->cd( histoFrameNr[0] ); 590 hPixelEdgeMax[pulse_order]->Draw(); 591 592 pixelCanvas[pulse_order]->cd( histoFrameNr[1] ); 593 hPixelEdgeMedian[pulse_order]->Draw(); 594 595 pixelCanvas[pulse_order]->cd( histoFrameNr[2] ); 596 hPixelEdgeMean[pulse_order]->Draw(); 597 598 } 599 } 600 // end of DrawTemplateHistograms 640 void 641 Pixel::LoadPulseHistos() 642 { 643 mRootFile->cd(); 644 mRootFile->cd(CreateSubDirName( mChid )); 645 if (mVerbosityLevel > 2) cout << endl << "...load pixel histograms" << endl; 646 for (int order = 0; order < mMaxPulseOrder; order++) 647 { 648 649 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hMaxOverlay", order) << endl; 650 hMaxOverlay[order] = (TH2F*)mRootFile->Get( HistoName("hMaxOverlay", order) ); 651 652 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hEdgeOverlay", order) << endl; 653 hEdgeOverlay[order] = (TH2F*)mRootFile->Get( HistoName("hEdgeOverlay", order) ); 654 655 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hMaxProfile", order) << endl; 656 hMaxProfile[order] = (TProfile*)mRootFile->Get( HistoName("hMaxProfile", order) ); 657 658 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hEdgeProfile", order) << endl; 659 hEdgeProfile[order] = (TProfile*)mRootFile->Get( HistoName("hEdgeProfile", order) ); 660 } 661 } 662 // end of LoadPulseHistos 601 663 //---------------------------------------------------------------------------- 602 664 … … 741 803 if (mVerbosityLevel > 3) 742 804 cout << endl << "\t\t...deleting hPixelMax" 743 << mChid << "_" << order 744 << " hPixelMax[order] adr " << hPixelMax[order] 745 << " hPixelMax adr " << hPixelMax 746 ; 747 805 << mChid << "_" << order; 748 806 delete hPixelMax[order]; 749 807 hPixelMax[order] = NULL; … … 828 886 829 887 void 830 Pixel::SavePixelHistograms( 831 TString outRootFileName, 832 bool saveResults 833 ) 834 { 835 if (mVerbosityLevel > 2) cout << endl << "Saving histograms of Pixel# " << mChid; 836 if (!saveResults) return; 837 SaveHistograms( 838 outRootFileName, 839 CreateSubDirName( mChid ), 840 hList, 841 saveResults, 842 mVerbosityLevel 843 ); 844 } 845 // end of SavePixelHistograms 846 //---------------------------------------------------------------------------- 847 848 void 849 Pixel::LoadPulseHistos() 850 { 851 mRootFile->cd(); 852 mRootFile->cd(CreateSubDirName( mChid )); 853 for (int order = 0; order < mMaxPulseOrder; order++) 854 { 855 hMaxOverlay[order] = (TH2F*)mRootFile->Get( HistoName("hMaxOverlay", order) ); 856 hEdgeOverlay[order] = (TH2F*)mRootFile->Get( HistoName("hEdgeOverlay", order) ); 857 hMaxProfile[order] = (TProfile*)mRootFile->Get( HistoName("hMaxProfile", order) ); 858 hEdgeProfile[order] = (TProfile*)mRootFile->Get( HistoName("hEdgeProfile", order) ); 859 } 860 } 861 // end of LoadPulseHistos 862 //---------------------------------------------------------------------------- 863 864 TString 865 Pixel::HistoName( 866 TString histoname, 867 int order 868 ) 869 { 870 histoname += mChid; 871 histoname += "_"; 872 histoname += order; 873 return histoname; 874 } 875 876 TString 877 Pixel::HistoTitle( 878 TString histo_title, 879 int order 880 ) 881 { 882 histo_title += " [Pixel_Order] "; 883 histo_title += mChid; 884 histo_title += "_"; 885 histo_title += order; 886 return histo_title; 887 } 888 889 TString 890 Pixel::CsvFileName( 891 TString path, 892 TString overlayMethod, 893 int order 894 ) 895 { 896 path += "CSV/"; 897 path += overlayMethod; 898 path += "OverlayTemplate"; 899 path += "_"; 900 path += mChid; 901 path += "_"; 902 path += order; 903 path += ".csv"; 904 return path; 905 } 906 907 908 //============================= ACESS =================================== 909 //============================= INQUIRY =================================== 910 /////////////////////////////// PROTECTED /////////////////////////////////// 911 912 /////////////////////////////// PRIVATE /////////////////////////////////// 913 914 915 916 917 918 919 920 888 Pixel::MakeTH1Pretty( 889 TH1* histo, 890 TString histName, 891 TString histTitle, 892 int order 893 ) 894 { 895 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName(histName, order) << endl; 896 897 histo->SetNameTitle( 898 HistoName(histName, order), 899 HistoTitle(histTitle, order) 900 ); 901 902 histo->SetBins( 903 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight , 904 (-1*mPixelOverlayXaxisLeft)-0.5, 905 mPixelOverlayXaxisRight-0.5 906 ); 907 908 histo->SetAxisRange( 909 mBSLMean - 5, 910 (mGainMean*(order+1)) + 10, 911 "Y"); 912 913 histo->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); 914 histo->GetYaxis()->SetTitle( "Amplitude [mV]" ); 915 //histo->SetBit(TH2F::kCanRebin); 916 histo->SetStats(mStats); 917 } 918 // end of MakeTH2Pretty 919 //---------------------------------------------------------------------------- 920 921 922 void 923 Pixel::MakeTH2Pretty( 924 TH2* histo, 925 TString histName, 926 TString histTitle, 927 int order 928 ) 929 { 930 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName(histName, order) << endl; 931 932 histo->SetNameTitle( 933 HistoName(histName, order), 934 HistoTitle(histTitle, order) 935 ); 936 937 histo->SetBins( 938 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight , 939 (-1*mPixelOverlayXaxisLeft)-0.5, 940 mPixelOverlayXaxisRight-0.5 , 941 512, 942 -55.5, 943 200.5 944 ); 945 946 histo->SetAxisRange( 947 mBSLMean - 5, 948 (mGainMean*(order+1)) + 10, 949 "Y"); 950 951 histo->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); 952 histo->GetYaxis()->SetTitle( "Amplitude [mV]" ); 953 //histo->SetBit(TH2F::kCanRebin); 954 histo->SetStats(mStats); 955 } 956 // end of MakeTH2Pretty 957 //---------------------------------------------------------------------------- 958 959 void 960 Pixel::MakeTProfilePretty( 961 TProfile* histo, 962 TString histName, 963 TString histTitle, 964 int order 965 ) 966 { 967 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName(histName, order) << endl; 968 969 histo->SetNameTitle( 970 HistoName(histName, order), 971 HistoTitle(histTitle, order) 972 ); 973 974 histo->SetBins( 975 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight , 976 (-1*mPixelOverlayXaxisLeft)-0.5, 977 mPixelOverlayXaxisRight-0.5 978 ); 979 histo->SetOption( "s" ); 980 981 histo->SetAxisRange( 982 mBSLMean - 5, 983 (mGainMean*(order+1)) + 10, 984 "Y"); 985 986 histo->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); 987 histo->GetYaxis()->SetTitle( "Amplitude [mV]" ); 988 //histo->SetBit(TH2F::kCanRebin); 989 histo->SetStats(mStats); 990 } 991 // end of MakeTProfilePretty 992 //---------------------------------------------------------------------------- 993 994 995
Note:
See TracChangeset
for help on using the changeset viewer.