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
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept 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 noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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_
 
bool isRun2_
 
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
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 29 of file PPSGeometryBuilder.cc.

Constructor & Destructor Documentation

◆ PPSGeometryBuilder()

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

Definition at line 47 of file PPSGeometryBuilder.cc.

48  : fromDD4hep_(iConfig.getUntrackedParameter<bool>("fromDD4hep", false)),
49  compactViewTag_(iConfig.getUntrackedParameter<std::string>("compactViewTag", "XMLIdealGeometryESSource_CTPPS")),
50  isRun2_(iConfig.getUntrackedParameter<bool>("isRun2", false)),
T getUntrackedParameter(std::string const &, T const &) const
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > dd4hepToken_
edm::ESGetToken< DDCompactView, IdealGeometryRecord > ddToken_

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 57 of file PPSGeometryBuilder.cc.

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(), isRun2_, watcherIdealGeometry_, and cond::service::PoolDBOutputService::writeOneIOV().

57  {
58  // Get DetGeomDesc tree
59  std::unique_ptr<DetGeomDesc> geoInfoRoot = nullptr;
60  if (watcherIdealGeometry_.check(iSetup)) {
61  edm::LogInfo("PPSGeometryBuilder") << "Got IdealGeometryRecord ";
62  // old DD
63  if (!fromDD4hep_) {
64  // Get CompactView from IdealGeometryRecord
65  auto const& myCompactView = iSetup.getData(ddToken_);
66 
67  // Build geometry
69  }
70  // DD4hep
71  else {
72  // Get CompactView from IdealGeometryRecord
73  auto const& myCompactView = iSetup.getData(dd4hepToken_);
74 
75  // Build geometry
77  }
78  }
79 
80  // Build persistent geometry data from geometry
81  PDetGeomDesc serializableData; // cond::service::PoolDBOutputService::writeOne interface requires raw pointer.
82  int counter = 0;
83  if (geoInfoRoot) {
84  buildSerializableDataFromGeoInfo(&serializableData, geoInfoRoot.get(), counter);
85  }
86 
87  // Save geometry in the database
88  if (serializableData.container_.empty()) {
89  throw cms::Exception("PPSGeometryBuilder") << "PDetGeomDesc is empty, no geometry to save in the database.";
90  } else {
91  if (dbService_.isAvailable()) {
92  dbService_->writeOneIOV(serializableData, dbService_->beginOfTime(), "VeryForwardIdealGeometryRecord");
93  edm::LogInfo("PPSGeometryBuilder") << "Successfully wrote DB, with " << serializableData.container_.size()
94  << " PDetGeomDesc items.";
95  } else {
96  throw cms::Exception("PPSGeometryBuilder") << "PoolDBService required.";
97  }
98  }
99 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::ESWatcher< IdealGeometryRecord > watcherIdealGeometry_
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > dd4hepToken_
void buildSerializableDataFromGeoInfo(PDetGeomDesc *serializableData, const DetGeomDesc *geoInfo, int &counter)
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
std::vector< Item > container_
Definition: PDetGeomDesc.h:26
std::unique_ptr< DetGeomDesc > buildDetGeomDescFromCompactView(const DDCompactView &myCompactView, const bool isRun2)
edm::ESGetToken< DDCompactView, IdealGeometryRecord > ddToken_
Log< level::Info, false > LogInfo
edm::Service< cond::service::PoolDBOutputService > dbService_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
static std::atomic< unsigned int > counter
bool isAvailable() const
Definition: Service.h:40

◆ buildItemFromDetGeomDesc()

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

Definition at line 126 of file PPSGeometryBuilder.cc.

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().

126  {
128  result.dx_ = geoInfo->translation().X();
129  result.dy_ = geoInfo->translation().Y();
130  result.dz_ = geoInfo->translation().Z();
131 
132  const DDRotationMatrix& rot = geoInfo->rotation();
133  rot.GetComponents(result.axx_,
134  result.axy_,
135  result.axz_,
136  result.ayx_,
137  result.ayy_,
138  result.ayz_,
139  result.azx_,
140  result.azy_,
141  result.azz_);
142  result.name_ = geoInfo->name();
143  result.params_ = geoInfo->params();
144  result.copy_ = geoInfo->copyno();
145  result.z_ = geoInfo->parentZPosition();
146  result.sensorType_ = geoInfo->sensorType();
147  result.geographicalID_ = geoInfo->geographicalID();
148 
149  return result;
150 }
const Translation & translation() const
Definition: DetGeomDesc.h:80
int copyno() const
Definition: DetGeomDesc.h:74
DetId geographicalID() const
Definition: DetGeomDesc.h:102
const std::string & sensorType() const
Definition: DetGeomDesc.h:99
float parentZPosition() const
Definition: DetGeomDesc.h:106
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
const RotationMatrix & rotation() const
Definition: DetGeomDesc.h:81
const std::string & name() const
Definition: DetGeomDesc.h:73
const std::vector< double > & params() const
Definition: DetGeomDesc.h:88

◆ buildSerializableDataFromGeoInfo()

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

Definition at line 105 of file PPSGeometryBuilder.cc.

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

Referenced by analyze().

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

Member Data Documentation

◆ compactViewTag_

std::string PPSGeometryBuilder::compactViewTag_
private

Definition at line 39 of file PPSGeometryBuilder.cc.

◆ dbService_

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

Definition at line 44 of file PPSGeometryBuilder.cc.

Referenced by analyze().

◆ dd4hepToken_

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

Definition at line 42 of file PPSGeometryBuilder.cc.

Referenced by analyze().

◆ ddToken_

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

Definition at line 41 of file PPSGeometryBuilder.cc.

Referenced by analyze().

◆ fromDD4hep_

bool PPSGeometryBuilder::fromDD4hep_
private

Definition at line 38 of file PPSGeometryBuilder.cc.

Referenced by analyze(), and buildSerializableDataFromGeoInfo().

◆ isRun2_

bool PPSGeometryBuilder::isRun2_
private

Definition at line 40 of file PPSGeometryBuilder.cc.

Referenced by analyze().

◆ watcherIdealGeometry_

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

Definition at line 43 of file PPSGeometryBuilder.cc.

Referenced by analyze().