CMS 3D CMS Logo

MTDTopologyEP.cc
Go to the documentation of this file.
1 //#define EDM_ML_DEBUG
2 
14 
15 #include <memory>
16 
18 public:
20 
21  using ReturnType = std::unique_ptr<MTDTopology>;
22 
23  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
24 
26 
27 private:
28  void fillParameters(const PMTDParameters&, int& mtdTopologyMode, MTDTopology::ETLValues&);
29 
31 };
32 
34  : token_{setWhatProduced(this).consumesFrom<PMTDParameters, PMTDParametersRcd>(edm::ESInputTag())} {}
35 
38  descriptions.add("mtdTopology", ttc);
39 }
40 
42  int mtdTopologyMode;
43  MTDTopology::ETLValues etlVals;
44 
45  fillParameters(iRecord.get(token_), mtdTopologyMode, etlVals);
46 
47  return std::make_unique<MTDTopology>(mtdTopologyMode, etlVals);
48 }
49 
50 void MTDTopologyEP::fillParameters(const PMTDParameters& ptp, int& mtdTopologyMode, MTDTopology::ETLValues& etlVals) {
51  mtdTopologyMode = ptp.topologyMode_;
52 
53  // for legacy geometry scenarios no topology informastion is stored, only for newer ETL 2-discs layout
54 
55  if (mtdTopologyMode <= static_cast<int>(MTDTopologyMode::Mode::barphiflat)) {
56  return;
57  }
58 
59  // Check on the internal consistency of thr ETL layout information provided by parameters
60 
61  for (size_t it = 3; it <= 9; it++) {
62  if (ptp.vitems_[it].vpars_.size() != ptp.vitems_[2].vpars_.size()) {
63  throw cms::Exception("MTDTopologyEP") << "Inconsistent size of ETL structure arrays";
64  }
65  }
66 
68 
69  // Front Face (0), starting with type Right (2)
70 
71  tmpFace.idDiscSide_ = 0; // ETL front side
72  tmpFace.idDetType1_ = 2; // ETL module type right
73 
74  tmpFace.start_copy_[0] = ptp.vitems_[3].vpars_; // start_copy_FR
75  tmpFace.start_copy_[1] = ptp.vitems_[2].vpars_; // start_copy_FL
76  tmpFace.offset_[0] = ptp.vitems_[7].vpars_; // offset_FR
77  tmpFace.offset_[1] = ptp.vitems_[6].vpars_; // offset_FL
78 
79  etlVals.emplace_back(tmpFace);
80 
81  // Back Face (1), starting with type Left (1)
82 
83  tmpFace.idDiscSide_ = 1; // ETL back side
84  tmpFace.idDetType1_ = 1; // ETL module type left
85 
86  tmpFace.start_copy_[0] = ptp.vitems_[4].vpars_; // start_copy_BL
87  tmpFace.start_copy_[1] = ptp.vitems_[5].vpars_; // start_copy_BR
88  tmpFace.offset_[0] = ptp.vitems_[8].vpars_; // offset_BL
89  tmpFace.offset_[1] = ptp.vitems_[9].vpars_; // offset_BR
90 
91  etlVals.emplace_back(tmpFace);
92 
93 #ifdef EDM_ML_DEBUG
94  edm::LogVerbatim("MTDTopologyEP") << " Topology mode = " << mtdTopologyMode << "\n";
95  auto print_array = [&](std::vector<int> vector) {
96  std::stringstream ss;
97  for (auto const& elem : vector) {
98  ss << " " << elem;
99  }
100  ss << "\n";
101  return ss.str();
102  };
103 
104  for (auto const& ilay : etlVals) {
105  edm::LogVerbatim("MTDTopologyEP") << " disc face = " << ilay.idDiscSide_ << " start det type = " << ilay.idDetType1_
106  << "\n start_copy[0]= " << print_array(ilay.start_copy_[0])
107  << "\n start_copy[1]= " << print_array(ilay.start_copy_[1])
108  << "\n offset[0]= " << print_array(ilay.offset_[0])
109  << "\n offset[1]= " << print_array(ilay.offset_[1]);
110  }
111 
112 #endif
113 }
114 
Log< level::Info, true > LogVerbatim
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:165
MTDTopologyEP(const edm::ParameterSet &)
std::vector< Item > vitems_
std::vector< ETLfaceLayout > ETLValues
Definition: MTDTopology.h:23
const edm::ESGetToken< PMTDParameters, PMTDParametersRcd > token_
std::array< std::vector< int >, 2 > start_copy_
Definition: MTDTopology.h:19
std::array< std::vector< int >, 2 > offset_
Definition: MTDTopology.h:20
ReturnType produce(const MTDTopologyRcd &)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:61
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::unique_ptr< MTDTopology > ReturnType
void fillParameters(const PMTDParameters &, int &mtdTopologyMode, MTDTopology::ETLValues &)
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const