CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/CalibFormats/SiPixelObjects/interface/PixelFEDCard.h

Go to the documentation of this file.
00001 #ifndef TP_PIXELFEDCARD_H
00002 #define TP_PIXELFEDCARD_H
00003 
00010 #include "CalibFormats/SiPixelObjects/interface/PixelConfigBase.h"
00011 
00012 #include <vector>
00013 #include <string>
00014 
00015 namespace pos{
00026   class PixelFEDCard : public PixelConfigBase{
00027 
00028   public:
00029     
00030     //Return true or false depending on if iChannel is used
00031     //iChannel=1..36
00032     bool useChannel(unsigned int iChannel);
00033 
00034     //Set iChannel enable to mode
00035     //iChannel=1..36
00036     void setChannel(unsigned int iChannel, bool mode);
00037 
00038     void restoreBaselinAndChannelMasks();
00039     void restoreControlAndModeRegister();
00040 
00041 
00042     // Constructor and destructor
00043     PixelFEDCard(); // empty
00044     PixelFEDCard(std::string filename); // create from files
00045     PixelFEDCard(std::vector<std::vector<std::string> > & tab); // create from DB
00046     ~PixelFEDCard() {};
00047 
00048     void readDBTBMLevels(std::vector<std::vector<std::string> > &tableMat, int first, int last) ;
00049     void readDBROCLevels(std::vector<std::vector<std::string> > &tableMat, int first, int last) ;
00050     void writeASCII(std::string dir="") const; // write to files
00051     void         writeXML(      pos::PixelConfigKey key, int version, std::string path)                     const ;
00052     virtual void writeXMLHeader(pos::PixelConfigKey key, int version, std::string path, std::ofstream *out) const ;
00053     virtual void writeXML(                                                              std::ofstream *out) const ;
00054     virtual void writeXMLTrailer(                                                       std::ofstream *out) const ;
00055     virtual void writeXMLHeader(pos::PixelConfigKey key, 
00056                                 int version, 
00057                                 std::string path, 
00058                                 std::ofstream *fedstream, 
00059                                 std::ofstream *roclvlstream, 
00060                                 std::ofstream *tbmlvlsteram) const ;
00061     virtual void writeXML(std::ofstream *fedstream,
00062                           std::ofstream *rocstream,
00063                           std::ofstream *tbmstream) const ;
00064     virtual void writeXMLTrailer(std::ofstream *fedstream,
00065                                  std::ofstream *recostream,
00066                                  std::ofstream *tbmstream) const ;
00067     unsigned long long enabledChannels();  // returns 64-bit integer mask 35..0
00068 
00069 
00070     //Settable optical input parameters (one for each 12-receiver)
00071     int opt_cap[3];   // Capacitor adjust
00072     int opt_inadj[3]; // DC-input offset
00073     int opt_ouadj[3]; // DC-output offset
00074   
00075     //input offset dac (one for each channel)
00076     int offs_dac[36];
00077   
00078     //clock phases, use bits 0-8, select the clock edge
00079     unsigned int clkphs1_9,clkphs10_18,clkphs19_27,clkphs28_36;
00080 
00081     //Channel delays, one for each channel, 0=15
00082     int DelayCh[36];
00083   
00084     //Blacks and Ultra-blacks, 3 limit per channel
00085     int BlackHi[36];
00086     int BlackLo[36];
00087     int Ublack[36];
00088     
00089     //Signal levels for the TBM, one per channel
00090     int TBM_L0[36],TBM_L1[36],TBM_L2[36],TBM_L3[36],TBM_L4[36];
00091     int TRL_L0[36],TRL_L1[36],TRL_L2[36],TRL_L3[36],TRL_L4[36];
00092     // Address levels 1 per channel (36) per roc(max=26)
00093     int ROC_L0[36][26],ROC_L1[36][26],ROC_L2[36][26],ROC_L3[36][26],
00094       ROC_L4[36][26];
00095 
00096     //These bits turn off(1) and on(0) channels
00097     unsigned int Ncntrl,NCcntrl,SCcntrl,Scntrl;
00098 
00099     //The values as read from file so that they can be restored after
00100     //calibration
00101     unsigned int Ncntrl_original,NCcntrl_original,SCcntrl_original,Scntrl_original;
00102 
00103      //Bits (1st 8) used to mask TBM trailer bits
00104     unsigned int N_TBMmask,NC_TBMmask,SC_TBMmask,S_TBMmask;
00105     
00106     //Bits (1st 8) used to set the Private Word in the gap and filler words
00107     unsigned int N_Pword,NC_Pword,SC_Pword,S_Pword;
00108 
00109     // 1 = Special Random trigger DAC mode on, 0=off
00110     unsigned int SpecialDac;
00111  
00112     // Control register and delays for the TTCrx
00113     int CoarseDel,FineDes2Del,FineDes1Del;
00114     unsigned int ClkDes2; 
00115 
00116     //Main control reg for determining the DAQ mode
00117     unsigned int Ccntrl; // "CtrlReg" in LAD_C
00118  
00119     //Mode register
00120     int modeRegister; // "ModeReg" in LAD_C
00121   
00122     //Number of ROCS per FED channel
00123     int NRocs[36];
00124 
00125     //Control Regs for setting ADC 1Vpp and 2Vpp
00126     unsigned int Nadcg,NCadcg,SCadcg,Sadcg;
00127 
00128     //Control and data Regs for setting Baseline Adjustment
00129     unsigned int Nbaseln,NCbaseln,SCbaseln,Sbaseln;
00130 
00131     //data Regs for TTs adjustable levels
00132     int Ooslvl,Errlvl;
00133 
00134     //data Regs adjustable fifo Almost Full levels
00135     int Nfifo1Bzlvl,NCfifo1Bzlvl,SCfifo1Bzlvl,Sfifo1Bzlvl,fifo3Wrnlvl;
00136                 
00137                 //Master delay for FED TTC signals 
00138                 int FedTTCDelay;
00139 
00140     //data Regs adjustable hit limits in fifo1s by fpga
00141     int N_hitlimit,NC_hitlimit,SC_hitlimit,S_hitlimit;
00142     
00143     //data Regs to skip bad ROCs by fpga
00144     int N_testreg,NC_testreg,SC_testreg,S_testreg;
00145     
00146     //The values as read from file so that they can be restored after
00147     //calibration
00148     int Nbaseln_original,NCbaseln_original,SCbaseln_original,
00149         Sbaseln_original;
00150 
00151     int Ccntrl_original;
00152     int modeRegister_original;
00153 
00154     //VME base address 
00155     unsigned long FEDBASE_0, fedNumber;
00156 
00157  private: 
00158  
00159     // Added by Dario (March 26th 2008)
00160     void clear(void) ;
00161 
00162   }; // end class PixelFEDCard
00163 }
00164 /* @} */
00165 #endif // ifdef include