Go to the documentation of this file.00001
00005 #include "RecoMuon/MuonSeedGenerator/plugins/SETMuonSeedProducer.h"
00006
00007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00008 #include "FWCore/Framework/interface/Event.h"
00009 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
00010 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00011 #include "DataFormats/TrajectoryState/interface/PTrajectoryStateOnDet.h"
00012 #include "DataFormats/TrajectorySeed/interface/PropagationDirection.h"
00013
00014 #include "RecoMuon/TrackingTools/interface/MuonPatternRecoDumper.h"
00015 #include "RecoMuon/Navigation/interface/DirectMuonNavigation.h"
00016
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018
00019 #include "DataFormats/TrajectoryState/interface/PTrajectoryStateOnDet.h"
00020 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00021 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00022 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00023 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00024 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00025 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00026 #include "TMath.h"
00027
00028 using namespace edm;
00029 using namespace std;
00030
00031 SETMuonSeedProducer::SETMuonSeedProducer(const ParameterSet& parameterSet)
00032 : thePatternRecognition(parameterSet),
00033 theSeedFinder(parameterSet),
00034 theBeamSpotTag(parameterSet.getParameter<edm::InputTag>("beamSpotTag"))
00035 {
00036 const string metname = "Muon|RecoMuon|SETMuonSeedSeed";
00037
00038
00039 ParameterSet serviceParameters = parameterSet.getParameter<ParameterSet>("ServiceParameters");
00040 theService = new MuonServiceProxy(serviceParameters);
00041 thePatternRecognition.setServiceProxy(theService);
00042 theSeedFinder.setServiceProxy(theService);
00043
00044 ParameterSet trajectoryBuilderParameters = parameterSet.getParameter<ParameterSet>("SETTrajBuilderParameters");
00045
00046 LogTrace(metname) << "constructor called" << endl;
00047
00048 apply_prePruning = trajectoryBuilderParameters.getParameter<bool>("Apply_prePruning");
00049
00050 useSegmentsInTrajectory = trajectoryBuilderParameters.getParameter<bool>("UseSegmentsInTrajectory");
00051
00052
00053 ParameterSet filterPSet = trajectoryBuilderParameters.getParameter<ParameterSet>("FilterParameters");
00054 filterPSet.addUntrackedParameter("UseSegmentsInTrajectory", useSegmentsInTrajectory);
00055 theFilter = new SETFilter(filterPSet,theService);
00056
00057
00058
00059 produces<TrajectorySeedCollection>();
00060
00061 }
00062
00063 SETMuonSeedProducer::~SETMuonSeedProducer(){
00064
00065 LogTrace("Muon|RecoMuon|SETMuonSeedProducer")
00066 << "SETMuonSeedProducer destructor called" << endl;
00067
00068 if(theFilter) delete theFilter;
00069 if (theService) delete theService;
00070 }
00071
00072 void SETMuonSeedProducer::produce(edm::Event& event, const edm::EventSetup& eventSetup){
00073
00074 const string metname = "Muon|RecoMuon|SETMuonSeedSeed";
00075
00076 MuonPatternRecoDumper debug;
00077
00078
00079 theService->update(eventSetup);
00080
00081 std::auto_ptr<TrajectorySeedCollection> output(new TrajectorySeedCollection());
00082
00083 Handle<View<TrajectorySeed> > seeds;
00084
00085 setEvent(event);
00086
00087 reco::BeamSpot beamSpot;
00088 edm::Handle<reco::BeamSpot> beamSpotHandle;
00089 event.getByLabel(theBeamSpotTag, beamSpotHandle);
00090 if ( beamSpotHandle.isValid() )
00091 {
00092 beamSpot = *beamSpotHandle;
00093
00094 } else
00095 {
00096 edm::LogInfo("MuonSeedGenerator")
00097 << "No beam spot available from EventSetup \n";
00098 }
00099
00100
00101 GlobalVector gv(beamSpot.x0(), beamSpot.y0(), beamSpot.z0());
00102 theSeedFinder.setBeamSpot(gv);
00103
00104 bool fwFitFailed = true;
00105
00106 std::vector <SeedCandidate> seedCandidates_AllChosen;
00107 std::vector< MuonRecHitContainer > MuonRecHitContainer_clusters;
00108
00109 thePatternRecognition.produce(event, eventSetup, MuonRecHitContainer_clusters);
00110
00111
00112
00113 for(unsigned int cluster = 0; cluster < MuonRecHitContainer_clusters.size(); ++cluster) {
00114
00115 std::vector <SeedCandidate> seedCandidates_inCluster;
00116
00117
00118
00119 std::vector< MuonRecHitContainer > MuonRecHitContainer_perLayer = theSeedFinder.sortByLayer(MuonRecHitContainer_clusters[cluster]);
00120
00121
00122 theSeedFinder.limitCombinatorics(MuonRecHitContainer_perLayer);
00123
00124 std::vector <MuonRecHitContainer> allValidSets = theSeedFinder.findAllValidSets(MuonRecHitContainer_perLayer);
00125 if(apply_prePruning){
00126
00127 theSeedFinder.validSetsPrePruning(allValidSets);
00128 }
00129
00130
00131
00132 if(allValidSets.size()<500){
00133 seedCandidates_inCluster = theSeedFinder.fillSeedCandidates(allValidSets);
00134 }
00135
00136
00137 if(!seedCandidates_inCluster.empty()){
00138
00139 std::vector < SeedCandidate> bestSets_inCluster;
00140 fwFitFailed = !(filter()->fwfit_SET(seedCandidates_inCluster, bestSets_inCluster));
00141
00142
00143 if(fwFitFailed){
00144
00145 continue;
00146 }
00147 for(unsigned int iSet = 0; iSet<bestSets_inCluster.size();++iSet){
00148 seedCandidates_AllChosen.push_back(bestSets_inCluster[iSet]);
00149 }
00150 }
00151 }
00152
00153 for(unsigned int iMuon = 0;iMuon<seedCandidates_AllChosen.size();++iMuon){
00154
00155 Trajectory::DataContainer finalCandidate;
00156 SeedCandidate * aFinalSet = &(seedCandidates_AllChosen[iMuon]);
00157 fwFitFailed = !(filter()->buildTrajectoryMeasurements(aFinalSet, finalCandidate));
00158 if(fwFitFailed ){
00159
00160 continue;
00161 }
00162
00163 if( filter()->layers().size() )
00164 LogTrace(metname) << debug.dumpLayer( filter()->lastDetLayer());
00165 else {
00166 continue;
00167 }
00168
00169
00170
00171
00172 if (filter()->goodState()) {
00173 TransientTrackingRecHit::ConstRecHitContainer hitContainer;
00174 TrajectoryStateOnSurface firstTSOS;
00175 bool conversionPassed = false;
00176 if(!useSegmentsInTrajectory){
00177
00178 conversionPassed = filter()->transform(finalCandidate, hitContainer, firstTSOS);
00179 }
00180 else{
00181
00182 conversionPassed = filter()->transformLight(finalCandidate, hitContainer, firstTSOS);
00183 }
00184 if ( conversionPassed && !finalCandidate.empty() && !hitContainer.empty()) {
00185
00186
00187
00188 edm::OwnVector<TrackingRecHit> recHitsContainer;
00189 for(unsigned int iHit = 0;iHit < hitContainer.size();++iHit){
00190 recHitsContainer.push_back(hitContainer.at(iHit)->hit()->clone());
00191 }
00192 PropagationDirection dir = oppositeToMomentum;
00193 if(useSegmentsInTrajectory){
00194 dir = alongMomentum;
00195 }
00196
00197 PTrajectoryStateOnDet seedTSOS =
00198 trajectoryStateTransform::persistentState( firstTSOS, hitContainer.at(0)->geographicalId().rawId());
00199 TrajectorySeed seed(seedTSOS,recHitsContainer,dir);
00200
00201
00202
00203
00204
00205
00206
00207 output->push_back(seed);
00208 }
00209 else{
00210
00211 continue;
00212 }
00213 }else{
00214
00215 continue;
00216 }
00217 }
00218 event.put(output);
00219 theFilter->reset();
00220 }
00221
00222
00223 void SETMuonSeedProducer::setEvent(const edm::Event& event){
00224 theFilter->setEvent(event);
00225 }