CMS 3D CMS Logo

CaloGeometryBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CaloGeometryBuilder
4 // Class: CaloGeometryBuilder
5 //
13 //
14 // Original Author: Jeremiah Mans
15 // Created: Mon Oct 3 11:35:27 CDT 2005
16 //
17 //
18 
19 // user include files
33 
34 namespace {
35  template <typename Record>
36  void makeToken(edm::ESConsumesCollector& cc,
37  std::vector<std::string>& list,
38  std::string const& tag,
40  auto found = std::find(list.begin(), list.end(), tag);
41  edm::LogVerbatim("CaloGeometryBuilder") << "Finds tag " << tag << " : " << (found != list.end());
42  if (found != list.end()) {
44  list.erase(found);
45  }
46  }
47 } // namespace
48 
49 //
50 // member functions
51 //
53  //the following line is needed to tell the framework what
54  // data is being produced
56 
57  //now do what ever other initialization is needed
58  auto caloList = iConfig.getParameter<std::vector<std::string> >("SelectedCalos");
59  if (caloList.empty())
60  throw cms::Exception("Configuration") << "No calorimeter specified for geometry, aborting";
61 
62  makeToken(cc, caloList, HcalGeometry::producerTag(), hcalToken_);
63  makeToken(cc, caloList, ZdcGeometry::producerTag(), zdcToken_);
64  makeToken(cc, caloList, CastorGeometry::producerTag(), castorToken_);
65  makeToken(cc, caloList, EcalBarrelGeometry::producerTag(), ecalBarrelToken_);
66  makeToken(cc, caloList, EcalEndcapGeometry::producerTag(), ecalEndcapToken_);
68  makeToken(cc, caloList, CaloTowerGeometry::producerTag(), caloTowerToken_);
69 
70  // Move HGC elements to the end
71  auto hgcBegin = std::partition(caloList.begin(), caloList.end(), [](std::string const& elem) {
72  return elem.find(HGCalGeometry::producerTag()) == std::string::npos;
73  });
74  // Process HGC elements
75  for (auto iter = hgcBegin; iter != caloList.end(); ++iter) {
76  hgcalTokens_.emplace_back(cc.consumesFrom<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag{"", *iter}), *iter);
77  }
78  // Erase HGC elements
79  caloList.erase(hgcBegin, caloList.end());
80 
81  // Throw if any elements are left
82  if (not caloList.empty()) {
83  cms::Exception ex{"Configuration"};
84  ex << "Reconstruction geometry requested for a not implemented sub-detectors:";
85  for (auto const& elem : caloList) {
86  ex << " " << elem;
87  }
88  throw ex;
89  }
90 }
91 
92 // ------------ method called to produce the data ------------
93 
95  ReturnType pCalo = std::make_unique<CaloGeometry>();
96 
97  // look for HCAL parts
98  // assume 'HCAL' for all of HCAL.
99  if (hcalToken_.isInitialized()) {
100  edm::LogVerbatim("CaloGeometryBuilder") << "Building HCAL reconstruction geometry";
101 
102  auto const& pG = iRecord.get(hcalToken_);
103  pCalo->setSubdetGeometry(DetId::Hcal, HcalBarrel, &pG);
104  pCalo->setSubdetGeometry(DetId::Hcal, HcalEndcap, &pG);
105  pCalo->setSubdetGeometry(DetId::Hcal, HcalOuter, &pG);
106  pCalo->setSubdetGeometry(DetId::Hcal, HcalForward, &pG);
107  }
108  if (zdcToken_.isInitialized()) {
109  edm::LogVerbatim("CaloGeometryBuilder") << "Building ZDC reconstruction geometry";
110  auto const& pG = iRecord.get(zdcToken_);
111  pCalo->setSubdetGeometry(DetId::Calo, HcalZDCDetId::SubdetectorId, &pG);
112  }
113  if (castorToken_.isInitialized()) {
114  edm::LogVerbatim("CaloGeometryBuilder") << "Building CASTOR reconstruction geometry";
115  auto const& pG = iRecord.get(castorToken_);
116  pCalo->setSubdetGeometry(DetId::Calo, HcalCastorDetId::SubdetectorId, &pG);
117  }
118 
119  // look for Ecal Barrel
121  edm::LogVerbatim("CaloGeometryBuilder") << "Building EcalBarrel reconstruction geometry";
122  auto const& pG = iRecord.get(ecalBarrelToken_);
123  pCalo->setSubdetGeometry(DetId::Ecal, EcalBarrel, &pG);
124  }
125  // look for Ecal Endcap
127  edm::LogVerbatim("CaloGeometryBuilder") << "Building EcalEndcap reconstruction geometry";
128  auto const& pG = iRecord.get(ecalEndcapToken_);
129  pCalo->setSubdetGeometry(DetId::Ecal, EcalEndcap, &pG);
130  }
131  // look for Ecal Preshower
133  edm::LogVerbatim("CaloGeometryBuilder") << "Building EcalPreshower reconstruction geometry";
134  const auto& pG = iRecord.get(ecalPreshowerToken_);
135  pCalo->setSubdetGeometry(DetId::Ecal, EcalPreshower, &pG);
136  }
137 
138  // look for TOWER parts
140  edm::LogVerbatim("CaloGeometryBuilder") << "Building TOWER reconstruction geometry";
141  const auto& pG = iRecord.get(caloTowerToken_);
142  pCalo->setSubdetGeometry(DetId::Calo, 1, &pG);
143  }
144 
145  for (auto const& hgcTokenLabel : hgcalTokens_) {
146  edm::LogVerbatim("CaloGeometryBuilder") << "Building " << hgcTokenLabel.second << " reconstruction geometry";
147  auto const& pHG = iRecord.get(hgcTokenLabel.first);
148  const auto& topo = pHG.topology();
149  pCalo->setSubdetGeometry(topo.detector(), topo.subDetector(), &pHG);
150  }
151 
152  return pCalo;
153 }
ZdcGeometry::producerTag
static std::string producerTag()
Definition: ZdcGeometry.h:44
edm::ESInputTag
Definition: ESInputTag.h:87
EcalBarrelGeometry.h
CaloGeometryBuilder::caloTowerToken_
edm::ESGetToken< CaloSubdetectorGeometry, CaloTowerGeometryRecord > caloTowerToken_
Definition: CaloGeometryBuilder.h:56
MessageLogger.h
CaloGeometryBuilder::ecalEndcapToken_
edm::ESGetToken< CaloSubdetectorGeometry, EcalEndcapGeometryRecord > ecalEndcapToken_
Definition: CaloGeometryBuilder.h:54
CaloGeometryBuilder::ecalPreshowerToken_
edm::ESGetToken< CaloSubdetectorGeometry, EcalPreshowerGeometryRecord > ecalPreshowerToken_
Definition: CaloGeometryBuilder.h:55
HcalGeometry::producerTag
static std::string producerTag()
Definition: HcalGeometry.h:65
edm::ESConsumesCollector
Definition: ESConsumesCollector.h:61
CaloGeometryBuilder::hcalToken_
edm::ESGetToken< CaloSubdetectorGeometry, HcalGeometryRecord > hcalToken_
Definition: CaloGeometryBuilder.h:50
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
DetId::Hcal
Definition: DetId.h:28
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
CaloTowerGeometry::producerTag
static std::string producerTag()
Definition: CaloTowerGeometry.h:40
HcalCastorDetId::SubdetectorId
static const int SubdetectorId
Definition: HcalCastorDetId.h:28
HcalBarrel
Definition: HcalAssistant.h:33
HcalZDCDetId.h
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
DetId::Calo
Definition: DetId.h:29
CastorGeometry::producerTag
static std::string producerTag()
Definition: CastorGeometry.h:48
EcalBarrel
Definition: EcalSubdetector.h:10
ZdcGeometry.h
HcalGeometry.h
edm::ESGetToken::isInitialized
constexpr bool isInitialized() const noexcept
Definition: ESGetToken.h:72
CaloGeometryBuilder::zdcToken_
edm::ESGetToken< CaloSubdetectorGeometry, ZDCGeometryRecord > zdcToken_
Definition: CaloGeometryBuilder.h:51
CaloGeometryBuilder.h
HcalOuter
Definition: HcalAssistant.h:35
CaloGeometryBuilder::hgcalTokens_
std::vector< std::pair< edm::ESGetToken< HGCalGeometry, IdealGeometryRecord >, std::string > > hgcalTokens_
Definition: CaloGeometryBuilder.h:57
EcalPreshowerGeometry.h
HcalZDCDetId::SubdetectorId
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:109
HGCalGeometry
Definition: HGCalGeometry.h:29
CaloGeometryBuilder::castorToken_
edm::ESGetToken< CaloSubdetectorGeometry, CastorGeometryRecord > castorToken_
Definition: CaloGeometryBuilder.h:52
EcalSubdetector.h
EcalEndcap
Definition: EcalSubdetector.h:10
EcalBarrelGeometry::producerTag
static std::string producerTag()
Definition: EcalBarrelGeometry.h:83
edm::ParameterSet
Definition: ParameterSet.h:47
makeGlobalPositionRcd_cfg.tag
tag
Definition: makeGlobalPositionRcd_cfg.py:6
EcalEndcapGeometry.h
CaloGeometryBuilder::CaloGeometryBuilder
CaloGeometryBuilder(const edm::ParameterSet &iConfig)
Definition: CaloGeometryBuilder.cc:52
HGCalGeometry::producerTag
static std::string producerTag()
Definition: HGCalGeometry.h:108
EcalPreshowerGeometry::producerTag
static std::string producerTag()
Definition: EcalPreshowerGeometry.h:62
HcalSubdetector.h
CaloGeometryBuilder::produceAligned
ReturnType produceAligned(const CaloGeometryRecord &iRecord)
Definition: CaloGeometryBuilder.cc:94
DetId::Ecal
Definition: DetId.h:27
cc
edm::ESGetToken
Definition: EventSetup.h:48
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalForward
Definition: HcalAssistant.h:36
EcalPreshower
Definition: EcalSubdetector.h:10
EcalEndcapGeometry::producerTag
static std::string producerTag()
Definition: EcalEndcapGeometry.h:77
HcalEndcap
Definition: HcalAssistant.h:34
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Record
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CaloTowerGeometry.h
cms::Exception
Definition: Exception.h:70
CaloGeometryBuilder::ReturnType
std::unique_ptr< CaloGeometry > ReturnType
Definition: CaloGeometryBuilder.h:39
HcalCastorDetId.h
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
CaloGeometryBuilder::ecalBarrelToken_
edm::ESGetToken< CaloSubdetectorGeometry, EcalBarrelGeometryRecord > ecalBarrelToken_
Definition: CaloGeometryBuilder.h:53
CastorGeometry.h
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316