CMS 3D CMS Logo

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=nullptr)
 
void writeASCII (std::string dir) const override
 
void writeXML (pos::PixelConfigKey key, int version, std::string path) const override
 
void writeXML (std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
 
void writeXMLHeader (pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
 
void writeXMLTrailer (std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
 
 ~PixelPortcardMap () override
 
- 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() [1/2]

PixelPortcardMap::PixelPortcardMap ( std::string  filename)

Definition at line 115 of file PixelPortcardMap.cc.

References cms::cuda::assert(), gather_cfg::cout, corrVsCorr::filename, recoMuon::in, map_, callgraph::module, and AlCaHLTBitMon_QueryRunRegistry::string.

115  : PixelConfigBase(" ", " ", " ") {
116  std::string mthn = "[PixelPortcardMap::PixelPortcardMap()]\t\t\t ";
117  std::ifstream in(filename.c_str());
118 
119  if (!in.good()) {
120  std::cout << __LINE__ << "]\t" << mthn << "Could not open: " << filename << std::endl;
121  throw std::runtime_error("Failed to open file " + filename);
122  } else {
123  std::cout << __LINE__ << "]\t" << mthn << "Reading from: " << filename << std::endl;
124  }
125 
127 
128  in >> dummy;
129  in >> dummy;
130  in >> dummy;
131  in >> dummy;
132  in >> dummy;
133 
134  do {
135  std::string portcardname;
136  std::string modulename;
137  std::string TBMChannel = "A";
138  std::string aoh_string;
139  unsigned int aoh;
140 
141  in >> portcardname >> modulename >> aoh_string;
142  if (aoh_string == "A" ||
143  aoh_string == "B") // Optionally, the TBM channel may be specified after the module name. Check for this.
144  {
145  TBMChannel = aoh_string;
146  in >> aoh_string;
147  }
148  aoh = atoi(aoh_string.c_str());
149 
150  if (!in.eof()) {
151  PixelModuleName module(modulename);
152  if (module.modulename() != modulename) {
153  std::cout << __LINE__ << "]\t" << mthn << "Modulename: " << modulename << std::endl;
154  std::cout << __LINE__ << "]\t" << mthn << "Parsed to : " << module.modulename() << std::endl;
155  assert(0);
156  }
157 
158  PixelChannel channel(module, TBMChannel);
159  std::pair<std::string, int> portcardAndAOH(portcardname, aoh);
160  map_[channel] = portcardAndAOH;
161  }
162 
163  } while (!in.eof());
164 }
assert(be >=bs)
This class implements..
std::map< PixelChannel, std::pair< std::string, int > > map_
PixelConfigBase(std::string description, std::string creator, std::string date)

◆ PixelPortcardMap() [2/2]

PixelPortcardMap::PixelPortcardMap ( std::vector< std::vector< std::string > > &  tableMat)

Definition at line 19 of file PixelPortcardMap.cc.

References cms::cuda::assert(), c, gather_cfg::cout, cuy::ins, createfilelist::int, map_, callgraph::module, dqmiodumpmetadata::n, alignCSCRings::r, and AlCaHLTBitMon_QueryRunRegistry::string.

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

◆ ~PixelPortcardMap()

PixelPortcardMap::~PixelPortcardMap ( )
override

Definition at line 178 of file PixelPortcardMap.cc.

178 {}

Member Function Documentation

◆ getName()

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

Definition at line 217 of file PixelPortcardMap.cc.

References genParticles_cff::map, map_, and EcalCalibMonitorClient_cfi::moduleName.

Referenced by plotting.Plot::draw().

217  {
218  for (std::map<PixelChannel, std::pair<std::string, int> >::const_iterator map_itr = map_.begin();
219  map_itr != map_.end();
220  ++map_itr) {
221  if (map_itr->first.modulename() == moduleName) {
222  portcardName = map_itr->second.first;
223  return true;
224  }
225  }
226  return false;
227 }
std::map< PixelChannel, std::pair< std::string, int > > map_

◆ modules()

std::set< PixelModuleName > PixelPortcardMap::modules ( std::string  portCardName) const

Definition at line 260 of file PixelPortcardMap.cc.

References genParticles_cff::map, and map_.

260  {
261  std::set<PixelModuleName> returnThis;
262 
263  // Loop over the entire map, searching for elements matching portCardName. Add matching elements to returnThis.
264  for (std::map<PixelChannel, std::pair<std::string, int> >::const_iterator map_itr = map_.begin();
265  map_itr != map_.end();
266  ++map_itr) {
267  if (map_itr->second.first == portCardName) {
268  returnThis.insert(map_itr->first.module());
269  }
270  }
271 
272  return returnThis;
273 }
std::map< PixelChannel, std::pair< std::string, int > > map_

◆ numChannels()

int pos::PixelPortcardMap::numChannels ( const PixelModuleName aModule)
inline

Definition at line 45 of file PixelPortcardMap.h.

References PortCardAndAOHs().

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

◆ PortCardAndAOH() [1/3]

const std::pair< std::string, int > PixelPortcardMap::PortCardAndAOH ( const PixelModuleName aModule,
const std::string &  TBMChannel 
) const

Definition at line 245 of file PixelPortcardMap.cc.

Referenced by PortCardAndAOH().

246  {
247  return PortCardAndAOH(PixelChannel(aModule, TBMChannel));
248 }
const std::pair< std::string, int > PortCardAndAOH(const PixelModuleName &aModule, const std::string &TBMChannel) const

◆ PortCardAndAOH() [2/3]

const std::pair< std::string, int > PixelPortcardMap::PortCardAndAOH ( const PixelModuleName aModule,
const PixelTBMChannel TBMChannel 
) const

Definition at line 240 of file PixelPortcardMap.cc.

References PortCardAndAOH().

241  {
242  return PortCardAndAOH(PixelChannel(aModule, TBMChannel));
243 }
const std::pair< std::string, int > PortCardAndAOH(const PixelModuleName &aModule, const std::string &TBMChannel) const

◆ PortCardAndAOH() [3/3]

const std::pair< std::string, int > PixelPortcardMap::PortCardAndAOH ( const PixelChannel aChannel) const

Definition at line 250 of file PixelPortcardMap.cc.

References newFWLiteAna::found, and map_.

250  {
251  std::map<PixelChannel, std::pair<std::string, int> >::const_iterator found = map_.find(aChannel);
252  if (found == map_.end()) {
253  std::pair<std::string, int> returnThis("none", 0);
254  return returnThis;
255  } else {
256  return found->second;
257  }
258 }
std::map< PixelChannel, std::pair< std::string, int > > map_

◆ PortCardAndAOHs()

const std::set< std::pair< std::string, int > > PixelPortcardMap::PortCardAndAOHs ( const PixelModuleName aModule) const

Definition at line 201 of file PixelPortcardMap.cc.

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

Referenced by numChannels(), and portcards().

201  {
202  std::set<std::pair<std::string, int> > returnThis;
203 
204  // Loop over the entire map, searching for elements matching PixelModuleName. Add matching elements to returnThis.
205  for (std::map<PixelChannel, std::pair<std::string, int> >::const_iterator map_itr = map_.begin();
206  map_itr != map_.end();
207  ++map_itr) {
208  if (map_itr->first.modulename() == aModule.modulename()) {
209  returnThis.insert(map_itr->second);
210  }
211  }
212 
213  return returnThis;
214 }
std::string modulename() const
std::map< PixelChannel, std::pair< std::string, int > > map_

◆ portcards() [1/2]

const std::set< std::string > PixelPortcardMap::portcards ( const PixelModuleName aModule) const

Definition at line 229 of file PixelPortcardMap.cc.

References PortCardAndAOHs().

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

229  {
230  std::set<std::string> returnThis;
231  const std::set<std::pair<std::string, int> > portCardAndAOHs = PortCardAndAOHs(aModule);
232  for (std::set<std::pair<std::string, int> >::const_iterator portCardAndAOHs_itr = portCardAndAOHs.begin();
233  portCardAndAOHs_itr != portCardAndAOHs.end();
234  ++portCardAndAOHs_itr) {
235  returnThis.insert((*portCardAndAOHs_itr).first);
236  }
237  return returnThis;
238 }
const std::set< std::pair< std::string, int > > PortCardAndAOHs(const PixelModuleName &aModule) const

◆ portcards() [2/2]

std::set< std::string > PixelPortcardMap::portcards ( const PixelDetectorConfig detconfig = nullptr)

Definition at line 275 of file PixelPortcardMap.cc.

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

275  {
276  std::set<std::string> returnThis;
277 
278  if (detconfig != nullptr) {
279  //still done done in an awkward way, but this avoids an
280  //double nested loop that we had in the first implementation
281  const std::vector<PixelModuleName> &moduleList = detconfig->getModuleList();
282  std::set<std::string> moduleNames;
283  for (std::vector<PixelModuleName>::const_iterator it = moduleList.begin(), it_end = moduleList.end(); it != it_end;
284  ++it) {
285  moduleNames.insert(it->modulename());
286  }
287 
288  for (std::map<PixelChannel, std::pair<std::string, int> >::const_iterator map_itr = map_.begin();
289  map_itr != map_.end();
290  ++map_itr) {
291  if (moduleNames.find(map_itr->first.modulename()) != moduleNames.end()) {
292  returnThis.insert(map_itr->second.first);
293  }
294  }
295 
296  } else {
297  for (std::map<PixelChannel, std::pair<std::string, int> >::const_iterator map_itr = map_.begin();
298  map_itr != map_.end();
299  ++map_itr) {
300  returnThis.insert(map_itr->second.first);
301  }
302  }
303 
304  return returnThis;
305 }
const std::vector< PixelModuleName > & getModuleList() const
std::map< PixelChannel, std::pair< std::string, int > > map_

◆ writeASCII()

void PixelPortcardMap::writeASCII ( std::string  dir) const
overridevirtual

Implements pos::PixelConfigBase.

Definition at line 180 of file PixelPortcardMap.cc.

References cms::cuda::assert(), gather_cfg::cout, DeadROC_duringRun::dir, corrVsCorr::filename, mps_fire::i, map_, MillePedeFileConverter_cfg::out, and AlCaHLTBitMon_QueryRunRegistry::string.

180  {
181  std::string mthn = "[PixelPortcardMap::writeASCII()]\t\t\t\t ";
182  if (!dir.empty())
183  dir += "/";
184  string filename = dir + "portcardmap.dat";
185 
186  ofstream out(filename.c_str());
187  if (!out.good()) {
188  cout << __LINE__ << "]\t" << mthn << "Could not open file: " << filename << endl;
189  assert(0);
190  }
191 
192  out << "# Portcard Module AOH channel" << endl;
193  std::map<PixelChannel, std::pair<std::string, int> >::const_iterator i = map_.begin();
194  for (; i != map_.end(); ++i) {
195  out << i->second.first << " " << i->first.module() << " " << i->first.TBMChannel() << " "
196  << i->second.second << endl;
197  }
198  out.close();
199 }
assert(be >=bs)
std::map< PixelChannel, std::pair< std::string, int > > map_

◆ writeXML() [1/2]

void pos::PixelPortcardMap::writeXML ( pos::PixelConfigKey  key,
int  version,
std::string  path 
) const
inlineoverridevirtual

Reimplemented from pos::PixelConfigBase.

Definition at line 63 of file PixelPortcardMap.h.

63 { ; }

◆ writeXML() [2/2]

void PixelPortcardMap::writeXML ( std::ofstream *  out,
std::ofstream *  out1 = nullptr,
std::ofstream *  out2 = nullptr 
) const
overridevirtual

Reimplemented from pos::PixelConfigBase.

Definition at line 347 of file PixelPortcardMap.cc.

References mps_fire::i, map_, and AlCaHLTBitMon_QueryRunRegistry::string.

347  {
348  std::string mthn = "[PixelPortcardMap::writeXML()]\t\t\t ";
349 
350  std::map<PixelChannel, std::pair<std::string, int> >::const_iterator i = map_.begin();
351  for (; i != map_.end(); ++i) {
352  *outstream << " <DATA>" << std::endl;
353  *outstream << " <PORT_CARD>" << i->second.first << "</PORT_CARD>" << std::endl;
354  *outstream << " <PANEL_NAME>" << i->first.module() << "</PANEL_NAME>" << std::endl;
355  *outstream << " <TBM_MODE>" << i->first.TBMChannel() << "</TBM_MODE>" << std::endl;
356  *outstream << " <AOH_CHAN>" << i->second.second << "</AOH_CHAN>" << std::endl;
357  *outstream << " </DATA>" << std::endl;
358  }
359 }
std::map< PixelChannel, std::pair< std::string, int > > map_

◆ writeXMLHeader()

void PixelPortcardMap::writeXMLHeader ( pos::PixelConfigKey  key,
int  version,
std::string  path,
std::ofstream *  out,
std::ofstream *  out1 = nullptr,
std::ofstream *  out2 = nullptr 
) const
overridevirtual

Reimplemented from pos::PixelConfigBase.

Definition at line 307 of file PixelPortcardMap.cc.

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

312  {
313  std::string mthn = "[PixelPortcardMap::writeXMLHeader()]\t\t\t ";
314  std::stringstream fullPath;
315  fullPath << path << "/Pixel_PortCardMap_" << PixelTimeFormatter::getmSecTime() << ".xml";
316  std::cout << __LINE__ << "]\t" << mthn << "Writing to: " << fullPath.str() << std::endl;
317 
318  outstream->open(fullPath.str().c_str());
319 
320  *outstream << "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl;
321  *outstream << "<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl;
322  *outstream << " <HEADER>" << std::endl;
323  *outstream << " <TYPE>" << std::endl;
324  *outstream << " <EXTENSION_TABLE_NAME>PIXEL_PORTCARD_MAP</EXTENSION_TABLE_NAME>" << std::endl;
325  *outstream << " <NAME>Pixel Port Card Map</NAME>" << std::endl;
326  *outstream << " </TYPE>" << std::endl;
327  *outstream << " <RUN>" << std::endl;
328  *outstream << " <RUN_TYPE>Pixel Port Card Map</RUN_TYPE>" << std::endl;
329  *outstream << " <RUN_NUMBER>1</RUN_NUMBER>" << std::endl;
330  *outstream << " <RUN_BEGIN_TIMESTAMP>" << pos::PixelTimeFormatter::getTime() << "</RUN_BEGIN_TIMESTAMP>"
331  << std::endl;
332  *outstream << " <LOCATION>CERN P5</LOCATION>" << std::endl;
333  *outstream << " </RUN>" << std::endl;
334  *outstream << " </HEADER>" << std::endl;
335  *outstream << "" << std::endl;
336  *outstream << " <DATA_SET>" << std::endl;
337  *outstream << " <PART>" << std::endl;
338  *outstream << " <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << std::endl;
339  *outstream << " <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << std::endl;
340  *outstream << " </PART>" << std::endl;
341  *outstream << " <VERSION>" << version << "</VERSION>" << std::endl;
342  *outstream << " <COMMENT_DESCRIPTION>" << getComment() << "</COMMENT_DESCRIPTION>" << std::endl;
343  *outstream << " <CREATED_BY_USER>" << getAuthor() << "</CREATED_BY_USER>" << std::endl;
344 }
std::string getComment() const
static std::string getmSecTime(void)
static std::string getTime(void)
std::string getAuthor() const

◆ writeXMLTrailer()

void PixelPortcardMap::writeXMLTrailer ( std::ofstream *  out,
std::ofstream *  out1 = nullptr,
std::ofstream *  out2 = nullptr 
) const
overridevirtual

Reimplemented from pos::PixelConfigBase.

Definition at line 362 of file PixelPortcardMap.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

364  {
365  std::string mthn = "[PixelPortcardMap::writeXMLTrailer()]\t\t\t ";
366 
367  *outstream << " </DATA_SET>" << std::endl;
368  *outstream << "</ROOT> " << std::endl;
369 
370  outstream->close();
371 }

Member Data Documentation

◆ map_

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