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;
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" );
58 for(
unsigned int c = 0 ;
c < ins.size() ;
c++)
60 for(
unsigned int n=0;
n<colNames.size();
n++)
62 if(tableMat[0][
c] == colNames[
n])
64 colM[colNames[
n]] =
c;
88 for(
unsigned int r = 1 ;
r < tableMat.size() ;
r++){
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"]] ;
101 aoh = (((
unsigned int)atoi(aohstring.c_str())));
106 std::cout << __LINE__ <<
"]\t" << mthn <<
"Modulename: " << modulename << std::endl;
107 std::cout << __LINE__ <<
"]\t" << mthn <<
"Parsed to : " << module.
modulename() << std::endl;
115 std::pair<std::string, int> portcardAndAOH(portcardname, aoh);
116 map_[channel] = portcardAndAOH;
126 std::string mthn =
"[PixelPortcardMap::PixelPortcardMap()]\t\t\t " ;
127 std::ifstream
in(filename.c_str());
130 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not open: " << filename <<std::endl;
131 throw std::runtime_error(
"Failed to open file "+filename);
134 std::cout << __LINE__ <<
"]\t" << mthn <<
"Reading from: " << filename <<std::endl;
153 in >> portcardname >> modulename >> aoh_string ;
154 if (aoh_string ==
"A" || aoh_string ==
"B")
156 TBMChannel = aoh_string;
159 aoh = atoi(aoh_string.c_str());
164 std::cout << __LINE__ <<
"]\t" << mthn <<
"Modulename: " << modulename << std::endl;
165 std::cout << __LINE__ <<
"]\t" << mthn <<
"Parsed to : " << module.
modulename() << std::endl;
170 std::pair<std::string, int> portcardAndAOH(portcardname, aoh);
171 map_[channel] = portcardAndAOH;
197 std::string mthn =
"[PixelPortcardMap::writeASCII()]\t\t\t\t " ;
198 if (dir!=
"") dir+=
"/";
199 string filename=dir+
"portcardmap.dat";
201 ofstream
out(filename.c_str());
203 cout << __LINE__ <<
"]\t" << mthn <<
"Could not open file: " << filename << endl;
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;
224 std::set< std::pair< std::string, int > > returnThis;
227 for( std::map<
PixelChannel, std::pair<std::string, int> >::const_iterator map_itr =
map_.begin(); map_itr !=
map_.end(); ++map_itr )
229 if ( map_itr->first.modulename() == aModule.
modulename() )
231 returnThis.insert(map_itr->second);
241 for( std::map<
PixelChannel, std::pair<std::string, int> >::const_iterator map_itr =
map_.begin(); map_itr !=
map_.end(); ++map_itr )
243 if ( map_itr->first.modulename() ==
moduleName )
245 portcardName = map_itr->second.first;
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)
258 returnThis.insert( (*portCardAndAOHs_itr).first );
275 std::map< PixelChannel, std::pair<std::string, int> >::const_iterator
found =
map_.find(aChannel);
276 if ( found ==
map_.end() )
278 std::pair< std::string, int > returnThis(
"none", 0);
283 return found->second;
289 std::set< PixelModuleName > returnThis;
292 for( std::map<
PixelChannel, std::pair<std::string, int> >::const_iterator map_itr =
map_.begin(); map_itr !=
map_.end(); ++map_itr )
294 if ( map_itr->second.first == portCardName )
296 returnThis.insert(map_itr->first.module());
305 std::set< std::string > returnThis;
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());
317 for( std::map<
PixelChannel, std::pair<std::string, int> >::const_iterator map_itr =
map_.begin(); map_itr !=
map_.end(); ++map_itr )
319 if ( moduleNames.find(map_itr->first.modulename()) != moduleNames.end() ){
320 returnThis.insert(map_itr->second.first);
330 for( std::map<
PixelChannel, std::pair<std::string, int> >::const_iterator map_itr =
map_.begin(); map_itr !=
map_.end(); ++map_itr )
333 returnThis.insert(map_itr->second.first);
344 std::ofstream *outstream,
345 std::ofstream *out1stream,
346 std::ofstream *out2stream)
const
348 std::string mthn =
"[PixelPortcardMap::writeXMLHeader()]\t\t\t " ;
351 std::cout << __LINE__ <<
"]\t" << mthn <<
"Writing to: " << fullPath.str() << std::endl ;
353 outstream->open(fullPath.str().c_str()) ;
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 ;
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 ;
382 std::ofstream *out1stream,
383 std::ofstream *out2stream)
const
385 std::string mthn =
"[PixelPortcardMap::writeXML()]\t\t\t " ;
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 ;
401 std::ofstream *out1stream,
402 std::ofstream *out2stream)
const
404 std::string mthn =
"[PixelPortcardMap::writeXMLTrailer()]\t\t\t " ;
406 *outstream <<
" </DATA_SET>" << std::endl ;
407 *outstream <<
"</ROOT> " << std::endl ;
This file contains the base class for "pixel configuration data" management.
Simple class to hold either "A" or "B" for the TBM channel.
This class provides the mapping between portcards and the modules controlled by the card...
PixelPortcardMap(std::string filename)
std::set< PixelModuleName > modules(std::string portCardName) const
std::string moduleName(Provenance const &provenance)
virtual void writeASCII(std::string dir) const
std::string getComment() const
This is the documentation about PixelDetectorConfig...
virtual void writeXMLHeader(pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) const
std::string getAuthor() const
virtual ~PixelPortcardMap()
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
const std::pair< std::string, int > PortCardAndAOH(const PixelModuleName &aModule, const std::string &TBMChannel) const
const std::vector< PixelModuleName > & getModuleList() const
void writeXML(pos::PixelConfigKey key, int version, std::string path) const
std::string modulename() const
virtual void writeXMLTrailer(std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) const
const std::set< std::pair< std::string, int > > PortCardAndAOHs(const PixelModuleName &aModule) const
const std::set< std::string > portcards(const PixelModuleName &aModule) const
volatile std::atomic< bool > shutdown_flag false
std::map< PixelChannel, std::pair< std::string, int > > map_
bool getName(std::string moduleName, std::string &portcardName)