CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
pos::PixelFEDConfig Class Reference

This is the documentation about PixelFEDConfig... More...

#include <PixelFEDConfig.h>

Inheritance diagram for pos::PixelFEDConfig:
pos::PixelConfigBase

Public Member Functions

unsigned int crateFromFEDNumber (unsigned int fednumber) const
 
unsigned int FEDNumberFromCrateAndVMEBaseAddress (unsigned int crate, unsigned int vmebaseaddress) const
 
unsigned int getCrate (unsigned int i) const
 
unsigned int getFEDNumber (unsigned int i) const
 
unsigned int getNFEDBoards () const
 
unsigned int getVMEBaseAddress (unsigned int i) const
 
 PixelFEDConfig (std::string filename)
 
 PixelFEDConfig (std::vector< std::vector< std::string > > &tableMat)
 
unsigned int VMEBaseAddressFromFEDNumber (unsigned int fednumber) const
 
virtual void writeASCII (std::string dir) const
 
void writeXML (pos::PixelConfigKey key, int version, std::string path) const
 
virtual void writeXML (std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) const
 
virtual void writeXMLHeader (pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) const
 
virtual void writeXMLTrailer (std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) const
 
virtual ~PixelFEDConfig ()
 
- Public Member Functions inherited from pos::PixelConfigBase
std::string creator ()
 
std::string date ()
 
std::string description ()
 
std::string getAuthor () const
 
std::string getComment () const
 
 PixelConfigBase (std::string description, std::string creator, std::string date)
 
void setAuthor (std::string author)
 
void setComment (std::string comment)
 
virtual void writeXML (std::ofstream *out) const
 
virtual void writeXMLHeader (pos::PixelConfigKey key, int version, std::string path, std::ofstream *out) const
 
virtual void writeXMLTrailer (std::ofstream *out) const
 
virtual ~PixelConfigBase ()
 

Private Attributes

std::vector< PixelFEDParametersfedconfig_
 

Detailed Description

This is the documentation about PixelFEDConfig...

" "

This class specifies which FED boards are used and how they are addressed

Definition at line 27 of file PixelFEDConfig.h.

Constructor & Destructor Documentation

PixelFEDConfig::PixelFEDConfig ( std::string  filename)

Definition at line 137 of file PixelFEDConfig.cc.

References gather_cfg::cout, TauDecayModes::dec, fedconfig_, recoMuon::in, pos::PixelFEDParameters::setFEDParameters(), AlCaHLTBitMon_QueryRunRegistry::string, and tmp.

137  :
138  PixelConfigBase(" "," "," "){
139 
140  std::string mthn = "[PixelFEDConfig::PixelFEDConfig()]\t\t\t " ;
141  std::ifstream in(filename.c_str());
142 
143  if (!in.good()){
144  std::cout << __LINE__ << "]\t" << mthn << "Could not open: " << filename.c_str() << std::endl;
145  throw std::runtime_error("Failed to open file "+filename);
146  }
147  else {
148  std::cout << __LINE__ << "]\t" << mthn << "Opened: " << filename.c_str() << std::endl;
149  }
150 
151  std::string dummy;
152 
153  in >> dummy;
154  in >> dummy;
155  in >> dummy;
156  in >> dummy;
157  in >> dummy;
158  in >> dummy;
159 
160  do {
161 
162  unsigned int fednumber;
163  unsigned int crate;
164  unsigned int vme_base_address;
165 
166  in >> fednumber >> crate >> std::hex >> vme_base_address >> std::dec;
167 
168  if (!in.eof() ){
169  // std::cout << __LINE__ << "]\t" << mthn << std::dec << fednumber <<" "<< crate << " 0x"
170  // << std::hex << vme_base_address<<std::dec<<std::endl;
172 
173  tmp.setFEDParameters(fednumber , crate , vme_base_address);
174 
175  fedconfig_.push_back(tmp);
176  }
177 
178  }
179  while (!in.eof());
180  in.close();
181 
182  }
void setFEDParameters(unsigned int fednumber, unsigned int crate, unsigned int vmebaseaddress)
std::vector< PixelFEDParameters > fedconfig_
This class implements..
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:121
PixelConfigBase(std::string description, std::string creator, std::string date)
PixelFEDConfig::PixelFEDConfig ( std::vector< std::vector< std::string > > &  tableMat)

Definition at line 18 of file PixelFEDConfig.cc.

References EnergyCorrector::c, fedconfig_, getFEDNumber(), cuy::ins, gen::n, alignCSCRings::r, pos::PixelFEDParameters::setFEDParameters(), AlCaHLTBitMon_QueryRunRegistry::string, and tmp.

18  : PixelConfigBase(" "," "," "){
19 
20  std::string mthn = "[PixelFEDConfig::PixelFEDConfig()]\t\t\t " ;
21 
22  std::vector< std::string > ins = tableMat[0];
23  std::map<std::string , int > colM;
24  std::vector<std::string > colNames;
25 /*
26  EXTENSION_TABLE_NAME: FED_CRATE_CONFIG (VIEW: CONF_KEY_FED_CRATE_CONFIGV)
27 
28  CONFIG_KEY NOT NULL VARCHAR2(80)
29  KEY_TYPE NOT NULL VARCHAR2(80)
30  KEY_ALIAS NOT NULL VARCHAR2(80)
31  VERSION VARCHAR2(40)
32  KIND_OF_COND NOT NULL VARCHAR2(40)
33  PIXEL_FED NOT NULL NUMBER(38)
34  CRATE_NUMBER NOT NULL NUMBER(38)
35  VME_ADDR NOT NULL VARCHAR2(200)
36 */
37 
38  colNames.push_back("CONFIG_KEY" );
39  colNames.push_back("KEY_TYPE" );
40  colNames.push_back("KEY_ALIAS" );
41  colNames.push_back("VERSION" );
42  colNames.push_back("KIND_OF_COND" );
43  colNames.push_back("PIXEL_FED" );
44  colNames.push_back("CRATE_NUMBER" );
45  colNames.push_back("VME_ADDR" );
46 /*
47  colNames.push_back("PIXEL_FED" ); //0
48  colNames.push_back("CRATE_NUMBER" ); //1
49  colNames.push_back("VME_ADDRS_HEX"); //2
50 */
51  for(unsigned int c = 0 ; c < tableMat[0].size() ; c++)
52  {
53  for(unsigned int n=0; n<colNames.size(); n++)
54  {
55  if(tableMat[0][c] == colNames[n])
56  {
57  colM[colNames[n]] = c;
58  break;
59  }
60  }
61  }//end for
62  /*
63  for(unsigned int n=0; n<colNames.size(); n++)
64  {
65  if(colM.find(colNames[n]) == colM.end())
66  {
67  std::cerr << __LINE__ << "]\t" << mthn << "Couldn't find in the database the column with name " << colNames[n] << std::endl;
68  assert(0);
69  }
70  }
71  */
72 
73  std::string fedname = "";
74  unsigned int fednum = 0;
75  fedconfig_.clear();
76  bool flag = false;
77  for(unsigned int r = 1 ; r < tableMat.size() ; r++){ //Goes to every row of the Matrix
78 
79  fedname = tableMat[r][colM["PIXEL_FED"]]; //This is not going to work if you change in the database "PxlFed_#" in the FED column.Im removing "PlxFed_" and store the number
80  //becuase the PixelFecConfig class ask for the fec number not the name.
81  // 01234567
82  // PxlFED_XX
83 // fedname.erase(0,7);
84  fednum = (unsigned int)atoi(fedname.c_str()) ;
85 
86  if(fedconfig_.empty())
87  {
89  unsigned int vme_base_address = 0 ;
90  vme_base_address = strtoul(tableMat[r][colM["VME_ADDR"]].c_str(), 0, 16);
91 // string hexVMEAddr = tableMat[r][colM["VME_ADDRS_HEX"]] ;
92 // sscanf(hexVMEAddr.c_str(), "%x", &vme_base_address) ;
93  tmp.setFEDParameters( fednum, (unsigned int)atoi(tableMat[r][colM["CRATE_NUMBER"]].c_str()) ,
94  vme_base_address);
95  fedconfig_.push_back(tmp);
96  }
97  else
98  {
99  for( unsigned int y = 0; y < fedconfig_.size() ; y++)
100  {
101  if (fedconfig_[y].getFEDNumber() == fednum) // This is to check if there are Pixel Feds already in the vector because
102  { // in the view of the database that I'm reading there are many repeated entries (AS FAR AS THESE PARAMS ARE CONCERNED).
103  flag = true; // This ensure that there are no objects in the fedconfig vector with repeated values.
104  break;
105  }
106  else flag = false;
107  }
108 
109  if(flag == false)
110  {
112  tmp.setFEDParameters( fednum, (unsigned int)atoi(tableMat[r][colM["CRATE_NUMBER"]].c_str()) ,
113  (unsigned int)strtoul(tableMat[r][colM["VME_ADDR"]].c_str(), 0, 16));
114  fedconfig_.push_back(tmp);
115  }
116  }//end else
117  }//end for r
118 /*
119  std::cout << __LINE__ << "]\t" << mthn << std::endl;
120 
121  for( unsigned int x = 0 ; x < fedconfig_.size() ; x++)
122  {
123  std::cout<< __LINE__ << "]\t" << mthn << fedconfig_[x] << std::endl;
124  }
125 
126  std::cout<< __LINE__ << "]\t" << mthn << fedconfig_.size() << std::endl;
127 */
128 }//end Constructor
void setFEDParameters(unsigned int fednumber, unsigned int crate, unsigned int vmebaseaddress)
std::vector< PixelFEDParameters > fedconfig_
unsigned int getFEDNumber(unsigned int i) const
tuple ins
Definition: cuy.py:312
This class implements..
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
PixelConfigBase(std::string description, std::string creator, std::string date)
PixelFEDConfig::~PixelFEDConfig ( )
virtual

Definition at line 193 of file PixelFEDConfig.cc.

193 {}

Member Function Documentation

unsigned int PixelFEDConfig::crateFromFEDNumber ( unsigned int  fednumber) const

Definition at line 247 of file PixelFEDConfig.cc.

References assert(), gather_cfg::cout, fedconfig_, getCrate(), getFEDNumber(), i, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by pos::PixelCalibConfiguration::fedCardsAndChannels(), and pos::PixelCalibConfiguration::getFEDCrates().

247  {
248 
249 
250  std::string mthn = "[PixelFEDConfig::crateFromFEDNumber()]\t\t\t " ;
251  for(unsigned int i=0;i<fedconfig_.size();i++){
252  if (fedconfig_[i].getFEDNumber()==fednumber) return fedconfig_[i].getCrate();
253  }
254 
255  std::cout << __LINE__ << "]\t" << mthn << "Could not find FED number: " << fednumber << std::endl;
256 
257  assert(0);
258 
259  return 0;
260 
261 }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
std::vector< PixelFEDParameters > fedconfig_
unsigned int getFEDNumber(unsigned int i) const
unsigned int getCrate(unsigned int i) const
tuple cout
Definition: gather_cfg.py:121
unsigned int PixelFEDConfig::FEDNumberFromCrateAndVMEBaseAddress ( unsigned int  crate,
unsigned int  vmebaseaddress 
) const

Definition at line 279 of file PixelFEDConfig.cc.

References assert(), gather_cfg::cout, fedconfig_, getCrate(), getFEDNumber(), i, and AlCaHLTBitMon_QueryRunRegistry::string.

279  {
280 
281  std::string mthn = "[PixelFEDConfig::FEDNumberFromCrateAndVMEBaseAddress()]\t " ;
282  for(unsigned int i=0;i<fedconfig_.size();i++){
283  if (fedconfig_[i].getCrate()==crate&&
284  fedconfig_[i].getVMEBaseAddress()==vmebaseaddress) return fedconfig_[i].getFEDNumber();
285  }
286 
287  std::cout << __LINE__ << "]\t" << mthn << "Could not find FED crate and address: "<< crate << ", " << vmebaseaddress << std::endl;
288 
289  assert(0);
290 
291  return 0;
292 
293 }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
std::vector< PixelFEDParameters > fedconfig_
unsigned int getFEDNumber(unsigned int i) const
unsigned int getCrate(unsigned int i) const
tuple cout
Definition: gather_cfg.py:121
unsigned int PixelFEDConfig::getCrate ( unsigned int  i) const

Definition at line 231 of file PixelFEDConfig.cc.

References assert(), fedconfig_, and i.

Referenced by crateFromFEDNumber(), and FEDNumberFromCrateAndVMEBaseAddress().

231  {
232 
233  assert(i<fedconfig_.size());
234  return fedconfig_[i].getCrate();
235 
236 }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
std::vector< PixelFEDParameters > fedconfig_
unsigned int PixelFEDConfig::getFEDNumber ( unsigned int  i) const

Definition at line 223 of file PixelFEDConfig.cc.

References assert(), fedconfig_, and i.

Referenced by crateFromFEDNumber(), FEDNumberFromCrateAndVMEBaseAddress(), PixelFEDConfig(), and VMEBaseAddressFromFEDNumber().

223  {
224 
225  assert(i<fedconfig_.size());
226  return fedconfig_[i].getFEDNumber();
227 
228 }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
std::vector< PixelFEDParameters > fedconfig_
unsigned int PixelFEDConfig::getNFEDBoards ( ) const

Definition at line 217 of file PixelFEDConfig.cc.

References fedconfig_.

217  {
218 
219  return fedconfig_.size();
220 
221 }
std::vector< PixelFEDParameters > fedconfig_
unsigned int PixelFEDConfig::getVMEBaseAddress ( unsigned int  i) const

Definition at line 239 of file PixelFEDConfig.cc.

References assert(), fedconfig_, and i.

Referenced by VMEBaseAddressFromFEDNumber().

239  {
240 
241  assert(i<fedconfig_.size());
242  return fedconfig_[i].getVMEBaseAddress();
243 
244 }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
std::vector< PixelFEDParameters > fedconfig_
unsigned int PixelFEDConfig::VMEBaseAddressFromFEDNumber ( unsigned int  fednumber) const

Definition at line 264 of file PixelFEDConfig.cc.

References assert(), gather_cfg::cout, fedconfig_, getFEDNumber(), getVMEBaseAddress(), i, and AlCaHLTBitMon_QueryRunRegistry::string.

264  {
265 
266  std::string mthn = "[PixelFEDConfig::VMEBaseAddressFromFEDNumber()]\t\t " ;
267  for(unsigned int i=0;i<fedconfig_.size();i++){
268  if (fedconfig_[i].getFEDNumber()==fednumber) return fedconfig_[i].getVMEBaseAddress();
269  }
270 
271  std::cout << __LINE__ << "]\t" << mthn << "Could not find FED number: " << fednumber << std::endl;
272 
273  assert(0);
274 
275  return 0;
276 
277 }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
std::vector< PixelFEDParameters > fedconfig_
unsigned int getFEDNumber(unsigned int i) const
unsigned int getVMEBaseAddress(unsigned int i) const
tuple cout
Definition: gather_cfg.py:121
void PixelFEDConfig::writeASCII ( std::string  dir) const
virtual

Implements pos::PixelConfigBase.

Definition at line 195 of file PixelFEDConfig.cc.

References assert(), gather_cfg::cout, TauDecayModes::dec, fedconfig_, lut2db_cfg::filename, i, dbtoconf::out, and AlCaHLTBitMon_QueryRunRegistry::string.

195  {
196 
197  std::string mthn = "[PixelFEDConfig::writeASCII()]\t\t\t\t " ;
198  if (dir!="") dir+="/";
199  string filename=dir+"fedconfig.dat";
200 
201  ofstream out(filename.c_str());
202  if(!out.good()){
203  cout << __LINE__ << "]\t" << mthn << "Could not open file: " << filename << endl;
204  assert(0);
205  }
206 
207  out <<" #FED number crate vme base address" <<endl;
208  for(unsigned int i=0;i<fedconfig_.size();i++){
209  out << fedconfig_[i].getFEDNumber()<<" "
210  << fedconfig_[i].getCrate()<<" "
211  << "0x"<<hex<<fedconfig_[i].getVMEBaseAddress()<<dec<<endl;
212  }
213  out.close();
214 }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
std::vector< PixelFEDParameters > fedconfig_
tuple out
Definition: dbtoconf.py:99
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:121
dbl *** dir
Definition: mlp_gen.cc:35
void pos::PixelFEDConfig::writeXML ( pos::PixelConfigKey  key,
int  version,
std::string  path 
) const
inlinevirtual

Reimplemented from pos::PixelConfigBase.

Definition at line 48 of file PixelFEDConfig.h.

48 {;}
void PixelFEDConfig::writeXML ( std::ofstream *  out,
std::ofstream *  out1 = NULL,
std::ofstream *  out2 = NULL 
) const
virtual

Reimplemented from pos::PixelConfigBase.

Definition at line 335 of file PixelFEDConfig.cc.

References TauDecayModes::dec, fedconfig_, i, and AlCaHLTBitMon_QueryRunRegistry::string.

338 {
339  std::string mthn = "[PixelFEDConfig::writeXML()]\t\t\t " ;
340 
341  for(unsigned int i=0;i<fedconfig_.size();i++){
342  *outstream << " <DATA>" << endl ;
343  *outstream << " <PIXEL_FED>" << fedconfig_[i].getFEDNumber() << "</PIXEL_FED>" << endl ;
344  *outstream << " <CRATE_NUMBER>" << fedconfig_[i].getCrate() << "</CRATE_NUMBER>" << endl ;
345  *outstream << " <VME_ADDR>" << "0x" << hex << fedconfig_[i].getVMEBaseAddress() << dec << "</VME_ADDR>" << endl ;
346  *outstream << " </DATA>" << endl ;
347  *outstream << "" << endl ;
348  }
349 
350 }
int i
Definition: DBlmapReader.cc:9
std::vector< PixelFEDParameters > fedconfig_
void PixelFEDConfig::writeXMLHeader ( pos::PixelConfigKey  key,
int  version,
std::string  path,
std::ofstream *  out,
std::ofstream *  out1 = NULL,
std::ofstream *  out2 = NULL 
) const
virtual

Reimplemented from pos::PixelConfigBase.

Definition at line 296 of file PixelFEDConfig.cc.

References gather_cfg::cout, contentValuesFiles::fullPath, pos::PixelConfigBase::getAuthor(), pos::PixelConfigBase::getComment(), pos::PixelTimeFormatter::getmSecTime(), pos::PixelTimeFormatter::getTime(), and AlCaHLTBitMon_QueryRunRegistry::string.

302 {
303  std::string mthn = "[PixelFEDConfig::::writeXMLHeader()]\t\t\t " ;
304  std::stringstream fullPath ;
305  fullPath << path << "/Pixel_FedCrateConfig_" << PixelTimeFormatter::getmSecTime() << ".xml" ;
306  cout << __LINE__ << "]\t" << mthn << "Writing to: " << fullPath.str() << endl ;
307 
308  outstream->open(fullPath.str().c_str()) ;
309  *outstream << "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << endl ;
310  *outstream << "<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << endl ;
311  *outstream << " <HEADER>" << endl ;
312  *outstream << " <TYPE>" << endl ;
313  *outstream << " <EXTENSION_TABLE_NAME>FED_CRATE_CONFIG</EXTENSION_TABLE_NAME>" << endl ;
314  *outstream << " <NAME>Pixel FED Crate Configuration</NAME>" << endl ;
315  *outstream << " </TYPE>" << endl ;
316  *outstream << " <RUN>" << endl ;
317  *outstream << " <RUN_NAME>Pixel FED Crate Configuration</RUN_NAME>" << endl ;
318  *outstream << " <RUN_BEGIN_TIMESTAMP>" << pos::PixelTimeFormatter::getTime() << "</RUN_BEGIN_TIMESTAMP>" << endl ;
319  *outstream << " <LOCATION>CERN P5</LOCATION>" << endl ;
320  *outstream << " </RUN>" << endl ;
321  *outstream << " </HEADER>" << endl ;
322  *outstream << " " << endl ;
323  *outstream << " <DATA_SET>" << endl ;
324  *outstream << " <PART>" << endl ;
325  *outstream << " <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << endl ;
326  *outstream << " <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << endl ;
327  *outstream << " </PART>" << endl ;
328  *outstream << " <VERSION>" << version << "</VERSION>" << endl ;
329  *outstream << " <COMMENT_DESCRIPTION>" << getComment() << "</COMMENT_DESCRIPTION>" << endl ;
330  *outstream << " <CREATED_BY_USER>" << getAuthor() << "</CREATED_BY_USER>" << endl ;
331  *outstream << " " << endl ;
332 }
static std::string getmSecTime(void)
static std::string getTime(void)
std::string getComment() const
std::string getAuthor() const
tuple cout
Definition: gather_cfg.py:121
void PixelFEDConfig::writeXMLTrailer ( std::ofstream *  out,
std::ofstream *  out1 = NULL,
std::ofstream *  out2 = NULL 
) const
virtual

Reimplemented from pos::PixelConfigBase.

Definition at line 353 of file PixelFEDConfig.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

356 {
357  std::string mthn = "[PixelFEDConfig::writeXMLTrailer()]\t\t\t " ;
358 
359  *outstream << " </DATA_SET>" << endl ;
360  *outstream << "</ROOT> " << endl ;
361 
362  outstream->close() ;
363 }

Member Data Documentation

std::vector< PixelFEDParameters > pos::PixelFEDConfig::fedconfig_
private