|
//____________________________________________________________________ // // Pedestal Calibration module for tile 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: BrTilePedCalModule.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_BrTilePedCalModule #include "BrTilePedCalModule.h" #endif #ifndef BRAT_BrTileDig #include "BrTileDig.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(BrTilePedCalModule); //____________________________________________________________________ BrTilePedCalModule::BrTilePedCalModule() { // Default constructor SetState(kSetup); } //____________________________________________________________________ BrTilePedCalModule::BrTilePedCalModule(const Char_t* name, const Char_t* title) : BrModule(name, title) { // Default constructor SetState(kSetup); SetOutputName(); } //____________________________________________________________________ BrTilePedCalModule::~BrTilePedCalModule() { // Destructor if (!HistBooked()) return; for (Int_t i = 0; i < BR_TILE_CHAN_MAX; i++) delete fAdcHisto[i]; delete fAdcHisto; } //____________________________________________________________________ void BrTilePedCalModule::SetOutputName(const Char_t* name) { // Set the file name of the file to output temporary calibration // parameters to if (GetState() != kSetup) { Failure("SetOutputName", "must be send before Init"); return; } fOutputName = name; } //____________________________________________________________________ void BrTilePedCalModule::DefineHistograms() { // Define a histogram for each tiles ADC output. // This is needed to do the calibrations. if (GetState() > kInit) { Failure("DefineHistograms", "must be send before Begin"); return; } fAdcHisto = new TH1F * [BR_TILE_CHAN_MAX]; for (Int_t i = 0; i < BR_TILE_CHAN_MAX; i++) fAdcHisto[i] = new TH1F(Form("tileAdc%02d", i), Form("ADC distribution in tile %d", i), 4098, 0, 4098); } //____________________________________________________________________ void BrTilePedCalModule::Init() { // SetState(kInit); } //____________________________________________________________________ void BrTilePedCalModule::Begin() { // Make sure histograms are booked, otherwise stop job. SetState(kBegin); if (!HistBooked()) Failure("Begin", "must book histograms for calibration to work"); } //____________________________________________________________________ void BrTilePedCalModule::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; } BrTileDig* dig = (BrTileDig*)input->GetObject(BRTABLENAMES kDigTiles); if (!dig) { if (DebugLevel() > 2) Warning("Event", "no '%s' in input event", BRTABLENAMES kDigTiles); return; } if (!HistOn()) return; for (Int_t i = 0; i < BR_TILE_CHAN_MAX; i++) fAdcHisto[i]->Fill(dig->GetAdc(i) + .5); } //____________________________________________________________________ void BrTilePedCalModule::End() { // SetState(kEnd); } //____________________________________________________________________ void BrTilePedCalModule::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_TILE_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: BrTilePedCalModule.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:58 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:44:04 cholm // Added two modules for making tile calibrations (pedestal and gap), as well // as a calibration data object foir use with the calibration database. The // ADC gap module is not complete, and the pedestal module isn't tested. // // |
||||||
This page automatically generated by script docBrat by Christian Holm |
Copyright ; 2002 BRAHMS Collaboration
<brahmlib@rcf.rhic.bnl.gov>
|