Changeset 14753 for fact/tools
- Timestamp:
- 12/17/12 15:34:08 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/PulseTemplates/FCalcPulseTemplate.C
r14749 r14753 19 19 #include <TMath.h> 20 20 #include <TFile.h> 21 #include <TGraph.h> 22 #include <TGraphErrors.h> 21 23 #include <TStyle.h> 22 24 #include <TString.h> … … 28 30 #include <iostream> 29 31 #include <fstream> 32 33 #include <vector> 34 #include <utility> 35 30 36 using namespace std; 31 37 … … 70 76 TCanvas** cgpAllPixelPulses = NULL; 71 77 TCanvas** cgpDistributions = NULL; 78 TCanvas* cgpGraphs = NULL; 72 79 //TCanvas* cgpTestHistos = NULL; 73 80 … … 94 101 TString OutPutPath = "analysis/FPulseTemplate/20120309_017/", 95 102 int firstpixel = 0, 96 int npixel = 1 ,103 int npixel = 10, 97 104 int pixelSetSize = 200, 98 int maxPulseOrder = 1,99 TString histoOptions = "SRM",105 int maxPulseOrder = 4, 106 // TString histoOptions = "SRM", 100 107 bool ProduceGraphic = true, 101 108 bool stats = true, 102 109 bool saveResults = false, 103 110 // bool fitdata = false, 104 bool debugPixel = true,111 bool debugPixel = false, 105 112 // int refresh_rate = 500, //refresh rate for canvases 106 int verbosityLevel = 4// different verbosity levels can be implemented here113 int verbosityLevel = 1 // different verbosity levels can be implemented here 107 114 ) 108 115 { … … 203 210 cgpPixelPulses = new TCanvas*[maxPulseOrder]; 204 211 cgpDistributions = new TCanvas*[maxPulseOrder]; 212 cgpGraphs = new TCanvas("graphs", "Dependences to pe" ); 205 213 206 214 //TCanvas* gpcDevelopment = NULL; … … 235 243 cgpPixelPulses[pulse_order]->Divide(4, 2); 236 244 } 245 246 cgpGraphs->Divide(1,3); 237 247 } 238 248 … … 241 251 //----------------------------------------------------------------------------- 242 252 243 244 253 //----------------------------------------------------------------------------- 245 // prepare datafile254 // Distrribution Histograms 246 255 //----------------------------------------------------------------------------- 256 TH1D hBsl[maxPulseOrder]; 257 TH1D hAsymptote[maxPulseOrder]; 258 TH1D hT0[maxPulseOrder]; 259 TH1D hTau1[maxPulseOrder]; 260 TH1D hTau2[maxPulseOrder]; 261 TH1D hIntegral[maxPulseOrder]; 262 TH1D hAmplitude[maxPulseOrder]; 263 264 //Lopp over pulse order configure distribution histograms 265 for (int i = 0; i<maxPulseOrder; i++) 266 { 267 //BSL 268 TString title; 269 title = "hBSL"; 270 title.Append(i); 271 hBsl[i].SetNameTitle(title, title); 272 hBsl[i].SetBins(400, -2-0.005, 2-0.005); 273 274 //Asymptote 275 title = "hAsymptote"; 276 title.Append(i); 277 hAsymptote[i].SetNameTitle(title, title); 278 hAsymptote[i].SetBins(60, -10.5, 49.5); 279 280 //T0 281 title = "hT0"; 282 title.Append(i); 283 hT0[i].SetNameTitle(title, title); 284 hT0[i].SetBins(80, 39.5, 119.5); 285 286 //Tau1 287 title = "hTau1"; 288 title.Append(i); 289 hTau1[i].SetNameTitle(title, title); 290 hTau1[i].SetBins(10, -10.5, 9.5); 291 292 //Tau2 293 title = "hTau2"; 294 title.Append(i); 295 hTau2[i].SetNameTitle(title, title); 296 hTau2[i].SetBins(40, 19.5, 59.5); 297 298 //Integral 299 title = "hIntegral"; 300 title.Append(i); 301 hIntegral[i].SetNameTitle(title, title); 302 hIntegral[i].SetBins(400, (i+1)*99.5, (i+1)*499.5); 303 304 //Amplitude 305 title = "hAmplitude"; 306 title.Append(i); 307 hAmplitude[i].SetNameTitle(title, title); 308 hAmplitude[i].SetBins(400, (i+1)*4.95, (i+1)*24.95); 309 } 310 311 //----------------------------------------------------------------------------- 312 // Graphs 313 //----------------------------------------------------------------------------- 314 TGraphErrors grPheVsAmpl; 315 grPheVsAmpl.SetNameTitle("grPheVsAmpl", "Distribution of Pulse Amplitude vs. Photon equivalent"); 316 grPheVsAmpl.SetMarkerStyle(21); 317 318 TGraphErrors grPheVsIntegral; 319 grPheVsIntegral.SetNameTitle("grPheVsIntegral", "Distribution of Pulse Integral vs. Photon equivalent"); 320 grPheVsIntegral.SetMarkerStyle(21); 321 322 TGraphErrors grPheVsTau2; 323 grPheVsTau2.SetNameTitle("grPheVsTau2", "Distribution of Tau2 vs. Photon equivalent"); 324 grPheVsTau2.SetMarkerStyle(21); 325 //----------------------------------------------------------------------------- 326 // Variables 327 //----------------------------------------------------------------------------- 328 247 329 248 330 //---------------------------------------------------------------------------- … … 269 351 //---------------------------------------------------------------------------- 270 352 271 Csv PixelCsv(OutPutPath, InRootFileName.Remove(12, 5), " SPn", verbosityLevel);353 Csv PixelCsv(OutPutPath, InRootFileName.Remove(12, 5), "points", verbosityLevel); 272 354 PixelCsv.WritePointSetHeader(); 273 Csv PixelModelCsv(OutPutPath, InRootFileName.Remove(12, 5), " SPModeln", verbosityLevel);355 Csv PixelModelCsv(OutPutPath, InRootFileName.Remove(12, 5), "fitResults", verbosityLevel); 274 356 PixelModelCsv.WritePulseAttributesHeader(); 275 357 // Csv AllPixelCsv(OutPutPath, InRootFileName.Remove(12, 5), -1, verbosityLevel); … … 340 422 stats, 341 423 "L", 342 70, // /TODO: get it from the root file343 230, // /TODO: get it from the root file344 -1, // /TODO: get it from the root file345 9, // /TODO: get it from the root file424 70, //pixelOverlayXaxisLeft /TODO: get it from the root file 425 230, //pixelOverlayXaxisRight /TODO: get it from the root file 426 -1, //bslMean /TODO: get it from the root file 427 9, //gain mean /TODO: get it from the root file 346 428 inputRootFile, 347 429 outputRootFile … … 426 508 ); 427 509 510 511 // ShiftStartOfHistoInXTo( 512 // pixel[pixelID]->hEdgeOverlay[pulse_order], 513 // 0 514 // ); 515 516 // ShiftStartOfHistoInXTo( 517 // pixel[pixelID]->hMaxOverlay[pulse_order], 518 // 0 519 // ); 520 428 521 PixelCsv.WritePointSet( 429 522 pixel[pixelID], … … 459 552 if (ProduceGraphic && debugPixel) 460 553 { 461 pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetXaxis()->SetLimits(462 0,463 300464 );465 pixel[pixelID]->hPixelEdgeMean[pulse_order]->GetXaxis()->SetLimits(466 0,467 300468 );469 pixel[pixelID]->hPixelEdgeMedian[pulse_order]->GetXaxis()->SetLimits(470 0,471 300472 );473 pixel[pixelID]->hPixelMax[pulse_order]->GetXaxis()->SetLimits(474 0,475 300476 );477 pixel[pixelID]->hPixelMean[pulse_order]->GetXaxis()->SetLimits(478 0,479 300480 );481 pixel[pixelID]->hPixelMedian[pulse_order]->GetXaxis()->SetLimits(482 0,483 300484 );485 486 pixel[pixelID]->hEdgeProfile[pulse_order]->GetXaxis()->SetLimits(487 0,488 300489 );554 // pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetXaxis()->SetLimits( 555 // 0, 556 // 300 557 // ); 558 // pixel[pixelID]->hPixelEdgeMean[pulse_order]->GetXaxis()->SetLimits( 559 // 0, 560 // 300 561 // ); 562 // pixel[pixelID]->hPixelEdgeMedian[pulse_order]->GetXaxis()->SetLimits( 563 // 0, 564 // 300 565 // ); 566 // pixel[pixelID]->hPixelMax[pulse_order]->GetXaxis()->SetLimits( 567 // 0, 568 // 300 569 // ); 570 // pixel[pixelID]->hPixelMean[pulse_order]->GetXaxis()->SetLimits( 571 // 0, 572 // 300 573 // ); 574 // pixel[pixelID]->hPixelMedian[pulse_order]->GetXaxis()->SetLimits( 575 // 0, 576 // 300 577 // ); 578 579 // pixel[pixelID]->hEdgeProfile[pulse_order]->GetXaxis()->SetLimits( 580 // 0, 581 // 300 582 // ); 490 583 491 584 … … 507 600 PixelCanvasFrameNrs 508 601 ); 602 603 // cgpPixelPulses[pulse_order]->cd(6); 604 509 605 510 606 //------------------------------------- … … 513 609 //------------------------------------- 514 610 //------------------------------------- 515 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_order532 );533 534 PixelModelCsv.WritePulseAttributes(535 pixel[pixelID],536 &pulse1,537 "2",538 pulse_order539 );540 611 541 612 cgpPixelPulses[pulse_order]->cd(8); … … 665 736 //------------------------------------- 666 737 //------------------------------------- 667 668 669 738 } 739 740 // ======================================================= 741 // Fit of pulse function to template 742 743 Pulse* pulseFits[6]; 744 745 pulses.cd(1); 746 Pulse maxMaxPulse("maxMaxPulse", pixel[pixelID]->hPixelMax[pulse_order], "Q", 1); 747 pulseFits[0] = &maxMaxPulse; 748 749 pulses.cd(2); 750 Pulse maxMedianPulse("maxMedianPulse", pixel[pixelID]->hPixelMedian[pulse_order], "Q",1); 751 pulseFits[1] = &maxMedianPulse; 752 753 pulses.cd(3); 754 Pulse maxMeanPulse("maxMeanPulse", pixel[pixelID]->hPixelMean[pulse_order], "Q",1); 755 pulseFits[2] = &maxMeanPulse; 756 757 Pulse edgeMaxPulse("edgeMaxPulse", pixel[pixelID]->hPixelEdgeMax[pulse_order], "Q",1); 758 pulseFits[3] = &edgeMaxPulse; 759 760 Pulse edgeMedianPulse("edgeMedianPulse", pixel[pixelID]->hPixelEdgeMedian[pulse_order], "Q",1); 761 pulseFits[4] = &edgeMedianPulse; 762 763 Pulse edgeMeanPulse("edgeMeanPulse", pixel[pixelID]->hPixelEdgeMean[pulse_order], "Q",1); 764 pulseFits[5] = &edgeMeanPulse; 765 766 767 //-------------------------------------------------------- 768 //Write parameters from pulse fit to CSV 769 770 for (int i = 0; i < 6; i++) 771 { 772 PixelModelCsv.WritePulseAttributes( 773 pixel[pixelID], 774 pulseFits[i], 775 "Edge_pix", 776 pulse_order 777 ); 778 } 779 //------------------------------------- 780 // Fill Distribution Histogramms 781 //------------------------------------- 782 783 hBsl[pulse_order].Fill( edgeMedianPulse.GetBsl() ); 784 hAsymptote[pulse_order].Fill( edgeMedianPulse.GetHeight() ); 785 hT0[pulse_order].Fill( edgeMedianPulse.GetT0() ); 786 hTau1[pulse_order].Fill( edgeMedianPulse.GetTau1() ); 787 hTau2[pulse_order].Fill( edgeMedianPulse.GetTau2() ); 788 hIntegral[pulse_order].Fill( edgeMedianPulse.GetIntegral()); 789 hAmplitude[pulse_order].Fill( edgeMedianPulse.GetAmplitude()); 790 791 //------------------------------------- 792 // Fill Distribution Containers 793 //------------------------------------- 794 795 grPheVsAmpl.Set(grPheVsAmpl.GetN()+1); 796 grPheVsIntegral.Set(grPheVsIntegral.GetN()+1); 797 798 799 grPheVsAmpl.SetPoint( 800 grPheVsAmpl.GetN()-1, 801 edgeMedianPulse.GetPhE(), 802 edgeMedianPulse.GetAmplitude() 803 ); 804 805 grPheVsAmpl.SetPointError( 806 grPheVsAmpl.GetN()-1, 807 edgeMedianPulse.GetPhEErr(), 808 edgeMedianPulse.GetAmplitudeErr() 809 ); 810 811 grPheVsIntegral.SetPoint( 812 grPheVsIntegral.GetN()-1, 813 edgeMedianPulse.GetPhE(), 814 edgeMedianPulse.GetIntegral() 815 ); 816 817 grPheVsAmpl.SetPointError( 818 grPheVsIntegral.GetN()-1, 819 edgeMedianPulse.GetPhEErr(), 820 edgeMedianPulse.GetIntegralErr() 821 ); 822 823 grPheVsTau2.SetPoint( 824 grPheVsIntegral.GetN()-1, 825 edgeMedianPulse.GetPhE(), 826 edgeMedianPulse.GetTau2() 827 ); 828 829 grPheVsTau2.SetPointError( 830 grPheVsIntegral.GetN()-1, 831 edgeMedianPulse.GetPhE(), 832 edgeMedianPulse.GetTau2Err() 833 ); 834 835 // cgpDistributions[pulse_order].cd(1); 836 837 670 838 // FitMaxPropabilityPuls( 671 839 // pixel[pixelID]->hPixelEdgeMean[pulse_order], … … 854 1022 ); 855 1023 } 1024 1025 ShiftStartOfHistoInXTo( 1026 wholeCamera->hEdgeOverlay[0], 1027 0 1028 ); 1029 1030 ShiftStartOfHistoInXTo( 1031 wholeCamera->hMaxOverlay[0], 1032 0 1033 ); 1034 1035 // ======================================================= 1036 // Fit of pulse function to template 1037 1038 Pulse* allPulseFits[6]; 1039 1040 pulses.cd(1); 1041 Pulse maxCamMaxPulse("maxMaxPulse", wholeCamera->hPixelMax[pulse_order], "Q", 1); 1042 allPulseFits[0] = &maxCamMaxPulse; 1043 1044 pulses.cd(2); 1045 Pulse maxCamMedianPulse("maxMedianPulse", wholeCamera->hPixelMedian[pulse_order], "Q", 1); 1046 allPulseFits[1] = &maxCamMedianPulse; 1047 1048 pulses.cd(3); 1049 Pulse maxCamMeanPulse("maxMeanPulse", wholeCamera->hPixelMean[pulse_order],"Q", 1); 1050 allPulseFits[2] = &maxCamMeanPulse; 1051 1052 Pulse edgeCamMaxPulse("edgeMaxPulse", wholeCamera->hPixelEdgeMax[pulse_order], "Q", 1); 1053 allPulseFits[3] = &edgeCamMaxPulse; 1054 1055 Pulse edgeCamMedianPulse("edgeMedianPulse", wholeCamera->hPixelEdgeMedian[pulse_order],"Q", 1); 1056 allPulseFits[4] = &edgeCamMedianPulse; 1057 1058 Pulse edgeCamMeanPulse("edgeMeanPulse", wholeCamera->hPixelEdgeMean[pulse_order], "Q", 1); 1059 allPulseFits[5] = &edgeCamMeanPulse; 1060 1061 1062 //-------------------------------------------------------- 1063 //Write parameters from pulse fit to CSV 1064 1065 for (int i = 0; i < 6; i++) 1066 { 1067 PixelModelCsv.WritePulseAttributes( 1068 wholeCamera, 1069 allPulseFits[i], 1070 "Edge", 1071 pulse_order 1072 ); 1073 } 856 1074 } //EOF: Draw All Pixel Histograms 1075 1076 1077 //------------------------------------- 1078 // Draw Parameter Distributions 1079 //------------------------------------- 1080 1081 if (ProduceGraphic) 1082 { 1083 cgpGraphs->cd(1); 1084 1085 if (verbosityLevel > 0) cout << "...drawing grPheVsAmpl" << endl; 1086 grPheVsAmpl.Draw("AP"); 1087 1088 cgpGraphs->cd(2); 1089 if (verbosityLevel > 0) cout << "...drawing grPheVsIntegral" << endl; 1090 grPheVsIntegral.Draw("AP"); 1091 1092 cgpGraphs->cd(3); 1093 if (verbosityLevel > 0) cout << "...drawing grPheVsTau2" << endl; 1094 grPheVsTau2.Draw("AP"); 1095 1096 cgpGraphs->Update(); 1097 1098 for (int i = 0; i < maxPulseOrder; i++){ 1099 cgpDistributions[i]->Divide(4,2); 1100 1101 cgpDistributions[i]->cd(1); 1102 hBsl[i].Draw(); 1103 cgpDistributions[i]->cd(2); 1104 hAsymptote[i].Draw(); 1105 cgpDistributions[i]->cd(3); 1106 hT0[i].Draw(); 1107 cgpDistributions[i]->cd(4); 1108 hTau1[i].Draw(); 1109 cgpDistributions[i]->cd(5); 1110 hTau2[i].Draw(); 1111 cgpDistributions[i]->cd(6); 1112 hIntegral[i].Draw(); 1113 cgpDistributions[i]->cd(7); 1114 hAmplitude[i].Draw(); 1115 1116 1117 1118 } 1119 1120 1121 1122 1123 1124 } 1125 1126 1127 1128 1129 857 1130 858 1131 … … 1061 1334 rcfile.mPixelSetSize, 1062 1335 rcfile.mMaxOrder, 1063 rcfile.mHistoOptions,1336 // rcfile.mHistoOptions, 1064 1337 rcfile.mProduceGraphic, 1065 1338 rcfile.mPrintStats,
Note:
See TracChangeset
for help on using the changeset viewer.