Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-03-03 23:53:07

0001 #include "FWCore/Framework/interface/ESProducer.h"
0002 #include "FWCore/Framework/interface/ESHandle.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 #include "FWCore/Utilities/interface/ESGetToken.h"
0005 #include "FWCore/Utilities/interface/ESInputTag.h"
0006 #include "DataFormats/Provenance/interface/ParameterSetID.h"
0007 #include "L1Trigger/TrackerDTC/interface/Setup.h"
0008 #include "MagneticField/Engine/interface/MagneticField.h"
0009 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0010 
0011 #include <memory>
0012 
0013 using namespace std;
0014 using namespace edm;
0015 
0016 namespace trackerDTC {
0017 
0018   /*! \class  trackerDTC::ProducerES
0019    *  \brief  Class to produce setup of Track Trigger emulators
0020    *  \author Thomas Schuh
0021    *  \date   2020, Apr
0022    */
0023   class ProducerES : public ESProducer {
0024   public:
0025     ProducerES(const ParameterSet& iConfig);
0026     ~ProducerES() override {}
0027     unique_ptr<Setup> produce(const SetupRcd& setupRcd);
0028 
0029   private:
0030     const ParameterSet iConfig_;
0031     ESGetToken<StubAlgorithm, TTStubAlgorithmRecord> getTokenTTStubAlgorithm_;
0032     ESGetToken<MagneticField, IdealMagneticFieldRecord> getTokenMagneticField_;
0033     ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> getTokenTrackerGeometry_;
0034     ESGetToken<TrackerTopology, TrackerTopologyRcd> getTokenTrackerTopology_;
0035     ESGetToken<TrackerDetToDTCELinkCablingMap, TrackerDetToDTCELinkCablingMapRcd> getTokenCablingMap_;
0036     ESGetToken<DDCompactView, IdealGeometryRecord> getTokenGeometryConfiguration_;
0037     ESGetToken<cms::DDCompactView, IdealGeometryRecord> getTokenGeometryConfigurationDD4hep_;
0038     bool fromDD4hep_;
0039   };
0040 
0041   ProducerES::ProducerES(const ParameterSet& iConfig) : iConfig_(iConfig) {
0042     fromDD4hep_ = iConfig.getParameter<bool>("fromDD4hep");
0043     auto cc = setWhatProduced(this);
0044     getTokenTTStubAlgorithm_ = cc.consumes();
0045     getTokenMagneticField_ = cc.consumes();
0046     getTokenTrackerGeometry_ = cc.consumes();
0047     getTokenTrackerTopology_ = cc.consumes();
0048     getTokenCablingMap_ = cc.consumes();
0049     if (fromDD4hep_)
0050       getTokenGeometryConfigurationDD4hep_ = cc.consumes();
0051     else
0052       getTokenGeometryConfiguration_ = cc.consumes();
0053   }
0054 
0055   unique_ptr<Setup> ProducerES::produce(const SetupRcd& setupRcd) {
0056     const MagneticField& magneticField = setupRcd.get(getTokenMagneticField_);
0057     const TrackerGeometry& trackerGeometry = setupRcd.get(getTokenTrackerGeometry_);
0058     const TrackerTopology& trackerTopology = setupRcd.get(getTokenTrackerTopology_);
0059     const TrackerDetToDTCELinkCablingMap& cablingMap = setupRcd.get(getTokenCablingMap_);
0060     const ESHandle<StubAlgorithm> handleStubAlgorithm = setupRcd.getHandle(getTokenTTStubAlgorithm_);
0061     const ParameterSetID& pSetIdTTStubAlgorithm = handleStubAlgorithm.description()->pid_;
0062     const StubAlgorithmOfficial& stubAlgoritm =
0063         *dynamic_cast<const StubAlgorithmOfficial*>(&setupRcd.get(getTokenTTStubAlgorithm_));
0064     const ParameterSet& pSetStubAlgorithm = getParameterSet(handleStubAlgorithm.description()->pid_);
0065     if (fromDD4hep_) {
0066       const ESHandle<cms::DDCompactView> handleGeometryConfiguration =
0067           setupRcd.getHandle(getTokenGeometryConfigurationDD4hep_);
0068       const ParameterSetID& pSetIdGeometryConfiguration = handleGeometryConfiguration.description()->pid_;
0069       const ParameterSet& pSetGeometryConfiguration = getParameterSet(handleGeometryConfiguration.description()->pid_);
0070       return make_unique<Setup>(iConfig_,
0071                                 magneticField,
0072                                 trackerGeometry,
0073                                 trackerTopology,
0074                                 cablingMap,
0075                                 stubAlgoritm,
0076                                 pSetStubAlgorithm,
0077                                 pSetGeometryConfiguration,
0078                                 pSetIdTTStubAlgorithm,
0079                                 pSetIdGeometryConfiguration);
0080     } else {
0081       const ESHandle<DDCompactView> handleGeometryConfiguration = setupRcd.getHandle(getTokenGeometryConfiguration_);
0082       const ParameterSetID& pSetIdGeometryConfiguration = handleGeometryConfiguration.description()->pid_;
0083       const ParameterSet& pSetGeometryConfiguration = getParameterSet(handleGeometryConfiguration.description()->pid_);
0084       return make_unique<Setup>(iConfig_,
0085                                 magneticField,
0086                                 trackerGeometry,
0087                                 trackerTopology,
0088                                 cablingMap,
0089                                 stubAlgoritm,
0090                                 pSetStubAlgorithm,
0091                                 pSetGeometryConfiguration,
0092                                 pSetIdTTStubAlgorithm,
0093                                 pSetIdGeometryConfiguration);
0094     }
0095   }
0096 }  // namespace trackerDTC
0097 
0098 DEFINE_FWK_EVENTSETUP_MODULE(trackerDTC::ProducerES);