CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
SETMuonSeedProducer Class Reference

#include <SETMuonSeedProducer.h>

Inheritance diagram for SETMuonSeedProducer:
edm::stream::EDProducer<>

Public Types

typedef MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
 
typedef std::vector< Trajectory * > TrajectoryContainer
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Public Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
 SETMuonSeedProducer (const edm::ParameterSet &)
 Constructor with Parameter set. More...
 
 ~SETMuonSeedProducer () override
 Destructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Member Functions

SETFilterfilter () const
 pre-filter More...
 
void setEvent (const edm::Event &)
 

Private Attributes

bool apply_prePruning
 
edm::EDGetTokenT< reco::BeamSpotbeamspotToken
 
edm::InputTag theBeamSpotTag
 
SETFiltertheFilter
 
SETPatternRecognitionthePatternRecognition
 
SETSeedFinder theSeedFinder
 
MuonServiceProxytheService
 
bool useSegmentsInTrajectory
 

Detailed Description

I. Bloch, E. James, S. Stoynev

Definition at line 30 of file SETMuonSeedProducer.h.

Member Typedef Documentation

Definition at line 32 of file SETMuonSeedProducer.h.

Definition at line 33 of file SETMuonSeedProducer.h.

Constructor & Destructor Documentation

SETMuonSeedProducer::SETMuonSeedProducer ( const edm::ParameterSet parameterSet)

Constructor with Parameter set.

Definition at line 30 of file SETMuonSeedProducer.cc.

References edm::ParameterSet::addUntrackedParameter(), apply_prePruning, beamspotToken, edm::ParameterSet::getParameter(), LogTrace, metname, MuonServiceProxy_cff::MuonServiceProxy, SETPatternRecognition::setServiceProxy(), SETSeedFinder::setServiceProxy(), theBeamSpotTag, theFilter, thePatternRecognition, theSeedFinder, theService, and useSegmentsInTrajectory.

31  : theSeedFinder(parameterSet), theBeamSpotTag(parameterSet.getParameter<edm::InputTag>("beamSpotTag")) {
32  edm::ConsumesCollector iC = consumesCollector();
33  thePatternRecognition = new SETPatternRecognition(parameterSet, iC);
34 
35  const string metname = "Muon|RecoMuon|SETMuonSeedSeed";
36  //std::cout<<" The SET SEED producer started."<<std::endl;
37 
38  ParameterSet serviceParameters = parameterSet.getParameter<ParameterSet>("ServiceParameters");
39  theService = new MuonServiceProxy(serviceParameters);
41  theSeedFinder.setServiceProxy(theService);
42  // Parameter set for the Builder
43  ParameterSet trajectoryBuilderParameters = parameterSet.getParameter<ParameterSet>("SETTrajBuilderParameters");
44 
45  LogTrace(metname) << "constructor called" << endl;
46 
47  apply_prePruning = trajectoryBuilderParameters.getParameter<bool>("Apply_prePruning");
48 
49  useSegmentsInTrajectory = trajectoryBuilderParameters.getParameter<bool>("UseSegmentsInTrajectory");
50 
51  // The inward-outward fitter (starts from seed state)
52  ParameterSet filterPSet = trajectoryBuilderParameters.getParameter<ParameterSet>("FilterParameters");
53  filterPSet.addUntrackedParameter("UseSegmentsInTrajectory", useSegmentsInTrajectory);
54  theFilter = new SETFilter(filterPSet, theService);
55 
56  //----
57 
58  beamspotToken = consumes<reco::BeamSpot>(theBeamSpotTag);
59  produces<TrajectorySeedCollection>();
60 }
void setServiceProxy(MuonServiceProxy *service)
Definition: SETSeedFinder.h:29
SETSeedFinder theSeedFinder
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::BeamSpot > beamspotToken
const std::string metname
edm::InputTag theBeamSpotTag
SETPatternRecognition * thePatternRecognition
void setServiceProxy(MuonServiceProxy *service)
#define LogTrace(id)
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:181
MuonServiceProxy * theService
SETMuonSeedProducer::~SETMuonSeedProducer ( )
override

Destructor.

Definition at line 62 of file SETMuonSeedProducer.cc.

References LogTrace, theFilter, thePatternRecognition, and theService.

62  {
63  LogTrace("Muon|RecoMuon|SETMuonSeedProducer") << "SETMuonSeedProducer destructor called" << endl;
64 
65  if (theFilter)
66  delete theFilter;
67  if (theService)
68  delete theService;
70  delete thePatternRecognition;
71 }
SETPatternRecognition * thePatternRecognition
#define LogTrace(id)
MuonServiceProxy * theService

Member Function Documentation

SETFilter* SETMuonSeedProducer::filter ( ) const
inlineprivate

pre-filter

Definition at line 48 of file SETMuonSeedProducer.h.

References theFilter.

Referenced by produce().

48 { return theFilter; }
void SETMuonSeedProducer::produce ( edm::Event event,
const edm::EventSetup eventSetup 
)
override

Definition at line 73 of file SETMuonSeedProducer.cc.

References alongMomentum, apply_prePruning, pwdgSkimBPark_cfi::beamSpot, beamspotToken, SETFilter::buildTrajectoryMeasurements(), debug, DeadROC_duringRun::dir, MuonPatternRecoDumper::dumpLayer(), SETSeedFinder::fillSeedCandidates(), filter(), SETSeedFinder::findAllValidSets(), SETFilter::fwfit_SET(), edm::HandleBase::isValid(), SETFilter::layers(), SETSeedFinder::limitCombinatorics(), LogTrace, metname, eostools::move(), oppositeToMomentum, convertSQLitetoXML_cfg::output, trajectoryStateTransform::persistentState(), SETPatternRecognition::produce(), edm::OwnVector< T, P >::push_back(), SETFilter::reset(), SurveyInfoScenario_cff::seed, MuonSeedVFinder::setBeamSpot(), setEvent(), SETSeedFinder::sortByLayer(), theFilter, thePatternRecognition, theSeedFinder, theService, SETFilter::transform(), SETFilter::transformLight(), useSegmentsInTrajectory, SETSeedFinder::validSetsPrePruning(), reco::BeamSpot::x0(), reco::BeamSpot::y0(), and reco::BeamSpot::z0().

73  {
74  //std::cout<<" start producing..."<<std::endl;
75  const string metname = "Muon|RecoMuon|SETMuonSeedSeed";
76 
78 
79  //Get the CSC Geometry :
80  theService->update(eventSetup);
81 
82  auto output = std::make_unique<TrajectorySeedCollection>();
83 
85 
86  setEvent(event);
87 
89  edm::Handle<reco::BeamSpot> beamSpotHandle;
90  event.getByToken(beamspotToken, beamSpotHandle);
91  if (beamSpotHandle.isValid()) {
92  beamSpot = *beamSpotHandle;
93 
94  } else {
95  edm::LogInfo("MuonSeedGenerator") << "No beam spot available from EventSetup \n";
96  }
97 
98  // make it a vector so we can subtract it from position vectors
99  GlobalVector gv(beamSpot.x0(), beamSpot.y0(), beamSpot.z0());
101 
102  bool fwFitFailed = true;
103 
104  std::vector<SeedCandidate> seedCandidates_AllChosen;
105  std::vector<MuonRecHitContainer> MuonRecHitContainer_clusters;
106  //---- this is "clustering"; later a trajectory can not use hits from different clusters
107  thePatternRecognition->produce(event, eventSetup, MuonRecHitContainer_clusters);
108 
109  //std::cout<<"We have formed "<<MuonRecHitContainer_clusters.size()<<" clusters"<<std::endl;
110  //---- for each cluster,
111  for (unsigned int cluster = 0; cluster < MuonRecHitContainer_clusters.size(); ++cluster) {
112  //std::cout<<" This is cluster number : "<<cluster<<std::endl;
113  std::vector<SeedCandidate> seedCandidates_inCluster;
114  //---- group hits in detector layers (if in same layer); the idea is that
115  //---- some hits could not belong to a track simultaneously - these will be in a
116  //---- group; two hits from one and the same group will not go to the same track
117  std::vector<MuonRecHitContainer> MuonRecHitContainer_perLayer =
118  theSeedFinder.sortByLayer(MuonRecHitContainer_clusters[cluster]);
119  //---- Add protection against huge memory consumption
120  //---- Delete busy layers if needed (due to combinatorics)
121  theSeedFinder.limitCombinatorics(MuonRecHitContainer_perLayer);
122  //---- build all possible combinations (valid sets)
123  std::vector<MuonRecHitContainer> allValidSets = theSeedFinder.findAllValidSets(MuonRecHitContainer_perLayer);
124  if (apply_prePruning) {
125  //---- remove "wild" segments from the combination
126  theSeedFinder.validSetsPrePruning(allValidSets);
127  }
128 
129  //---- build the appropriate output: seedCandidates_inCluster
130  //---- if too many (?) valid sets in a cluster - skip it
131  if (allValidSets.size() < 500) { // hardcoded - remove it
132  seedCandidates_inCluster = theSeedFinder.fillSeedCandidates(allValidSets);
133  }
134  //---- find the best valid combinations using simple (no propagation errors) chi2-fit
135  //std::cout<<" Found "<<seedCandidates_inCluster.size()<<" valid sets in the current cluster."<<std::endl;
136  if (!seedCandidates_inCluster.empty()) {
137  //---- this is the forward fitter (segments); choose which of the SETs in a cluster to be considered further
138  std::vector<SeedCandidate> bestSets_inCluster;
139  fwFitFailed = !(filter()->fwfit_SET(seedCandidates_inCluster, bestSets_inCluster));
140 
141  //---- has the fit failed? continue to the next cluster instead of returning the empty trajectoryContainer and stop the loop IBL 080903
142  if (fwFitFailed) {
143  //std::cout<<" fwfit_SET failed!"<<std::endl;
144  continue;
145  }
146  for (unsigned int iSet = 0; iSet < bestSets_inCluster.size(); ++iSet) {
147  seedCandidates_AllChosen.push_back(bestSets_inCluster[iSet]);
148  }
149  }
150  }
151  //---- loop over all the SETs candidates
152  for (unsigned int iMuon = 0; iMuon < seedCandidates_AllChosen.size(); ++iMuon) {
153  //std::cout<<" chosen iMuon = "<<iMuon<<std::endl;
154  Trajectory::DataContainer finalCandidate;
155  SeedCandidate* aFinalSet = &(seedCandidates_AllChosen[iMuon]);
156  fwFitFailed = !(filter()->buildTrajectoryMeasurements(aFinalSet, finalCandidate));
157  if (fwFitFailed) {
158  //std::cout<<" buildTrajectoryMeasurements failed!"<<std::endl;
159  continue;
160  }
161  //---- are there measurements (or detLayers) used at all?
162  if (!filter()->layers().empty())
163  LogTrace(metname) << debug.dumpLayer(filter()->lastDetLayer());
164  else {
165  continue;
166  }
167  //std::cout<<" chambers used - all : "<<filter()->getTotalChamberUsed()<<", DT : "<<filter()->getDTChamberUsed()<<
168  //", CSC : "<<filter()->getCSCChamberUsed()<<", RPC : "<<filter()->getRPCChamberUsed()<<std::endl;
169  //---- ask for some "reasonable" conditions to build a STA muon;
170  //---- (totalChambers >= 2, dtChambers + cscChambers >0)
171  if (filter()->goodState()) {
173  TrajectoryStateOnSurface firstTSOS;
174  bool conversionPassed = false;
176  //---- transforms set of segment measurements to a set of rechit measurements
177  conversionPassed = filter()->transform(finalCandidate, hitContainer, firstTSOS);
178  } else {
179  //---- transforms set of segment measurements to a set of segment measurements
180  conversionPassed = filter()->transformLight(finalCandidate, hitContainer, firstTSOS);
181  }
182  if (conversionPassed && !finalCandidate.empty() && !hitContainer.empty()) {
183  //---- doesn't work...
184  //output->push_back( theSeedFinder.makeSeed(firstTSOS, hitContainer) );
185 
186  edm::OwnVector<TrackingRecHit> recHitsContainer;
187  for (unsigned int iHit = 0; iHit < hitContainer.size(); ++iHit) {
188  recHitsContainer.push_back(hitContainer.at(iHit)->hit()->clone());
189  }
192  dir = alongMomentum; // why forward (for rechits) later?
193  }
194 
195  PTrajectoryStateOnDet seedTSOS =
196  trajectoryStateTransform::persistentState(firstTSOS, hitContainer.at(0)->geographicalId().rawId());
197  TrajectorySeed seed(seedTSOS, recHitsContainer, dir);
198 
199  //MuonPatternRecoDumper debug;
200  //std::cout<<" firstTSOS (not IP) = "<<debug.dumpTSOS(firstTSOS)<<std::endl;
201  //std::cout<<" hits(from range) = "<<range.second-range.first<<" hits (from size) = "<<hitContainer.size()<<std::endl;
202  //for(unsigned int iRH=0;iRH<hitContainer.size();++iRH){
203  //std::cout<<" RH = "<<iRH+1<<" globPos = "<<hitContainer.at(iRH)->globalPosition()<<std::endl;
204  //}
205  output->push_back(seed);
206  } else {
207  //std::cout<<" Transformation from TrajectoryMeasurements to RecHitContainer faild - skip "<<std::endl;
208  continue;
209  }
210  } else {
211  //std::cout<<" Not enough (as defined) measurements to build trajectory - skip"<<std::endl;
212  continue;
213  }
214  }
215  event.put(std::move(output));
216  theFilter->reset();
217 }
SETSeedFinder theSeedFinder
void setBeamSpot(const GlobalVector &gv)
bool transform(Trajectory::DataContainer &measurements_segments, TransientTrackingRecHit::ConstRecHitContainer &hitContainer, TrajectoryStateOnSurface &firstTSOS)
transforms "segment trajectory" to "rechit container"
Definition: SETFilter.cc:158
double z0() const
z coordinate
Definition: BeamSpot.h:65
bool transformLight(Trajectory::DataContainer &measurements_segments, TransientTrackingRecHit::ConstRecHitContainer &hitContainer, TrajectoryStateOnSurface &firstTSOS)
transforms "segment trajectory" to "segment container"
Definition: SETFilter.cc:207
edm::EDGetTokenT< reco::BeamSpot > beamspotToken
std::string dumpLayer(const DetLayer *layer) const
const std::string metname
void reset()
Definition: SETFilter.cc:62
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
bool buildTrajectoryMeasurements(SeedCandidate *validSegmentsSet, Trajectory::DataContainer &finalCandidate)
from SeedCandidate to DataContainer only
Definition: SETFilter.cc:124
PropagationDirection
std::vector< MuonRecHitContainer > sortByLayer(MuonRecHitContainer &cluster) const
void push_back(D *&d)
Definition: OwnVector.h:326
std::vector< const DetLayer * > layers() const
return the layer used for the refit
Definition: SETFilter.h:100
std::vector< TrajectoryMeasurement > DataContainer
Definition: Trajectory.h:40
bool fwfit_SET(std::vector< SeedCandidate > &validSegmentsSet_in, std::vector< SeedCandidate > &validSegmentsSet_out)
Perform the SET inner-outward fitting.
Definition: SETFilter.cc:89
SETPatternRecognition * thePatternRecognition
bool isValid() const
Definition: HandleBase.h:70
#define LogTrace(id)
std::vector< ConstRecHitPointer > ConstRecHitContainer
void limitCombinatorics(std::vector< MuonRecHitContainer > &MuonRecHitContainer_perLayer)
#define debug
Definition: HDRShower.cc:19
void setEvent(const edm::Event &)
std::vector< MuonRecHitContainer > findAllValidSets(const std::vector< MuonRecHitContainer > &MuonRecHitContainer_perLayer)
MuonServiceProxy * theService
void validSetsPrePruning(std::vector< MuonRecHitContainer > &allValidSets)
double y0() const
y coordinate
Definition: BeamSpot.h:63
std::vector< SeedCandidate > fillSeedCandidates(std::vector< MuonRecHitContainer > &allValidSets)
SETFilter * filter() const
pre-filter
void produce(const edm::Event &event, const edm::EventSetup &eSetup, std::vector< MuonRecHitContainer > &result) override
def move(src, dest)
Definition: eostools.py:511
double x0() const
x coordinate
Definition: BeamSpot.h:61
void SETMuonSeedProducer::setEvent ( const edm::Event event)
private

Definition at line 220 of file SETMuonSeedProducer.cc.

References SETFilter::setEvent(), and theFilter.

Referenced by produce().

220 { theFilter->setEvent(event); }
virtual void setEvent(const edm::Event &event)
Pass the Event to the algo at each event.
Definition: SETFilter.cc:60

Member Data Documentation

bool SETMuonSeedProducer::apply_prePruning
private

Definition at line 58 of file SETMuonSeedProducer.h.

Referenced by produce(), and SETMuonSeedProducer().

edm::EDGetTokenT<reco::BeamSpot> SETMuonSeedProducer::beamspotToken
private

Definition at line 66 of file SETMuonSeedProducer.h.

Referenced by produce(), and SETMuonSeedProducer().

edm::InputTag SETMuonSeedProducer::theBeamSpotTag
private

Definition at line 65 of file SETMuonSeedProducer.h.

Referenced by SETMuonSeedProducer().

SETFilter* SETMuonSeedProducer::theFilter
private
SETPatternRecognition* SETMuonSeedProducer::thePatternRecognition
private

Definition at line 62 of file SETMuonSeedProducer.h.

Referenced by produce(), SETMuonSeedProducer(), and ~SETMuonSeedProducer().

SETSeedFinder SETMuonSeedProducer::theSeedFinder
private

Definition at line 63 of file SETMuonSeedProducer.h.

Referenced by produce(), and SETMuonSeedProducer().

MuonServiceProxy* SETMuonSeedProducer::theService
private

Definition at line 60 of file SETMuonSeedProducer.h.

Referenced by produce(), SETMuonSeedProducer(), and ~SETMuonSeedProducer().

bool SETMuonSeedProducer::useSegmentsInTrajectory
private

Definition at line 59 of file SETMuonSeedProducer.h.

Referenced by produce(), and SETMuonSeedProducer().