#include <CalibFormats/SiPixelObjects/interface/PixelTBMSettings.h>
Public Member Functions | |
void | generateConfiguration (PixelFECConfigInterface *pixelFEC, PixelNameTranslation *trans, bool physics=false) const |
unsigned char | getAnalogInputBias () |
unsigned char | getAnalogOutputBias () |
unsigned char | getAnalogOutputGain () |
bool | getMode (void) |
PixelTBMSettings () | |
PixelTBMSettings (std::string filename) | |
PixelTBMSettings (std::vector< std::vector< std::string > > &tableMat) | |
void | setAnalogInputBias (unsigned char analogInputBias) |
void | setAnalogOutputBias (unsigned char analogOutputBias) |
void | setAnalogOutputGain (unsigned char analogOutputGain) |
void | setMode (bool mode) |
void | setROCName (std::string rocname) |
void | setTBMGenericValue (std::string, int) |
void | writeASCII (std::string dir) const |
void | writeBinary (std::string filename) const |
virtual void | writeXML (std::ofstream *out) const |
void | writeXML (pos::PixelConfigKey key, int version, std::string path) const |
virtual void | writeXMLHeader (pos::PixelConfigKey key, int version, std::string path, std::ofstream *out) const |
virtual void | writeXMLTrailer (std::ofstream *out) const |
virtual | ~PixelTBMSettings () |
Private Attributes | |
unsigned char | analogInputBias_ |
unsigned char | analogOutputBias_ |
unsigned char | analogOutputGain_ |
PixelModuleName | moduleId_ |
PixelROCName | rocid_ |
bool | singlemode_ |
Friends | |
std::ostream & | operator<< (std::ostream &s, const PixelTBMSettings &mask) |
" "
A longer explanation will be placed here later
Definition at line 27 of file PixelTBMSettings.h.
PixelTBMSettings::PixelTBMSettings | ( | std::vector< std::vector< std::string > > & | tableMat | ) |
View's name: CONF_KEY_PIXEL_TBM_MV
----------------------------------------- -------- ---------------------------- CONFIG_KEY_ID NUMBER(38) CONFIG_KEY VARCHAR2(80) VERSION VARCHAR2(40) CONDITION_DATA_SET_ID NUMBER(38) KIND_OF_CONDITION_ID NUMBER(38) KIND_OF_COND VARCHAR2(40) TBM_PART_ID NUMBER(38) TBM_SER_NUM VARCHAR2(40) MODULE_NAME VARCHAR2(99) HUB_ADDRS NUMBER(38) ANLG_INBIAS_ADDR NUMBER(38) ANLG_INBIAS_VAL NUMBER(38) ANLG_OUTBIAS_ADDR NUMBER(38) ANLG_OUTBIAS_VAL NUMBER(38) ANLG_OUTGAIN_ADDR NUMBER(38) ANLG_OUTGAIN_VAL NUMBER(38) TBM_MODE VARCHAR2(200)
N.B.: Here we should (MUST) get a single row referring to a particula module for a particula version.
Definition at line 20 of file PixelTBMSettings.cc.
References analogInputBias_, analogOutputBias_, analogOutputGain_, c, TestMuL1L2Filter_cff::cerr, lat::endl(), moduleId_, n, singlemode_, and tmp.
00020 :PixelConfigBase("","",""){ 00021 std::vector< std::string > ins = tableMat[0]; 00022 std::map<std::string , int > colM; 00023 std::vector<std::string > colNames; 00024 00053 colNames.push_back("CONFIG_KEY_ID" ); 00054 colNames.push_back("CONFIG_KEY" ); 00055 colNames.push_back("VERSION" ); 00056 colNames.push_back("CONDITION_DATA_SET_ID"); 00057 colNames.push_back("KIND_OF_CONDITION_ID" ); 00058 colNames.push_back("KIND_OF_COND" ); 00059 colNames.push_back("TBM_PART_ID" ); 00060 colNames.push_back("TBM_SER_NUM" ); 00061 colNames.push_back("MODULE_NAME" ); 00062 colNames.push_back("HUB_ADDRS" ); 00063 colNames.push_back("ANLG_INBIAS_ADDR" ); 00064 colNames.push_back("ANLG_INBIAS_VAL" ); 00065 colNames.push_back("ANLG_OUTBIAS_ADDR" ); 00066 colNames.push_back("ANLG_OUTBIAS_VAL" ); 00067 colNames.push_back("ANLG_OUTGAIN_ADDR" ); 00068 colNames.push_back("ANLG_OUTGAIN_VAL" ); 00069 colNames.push_back("TBM_MODE" ); 00070 00071 00072 00073 for(unsigned int c = 0 ; c < ins.size() ; c++){ 00074 for(unsigned int n=0; n<colNames.size(); n++){ 00075 if(tableMat[0][c] == colNames[n]){ 00076 colM[colNames[n]] = c; 00077 break; 00078 } 00079 } 00080 }//end for 00081 for(unsigned int n=0; n<colNames.size(); n++){ 00082 if(colM.find(colNames[n]) == colM.end()){ 00083 std::cerr << "[PixelTBMSettings::PixelTBMSettings()]\tCouldn't find in the database the column with name " << colNames[n] << std::endl; 00084 assert(0); 00085 } 00086 } 00087 00088 if(tableMat.size() >1) 00089 { 00090 PixelModuleName tmp(tableMat[1][colM["MODULE_NAME"]]); 00091 moduleId_ = tmp ; 00092 00093 analogInputBias_ = atoi(tableMat[1][colM["ANLG_INBIAS_VAL"]].c_str()); 00094 analogOutputBias_ = atoi(tableMat[1][colM["ANLG_OUTBIAS_VAL"]].c_str()); 00095 analogOutputGain_ = atoi(tableMat[1][colM["ANLG_OUTGAIN_VAL"]].c_str()); 00096 00097 if( tableMat[1][colM["TBM_MODE"]] == "Single"){ 00098 singlemode_=true; 00099 } 00100 else{ 00101 singlemode_=false; 00102 } 00103 } 00104 }//end contructor
PixelTBMSettings::PixelTBMSettings | ( | std::string | filename | ) |
Definition at line 108 of file PixelTBMSettings.cc.
References analogInputBias_, analogOutputBias_, analogOutputGain_, c, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), i, in, rocid_, s1, singlemode_, ecalRecalibSequence_cff::tag, and tmp.
00108 : 00109 PixelConfigBase("","",""){ 00110 00111 00112 if (filename[filename.size()-1]=='t'){ 00113 00114 std::ifstream in(filename.c_str()); 00115 00116 if (!in.good()){ 00117 std::cout << "[PixelTBMSettings::PixelTBMSettings()]\t\tCould not open:"<<filename<<std::endl; 00118 assert(0); 00119 } 00120 else { 00121 // std::cout << "Opened:"<<filename<<std::endl; 00122 } 00123 00124 std::string tag; 00125 00126 PixelROCName tmp(in); 00127 00128 rocid_=tmp; 00129 00130 unsigned int tmpint; 00131 00132 in >> tag; 00133 //std::cout << "Tag="<<tag<<std::endl; 00134 assert(tag=="AnalogInputBias:"); 00135 in >> tmpint; 00136 analogInputBias_=tmpint; 00137 00138 in >> tag; 00139 //std::cout << "Tag="<<tag<<std::endl; 00140 assert(tag=="AnalogOutputBias:"); 00141 in >> tmpint; 00142 analogOutputBias_=tmpint; 00143 00144 in >> tag; 00145 //std::cout << "Tag="<<tag<<std::endl; 00146 assert(tag=="AnalogOutputGain:"); 00147 in >> tmpint; 00148 analogOutputGain_=tmpint; 00149 00150 in >> tag; 00151 //std::cout << "Tag="<<tag<<std::endl; 00152 assert(tag=="Mode:"); 00153 in >> tag; 00154 assert(tag=="SingleMode"||tag=="DualMode"); 00155 00156 singlemode_=true; 00157 00158 if (tag=="DualMode") singlemode_=false; 00159 00160 in.close(); 00161 00162 } 00163 else{ 00164 00165 std::ifstream in(filename.c_str(),std::ios::binary); 00166 00167 if (!in.good()){ 00168 std::cout << "Could not open:"<<filename<<std::endl; 00169 assert(0); 00170 } 00171 else { 00172 std::cout << "Opened:"<<filename<<std::endl; 00173 } 00174 00175 char nchar; 00176 std::string s1; 00177 00178 in.read(&nchar,1); 00179 00180 s1.clear(); 00181 00182 //wrote these lines of code without ref. needs to be fixed 00183 for(int i=0;i< nchar; i++){ 00184 char c; 00185 in >>c; 00186 s1.push_back(c); 00187 } 00188 00189 PixelROCName tmp(s1); 00190 00191 rocid_=tmp; 00192 00193 in >> analogInputBias_; 00194 in >> analogOutputBias_; 00195 in >> analogOutputGain_; 00196 in >> singlemode_; 00197 00198 in.close(); 00199 00200 00201 00202 } 00203 00204 00205 }
pos::PixelTBMSettings::PixelTBMSettings | ( | ) | [inline] |
virtual pos::PixelTBMSettings::~PixelTBMSettings | ( | ) | [inline, virtual] |
void PixelTBMSettings::generateConfiguration | ( | PixelFECConfigInterface * | pixelFEC, | |
PixelNameTranslation * | trans, | |||
bool | physics = false | |||
) | const |
Definition at line 260 of file PixelTBMSettings.cc.
References analogInputBias_, analogOutputBias_, analogOutputGain_, pos::PixelFECConfigInterface::callatencycount(), pos::PixelFECConfigInterface::disableexttrigger(), pos::PixelFECConfigInterface::enablecallatency(), pos::PixelNameTranslation::getHdwAddress(), pos::PixelHdwAddress::hubaddress(), pos::PixelFECConfigInterface::injectrstroc(), pos::PixelFECConfigInterface::injectrsttbm(), pos::PixelFECConfigInterface::injecttrigger(), pos::PixelHdwAddress::mfec(), pos::PixelHdwAddress::mfecchannel(), rocid_, singlemode_, and pos::PixelFECConfigInterface::tbmcmd().
00262 { 00263 00264 PixelHdwAddress theROC=*(trans->getHdwAddress(rocid_)); 00265 00266 00267 int mfec=theROC.mfec(); 00268 int mfecchannel=theROC.mfecchannel(); 00269 int tbmchannel=14; 00270 int tbmchannelB=15; 00271 int hubaddress=theROC.hubaddress(); 00272 00273 pixelFEC->injectrsttbm(mfec, 1); 00274 pixelFEC->injectrstroc(mfec,1); 00275 pixelFEC->enablecallatency(mfec,0); 00276 pixelFEC->disableexttrigger(mfec,0); 00277 pixelFEC->injecttrigger(mfec,0); 00278 pixelFEC->callatencycount(mfec,79); 00279 00280 //pixelFEC->synccontrolregister(mfec); 00281 00282 //Reset TBM and reset ROC 00283 pixelFEC->tbmcmd(mfec, mfecchannel, tbmchannel, hubaddress, 4, 2, 0x14, 0); 00284 //setting speed to 40MHz 00285 pixelFEC->tbmcmd(mfec, mfecchannel, tbmchannel, hubaddress, 4, 0, 1, 0); 00286 if (physics) { 00287 pixelFEC->tbmcmd(mfec, mfecchannel, tbmchannel, hubaddress, 4, 1, 0x80, 0); 00288 } else { 00289 pixelFEC->tbmcmd(mfec, mfecchannel, tbmchannel, hubaddress, 4, 1, 0xc0, 0); 00290 } 00291 //Enable token and analog output 00292 pixelFEC->tbmcmd(mfec, mfecchannel, tbmchannel, hubaddress, 4, 4, 0x0, 0); 00293 00294 //Analog input bias 00295 pixelFEC->tbmcmd(mfec, mfecchannel, tbmchannel, hubaddress, 4, 5, 00296 analogInputBias_, 0); 00297 //Analog output bias 00298 pixelFEC->tbmcmd(mfec, mfecchannel, tbmchannel, hubaddress, 4, 6, 00299 analogOutputBias_, 0); 00300 //Analog output gain 00301 pixelFEC->tbmcmd(mfec, mfecchannel, tbmchannel, hubaddress, 4, 7, 00302 analogOutputGain_, 0); 00303 00304 00305 //setting speed to 40MHz 00306 pixelFEC->tbmcmd(mfec, mfecchannel, tbmchannelB, hubaddress, 4, 0, 1, 0); 00307 //pre-calibration FIXME can not be used for data taking 00308 pixelFEC->tbmcmd(mfec, mfecchannel, tbmchannelB, hubaddress, 4, 1, 0xc0, 0); 00309 //Reset TBM and reset ROC 00310 pixelFEC->tbmcmd(mfec, mfecchannel, tbmchannelB, hubaddress, 4, 2, 0x14, 0); 00311 //Enable token and analog output 00312 if (singlemode_){ 00313 pixelFEC->tbmcmd(mfec, mfecchannel, tbmchannelB, hubaddress, 4, 4, 0x3, 0); 00314 } 00315 else{ 00316 pixelFEC->tbmcmd(mfec, mfecchannel, tbmchannelB, hubaddress, 4, 4, 0x0, 0); 00317 } 00318 }
unsigned char pos::PixelTBMSettings::getAnalogInputBias | ( | ) | [inline] |
Definition at line 53 of file PixelTBMSettings.h.
References analogInputBias_.
00053 {return analogInputBias_;}
unsigned char pos::PixelTBMSettings::getAnalogOutputBias | ( | ) | [inline] |
Definition at line 56 of file PixelTBMSettings.h.
References analogOutputBias_.
00056 {return analogOutputBias_;}
unsigned char pos::PixelTBMSettings::getAnalogOutputGain | ( | ) | [inline] |
Definition at line 59 of file PixelTBMSettings.h.
References analogOutputGain_.
00059 {return analogOutputGain_;}
Definition at line 63 of file PixelTBMSettings.h.
References singlemode_.
00063 {return singlemode_;}
void pos::PixelTBMSettings::setAnalogInputBias | ( | unsigned char | analogInputBias | ) | [inline] |
Definition at line 54 of file PixelTBMSettings.h.
References analogInputBias_.
00054 {analogInputBias_=analogInputBias;}
void pos::PixelTBMSettings::setAnalogOutputBias | ( | unsigned char | analogOutputBias | ) | [inline] |
Definition at line 57 of file PixelTBMSettings.h.
References analogOutputBias_.
00057 {analogOutputBias_=analogOutputBias;}
void pos::PixelTBMSettings::setAnalogOutputGain | ( | unsigned char | analogOutputGain | ) | [inline] |
Definition at line 60 of file PixelTBMSettings.h.
References analogOutputGain_.
00060 {analogOutputGain_=analogOutputGain;}
Definition at line 64 of file PixelTBMSettings.h.
References singlemode_.
00064 {singlemode_ = mode;}
void pos::PixelTBMSettings::setROCName | ( | std::string | rocname | ) | [inline] |
Definition at line 207 of file PixelTBMSettings.cc.
References analogInputBias_, analogOutputBias_, analogOutputGain_, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), and singlemode_.
00208 { 00209 if( what == "analogInputBias" ) {analogInputBias_ = (unsigned char)value;} 00210 else if( what == "analogOutputBias" ) {analogOutputBias_ = (unsigned char)value;} 00211 else if( what == "analogOutputGain" ) {analogOutputGain_ = (unsigned char)value;} 00212 else if( what == "Mode" ) {singlemode_ = (bool)value; } 00213 else {std::cout << "[PixelTBMSettings::setTBMGenericValue()]\t\tFATAL: invalid key/value pair: " << what << "/" << value << std::endl ; assert(0);} 00214 }
void PixelTBMSettings::writeASCII | ( | std::string | dir | ) | const [virtual] |
Implements pos::PixelConfigBase.
Definition at line 232 of file PixelTBMSettings.cc.
References analogInputBias_, analogOutputBias_, analogOutputGain_, lat::endl(), EgammaValidation_cff::filename, int, module(), out, rocid_, pos::PixelROCName::rocname(), and singlemode_.
00232 { 00233 00234 PixelModuleName module(rocid_.rocname()); 00235 00236 if (dir!="") dir+="/"; 00237 std::string filename=dir+"TBM_module_"+module.modulename()+".dat"; 00238 00239 std::ofstream out(filename.c_str()); 00240 00241 out << rocid_.rocname() << std::endl; 00242 00243 out << "AnalogInputBias: "<<(int)analogInputBias_<<std::endl; 00244 out << "AnalogOutputBias: "<<(int)analogOutputBias_<<std::endl; 00245 out << "AnalogOutputGain: "<<(int)analogOutputGain_<<std::endl; 00246 out << "Mode: "; 00247 if (singlemode_) { 00248 out << "SingleMode" << std::endl; 00249 } 00250 else{ 00251 out << "DualMode" << std::endl; 00252 } 00253 00254 00255 00256 }
void PixelTBMSettings::writeBinary | ( | std::string | filename | ) | const |
Definition at line 216 of file PixelTBMSettings.cc.
References analogInputBias_, analogOutputBias_, analogOutputGain_, out, rocid_, pos::PixelROCName::rocname(), and singlemode_.
00216 { 00217 00218 std::ofstream out(filename.c_str(),std::ios::binary); 00219 00220 out << (char)rocid_.rocname().size(); 00221 out.write(rocid_.rocname().c_str(),rocid_.rocname().size()); 00222 00223 out <<analogInputBias_; 00224 out <<analogOutputBias_; 00225 out <<analogOutputGain_; 00226 out << singlemode_; 00227 00228 00229 }
virtual void pos::PixelTBMSettings::writeXML | ( | std::ofstream * | out | ) | const [inline, virtual] |
void pos::PixelTBMSettings::writeXML | ( | pos::PixelConfigKey | key, | |
int | version, | |||
std::string | path | |||
) | const [inline, virtual] |
virtual void pos::PixelTBMSettings::writeXMLHeader | ( | pos::PixelConfigKey | key, | |
int | version, | |||
std::string | path, | |||
std::ofstream * | out | |||
) | const [inline, virtual] |
virtual void pos::PixelTBMSettings::writeXMLTrailer | ( | std::ofstream * | out | ) | const [inline, virtual] |
std::ostream& operator<< | ( | std::ostream & | s, | |
const PixelTBMSettings & | mask | |||
) | [friend] |
Definition at line 321 of file PixelTBMSettings.cc.
00321 { 00322 00323 s << "Module :"<<tbm.rocid_.rocname() <<std::endl; 00324 s << "analogInputBias :"<<tbm.analogInputBias_<<std::endl; 00325 s << "analogOutputBias:"<<tbm.analogOutputBias_<<std::endl; 00326 s << "analogOutputGain:"<<tbm.analogOutputGain_<<std::endl; 00327 if (tbm.singlemode_){ 00328 s << "mode :Singlemode"<<std::endl; 00329 } 00330 else{ 00331 s << "mode :Dualmode"<<std::endl; 00332 } 00333 00334 return s; 00335 00336 }
unsigned char pos::PixelTBMSettings::analogInputBias_ [private] |
Definition at line 76 of file PixelTBMSettings.h.
Referenced by generateConfiguration(), getAnalogInputBias(), pos::operator<<(), PixelTBMSettings(), setAnalogInputBias(), setTBMGenericValue(), writeASCII(), and writeBinary().
unsigned char pos::PixelTBMSettings::analogOutputBias_ [private] |
Definition at line 77 of file PixelTBMSettings.h.
Referenced by generateConfiguration(), getAnalogOutputBias(), pos::operator<<(), PixelTBMSettings(), setAnalogOutputBias(), setTBMGenericValue(), writeASCII(), and writeBinary().
unsigned char pos::PixelTBMSettings::analogOutputGain_ [private] |
Definition at line 78 of file PixelTBMSettings.h.
Referenced by generateConfiguration(), getAnalogOutputGain(), pos::operator<<(), PixelTBMSettings(), setAnalogOutputGain(), setTBMGenericValue(), writeASCII(), and writeBinary().
PixelROCName pos::PixelTBMSettings::rocid_ [private] |
Definition at line 73 of file PixelTBMSettings.h.
Referenced by generateConfiguration(), pos::operator<<(), PixelTBMSettings(), setROCName(), writeASCII(), and writeBinary().
bool pos::PixelTBMSettings::singlemode_ [private] |
Definition at line 79 of file PixelTBMSettings.h.
Referenced by generateConfiguration(), getMode(), pos::operator<<(), PixelTBMSettings(), setMode(), setTBMGenericValue(), writeASCII(), and writeBinary().