BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
//--------------------------------------------------------------------
//
// BrChkvCalibration is a BRAHMS data class providing storage and 
// access function for Cherenkov specific calibration parameters.
// Note that all the DB access work is done in the Baseclass. The user
// code tells the Baseclass the name and element of the data
// 
// Code inspired by BrTofCalibration.cxx
//--------------------------------------------------------------------

//--------------------------------------------------------------------
//
// $Id: BrChkvCalibration.cxx,v 1.4 2001/10/23 20:49:46 ouerdane Exp $
// $Author: ouerdane $
// $Date: 2001/10/23 20:49:46 $
// $Copyright: (C) 2001 BRAHMS Collaboration <brahmlib@rhic.bnl.gov>


#ifndef WIN32
#include <iostream>
#include <iomanip>
#else
#include <iostream.h>
#include <iomanip.h>
#endif

#ifndef BRAT_BrChkvCalibration
#include "BrChkvCalibration.h"
#endif
#ifndef BRAT_BrCalibration
#include "BrCalibration.h"
#endif
#ifndef ROOT_TString
#include "TString.h"
#endif
#ifndef BRAT_BrParameterDbManager
#include "BrParameterDbManager.h"
#endif

ClassImp(BrChkvCalibration);


 BrChkvCalibration::BrChkvCalibration()
{
  // Constructor. DO NOT USE
}

//_________________________________________________________________________
 BrChkvCalibration::BrChkvCalibration(Char_t *name, Char_t *title) :
  BrCalibration(name, title)
{
  // Standard constructor. 
  // the name should be that of the associated detector 
  // e.g. "C1" or "RICH"
  // Create the Db Objects needed for the specific tables.
  // Beware difference between constructor and Init. 
  
  AddParameterData("pedestal",      &fPedestal);
  AddParameterData("pedestalWidth", &fPedestalWidth);
  AddParameterData("adcGain",       &fAdcGain);
  
  BrParameterDbManager* parMan = BrParameterDbManager::Instance();
  fParamsChkv = (BrChkvParameters*)parMan->
    GetDetectorParameters("BrChkvParameters", GetName());
  
}


//_________________________________________________________________________
  BrChkvCalibration::~BrChkvCalibration()
{
  // Default destructor
  //
}


//
// For each Table setup in the constructor via the AddParameterData
// an access method must be declared (in the .h files) and defined
// (here in the .cxx file). The fAccesMode test guarentees that the array has
// been setup, but does not make an index check. It is assumed the usercode
// knows how many data each calibration has (to make coding effecient)
// 



//_____________________________________________________________________________
 Int_t BrChkvCalibration::GetAccessMode(const Char_t* par) const
{
  // get the accessmode of the parameter data  
  TString s(par);
  Int_t mode = 0;

  if (s == "pedestal")
    mode = fPedestal.fAccessMode;
  if (s == "pedestalWidth")
    mode = fPedestalWidth.fAccessMode;
  if (s == "adcGain")
    mode = fAdcGain.fAccessMode;
  
  return mode;
}

//_____________________________________________________________________________
 void BrChkvCalibration::SetPedestal(Int_t tube, Float_t value) {
  CheckTube(tube);
  if (fTubeOutOfBound)
    return;
  
  if(fPedestal.fAccessMode){
    Float_t* array = (Float_t*)fPedestal.fRevision->GetArray();
    array[tube-1]= value;
  }
}

//_____________________________________________________________________________
 void BrChkvCalibration::SetPedestalWidth(Int_t tube, Float_t value) {
  CheckTube(tube);
  if (fTubeOutOfBound)
    return;
  
  if(fPedestalWidth.fAccessMode){
    Float_t* array = (Float_t*)fPedestalWidth.fRevision->GetArray();
    array[tube-1]= value;
  }
}

//_____________________________________________________________________________
 void BrChkvCalibration::SetAdcGain(Int_t tube, Float_t value) {
  CheckTube(tube);
  if (fTubeOutOfBound)
    return;
  
  if(fAdcGain.fAccessMode){
    Float_t* array = (Float_t*)fAdcGain.fRevision->GetArray();
    array[tube-1]= value;
  }
}

//_____________________________________________________________________________
 Float_t BrChkvCalibration::GetPedestal(Int_t tube) const {
  CheckTube(tube);
  if (fTubeOutOfBound)
  return 0;
  
  if(fPedestal.fAccessMode )
    return ((Float_t*) fPedestal.fRevision->GetArray())[tube-1] ;
  else
    return 0;
}
//_____________________________________________________________________________
 Float_t BrChkvCalibration::GetPedestalWidth(Int_t tube) const {
  CheckTube(tube);
  if (fTubeOutOfBound)
    return 0;
  
  if(fPedestalWidth.fAccessMode ) 
    return ((Float_t*) fPedestalWidth.fRevision->GetArray())[tube-1] ;
  else
    return 0;
}

//_____________________________________________________________________________
 Float_t BrChkvCalibration::GetAdcGain(Int_t tube) const {
  CheckTube(tube);
  if (fTubeOutOfBound)
    return 0;
  
  if(fAdcGain.fAccessMode ) 
    return ((Float_t*) fAdcGain.fRevision->GetArray())[tube-1] ;
  else
    return 0;
}

//_____________________________________________________________________________
 void BrChkvCalibration::CheckTube(Int_t tube) const
{
  fTubeOutOfBound = kFALSE;
  
  if (tube < 1 || tube > fParamsChkv->GetNoTubes()) {
    cerr << GetName() << " tube number " << tube 
	 << " is out of bound" << endl;
    fTubeOutOfBound = kTRUE;
  }
}

//_____________________________________________________________________________
 Bool_t BrChkvCalibration::ValidCalibration(Int_t tube)
{
  CheckTube(tube);
  if (fTubeOutOfBound)
    return kFALSE;

  if (GetPedestal(tube)     == kCalException ||
      GetPedestalWidth(tube)== kCalException ||
      GetAdcGain(tube)      == kCalException)
    return kFALSE;
  
  return kTRUE;
}


//---------------------------------------------------------------
//
// $Log: BrChkvCalibration.cxx,v $
// Revision 1.4  2001/10/23 20:49:46  ouerdane
// Added method Int_t GetAccessMode(<par name>) const
//
// Revision 1.3  2001/10/08 10:26:55  cholm
// Changed detector calibration data classes to derive from BrCalibration,
// rather than BrParameterElement, since that has been replaced. Impact
// on various modules, and so on.  Some user code may need to be changed to.
//
// Revision 1.2  2001/07/31 09:10:19  ouerdane
// made getters const, member fTubeOutOfBound mutable and non persistent
// class version number is now 2
//
// Revision 1.1  2001/07/20 16:00:07  ouerdane
// New class for cherenkov detector calibration: BrChkvCalibration
// is the parameter class to be used in the parameter element manager
// It works both for C1 and RICH and deals now with the pedestals
// but has also the adc gain parameter
//

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