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::PixelPortcardMap Class Reference

#include <PixelPortcardMap.h>

Inheritance diagram for pos::PixelPortcardMap:
pos::PixelConfigBase

Public Member Functions

bool getName (std::string moduleName, std::string &portcardName)
 
std::set< PixelModuleNamemodules (std::string portCardName) const
 
int numChannels (const PixelModuleName &aModule)
 
 PixelPortcardMap (std::string filename)
 
 PixelPortcardMap (std::vector< std::vector< std::string > > &tableMat)
 
const std::pair< std::string, int > PortCardAndAOH (const PixelModuleName &aModule, const std::string &TBMChannel) const
 
const std::pair< std::string, int > PortCardAndAOH (const PixelModuleName &aModule, const PixelTBMChannel &TBMChannel) const
 
const std::pair< std::string, int > PortCardAndAOH (const PixelChannel &aChannel) const
 
const std::set< std::pair
< std::string, int > > 
PortCardAndAOHs (const PixelModuleName &aModule) const
 
const std::set< std::string > portcards (const PixelModuleName &aModule) const
 
std::set< std::string > portcards (const PixelDetectorConfig *detconfig=0)
 
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 ~PixelPortcardMap ()
 
- 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::map< PixelChannel,
std::pair< std::string, int > > 
map_
 

Detailed Description

Definition at line 31 of file PixelPortcardMap.h.

Constructor & Destructor Documentation

PixelPortcardMap::PixelPortcardMap ( std::string  filename)

Definition at line 123 of file PixelPortcardMap.cc.

References gather_cfg::cout, recoMuon::in, map_, python.rootplot.argparse::module, pos::PixelModuleName::modulename(), and AlCaHLTBitMon_QueryRunRegistry::string.

123  :
124  PixelConfigBase(" "," "," "){
125 
126  std::string mthn = "[PixelPortcardMap::PixelPortcardMap()]\t\t\t " ;
127  std::ifstream in(filename.c_str());
128 
129  if (!in.good()){
130  std::cout << __LINE__ << "]\t" << mthn << "Could not open: " << filename <<std::endl;
131  throw std::runtime_error("Failed to open file "+filename);
132  }
133  else {
134  std::cout << __LINE__ << "]\t" << mthn << "Reading from: " << filename <<std::endl;
135  }
136 
137  std::string dummy;
138 
139  in >> dummy;
140  in >> dummy;
141  in >> dummy;
142  in >> dummy;
143  in >> dummy;
144 
145  do {
146 
147  std::string portcardname;
148  std::string modulename;
149  std::string TBMChannel = "A";
150  std::string aoh_string;
151  unsigned int aoh;
152 
153  in >> portcardname >> modulename >> aoh_string ;
154  if (aoh_string == "A" || aoh_string == "B") // Optionally, the TBM channel may be specified after the module name. Check for this.
155  {
156  TBMChannel = aoh_string;
157  in >> aoh_string;
158  }
159  aoh = atoi(aoh_string.c_str());
160 
161  if (!in.eof() ){
162  PixelModuleName module(modulename);
163  if (module.modulename()!=modulename){
164  std::cout << __LINE__ << "]\t" << mthn << "Modulename: " << modulename << std::endl;
165  std::cout << __LINE__ << "]\t" << mthn << "Parsed to : " << module.modulename() << std::endl;
166  assert(0);
167  }
168 
169  PixelChannel channel(module, TBMChannel);
170  std::pair<std::string, int> portcardAndAOH(portcardname, aoh);
171  map_[channel] = portcardAndAOH;
172  }
173 
174 
175  }while (!in.eof());
176 }
This class implements..
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:121
std::map< PixelChannel, std::pair< std::string, int > > map_
Definition: vlib.h:209
PixelConfigBase(std::string description, std::string creator, std::string date)
PixelPortcardMap::PixelPortcardMap ( std::vector< std::vector< std::string > > &  tableMat)

Definition at line 19 of file PixelPortcardMap.cc.

References trackerHits::c, gather_cfg::cout, cuy::ins, map_, python.rootplot.argparse::module, pos::PixelModuleName::modulename(), n, alignCSCRings::r, and AlCaHLTBitMon_QueryRunRegistry::string.

19  :PixelConfigBase(" "," "," "){
20 
21  std::string mthn = "[PixelPortcardMap::PixelPortcardMap()]\t\t\t " ;
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: PIXEL_PORTCARD_MAP (VIEW: CONF_KEY_PORTCARD_MAP_V)
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  PORT_CARD NOT NULL VARCHAR2(200)
34  PANEL_NAME NOT NULL VARCHAR2(200)
35  TBM_MODE VARCHAR2(200)
36  AOH_CHAN NOT NULL NUMBER(38)
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("PORT_CARD" );
44  colNames.push_back("PANEL_NAME" );
45  colNames.push_back("TBM_MODE" );
46  colNames.push_back("AOH_CHAN" );
47 /*
48  colNames.push_back("CONFIG_KEY_ID" );
49  colNames.push_back("CONFG_KEY" );
50  colNames.push_back("VERSION" );
51  colNames.push_back("KIND_OF_COND" );
52  colNames.push_back("SERIAL_NUMBER" );
53  colNames.push_back("PORT_CARD" );
54  colNames.push_back("PANEL_NAME" );
55  colNames.push_back("TBM_MODE" );
56  colNames.push_back("AOH_CHAN" );
57  */
58  for(unsigned int c = 0 ; c < ins.size() ; c++)
59  {
60  for(unsigned int n=0; n<colNames.size(); n++)
61  {
62  if(tableMat[0][c] == colNames[n])
63  {
64  colM[colNames[n]] = c;
65  break;
66  }
67  }
68  }//end for
69  /*
70  for(unsigned int n=0; n<colNames.size(); n++)
71  {
72  if(colM.find(colNames[n]) == colM.end())
73  {
74  std::cerr << __LINE__ << "]\t" << mthn
75  << "Couldn't find in the database the column with name " << colNames[n] << std::endl;
76  assert(0);
77  }
78  }
79  */
80 
81 
82  std::string portcardname;
83  std::string modulename;
84  unsigned int aoh;
85  std::string aohstring;
86  std::string tbmChannel;
87 
88  for(unsigned int r = 1 ; r < tableMat.size() ; r++){ //Goes to every row of the Matrix
89 
90  portcardname = tableMat[r][colM["PORT_CARD"]];
91  modulename = tableMat[r][colM["PANEL_NAME"]];
92  aohstring = tableMat[r][colM["AOH_CHAN"]];
93  tbmChannel = tableMat[r][colM["TBM_MODE"]] ;
94 // cout << "[PixelPortcardMap::PixelPortcardMap()]\t\t\t "
95 // << "Portcardname: " << portcardname
96 // << "\tmodulename: " << modulename
97 // << "\taohstring: " << aohstring
98 // << "\ttbmChannel:" << tbmChannel
99 // << endl ;
100  //aohname.erase(0,20); // Is going to be change when Umesh put a AOH Channel column in the view.
101  aoh = (((unsigned int)atoi(aohstring.c_str())));
102  //std::cout<<aoh<<std::endl;
103  PixelModuleName module(modulename);
104  if (module.modulename()!=modulename)
105  {
106  std::cout << __LINE__ << "]\t" << mthn << "Modulename: " << modulename << std::endl;
107  std::cout << __LINE__ << "]\t" << mthn << "Parsed to : " << module.modulename() << std::endl;
108  assert(0);
109  }
110  if(tbmChannel == "")
111  {
112  tbmChannel = "A";// assert(0); // add TBMChannel to the input, then remove assert
113  }
114  PixelChannel channel(module, tbmChannel);
115  std::pair<std::string, int> portcardAndAOH(portcardname, aoh);
116  map_[channel] = portcardAndAOH;
117  }//end for r
118 
119 
120 }//end constructor
tuple ins
Definition: cuy.py:312
This class implements..
tuple cout
Definition: gather_cfg.py:121
std::map< PixelChannel, std::pair< std::string, int > > map_
Definition: vlib.h:209
PixelConfigBase(std::string description, std::string creator, std::string date)
PixelPortcardMap::~PixelPortcardMap ( )
virtual

Definition at line 191 of file PixelPortcardMap.cc.

191 {}

Member Function Documentation

bool PixelPortcardMap::getName ( std::string  moduleName,
std::string &  portcardName 
)

Definition at line 239 of file PixelPortcardMap.cc.

References funct::false, Association::map, map_, and funct::true.

240 {
241  for( std::map< PixelChannel, std::pair<std::string, int> >::const_iterator map_itr = map_.begin(); map_itr != map_.end(); ++map_itr )
242  {
243  if ( map_itr->first.modulename() == moduleName )
244  {
245  portcardName = map_itr->second.first;
246  return true ;
247  }
248  }
249  return false ;
250 }
dictionary map
Definition: Association.py:205
std::map< PixelChannel, std::pair< std::string, int > > map_
std::set< PixelModuleName > PixelPortcardMap::modules ( std::string  portCardName) const

Definition at line 287 of file PixelPortcardMap.cc.

References Association::map, and map_.

288 {
289  std::set< PixelModuleName > returnThis;
290 
291  // Loop over the entire map, searching for elements matching portCardName. Add matching elements to returnThis.
292  for( std::map< PixelChannel, std::pair<std::string, int> >::const_iterator map_itr = map_.begin(); map_itr != map_.end(); ++map_itr )
293  {
294  if ( map_itr->second.first == portCardName )
295  {
296  returnThis.insert(map_itr->first.module());
297  }
298  }
299 
300  return returnThis;
301 }
dictionary map
Definition: Association.py:205
std::map< PixelChannel, std::pair< std::string, int > > map_
int pos::PixelPortcardMap::numChannels ( const PixelModuleName aModule)
inline

Definition at line 47 of file PixelPortcardMap.h.

References PortCardAndAOHs().

47 {return PortCardAndAOHs(aModule).size();}
const std::set< std::pair< std::string, int > > PortCardAndAOHs(const PixelModuleName &aModule) const
const std::pair< std::string, int > PixelPortcardMap::PortCardAndAOH ( const PixelModuleName aModule,
const std::string &  TBMChannel 
) const

Definition at line 268 of file PixelPortcardMap.cc.

Referenced by PortCardAndAOH().

269 {
270  return PortCardAndAOH(PixelChannel(aModule, TBMChannel));
271 }
const std::pair< std::string, int > PortCardAndAOH(const PixelModuleName &aModule, const std::string &TBMChannel) const
const std::pair< std::string, int > PixelPortcardMap::PortCardAndAOH ( const PixelModuleName aModule,
const PixelTBMChannel TBMChannel 
) const

Definition at line 263 of file PixelPortcardMap.cc.

References PortCardAndAOH().

264 {
265  return PortCardAndAOH(PixelChannel(aModule, TBMChannel));
266 }
const std::pair< std::string, int > PortCardAndAOH(const PixelModuleName &aModule, const std::string &TBMChannel) const
const std::pair< std::string, int > PixelPortcardMap::PortCardAndAOH ( const PixelChannel aChannel) const

Definition at line 273 of file PixelPortcardMap.cc.

References newFWLiteAna::found, and map_.

274 {
275  std::map< PixelChannel, std::pair<std::string, int> >::const_iterator found = map_.find(aChannel);
276  if ( found == map_.end() )
277  {
278  std::pair< std::string, int > returnThis("none", 0);
279  return returnThis;
280  }
281  else
282  {
283  return found->second;
284  }
285 }
std::map< PixelChannel, std::pair< std::string, int > > map_
const std::set< std::pair< std::string, int > > PixelPortcardMap::PortCardAndAOHs ( const PixelModuleName aModule) const

Definition at line 222 of file PixelPortcardMap.cc.

References Association::map, map_, and pos::PixelModuleName::modulename().

Referenced by numChannels(), and portcards().

223 {
224  std::set< std::pair< std::string, int > > returnThis;
225 
226  // Loop over the entire map, searching for elements matching PixelModuleName. Add matching elements to returnThis.
227  for( std::map< PixelChannel, std::pair<std::string, int> >::const_iterator map_itr = map_.begin(); map_itr != map_.end(); ++map_itr )
228  {
229  if ( map_itr->first.modulename() == aModule.modulename() )
230  {
231  returnThis.insert(map_itr->second);
232  }
233  }
234 
235  return returnThis;
236 }
dictionary map
Definition: Association.py:205
std::string modulename() const
std::map< PixelChannel, std::pair< std::string, int > > map_
const std::set< std::string > PixelPortcardMap::portcards ( const PixelModuleName aModule) const

Definition at line 252 of file PixelPortcardMap.cc.

References PortCardAndAOHs().

Referenced by pos::PixelCalibConfiguration::getTKFECCrates().

253 {
254  std::set< std::string > returnThis;
255  const std::set< std::pair< std::string, int > > portCardAndAOHs = PortCardAndAOHs(aModule);
256  for ( std::set< std::pair< std::string, int > >::const_iterator portCardAndAOHs_itr = portCardAndAOHs.begin(); portCardAndAOHs_itr != portCardAndAOHs.end(); ++portCardAndAOHs_itr)
257  {
258  returnThis.insert( (*portCardAndAOHs_itr).first );
259  }
260  return returnThis;
261 }
const std::set< std::pair< std::string, int > > PortCardAndAOHs(const PixelModuleName &aModule) const
std::set< std::string > PixelPortcardMap::portcards ( const PixelDetectorConfig detconfig = 0)

Definition at line 303 of file PixelPortcardMap.cc.

References pos::PixelDetectorConfig::getModuleList(), Association::map, and map_.

304 {
305  std::set< std::string > returnThis;
306 
307  if(detconfig != 0){
308 
309  //still done done in an awkward way, but this avoids an
310  //double nested loop that we had in the first implementation
311  const std::vector <PixelModuleName> moduleList=detconfig->getModuleList();
312  std::set< std::string > moduleNames;
313  for(std::vector <PixelModuleName>::const_iterator it=moduleList.begin(), it_end=moduleList.end(); it!=it_end; ++it){
314  moduleNames.insert(it->modulename());
315  }
316 
317  for( std::map< PixelChannel, std::pair<std::string, int> >::const_iterator map_itr = map_.begin(); map_itr != map_.end(); ++map_itr )
318  {
319  if ( moduleNames.find(map_itr->first.modulename()) != moduleNames.end() ){
320  returnThis.insert(map_itr->second.first);
321  }
322  }
323 
324 
325 
326 
327  }
328  else{
329 
330  for( std::map< PixelChannel, std::pair<std::string, int> >::const_iterator map_itr = map_.begin(); map_itr != map_.end(); ++map_itr )
331  {
332 
333  returnThis.insert(map_itr->second.first);
334  }
335 
336  }
337 
338  return returnThis;
339 }
dictionary map
Definition: Association.py:205
const std::vector< PixelModuleName > & getModuleList() const
std::map< PixelChannel, std::pair< std::string, int > > map_
void PixelPortcardMap::writeASCII ( std::string  dir) const
virtual

Implements pos::PixelConfigBase.

Definition at line 194 of file PixelPortcardMap.cc.

References gather_cfg::cout, lut2db_cfg::filename, i, map_, dbtoconf::out, and AlCaHLTBitMon_QueryRunRegistry::string.

194  {
195 
196 
197  std::string mthn = "[PixelPortcardMap::writeASCII()]\t\t\t\t " ;
198  if (dir!="") dir+="/";
199  string filename=dir+"portcardmap.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 <<"# Portcard Module AOH channel" <<endl;
208  std::map< PixelChannel, std::pair<std::string, int> >::const_iterator i=map_.begin();
209  for(;i!=map_.end();++i){
210  out << i->second.first<<" "
211  << i->first.module()<<" "
212  << i->first.TBMChannel()<<" "
213  << i->second.second<<endl;
214  }
215  out.close();
216 
217 
218 }
int i
Definition: DBlmapReader.cc:9
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
std::map< PixelChannel, std::pair< std::string, int > > map_
void pos::PixelPortcardMap::writeXML ( pos::PixelConfigKey  key,
int  version,
std::string  path 
) const
inlinevirtual

Reimplemented from pos::PixelConfigBase.

Definition at line 63 of file PixelPortcardMap.h.

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

Reimplemented from pos::PixelConfigBase.

Definition at line 381 of file PixelPortcardMap.cc.

References i, map_, and AlCaHLTBitMon_QueryRunRegistry::string.

384 {
385  std::string mthn = "[PixelPortcardMap::writeXML()]\t\t\t " ;
386 
387 
388  std::map< PixelChannel, std::pair<std::string, int> >::const_iterator i=map_.begin();
389  for(;i!=map_.end();++i){
390  *outstream << " <DATA>" << std::endl ;
391  *outstream << " <PORT_CARD>" << i->second.first << "</PORT_CARD>" << std::endl ;
392  *outstream << " <PANEL_NAME>" << i->first.module() << "</PANEL_NAME>" << std::endl ;
393  *outstream << " <TBM_MODE>" << i->first.TBMChannel() << "</TBM_MODE>" << std::endl ;
394  *outstream << " <AOH_CHAN>" << i->second.second << "</AOH_CHAN>" << std::endl ;
395  *outstream << " </DATA>" << std::endl ;
396  }
397 }
int i
Definition: DBlmapReader.cc:9
std::map< PixelChannel, std::pair< std::string, int > > map_
void PixelPortcardMap::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 341 of file PixelPortcardMap.cc.

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

347 {
348  std::string mthn = "[PixelPortcardMap::writeXMLHeader()]\t\t\t " ;
349  std::stringstream fullPath ;
350  fullPath << path << "/Pixel_PortCardMap_" << PixelTimeFormatter::getmSecTime() << ".xml" ;
351  std::cout << __LINE__ << "]\t" << mthn << "Writing to: " << fullPath.str() << std::endl ;
352 
353  outstream->open(fullPath.str().c_str()) ;
354 
355  *outstream << "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl ;
356  *outstream << "<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl ;
357  *outstream << " <HEADER>" << std::endl ;
358  *outstream << " <TYPE>" << std::endl ;
359  *outstream << " <EXTENSION_TABLE_NAME>PIXEL_PORTCARD_MAP</EXTENSION_TABLE_NAME>" << std::endl ;
360  *outstream << " <NAME>Pixel Port Card Map</NAME>" << std::endl ;
361  *outstream << " </TYPE>" << std::endl ;
362  *outstream << " <RUN>" << std::endl ;
363  *outstream << " <RUN_TYPE>Pixel Port Card Map</RUN_TYPE>" << std::endl ;
364  *outstream << " <RUN_NUMBER>1</RUN_NUMBER>" << std::endl ;
365  *outstream << " <RUN_BEGIN_TIMESTAMP>" << pos::PixelTimeFormatter::getTime() << "</RUN_BEGIN_TIMESTAMP>" << std::endl ;
366  *outstream << " <LOCATION>CERN P5</LOCATION>" << std::endl ;
367  *outstream << " </RUN>" << std::endl ;
368  *outstream << " </HEADER>" << std::endl ;
369  *outstream << "" << std::endl ;
370  *outstream << " <DATA_SET>" << std::endl ;
371  *outstream << " <PART>" << std::endl ;
372  *outstream << " <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << std::endl ;
373  *outstream << " <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << std::endl ;
374  *outstream << " </PART>" << std::endl ;
375  *outstream << " <VERSION>" << version << "</VERSION>" << std::endl ;
376  *outstream << " <COMMENT_DESCRIPTION>" << getComment() << "</COMMENT_DESCRIPTION>" << std::endl ;
377  *outstream << " <CREATED_BY_USER>" << getAuthor() << "</CREATED_BY_USER>" << std::endl ;
378 }
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 PixelPortcardMap::writeXMLTrailer ( std::ofstream *  out,
std::ofstream *  out1 = NULL,
std::ofstream *  out2 = NULL 
) const
virtual

Reimplemented from pos::PixelConfigBase.

Definition at line 400 of file PixelPortcardMap.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

403 {
404  std::string mthn = "[PixelPortcardMap::writeXMLTrailer()]\t\t\t " ;
405 
406  *outstream << " </DATA_SET>" << std::endl ;
407  *outstream << "</ROOT> " << std::endl ;
408 
409  outstream->close() ;
410 }

Member Data Documentation

std::map< PixelChannel, std::pair<std::string, int> > pos::PixelPortcardMap::map_
private