STEER/TFndFeeMap.cxx

00001 // @(#)fROOT/STEER:$Name:  $:$Id: TFndFeeMap.cxx,v 1.34 2007/09/24 07:32:41 Diego_Faso Exp $
00002 // Revision Author: Diego Faso <mailto:faso@to.infn.it>, 2005/06/24
00003 // Original Author: P. Cerello <mailto:cerello@to.infn.it>, 2000
00004 
00006 //                                                                         //
00007 //                                  TFndFeeMap                             //
00008 //                                                                         //
00009 // The FINUDA Database mapper: this class describes all the                //
00010 // tables contained in the mSQL database useful for the Front              //
00011 // End Electronics mapping in order to define the real detector channel    //
00012 // associated to a given electronic channel                                //
00013 //                                                                         //
00015 
00016 #include "TFndFeeMap.h"
00017 #include "TFndRun.h"
00018 #include "TDatime.h"
00019 #include "TString.h"
00020 #include "TThread.h"
00021 #include <stdlib.h>
00022 #include <stdio.h>
00023 #include <string.h>
00024 
00025 //#include "TFndRunConfiguration.h"
00026 #include "msql.h"
00027 
00028 ClassImp(TFndFeeMap)
00029 
00030 //_______________________________________
00031 TFndFeeMap::TFndFeeMap():
00032   fRunTime(),fTofNRows(),fTofNFields(),fTofAdcSlab(),fTofAdcSide(),fTofTdcSlab(),fTofTdcSide(),fTofMtSlab(),
00033   fLmdNRows(),fLmdNFields(),fLmdAdcDCH(),fLmdAdcWire(),fLmdAdcSide(),fLmdTdcDCH(),fLmdTdcWire(),fLmdTdcSide(),
00034   fStbNRows(),fStbNFields(),fStbTdcCrown(),fStbTdcWire(),fStbTdcPPan()
00035 {
00036   fMsqSock = -1;
00037   fIsThere = kFALSE;
00038   if(fndrun) fDebug = fndrun->GetDebug();
00039   else{
00040     Warning("TFndFeeMap","fndrun not available: Setting debug to \"0\"");
00041     fDebug = 0;
00042   }
00043 
00044   Reset();
00045 }
00046 
00047 //_______________________________________
00048 int TFndFeeMap::extract(char *r, int c) {
00049   int x;
00050   char z[5];
00051   z[4]='\0';
00052   memcpy(z ,r+c*4 ,4);
00053   sscanf(z,"%d",&x);
00054   return x;
00055 }
00056 
00057 //_______________________________________
00058 Int_t TFndFeeMap::ConnectToHost(const TString &host,TString user,TString passwd){
00059 
00060   cout << "TFndFeeMap::TFndFeeMap Info:host= " << ExpandPathName(host.Data()).Data() << endl; 
00061   fMsqSock = -1;
00062   fIsThere = kFALSE;
00063 
00064   fMsqSock = msqlConnect((Char_t*)(ExpandPathName(host.Data()).Data()));  
00065   if(fMsqSock != -1) fIsThere = kTRUE; 
00066   else cout << "TFndFeeMap::TFndFeeMap connection ID: " << fMsqSock << endl; 
00067   return fMsqSock;
00068 }
00069 
00070 //_______________________________________
00071 void TFndFeeMap::DisconnectFromHost(){
00072 
00073   if(fMsqSock == -1){
00074     Warning("DisConnectFromHost()","Not connected");
00075     return;
00076   }
00077   msqlClose(fMsqSock);
00078   fMsqSock = -1; // used to return the connection status (must be resetted here)  
00079   //   Printf(" ---> TFndFeeMap::DisconnectFromHost ---> Printing database content");
00080   //   Print();
00081   //   Printf(" ---> TFndFeeMap::DisconnectFromHost ---> Database content printed");
00082   return;
00083 }
00084 
00085 //_______________________________________
00086 void TFndFeeMap::Reset(){
00087 
00088   if(fDebug) Info("Reset","entering method");
00089   fTofNRows = 0;
00090   fTofNFields = 0;
00091   
00092   bzero(fTofAdcSlab,sizeof(fTofAdcSlab));
00093   bzero(fTofAdcSide,sizeof(fTofAdcSide));
00094   bzero(fTofTdcSlab,sizeof(fTofTdcSlab));
00095   bzero(fTofTdcSide,sizeof(fTofTdcSide));
00096   
00097   fLmdNRows = 0;
00098   fLmdNFields = 0;
00099   bzero(fLmdAdcDCH,sizeof(fLmdAdcDCH));
00100   bzero(fLmdAdcWire,sizeof(fLmdAdcWire));
00101   bzero(fLmdAdcSide,sizeof(fLmdAdcSide));  
00102   bzero(fLmdTdcDCH,sizeof(fLmdTdcDCH));
00103   bzero(fLmdTdcWire,sizeof(fLmdTdcWire));
00104   bzero(fLmdTdcSide,sizeof(fLmdTdcSide));
00105   
00106   fStbNRows = 0;
00107   fStbNFields = 0;
00108   bzero(fStbTdcCrown,sizeof(fStbTdcCrown));
00109   bzero(fStbTdcWire,sizeof(fStbTdcWire));
00110   bzero(fStbTdcPPan,sizeof(fStbTdcPPan));
00111   for(Int_t i=0;i<K_N_STB_CROWNS ; i++) for(Int_t j=0;j<K_N_STB_TUBES ; j++) fStbStatus[i][j];
00112   
00113   bzero(IsiDbAdc,sizeof(IsiDbAdc));
00114   bzero(OsiDbAdc,sizeof(OsiDbAdc));
00115   
00116   if(fDebug) Info("Reset","completed");
00117 }
00118 
00119 //_______________________________________
00120 Int_t TFndFeeMap::FetchRunInfo(const Bool_t &verbose,UInt_t run_time,Bool_t also_calib){
00121   // A selection of needed information
00122   // according to the run-time is performed
00123   //
00124   // return value:
00125   //              as msqlSelectDB() [-1 in case of error]
00126 
00127 
00128   if(! IsConnected() ){
00129     Error("FetchRunInfo","not connected to DB: can not fetch information");
00130     gApplication->Terminate();
00131   }
00132 
00133   Reset();
00134 
00135   // update local reference to the time of the run (or to the given one)
00136   if(run_time != 0) fRunTime = run_time;
00137   else{
00138     if(fndrun) fRunTime = fndrun->GetRunTime(); 
00139     else{
00140       Error("FetchRunInfo","fndrun not defined: run-time not available: can not fetch run-info!");
00141       return -1;
00142     }
00143   }
00144 
00145   Int_t ierr = 0;
00146 
00147   ierr += FetchTofInfo(verbose);
00148   ierr += FetchLmdInfo(verbose);
00149   ierr += FetchSilInfo(verbose);
00150   ierr += FetchStbInfo(verbose);
00151 
00152   if(also_calib){
00153     // calib. info
00154     ierr += FetchTofCalibInfo(verbose);
00155     ierr += FetchLmdCalibInfo(verbose);
00156     ierr += FetchStbCalibInfo(verbose);
00157   }
00158   
00159   return ierr;
00160 }
00161 
00162 //_______________________________________
00163 Int_t TFndFeeMap::FetchTofInfo(const Bool_t &verbose){
00164 
00165   if(! IsConnected() ){
00166     Error("FetchTofInfo","not connected to DB: can not fetch information");
00167     gApplication->Terminate();
00168   }
00169 
00170   Int_t ierr = 0;
00171   TString dbName = "TofDB";
00172   if(fRunTime > FROOT::DTak_2006_SftwStartTime) dbName = "TofDB2";
00173   Info("FetchTofInfo","Selected TOF database: \"%s\" (RunTime = %d)",dbName.Data(),fRunTime);
00174   ierr = msqlSelectDB(fMsqSock,(Char_t *)dbName.Data());
00175   
00176   if (ierr != 0) {
00177     fIsThere = kFALSE; 
00178     cout << ierr << "Exit: no database selection (msqlSelectDB)" << endl;
00179     Warning("FetchTofInfo","Exit: TOF database not available (msqlSelectDB)");
00180     TerminateFroot();
00181   }
00182   else if(verbose) cout << " *** Database " << dbName.Data() << " selected " << endl;
00183   
00184   //*********** Send a query to mSQL */
00185   TString TofQuery = TString("SELECT w, ae, ap, te, tp, tm FROM fee ");
00186   TofQuery+=" WHERE A<";
00187   TofQuery+=fRunTime;
00188   TofQuery+=" AND Z > ";
00189   TofQuery+=fRunTime;
00190   TofQuery+=" ORDER by w";
00191   ierr = msqlQuery(fMsqSock,(char *) TofQuery.Data());
00192   if(fDebug) cout << TofQuery.Data() << endl;
00193   
00194   m_result *tof_res_ptr = NULL;
00195   if (ierr < 0) {
00196     cout << ierr << "Bad result from Tof query (msqlQuery)" << endl;
00197   }
00198   else { // Store the result
00199     tof_res_ptr  = msqlStoreResult();
00200     fTofNRows   = msqlNumRows(tof_res_ptr);
00201     fTofNFields = msqlNumFields(tof_res_ptr);
00202   }
00203   
00204   // Set the ADC and TDC mappers for TOF
00205   Int_t imodule_adc = 0;
00206   Int_t ichannel_adc = 0;
00207   Int_t imodule_tdc = 0;
00208   Int_t ichannel_tdc = 0;
00209   Int_t imodule_mt = 0;
00210   Int_t ichannel_mt = 0;
00211   
00212   for(Int_t ij=0;ij<fTofNRows;ij++) {
00213     msqlDataSeek(tof_res_ptr,ij);
00214     m_row tof_row = msqlFetchRow(tof_res_ptr);
00215 
00216     for(Int_t k=0; k<2; k++) { // k: side [0,1] = [E,P]
00217       Int_t islab = ::atoi(*(tof_row));
00218       Int_t itof_adc = ::atoi(*(tof_row+1+k));
00219       imodule_adc = itof_adc/100;
00220       ichannel_adc = (itof_adc%100);
00221       Int_t itof_tdc = ::atoi(*(tof_row+3+k));
00222       imodule_tdc = (itof_tdc)/100;
00223       ichannel_tdc = (itof_tdc%100);
00224       if(!fTofAdcSlab[imodule_adc][ichannel_adc]) fTofAdcSlab[imodule_adc][ichannel_adc] = islab;
00225       //else Warning("FetchTofInfo","tof db duplicated ADC: slab %d",islab);
00226       
00227       if(!fTofTdcSlab[imodule_tdc][ichannel_tdc]){
00228         fTofTdcSlab[imodule_tdc][ichannel_tdc] = islab;
00229       }
00230       else Warning("FetchTofInfo","tof db duplicated TDC: slab %d",islab);
00231       
00232       if(!fTofAdcSide[imodule_adc][ichannel_adc]) fTofAdcSide[imodule_adc][ichannel_adc] = k;
00233       //else Warning("FetchTofInfo","tof db duplicated ADC: side %d",k);
00234      
00235       if(!fTofTdcSide[imodule_tdc][ichannel_tdc]) fTofTdcSide[imodule_tdc][ichannel_tdc] = k;
00236       else Warning("FetchTofInfo","tof db duplicated TDC: side %d",k);
00237       
00238       if(k == 0) {
00239         Int_t itof_mt = ::atoi(*(tof_row+5));
00240         imodule_mt = (itof_mt)/100;
00241         ichannel_mt = (itof_mt%100);    
00242         if(!fTofMtSlab[imodule_mt][ichannel_mt]){
00243           fTofMtSlab[imodule_mt][ichannel_mt] = islab;
00244         }
00245       }
00246       // --- print TOF DB
00247       if(verbose){
00248         cout << "Slab: " << ::atoi(*(tof_row));
00249         if(k == 0) cout << ", side: e";
00250         if(k == 1) cout << ", side: p";
00251         cout << ", adc module/channel: " << imodule_adc << ", " << ichannel_adc;
00252         cout << ", tdc module/channel: " << imodule_tdc << ", " << ichannel_tdc;
00253         cout << ", mean timer: " << imodule_mt << ", " << ichannel_mt;
00254         cout << endl;
00255       }
00256       // ---
00257     }
00258   }
00259   // ---
00260   msqlFreeResult(tof_res_ptr);
00261   return ierr;
00262 
00263 }
00264 
00265 //_______________________________________
00266 Int_t TFndFeeMap::FetchSilInfo(const Bool_t &verbose){
00267 
00268   if(! IsConnected() ){
00269     Error("FetchSilInfo","not connected to DB: can not fetch information");
00270     gApplication->Terminate();
00271   }
00272   
00273   Int_t ierr = 0;
00274   TString dbName = "SilDB";
00275   ierr = msqlSelectDB(fMsqSock,(Char_t *)dbName.Data());
00276   
00277   if (ierr != 0) {
00278     fIsThere = kFALSE; 
00279     cout << ierr << "Exit: no database selection (msqlSelectDB)" << endl;
00280     Warning("FetchSilInfo","Exit: SIL database not available (msqlSelectDB)");
00281     TerminateFroot();
00282   }
00283   else if(verbose) cout << " *** Database " << dbName.Data() << " selected " << endl;
00284   
00285   // Send a query to mSQL  
00286   TString SilQuery = TString("SELECT w ,ph_hyb ,ph_cram ,ph_sec ,ph_strip ,ph_amp ,ph_spy ,ph_dead ,za_hyb ,za_cram ,za_sec ,za_strip ,za_amp ,za_spy ,za_dead ,zb_hyb ,zb_cram ,zb_sec ,zb_strip ,zb_amp ,zb_spy ,zb_dead  FROM fee  "); 
00287   SilQuery+=" WHERE A<"; SilQuery+=fRunTime; SilQuery+=" AND Z > "; SilQuery+=fRunTime; SilQuery+=" ORDER by w";
00288 
00289   ierr = msqlQuery(fMsqSock,(char *) SilQuery.Data());
00290   if (ierr < 0) { cout << ierr << "Bad result from Sil query (msqlQuery)" << endl;  return ierr; }
00291 
00292   m_result *sil_ptr = NULL;
00293   
00294   //Store the result
00295   sil_ptr = msqlStoreResult();
00296   if(sil_ptr == 0){ cout << ierr << "Bad result from Sil (msqlStoreResult)" << endl;  return -1; }
00297     
00298   Int_t b_addr = K_Sil_Crams_BaseAddress_03;
00299   if(fRunTime > Fee_2006_NewSilDB_StartTime) b_addr = K_Sil_Crams_BaseAddress_06;
00300   if(verbose) cout << "selected base address: " << hex << b_addr << dec << endl;
00301 
00302   for (int k=0; k<msqlNumRows(sil_ptr); k++) {
00303     m_row r0 = msqlFetchRow(sil_ptr);
00304 
00305     int w = atoi(r0[0]);
00306     SILDBADC *dbph,*dbza,*dbzb;
00307     if (w<10) {
00308       dbph = &IsiDbAdc [atoi(r0[ 2])-b_addr][atoi(r0[ 3])];
00309       dbza = &IsiDbAdc [atoi(r0[ 9])-b_addr][atoi(r0[10])];
00310       dbzb = &IsiDbAdc [atoi(r0[16])-b_addr][atoi(r0[17])];
00311       dbph->Module = dbza->Module = dbzb->Module = w;
00312     }
00313     else {
00314       dbph = &OsiDbAdc [atoi(r0[ 2])-b_addr][atoi(r0[ 3])];
00315       dbza = &OsiDbAdc [atoi(r0[ 9])-b_addr][atoi(r0[10])];
00316       dbzb = &OsiDbAdc [atoi(r0[16])-b_addr][atoi(r0[17])];
00317       dbph->Module = dbza->Module = dbzb->Module = w-10;
00318     }
00319 
00320     dbph->P_Z = 0;
00321     dbza->P_Z = 1;
00322     dbzb->P_Z = 2;
00323 
00324     for (int c=0;c<1024;c++) {
00325       dbph->Strip[c] = extract(r0[ 4],c);
00326       dbph->Chip[c]  = c/0x80 + 1;
00327       dbph->Amp[c]   = (Float_t) extract(r0[ 5],c)/1000;
00328       dbph->Spy[c]   = r0[ 6][c] - 0x30;
00329       dbph->Noise[c] = r0[ 7][c] - 0x30;
00330 
00331       dbza->Strip[c] = extract(r0[11],c);
00332       dbza->Chip[c]  = c/0x80 + 1;
00333       dbza->Amp[c]   = (Float_t) extract(r0[12],c)/1000;
00334       dbza->Spy[c]   = r0[13][c] - 0x30;
00335       dbza->Noise[c] = r0[14][c] - 0x30;
00336 
00337       dbzb->Strip[c] = extract(r0[18],c);
00338       dbzb->Chip[c]  = c/0x80 + 9;
00339       dbzb->Amp[c]   = (Float_t) extract(r0[19],c)/1000;
00340       dbzb->Spy[c]   = r0[20][c] - 0x30;
00341       dbzb->Noise[c] = r0[21][c] - 0x30;
00342     }
00343 
00344   }
00345 
00346   msqlFreeResult(sil_ptr);  
00347   return ierr;
00348 
00349 }
00350 
00351 //_______________________________________
00352 Int_t TFndFeeMap::FetchLmdInfo(const Bool_t &verbose){
00353 
00354   if(! IsConnected() ){
00355     Error("FetchLmdInfo","not connected to DB: can not fetch information");
00356     gApplication->Terminate();
00357   }
00358   
00359   Int_t ierr = 0;
00360   Int_t imodule_adc = 0;
00361   Int_t ichannel_adc = 0;
00362   Int_t imodule_tdc = 0;
00363   Int_t ichannel_tdc = 0;
00364   TString dbName = "LmdDB";
00365   ierr = msqlSelectDB(fMsqSock,(Char_t *)dbName.Data());
00366   if (ierr != 0) {
00367     fIsThere = kFALSE; 
00368     cout << ierr << "Exit: no database selection (msqlSelectDB)" << endl;
00369     Warning("FetchLmdInfo","Exit: LMD database not available (msqlSelectDB)");
00370     TerminateFroot();
00371   }
00372   else  if(verbose) cout << " *** Database " << dbName.Data() << " selected " << endl;
00373   
00374   // Send a query to mSQL
00375    
00376   TString LmdQuery = TString("SELECT w, ae ,ap ,te ,tp FROM fee ");
00377   LmdQuery+=" WHERE A < ";
00378   LmdQuery+=fRunTime;
00379   LmdQuery+=" AND Z > ";
00380   LmdQuery+=fRunTime;
00381   LmdQuery+=" ORDER by w ";
00382   ierr = msqlQuery(fMsqSock,(char *) LmdQuery.Data());
00383   if(fDebug) cout << LmdQuery.Data() << endl;
00384   
00385   m_result *lmd_res_ptr=NULL;
00386   if (ierr < 0) {
00387     cout << ierr << " error from msqlQuery" << endl;
00388   } else { 
00389     
00390     // Store the result
00391     if(fDebug) cout << "Store  LMD  query  result" << endl;
00392     lmd_res_ptr = msqlStoreResult();
00393     fLmdNRows = msqlNumRows(lmd_res_ptr);
00394     fLmdNFields = msqlNumFields(lmd_res_ptr);
00395   }
00396   
00397   // Set the ADC and TDC mappers for LMD 
00398   Int_t itdcoffset = 0;
00399   if(fRunTime < Fee_Lmd_NewTdcsTime) itdcoffset = 14;
00400   
00401   for(Int_t ij=0;ij<fLmdNRows;ij++) {
00402     msqlDataSeek(lmd_res_ptr,ij);
00403     m_row lmd_row = msqlFetchRow(lmd_res_ptr);
00404     
00405     for(Int_t k=0; k<2; k++) {
00406       Int_t ilmd_adc = ::atoi(*(lmd_row+k+1));
00407       imodule_adc = ilmd_adc/100;
00408       ichannel_adc = (ilmd_adc%100);
00409       Int_t ilmd_tdc = ::atoi(*(lmd_row+k+3));
00410       imodule_tdc = (ilmd_tdc)/100;
00411       ichannel_tdc = (ilmd_tdc%100);
00412       fLmdAdcDCH[imodule_adc][ichannel_adc] = ::atoi(*(lmd_row))/100;
00413       fLmdAdcWire[imodule_adc][ichannel_adc] = ::atoi(*(lmd_row))%100;
00414       fLmdAdcSide[imodule_adc][ichannel_adc] = k;
00415       fLmdTdcDCH[imodule_tdc-itdcoffset][ichannel_tdc] = ::atoi(*(lmd_row))/100;
00416       fLmdTdcWire[imodule_tdc-itdcoffset][ichannel_tdc] = ::atoi(*(lmd_row))%100;
00417       fLmdTdcSide[imodule_tdc-itdcoffset][ichannel_tdc] = k;
00418 
00419       if(verbose){
00420         cout << "Chamber/Wire: " << ::atoi(*(lmd_row));
00421         if(k == 0) cout << ", side: e";
00422         if(k == 1) cout << ", side: p";
00423         cout << ", adc module/channel: " << imodule_adc << ", " << ichannel_adc;
00424         cout << ", tdc module/channel: " << imodule_tdc << ", " << ichannel_tdc;
00425         cout << endl;
00426       }
00427     }
00428   }  
00429 
00430   msqlFreeResult(lmd_res_ptr);  
00431 
00432   return ierr;
00433 
00434 }
00435 
00436 //_______________________________________
00437 Int_t TFndFeeMap::FetchStbInfo(const Bool_t &verbose){
00438 
00439   if(! IsConnected() ){
00440     Error("FetchStbInfo","not connected to DB: can not fetch information");
00441     gApplication->Terminate();
00442   }
00443   
00444   Int_t ierr = 0;
00445   TString dbName = "finuda";
00446   ierr = msqlSelectDB(fMsqSock,(Char_t *)dbName.Data());
00447   
00448   if (ierr != 0) {
00449     fIsThere = kFALSE; 
00450     cout << ierr << "Exit: no database selection (msqlSelectDB)" << endl;
00451     Warning("FetchStbInfo","Exit: finuda database not available (msqlSelectDB)");
00452     TerminateFroot();
00453   }
00454   else if(verbose) cout << " *** Database " << dbName.Data() << " selected (Stb)" << endl;
00455   
00456   //Send a query to mSQL 
00457 //   TString StbQuery = TString("SELECT  status, st_layer, st_number, pp_number, td_crate, td_board, td_channel FROM st_hard WHERE expiry = 2000000000");
00458   TString StbQuery = TString("SELECT  status, st_layer, st_number, pp_number, td_crate, td_board, td_channel FROM st_hard");
00459   StbQuery+=" WHERE date < ";
00460   StbQuery+=fRunTime;
00461   StbQuery+=" AND expiry > ";
00462   StbQuery+=fRunTime;
00463   StbQuery+="ORDER BY td_crate,td_board,td_channel"; 
00464 
00465   ierr = msqlQuery(fMsqSock,(char *) StbQuery.Data());
00466   if(fDebug) cout << StbQuery.Data() << endl;
00467   
00468   m_result *stb_res_ptr=NULL;
00469   if (ierr < 0) {
00470     cout << ierr << " error from msqlQuery" << endl;
00471   } else { 
00472     
00473     // Store the result
00474     
00475     stb_res_ptr = msqlStoreResult();
00476     fStbNRows = msqlNumRows(stb_res_ptr);
00477     fStbNFields = msqlNumFields(stb_res_ptr);
00478   }
00479 
00480   // Set the TDC mapper for STB
00481   Int_t icrate   = 0;
00482   Int_t icrow    = 0;
00483   Int_t itube    = 0;
00484   Int_t imodule  = 0;
00485   Int_t ichannel = 0;
00486   for(Int_t ja=0;ja<fStbNRows;ja++) {
00487     msqlDataSeek(stb_res_ptr,ja);
00488     m_row stb_row = msqlFetchRow(stb_res_ptr);
00489     icrate = ::atoi(*(stb_row + 4)) - 10;
00490     if((icrate   < 0) || (icrate >= K_N_Stb_Crates)) { 
00491       cout << "Warning: Stb crate number " << icrate << endl;
00492       continue;
00493     }
00494 
00495     imodule = ::atoi(*(stb_row + 5)) ;
00496     if((imodule  < 6) || (imodule > K_N_Stb_Mod))  {
00497       cout << "Warning: Stb module number " << imodule << endl;
00498       continue; 
00499     }
00500 
00501     //    ichannel = ::atoi(*(stb_row + 6))-1; // OLD BUG !!!
00502     ichannel = ::atoi(*(stb_row + 6)); // fixed by D. Faso (October 12, 2006)
00503     if((ichannel < 0) || (ichannel > K_N_Stb_Cha))  { 
00504       cout << "Warning: Stb channel number " << ichannel << endl;
00505       continue; 
00506     }
00507     icrow = fStbTdcCrown[icrate][imodule][ichannel] = ::atoi(*(stb_row+1)); //st_layer
00508     itube = fStbTdcWire[icrate][imodule][ichannel] = ::atoi(*(stb_row+2)); //st_number
00509     fStbTdcPPan[icrate][imodule][ichannel] = ::atoi(*(stb_row+3)); //pp_number
00510     
00511     if((icrow > 0)&&(icrow <= K_N_STB_CROWNS)&&(itube > 0)&&(itube <= K_N_STB_TUBES)){
00512       fStbStatus[icrow-1][itube-1] = "";
00513       fStbStatus[icrow-1][itube-1].Append(*stb_row,10);
00514       //Char_t tmp_str[11];
00515       //strncpy(tmp_str,*stb_row,10);
00516       //fStbStatus[icrow-1][itube-1] = tmp_str;
00517     }
00518     else{
00519       cout << "Warning on crown = " << icrow << " tube = " << itube << endl;
00520       cout << "Crown: " << icrow << ", Tube: " << itube;
00521       cout << ", Crate: " << icrate; // OK
00522       cout << ", Module: " << imodule; // OK
00523       cout << ", Channel: " << ichannel << endl;; // OK    
00524     }
00525   }
00526   msqlFreeResult(stb_res_ptr);
00527   return ierr;
00528 }
00529 
00530 //_______________________________________
00531 Int_t TFndFeeMap::FetchTofCalibInfo(const Bool_t &verbose){
00532 
00533   if(verbose) cout << "TFndFeeMap::FetchTofCalibInfo ---> entering method" << endl;
00534   if(! IsConnected() ){
00535     Error("FetchTofCalibInfo","not connected to DB: can not fetch information");
00536     gApplication->Terminate();
00537   }
00538   
00539 
00540   Int_t ierr = 0;
00541   TString dbName = "TofDB";
00542   TString subtable_name = "fee";
00543   if(fRunTime > FROOT::DTak_2006_SftwStartTime){
00544     dbName = "TofDB2";
00545     subtable_name = "calib";
00546   }
00547   Info("FetchTofCalibInfo","Selected TOF database: \"%s\" (RunTime = %d)",dbName.Data(),fRunTime);
00548   ierr = msqlSelectDB(fMsqSock,(Char_t *)dbName.Data());
00549   
00550   if (ierr != 0) {
00551     fIsThere = kFALSE; 
00552     cout << ierr << "Exit: no database selection (msqlSelectDB)" << endl;
00553     Warning("FetchTofCalibInfo","Exit: TOF database not available (msqlSelectDB)");
00554     TerminateFroot();
00555   }
00556   else if(verbose) cout << " *** Database " << dbName.Data() << " selected " << endl;
00557   
00558   //*********** Send a query to mSQL */
00559   TString TofQuery = TString("SELECT w, q0e, q0p, q1e, q1p, t0e, t0p, t0m , cne, cnp, cnm  FROM ");
00560   TofQuery+=subtable_name;
00561   TofQuery+=" WHERE A<";
00562   TofQuery+=fRunTime;
00563   TofQuery+=" AND Z > ";
00564   TofQuery+=fRunTime;
00565   TofQuery+=" ORDER by w";
00566   ierr = msqlQuery(fMsqSock,(char *) TofQuery.Data());
00567   
00568   if(fDebug) cout << TofQuery.Data() << endl;
00569   
00570   m_result *tof_res_ptr = NULL;
00571   Int_t TofCalNRows   = 0;
00572   Int_t TofCalNFields = 0;
00573   if (ierr < 0) {
00574     cout << ierr << "Bad result from Tof query (msqlQuery)" << endl;
00575   }
00576   else { // Store the result
00577     tof_res_ptr  = msqlStoreResult();
00578     TofCalNRows   = msqlNumRows(tof_res_ptr);
00579     TofCalNFields = msqlNumFields(tof_res_ptr);
00580   }
00581   // --- now store result into data-members
00582   Int_t lay = 0;
00583   Int_t sl = 0;
00584   Bool_t is_high_th = kFALSE;
00585   
00586   //   cout << endl << endl << "TFndFeeMap::FetchTofCalibInfo DEBUG 1 : " << TofCalNRows << " ; " << TofCalNFields << endl;
00587   
00588   for(Int_t ij=0;ij<TofCalNRows;ij++) {
00589     msqlDataSeek(tof_res_ptr,ij);
00590     m_row tof_row = msqlFetchRow(tof_res_ptr);
00591     // read single row
00592     Int_t cur_ch = ::atoi(*(tof_row));
00593     if(cur_ch > 300 ){
00594       is_high_th = kTRUE; 
00595       cur_ch -=300;
00596     }
00597     
00598     TFndDB::Tof_ChNum_To_DetChan(cur_ch,lay,sl);
00599     //     Printf("cur_ch: %d; is_h: %i; lay: %i; sl: %i",cur_ch,is_high_th,lay,sl);
00600     
00602     if(0){ // hard-coded debug  
00603       for(Int_t nf=1;nf<TofCalNFields;nf++){
00604         Float_t cur_field = ::atof(*(tof_row+nf));
00605         cout << " row[" << nf << "]: \"" << cur_field << "\" | "; 
00606       }
00607       cout << endl << endl;
00608     } // hard-coded debug  
00610     fTofCal_Q0[lay][sl][E_FIN_SIDE_E] = ::atof(*(tof_row +  1));
00611     fTofCal_Q0[lay][sl][E_FIN_SIDE_P] = ::atof(*(tof_row +  2));
00612     fTofCal_Q1[lay][sl][E_FIN_SIDE_E] = ::atof(*(tof_row +  3));
00613     fTofCal_Q1[lay][sl][E_FIN_SIDE_P] = ::atof(*(tof_row +  4));
00614                                 
00615     if(is_high_th){                 
00616       fTofCal_T0_HighTh[lay][sl][E_FIN_SIDE_E] = ::atof(*(tof_row +  5));
00617       fTofCal_T0_HighTh[lay][sl][E_FIN_SIDE_P] = ::atof(*(tof_row +  6));
00618       fTofCal_T0_HighTh[lay][sl][2]            = ::atof(*(tof_row +  7));
00619       
00620       fTofCal_T1_HighTh[lay][sl][E_FIN_SIDE_E] = ::atof(*(tof_row +  8));
00621       fTofCal_T1_HighTh[lay][sl][E_FIN_SIDE_P] = ::atof(*(tof_row +  9));
00622       fTofCal_T1_HighTh[lay][sl][2]            = ::atof(*(tof_row + 10));
00623     }
00624     else{
00625       fTofCal_T0_LowTh[lay][sl][E_FIN_SIDE_E] = ::atof(*(tof_row +  5));
00626       fTofCal_T0_LowTh[lay][sl][E_FIN_SIDE_P] = ::atof(*(tof_row +  6));
00627       fTofCal_T0_LowTh[lay][sl][2]            = ::atof(*(tof_row +  7));
00628       
00629       fTofCal_T1_LowTh[lay][sl][E_FIN_SIDE_E] = ::atof(*(tof_row +  8));
00630       fTofCal_T1_LowTh[lay][sl][E_FIN_SIDE_P] = ::atof(*(tof_row +  9));
00631       fTofCal_T1_LowTh[lay][sl][2]            = ::atof(*(tof_row + 10));
00632     }
00633   }
00634 
00635   // ---
00636   msqlFreeResult(tof_res_ptr);
00637   if(verbose) cout << "TFndFeeMap::FetchTofCalibInfo ---> exiting method" << endl;
00638   return ierr;
00639 }
00640 
00641 
00642 //_______________________________________
00643 Int_t TFndFeeMap::FetchLmdCalibInfo(const Bool_t &verbose){
00644 
00645   if(verbose) cout << "TFndFeeMap::FetchLmdCalibInfo ---> entering method" << endl;
00646   if(! IsConnected() ){
00647     Error("FetchLmdCalibInfo","not connected to DB: can not fetch information");
00648     gApplication->Terminate();
00649   }
00650   
00651   Int_t ierr = 0;
00652   Int_t Lmd_N_Rows   = 0;
00653   Int_t Lmd_N_Fields = 0;
00654   TString dbName = "LmdDB";
00655   ierr = msqlSelectDB(fMsqSock,(Char_t *)dbName.Data());
00656   if (ierr != 0) {
00657     fIsThere = kFALSE; 
00658     cout << ierr << "Exit: no database selection (msqlSelectDB)" << endl;
00659     Warning("FetchLmdInfo","Exit: LMD database not available (msqlSelectDB)");
00660     TerminateFroot();
00661   }
00662   else  if(verbose) cout << " *** Database " << dbName.Data() << " selected " << endl;
00663   
00664   // Send a query to mSQL
00665    
00666   TString LmdQuery = TString("SELECT w, q0e, q0p, q1e, q1p, t0e, t0p, t0m, t0Ce, t0Cp, t0Cm FROM fee ");
00667   LmdQuery+=" WHERE A < ";
00668   LmdQuery+=fRunTime;
00669   LmdQuery+=" AND Z > ";
00670   LmdQuery+=fRunTime;
00671   LmdQuery+=" ORDER by w ";
00672   ierr = msqlQuery(fMsqSock,(char *) LmdQuery.Data());
00673   if(fDebug) cout << LmdQuery.Data() << endl;
00674   
00675   m_result *lmd_res_ptr=NULL;
00676   if (ierr < 0) {
00677     cout << ierr << " error from msqlQuery" << endl;
00678     return ierr;
00679   } 
00680   
00681   // --- Store the result
00682   if(fDebug) cout << "Store  LMD  calib.  query  result" << endl;
00683   lmd_res_ptr = msqlStoreResult();
00684   Lmd_N_Rows = msqlNumRows(lmd_res_ptr);
00685   Lmd_N_Fields = msqlNumFields(lmd_res_ptr);
00686   
00687   Int_t lay = 0; // layer
00688   Int_t cha = 0; // chamber
00689   Int_t wir = 0; // wire
00690   Int_t wirnod = 0; // wire node (not used, but needed by TFndDB numbering conversion method)
00691 
00692   //cout << endl << endl << "TFndFeeMap::FetchLmdCalibInfo DEBUG 1 : " << Lmd_N_Rows << " ; " << Lmd_N_Fields << endl;
00693 
00694 
00695   // lines loop
00696   for(Int_t ij=0;ij<Lmd_N_Rows;ij++) {
00697     msqlDataSeek(lmd_res_ptr,ij);
00698     m_row lmd_row = msqlFetchRow(lmd_res_ptr);
00699     // read single row
00700     Int_t cur_ch = ::atoi(*(lmd_row));
00701     TFndDB::Lmd_ChNum_To_DetChan(cur_ch,lay,cha,wir,wirnod);
00702 
00703     //
00705     if(0){ // hard-coded debug  
00706       cout << "cur_ch:" << cur_ch << "; lay:" << lay << "; cha:" << cha << "; wir:" << wir << "; wirnod:" << wirnod << endl;
00707       for(Int_t ti=0; ti < Lmd_N_Fields; ti++) cout <<  ::atof(*(lmd_row +  ti )) << " " ;
00708       cout << endl << endl;
00709     }
00710     //
00711     
00712     fLmdCal_Q0 [lay][cha][wir][E_FIN_SIDE_E] = ::atof(*(lmd_row +  1 ));
00713     fLmdCal_Q0 [lay][cha][wir][E_FIN_SIDE_P] = ::atof(*(lmd_row +  2 ));
00714                                                                    
00715     fLmdCal_Q1 [lay][cha][wir][E_FIN_SIDE_E] = ::atof(*(lmd_row +  3 ));
00716     fLmdCal_Q1 [lay][cha][wir][E_FIN_SIDE_P] = ::atof(*(lmd_row +  4 ));
00717                                                                    
00718     fLmdCal_T0 [lay][cha][wir][E_FIN_SIDE_E] = ::atof(*(lmd_row +  5 ));
00719     fLmdCal_T0 [lay][cha][wir][E_FIN_SIDE_P] = ::atof(*(lmd_row +  6 ));
00720     fLmdCal_T0 [lay][cha][wir][2]            = ::atof(*(lmd_row +  7 )); // mean-time software
00721                                                                    
00722     fLmdCal_T0C[lay][cha][wir][E_FIN_SIDE_E] = ::atof(*(lmd_row +  8 ));
00723     fLmdCal_T0C[lay][cha][wir][E_FIN_SIDE_P] = ::atof(*(lmd_row +  9 ));
00724     fLmdCal_T0C[lay][cha][wir][2]            = ::atof(*(lmd_row + 10 )); // mean-time software
00725 
00726   } // lines loop completed
00727   
00728   // ---
00729   msqlFreeResult(lmd_res_ptr);
00730   if(verbose) cout << "TFndFeeMap::FetchLmdCalibInfo ---> exiting method" << endl;
00731   return ierr;
00732   
00733 }
00734 
00735 //_______________________________________
00736 Int_t TFndFeeMap::FetchStbCalibInfo(const Bool_t &verbose){
00737   //   Float_t   fStbCal_T0[K_N_STB_CROWNS+1][K_N_STB_TUBES+1];
00738   //   Float_t fStbCal_Tbar[K_N_STB_CROWNS+1][K_N_STB_TUBES+1];
00739   
00740   if(verbose) cout << "TFndFeeMap::FetchStbCalibInfo ---> entering method" << endl;
00741   if(! IsConnected() ){
00742     Error("FetchStbCalibInfo","not connected to DB: can not fetch information");
00743     gApplication->Terminate();
00744   }
00745   
00746   Int_t ierr = 0;
00747   TString dbName = "finuda";
00748   ierr = msqlSelectDB(fMsqSock,(Char_t *)dbName.Data());
00749   
00750   if (ierr != 0) {
00751     fIsThere = kFALSE; 
00752     cout << ierr << "Exit: no database selection (msqlSelectDB)" << endl;
00753     Warning("FetchStbInfo","Exit: finuda database not available (msqlSelectDB)");
00754     TerminateFroot();
00755   }
00756   if(verbose) cout << " *** Database " << dbName.Data() << " selected (Stb)" << endl;
00757 
00758   // --- query
00759   TString StbQuery = TString("SELECT  st_layer, st_number, r_mean,t_zero  FROM st_hard");
00760   StbQuery+=" WHERE date < ";
00761   StbQuery+=fRunTime;
00762   StbQuery+=" AND expiry > ";
00763   StbQuery+=fRunTime;
00764   StbQuery+="ORDER BY st_layer, st_number"; 
00765   
00766   if(fDebug) cout << StbQuery.Data() << endl;
00767   ierr = msqlQuery(fMsqSock,(char *) StbQuery.Data());
00768   if (ierr < 0) {
00769     cout << ierr << " error from msqlQuery" << endl;
00770     //    return -1;
00771     TerminateFroot();
00772   }
00773   
00774   // --- result
00775   m_result *stb_res_ptr = msqlStoreResult();
00776   Int_t Stb_N_Rows = msqlNumRows(stb_res_ptr);
00777   Int_t Stb_N_Fields = msqlNumFields(stb_res_ptr);
00778   
00779   // --- grab information
00780   Int_t crw = 0; // crown number [1-6]
00781   Int_t tub = 0; // tube number  [1-404]
00782 
00783   for(Int_t ja=0;ja<Stb_N_Rows;ja++) {
00784     msqlDataSeek(stb_res_ptr,ja);
00785     m_row stb_row = msqlFetchRow(stb_res_ptr);
00787     if(0){ // hard-coded debug  
00788       for(Int_t ti=0; ti < Stb_N_Fields; ti++) cout <<  ::atof(*(stb_row +  ti )) << " " ;
00789       cout << endl;
00790     }
00791     //
00792     
00793     crw = ::atoi(*(stb_row + 0));
00794     if((crw   < 1) || (crw > K_N_STB_CROWNS) ) { 
00795       Warning("FetchStbCalibInfo","STB crown: %d",crw);
00796       continue;
00797     }
00798     
00799     tub = ::atoi(*(stb_row + 1)) ;
00800     if((tub < 1) || (tub > K_N_STB_TUBES))  {
00801       Warning("FetchStbCalibInfo","STB tube: %d",tub);
00802       continue; 
00803     }
00804     
00805     fStbCal_Tbar[crw][tub] = ::atof(*(stb_row +  2 ));
00806     fStbCal_T0[crw][tub] = ::atof(*(stb_row +  3 ));
00807     
00808   }
00809   
00810   // ---  
00811   msqlFreeResult(stb_res_ptr);
00812   if(verbose) cout << "TFndFeeMap::FetchStbCalibInfo ---> exiting method" << endl;
00813   return ierr;
00814 }
00815 
00816 
00817 
00818 //_______________________________________
00819 void TFndFeeMap::PrintTofCalibInfo(){
00820   
00821   cout << "TFndFeeMap::PrintTofCalibInfo ---> entering method" << endl;
00822 
00823   TString msg = "";     // complete message
00824   TString app_msg = ""; // single line
00825   TString tmp_str = ""; // part of a single line
00826 
00827   msg+=" ***** Printing single-channels calibration data: *****\n";
00828   app_msg = " Lay\tslab\t|  Q0e \t|  Q0p \t|  Q1e \t|  Q1p \t";
00829   app_msg += "|  T0eL\t\t|  T0pL\t\t|  T1eL\t|  T1pL\t";
00830   app_msg += "|  T0eH\t\t|  T0pH\t\t|  T1eH\t|  T1pH\n";
00831   msg+=app_msg;
00832   
00833   for(Int_t lay=E_FIN_INNER_LAYER;lay<=E_FIN_OUTER_LAYER;lay++){
00834     for(Int_t ch=1; ch <= K_N_TOFONE_SLABS; ch++){
00835       if(lay==E_FIN_INNER_LAYER && ch > K_N_TOFINO_SLABS) continue;
00836       //
00837       tmp_str.Form("  %d \t %d \t",lay,ch);
00838       app_msg = tmp_str; // reset new line content
00839       //
00840       tmp_str.Form(" %.4f\t %.4f\t",
00841                    fTofCal_Q0[lay][ch][E_FIN_SIDE_E],
00842                    fTofCal_Q0[lay][ch][E_FIN_SIDE_P]); 
00843       app_msg+=tmp_str;
00844       tmp_str.Form(" %.4f\t %.4f\t",
00845                    fTofCal_Q1[lay][ch][E_FIN_SIDE_E],
00846                    fTofCal_Q1[lay][ch][E_FIN_SIDE_P]); 
00847       app_msg+=tmp_str;
00848       //
00849       tmp_str.Form(" %.4f\t %.4f\t",
00850                    fTofCal_T0_LowTh[lay][ch][E_FIN_SIDE_E],
00851                    fTofCal_T0_LowTh[lay][ch][E_FIN_SIDE_P]); 
00852       app_msg+=tmp_str;
00853       tmp_str.Form(" %.4f\t %.4f\t",
00854                    fTofCal_T1_LowTh[lay][ch][E_FIN_SIDE_E],
00855                    fTofCal_T1_LowTh[lay][ch][E_FIN_SIDE_P]); 
00856       app_msg+=tmp_str;
00857       //
00858       if(lay == E_FIN_INNER_LAYER){
00859         tmp_str.Form(" %.4f\t %.4f\t",
00860                      fTofCal_T0_HighTh[lay][ch][E_FIN_SIDE_E],
00861                      fTofCal_T0_HighTh[lay][ch][E_FIN_SIDE_P]); 
00862         app_msg+=tmp_str;
00863         tmp_str.Form(" %.4f\t %.4f\t",
00864                      fTofCal_T1_HighTh[lay][ch][E_FIN_SIDE_E],
00865                      fTofCal_T1_HighTh[lay][ch][E_FIN_SIDE_P]); 
00866         app_msg+=tmp_str;
00867       }
00868       //
00869       app_msg+="\n";
00870       msg+=app_msg;
00871     }
00872   }  
00873   // ---
00874   msg+="\n ***** Printing mean-timer (hardware) calibration data: *****\n";
00875   app_msg = " Lay\tslab\t|  MT0L\t\t|  MT1L\t|  MToH\t\t|  MT1H\n";
00876   msg+=app_msg;
00877   for(Int_t lay=E_FIN_INNER_LAYER;lay<=E_FIN_OUTER_LAYER;lay++){
00878     for(Int_t ch=1; ch <= K_N_TOFONE_SLABS; ch++){
00879       if(lay==E_FIN_INNER_LAYER && ch > K_N_TOFINO_SLABS) continue;
00880       //
00881       tmp_str.Form("  %d \t %d \t",lay,ch);
00882       app_msg = tmp_str; // reset new line content
00883       //
00884       tmp_str.Form(" %.4f\t %.4f\t",
00885                    fTofCal_T0_LowTh[lay][ch][2],
00886                    fTofCal_T1_LowTh[lay][ch][2]); 
00887       app_msg+=tmp_str;
00888       //
00889       if(lay == E_FIN_INNER_LAYER){
00890         tmp_str.Form(" %.4f\t %.4f\t",
00891                      fTofCal_T0_HighTh[lay][ch][2],
00892                      fTofCal_T1_HighTh[lay][ch][2]); 
00893         app_msg+=tmp_str;
00894       }
00895       //
00896       app_msg+="\n";
00897       msg+=app_msg;
00898     }
00899   }  
00900       
00901 
00902     // --- --- --- --- ---
00903   cout << msg.Data() << endl;
00904   cout << "TFndFeeMap::PrintTofCalibInfo ---> exiting method" << endl;
00905 }
00906 
00907 //_______________________________________
00908 void TFndFeeMap::PrintLmdCalibInfo(){
00909 
00910   cout << "TFndFeeMap::PrintLmdCalibInfo ---> entering method" << endl;
00911 
00912   TString msg = "";     // complete message
00913   TString app_msg = ""; // single line
00914   TString tmp_str = ""; // part of a single line
00915 
00916   msg+=" ***** Printing single-channels calibration data: *****\n";
00917   app_msg = " Lay\tcham\twire\t|  Q0e \t|  Q0p \t|  Q1e \t|  Q1p \t";
00918   app_msg += "|  T0e \t\t|  T0p \t\t|  T0Ce\t\t|  T0Cp\n";
00919   msg+=app_msg;
00920   
00921 
00922   for(Int_t lay=E_FIN_INNER_LAYER;lay<=E_FIN_OUTER_LAYER;lay++){
00923     for(Int_t ch=1; ch <= K_N_LMD_CHAMS_PER_LAYER; ch++){
00924       if(lay==E_FIN_INNER_LAYER && ch > K_N_TOFINO_SLABS) continue;
00925       for(Int_t wir=1; wir<=K_N_LMD_OUTER_WIRES; wir++ ){
00926         if(lay==E_FIN_INNER_LAYER && wir > K_N_LMD_INNER_WIRES) continue;
00927         //
00928         tmp_str.Form("  %d \t  %d \t  %d \t",lay,ch,wir);
00929         app_msg = tmp_str; // reset new line content
00930         //
00931         tmp_str.Form(" %.2f\t %.2f\t",
00932                      fLmdCal_Q0[lay][ch][wir][E_FIN_SIDE_E],
00933                      fLmdCal_Q0[lay][ch][wir][E_FIN_SIDE_P]); 
00934         app_msg+=tmp_str;
00935         tmp_str.Form(" %.4f\t %.4f\t",
00936                      fLmdCal_Q1[lay][ch][wir][E_FIN_SIDE_E],
00937                      fLmdCal_Q1[lay][ch][wir][E_FIN_SIDE_P]); 
00938         app_msg+=tmp_str;
00939         //
00940         tmp_str.Form(" %.4f\t %.4f\t",
00941                      fLmdCal_T0[lay][ch][wir][E_FIN_SIDE_E],
00942                      fLmdCal_T0[lay][ch][wir][E_FIN_SIDE_P]); 
00943         app_msg+=tmp_str;
00944         tmp_str.Form(" %.4f\t %.4f\t",
00945                      fLmdCal_T0C[lay][ch][wir][E_FIN_SIDE_E],
00946                      fLmdCal_T0C[lay][ch][wir][E_FIN_SIDE_P]); 
00947         app_msg+=tmp_str;
00948         //
00949         // ---
00950         app_msg+="\n";
00951         msg+=app_msg;
00952       }
00953     }
00954   }  
00955 
00957 
00958   msg+="\n ***** Printing mean-time (software) calibration data: *****\n";
00959   app_msg = " Lay\tcham\twire\t|  T0m\t\t|  T0Cm \n";
00960   msg+=app_msg;
00961   
00962 
00963   for(Int_t lay=E_FIN_INNER_LAYER;lay<=E_FIN_OUTER_LAYER;lay++){
00964     for(Int_t ch=1; ch <= K_N_LMD_CHAMS_PER_LAYER; ch++){
00965       if(lay==E_FIN_INNER_LAYER && ch > K_N_TOFINO_SLABS) continue;
00966       for(Int_t wir=1; wir<=K_N_LMD_OUTER_WIRES; wir++ ){
00967         if(lay==E_FIN_INNER_LAYER && wir > K_N_LMD_INNER_WIRES) continue;
00968         //
00969         tmp_str.Form("  %d \t  %d \t  %d \t",lay,ch,wir);
00970         app_msg = tmp_str; // reset new line content
00971         //
00972         tmp_str.Form(" %.4f\t %.4f\t",
00973                      fLmdCal_T0[lay][ch][wir][2],
00974                      fLmdCal_T0C[lay][ch][wir][2]); 
00975         app_msg+=tmp_str;
00976         
00977         //
00978         // ---
00979         app_msg+="\n";
00980         msg+=app_msg;
00981       }
00982     }
00983   }  
00984 
00985 
00987   cout << msg.Data() << endl; 
00988   cout << "TFndFeeMap::PrintLmdCalibInfo ---> exiting method" << endl;
00989   
00990 }
00991 
00992 //_______________________________________
00993 void TFndFeeMap::PrintStbCalibInfo(){
00994   
00995   cout << "TFndFeeMap::PrintStbCalibInfo ---> entering method" << endl;
00996   
00997   TString msg ="\n ***** Printing calibration data: *****\n";
00998   TString app_msg = " Crown\tTube\t|  T0\t|  Tbar\n";
00999   msg+=app_msg;
01000   
01001   for(Int_t crw=1;crw<=K_N_STB_CROWNS;crw++){
01002     for(Int_t tub=1; tub <= K_N_STB_TUBES; tub++){
01003       app_msg.Form(" %d\t %d\t %.0f\t %.0f\n",crw,tub,fStbCal_T0[crw][tub],fStbCal_Tbar[crw][tub]);
01004       msg+=app_msg;
01005     }
01006   }  
01007    
01008   cout << msg.Data() << endl;
01009   cout << "TFndFeeMap::PrintStbCalibInfo ---> exiting method" << endl;
01010 
01011 }
01012 
01013 //_______________________________________
01014 void TFndFeeMap::Print(Option_t *)const {
01015 
01016   cout << "*********************************" << endl;
01017   cout << "TOF database: ";
01018   cout << fTofNRows << " rows, " << fTofNFields << " fields" << endl;
01019   cout << "*********************************" << endl;
01020 
01021   for(Int_t j=0;j<K_N_Tof_AdcMod;j++) {
01022     for(Int_t i=0;i<K_N_Tof_AdcCha;i++) {
01023       cout << "ADC Module: " << j+1 << ", Channel: " << i;
01024       cout << ", Slab: " << fTofAdcSlab[j][i] << ", is_side_p flag: " << fTofAdcSide[j][i] << endl;
01025     }
01026   }
01027   for(Int_t ja=0;ja<K_N_Tof_TdcMod;ja++) {
01028     for(Int_t ia=0;ia<K_N_Tof_TdcCha;ia++) {
01029       cout << "TDC Module: " << ja+1 << ", Channel: " << ia;
01030       cout << ", Slab: " << fTofTdcSlab[ja][ia] << ", is_side_p flag: " << fTofTdcSide[ja][ia] << endl;
01031     }
01032   }
01033 
01034   // ---
01035   
01036   cout << "*********************************" << endl;
01037   cout << "SIL database: ";
01038   cout << "*********************************" << endl;
01039 
01040   cout << "*********************************" << endl;
01041   cout << "    ->ISIM database: ";
01042   cout << "*********************************" << endl;
01043   TString message_str = "";
01044   for(Int_t i=0;i<0x60;i++) {
01045     for(Int_t j=0;j<2;j++) {
01046       for(Int_t ncha=0;ncha<K_N_Sil_AdcCha;ncha++) {
01047         message_str.Form("Module %d; P_Z %d; Spy %d; Noise %d; Strip %d; Chip %d; Amp %f (ncha: %d)",
01048                          IsiDbAdc[i][j].Module,
01049                          IsiDbAdc[i][j].P_Z,
01050                          IsiDbAdc[i][j].Spy[ncha],
01051                          IsiDbAdc[i][j].Noise[ncha],
01052                          IsiDbAdc[i][j].Strip[ncha],
01053                          IsiDbAdc[i][j].Chip[ncha],
01054                         IsiDbAdc[i][j].Amp[ncha],
01055                          ncha
01056                          );
01057         cout << message_str.Data() << endl;
01058       }
01059     }
01060   }
01061   cout << "*********************************" << endl;
01062   cout << "    ->OSIM database: ";
01063   cout << "*********************************" << endl;
01064   for(Int_t i=0;i<0x60;i++) {
01065     for(Int_t j=0;j<2;j++) {
01066       for(Int_t ncha=0;ncha<K_N_Sil_AdcCha;ncha++) {
01067         message_str.Form("Module %d; P_Z %d; Spy %d; Noise %d; Strip %d; Chip %d; Amp %f (ncha: %d)",
01068                          OsiDbAdc[i][j].Module,
01069                          OsiDbAdc[i][j].P_Z,
01070                          OsiDbAdc[i][j].Spy[ncha],
01071                          OsiDbAdc[i][j].Noise[ncha],
01072                          OsiDbAdc[i][j].Strip[ncha],
01073                          OsiDbAdc[i][j].Chip[ncha],
01074                          OsiDbAdc[i][j].Amp[ncha],
01075                          ncha
01076                          );
01077         cout << message_str.Data() << endl;
01078       }
01079     }
01080   }
01081 
01082   
01083   // ---
01084   
01085   cout << "*********************************" << endl;
01086   cout << "LMD database: ";
01087   cout << fLmdNRows << " rows, " << fLmdNFields << " fields" << endl;
01088   cout << "*********************************" << endl;
01089 
01090   for(Int_t jc=0;jc<K_N_Lmd_AdcMod;jc++) {
01091     for(Int_t ic=0;ic<K_N_Lmd_AdcCha;ic++) {
01092       cout << "ADC Module: " << jc+1 << ", Channel: " << ic+1;
01093       cout << " Drift number: " << fLmdAdcDCH[jc][ic];
01094       cout << ", Wire number: " << fLmdAdcWire[jc][ic];
01095       cout << ", is_side_p flag: " << fLmdAdcSide[jc][ic] << endl;
01096     }
01097   }
01098   for(Int_t jd=0;jd<K_N_Lmd_TdcMod;jd++) {
01099     for(Int_t id=0;id<K_N_Lmd_TdcCha;id++) {
01100       cout << "TDC Module: " << jd+1 << ", Channel: " << id+1;
01101       cout << " Drift number: " << fLmdTdcDCH[jd][id];
01102       cout << ", Wire number: " << fLmdTdcWire[jd][id];
01103       cout << ", is_side_p flag: " << fLmdTdcSide[jd][id] << endl;
01104     }
01105   }
01106   
01107   // ---
01108 
01109   cout << "*********************************" << endl;
01110   cout << "STB database: ";
01111   cout << fStbNRows << " rows, " << fStbNFields << " fields" << endl;
01112   cout << "*********************************" << endl;
01113 }

Generated on Tue Oct 16 15:40:48 2007 by  doxygen 1.5.2