CMS 3D CMS Logo

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 (const std::string &mapFile, const bool debug)
 
void BuildMap (const std::string &mapFile, std::vector< std::pair< uint32_t, std::string > > &rawmap)
 
void BuildMap (const std::string &mapFile, const bool debug, std::map< std::string, std::vector< uint32_t > > &LVmap, std::map< std::string, std::vector< uint32_t > > &HVmap, std::map< std::string, std::vector< uint32_t > > &HVUnmappedmap, std::map< std::string, std::vector< uint32_t > > &HVCrosstalkingmap)
 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 ()
 
void getDetID (std::string pvss, bool, std::vector< uint32_t > &detids, std::vector< uint32_t > &unmapped_detids, std::vector< uint32_t > &crosstalking_detids)
 
std::map< std::string, std::vector< uint32_t > > getHVCrosstalkingMap ()
 
void getHvDetID (std::string psuchannel, std::vector< uint32_t > &ids, std::vector< uint32_t > &unmapped_ids, std::vector< uint32_t > &crosstalking_ids)
 
std::map< std::string, std::vector< uint32_t > > getHVUnmappedMap ()
 
std::vector< uint32_t > getLvDetID (std::string psu)
 
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 ()
 
void RemoveDuplicateDetIDs (std::vector< uint32_t > &detids)
 
 SiStripPsuDetIdMap ()
 
 ~SiStripPsuDetIdMap ()
 

Private Types

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

Private Member Functions

void checkMapInputValues (const SiStripConfigDb::DcuDetIdsV &dcuDetIds_, const 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
 
std::vector< std::pair< uint32_t, std::string > > 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 HVCrosstalking_Map
 
PsuDetIdMap HVMap
 
PsuDetIdMap HVUnmapped_Map
 
PsuDetIdMap LVMap
 
std::vector< std::pair< uint32_t, std::string > > 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 126 of file SiStripPsuDetIdMap.h.

Definition at line 127 of file SiStripPsuDetIdMap.h.

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

Definition at line 124 of file SiStripPsuDetIdMap.h.

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

Definition at line 125 of file SiStripPsuDetIdMap.h.

Constructor & Destructor Documentation

SiStripPsuDetIdMap::SiStripPsuDetIdMap ( )

Constructor

Definition at line 20 of file SiStripPsuDetIdMap.cc.

References LogTrace.

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

Destructor

Definition at line 24 of file SiStripPsuDetIdMap.cc.

References LogTrace.

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

Member Function Documentation

void SiStripPsuDetIdMap::BuildMap ( const std::string &  mapFile,
const bool  debug 
)

Main routine that accesses the DB and builds the PSU-DETID map. Build the map from given file. ATTENTION: this will only build the pgMap, not the cgMap.

Definition at line 29 of file SiStripPsuDetIdMap.cc.

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

29  {
31 }
#define debug
Definition: HDRShower.cc:19
void BuildMap(const std::string &mapFile, const bool debug)
PsuDetIdMap HVCrosstalking_Map
void SiStripPsuDetIdMap::BuildMap ( const std::string &  mapFile,
std::vector< std::pair< uint32_t, std::string > > &  rawmap 
)

Definition at line 33 of file SiStripPsuDetIdMap.cc.

References BuildMap(), gather_cfg::cout, debug, FrontierConditions_GlobalTag_cff::file, mps_fire::i, mps_splice::line, and AlCaHLTBitMon_QueryRunRegistry::string.

33  {
34  //This method is a remnant of the old method, that provided a vector type of map, based on the
35  //raw reading of a file, with no processing.
36  //FIXME:
37  //This is not currently used, but I think we could slim this down to just a vector with
38  //the detIDs since the PSUChannel part of the excludedlist (if it ever is in a file) is never used!
39  edm::FileInPath file(mapFile.c_str());
40  std::ifstream ifs(file.fullPath().c_str());
41  string line;
42  while (getline(ifs, line)) {
43  if (!line.empty()) {
44  // split the line and insert in the map
45  stringstream ss(line);
46  string PSUChannel;
47  uint32_t detId;
48  ss >> detId;
49  ss >> PSUChannel;
50  rawmap.push_back(std::make_pair(detId, PSUChannel));
51  }
52  }
53 }
void SiStripPsuDetIdMap::BuildMap ( const std::string &  mapFile,
const bool  debug,
std::map< std::string, std::vector< uint32_t > > &  LVmap,
std::map< std::string, std::vector< uint32_t > > &  HVmap,
std::map< std::string, std::vector< uint32_t > > &  HVUnmappedmap,
std::map< std::string, std::vector< uint32_t > > &  HVCrosstalkingmap 
)

Overloaded method that does the buidling.

void SiStripPsuDetIdMap::checkMapInputValues ( const SiStripConfigDb::DcuDetIdsV dcuDetIds_,
const DcuPsuVector dcuPsus_ 
)
private

Produces a detailed debug of the input values.

Definition at line 507 of file SiStripPsuDetIdMap.cc.

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

508  {
509  std::cout << "Number of entries in DCU-PSU map: " << dcuPsus_.size() << std::endl;
510  std::cout << "Number of entries in DCU-DETID map: " << dcuDetIds_.size() << std::endl;
511  std::cout << std::endl;
512 
513  std::vector<bool> ddUsed(dcuDetIds_.size(), false);
514  std::vector<bool> dpUsed(dcuPsus_.size(), false);
515 
516  for (unsigned int dp = 0; dp < dcuPsus_.size(); dp++) {
517  for (unsigned int dd = 0; dd < dcuDetIds_.size(); dd++) {
518  if (dcuPsus_[dp]->getDcuHardId() == dcuDetIds_[dd].second->getDcuHardId()) {
519  dpUsed[dp] = true;
520  ddUsed[dd] = true;
521  }
522  }
523  }
524  unsigned int numDpUsed = 0, numDpNotUsed = 0;
525  for (unsigned int dp = 0; dp < dpUsed.size(); dp++) {
526  if (dpUsed[dp]) {
527  numDpUsed++;
528  } else {
529  numDpNotUsed++;
530  }
531  }
532 
533  std::cout << "Number of used DCU-PSU entries: " << numDpUsed << std::endl;
534  std::cout << "Number of unused DCU-PSU entries: " << numDpNotUsed << std::endl;
535 
536  unsigned int numDdUsed = 0, numDdNotUsed = 0;
537  for (unsigned int dd = 0; dd < ddUsed.size(); dd++) {
538  if (ddUsed[dd]) {
539  numDdUsed++;
540  } else {
541  numDdNotUsed++;
542  }
543  }
544 
545  std::cout << "Number of used DCU-DETID entries: " << numDdUsed << std::endl;
546  std::cout << "Number of unused DCU-DETID entries: " << numDdNotUsed << std::endl;
547  std::cout << std::endl;
548  std::cout << "Size of PSU-DETID map: " << pgMap.size() << std::endl;
549  std::cout << "Size of detectorLocations: " << detectorLocations.size() << std::endl;
550 }
std::vector< std::string > detectorLocations
std::vector< std::pair< uint32_t, std::string > > pgMap
void SiStripPsuDetIdMap::clone ( DcuPsuVector input,
DcuPsuVector output 
)
private

Utility to clone a DCU-PSU map.

Definition at line 473 of file SiStripPsuDetIdMap.cc.

References mps_fire::i.

473  {
474  output.clear();
475  for (unsigned int i = 0; i < input.size(); i++) {
476  output.push_back(new TkDcuPsuMap(*(input[i])));
477  }
478 }
static std::string const input
Definition: EdmProvDump.cc:48
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 625 of file SiStripPsuDetIdMap.cc.

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

625  {
626  std::vector<std::pair<std::vector<uint16_t>, std::vector<uint32_t> > >::iterator iter =
627  dcu_device_addr_vector.begin();
628  std::vector<std::pair<std::vector<uint16_t>, std::vector<uint32_t> > >::iterator res_iter =
630  std::vector<uint32_t> pgDcu;
631 
632  for (; iter != dcu_device_addr_vector.end(); iter++) {
633  std::vector<uint32_t> dcuids = iter->second;
634  std::vector<uint32_t>::iterator dcu_iter = std::find(dcuids.begin(), dcuids.end(), dcuid_);
635  bool alreadyFound = false;
636  if (res_iter != dcu_device_addr_vector.end()) {
637  alreadyFound = true;
638  }
639  if (dcu_iter != dcuids.end()) {
640  res_iter = iter;
641  if (!alreadyFound) {
642  for (unsigned int i = 0; i < dcuids.size(); i++) {
643  if (dcuids[i] != dcuid_) {
644  pgDcu.push_back(dcuids[i]);
645  }
646  }
647  } else {
648  std::cout << "Oh oh ... we have a duplicate :-(" << std::endl;
649  }
650  }
651  }
652  return pgDcu;
653 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< std::pair< std::vector< uint16_t >, std::vector< uint32_t > > > dcu_device_addr_vector
std::vector<uint32_t> SiStripPsuDetIdMap::getCcuDcuIds ( )
inline

Return the CCU DCU IDs associated to the CG map.

Definition at line 91 of file SiStripPsuDetIdMap.h.

References BuildMap(), ccuDcuIds, debug, getDcuPsuMap(), IsHVChannel(), genParticles_cff::map, printControlMap(), printMap(), RemoveDuplicateDetIDs(), and AlCaHLTBitMon_QueryRunRegistry::string.

91 { 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 89 of file SiStripPsuDetIdMap.h.

References cgDcuIds.

89 { 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 87 of file SiStripPsuDetIdMap.h.

References controlLocations.

87 { 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 85 of file SiStripPsuDetIdMap.h.

References cgMap.

85 { return cgMap; }
std::vector< std::pair< uint32_t, std::string > > 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 426 of file SiStripPsuDetIdMap.cc.

References mps_fire::i, and edm::second().

426  {
427  for (unsigned int i = 0; i < pgMap.size(); i++) {
428  if (pgMap[i].second == PSUChannel) {
429  return dcuIds[i];
430  }
431  }
432  for (unsigned int i = 0; i < cgMap.size(); i++) {
433  if (cgMap[i].second == PSUChannel) {
434  return cgDcuIds[i];
435  }
436  }
437  return 0;
438 }
std::vector< uint32_t > cgDcuIds
U second(std::pair< T, U > const &p)
std::vector< uint32_t > dcuIds
std::vector< std::pair< uint32_t, std::string > > pgMap
std::vector< std::pair< uint32_t, std::string > > cgMap
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 440 of file SiStripPsuDetIdMap.cc.

References plotBeamSpotDB::first, and mps_fire::i.

440  {
441  for (unsigned int i = 0; i < pgMap.size(); i++) {
442  if (pgMap[i].first == detid) {
443  return dcuIds[i];
444  }
445  }
446  return 0;
447 }
std::vector< uint32_t > dcuIds
std::vector< std::pair< uint32_t, std::string > > pgMap
std::vector<uint32_t> SiStripPsuDetIdMap::getDcuIds ( )
inline

Return the DCU IDs associated to the PG map.

Definition at line 83 of file SiStripPsuDetIdMap.h.

References dcuIds.

83 { 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 499 of file SiStripPsuDetIdMap.cc.

Referenced by getCcuDcuIds().

499  {
500  if (!pgMap.empty()) {
501  return pgMap;
502  }
503  std::vector<std::pair<uint32_t, std::string> > emptyVec;
504  return emptyVec;
505 }
std::vector< std::pair< uint32_t, std::string > > pgMap
void SiStripPsuDetIdMap::getDcuPsuMap ( DcuPsusRange pRange,
DcuPsusRange cRange,
std::string  partition 
)
private

Extracts the DCU-PSU map from the DB.

std::string SiStripPsuDetIdMap::getDetectorLocation ( uint32_t  detid)

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

Definition at line 382 of file SiStripPsuDetIdMap.cc.

References plotBeamSpotDB::first, and mps_fire::i.

382  {
383  for (unsigned int i = 0; i < pgMap.size(); i++) {
384  if (pgMap[i].first == detid) {
385  return detectorLocations[i];
386  }
387  }
388  return "UNKNOWN";
389 }
std::vector< std::string > detectorLocations
std::vector< std::pair< uint32_t, std::string > > pgMap
std::string SiStripPsuDetIdMap::getDetectorLocation ( std::string  pvss)

Returns the detector location for the specified PSU channel.

Definition at line 411 of file SiStripPsuDetIdMap.cc.

References mps_fire::i, and edm::second().

411  {
412  for (unsigned int i = 0; i < pgMap.size(); i++) {
413  if (pgMap[i].second == PSUChannel) {
414  return detectorLocations[i];
415  }
416  }
417  for (unsigned int i = 0; i < cgMap.size(); i++) {
418  if (cgMap[i].second == PSUChannel) {
419  return controlLocations[i];
420  }
421  }
422  return "UNKNOWN";
423 }
U second(std::pair< T, U > const &p)
std::vector< std::string > controlLocations
std::vector< std::string > detectorLocations
std::vector< std::pair< uint32_t, std::string > > pgMap
std::vector< std::pair< uint32_t, std::string > > cgMap
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 392 of file SiStripPsuDetIdMap.cc.

References plotBeamSpotDB::first, and mps_fire::i.

392  {
393  if (group == "PG") {
394  for (unsigned int i = 0; i < pgMap.size(); i++) {
395  if (pgMap[i].first == detid) {
396  return detectorLocations[i];
397  }
398  }
399  }
400  if (group == "CG") {
401  for (unsigned int i = 0; i < cgMap.size(); i++) {
402  if (cgMap[i].first == detid) {
403  return controlLocations[i];
404  }
405  }
406  }
407  return "UNKNOWN";
408 }
std::vector< std::string > controlLocations
std::vector< std::string > detectorLocations
std::vector< std::pair< uint32_t, std::string > > pgMap
std::vector< std::pair< uint32_t, std::string > > cgMap
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 81 of file SiStripPsuDetIdMap.h.

References detectorLocations.

81 { return detectorLocations; }
std::vector< std::string > detectorLocations
void SiStripPsuDetIdMap::getDetID ( std::string  pvss,
bool  debug,
std::vector< uint32_t > &  detids,
std::vector< uint32_t > &  unmapped_detids,
std::vector< uint32_t > &  crosstalking_detids 
)

Definition at line 195 of file SiStripPsuDetIdMap.cc.

References gather_cfg::cout, or, and AlCaHLTBitMon_QueryRunRegistry::string.

199  {
200  //This function takes as argument the PSUChannel (i.e. the dpname as it comes from the PVSS query, e.g. cms_trk_dcs_02:CAEN/CMS_TRACKER_SY1527_2/branchController05/easyCrate0/easyBoard12/channel001)
201  //And it returns 3 vectors:
202  //1-detids->all the detids positively matching the PSUChannel in question
203  //2-unmapped_detids->the detids that are matching the PSU in question but that are not HV mapped
204  //3-crosstalking_detids->the detids that are matching the PSU in question but exhibit the HV channel cross-talking behavior (they are ON as long as ANY of the 2 HV channels of the supply is ON, so they only go OFF when both channels are OFF)
205  //The second and third vectors are only relevant for the HV case, when unmapped and cross-talking channels need further processing before being turned ON and OFF.
206 
207  const std::string& PSUChannelFromQuery = PSUChannel;
208 
209  //Get the channel to see if it is LV or HV, they will be treated differently
210  std::string ChannelFromQuery = PSUChannelFromQuery.substr(PSUChannelFromQuery.size() - 10);
211  //Get the PSU from Query, to be used for LVMap and for the HVUnmapped and HVCrosstalking maps:
212  std::string PSUFromQuery = PSUChannelFromQuery.substr(0, PSUChannelFromQuery.size() - 10);
213  if (debug) {
214  //FIXME:
215  //Should handle all the couts with MessageLogger!
216  std::cout << "DPNAME from QUERY: " << PSUChannelFromQuery << ", Channel: " << ChannelFromQuery
217  << "PSU: " << PSUFromQuery << std::endl;
218  }
219 
220  //First prepare the strings needed to do the matching of the PSUChannel from the query to the ones in the map
221 
222  //Handle the LV case first:
223  if (ChannelFromQuery == "channel000" or ChannelFromQuery == "channel001") {
224  //For LV channels we need to look for any detID that is reported either as channel000 (not HV mapped)
225  //but also as channel002 and channel003 (if they are HV mapped), or as channel999 (if they are in a crosstalking PSU)
226  //Get the PSU to do a PSU-only matching to get all detIDs connected to the LV channel:
227  //Now loop over the map!
228  //for (PsuDetIdMap::iterator iter = pgMap.begin(); iter != pgMap.end(); iter++) {
229  // std::string PSUFromMap = iter->second.substr(0,iter->second.size()-10);
230  // //Careful if you uncomment this cout: it prints 15148 lines when checking for 1 psu name match! (meant for debugging of course)
231  // //std::cout<<"Truncated DPNAME from MAP: "<<PSUFromMap<<std::endl;
232  // if (PSUFromQuery == PSUFromMap) {
233  // detids.push_back(iter->first); //And fill the detids vector with the all detids matching the PSU from the query!
234  // }
235  //}
236  //No need to loop over if we use an actual map!
237 
238  if (LVMap.find(PSUFromQuery) != LVMap.end()) {
239  detids = LVMap[PSUFromQuery];
240  }
241  }
242  //Handle the HV case too:
243  else if (ChannelFromQuery == "channel002" or ChannelFromQuery == "channel003") {
244  //For the HV channel we need to look at the actual positive matching detIDs,
245  //but also to the unmapped one (channel000) and the crosstalking ones (channel999).
246  //Assemble the corresponding channel000 (unmapped channels) replacing the last character in PSUChannelFromQuery:
247  // std::string ZeroedPSUChannelFromQuery= PSUChannelFromQuery;
248  // ZeroedPSUChannelFromQuery.replace(ZeroedPSUChannelFromQuery.size()-1,1,"0");
249  // //Same for channel999 for the crosstalking channels:
250  // //std::string NineNineNine='999';
251  // std::string NinedPSUChannelFromQuery= PSUChannelFromQuery;
252  // NinedPSUChannelFromQuery.replace(NinedPSUChannelFromQuery.size()-3,3,"999");
253  // //std::string NinedPSUChannelFromQuery= PSUChannelFromQuery.substr(0,PSUChannelFromQuery.size()-3);// + '999';
254  // //Now loop over the map!
255  // for (PsuDetIdMap::iterator iter = pgMap.begin(); iter != pgMap.end(); iter++) {
256  // std::string PSUChannelFromMap = iter->second;
257  // //Careful if you uncomment this cout: it prints 15148 lines when checking for 1 psu name match! (meant for debugging of course)
258  // //std::cout<<"Truncated DPNAME from MAP: "<<PSUFromMap<<std::endl;
259  // if (PSUChannelFromMap==PSUChannelFromQuery) {
260  // detids.push_back(iter->first); //Fill the detids vector with the all detids matching the PSUChannel from the query!
261  // }
262  // if (PSUChannelFromMap==ZeroedPSUChannelFromQuery) {
263  // unmapped_detids.push_back(iter->first); //Fill the unmapped_detids vector with the all detids matching the channel000 for the PSU from the query!
264  // if (debug) { //BEWARE: this debug printouts can become very heavy! 1 print out per detID matched!
265  // std::cout<<"Matched one of the HV-UNMAPPED channels: "<<ZeroedPSUChannelFromQuery<<std::endl;
266  // std::cout<<"Corresponding to detID: "<<iter->first<<std::endl;
267  // //for (unsigned int i_nohvmap_detid=0;i_nohvmap_detid < iter->first.size();i_nohvmap_detid++) {
268  // // cout<< iter->first[i_nohvmap_detid] << std::endl;
269  // }
270  // }
271  // if (PSUChannelFromMap==NinedPSUChannelFromQuery) {
272  // crosstalking_detids.push_back(iter->first); //Fill the crosstalking_detids vector with the all detids matching the channel999 for the PSU from the query!
273  // }
274  // }
275  if (HVMap.find(PSUChannelFromQuery) != HVMap.end()) {
276  detids = HVMap[PSUChannelFromQuery];
277  } else if (HVUnmapped_Map.find(PSUFromQuery) != HVUnmapped_Map.end()) {
278  unmapped_detids = HVUnmapped_Map[PSUFromQuery];
279  } else if (HVCrosstalking_Map.find(PSUFromQuery) != HVCrosstalking_Map.end()) {
280  crosstalking_detids = HVCrosstalking_Map[PSUFromQuery];
281  }
282  }
283  //
284  //
285  // //With the new code above that makes use of the channel00X information in the map
286  // //we should no more need to remove duplicates by construction.
287  // //The following code was used when there was no channel information in the map,
288  // //to elegantly eliminate duplicates.
289  // //We can now use it as a cross-check (still removing duplicates in case they happen, but writing a message out)
290  //
291  // // remove duplicates
292  //
293  // //First sort detIDs vector, so that duplicates will be consecutive
294  // if (!detids.empty()) {
295  // std::sort(detids.begin(),detids.end());
296  // //Then use the forward iterator unique from STD that basically removes all consecutive duplicates from the vector
297  // //and reports a forward iterator pointing to the new end of the sequence
298  // std::vector<uint32_t>::iterator it = std::unique(detids.begin(),detids.end());
299  // if (it!=detids.end()) {
300  // std::cout<<"ARGH! It seems we found duplicate detIDs in the map corresponding to this PSUChannel: "<<PSUChannelFromQuery<<std::endl;
301  // detids.resize( it - detids.begin() );
302  // }
303  // if (debug) {
304  // std::cout<<"Matched the following detIDs to PSU channel from query "<<PSUChannelFromQuery <<":"<<std::endl;
305  // for (std::vector<uint32_t>::iterator i_detid=detids.begin();i_detid!=detids.end(); i_detid++) {
306  // std::cout<<*i_detid<<std::endl;;
307  // }
308  // }
309  // }
310  // //Same for unmapped detIDs:
311  // if (!unmapped_detids.empty()) {
312  // std::sort(unmapped_detids.begin(),unmapped_detids.end());
313  // //Then use the forward iterator unique from STD that basically removes all consecutive duplicates from the vector
314  // //and reports a forward iterator pointing to the new end of the sequence
315  // std::vector<uint32_t>::iterator it = std::unique(unmapped_detids.begin(),unmapped_detids.end());
316  // if (it!=unmapped_detids.end()) {
317  // std::cout<<"ARGH! It seems we found duplicate unmapped_detids in the map corresponding to this PSUChannel: "<<PSUChannelFromQuery<<std::endl;
318  // unmapped_detids.resize( it - unmapped_detids.begin() );
319  // }
320  // if (debug) {
321  // std::cout<<"Matched the following unmapped_detids to PSU channel from query "<<PSUChannelFromQuery <<":"<<std::endl;
322  // for (std::vector<uint32_t>::iterator i_detid=unmapped_detids.begin();i_detid!=unmapped_detids.end(); i_detid++) {
323  // std::cout<<*i_detid<<std::endl;;
324  // }
325  // }
326  // }
327  // //Finally, same for crosstalking detIDs:
328  // if (!crosstalking_detids.empty()) {
329  // std::sort(crosstalking_detids.begin(),crosstalking_detids.end());
330  // //Then use the forward iterator unique from STD that basically removes all consecutive duplicates from the vector
331  // //and reports a forward iterator pointing to the new end of the sequence
332  // std::vector<uint32_t>::iterator it = std::unique(crosstalking_detids.begin(),crosstalking_detids.end());
333  // if (it!=crosstalking_detids.end()) {
334  // std::cout<<"ARGH! It seems we found duplicate crosstalking_detids in the map corresponding to this PSUChannel: "<<PSUChannelFromQuery<<std::endl;
335  // crosstalking_detids.resize( it - crosstalking_detids.begin() );
336  // }
337  // if (debug) {
338  // std::cout<<"Matched the following crosstalking_detids to PSU channel from query "<<PSUChannelFromQuery <<":"<<std::endl;
339  // for (std::vector<uint32_t>::iterator i_detid=crosstalking_detids.begin();i_detid!=crosstalking_detids.end(); i_detid++) {
340  // std::cout<<*i_detid<<std::endl;;
341  // }
342  // }
343  // }
344  //
345  // //Using reference parameters since we are returning multiple objects.
346  // //return detids;
347 }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
#define debug
Definition: HDRShower.cc:19
PsuDetIdMap HVCrosstalking_Map
std::map<std::string, std::vector<uint32_t> > SiStripPsuDetIdMap::getHVCrosstalkingMap ( )
inline

Definition at line 73 of file SiStripPsuDetIdMap.h.

References HVCrosstalking_Map.

Referenced by SiStripDetVOffBuilder::buildPSUdetIdMap().

73 { return HVCrosstalking_Map; }
PsuDetIdMap HVCrosstalking_Map
void SiStripPsuDetIdMap::getHvDetID ( std::string  psuchannel,
std::vector< uint32_t > &  ids,
std::vector< uint32_t > &  unmapped_ids,
std::vector< uint32_t > &  crosstalking_ids 
)

Definition at line 173 of file SiStripPsuDetIdMap.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by SiStripDetVOffBuilder::buildPSUdetIdMap().

176  {
177  //Function that (via reference parameters) populates ids, unmapped_ids, crosstalking_ids vectors of detids associated with a given PSU *HV* channel.
178  if (HVMap.find(PSUChannel) != HVMap.end()) {
179  ids = HVMap[PSUChannel];
180  }
181  //Extract the PSU to check the unmapped and crosstalking maps too corresponding to this channel
182  std::string PSU = PSUChannel.substr(0, PSUChannel.size() - 10);
183  if (HVUnmapped_Map.find(PSU) != HVUnmapped_Map.end()) {
184  unmapped_ids = HVUnmapped_Map[PSU];
185  }
186  if (HVCrosstalking_Map.find(PSU) != HVCrosstalking_Map.end()) {
187  crosstalking_ids = HVCrosstalking_Map[PSU];
188  }
189 }
PsuDetIdMap HVCrosstalking_Map
std::map<std::string, std::vector<uint32_t> > SiStripPsuDetIdMap::getHVUnmappedMap ( )
inline

Definition at line 71 of file SiStripPsuDetIdMap.h.

References HVUnmapped_Map.

Referenced by SiStripDetVOffBuilder::buildPSUdetIdMap().

71 { return HVUnmapped_Map; }
std::vector< uint32_t > SiStripPsuDetIdMap::getLvDetID ( std::string  psu)

Definition at line 162 of file SiStripPsuDetIdMap.cc.

Referenced by SiStripDetVOffBuilder::buildPSUdetIdMap().

162  {
163  //Function that returns a vector with all detids associated with a PSU
164  //(no channel information is saved in the map since it is not relevant for LV!)
165  if (LVMap.find(PSU) != LVMap.end()) {
166  return LVMap[PSU];
167  } else {
168  std::vector<uint32_t> detids;
169  return detids;
170  }
171 }
std::vector<std::pair<uint32_t, std::string> > SiStripPsuDetIdMap::getPsuDetIdMap ( )
inline

Return the PG PSU-DETID map as a vector.

Definition at line 79 of file SiStripPsuDetIdMap.h.

References pgMap.

79 { return pgMap; }
std::vector< std::pair< uint32_t, std::string > > 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 350 of file SiStripPsuDetIdMap.cc.

350  {
351  std::vector<std::pair<uint32_t, std::string> >::iterator iter;
352  for (iter = pgMap.begin(); iter != pgMap.end(); iter++) {
353  if (iter->first && iter->first == detid) {
354  return iter->second;
355  }
356  }
357  // if we reach here, then we didn't find the detid in the map
358  return "UNKNOWN";
359 }
std::vector< std::pair< uint32_t, std::string > > pgMap
std::string SiStripPsuDetIdMap::getPSUName ( uint32_t  detid,
std::string  group 
)

Returns the PSU channel name for the specified Det ID.

Definition at line 361 of file SiStripPsuDetIdMap.cc.

361  {
362  std::vector<std::pair<uint32_t, std::string> >::iterator iter;
363  if (group == "PG") {
364  for (iter = pgMap.begin(); iter != pgMap.end(); iter++) {
365  if (iter->first && iter->first == detid) {
366  return iter->second;
367  }
368  }
369  }
370  if (group == "CG") {
371  for (iter = cgMap.begin(); iter != cgMap.end(); iter++) {
372  if (iter->first && iter->first == detid) {
373  return iter->second;
374  }
375  }
376  }
377  // if we reach here, then we didn't find the detid in the map
378  return "UNKNOWN";
379 }
std::vector< std::pair< uint32_t, std::string > > pgMap
std::vector< std::pair< uint32_t, std::string > > cgMap
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 450 of file SiStripPsuDetIdMap.cc.

References create_public_lumi_plots::loc, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getCcuDcuIds().

450  {
451  // isHV = 0 means LV, = 1 means HV, = -1 means error
452  int isHV = 0;
453  std::string::size_type loc = PSUChannel.find("channel", 0);
454  if (loc != std::string::npos) {
455  std::string chNumber = PSUChannel.substr(loc + 7, 3);
456  if (chNumber == "002" || chNumber == "003") {
457  isHV = 1;
458  } else if (chNumber == "000" || chNumber == "001") {
459  isHV = 0;
460  } else {
461  edm::LogWarning("SiStripPsuDetIdMap")
462  << "[SiStripPsuDetIdMap::" << __func__ << "] channel number of unexpected format, setting error flag!";
463  isHV = -1;
464  }
465  } else {
466  edm::LogWarning("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__
467  << "] channel number not located in PSU channel name, setting error flag!";
468  isHV = -1;
469  }
470  return isHV;
471 }
uint16_t size_type
void SiStripPsuDetIdMap::printControlMap ( )

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

Definition at line 489 of file SiStripPsuDetIdMap.cc.

References AlCaHLTBitMon_ParallelJobs::p.

Referenced by getCcuDcuIds().

489  {
490  stringstream cg;
491  cg << "Map of control power supplies to DET IDs: " << std::endl
492  << "-- PSU name -- -- Det Id --" << std::endl;
493  for (unsigned int p = 0; p < cgMap.size(); p++) {
494  cg << cgMap[p].first << " " << cgMap[p].second << std::endl;
495  }
496  edm::LogInfo("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] " << cg.str();
497 }
std::vector< std::pair< uint32_t, std::string > > cgMap
void SiStripPsuDetIdMap::printMap ( )

Produces a formatted printout of the PSU-DETID map.

Definition at line 480 of file SiStripPsuDetIdMap.cc.

References AlCaHLTBitMon_ParallelJobs::p.

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

480  {
481  stringstream pg;
482  pg << "Map of power supplies to DET IDs: " << std::endl << "-- PSU name -- -- Det Id --" << std::endl;
483  for (unsigned int p = 0; p < pgMap.size(); p++) {
484  pg << pgMap[p].first << " " << pgMap[p].second << std::endl;
485  }
486  edm::LogInfo("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] " << pg.str();
487 }
std::vector< std::pair< uint32_t, std::string > > pgMap
void SiStripPsuDetIdMap::RemoveDuplicateDetIDs ( std::vector< uint32_t > &  detids)

Definition at line 153 of file SiStripPsuDetIdMap.cc.

References tier0::unique().

Referenced by getCcuDcuIds().

153  {
154  //Function to remove duplicates from a vector of detids
155  if (!detids.empty()) { //Leave empty vector alone ;)
156  std::sort(detids.begin(), detids.end());
157  std::vector<uint32_t>::iterator it = std::unique(detids.begin(), detids.end());
158  detids.resize(it - detids.begin());
159  }
160 }
def unique(seq, keepstr=True)
Definition: tier0.py:25
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 553 of file SiStripPsuDetIdMap.cc.

References begin, SiStripPartition::defaultPartitionName_, end, plotBeamSpotDB::first, mps_fire::i, SiStripDbParams::partitions(), and tier0::unique().

554  {
555  // get the DB parameters
556  SiStripDbParams dbParams_ = db_->dbParams();
557  SiStripDbParams::SiStripPartitions::const_iterator iter;
558 
559  std::vector<std::pair<uint32_t, SiStripConfigDb::DeviceAddress> > resultVec;
560 
562  SiStripConfigDb::DeviceType device_ = DCU;
563 
564  for (iter = dbParams_.partitions().begin(); iter != dbParams_.partitions().end(); ++iter) {
565  if (partition.empty() || partition == iter->second.partitionName()) {
566  if (iter->second.partitionName() == SiStripPartition::defaultPartitionName_) {
567  continue;
568  }
569  if (iter->second.dcuVersion().first > 0 && iter->second.fecVersion().first > 0) {
571  db_->getDeviceDescriptions(device_, iter->second.partitionName());
572  if (!range.empty()) {
573  SiStripConfigDb::DeviceDescriptionsV nextVec(range.begin(), range.end());
574  for (unsigned int i = 0; i < nextVec.size(); i++) {
575  dcuDescription* desc = dynamic_cast<dcuDescription*>(nextVec[i]);
576  resultVec.push_back(std::make_pair(desc->getDcuHardId(), db_->deviceAddress(*(nextVec[i]))));
577  }
578  }
579  }
580  }
581  }
582 
583  std::vector<std::pair<std::vector<uint16_t>, std::vector<uint32_t> > > testVec;
584  std::vector<std::pair<uint32_t, SiStripConfigDb::DeviceAddress> >::iterator reorg_iter = resultVec.begin();
585 
586  for (; reorg_iter != resultVec.end(); reorg_iter++) {
587  std::vector<uint16_t> fecInfo(4, 0);
588  fecInfo[0] = reorg_iter->second.fecCrate_;
589  fecInfo[1] = reorg_iter->second.fecSlot_;
590  fecInfo[2] = reorg_iter->second.fecRing_;
591  fecInfo[3] = reorg_iter->second.ccuAddr_;
592  std::vector<uint32_t> dcuids;
593  std::vector<std::pair<uint32_t, SiStripConfigDb::DeviceAddress> >::iterator jter = reorg_iter;
594  for (; jter != resultVec.end(); jter++) {
595  if (reorg_iter->second.fecCrate_ == jter->second.fecCrate_ &&
596  reorg_iter->second.fecSlot_ == jter->second.fecSlot_ &&
597  reorg_iter->second.fecRing_ == jter->second.fecRing_ &&
598  reorg_iter->second.ccuAddr_ == jter->second.ccuAddr_) {
599  dcuids.push_back(jter->first);
600  }
601  }
602  // handle duplicates
603  bool isDup = false;
604  for (unsigned int i = 0; i < testVec.size(); i++) {
605  if (fecInfo == testVec[i].first) {
606  isDup = true;
607  dcuids.insert(dcuids.end(), (testVec[i].second).begin(), (testVec[i].second).end());
608  std::sort(dcuids.begin(), dcuids.end());
609  std::vector<uint32_t>::iterator it = std::unique(dcuids.begin(), dcuids.end());
610  dcuids.resize(it - dcuids.begin());
611  testVec[i].second = dcuids;
612  }
613  }
614  if (!isDup) {
615  std::sort(dcuids.begin(), dcuids.end());
616  std::vector<uint32_t>::iterator it = std::unique(dcuids.begin(), dcuids.end());
617  dcuids.resize(it - dcuids.begin());
618  testVec.push_back(std::make_pair(fecInfo, dcuids));
619  }
620  }
621  // return resultVec;
622  return testVec;
623 }
static const std::string defaultPartitionName_
const_iterator_range partitions() const
enumDeviceType DeviceType
edm::Service< SiStripConfigDb > db_
DeviceDescriptions::range DeviceDescriptionsRange
def unique(seq, keepstr=True)
Definition: tier0.py:25
#define end
Definition: vmac.h:39
DeviceAddress deviceAddress(const deviceDescription &)
const SiStripDbParams & dbParams() const
Container class for database connection parameters.
#define begin
Definition: vmac.h:32
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
std::vector< DeviceDescription * > DeviceDescriptionsV

Member Data Documentation

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

Definition at line 147 of file SiStripPsuDetIdMap.h.

Referenced by getCcuDcuIds().

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

Definition at line 147 of file SiStripPsuDetIdMap.h.

Referenced by getCgDcuIds().

std::vector<std::pair<uint32_t, std::string> > SiStripPsuDetIdMap::cgMap
private

Definition at line 145 of file SiStripPsuDetIdMap.h.

Referenced by getControlPsuDetIdMap().

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

Definition at line 146 of file SiStripPsuDetIdMap.h.

Referenced by getControlDetectorLocations().

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

Definition at line 143 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 150 of file SiStripPsuDetIdMap.h.

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

Definition at line 147 of file SiStripPsuDetIdMap.h.

Referenced by getDcuIds().

DcuPsus SiStripPsuDetIdMap::DcuPsuMapCG_
private

Definition at line 148 of file SiStripPsuDetIdMap.h.

DcuPsus SiStripPsuDetIdMap::DcuPsuMapPG_
private

Definition at line 148 of file SiStripPsuDetIdMap.h.

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

Definition at line 146 of file SiStripPsuDetIdMap.h.

Referenced by getDetectorLocations().

PsuDetIdMap SiStripPsuDetIdMap::HVCrosstalking_Map
private

Definition at line 144 of file SiStripPsuDetIdMap.h.

Referenced by getHVCrosstalkingMap().

PsuDetIdMap SiStripPsuDetIdMap::HVMap
private

Definition at line 144 of file SiStripPsuDetIdMap.h.

PsuDetIdMap SiStripPsuDetIdMap::HVUnmapped_Map
private

Definition at line 144 of file SiStripPsuDetIdMap.h.

Referenced by getHVUnmappedMap().

PsuDetIdMap SiStripPsuDetIdMap::LVMap
private

Definition at line 144 of file SiStripPsuDetIdMap.h.

std::vector<std::pair<uint32_t, std::string> > SiStripPsuDetIdMap::pgMap
private

Definition at line 145 of file SiStripPsuDetIdMap.h.

Referenced by getPsuDetIdMap().