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_);
67  makeToken(cc, caloList, EcalPreshowerGeometry::producerTag(), ecalPreshowerToken_);
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 
96 
97  ReturnType pCalo = std::make_unique<CaloGeometry>();
98 
99  // look for HCAL parts
100  // assume 'HCAL' for all of HCAL.
101  if (hcalToken_.isInitialized()) {
102  edm::LogVerbatim("CaloGeometryBuilder") << "Building HCAL reconstruction geometry";
103 
104  auto const& pG = iRecord.get(hcalToken_);
105  pCalo->setSubdetGeometry(DetId::Hcal, HcalBarrel, &pG);
106  pCalo->setSubdetGeometry(DetId::Hcal, HcalEndcap, &pG);
107  pCalo->setSubdetGeometry(DetId::Hcal, HcalOuter, &pG);
108  pCalo->setSubdetGeometry(DetId::Hcal, HcalForward, &pG);
109  }
110  if (zdcToken_.isInitialized()) {
111  edm::LogVerbatim("CaloGeometryBuilder") << "Building ZDC reconstruction geometry";
112  auto const& pG = iRecord.get(zdcToken_);
113  pCalo->setSubdetGeometry(DetId::Calo, HcalZDCDetId::SubdetectorId, &pG);
114  }
115  if (castorToken_.isInitialized()) {
116  edm::LogVerbatim("CaloGeometryBuilder") << "Building CASTOR reconstruction geometry";
117  auto const& pG = iRecord.get(castorToken_);
118  pCalo->setSubdetGeometry(DetId::Calo, HcalCastorDetId::SubdetectorId, &pG);
119  }
120 
121  // look for Ecal Barrel
123  edm::LogVerbatim("CaloGeometryBuilder") << "Building EcalBarrel reconstruction geometry";
124  auto const& pG = iRecord.get(ecalBarrelToken_);
125  pCalo->setSubdetGeometry(DetId::Ecal, EcalBarrel, &pG);
126  }
127  // look for Ecal Endcap
129  edm::LogVerbatim("CaloGeometryBuilder") << "Building EcalEndcap reconstruction geometry";
130  auto const& pG = iRecord.get(ecalEndcapToken_);
131  pCalo->setSubdetGeometry(DetId::Ecal, EcalEndcap, &pG);
132  }
133  // look for Ecal Preshower
135  edm::LogVerbatim("CaloGeometryBuilder") << "Building EcalPreshower reconstruction geometry";
136  const auto& pG = iRecord.get(ecalPreshowerToken_);
137  pCalo->setSubdetGeometry(DetId::Ecal, EcalPreshower, &pG);
138  }
139 
140  // look for TOWER parts
142  edm::LogVerbatim("CaloGeometryBuilder") << "Building TOWER reconstruction geometry";
143  const auto& pG = iRecord.get(caloTowerToken_);
144  pCalo->setSubdetGeometry(DetId::Calo, 1, &pG);
145  }
146 
147  for (auto const& hgcTokenLabel : hgcalTokens_) {
148  edm::LogVerbatim("CaloGeometryBuilder") << "Building " << hgcTokenLabel.second << " reconstruction geometry";
149  auto const& pHG = iRecord.get(hgcTokenLabel.first);
150  const auto& topo = pHG.topology();
151  pCalo->setSubdetGeometry(topo.detector(), topo.subDetector(), &pHG);
152  }
153 
154  return pCalo;
155 }
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
static std::string producerTag()
Definition: ZdcGeometry.h:44
static std::string producerTag()
static std::string producerTag()
Definition: HcalGeometry.h:63
edm::ESGetToken< CaloSubdetectorGeometry, CaloTowerGeometryRecord > caloTowerToken_
static std::string producerTag()
auto consumesFrom(ESInputTag const &tag)
edm::ESGetToken< CaloSubdetectorGeometry, HcalGeometryRecord > hcalToken_
CaloGeometryBuilder(const edm::ParameterSet &iConfig)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
static std::string producerTag()
static std::string producerTag()
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
static const int SubdetectorId
std::vector< std::pair< edm::ESGetToken< HGCalGeometry, IdealGeometryRecord >, std::string > > hgcalTokens_
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:19
edm::ESGetToken< CaloSubdetectorGeometry, CastorGeometryRecord > castorToken_
static std::string producerTag()
edm::ESGetToken< CaloSubdetectorGeometry, EcalBarrelGeometryRecord > ecalBarrelToken_
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
edm::ESGetToken< CaloSubdetectorGeometry, ZDCGeometryRecord > zdcToken_
static std::string producerTag()
std::unique_ptr< CaloGeometry > ReturnType
edm::ESGetToken< CaloSubdetectorGeometry, EcalPreshowerGeometryRecord > ecalPreshowerToken_
constexpr bool isInitialized() const noexcept
Definition: ESGetToken.h:52
edm::ESGetToken< CaloSubdetectorGeometry, EcalEndcapGeometryRecord > ecalEndcapToken_
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
ReturnType produceAligned(const CaloGeometryRecord &iRecord)