CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
SiStripPsuDetIdMap Class Reference

Extension to SiStripConfigDb to map PSU channels to DetIDs using DCU-PSU map and DCU-DetID map. More...

#include <SiStripPsuDetIdMap.h>

Public Member Functions

void BuildMap ()
 
void BuildMap (const std::string &mapFile)
 
void BuildMap (const std::string &mapFile, std::vector< std::pair< uint32_t, std::string > > &map)
 Overloaded method that does the buidling. More...
 
std::vector< uint32_t > getCcuDcuIds ()
 
std::vector< uint32_t > getCgDcuIds ()
 
std::vector< std::string > getControlDetectorLocations ()
 
std::vector< std::pair
< uint32_t, std::string > > 
getControlPsuDetIdMap ()
 
uint32_t getDcuId (std::string pvss)
 
uint32_t getDcuId (uint32_t detid)
 
std::vector< uint32_t > getDcuIds ()
 
std::vector< std::pair
< uint32_t, std::string > > 
getDcuPsuMap ()
 
std::string getDetectorLocation (uint32_t detid)
 
std::string getDetectorLocation (std::string pvss)
 
std::string getDetectorLocation (uint32_t detid, std::string group)
 
std::vector< std::string > getDetectorLocations ()
 
std::vector< uint32_t > getDetID (std::string pvss)
 
std::vector< uint32_t > getHvDetID (std::string pvss)
 
std::vector< uint32_t > getLvDetID (std::string pvss)
 
std::vector< std::pair
< uint32_t, std::string > > 
getPsuDetIdMap ()
 
std::string getPSUName (uint32_t detid)
 
std::string getPSUName (uint32_t detid, std::string group)
 
int IsHVChannel (std::string pvss)
 
void printControlMap ()
 
void printMap ()
 
 SiStripPsuDetIdMap ()
 
 ~SiStripPsuDetIdMap ()
 

Private Types

typedef edm::MapOfVectors
< std::string, TkDcuPsuMap * > 
DcuPsus
 
typedef DcuPsus::range DcuPsusRange
 
typedef std::vector
< TkDcuPsuMap * > 
DcuPsuVector
 
typedef std::vector< std::pair
< uint32_t, std::string > > 
PsuDetIdMap
 

Private Member Functions

void checkMapInputValues (SiStripConfigDb::DcuDetIdsV dcuDetIds_, DcuPsuVector dcuPsus_)
 
void clone (DcuPsuVector &input, DcuPsuVector &output)
 
std::vector< uint32_t > findDcuIdFromDeviceAddress (uint32_t dcuid_)
 
void getDcuPsuMap (DcuPsusRange &pRange, DcuPsusRange &cRange, std::string partition)
 
std::vector< std::pair
< std::vector< uint16_t >
, std::vector< uint32_t > > > 
retrieveDcuDeviceAddresses (std::string partition)
 

Private Attributes

std::vector< uint32_t > ccuDcuIds
 
std::vector< uint32_t > cgDcuIds
 
PsuDetIdMap cgMap
 
std::vector< std::string > controlLocations
 
edm::Service< SiStripConfigDbdb_
 
std::vector< std::pair
< std::vector< uint16_t >
, std::vector< uint32_t > > > 
dcu_device_addr_vector
 
std::vector< uint32_t > dcuIds
 
DcuPsus DcuPsuMapCG_
 
DcuPsus DcuPsuMapPG_
 
std::vector< std::string > detectorLocations
 
PsuDetIdMap pgMap
 

Detailed Description

Extension to SiStripConfigDb to map PSU channels to DetIDs using DCU-PSU map and DCU-DetID map.

Author
J.Cole

Definition at line 33 of file SiStripPsuDetIdMap.h.

Member Typedef Documentation

typedef edm::MapOfVectors<std::string,TkDcuPsuMap*> SiStripPsuDetIdMap::DcuPsus
private

Definition at line 100 of file SiStripPsuDetIdMap.h.

Definition at line 101 of file SiStripPsuDetIdMap.h.

typedef std::vector<TkDcuPsuMap *> SiStripPsuDetIdMap::DcuPsuVector
private

Definition at line 98 of file SiStripPsuDetIdMap.h.

typedef std::vector< std::pair<uint32_t, std::string> > SiStripPsuDetIdMap::PsuDetIdMap
private

Definition at line 99 of file SiStripPsuDetIdMap.h.

Constructor & Destructor Documentation

SiStripPsuDetIdMap::SiStripPsuDetIdMap ( )

Constructor

Definition at line 20 of file SiStripPsuDetIdMap.cc.

References LogTrace.

20 { LogTrace("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] Constructing ..."; }
#define LogTrace(id)
SiStripPsuDetIdMap::~SiStripPsuDetIdMap ( )

Destructor

Definition at line 22 of file SiStripPsuDetIdMap.cc.

References LogTrace.

22 {LogTrace("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] Destructing ..."; }
#define LogTrace(id)

Member Function Documentation

void SiStripPsuDetIdMap::BuildMap ( )

Main routine that accesses the DB and builds the PSU-DETID map.

Definition at line 25 of file SiStripPsuDetIdMap.cc.

References SiStripConfigDb::findDcuDetId(), first, LogTrace, and SiStripDbParams::partitions().

Referenced by SiStripDetVOffBuilder::BuildDetVOffObj(), and SiStripDetVOffBuilder::buildPSUdetIdMap().

26 {
27  // initialize the map vector
28  pgMap.clear();
29  detectorLocations.clear();
30  dcuIds.clear();
31  cgDcuIds.clear();
32  ccuDcuIds.clear();
33 
34  // first = DCU ID, second = pointer to TkDcuInfo object
35  SiStripConfigDb::DcuDetIdsV dcu_detid_vector;
36  dcu_device_addr_vector.clear();
37  // pointer to TkDcuPsuMap objects
38  DcuPsuVector powerGroup, controlGroup;
39 
40  // check that the db connection is ready
41  if ( db_ ) {
42  // retrieve both maps, if available
43  SiStripDbParams dbParams_ = db_->dbParams();
44  SiStripDbParams::SiStripPartitions::const_iterator iter;
45  for (iter = dbParams_.partitions().begin(); iter != dbParams_.partitions().end(); ++iter) {
46  if (iter->second.psuVersion().first > 0) {
47  DcuPsusRange PGrange, CGrange;
48  getDcuPsuMap(PGrange,CGrange,iter->second.partitionName());
49  if (!PGrange.empty()) {
50  DcuPsuVector nextVec( PGrange.begin(), PGrange.end() );
51  powerGroup.insert( powerGroup.end(), nextVec.begin(), nextVec.end() );
52  }
53  if (!CGrange.empty()) {
54  DcuPsuVector nextVec( CGrange.begin(), CGrange.end() );
55  controlGroup.insert( controlGroup.end(), nextVec.begin(), nextVec.end() );
56  }
57  }
58 
59  if (iter->second.dcuVersion().first > 0 && iter->second.fecVersion().first > 0) {
60  SiStripConfigDb::DcuDetIdsRange range = db_->getDcuDetIds(iter->second.partitionName());
61  if (!range.empty()) {
62  SiStripConfigDb::DcuDetIdsV nextVec( range.begin(), range.end() );
63  dcu_detid_vector.insert( dcu_detid_vector.end(), nextVec.begin(), nextVec.end() );
64  }
65  // std::vector< std::pair<uint32_t, SiStripConfigDb::DeviceAddress> > nextControlVector = retrieveDcuDeviceAddresses(iter->second.partitionName());
66  std::vector< std::pair< std::vector<uint16_t> , std::vector<uint32_t> > > nextControlVector = retrieveDcuDeviceAddresses(iter->second.partitionName());
67  dcu_device_addr_vector.insert( dcu_device_addr_vector.end(), nextControlVector.begin(), nextControlVector.end() );
68  }
69  }
70  } else {
71  edm::LogWarning("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] NULL pointer to SiStripConfigDb service returned! Cannot build PSU <-> DETID map";
72  return;
73  }
74  LogTrace("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] All information retrieved!";
75 
76  if (!powerGroup.empty()) {
77  if (!dcu_detid_vector.empty()) {
78  // Retrieve the collated information for all partitions
79  // Now build the map, starting from the PSUs for power groups
80  for (unsigned int psu = 0; psu < powerGroup.size(); psu++) {
81  SiStripConfigDb::DcuDetIdsV::iterator iter = SiStripConfigDb::findDcuDetId( dcu_detid_vector.begin(), dcu_detid_vector.end(), powerGroup[psu]->getDcuHardId() );
82  if (iter != dcu_detid_vector.end()) {
83  // check for duplicates
84  bool presentInMap = false, multiEntry = false;
85  unsigned int locInMap = 0;
86  for (unsigned int ch = 0; ch < pgMap.size(); ch++) {
87  if (pgMap[ch].first == iter->second->getDetId() && pgMap[ch].second == powerGroup[psu]->getDatapointName()) {presentInMap = true;}
88  if (pgMap[ch].first == iter->second->getDetId() && pgMap[ch].second != powerGroup[psu]->getDatapointName()) {
89  multiEntry = true;
90  locInMap = ch;
91  }
92  }
93  // if no duplicates, store it!
94  if (!presentInMap && !multiEntry) {
95  pgMap.push_back( std::make_pair( iter->second->getDetId(), powerGroup[psu]->getDatapointName() ) );
96  detectorLocations.push_back( powerGroup[psu]->getPVSSName() );
97  dcuIds.push_back( powerGroup[psu]->getDcuHardId() );
98  }
99  if (multiEntry) {
100  pgMap[locInMap].first = iter->second->getDetId();
101  pgMap[locInMap].second = powerGroup[psu]->getDatapointName();
102  detectorLocations[locInMap] = powerGroup[psu]->getPVSSName();
103  dcuIds[locInMap] = powerGroup[psu]->getDcuHardId();
104  }
105  }
106  }
107  } else {
108  edm::LogWarning("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] DCU <-> DETID mapping missing! Cannot build PSU <-> DETID map";
109  }
110  } else {
111  edm::LogWarning("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] DCU <-> PSU mapping missing! Cannot build PSU <-> DETID map";
112  }
113 
114  if (!controlGroup.empty() && !dcu_detid_vector.empty()) {
115  for (unsigned int cg = 0; cg < controlGroup.size(); cg++) {
116  std::vector<uint32_t> dcuids = findDcuIdFromDeviceAddress(controlGroup[cg]->getDcuHardId());
117 
118  for (unsigned int d = 0; d < dcuids.size(); d++) {
119  SiStripConfigDb::DcuDetIdsV::iterator iter = SiStripConfigDb::findDcuDetId( dcu_detid_vector.begin(), dcu_detid_vector.end(), dcuids[d] );
120  if (iter != dcu_detid_vector.end()) {
121  bool presentInMap = false, multiEntry = false;
122  unsigned int locInMap = 0, locOfCopy = 0;
123  for (unsigned int ch = 0; ch < cgMap.size(); ch++) {
124  if (cgMap[ch].first == iter->second->getDetId() && cgMap[ch].second == controlGroup[cg]->getDatapointName()) {
125  presentInMap = true;
126  locOfCopy = ch;
127  }
128  if (cgMap[ch].first == iter->second->getDetId() && cgMap[ch].second != controlGroup[cg]->getDatapointName()) {
129  multiEntry = true;
130  locInMap = ch;
131  }
132  }
133 
134  if (!presentInMap && !multiEntry) {
135  cgMap.push_back( std::make_pair(iter->second->getDetId(), controlGroup[cg]->getDatapointName()) );
136  controlLocations.push_back( controlGroup[cg]->getPVSSName() );
137  cgDcuIds.push_back( dcuids[d] );
138  ccuDcuIds.push_back( controlGroup[cg]->getDcuHardId() );
139  }
140  if (multiEntry) {
141  cgMap[locInMap].first = iter->second->getDetId();
142  cgMap[locInMap].second = controlGroup[cg]->getDatapointName();
143  controlLocations[locInMap] = controlGroup[cg]->getPVSSName();
144  cgDcuIds[locInMap] = dcuids[d];
145  ccuDcuIds[locInMap] = controlGroup[cg]->getDcuHardId();
146  }
147  }
148  }
149  }
150  }
151  LogTrace("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "]: Size of power group PSU-DetID map is: " << pgMap.size();
152  LogTrace("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "]: Size of control group PSU-DetID map is: " << cgMap.size();
153 }
std::vector< std::pair< std::vector< uint16_t >, std::vector< uint32_t > > > dcu_device_addr_vector
std::vector< uint32_t > ccuDcuIds
DcuDetIds::range DcuDetIdsRange
std::vector< std::pair< std::vector< uint16_t >, std::vector< uint32_t > > > retrieveDcuDeviceAddresses(std::string partition)
DcuPsus::range DcuPsusRange
std::vector< uint32_t > cgDcuIds
const_iterator_range partitions() const
static DcuDetIdsV::const_iterator findDcuDetId(DcuDetIdsV::const_iterator begin, DcuDetIdsV::const_iterator end, uint32_t dcu_id)
Definition: DcuDetIds.cc:396
edm::Service< SiStripConfigDb > db_
std::vector< uint32_t > dcuIds
std::vector< std::pair< uint32_t, std::string > > getDcuPsuMap()
bool first
Definition: L1TdeRCT.cc:79
#define LogTrace(id)
std::vector< uint32_t > findDcuIdFromDeviceAddress(uint32_t dcuid_)
std::vector< std::string > controlLocations
std::vector< DcuDetId > DcuDetIdsV
const SiStripDbParams & dbParams() const
Container class for database connection parameters.
std::vector< std::string > detectorLocations
std::vector< TkDcuPsuMap * > DcuPsuVector
DcuDetIdsRange getDcuDetIds(std::string partition="")
Definition: DcuDetIds.cc:11
void SiStripPsuDetIdMap::BuildMap ( const std::string &  mapFile)

Build the map from given file. ATTENTION: this will only build the pgMap, not the cgMap.

Definition at line 241 of file SiStripPsuDetIdMap.cc.

242 {
243  BuildMap(mapFile, pgMap);
244 }
void SiStripPsuDetIdMap::BuildMap ( const std::string &  mapFile,
std::vector< std::pair< uint32_t, std::string > > &  map 
)

Overloaded method that does the buidling.

Definition at line 246 of file SiStripPsuDetIdMap.cc.

References dbtoweb::file, and geometryCSVtoXML::line.

247 {
248  edm::FileInPath file(mapFile.c_str());
249  ifstream ifs( file.fullPath().c_str() );
250  string line;
251  while( getline( ifs, line ) ) {
252  if( line != "" ) {
253  // split the line and insert in the map
254  stringstream ss(line);
255  string dpName;
256  uint32_t detId;
257  ss >> detId;
258  ss >> dpName;
259  map.push_back( std::make_pair(detId, dpName) );
260  }
261  }
262 }
list file
Definition: dbtoweb.py:253
dictionary map
Definition: Association.py:160
void SiStripPsuDetIdMap::checkMapInputValues ( SiStripConfigDb::DcuDetIdsV  dcuDetIds_,
DcuPsuVector  dcuPsus_ 
)
private

Produces a detailed debug of the input values.

Definition at line 477 of file SiStripPsuDetIdMap.cc.

References gather_cfg::cout, and createTree::dd.

477  {
478  std::cout << "Number of entries in DCU-PSU map: " << dcuPsus_.size() << std::endl;
479  std::cout << "Number of entries in DCU-DETID map: " << dcuDetIds_.size() << std::endl;
480  std::cout << std::endl;
481 
482  std::vector<bool> ddUsed(dcuDetIds_.size(),false);
483  std::vector<bool> dpUsed(dcuPsus_.size(),false);
484 
485  for (unsigned int dp = 0; dp < dcuPsus_.size(); dp++) {
486  for (unsigned int dd = 0; dd < dcuDetIds_.size(); dd++) {
487  if (dcuPsus_[dp]->getDcuHardId() == dcuDetIds_[dd].second->getDcuHardId()) {
488  dpUsed[dp] = true;
489  ddUsed[dd] = true;
490  }
491  }
492  }
493  unsigned int numDpUsed = 0, numDpNotUsed = 0;
494  for (unsigned int dp = 0; dp < dpUsed.size(); dp++) {
495  if (dpUsed[dp]) { numDpUsed++; }
496  else { numDpNotUsed++; }
497  }
498 
499  std::cout << "Number of used DCU-PSU entries: " << numDpUsed << std::endl;
500  std::cout << "Number of unused DCU-PSU entries: " << numDpNotUsed << std::endl;
501 
502  unsigned int numDdUsed = 0, numDdNotUsed = 0;
503  for (unsigned int dd = 0; dd < ddUsed.size(); dd++) {
504  if (ddUsed[dd]) { numDdUsed++; }
505  else { numDdNotUsed++; }
506  }
507 
508  std::cout << "Number of used DCU-DETID entries: " << numDdUsed << std::endl;
509  std::cout << "Number of unused DCU-DETID entries: " << numDdNotUsed << std::endl;
510  std::cout << std::endl;
511  std::cout << "Size of PSU-DETID map: " << pgMap.size() << std::endl;
512  std::cout << "Size of detectorLocations: " << detectorLocations.size() << std::endl;
513 }
std::vector< std::string > detectorLocations
tuple cout
Definition: gather_cfg.py:41
void SiStripPsuDetIdMap::clone ( DcuPsuVector input,
DcuPsuVector output 
)
private

Utility to clone a DCU-PSU map.

Definition at line 444 of file SiStripPsuDetIdMap.cc.

References i.

444  {
445  output.clear();
446  for (unsigned int i = 0; i < input.size(); i++) {
447  output.push_back(new TkDcuPsuMap(*(input[i])));
448  }
449 }
int i
Definition: DBlmapReader.cc:9
tuple input
Definition: collect_tpl.py:10
std::vector< uint32_t > SiStripPsuDetIdMap::findDcuIdFromDeviceAddress ( uint32_t  dcuid_)
private

Searches the DCU device descriptions for the specified DCU ID. Needed for control groups.

Definition at line 584 of file SiStripPsuDetIdMap.cc.

References gather_cfg::cout, spr::find(), and i.

584  {
585  std::vector< std::pair< std::vector<uint16_t> , std::vector<uint32_t> > >::iterator iter = dcu_device_addr_vector.begin();
586  std::vector< std::pair< std::vector<uint16_t> , std::vector<uint32_t> > >::iterator res_iter = dcu_device_addr_vector.end();
587  std::vector<uint32_t> pgDcu;
588 
589  for ( ; iter != dcu_device_addr_vector.end(); iter++) {
590  std::vector<uint32_t> dcuids = iter->second;
591  std::vector<uint32_t>::iterator dcu_iter = std::find(dcuids.begin(),dcuids.end(),dcuid_);
592  bool alreadyFound = false;
593  if (res_iter != dcu_device_addr_vector.end()) {alreadyFound = true;}
594  if (dcu_iter != dcuids.end()) {
595  res_iter = iter;
596  if (!alreadyFound) {
597  for (unsigned int i = 0; i < dcuids.size(); i++) {
598  if (dcuids[i] != dcuid_) {pgDcu.push_back(dcuids[i]);}
599  }
600  } else {
601  std::cout << "Oh oh ... we have a duplicate :-(" << std::endl;
602  }
603  }
604  }
605  return pgDcu;
606 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::pair< std::vector< uint16_t >, std::vector< uint32_t > > > dcu_device_addr_vector
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
tuple cout
Definition: gather_cfg.py:41
std::vector<uint32_t> SiStripPsuDetIdMap::getCcuDcuIds ( )
inline

Return the CCU DCU IDs associated to the CG map.

Definition at line 74 of file SiStripPsuDetIdMap.h.

References ccuDcuIds.

74 {return ccuDcuIds;}
std::vector< uint32_t > ccuDcuIds
std::vector<uint32_t> SiStripPsuDetIdMap::getCgDcuIds ( )
inline

Return the module DCU IDs associated to the CG map.

Definition at line 72 of file SiStripPsuDetIdMap.h.

References cgDcuIds.

72 {return cgDcuIds;}
std::vector< uint32_t > cgDcuIds
std::vector<std::string> SiStripPsuDetIdMap::getControlDetectorLocations ( )
inline

Return the CG detector locations as a vector - one-to-one correspondance with the contents of the PSU-DetID map vector.

Definition at line 70 of file SiStripPsuDetIdMap.h.

References controlLocations.

70 {return controlLocations;}
std::vector< std::string > controlLocations
std::vector< std::pair<uint32_t, std::string> > SiStripPsuDetIdMap::getControlPsuDetIdMap ( )
inline

Return the CG PSU-DETID map as a vector.

Definition at line 68 of file SiStripPsuDetIdMap.h.

References cgMap.

68 {return cgMap;}
uint32_t SiStripPsuDetIdMap::getDcuId ( std::string  pvss)

Returns the DCU ID for the specified PSU channel - checks power and control groups.

Definition at line 405 of file SiStripPsuDetIdMap.cc.

References i, and edm::second().

405  {
406  for (unsigned int i = 0; i < pgMap.size(); i++) {
407  if (pgMap[i].second == pvss) {return dcuIds[i];}
408  }
409  for (unsigned int i = 0; i < cgMap.size(); i++) {
410  if (cgMap[i].second == pvss) {return cgDcuIds[i];}
411  }
412  return 0;
413 }
int i
Definition: DBlmapReader.cc:9
std::vector< uint32_t > cgDcuIds
U second(std::pair< T, U > const &p)
std::vector< uint32_t > dcuIds
uint32_t SiStripPsuDetIdMap::getDcuId ( uint32_t  detid)

Returns the DCU ID associated to the specified Det ID. NB. This checks power groups only, by definition.

Definition at line 415 of file SiStripPsuDetIdMap.cc.

References first, and i.

415  {
416  for (unsigned int i = 0; i < pgMap.size(); i++) {
417  if (pgMap[i].first == detid) {return dcuIds[i];}
418  }
419  return 0;
420 }
int i
Definition: DBlmapReader.cc:9
std::vector< uint32_t > dcuIds
bool first
Definition: L1TdeRCT.cc:79
std::vector<uint32_t> SiStripPsuDetIdMap::getDcuIds ( )
inline

Return the DCU IDs associated to the PG map.

Definition at line 66 of file SiStripPsuDetIdMap.h.

References dcuIds.

66 {return dcuIds;}
std::vector< uint32_t > dcuIds
std::vector< std::pair< uint32_t, std::string > > SiStripPsuDetIdMap::getDcuPsuMap ( )

Returns the DCU-PSU map as a vector.

Definition at line 471 of file SiStripPsuDetIdMap.cc.

471  {
472  if (pgMap.size() != 0) { return pgMap; }
473  std::vector< std::pair<uint32_t, std::string> > emptyVec;
474  return emptyVec;
475 }
void SiStripPsuDetIdMap::getDcuPsuMap ( DcuPsusRange pRange,
DcuPsusRange cRange,
std::string  partition 
)
private

Extracts the DCU-PSU map from the DB.

Definition at line 156 of file SiStripPsuDetIdMap.cc.

References begin, clone(), SiStripPartition::defaultPartitionName_, end, LogTrace, and SiStripDbParams::partitions().

157 {
158  // initialize the DCU-PSU range
159  pRange = DcuPsuMapPG_.emptyRange();
160  cRange = DcuPsuMapCG_.emptyRange();
161  // check that the db connection is ready
162  SiStripDbParams dbParams_ = db_->dbParams();
163  // devicefactory needed for DCU-PSU information
164  if ( db_->deviceFactory() ) {
165  // loop over all specified partitions
166  SiStripDbParams::SiStripPartitions::const_iterator iter;
167  for (iter = dbParams_.partitions().begin(); iter != dbParams_.partitions().end(); ++iter) {
168  if ( partition == "" || partition == iter->second.partitionName() ) {
169  if ( iter->second.partitionName() == SiStripPartition::defaultPartitionName_ ) { continue; }
170  // Stolen from RB code - modify to store DCU PSU map instead
171  // Do things the way RB does to make life easier
172  DcuPsusRange rangePG = DcuPsuMapPG_.find(iter->second.partitionName());
173 
174  if (rangePG == DcuPsuMapPG_.emptyRange()) {
175  try {
176  db_->deviceFactory()->getDcuPsuMapPartition(iter->second.partitionName(),iter->second.psuVersion().first,iter->second.psuVersion().second);
177  } catch (... ) { db_->handleException( __func__ ); }
178 
179  // now store it locally for power groups
180  DcuPsuVector pGroup = db_->deviceFactory()->getPowerGroupDcuPsuMaps();
181  DcuPsuVector cGroup = db_->deviceFactory()->getControlGroupDcuPsuMaps();
182  DcuPsuVector dstPG, dstCG;
183  clone(pGroup, dstPG);
184  clone(cGroup, dstCG);
185  DcuPsuMapPG_.loadNext(iter->second.partitionName(), dstPG);
186  DcuPsuMapCG_.loadNext(iter->second.partitionName(), dstCG);
187  }
188  } // if partition is blank or equal to the partitionName specified
189  } // for loop
190  } // device factory check
191 
192  // Create range object
193  uint16_t npPG = 0, ncPG = 0;
194  DcuPsusRange PGrange;
195  if ( partition != "" ) {
196  PGrange = DcuPsuMapPG_.find(partition);
197  npPG = 1;
198  ncPG = PGrange.size();
199  } else {
200  if (!DcuPsuMapPG_.empty()) {
201  PGrange = DcuPsusRange( DcuPsuMapPG_.find( dbParams_.partitions().begin()->second.partitionName() ).begin(),
202  DcuPsuMapPG_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).end() );
203  } else {
204  PGrange = DcuPsuMapPG_.emptyRange();
205  }
206  npPG = DcuPsuMapPG_.size();
207  ncPG = PGrange.size();
208  }
209 
210  stringstream ss;
211  ss << "Found " << ncPG << " entries for power groups in DCU-PSU map";
212  if (DcuPsuMapPG_.empty()) {edm::LogWarning("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] " << ss.str();}
213  else {LogTrace("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] " << ss.str();}
214 
215  uint16_t npCG = 0, ncCG = 0;
216  DcuPsusRange CGrange;
217  if ( partition != "" ) {
218  CGrange = DcuPsuMapCG_.find(partition);
219  npCG = 1;
220  ncCG = CGrange.size();
221  } else {
222  if (!DcuPsuMapCG_.empty()) {
223  CGrange = DcuPsusRange( DcuPsuMapCG_.find( dbParams_.partitions().begin()->second.partitionName() ).begin(),
224  DcuPsuMapCG_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).end() );
225  } else {
226  CGrange = DcuPsuMapCG_.emptyRange();
227  }
228  npCG = DcuPsuMapCG_.size();
229  ncCG = CGrange.size();
230  }
231 
232  std::stringstream ss1;
233  ss1 << "Found " << ncCG << " entries for control groups in DCU-PSU map";
234  if (DcuPsuMapCG_.empty()) {edm::LogWarning("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] " << ss1.str();}
235  else {LogTrace("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] " << ss1.str();}
236 
237  cRange = CGrange;
238  pRange = PGrange;
239 }
static std::string defaultPartitionName_
void clone(DcuPsuVector &input, DcuPsuVector &output)
void loadNext(K const &k, std::vector< T > const &v)
Definition: MapOfVectors.h:97
DeviceFactory *const deviceFactory(std::string method_name="") const
void handleException(const std::string &method_name, const std::string &extra_info="") const
DcuPsus::range DcuPsusRange
const_iterator_range partitions() const
edm::Service< SiStripConfigDb > db_
size_type size() const
Definition: MapOfVectors.h:104
#define end
Definition: vmac.h:38
range find(K const &k) const
Definition: MapOfVectors.h:120
#define LogTrace(id)
const SiStripDbParams & dbParams() const
Container class for database connection parameters.
range emptyRange() const
Definition: MapOfVectors.h:80
bool empty() const
Definition: MapOfVectors.h:106
#define begin
Definition: vmac.h:31
std::vector< TkDcuPsuMap * > DcuPsuVector
std::string SiStripPsuDetIdMap::getDetectorLocation ( uint32_t  detid)

Returns the detector location for the specified Det ID, for power groups only.

Definition at line 371 of file SiStripPsuDetIdMap.cc.

References first, and i.

371  {
372  for (unsigned int i = 0; i < pgMap.size(); i++) {
373  if (pgMap[i].first == detid) {return detectorLocations[i];}
374  }
375  return "UNKNOWN";
376 }
int i
Definition: DBlmapReader.cc:9
bool first
Definition: L1TdeRCT.cc:79
std::vector< std::string > detectorLocations
std::string SiStripPsuDetIdMap::getDetectorLocation ( std::string  pvss)

Returns the detector location for the specified PSU channel.

Definition at line 394 of file SiStripPsuDetIdMap.cc.

References i, and edm::second().

394  {
395  for (unsigned int i = 0; i < pgMap.size(); i++) {
396  if (pgMap[i].second == pvss) {return detectorLocations[i];}
397  }
398  for (unsigned int i = 0; i < cgMap.size(); i++) {
399  if (cgMap[i].second == pvss) {return controlLocations[i];}
400  }
401  return "UNKNOWN";
402 }
int i
Definition: DBlmapReader.cc:9
U second(std::pair< T, U > const &p)
std::vector< std::string > controlLocations
std::vector< std::string > detectorLocations
std::string SiStripPsuDetIdMap::getDetectorLocation ( uint32_t  detid,
std::string  group 
)

Returns the detector location for the specified Det ID and specified group type (PG or CG).

Definition at line 379 of file SiStripPsuDetIdMap.cc.

References first, and i.

379  {
380  if (group == "PG") {
381  for (unsigned int i = 0; i < pgMap.size(); i++) {
382  if (pgMap[i].first == detid) {return detectorLocations[i];}
383  }
384  }
385  if (group == "CG") {
386  for (unsigned int i = 0; i < cgMap.size(); i++) {
387  if (cgMap[i].first == detid) {return controlLocations[i];}
388  }
389  }
390  return "UNKNOWN";
391 }
int i
Definition: DBlmapReader.cc:9
bool first
Definition: L1TdeRCT.cc:79
std::vector< std::string > controlLocations
std::vector< std::string > detectorLocations
std::vector<std::string> SiStripPsuDetIdMap::getDetectorLocations ( )
inline

Return the PG detector locations as a vector - one-to-one correspondance with the contents of the PSU-DetID map vector.

Definition at line 64 of file SiStripPsuDetIdMap.h.

References detectorLocations.

64 {return detectorLocations;}
std::vector< std::string > detectorLocations
std::vector< uint32_t > SiStripPsuDetIdMap::getDetID ( std::string  pvss)

Returns the DetIDs associate to the specified PSU channel.

Definition at line 307 of file SiStripPsuDetIdMap.cc.

References python.multivaluedict::sort().

Referenced by SiStripDetVOffBuilder::buildPSUdetIdMap().

307  {
308  std::vector<uint32_t> detids;
309 
310  std::string inputBoard = pvss;
311  std::string::size_type loc = inputBoard.size()-3;
312  inputBoard.erase(loc,3);
313 
314  for (PsuDetIdMap::iterator iter = pgMap.begin(); iter != pgMap.end(); iter++) {
315  std::string board = iter->second;
316  std::string::size_type loca = board.size()-3;
317  board.erase(loca,3);
318  if (inputBoard == board) {
319  detids.push_back(iter->first);
320  }
321  }
322  // 12/6/09 (JEC) Remove control groups because O2O is power groups ONLY
323  /*
324  if (detids.empty()) {
325  LogTrace("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] PSU channel not found in PGs ... Searching CGs!";
326  for (PsuDetIdMap::iterator iter = cgMap.begin(); iter != cgMap.end(); iter++) {
327  std::string board = iter->second;
328  // control groups are ONLY LV
329  std::string::size_type loca = board.size()-3;
330  board.erase(loca,3);
331  if (iter->first && inputBoard == board) {detids.push_back(iter->first);}
332  }
333  }
334  */
335 
336  // remove duplicates
337  std::sort(detids.begin(),detids.end());
338  std::vector<uint32_t>::iterator it = std::unique(detids.begin(),detids.end());
339  detids.resize( it - detids.begin() );
340 
341  return detids;
342 }
uint16_t size_type
std::vector< uint32_t > SiStripPsuDetIdMap::getHvDetID ( std::string  pvss)

Definition at line 281 of file SiStripPsuDetIdMap.cc.

References python.multivaluedict::sort().

281  {
282  std::vector<uint32_t> detids;
283  std::string inputBoard = pvss;
284  std::string::size_type loc = inputBoard.size()-3;
285  inputBoard.erase(loc,3);
286 
287  for (PsuDetIdMap::iterator iter = pgMap.begin(); iter != pgMap.end(); iter++) {
288  std::string board = iter->second;
289  std::string::size_type loca = board.size()-3;
290  board.erase(loca,3);
291  if (iter->first && inputBoard == board) {
292  detids.push_back(iter->first);
293  }
294  }
295 
296  // remove duplicates
297  std::sort(detids.begin(),detids.end());
298  std::vector<uint32_t>::iterator it = std::unique(detids.begin(),detids.end());
299  detids.resize( it - detids.begin() );
300 
301  return detids;
302 }
uint16_t size_type
std::vector< uint32_t > SiStripPsuDetIdMap::getLvDetID ( std::string  pvss)

Definition at line 264 of file SiStripPsuDetIdMap.cc.

References python.multivaluedict::sort().

264  {
265  std::vector<uint32_t> detids;
266 
267  for (PsuDetIdMap::iterator iter = pgMap.begin(); iter != pgMap.end(); iter++) {
268  if (iter->first && iter->second == pvss) {
269  detids.push_back(iter->first);
270  }
271  }
272 
273  // remove duplicates
274  std::sort(detids.begin(),detids.end());
275  std::vector<uint32_t>::iterator it = std::unique(detids.begin(),detids.end());
276  detids.resize( it - detids.begin() );
277 
278  return detids;
279 }
std::vector< std::pair<uint32_t, std::string> > SiStripPsuDetIdMap::getPsuDetIdMap ( )
inline

Return the PG PSU-DETID map as a vector.

Definition at line 62 of file SiStripPsuDetIdMap.h.

References pgMap.

62 {return pgMap;}
std::string SiStripPsuDetIdMap::getPSUName ( uint32_t  detid)

Returns the PSU channel name for the specified Det ID, for power groups only.

Definition at line 345 of file SiStripPsuDetIdMap.cc.

345  {
346  PsuDetIdMap::iterator iter;
347  for (iter = pgMap.begin(); iter != pgMap.end(); iter++) {
348  if (iter->first && iter->first == detid) {return iter->second;}
349  }
350  // if we reach here, then we didn't find the detid in the map
351  return "UNKNOWN";
352 }
std::string SiStripPsuDetIdMap::getPSUName ( uint32_t  detid,
std::string  group 
)

Returns the PSU channel name for the specified Det ID.

Definition at line 354 of file SiStripPsuDetIdMap.cc.

354  {
355  PsuDetIdMap::iterator iter;
356  if (group == "PG") {
357  for (iter = pgMap.begin(); iter != pgMap.end(); iter++) {
358  if (iter->first && iter->first == detid) {return iter->second;}
359  }
360  }
361  if (group == "CG") {
362  for (iter = cgMap.begin(); iter != cgMap.end(); iter++) {
363  if (iter->first && iter->first == detid) {return iter->second;}
364  }
365  }
366  // if we reach here, then we didn't find the detid in the map
367  return "UNKNOWN";
368 }
int SiStripPsuDetIdMap::IsHVChannel ( std::string  pvss)

Returns 1 if the specified PSU channel is a HV channel, 0 if it is a LV channel. -1 means error.

Definition at line 423 of file SiStripPsuDetIdMap.cc.

423  {
424  // isHV = 0 means LV, = 1 means HV, = -1 means error
425  int isHV = 0;
426  std::string::size_type loc = pvss.find( "channel", 0 );
427  if (loc != std::string::npos) {
428  std::string chNumber = pvss.substr(loc+7,3);
429  if (chNumber == "002" || chNumber == "003") {
430  isHV = 1;
431  } else if (chNumber == "000" || chNumber == "001") {
432  isHV = 0;
433  } else {
434  edm::LogWarning("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] channel number of expected format, setting error flag!";
435  isHV = -1;
436  }
437  } else {
438  edm::LogWarning("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] channel number not located in PVSS name, setting error flag!";
439  isHV = -1;
440  }
441  return isHV;
442 }
uint16_t size_type
void SiStripPsuDetIdMap::printControlMap ( )

Produces a formatted printout of the control PSU-DETID map.

Definition at line 461 of file SiStripPsuDetIdMap.cc.

References L1TEmulatorMonitor_cff::p.

461  {
462  stringstream cg;
463  cg << "Map of control power supplies to DET IDs: " << std::endl
464  << "-- PSU name -- -- Det Id --" << std::endl;
465  for (unsigned int p = 0; p < cgMap.size(); p++) {
466  cg << cgMap[p].first << " " << cgMap[p].second << std::endl;
467  }
468  edm::LogInfo("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] " << cg.str();
469 }
void SiStripPsuDetIdMap::printMap ( )

Produces a formatted printout of the PSU-DETID map.

Definition at line 451 of file SiStripPsuDetIdMap.cc.

References L1TEmulatorMonitor_cff::p.

Referenced by SiStripDetVOffBuilder::buildPSUdetIdMap().

451  {
452  stringstream pg;
453  pg << "Map of power supplies to DET IDs: " << std::endl
454  << "-- PSU name -- -- Det Id --" << std::endl;
455  for (unsigned int p = 0; p < pgMap.size(); p++) {
456  pg << pgMap[p].first << " " << pgMap[p].second << std::endl;
457  }
458  edm::LogInfo("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] " << pg.str();
459 }
std::vector< std::pair< std::vector< uint16_t >, std::vector< uint32_t > > > SiStripPsuDetIdMap::retrieveDcuDeviceAddresses ( std::string  partition)
private

Extracts the DCU device descriptions and stores them for further use. Only used for control groups.

Definition at line 516 of file SiStripPsuDetIdMap.cc.

References begin, SiStripPartition::defaultPartitionName_, end, first, i, SiStripDbParams::partitions(), and python.multivaluedict::sort().

516  {
517  // get the DB parameters
518  SiStripDbParams dbParams_ = db_->dbParams();
519  SiStripDbParams::SiStripPartitions::const_iterator iter;
520 
521  std::vector< std::pair<uint32_t, SiStripConfigDb::DeviceAddress> > resultVec;
522 
524  SiStripConfigDb::DeviceType device_ = DCU;
525 
526  for (iter = dbParams_.partitions().begin(); iter != dbParams_.partitions().end(); ++iter) {
527  if ( partition == "" || partition == iter->second.partitionName() ) {
528  if ( iter->second.partitionName() == SiStripPartition::defaultPartitionName_ ) { continue; }
529  if (iter->second.dcuVersion().first > 0 && iter->second.fecVersion().first > 0) {
530  SiStripConfigDb::DeviceDescriptionsRange range = db_->getDeviceDescriptions(device_,iter->second.partitionName());
531  if (!range.empty()) {
532  SiStripConfigDb::DeviceDescriptionsV nextVec( range.begin(), range.end() );
533  for (unsigned int i = 0; i < nextVec.size(); i++) {
534  dcuDescription * desc = dynamic_cast<dcuDescription *>(nextVec[i]);
535  resultVec.push_back( std::make_pair( desc->getDcuHardId(), db_->deviceAddress(*(nextVec[i])) ) );
536  }
537  }
538  }
539  }
540  }
541 
542  std::vector< std::pair< std::vector<uint16_t> , std::vector<uint32_t> > > testVec;
543  std::vector< std::pair<uint32_t, SiStripConfigDb::DeviceAddress> >::iterator reorg_iter = resultVec.begin();
544 
545  for ( ; reorg_iter != resultVec.end(); reorg_iter++) {
546  std::vector<uint16_t> fecInfo(4,0);
547  fecInfo[0] = reorg_iter->second.fecCrate_;
548  fecInfo[1] = reorg_iter->second.fecSlot_;
549  fecInfo[2] = reorg_iter->second.fecRing_;
550  fecInfo[3] = reorg_iter->second.ccuAddr_;
551  std::vector<uint32_t> dcuids;
552  std::vector< std::pair<uint32_t, SiStripConfigDb::DeviceAddress> >::iterator jter = reorg_iter;
553  for ( ; jter != resultVec.end(); jter++) {
554  if (reorg_iter->second.fecCrate_ == jter->second.fecCrate_ &&
555  reorg_iter->second.fecSlot_ == jter->second.fecSlot_ &&
556  reorg_iter->second.fecRing_ == jter->second.fecRing_ &&
557  reorg_iter->second.ccuAddr_ == jter->second.ccuAddr_) {
558  dcuids.push_back(jter->first);
559  }
560  }
561  // handle duplicates
562  bool isDup = false;
563  for (unsigned int i = 0; i < testVec.size(); i++) {
564  if (fecInfo == testVec[i].first) {
565  isDup = true;
566  dcuids.insert(dcuids.end(), (testVec[i].second).begin(), (testVec[i].second).end() );
567  std::sort(dcuids.begin(),dcuids.end());
568  std::vector<uint32_t>::iterator it = std::unique(dcuids.begin(),dcuids.end());
569  dcuids.resize( it - dcuids.begin() );
570  testVec[i].second = dcuids;
571  }
572  }
573  if (!isDup) {
574  std::sort(dcuids.begin(),dcuids.end());
575  std::vector<uint32_t>::iterator it = std::unique(dcuids.begin(),dcuids.end());
576  dcuids.resize( it - dcuids.begin() );
577  testVec.push_back(std::make_pair(fecInfo,dcuids));
578  }
579  }
580  // return resultVec;
581  return testVec;
582 }
static std::string defaultPartitionName_
int i
Definition: DBlmapReader.cc:9
const_iterator_range partitions() const
enumDeviceType DeviceType
edm::Service< SiStripConfigDb > db_
DeviceDescriptions::range DeviceDescriptionsRange
#define end
Definition: vmac.h:38
DeviceAddress deviceAddress(const deviceDescription &)
bool first
Definition: L1TdeRCT.cc:79
const SiStripDbParams & dbParams() const
Container class for database connection parameters.
#define begin
Definition: vmac.h:31
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
std::vector< DeviceDescription * > DeviceDescriptionsV

Member Data Documentation

std::vector<uint32_t> SiStripPsuDetIdMap::ccuDcuIds
private

Definition at line 119 of file SiStripPsuDetIdMap.h.

Referenced by getCcuDcuIds().

std::vector<uint32_t> SiStripPsuDetIdMap::cgDcuIds
private

Definition at line 119 of file SiStripPsuDetIdMap.h.

Referenced by getCgDcuIds().

PsuDetIdMap SiStripPsuDetIdMap::cgMap
private

Definition at line 117 of file SiStripPsuDetIdMap.h.

Referenced by getControlPsuDetIdMap().

std::vector<std::string> SiStripPsuDetIdMap::controlLocations
private

Definition at line 118 of file SiStripPsuDetIdMap.h.

Referenced by getControlDetectorLocations().

edm::Service<SiStripConfigDb> SiStripPsuDetIdMap::db_
private

Definition at line 116 of file SiStripPsuDetIdMap.h.

std::vector< std::pair< std::vector<uint16_t> , std::vector<uint32_t> > > SiStripPsuDetIdMap::dcu_device_addr_vector
private

Definition at line 122 of file SiStripPsuDetIdMap.h.

std::vector<uint32_t> SiStripPsuDetIdMap::dcuIds
private

Definition at line 119 of file SiStripPsuDetIdMap.h.

Referenced by getDcuIds().

DcuPsus SiStripPsuDetIdMap::DcuPsuMapCG_
private

Definition at line 120 of file SiStripPsuDetIdMap.h.

DcuPsus SiStripPsuDetIdMap::DcuPsuMapPG_
private

Definition at line 120 of file SiStripPsuDetIdMap.h.

std::vector<std::string> SiStripPsuDetIdMap::detectorLocations
private

Definition at line 118 of file SiStripPsuDetIdMap.h.

Referenced by getDetectorLocations().

PsuDetIdMap SiStripPsuDetIdMap::pgMap
private

Definition at line 117 of file SiStripPsuDetIdMap.h.

Referenced by getPsuDetIdMap().