|
//____________________________________________________________________ // // Pedestal Calibration module for si scinitilators in multiplicity // array. // // This class will for each passed event (should be syncroniusation // events) update a set of histograms with the bare ADC value from the // DAQ. // // At the end of the job, these histograms are fitted with gaussians // to find the pedestal and pedestal with. // // These numbers, will be written to a flat ASCII file. This file, and // the hisotgrams generated, should be manually inspected, to make // sure the fits are appropiate. // //____________________________________________________________________ // $Id: BrSiPedCalModule.cxx,v 1.3 2002/04/19 21:33:14 hito Exp $ // $Author: hito $ // $Date: 2002/04/19 21:33:14 $ // $Copyright: 2001 BRAHMS Collaboration <brahmlib@rhic.bnl.gov> // #ifndef BRAT_BrSiPedCalModule #include "BrSiPedCalModule.h" #endif #ifndef BRAT_BrSiDig #include "BrSiDig.h" #endif #ifndef BRAT_BrTableNames #include "BrTableNames.h" #endif #ifndef ROOT_TF1 #include "TF1.h" #endif #ifdef WIN32 #include <fstream.h> #include <iomanip.h> #else #include <fstream> #include <iomanip> #endif //____________________________________________________________________ ClassImp(BrSiPedCalModule); //____________________________________________________________________ BrSiPedCalModule::BrSiPedCalModule() { // Default constructor SetState(kSetup); } //____________________________________________________________________ BrSiPedCalModule::BrSiPedCalModule(const Char_t* name, const Char_t* title) : BrModule(name, title) { // Default constructor SetState(kSetup); SetOutputName(); } //____________________________________________________________________ BrSiPedCalModule::~BrSiPedCalModule() { // Destructor if (!HistBooked()) return; for (Int_t i = 0; i < BR_SI_CHAN_MAX; i++) delete fAdcHisto[i]; delete fAdcHisto; } //____________________________________________________________________ void BrSiPedCalModule::SetOutputName(const Char_t* name) { // Set the file name of the file to output temporary calibration // parameters to if (GetState() != kSetup) { Failure("SetFileName", "must be send before Init"); return; } fOutputName = name; } //____________________________________________________________________ void BrSiPedCalModule::DefineHistograms() { // Define a histogram for each sis ADC output. // This is needed to do the calibrations. if (GetState() > kInit) { Failure("DefineHistograms", "must be send before Begin"); return; } fAdcHisto = new TH1F * [BR_SI_CHAN_MAX]; for (Int_t i = 0; i < BR_SI_CHAN_MAX; i++) fAdcHisto[i] = new TH1F(Form("siAdc%02d", i), Form("ADC distribution in si %d", i), 4098, 0, 4098); } //____________________________________________________________________ void BrSiPedCalModule::Init() { // SetState(kInit); } //____________________________________________________________________ void BrSiPedCalModule::Begin() { // Make sure histograms are booked, otherwise stop job. SetState(kBegin); if (!HistBooked()) Failure("Begin", "must book histograms for calibration to work"); } //____________________________________________________________________ void BrSiPedCalModule::Event(BrEventNode* input, BrEventNode* output) { // Fill the ADC histograms SetState(kEvent); SetStatus(kOk); if (!HistBooked()) { Failure("Event", "must book histograms for calibration to work"); return; } BrSiDig* dig = (BrSiDig*)input->GetObject(BRTABLENAMES kDigSi); if (!dig) { if (DebugLevel() > 2) Warning("Event", "no '%s' in input event", BRTABLENAMES kDigSi); return; } if (!HistOn()) return; for (Int_t i = 0; i < BR_SI_CHAN_MAX; i++) fAdcHisto[i]->Fill(dig->GetAdc(i) + .5); } //____________________________________________________________________ void BrSiPedCalModule::End() { // SetState(kEnd); } //____________________________________________________________________ void BrSiPedCalModule::Finish() { // SetState(kFinish); if (!HistBooked()) { Failure("Finish", "must book histograms for calibration to work"); return; } // Try to open the output file // removed ios::noreplace !!!!!! ofstream outputFile(fOutputName.Data(), ios::out); if(!outputFile) { Failure("Finish", "couldn't open file '%s'", fOutputName.Data()); return; } // Write a header outputFile << "# NotPedestal tWidth" << endl; for (Int_t i = 0; i < BR_SI_CHAN_MAX; i++) { // Fit histograms fAdcHisto[i]->Fit("gaus"); TF1* func = fAdcHisto[i]->GetFunction("gaus"); // Get parameters of fit Double_t mean = func->GetParameter(1); Double_t sigma = func->GetParameter(2); // Write fit to file outputFile << setw(4) << i << "t" << setw(12) << mean << "t" << setw(12) << sigma << endl; } // Close oputput file outputFile.close(); } //____________________________________________________________________ // // $Log: BrSiPedCalModule.cxx,v $ // Revision 1.3 2002/04/19 21:33:14 hito // Minor change for compiling with gcc3. // // Revision 1.2 2002/01/03 19:50:48 cholm // Prepared to use BrTableNames class (or perhaps BrDetectorList) for table names // // Revision 1.1.1.1 2001/06/21 14:55:05 hagel // Initial revision of brat2 // // Revision 1.1 2001/01/29 20:49:33 cholm // Added a claibration module for silicon pedestals, plus a calibration // class for use with the calibrations database. Both classes havent been // tested yet. // // |
||||||
This page automatically generated by script docBrat by Christian Holm |
Copyright ; 2002 BRAHMS Collaboration
<brahmlib@rcf.rhic.bnl.gov>
|