#include <CalibFormats/SiStripObjects/interface/SiStripDetCabling.h>
Public Member Functions | |
void | addActiveDetectorsRawIds (std::vector< uint32_t > &) const |
void | addAllDetectorsRawIds (std::vector< uint32_t > &vector_to_fill_with_detids) const |
void | addConnected (std::map< uint32_t, std::vector< int > > &) const |
void | addDetected (std::map< uint32_t, std::vector< int > > &) const |
void | addDevices (const FedChannelConnection &) |
void | addDevices (const FedChannelConnection &, std::map< uint32_t, std::vector< FedChannelConnection > > &) |
void | addNotConnectedAPVs (std::map< uint32_t, std::vector< int > > &) const |
void | addUnDetected (std::map< uint32_t, std::vector< int > > &) const |
void | getActiveDetectorsContiguousIds (std::map< uint32_t, unsigned int > &) const |
void | getAllDetectorsContiguousIds (std::map< uint32_t, unsigned int > &) const |
const FedChannelConnection & | getConnection (uint32_t det_id, unsigned short apv_pair) const |
const std::vector < FedChannelConnection > & | getConnections (uint32_t det_id) const |
const unsigned int | getDcuId (uint32_t det_id) const |
const std::map< uint32_t, std::vector < FedChannelConnection > > & | getDetCabling () const |
bool | IsConnected (const uint32_t &det_id) const |
bool | IsDetected (const uint32_t &det_id) const |
bool | IsUndetected (const uint32_t &det_id) const |
const uint16_t | nApvPairs (uint32_t det_id) const |
SiStripDetCabling (const SiStripFedCabling &) | |
SiStripDetCabling () | |
virtual | ~SiStripDetCabling () |
Private Member Functions | |
void | addFromSpecificConnection (std::map< uint32_t, std::vector< int > > &, const std::map< uint32_t, std::vector< int > > &) const |
bool | IsInMap (const uint32_t &det_id, const std::map< uint32_t, std::vector< int > > &) const |
const SiStripDetCabling & | operator= (const SiStripDetCabling &) |
SiStripDetCabling (const SiStripDetCabling &) | |
Private Attributes | |
std::map< uint32_t, std::vector< int > > | connected_ |
std::map< uint32_t, std::vector< int > > | detected_ |
std::map< uint32_t, std::vector < FedChannelConnection > > | fullcabling_ |
std::map< uint32_t, std::vector< int > > | undetected_ |
Definition at line 19 of file SiStripDetCabling.h.
SiStripDetCabling::SiStripDetCabling | ( | ) |
SiStripDetCabling::~SiStripDetCabling | ( | ) | [virtual] |
SiStripDetCabling::SiStripDetCabling | ( | const SiStripFedCabling & | fedcabling | ) |
Definition at line 16 of file SiStripDetCabling.cc.
References addDevices(), addFromSpecificConnection(), connected_, SiStripFedCabling::connections(), SiStripFedCabling::detected(), detected_, SiStripFedCabling::feds(), fullcabling_, sistrip::invalid32_, sistrip::invalid_, SiStripFedCabling::undetected(), and undetected_.
00016 : fullcabling_(), connected_(), detected_(), undetected_() 00017 { 00018 // --- CONNECTED = have fedid and i2cAddr 00019 // create fullcabling_, loop over vector of FedChannelConnection, either make new element of map, or add to appropriate vector of existing map element 00020 // get feds list (vector) from fedcabling object - these are the active FEDs 00021 const vector<uint16_t>& feds = fedcabling.feds(); 00022 vector<uint16_t>::const_iterator ifed; 00023 for ( ifed = feds.begin(); ifed != feds.end(); ifed++ ) { // iterate over active feds, get all their FedChannelConnection-s 00024 const vector<FedChannelConnection>& conns = fedcabling.connections( *ifed ); 00025 vector<FedChannelConnection>::const_iterator iconn; 00026 for ( iconn = conns.begin(); iconn != conns.end(); iconn++ ) { // loop over FedChannelConnection objects 00027 addDevices(*iconn, fullcabling_); // leave separate method, in case you will need to add devices also after constructing 00028 bool have_fed_id = iconn->fedId(); 00029 vector<int> vector_of_connected_apvs; 00030 if(have_fed_id){ // these apvpairs are seen from the readout 00031 // there can be at most 6 APVs on one DetId: 0,1,2,3,4,5 00032 int which_apv_pair = iconn->apvPairNumber(); // APVPair (0,1) for 512 strips and (0,1,2) for 768 strips 00033 00034 // patch needed to take into account invalid detids or apvPairs 00035 if( iconn->detId()==0 || 00036 iconn->detId() == sistrip::invalid32_ || 00037 iconn->apvPairNumber() == sistrip::invalid_ || 00038 iconn->nApvPairs() == sistrip::invalid_ ) { 00039 continue; 00040 } 00041 00042 if(iconn->i2cAddr(0)) vector_of_connected_apvs.push_back(2*which_apv_pair + 0); // first apv of the pair 00043 if(iconn->i2cAddr(1)) vector_of_connected_apvs.push_back(2*which_apv_pair + 1); // second apv of the pair 00044 } 00045 if(vector_of_connected_apvs.size() != 0){ // add only is smth. there, obviously 00046 map<uint32_t, vector<int> > map_of_connected_apvs; 00047 map_of_connected_apvs.insert(std::make_pair(iconn->detId(),vector_of_connected_apvs)); 00048 addFromSpecificConnection(connected_, map_of_connected_apvs); 00049 } 00050 } 00051 } 00052 // --- DETECTED = do not have fedid but have i2cAddr 00053 const std::vector<FedChannelConnection>& detected_fed_connections = fedcabling.detected(); 00054 for(std::vector<FedChannelConnection>::const_iterator idtct = detected_fed_connections.begin(); idtct != detected_fed_connections.end(); idtct++){ 00055 addDevices(*idtct, fullcabling_); 00056 bool have_fed_id = idtct->fedId(); 00057 vector<int> vector_of_detected_apvs; 00058 if(! have_fed_id){ 00059 int which_apv_pair = idtct->apvPairNumber(); // APVPair (0,1) for 512 strips and (0,1,2) for 768 strips 00060 if(idtct->i2cAddr(0)) vector_of_detected_apvs.push_back(2*which_apv_pair + 0); // first apv of the pair 00061 if(idtct->i2cAddr(1)) vector_of_detected_apvs.push_back(2*which_apv_pair + 1); // second apv of the pair 00062 } 00063 if(vector_of_detected_apvs.size() != 0){ // add only is smth. there, obviously 00064 map<uint32_t,vector<int> > map_of_detected_apvs; 00065 map_of_detected_apvs.insert(std::make_pair(idtct->detId(),vector_of_detected_apvs)); 00066 addFromSpecificConnection(detected_, map_of_detected_apvs); 00067 } 00068 } 00069 // --- UNDETECTED = have neither fedid nor i2caddr 00070 const std::vector<FedChannelConnection>& undetected_fed_connections = fedcabling.undetected(); 00071 for(std::vector<FedChannelConnection>::const_iterator iudtct = undetected_fed_connections.begin(); iudtct != undetected_fed_connections.end(); iudtct++){ 00072 addDevices(*iudtct, fullcabling_); 00073 bool have_fed_id = iudtct->fedId(); 00074 vector<int> vector_of_undetected_apvs; 00075 if(! have_fed_id){ 00076 int which_apv_pair = iudtct->apvPairNumber(); // APVPair (0,1) for 512 strips and (0,1,2) for 768 strips 00077 if(iudtct->i2cAddr(0)) vector_of_undetected_apvs.push_back(2*which_apv_pair + 0); // first apv of the pair 00078 if(iudtct->i2cAddr(1)) vector_of_undetected_apvs.push_back(2*which_apv_pair + 1); // second apv of the pair 00079 } 00080 if(vector_of_undetected_apvs.size() != 0){ // add only is smth. there, obviously 00081 map<uint32_t, vector<int> > map_of_undetected_apvs; 00082 map_of_undetected_apvs.insert(std::make_pair(iudtct->detId(),vector_of_undetected_apvs)); 00083 addFromSpecificConnection(undetected_, map_of_undetected_apvs); 00084 } 00085 } 00086 }
SiStripDetCabling::SiStripDetCabling | ( | const SiStripDetCabling & | ) | [private] |
void SiStripDetCabling::addActiveDetectorsRawIds | ( | std::vector< uint32_t > & | vector_to_fill_with_detids | ) | const |
Definition at line 105 of file SiStripDetCabling.cc.
References connected_.
Referenced by SiStripQuality::addInvalidConnectionFromCabling(), newSiStripO2O::analyze(), and SiStripCondObjBuilderFromDb::buildStripRelatedObjects().
00105 { 00106 for(map< uint32_t, vector<int> >::const_iterator conn_it = connected_.begin(); conn_it!=connected_.end(); conn_it++){ 00107 vector_to_fill_with_detids.push_back(conn_it->first); 00108 } 00109 // no elements added to vector_to_fill_with_detids is empty connected_ 00110 }
void SiStripDetCabling::addAllDetectorsRawIds | ( | std::vector< uint32_t > & | vector_to_fill_with_detids | ) | const |
Definition at line 113 of file SiStripDetCabling.cc.
References connected_, detected_, and undetected_.
Referenced by getActiveDetectorsContiguousIds(), and getAllDetectorsContiguousIds().
00113 { 00114 for(map< uint32_t, vector<int> >::const_iterator conn_it = connected_.begin(); conn_it!=connected_.end(); conn_it++){ 00115 vector_to_fill_with_detids.push_back(conn_it->first); 00116 } 00117 for(map< uint32_t, vector<int> >::const_iterator conn_it = detected_.begin(); conn_it!=detected_.end(); conn_it++){ 00118 vector_to_fill_with_detids.push_back(conn_it->first); 00119 } 00120 for(map< uint32_t, vector<int> >::const_iterator conn_it = undetected_.begin(); conn_it!=undetected_.end(); conn_it++){ 00121 vector_to_fill_with_detids.push_back(conn_it->first); 00122 } 00123 // no elements added to vector_to_fill_with_detids is empty connected_, detected_.begin and undetected_.begin 00124 }
void SiStripDetCabling::addConnected | ( | std::map< uint32_t, std::vector< int > > & | map_to_add_to | ) | const |
Definition at line 179 of file SiStripDetCabling.cc.
References addFromSpecificConnection(), and connected_.
00179 { 00180 addFromSpecificConnection(map_to_add_to, connected_); 00181 }
void SiStripDetCabling::addDetected | ( | std::map< uint32_t, std::vector< int > > & | map_to_add_to | ) | const |
Definition at line 184 of file SiStripDetCabling.cc.
References addFromSpecificConnection(), and detected_.
00184 { 00185 addFromSpecificConnection(map_to_add_to, detected_); 00186 }
void SiStripDetCabling::addDevices | ( | const FedChannelConnection & | conn | ) |
Definition at line 100 of file SiStripDetCabling.cc.
References addDevices(), and fullcabling_.
00100 { // by default add to fullcabling_ connections - special case of above class 00101 addDevices(conn, fullcabling_ ); // add to fullcabling_ 00102 }
void SiStripDetCabling::addDevices | ( | const FedChannelConnection & | conn, | |
std::map< uint32_t, std::vector< FedChannelConnection > > & | conns | |||
) |
Definition at line 89 of file SiStripDetCabling.cc.
References FedChannelConnection::apvPairNumber(), FedChannelConnection::detId(), sistrip::invalid32_, and sistrip::invalid_.
Referenced by addDevices(), and SiStripDetCabling().
00090 { 00091 if ( conn.detId() && conn.detId() != sistrip::invalid32_ && // check for valid detid 00092 conn.apvPairNumber() != sistrip::invalid_ ) { // check for valid apv pair number 00093 if ( conn.apvPairNumber() >= conns[conn.detId()].size() ) // check cached vector size is sufficient 00094 conns[conn.detId()].resize( conn.apvPairNumber()+1 ); // if not, resize 00095 conns[conn.detId()][conn.apvPairNumber()] = conn; // add latest connection object 00096 } 00097 }
void SiStripDetCabling::addFromSpecificConnection | ( | std::map< uint32_t, std::vector< int > > & | , | |
const std::map< uint32_t, std::vector< int > > & | ||||
) | const [private] |
Referenced by addConnected(), addDetected(), addNotConnectedAPVs(), addUnDetected(), and SiStripDetCabling().
void SiStripDetCabling::addNotConnectedAPVs | ( | std::map< uint32_t, std::vector< int > > & | map_to_add_to | ) | const |
Definition at line 194 of file SiStripDetCabling.cc.
References addFromSpecificConnection(), detected_, and undetected_.
00194 { 00195 addFromSpecificConnection(map_to_add_to, detected_); 00196 addFromSpecificConnection(map_to_add_to, undetected_); 00197 }
void SiStripDetCabling::addUnDetected | ( | std::map< uint32_t, std::vector< int > > & | map_to_add_to | ) | const |
Definition at line 189 of file SiStripDetCabling.cc.
References addFromSpecificConnection(), and undetected_.
00189 { 00190 addFromSpecificConnection(map_to_add_to, undetected_); 00191 }
void SiStripDetCabling::getActiveDetectorsContiguousIds | ( | std::map< uint32_t, unsigned int > & | connectedToContiguous | ) | const |
Definition at line 241 of file SiStripDetCabling.cc.
References addAllDetectorsRawIds(), getAllDetectorsContiguousIds(), and python::multivaluedict::sort().
00241 { 00242 connectedToContiguous.clear(); // reset map 00243 std::vector<uint32_t> connected; addAllDetectorsRawIds(connected); std::sort(connected.begin(), connected.end()); // get connected detids and sort them (not strictly necessary) 00244 std::map<uint32_t, unsigned int> allToContiguous; getAllDetectorsContiguousIds(allToContiguous); // create map of all indices 00245 for(std::vector<uint32_t>::const_iterator idet = connected.begin(); idet!= connected.end(); ++idet){ // select only the indices for active detectors 00246 std::map<uint32_t, unsigned int>::iterator deco = allToContiguous.find(*idet); 00247 if(deco!=allToContiguous.end()){ 00248 connectedToContiguous.insert(*deco); 00249 } 00250 } 00251 }
void SiStripDetCabling::getAllDetectorsContiguousIds | ( | std::map< uint32_t, unsigned int > & | allToContiguous | ) | const |
Definition at line 230 of file SiStripDetCabling.cc.
References addAllDetectorsRawIds(), python::cmstools::all(), and python::multivaluedict::sort().
Referenced by getActiveDetectorsContiguousIds().
00230 { 00231 allToContiguous.clear(); // reset map 00232 std::vector<uint32_t> all; addAllDetectorsRawIds(all); std::sort(all.begin(), all.end()); // get all detids and sort them 00233 unsigned int contiguousIndex = 0; 00234 for(std::vector<uint32_t>::const_iterator idet = all.begin(); idet!= all.end(); ++idet){ 00235 ++contiguousIndex; 00236 allToContiguous.insert(std::make_pair(*idet,contiguousIndex)); 00237 } 00238 }
const FedChannelConnection & SiStripDetCabling::getConnection | ( | uint32_t | det_id, | |
unsigned short | apv_pair | |||
) | const |
Definition at line 138 of file SiStripDetCabling.cc.
References getConnections().
00138 { 00139 const vector<FedChannelConnection>& fcconns = getConnections(det_id); 00140 for(vector<FedChannelConnection>::const_iterator iconn = fcconns.begin(); iconn!=fcconns.end();iconn++){ 00141 if ( (iconn->apvPairNumber()) == apv_pair){ // check if apvPairNumber() of present FedChannelConnection is the same as requested one 00142 return (*iconn); // if yes, return the FedChannelConnection object 00143 } 00144 } 00145 // if did not match none of the above, return some default value - DKwarn : also output message? 00146 static FedChannelConnection default_empty_fedchannelconnection; 00147 return default_empty_fedchannelconnection; 00148 }
const vector< FedChannelConnection > & SiStripDetCabling::getConnections | ( | uint32_t | det_id | ) | const |
Definition at line 127 of file SiStripDetCabling.cc.
References fullcabling_.
Referenced by SiStripQuality::addInvalidConnectionFromCabling(), SiStripCondObjBuilderFromDb::buildStripRelatedObjects(), getConnection(), getDcuId(), and nApvPairs().
00127 { // return all connections corresponding to one det_id 00128 map< uint32_t, vector<FedChannelConnection> >::const_iterator detcabl_it = fullcabling_.find(det_id); // has to be const_iterator because this function cannot change data members 00129 if( ! (detcabl_it==fullcabling_.end()) ){ // found detid in fullcabling_ 00130 return ( detcabl_it->second ); 00131 }else{ // DKwarn : is there need for output message here telling det_id does not exist? 00132 static vector<FedChannelConnection> default_empty_fedchannelconnection; 00133 return default_empty_fedchannelconnection; 00134 } 00135 }
const unsigned int SiStripDetCabling::getDcuId | ( | uint32_t | det_id | ) | const |
Definition at line 151 of file SiStripDetCabling.cc.
References getConnections(), i, and sistrip::invalid32_.
00151 { 00152 const vector<FedChannelConnection>& fcconns = getConnections( det_id ); 00153 if(fcconns.size()!=0) { 00154 // patch needed to take into account the possibility that the first component of fcconns is invalid 00155 for(size_t i=0;i<fcconns.size();++i) 00156 if (fcconns.at(i).detId() != sistrip::invalid32_ && fcconns.at(i).detId() != 0 ) 00157 return ( fcconns.at(i) ).dcuId(); // get dcuId of first element - when you build check this consistency 00158 } 00159 // default if none of the above is fulfilled 00160 unsigned int default_zero_value = 0; 00161 return default_zero_value; 00162 }
const std::map< uint32_t, std::vector<FedChannelConnection> >& SiStripDetCabling::getDetCabling | ( | ) | const [inline] |
Definition at line 28 of file SiStripDetCabling.h.
References fullcabling_.
00028 { return fullcabling_; }
bool SiStripDetCabling::IsConnected | ( | const uint32_t & | det_id | ) | const |
Definition at line 253 of file SiStripDetCabling.cc.
References connected_, and IsInMap().
Referenced by SiStripQuality::addNotConnectedConnectionFromCabling(), and SiStripQuality::IsModuleUsable().
00253 { 00254 return IsInMap(det_id,connected_); 00255 }
bool SiStripDetCabling::IsDetected | ( | const uint32_t & | det_id | ) | const |
bool SiStripDetCabling::IsInMap | ( | const uint32_t & | det_id, | |
const std::map< uint32_t, std::vector< int > > & | map | |||
) | const [private] |
Definition at line 263 of file SiStripDetCabling.cc.
Referenced by IsConnected(), IsDetected(), and IsUndetected().
00263 { 00264 std::map< uint32_t, std::vector<int> >::const_iterator it=map.find(det_id); 00265 return (it!=map.end()); 00266 }
bool SiStripDetCabling::IsUndetected | ( | const uint32_t & | det_id | ) | const |
Definition at line 260 of file SiStripDetCabling.cc.
References IsInMap(), and undetected_.
00260 { 00261 return IsInMap(det_id,undetected_); 00262 }
const uint16_t SiStripDetCabling::nApvPairs | ( | uint32_t | det_id | ) | const |
Definition at line 165 of file SiStripDetCabling.cc.
References getConnections(), i, and sistrip::invalid_.
Referenced by SiStripQuality::addInvalidConnectionFromCabling().
00165 { 00166 const vector<FedChannelConnection>& fcconns = getConnections( det_id ); 00167 if(fcconns.size()!=0) { 00168 // patch needed to take into account the possibility that the first component of fcconns is invalid 00169 for(size_t i=0;i<fcconns.size();++i) 00170 if (fcconns.at(i).nApvPairs() != sistrip::invalid_) 00171 return fcconns.at(i).nApvPairs(); // nr of apvpairs for associated module 00172 }else{ 00173 return 0; 00174 } 00175 return 0; 00176 }
const SiStripDetCabling& SiStripDetCabling::operator= | ( | const SiStripDetCabling & | ) | [private] |
std::map< uint32_t, std::vector<int> > SiStripDetCabling::connected_ [private] |
Definition at line 59 of file SiStripDetCabling.h.
Referenced by addActiveDetectorsRawIds(), addAllDetectorsRawIds(), addConnected(), IsConnected(), and SiStripDetCabling().
std::map< uint32_t, std::vector<int> > SiStripDetCabling::detected_ [private] |
Definition at line 60 of file SiStripDetCabling.h.
Referenced by addAllDetectorsRawIds(), addDetected(), addNotConnectedAPVs(), IsDetected(), and SiStripDetCabling().
std::map< uint32_t, std::vector<FedChannelConnection> > SiStripDetCabling::fullcabling_ [private] |
Definition at line 57 of file SiStripDetCabling.h.
Referenced by addDevices(), getConnections(), getDetCabling(), and SiStripDetCabling().
std::map< uint32_t, std::vector<int> > SiStripDetCabling::undetected_ [private] |
Definition at line 61 of file SiStripDetCabling.h.
Referenced by addAllDetectorsRawIds(), addNotConnectedAPVs(), addUnDetected(), IsUndetected(), and SiStripDetCabling().