28 for (
auto ifed =
feds.begin(); ifed !=
feds.end(); ifed++ ) {
30 for (
auto iconn = conns.begin(); iconn != conns.end(); iconn++ ) {
32 bool have_fed_id = iconn->fedId();
33 std::vector<int> vector_of_connected_apvs;
36 int which_apv_pair = iconn->apvPairNumber();
39 if( iconn->detId()==0 ||
46 if(iconn->i2cAddr(0)) vector_of_connected_apvs.push_back(2*which_apv_pair + 0);
47 if(iconn->i2cAddr(1)) vector_of_connected_apvs.push_back(2*which_apv_pair + 1);
49 if(vector_of_connected_apvs.size() != 0){
50 std::map<uint32_t, std::vector<int> > map_of_connected_apvs;
51 map_of_connected_apvs.insert(std::make_pair(iconn->detId(),vector_of_connected_apvs));
58 for(std::vector<FedChannelConnection>::const_iterator idtct = detected_fed_connections.begin(); idtct != detected_fed_connections.end(); idtct++){
60 bool have_fed_id = idtct->fedId();
61 std::vector<int> vector_of_detected_apvs;
63 int which_apv_pair = idtct->apvPairNumber();
64 if(idtct->i2cAddr(0)) vector_of_detected_apvs.push_back(2*which_apv_pair + 0);
65 if(idtct->i2cAddr(1)) vector_of_detected_apvs.push_back(2*which_apv_pair + 1);
67 if(vector_of_detected_apvs.size() != 0){
68 std::map<uint32_t,std::vector<int> > map_of_detected_apvs;
69 map_of_detected_apvs.insert(std::make_pair(idtct->detId(),vector_of_detected_apvs));
75 for(std::vector<FedChannelConnection>::const_iterator iudtct = undetected_fed_connections.begin(); iudtct != undetected_fed_connections.end(); iudtct++){
77 bool have_fed_id = iudtct->fedId();
78 std::vector<int> vector_of_undetected_apvs;
80 int which_apv_pair = iudtct->apvPairNumber();
81 if(iudtct->i2cAddr(0)) vector_of_undetected_apvs.push_back(2*which_apv_pair + 0);
82 if(iudtct->i2cAddr(1)) vector_of_undetected_apvs.push_back(2*which_apv_pair + 1);
84 if(vector_of_undetected_apvs.size() != 0){
85 std::map<uint32_t, std::vector<int> > map_of_undetected_apvs;
86 map_of_undetected_apvs.insert(std::make_pair(iudtct->detId(),vector_of_undetected_apvs));
94 std::map< uint32_t, std::vector<const FedChannelConnection *> >& conns ){
98 edm::LogInfo(
"") <<
" SiStripDetCabling::addDevices for connection associated to detid " << conn.
detId() <<
" apvPairNumber " << conn.
apvPairNumber() <<
"the fedId is " << conn.
fedId();
119 vector_to_fill_with_detids.push_back(conn_it->first);
127 vector_to_fill_with_detids.push_back(conn_it->first);
130 vector_to_fill_with_detids.push_back(conn_it->first);
133 vector_to_fill_with_detids.push_back(conn_it->first);
140 std::map< uint32_t, std::vector<const FedChannelConnection *> >::const_iterator detcabl_it =
fullcabling_.find(det_id);
142 return ( detcabl_it->second );
144 const static std::vector<const FedChannelConnection *> default_empty_fedchannelconnection;
145 return default_empty_fedchannelconnection;
151 const std::vector<const FedChannelConnection *>& fcconns =
getConnections(det_id);
152 for(std::vector<const FedChannelConnection *>::const_iterator iconn = fcconns.begin(); iconn!=fcconns.end();iconn++){
153 if ( ((*iconn) != 0) && (((*iconn)->apvPairNumber()) == apv_pair) ) {
159 return default_empty_fedchannelconnection;
164 const std::vector<const FedChannelConnection *>& fcconns =
getConnections( det_id );
165 if(fcconns.size()!=0) {
167 for(
size_t i=0;
i<fcconns.size();++
i)
169 return ( fcconns.at(
i) )->dcuId();
172 unsigned int default_zero_value = 0;
173 return default_zero_value;
178 const std::vector<const FedChannelConnection *>& fcconns =
getConnections( det_id );
179 if(fcconns.size()!=0) {
181 for(
size_t i=0;
i<fcconns.size();++
i) {
183 return fcconns.at(
i)->nApvPairs();
216 const std::map< uint32_t, std::vector<int> > & specific_connection,
217 std::map< int16_t, uint32_t >* connectionsToFill )
const {
218 for(
std::map< uint32_t, std::vector<int> >::const_iterator conn_it = specific_connection.begin(); conn_it!=specific_connection.end(); ++conn_it){
219 uint32_t new_detid = conn_it->first;
220 std::vector<int> new_apv_vector = conn_it->second;
221 std::map<uint32_t, std::vector<int> >::iterator it = map_to_add_to.find(new_detid);
222 if( it == map_to_add_to.end() ){
223 std::sort(new_apv_vector.begin(),new_apv_vector.end());
224 map_to_add_to.insert(std::make_pair(new_detid,new_apv_vector));
235 if( connectionsToFill ) {
240 std::vector<int> existing_apv_vector = it->second;
241 for(std::vector<int>::iterator inew = new_apv_vector.begin(); inew != new_apv_vector.end(); inew++ ){
242 bool there_already =
false;
243 for(std::vector<int>::iterator iold = existing_apv_vector.begin(); iold != existing_apv_vector.end(); iold++){
245 there_already =
true;
249 if( ! there_already ){
250 existing_apv_vector.push_back(*inew);
251 std::sort(existing_apv_vector.begin(),existing_apv_vector.end());
282 uint16_t subDetLayer = layer;
284 if( subDet ==
"TID-" ) subDetLayer += 10;
285 else if( subDet ==
"TID+" ) subDetLayer += 10 + 3;
286 else if( subDet ==
"TOB" ) subDetLayer += 100;
287 else if( subDet ==
"TEC-" ) subDetLayer += 1000;
288 else if( subDet ==
"TEC+" ) subDetLayer += 1000 + 9;
289 else if( subDet !=
"TIB" ) {
290 LogDebug(
"SiStripDetCabling") <<
"Error: Wrong subDet. Please use one of TIB, TID, TOB, TEC." << std::endl;
295 return found->second;
302 allToContiguous.clear();
304 unsigned int contiguousIndex = 0;
305 for(std::vector<uint32_t>::const_iterator idet = all.begin(); idet!= all.end(); ++idet){
307 allToContiguous.insert(std::make_pair(*idet,contiguousIndex));
313 connectedToContiguous.clear();
316 for(std::vector<uint32_t>::const_iterator idet = connected.begin(); idet!= connected.end(); ++idet){
317 std::map<uint32_t, unsigned int>::iterator deco = allToContiguous.find(*idet);
318 if(deco!=allToContiguous.end()){
319 connectedToContiguous.insert(*deco);
335 std::map< uint32_t, std::vector<int> >::const_iterator it=
map.find(det_id);
336 return (it!=
map.end());
344 typedef std::vector<const FedChannelConnection *> Conns;
345 typedef std::map<uint32_t,Conns> ConnsMap;
348 ss <<
"[SiStripDetCabling::" << __func__ <<
"]"
350 <<
" modules " << std::endl;
351 for ( ; ii !=
jj; ++
ii ) {
352 ss <<
"Printing " << ii->second.size()
353 <<
" connections for DetId: " << ii->first << std::endl;
354 Conns::const_iterator iii = ii->second.begin();
355 Conns::const_iterator jjj = ii->second.end();
356 for ( ; iii != jjj; ++iii ) {
357 if ( (*iii)->isConnected() ) { valid++; }
359 ss << **iii << std::endl;
362 ss <<
"Number of connected: " << valid << std::endl
363 <<
"Number of connections: " << total << std::endl;
367 for(
int connectionType = 0; connectionType < 3; ++connectionType ) {
368 if( connectionType == 0 ) ss <<
"Connected modules:" << std::endl;
369 else if( connectionType == 1 ) ss <<
"Detected modules:" << std::endl;
370 else ss <<
"Undetected modules:" << std::endl;
371 ss <<
"SubDet and layer\t modules" << std::endl;
372 std::map< int16_t, uint32_t >::const_iterator
iter =
connectionCount[connectionType].begin();
374 uint32_t subDetLayer = iter->first;
375 uint32_t
modules = iter->second;
376 if(
int(subDetLayer/10) == 0 ) {
377 ss <<
"TIB \t layer " << subDetLayer <<
" \t" << modules << std::endl;
379 else if(
int(subDetLayer/100) == 0 ) {
380 int layer = subDetLayer%10;
381 if( layer <= 3 ) ss <<
"TID- \t disk " << layer <<
"\t" << modules << std::endl;
382 else ss <<
"TID+ \t disk " << layer-3 <<
"\t" << modules << std::endl;
384 else if(
int(subDetLayer/1000) == 0 ) {
385 int layer = subDetLayer%100;
386 ss <<
"TOB \t layer " << layer <<
" \t" << modules << std::endl;
389 int layer = subDetLayer%100;
390 if( layer <= 9 ) ss <<
"TEC- \t disk " << layer <<
" \t" << modules << std::endl;
391 else ss <<
"TEC+ \t disk " << layer-9 <<
" \t" << modules << std::endl;
ConnsConstIterRange detectedDevices() const
const FedChannelConnection & getConnection(uint32_t det_id, unsigned short apv_pair) const
void addActiveDetectorsRawIds(std::vector< uint32_t > &) const
std::map< uint32_t, std::vector< int > > connected_
const unsigned int getDcuId(uint32_t det_id) const
static const uint32_t invalid32_
ConnsConstIterRange undetectedDevices() const
uint16_t apvPairNumber() const
bool IsInMap(const uint32_t &det_id, const std::map< uint32_t, std::vector< int > > &) const
bool IsConnected(const uint32_t &det_id) const
int16_t layerSearch(const uint32_t detId) const
const uint16_t & fedId() const
unsigned int side() const
positive or negative id
unsigned int layerNumber() const
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
boost::iterator_range< ConnsConstIter > ConnsConstIterRange
void addFromSpecificConnection(std::map< uint32_t, std::vector< int > > &, const std::map< uint32_t, std::vector< int > > &, std::map< int16_t, uint32_t > *connectionsToFill=nullptr) const
unsigned int layerNumber() const
std::map< uint32_t, std::vector< int > > detected_
const uint32_t & detId() const
Class containning control, module, detector and connection information, at the level of a FED channel...
FedsConstIterRange fedIds() const
void addNotConnectedAPVs(std::map< uint32_t, std::vector< int > > &) const
uint32_t detNumber(const std::string &subDet, const uint16_t layer, const int connectionType) const
Return the number of modules for the specified subDet, layer and connectionType.
std::map< uint32_t, std::vector< const FedChannelConnection * > > fullcabling_
bool IsUndetected(const uint32_t &det_id) const
void getAllDetectorsContiguousIds(std::map< uint32_t, unsigned int > &) const
Detector identifier class for the strip tracker.
virtual ~SiStripDetCabling()
void printSummary(std::stringstream &ss) const
DecomposeProduct< arg, typename Div::arg > D
unsigned int side() const
positive or negative id
static const uint16_t invalid_
std::map< int16_t, uint32_t > connectionCount[3]
unsigned int wheel() const
wheel id
ConnsConstIterRange fedConnections(uint16_t fed_id) const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
const uint16_t nApvPairs(uint32_t det_id) const
void getActiveDetectorsContiguousIds(std::map< uint32_t, unsigned int > &) const
std::map< uint32_t, std::vector< int > > const & connected() const
void addDetected(std::map< uint32_t, std::vector< int > > &) const
void printDebug(std::stringstream &ss) const
void addDevices(const FedChannelConnection &, std::map< uint32_t, std::vector< const FedChannelConnection * > > &)
std::map< uint32_t, std::vector< int > > undetected_
void addAllDetectorsRawIds(std::vector< uint32_t > &vector_to_fill_with_detids) const
void addUnDetected(std::map< uint32_t, std::vector< int > > &) const
bool IsDetected(const uint32_t &det_id) const
void print(std::stringstream &) const
void addConnected(std::map< uint32_t, std::vector< int > > &) const
unsigned int wheel() const
wheel id