File indexing completed on 2024-04-06 11:59:48
0001 #ifndef SISTRIPPSUDETIDMAP_H
0002 #define SISTRIPPSUDETIDMAP_H
0003
0004 #include <memory>
0005 #include "FWCore/ServiceRegistry/interface/Service.h"
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "DataFormats/Common/interface/Handle.h"
0008 #include "FWCore/Framework/interface/EventSetup.h"
0009 #include "DataFormats/Common/interface/MapOfVectors.h"
0010
0011 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
0012 #include "OnlineDB/SiStripConfigDb/interface/SiStripConfigDb.h"
0013 #include "OnlineDB/SiStripConfigDb/interface/SiStripDbParams.h"
0014 #include "DeviceFactory.h"
0015
0016 #include <vector>
0017 #include <string>
0018 #include <iostream>
0019 #include <fstream>
0020 #include <sstream>
0021 #include <ostream>
0022 #include <cstdint>
0023
0024 class SiStripConfigDb;
0025
0026
0027
0028
0029
0030
0031
0032 class SiStripPsuDetIdMap {
0033 public:
0034
0035 SiStripPsuDetIdMap();
0036
0037 ~SiStripPsuDetIdMap();
0038
0039 std::vector<uint32_t> getLvDetID(std::string psu);
0040 void getHvDetID(std::string psuchannel,
0041 std::vector<uint32_t> &ids,
0042 std::vector<uint32_t> &unmapped_ids,
0043 std::vector<uint32_t> &crosstalking_ids);
0044
0045
0046
0047
0048
0049 void getDetID(std::string pvss,
0050 bool,
0051 std::vector<uint32_t> &detids,
0052 std::vector<uint32_t> &unmapped_detids,
0053 std::vector<uint32_t> &crosstalking_detids);
0054
0055 std::string getPSUName(uint32_t detid);
0056
0057 std::string getPSUName(uint32_t detid, std::string group);
0058
0059 std::string getDetectorLocation(uint32_t detid);
0060
0061 std::string getDetectorLocation(std::string pvss);
0062
0063 std::string getDetectorLocation(uint32_t detid, std::string group);
0064
0065 uint32_t getDcuId(std::string pvss);
0066
0067 uint32_t getDcuId(uint32_t detid);
0068
0069
0070 std::map<std::string, std::vector<uint32_t> > getHVUnmappedMap() { return HVUnmapped_Map; }
0071
0072 std::map<std::string, std::vector<uint32_t> > getHVCrosstalkingMap() { return HVCrosstalking_Map; }
0073
0074
0075
0076
0077
0078 std::vector<std::pair<uint32_t, std::string> > getPsuDetIdMap() { return pgMap; }
0079
0080 std::vector<std::string> getDetectorLocations() { return detectorLocations; }
0081
0082 std::vector<uint32_t> getDcuIds() { return dcuIds; }
0083
0084 std::vector<std::pair<uint32_t, std::string> > getControlPsuDetIdMap() { return cgMap; }
0085
0086 std::vector<std::string> getControlDetectorLocations() { return controlLocations; }
0087
0088 std::vector<uint32_t> getCgDcuIds() { return cgDcuIds; }
0089
0090 std::vector<uint32_t> getCcuDcuIds() { return ccuDcuIds; }
0091
0092
0093 void printMap();
0094
0095 void printControlMap();
0096
0097
0098
0099
0100
0101
0102 void BuildMap(const std::string &mapFile, const bool debug);
0103
0104 void BuildMap(const std::string &mapFile, std::vector<std::pair<uint32_t, std::string> > &rawmap);
0105
0106 void BuildMap(const std::string &mapFile,
0107 const bool debug,
0108 std::map<std::string, std::vector<uint32_t> > &LVmap,
0109 std::map<std::string, std::vector<uint32_t> > &HVmap,
0110 std::map<std::string, std::vector<uint32_t> > &HVUnmappedmap,
0111 std::map<std::string, std::vector<uint32_t> > &HVCrosstalkingmap);
0112
0113
0114 void RemoveDuplicateDetIDs(std::vector<uint32_t> &detids);
0115
0116
0117 std::vector<std::pair<uint32_t, std::string> > getDcuPsuMap();
0118
0119 int IsHVChannel(std::string pvss);
0120
0121 private:
0122
0123 typedef std::vector<TkDcuPsuMap *> DcuPsuVector;
0124 typedef std::map<std::string, std::vector<uint32_t> > PsuDetIdMap;
0125 typedef edm::MapOfVectors<std::string, TkDcuPsuMap *> DcuPsus;
0126 typedef DcuPsus::range DcuPsusRange;
0127
0128 void getDcuPsuMap(DcuPsusRange &pRange, DcuPsusRange &cRange, std::string partition);
0129
0130
0131 std::vector<std::pair<std::vector<uint16_t>, std::vector<uint32_t> > > retrieveDcuDeviceAddresses(
0132 std::string partition);
0133
0134 std::vector<uint32_t> findDcuIdFromDeviceAddress(uint32_t dcuid_);
0135
0136 void clone(DcuPsuVector &input, DcuPsuVector &output);
0137
0138
0139 void checkMapInputValues(const SiStripConfigDb::DcuDetIdsV &dcuDetIds_, const DcuPsuVector &dcuPsus_);
0140
0141
0142 edm::Service<SiStripConfigDb> db_;
0143 PsuDetIdMap LVMap, HVMap, HVUnmapped_Map, HVCrosstalking_Map;
0144 std::vector<std::pair<uint32_t, std::string> > pgMap, cgMap;
0145 std::vector<std::string> detectorLocations, controlLocations;
0146 std::vector<uint32_t> dcuIds, cgDcuIds, ccuDcuIds;
0147 DcuPsus DcuPsuMapPG_, DcuPsuMapCG_;
0148
0149 std::vector<std::pair<std::vector<uint16_t>, std::vector<uint32_t> > > dcu_device_addr_vector;
0150 };
0151 #endif