File indexing completed on 2024-04-06 12:14:36
0001 #ifndef ECALELECTRONICSMAPPING_H
0002 #define ECALELECTRONICSMAPPING_H 1
0003
0004 #include <memory>
0005 #include <iostream>
0006 #include <string>
0007
0008 #include "DataFormats/EcalDetId/interface/EcalDetIdCollections.h"
0009 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
0010
0011 #include <boost/multi_index_container.hpp>
0012 #include <boost/multi_index/member.hpp>
0013 #include <boost/multi_index/ordered_index.hpp>
0014 #include <boost/tuple/tuple.hpp>
0015 #include <boost/multi_index/mem_fun.hpp>
0016 #include <boost/multi_index/composite_key.hpp>
0017
0018 #include "DataFormats/Math/interface/RectangularEtaPhiRegion.h"
0019
0020 #include <vector>
0021 #include <map>
0022
0023
0024
0025
0026
0027
0028 class EcalElectronicsMapping {
0029 public:
0030 EcalElectronicsMapping();
0031
0032
0033 EcalElectronicsId getElectronicsId(const DetId& id) const;
0034
0035
0036 EcalTriggerElectronicsId getTriggerElectronicsId(const DetId& id) const;
0037
0038
0039 DetId getDetId(const EcalElectronicsId& id) const;
0040
0041
0042 EcalTriggerElectronicsId getTriggerElectronicsId(const EcalElectronicsId& id) const;
0043
0044
0045 DetId getDetId(const EcalTriggerElectronicsId& id) const;
0046
0047
0048 EcalElectronicsId getElectronicsId(const EcalTriggerElectronicsId& id) const;
0049
0050
0051 std::vector<DetId> dccConstituents(int dccId) const;
0052
0053
0054 std::vector<DetId> dccTowerConstituents(int dccId, int tower) const;
0055
0056
0057 std::vector<DetId> stripConstituents(int dccId, int tower, int strip) const;
0058
0059
0060 std::vector<DetId> tccConstituents(int tccId) const;
0061
0062
0063 std::vector<DetId> ttConstituents(int tccId, int tt) const;
0064
0065
0066 std::vector<DetId> pseudoStripConstituents(int tccId, int tt, int pseudostrip) const;
0067
0068
0069 void assign(const DetId& cell, const EcalElectronicsId&, const EcalTriggerElectronicsId& tower);
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 std::pair<int, int> getDCCandSC(EcalScDetId id) const;
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100 std::vector<EcalScDetId> getEcalScDetId(int DCCid, int DCC_Channel, bool ignoreSingleCrystal = true) const;
0101
0102
0103 int DCCid(const EBDetId& id) const;
0104
0105
0106 int TCCid(const EBDetId& id) const;
0107
0108
0109 int iTT(const EcalTrigTowerDetId& id) const;
0110
0111
0112 int TCCid(const EcalTrigTowerDetId& id) const;
0113
0114
0115 int DCCid(const EcalTrigTowerDetId& id) const;
0116
0117
0118 EcalTrigTowerDetId getTrigTowerDetId(int TCCid, int iTT) const;
0119
0120 EcalSubdetector subdet(int dccid, int mode) const;
0121 int zside(int dcctcc, int mode) const;
0122
0123 bool rightTower(int tower) const;
0124
0125
0126 std::vector<int> GetListofFEDs(const RectangularEtaPhiRegion& region) const;
0127 void GetListofFEDs(const RectangularEtaPhiRegion& region, std::vector<int>& FEDs) const;
0128 int GetFED(double eta, double phi) const;
0129 int DCCBoundary(int FED) const;
0130
0131
0132
0133 int getLMNumber(const DetId& id) const;
0134
0135
0136 static const int kCrystalsInPhi = EBDetId::kCrystalsInPhi;
0137 static const int kTowersInPhi = EBDetId::kTowersInPhi;
0138
0139
0140
0141 static const int kEBTowersInPhi = EcalTrigTowerDetId::kEBTowersInPhi;
0142 static const int kEBTowersPerSM = EcalTrigTowerDetId::kEBTowersPerSM;
0143 static const int kEBTowersInEta = EcalTrigTowerDetId::kEBTowersInEta;
0144 static const int kEETowersInEta = EcalTrigTowerDetId::kEETowersInEta;
0145 static const int kEETowersInPhiPerQuadrant = EcalTrigTowerDetId::kEETowersInPhiPerQuadrant;
0146
0147 static const int kEETowersInPhiPerTCC = 4;
0148 static const int kEETowersInEtaPerInnerTCC = 7;
0149 static const int kEETowersInEtaPerOuterTCC = 4;
0150 static const int iEEEtaMinOuter = 18;
0151 static const int iEEEtaMinInner = 22;
0152
0153
0154 static const int MAX_DCCID = EcalElectronicsId::MAX_DCCID;
0155 static const int MIN_DCCID = EcalElectronicsId::MIN_DCCID;
0156 static const int MIN_DCCID_EEM = EcalElectronicsId::MIN_DCCID_EEM;
0157 static const int MAX_DCCID_EEM = EcalElectronicsId::MAX_DCCID_EEM;
0158 static const int MIN_DCCID_EBM = EcalElectronicsId::MIN_DCCID_EBM;
0159 static const int MAX_DCCID_EBM = EcalElectronicsId::MAX_DCCID_EBM;
0160 static const int MIN_DCCID_EBP = EcalElectronicsId::MIN_DCCID_EBP;
0161 static const int MAX_DCCID_EBP = EcalElectronicsId::MAX_DCCID_EBP;
0162 static const int MIN_DCCID_EEP = EcalElectronicsId::MIN_DCCID_EEP;
0163 static const int MAX_DCCID_EEP = EcalElectronicsId::MAX_DCCID_EEP;
0164
0165 static const int DCCID_PHI0_EBM = EcalElectronicsId::DCCID_PHI0_EBM;
0166 static const int DCCID_PHI0_EBP = EcalElectronicsId::DCCID_PHI0_EBP;
0167
0168
0169 static const int MAX_TCCID = EcalTriggerElectronicsId::MAX_TCCID;
0170 static const int MIN_TCCID = EcalTriggerElectronicsId::MIN_TCCID;
0171 static const int MIN_TCCID_EEM = EcalTriggerElectronicsId::MIN_TCCID_EEM;
0172 static const int MAX_TCCID_EEM = EcalTriggerElectronicsId::MAX_TCCID_EEM;
0173 static const int MIN_TCCID_EBM = EcalTriggerElectronicsId::MIN_TCCID_EBM;
0174 static const int MAX_TCCID_EBM = EcalTriggerElectronicsId::MAX_TCCID_EBM;
0175 static const int MIN_TCCID_EBP = EcalTriggerElectronicsId::MIN_TCCID_EBP;
0176 static const int MAX_TCCID_EBP = EcalTriggerElectronicsId::MAX_TCCID_EBP;
0177 static const int MIN_TCCID_EEP = EcalTriggerElectronicsId::MIN_TCCID_EEP;
0178 static const int MAX_TCCID_EEP = EcalTriggerElectronicsId::MAX_TCCID_EEP;
0179
0180 static const int TCCID_PHI0_EBM = EcalTriggerElectronicsId::TCCID_PHI0_EBM;
0181 static const int TCCID_PHI0_EBP = EcalTriggerElectronicsId::TCCID_PHI0_EBP;
0182
0183 static const int TCCID_PHI0_EEM_IN = EcalTriggerElectronicsId::TCCID_PHI0_EEM_IN;
0184 static const int TCCID_PHI0_EEM_OUT = EcalTriggerElectronicsId::TCCID_PHI0_EEM_OUT;
0185 static const int TCCID_PHI0_EEP_IN = EcalTriggerElectronicsId::TCCID_PHI0_EEP_IN;
0186 static const int TCCID_PHI0_EEP_OUT = EcalTriggerElectronicsId::TCCID_PHI0_EEP_OUT;
0187
0188 static const int kTCCinPhi = 18;
0189
0190
0191 static const int MIN_LM_EEM = 73;
0192 static const int MIN_LM_EBM = 1;
0193 static const int MIN_LM_EBP = 37;
0194 static const int MIN_LM_EEP = 83;
0195 static const int MAX_LM = 92;
0196
0197 private:
0198 static const int DCCMODE = 0;
0199 static const int TCCMODE = 1;
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209 struct MapItem {
0210 MapItem(const DetId& acell, const EcalElectronicsId& aelid, const EcalTriggerElectronicsId& atrelid)
0211 : cell(acell), elid(aelid), trelid(atrelid) {}
0212 DetId cell;
0213 EcalElectronicsId elid;
0214 EcalTriggerElectronicsId trelid;
0215 int dccId() const { return elid.dccId(); }
0216 int towerId() const { return elid.towerId(); }
0217 int stripId() const { return elid.stripId(); }
0218 int tccId() const { return trelid.tccId(); }
0219 int ttId() const { return trelid.ttId(); }
0220 int pseudoStripId() const { return trelid.pseudoStripId(); }
0221 };
0222
0223
0224 typedef boost::multi_index::multi_index_container<
0225 MapItem,
0226 boost::multi_index::indexed_by<
0227
0228
0229
0230 boost::multi_index::ordered_unique<boost::multi_index::member<MapItem, DetId, &MapItem::cell> >,
0231 boost::multi_index::ordered_unique<boost::multi_index::member<MapItem, EcalElectronicsId, &MapItem::elid> >,
0232 boost::multi_index::ordered_unique<
0233 boost::multi_index::member<MapItem, EcalTriggerElectronicsId, &MapItem::trelid> >,
0234 boost::multi_index::ordered_non_unique<boost::multi_index::const_mem_fun<MapItem, int, &MapItem::dccId> >,
0235 boost::multi_index::ordered_non_unique<
0236 boost::multi_index::composite_key<MapItem,
0237 boost::multi_index::const_mem_fun<MapItem, int, &MapItem::dccId>,
0238 boost::multi_index::const_mem_fun<MapItem, int, &MapItem::towerId> > >,
0239 boost::multi_index::ordered_non_unique<
0240 boost::multi_index::composite_key<MapItem,
0241 boost::multi_index::const_mem_fun<MapItem, int, &MapItem::dccId>,
0242 boost::multi_index::const_mem_fun<MapItem, int, &MapItem::towerId>,
0243 boost::multi_index::const_mem_fun<MapItem, int, &MapItem::stripId> > >,
0244 boost::multi_index::ordered_non_unique<boost::multi_index::const_mem_fun<MapItem, int, &MapItem::tccId> >,
0245 boost::multi_index::ordered_non_unique<
0246 boost::multi_index::composite_key<MapItem,
0247 boost::multi_index::const_mem_fun<MapItem, int, &MapItem::tccId>,
0248 boost::multi_index::const_mem_fun<MapItem, int, &MapItem::ttId> > >,
0249 boost::multi_index::ordered_non_unique<boost::multi_index::composite_key<
0250 MapItem,
0251 boost::multi_index::const_mem_fun<MapItem, int, &MapItem::tccId>,
0252 boost::multi_index::const_mem_fun<MapItem, int, &MapItem::ttId>,
0253 boost::multi_index::const_mem_fun<MapItem, int, &MapItem::pseudoStripId> > > > >
0254 EcalElectronicsMap;
0255
0256 typedef EcalElectronicsMap::nth_index<0>::type EcalElectronicsMap_by_DetId;
0257 typedef EcalElectronicsMap::nth_index<1>::type EcalElectronicsMap_by_ElectronicsId;
0258 typedef EcalElectronicsMap::nth_index<2>::type EcalElectronicsMap_by_TriggerElectronicsId;
0259
0260 typedef EcalElectronicsMap::nth_index<3>::type EcalElectronicsMap_by_DccId;
0261 typedef EcalElectronicsMap::nth_index<4>::type EcalElectronicsMap_by_DccId_and_TowerId;
0262 typedef EcalElectronicsMap::nth_index<5>::type EcalElectronicsMap_by_DccId_TowerId_and_StripId;
0263
0264 typedef EcalElectronicsMap::nth_index<6>::type EcalElectronicsMap_by_TccId;
0265 typedef EcalElectronicsMap::nth_index<7>::type EcalElectronicsMap_by_TccId_and_TtId;
0266 typedef EcalElectronicsMap::nth_index<8>::type EcalElectronicsMap_by_TccId_TtId_and_PseudostripId;
0267
0268
0269 EcalElectronicsMap m_items;
0270
0271
0272
0273
0274
0275 std::map<int, int> LaserMonitoringMap_EB;
0276 std::map<int, int> LaserMonitoringMap_EE;
0277 };
0278
0279 #endif