#include <CalibFormats/SiPixelObjects/interface/PixelPortcardMap.h>
Public Member Functions | |
std::set< PixelModuleName > | modules (std::string portCardName) const |
int | numChannels (const PixelModuleName &aModule) |
PixelPortcardMap (std::vector< std::vector< std::string > > &tableMat) | |
PixelPortcardMap (std::string filename) | |
const std::pair< std::string, int > | PortCardAndAOH (const PixelChannel &aChannel) const |
const std::pair< std::string, int > | PortCardAndAOH (const PixelModuleName &aModule, const PixelTBMChannel &TBMChannel) const |
const std::pair< std::string, int > | PortCardAndAOH (const PixelModuleName &aModule, const std::string &TBMChannel) const |
const std::set< std::pair < std::string, int > > | PortCardAndAOHs (const PixelModuleName &aModule) const |
std::set< std::string > | portcards () |
const std::set< std::string > | portcards (const PixelModuleName &aModule) const |
virtual void | writeASCII (std::string dir) 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 | ~PixelPortcardMap () |
Private Attributes | |
std::map< PixelChannel, std::pair< std::string, int > > | map_ |
Definition at line 31 of file PixelPortcardMap.h.
PixelPortcardMap::PixelPortcardMap | ( | std::string | filename | ) |
Definition at line 94 of file PixelPortcardMap.cc.
References GenMuonPlsPt100GeV_cfg::cout, dummy, lat::endl(), in, map_, module(), and pos::PixelModuleName::modulename().
00094 : 00095 PixelConfigBase(" "," "," "){ 00096 00097 std::ifstream in(filename.c_str()); 00098 00099 if (!in.good()){ 00100 std::cout << "[PixelPortcardMap::PixelPortcardMap()]\t\t\t Could not open: " << filename <<std::endl; 00101 assert(0); 00102 } 00103 else { 00104 std::cout << "[PixelPortcardMap::PixelPortcardMap()]\t\t\t Reading from: " << filename <<std::endl; 00105 } 00106 00107 std::string dummy; 00108 00109 in >> dummy; 00110 in >> dummy; 00111 in >> dummy; 00112 in >> dummy; 00113 in >> dummy; 00114 00115 do { 00116 00117 std::string portcardname; 00118 std::string modulename; 00119 std::string TBMChannel = "A"; 00120 std::string aoh_string; 00121 unsigned int aoh; 00122 00123 in >> portcardname >> modulename >> aoh_string ; 00124 if (aoh_string == "A" || aoh_string == "B") // Optionally, the TBM channel may be specified after the module name. Check for this. 00125 { 00126 TBMChannel = aoh_string; 00127 in >> aoh_string; 00128 } 00129 aoh = atoi(aoh_string.c_str()); 00130 00131 if (!in.eof() ){ 00132 PixelModuleName module(modulename); 00133 if (module.modulename()!=modulename){ 00134 std::cout << "Modulename:"<<modulename<<std::endl; 00135 std::cout << "Parsed to:"<<module.modulename()<<std::endl; 00136 assert(0); 00137 } 00138 00139 PixelChannel channel(module, TBMChannel); 00140 std::pair<std::string, int> portcardAndAOH(portcardname, aoh); 00141 map_[channel] = portcardAndAOH; 00142 } 00143 00144 00145 }while (!in.eof()); 00146 }
PixelPortcardMap::PixelPortcardMap | ( | std::vector< std::vector< std::string > > & | tableMat | ) |
Definition at line 16 of file PixelPortcardMap.cc.
References c, TestMuL1L2Filter_cff::cerr, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), int, map_, module(), pos::PixelModuleName::modulename(), n, and r.
00016 :PixelConfigBase(" "," "," "){ 00017 00018 std::vector< std::string > ins = tableMat[0]; 00019 std::map<std::string , int > colM; 00020 std::vector<std::string > colNames; 00021 colNames.push_back("CONFIG_KEY_ID" ); 00022 colNames.push_back("CONFG_KEY" ); 00023 colNames.push_back("VERSION" ); 00024 colNames.push_back("KIND_OF_COND" ); 00025 colNames.push_back("SERIAL_NUMBER" ); 00026 colNames.push_back("PORT_CARD" ); 00027 colNames.push_back("PANEL_NAME" ); 00028 colNames.push_back("TBM_MODE" ); 00029 colNames.push_back("AOH_CHAN" ); 00030 00031 for(unsigned int c = 0 ; c < ins.size() ; c++) 00032 { 00033 for(unsigned int n=0; n<colNames.size(); n++) 00034 { 00035 if(tableMat[0][c] == colNames[n]) 00036 { 00037 colM[colNames[n]] = c; 00038 break; 00039 } 00040 } 00041 }//end for 00042 for(unsigned int n=0; n<colNames.size(); n++) 00043 { 00044 if(colM.find(colNames[n]) == colM.end()) 00045 { 00046 std::cerr << "[PixelPortcardMap::PixelPortcardMap()]\tCouldn't find in the database the column with name " << colNames[n] << std::endl; 00047 assert(0); 00048 } 00049 } 00050 00051 00052 00053 std::string portcardname; 00054 std::string modulename; 00055 unsigned int aoh; 00056 std::string aohstring; 00057 std::string tbmChannel; 00058 00059 for(unsigned int r = 1 ; r < tableMat.size() ; r++){ //Goes to every row of the Matrix 00060 00061 portcardname = tableMat[r][colM["PORT_CARD"]]; 00062 modulename = tableMat[r][colM["PANEL_NAME"]]; 00063 aohstring = tableMat[r][colM["AOH_CHAN"]]; 00064 tbmChannel = tableMat[r][colM["TBM_MODE"]] ; 00065 cout << "[PixelPortcardMap::PixelPortcardMap()]\t\t\t " 00066 << "Portcardname: " << portcardname 00067 << "\tmodulename: " << modulename 00068 << "\taohstring: " << aohstring 00069 << "\ttbmChannel:" << tbmChannel 00070 << endl ; 00071 //aohname.erase(0,20); // Is going to be change when Umesh put a AOH Channel column in the view. 00072 aoh = (((unsigned int)atoi(aohstring.c_str()))+1); 00073 //std::cout<<aoh<<std::endl; 00074 PixelModuleName module(modulename); 00075 if (module.modulename()!=modulename) 00076 { 00077 std::cout << "[PixelPortcardMap::PixelPortcardMap()]\t\t\t Modulename:"<<modulename<<std::endl; 00078 std::cout << "[PixelPortcardMap::PixelPortcardMap()]\t\t\t Parsed to:"<<module.modulename()<<std::endl; 00079 assert(0); 00080 } 00081 if(tbmChannel == "") 00082 { 00083 tbmChannel = "A";// assert(0); // add TBMChannel to the input, then remove assert 00084 } 00085 PixelChannel channel(module, tbmChannel); 00086 std::pair<std::string, int> portcardAndAOH(portcardname, aoh); 00087 map_[channel] = portcardAndAOH; 00088 }//end for r 00089 00090 00091 }//end constructor
PixelPortcardMap::~PixelPortcardMap | ( | ) | [virtual] |
std::set< PixelModuleName > PixelPortcardMap::modules | ( | std::string | portCardName | ) | const |
Definition at line 241 of file PixelPortcardMap.cc.
References python::multivaluedict::map(), and map_.
00242 { 00243 std::set< PixelModuleName > returnThis; 00244 00245 // Loop over the entire map, searching for elements matching portCardName. Add matching elements to returnThis. 00246 for( std::map< PixelChannel, std::pair<std::string, int> >::const_iterator map_itr = map_.begin(); map_itr != map_.end(); ++map_itr ) 00247 { 00248 if ( map_itr->second.first == portCardName ) 00249 { 00250 returnThis.insert(map_itr->first.module()); 00251 } 00252 } 00253 00254 return returnThis; 00255 }
int pos::PixelPortcardMap::numChannels | ( | const PixelModuleName & | aModule | ) | [inline] |
Definition at line 47 of file PixelPortcardMap.h.
References PortCardAndAOHs().
00047 {return PortCardAndAOHs(aModule).size();}
const std::pair< std::string, int > PixelPortcardMap::PortCardAndAOH | ( | const PixelChannel & | aChannel | ) | const |
Definition at line 227 of file PixelPortcardMap.cc.
References map_.
00228 { 00229 std::map< PixelChannel, std::pair<std::string, int> >::const_iterator found = map_.find(aChannel); 00230 if ( found == map_.end() ) 00231 { 00232 std::pair< std::string, int > returnThis("none", 0); 00233 return returnThis; 00234 } 00235 else 00236 { 00237 return found->second; 00238 } 00239 }
const std::pair< std::string, int > PixelPortcardMap::PortCardAndAOH | ( | const PixelModuleName & | aModule, | |
const PixelTBMChannel & | TBMChannel | |||
) | const |
Definition at line 217 of file PixelPortcardMap.cc.
References PortCardAndAOH().
00218 { 00219 return PortCardAndAOH(PixelChannel(aModule, TBMChannel)); 00220 }
const std::pair< std::string, int > PixelPortcardMap::PortCardAndAOH | ( | const PixelModuleName & | aModule, | |
const std::string & | TBMChannel | |||
) | const |
Definition at line 222 of file PixelPortcardMap.cc.
Referenced by PortCardAndAOH().
00223 { 00224 return PortCardAndAOH(PixelChannel(aModule, TBMChannel)); 00225 }
const std::set< std::pair< std::string, int > > PixelPortcardMap::PortCardAndAOHs | ( | const PixelModuleName & | aModule | ) | const |
Definition at line 190 of file PixelPortcardMap.cc.
References python::multivaluedict::map(), map_, and pos::PixelModuleName::modulename().
Referenced by numChannels(), and portcards().
00191 { 00192 std::set< std::pair< std::string, int > > returnThis; 00193 00194 // Loop over the entire map, searching for elements matching PixelModuleName. Add matching elements to returnThis. 00195 for( std::map< PixelChannel, std::pair<std::string, int> >::const_iterator map_itr = map_.begin(); map_itr != map_.end(); ++map_itr ) 00196 { 00197 if ( map_itr->first.modulename() == aModule.modulename() ) 00198 { 00199 returnThis.insert(map_itr->second); 00200 } 00201 } 00202 00203 return returnThis; 00204 }
std::set< std::string > PixelPortcardMap::portcards | ( | ) |
Definition at line 257 of file PixelPortcardMap.cc.
References python::multivaluedict::map(), and map_.
00258 { 00259 std::set< std::string > returnThis; 00260 00261 // Loop over the entire map, and add all port cards to returnThis. 00262 for( std::map< PixelChannel, std::pair<std::string, int> >::const_iterator map_itr = map_.begin(); map_itr != map_.end(); ++map_itr ) 00263 { 00264 returnThis.insert(map_itr->second.first); 00265 } 00266 00267 return returnThis; 00268 }
const std::set< std::string > PixelPortcardMap::portcards | ( | const PixelModuleName & | aModule | ) | const |
Definition at line 206 of file PixelPortcardMap.cc.
References PortCardAndAOHs().
Referenced by pos::PixelCalibConfiguration::getTKFECCrates().
00207 { 00208 std::set< std::string > returnThis; 00209 const std::set< std::pair< std::string, int > > portCardAndAOHs = PortCardAndAOHs(aModule); 00210 for ( std::set< std::pair< std::string, int > >::const_iterator portCardAndAOHs_itr = portCardAndAOHs.begin(); portCardAndAOHs_itr != portCardAndAOHs.end(); ++portCardAndAOHs_itr) 00211 { 00212 returnThis.insert( (*portCardAndAOHs_itr).first ); 00213 } 00214 return returnThis; 00215 }
void PixelPortcardMap::writeASCII | ( | std::string | dir | ) | const [virtual] |
Implements pos::PixelConfigBase.
Definition at line 163 of file PixelPortcardMap.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), EgammaValidation_cff::filename, i, map_, and out.
00163 { 00164 00165 00166 if (dir!="") dir+="/"; 00167 string filename=dir+"portcardmap.dat"; 00168 00169 ofstream out(filename.c_str()); 00170 if(!out.good()){ 00171 cout << "Could not open file:"<<filename<<endl; 00172 assert(0); 00173 } 00174 00175 out <<"# Portcard Module AOH channel" <<endl; 00176 std::map< PixelChannel, std::pair<std::string, int> >::const_iterator i=map_.begin(); 00177 for(;i!=map_.end();++i){ 00178 out << i->second.first<<" " 00179 << i->first.module()<<" " 00180 << i->first.TBMChannel()<<" " 00181 << i->second.second<<endl; 00182 } 00183 out.close(); 00184 00185 00186 }
virtual void pos::PixelPortcardMap::writeXML | ( | std::ofstream * | out | ) | const [inline, virtual] |
void pos::PixelPortcardMap::writeXML | ( | pos::PixelConfigKey | key, | |
int | version, | |||
std::string | path | |||
) | const [inline, virtual] |
virtual void pos::PixelPortcardMap::writeXMLHeader | ( | pos::PixelConfigKey | key, | |
int | version, | |||
std::string | path, | |||
std::ofstream * | out | |||
) | const [inline, virtual] |
virtual void pos::PixelPortcardMap::writeXMLTrailer | ( | std::ofstream * | out | ) | const [inline, virtual] |
std::map< PixelChannel, std::pair<std::string, int> > pos::PixelPortcardMap::map_ [private] |
Definition at line 67 of file PixelPortcardMap.h.
Referenced by modules(), PixelPortcardMap(), PortCardAndAOH(), PortCardAndAOHs(), portcards(), and writeASCII().