# Write Gains To ASCII for Daq

```/////////////////////////////////////////////////////////////////////////
//                                                                     //
//  Module:  TpcGains.C						       //
//  Author:  Jim Thomas						       //
//  Date:    11/17/99						       //
// 								       //
//  Purpose: 							       //
//           Simple main routine to read the tpc pad gain factors      //
//  from the database and send them to stdout with the sector IDs,     //
//  								       //
//  Output:  							       //
//								       //
//  Input:							       //
//           ValidDate   VersionName-(optional)			       //
//								       //
//  Discussion: 						       //
// 								       //
//           The TPC geometry is defined in STAR Note 229.  All	       //
//  reference to the TPC sectors and pads is made from the outside     //
//  looking in.  Looking at the west end (PHENIX end) from the         //
//  outside, the sectors are numbered 1-12 like a clock.  The East     //
//  end is numbered 13-24 with 24 at the top; but viewed from the      //
//  outside, standing at the East end, looking in to the  vertex.      //
//  The  padrows in each sector are numbered from the smallest radius  //
//  to the largest.  So the inner sectors rows are 1-13 with row 1     //
//  closest to the inner field cage.  The outer sector rows are	       //
//  14-45 with row 45 at the outermost radius near the outer field     //
//  cage.  The individual pads within a row are numbered with          //
//  increasing number in the clockwise direction.  This means left     //
//  to right on sector 12 - looking from the outside of the TPC.       //
//  There are 1750 pads in each innersector and 3942 pads in each      //
//  outersector.	                                               //
// 								       //
//  Example:							       //
//           TpcGains 11-09-99 00:01:00 myVersion		       //
//								       //
//  Changes:							       //
//								       //
/////////////////////////////////////////////////////////////////////////

#include <stdio.h>
#include <iostream.h>
#include <string.h>

#include "StDbManager.hh"
#include "StDbConfigNode.hh"
#include "StDbTable.h"
#include "StDbDefs.hh"
#include "Calibrations/tpcISGains.h"
#include "Calibrations/tpcOSGains.h"

int main(int argc, char* argv[])

{

int   index, i, j, k ;
char  DateTime[30], Version[30] ;
const int Sectors = 24 ;
const int ISRows  = 13 ;
const int OSRows  = 32 ;

int ISPadsPerRow[ISRows] = {  88,  96, 104, 112, 118, 126, 134, 142,
150, 158, 166, 174, 182  } ;
int OSPadsPerRow[OSRows] = {  98, 100, 102, 104, 106, 106, 108, 110,
112, 112, 114, 116, 118, 120, 122, 122,
124, 126, 128, 128, 130, 132, 134, 136,
138, 138, 140, 142, 144, 144, 144, 144  } ;
if ( argc < 3 )
{
cout << endl ;
cout << " Usage: " << endl << endl ;
cout << "        TpcGains  Date        Time      Version(optional) " << endl ;
cout << endl ;
cout << "        TpcGains  1999-10-21  13:10:00  default " << endl ;
cout << endl;
return(0) ;
}

strcpy( DateTime, argv[1] ) ;
strcat( DateTime, " " ) ;
strcat( DateTime, argv[2] ) ;

if ( argc > 3 ) strcpy( Version, argv[3] ) ;
else strcpy( Version, "default" ) ;

StDbManager*  mgr = StDbManager::Instance() ;
mgr -> setRequestTime(DateTime) ;
StDbType     type = Calibrations ;
StDbDomain domain = Star ;
StDbConfigNode* configNode = mgr -> initConfig(type,domain) ;

cerr << endl ;

StDbTable* IStable  =   configNode -> addDbTable("tpcISGains",Version) ;
cerr << " TableName = " << IStable -> getTableName() << endl ;
cerr << " BeginTime = " << IStable -> getBeginDateTime() << endl ;
cerr << " EndTime   = " << IStable -> getEndDateTime() << endl ;
cerr << " Requested = " <<     mgr -> getDateCheckTime() << endl ;
cerr << " Version   = " << IStable -> getVersion() << endl;
cerr << " DB Type   = " <<     mgr -> getDbTypeName( IStable->getDbType() ) << endl ;
cerr << " DB Domain = " <<     mgr -> getDbDomainName( IStable->getDbDomain() ) ;

cerr << endl << endl ;

StDbTable* OStable  =   configNode -> addDbTable("tpcOSGains",Version) ;
cerr << " TableName = " << OStable -> getTableName() << endl ;
cerr << " BeginTime = " << OStable -> getBeginDateTime() << endl ;
cerr << " EndTime   = " << OStable -> getEndDateTime() << endl ;
cerr << " Requested = " <<     mgr -> getDateCheckTime() << endl ;
cerr << " Version   = " << OStable -> getVersion() << endl;
cerr << " DB Type   = " <<     mgr -> getDbTypeName( OStable->getDbType() ) << endl ;
cerr << " DB Domain = " <<     mgr -> getDbDomainName( OStable->getDbDomain() ) ;

cerr << endl << endl ;

// We need some sort of success or failure flag ** here **

tpcISGains* ISgains ;
tpcOSGains* OSgains ;

mgr -> fetchDbTable(IStable) ;
mgr -> fetchDbTable(OStable) ;
ISgains = (tpcISGains*)IStable -> GetTable() ;
OSgains = (tpcOSGains*)OStable -> GetTable() ;

for ( i = 0 ; i < Sectors ; i++ )
{
index = 0 ;
for ( j = 0 ; j < ISRows ; j++ )
{
for ( k = 0 ; k < ISPadsPerRow[j] ; k++ )
{
printf( " %2d %2d %3d %7.4f n",
i+1, j+1, k+1, ISgains[i].gain[index] ) ;
index++;
}
}

index = 0 ;
for ( j = 0 ; j < OSRows ; j++ )
{
for ( k = 0 ; k < OSPadsPerRow[j] ; k++ )
{
printf( " %2d %2d %3d %7.4f n",
i+1, j+ISRows+1, k+1, OSgains[i].gain[index] ) ;
index++;
}
}
}
}

```

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.