Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:06

0001 /**
0002  *  See header file for a description of this class.
0003  *  
0004  *  All the code is under revision
0005  *
0006  *
0007  *  \author A. Vitelli - INFN Torino, V.Palichik
0008  *  \author ported by: R. Bellan - INFN Torino
0009  */
0010 
0011 #include "RecoMuon/MuonSeedGenerator/plugins/MuonSeedGenerator.h"
0012 #include "RecoMuon/MuonSeedGenerator/src/MuonSeedFinder.h"
0013 #include "RecoMuon/MuonSeedGenerator/src/MuonSeedOrcaPatternRecognition.h"
0014 #include "RecoMuon/MuonSeedGenerator/src/MuonSeedFinder.h"
0015 #include "RecoMuon/MuonSeedGenerator/src/MuonSeedSimpleCleaner.h"
0016 
0017 // Data Formats
0018 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
0019 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
0020 
0021 #include "DataFormats/Common/interface/Handle.h"
0022 
0023 #include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h"
0024 #include "RecoMuon/Records/interface/MuonRecoGeometryRecord.h"
0025 
0026 // Geometry
0027 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0028 #include "TrackingTools/DetLayers/interface/DetLayer.h"
0029 
0030 #include "RecoMuon/MeasurementDet/interface/MuonDetLayerMeasurements.h"
0031 #include "RecoMuon/DetLayers/interface/MuonDetLayerGeometry.h"
0032 #include "RecoMuon/Records/interface/MuonRecoGeometryRecord.h"
0033 
0034 // Framework
0035 #include "FWCore/Framework/interface/EventSetup.h"
0036 #include "FWCore/Framework/interface/Event.h"
0037 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0038 #include "FWCore/Framework/interface/ESHandle.h"
0039 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0040 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0041 
0042 // C++
0043 #include <vector>
0044 
0045 using namespace std;
0046 
0047 typedef MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer;
0048 typedef MuonTransientTrackingRecHit::ConstMuonRecHitPointer ConstMuonRecHitPointer;
0049 typedef MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer;
0050 
0051 // Constructor
0052 MuonSeedGenerator::MuonSeedGenerator(const edm::ParameterSet& pset)
0053     : theSeedFinder(new MuonSeedFinder(pset)),
0054       theSeedCleaner(new MuonSeedSimpleCleaner()),
0055       theBeamSpotTag(pset.getParameter<edm::InputTag>("beamSpotTag")) {
0056   produces<TrajectorySeedCollection>();
0057 
0058   edm::ConsumesCollector iC = consumesCollector();
0059   thePatternRecognition = new MuonSeedOrcaPatternRecognition(pset, iC);
0060 
0061   beamspotToken = consumes<reco::BeamSpot>(theBeamSpotTag);
0062   magFieldToken = esConsumes<MagneticField, IdealMagneticFieldRecord>();
0063 }
0064 
0065 // Destructor
0066 MuonSeedGenerator::~MuonSeedGenerator() {
0067   delete thePatternRecognition;
0068   delete theSeedFinder;
0069   delete theSeedCleaner;
0070 }
0071 
0072 // reconstruct muon's seeds
0073 void MuonSeedGenerator::produce(edm::Event& event, const edm::EventSetup& eSetup) {
0074   // create the pointer to the Seed container
0075   auto output = std::make_unique<TrajectorySeedCollection>();
0076 
0077   edm::ESHandle<MagneticField> field = eSetup.getHandle(magFieldToken);
0078   theSeedFinder->setBField(&*field);
0079 
0080   reco::BeamSpot beamSpot;
0081   edm::Handle<reco::BeamSpot> beamSpotHandle;
0082   event.getByToken(beamspotToken, beamSpotHandle);
0083   if (beamSpotHandle.isValid()) {
0084     beamSpot = *beamSpotHandle;
0085 
0086   } else {
0087     edm::LogInfo("MuonSeedGenerator") << "No beam spot available from EventSetup \n";
0088   }
0089 
0090   // make it a vector so we can subtract it from position vectors
0091   GlobalVector gv(beamSpot.x0(), beamSpot.y0(), beamSpot.z0());
0092   theSeedFinder->setBeamSpot(gv);
0093 
0094   std::vector<MuonRecHitContainer> patterns;
0095   thePatternRecognition->produce(event, eSetup, patterns);
0096 
0097   for (std::vector<MuonRecHitContainer>::const_iterator seedSegments = patterns.begin(); seedSegments != patterns.end();
0098        ++seedSegments) {
0099     theSeedFinder->seeds(*seedSegments, *output);
0100   }
0101 
0102   theSeedCleaner->clean(*output);
0103 
0104   event.put(std::move(output));
0105 }
0106 
0107 void MuonSeedGenerator::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0108   edm::ParameterSetDescription desc;
0109   desc.setAllowAnything();
0110   desc.add<edm::InputTag>("beamSpotTag", edm::InputTag("offlineBeamSpot"));
0111   desc.add<bool>("scaleDT", true);
0112   desc.add<edm::InputTag>("CSCRecSegmentLabel", edm::InputTag("cscSegments"));
0113   desc.add<edm::InputTag>("DTRecSegmentLabel", edm::InputTag("dt4DSegments"));
0114   desc.add<edm::InputTag>("ME0RecSegmentLabel", edm::InputTag("me0Segments"));
0115   desc.add<bool>("EnableDTMeasurement", true);
0116   desc.add<bool>("EnableCSCMeasurement", true);
0117   desc.add<bool>("EnableME0Measurement", false);
0118   desc.add<std::vector<double>>("crackEtas", {0.2, 1.6, 1.7});
0119   desc.add<double>("crackWindow", 0.04);
0120   desc.add<double>("deltaPhiSearchWindow", 0.25);
0121   desc.add<double>("deltaEtaSearchWindow", 0.2);
0122   desc.add<double>("deltaEtaCrackSearchWindow", 0.25);
0123   descriptions.add("muonSeedGenerator", desc);
0124 }