21 LogTrace(
"SiStripPsuDetIdMap") <<
"[SiStripPsuDetIdMap::" << __func__ <<
"] Constructing ...";
25 LogTrace(
"SiStripPsuDetIdMap") <<
"[SiStripPsuDetIdMap::" << __func__ <<
"] Destructing ...";
30 BuildMap(mapFile, debug, LVMap, HVMap, HVUnmapped_Map, HVCrosstalking_Map);
40 std::ifstream ifs(
file.fullPath().c_str());
42 while (getline(ifs, line)) {
45 stringstream ss(line);
50 rawmap.push_back(std::make_pair(detId, PSUChannel));
73 std::ifstream ifs(
file.fullPath().c_str());
75 while (getline(ifs, line)) {
78 stringstream ss(line);
86 std::string PSU = PSUChannel.substr(0, PSUChannel.size() - 10);
88 LVmap[PSU].push_back(detId);
89 if (Channel ==
"channel000") {
90 HVUnmappedmap[PSU].push_back(
92 }
else if (Channel ==
"channel999") {
93 HVCrosstalkingmap[PSU].push_back(
96 HVmap[PSUChannel].push_back(detId);
102 for (PsuDetIdMap::iterator psu = LVMap.begin(); psu != LVMap.end(); psu++) {
103 RemoveDuplicateDetIDs(psu->second);
105 for (PsuDetIdMap::iterator psuchan = HVMap.begin(); psuchan != HVMap.end(); psuchan++) {
106 RemoveDuplicateDetIDs(psuchan->second);
108 for (PsuDetIdMap::iterator psu = HVUnmapped_Map.begin(); psu != HVUnmapped_Map.end(); psu++) {
109 RemoveDuplicateDetIDs(psu->second);
111 for (PsuDetIdMap::iterator psu = HVCrosstalking_Map.begin(); psu != HVCrosstalking_Map.end(); psu++) {
112 RemoveDuplicateDetIDs(psu->second);
116 std::cout <<
"Dumping the LV map" << std::endl;
118 for (PsuDetIdMap::iterator psu = LVMap.begin(); psu != LVMap.end(); psu++) {
119 std::cout << psu->first <<
" corresponds to following detids" << endl;
120 for (
unsigned int i = 0;
i < psu->second.size();
i++) {
121 std::cout <<
"\t\t" << psu->second[
i] << std::endl;
124 std::cout <<
"Dumping the HV map for HV mapped channels" << std::endl;
125 std::cout <<
"PSUChannel->detids" << std::endl;
126 for (PsuDetIdMap::iterator psuchan = HVMap.begin(); psuchan != HVMap.end(); psuchan++) {
127 std::cout << psuchan->first <<
" corresponds to following detids" << endl;
128 for (
unsigned int i = 0;
i < psuchan->second.size();
i++) {
129 std::cout <<
"\t\t" << psuchan->second[
i] << std::endl;
132 std::cout <<
"Dumping the HV map for HV UNmapped channels" << std::endl;
134 for (PsuDetIdMap::iterator psu = HVUnmapped_Map.begin(); psu != HVUnmapped_Map.end(); psu++) {
135 std::cout << psu->first <<
" corresponds to following detids" << endl;
136 for (
unsigned int i = 0;
i < psu->second.size();
i++) {
137 std::cout <<
"\t\t" << psu->second[
i] << std::endl;
140 std::cout <<
"Dumping the HV map for HV Crosstalking channels" << std::endl;
142 for (PsuDetIdMap::iterator psu = HVCrosstalking_Map.begin(); psu != HVCrosstalking_Map.end(); psu++) {
143 std::cout << psu->first <<
" corresponds to following detids" << endl;
144 for (
unsigned int i = 0;
i < psu->second.size();
i++) {
145 std::cout <<
"\t\t" << psu->second[
i] << std::endl;
155 if (!detids.empty()) {
157 std::vector<uint32_t>::iterator it =
std::unique(detids.begin(), detids.end());
158 detids.resize(it - detids.begin());
165 if (LVMap.find(PSU) != LVMap.end()) {
168 std::vector<uint32_t> detids;
174 std::vector<uint32_t>& ids,
175 std::vector<uint32_t>& unmapped_ids,
176 std::vector<uint32_t>& crosstalking_ids) {
178 if (HVMap.find(PSUChannel) != HVMap.end()) {
179 ids = HVMap[PSUChannel];
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];
186 if (HVCrosstalking_Map.find(PSU) != HVCrosstalking_Map.end()) {
187 crosstalking_ids = HVCrosstalking_Map[PSU];
197 std::vector<uint32_t>& detids,
198 std::vector<uint32_t>& unmapped_detids,
199 std::vector<uint32_t>& crosstalking_detids) {
207 const std::string& PSUChannelFromQuery = PSUChannel;
210 std::string ChannelFromQuery = PSUChannelFromQuery.substr(PSUChannelFromQuery.size() - 10);
212 std::string PSUFromQuery = PSUChannelFromQuery.substr(0, PSUChannelFromQuery.size() - 10);
216 std::cout <<
"DPNAME from QUERY: " << PSUChannelFromQuery <<
", Channel: " << ChannelFromQuery
217 <<
"PSU: " << PSUFromQuery << std::endl;
223 if (ChannelFromQuery ==
"channel000" or ChannelFromQuery ==
"channel001") {
238 if (LVMap.find(PSUFromQuery) != LVMap.end()) {
239 detids = LVMap[PSUFromQuery];
243 else if (ChannelFromQuery ==
"channel002" or ChannelFromQuery ==
"channel003") {
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];
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) {
362 std::vector<std::pair<uint32_t, std::string> >::iterator iter;
364 for (iter = pgMap.begin(); iter != pgMap.end(); iter++) {
365 if (iter->first && iter->first == detid) {
371 for (iter = cgMap.begin(); iter != cgMap.end(); iter++) {
372 if (iter->first && iter->first == detid) {
383 for (
unsigned int i = 0;
i < pgMap.size();
i++) {
384 if (pgMap[
i].
first == detid) {
385 return detectorLocations[
i];
394 for (
unsigned int i = 0;
i < pgMap.size();
i++) {
395 if (pgMap[
i].
first == detid) {
396 return detectorLocations[
i];
401 for (
unsigned int i = 0;
i < cgMap.size();
i++) {
402 if (cgMap[
i].
first == detid) {
403 return controlLocations[
i];
412 for (
unsigned int i = 0;
i < pgMap.size();
i++) {
413 if (pgMap[
i].
second == PSUChannel) {
414 return detectorLocations[
i];
417 for (
unsigned int i = 0;
i < cgMap.size();
i++) {
418 if (cgMap[
i].
second == PSUChannel) {
419 return controlLocations[
i];
427 for (
unsigned int i = 0;
i < pgMap.size();
i++) {
428 if (pgMap[
i].
second == PSUChannel) {
432 for (
unsigned int i = 0;
i < cgMap.size();
i++) {
433 if (cgMap[
i].
second == PSUChannel) {
441 for (
unsigned int i = 0;
i < pgMap.size();
i++) {
442 if (pgMap[
i].
first == detid) {
454 if (loc != std::string::npos) {
455 std::string chNumber = PSUChannel.substr(loc + 7, 3);
456 if (chNumber ==
"002" || chNumber ==
"003") {
458 }
else if (chNumber ==
"000" || chNumber ==
"001") {
462 <<
"[SiStripPsuDetIdMap::" << __func__ <<
"] channel number of unexpected format, setting error flag!";
466 edm::LogWarning(
"SiStripPsuDetIdMap") <<
"[SiStripPsuDetIdMap::" << __func__
467 <<
"] channel number not located in PSU channel name, setting error flag!";
475 for (
unsigned int i = 0;
i < input.size();
i++) {
476 output.push_back(
new TkDcuPsuMap(*(input[
i])));
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;
486 edm::LogInfo(
"SiStripPsuDetIdMap") <<
"[SiStripPsuDetIdMap::" << __func__ <<
"] " << pg.str();
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;
496 edm::LogInfo(
"SiStripPsuDetIdMap") <<
"[SiStripPsuDetIdMap::" << __func__ <<
"] " << cg.str();
500 if (!pgMap.empty()) {
503 std::vector<std::pair<uint32_t, std::string> > emptyVec;
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;
513 std::vector<bool> ddUsed(dcuDetIds_.size(),
false);
514 std::vector<bool> dpUsed(dcuPsus_.size(),
false);
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()) {
524 unsigned int numDpUsed = 0, numDpNotUsed = 0;
525 for (
unsigned int dp = 0; dp < dpUsed.size(); dp++) {
533 std::cout <<
"Number of used DCU-PSU entries: " << numDpUsed << std::endl;
534 std::cout <<
"Number of unused DCU-PSU entries: " << numDpNotUsed << std::endl;
536 unsigned int numDdUsed = 0, numDdNotUsed = 0;
537 for (
unsigned int dd = 0;
dd < ddUsed.size();
dd++) {
545 std::cout <<
"Number of used DCU-DETID entries: " << numDdUsed << std::endl;
546 std::cout <<
"Number of unused DCU-DETID entries: " << numDdNotUsed << std::endl;
548 std::cout <<
"Size of PSU-DETID map: " << pgMap.size() << std::endl;
549 std::cout <<
"Size of detectorLocations: " << detectorLocations.size() << std::endl;
557 SiStripDbParams::SiStripPartitions::const_iterator iter;
559 std::vector<std::pair<uint32_t, SiStripConfigDb::DeviceAddress> > resultVec;
565 if (partition.empty() || partition == iter->second.partitionName()) {
569 if (iter->second.dcuVersion().first > 0 && iter->second.fecVersion().first > 0) {
571 db_->getDeviceDescriptions(device_, iter->second.partitionName());
572 if (!range.empty()) {
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]))));
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();
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);
604 for (
unsigned int i = 0;
i < testVec.size();
i++) {
605 if (fecInfo == testVec[
i].
first) {
607 dcuids.insert(dcuids.end(), (testVec[
i].second).
begin(), (testVec[
i].second).
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;
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));
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 =
629 dcu_device_addr_vector.end();
630 std::vector<uint32_t> pgDcu;
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()) {
639 if (dcu_iter != dcuids.end()) {
642 for (
unsigned int i = 0;
i < dcuids.size();
i++) {
643 if (dcuids[
i] != dcuid_) {
644 pgDcu.push_back(dcuids[
i]);
648 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)
std::map< std::string, std::vector< uint32_t > > PsuDetIdMap
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()
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_)