CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
PPSGeometryBuilder Class Reference
Inheritance diagram for PPSGeometryBuilder:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
 PPSGeometryBuilder (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

PDetGeomDesc::Item buildItemFromDetGeomDesc (const DetGeomDesc *geoInfo)
 
void buildSerializableDataFromGeoInfo (PDetGeomDesc *serializableData, const DetGeomDesc *geoInfo, int &counter)
 

Private Attributes

std::string compactViewTag_
 
edm::Service< cond::service::PoolDBOutputServicedbService_
 
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecorddd4hepToken_
 
edm::ESGetToken< DDCompactView, IdealGeometryRecordddToken_
 
bool fromDD4hep_
 
edm::ESWatcher< IdealGeometryRecordwatcherIdealGeometry_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 29 of file PPSGeometryBuilder.cc.

Constructor & Destructor Documentation

◆ PPSGeometryBuilder()

PPSGeometryBuilder::PPSGeometryBuilder ( const edm::ParameterSet iConfig)
explicit

Definition at line 46 of file PPSGeometryBuilder.cc.

47  : fromDD4hep_(iConfig.getUntrackedParameter<bool>("fromDD4hep", false)),
48  compactViewTag_(iConfig.getUntrackedParameter<std::string>("compactViewTag", "XMLIdealGeometryESSource_CTPPS")),

Member Function Documentation

◆ analyze()

void PPSGeometryBuilder::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 55 of file PPSGeometryBuilder.cc.

55  {
56  // Get DetGeomDesc tree
57  std::unique_ptr<DetGeomDesc> geoInfoRoot = nullptr;
58  if (watcherIdealGeometry_.check(iSetup)) {
59  edm::LogInfo("PPSGeometryBuilder") << "Got IdealGeometryRecord ";
60  // old DD
61  if (!fromDD4hep_) {
62  // Get CompactView from IdealGeometryRecord
63  auto const& myCompactView = iSetup.getData(ddToken_);
64 
65  // Build geometry
66  geoInfoRoot = detgeomdescbuilder::buildDetGeomDescFromCompactView(myCompactView);
67  }
68  // DD4hep
69  else {
70  // Get CompactView from IdealGeometryRecord
71  auto const& myCompactView = iSetup.getData(dd4hepToken_);
72 
73  // Build geometry
74  geoInfoRoot = detgeomdescbuilder::buildDetGeomDescFromCompactView(myCompactView);
75  }
76  }
77 
78  // Build persistent geometry data from geometry
79  PDetGeomDesc* serializableData =
80  new PDetGeomDesc(); // cond::service::PoolDBOutputService::writeOne interface requires raw pointer.
81  int counter = 0;
82  if (geoInfoRoot) {
83  buildSerializableDataFromGeoInfo(serializableData, geoInfoRoot.get(), counter);
84  }
85 
86  // Save geometry in the database
87  if (serializableData->container_.empty()) {
88  throw cms::Exception("PPSGeometryBuilder") << "PDetGeomDesc is empty, no geometry to save in the database.";
89  } else {
90  if (dbService_.isAvailable()) {
91  dbService_->writeOne(serializableData, dbService_->beginOfTime(), "VeryForwardIdealGeometryRecord");
92  edm::LogInfo("PPSGeometryBuilder") << "Successfully wrote DB, with " << serializableData->container_.size()
93  << " PDetGeomDesc items.";
94  } else {
95  throw cms::Exception("PPSGeometryBuilder") << "PoolDBService required.";
96  }
97  }
98 }

References cond::service::PoolDBOutputService::beginOfTime(), detgeomdescbuilder::buildDetGeomDescFromCompactView(), buildSerializableDataFromGeoInfo(), edm::ESWatcher< T >::check(), PDetGeomDesc::container_, counter, dbService_, dd4hepToken_, ddToken_, Exception, fromDD4hep_, edm::EventSetup::getData(), edm::Service< T >::isAvailable(), watcherIdealGeometry_, and cond::service::PoolDBOutputService::writeOne().

◆ buildItemFromDetGeomDesc()

PDetGeomDesc::Item PPSGeometryBuilder::buildItemFromDetGeomDesc ( const DetGeomDesc geoInfo)
private

Definition at line 125 of file PPSGeometryBuilder.cc.

125  {
127  result.dx_ = geoInfo->translation().X();
128  result.dy_ = geoInfo->translation().Y();
129  result.dz_ = geoInfo->translation().Z();
130 
131  const DDRotationMatrix& rot = geoInfo->rotation();
132  rot.GetComponents(result.axx_,
133  result.axy_,
134  result.axz_,
135  result.ayx_,
136  result.ayy_,
137  result.ayz_,
138  result.azx_,
139  result.azy_,
140  result.azz_);
141  result.name_ = geoInfo->name();
142  result.params_ = geoInfo->params();
143  result.copy_ = geoInfo->copyno();
144  result.z_ = geoInfo->parentZPosition();
145  result.sensorType_ = geoInfo->sensorType();
146  result.geographicalID_ = geoInfo->geographicalID();
147 
148  return result;
149 }

References DetGeomDesc::copyno(), DetGeomDesc::geographicalID(), DetGeomDesc::name(), DetGeomDesc::params(), DetGeomDesc::parentZPosition(), mps_fire::result, makeMuonMisalignmentScenario::rot, DetGeomDesc::rotation(), DetGeomDesc::sensorType(), and DetGeomDesc::translation().

Referenced by buildSerializableDataFromGeoInfo().

◆ buildSerializableDataFromGeoInfo()

void PPSGeometryBuilder::buildSerializableDataFromGeoInfo ( PDetGeomDesc serializableData,
const DetGeomDesc geoInfo,
int &  counter 
)
private

Definition at line 104 of file PPSGeometryBuilder.cc.

106  {
107  PDetGeomDesc::Item serializableItem = buildItemFromDetGeomDesc(geoInfo);
108  counter++;
109 
110  // Store item in serializableData
111  if ((!fromDD4hep_ && counter >= 2) // Old DD: Skip CMSE
112  || (fromDD4hep_ && counter >= 4)) { // DD4hep: Skip world + OCMS + CMSE
113  serializableData->container_.emplace_back(serializableItem);
114  }
115 
116  // Recursive calls on children
117  for (auto& child : geoInfo->components()) {
118  buildSerializableDataFromGeoInfo(serializableData, child, counter);
119  }
120 }

References buildItemFromDetGeomDesc(), DetGeomDesc::components(), PDetGeomDesc::container_, and fromDD4hep_.

Referenced by analyze().

Member Data Documentation

◆ compactViewTag_

std::string PPSGeometryBuilder::compactViewTag_
private

Definition at line 45 of file PPSGeometryBuilder.cc.

◆ dbService_

edm::Service<cond::service::PoolDBOutputService> PPSGeometryBuilder::dbService_
private

Definition at line 49 of file PPSGeometryBuilder.cc.

Referenced by analyze().

◆ dd4hepToken_

edm::ESGetToken<cms::DDCompactView, IdealGeometryRecord> PPSGeometryBuilder::dd4hepToken_
private

Definition at line 47 of file PPSGeometryBuilder.cc.

Referenced by analyze().

◆ ddToken_

edm::ESGetToken<DDCompactView, IdealGeometryRecord> PPSGeometryBuilder::ddToken_
private

Definition at line 46 of file PPSGeometryBuilder.cc.

Referenced by analyze().

◆ fromDD4hep_

bool PPSGeometryBuilder::fromDD4hep_
private

Definition at line 44 of file PPSGeometryBuilder.cc.

Referenced by analyze(), and buildSerializableDataFromGeoInfo().

◆ watcherIdealGeometry_

edm::ESWatcher<IdealGeometryRecord> PPSGeometryBuilder::watcherIdealGeometry_
private

Definition at line 48 of file PPSGeometryBuilder.cc.

Referenced by analyze().

PPSGeometryBuilder::watcherIdealGeometry_
edm::ESWatcher< IdealGeometryRecord > watcherIdealGeometry_
Definition: PPSGeometryBuilder.cc:48
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
counter
Definition: counter.py:1
edm::ESInputTag
Definition: ESInputTag.h:87
cond::service::PoolDBOutputService::beginOfTime
cond::Time_t beginOfTime() const
Definition: PoolDBOutputService.cc:215
PPSGeometryBuilder::compactViewTag_
std::string compactViewTag_
Definition: PPSGeometryBuilder.cc:45
DetGeomDesc::translation
const Translation & translation() const
Definition: DetGeomDesc.h:73
PDetGeomDesc::Item
Definition: PDetGeomDesc.h:11
DetGeomDesc::sensorType
const std::string & sensorType() const
Definition: DetGeomDesc.h:91
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
PPSGeometryBuilder::buildItemFromDetGeomDesc
PDetGeomDesc::Item buildItemFromDetGeomDesc(const DetGeomDesc *geoInfo)
Definition: PPSGeometryBuilder.cc:125
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
DetGeomDesc::parentZPosition
float parentZPosition() const
Definition: DetGeomDesc.h:98
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
PPSGeometryBuilder::buildSerializableDataFromGeoInfo
void buildSerializableDataFromGeoInfo(PDetGeomDesc *serializableData, const DetGeomDesc *geoInfo, int &counter)
Definition: PPSGeometryBuilder.cc:104
DetGeomDesc::geographicalID
DetId geographicalID() const
Definition: DetGeomDesc.h:94
PDetGeomDesc::container_
std::vector< Item > container_
Definition: PDetGeomDesc.h:26
PPSGeometryBuilder::dbService_
edm::Service< cond::service::PoolDBOutputService > dbService_
Definition: PPSGeometryBuilder.cc:49
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DetGeomDesc::components
const Container & components() const
Definition: DetGeomDesc.h:97
PPSGeometryBuilder::dd4hepToken_
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > dd4hepToken_
Definition: PPSGeometryBuilder.cc:47
DetGeomDesc::name
const std::string & name() const
Definition: DetGeomDesc.h:66
PPSGeometryBuilder::fromDD4hep_
bool fromDD4hep_
Definition: PPSGeometryBuilder.cc:44
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:17
PDetGeomDesc
Definition: PDetGeomDesc.h:9
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:120
detgeomdescbuilder::buildDetGeomDescFromCompactView
std::unique_ptr< DetGeomDesc > buildDetGeomDescFromCompactView(const DDCompactView &myCompactView)
Definition: DetGeomDescBuilder.cc:9
DDRotationMatrix
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
Definition: DDRotationMatrix.h:8
PPSGeometryBuilder::ddToken_
edm::ESGetToken< DDCompactView, IdealGeometryRecord > ddToken_
Definition: PPSGeometryBuilder.cc:46
Exception
Definition: hltDiff.cc:246
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:63
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
DetGeomDesc::params
const std::vector< double > & params() const
Definition: DetGeomDesc.h:80
edm::EDConsumerBase::esConsumes
auto esConsumes()
Definition: EDConsumerBase.h:200
mps_fire.result
result
Definition: mps_fire.py:311
DetGeomDesc::copyno
int copyno() const
Definition: DetGeomDesc.h:67
DetGeomDesc::rotation
const RotationMatrix & rotation() const
Definition: DetGeomDesc.h:74
child
Definition: simpleInheritance.h:11