/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Private Member Functions | Private Attributes
PMTParamSaver Class Reference

#include <PMTParamSaver.h>

Collaboration diagram for PMTParamSaver:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PMTParamSaver (TTree *pulses, int *sensorFullPackedData, const char *detName)
 ~PMTParamSaver ()
void GetParamTree ()

Private Member Functions

TH1F * GetParamGraph (int pmt, double *param, double *error, const char *parname)
void FitParam (int pmt, double *param_addr, double *error_addr, const char *parname, const char *formula, double *parDest, int len)
void SavePMTParams (int pmt)

Private Attributes

TTree * pulseTree
TTree * pmtParamTree
int * sensorFullPackedData
PMTParams pmtParams
PMTParamspPmtParams
PulseParams pulseParams
PulseParamspPulseParams
const char * detName
TFile * fitsFile
TFile * paramsFile

Detailed Description

Definition at line 13 of file PMTParamSaver.h.


Constructor & Destructor Documentation

PMTParamSaver::PMTParamSaver ( TTree *  pulses,
int *  sensorFullPackedData,
const char *  detName 
)

Definition at line 18 of file PMTParamSaver.cc.

  : pulseTree(pulses),
    sensorFullPackedData(sensorFullPackedData),
    detName(detName)
{
  pPulseParams = &pulseParams;
  pulseTree->SetBranchAddress("params", &pPulseParams);

  if (sensorFullPackedData == NULL)
    this->sensorFullPackedData = new int[NUM_PMTS];

  string fitsFname = string("param_fits_") + detName + ".root";
  fitsFile = new TFile(fitsFname.c_str(), "recreate");

  string paramsFname = string("params_") + detName + ".root";
  paramsFile = new TFile(paramsFname.c_str(), "recreate");

  pmtParamTree = new TTree("pmtParams", "PMT parameters");
  pPmtParams = &pmtParams;
  pmtParamTree->Branch("params", "PMTParams", &pPmtParams);
}
PMTParamSaver::~PMTParamSaver ( )

Definition at line 42 of file PMTParamSaver.cc.

{
  delete pmtParamTree;
  delete fitsFile;
  delete paramsFile;
}

Member Function Documentation

void PMTParamSaver::GetParamTree ( )

Definition at line 50 of file PMTParamSaver.cc.

{
  for (int pmtIdx = 0; pmtIdx < NUM_PMTS; ++pmtIdx)
    SavePMTParams(pmtIdx);

  paramsFile->cd();
  pmtParamTree->Write();
}
TH1F * PMTParamSaver::GetParamGraph ( int  pmt,
double *  param,
double *  error,
const char *  parname 
) [private]

Definition at line 60 of file PMTParamSaver.cc.

{
  ostringstream hname;
  hname << "h_" << pmt << "_" << parname;
  
  TH1F* h1 = new TH1F(hname.str().c_str(), "", NUM_ADC_CUTS,
                      ADC_MIN-ADC_INC/2, ADC_MAX+ADC_INC/2);

  int n = pulseTree->GetEntriesFast();
  for (int i = 0; i < n; ++i) {
    pulseTree->GetEntry(i);
    if (pulseParams.pmtIdx == pmt) {
      int bin = h1->FindBin(pulseParams.adc);
      h1->SetBinContent(bin, *param);
      h1->SetBinError(bin, *error);
    }
  }

  return h1;
}
void PMTParamSaver::FitParam ( int  pmt,
double *  param_addr,
double *  error_addr,
const char *  parname,
const char *  formula,
double *  parDest,
int  len 
) [private]

Definition at line 82 of file PMTParamSaver.cc.

{
  TH1F *graph = GetParamGraph(pmt, param_addr, error_addr, parname);
  TFitResultPtr pResults = graph->Fit(formula, "S");
  TFitResult* results = pResults.Get();

  const double *fitParams = results->GetParams();
  copy(fitParams, fitParams + len, parDest);
  fitsFile->cd();
  graph->Write();
}
void PMTParamSaver::SavePMTParams ( int  pmt) [private]

Definition at line 97 of file PMTParamSaver.cc.

{
#define FIT_PARAM(par, formula, len)                            \
  FitParam(pmt, &pulseParams.params.par, &pulseParams.err.par, \
           #par, formula, (double*)&pmtParams.par.p0, len)

#define FIT_LIN(par) FIT_PARAM(par, "pol1", 2)
#define FIT_QUAD(par) FIT_PARAM(par, "pol2", 3)

  FIT_LIN(amp);
  FIT_QUAD(mean);
  FIT_QUAD(sigma);
  FIT_LIN(p0);
  FIT_LIN(p1);
  FIT_LIN(p2);
  FIT_LIN(p3);

  pmtParams.fullPackedData = sensorFullPackedData[pmt];
  pmtParams.ring = pmt/24 + 1;
  pmtParams.column = pmt%24 + 1;

  pmtParamTree->Fill();
}

Member Data Documentation

TTree* PMTParamSaver::pulseTree [private]

Definition at line 21 of file PMTParamSaver.h.

TTree * PMTParamSaver::pmtParamTree [private]

Definition at line 21 of file PMTParamSaver.h.

Definition at line 22 of file PMTParamSaver.h.

Definition at line 23 of file PMTParamSaver.h.

Definition at line 23 of file PMTParamSaver.h.

Definition at line 24 of file PMTParamSaver.h.

Definition at line 24 of file PMTParamSaver.h.

const char* PMTParamSaver::detName [private]

Definition at line 25 of file PMTParamSaver.h.

TFile* PMTParamSaver::fitsFile [private]

Definition at line 26 of file PMTParamSaver.h.

TFile * PMTParamSaver::paramsFile [private]

Definition at line 26 of file PMTParamSaver.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:03:47 for PulseParamGen by doxygen 1.7.4