/********************** FPulseTemplate *********************** * open a root-file with pulse overlay histograms * calculate most propable Pulse-Shape * compute pulse height and pulse integral spektrum of the peaks + draw histos for single, double, tripple, ....above 100mV Photonpulses + draw Parameterdevelopment depending on photon quantity + form a template (shape depending on number of photons) so it can be used for detection of other peaks *************************************************************/ //---------------------------------------------------------------------------- // root libraries //---------------------------------------------------------------------------- #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define NPIX 1440 #define NCELL 1024 #define FAD_MAX_SAMPLES 1024 #define MAX_PULS_ORDER 1 #define HAVE_ZLIB //---------------------------------------------------------------------------- // Classes //---------------------------------------------------------------------------- #include "rootfilehandler.h" #include "pixel.h" #include "pixelsum.h" #include "pulse.h" #include "templateextractors.h" #include "configfile.h" #include "csv.h" //---------------------------------------------------------------------------- // Decleration of global variables //---------------------------------------------------------------------------- bool breakout=false; //---------------------------------------------------------------------------- // Initialisation of Root Objects //---------------------------------------------------------------------------- // Temporary Objects //Pixelwise Histograms //All Pixel Histograms //Root-File Objects TObjArray* hAllPixelList = NULL; TObjArray* hRootList = NULL; //Canvases TCanvas** cgpPixelPulses = NULL; TCanvas** cgpAllPixelPulses = NULL; TCanvas** cgpDistributions = NULL; TCanvas* cgpGraphs = NULL; //TCanvas* cgpTestHistos = NULL; //---------------------------------------------------------------------------- // Functions //---------------------------------------------------------------------------- void DeletePixelCanvases( int, int ); void UpdateCanvases( int verbosityLevel, int max_pulse_order, bool testmode ); //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- // MAIN - Funtion //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- int FCalcPulseTemplate( TString InRootFileName = "20120309_017.root", // TString InRootFileName = "20120309_032.root", TString InputPath = "analysis/analysis/FPulseTemplate/20120309_017/Overlay/", // TString InputPath = "analysis/analysis/FPulseTemplate/20120309_032/Overlay/", TString OutputRootFileName = "test.root", TString OutPutPath = "analysis/FPulseTemplate/20120309_017/", int firstpixel = 0, int npixel = 100, int pixelSetSize = 200, int maxPulseOrder = 1, // TString histoOptions = "SRM", bool ProduceGraphic = true, bool stats = true, bool saveResults = false, // bool fitdata = false, bool debugPixel = false, // int refresh_rate = 500, //refresh rate for canvases int verbosityLevel = 1 // different verbosity levels can be implemented here ) { InputPath = SetHostsPaths(true, InputPath ); OutPutPath = SetHostsPaths(true, OutPutPath ); TString outFile = OutPutPath; outFile += OutputRootFileName; //---------------------------------------------------------------------------- // Open-Root-File Settings //---------------------------------------------------------------------------- if (verbosityLevel > 0) { cout << endl << "...load root file" << endl; } TFile * inputRootFile = LoadRootFile( InputPath, InRootFileName, verbosityLevel ); if (inputRootFile == NULL) { cerr << "input file not readable, check file path!!!" << endl; return(0); } if (saveResults) { CreateRootFile( outFile, true, verbosityLevel ); } TFile * outputRootFile = OpenRootFile( OutPutPath, OutputRootFileName, verbosityLevel ); //---------------------------------------------------------------------------- // Define operation range //---------------------------------------------------------------------------- if ( npixel == -1 ) { npixel = NPIX - firstpixel; } if ( pixelSetSize == -1 ) { pixelSetSize = firstpixel +npixel; } // float GainMean = GainMean; // this has to be extracted from root files // float BSLMean = BSLMean; // this has to be extracted from root files //---------------------------------------------------------------------------- // root global Settings //---------------------------------------------------------------------------- if (verbosityLevel > 0) { cout << endl << "...setting up root environment" ; } gStyle->SetPalette(1,0); gROOT->SetStyle("Plain"); // gPad->SetGrid(); //---------------------------------------------------------------------------- // root Canvas Settings //---------------------------------------------------------------------------- if (verbosityLevel > 0) { cout << endl << "...preparing canvases" << endl; } //Canvas Pad numbering int PixelCanvasFrameNrs[8] = { 1, // Top left 2, // Top mid left 3, // Top mid right 4, // Top right 5, // bootom left 6, // bootom mid left 7, // bottom mid right 8 // bootom right }; // //Canvas Pad numbering // int DistributionCanvasFrameNrs[4] = { // 1, // Top left // 2, // Top right // 3, // bottom left // 4 // bootom right // }; if (ProduceGraphic) { //Canvases cgpPixelPulses = new TCanvas*[maxPulseOrder]; cgpDistributions = new TCanvas*[maxPulseOrder]; cgpGraphs = new TCanvas("graphs", "Dependences to pe" ); //TCanvas* gpcDevelopment = NULL; TString cName = ""; TString cTitle = ""; //naming of pulse canvases for ( int pulse_order = maxPulseOrder - 1; pulse_order >= 0 ; pulse_order-- ) { cName ="cgpDistributions"; cName += pulse_order; cTitle ="Distributions of Pulses with Order of: "; cTitle += pulse_order; cgpDistributions[pulse_order] = new TCanvas(cName,cTitle, 720,pulse_order*20,720,720); // cgpDistributions[pulse_order]->Divide(2, 2); cName ="cgpPixelPulses"; cName += pulse_order; cTitle ="Overlays of Pulses with Order of: "; cTitle += pulse_order; cgpPixelPulses[pulse_order] = new TCanvas(cName,cTitle, 0,pulse_order*20,800,800); cgpPixelPulses[pulse_order]->Divide(4, 2); } cgpGraphs->Divide(1,3); } //----------------------------------------------------------------------------- // Filter-Settings //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Distrribution Histograms //----------------------------------------------------------------------------- TH1D hBsl[maxPulseOrder]; TH1D hAsymptote[maxPulseOrder]; TH1D hT0[maxPulseOrder]; TH1D hTau1[maxPulseOrder]; TH1D hTau2[maxPulseOrder]; TH1D hIntegral[maxPulseOrder]; TH1D hAmplitude[maxPulseOrder]; TH1D hRiseTime[maxPulseOrder]; //Lopp over pulse order configure distribution histograms for (int i = 0; i 0) { cout << endl << "...preparing pixels" << endl; } Pixel** pixel = new Pixel*[NPIX]; for (int i = 0 ; i < NPIX; i++) { pixel[i] = NULL; } PixelSum* wholeCamera = NULL; bool first_pass = true; //---------------------------------------------------------------------------- // Initialize Outputfiles //---------------------------------------------------------------------------- Csv PixelCsv(OutPutPath, InRootFileName.Remove(12, 5), "points", verbosityLevel); PixelCsv.WritePointSetHeader(); Csv PixelModelCsv(OutPutPath, InRootFileName.Remove(12, 5), "fitResults", verbosityLevel); PixelModelCsv.WritePulseAttributesHeader(); // Csv AllPixelCsv(OutPutPath, InRootFileName.Remove(12, 5), -1, verbosityLevel); // Csv AllPixelModelCsv(OutPutPath, InRootFileName.Remove(12, 5), "AllPixelModel", verbosityLevel); TCanvas pulses("Templates","Templates", 0,0,1200,600); pulses.Divide(3,1); //------------------------------------- // Loop over Pixel Sets //------------------------------------- for ( int firstPixelOfSet = firstpixel; firstPixelOfSet < firstpixel + npixel; firstPixelOfSet += pixelSetSize ) { if (verbosityLevel >= 0) { cout << "------------------------------------------------" << endl << "...processing Pixel: " << firstPixelOfSet << " to Pixel: " << firstPixelOfSet+pixelSetSize-1 << endl; } //-------------------------------------------------------------------- // Loop over every Pixel of a Set of Pixels //-------------------------------------------------------------------- for ( int pixelID = firstPixelOfSet; pixelID < firstPixelOfSet + pixelSetSize && pixelID < firstpixel + npixel; pixelID++ ) { if (verbosityLevel >= 0) { cout << "------------------------------------------------" << endl << "...processing Pixel: " << pixelID << "/" << firstPixelOfSet + pixelSetSize - 1 << endl; } if (verbosityLevel > 1) { cout << "-------------------------------------" << endl << "...processing Set from Pixel " << firstPixelOfSet << " to Pixel " << firstPixelOfSet+pixelSetSize-1 << " Pixel: " << pixelID << "/" << firstpixel + npixel -1 << endl; } //------------------------------------- // Create individual Pixel //------------------------------------- if (verbosityLevel > 3) { cout << "...creating pixel: " << pixelID << endl; } pixel[pixelID] = new Pixel( pixelID, maxPulseOrder, ///One should get this from the file verbosityLevel, stats, "L", 70, //pixelOverlayXaxisLeft /TODO: get it from the root file 230, //pixelOverlayXaxisRight /TODO: get it from the root file -1, //bslMean /TODO: get it from the root file 9, //gain mean /TODO: get it from the root file inputRootFile, outputRootFile ); if (breakout) break; //Preparing Camera if (first_pass) { if (verbosityLevel > 0) { cout << endl << "...preparing camera" << endl; } wholeCamera = new PixelSum( "AllPixel", 1440, maxPulseOrder, verbosityLevel, stats, "C", pixel[pixelID]->mPixelOverlayXaxisLeft, pixel[pixelID]->mPixelOverlayXaxisRight , pixel[pixelID]->mBSLMean , pixel[pixelID]->mGainMean , outputRootFile ); first_pass = false; } //------------------------------------- // Histogramms of Maximas in Overlay Spectra //------------------------------------- for ( int pulse_order = 0 ; pulse_order < pixel[pixelID]->mMaxPulseOrder ; pulse_order ++) { if (verbosityLevel > 2) { cout << "-------------------------------------" << endl << "...processing Set from Pixel " << firstPixelOfSet << " to Pixel " << firstPixelOfSet+pixelSetSize-1 << " Pixel: " << pixelID << "/" << firstpixel + npixel -1 << " Pulse-Order: " << pulse_order << endl; } // Calculate Max Prop. Value of each slice //------------------------------------- //from Maximum Overlay if (verbosityLevel > 2) { cout << "...extracting templates from Maximum Overlay " << endl; } ExtractPulseTemplate( pixel[pixelID], "Maximum", pulse_order, 10, verbosityLevel ); //from Edge Overlay if (verbosityLevel > 2) { cout << "...extracting templates from Edge Overlay " << endl; } ExtractPulseTemplate( pixel[pixelID], "Edge", pulse_order, 10, verbosityLevel ); // ShiftStartOfHistoInXTo( // pixel[pixelID]->hEdgeOverlay[pulse_order], // 0 // ); // ShiftStartOfHistoInXTo( // pixel[pixelID]->hMaxOverlay[pulse_order], // 0 // ); PixelCsv.WritePointSet( pixel[pixelID], "Maximum", pulse_order ); PixelCsv.WritePointSet( pixel[pixelID], "Edge", pulse_order ); if ( saveResults ) { WritePixelTemplateToCsv( pixel[pixelID], OutPutPath, "Maximum", pulse_order, verbosityLevel ); WritePixelTemplateToCsv( pixel[pixelID], OutPutPath, "Edge", pulse_order, verbosityLevel ); } if (ProduceGraphic && debugPixel) { // pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetXaxis()->SetLimits( // 0, // 300 // ); // pixel[pixelID]->hPixelEdgeMean[pulse_order]->GetXaxis()->SetLimits( // 0, // 300 // ); // pixel[pixelID]->hPixelEdgeMedian[pulse_order]->GetXaxis()->SetLimits( // 0, // 300 // ); // pixel[pixelID]->hPixelMax[pulse_order]->GetXaxis()->SetLimits( // 0, // 300 // ); // pixel[pixelID]->hPixelMean[pulse_order]->GetXaxis()->SetLimits( // 0, // 300 // ); // pixel[pixelID]->hPixelMedian[pulse_order]->GetXaxis()->SetLimits( // 0, // 300 // ); // pixel[pixelID]->hEdgeProfile[pulse_order]->GetXaxis()->SetLimits( // 0, // 300 // ); // pixel[pixelID]->ShiftHistoInY( // pixel[pixelID]->hPixelEdgeMax[pulse_order], // 0.25 // ); pixel[pixelID]->DrawTemplateHistograms( cgpPixelPulses, PixelCanvasFrameNrs ); pixel[pixelID]->DrawEdgeTemplateHistograms( cgpPixelPulses, PixelCanvasFrameNrs ); // cgpPixelPulses[pulse_order]->cd(6); //------------------------------------- //------------------------------------- // Test Area //------------------------------------- //------------------------------------- cgpPixelPulses[pulse_order]->cd(8); // pixel[pixelID]->hEdgeProfile[pulse_order]->SetLineColor(kBlack); // Pulse pulseMean("PulseMean", pixel[pixelID]->hEdgeProfile[pulse_order], 0); // double fit_parameters5[3]; // fit_parameters5[0] = fit_parameters[0]; // fit_parameters5[0] = fit_parameters[0]; // FitPulse( // "hugo3", // pixel[pixelID]->hPixelEdgeMax[pulse_order], // pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetMaximumBin()-12, // pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetMaximumBin(), // fit_parameters5 // ); // cout << "Parameters\t" << fit_parameters[0] << "\n" // << fit_parameters[1] << "\n" // << fit_parameters[2] << "\n" << endl; // TF1 *func = new TF1("func", template_function, 0, 300, 10); // func->SetParameters( // -0.5, // bsl // pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetXaxis()->GetFirst() + 50, // pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetMaximumBin() // ); // range // func->SetParNames("baseline", // "begin of pol3", "begin of exp", // "exp-factor", "exp-tau", "ext-t0", // "pol3_0", "pol3_1", "pol3_2", "pol3_3" // ); // pixel[pixelID]->hPixelEdgeMax[pulse_order]->Fit(func); // TH1F* hTest = new TH1F( // "hTest", // "Test", // pixel[pixelID]->mPixelOverlayXaxisLeft // + pixel[pixelID]->mPixelOverlayXaxisRight , // (-1*pixel[pixelID]->mPixelOverlayXaxisLeft)-0.5, // pixel[pixelID]->mPixelOverlayXaxisRight-0.5 // ); // hTest->GetXaxis()->SetLimits( // 0, // 300 // ); // for (int bin = 0; // bin < pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetXaxis()->GetLast(); // bin++ // ) // { // hTest->SetBinContent( bin, (-1)*(fit_parameters[0]+TMath::Exp(fit_parameters[1]+fit_parameters[2]*(bin))) ); // } // hTest->Add(pixel[pixelID]->hPixelEdgeMax[pulse_order], 1); // cgpPixelPulses[pulse_order]->cd(7); // hTest->Draw(); // for (int bin = 0; // bin < pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetXaxis()->GetLast(); // bin++ // ) // { // hTest->SetBinContent( bin, (-1)*(hTest->GetBinContent(bin)) ); // } // double fit_parameters2[3]; // FitFallingEdge( // "hugo2", // hTest, // hTest->GetXaxis()->GetFirst()+68, // hTest->GetXaxis()->GetFirst()+80, // fit_parameters2 // ); // cgpPixelPulses[pulse_order]->cd(8); // TH1F* hTest2 = new TH1F( // "hTest2", // "Test", // pixel[pixelID]->mPixelOverlayXaxisLeft // + pixel[pixelID]->mPixelOverlayXaxisRight , // (-1*pixel[pixelID]->mPixelOverlayXaxisLeft)-0.5, // pixel[pixelID]->mPixelOverlayXaxisRight-0.5 // ); // hTest2->GetXaxis()->SetLimits( // 0, // 300 // ); // for (int bin = 0; // bin < pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetXaxis()->GetLast(); // bin++ // ) // { // hTest2->SetBinContent( bin, (-1)*(hTest->GetBinContent(bin)) ); // } // double fit_parameters3[3]; // FitRisingEdge( // "hugo3", // hTest2, // hTest2->GetXaxis()->GetFirst()+68, // hTest2->GetXaxis()->GetFirst()+80, // fit_parameters3 // ); // hTest2->Draw(); //------------------------------------- //------------------------------------- // EOF Test Area //------------------------------------- //------------------------------------- } // ======================================================= // Fit of pulse function to template Pulse* pulseFits[6]; // pulses.cd(1); Pulse maxMaxPulse("maxMaxPulse", pixel[pixelID]->hPixelMax[pulse_order], "Q", 1); pulseFits[0] = &maxMaxPulse; // pulses.cd(2); Pulse maxMedianPulse("maxMedianPulse", pixel[pixelID]->hPixelMedian[pulse_order], "Q",1); pulseFits[1] = &maxMedianPulse; // pulses.cd(3); Pulse maxMeanPulse("maxMeanPulse", pixel[pixelID]->hPixelMean[pulse_order], "Q",1); pulseFits[2] = &maxMeanPulse; Pulse edgeMaxPulse("edgeMaxPulse", pixel[pixelID]->hPixelEdgeMax[pulse_order], "Q",1); pulseFits[3] = &edgeMaxPulse; Pulse edgeMedianPulse("edgeMedianPulse", pixel[pixelID]->hPixelEdgeMedian[pulse_order], "Q",1); pulseFits[4] = &edgeMedianPulse; Pulse edgeMeanPulse("edgeMeanPulse", pixel[pixelID]->hPixelEdgeMean[pulse_order], "Q",1); pulseFits[5] = &edgeMeanPulse; //-------------------------------------------------------- //Write parameters from pulse fit to CSV for (int i = 0; i < 6; i++) { PixelModelCsv.WritePulseAttributes( pixel[pixelID], pulseFits[i], "Edge_pix", pulse_order ); } //------------------------------------- // Fill Error Histogramms //------------------------------------- for (int i = pixel[pixelID]->hPixelEdgeMedian[pulse_order]->GetXaxis()->GetFirst(); i <= pixel[pixelID]->hPixelEdgeMedian[pulse_order]->GetXaxis()->GetLast(); i++) { hMedianErrors[pulse_order].SetBinContent( i, pixel[pixelID]->hPixelEdgeMedian[pulse_order]->GetBinError(i) ); hMeanErrors[pulse_order].SetBinContent( i, pixel[pixelID]->hPixelEdgeMean[pulse_order]->GetBinError(i) ); hMaxErrors[pulse_order].SetBinContent( i, pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetBinError(i) ); } if (ProduceGraphic && debugPixel) { int current_order = 0; pulses.cd(1); hMaxErrors[current_order].Draw(); pulses.cd(2); hMedianErrors[current_order].Draw(); pulses.cd(3); hMeanErrors[current_order].Draw(); pulses.Update(); } //------------------------------------- // Fill Distribution Histogramms //------------------------------------- hBsl[pulse_order].Fill( edgeMedianPulse.GetBsl() ); hAsymptote[pulse_order].Fill( edgeMedianPulse.GetHeight() ); hT0[pulse_order].Fill( edgeMedianPulse.GetT0() ); hTau1[pulse_order].Fill( edgeMedianPulse.GetTau1() ); hTau2[pulse_order].Fill( edgeMedianPulse.GetTau2() ); hIntegral[pulse_order].Fill( edgeMedianPulse.GetIntegral()); hAmplitude[pulse_order].Fill( edgeMedianPulse.GetAmplitude()); hRiseTime[pulse_order].Fill( edgeMedianPulse.GetRiseTime()); //------------------------------------- // Fill Distribution Graphs //------------------------------------- grPheVsAmpl.Set(grPheVsAmpl.GetN()+1); grPheVsIntegral.Set(grPheVsIntegral.GetN()+1); grPheVsAmpl.SetPoint( grPheVsAmpl.GetN()-1, edgeMedianPulse.GetPhE(), edgeMedianPulse.GetAmplitude() ); grPheVsAmpl.SetPointError( grPheVsAmpl.GetN()-1, edgeMedianPulse.GetPhEErr(), edgeMedianPulse.GetAmplitudeErr() ); grPheVsIntegral.SetPoint( grPheVsIntegral.GetN()-1, edgeMedianPulse.GetPhE(), edgeMedianPulse.GetIntegral() ); grPheVsAmpl.SetPointError( grPheVsIntegral.GetN()-1, edgeMedianPulse.GetPhEErr(), edgeMedianPulse.GetIntegralErr() ); grPheVsTau2.SetPoint( grPheVsIntegral.GetN()-1, edgeMedianPulse.GetPhE(), edgeMedianPulse.GetTau2() ); grPheVsTau2.SetPointError( grPheVsIntegral.GetN()-1, edgeMedianPulse.GetPhE(), edgeMedianPulse.GetTau2Err() ); // cgpDistributions[pulse_order].cd(1); // FitMaxPropabilityPuls( // pixel[pixelID]->hPixelEdgeMean[pulse_order], // verbosityLevel // ); //------------------------------------- // Fill Histogramms of Camera //------------------------------------- wholeCamera->hMaxOverlay[pulse_order]->Add( pixel[pixelID]->hMaxOverlay[pulse_order] ); wholeCamera->hMaxProfile[pulse_order]->Add( pixel[pixelID]->hMaxProfile[pulse_order] ); wholeCamera->hEdgeOverlay[pulse_order]->Add( pixel[pixelID]->hEdgeOverlay[pulse_order] ); wholeCamera->hEdgeProfile[pulse_order]->Add( pixel[pixelID]->hEdgeProfile[pulse_order] ); //------------------------------------- // Comparisons //------------------------------------- //chi2 test // float chi2 = // pixel[pixelID]->hPixelEdgeMean[pulse_order]->Chi2Test( // pixel[pixelID]->hPixelMean[pulse_order], // "UUPCHI2" // ); // cout << "p-Value :" << chi2 << endl; // wholeCamera->hChi2EdgetoMax[pulse_order]->Fill(chi2); // cgpDistributions[pulse_order]->cd(); // wholeCamera->hChi2EdgetoMax[pulse_order]->Draw(); if (verbosityLevel > 2) { cout << endl << "...End of pulseorder " << pulse_order << endl; } } // End of Loop over pulsorder of current Pixel if (ProduceGraphic && debugPixel) { UpdateCanvases( verbosityLevel, MAX_PULS_ORDER, false ); } if (debugPixel) { //Process gui events asynchronously during input cout << endl; TTimer timer("gSystem->ProcessEvents();", 50, kFALSE); timer.TurnOn(); TString input = Getline("Type 'q' to exit, Type 's' to exit set, to go on: "); timer.TurnOff(); if (input=="q\n") { return(0); } if (input=="s\n") { break; } } if ( saveResults ) { pixel[pixelID]->SavePixelHistograms( outFile, saveResults ); } //deleteCurrent Pixel from Heap delete pixel[pixelID]; pixel[pixelID] = NULL; if (verbosityLevel > 2) { cout << endl << "...End of Pixel" << endl << "------------------------------------------------" << endl; } } // End of Loop over all Pixels of set if (verbosityLevel > 1) { cout << endl << "...End of Loop over all Pixels of set" << endl << "------------------------------------------------" << endl; } } // End of Loop over all Pixelsets if (verbosityLevel > 0) { cout << endl << "...End of Loop over all Pixelsets" << endl << "------------------------------------------------" << endl; } delete[] pixel; pixel = NULL; //------------------------------------- // Draw All Pixel Histograms //------------------------------------- for ( int pulse_order = 0 ; pulse_order < wholeCamera->mMaxPulseOrder ; pulse_order ++) { if (verbosityLevel > 2) { cout << "-------------------------------------" << endl << "...processing Pulse-Order: " << pulse_order; } // Calculate Max Prop. Value of each slice //------------------------------------- //from Maximum Overlay ExtractPulseTemplate( wholeCamera, "Maximum", pulse_order, 10, verbosityLevel ); if ( saveResults ) { WritePixelTemplateToCsv( wholeCamera, OutPutPath, "Maximum", pulse_order, verbosityLevel ); } //from Edge Overlay ExtractPulseTemplate( wholeCamera, "Edge", pulse_order, 10, verbosityLevel ); if ( saveResults ) { WritePixelTemplateToCsv( wholeCamera, OutPutPath, "Edge", pulse_order, verbosityLevel ); } if (ProduceGraphic) { wholeCamera->DrawTemplateHistograms( cgpPixelPulses, PixelCanvasFrameNrs ); wholeCamera->DrawEdgeTemplateHistograms( cgpPixelPulses, PixelCanvasFrameNrs ); } ShiftStartOfHistoInXTo( wholeCamera->hEdgeOverlay[0], 0 ); ShiftStartOfHistoInXTo( wholeCamera->hMaxOverlay[0], 0 ); // ======================================================= // Fit of pulse function to template Pulse* allPulseFits[6]; pulses.cd(1); Pulse maxCamMaxPulse("maxMaxPulse", wholeCamera->hPixelMax[pulse_order], "Q", 1); allPulseFits[0] = &maxCamMaxPulse; pulses.cd(2); Pulse maxCamMedianPulse("maxMedianPulse", wholeCamera->hPixelMedian[pulse_order], "Q", 1); allPulseFits[1] = &maxCamMedianPulse; pulses.cd(3); Pulse maxCamMeanPulse("maxMeanPulse", wholeCamera->hPixelMean[pulse_order],"Q", 1); allPulseFits[2] = &maxCamMeanPulse; Pulse edgeCamMaxPulse("edgeMaxPulse", wholeCamera->hPixelEdgeMax[pulse_order], "Q", 1); allPulseFits[3] = &edgeCamMaxPulse; Pulse edgeCamMedianPulse("edgeMedianPulse", wholeCamera->hPixelEdgeMedian[pulse_order],"Q", 1); allPulseFits[4] = &edgeCamMedianPulse; Pulse edgeCamMeanPulse("edgeMeanPulse", wholeCamera->hPixelEdgeMean[pulse_order], "Q", 1); allPulseFits[5] = &edgeCamMeanPulse; //-------------------------------------------------------- //Write parameters from pulse fit to CSV for (int i = 0; i < 6; i++) { PixelModelCsv.WritePulseAttributes( wholeCamera, allPulseFits[i], "Edge", pulse_order ); } } //EOF: Draw All Pixel Histograms //------------------------------------- // Draw Parameter Distributions //------------------------------------- if (ProduceGraphic) { cgpGraphs->cd(1); if (verbosityLevel > 0) cout << "...drawing grPheVsAmpl" << endl; grPheVsAmpl.Draw("AP"); cgpGraphs->cd(2); if (verbosityLevel > 0) cout << "...drawing grPheVsIntegral" << endl; grPheVsIntegral.Draw("AP"); cgpGraphs->cd(3); if (verbosityLevel > 0) cout << "...drawing grPheVsTau2" << endl; grPheVsTau2.Draw("AP"); cgpGraphs->Update(); for (int i = 0; i < maxPulseOrder; i++){ cgpDistributions[i]->Divide(4,2); cgpDistributions[i]->cd(1); hBsl[i].Draw(); cgpDistributions[i]->cd(2); hAsymptote[i].Draw(); cgpDistributions[i]->cd(3); hT0[i].Draw(); cgpDistributions[i]->cd(4); hTau1[i].Draw(); cgpDistributions[i]->cd(5); hTau2[i].Draw(); cgpDistributions[i]->cd(6); hIntegral[i].Draw(); cgpDistributions[i]->cd(7); hAmplitude[i].Draw(); cgpDistributions[i]->cd(8); hRiseTime[i].Draw(); } } //------------------------------------- // Save All Pixel Histograms //------------------------------------- if ( saveResults ) { wholeCamera->SavePixelHistograms( outFile, saveResults ); } if (ProduceGraphic) { UpdateCanvases( verbosityLevel, MAX_PULS_ORDER, false ); //Process gui events asynchronously during input cout << endl; TTimer timer("gSystem->ProcessEvents();", 50, kFALSE); timer.TurnOn(); TString input = Getline("press to exit: "); timer.TurnOff(); cout << input ; } //------------------------------------- // Delete Objects on Heap //------------------------------------- delete wholeCamera; if (ProduceGraphic) { DeletePixelCanvases( maxPulseOrder ,verbosityLevel ); } delete inputRootFile; delete outputRootFile; return( 0 ); } //---------------------------------------------------------------------------- // end of main function //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Funktions //----------------------------------------------------------------------------- void DeletePixelCanvases( int maxPulseOrder, int verbosityLevel ) { if (verbosityLevel > 2) { cout << endl << "...delete pixel Canvases" << endl; } for ( int pulse_order = 0; pulse_order < maxPulseOrder; pulse_order++ ) { delete cgpPixelPulses[pulse_order]; cgpPixelPulses[pulse_order] = NULL; delete cgpDistributions[pulse_order]; cgpDistributions[pulse_order] = NULL; } delete[] cgpPixelPulses; cgpPixelPulses = NULL; delete[] cgpDistributions; cgpDistributions = NULL; } void UpdateCanvases( int verbosityLevel, int max_pulse_order, bool testmode ) { if (verbosityLevel > 3) { cout << endl << "...updating canvases" << endl; } for (int pulse_order = 0; pulse_order < max_pulse_order; pulse_order++) { cgpPixelPulses[pulse_order]->Modified(); cgpPixelPulses[pulse_order]->Update(); cgpDistributions[pulse_order]->Modified(); cgpDistributions[pulse_order]->Update(); // if ( testmode ) // { // cgpTestHistos->Modified(); // cgpTestHistos->Update(); // } } } //----------------------------------------------------------------------------- // MAIN Funktion for C compilation //----------------------------------------------------------------------------- int main(int argc,char *argv[]) { // Int_t index; TString test; TString rcFileName; TString processType = "template"; bool rcFileNameCmdSet = false; int verbLevel = 0; // different verbosity levels can be implemented here bool verbLevelCmdSet = false; bool save = false; bool produceGraphic = false; // TString inputRootFile = "test.root"; // TString inputPath = ""; // TString outputRootFile = "test.root"; // TString outPutPath = ""; // int firstPixel = 0; // int nPixel = -1; // int pixelSetSize = 40; // int maxOrder = 3; // bool dbgPixel = false; // bool fitdata = false; // bool printStats = false; // decode arguments if(argc < 2) { printf("no arguements given, using standard arguments\n"); } // set conditions for functions arguments for (int i=1;i