27 BuildMap(mapFile, debug, LVMap, HVMap, HVUnmapped_Map, HVCrosstalking_Map);
37 std::ifstream ifs(
file.fullPath().c_str() );
39 while( getline( ifs, line ) ) {
42 stringstream ss(line);
47 rawmap.push_back(std::make_pair(detId, PSUChannel) );
64 std::ifstream ifs(
file.fullPath().c_str() );
66 while( getline( ifs, line ) ) {
69 stringstream ss(line);
77 std::string PSU=PSUChannel.substr(0,PSUChannel.size()-10);
79 LVmap[PSU].push_back(detId);
80 if (Channel==
"channel000") {
81 HVUnmappedmap[PSU].push_back(detId);
83 else if (Channel==
"channel999") {
84 HVCrosstalkingmap[PSU].push_back(detId);
87 HVmap[PSUChannel].push_back(detId);
93 for (PsuDetIdMap::iterator psu = LVMap.begin(); psu != LVMap.end(); psu++) {
94 RemoveDuplicateDetIDs(psu->second);
96 for (PsuDetIdMap::iterator psuchan = HVMap.begin(); psuchan != HVMap.end(); psuchan++) {
97 RemoveDuplicateDetIDs(psuchan->second);
99 for (PsuDetIdMap::iterator psu = HVUnmapped_Map.begin(); psu != HVUnmapped_Map.end(); psu++) {
100 RemoveDuplicateDetIDs(psu->second);
102 for (PsuDetIdMap::iterator psu = HVCrosstalking_Map.begin(); psu != HVCrosstalking_Map.end(); psu++) {
103 RemoveDuplicateDetIDs(psu->second);
107 std::cout<<
"Dumping the LV map"<<std::endl;
109 for (PsuDetIdMap::iterator psu = LVMap.begin(); psu != LVMap.end(); psu++) {
110 std::cout<<psu->first<<
" corresponds to following detids"<<endl;
111 for (
unsigned int i=0;
i<psu->second.size();
i++) {
115 std::cout<<
"Dumping the HV map for HV mapped channels"<<std::endl;
116 std::cout<<
"PSUChannel->detids"<<std::endl;
117 for (PsuDetIdMap::iterator psuchan = HVMap.begin(); psuchan != HVMap.end(); psuchan++) {
118 std::cout<<psuchan->first<<
" corresponds to following detids"<<endl;
119 for (
unsigned int i=0;
i<psuchan->second.size();
i++) {
120 std::cout<<
"\t\t"<<psuchan->second[
i]<<std::endl;
123 std::cout<<
"Dumping the HV map for HV UNmapped channels"<<std::endl;
125 for (PsuDetIdMap::iterator psu = HVUnmapped_Map.begin(); psu != HVUnmapped_Map.end(); psu++) {
126 std::cout<<psu->first<<
" corresponds to following detids"<<endl;
127 for (
unsigned int i=0;
i<psu->second.size();
i++) {
131 std::cout<<
"Dumping the HV map for HV Crosstalking channels"<<std::endl;
133 for (PsuDetIdMap::iterator psu = HVCrosstalking_Map.begin(); psu != HVCrosstalking_Map.end(); psu++) {
134 std::cout<<psu->first<<
" corresponds to following detids"<<endl;
135 for (
unsigned int i=0;
i<psu->second.size();
i++) {
146 if (!detids.empty()) {
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() );
156 if (LVMap.find(PSU)!=LVMap.end()) {
160 std::vector<uint32_t> detids;
167 if (HVMap.find(PSUChannel)!=HVMap.end()) {
168 ids=HVMap[PSUChannel];
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];
175 if (HVCrosstalking_Map.find(PSU)!=HVCrosstalking_Map.end()) {
176 crosstalking_ids=HVCrosstalking_Map[PSU];
192 const std::string& PSUChannelFromQuery = PSUChannel;
195 std::string ChannelFromQuery=PSUChannelFromQuery.substr(PSUChannelFromQuery.size()-10);
197 std::string PSUFromQuery=PSUChannelFromQuery.substr(0,PSUChannelFromQuery.size()-10);
201 std::cout <<
"DPNAME from QUERY: "<<PSUChannelFromQuery<<
", Channel: "<<ChannelFromQuery<<
"PSU: "<<PSUFromQuery<<std::endl;
207 if (ChannelFromQuery==
"channel000" or ChannelFromQuery==
"channel001") {
222 if (LVMap.find(PSUFromQuery)!=LVMap.end()) {
223 detids=LVMap[PSUFromQuery];
227 else if (ChannelFromQuery==
"channel002" or ChannelFromQuery==
"channel003") {
259 if (HVMap.find(PSUChannelFromQuery)!=HVMap.end()) {
260 detids=HVMap[PSUChannelFromQuery];
262 else if (HVUnmapped_Map.find(PSUFromQuery)!=HVUnmapped_Map.end()) {
263 unmapped_detids=HVUnmapped_Map[PSUFromQuery];
265 else if (HVCrosstalking_Map.find(PSUFromQuery)!=HVCrosstalking_Map.end()) {
266 crosstalking_detids=HVCrosstalking_Map[PSUFromQuery];
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;}
347 std::vector< std::pair<uint32_t, std::string> >::iterator iter;
349 for (iter = pgMap.begin(); iter != pgMap.end(); iter++) {
350 if (iter->first && iter->first == detid) {
return iter->second;}
354 for (iter = cgMap.begin(); iter != cgMap.end(); iter++) {
355 if (iter->first && iter->first == detid) {
return iter->second;}
364 for (
unsigned int i = 0;
i < pgMap.size();
i++) {
365 if (pgMap[
i].
first == detid) {
return detectorLocations[
i];}
373 for (
unsigned int i = 0;
i < pgMap.size();
i++) {
374 if (pgMap[
i].
first == detid) {
return detectorLocations[
i];}
378 for (
unsigned int i = 0;
i < cgMap.size();
i++) {
379 if (cgMap[
i].
first == detid) {
return controlLocations[
i];}
387 for (
unsigned int i = 0;
i < pgMap.size();
i++) {
388 if (pgMap[
i].
second == PSUChannel) {
return detectorLocations[
i];}
390 for (
unsigned int i = 0;
i < cgMap.size();
i++) {
391 if (cgMap[
i].
second == PSUChannel) {
return controlLocations[
i];}
398 for (
unsigned int i = 0;
i < pgMap.size();
i++) {
399 if (pgMap[
i].
second == PSUChannel) {
return dcuIds[
i];}
401 for (
unsigned int i = 0;
i < cgMap.size();
i++) {
402 if (cgMap[
i].
second == PSUChannel) {
return cgDcuIds[
i];}
408 for (
unsigned int i = 0;
i < pgMap.size();
i++) {
409 if (pgMap[
i].
first == detid) {
return dcuIds[
i];}
419 if (loc != std::string::npos) {
421 if (chNumber ==
"002" || chNumber ==
"003") {
423 }
else if (chNumber ==
"000" || chNumber ==
"001") {
426 edm::LogWarning(
"SiStripPsuDetIdMap") <<
"[SiStripPsuDetIdMap::" << __func__ <<
"] channel number of unexpected format, setting error flag!";
430 edm::LogWarning(
"SiStripPsuDetIdMap") <<
"[SiStripPsuDetIdMap::" << __func__ <<
"] channel number not located in PSU channel name, setting error flag!";
438 for (
unsigned int i = 0;
i < input.size();
i++) {
439 output.push_back(
new TkDcuPsuMap(*(input[
i])));
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;
450 edm::LogInfo(
"SiStripPsuDetIdMap") <<
"[SiStripPsuDetIdMap::" << __func__ <<
"] " << pg.str();
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;
460 edm::LogInfo(
"SiStripPsuDetIdMap") <<
"[SiStripPsuDetIdMap::" << __func__ <<
"] " << cg.str();
464 if (!pgMap.empty()) {
return pgMap; }
465 std::vector< std::pair<uint32_t, std::string> > emptyVec;
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;
474 std::vector<bool> ddUsed(dcuDetIds_.size(),
false);
475 std::vector<bool> dpUsed(dcuPsus_.size(),
false);
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()) {
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++; }
491 std::cout <<
"Number of used DCU-PSU entries: " << numDpUsed << std::endl;
492 std::cout <<
"Number of unused DCU-PSU entries: " << numDpNotUsed << std::endl;
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++; }
500 std::cout <<
"Number of used DCU-DETID entries: " << numDdUsed << std::endl;
501 std::cout <<
"Number of unused DCU-DETID entries: " << numDdNotUsed << std::endl;
503 std::cout <<
"Size of PSU-DETID map: " << pgMap.size() << std::endl;
504 std::cout <<
"Size of detectorLocations: " << detectorLocations.size() << std::endl;
511 SiStripDbParams::SiStripPartitions::const_iterator iter;
513 std::vector< std::pair<uint32_t, SiStripConfigDb::DeviceAddress> > resultVec;
519 if ( partition ==
"" || partition == iter->second.partitionName() ) {
521 if (iter->second.dcuVersion().first > 0 && iter->second.fecVersion().first > 0) {
523 if (!range.empty()) {
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])) ) );
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();
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);
555 for (
unsigned int i = 0;
i < testVec.size();
i++) {
556 if (fecInfo == testVec[
i].
first) {
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;
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));
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;
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()) {
589 for (
unsigned int i = 0;
i < dcuids.size();
i++) {
590 if (dcuids[
i] != dcuid_) {pgDcu.push_back(dcuids[
i]);}
593 std::cout <<
"Oh oh ... we have a duplicate :-(" << std::endl;
void clone(DcuPsuVector &input, DcuPsuVector &output)
static const std::string defaultPartitionName_
std::string getPSUName(uint32_t detid)
void getDetID(std::string pvss, bool, std::vector< uint32_t > &detids, std::vector< uint32_t > &unmapped_detids, std::vector< uint32_t > &crosstalking_detids)
std::vector< std::pair< std::vector< uint16_t >, std::vector< uint32_t > > > retrieveDcuDeviceAddresses(std::string partition)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
static std::string const input
U second(std::pair< T, U > const &p)
const_iterator_range partitions() const
enumDeviceType DeviceType
int IsHVChannel(std::string pvss)
DeviceDescriptions::range DeviceDescriptionsRange
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
def unique(seq, keepstr=True)
std::vector< uint32_t > getLvDetID(std::string psu)
std::vector< std::pair< uint32_t, std::string > > getDcuPsuMap()
std::map< std::string, std::vector< uint32_t > > PsuDetIdMap
void getHvDetID(std::string psuchannel, std::vector< uint32_t > &ids, std::vector< uint32_t > &unmapped_ids, std::vector< uint32_t > &crosstalking_ids)
void RemoveDuplicateDetIDs(std::vector< uint32_t > &detids)
std::vector< uint32_t > findDcuIdFromDeviceAddress(uint32_t dcuid_)
std::vector< DcuDetId > DcuDetIdsV
Container class for database connection parameters.
void BuildMap(const std::string &mapFile, const bool debug)
uint32_t getDcuId(std::string pvss)
std::vector< TkDcuPsuMap * > DcuPsuVector
std::string getDetectorLocation(uint32_t detid)
std::vector< DeviceDescription * > DeviceDescriptionsV
void checkMapInputValues(const SiStripConfigDb::DcuDetIdsV &dcuDetIds_, const DcuPsuVector &dcuPsus_)