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 (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 115 of file SiStripPsuDetIdMap.h.

Definition at line 116 of file SiStripPsuDetIdMap.h.

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

Definition at line 113 of file SiStripPsuDetIdMap.h.

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

Definition at line 114 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 ( 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 25 of file SiStripPsuDetIdMap.cc.

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

26 {
28 }
#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 30 of file SiStripPsuDetIdMap.cc.

References mergeVDriftHistosByStation::file, geometryCSVtoXML::line, and contentValuesCheck::ss.

30  {
31  //This method is a remnant of the old method, that provided a vector type of map, based on the
32  //raw reading of a file, with no processing.
33  //FIXME:
34  //This is not currently used, but I think we could slim this down to just a vector with
35  //the detIDs since the PSUChannel part of the excludedlist (if it ever is in a file) is never used!
36  edm::FileInPath file(mapFile.c_str());
37  std::ifstream ifs( file.fullPath().c_str() );
38  string line;
39  while( getline( ifs, line ) ) {
40  if( line != "" ) {
41  // split the line and insert in the map
42  stringstream ss(line);
43  string PSUChannel;
44  uint32_t detId;
45  ss >> detId;
46  ss >> PSUChannel;
47  rawmap.push_back(std::make_pair(detId, PSUChannel) );
48  }
49  }
50 }
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 469 of file SiStripPsuDetIdMap.cc.

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

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

Utility to clone a DCU-PSU map.

Definition at line 436 of file SiStripPsuDetIdMap.cc.

References i.

436  {
437  output.clear();
438  for (unsigned int i = 0; i < input.size(); i++) {
439  output.push_back(new TkDcuPsuMap(*(input[i])));
440  }
441 }
int i
Definition: DBlmapReader.cc:9
static std::string const input
Definition: EdmProvDump.cc:44
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 576 of file SiStripPsuDetIdMap.cc.

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

576  {
577  std::vector< std::pair< std::vector<uint16_t> , std::vector<uint32_t> > >::iterator iter = dcu_device_addr_vector.begin();
578  std::vector< std::pair< std::vector<uint16_t> , std::vector<uint32_t> > >::iterator res_iter = dcu_device_addr_vector.end();
579  std::vector<uint32_t> pgDcu;
580 
581  for ( ; iter != dcu_device_addr_vector.end(); iter++) {
582  std::vector<uint32_t> dcuids = iter->second;
583  std::vector<uint32_t>::iterator dcu_iter = std::find(dcuids.begin(),dcuids.end(),dcuid_);
584  bool alreadyFound = false;
585  if (res_iter != dcu_device_addr_vector.end()) {alreadyFound = true;}
586  if (dcu_iter != dcuids.end()) {
587  res_iter = iter;
588  if (!alreadyFound) {
589  for (unsigned int i = 0; i < dcuids.size(); i++) {
590  if (dcuids[i] != dcuid_) {pgDcu.push_back(dcuids[i]);}
591  }
592  } else {
593  std::cout << "Oh oh ... we have a duplicate :-(" << std::endl;
594  }
595  }
596  }
597  return pgDcu;
598 }
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:145
std::vector<uint32_t> SiStripPsuDetIdMap::getCcuDcuIds ( )
inline

Return the CCU DCU IDs associated to the CG map.

Definition at line 85 of file SiStripPsuDetIdMap.h.

References ccuDcuIds.

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

References cgDcuIds.

83 {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 81 of file SiStripPsuDetIdMap.h.

References controlLocations.

81 {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 79 of file SiStripPsuDetIdMap.h.

References cgMap.

79 {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 397 of file SiStripPsuDetIdMap.cc.

References i, and edm::second().

397  {
398  for (unsigned int i = 0; i < pgMap.size(); i++) {
399  if (pgMap[i].second == PSUChannel) {return dcuIds[i];}
400  }
401  for (unsigned int i = 0; i < cgMap.size(); i++) {
402  if (cgMap[i].second == PSUChannel) {return cgDcuIds[i];}
403  }
404  return 0;
405 }
int i
Definition: DBlmapReader.cc:9
std::vector< uint32_t > cgDcuIds
U second(std::pair< T, U > const &p)
std::vector< std::pair< uint32_t, std::string > > pgMap
std::vector< std::pair< uint32_t, std::string > > cgMap
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 407 of file SiStripPsuDetIdMap.cc.

References plotBeamSpotDB::first, and i.

407  {
408  for (unsigned int i = 0; i < pgMap.size(); i++) {
409  if (pgMap[i].first == detid) {return dcuIds[i];}
410  }
411  return 0;
412 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::pair< uint32_t, std::string > > pgMap
std::vector< uint32_t > dcuIds
std::vector<uint32_t> SiStripPsuDetIdMap::getDcuIds ( )
inline

Return the DCU IDs associated to the PG map.

Definition at line 77 of file SiStripPsuDetIdMap.h.

References dcuIds.

77 {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 463 of file SiStripPsuDetIdMap.cc.

463  {
464  if (pgMap.size() != 0) { return pgMap; }
465  std::vector< std::pair<uint32_t, std::string> > emptyVec;
466  return emptyVec;
467 }
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 363 of file SiStripPsuDetIdMap.cc.

References plotBeamSpotDB::first, and i.

363  {
364  for (unsigned int i = 0; i < pgMap.size(); i++) {
365  if (pgMap[i].first == detid) {return detectorLocations[i];}
366  }
367  return "UNKNOWN";
368 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::pair< uint32_t, std::string > > pgMap
std::vector< std::string > detectorLocations
std::string SiStripPsuDetIdMap::getDetectorLocation ( std::string  pvss)

Returns the detector location for the specified PSU channel.

Definition at line 386 of file SiStripPsuDetIdMap.cc.

References i, and edm::second().

386  {
387  for (unsigned int i = 0; i < pgMap.size(); i++) {
388  if (pgMap[i].second == PSUChannel) {return detectorLocations[i];}
389  }
390  for (unsigned int i = 0; i < cgMap.size(); i++) {
391  if (cgMap[i].second == PSUChannel) {return controlLocations[i];}
392  }
393  return "UNKNOWN";
394 }
int i
Definition: DBlmapReader.cc:9
U second(std::pair< T, U > const &p)
std::vector< std::pair< uint32_t, std::string > > pgMap
std::vector< std::pair< uint32_t, std::string > > cgMap
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 371 of file SiStripPsuDetIdMap.cc.

References plotBeamSpotDB::first, and i.

371  {
372  if (group == "PG") {
373  for (unsigned int i = 0; i < pgMap.size(); i++) {
374  if (pgMap[i].first == detid) {return detectorLocations[i];}
375  }
376  }
377  if (group == "CG") {
378  for (unsigned int i = 0; i < cgMap.size(); i++) {
379  if (cgMap[i].first == detid) {return controlLocations[i];}
380  }
381  }
382  return "UNKNOWN";
383 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::pair< uint32_t, std::string > > pgMap
std::vector< std::pair< uint32_t, std::string > > cgMap
std::vector< std::string > controlLocations
tuple group
Definition: watchdog.py:82
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 75 of file SiStripPsuDetIdMap.h.

References detectorLocations.

75 {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 184 of file SiStripPsuDetIdMap.cc.

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

184  {
185  //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)
186  //And it returns 3 vectors:
187  //1-detids->all the detids positively matching the PSUChannel in question
188  //2-unmapped_detids->the detids that are matching the PSU in question but that are not HV mapped
189  //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)
190  //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.
191 
192  std::string PSUChannelFromQuery = PSUChannel;
193 
194  //Get the channel to see if it is LV or HV, they will be treated differently
195  std::string ChannelFromQuery=PSUChannelFromQuery.substr(PSUChannelFromQuery.size()-10);
196  //Get the PSU from Query, to be used for LVMap and for the HVUnmapped and HVCrosstalking maps:
197  std::string PSUFromQuery=PSUChannelFromQuery.substr(0,PSUChannelFromQuery.size()-10);
198  if (debug) {
199  //FIXME:
200  //Should handle all the couts with MessageLogger!
201  std::cout << "DPNAME from QUERY: "<<PSUChannelFromQuery<<", Channel: "<<ChannelFromQuery<<"PSU: "<<PSUFromQuery<<std::endl;
202  }
203 
204  //First prepare the strings needed to do the matching of the PSUChannel from the query to the ones in the map
205 
206  //Handle the LV case first:
207  if (ChannelFromQuery=="channel000" or ChannelFromQuery=="channel001") {
208  //For LV channels we need to look for any detID that is reported either as channel000 (not HV mapped)
209  //but also as channel002 and channel003 (if they are HV mapped), or as channel999 (if they are in a crosstalking PSU)
210  //Get the PSU to do a PSU-only matching to get all detIDs connected to the LV channel:
211  //Now loop over the map!
212  //for (PsuDetIdMap::iterator iter = pgMap.begin(); iter != pgMap.end(); iter++) {
213  // std::string PSUFromMap = iter->second.substr(0,iter->second.size()-10);
214  // //Careful if you uncomment this cout: it prints 15148 lines when checking for 1 psu name match! (meant for debugging of course)
215  // //std::cout<<"Truncated DPNAME from MAP: "<<PSUFromMap<<std::endl;
216  // if (PSUFromQuery == PSUFromMap) {
217  // detids.push_back(iter->first); //And fill the detids vector with the all detids matching the PSU from the query!
218  // }
219  //}
220  //No need to loop over if we use an actual map!
221 
222  if (LVMap.find(PSUFromQuery)!=LVMap.end()) {
223  detids=LVMap[PSUFromQuery];
224  }
225  }
226  //Handle the HV case too:
227  else if (ChannelFromQuery=="channel002" or ChannelFromQuery=="channel003") {
228  //For the HV channel we need to look at the actual positive matching detIDs,
229  //but also to the unmapped one (channel000) and the crosstalking ones (channel999).
230  //Assemble the corresponding channel000 (unmapped channels) replacing the last character in PSUChannelFromQuery:
231  // std::string ZeroedPSUChannelFromQuery= PSUChannelFromQuery;
232  // ZeroedPSUChannelFromQuery.replace(ZeroedPSUChannelFromQuery.size()-1,1,"0");
233  // //Same for channel999 for the crosstalking channels:
234  // //std::string NineNineNine='999';
235  // std::string NinedPSUChannelFromQuery= PSUChannelFromQuery;
236  // NinedPSUChannelFromQuery.replace(NinedPSUChannelFromQuery.size()-3,3,"999");
237  // //std::string NinedPSUChannelFromQuery= PSUChannelFromQuery.substr(0,PSUChannelFromQuery.size()-3);// + '999';
238  // //Now loop over the map!
239  // for (PsuDetIdMap::iterator iter = pgMap.begin(); iter != pgMap.end(); iter++) {
240  // std::string PSUChannelFromMap = iter->second;
241  // //Careful if you uncomment this cout: it prints 15148 lines when checking for 1 psu name match! (meant for debugging of course)
242  // //std::cout<<"Truncated DPNAME from MAP: "<<PSUFromMap<<std::endl;
243  // if (PSUChannelFromMap==PSUChannelFromQuery) {
244  // detids.push_back(iter->first); //Fill the detids vector with the all detids matching the PSUChannel from the query!
245  // }
246  // if (PSUChannelFromMap==ZeroedPSUChannelFromQuery) {
247  // unmapped_detids.push_back(iter->first); //Fill the unmapped_detids vector with the all detids matching the channel000 for the PSU from the query!
248  // if (debug) { //BEWARE: this debug printouts can become very heavy! 1 print out per detID matched!
249  // std::cout<<"Matched one of the HV-UNMAPPED channels: "<<ZeroedPSUChannelFromQuery<<std::endl;
250  // std::cout<<"Corresponding to detID: "<<iter->first<<std::endl;
251  // //for (unsigned int i_nohvmap_detid=0;i_nohvmap_detid < iter->first.size();i_nohvmap_detid++) {
252  // // cout<< iter->first[i_nohvmap_detid] << std::endl;
253  // }
254  // }
255  // if (PSUChannelFromMap==NinedPSUChannelFromQuery) {
256  // crosstalking_detids.push_back(iter->first); //Fill the crosstalking_detids vector with the all detids matching the channel999 for the PSU from the query!
257  // }
258  // }
259  if (HVMap.find(PSUChannelFromQuery)!=HVMap.end()) {
260  detids=HVMap[PSUChannelFromQuery];
261  }
262  else if (HVUnmapped_Map.find(PSUFromQuery)!=HVUnmapped_Map.end()) {
263  unmapped_detids=HVUnmapped_Map[PSUFromQuery];
264  }
265  else if (HVCrosstalking_Map.find(PSUFromQuery)!=HVCrosstalking_Map.end()) {
266  crosstalking_detids=HVCrosstalking_Map[PSUFromQuery];
267  }
268  }
269  //
270  //
271  // //With the new code above that makes use of the channel00X information in the map
272  // //we should no more need to remove duplicates by construction.
273  // //The following code was used when there was no channel information in the map,
274  // //to elegantly eliminate duplicates.
275  // //We can now use it as a cross-check (still removing duplicates in case they happen, but writing a message out)
276  //
277  // // remove duplicates
278  //
279  // //First sort detIDs vector, so that duplicates will be consecutive
280  // if (!detids.empty()) {
281  // std::sort(detids.begin(),detids.end());
282  // //Then use the forward iterator unique from STD that basically removes all consecutive duplicates from the vector
283  // //and reports a forward iterator pointing to the new end of the sequence
284  // std::vector<uint32_t>::iterator it = std::unique(detids.begin(),detids.end());
285  // if (it!=detids.end()) {
286  // std::cout<<"ARGH! It seems we found duplicate detIDs in the map corresponding to this PSUChannel: "<<PSUChannelFromQuery<<std::endl;
287  // detids.resize( it - detids.begin() );
288  // }
289  // if (debug) {
290  // std::cout<<"Matched the following detIDs to PSU channel from query "<<PSUChannelFromQuery <<":"<<std::endl;
291  // for (std::vector<uint32_t>::iterator i_detid=detids.begin();i_detid!=detids.end(); i_detid++) {
292  // std::cout<<*i_detid<<std::endl;;
293  // }
294  // }
295  // }
296  // //Same for unmapped detIDs:
297  // if (!unmapped_detids.empty()) {
298  // std::sort(unmapped_detids.begin(),unmapped_detids.end());
299  // //Then use the forward iterator unique from STD that basically removes all consecutive duplicates from the vector
300  // //and reports a forward iterator pointing to the new end of the sequence
301  // std::vector<uint32_t>::iterator it = std::unique(unmapped_detids.begin(),unmapped_detids.end());
302  // if (it!=unmapped_detids.end()) {
303  // std::cout<<"ARGH! It seems we found duplicate unmapped_detids in the map corresponding to this PSUChannel: "<<PSUChannelFromQuery<<std::endl;
304  // unmapped_detids.resize( it - unmapped_detids.begin() );
305  // }
306  // if (debug) {
307  // std::cout<<"Matched the following unmapped_detids to PSU channel from query "<<PSUChannelFromQuery <<":"<<std::endl;
308  // for (std::vector<uint32_t>::iterator i_detid=unmapped_detids.begin();i_detid!=unmapped_detids.end(); i_detid++) {
309  // std::cout<<*i_detid<<std::endl;;
310  // }
311  // }
312  // }
313  // //Finally, same for crosstalking detIDs:
314  // if (!crosstalking_detids.empty()) {
315  // std::sort(crosstalking_detids.begin(),crosstalking_detids.end());
316  // //Then use the forward iterator unique from STD that basically removes all consecutive duplicates from the vector
317  // //and reports a forward iterator pointing to the new end of the sequence
318  // std::vector<uint32_t>::iterator it = std::unique(crosstalking_detids.begin(),crosstalking_detids.end());
319  // if (it!=crosstalking_detids.end()) {
320  // std::cout<<"ARGH! It seems we found duplicate crosstalking_detids in the map corresponding to this PSUChannel: "<<PSUChannelFromQuery<<std::endl;
321  // crosstalking_detids.resize( it - crosstalking_detids.begin() );
322  // }
323  // if (debug) {
324  // std::cout<<"Matched the following crosstalking_detids to PSU channel from query "<<PSUChannelFromQuery <<":"<<std::endl;
325  // for (std::vector<uint32_t>::iterator i_detid=crosstalking_detids.begin();i_detid!=crosstalking_detids.end(); i_detid++) {
326  // std::cout<<*i_detid<<std::endl;;
327  // }
328  // }
329  // }
330  //
331  // //Using reference parameters since we are returning multiple objects.
332  // //return detids;
333 
334 }
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::EventIDconst &, edm::Timestampconst & > 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
tuple cout
Definition: gather_cfg.py:145
PsuDetIdMap HVCrosstalking_Map
std::map<std::string,std::vector<uint32_t> > SiStripPsuDetIdMap::getHVCrosstalkingMap ( )
inline

Definition at line 67 of file SiStripPsuDetIdMap.h.

References HVCrosstalking_Map.

Referenced by SiStripDetVOffBuilder::buildPSUdetIdMap().

67 {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 165 of file SiStripPsuDetIdMap.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by SiStripDetVOffBuilder::buildPSUdetIdMap().

165  {
166  //Function that (via reference parameters) populates ids, unmapped_ids, crosstalking_ids vectors of detids associated with a given PSU *HV* channel.
167  if (HVMap.find(PSUChannel)!=HVMap.end()) {
168  ids=HVMap[PSUChannel];
169  }
170  //Extract the PSU to check the unmapped and crosstalking maps too corresponding to this channel
171  std::string PSU = PSUChannel.substr(0,PSUChannel.size()-10);
172  if (HVUnmapped_Map.find(PSU)!=HVUnmapped_Map.end()) {
173  unmapped_ids=HVUnmapped_Map[PSU];
174  }
175  if (HVCrosstalking_Map.find(PSU)!=HVCrosstalking_Map.end()) {
176  crosstalking_ids=HVCrosstalking_Map[PSU];
177  }
178 }
PsuDetIdMap HVCrosstalking_Map
std::map<std::string,std::vector<uint32_t> > SiStripPsuDetIdMap::getHVUnmappedMap ( )
inline

Definition at line 65 of file SiStripPsuDetIdMap.h.

References HVUnmapped_Map.

Referenced by SiStripDetVOffBuilder::buildPSUdetIdMap().

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

Definition at line 153 of file SiStripPsuDetIdMap.cc.

Referenced by SiStripDetVOffBuilder::buildPSUdetIdMap().

153  {
154  //Function that returns a vector with all detids associated with a PSU
155  //(no channel information is saved in the map since it is not relevant for LV!)
156  if (LVMap.find(PSU)!=LVMap.end()) {
157  return LVMap[PSU];
158  }
159  else {
160  std::vector<uint32_t> detids;
161  return detids;
162  }
163 }
std::vector< std::pair<uint32_t, std::string> > SiStripPsuDetIdMap::getPsuDetIdMap ( )
inline

Return the PG PSU-DETID map as a vector.

Definition at line 73 of file SiStripPsuDetIdMap.h.

References pgMap.

73 {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 337 of file SiStripPsuDetIdMap.cc.

337  {
338  std::vector< std::pair<uint32_t, std::string> >::iterator iter;
339  for (iter = pgMap.begin(); iter != pgMap.end(); iter++) {
340  if (iter->first && iter->first == detid) {return iter->second;}
341  }
342  // if we reach here, then we didn't find the detid in the map
343  return "UNKNOWN";
344 }
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 346 of file SiStripPsuDetIdMap.cc.

346  {
347  std::vector< std::pair<uint32_t, std::string> >::iterator iter;
348  if (group == "PG") {
349  for (iter = pgMap.begin(); iter != pgMap.end(); iter++) {
350  if (iter->first && iter->first == detid) {return iter->second;}
351  }
352  }
353  if (group == "CG") {
354  for (iter = cgMap.begin(); iter != cgMap.end(); iter++) {
355  if (iter->first && iter->first == detid) {return iter->second;}
356  }
357  }
358  // if we reach here, then we didn't find the detid in the map
359  return "UNKNOWN";
360 }
std::vector< std::pair< uint32_t, std::string > > pgMap
std::vector< std::pair< uint32_t, std::string > > cgMap
tuple group
Definition: watchdog.py:82
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 415 of file SiStripPsuDetIdMap.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

415  {
416  // isHV = 0 means LV, = 1 means HV, = -1 means error
417  int isHV = 0;
418  std::string::size_type loc = PSUChannel.find( "channel", 0 );
419  if (loc != std::string::npos) {
420  std::string chNumber = PSUChannel.substr(loc+7,3);
421  if (chNumber == "002" || chNumber == "003") {
422  isHV = 1;
423  } else if (chNumber == "000" || chNumber == "001") {
424  isHV = 0;
425  } else {
426  edm::LogWarning("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] channel number of unexpected format, setting error flag!";
427  isHV = -1;
428  }
429  } else {
430  edm::LogWarning("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] channel number not located in PSU channel name, setting error flag!";
431  isHV = -1;
432  }
433  return isHV;
434 }
uint16_t size_type
void SiStripPsuDetIdMap::printControlMap ( )

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

Definition at line 453 of file SiStripPsuDetIdMap.cc.

References AlCaHLTBitMon_ParallelJobs::p.

453  {
454  stringstream cg;
455  cg << "Map of control power supplies to DET IDs: " << std::endl
456  << "-- PSU name -- -- Det Id --" << std::endl;
457  for (unsigned int p = 0; p < cgMap.size(); p++) {
458  cg << cgMap[p].first << " " << cgMap[p].second << std::endl;
459  }
460  edm::LogInfo("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] " << cg.str();
461 }
std::vector< std::pair< uint32_t, std::string > > cgMap
void SiStripPsuDetIdMap::printMap ( )

Produces a formatted printout of the PSU-DETID map.

Definition at line 443 of file SiStripPsuDetIdMap.cc.

References AlCaHLTBitMon_ParallelJobs::p.

Referenced by SiStripDetVOffBuilder::buildPSUdetIdMap().

443  {
444  stringstream pg;
445  pg << "Map of power supplies to DET IDs: " << std::endl
446  << "-- PSU name -- -- Det Id --" << std::endl;
447  for (unsigned int p = 0; p < pgMap.size(); p++) {
448  pg << pgMap[p].first << " " << pgMap[p].second << std::endl;
449  }
450  edm::LogInfo("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] " << pg.str();
451 }
std::vector< std::pair< uint32_t, std::string > > pgMap
void SiStripPsuDetIdMap::RemoveDuplicateDetIDs ( std::vector< uint32_t > &  detids)

Definition at line 144 of file SiStripPsuDetIdMap.cc.

References FrontierCondition_GT_autoExpress_cfi::unique().

144  {
145  //Function to remove duplicates from a vector of detids
146  if (!detids.empty()) { //Leave empty vector alone ;)
147  std::sort(detids.begin(),detids.end());
148  std::vector<uint32_t>::iterator it = std::unique(detids.begin(),detids.end());
149  detids.resize( it - detids.begin() );
150  }
151 }
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 508 of file SiStripPsuDetIdMap.cc.

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

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

Member Data Documentation

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

Definition at line 135 of file SiStripPsuDetIdMap.h.

Referenced by getCcuDcuIds().

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

Definition at line 135 of file SiStripPsuDetIdMap.h.

Referenced by getCgDcuIds().

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

Definition at line 133 of file SiStripPsuDetIdMap.h.

Referenced by getControlPsuDetIdMap().

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

Definition at line 134 of file SiStripPsuDetIdMap.h.

Referenced by getControlDetectorLocations().

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

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

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

Definition at line 135 of file SiStripPsuDetIdMap.h.

Referenced by getDcuIds().

DcuPsus SiStripPsuDetIdMap::DcuPsuMapCG_
private

Definition at line 136 of file SiStripPsuDetIdMap.h.

DcuPsus SiStripPsuDetIdMap::DcuPsuMapPG_
private

Definition at line 136 of file SiStripPsuDetIdMap.h.

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

Definition at line 134 of file SiStripPsuDetIdMap.h.

Referenced by getDetectorLocations().

PsuDetIdMap SiStripPsuDetIdMap::HVCrosstalking_Map
private

Definition at line 132 of file SiStripPsuDetIdMap.h.

Referenced by getHVCrosstalkingMap().

PsuDetIdMap SiStripPsuDetIdMap::HVMap
private

Definition at line 132 of file SiStripPsuDetIdMap.h.

PsuDetIdMap SiStripPsuDetIdMap::HVUnmapped_Map
private

Definition at line 132 of file SiStripPsuDetIdMap.h.

Referenced by getHVUnmappedMap().

PsuDetIdMap SiStripPsuDetIdMap::LVMap
private

Definition at line 132 of file SiStripPsuDetIdMap.h.

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

Definition at line 133 of file SiStripPsuDetIdMap.h.

Referenced by getPsuDetIdMap().