|
// // $Id: BrDbPlatformPosition.cxx,v 1.1.1.1 2001/06/21 14:55:18 hagel Exp $ // $Author: hagel $ // $Date: 2001/06/21 14:55:18 $ // $Copyright: 2001 Brahms Collaboration // /////////////////////////////////////////////////////////////////////// // // BrDbPlatformPosition is a class that maps onto the BRAHMS DB // platform Position tables. This table is expected to be change // from run to run and will keep track of the angle of the various // platforms (ie FFS, BFS, MRS). The absolute positions of the // various detectors will be calculated by using the detector tables // (BrDbDetectorVolume, BrDbMagnetVolume) which store positions and angles // relative to the platform and transforming to the absolute system using // the information in these tables. // /////////////////////////////////////////////////////////////////////// #include <BrDbPlatformPosition.h> #ifndef BRAT_BrException #include "BrException.h" #endif #ifndef WIN32 #include <cstdlib> #include <iostream> #else #include <cstdlib> #include <iostream.h> #endif ClassImp(BrDbPlatformPosition); //____________________________________________________________________ const Char_t* BrDbPlatformPosition::kTableName = "PlatformPositions"; //____________________________________________________________________ BrDbPlatformPosition::BrDbPlatformPosition(void) { // Empty default constructor. } //____________________________________________________________________ BrDbPlatformPosition::BrDbPlatformPosition(const Char_t *name, Int_t run, Float_t angle) { // Constructor assuming position is at nominal vertex. SetName(name); fRunNo = run; fAngle = angle; fPosX = 0; fPosY = 0; fPosZ = 0; fRevisionId = 0; } //____________________________________________________________________ BrDbPlatformPosition::BrDbPlatformPosition(const Char_t *name, Int_t run, Float_t angle, Float_t posX, Float_t posY, Float_t posZ) { // Constructor to set everything. SetName(name); fRunNo = run; fAngle = angle; fPosX = posX; fPosY = posY; fPosZ = posZ; fRevisionId = 0; } //____________________________________________________________________ BrDbQuery* BrDbPlatformPosition::Create(void) { // Returns a SQL query string suitable for creation of this table in // a database. return BrDbQuery::Create(BrDbPlatformPosition::kTableName, "PlatformName VARCHAR(64) NOT NULL, RunNo INT NOT NULL, Angle FLOAT(12,4) NOT NULL, posX FLOAT(12,4) NOT NULL, posY FLOAT(12,4) NOT NULL, posZ FLOAT(12,4) NOT NULL, RevisionId INT NOT NULL"); } //____________________________________________________________________ BrDbPlatformPosition*BrDbPlatformPosition::SingleInstance(TSQLRow* row) { // Returns an instance of a BrDbPlatformPosition. User needs to store this // object immediately. if (!row) return 0; Float_t angle,posX,posY,posZ; sscanf(row->GetField(3),"%f",&angle); sscanf(row->GetField(4),"%f",&posX); sscanf(row->GetField(5),"%f",&posY); sscanf(row->GetField(6),"%f",&posZ); BrDbPlatformPosition* pos = new BrDbPlatformPosition(row->GetField(1), //name strtol(row->GetField(2),NULL,0), //runNo angle,posX,posY,posZ); pos->SetRevisionId(strtol(row->GetField(7),NULL,0)); return pos; } //____________________________________________________________________ TObjArray* BrDbPlatformPosition::MultipleInstance(TSQLResult* res) { // Returns an (1D) array of BrDbPlatformPosition's matching Query // that made the TSQLResult. User need to store this immediately. Int_t count = (res) ? res->GetRowCount() : 0; TObjArray* table = new TObjArray(count); for (Int_t i = 0; i < count; i++) table->Add(BrDbPlatformPosition::SingleInstance(res->Next())); return table; } //____________________________________________________________________ BrDbQuery* BrDbPlatformPosition::Insert(void) { return BrDbQuery::Insert(BrDbPlatformPosition::kTableName, Form("%d, '%s', %d, %f, %f, %f, %f, %d", GetDBID(),fName,fRunNo,fAngle,fPosX,fPosY,fPosZ,fRevisionId)); } //____________________________________________________________________ void BrDbPlatformPosition::SetName(const Char_t *name) { //Set the detector name Int_t len = strlen(name); if(len > 64) len = 64; strncpy(fName,name,len); } //____________________________________________________________________ void BrDbPlatformPosition::SetPosition(Float_t x, Float_t y, Float_t z) { //Set the position parameters (relative to platform it is on) fPosX = x; fPosY = y; fPosZ = z; } // // $Log: BrDbPlatformPosition.cxx,v $ // Revision 1.1.1.1 2001/06/21 14:55:18 hagel // Initial revision of brat2 // // Revision 1.3 2001/06/05 18:40:59 cholm // Removed BrDbInc.h an all references to it // // Revision 1.2 2001/03/22 20:44:57 cholm // Added protection for NULL TSqlRow in SingleInstance methods, and cleaned // up a bit of the stuff. // // Revision 1.1 2001/03/07 16:54:04 hagel // Initial revision, probably needs more iterations // // |
||||||
This page automatically generated by script docBrat by Christian Holm |
Copyright ; 2002 BRAHMS Collaboration
<brahmlib@rcf.rhic.bnl.gov>
|