File indexing completed on 2024-04-06 12:29:26
0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 #include "SimCalorimetry/EcalSimAlgos/interface/ComponentShapeCollection.h"
0003
0004
0005 void ComponentShapeCollection::setEventSetup(const edm::EventSetup& evtSetup) {
0006 #ifdef component_shape_debug
0007 std::cout << "ComponentShapeCollection::setEventSetup called " << std::endl;
0008 #endif
0009 buildMe(&evtSetup);
0010 for (int i = 0; i < m_nDepthBins; ++i) {
0011 m_shapeArr[i]->setEventSetup(evtSetup, false);
0012 }
0013 }
0014
0015 void ComponentShapeCollection::buildMe(const edm::EventSetup* evtSetup) {
0016 #ifdef component_shape_debug
0017 std::cout << "ComponentShapeCollection::buildMe called " << std::endl;
0018 #endif
0019 fillCollection(m_useDBShape);
0020 };
0021
0022 void ComponentShapeCollection::fillCollection(edm::ConsumesCollector iC) {
0023 #ifdef component_shape_debug
0024 std::cout << "ComponentShapeCollection::fillCollection(edm::ConsumesCollector iC) called " << std::endl;
0025 #endif
0026
0027 for (int i = 0; i < m_nDepthBins; ++i) {
0028 m_shapeArr[i] = std::make_shared<ComponentShape>(i, espsToken_);
0029 }
0030 }
0031
0032 void ComponentShapeCollection::fillCollection(bool useDBShape = false) {
0033 #ifdef component_shape_debug
0034 std::cout << "ComponentShapeCollection::fillCollection(bool useDBShape) called " << std::endl;
0035 #endif
0036
0037 if (useDBShape) {
0038 for (int i = 0; i < m_nDepthBins; ++i) {
0039 m_shapeArr[i] = std::make_shared<ComponentShape>(i, espsToken_);
0040 }
0041 } else {
0042 for (int i = 0; i < m_nDepthBins; ++i) {
0043 m_shapeArr[i] = std::make_shared<ComponentShape>(i);
0044 }
0045 }
0046 }
0047
0048 const std::shared_ptr<ComponentShape> ComponentShapeCollection::at(int depthIndex) const {
0049 if (0 > toDepthBin(depthIndex) || toDepthBin(depthIndex) > m_nDepthBins - 1)
0050 throw cms::Exception("ComponentShape:: invalid depth requested");
0051 return m_shapeArr[toDepthBin(depthIndex)];
0052 }
0053
0054 int ComponentShapeCollection::toDepthBin(int index) { return index >> 3; }
0055
0056 int ComponentShapeCollection::maxDepthBin() { return m_nDepthBins - 1; }