#include #include #include #include #include "rootfilehandler.h" #include "pixel.h" // class implemented using namespace std; /////////////////////////////// PUBLIC /////////////////////////////////////// //============================= LIFECYCLE ==================================== Pixel::Pixel( int pixelID, int maxPulsorder, int verbosityLevel, bool stats, TString options, int pixelOverlayXaxisLeft, int pixelOverlayXaxisRight, float bSLMean, float gainMean, TFile* filename, TFile* outfilename ) { mConstructorType = 1; //important for deletion 0 delete distribution 1 delete TemplateHistos mChid = pixelID; mMaxPulseOrder = maxPulsorder; mVerbosityLevel = verbosityLevel; mStats = stats; mOptions = options; mPixelOverlayXaxisLeft = pixelOverlayXaxisLeft; mPixelOverlayXaxisRight = pixelOverlayXaxisRight; mBSLMean = bSLMean; mGainMean = gainMean; mRootFile = filename; mOutRootFile = outfilename; hMaxOverlay = new TH2F*[mMaxPulseOrder]; hEdgeOverlay = new TH2F*[mMaxPulseOrder]; hMaxProfile = new TProfile*[mMaxPulseOrder]; hEdgeProfile = new TProfile*[mMaxPulseOrder]; hPixelMax = new TH1F*[mMaxPulseOrder]; hPixelMedian = new TH1F*[mMaxPulseOrder]; hPixelMean = new TH1F*[mMaxPulseOrder]; hPixelEdgeMax = new TH1F*[mMaxPulseOrder]; hPixelEdgeMedian = new TH1F*[mMaxPulseOrder]; hPixelEdgeMean = new TH1F*[mMaxPulseOrder]; hList = new TList(); hMemberlist = new TList(); if (mOptions.Contains("C") ) { hChi2EdgetoMax = new TH1F*[mMaxPulseOrder]; } if (options.Contains("L")) { LoadPulseHistos( ); } else { BookPixelHistos(); } if (mOptions.Contains("C")) { BookDistributionHistos(); } BookTemplateHistos(); BookEdgeTemplateHistos(); } Pixel::Pixel( int pixelID, int maxPulsorder, int verbosityLevel, bool stats, TString options, int pixelOverlayXaxisLeft, int pixelOverlayXaxisRight, float bSLMean, float gainMean ) { mConstructorType = 0; mChid = pixelID; mMaxPulseOrder = maxPulsorder; mVerbosityLevel = verbosityLevel; mStats = stats; ///TODO: HANDOVER THE VALUE mOptions = options; mPixelOverlayXaxisLeft = pixelOverlayXaxisLeft; mPixelOverlayXaxisRight = pixelOverlayXaxisRight; mBSLMean = bSLMean; mGainMean = gainMean; hMaxOverlay = new TH2F*[mMaxPulseOrder]; hEdgeOverlay = new TH2F*[mMaxPulseOrder]; hMaxProfile = new TProfile*[mMaxPulseOrder]; hEdgeProfile = new TProfile*[mMaxPulseOrder]; if (mOptions.Contains("S") ) { hSlopeRisingEdge = new TH1F*[mMaxPulseOrder]; } if (mOptions.Contains("R") ) { hRisingEdgeToMax = new TH1I*[mMaxPulseOrder]; } if (mOptions.Contains("M") ) { hPosOfMax = new TH1I*[mMaxPulseOrder]; } hList = new TList(); hMemberlist = new TList(); BookPixelHistos(); BookDistributionHistos(); } Pixel::~Pixel() { if (mVerbosityLevel > 1) { cout << endl << "...delete histograms of pixel " << mChid ; cout << endl << "...mConstructorType = " << mConstructorType ; } if (mConstructorType == 0) { DeleteDistributionHistos(); } if (mConstructorType == 1) { DeleteTemplateHistos(); DeleteEdgeTemplateHistos(); } DeletePixelHistos(); delete hList; delete hMemberlist; hList = NULL; hMemberlist = NULL; if (mVerbosityLevel > 1) { cout << endl << "...histograms of pixel " << mChid ; cout << "...deleted " << endl ; } }// ~Pixel //============================= OPERATORS ==================================== //XX& //XX::operator=(const XX&); //{ // return *this; //}// = //============================= OPERATIONS =================================== void Pixel::DrawOverlayHistograms( TCanvas** pixelCanvas, int* histoFrameNr ) { if (mVerbosityLevel > 2) cout << endl << "...drawing pulse histograms" ; for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++) { pixelCanvas[pulse_order]->cd( histoFrameNr[0] ); hMaxOverlay[pulse_order]->Draw("COLZ"); pixelCanvas[pulse_order]->cd( histoFrameNr[2] ); hMaxProfile[pulse_order]->Draw(); pixelCanvas[pulse_order]->cd( histoFrameNr[1] ); hEdgeOverlay[pulse_order]->Draw("COLZ"); pixelCanvas[pulse_order]->cd( histoFrameNr[3] ); hEdgeProfile[pulse_order]->Draw(); } } // end of DrawOverlayHistograms //---------------------------------------------------------------------------- void Pixel::DrawDistributionHistograms( TCanvas** pixelCanvas, int* histoFrameNr ) { if (mVerbosityLevel > 2) cout << endl << "...drawing distribution histograms" ; bool nothing_to_fill = true; for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++) { if (mOptions.Contains("S") ) { pixelCanvas[pulse_order]->cd( histoFrameNr[0] ); hSlopeRisingEdge[pulse_order]->Draw(); nothing_to_fill = false; } if (mOptions.Contains("R") ) { pixelCanvas[pulse_order]->cd( histoFrameNr[1] ); hRisingEdgeToMax[pulse_order]->Draw(); nothing_to_fill = false; } if (mOptions.Contains("M") ) { pixelCanvas[pulse_order]->cd( histoFrameNr[2] ); hPosOfMax[pulse_order]->Draw(); nothing_to_fill = false; } } if (nothing_to_fill) { cout << endl << "there were NO DISTRIBUTION HISTOGRAMS to fill" << endl; } } // end of DrawDistributionHistograms //---------------------------------------------------------------------------- void Pixel::DrawTemplateHistograms( TCanvas** pixelCanvas, int* histoFrameNr ) { int mrkStyle =1; int mrkSize = 2; if (mVerbosityLevel > 2) cout << "...drawing Template histograms" << endl ; for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++) { pixelCanvas[pulse_order]->cd( histoFrameNr[0] ); hMaxOverlay[pulse_order]->Draw("COLZ"); pixelCanvas[pulse_order]->cd( histoFrameNr[1] ); hPixelMax[pulse_order]->Draw("E1"); hPixelMax[pulse_order]->SetMarkerColor(kBlue); hPixelMax[pulse_order]->SetLineColor(kBlack); hPixelMax[pulse_order]->SetMarkerStyle(mrkStyle); hPixelMax[pulse_order]->SetMarkerSize(mrkSize); pixelCanvas[pulse_order]->cd( histoFrameNr[2] ); hPixelMedian[pulse_order]->Draw("E1"); hPixelMedian[pulse_order]->SetMarkerColor(kBlue); hPixelMedian[pulse_order]->SetLineColor(kBlack); hPixelMedian[pulse_order]->SetMarkerStyle(mrkStyle); hPixelMedian[pulse_order]->SetMarkerSize(mrkSize); pixelCanvas[pulse_order]->cd( histoFrameNr[3] ); hPixelMean[pulse_order]->Draw("E1"); hPixelMean[pulse_order]->SetMarkerColor(kBlue); hPixelMean[pulse_order]->SetLineColor(kBlack); hPixelMean[pulse_order]->SetMarkerStyle(mrkStyle); hPixelMean[pulse_order]->SetMarkerSize(mrkSize); // hPixelMax[pulse_order]->Draw("SAME"); // hPixelMedian[pulse_order]->Draw("SAME"); } } // end of DrawTemplateHistograms //---------------------------------------------------------------------------- void Pixel::DrawEdgeTemplateHistograms( TCanvas** pixelCanvas, int* histoFrameNr ) { int mrkStyle = 1; int mrkSize = 3; if (mVerbosityLevel > 2) cout << endl << "...drawing Template histograms" ; for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++) { pixelCanvas[pulse_order]->cd( histoFrameNr[4] ); hEdgeOverlay[pulse_order]->Draw("COLZ"); pixelCanvas[pulse_order]->cd( histoFrameNr[5] ); hPixelEdgeMax[pulse_order]->Draw("E1"); hPixelEdgeMax[pulse_order]->SetLineColor(kBlack); hPixelEdgeMax[pulse_order]->SetMarkerColor(kBlue); hPixelEdgeMax[pulse_order]->SetMarkerStyle(mrkStyle); hPixelEdgeMax[pulse_order]->SetMarkerSize(mrkSize); pixelCanvas[pulse_order]->cd( histoFrameNr[6] ); hPixelEdgeMedian[pulse_order]->Draw("E1"); hPixelEdgeMedian[pulse_order]->SetLineColor(kBlack); hPixelEdgeMedian[pulse_order]->SetMarkerColor(kBlue); hPixelEdgeMedian[pulse_order]->SetMarkerStyle(mrkStyle); hPixelEdgeMedian[pulse_order]->SetMarkerSize(mrkSize); pixelCanvas[pulse_order]->cd( histoFrameNr[7] ); hPixelEdgeMean[pulse_order]->Draw("E1"); hPixelEdgeMean[pulse_order]->SetLineColor(kBlack); hPixelEdgeMean[pulse_order]->SetMarkerColor(kBlue); hPixelEdgeMean[pulse_order]->SetMarkerStyle(mrkStyle); hPixelEdgeMean[pulse_order]->SetMarkerSize(mrkSize); // hPixelEdgeMax[pulse_order]->Draw("SAME"); // hPixelEdgeMedian[pulse_order]->Draw("SAME"); } } // end of DrawTemplateHistograms //---------------------------------------------------------------------------- void Pixel::SavePixelHistograms( TString outRootFileName, bool saveResults ) { if (mVerbosityLevel > 2) cout << endl << "Saving histograms of Pixel# " << mChid; if (!saveResults) return; SaveList( outRootFileName, CreateSubDirName( mChid ), hList, saveResults, mVerbosityLevel ); /* we also need to save same values: EXAMPLE root > TFile f("v.root","recreate") root > TVectorD v(1) root > v[0] = 3.14 root > v.Write("v") and to read the file do CODE: SELECT ALL root > TFile f("v.root") root > TVectorD *v = (TVectorD*)f.get("v"); root > v->Print() */ } // end of SavePixelHistograms //---------------------------------------------------------------------------- TString Pixel::HistoName( TString histoname, int order ) { histoname += mChid; histoname += "_"; histoname += order; return histoname; } TString Pixel::ChooseCycleNumber( TString histoname, int cycleNumber ) { histoname += ";"; histoname += cycleNumber; return histoname; } TString Pixel::HistoTitle( TString histo_title, int order ) { histo_title += " [Pixel_Order] "; histo_title += mChid; histo_title += "_"; histo_title += order; return histo_title; } TString Pixel::CsvFileName( TString path, TString overlayMethod, int order ) { path += "CSV/"; path += overlayMethod; path += "OverlayTemplate"; path += "_"; path += mChid; path += "_"; path += order; path += ".csv"; return path; } //============================= ACESS =================================== //============================= INQUIRY =================================== /////////////////////////////// PROTECTED /////////////////////////////////// /////////////////////////////// PRIVATE /////////////////////////////////// void Pixel::BookPixelHistos() { if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl; for (int order = 0; order < mMaxPulseOrder; order++) { if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hMaxOverlay", order) << endl; hMaxOverlay[order]=new TH2F( HistoName("hMaxOverlay", order), HistoTitle("Overlay at peak maximum of detected pulses of", order), mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight , (-1*mPixelOverlayXaxisLeft)-0.5, mPixelOverlayXaxisRight-0.5 , 512, -55.5, 200.5 ); hMaxOverlay[order]->SetAxisRange( mBSLMean - 5, (mGainMean*(order+1)) + 10, "Y"); hMaxOverlay[order]->SetDrawOption("colz"); hMaxOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); hMaxOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); //hMaxProfile->SetBit(TH2F::kCanRebin); hMaxOverlay[order]->SetStats(mStats); hList->Add( hMaxOverlay[order] ); //------------------------------------------------------------------------ if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hEdgeOverlay", order) << endl; hEdgeOverlay[order] = new TH2F( HistoName("hEdgeOverlay", order), HistoTitle("Overlay at rising edge of detected pulses of", order), mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight , (-1*mPixelOverlayXaxisLeft)-0.5, mPixelOverlayXaxisRight-0.5 , 512, -55.5, 200.5 ); hEdgeOverlay[order]->SetAxisRange( mBSLMean - 5, (mGainMean*(order+1)) + 10, "Y"); hEdgeOverlay[order]->SetDrawOption("colz"); hEdgeOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); hEdgeOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); hEdgeOverlay[order]->SetStats(mStats); hList->Add( hEdgeOverlay[order] ); //------------------------------------------------------------------------ if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hMaxProfile", order) << endl; hMaxProfile[order] = new TProfile( HistoName("hMaxProfile", order), HistoTitle("Mean value of each slice in overlay plot (Tprofile)", order), mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx (-1*mPixelOverlayXaxisLeft)-0.5, //xlow mPixelOverlayXaxisRight-0.5 , //xup // 512, //nbinsy -55.5, //ylow 300.5, //yup "s"); //option hMaxProfile[order]->SetAxisRange( mBSLMean - 5, (mGainMean*(order+1)) + 10, "Y"); hMaxProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); hMaxProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); //hMaxProfile->SetBit(TH2F::kCanRebin); hMaxProfile[order]->SetStats(mStats); hList->Add( hMaxProfile[order] ); //------------------------------------------------------------------------ if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hEdgeProfile", order) << endl; hEdgeProfile[order] = new TProfile( HistoName("hEdgeProfile", order), HistoTitle("Mean value of each slice in overlay plot (Tprofile)", order), mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx (-1*mPixelOverlayXaxisLeft)-0.5, //xlow mPixelOverlayXaxisRight-0.5 , //xup // 512, //nbinsy -55.5, //ylow 300.5, //yup "s"); //option hEdgeProfile[order]->SetLineColor(kRed); hEdgeProfile[order]->SetAxisRange( mBSLMean - 5, (mGainMean*(order+1)) + 10, "Y"); hEdgeProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); hEdgeProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); //hMaxProfile->SetBit(TH2F::kCanRebin); hEdgeProfile[order]->SetStats(mStats); hList->Add( hEdgeProfile[order] ); } if (mVerbosityLevel > 2) cout << "...done" << endl; } //end of BookPixelHistos //---------------------------------------------------------------------------- void Pixel::BookDistributionHistos( ) { if (!mOptions.IsNull() ) { int x_min = 0; int x_max = 0; for (int order =0; order < mMaxPulseOrder; order++) { if (mVerbosityLevel > 2) cout << endl << "...book distribution histograms" << endl; if (mOptions.Contains("S")) { if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hSlopeRisingEdge", order) << endl; hSlopeRisingEdge[order] = new TH1F ( HistoName("hSlopeRisingEdge", order), HistoTitle("Distribution of rising edge's slope", order), 600, -10.1, 10.1 ); hSlopeRisingEdge[order]->SetAxisRange( -1, 7, "X"); hSlopeRisingEdge[order]->GetXaxis()->SetTitle( "Slope Amplitude/time [mV/timeslices]" ); hSlopeRisingEdge[order]->GetYaxis()->SetTitle( "counts" ); hSlopeRisingEdge[order]->SetStats(mStats); hList->Add( hSlopeRisingEdge[order] ); } if (mOptions.Contains("R")) { x_min = -15; x_max = 35; if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hRisingEdgeToMax", order) << endl; hRisingEdgeToMax[order] = new TH1I ( HistoName("hRisingEdgeToMax", order), HistoTitle("Distribution of distance between rising edge and pulse's maximum", order), x_max -x_min, x_min, x_max ); hSlopeRisingEdge[order]->SetAxisRange( -5, 25, "X"); hRisingEdgeToMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); hRisingEdgeToMax[order]->GetYaxis()->SetTitle( "counts" ); hRisingEdgeToMax[order]->SetStats(mStats); hList->Add( hRisingEdgeToMax[order] ); } if (mOptions.Contains("M")) { x_min = 10; x_max = 290; if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPosOfMax", order) << endl; hPosOfMax[order] = new TH1I ( HistoName("hPosOfMax", order), HistoTitle("Distribution of pulse's maximum's positon", order), x_max - x_min, x_min, x_max ); hPosOfMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); hPosOfMax[order]->GetYaxis()->SetTitle( "counts" ); hRisingEdgeToMax[order]->SetStats(mStats); hList->Add( hPosOfMax[order] ); } if (mOptions.Contains("C")) { if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hSlopeRisingEdge", order) << endl; hChi2EdgetoMax[order] = new TH1F ( HistoName("hChi2EdgetoMax", order), HistoTitle("Distribution of CHI2 comparison of Edge and Max", order), 600, -299, 300 ); hChi2EdgetoMax[order]->SetAxisRange( -1, 7, "X"); hChi2EdgetoMax[order]->GetXaxis()->SetTitle( "p-Value" ); hChi2EdgetoMax[order]->GetYaxis()->SetTitle( "counts" ); hChi2EdgetoMax[order]->SetStats(mStats); // hList->Add( hChi2EdgetoMax[order] ); } if (mVerbosityLevel > 2) cout << "...done" << endl; } // Arrival Time Distributions //---------------------------------- if (mVerbosityLevel > 3) cout << "\t...booking " << "hMaxPos" << endl; hMaxPos = new TH1F ( "hMaxPos", "Distribution of arrival times according to the EdgePos", 1025, -1, 1024 ); // hMaxPos->SetAxisRange( // 0, // 1024, // "X"); hMaxPos->SetDrawOption("colz"); hMaxPos->GetXaxis()->SetTitle( " arrival time [timeslices]" ); hMaxPos->GetYaxis()->SetTitle( "counts" ); hMaxPos->SetStats(mStats); hList->Add( hMaxPos ); if (mVerbosityLevel > 3) cout << "\t...booking " << "hEdgePos" << endl; hEdgePos = new TH1F ( "hEdgePos", "Distribution of arrival times according to the EdgePos", 1125, -1, 1124 ); // hEdgePos->SetAxisRange( // 0, // 1024, // "X"); hEdgePos->SetDrawOption("colz"); hEdgePos->GetXaxis()->SetTitle( " arrival time [timeslices]" ); hEdgePos->GetYaxis()->SetTitle( "counts" ); hEdgePos->SetStats(mStats); hList->Add( hEdgePos ); // Edge Slope Distributions //---------------------------------- if (mVerbosityLevel > 3) cout << "\t...booking " << "hEdgeSlope" << endl; hEdgeSlope = new TH1F ( "hEdgeSlope", "Distribution of slope of leading edges", 100, -1.55, 8.45 ); hEdgeSlope->SetAxisRange( 0.5, 7, "X"); hEdgeSlope->SetDrawOption("colz"); hEdgeSlope->GetXaxis()->SetTitle( " slope [a.u.]" ); hEdgeSlope->GetYaxis()->SetTitle( "counts" ); hEdgeSlope->SetStats(mStats); hList->Add( hEdgeSlope ); // Edge Slope Distributions //---------------------------------- if (mVerbosityLevel > 3) cout << "\t...booking " << "hMaxEdgeSlope" << endl; hMaxEdgeSlope = new TH1F ( "hMaxEdgeSlope", "Distribution of maximum slope in slices of leading edges", 100, -1.55, 8.45 ); hMaxEdgeSlope->SetAxisRange( 0.5, 7, "X"); hMaxEdgeSlope->SetDrawOption("colz"); hMaxEdgeSlope->GetXaxis()->SetTitle( " slope [a.u.]" ); hMaxEdgeSlope->GetYaxis()->SetTitle( "counts" ); hMaxEdgeSlope->SetStats(mStats); hList->Add( hMaxEdgeSlope ); // Intercept Distributions //---------------------------------- if (mVerbosityLevel > 3) cout << "\t...booking " << "hIntercept" << endl; hIntercept = new TH1F ( "hIntercept", "Distribution of Intercept of leading edges", 1041, -1, 1040 ); hIntercept->SetAxisRange( -100, 100, "X"); hIntercept->SetDrawOption("colz"); hIntercept->GetXaxis()->SetTitle( " Intercept [a.u.]" ); hIntercept->GetYaxis()->SetTitle( "counts" ); hIntercept->SetStats(mStats); hList->Add( hIntercept ); // Edge lengt Distributions //---------------------------------- if (mVerbosityLevel > 3) cout << "\t...booking " << "hEdgeLength" << endl; hEdgeLength = new TH1F ( "hEdgeLength", "Distribution of hEdgeLength of leading edges", 200, -0.5, 199.5 ); hEdgeLength->SetAxisRange( 0, 100, "X"); hEdgeLength->SetDrawOption("colz"); hEdgeLength->GetXaxis()->SetTitle( " edge length [a.u.]" ); hEdgeLength->GetYaxis()->SetTitle( "counts" ); hEdgeLength->SetStats(mStats); hList->Add( hEdgeLength ); // Pulse length Distributions //---------------------------------- if (mVerbosityLevel > 3) cout << "\t...booking " << "hPulseLength" << endl; hPulseLength = new TH1F ( "hPulseLength", "Distribution of pulse lengthes", 1024, -0.5, 1023.5 ); hPulseLength->SetAxisRange( 0, 600, "X"); hPulseLength->SetDrawOption("colz"); hPulseLength->GetXaxis()->SetTitle( " pulse length [samples]" ); hPulseLength->GetYaxis()->SetTitle( "counts" ); hPulseLength->SetStats(mStats); hList->Add( hPulseLength ); if (mVerbosityLevel > 3) cout << "\t...booking " << "hPulseLengthAPcutoff" << endl; hPulseLengthAPcutoff = new TH1F ( "hPulseLengthAPcutoff", "Distribution of pulse lengthes due to afterpulse cut off", 1024, -0.5, 1023.5 ); // hPulseLength->SetAxisRange( // 0, // 1024, // "X"); hPulseLengthAPcutoff->SetDrawOption("colz"); hPulseLengthAPcutoff->GetXaxis()->SetTitle( " pulse length [samples]" ); hPulseLengthAPcutoff->GetYaxis()->SetTitle( "counts" ); hPulseLengthAPcutoff->SetStats(mStats); hList->Add( hPulseLengthAPcutoff ); if (mVerbosityLevel > 3) cout << "\t...booking " << "hPulseLengthTLcutoff" << endl; hPulseLengthTLcutoff = new TH1F ( "hPulseLengthTLcutoff", "Distribution of pulse lengthes due to time line cut off", 1024, -0.5, 1023.5 ); // hPulseLengthTLcutoff->SetAxisRange( // 0, // 1024, // "X"); hPulseLengthTLcutoff->SetDrawOption("colz"); hPulseLengthTLcutoff->GetXaxis()->SetTitle( " pulse length [samples]" ); hPulseLengthTLcutoff->GetYaxis()->SetTitle( "counts" ); hPulseLengthTLcutoff->SetStats(mStats); hList->Add( hPulseLengthTLcutoff ); // Amplitude Distributions //---------------------------------- if (mVerbosityLevel > 3) cout << "\t...booking " << "hMaxAmpl" << endl; hMaxAmpl = new TH1F ( "hMaxAmpl", "Distribution of MaxAmpl of leading edges", 100*10, 0, 100 ); // hMaxAmpl->SetAxisRange( // 0, // 1024, // "X"); hMaxAmpl->SetDrawOption("colz"); hMaxAmpl->GetXaxis()->SetTitle( " Amplitude [a.u.]" ); hMaxAmpl->GetYaxis()->SetTitle( "counts" ); hMaxAmpl->SetStats(mStats); hList->Add( hMaxAmpl ); // Discarted Pulses Distributions //---------------------------------- if (mVerbosityLevel > 3) cout << "\t...booking " << "hDiscartedPulses" << endl; hDiscartedPulses=new TProfile( "hDiscartedPulses", "DiscartedPulses vs. preperation step", 15 , -0.5, 14.5 /*, 100, 0, 1*/ ); // hDiscartedPulses->SetAxisRange( // 0, // 50, // "Y"); hDiscartedPulses->SetAxisRange( -0.5, 9.5, "X"); hDiscartedPulses->SetDrawOption("colz"); hDiscartedPulses->GetXaxis()->SetTitle( "step [a.u.]" ); hDiscartedPulses->GetYaxis()->SetTitle( "# discartep pulses [a.u.]" ); //hDiscartedPulses->SetBit(TH2F::kCanRebin); hDiscartedPulses->SetStats(mStats); hList->Add( hDiscartedPulses ); // Afterpulse Distributions //---------------------------------- if (mVerbosityLevel > 3) cout << "\t...booking " << "hAfterPulses" << endl; hAfterPulses=new TH2F( "hAfterPulses", "amplitude distribution of pulses after trigger pulse", 1024 , 0, 1024 , 10*70, -9, 60 ); // hMaxOverlay[order]->SetAxisRange( // mBSLMean - 5, // (mGainMean*(order+1)) + 10, // "Y"); hAfterPulses->SetDrawOption("colz"); hAfterPulses->GetXaxis()->SetTitle( "delay [sample/ 0.5 ns]" ); hAfterPulses->GetYaxis()->SetTitle( "amplitude [mV]" ); //hDiscartedPulses->SetBit(TH2F::kCanRebin); hAfterPulses->SetStats(mStats); hList->Add( hAfterPulses ); } } //end of BookDistributionHistos //---------------------------------------------------------------------------- void Pixel::BookTemplateHistos() { if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl; for (int order = 0; order < mMaxPulseOrder; order++) { if (mVerbosityLevel > 3) { cout << "\t...booking " << HistoName("hPixelMax", order) << endl; } hPixelMax[order]=new TH1F( HistoName("hPixelMax", order), HistoTitle("Maximum value of each slice in overlay plot of", order), mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight , (-1*mPixelOverlayXaxisLeft)-0.5, mPixelOverlayXaxisRight-0.5 ); hPixelMax[order]->SetAxisRange( mBSLMean - 5, (mGainMean*(order+1)) + 10, "Y"); hPixelMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); hPixelMax[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); //hMaxProfile->SetBit(TH2F::kCanRebin); hPixelMax[order]->SetStats(mStats); hList->Add( hPixelMax[order] ); //------------------------------------------------------------------------ if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelMean", order) << endl; hPixelMean[order] = new TH1F( HistoName("hPixelMean", order), HistoTitle("Mean value of each slice in overlay plot of", order), mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight , (-1*mPixelOverlayXaxisLeft)-0.5, mPixelOverlayXaxisRight-0.5 ); hPixelMean[order]->SetLineColor(kBlue); hPixelMean[order]->SetAxisRange( mBSLMean - 5, (mGainMean*(order+1)) + 10, "Y"); hPixelMean[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); hPixelMean[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); hPixelMean[order]->SetStats(mStats); hList->Add( hPixelMean[order] ); //------------------------------------------------------------------------ if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelMedian", order) << endl; hPixelMedian[order] = new TH1F( HistoName("hPixelMedian", order), HistoTitle("Median value of each slice in overlay plot of", order), mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx (-1*mPixelOverlayXaxisLeft)-0.5, //xlow mPixelOverlayXaxisRight-0.5 //xup ); hPixelMedian[order]->SetLineColor(kRed); hPixelMedian[order]->SetAxisRange( mBSLMean - 5, (mGainMean*(order+1)) + 10, "Y"); hPixelMedian[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); hPixelMedian[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); //hMaxProfile->SetBit(TH2F::kCanRebin); hPixelMedian[order]->SetStats(mStats); hList->Add( hPixelMedian[order] ); } if (mVerbosityLevel > 2) cout << "...done" << endl; } //end of BookTemplateHistos //---------------------------------------------------------------------------- void Pixel::BookEdgeTemplateHistos() { if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl; for (int order = 0; order < mMaxPulseOrder; order++) { if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMax", order) << endl; hPixelEdgeMax[order]=new TH1F( HistoName("hPixelEdgeMax", order), HistoTitle("Maximum value of each slice in overlay plot of", order), mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight , (-1*mPixelOverlayXaxisLeft)-0.5, mPixelOverlayXaxisRight-0.5 ); hPixelEdgeMax[order]->SetAxisRange( mBSLMean - 5, (mGainMean*(order+1)) + 10, "Y"); hPixelEdgeMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); hPixelEdgeMax[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); //hMaxProfile->SetBit(TH2F::kCanRebin); hPixelEdgeMax[order]->SetStats(mStats); hList->Add( hPixelEdgeMax[order] ); //------------------------------------------------------------------------ if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMean", order) << endl; hPixelEdgeMean[order] = new TH1F( HistoName("hPixelEdgeMean", order), HistoTitle("Mean value of each slice in overlay plot of", order), mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight , (-1*mPixelOverlayXaxisLeft)-0.5, mPixelOverlayXaxisRight-0.5 ); hPixelEdgeMean[order]->SetLineColor(kBlue); hPixelEdgeMean[order]->SetAxisRange( mBSLMean - 5, (mGainMean*(order+1)) + 10, "Y"); hPixelEdgeMean[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); hPixelEdgeMean[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); hPixelEdgeMean[order]->SetStats(mStats); hList->Add( hPixelEdgeMean[order] ); //------------------------------------------------------------------------ if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMedian", order) << endl; hPixelEdgeMedian[order] = new TH1F( HistoName("hPixelEdgeMedian", order), HistoTitle("Median value of each slice in overlay plot of", order), mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx (-1*mPixelOverlayXaxisLeft)-0.5, //xlow mPixelOverlayXaxisRight-0.5 //xup ); hPixelEdgeMedian[order]->SetLineColor(kRed); hPixelEdgeMedian[order]->SetAxisRange( mBSLMean - 5, (mGainMean*(order+1)) + 10, "Y"); hPixelEdgeMedian[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); hPixelEdgeMedian[order]->GetYaxis()->SetTitle( "Amplitude [mV]" ); //hMaxProfile->SetBit(TH2F::kCanRebin); hPixelEdgeMedian[order]->SetStats(mStats); hList->Add( hPixelEdgeMedian[order] ); } if (mVerbosityLevel > 2) cout << "...done" << endl; } //end of BookEdgeTemplateHistos //---------------------------------------------------------------------------- void Pixel::LoadPulseHistos() { mRootFile->cd(); if (mVerbosityLevel > 2) { if (mVerbosityLevel > 3) { mRootFile->ls(); } cout << "loading current File: " ; gFile->pwd(); } mRootFile->cd( CreateSubDirName( mChid ) ); //Go to pixel's subdirectory mDirectory = gDirectory; if (mVerbosityLevel > 2) { if (mVerbosityLevel > 3) { gDirectory->ls(); } cout << "Current Directory: " ; gDirectory->pwd(); } if (mVerbosityLevel > 2) cout << endl << "...load pixel histograms" << endl; for (int order = 0; order < mMaxPulseOrder; order++) { if (mVerbosityLevel > 3) cout << "\t...loading " << ChooseCycleNumber( HistoName("hMaxOverlay", order), 1) << endl; hMaxOverlay[order] = (TH2F*)mDirectory->Get( ChooseCycleNumber( HistoName("hMaxOverlay", order), 1) ); if (mVerbosityLevel > 3) cout << "\t...loading " << HistoName("hEdgeOverlay", order) << endl; hEdgeOverlay[order] = (TH2F*)mDirectory->Get( ChooseCycleNumber( HistoName("hEdgeOverlay", order), 1) ); if (mVerbosityLevel > 3) cout << "\t...loading " << HistoName("hMaxProfile", order) << endl; hMaxProfile[order] = (TProfile*)mDirectory->Get( ChooseCycleNumber( HistoName("hMaxProfile", order), 1) ); if (mVerbosityLevel > 3) cout << "\t...loading " << HistoName("hEdgeProfile", order) << endl; hEdgeProfile[order] = (TProfile*)mDirectory->Get( ChooseCycleNumber( HistoName("hEdgeProfile", order), 1) ); } // mPixelOverlayXaxisRight =70; ///TODO: get it from the root file // mPixelOverlayXaxisLeft =230; ///TODO: get it from the root file // mBSLMean =-2; ///TODO: get it from the root file // mGainMean =11; ///TODO: get it from the root file // mOptions ="SRM"; ///TODO: get it from the root file // mPixelOverlayXaxisRight = hEdgeOverlay[0]->GetXaxis()->GetBinLowEdge( // hEdgeOverlay[0]->GetXaxis()->GetFirst() // ); // mPixelOverlayXaxisLeft = hEdgeOverlay[0]->GetXaxis()->GetBinUpEdge( // hEdgeOverlay[0]->GetXaxis()->GetLast() // ); mPixelOverlayXaxisLeft = hEdgeOverlay[0]->GetBinCenter( hEdgeOverlay[0]->GetXaxis()->GetFirst() ); mPixelOverlayXaxisLeft *= -1; mPixelOverlayXaxisRight = hEdgeOverlay[0]->GetBinCenter( hEdgeOverlay[0]->GetXaxis()->GetLast() ); } // end of LoadPulseHistos //---------------------------------------------------------------------------- void Pixel::DeletePixelHistos() { if (mVerbosityLevel > 2) { cout << endl << endl << "\t...delete current overlay histograms of Pixel# " << mChid; } for (int order = 0; order < mMaxPulseOrder; order ++) { if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxOverlay" << mChid << "_" << order; delete hMaxOverlay[order]; hMaxOverlay[order] = NULL; if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeOverlay" << mChid << "_" << order ; delete hEdgeOverlay[order]; hEdgeOverlay[order] = NULL; if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile" << mChid << "_" << order ; delete hMaxProfile[order]; hMaxProfile[order] = NULL; if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile2" << mChid << "_" << order ; delete hEdgeProfile[order]; hEdgeProfile[order] = NULL; } if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays"; if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxOverlay"; delete[] hMaxOverlay; hMaxOverlay = NULL; if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeOverlay"; delete[] hEdgeOverlay; hEdgeOverlay = NULL; if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile"; delete[] hMaxProfile; hMaxProfile = NULL; if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeProfile"; delete[] hEdgeProfile; hEdgeProfile = NULL; } // end of DeletePixelHistos //---------------------------------------------------------------------------- void Pixel::DeleteDistributionHistos() { if (mVerbosityLevel > 2) { cout << endl << "\t...delete current distribution histograms" ; } delete hMaxPos; delete hEdgePos; delete hEdgeSlope; delete hMaxEdgeSlope; delete hIntercept; delete hEdgeLength; delete hPulseLength; delete hPulseLengthAPcutoff; delete hPulseLengthTLcutoff; delete hMaxAmpl; delete hDiscartedPulses; delete hAfterPulses; for (int order = 0; order < mMaxPulseOrder; order ++) { if (mOptions.Contains("S")) { if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hSlopeRisingEdge" << mChid << "_" << order ; delete hSlopeRisingEdge[order]; } if (mOptions.Contains("R")) { if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hRisingEdgeToMax" << mChid << "_" << order ; delete hRisingEdgeToMax[order]; } if (mOptions.Contains("M")) { if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPosOfMax" << mChid << "_" << order ; delete hPosOfMax[order]; } } if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays"; if (mOptions.Contains("S")) { if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hSlopeRisingEdge"; delete[] hSlopeRisingEdge; hSlopeRisingEdge = NULL; } if (mOptions.Contains("R")) { if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hRisingEdgeToMax"; delete[] hRisingEdgeToMax; hRisingEdgeToMax = NULL; } if (mOptions.Contains("M")) { if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPosOfMax"; delete[] hPosOfMax; hPosOfMax = NULL; } } // end of DeletePixelHistos //---------------------------------------------------------------------------- void Pixel::DeleteTemplateHistos() { if (mVerbosityLevel > 2) { cout << endl << "\t...delete current template histograms of Pixel# " << mChid; } for (int order = 0; order < mMaxPulseOrder; order ++) { if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMean" << mChid << "_" << order ; delete hPixelMean[order]; hPixelMean[order] = NULL; if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMedian" << mChid << "_" << order ; delete hPixelMedian[order]; hPixelMedian[order] = NULL; if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMax" << mChid << "_" << order; delete hPixelMax[order]; hPixelMax[order] = NULL; } if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays"; if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMax"; delete[] hPixelMax; hPixelMax = NULL; if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMedian"; delete[] hPixelMedian; hPixelMedian = NULL; if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMean"; delete[] hPixelMean; hPixelMean = NULL; } // end of DeleteTemplateHistos //---------------------------------------------------------------------------- void Pixel::DeleteEdgeTemplateHistos() { if (mVerbosityLevel > 2) { cout << endl << "\t...delete current Edge template histograms of Pixel# " << mChid; } for (int order = 0; order < mMaxPulseOrder; order ++) { if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMax" << mChid << "_" << order; delete hPixelEdgeMax[order]; hPixelEdgeMax[order] = NULL; if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMedian" << mChid << "_" << order ; delete hPixelEdgeMedian[order]; hPixelEdgeMedian[order] = NULL; if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMean" << mChid << "_" << order ; delete hPixelEdgeMean[order]; hPixelEdgeMean[order] = NULL; } if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays"; if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMax"; delete[] hPixelEdgeMax; hPixelEdgeMax = NULL; if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMedian"; delete[] hPixelEdgeMedian; hPixelEdgeMedian = NULL; if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMean"; delete[] hPixelEdgeMean; hPixelEdgeMean = NULL; } // end of DeleteTemplateHistos //---------------------------------------------------------------------------- void Pixel::MakeTH1Pretty( TH1* histo, TString histName, TString histTitle, int order ) { if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName(histName, order) << endl; histo->SetNameTitle( HistoName(histName, order), HistoTitle(histTitle, order) ); histo->SetBins( mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight , (-1*mPixelOverlayXaxisLeft)-0.5, mPixelOverlayXaxisRight-0.5 ); histo->SetAxisRange( mBSLMean - 5, (mGainMean*(order+1)) + 10, "Y"); histo->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); histo->GetYaxis()->SetTitle( "Amplitude [mV]" ); //histo->SetBit(TH2F::kCanRebin); histo->SetStats(mStats); } // end of MakeTH2Pretty //---------------------------------------------------------------------------- void Pixel::MakeTH2Pretty( TH2* histo, TString histName, TString histTitle, int order ) { if (mVerbosityLevel > 3) cout << "\t...designing " << HistoName(histName, order) << endl; histo->SetNameTitle( HistoName(histName, order), HistoTitle(histTitle, order) ); histo->SetBins( mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight , (-1*mPixelOverlayXaxisLeft)-0.5, mPixelOverlayXaxisRight-0.5 , 512, -55.5, 200.5 ); histo->SetAxisRange( mBSLMean - 5, (mGainMean*(order+1)) + 10, "Y"); histo->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); histo->GetYaxis()->SetTitle( "Amplitude [mV]" ); //histo->SetBit(TH2F::kCanRebin); histo->SetStats(mStats); } // end of MakeTH2Pretty //---------------------------------------------------------------------------- void Pixel::MakeTProfilePretty( TProfile* histo, TString histName, TString histTitle, int order ) { if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName(histName, order) << endl; histo->SetNameTitle( HistoName(histName, order), HistoTitle(histTitle, order) ); histo->SetBins( mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight , (-1*mPixelOverlayXaxisLeft)-0.5, mPixelOverlayXaxisRight-0.5 ); histo->SetOption( "s" ); histo->SetAxisRange( mBSLMean - 5, (mGainMean*(order+1)) + 10, "Y"); histo->GetXaxis()->SetTitle( "Timeslices [a.u.]" ); histo->GetYaxis()->SetTitle( "Amplitude [mV]" ); //histo->SetBit(TH2F::kCanRebin); histo->SetStats(mStats); } // end of MakeTProfilePretty //---------------------------------------------------------------------------- void Pixel::ShiftHistoInY( TH1* histo, float shift ) { int min_bin = histo->GetXaxis()->GetFirst(); int max_bin = histo->GetXaxis()->GetLast(); for (int bin = min_bin; bin <= max_bin; bin++) { histo->AddBinContent( bin, shift); } } void Pixel::SetRangeUser(float xMin, float xMax, int order) { hMaxOverlay[order]->GetXaxis()->SetRangeUser(xMin, xMax); hEdgeOverlay[order]->GetXaxis()->SetRangeUser(xMin, xMax); hPixelMax[order]->GetXaxis()->SetRangeUser(xMin, xMax); hPixelMedian[order]->GetXaxis()->SetRangeUser(xMin, xMax); hPixelMean[order]->GetXaxis()->SetRangeUser(xMin, xMax); hPixelEdgeMax[order]->GetXaxis()->SetRangeUser(xMin, xMax); hPixelEdgeMedian[order]->GetXaxis()->SetRangeUser(xMin, xMax); hPixelEdgeMean[order]->GetXaxis()->SetRangeUser(xMin, xMax); return; } void Pixel::NormalizeSamplesTH2F(TH2F* histo) { int first = histo->GetXaxis()->GetFirst(); int last = histo->GetXaxis()->GetLast(); TH2F *hTemp = new TH2F(*histo); hTemp->Reset(); for (int i = first; i < last; i++) { TH1* hTemp1D = histo->ProjectionY("_px1", i, i+1); double integral = hTemp1D->Integral(); // double maximum = hTemp->GetBinContent(hTemp->GetMaximumBin()); hTemp1D->Scale(1/integral); // hTemp->Scale(1/maximum); int first_sl = hTemp1D->GetXaxis()->GetFirst(); int last_sl = hTemp1D->GetXaxis()->GetLast(); for (int j = first_sl; j < last_sl; j++) { hTemp->SetBinContent(i, j, hTemp->GetBinContent(j)); } } histo->Reset(); histo->Add(hTemp); delete hTemp; return; } void Pixel::Normalize2Dhistos(int order) { NormalizeSamplesTH2F(hMaxOverlay[order]); NormalizeSamplesTH2F(hEdgeOverlay[order]); return; }