BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
//____________________________________________________________________
//
// 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: BrTileGapCalModule.cxx,v 1.2 2002/01/03 19:50:55 cholm Exp $
// $Author: cholm $
// $Date: 2002/01/03 19:50:55 $
// $Copyright: 2001 BRAHMS Collaboration <brahmlib@rhic.bnl.gov>
//
#ifndef BRAT_BrTileGapCalModule
#include "BrTileGapCalModule.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(BrTileGapCalModule);

//____________________________________________________________________
 BrTileGapCalModule::BrTileGapCalModule()
{
  // Default constructor
  SetState(kSetup);
}

//____________________________________________________________________
 BrTileGapCalModule::BrTileGapCalModule(const Char_t* name, 
				       const Char_t* title)
  : BrModule(name, title)
{
  // Default constructor
  SetState(kSetup);
  SetOutputName();
}

//____________________________________________________________________
 BrTileGapCalModule::~BrTileGapCalModule()
{
  // Destructor
  if (!HistBooked())
    return;
  for (Int_t i = 0; i < BR_TILE_CHAN_MAX; i++)
    delete fAdcHisto[i];
  delete fAdcHisto;
}


//____________________________________________________________________
 void BrTileGapCalModule::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 BrTileGapCalModule::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 BrTileGapCalModule::Init() 
{
  //
  SetState(kInit);  
}

//____________________________________________________________________
 void BrTileGapCalModule::Begin() 
{
  // Make sure histograms are booked, otherwise stop job. 
  SetState(kBegin);
  if (!HistBooked())
    Failure("Begin", "must book histograms for calibration to work"); 
}

//____________________________________________________________________
 void BrTileGapCalModule::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 BrTileGapCalModule::End() 
{
  // 
  SetState(kEnd);
}

//____________________________________________________________________
 void BrTileGapCalModule::Finish() 
{
  // Nothing yet - sorry. Need to be filled out soon
  SetState(kFinish);
  if (!HistBooked()) {
    Failure("Finish", "must book histograms for calibration to work"); 
    return;
  }

#if 0
  // Try to open the output file 
  ofstream outputFile(fOutputName.Data(), ios::out|ios::noreplace);
  if(!outputFile) {
    Failure("Finish", "couldn't open file '%s'", fOutputName.Data());
    return;
  }

  // Write a header
  outputFile << "# NotLow Gap    tHigh Gap" << 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();
#endif
}

//____________________________________________________________________
//
// $Log: BrTileGapCalModule.cxx,v $
// Revision 1.2  2002/01/03 19:50:55  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:00  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>
Last Update on by

Validate HTML
Validate CSS