BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
// $Id: BrDetectorParamsTPC.cxx,v 1.7 2002/02/27 21:15:40 videbaek Exp $
// $Author: videbaek $
// $Date: 2002/02/27 21:15:40 $
//
//

//_______________________________________________________________
//
// BrDetectorParamsTPC is a BRAHMS data class providing storage and 
// access function for TPC specific digitasation parameters.
// This allows modification of the BrDetectorParams content by the 
// user This class is not yet implemeted as a proper database/geometry
// class. 
//
//
// Update:
//    June 2000 /fv
//    Introduce fTimingoffset ie. time from interaction to
//    readoutstart.
//    Let the IntrinsicToTime.. depend on row number as per
//    real data i.e. calibration data
//    Add array to take care of this.
//
//   September 2000
//    Completed change of refering row number by 1,...20
//    This also involved a change in the default DetectorParameters.txt
//

#include <BrIostream.h>
#include <BrDetectorParamsTPC.h>

//_______________________________________________________________
ClassImp(BrDetectorParamsTPC)

//_______________________________________________________________
  BrDetectorParamsTPC::BrDetectorParamsTPC()

{
// Constructor. Set counter and list data members to zero.
// Don't use this constructor unless you have to and know
// what you are doing
// Use BrDetectorParams(Char_t, Char_t ) instead
}

//_______________________________________________________________
 BrDetectorParamsTPC::BrDetectorParamsTPC(Char_t *name, Char_t *title)
: BrDetectorParamsBase(name,title)
{
  fPadRowStatus = 0;
  SetDefaultParams();
}
//________________________________________________________________
 BrDetectorParamsTPC::BrDetectorParamsTPC(Char_t *name, Char_t *title, Char_t *filename)
: BrDetectorParamsBase(name,title)
{
  fPadRowStatus = 0;
  SetDefaultParams();
  ReadASCIIFile(filename);
}

//_______________________________________________________________
  BrDetectorParamsTPC::~BrDetectorParamsTPC()
{
  if(fPadRowStatus){
    Int_t i;
    for(i=(fNumberOfRows-1);i>=0;i--)
      {
	delete [] fPadRowStatus[i];
      }
    delete [] fPadRowStatus;
  }

}

//_________________________________________________________________________
Float_t 
 BrDetectorParamsTPC::AddTimeCorrection(Int_t row, Float_t &time)
  // Add the time correction when you go from time to another
  // coordinate, like intrinsic position or drift
{
  time = time - fRowTimeCorrection[row-1]/fTimeBucket
    - time*fRowTimeCorrectionSlope[row-1]/fTimeBucket;
  return time;
}

//_________________________________________________________________________
 Int_t BrDetectorParamsTPC::GetRowNumber(Int_t row) const
{
  // returns the active rownumber of a row
  // Inverse method of GetActiveRowNumber
  // returns -1 if row number is invalid or row
  // is inactive

  // Check that row number is in range
  if( 1 > row || row > fNumberOfRows ) {
    Warning("GetRowNumber", 
	    Form("%s : %d is NOT a valid row number", GetName(), row)); 
    return -1;
  }
  
  for(Int_t i = 0; i < fNumberOfActiveRows; i++) {
    if( fActiveRowNumber[i]+1 == row )
      return i+1;
  }
  
  // Conclusion must be that row is not active
  return -1;
}

//_________________________________________________________________________
 void BrDetectorParamsTPC::SetDefaultParams()
{
  // A set of resonable parameters for TPC digitization routines
  // are being set. Called by the constructor. The parameters here
  // correspond to T1 in the forward spectrometer and several for T1.
  // The TPM1 and TPM2 default are set in the following blocks of code. 
  //

   fTwoPar       = (Float_t)0.80;
   fDlong        = (Float_t)0.04;
   fDtrans       = (Float_t)0.05;
   fEff          = (Float_t)0.97;
   fDriftVelocity= (Float_t)0.0016;
   fRowDistance  =    (Float_t)4.0;
   fNumberOfRows =           14;
   fNoBuckets    =           158;
   fPadsPerRow   =           96;
   fPadDistance  =   (Float_t).35;
   fPadWidth     =   (Float_t).30;
   fPadLength    =  (Float_t)2.90;
   fAnodeGap     =   (Float_t)0.4;
   fTimeBucket   =  (Float_t)100.0;
   fShapingTime  = (Float_t)180.0;
   fADCGain      =   (Float_t)2.0;
   fADCChannels  =           1024;
   fPadBasePosition  = fPadsPerRow*fPadDistance /2.;
   fTimeBasePosition = 11.8;   // offset cm.
   fTimingOffset     = 1030.0;  // offset nsec
   fHitWidthX    = -1;
   fHitWidthY    = -1;

   Int_t irow;

   for(irow=0;irow<kMaxRows;irow++) {
     
     fRowTimeCorrection[irow] = 0.0;
     fRowTimeCorrectionSlope[irow] = 0.0;
   }
   
   //
   // Default T1 values
   //
   if(!strcasecmp(GetName(),"T1")) { 
     fNumberOfRows = 14;
     for(irow=0;irow<fNumberOfRows;irow++){ 
       fRowPosition[irow] = -(Float_t)26.6493 + (Float_t)4*irow;
       fRowActive[irow] = kTRUE;
     }
      fRowActive[0]  = kTRUE;
      fRowActive[1]  = kTRUE;
      fRowActive[2]  = kTRUE;
      fRowActive[3]  = kTRUE;
      fRowActive[4]  = kTRUE;
      fRowActive[5]  = kTRUE;
      fRowActive[6]  = kTRUE;
      fRowActive[7]  = kTRUE;
      fRowActive[8]  = kFALSE;
      fRowActive[9]  = kFALSE;
      fRowActive[10] = kTRUE;
      fRowActive[11] = kTRUE;
      fRowActive[12] = kTRUE;
      fRowActive[13] = kTRUE;

//        fRowTimeCorrection[0] = -99.2803;     
//        fRowTimeCorrectionSlope[0] = 1.79329;
//        fRowTimeCorrection[1] = -48.4988;    
//        fRowTimeCorrectionSlope[1] = 0.390106;
//        fRowTimeCorrection[2] = -29.4296;    
//        fRowTimeCorrectionSlope[2] = 0.120554;
//        fRowTimeCorrection[3] = -6.8677;   
//        fRowTimeCorrectionSlope[3] = -0.125305;

//        fRowTimeCorrection[6] = 26.64;   
//        fRowTimeCorrectionSlope[6] = 0.0127807;
//        fRowTimeCorrection[7] = -14.008;    
//        fRowTimeCorrectionSlope[7] = 0.166877;

//        fRowTimeCorrection[10] = 1.4711;   
//        fRowTimeCorrectionSlope[10] = -0.206937;
//        fRowTimeCorrection[11] = -4.28278; 
//        fRowTimeCorrectionSlope[11] = -0.00262319;
//        fRowTimeCorrection[12] = -36.6112;    
//        fRowTimeCorrectionSlope[12] = 0.183559;
//        fRowTimeCorrection[13] = -70.5915;    
//        fRowTimeCorrectionSlope[13] = 0.915618;
   }

   //
   //The following are default values for T2
   //
   if(!strcasecmp(GetName(),"T2")) {
      fNumberOfRows = 16;
      fPadsPerRow  = 112;
      for(irow=0;irow<8;irow++)  
         fRowPosition[irow] = (Float_t)-36.25  + (Float_t)(4*irow);
      for(irow=8;irow<16;irow++) 
         fRowPosition[irow] = (Float_t)  7.15 + (Float_t)(4*(irow-8));
      fRowActive[0]  = kTRUE;
      fRowActive[1]  = kTRUE;
      fRowActive[2]  = kFALSE;
      fRowActive[3]  = kFALSE;
      fRowActive[6]  = kFALSE;
      fRowActive[7]  = kFALSE;
      fRowActive[4]  = kTRUE;
      fRowActive[5]  = kTRUE;
      fRowActive[8]  = kTRUE;
      fRowActive[9]  = kTRUE;
      fRowActive[10] = kFALSE;
      fRowActive[11] = kFALSE;
      fRowActive[12] = kFALSE;
      fRowActive[13] = kFALSE;
      fRowActive[14] = kTRUE;
      fRowActive[15] = kTRUE;

//        fRowTimeCorrection[0] = -375.605;    
//        fRowTimeCorrectionSlope[0] = 3.83272;
//        fRowTimeCorrection[1] = -192.377;    
//        fRowTimeCorrectionSlope[1] = 1.59535;

//        fRowTimeCorrection[4] = 6.3246; 
//        fRowTimeCorrectionSlope[4] = -0.0215169;
//        fRowTimeCorrection[5] = -6.23002;  
//        fRowTimeCorrectionSlope[5] = -0.129807;

//        fRowTimeCorrection[8] = -108.573;    
//        fRowTimeCorrectionSlope[8] = 1.10917;
//        fRowTimeCorrection[9] = 101.03;  
//        fRowTimeCorrectionSlope[9] = -1.20113;

//        fRowTimeCorrection[14] = 207.347;   
//        fRowTimeCorrectionSlope[14] = -1.59216;
//        fRowTimeCorrection[15] = 186.484;  
//        fRowTimeCorrectionSlope[15] = -0.352025;

      }

   
 //
 //The following are default values for TPM2
 //
   if(!strcasecmp(GetName(),"TPM2")) {
     fNumberOfRows = 20;
     fPadDistance  =   (Float_t).47;
     fPadWidth     =   (Float_t).42;
     fPadLength    =  (Float_t)2.40;
     fAnodeGap     =   (Float_t)0.4;
     fPadsPerRow     =           144;
 
      for(irow=0;irow<20;irow++)  
         fRowPosition[irow] = (Float_t)-2.5*9.5  + (Float_t)(2.5*irow);
      fRowActive[0]  = kTRUE;
      fRowActive[1]  = kTRUE;
      fRowActive[2]  = kFALSE;
      fRowActive[3]  = kFALSE;
      fRowActive[4]  = kTRUE;
      fRowActive[5]  = kTRUE;
      fRowActive[6]  = kFALSE;
      fRowActive[7]  = kFALSE;
      // 2000 run setting
      // fRowActive[8]  = kTRUE;
      // fRowActive[9]  = kTRUE;
      fRowActive[8]  = kFALSE;
      fRowActive[9]  = kFALSE;
      fRowActive[10] = kTRUE;
      fRowActive[11] = kTRUE;
      fRowActive[12] = kFALSE;
      fRowActive[13] = kFALSE;
      fRowActive[14] = kTRUE;
      fRowActive[15] = kTRUE;
      fRowActive[16] = kFALSE;
      fRowActive[17] = kFALSE;
      fRowActive[18] = kTRUE;
      fRowActive[19] = kTRUE;

      fRowTimeCorrection[0] =  -150.;
      fRowTimeCorrection[1] =   -50.;
      fRowTimeCorrection[18] =  -50.;
      fRowTimeCorrection[19] = -150.;
   }
//
 //The following are default values for TPM1
 //
   if(!strcasecmp(GetName(),"TPM1")) {
     fNumberOfRows = 12;
     fPadDistance  =   (Float_t).39;
     fPadWidth     =   (Float_t).35;
     fPadLength    =   (Float_t)2.95;
     fAnodeGap     =   (Float_t)0.45;
 
     for(irow=0;irow<12;irow++){  
        fRowPosition[irow] = (Float_t)-3.05*5.5  + (Float_t)(3.05*irow);
        fRowActive[irow] = kTRUE;
     }
   }
   fPadBasePosition = (fPadsPerRow*fPadDistance /2.);

   SetActiveParameters();
}

//_________________________________________________________________________
 void BrDetectorParamsTPC::ListPadStatus() const
{
//
//  List the status for all pads in tpc 
//

  cout << "Row";

  for(Int_t i = 0; i < fNumberOfRows; i++)
    cout << setw(3) << i+1;
  
  cout << endl;

  for(Int_t i = 0; i < fPadsPerRow; i++) {
    
    if(i%16 == 0)
      cout << endl;
    
    cout << setw(3) << i;
    
    for(Int_t j = 0; j < fNumberOfRows; j++) {

      cout << setw(3) << fPadRowStatus[j][i];
    }
    
    cout << endl;
  }
}

//_________________________________________________________________________
 void BrDetectorParamsTPC::ListParameters() const
{
//
//  List the current Detector Parameters 
//
  cout << "**TPC Parameters for : " << GetName();
  cout.width(12);
  cout << "nSimulation Parameters";
  cout.width(12);
  cout << "n Two Particle Resolution " << fTwoPar      << " (cm)";
  cout << "n D(Longitudinal)         " << fDlong       << " (cm)";
  cout.width(12);
  cout << "n D(Transverse)           " << fDtrans      << " (cm)";
  cout.width(12);
  cout << "n Effenciency             " << fEff;
  cout << "n AnodeGap                " << fAnodeGap    << " (cm)";

  cout << "nGas and Readout Parameters";
  cout << "n Drift Velocity          " << fDriftVelocity      << " (micron/ nsec)";
  cout << "n Bucket Size             " << fTimeBucket  << " (nsec)";
  cout << "n Number Of Buckets       " << fNoBuckets;
  cout << "n Shaping time            " << fShapingTime << " (nsec)";
  cout << "n ADC relative Gain       " << fADCGain ;
  cout << "n ADC relative Channels   " << fADCChannels ;
  cout << "n Timing Offset           " << fTimingOffset;
  cout << "nGeometry Parameters";
  cout << "n Row Distance            " << fRowDistance  << " (cm)";
  cout << "n Number of Rows          " << fNumberOfRows;
  cout << "n Number of Active Rows   " << fNumberOfActiveRows;
  cout << "n Pads per row            " << fPadsPerRow ;
  cout << "n Pad Pitch               " << fPadDistance  << " (cm)";
  cout << "n Pad Width               " << fPadWidth     << " (cm)";
  cout << "n Pad length              " << fPadLength     << " (cm)";
  cout << "n Pad Baseposition        " << fPadBasePosition    << " (cm)";
  cout << "n TimeBaseposition        " << fTimeBasePosition    << " (cm)";

  if(fHitWidthX>0 && fHitWidthY>0)
    cout << endl 
	 << " HitWidthX               " << fHitWidthX    << " (cm)" << endl
	 << " HitWidthY               " << fHitWidthY    << " (cm)";
  
  cout << endl;
  
  for(int i=0;i<fNumberOfRows;i++){
    cout << endl << "  Row "<< setw(2)<< (i+1) << " : "
	 << setw(8) << fRowPosition[i] 
	 << " :  " << setw(8) << fRowTimeCorrection[i]<< " (nsec)  " 
	 << ",  "  << setw(11) << fRowTimeCorrectionSlope[i]<< " (slope)  ";

    if(fRowActive[i]) 
      cout << "ACTIVE";

  }

  cout << endl << endl;
}

//_______________________________________________________________
 void BrDetectorParamsTPC::SetRowPosition(Int_t irow,Float_t xpos)
{
   if((0 <irow) && (irow <= kMaxRows))
      fRowPosition[irow-1] = xpos;
   else
     Error("SetRowPosition","Out of Range %d",irow);
}

//_______________________________________________________________
 void BrDetectorParamsTPC::SetRowActive(Int_t irow)
 {
   if((0 <irow) && (irow <= fNumberOfRows))
      fRowActive[irow-1] = kTRUE;
   else
     Error("SetRowActive","Out of Range %d",irow);
   SetActiveParameters();

}

//_______________________________________________________________
 void BrDetectorParamsTPC::SetRowInActive(Int_t irow)
 {
   if((0 <irow) && (irow <= fNumberOfRows))
      fRowActive[irow-1] = kFALSE;
   else
     Error("SetRowInActive","Out of Range %d",irow);
   SetActiveParameters();
}


//_______________________________________________________________
 void BrDetectorParamsTPC::SetActiveParameters(){
  //
  //  Calculate derived parameters for active rows
  //  i.e. number of active rows, and actual rownumber for
  //  active rows.
  //
  fNumberOfActiveRows = 0;
  for(int irow=0; irow < fNumberOfRows; irow++){
    if(fRowActive[irow]){
      fActiveRowNumber[fNumberOfActiveRows] = irow;
      fNumberOfActiveRows++;
    }
  }
  //
  // Create the Pad status table and
  // fill with data corresponding to all active rows.
  //


  if(fPadRowStatus){
    Int_t i;
    for(i=(fNumberOfRows-1);i>=0;i--)
      {
	delete [] fPadRowStatus[i];
      }
    delete [] fPadRowStatus;
  }

  Short_t** val = new Short_t * [fNumberOfRows];
  Int_t i;
  for( i=0;i<fNumberOfRows;i++){
    val[i] = new Short_t [fPadsPerRow];
  }

  fPadRowStatus   = val;
  for( i=0;i<fNumberOfRows; i++){
    for(int k=0;k<fPadsPerRow; k++)
      fPadRowStatus[i][k]= kPadActive;
  }

}

//___________________________________________________________________
 void BrDetectorParamsTPC::SetASCIIParameters(Char_t *line) {
  //Interpret a line for TPC params.  Form is ParamName:value.  Eg 
  //Eg fTwopar:.20 or fEff:  0.95
  Char_t ParamName[80];
  
  //Find first non-blank character in the line (in case user didn't start in column 1
  
  Int_t i;
  Int_t len = (Int_t)strlen(line);
  for(i=0; i < len; i++) {
    if(strncmp(&line[i]," ",1)) break;
  }
  //Copy that to ParamName
  strcpy(ParamName,&line[i]);
  
  Char_t *iloc = strchr(ParamName,':');
  Char_t *value_loc = iloc+1;
  if(iloc) {
    iloc[0] = 0;    //blank out the semicolon
    if(!strcasecmp(ParamName,"fTwoPar")) {
      sscanf(value_loc,"%f",&fTwoPar);
    }
    else if(!strcasecmp(ParamName,"fEff")) {
      sscanf(value_loc,"%f",&fEff);
    }
    else if(!strcasecmp(ParamName,"fDriftVelocity")) {
      sscanf(value_loc,"%f",&fDriftVelocity);
    }
    else if(!strcasecmp(ParamName,"fDLong")) {
      sscanf(value_loc,"%f",&fDlong);
    }
    else if(!strcasecmp(ParamName,"fDtrans")) {
      sscanf(value_loc,"%f",&fDtrans);
    }
    else if(!strcasecmp(ParamName,"fAnodeGap")) {
      sscanf(value_loc,"%f",&fAnodeGap);
    }
    else if(!strcasecmp(ParamName,"fTimeBucket")) {
      sscanf(value_loc,"%f",&fTimeBucket);
      }
    else if(!strcasecmp(ParamName,"fNoBuckets")) {
      sscanf(value_loc,"%d",&fNoBuckets);
    }
    else if(!strcasecmp(ParamName,"fTimingOffset")) {
      sscanf(value_loc,"%f",&fTimingOffset);
    }
    else if(!strcasecmp(ParamName,"fShapingTime")) {
      sscanf(value_loc,"%f",&fShapingTime);
    }
    else if(!strcasecmp(ParamName,"fADCGain")) {
      sscanf(value_loc,"%f",&fADCGain);
    }
    else if(!strcasecmp(ParamName,"fADCChannels")) {
      sscanf(value_loc,"%d",&fADCChannels);
    }
    else if(!strcasecmp(ParamName,"fRowDistance")) {
      sscanf(value_loc,"%f",&fRowDistance);
    }
    else if(!strcasecmp(ParamName,"fPadWidth")) {
      sscanf(value_loc,"%f",&fPadWidth);
    }
    else if(!strcasecmp(ParamName,"fPadBasePosition")) {
      sscanf(value_loc,"%f",&fPadBasePosition);
    }
    else if(!strcasecmp(ParamName,"fTimeBasePosition")) {
      sscanf(value_loc,"%f",&fTimeBasePosition);
    }  
    else if(!strcasecmp(ParamName,"fPadLength")) {
      sscanf(value_loc,"%f",&fPadLength);
    }
    else if(!strcasecmp(ParamName,"fRowPosition")) {
      Int_t irow;
      Float_t row_val;
      sscanf(value_loc,"%d %f",&irow,&row_val);
      SetRowPosition(irow,row_val);
    }
    else if(!strcasecmp(ParamName,"fTimeCorrection")) {
      Int_t irow;
      Float_t offset, slope;
      sscanf(value_loc,"%d %f %f",&irow,&offset,&slope);
      SetTimeCorrection(irow, offset, slope);
    }
    else if(!strcasecmp(ParamName,"fRowActive")) {
      Int_t irow;
      Char_t row_active[6];
      sscanf(value_loc,"%d %s",&irow,row_active);
      if(!strcasecmp(row_active,"kTRUE")) {
	SetRowActive(irow);
      }
      else {
	SetRowInActive(irow);
      }
      SetActiveParameters();       //Update the active parameters after adding one more
    }
    else if(!strcasecmp(ParamName,"fNumberOfActiveRows")) {
      sscanf(value_loc,"%d",&fNumberOfActiveRows);
    }
    else if(!strcasecmp(ParamName,"fNumberOfRows")) {
      sscanf(value_loc,"%d",&fNumberOfRows);
    }
    else if(!strcasecmp(ParamName,"fPadsprow")) {
      sscanf(value_loc,"%d",&fPadsPerRow);
    }
    else if(!strcasecmp(ParamName,"fPadDistance")) {
      sscanf(value_loc,"%f",&fPadDistance);
    }
    else {
      cout<<"Error: "<<ParamName<<" is not one of the parameters"<<endl;
      return;
    }
    return;      //this is a normal return
  }
  else {
    cout<<"Error, : missing to delineate name from value"<<endl;
    cout<<"The string is "<<line<<endl;
    cout<<"No value set!!!"<<endl;
    return;
  }
}

//__________________________________________________________________________
 void BrDetectorParamsTPC::SetDeadPad(Int_t row, Int_t pad){
  // Mark pads pad in row as dead
  //  removed from sequences
  fPadRowStatus[row-1][pad] = kPadDead;
}

//__________________________________________________________________________
 void BrDetectorParamsTPC::SetDeadPad(Int_t row, Int_t pad1, Int_t pad2){
  // Mark pads pad1 through pad2 in row as dead
  // i.e. will be aremoved from sequences
  for(int pad = pad1; pad <=pad2;pad++)
    fPadRowStatus[row-1][pad] = kPadDead;
}

//__________________________________________________________________________
 void BrDetectorParamsTPC::SetDummyPad(Int_t row, Int_t pad){
  fPadRowStatus[row-1][pad] = kPadNotInstrumented;
}

//__________________________________________________________________________
 void BrDetectorParamsTPC::SetDummyPad(Int_t row, Int_t pad1, Int_t pad2){
  // Mark pads pad1 through pad2 in row as Dummy or not instrumented
  // This can be used in acceptance, and will definitely be used
  // in geant digitization
  for(int pad = pad1; pad <=pad2;pad++)
    fPadRowStatus[row-1][pad] = kPadNotInstrumented;
}

//__________________________________________________________________________
 Float_t BrDetectorParamsTPC::DistanceToPad(Float_t pos){
//
// Convert distance from Padbase to a padnumber (expressed in floats
// relative to edge of pad.
//
	return (pos/fPadDistance) ;
}

//__________________________________________________________________________
 Float_t BrDetectorParamsTPC::DriftToIntrinsic(Float_t drift){
//
// Convert intrinsic ccordinates to a DriftLength (cm)
//
 	return (fTimeBasePosition-drift);
}


//__________________________________________________________________________
 Float_t BrDetectorParamsTPC::DistanceToIntrinsic(Float_t dist){
//
// Convert intrinsic ccordinates to a DriftLength (cm)
//
 	return (fPadBasePosition-dist);
}

//___________________________________________________________________________
 Float_t BrDetectorParamsTPC::DriftToTime(Float_t drift){
  //
  // Convert drift distances to Time bins
  //
  Float_t bin = (drift /fDriftVelocity-fTimingOffset)/fTimeBucket;
  bin = TimeToBin(bin);
  return bin;
}

//___________________________________________________________________________
 Float_t BrDetectorParamsTPC::DriftToTime(Int_t row, Float_t drift){
  //
  // Convert drift distances to Time bins
  // 
  Float_t bin = DriftToTime(drift);
  RemoveTimeCorrection(row, bin);

  if(bin > 0)
    return bin;
  else
    return 0;
}

//__________________________________________________________________________
 Float_t BrDetectorParamsTPC::IntrinsicToPad(Float_t pos){
//
// Convert intrinsic ccordinates to a padnumber (expressed in floats
// relative to center of pad.
// The first implementation. Future may depend on additional calibration
// parameters. The same comments apply to the other Intrinsic conversion
// functions.
//
	return ((fPadBasePosition-pos)/fPadDistance) ;
}

//__________________________________________________________________________
 Float_t BrDetectorParamsTPC::IntrinsicToTime(Float_t pos){
//
// Convert intrinsic coordinates to a timebin
//
  Float_t bin = (fTimeBasePosition-pos)/fDriftVelocity - fTimingOffset;
  bin = bin/fTimeBucket;
  bin = TimeToBin(bin);
  
  return bin;
}

//__________________________________________________________________________
 Float_t BrDetectorParamsTPC::IntrinsicToTime(Int_t row, Float_t pos){
//
// Convert intrinsic ccordinates to a timebin
//
  Float_t time = IntrinsicToTime(pos);
  RemoveTimeCorrection(row, time);

  return time;
}

//__________________________________________________________________________
 Float_t BrDetectorParamsTPC::IntrinsicToDrift(Float_t pos){
//
// Convert intrinsic ccordinates to a DriftLength (cm)
//
 	return (fTimeBasePosition-pos);
}

//__________________________________________________________________________
 Float_t BrDetectorParamsTPC::IntrinsicToDistance(Float_t pos){
//
// Convert intrinsic ccordinates to a Distance From Padedge (cm)
//
 	return (fPadBasePosition-pos);
}

//__________________________________________________________________________
 Float_t BrDetectorParamsTPC::PadToIntrinsic(Float_t pad){
//
// Convert Pad numbers (0...n) to intrinsic coordinates
//
  return ( -fPadDistance*(pad+0.5)+ fPadBasePosition );
}

//_________________________________________________________________________
Float_t 
 BrDetectorParamsTPC::RemoveTimeCorrection(Int_t row, Float_t &time)
  //
  // Remove the time correction when you go from some other coordinate
  // (position, drift) to time
  //
{
  if(fRowTimeCorrectionSlope[row-1] == 0)
    time = time + fRowTimeCorrection[row-1]/fTimeBucket;
  else
    time = (time + fRowTimeCorrection[row-1]/fTimeBucket)/
      (1 - fRowTimeCorrectionSlope[row-1]/fTimeBucket);

  return time;
}

  //__________________________________________________________________________
 Float_t BrDetectorParamsTPC::TimeToIntrinsic(Float_t time){
  //
  // Convert Time Bucket (0...n) to intrinsic coordinates.  
  //
  time = BinToTime(time);
  return ( -fDriftVelocity * (fTimeBucket * time + fTimingOffset)
	   + fTimeBasePosition );
}

//__________________________________________________________________________
 Float_t BrDetectorParamsTPC::TimeToIntrinsic(Int_t rownumber, Float_t time){
  //
  // Convert Time Bucket (0...n) to intrinsic coordinates.  
  //
  AddTimeCorrection(rownumber, time);
  return TimeToIntrinsic(time);
}

//___________________________________________________________________________
 Float_t BrDetectorParamsTPC::TimeToDrift(Float_t time){
//
// Convert Time value to a drift distance
//
  time = BinToTime(time);
  return (fDriftVelocity*(fTimeBucket*time + fTimingOffset));
}

//___________________________________________________________________________
 Float_t BrDetectorParamsTPC::TimeToDrift(Int_t rownumber, Float_t time){
//
// Convert Time value to a drift distance
//
  AddTimeCorrection(rownumber, time);
  return TimeToDrift(time);
}

//______________________________________________________________________
void 
 BrDetectorParamsTPC::SetTimeCorrection(Int_t row, Float_t offset,
				       Float_t slope = 0){
  //
  // Set the calibration parameters for the row time corrections
  // The correction is applied in 
  // AddTimeCorrection and RemoveTimeCorrection
  //
  if(0 < row && row < kMaxRows+1) {
    
    fRowTimeCorrection[row-1]      = offset;
    fRowTimeCorrectionSlope[row-1] = slope;
    
  }
  
}

////////////////////////////////////////////////////////////////////////////
//
//  $Log: BrDetectorParamsTPC.cxx,v $
//  Revision 1.7  2002/02/27 21:15:40  videbaek
//  Update default calculation of row position. It does not really matter since
//  it is always read in people analysis from the perameter file.
//
//  Revision 1.6  2002/02/22 20:05:13  videbaek
//  Change default parameters to correct values. This most likely has not caused any
//  problems since the paramaters in most analysis has been overwritten by the reading of
//  the detectorparams file.
//
//  Revision 1.5  2001/10/12 11:05:16  pchristi
//  Added new variables fHitWidthX and fHitWidthY and setters and getters
//  plus a new method ListPadStatus() for printing out the status of all
//  pads in tpc.  CVS:
//  ----------------------------------------------------------------------
//  BrDetectorParamsTPC.cxx BrDetectorParamsTPC.h CVS:
//  ----------------------------------------------------------------------
//
//  Revision 1.4  2001/09/10 18:16:13  videbaek
//  modified the TPM1 pitch to the measured .39 value
//
//  Revision 1.3  2001/07/29 08:55:12  nbi
//  Removed debug call to ListParameters that I had forgotten to remove.
//
//  Revision 1.2  2001/07/29 06:50:43  nbi
//  Found 2 bugs. Slope params were not initilised to 0 and when read from parameter
//  file only 2 instead of 3 numbers were read.
//  Set row 9 and 10 in TPM2 to kFALSE.
//
//  Revision 1.1.1.1  2001/06/21 14:55:00  hagel
//  Initial revision of brat2
//
//  Revision 1.44  2001/05/03 20:54:27  videbaek
//  Add fTimeCorrection as possible setup in ascii file. This is particular
//  useful to override the default fitted params when performing simulations.
//
//  Revision 1.43  2001/02/20 09:44:25  pchristi
//  Added new rowtimecorrections for T1 and T2.
//
//  Revision 1.42  2001/02/09 18:17:31  pchristi
//  Modified methods that have to do with transformations between time and
//  another coordinate. I introduced a new test TestBrDetectorParamsTPC that
//  test that the time transformations are consistent.
//  Removed a histogram that was also defined in BrTrackFinderBase
//  from BrTrackFollowFinder.
//
//  Revision 1.41  2001/01/30 10:36:04  pchristi
//  Fixed a memory leak in BrTPCClusterTable and added a new method GetRowNumber
//  to BrDetectorParamsTPC. I added some const pointers to the tracking classes to
//  reflect changes to const methods in BrDetectorHit and found a bug in
//  BrTrackFollowFinder that I myself had introduced.
//
//  Revision 1.40  2000/12/16 01:05:58  videbaek
//  The default time offsets had thye wrong sign. Change to be negative
//
//  Revision 1.39  2000/10/24 21:09:10  videbaek
//  Fixed an error that caused changes set by SetRowInactive(i) not to take effect.
//
//  Revision 1.38  2000/10/12 14:10:03  videbaek
//  Added some comments to method description.
//
//  Revision 1.37  2000/10/12 12:58:46  videbaek
//  Added a row,pad map to BrDetectorParameters. This padmap is meant to maintain
//  the status of each single pad i.e. instrumented, dead etc. So far the default is
//  to have all pads active. The BrTPCPreprocess module is also changed to check all
//  sequences for active, non-active pad status.
//
//  Revision 1.36  2000/10/02 17:07:53  pchristi
//  Cleaned up headers and source files in the tpc dir
//
//  Revision 1.35  2000/09/09 18:46:45  videbaek
//  Corrected error (similar to the one PC found recently) for row dependent
//  DriftToTime(row, time);
//
//  Revision 1.34  2000/09/07 21:15:15  videbaek
//  Last update (for now to ReadAscii) setting active rows.
//  The Trackreco (in fv_app/Macros/reco works as it should.
//
//  Revision 1.33  2000/09/07 20:46:35  videbaek
//  Fix merge problem. Remove code for unused variable.
//
//  Revision 1.32  2000/09/07 20:05:29  videbaek
//  Add methods for row setting, and Modified to proper row numbers 1,2...
//
//  Revision 1.31  2000/08/30 08:25:00  bjornhs
//  Removed small typo to make it compile
//
//  Revision 1.30  2000/08/30 04:25:50  videbaek
//  Corrected a few places where the conversion between Time and Intrinsic did not use the
//  rownumber as an argument.
//
//  Revision 1.29  2000/08/29 18:33:39  pchristi
//  Corrected errors in IntrinsicToPad and PadToIntrinsic.
//
//  Revision 1.28  2000/08/28 00:18:45  videbaek
//  Added calibration parameter to Detectorparams, to deal better with time-distance conversion
//  in TPCs. Added row dependent conversion too.
//
//
//  Revision 1.27  2000/07/25 18:00:45  ejkim
//  Put "for T2, default value fPadspRow=112"
//  Revision 1.26  2000/06/19 23:59:41  videbaek
//  Modified no times bins default to 157. Added fNoBuckets to reading
//  of parameters.
//
//  Revision 1.25  2000/04/28 21:22:13  videbaek
//  Add new classes for TPC. Many changes and not completely debugged.
//  Note that the old method BrTPCLocaltracking has been tested to work.
//
//  Revision 1.24  2000/04/06 20:27:13  cholm
//  Corrected some minor faults

//  Revision 1.23  2000/03/27 22:28:59  videbaek
//  The MTP2 fixes are now ok
//
//  Revision 1.22  2000/03/27 21:45:47  videbaek
//  Modified MTP2 to have proper 20 rows, as well as better defualt parameters.
//
//  Revision 1.20  2000/03/08 20:18:01  videbaek
//  Change clustering algorithms by adding a new method. BrTPCCluster is redefined.
//  Tracking reorganized with updates by Alv, Peter and Flemming
//
//  Revision 1.19  2000/01/18 18:39:53  videbaek
//  Moved covariance array from fit to calling parameter.
//  finalized and checkout of digitization, reconstruction code.
//  Added (possible noise ) to digitization. Changed default value of
//  dedxton0. Made it parameter in DetectorParamsTPC
//
//  Revision 1.18  1999/12/30 19:45:00  videbaek
//  Code changes to use the intrinsic cocrdinates consistently.
//
//  Revision 1.17  1999/12/18 21:37:40  videbaek
//  Obsolete for a long timeBrDigTTPC.cxx
//
//  Revision 1.15  1999/03/07 22:39:01  videbaek
//  Added TPCTrackingModule that uses DetectorHit for tracking.
//  It essentailly works.
//
//  Revision 1.14  1999/03/07 00:00:45  hagel
// 
//
//  Revision 1.13  1999/02/26 21:14:40  hagel
//  Minor changes to make compatible with BrFSTrackingModule
//
//  Revision 1.12  1999/02/25 14:53:14  videbaek
//  Inserted code for using BrTPCSequnece instead of BrDigTPC for both
//  TPC digitization and the TPC local track reconstruction.
//
//  Revision 1.11  1999/01/15 16:35:48  videbaek
//  Changes included using clonesarrays in digitizations.
//  Localtracking added cuts for type 4 clusters
//
//  Revision 1.10  1998/12/21 20:27:41  videbaek
//  Improved geometry for MTP1 and MTP2
//
//  Revision 1.9  1998/12/04 21:37:25  videbaek
//  Many changed to accomodate variable# of active rows in the TPC.
//  The present layout corresponds to the gbrahms setup as of November 98
//  being used for production.
//  Fix type SHLIB->$(SHLIB) .. in makefile
//
//  Revision 1.8  1998/09/24 23:31:09  hagel
//  Put in defaults for T2 if object created with name of T2
//
//  Revision 1.7  1998/09/18 20:37:39  videbaek
//  Move SetRowPosition from being inline


















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