Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:10

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