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 
ConfigurationDescriptions.h
PMTDParameters
Definition: PMTDParameters.h:6
MTDTopologyEP::produce
ReturnType produce(const MTDTopologyRcd &)
Definition: MTDTopologyEP.cc:41
MTDTopologyEP::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: MTDTopologyEP.cc:36
edm::ESInputTag
Definition: ESInputTag.h:87
MessageLogger.h
MTDTopology::ETLValues
std::vector< ETLfaceLayout > ETLValues
Definition: MTDTopology.h:23
MTDTopologyEP::token_
const edm::ESGetToken< PMTDParameters, PMTDParametersRcd > token_
Definition: MTDTopologyEP.cc:30
PMTDParameters::vitems_
std::vector< Item > vitems_
Definition: PMTDParameters.h:18
ESHandle.h
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ESProducer.h
MTDTopologyMode::Mode::barphiflat
MTDTopologyMode.h
MTDTopology::ETLfaceLayout
Definition: MTDTopology.h:15
MTDTopologyEP::ReturnType
std::unique_ptr< MTDTopology > ReturnType
Definition: MTDTopologyEP.cc:21
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
MTDTopology::ETLfaceLayout::start_copy_
std::array< std::vector< int >, 2 > start_copy_
Definition: MTDTopology.h:19
MTDTopology::ETLfaceLayout::offset_
std::array< std::vector< int >, 2 > offset_
Definition: MTDTopology.h:20
ParameterSetDescription.h
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:109
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
MTDTopologyEP::MTDTopologyEP
MTDTopologyEP(const edm::ParameterSet &)
Definition: MTDTopologyEP.cc:33
PMTDParametersRcd.h
edm::ParameterSet
Definition: ParameterSet.h:47
MTDTopologyRcd
Definition: MTDTopologyRcd.h:10
PMTDParametersRcd
Definition: PMTDParametersRcd.h:9
MTDTopologyEP::fillParameters
void fillParameters(const PMTDParameters &, int &mtdTopologyMode, MTDTopology::ETLValues &)
Definition: MTDTopologyEP.cc:50
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
PMTDParameters::topologyMode_
int topologyMode_
Definition: PMTDParameters.h:20
edm::ESGetToken< PMTDParameters, PMTDParametersRcd >
ModuleFactory.h
MTDTopologyRcd.h
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Exception
Definition: hltDiff.cc:245
PMTDParameters.h
MTDTopology::ETLfaceLayout::idDetType1_
uint32_t idDetType1_
Definition: MTDTopology.h:17
MTDTopology::ETLfaceLayout::idDiscSide_
uint32_t idDiscSide_
Definition: MTDTopology.h:16
edm::ESProducer
Definition: ESProducer.h:104
MTDTopologyEP
Definition: MTDTopologyEP.cc:17
MTDTopology.h