STEER/TFndFeeMap.h

00001 // @(#)fROOT/STEER:$Name:  $:$Id: TFndFeeMap.h,v 1.23 2007/09/05 11:09:42 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 
00005 #ifndef FROOT_TFndFeeMap
00006 #define FROOT_TFndFeeMap
00007 
00009 //                                                                         //
00010 //                               TFndFeeMap                                //
00011 //                                                                         //
00012 // The FINUDA Database mapper: this class describes all the                //
00013 // tables contained in the mSQL database useful for the Front              //
00014 // End Electronics mapping in order to define the real detector channel    //
00015 // associated to a given electronic channel                                //
00016 //                                                                         //
00018 
00019 #include <Riostream.h>
00020 #include "TObject.h"
00021 #include "TString.h"
00022 
00023 #include "TFndDB.h" // used for channel numbering calculation
00024 
00025 #include "FROOT.h"
00026 
00027 using namespace FROOT;
00028 
00029 typedef struct {
00030   Char_t  Module;               // Module number
00031   Char_t  P_Z;                  // 0=Phi 1=Za  2=Zb
00032   char  Spy[K_N_Sil_AdcCha];   // 1=Spy
00033   char  Noise[K_N_Sil_AdcCha]; // Noise level: 0=OK ... 6=dead
00034   short Strip[K_N_Sil_AdcCha]; // Strip number
00035   short Chip[K_N_Sil_AdcCha];  // Chip (VA1) number
00036   float Amp[K_N_Sil_AdcCha];   // Strip amplification
00037 } SILDBADC;
00038 
00039 
00040 class TFndFeeMap : public TObject {
00041 
00042 private:
00043 
00044   Int_t fDebug;   
00045   UInt_t fRunTime; 
00046 
00047   Bool_t fIsThere; 
00048   Int_t fMsqSock; 
00049   
00050   Int_t fTofNRows;                // Number of Rows from the TOF Query
00051   Int_t fTofNFields;              // Number of Fields in each Row
00052   // NOTE: since modules start from 1 the first element of [K_N_Tof_AdcMod+1] will remain empty
00053   Int_t fTofAdcSlab[K_N_Tof_AdcMod+1][K_N_Tof_AdcCha]; // TOF-ADC: Slab number
00054   Int_t fTofAdcSide[K_N_Tof_AdcMod+1][K_N_Tof_AdcCha]; // TOF-ADC: side flag (0:p-side ; 1:e-side)
00055   Int_t fTofTdcSlab[K_N_Tof_TdcMod+1][K_N_Tof_TdcCha]; // TOF-TDC: Slab number
00056   Int_t fTofTdcSide[K_N_Tof_TdcMod+1][K_N_Tof_TdcCha]; // TOF-TDC: side flag (0:p-side ; 1:e-side)
00057   Int_t fTofMtSlab[K_N_Tof_TdcMod+1][K_N_Tof_TdcCha];  // Slab Number
00058 
00059   Int_t fLmdNRows;                // Number of Rows from the LMD Query
00060   Int_t fLmdNFields;              // Number of Fields in each Row
00061   Int_t fLmdAdcDCH[K_N_Lmd_AdcMod+1][K_N_Lmd_AdcCha];  // LMD-ADC: DCH number
00062   Int_t fLmdAdcWire[K_N_Lmd_AdcMod+1][K_N_Lmd_AdcCha]; // LMD-ADC: Wire number
00063   Int_t fLmdAdcSide[K_N_Lmd_AdcMod+1][K_N_Lmd_AdcCha]; // LMD-ADC: side flag (0:p-side ; 1:e-side)
00064 
00065   Int_t fLmdTdcDCH[K_N_Lmd_TdcMod+1][K_N_Lmd_TdcCha];  // LMD-TDC: DCH number
00066   Int_t fLmdTdcWire[K_N_Lmd_TdcMod+1][K_N_Lmd_TdcCha]; // LMD-TDC: Wire number
00067   Int_t fLmdTdcSide[K_N_Lmd_TdcMod+1][K_N_Lmd_TdcCha]; // LMD-TDC: side flag (0:p-side ; 1:e-side)
00068 
00069   Int_t fStbNRows;                // Number of Rows from the STB Query
00070   Int_t fStbNFields;              // Number of Fields in each Row
00071   // NOTE: since channels start from 1 the first element of [K_N_Stb_Cha+1] will remain empty
00072   Int_t fStbTdcCrown[K_N_Stb_Crates+1][K_N_Stb_Mod+1][K_N_Stb_Cha+1]; // STB-TDC: Crown number
00073   Int_t fStbTdcWire[K_N_Stb_Crates+1][K_N_Stb_Mod+1][K_N_Stb_Cha+1];  // STB-TDC: Wire number
00074   Int_t fStbTdcPPan[K_N_Stb_Crates+1][K_N_Stb_Mod+1][K_N_Stb_Cha+1];  // STB-TDC: PatchPanel number
00075   TString fStbStatus[K_N_STB_CROWNS][K_N_STB_TUBES];
00076 
00077   SILDBADC IsiDbAdc[0x60][2];   // [cram 0xA0:0xFF][adc section 0:1]
00078   SILDBADC OsiDbAdc[0x60][2];   // [cram 0xA0:0xFF][adc section 0:1]
00079   
00080   // --- CALIB info
00081   //         side (E_FIN_SIDE_E,E_FIN_SIDE_P,mean(2)]
00082   Float_t fTofCal_Q0[E_FIN_OUTER_LAYER+1][K_N_TOFONE_SLABS+1][2]; // adc pede
00083   Float_t fTofCal_Q1[E_FIN_OUTER_LAYER+1][K_N_TOFONE_SLABS+1][2]; // adc equ
00084   Float_t  fTofCal_T0_LowTh[E_FIN_OUTER_LAYER+1][K_N_TOFONE_SLABS+1][3]; // t-zero
00085   Float_t  fTofCal_T1_LowTh[E_FIN_OUTER_LAYER+1][K_N_TOFONE_SLABS+1][3]; // t-ns/ch
00086   Float_t fTofCal_T0_HighTh[E_FIN_OUTER_LAYER+1][K_N_TOFONE_SLABS+1][3]; // t-zero
00087   Float_t fTofCal_T1_HighTh[E_FIN_OUTER_LAYER+1][K_N_TOFONE_SLABS+1][3]; // t-ns/ch
00088   
00089   Float_t  fLmdCal_Q0[E_FIN_OUTER_LAYER+1][K_N_LMD_CHAMS_PER_LAYER+1][K_N_LMD_OUTER_WIRES+1][2]; // adc pede
00090   Float_t  fLmdCal_Q1[E_FIN_OUTER_LAYER+1][K_N_LMD_CHAMS_PER_LAYER+1][K_N_LMD_OUTER_WIRES+1][2]; // adc equ
00091   Float_t  fLmdCal_T0[E_FIN_OUTER_LAYER+1][K_N_LMD_CHAMS_PER_LAYER+1][K_N_LMD_OUTER_WIRES+1][3]; // t-zero (phys trig)
00092   Float_t fLmdCal_T0C[E_FIN_OUTER_LAYER+1][K_N_LMD_CHAMS_PER_LAYER+1][K_N_LMD_OUTER_WIRES+1][3]; // t-zero (central trig: COSM)
00093   
00094   Float_t fStbCal_T0[K_N_STB_CROWNS+1][K_N_STB_TUBES+1];
00095   Float_t fStbCal_Tbar[K_N_STB_CROWNS+1][K_N_STB_TUBES+1];
00096   
00097 
00098  private:
00099   int extract(char *r, int c);
00100   void Reset(); // empty all data members
00101   Int_t FetchTofInfo(const Bool_t &verbose);
00102   Int_t FetchSilInfo(const Bool_t &verbose);
00103   Int_t FetchLmdInfo(const Bool_t &verbose);
00104   Int_t FetchStbInfo(const Bool_t &verbose);
00105 
00106   Int_t FetchTofCalibInfo(const Bool_t &verbose);
00107   Int_t FetchLmdCalibInfo(const Bool_t &verbose);
00108   Int_t FetchStbCalibInfo(const Bool_t &verbose);
00109 
00110 
00111 public:
00112 
00113   TFndFeeMap();      
00114   ~TFndFeeMap() { } 
00115 
00116   Int_t ConnectToHost(const TString &host,TString user="",TString passwd="");
00117   void DisconnectFromHost();
00118   Bool_t IsConnected(){ return (fMsqSock !=-1) ? kTRUE : kFALSE; }
00119   Int_t GetDBSockDesc() { return fMsqSock; }
00120   Int_t FetchRunInfo(const Bool_t &verbose,UInt_t run_time=0,Bool_t also_calib=kTRUE);
00121 
00122   Bool_t IsThere() {return fIsThere;}     // Is there a database link?
00123   
00124   Int_t GetTofAdcSlb(Int_t brd,Int_t chan) { return fTofAdcSlab[brd][chan]; } // Slab number for ADC hit
00125   Int_t GetTofAdcSide(Int_t brd,Int_t chan) { return fTofAdcSide[brd][chan]; } // Get Side for ADC hit
00126   Int_t GetTofTdcSlb(Int_t brd,Int_t chan) { return fTofTdcSlab[brd][chan]; } // Get Slab number for TDC hit
00127   Int_t GetTofTdcSide(Int_t brd,Int_t chan) { return fTofTdcSide[brd][chan]; } // Get Side for TDC hit
00128   Int_t GetTofMTSlb(Int_t brd,Int_t chan) { return fTofMtSlab[brd][chan]; } // Get Slab number for Mean timer
00129 
00130   Int_t GetSilModule(Int_t lay,Int_t icram, Int_t isect)
00131     {
00132       if(lay== (Int_t) E_FIN_INNER_LAYER) return IsiDbAdc[icram][isect].Module;
00133       else if(lay== (Int_t) E_FIN_OUTER_LAYER) return OsiDbAdc[icram][isect].Module;
00134       else cout << "TFndFee BUG!" << endl; return 0;
00135     }
00136   Int_t GetSilSide(Int_t lay,Int_t icram, Int_t isect)
00137     {
00138       if(lay== (Int_t) E_FIN_INNER_LAYER) return IsiDbAdc[icram][isect].P_Z;
00139       else if(lay== (Int_t) E_FIN_OUTER_LAYER) return OsiDbAdc[icram][isect].P_Z;
00140       else cout << "TFndFee BUG!" << endl; return 0;
00141     } 
00142   
00143   Short_t GetSilStrip(Int_t lay,Int_t icram, Int_t isect, Int_t istrip)
00144     {
00145       if(lay== (Int_t) E_FIN_INNER_LAYER) return IsiDbAdc[icram][isect].Strip[istrip];
00146       else if(lay== (Int_t) E_FIN_OUTER_LAYER) return OsiDbAdc[icram][isect].Strip[istrip];
00147       else cout << "TFndFee BUG!" << endl; return 0;
00148     } 
00149 
00150 
00151   //  Short_t GetSilStatus(Int_t icram, Int_t isect, Int_t istrip) {return fSilStatus[istrip][icram][isect]; }     // Get Strip Status
00152   Float_t GetSilSgain(Int_t lay,Int_t icram, Int_t isect, Int_t istrip)
00153     { 
00154       if(lay== (Int_t) E_FIN_INNER_LAYER) return IsiDbAdc[icram][isect].Amp[istrip];
00155       else if(lay== (Int_t) E_FIN_OUTER_LAYER) return OsiDbAdc[icram][isect].Amp[istrip];
00156       else cout << "TFndFee BUG!" << endl; return 0;
00157     } 
00158   
00159   Int_t GetLmdAdcDch(Int_t imodule, Int_t ichannel) { return fLmdAdcDCH[imodule][ichannel]; } // Get DC number for ADC hit
00160   Int_t GetLmdAdcWire(Int_t imodule, Int_t ichannel){ return fLmdAdcWire[imodule][ichannel]; }   // Get Wire number for ADC hit
00161   Int_t GetLmdAdcSide(Int_t imodule, Int_t ichannel) { return fLmdAdcSide[imodule][ichannel]; }   // Get Side for ADC hit
00162   Int_t GetLmdTdcDch(Int_t imodule, Int_t ichannel) { return fLmdTdcDCH[imodule][ichannel]; }   // Get DC number for TDC hit
00163   Int_t GetLmdTdcWire(Int_t imodule, Int_t ichannel) { return fLmdTdcWire[imodule][ichannel]; }   // Get Wire number for TDC hit
00164   Int_t GetLmdTdcSide(Int_t imodule, Int_t ichannel) { return fLmdTdcSide[imodule][ichannel]; }    // Get Side for TDC hit 
00165 
00166   Int_t GetStbCrown (Int_t icrate, Int_t imodule, Int_t ichannel) { return fStbTdcCrown[icrate-10][imodule][ichannel]; } // Get STB crown number  
00167   Int_t GetStbWire(Int_t icrate, Int_t imodule, Int_t ichannel) { return fStbTdcWire[icrate-10][imodule][ichannel]; }  // Get STB wire number
00168   Int_t GetStbPatchPanel(Int_t icrate, Int_t imodule, Int_t ichannel) { return fStbTdcPPan[icrate-10][imodule][ichannel]; }  // Get STB patchpanel number
00169   TString GetStbStatus(Int_t icrow, Int_t itube) { return fStbStatus[icrow][itube]; }  // Get STB status
00170   //  Int_t IsSilSpy(Int_t hybrid,Int_t strip);  // Is a spy?
00171   
00172   // --- CALIB INFO (TOF)
00173   // side: 0,1 (see FROOT::E_Fnd_Side); 2: mean
00174   Float_t GetTofCal_Q0(Int_t lay,Int_t ch,Int_t side) { return fTofCal_Q0[lay][ch][side]; }
00175   Float_t GetTofCal_Q1(Int_t lay,Int_t ch,Int_t side) { return fTofCal_Q1[lay][ch][side]; }
00176   Float_t GetTofCal_T0_LowTh(Int_t lay,Int_t ch,Int_t side) { return fTofCal_T0_LowTh[lay][ch][side]; }
00177   Float_t GetTofCal_T1_LowTh(Int_t lay,Int_t ch,Int_t side) { return fTofCal_T1_LowTh[lay][ch][side]; }
00178   Float_t GetTofCal_T0_HighTh(Int_t lay,Int_t ch,Int_t side) { return fTofCal_T0_HighTh[lay][ch][side]; }
00179   Float_t GetTofCal_T1_HighTh(Int_t lay,Int_t ch,Int_t side) { return fTofCal_T1_HighTh[lay][ch][side]; }
00180   // alias methods
00181   Float_t GetTofCal_AdcPede(Int_t lay,Int_t ch,Int_t side) { return GetTofCal_Q0(lay,ch,side); }
00182   Float_t GetTofCal_AdcEqu (Int_t lay,Int_t ch,Int_t side) { return GetTofCal_Q1(lay,ch,side); }
00183   Float_t GetTofCal_Tzero_LowTh  (Int_t lay,Int_t ch,Int_t side) { return GetTofCal_T0_LowTh(lay,ch,side); }
00184   Float_t GetTofCal_Tconv_LowTh  (Int_t lay,Int_t ch,Int_t side) { return GetTofCal_T1_LowTh(lay,ch,side); }
00185   Float_t GetTofCal_Tzero_HighTh  (Int_t lay,Int_t ch,Int_t side) { return GetTofCal_T0_HighTh(lay,ch,side); }
00186   Float_t GetTofCal_Tconv_HighTh  (Int_t lay,Int_t ch,Int_t side) { return GetTofCal_T1_HighTh(lay,ch,side); }
00187   
00188   // --- CALIB INFO (LMD)
00189   // side: 0,1 (see FROOT::E_Fnd_Side) ; 2: mean
00190   Float_t GetLmdCal_Q0 (Int_t lay,Int_t ch,Int_t wir,Int_t side) { return  fLmdCal_Q0[lay][ch][wir][side]; }
00191   Float_t GetLmdCal_Q1 (Int_t lay,Int_t ch,Int_t wir,Int_t side) { return  fLmdCal_Q1[lay][ch][wir][side]; }
00192   Float_t GetLmdCal_T0 (Int_t lay,Int_t ch,Int_t wir,Int_t side) { return  fLmdCal_T0[lay][ch][wir][side]; }
00193   Float_t GetLmdCal_T0C(Int_t lay,Int_t ch,Int_t wir,Int_t side) { return fLmdCal_T0C[lay][ch][wir][side]; }
00194   // alias methods
00195   Float_t GetLmdCal_AdcPede(Int_t lay,Int_t ch,Int_t wir,Int_t side) { return GetLmdCal_Q0(lay,ch,wir,side); }
00196   Float_t GetLmdCal_AdcEqu(Int_t lay,Int_t ch,Int_t wir,Int_t side)  { return GetLmdCal_Q1(lay,ch,wir,side); }
00197   Float_t GetLmdCal_TzeroHype(Int_t lay,Int_t ch,Int_t wir,Int_t side) { return GetLmdCal_T0(lay,ch,wir,side); }
00198   Float_t GetLmdCal_TzeroCentral(Int_t lay,Int_t ch,Int_t wir,Int_t side) { return GetLmdCal_T0C(lay,ch,wir,side); }
00199   
00200   Float_t GetStbCal_T0(Int_t lay,Int_t tub)   { return fStbCal_T0[lay][tub]; }
00201   Float_t GetStbCal_Tbar(Int_t lay,Int_t tub) { return fStbCal_Tbar[lay][tub]; }
00202   
00204 
00205 
00206   void PrintTofCalibInfo();
00207   void PrintLmdCalibInfo();
00208   void PrintStbCalibInfo();
00209 
00210   void Print(Option_t * = 0) const;     // (overload of TObject method)
00211   //  friend class TFndRdt;
00212   ClassDef(TFndFeeMap,1)  // The Database mapper 
00213 
00214 };
00215 
00216 #endif // FROOT_TFndFeeMap
00217 
00218 
00219 

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