Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-09 03:15:14

0001 
0002 #include <memory>
0003 
0004 #include "FWCore/Framework/interface/ESProducer.h"
0005 #include "FWCore/Framework/interface/ESProducts.h"
0006 #include "FWCore/Framework/interface/ModuleFactory.h"
0007 
0008 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0009 
0010 #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"
0011 
0012 class HGCalTriggerGeometryESProducer : public edm::ESProducer {
0013 public:
0014   HGCalTriggerGeometryESProducer(const edm::ParameterSet&);
0015   ~HGCalTriggerGeometryESProducer() override;
0016 
0017   typedef std::unique_ptr<HGCalTriggerGeometryBase> ReturnType;
0018 
0019   ReturnType produce(const CaloGeometryRecord&);
0020 
0021 private:
0022   edm::ParameterSet geometry_config_;
0023   std::string geometry_name_;
0024   edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> ee_geometry_token_;
0025   edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> hsi_geometry_token_;
0026   edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> hsc_geometry_token_;
0027   edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> nose_geometry_token_;
0028   bool isV9Geometry_;
0029 };
0030 
0031 HGCalTriggerGeometryESProducer::HGCalTriggerGeometryESProducer(const edm::ParameterSet& iConfig)
0032     : geometry_config_(iConfig.getParameterSet("TriggerGeometry")),
0033       geometry_name_(geometry_config_.getParameter<std::string>("TriggerGeometryName")) {
0034   auto cc = setWhatProduced(this);
0035   ee_geometry_token_ = cc.consumes(edm::ESInputTag{"", "HGCalEESensitive"});
0036   hsi_geometry_token_ = cc.consumes(edm::ESInputTag{"", "HGCalHESiliconSensitive"});
0037   hsc_geometry_token_ = cc.consumes(edm::ESInputTag{"", "HGCalHEScintillatorSensitive"});
0038   nose_geometry_token_ = cc.consumes(edm::ESInputTag{"", "HGCalHFNoseSensitive"});
0039 }
0040 
0041 HGCalTriggerGeometryESProducer::~HGCalTriggerGeometryESProducer() {
0042   // do anything here that needs to be done at desctruction time
0043   // (e.g. close files, deallocate resources etc.)
0044 }
0045 
0046 HGCalTriggerGeometryESProducer::ReturnType HGCalTriggerGeometryESProducer::produce(const CaloGeometryRecord& iRecord) {
0047   ReturnType geometry(HGCalTriggerGeometryFactory::get()->create(geometry_name_, geometry_config_));
0048 
0049   // Initialization with or without nose geometry
0050   if (iRecord.getHandle(nose_geometry_token_)) {
0051     geometry->setWithNoseGeometry(true);
0052     geometry->initialize(&iRecord.get(ee_geometry_token_),
0053                          &iRecord.get(hsi_geometry_token_),
0054                          &iRecord.get(hsc_geometry_token_),
0055                          &iRecord.get(nose_geometry_token_));
0056   } else {
0057     geometry->initialize(
0058         &iRecord.get(ee_geometry_token_), &iRecord.get(hsi_geometry_token_), &iRecord.get(hsc_geometry_token_));
0059   }
0060   return geometry;
0061 }
0062 
0063 // define this as a plug-in
0064 DEFINE_FWK_EVENTSETUP_MODULE(HGCalTriggerGeometryESProducer);