Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:13

0001 #ifndef PixelROCDACSettings_h
0002 #define PixelROCDACSettings_h
0003 /*! \file CalibFormats/SiPixelObjects/interface/PixelROCDACSettings.h
0004 *   \brief This class provide the data structure for the ROC DAC parameters
0005 *
0006 *   At this point I do not see a reason to make an abstract layer for this code.
0007 */
0008 
0009 #include <string>
0010 #include <iostream>
0011 #include <vector>
0012 #include <map>
0013 #include <fstream>
0014 #include <sstream>
0015 #include "CalibFormats/SiPixelObjects/interface/PixelConfigKey.h"
0016 #include "CalibFormats/SiPixelObjects/interface/PixelROCName.h"
0017 
0018 namespace pos {
0019   typedef unsigned char bits8;
0020   typedef unsigned char bits4;
0021 
0022   class PixelROCDACSettings;
0023   std::ostream& operator<<(std::ostream& s, const PixelROCDACSettings& dacs);
0024 
0025   /*! \class PixelROCDACSettings PixelROCDACSettings.h "interface/PixelROCDACSettings.h"
0026 *   \brief This class implements..
0027 *
0028 *   A longer explanation will be placed here later
0029 */
0030   class PixelROCDACSettings {
0031   public:
0032     PixelROCDACSettings();
0033     virtual ~PixelROCDACSettings() { ; };
0034 
0035     PixelROCDACSettings(const PixelROCName& rocid) { rocid_ = rocid; }
0036 
0037     //Build the commands needed to configure ROC
0038     //Need to use the mask bits also for this
0039     std::string getConfigCommand();
0040 
0041     int read(std::ifstream& in, const PixelROCName& rocid);
0042     int read(std::istringstream& in, const PixelROCName& rocid);
0043 
0044     int readBinary(std::ifstream& in, const PixelROCName& rocid);
0045 
0046     void writeBinary(std::ofstream& out) const;
0047 
0048     void writeASCII(std::ostream& out) const;
0049     void writeXML(pos::PixelConfigKey key, int version, std::string path) const { ; }
0050     virtual void writeXMLHeader(pos::PixelConfigKey key, int version, std::string path, std::ofstream* out) const { ; }
0051     virtual void writeXML(std::ofstream* out) const;
0052     virtual void writeXMLTrailer(std::ofstream* out) const { ; }
0053 
0054     void getDACs(std::vector<unsigned int>& dacs) const;
0055     void getDACs(std::map<std::string, unsigned int>& dacs) const;
0056 
0057     void setDAC(unsigned int dacaddress, unsigned int dacvalue);
0058     void setDACs(std::map<std::string, unsigned int>& dacs);
0059 
0060     void compareDACs(std::map<std::string, unsigned int>& dacs,
0061                      std::map<std::string, bool>& changes,
0062                      std::map<std::string, unsigned int>& previous);
0063 
0064     void checkTag(std::string tag, std::string dacName, const PixelROCName& rocid);
0065 
0066     void setDac(std::string dacName, int value);
0067 
0068     unsigned int getDac(std::string dacName) const;
0069 
0070     bits4 getVdd() { return Vdd_; }
0071     void setVdd(bits4 vdd) { Vdd_ = vdd; }
0072 
0073     bits8 getVana() { return Vana_; }
0074     void setVana(bits8 vana) { Vana_ = vana; }
0075 
0076     bits8 getVsf() { return Vsf_; }
0077     void setVsf(bits8 vsf) { Vsf_ = vsf; }
0078 
0079     bits4 getVcomp() { return Vcomp_; }
0080     void setVcomp(bits4 vcomp) { Vcomp_ = vcomp; }
0081 
0082     bits8 getVleak() { return Vleak_; }
0083     void setVleak(bits8 vleak) { Vleak_ = vleak; }
0084 
0085     bits4 getVrgPr() { return VrgPr_; }
0086     void setVrgPr(bits4 vrgPr) { VrgPr_ = vrgPr; }
0087 
0088     bits8 getVwllPr() { return VwllPr_; }
0089     void setVwllPr_(bits8 vwllPr) { VwllPr_ = vwllPr; }
0090 
0091     bits4 getVrgSh() { return VrgSh_; }
0092     void setVrgSh(bits4 vrgSh) { VrgSh_ = vrgSh; }
0093 
0094     bits8 getVwllSh() { return VwllSh_; }
0095     void setVwllSh(bits8 vwllSh) { VwllSh_ = vwllSh; }
0096 
0097     bits8 getVHldDel() { return VHldDel_; }
0098     void setVHldDel(bits8 vHldDel) { VHldDel_ = vHldDel; }
0099 
0100     bits8 getVtrim() { return Vtrim_; }
0101     void setVtrim(bits8 vtrim) { Vtrim_ = vtrim; }
0102 
0103     bits8 getVcThr() { return VcThr_; }
0104     void setVcThr(bits8 vcThr) { VcThr_ = vcThr; }
0105 
0106     bits8 getVIbias_bus() { return VIbias_bus_; }
0107     void setVIbias_bus(bits8 vIbias_bus) { VIbias_bus_ = vIbias_bus; }
0108 
0109     bits4 getVIbias_sf() { return VIbias_sf_; }
0110     void setVIbias_sf(bits4 vIbias_sf) { VIbias_sf_ = vIbias_sf; }
0111 
0112     bits8 getVOffsetOp() { return VOffsetOp_; }
0113     void setVOffsetOp(bits8 vOffsetOp) { VOffsetOp_ = vOffsetOp; }
0114 
0115     bits8 getVbiasOp() { return VbiasOp_; }
0116     void setVbiasOp(bits8 vbiasOp) { VbiasOp_ = vbiasOp; }
0117 
0118     bits8 getVOffsetRO() { return VOffsetRO_; }
0119     void setVOffsetRO(bits8 vOffsetRO) { VOffsetRO_ = vOffsetRO; }
0120 
0121     bits8 getVIon() { return VIon_; }
0122     void setVIon(bits8 vIon) { VIon_ = vIon; }
0123 
0124     bits8 getVIbias_PH() { return VIbias_PH_; }
0125     void setVIbias_PH(bits8 vIbias_PH) { VIbias_PH_ = vIbias_PH; }
0126 
0127     bits8 getVIbias_DAC() { return VIbias_DAC_; }
0128     void setVIbias_DAC(bits8 vIbias_DAC) { VIbias_DAC_ = vIbias_DAC; }
0129 
0130     bits8 getVIbias_roc() { return VIbias_roc_; }
0131     void setVIbias_roc(bits8 vIbias_roc) { VIbias_roc_ = vIbias_roc; }
0132 
0133     bits8 getVIColOr() { return VIColOr_; }
0134     void setVIColOr(bits8 vIColOr) { VIColOr_ = vIColOr; }
0135 
0136     bits8 getVnpix() { return Vnpix_; }
0137     void setVnpix(bits8 vnpix) { Vnpix_ = vnpix; }
0138 
0139     bits8 getVsumCol() { return VsumCol_; }
0140     void setVsumCol(bits8 vsumCol) { VsumCol_ = vsumCol; }
0141 
0142     bits8 getVcal() { return Vcal_; }
0143     void setVcal(bits8 vcal) { Vcal_ = vcal; }
0144 
0145     bits8 getCalDel() { return CalDel_; }
0146     void setCalDel(bits8 calDel) { CalDel_ = calDel; }
0147 
0148     bits8 getTempRange() { return TempRange_; }
0149     void setTempRange(bits8 tempRange) { TempRange_ = tempRange; }
0150 
0151     bits8 getWBC() { return WBC_; }
0152     void setWBC(bits8 wbc) { WBC_ = wbc; }
0153 
0154     bits8 getControlRegister() const { return ChipContReg_; }
0155     void setControlRegister(bits8 controlregister) { ChipContReg_ = controlregister; }
0156 
0157     PixelROCName getROCName() const { return rocid_; }
0158 
0159     friend std::ostream& operator<<(std::ostream& s, const PixelROCDACSettings& dacs);
0160 
0161   private:
0162     PixelROCName rocid_;
0163 
0164     //The dac settings used by the ROC
0165 
0166     bits4 Vdd_;          //addr 1
0167     bits8 Vana_;         //addr 2
0168     bits8 Vsf_;          //addr 3
0169     bits4 Vcomp_;        //addr 4
0170     bits8 Vleak_;        //addr 5
0171     bits4 VrgPr_;        //addr 6
0172     bits8 VwllPr_;       //addr 7
0173     bits4 VrgSh_;        //addr 8
0174     bits8 VwllSh_;       //addr 9
0175     bits8 VHldDel_;      //addr 10
0176     bits8 Vtrim_;        //addr 11
0177     bits8 VcThr_;        //addr 12
0178     bits8 VIbias_bus_;   //addr 13
0179     bits4 VIbias_sf_;    //addr 14
0180     bits8 VOffsetOp_;    //addr 15
0181     bits8 VbiasOp_;      //addr 16
0182     bits8 VOffsetRO_;    //addr 17
0183     bits8 VIon_;         //addr 18
0184     bits8 VIbias_PH_;    //addr 19
0185     bits8 VIbias_DAC_;   //addr 20
0186     bits8 VIbias_roc_;   //addr 21
0187     bits8 VIColOr_;      //addr 22
0188     bits8 Vnpix_;        //addr 23
0189     bits8 VsumCol_;      //addr 24
0190     bits8 Vcal_;         //addr 25
0191     bits8 CalDel_;       //addr 26
0192     bits8 TempRange_;    //addr 27
0193     bits8 WBC_;          //addr 254
0194     bits8 ChipContReg_;  //addr 253
0195 
0196     std::string ToLower(std::string);
0197   };
0198 }  // namespace pos
0199 #endif