Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:35

0001 /** \class BeamHaloPropagatorESProducer
0002  *  ES producer needed to put the BeamHaloPropagator inside the EventSetup
0003  *
0004  *  \author Jean-Roch VLIMANT UCSB
0005  */
0006 
0007 #include "FWCore/Framework/interface/ESProducer.h"
0008 
0009 #include "TrackingTools/GeomPropagators/interface/BeamHaloPropagator.h"
0010 #include "DataFormats/TrajectorySeed/interface/PropagationDirection.h"
0011 
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "FWCore/Framework/interface/ESHandle.h"
0014 #include "DataFormats/Common/interface/Handle.h"
0015 #include "FWCore/Framework/interface/ModuleFactory.h"
0016 #include "FWCore/Utilities/interface/Exception.h"
0017 
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
0020 
0021 #include "MagneticField/Engine/interface/MagneticField.h"
0022 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0023 
0024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0025 
0026 #include <memory>
0027 
0028 class BeamHaloPropagatorESProducer : public edm::ESProducer {
0029 public:
0030   /// Constructor
0031   BeamHaloPropagatorESProducer(const edm::ParameterSet&);
0032 
0033   /// Destructor
0034   ~BeamHaloPropagatorESProducer() override;
0035 
0036   // Operations
0037   std::unique_ptr<Propagator> produce(const TrackingComponentsRecord&);
0038 
0039 private:
0040   PropagationDirection thePropagationDirection;
0041   std::string myname;
0042   std::string theEndCapTrackerPropagatorName;
0043   std::string theCrossingTrackerPropagatorName;
0044   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magToken_;
0045   edm::ESGetToken<Propagator, TrackingComponentsRecord> endcapToken_;
0046   edm::ESGetToken<Propagator, TrackingComponentsRecord> crossToken_;
0047 };
0048 
0049 using namespace edm;
0050 using namespace std;
0051 
0052 BeamHaloPropagatorESProducer::BeamHaloPropagatorESProducer(const ParameterSet& parameterSet) {
0053   myname = parameterSet.getParameter<string>("ComponentName");
0054 
0055   string propDir = parameterSet.getParameter<string>("PropagationDirection");
0056 
0057   if (propDir == "oppositeToMomentum")
0058     thePropagationDirection = oppositeToMomentum;
0059   else if (propDir == "alongMomentum")
0060     thePropagationDirection = alongMomentum;
0061   else if (propDir == "anyDirection")
0062     thePropagationDirection = anyDirection;
0063   else
0064     throw cms::Exception("BeamHaloPropagatorESProducer")
0065         << "Wrong fit direction (" << propDir << ")chosen in BeamHaloPropagatorESProducer";
0066 
0067   theEndCapTrackerPropagatorName = parameterSet.getParameter<string>("EndCapTrackerPropagator");
0068   theCrossingTrackerPropagatorName = parameterSet.getParameter<string>("CrossingTrackerPropagator");
0069 
0070   auto cc = setWhatProduced(this, myname);
0071   magToken_ = cc.consumes();
0072   endcapToken_ = cc.consumes(edm::ESInputTag(""s, theEndCapTrackerPropagatorName));
0073   crossToken_ = cc.consumes(edm::ESInputTag(""s, theCrossingTrackerPropagatorName));
0074 }
0075 
0076 BeamHaloPropagatorESProducer::~BeamHaloPropagatorESProducer() {}
0077 
0078 std::unique_ptr<Propagator> BeamHaloPropagatorESProducer::produce(const TrackingComponentsRecord& iRecord) {
0079   LogDebug("BeamHaloPropagator") << "Creating a BeamHaloPropagator: " << myname
0080                                  << "\n with EndCap Propagator: " << theEndCapTrackerPropagatorName
0081                                  << "\n with Crossing Propagator: " << theCrossingTrackerPropagatorName;
0082 
0083   return std::make_unique<BeamHaloPropagator>(
0084       iRecord.get(endcapToken_), iRecord.get(crossToken_), &iRecord.get(magToken_), thePropagationDirection);
0085 }
0086 
0087 DEFINE_FWK_EVENTSETUP_MODULE(BeamHaloPropagatorESProducer);