Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:26:02

0001 /**
0002  *  See header file for a description of this class.
0003  *  
0004  *  \author Dominique Fortin - UCR
0005  */
0006 
0007 #include "RecoMuon/MuonSeedGenerator/plugins/MuonSeedProducer.h"
0008 #include "RecoMuon/MuonSeedGenerator/src/MuonSeedBuilder.h"
0009 
0010 // Data Formats
0011 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
0012 
0013 // Geometry
0014 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0015 #include "TrackingTools/DetLayers/interface/DetLayer.h"
0016 
0017 // Framework
0018 #include "FWCore/Framework/interface/EventSetup.h"
0019 #include "FWCore/Framework/interface/Event.h"
0020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0021 #include "FWCore/Framework/interface/ESHandle.h"
0022 #include <DataFormats/Common/interface/Handle.h>
0023 // C++
0024 #include <vector>
0025 
0026 /* 
0027  * Constructor
0028  */
0029 MuonSeedProducer::MuonSeedProducer(const edm::ParameterSet& pset) {
0030   // Register what this produces
0031   produces<TrajectorySeedCollection>();
0032 
0033   // Local Debug flag
0034   debug = pset.getParameter<bool>("DebugMuonSeed");
0035 
0036   edm::ConsumesCollector iC = consumesCollector();
0037 
0038   // Builder which returns seed collection
0039   muonSeedBuilder_ = new MuonSeedBuilder(pset, iC);
0040 
0041   muonLayersToken_ = esConsumes<MuonDetLayerGeometry, MuonRecoGeometryRecord>();
0042   magFieldToken_ = esConsumes<MagneticField, IdealMagneticFieldRecord>();
0043 }
0044 
0045 /*
0046  * Destructor
0047  */
0048 MuonSeedProducer::~MuonSeedProducer() { delete muonSeedBuilder_; }
0049 
0050 /*
0051  * Producer (the main)
0052  */
0053 void MuonSeedProducer::produce(edm::Event& event, const edm::EventSetup& eSetup) {
0054   // Muon Geometry
0055   edm::ESHandle<MuonDetLayerGeometry> muonLayers = eSetup.getHandle(muonLayersToken_);
0056   const MuonDetLayerGeometry* lgeom = &*muonLayers;
0057   muonSeedBuilder_->setGeometry(lgeom);
0058 
0059   // Magnetic field
0060   edm::ESHandle<MagneticField> field = eSetup.getHandle(magFieldToken_);
0061   const MagneticField* theField = &*field;
0062   muonSeedBuilder_->setBField(theField);
0063 
0064   // Create pointer to the seed container
0065 
0066   auto output = std::make_unique<TrajectorySeedCollection>();
0067 
0068   //UNUED:  int nSeeds = 0;
0069   //UNUSED: nSeeds =
0070   muonSeedBuilder_->build(event, eSetup, *output);
0071 
0072   // Append muon seed collection to event
0073   event.put(std::move(output));
0074 }