BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
//____________________________________________________________________
// 
// 
// 

//____________________________________________________________________
//
// $Id: BrMultCalibration.cxx,v 1.5 2002/03/14 10:02:20 cholm Exp $
// $Author: cholm $
// $Date: 2002/03/14 10:02:20 $
// $Copyright: (C) 2001 BRAHMS Collaboration <brahmlib@rhic.bnl.gov>
//
#ifndef WIN32
#include <iostream>
#include <iomanip>
#include <cfloat>
#include <fstream>
#else
#include <iostream.h>
#include <iomanip.h>
#include <float.h>
#include <fstream.h>
#endif 
#ifndef BRAT_BrDataObject
#include "BrDataObject.h"
#endif
#ifndef BRAT_BrMultCalibration
#include "BrMultCalibration.h"
#endif

//____________________________________________________________________
ClassImp(BrMultCalibration);

//____________________________________________________________________
BrMultCalibration::BrMultCalibration()
{
  // Default constructor
}

//____________________________________________________________________
BrMultCalibration::BrMultCalibration(const Char_t* name, 
				     const Char_t* title) 
  : BrCalibration((char*)name, (char*)title) 
{
  // Standard CTOR 
  // The name hould be that of the associated detector e.g. 
  // "MultMult" 
  AddParameterData("pedestal",        &fPedestal);
  AddParameterData("pedestalWidth",   &fPedestalWidth);
  AddParameterData("adcGain",         &fAdcGain);
  // Eta correction 
  AddParameterData("conversionFunc",  &fConversionFunc);
  // vtx dep. correction for secondaires 
  AddParameterData("correctionFunc",  &fCorrectionFunc);
  // Centrality cuts 
  AddParameterData("centralityFunc",  &fCentralityFunc);
  // Geometry - should be in geometry database, but left here until a
  // conceous is reach on how to do the geometry database 
  AddParameterData("ringMap",         &fRingMap);
  AddParameterData("rowMap",          &fRowMap);
  AddParameterData("ringPosition",    &fRingPosition);
  AddParameterData("tilt",            &fTilt);
}

//____________________________________________________________________
//
// ADC calibrations  
//
//____________________________________________________________________
Float_t BrMultCalibration::GetPedestal(Int_t singleNo) const 
{
  // Get pedestal for single number singleNo (zero based) 
  if (fPedestal.fAccessMode && fPedestal.fRevision) 
    return ((Float_t*)fPedestal.fRevision->GetArray())[singleNo];
  else 
    return 0;
}

//____________________________________________________________________
Float_t BrMultCalibration::GetPedestalWidth(Int_t singleNo) const 
{
  // Get pedestal width for single number singleNo (zero based) 
  if (fPedestalWidth.fAccessMode && fPedestalWidth.fRevision) 
    return ((Float_t*)fPedestalWidth.fRevision->GetArray())[singleNo];
  else 
    return 0;
}

//____________________________________________________________________
Float_t BrMultCalibration::GetAdcGain(Int_t singleNo) const 
{
  // Get ADC gain for single number singleNo (zero based) 
  if (fAdcGain.fAccessMode && fAdcGain.fRevision) 
    return ((Float_t*)fAdcGain.fRevision->GetArray())[singleNo];
  else 
    return 0;
}

//____________________________________________________________________
//
// Eta dependent E to M conversion 
// 
//____________________________________________________________________
Int_t BrMultCalibration::GetConversionFuncOrder() const 
{
  // Returns the order of the conversion functions e.g., 3 for a third 
  // degree polynomial (a0 + a1 * x + a2 * x^2 + a3 * x^3). -1 is
  // returned in case of error. 
  if (!fConversionFunc.fAccessMode || !fConversionFunc.fRevision) 
    return -1;

  Float_t* array = (Float_t*)fConversionFunc.fRevision->GetArray();
  if (!array) 
    return -1;

  return Int_t(array[0]);
}

//____________________________________________________________________
Float_t BrMultCalibration::GetConversionFuncPar(Int_t ringNo, 
						Int_t parNo) const 
{
  // Returns the ith parameter of the energy to multiplicity
  // conversion function. 

  // The conversion function, is a factor to apply to the deposited
  // energy in a single to get the number of MIP's 
  if (!fConversionFunc.fAccessMode || !fConversionFunc.fRevision) 
    return 0;

  // Get the array 
  Float_t* array = (Float_t*)fConversionFunc.fRevision->GetArray();
  if (!array) 
    return 0;

  // Get the order of the function 
  Int_t norder = Int_t(array[0]);
  
  // If user requested an invalid parameter, return 0
  if (ringNo < 0 || parNo < 0 || parNo > norder + 1) 
    return 0; 

  // Return the parameter (the +1 is for the order)
  return array[ringNo * (norder + 1) + 1 + parNo];
}


//____________________________________________________________________
//
// Vtx dependent multiplicity correction
// 
//____________________________________________________________________
Int_t BrMultCalibration::GetCorrectionFuncOrder() const 
{
  // Returns the order of the correction function e.g., 3 for a third  
  // degree polynomial (a0 + a1 * x + a2 * x^2 + a3 * x^3). -1 is
  // returned in case of error. 
  if (!fCorrectionFunc.fAccessMode || !fCorrectionFunc.fRevision) 
    return -1;

  Float_t* array = (Float_t*)fCorrectionFunc.fRevision->GetArray();
  if (!array) 
    return -1;

  return Int_t(array[0]);
}

//____________________________________________________________________
Float_t BrMultCalibration::GetCorrectionFuncCut() const 
{
  // Returns the maximum vertex Z for which this function is valid. 

  // The conversion function, is a factor to apply to the deposited
  // energy in a single to get the number of MIP's 
  if (!fCorrectionFunc.fAccessMode || !fCorrectionFunc.fRevision) 
    return 0;

  // Get the array 
  Float_t* array = (Float_t*)fCorrectionFunc.fRevision->GetArray();
  if (!array) 
    return 0;

  // Get the order of the function 
  Int_t norder = Int_t(array[0]);
  
  // Return the cut
  return array[1];
}


//____________________________________________________________________
Float_t BrMultCalibration::GetCorrectionFuncPar(Int_t i) const 
{
  // Returns the ith parameter of the vertex correction function. 

  // The conversion function, is a factor to apply to the deposited
  // energy in a single to get the number of MIP's 
  if (!fCorrectionFunc.fAccessMode || !fCorrectionFunc.fRevision) 
    return 0;

  // Get the array 
  Float_t* array = (Float_t*)fCorrectionFunc.fRevision->GetArray();
  if (!array) 
    return 0;

  // Get the order of the function 
  Int_t norder = Int_t(array[0]);
  
  // If user requested an invalid parameter, return 0
  if (i < 0 || i > norder + 1) 
    return 0; 

  // Return the parameter (the +2 is: one for the order, and one for
  // cut) 
  return array[i + 2];
}


//____________________________________________________________________
//
// Centrality 
// 
//____________________________________________________________________
Int_t BrMultCalibration::GetCentralityFuncOrder() const 
{
  // Returns the order of the centrality functions e.g., 3 for a third
  // degree polynomial (a0 + a1 * x + a2 * x^2 + a3 * x^3). -1 is
  // returned in case of error. 
  if (!fCentralityFunc.fAccessMode || !fCentralityFunc.fRevision) 
    return -1;

  Float_t* array = (Float_t*)fCentralityFunc.fRevision->GetArray();
  if (!array) 
    return -1;

  return Int_t(array[0]);
}

//____________________________________________________________________
Int_t BrMultCalibration::GetNCentralityFunc() const 
{
  // Returns the numbr of centrality functions. Zero is returned
  // incase of error
  if (!fCentralityFunc.fAccessMode || !fCentralityFunc.fRevision) 
    return 0;

  Float_t* array = (Float_t*)fCentralityFunc.fRevision->GetArray();
  if (!array) 
    return 0;

  return Int_t(array[1]);
}

//____________________________________________________________________
Float_t BrMultCalibration::GetCentralityFuncCut(Int_t funcNo) const 
{
  // Returns the centraility cut (0 to 100) of the funcNo centrality
  // function. Return FLT_MAX in case of errors 
  if (!fCentralityFunc.fAccessMode || !fCentralityFunc.fRevision) 
    return FLT_MAX;
  
  
  Float_t* array = (Float_t*)fCentralityFunc.fRevision->GetArray();
  if (!array) 
    return FLT_MAX;
  
  Int_t norder = Int_t(array[0]);
  Int_t nfuncs = Int_t(array[1]);
  
  if (nfuncs <= funcNo) 
    return FLT_MAX;
    
  // Offset of function in array:
  //   i * (number of parameters + one for cent) + two reserved places
  Int_t offset = funcNo * (norder + 2) + 2;
  return array[offset];
}

//____________________________________________________________________
Float_t BrMultCalibration::GetCentralityFuncPar(Int_t funcNo, 
						Int_t parNo) const
{
  // Returns the parNo'th parameter of the centraility cut function
  // funcNo. Return FLT_MAX in case of errors 
  if (!fCentralityFunc.fAccessMode || !fCentralityFunc.fRevision)
    return FLT_MAX;
  
  Float_t* array = (Float_t*)fCentralityFunc.fRevision->GetArray();
  if (!array)
    return FLT_MAX;
  
  Int_t norder = Int_t(array[0]);
  Int_t nfuncs = Int_t(array[1]);
  
  if (nfuncs <= funcNo)
    return FLT_MAX;
    
  // Offset of function in array:
  //   i * (number of parameters + one for cent) + two reserved places
  //   + 1 for cent 
  Int_t offset = funcNo * (norder + 2) + 2 + 1;
  return array[offset + parNo];
}
  
//____________________________________________________________________
//
// Geometry 
// 
//____________________________________________________________________
Short_t BrMultCalibration::GetRingMap(Int_t singleNo) const 
{
  // Get map (ring) for single number singleNo (zero based) 
  if (fRingMap.fAccessMode && fRingMap.fRevision) 
    return ((Short_t*)fRingMap.fRevision->GetArray())[singleNo];
  else 
    return 0;
}

//____________________________________________________________________
Short_t BrMultCalibration::GetRowMap(Int_t singleNo) const 
{
  // Get map (row) for single number singleNo (zero based) 
  if (fRowMap.fAccessMode && fRowMap.fRevision) 
    return ((Short_t*)fRowMap.fRevision->GetArray())[singleNo];
  else 
    return 0;
}

//____________________________________________________________________
Float_t BrMultCalibration::GetRingPosition(Int_t ringNo) const 
{
  // Get map (ring) for single number singleNo (zero based) 
  if (fRingPosition.fAccessMode && fRingPosition.fRevision) 
    return ((Float_t*)fRingPosition.fRevision->GetArray())[ringNo];
  else 
    return 0;
}

//____________________________________________________________________
Float_t BrMultCalibration::GetTilt(Int_t singleNo) const 
{
  // Get map (row) for single number singleNo (zero based) 
  if (fTilt.fAccessMode && fTilt.fRevision) 
    return ((Float_t*)fTilt.fRevision->GetArray())[singleNo];
  else 
    return 0;
}


//____________________________________________________________________
//
// ADC calibrations  
//
//____________________________________________________________________
void BrMultCalibration::SetPedestal(Int_t singleNo, Float_t pedestal) 
{
  // Set pedestal for single number singleNo (zero based) 
  if (!fPedestal.fAccessMode || !fPedestal.fRevision) 
    return;
  if (singleNo >= fPedestal.fRevision->GetEntries()) 
    return;
  Float_t* array = (Float_t*)fPedestal.fRevision->GetArray();
  if (!array)
    return;
  array[singleNo]  = pedestal; 
}

//____________________________________________________________________
void BrMultCalibration::SetPedestalWidth(Int_t singleNo, 
					 Float_t pedestalWidth) 
{
  // Set pedestal width for single number singleNo (zero based) 
  if (!fPedestalWidth.fAccessMode || !fPedestalWidth.fRevision) 
    return;
  if (singleNo >= fPedestalWidth.fRevision->GetEntries()) 
    return;
  Float_t* array = (Float_t*)fPedestalWidth.fRevision->GetArray();
  if (!array)
    return;
  array[singleNo]  = pedestalWidth;
}

//____________________________________________________________________
void BrMultCalibration::SetAdcGain(Int_t singleNo, Float_t adcGain) 
{
  // Set pedestal width for single number singleNo (zero based) 
  if (!fAdcGain.fAccessMode || !fAdcGain.fRevision) 
    return;
  if (singleNo >= fAdcGain.fRevision->GetEntries()) 
    return;
  Float_t* array = (Float_t*)fAdcGain.fRevision->GetArray();
  if (!array)
    return;
  array[singleNo]  = adcGain;
}

//____________________________________________________________________
//
// Eta dependent conversion from E to M 
//
//____________________________________________________________________
void BrMultCalibration::SetConversionFuncOrder(Int_t o) 
{
  // Set the number of functions to store in calibration
  if (!fConversionFunc.fAccessMode || !fConversionFunc.fRevision) 
    return;
  Float_t* array = (Float_t*)fConversionFunc.fRevision->GetArray();
  if (!array) 
    return;
  array[0] = o;
}

//____________________________________________________________________
void BrMultCalibration::SetConversionFunc(Int_t ringNo, 
					  Float_t* func) 
{
  // Set the number of functions to store in calibration
  if (!fConversionFunc.fAccessMode || !fConversionFunc.fRevision) 
    return;
  Float_t* array = (Float_t*)fConversionFunc.fRevision->GetArray();
  if (!array) 
    return;
  Int_t o = Int_t(array[0]);

  if (ringNo < 0) 
    return; 

  for (Int_t i = 0; i < o + 1; i++)
    array[1 + ringNo * (o + 1) + i] = func[i];
}
  
//____________________________________________________________________
//
// Vertex Z correction function
//
//____________________________________________________________________
void BrMultCalibration::SetCorrectionFunc(Int_t o, Float_t cut, Float_t* func) 
{
  // Set function to store in calibration. First argument is the
  // order, second the valid range in vertex Z, third the actual o+1
  // parameters 
  if (!fCorrectionFunc.fAccessMode || !fCorrectionFunc.fRevision) 
    return;
  Float_t* array = (Float_t*)fCorrectionFunc.fRevision->GetArray();
  if (!array) 
    return;
  array[0] = o;
  array[1] = cut;

  for (Int_t i = 0; i < o + 1; i++)
    array[2 + i] = func[i];
}
  
//____________________________________________________________________
//
// Centrality cuts 
// 
//____________________________________________________________________
void BrMultCalibration::SetNCentralityFunc(Int_t n) 
{
  // Set the number of functions to store in calibration
  if (!fCentralityFunc.fAccessMode || !fCentralityFunc.fRevision) 
    return;
  Float_t* array = (Float_t*)fCentralityFunc.fRevision->GetArray();
  if (!array) 
    return;
  array[1] = n;
}

//____________________________________________________________________
void BrMultCalibration::SetCentralityFuncOrder(Int_t o) 
{
  // Set the number of functions to store in calibration
  if (!fCentralityFunc.fAccessMode || !fCentralityFunc.fRevision) 
    return;
  Float_t* array = (Float_t*)fCentralityFunc.fRevision->GetArray();
  if (!array) 
    return;
  array[0] = o;
}
  
//____________________________________________________________________
void BrMultCalibration::SetCentralityFunc(Int_t funcNo, Float_t cent,
					  Float_t* func) 
{
  // Sets the centraility cut (0 to 100) from second argument, and the
  // function parameters from third argument, of centraility function
  // numbered funcNo. Third argument must be order, as set by
  // SetCentralityFuncOrder long, or you'll get a SIGSEGV!
  if (!fCentralityFunc.fAccessMode || !fCentralityFunc.fRevision) 
    return;
  Float_t* array = (Float_t*)fCentralityFunc.fRevision->GetArray();
  if (!array) 
    return;  

  Int_t norder = Int_t(array[0]);
  Int_t nfuncs = Int_t(array[1]);

  if (funcNo >= nfuncs)
    return;

  // two reserved + i * (# parameters + one for centrality) 
  // Where (# parameters) = order + 1 constant
  Int_t offset = 2 + funcNo * (norder + 2); 

  array[offset] = cent;
  for (Int_t i = 0; i < norder + 1; i++)
    array[offset + i + 1] = func[i];
}
//____________________________________________________________________
//
// Geometry 
//
//____________________________________________________________________
void BrMultCalibration::SetRingMap(Int_t singleNo, Short_t map)
{
  // Get map (row) for single number singleNo (zero based) 
  if (!fRingMap.fAccessMode || !fRingMap.fRevision) 
    return;
  if (singleNo >= fRingMap.fRevision->GetEntries()) 
    return;
  Short_t* array = (Short_t*)fRingMap.fRevision->GetArray();
  if (!array)
    return;
  array[singleNo]  = map; 
}

//____________________________________________________________________
void BrMultCalibration::SetRowMap(Int_t singleNo, Short_t map) 
{
  // Set map (row) for single number singleNo (zero based) 
  if (!fRowMap.fAccessMode || !fRowMap.fRevision) 
    return;
  if (singleNo >= fRowMap.fRevision->GetEntries()) 
    return;
  
  Short_t* array = (Short_t*)fRowMap.fRevision->GetArray();
  if (!array) 
    return;
  
  array[singleNo]  = map; 
}

//____________________________________________________________________
void BrMultCalibration::SetRingPosition(Int_t rowNo, Float_t position) 
{
  // Get position (row) for ring number ringNo (zero based) 
  if (!fRingPosition.fAccessMode || !fRingPosition.fRevision) 
    return;
  if (rowNo >= fRingPosition.fRevision->GetEntries()) 
    return;
  Float_t* array = (Float_t*)fRingPosition.fRevision->GetArray();
  if (!array)
    return;
  array[rowNo]  = position; 
}

//____________________________________________________________________
void BrMultCalibration::SetTilt(Int_t singleNo, Float_t tilt) 
{
  // Get tilt for single number singleNo (zero based) 
  if (!fTilt.fAccessMode || !fTilt.fRevision) 
    return;
  if (singleNo >= fTilt.fRevision->GetEntries()) 
    return;
  Float_t* array = (Float_t*)fTilt.fRevision->GetArray();
  if (!array)
    return;
  array[singleNo]  = tilt; 
}

#ifdef BR_MULT_CAL_TMP

//____________________________________________________________________
ClassImp(BrMultTmpCalibration);

//____________________________________________________________________
BrMultTmpCalibration::BrMultTmpCalibration()
{
  Warning("Init", "n"
	  "* WARNING * WARNING * WARNING * WARNING *n" 
	  "=========================================n"
	  " Using temporary hardcoded calibrationn"
	  " constants. Check it out!!!n");
  fDebugLevel = 0;
}

//____________________________________________________________________
BrMultTmpCalibration::BrMultTmpCalibration(const Char_t* name, 
					   const Char_t* title) 
  : TNamed(name, title)
{
  Warning("Init", "n"
	  "* WARNING * WARNING * WARNING * WARNING *n" 
	  "=========================================n"
	  " Using temporary hardcoded calibrationn"
	  " constants. Check it out!!!n");
  fDebugLevel = 0;
}
    
//____________________________________________________________________
 BrMultTmpCalibration::~BrMultTmpCalibration()
{}
    
// For the eta correction function 
//____________________________________________________________________
 Int_t BrMultTmpCalibration::GetConversionFuncOrder() const
{ 
  // Return the order of the conversion function 
  return fConversionOrder;
}

// For the correction function 
//____________________________________________________________________
 Int_t BrMultTmpCalibration::GetCorrectionFuncOrder() const
{ 
  // Return the order of the vertex Z  correction function.
  return fCorrectionOrder;
}

//____________________________________________________________________
 Float_t BrMultTmpCalibration::GetCorrectionFuncCut() const
{ 
  // Return the max vertex Z for whichthe correction function is
  // valid. 
  return fCorrectionCut;
}

// For the centrality cuts 
//____________________________________________________________________
 Int_t BrMultTmpCalibration::GetCentralityFuncOrder() const
{ 
  // Return the order of the centrlity functions.
  return fCentralityOrder;
}

//____________________________________________________________________
 Int_t BrMultTmpCalibration::GetNCentralityFunc() const
{ 
  // Return the number of centrality fuctions 
  return fCentralityN;
}

#endif
//____________________________________________________________________
//
// $Log: BrMultCalibration.cxx,v $
// Revision 1.5  2002/03/14 10:02:20  cholm
// minor fixes to output
//
// Revision 1.4  2001/10/08 10:27:02  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.3  2001/09/12 15:05:26  cholm
// Varius fixes that was needed for the thing to work properly.  Mistakes on
// my part.  Stupid ones too.
//
// Revision 1.2  2001/07/20 15:17:39  cholm
// Added the warning to default named CTOR as well.
//
// Revision 1.1.1.1  2001/06/21 14:54:59  hagel
// Initial revision of brat2
//
// Revision 1.2  2001/06/05 18:42:36  cholm
// Removed BrDbInc.h an all references to it
//
// Revision 1.1  2001/05/31 01:45:47  cholm
// Second rewamp of this directory.  All RDO modules use the common
// BrMultRdoModule, and they both write BrMultRdo Objects.  Also introduced
// ABC for Br[Tile|Si][Parameters|Calibration] since they have a lot in common,
// and the code can be made more efficient this way.
//
// A possible further thing to do, is to make an ABC for the CentModules, and
// the corresponding calibration modules, since they are very VERY similar.
// However, the current module BrMultCentModule is in the way.  Need to talk
// to Steve about that.
//
//

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