Skip to content
Snippets Groups Projects
pcal_calib.cpp 1.81 KiB
Newer Older
  • Learn to ignore specific revisions
  • #include <TStyle.h>
    #include <TCanvas.h>
    #include <TH1.h>
    #include <TF1.h>
    #include "THcPShowerCalib.h"
    
    //
    // A steering Root script for the SHMS calorimeter calibration.
    //
    
    void pcal_calib(string RunNumber) {
    
    
      // Initialize the analysis clock
      clock_t t = clock();
    
      cout << "Calibrating run " << RunNumber << endl;
    
      THcPShowerCalib theShowerCalib(RunNumber);
    
      theShowerCalib.Init();            // Initialize constants and variables
      theShowerCalib.CalcThresholds();  // Thresholds on the uncalibrated Edep/P
      theShowerCalib.ComposeVMs();      // Compute vectors amd matrices for calib.
      theShowerCalib.SolveAlphas();     // Solve for the calibration constants
      theShowerCalib.SaveAlphas();      // Save the constants
      //theShowerCalib.SaveRawData();   // Save raw data into file for debuging
      theShowerCalib.FillHEcal();       // Fill histograms
    
      // Plot histograms
    
      TCanvas* Canvas =
        new TCanvas("Canvas", "PHMS Shower Counter calibration", 1000, 667);
      Canvas->Divide(2,2);
    
      // Normalized uncalibrated energy deposition.
    
      theShowerCalib.hEunc->DrawCopy();
    
      theShowerCalib.hEuncSel->SetFillColor(kGreen);
      theShowerCalib.hEuncSel->DrawCopy("same");
    
      theShowerCalib.hESHvsEPR->Draw("colz");
    
      // Normalized energy deposition after calibration.
    
      Canvas->cd(3);
      gStyle->SetOptFit();
    
      theShowerCalib.hEcal->Fit("gaus","","",0.9,1.1);
      theShowerCalib.hEcal->GetFunction("gaus")->SetLineColor(2);
      theShowerCalib.hEcal->GetFunction("gaus")->SetLineWidth(1);
      theShowerCalib.hEcal->GetFunction("gaus")->SetLineStyle(1);
    
      // SHMS delta(P) versus the calibrated energy deposition.
    
      theShowerCalib.hDPvsEcal->Draw("colz");
    
      // Calculate the analysis rate
      t = clock() - t;
      printf ("The analysis took %.1f seconds \n", ((float) t) / CLOCKS_PER_SEC);