#include "TFndFeeMap.h"
#include <iostream.h>
#include <stdlib.h>
ClassImp(TFndFeeMap);
TFndFeeMap::TFndFeeMap(){
cout << "Dummy Database Constructor: no link to mSQL" << endl;
isthere = 0;
}
TFndFeeMap::TFndFeeMap(char *host){
Int_t ierr = 0;
Int_t sd = -1;
isthere = 1;
//*********** Connect to mSQL */
sd = msqlConnect(host);
if(sd == -1) {
isthere = 0;
cout << ierr << "Exit: no connection to database (msqlConnect)" << endl;
exit(0);
}
else
cout << " Socket to msql opened with identifier " << sd << endl;
//******************************************************************/
/* inquire msql for tof */
//******************************************************************/
char *dbName;
char *query;
//*********** Select database within the available from mSQL */
dbName = "tofdb";
ierr = msqlSelectDB(sd,dbName);
if (ierr != 0) {
isthere = 0;
cout << ierr << "Exit: no database selection (msqlSelectDB)" << endl;
exit(0);
}
else
cout << " *** Database " << dbName << " selected " << endl;
//*********** Send a query to mSQL */
query = "SELECT slab,f_r,chadc,chtdc from fee";
ierr = msqlQuery(sd,query);
if (ierr < 0) {
cout << ierr << "Bad result from Tof query (msqlQuery)" << endl;
} else {
//*********** Store the result */
tof_res_ptr = msqlStoreResult();
tof_n_rows = msqlNumRows(tof_res_ptr);
tof_n_fields = msqlNumFields(tof_res_ptr);
cout << tof_n_rows << " rows and " << tof_n_fields << " fields in the TOF table " << endl;
}
//******************************************************************/
/* inquire msql for sil */
//******************************************************************/
//*********** Select database within the available from mSQL */
dbName = "sildb";
ierr = msqlSelectDB(sd,dbName);
if (ierr != 0) {
isthere = 0;
cout << ierr << "Exit: no database selection (msqlSelectDB)" << endl;
exit(0);
}
else
cout << " *** Database " << dbName << " selected " << endl;
//*********** Send a query to mSQL */
query = "SELECT hybrid,module,section from fee";
ierr = msqlQuery(sd,query);
if (ierr < 0) {
cout << ierr << "Bad result from Sil query (msqlQuery)" << endl;
} else {
//*********** Store the result */
sil_res_ptr = msqlStoreResult();
sil_n_rows = msqlNumRows(sil_res_ptr);
sil_n_fields = msqlNumFields(sil_res_ptr);
cout << sil_n_rows << " rows and " << sil_n_fields << " fields in the SIL table " << endl;
}
//*********** Send a query to mSQL */
query = "SELECT hybrid,strip,spy from stst";
ierr = msqlQuery(sd,query);
if (ierr < 0) {
cout << ierr << "Bad result from Sil Spy query (msqlQuery)" << endl;
} else {
//*********** Store the result */
sil_spy_ptr = msqlStoreResult();
sil_spy_n_rows = msqlNumRows(sil_spy_ptr);
sil_spy_n_fields = msqlNumFields(sil_spy_ptr);
cout << sil_spy_n_rows << " rows and " << sil_spy_n_fields << " fields in the SIL SPY table " << endl;
}
//******************************************************************/
/* inquire msql for lmd */
//******************************************************************/
//*********** Select database within the available from mSQL */
dbName = "lmddb";
ierr = msqlSelectDB(sd,dbName);
if (ierr != 0) {
isthere = 0;
cout << ierr << "Exit: no database selection (msqlSelectDB)" << endl;
exit(0);
}
else
cout << " *** Database " << dbName << " selected " << endl;
//*********** Send a query to mSQL */
query = "SELECT chamber,wire,f_r,chadc,chtdc from fee";
ierr = msqlQuery(sd,query);
if (ierr < 0) {
cout << ierr << " error from msqlQuery" << endl;
} else {
//*********** Store the result */
lmd_res_ptr = msqlStoreResult();
lmd_n_rows = msqlNumRows(lmd_res_ptr);
lmd_n_fields = msqlNumFields(lmd_res_ptr);
cout << lmd_n_rows << " rows and " << lmd_n_fields << " fields in the LMD table " << endl;
}
//******************************************************************/
//* inquire msql for stb */
//******************************************************************/
//*********** Select database within the available from mSQL */
dbName = "stbdb";
ierr = msqlSelectDB(sd,dbName);
if (ierr != 0) {
isthere = 0;
cout << ierr << "Exit: no database selection (msqlSelectDB)" << endl;
exit(0);
}
else
cout << " *** Database " << dbName << " selected" << endl;
//*********** Send a query to mSQL */
query = "SELECT straw,patchpanel,chtdc from fee";
ierr = msqlQuery(sd,query);
if (ierr < 0) {
cout << ierr << " error from msqlQuery" << endl;
} else {
//*********** Store the result */
stb_res_ptr = msqlStoreResult();
stb_n_rows = msqlNumRows(stb_res_ptr);
stb_n_fields = msqlNumFields(stb_res_ptr);
cout << stb_n_rows << " rows and " << stb_n_fields << " fields in the STB table " << endl;
}
//*********** Close the connection to mSQL */
msqlClose(sd);
//*********** Set the ADC and TDC mappers for TOF */
Int_t imodule = 0;
Int_t ichannel = 0;
for(Int_t ij=0;ij<tof_n_rows;ij++) {
msqlDataSeek(tof_res_ptr,ij);
tof_row = msqlFetchRow(tof_res_ptr);
Int_t itof_adc = ::atoi(*(tof_row+2));
imodule = itof_adc/100;
ichannel = (itof_adc-100*imodule);
for(Int_t k=0; k<2; k++)
tof_adc_tab[k][imodule][ichannel] = ::atoi(*(tof_row+k));
Int_t itof_tdc = ::atoi(*(tof_row+3));
imodule = (itof_tdc)/100;
ichannel = (itof_tdc-100*imodule);
for(Int_t ik=0; ik<2; ik++)
tof_tdc_tab[ik][imodule][ichannel] = ::atoi(*(tof_row+ik));
}
//*********** Set the Module and Section mappers for SIL */
for(Int_t jj=0;jj<sil_n_rows;jj++) {
msqlDataSeek(sil_res_ptr,jj);
sil_row = msqlFetchRow(sil_res_ptr);
Int_t hybrid_number = ::atoi(*(sil_row));
if(hybrid_number < 0 || hybrid_number >= SIL_NCRAMS) {
cout << "Wrong hybrid number: " << hybrid_number << endl;
hybrid_number = 1;
}
sil_mod_tab[hybrid_number] = ::atoi(*(sil_row+1));
sil_sec_tab[hybrid_number] = ::atoi(*(sil_row+2));
}
//*********** Set the Spy mappers for SIL */
for(Int_t jf=0;jf<sil_spy_n_rows;jf++) {
msqlDataSeek(sil_spy_ptr,jf);
sil_spy_row = msqlFetchRow(sil_spy_ptr);
Int_t hybrid_number = ::atoi(*(sil_spy_row));
if(hybrid_number < 0 || hybrid_number >= SIL_NCRAMS) {
cout << "Wrong hybrid number: " << hybrid_number << endl;
hybrid_number = 1;
}
Int_t strip = ::atoi(*(sil_spy_row+1));
sil_spy_tab[hybrid_number][strip-1] = ::atoi(*(sil_spy_row+2));
}
//*********** Set the ADC and TDC mappers for LMD */
for(Int_t j=0;j<lmd_n_rows;j++) {
msqlDataSeek(lmd_res_ptr,j);
lmd_row = msqlFetchRow(lmd_res_ptr);
Int_t ilmd_adc = ::atoi(*(lmd_row+3));
imodule = ilmd_adc/100;
ichannel = (ilmd_adc-100*imodule);
for(Int_t k=0; k<3; k++)
lmd_adc_tab[k][imodule-1][ichannel] = ::atoi(*(lmd_row+k));
Int_t ilmd_tdc = ::atoi(*(lmd_row+4));
imodule = (ilmd_tdc)/100;
ichannel = (ilmd_tdc-100*imodule);
for(Int_t jk=0; jk<3; jk++)
lmd_tdc_tab[jk][imodule-1][ichannel] = ::atoi(*(lmd_row+jk));
}
//*********** Set the TDC mapper for STB */
Int_t icrate = 0;
for(Int_t ja=0;ja<stb_n_rows;ja++) {
msqlDataSeek(stb_res_ptr,ja);
stb_row = msqlFetchRow(stb_res_ptr);
Int_t istb_tdc = ::atoi(*(stb_row+2));
icrate = istb_tdc/10000-10;
if(icrate < 0 || icrate >=STB_NCRATE) {
cout << "Warning: Stb crate number " << icrate << endl;
continue;
}
imodule = (istb_tdc-10000*(icrate+10))/100;
if(imodule<1 || imodule>STB_NMODULE) {
cout << "Warning: Stb module number " << imodule << endl;
continue;
}
ichannel = (istb_tdc-10000*(icrate+10)-100*imodule)-1;
if(ichannel<0 || ichannel >=STB_NCHANNEL) {
cout << "Warning: Stb channel number " << ichannel << endl;
continue;
}
stb_tdc_tab[0][icrate][imodule-1][ichannel] = ::atoi(*stb_row);
stb_tdc_tab[1][icrate][imodule-1][ichannel] = ::atoi(*(stb_row+1));
}
}
TFndFeeMap::~TFndFeeMap() { }
Int_t TFndFeeMap::GetTofAdcSlb(Int_t chan) {
Int_t islb = -1;
Int_t imodule = chan/100;
Int_t ichannel = chan-100*imodule;
islb = tof_adc_tab[0][imodule][ichannel];
return islb;
}
Int_t TFndFeeMap::GetTofAdcSide(Int_t chan) {
Int_t rflag = -1;
Int_t imodule = chan/100;
Int_t ichannel = chan-100*imodule;
rflag = tof_adc_tab[1][imodule][ichannel];
return rflag;
}
Int_t TFndFeeMap::GetTofTdcSlb(Int_t chan) {
Int_t islb = -1;
Int_t imodule = chan/100;
Int_t ichannel = chan-100*imodule;
islb = tof_tdc_tab[0][imodule][ichannel];
return islb;
}
Int_t TFndFeeMap::GetTofTdcSide(Int_t chan) {
Int_t rflag = -1;
Int_t imodule = chan/100;
Int_t ichannel = chan-100*imodule;
rflag = tof_tdc_tab[1][imodule][ichannel];
return rflag;
}
Int_t TFndFeeMap::GetSilModule(Int_t chan) {
return sil_mod_tab[chan];
}
Int_t TFndFeeMap::GetSilSection(Int_t chan) {
return sil_sec_tab[chan];
}
Int_t TFndFeeMap::GetLmdAdcDch(Int_t imodule, Int_t ichannel) {
Int_t idch = -1;
idch = lmd_adc_tab[0][imodule-1][ichannel];
return idch;
}
Int_t TFndFeeMap::GetLmdAdcWire(Int_t imodule, Int_t ichannel) {
Int_t wire=-1;
wire = lmd_adc_tab[1][imodule-1][ichannel];
return wire;
}
Int_t TFndFeeMap::GetLmdTdcDch(Int_t imodule, Int_t ichannel) {
Int_t idch=-1;
idch = lmd_tdc_tab[0][imodule-1][ichannel];
return idch;
}
Int_t TFndFeeMap::GetLmdTdcWire(Int_t imodule, Int_t ichannel) {
Int_t wire=-1;
wire = lmd_tdc_tab[1][imodule-1][ichannel];
return wire;
}
Int_t TFndFeeMap::GetLmdAdcSide(Int_t imodule, Int_t ichannel) {
Int_t rflag=-1;
rflag = lmd_adc_tab[2][imodule-1][ichannel];
return rflag;
}
Int_t TFndFeeMap::GetLmdTdcSide(Int_t imodule, Int_t ichannel) {
Int_t rflag=-1;
rflag = lmd_tdc_tab[2][imodule-1][ichannel];
return rflag;
}
Int_t TFndFeeMap::GetStbWire(Int_t icrate, Int_t imodule, Int_t ichannel) {
Int_t stbwir=0;
stbwir = stb_tdc_tab[0][icrate-10][imodule-1][ichannel];
return stbwir;
}
Int_t TFndFeeMap::GetStbPatchPanel(Int_t icrate, Int_t imodule, Int_t ichannel) {
Int_t stbpat=0;
stbpat = stb_tdc_tab[1][icrate-10][imodule-1][ichannel];
return stbpat;
}
void TFndFeeMap::Print() {
cout << "*********************************" << endl;
cout << "TOF database: ";
cout << tof_n_rows << " rows, " << tof_n_fields << " fields" << endl;
cout << "*********************************" << endl;
for(Int_t j=0;j<tof_n_rows;j++) {
msqlDataSeek(tof_res_ptr,j);
tof_row = msqlFetchRow(tof_res_ptr);
for(Int_t i=0;i<tof_n_fields;i++) cout << "tof_row[" << j << "," << i << "] = " << ::atoi(*tof_row++) << endl;
}
cout << "*********************************" << endl;
cout << "SIL database: ";
cout << sil_n_rows << " rows, " << sil_n_fields << " fields" << endl;
cout << "*********************************" << endl;
for(Int_t ij=0;ij<sil_n_rows;ij++) {
msqlDataSeek(sil_res_ptr,ij);
sil_row = msqlFetchRow(sil_res_ptr);
for(Int_t ii=0;ii<sil_n_fields;ii++) cout << "sil_row[" << ij << "," << ii << "] = " << ::atoi(*sil_row++) << endl;
}
cout << "*********************************" << endl;
cout << "LMD database: ";
cout << lmd_n_rows << " rows, " << lmd_n_fields << " fields" << endl;
cout << "*********************************" << endl;
for(Int_t jj=0;jj<lmd_n_rows;jj++) {
msqlDataSeek(lmd_res_ptr,jj);
lmd_row = msqlFetchRow(lmd_res_ptr);
for(Int_t i=0;i<lmd_n_fields;i++) cout << "lmd_row[" << jj << "," << i << "] = " << ::atoi(*lmd_row++) << endl;
}
cout << "*********************************" << endl;
cout << "STB database: ";
cout << stb_n_rows << " rows, " << stb_n_fields << " fields" << endl;
cout << "*********************************" << endl;
for(Int_t jb=0;jb<stb_n_rows;jb++) {
msqlDataSeek(stb_res_ptr,jb);
stb_row = msqlFetchRow(stb_res_ptr);
for(Int_t i=0;i<stb_n_fields;i++) cout << "stb_row[" << jb << "," << i << "] = " << ::atoi(*stb_row++) << endl;
}
cout << "*********************************" << endl;
}
Int_t TFndFeeMap::IsSilSpy(Int_t hybrid, Int_t strip) {
if(hybrid < 0 || hybrid >= SIL_NCRAMS) {
cout << "Wrong Hybrid Number: " << hybrid << endl;
return -1;
}
if(strip <= 0 || hybrid > SIL_NSTRPS) {
cout << "Wrong Strip Number: " << strip << endl;
return -1;
}
return sil_spy_tab[hybrid][strip-1];
}
void TFndFeeMap::Streamer(TBuffer &R__b) {
// Stream an object of class TFndFeeMap.
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(); if (R__v) { }
TObject::Streamer(R__b);
R__b >> isthere;
R__b >> tof_n_rows;
R__b >> tof_n_fields;
R__b.ReadStaticArray((int*)tof_adc_tab);
R__b.ReadStaticArray((int*)tof_tdc_tab);
if(R__v > 1) {
R__b >> sil_n_rows;
R__b >> sil_n_fields;
R__b.ReadStaticArray((int*)sil_mod_tab);
R__b.ReadStaticArray((int*)sil_sec_tab);
}
R__b >> lmd_n_rows;
R__b >> lmd_n_fields;
R__b.ReadStaticArray((int*)lmd_adc_tab);
R__b.ReadStaticArray((int*)lmd_tdc_tab);
R__b >> stb_n_rows;
R__b >> stb_n_fields;
R__b.ReadStaticArray((int*)stb_tdc_tab);
} else {
R__b.WriteVersion(TFndFeeMap::IsA());
TObject::Streamer(R__b);
R__b << isthere;
R__b << tof_n_rows;
R__b << tof_n_fields;
R__b.WriteArray((int*)tof_adc_tab, 1152);
R__b.WriteArray((int*)tof_tdc_tab, 1152);
R__b << sil_n_rows;
R__b << sil_n_fields;
R__b.WriteArray((int*)sil_mod_tab, SIL_NCRAMS);
R__b.WriteArray((int*)sil_sec_tab, SIL_NCRAMS);
R__b << lmd_n_rows;
R__b << lmd_n_fields;
R__b.WriteArray((int*)lmd_adc_tab, 1728);
R__b.WriteArray((int*)lmd_tdc_tab, 1728);
R__b << stb_n_rows;
R__b << stb_n_fields;
R__b.WriteArray((int*)stb_tdc_tab, 6912);
}
}
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.