CMS 3D CMS Logo

MuonOffsetESProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: DetectorDescription/MuonOffsetESProducer
4 // Class: MuonOffsetESProducer
5 //
13 //
14 // Original Author: Sunanda Banerjee
15 // Created: Fri, 16 Oct 2020 09:10:32 GMT
16 //
17 //
18 
30 
31 #include <memory>
32 #include <string>
33 #include <vector>
34 
35 //#define EDM_ML_DEBUG
36 
38 public:
40 
41  using ReturnType = std::unique_ptr<MuonOffsetMap>;
42 
45 
46 private:
47  const bool fromDD4hep_;
48  const std::vector<std::string> names_;
51 };
52 
54  : fromDD4hep_(iConfig.getParameter<bool>("fromDD4hep")),
55  names_(iConfig.getParameter<std::vector<std::string>>("names")) {
56  auto cc = setWhatProduced(this);
57  if (fromDD4hep_) {
59  } else {
61  }
62 #ifdef EDM_ML_DEBUG
63  edm::LogVerbatim("MuonGeom") << "MuonOffsetESProducer::MuonOffsetESProducer called with dd4hep: " << fromDD4hep_;
64 #endif
65 }
66 
69  std::vector<std::string> names = {"MuonCommonNumbering",
70  "MuonBarrel",
71  "MuonEndcap",
72  "MuonBarrelWheels",
73  "MuonBarrelStation1",
74  "MuonBarrelStation2",
75  "MuonBarrelStation3",
76  "MuonBarrelStation4",
77  "MuonBarrelSuperLayer",
78  "MuonBarrelLayer",
79  "MuonBarrelWire",
80  "MuonRpcPlane1I",
81  "MuonRpcPlane1O",
82  "MuonRpcPlane2I",
83  "MuonRpcPlane2O",
84  "MuonRpcPlane3S",
85  "MuonRpcPlane4",
86  "MuonRpcChamberLeft",
87  "MuonRpcChamberMiddle",
88  "MuonRpcChamberRight",
89  "MuonRpcEndcap1",
90  "MuonRpcEndcap2",
91  "MuonRpcEndcap3",
92  "MuonRpcEndcap4",
93  "MuonRpcEndcapSector",
94  "MuonRpcEndcapChamberB1",
95  "MuonRpcEndcapChamberB2",
96  "MuonRpcEndcapChamberB3",
97  "MuonRpcEndcapChamberC1",
98  "MuonRpcEndcapChamberC2",
99  "MuonRpcEndcapChamberC3",
100  "MuonRpcEndcapChamberE1",
101  "MuonRpcEndcapChamberE2",
102  "MuonRpcEndcapChamberE3",
103  "MuonRpcEndcapChamberF1",
104  "MuonRpcEndcapChamberF2",
105  "MuonRpcEndcapChamberF3",
106  "MuonEndcapStation1",
107  "MuonEndcapStation2",
108  "MuonEndcapStation3",
109  "MuonEndcapStation4",
110  "MuonEndcapSubrings",
111  "MuonEndcapSectors",
112  "MuonEndcapLayers",
113  "MuonEndcapRing1",
114  "MuonEndcapRing2",
115  "MuonEndcapRing3",
116  "MuonEndcapRingA",
117  "MuonGEMEndcap",
118  "MuonGEMSector",
119  "MuonGEMChamber"};
120  desc.add<bool>("fromDD4hep", false);
121  desc.add<std::vector<std::string>>("names", names);
122  descriptions.add("muonOffsetESProducer", desc);
123 }
124 
126 #ifdef EDM_ML_DEBUG
127  edm::LogVerbatim("MuonGeom") << "MuonOffsetESProducer::produce(const IdealGeometryRecord& iRecord)";
128 #endif
129 
130  auto ptp = std::make_unique<MuonOffsetMap>();
131  MuonOffsetFromDD builder(names_);
132 
133  if (fromDD4hep_) {
134 #ifdef EDM_ML_DEBUG
135  edm::LogVerbatim("MuonGeom") << "MuonOffsetESProducer::Try to access cms::DDCompactView";
136 #endif
138  builder.build(&(*cpv), *ptp);
139  } else {
140 #ifdef EDM_ML_DEBUG
141  edm::LogVerbatim("MuonGeom") << "MuonOffsetESProducer::Try to access DDCompactView";
142 #endif
144  builder.build(&(*cpv), *ptp);
145  }
146  return ptp;
147 }
148 
ESTransientHandle< ProductT > getTransientHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
Log< level::Info, true > LogVerbatim
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
edm::ESGetToken< DDCompactView, IdealGeometryRecord > cpvTokenDDD_
std::unique_ptr< MuonOffsetMap > ReturnType
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
const std::string names[nVars_]
ReturnType produce(const IdealGeometryRecord &)
static void fillDescriptions(edm::ConfigurationDescriptions &)
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > cpvTokenDD4hep_
MuonOffsetESProducer(const edm::ParameterSet &)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const std::vector< std::string > names_