23 auto feds = fedcabling.
fedIds();
24 for (
auto ifed = feds.begin(); ifed != feds.end(); ifed++ ) {
26 for (
auto iconn = conns.begin(); iconn != conns.end(); iconn++ ) {
28 bool have_fed_id = iconn->fedId();
29 std::vector<int> vector_of_connected_apvs;
32 int which_apv_pair = iconn->apvPairNumber();
35 if( iconn->detId()==0 ||
42 if(iconn->i2cAddr(0)) vector_of_connected_apvs.push_back(2*which_apv_pair + 0);
43 if(iconn->i2cAddr(1)) vector_of_connected_apvs.push_back(2*which_apv_pair + 1);
45 if(!vector_of_connected_apvs.empty()){
46 std::map<uint32_t, std::vector<int> > map_of_connected_apvs;
47 map_of_connected_apvs.insert(std::make_pair(iconn->detId(),vector_of_connected_apvs));
54 for(std::vector<FedChannelConnection>::const_iterator idtct = detected_fed_connections.begin(); idtct != detected_fed_connections.end(); ++idtct){
56 bool have_fed_id = idtct->fedId();
57 std::vector<int> vector_of_detected_apvs;
59 int which_apv_pair = idtct->apvPairNumber();
60 if(idtct->i2cAddr(0)) vector_of_detected_apvs.push_back(2*which_apv_pair + 0);
61 if(idtct->i2cAddr(1)) vector_of_detected_apvs.push_back(2*which_apv_pair + 1);
63 if(!vector_of_detected_apvs.empty()){
64 std::map<uint32_t,std::vector<int> > map_of_detected_apvs;
65 map_of_detected_apvs.insert(std::make_pair(idtct->detId(),vector_of_detected_apvs));
71 for(std::vector<FedChannelConnection>::const_iterator iudtct = undetected_fed_connections.begin(); iudtct != undetected_fed_connections.end(); ++iudtct){
73 bool have_fed_id = iudtct->fedId();
74 std::vector<int> vector_of_undetected_apvs;
76 int which_apv_pair = iudtct->apvPairNumber();
77 if(iudtct->i2cAddr(0)) vector_of_undetected_apvs.push_back(2*which_apv_pair + 0);
78 if(iudtct->i2cAddr(1)) vector_of_undetected_apvs.push_back(2*which_apv_pair + 1);
80 if(!vector_of_undetected_apvs.empty()){
81 std::map<uint32_t, std::vector<int> > map_of_undetected_apvs;
82 map_of_undetected_apvs.insert(std::make_pair(iudtct->detId(),vector_of_undetected_apvs));
90 std::map< uint32_t, std::vector<const FedChannelConnection *> >& conns ){
94 edm::LogInfo(
"") <<
" SiStripDetCabling::addDevices for connection associated to detid " << conn.
detId() <<
" apvPairNumber " << conn.
apvPairNumber() <<
"the fedId is " << conn.
fedId();
115 vector_to_fill_with_detids.push_back(conn_it->first);
123 vector_to_fill_with_detids.push_back(conn_it->first);
126 vector_to_fill_with_detids.push_back(conn_it->first);
129 vector_to_fill_with_detids.push_back(conn_it->first);
136 std::map< uint32_t, std::vector<const FedChannelConnection *> >::const_iterator detcabl_it =
fullcabling_.find(det_id);
138 return ( detcabl_it->second );
140 const static std::vector<const FedChannelConnection *> default_empty_fedchannelconnection;
141 return default_empty_fedchannelconnection;
147 const std::vector<const FedChannelConnection *>& fcconns =
getConnections(det_id);
148 for(std::vector<const FedChannelConnection *>::const_iterator iconn = fcconns.begin(); iconn!=fcconns.end();++iconn){
149 if ( ((*iconn) !=
nullptr) && (((*iconn)->apvPairNumber()) == apv_pair) ) {
155 return default_empty_fedchannelconnection;
160 const std::vector<const FedChannelConnection *>& fcconns =
getConnections( det_id );
161 if(!fcconns.empty()) {
163 for(
size_t i=0;
i<fcconns.size();++
i)
165 return ( fcconns.at(
i) )->dcuId();
168 unsigned int default_zero_value = 0;
169 return default_zero_value;
174 const std::vector<const FedChannelConnection *>& fcconns =
getConnections( det_id );
175 if(!fcconns.empty()) {
177 for(
size_t i=0;
i<fcconns.size();++
i) {
179 return fcconns.at(
i)->nApvPairs();
212 const std::map< uint32_t, std::vector<int> > & specific_connection,
213 std::map< int16_t, uint32_t >* connectionsToFill )
const {
214 for(
std::map< uint32_t, std::vector<int> >::const_iterator conn_it = specific_connection.begin(); conn_it!=specific_connection.end(); ++conn_it){
215 uint32_t new_detid = conn_it->first;
216 std::vector<int> new_apv_vector = conn_it->second;
217 std::map<uint32_t, std::vector<int> >::iterator it = map_to_add_to.find(new_detid);
218 if( it == map_to_add_to.end() ){
219 std::sort(new_apv_vector.begin(),new_apv_vector.end());
220 map_to_add_to.insert(std::make_pair(new_detid,new_apv_vector));
231 if( connectionsToFill ) {
236 std::vector<int> existing_apv_vector = it->second;
237 for(std::vector<int>::iterator inew = new_apv_vector.begin(); inew != new_apv_vector.end(); ++inew ){
238 bool there_already =
false;
239 for(std::vector<int>::iterator iold = existing_apv_vector.begin(); iold != existing_apv_vector.end(); ++iold){
241 there_already =
true;
245 if( ! there_already ){
246 existing_apv_vector.push_back(*inew);
247 std::sort(existing_apv_vector.begin(),existing_apv_vector.end());
259 const int subdet = detectorId.
subdetId();
276 uint16_t subDetLayer = layer;
278 if( subDet ==
"TID-" ) subDetLayer += 10;
279 else if( subDet ==
"TID+" ) subDetLayer += 10 + 3;
280 else if( subDet ==
"TOB" ) subDetLayer += 100;
281 else if( subDet ==
"TEC-" ) subDetLayer += 1000;
282 else if( subDet ==
"TEC+" ) subDetLayer += 1000 + 9;
283 else if( subDet !=
"TIB" ) {
284 LogDebug(
"SiStripDetCabling") <<
"Error: Wrong subDet. Please use one of TIB, TID, TOB, TEC." << std::endl;
289 return found->second;
296 allToContiguous.clear();
298 unsigned int contiguousIndex = 0;
299 for(std::vector<uint32_t>::const_iterator idet = all.begin(); idet!= all.end(); ++idet){
301 allToContiguous.insert(std::make_pair(*idet,contiguousIndex));
307 connectedToContiguous.clear();
310 for(std::vector<uint32_t>::const_iterator idet = connected.begin(); idet!= connected.end(); ++idet){
311 std::map<uint32_t, unsigned int>::iterator deco = allToContiguous.find(*idet);
312 if(deco!=allToContiguous.end()){
313 connectedToContiguous.insert(*deco);
329 std::map< uint32_t, std::vector<int> >::const_iterator it=
map.find(det_id);
330 return (it!=
map.end());
338 typedef std::vector<const FedChannelConnection *> Conns;
339 typedef std::map<uint32_t,Conns> ConnsMap;
342 ss <<
"[SiStripDetCabling::" << __func__ <<
"]" 344 <<
" modules " << std::endl;
345 for ( ; ii !=
jj; ++
ii ) {
346 ss <<
"Printing " << ii->second.size()
347 <<
" connections for DetId: " << ii->first << std::endl;
348 Conns::const_iterator iii = ii->second.begin();
349 Conns::const_iterator jjj = ii->second.end();
350 for ( ; iii != jjj; ++iii ) {
351 if ( (*iii)->isConnected() ) { valid++; }
353 ss << **iii << std::endl;
356 ss <<
"Number of connected: " << valid << std::endl
357 <<
"Number of connections: " << total << std::endl;
361 for(
int connectionType = 0; connectionType < 3; ++connectionType ) {
362 if( connectionType == 0 ) ss <<
"Connected modules:" << std::endl;
363 else if( connectionType == 1 ) ss <<
"Detected modules:" << std::endl;
364 else ss <<
"Undetected modules:" << std::endl;
365 ss <<
"SubDet and layer\t modules" << std::endl;
366 std::map< int16_t, uint32_t >::const_iterator iter =
connectionCount[connectionType].begin();
368 uint32_t subDetLayer = iter->first;
369 uint32_t
modules = iter->second;
370 if(
int(subDetLayer/10) == 0 ) {
371 ss <<
"TIB \t layer " << subDetLayer <<
" \t" << modules << std::endl;
373 else if(
int(subDetLayer/100) == 0 ) {
374 int layer = subDetLayer%10;
375 if( layer <= 3 ) ss <<
"TID- \t disk " << layer <<
"\t" << modules << std::endl;
376 else ss <<
"TID+ \t disk " << layer-3 <<
"\t" << modules << std::endl;
378 else if(
int(subDetLayer/1000) == 0 ) {
379 int layer = subDetLayer%100;
380 ss <<
"TOB \t layer " << layer <<
" \t" << modules << std::endl;
383 int layer = subDetLayer%100;
384 if( layer <= 9 ) ss <<
"TEC- \t disk " << layer <<
" \t" << modules << std::endl;
385 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_
CaloTopology const * topology(0)
const unsigned int getDcuId(uint32_t det_id) const
static const uint32_t invalid32_
ConnsConstIterRange undetectedDevices() const
uint16_t apvPairNumber() const
unsigned int side(const DetId &id) 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
const SiStripFedCabling * fedCabling_
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
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.
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::map< uint32_t, std::vector< const FedChannelConnection * > > fullcabling_
bool IsUndetected(const uint32_t &det_id) const
void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const
void getAllDetectorsContiguousIds(std::map< uint32_t, unsigned int > &) const
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
virtual ~SiStripDetCabling()
static const uint16_t invalid_
std::map< int16_t, uint32_t > connectionCount[3]
ConnsConstIterRange fedConnections(uint16_t fed_id) const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
unsigned int layer(const DetId &id) const
const uint16_t nApvPairs(uint32_t det_id) const
void getActiveDetectorsContiguousIds(std::map< uint32_t, unsigned int > &) const
const TrackerTopology *const tTopo
std::map< uint32_t, std::vector< int > > const & connected() const
void addDetected(std::map< uint32_t, std::vector< int > > &) 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
SiStripDetCabling(const TrackerTopology *const topology)
void addConnected(std::map< uint32_t, std::vector< int > > &) const