// ----------------------------------------------------------------------------
// $Id: LCDGetTrackLookups.cxx,v 1.1 2001/05/10 17:55:58 toshi Exp $
// ----------------------------------------------------------------------------
//
// $Log: LCDGetTrackLookups.cxx,v $
// Revision 1.1  2001/05/10 17:55:58  toshi
// Changes C++ name convention from *.C to *.cxx to allow Windows usage.
//
//
// extract lookup table for track parameter smear
// Version 1.0 7-Jan-1999 Richard creation


#include "LCDGetTrackLookups.h"

#include <assert.h>

//______________________________________________________________________
//
// GetTrackLookups
//
// Extracts lookup tables for track parameter smear  

ClassImp(LCDGetTrackLookups)
 LCDGetTrackLookups::LCDGetTrackLookups(FILE* parFile) {
  // parses parameter file to get track block and then create the 
  // requested lookup tables

  TString input_line, input_string;

  char temp[100]; 

  Int_t pos;
  
  // rewind the file
  
  fseek(parFile, 0L, 0);
  
  while( (pos = fscanf(parFile,"%s",&temp[0])) > 0 ) {
    
    input_line = temp;

    if(input_line.Contains(":")) {

      Ssiz_t patLen=1, colonPos=0;
      Ssiz_t colonLen = input_line.Index(":",patLen,colonPos,TString::kExact);
      TString parName = TString(temp,colonLen);

      Int_t inpos;

      Int_t numTables, numPbins;
      inpos = fscanf(parFile,"%i %i",&numTables,&numPbins);
      
      Double_t* par    = new Double_t[numTables*numPbins];
      Double_t* cArray = new Double_t[numTables];
      Double_t* pArray = new Double_t[numPbins];
      
      for (Int_t itable=0; itable < numTables; itable++) {
	
	Double_t costh;
	inpos = fscanf(parFile,"%lf",&costh);
	cArray[itable] = costh;	    
	
	for (Int_t pBin=0; pBin < numPbins; pBin++) {
	  
	  Double_t p, res;
	  inpos = fscanf(parFile,"%lf %lf",&p, &res);
	  
	  pArray[pBin] = p;
	  par[itable*numPbins+pBin] = res;
	  
	};
	
      };
      
      LCDLookUp2d* Cvs = new LCDLookUp2d(parName,cArray,pArray,par,
				   numTables,numPbins);
      m_lookupsArray.Add(Cvs);
      
      
      char endChar[100];
      inpos = fscanf(parFile,"%s",&endChar[0]);
      TString endString = endChar;
      assert ( endString.Contains("end"));
      
      
    };  // close parameter read section

  }; // close file read


}; // close GetTrackLookups()

 LCDGetTrackLookups::~LCDGetTrackLookups() {
  Int_t numPar = m_lookupsArray.GetEntries();
  LCDLookUp2d* a;
  for (Int_t i=0 ; i < numPar ; i++) {
    a=(LCDLookUp2d*)m_lookupsArray[i];
    delete a->GetKey1();
    delete a->GetKey2();
    delete a->GetMatrix();
  }
  m_lookupsArray.Delete();
};

 LCDLookUp2d* LCDGetTrackLookups::GetParamLookup(char* name) {
  // Gets pointer to appropriate lookup table given the name

    TString tname = name;

    Int_t numPar = m_lookupsArray.GetEntries();

    for (Int_t i=0; i<numPar; i++) {
      if ( ((LCDLookUp2d*)
	    m_lookupsArray[i])->GetTableName()->CompareTo(tname, TString::kExact) ){
	return (LCDLookUp2d*)(m_lookupsArray[i]);
      };		
    };
    return 0;  // name not found!
};

 LCDLookUp2d* LCDGetTrackLookups::GetParamLookup(Int_t number) {
  // Gets pointer to appropriate lookup table given the number

  return (LCDLookUp2d*)m_lookupsArray[number];
};



ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.