BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
//____________________________________________________________________
//
// Calbration data object for scintilator tiles in the multiplicity
// array 
//

//____________________________________________________________________
//
// $Id: BrTileCalibration.cxx,v 1.18 2002/04/23 15:32:25 videbaek Exp $
// $Author: videbaek $
// $Date: 2002/04/23 15:32:25 $
// $Copyright: 2001 BRAHMS Collaboration 
//
#ifndef WIN32
#include <iostream>
#include <iomanip>
#include <cfloat>
#include <fstream>
#else
#include <iostream.h>
#include <iomanip.h>
#include <float.h>
#include <fstream>
#endif 
#include <TString.h>
#include <TSystem.h>
#ifndef BRAT_BrDataObject
#include "BrDataObject.h"
#endif
#ifndef BRAT_BrTileCalibration
#include "BrTileCalibration.h"
#endif
#ifndef BRAT_BrPathManager
#include "BrPathManager.h"
#endif

//____________________________________________________________________
ClassImp(BrTileCalibration);
 
//____________________________________________________________________
 BrTileCalibration::BrTileCalibration() 
{
  // Default CTOR
}

//____________________________________________________________________
 BrTileCalibration::BrTileCalibration(const Char_t* name, 
				     const Char_t* title) 
  : BrMultCalibration((char*)name, (char*)title) 
{
  // Standard CTOR 
  // The name hould be that of the associated detector e.g. 
  // "MultTile" 
  AddParameterData("adcGap",          &fAdcGap);
  //  fRingRadius =  13.86;
}

//____________________________________________________________________
//
// ADC calibrations  
//
//____________________________________________________________________
 Short_t BrTileCalibration::GetAdcGap(Int_t tileNo) const 
{
  // Get ADC gap for tile number tileNo (zero based) 
  if (fAdcGap.fAccessMode && fAdcGap.fRevision) 
    return ((Short_t*)fAdcGap.fRevision->GetArray())[tileNo];
  else 
    return 0;
}

//____________________________________________________________________
//
// ADC calibrations  
//
//____________________________________________________________________
 void BrTileCalibration::SetAdcGap(Int_t tileNo, Short_t adcGap) 
{
  // Set pedestal width for tile number tileNo (zero based) 
  if (!fAdcGap.fAccessMode || !fAdcGap.fRevision) 
    return;
  if (tileNo >= fAdcGap.fRevision->GetEntries()) 
    return;
  Short_t* array = (Short_t*)fAdcGap.fRevision->GetArray();
  if (!array)
    return;
  array[tileNo]  = adcGap;
}

#ifdef BR_MULT_CAL_TMP

//____________________________________________________________________
ClassImp(BrTileTmpCalibration);

//____________________________________________________________________
BrTileTmpCalibration* BrTileTmpCalibration::fgInstance = 0;

//____________________________________________________________________
BrTileTmpCalibration::BrTileTmpCalibration()
{
  Defaults();
}

//____________________________________________________________________
BrTileTmpCalibration::BrTileTmpCalibration(const Char_t* name, 
					   const Char_t* title) 
  : BrMultTmpCalibration(name, title)
{
  Defaults();
}
    
//____________________________________________________________________
BrTileTmpCalibration::~BrTileTmpCalibration()
{}
    
//____________________________________________________________________
BrTileTmpCalibration* BrTileTmpCalibration::Instance() 
{
  // 
  if (!fgInstance) 
    fgInstance = new BrTileTmpCalibration("MultTile", 
					  "Temporaty tile calib");
  
  return fgInstance;
}


//____________________________________________________________________
void  BrTileTmpCalibration::Defaults() 
{
  //Vertex dependent conversion functions to convert 
  //detected energy to a charged particle multiplicity.  
  //All calibrations are limited to vertices within 45 cm of the
  //multiplicity array center.

  fConversionOrder = 6;
  //Ring 0
  fConversionFunc[0] = 4.84185e+02;	
  fConversionFunc[1] = 1.23184e+00;	
  fConversionFunc[2] = -1.18066e+02;	
  fConversionFunc[3] = 9.21305e+00;	
  fConversionFunc[4] = 2.95385e+00;	
  fConversionFunc[5] = -1.13636e+01;	
  fConversionFunc[6] = -2.96796e+00;	

  //Ring 1
  fConversionFunc[7] = 4.91871e+02;	
  fConversionFunc[8] = 2.26433e+00;	
  fConversionFunc[9] = -1.39763e+02;	
  fConversionFunc[10] = -1.02124e+00;	
  fConversionFunc[11] = 1.68886e+01;	
  fConversionFunc[12] = 1.33643e-02;	
  fConversionFunc[13] = -7.84149e-01;

  //Ring 2
  fConversionFunc[14] = 4.73446e+02;	
  fConversionFunc[15] = 1.62418e+00;	
  fConversionFunc[16] = -1.38524e+02;	
  fConversionFunc[17] = -1.20745e+00;	
  fConversionFunc[18] = 1.77686e+01;	
  fConversionFunc[19] = 3.82261e-01;	
  fConversionFunc[20] = -7.63966e-01;

  //Ring 3
  fConversionFunc[21] = 4.70448e+02;	
  fConversionFunc[22] = -3.09692e+00;	
  fConversionFunc[23] = -1.38683e+02;	
  fConversionFunc[24] = 1.20176e+00;	
  fConversionFunc[25] = 1.85111e+01;	
  fConversionFunc[26] = -1.43594e-01;	
  fConversionFunc[27] = -9.62190e-01;

  //Ring 4
  fConversionFunc[28] = 4.70545e+02;	
  fConversionFunc[29] = -3.01060e+00;	
  fConversionFunc[30] = -1.36386e+02;	
  fConversionFunc[31] = 9.25114e-01;	
  fConversionFunc[32] = 1.73635e+01;	
  fConversionFunc[33] = -7.64499e-02;	
  fConversionFunc[34] = -8.09410e-01;

  //Ring 5
  fConversionFunc[35] = 4.82320e+02;	
  fConversionFunc[36] = -1.25037e+00;	
  fConversionFunc[37] = -1.43339e+02;	
  fConversionFunc[38] = -1.50430e+00;	
  fConversionFunc[39] = 2.02611e+01;	
  fConversionFunc[40] = 3.50551e-01;	
  fConversionFunc[41] = -1.20978e+00;

  //Ring 6
  fConversionFunc[42] = 4.94808e+02;	
  fConversionFunc[43] = -1.80025e+00;	
  fConversionFunc[44] = -1.34922e+02;	
  fConversionFunc[45] = -3.18705e+00;	
  fConversionFunc[46] = 1.53281e+01;	
  fConversionFunc[47] = 1.84737e+00;	
  fConversionFunc[48] = -1.14716e+00;

  //Ring 7
  fConversionFunc[49] = 4.97694e+02;	
  fConversionFunc[50] = -3.28808e+00;	
  fConversionFunc[51] = -1.39092e+02;	
  fConversionFunc[52] = 2.54734e+00;	
  fConversionFunc[53] = 1.80464e+01;	
  fConversionFunc[54] = -1.67089e+00;	
  fConversionFunc[55] = -4.26461e-01;

  // Function parameters for adjusting the sum multiplicity for
  //the vertex location. Used in BrMultRdoModule::CalibrateMultiplicity.
  fCorrectionOrder    = 4;
  fCorrectionCut      = 45;
  fCorrectionFunc[0]  =  1.00920e+00;
  fCorrectionFunc[1]  = -2.50948e-03;
  fCorrectionFunc[2]  = -1.12368e-05;
  fCorrectionFunc[3]  =  4.26331e-07;
  fCorrectionFunc[4]  = -4.34291e-08;

  // Set the default values for the centrality functions 
  // These are based on trigger 4 events from run 2481 in a vertex
  // region from -40cm to 40cm, using 20 vertex bins and 1000
  // multiplicity bins, and a straight line fit. 
  fCentralityOrder = 4;
  fCentralityN     = 14;
  for (Int_t i = 0; i < 84; i++) 
    fCentralityFunc[i] = 0;
  // Maps 
  for (Int_t i = 0; i < BR_TILE_CHAN_MAX; i++) {
    fPedestal[i]      = 0;
    fPedestalWidth[i] = 0;
    fAdcGain[i]       = 0.945 / 160;
    fAdcGap[i]        = 2156;
    fRingMap[i]       = -1;
    fRowMap[i]        = -1;
    fTilt[i]          = 0;  
  }
  
  // Geometry
  fRingPosition[0]    = -43.7625;
  fRingPosition[1]    = -31.3025;
  fRingPosition[2]    = -18.8425;
  fRingPosition[3]    =  -6.3825;
  fRingPosition[4]    =    6.3825;
  fRingPosition[5]    =  18.8425;
  fRingPosition[6]    =  31.3025;
  fRingPosition[7]    =  43.7625;

  // 
  fRingRadius         =  13.86;
  fRingDetectorFront = 13.5;
  fRingDetectorDepth = 0.5;
  fRingDetectorWidth = 12.;
  fRingDetectorHeight = 12.;

  //
  
}

//____________________________________________________________________
void BrTileTmpCalibration::Clear() 
{
  // Clear everything
}

//____________________________________________________________________
void BrTileTmpCalibration::ReadASCIIFile(Int_t runNo) 
{
  char line[128];
  BrPathManager* pathMan = BrPathManager::Instance();

  // Set run specific calibration parameters
  SetRunNo(runNo);
  for(Int_t i = 0; i< BR_TILE_RING_MAX; i++) fRingCnt[i]=0;

  if (DebugLevel() > 5) 
    cout << ClassName() << "::ReadASCIIFile: for runNo: " << runNo 
	 << endl; 
  if (runNo < 1761) {
    //
    // calibrations for early runs. Only a ADC to row, ring map is
    // avaliable. For everything else, use the default parameters. 
    // 
    TString fileName("ActiveMultDet");

    // Append to file name 
    if (runNo < 0) 
      fileName += ".dat";
    else 
      fileName += "_0.dat";

    // Try to open in current directory 
    ifstream file(fileName.Data());
    if (file.fail()) {
      file.close();
      file.clear();
      // If that fails try in BRATSYS/params
      fileName.Prepend(Form("%s/params/",
			    pathMan->GetDataDir()));
      file.open(fileName.Data());

      if (file.fail()) {
	// If that also fails, give up
	Fatal("ReadASCIIFile", "couldn't find file");
	return;
      }
    }
    
    // Read the file 
    while (kTRUE) {
      // Peek to see what comes next 
      char c = file.peek();
      // if line starts with a 't', we've got a tile line 
      if (c == 't') {
	// Some variables we need 
	char tile[5];
	char underscore[2];
	int ring, row, ch;
	
	// First read the tile name 
	file.get(tile,5); 
	// Then the row number
	file >> row;
	// and then the underscore in the name
	file.get(underscore,2);
	// then the ring number 
	file >> ring;
	// and finally the ADC channel 
	file >> ch;

	// Set the ring and row maps 
	fRingMap[ch] = ring - 1;
	++fRingCnt[ring-1];
	fRowMap[ch]  = row;
	if (DebugLevel() > 10)
	  cout << setw(3) << ch << " " << row << " " << ring << endl;
      }
      // Read the reminder of the line 
      file.getline(line, 128);

      // If we met EOF, break the loop 
      if (file.eof()) 
	break;

      // If some read fialed, stop the whole thing
      if (file.fail()) {
	Fatal("ReadASCIIFile", "failure while reading file");
	return;
      }
      
    } // while(kTRUE)
    file.close();
    return;
  }
  else {
    Char_t fname[120];
    // Later runs, for which we got full calibrations. 
    sprintf(fname, "%s/params/mult/BrCalibrMult_%d.dat", 
			    pathMan->GetDataDir(), runNo);

    ifstream file(fname);
    if (file.fail()) {
      file.close();
      file.clear();

      // If we couldn't open a specific file for the requested run,

      // fall back to runNo = 0 if Yr 1 run, runNo = 1 if Yr 2 run 
      if (runNo >= 5702) 
	sprintf(fname,"%s/params/mult/BrCalibrMult_5702.dat", 
		      pathMan->GetDataDir());
      else if (runNo >= 5685) 
	sprintf(fname,"%s/params/mult/BrCalibrMult_5685.dat", 
		      pathMan->GetDataDir());
      else if (runNo >= 5684) 
	sprintf(fname,"%s/params/mult/BrCalibrMult_5684.dat", 
		      pathMan->GetDataDir());
      else if (runNo >= 5682) 
	sprintf(fname,"%s/params/mult/BrCalibrMult_5682.dat", 
		      pathMan->GetDataDir());
      else if (runNo >= 5681) 
	sprintf(fname,"%s/params/mult/BrCalibrMult_5681.dat", 
		      pathMan->GetDataDir());
      else if (runNo >= 5680) 
	sprintf(fname,"%s/params/mult/BrCalibrMult_5680.dat", 
		      pathMan->GetDataDir());
      else if (runNo >= 5677) 
	sprintf(fname,"%s/params/mult/BrCalibrMult_5677.dat", 
		      pathMan->GetDataDir());
      else if (runNo >= 4713) 
	sprintf(fname,"%s/params/mult/BrCalibrMult_4713.dat", 
		      pathMan->GetDataDir());
      else if (runNo >= 4640) 
	sprintf(fname,"%s/params/mult/BrCalibrMult_4640.dat", 
		      pathMan->GetDataDir());
      else if (runNo >= 3700) 
	sprintf(fname,"%s/params/mult/BrCalibrMult_1.dat", 
		      pathMan->GetDataDir());
      else
	sprintf(fname,"%s/params/mult/BrCalibrMult_0.dat", 
		      pathMan->GetDataDir());

      file.open(fname);
      
      if (file.fail()) {
	// If that also fails, give up
	Fatal("ReadASCIIFile", "couldn't open file %s", fname);
	return;
      }
    }
    if (DebugLevel() > 5) 
      cout << ClassName() 
	   << "::ReadASCIIFile: Reading Tile Calibrations from file "
	   << fname << endl;
    
    // First thing in the file is a number
    Int_t fileRunNo = 0;
    file >> fileRunNo;
    file.getline(line, 128);
    if (fileRunNo != runNo)
      Warning("ReadASCIIFile", 
	      "you requsted run %d, but file %s is for %d", 
	      runNo, fname, fileRunNo);
      
    // Second thing is just a comment line, telling us what the
    // entries are. 
    file.getline(line, 128);
    if (file.fail()) {
      Fatal("ReadASCIIFile", "Failure while reading file %s", 
	    fname);
      return;
    }
            
    Int_t adcChannel     = -1;
    Int_t row            = -1;
    Int_t ring           = -1;
    Int_t status         = 0;
    float pedestal       = 0;
    float pedestalWidth  = 0;
    float tilt           = 0;
    float gain           = 0;
    float gap            = 0;
    if (DebugLevel() > 10)
      cout << "Ch:  " 
	   << "Row " 
	   << "Rin "
	   << "Pedestal "
	   << "PedWidth "
	   << "Gap      "
	   << "Gain     "
	   << "Tilt     " << endl;
    // Start reading the entries 

    while(kTRUE) {
      char c = file.peek();
      if (c == 'A') {
	// Read reminder of the line 
	file.getline(line, 128);
	// beginning of silicon section 
	break;
      }
      if(c=='#') //we have a comment line
	{
	  file.getline(line, 128);
	  continue;
	}
      // Read the ADC channel number. 
      file >> adcChannel;
      // Read the name 
      Int_t n = 0;
      while (n < 4) {
	file.get(c); 
	if      (n == 0 && c == 't') n++;
	else if (n == 1 && c == 'i') n++;
	else if (n == 2 && c == 'l') n++;
	else if (n == 3 && c == 'e') n++;
	else if (c == 't' || c == ' ') 
	  // ignore white space 
	  ;
	else {
	  Error("ReadASCIIFile", 
		"Ill formed tile line in file %s '%c'", 
		fname, c);
	  return;
	}
      }

      // read the row number
      file >> row;
	
      // read seperating underscore 
      file.get(c);
      if (c != '_') {
	Error("ReadASCIIFile", 
	      "Ill formed tile line in file %s. Should be '_' but got '%c'", 
	      fname);
	return;
      }
	
      // read the status 
      file >> ring;

      // read the tatus 
      file >> status;

      // read the pedestal and pedestal width 
      file >> pedestal;
      file >> pedestalWidth;
	
      // read the ADC gap width 
      file >> gap;

      // read the tilt of the detector 
      file >> tilt;

      // read the gain 
      file >> gain;

      // Break on EOF
      if (file.eof()) {
	if (DebugLevel() > 5)
	  cout << "Found EOF" << endl;
	break;
      }
      
      // Return on failure 
      if (file.fail()) {
	Fatal("ReadASCIIFile", "Failure while reading file %s", 
	      fname);
	return;
      }
	  
      // Read reminder of the line 
      file.getline(line, 128);

      --ring;
      // If tile is not flaged as good, add 100 to ring as flag
      if (status < 1) 
	ring+=100;;

      fPedestal[adcChannel]      = pedestal;
      fPedestalWidth[adcChannel] = pedestalWidth;
      fAdcGain[adcChannel]       = gain;
      fAdcGap[adcChannel]        = Int_t(gap);
      fTilt[adcChannel]          = tilt;
      fRowMap[adcChannel]        = row;
      fRingMap[adcChannel]       = ring ;
      if( ring <  BR_TILE_RING_MAX) ++fRingCnt[ring];

      if (DebugLevel() > 10)
	cout << setw(3) << adcChannel << ": " 
	     << setw(3) << fRowMap[adcChannel] << " " 
	     << setw(3) << fRingMap[adcChannel] << " "
	     << setw(8) << fPedestal[adcChannel] << " "
	     << setw(8) << fPedestalWidth[adcChannel] << " " 
	     << setw(8) << fAdcGap[adcChannel] << " " 
	     << setw(8) << fAdcGain[adcChannel] << " " 
	     << setw(8) << fTilt[adcChannel] << endl;

    } // while (kTRUE)
  
    file.close();
  } // if (runNo < 1761) ... else 

  TString name;
  if (runNo < 3700) 
    name = Form("%s/params/mult/tmacent.dat", 
		pathMan->GetDataDir());
  else if (runNo < 5677)
    name = Form("%s/params/mult/tmacent004640.dat", 
		pathMan->GetDataDir());
  else 
    name = Form("%s/params/mult/tmacent005677.dat", 
		pathMan->GetDataDir());
  if (DebugLevel() > 5)
    cout << "Reading TMA Centrality Calibrations from file " << name
	 <<endl; 

  cout << ":"<<name.Data() << ":" <<endl;
  ifstream file(name.Data());
  
  if (file.fail()) {
    // If that also fails, give up
    Fatal("ReadASCIIFile", "couldn't find file '%s'", name.Data());
    return;
  }

  fCentralityN = 0;
  fCentralityOrder = 0;
  // Read the file 
  while (kTRUE) {
    // Peek to see what comes next 
    char c = file.peek();
    // if line starts with a '#', we've got a comment line  
    if (c == '#') {
      file.getline(line, 128);
      continue;
    }

    // Read the first word on the line
    TString token;
    file >> token;
    token.ToLower();

    // If the first word is "order", then we read that
    if (!token.CompareTo("order")) {
      file >> token;
      if (!token.CompareTo("="))
	file >> fCentralityOrder;
    } 
    // If the first word is "ncuts", then we read that
    else if (!token.CompareTo("ncuts")) {
      file >> token;
      if (!token.CompareTo("="))
	file >> fCentralityN;
    }
    // Read the rest of the line 
    file.getline(line, 128);

    // Break out of this state if we got all we need for  now. 
    if (fCentralityOrder > 0 && fCentralityN > 0) 
      break;

    // Return if we got some error. 
    if (file.eof() || file.fail()) {
      Error("ReadASCIIFile", 
	    "Incomplete read of centrality parameters"); 
      file.close();
      fCentralityN = 0;
      fCentralityOrder = 0;
      return;
    }
  }
  
  if (fCentralityN * (fCentralityOrder+2) > 128) {
    Warning("ReadASCIIFile", 
	    "Insufficient memory to store cuts");
    return;
  }
    

  Int_t cut = 0;
  while(true) {
    // Peek to see what comes next 
    char c = file.peek();
    // if line starts with a '#', we've got a comment line 
    if (c == '#') {
      file.getline(line, 128);
      continue;
    }
    
    // Read the cut value;
    file >> fCentralityFunc[cut * (fCentralityOrder + 2)];
    if (DebugLevel() > 10)
      cout << " Cut: " 
	   << fCentralityFunc[cut * (fCentralityOrder + 2)] 
	   << flush;
    

    // Read the parameters 
    for (Int_t i = 0; i < fCentralityOrder + 1; i++) {
      file >> fCentralityFunc[cut * (fCentralityOrder + 2) + i + 1];
      if (DebugLevel() > 10)
	cout << " + " 
	     << fCentralityFunc[cut * (fCentralityOrder + 2) + i + 1] 
	     << "x^" << i << "(" << cut * (fCentralityOrder + 2) + i + 1 
	     << ")" << flush;
    }
    if (DebugLevel() > 10)
      cout << endl;
    
    
    // Increment the cut counter, and see if we are at the last one. 
    if (++cut >= fCentralityN) {
      file.close();
      break;
    }
    
    // Return if we got some error. 
    if (file.eof() || file.fail()) {
      Error("ReadASCIIFile", 
	    "Incomplete read of centrality parameters"); 
      fCentralityN = cut;
      file.close();
      return;
    }
  }
}

// ADC calibration 
//____________________________________________________________________
Float_t BrTileTmpCalibration::GetPedestal(Int_t tileNo) const
{ 
  // Returnt the ADC pedestal 
  if (tileNo >= BR_TILE_CHAN_MAX || !fPedestal)
    return 0;
  return fPedestal[tileNo];
}
 
//____________________________________________________________________
Float_t BrTileTmpCalibration::GetPedestalWidth(Int_t tileNo) const
{ 
  // Returnt the ADC pedestal Widht
  if (tileNo >= BR_TILE_CHAN_MAX || !fPedestalWidth)
    return 0;
  return fPedestalWidth[tileNo];
}
 
//____________________________________________________________________
Int_t BrTileTmpCalibration::GetAdcGap(Int_t tileNo) const
{ 
  // Returnt the ADC gap width
  if (tileNo >= BR_TILE_CHAN_MAX || !fAdcGap)
    return 0;
  return fAdcGap[tileNo];
}
 
//____________________________________________________________________
Float_t BrTileTmpCalibration::GetAdcGain(Int_t tileNo) const
{ 
  // Returnt the ADC gain
  if (tileNo >= BR_TILE_CHAN_MAX || !fAdcGain)
    return 0;
  return fAdcGain[tileNo];
}
 
// For the eta correction function 
//____________________________________________________________________
Float_t BrTileTmpCalibration::GetConversionFuncPar(Int_t ringNo, 
						   Int_t parno) const
{ 
  // return the parNo conversion parameter
  if (!fConversionFunc || parno > fConversionOrder ||
      ringNo > BR_TILE_RING_MAX) 
    return 0;
  return fConversionFunc[ringNo * (fConversionOrder + 1) + parno];
}

// For the correction function 
//____________________________________________________________________
Float_t BrTileTmpCalibration::GetCorrectionFuncPar(Int_t parno) const
{ 
  // return the parno parameter of the vertex correction function
  if (!fCorrectionFunc || parno > fCorrectionOrder) 
    return 0;
  return fCorrectionFunc[parno];
}

// For the centrality cuts 
//____________________________________________________________________
Float_t BrTileTmpCalibration::GetCentralityFuncCut(Int_t funcno) const
{ 
  // return the centrality cut of the funcno centrality function
  if (!fCentralityFunc || funcno > fCentralityN) 
    return 0;
  return fCentralityFunc[funcno * (fCentralityOrder + 2)];
}

//____________________________________________________________________
Float_t BrTileTmpCalibration::GetCentralityFuncPar(Int_t funcno, 
						   Int_t parno) const
{ 
  // return the parno parameter of the funcno centrality function
  if (!fCentralityFunc || 
      parno > fCentralityOrder || 
      funcno > fCentralityN) 
    return 0;
  return fCentralityFunc[funcno * (fCentralityOrder + 2) + parno + 1];
}

  // Geometry - shoud be in geometry database
//____________________________________________________________________
Short_t BrTileTmpCalibration::GetRingMap(Int_t tileNo) const
{ 
  // Return the ring # corresponding til ADC channel # tileno
  if (!fRingMap || tileNo >= BR_TILE_CHAN_MAX){
    Warning("GetRingMap", "either no ringmap, or %d >= %d", 
	    tileNo, BR_TILE_CHAN_MAX);
    return 0;
  }
  
  return fRingMap[tileNo];
}
 
//____________________________________________________________________
Short_t BrTileTmpCalibration::GetRowMap(Int_t tileNo) const
{ 
  // Return the row # corresponding til ADC channel # tileno
  if (!fRowMap || tileNo >= BR_TILE_CHAN_MAX) {
    Warning("GetRowMap", "either no rowmap, or %d >= %d", 
	    tileNo, BR_TILE_CHAN_MAX);
    return 0;
  }
  
  return fRowMap[tileNo];
}
 
//____________________________________________________________________
Float_t BrTileTmpCalibration::GetRingPosition(Int_t ringNo) const
{ 
  // 
  if (ringNo >= BR_TILE_RING_MAX || !fRingPosition)
    return 0;
  return fRingPosition[ringNo];
}
 
//____________________________________________________________________
Float_t BrTileTmpCalibration::GetTilt(Int_t tileNo) const
{ 
  // 
  if (!fTilt || tileNo >= BR_TILE_CHAN_MAX)
    return 0;
  return fTilt[tileNo];
}

//____________________________________________________________________
void BrTileTmpCalibration::SetRunNo(const Int_t runno)
{
  fRunNo = runno;
  // Function parameters for adjusting the sum multiplicity for
  //the vertex location. Used in BrMultRdoModule::CalibrateMultiplicity.
  fCorrectionOrder    = 4;
  fCorrectionCut      = 45;
  if(runno < 3700)
    {
      fCorrectionFunc[0]  =  1.00920e+00;
      fCorrectionFunc[1]  = -2.50948e-03;
      fCorrectionFunc[2]  = -1.12368e-05;
      fCorrectionFunc[3]  =  4.26331e-07;
      fCorrectionFunc[4]  = -4.34291e-08;
    }
  else
    {
      fCorrectionFunc[0]  =  9.77354e-01;
      fCorrectionFunc[1]  = -1.19621e-03;
      fCorrectionFunc[2]  = -3.64626e-05;
      fCorrectionFunc[3]  = -1.51515e-07;
      fCorrectionFunc[4]  = -4.17250e-08;
    }

}

//____________________________________________________________________
void BrTileTmpCalibration::Print(Option_t* option) const 
{
  Int_t i = 0;
  cout << "BrTileTmpCalibration: " << flush; 

  // Pedestal of ADCs
  cout << endl << "  Pedesal:" << flush;
  for (i = 0; i < BR_TILE_CHAN_MAX; i++) {
    if (i % 8 == 0) cout << endl;
    cout << setw(8) << fPedestal[i] << " " << flush;
  }
  
  // Pedestal width of ADCs
  cout << endl << "  Pedestal width: " << flush;
  for (i = 0; i < BR_TILE_CHAN_MAX; i++) {
    if (i % 8 == 0) cout << endl;
    cout << setw(8) << fPedestalWidth[i] << " " << flush;
  }
  
  // Pedestal width of ADCs
  cout << endl << "  ADC Gap: " << flush;
  for (i = 0; i < BR_TILE_CHAN_MAX; i++) {
    if (i % 8 == 0) cout << endl;
    cout << setw(8) << fAdcGap[i] << " " << flush;
  }

  // Pedestal width of ADCs
  cout << endl << "  ADC Gap: " << flush;
  for (i = 0; i < BR_TILE_CHAN_MAX; i++) {
    if (i % 8 == 0) cout << endl;
    cout << setw(8) << fAdcGain[i] << " " << flush;
  }


  // Pedestal width of ADCs
  cout << endl << "  Conversion func: " << flush;
  for (i = 0; i < 7 * BR_TILE_RING_MAX; i++) {
    if (i % 8 == 0) cout << endl;
    cout << setw(8) << fConversionFunc[i] << " " << flush;
  }

  // Pedestal width of ADCs
  cout << endl << "  Correction func: " << flush;
  for (i = 0; i < 5; i++) {
    if (i % 8 == 0) cout << endl;
    cout << setw(8) << fCorrectionFunc[i] << " " << flush;
  }

  // Centrality 
  cout << endl << "  Centrality:  Order=" << fCentralityOrder 
       << " Number=" << fCentralityN << flush;
  for (i = 0; i < 70; i++) {
    if (i % 8 == 0) cout << endl;
    cout << setw(8) << fCentralityFunc[i] << " " << flush;
  }

  // Tilt
  cout << endl << "  tilt: " << flush;
  for (i = 0; i < BR_TILE_CHAN_MAX; i++) {
    if (i % 8 == 0) cout << endl;
    cout << setw(8) << fTilt[i] << " " << flush;
  }

  // Ring map
  cout << endl << "  Ring map: " << flush;
  for (i = 0; i < BR_TILE_CHAN_MAX; i++) {
    if (i % 8 == 0) cout << endl;
    cout << setw(8) << fRingMap[i] << " " << flush;
  }

  // Row map
   cout << endl << "  Row map: " << flush;
  for (i = 0; i < BR_TILE_CHAN_MAX; i++) {
    if (i % 8 == 0) cout << endl;
    cout << setw(8) << fRowMap[i] << " " << flush;
  }


  // Row map
  cout << endl << "  Ring position: " << flush;
  for (i = 0; i < BR_TILE_RING_MAX; i++) {
    if (i % 8 == 0) cout << endl;
    cout << setw(8) << fRingPosition[i] << " " << flush;
  }
  cout << endl;
}

#endif 

//
// $Log: BrTileCalibration.cxx,v $
// Revision 1.18  2002/04/23 15:32:25  videbaek
// Removed ios::in. Added close + clear in cases where you want to re-open another file
// (The error flags are not cleared on an open in C++ standard, was in gcc 2.91 but not in g++3
// Added lineno counter for error ouput.
//
// Revision 1.17  2002/03/14 10:02:35  cholm
// minor fixes to output
//
// Revision 1.16  2002/03/02 15:33:32  cholm
// Expanded arrays for more centrality cuts
//
// Revision 1.15  2002/03/02 14:45:50  cholm
// Added more cases for reading calibrations
//
// Revision 1.14  2002/02/19 23:28:32  sanders
// another correction to brRingCnt
//
// Revision 1.13  2002/02/19 23:25:57  sanders
// fixed bad initialization of fRingCnt array
//
// Revision 1.12  2002/02/17 18:04:15  sanders
// Added code to allow comments at end of ascii calibration files
//
// Revision 1.11  2002/02/04 23:51:37  sanders
// Add setter for detector gains
//
// Revision 1.10  2002/01/05 08:52:27  sanders
// Changed how detectors with bad status are handled when reading
// ascii file.  Before the status was checked and if found bad the
// detector was skipped.  Now the ring number is incremented by 100
// to flag the status situation.
//
// Revision 1.9  2001/12/06 00:33:08  sanders
// Fixed calibrations to obtain average pseudorapidity and geometric
// scaling factor for si and tile elements.
//
// Revision 1.8  2001/11/24 15:42:56  sanders
// Added si and tile calibrations for:
// 1) converting from detector multiplicities to ring dNdEta values
// 2) finding the HIJING weighted ring eta value for a given vertex position
// Both of these calibrations were found doing 8th order polynomial fits
// to functions obtained by taking HIJING particle distributions starting
// from vertex locations between -46cm and +46 cm, in 2 cm steps, and
// checking if the corresponding particles "hit" any of the si or tile
// detectors in the array.
//
// Revision 1.7  2001/11/21 19:12:20  cholm
// Added code for reading SDE centrality calibrations for run 4640
// (and forward?).  See also http://www4.rhic.bnl.gov/~cholm/mult.html. Took
// out the default numbers since they were invalid and not used.
//
// Revision 1.6  2001/11/19 04:09:36  sanders
// Revised calibration modules for 200 GeV (yr 2001) si/tile calibrations.
//
// Revision 1.5  2001/11/15 00:33:51  sanders
// fix premature submission
//
// Revision 1.4  2001/11/15 00:08:59  sanders
// Print name of ascii calibration file if Verbose() >=3
//
// Revision 1.3  2001/10/27 23:01:42  sanders
// Added code for yr 2 calibration in tmpCalibration.  The yr 2
// default ascii file is BrCalibrMult_1.dat
//
// Revision 1.2  2001/09/12 15:05:51  cholm
// Varius fixes that was needed for the thing to work properly.  Mistakes on
// my part.  Stupid ones too.
//
// Revision 1.1.1.1  2001/06/21 14:54:59  hagel
// Initial revision of brat2
//
// Revision 1.15  2001/06/05 18:42:54  cholm
// Removed BrDbInc.h an all references to it
//
// Revision 1.14  2001/06/04 13:37:17  cholm
// Changes to use BrPathManager, BrVersion, and perpare to use BrFileTag.
//
// Revision 1.13  2001/06/02 15:24:21  sanders
// Modified parameters for E-to-N conversions.  Also modified parameters
// for converting the average Si+Tile sum multiplicity to centrality.  The
// new parameters result from an analysis where GEANT simulations are used
// to correct for the excessive number of low multiplicity events arising from
// pedestal tails being counted as particle hits.  Events with tile multiplicities
// between 4 and 200 are compared to the corresponding GBRAHMS (Hijing input)
// simulations to estimate the number of expected events with tile multiplicity
// below 4.
//
// Revision 1.12  2001/05/31 01:46:52  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.
//
// Revision 1.11  2001/05/23 12:29:06  cholm
// Important bug fixes in returning centrality function
//
// Revision 1.10  2001/05/17 11:13:01  cholm
// Added support for reading ASCII calibration files for centrality cuts
// in classes BrTileTmpCalibration and BrSiTmpCalibration.
// Added some preliminary work for using the energy signal rather than the
// multiplicity signal for the centrality determination in classses
// BrTileCentCalModule and BrSiCentCalModule.
//
// Revision 1.9  2001/04/11 14:02:52  cholm
// Use 9'th degree polynomial for correction (was 8'th)
//
// Revision 1.8  2001/04/06 20:00:07  cholm
// Updated to use per ring conversion functions, as outlined by
// Steve and Hiro in BAN24.
//
// Revision 1.7  2001/04/05 03:26:34  sanders
// removed unnecessary conditional compilation code
//
// Revision 1.6  2001/04/05 03:04:55  sanders
// Restored "brat complience" to Si and Tile Rdo, BrRdoModuleMult still not complient.
//
// Revision 1.5  2001/04/02 01:18:16  sanders
// BrRdoMult and BrRdoModuleMult reinstated.  These files develop the joint
// Si+Tile multiplicity.  BrRdoModuleMult now gets it parameters from the
// BrTileRdoModule and BrSiRdoModule classes and is a friend of these classes.
//
// Revision 1.4  2001/03/21 11:03:37  cholm
// Updated centrality calibrations, and corrected a few mistakes in
// temporary calibration class BrTileTmpCalibration.
//
// Revision 1.3  2001/03/12 19:03:45  cholm
// Revisted the tile classes. Please note, that these are binary incompatible
// with previous classes. These classes now includes (I believe) all that
// Steve and Hiro recently added to thier working code.
//
// Revision 1.2  2001/02/08 15:12:12  cholm
// Fixed a minor bug in BrTileCalibration
// Fleshed out BrtileCent.
// Finalised BrTileCentCalModule.
// Finalised BrTileCentModule.
// Minor bug fixes to BrTileRdoModule.
//
// Revision 1.1  2001/01/29 20:44:02  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