CMS 3D CMS Logo

MuonReSeeder.cc
Go to the documentation of this file.
1 
2 //
3 //
4 
17 
19 
29 
31 public:
32  explicit MuonReSeeder(const edm::ParameterSet &iConfig);
33  ~MuonReSeeder() override {}
34 
35  void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override;
36 
37 private:
41 
44 
47 
49  bool insideOut_;
50 
52  bool debug_;
53 
56 };
57 
59  : src_(consumes<edm::View<reco::Muon>>(iConfig.getParameter<edm::InputTag>("src"))),
60  tTopoToken_(esConsumes()),
61  selector_(iConfig.existsAs<std::string>("cut") ? iConfig.getParameter<std::string>("cut") : "", true),
62  layersToKeep_(iConfig.getParameter<int32_t>("layersToKeep")),
63  insideOut_(iConfig.getParameter<bool>("insideOut")),
64  debug_(iConfig.getUntrackedParameter<bool>("debug", false)),
65  refitter_(iConfig, consumesCollector()) {
66  produces<std::vector<TrajectorySeed>>();
67 }
68 
70  using namespace edm;
71  using namespace std;
72 
73  refitter_.setServices(iSetup);
74 
76  iEvent.getByToken(src_, src);
77 
78  //Retrieve tracker topology from geometry
79  const TrackerTopology &tTopo = iSetup.getData(tTopoToken_);
80 
81  auto out = std::make_unique<std::vector<TrajectorySeed>>();
82  unsigned int nsrc = src->size();
83  out->reserve(nsrc);
84 
85  for (View<reco::Muon>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
86  const reco::Muon &mu = *it;
87  if (mu.track().isNull() || !selector_(mu))
88  continue;
89  std::vector<Trajectory> traj = refitter_.transform(*mu.track());
90  if (traj.size() != 1)
91  continue;
93  const std::vector<TrajectoryMeasurement> &tms = traj.front().measurements();
95  const TrackingRecHit *hit = nullptr;
96  bool fromInside = (insideOut_ == (traj.front().direction() == alongMomentum));
97  if (debug_) {
98  std::cout << "Considering muon of pt " << mu.pt() << ", eta = " << mu.eta() << ", phi = " << mu.phi()
99  << std::endl;
100  std::cout << "Trajectory is " << (traj.front().direction() == alongMomentum ? "along" : "opposite")
101  << " to momentum, so will start from " << (fromInside ? "inside" : "outside") << std::endl;
102  }
103  const TrajectoryMeasurement &tin = (fromInside ? tms.front() : tms.back());
104  const TrajectoryMeasurement &tou = (fromInside ? tms.front() : tms.back());
105  if (debug_) {
106  std::cout << "IN state: subdetector = " << tin.recHit()->geographicalId().subdetId() << std::endl;
107  std::cout << " global pos Rho " << tin.updatedState().globalPosition().perp() << ", Z "
108  << tin.updatedState().globalPosition().z() << std::endl;
109  std::cout << "OU state: subdetector = " << tou.recHit()->geographicalId().subdetId() << std::endl;
110  std::cout << " global pos Rho " << tou.updatedState().globalPosition().perp() << ", Z "
111  << tou.updatedState().globalPosition().z() << std::endl;
112  }
113  int lastSubdet = 0, lastLayer = -1;
114  for (int i = (fromInside ? 0 : tms.size() - 1),
115  end = (fromInside ? tms.size() : -1),
116  step = (fromInside ? +1 : -1),
117  taken = 0;
118  (end - i) * step > 0;
119  i += step) {
120  const TrackingRecHit *lastHit = hit;
121  hit = tms[i].recHit()->hit();
122  if (debug_)
123  std::cout << " considering hit " << i << ": rechit on " << (hit ? hit->geographicalId().rawId() : -1)
124  << std::endl;
125  if (!hit)
126  continue;
127  int subdet = hit->geographicalId().subdetId();
128  int lay = tTopo.layer(hit->geographicalId());
129  if (subdet != lastSubdet || lay != lastLayer) {
130  // I'm on a new layer
131  if (lastHit != nullptr && taken == layersToKeep_) {
132  // I've had enough layers, I can stop here
133  hit = lastHit;
134  break;
135  }
136  lastSubdet = subdet;
137  lastLayer = lay;
138  taken++;
139  }
140  seedHits.push_back(*hit);
141  tsos = tms[i].updatedState().isValid()
142  ? tms[i].updatedState()
143  : (abs(i - end) < abs(i) ? tms[i].forwardPredictedState() : tms[i].backwardPredictedState());
144  if (debug_) {
145  std::cout << " hit : subdetector = " << tms[i].recHit()->geographicalId().subdetId() << std::endl;
146  if (hit->isValid()) {
147  std::cout << " global pos Rho " << tms[i].recHit()->globalPosition().perp() << ", Z "
148  << tms[i].recHit()->globalPosition().z() << std::endl;
149  } else {
150  std::cout << " invalid tracking rec hit, so no global position" << std::endl;
151  }
152  std::cout << " state: global pos Rho " << tsos.globalPosition().perp() << ", Z "
153  << tsos.globalPosition().z() << std::endl;
154  }
155  }
156  if (!tsos.isValid())
157  continue;
158  PTrajectoryStateOnDet const &PTraj = trajectoryStateTransform::persistentState(tsos, hit->geographicalId().rawId());
160  out->push_back(seed);
161  }
162 
163  iEvent.put(std::move(out));
164 }
165 
TrajectoryStateOnSurface.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
Muon.h
funct::false
false
Definition: Factorize.h:29
step
step
Definition: StallMonitor.cc:94
sistrip::View
View
Definition: ConstantsForView.h:26
TrackTransformer::setServices
void setServices(const edm::EventSetup &) override
set the services needed by the TrackTransformer
Definition: TrackTransformer.cc:79
MuonReSeeder::MuonReSeeder
MuonReSeeder(const edm::ParameterSet &iConfig)
Definition: MuonReSeeder.cc:58
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
MuonReSeeder::src_
edm::EDGetTokenT< edm::View< reco::Muon > > src_
Labels for input collections.
Definition: MuonReSeeder.cc:39
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackerTopology
Definition: TrackerTopology.h:16
trajectoryStateTransform::persistentState
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
Definition: TrajectoryStateTransform.cc:14
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
gather_cfg.cout
cout
Definition: gather_cfg.py:144
MuonReSeeder
Definition: MuonReSeeder.cc:30
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
MuonReSeeder::~MuonReSeeder
~MuonReSeeder() override
Definition: MuonReSeeder.cc:33
TrackTransformer::transform
std::vector< Trajectory > transform(const reco::Track &) const override
Convert a reco::Track into Trajectory.
Definition: TrackTransformer.cc:182
oppositeToMomentum
Definition: PropagationDirection.h:4
EDProducer.h
TrackerTopology::layer
unsigned int layer(const DetId &id) const
Definition: TrackerTopology.cc:47
TrajectoryMeasurement.h
TrajectoryMeasurement::updatedState
TrajectoryStateOnSurface const & updatedState() const
Definition: TrajectoryMeasurement.h:184
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
MuonReSeeder::debug_
bool debug_
Dump deug information.
Definition: MuonReSeeder.cc:52
edm::Handle
Definition: AssociativeIterator.h:50
MuonReSeeder::refitter_
TrackTransformer refitter_
Track Transformer.
Definition: MuonReSeeder.cc:55
Muon
Definition: Muon.py:1
reco::Muon
Definition: Muon.h:27
MuonReSeeder::insideOut_
bool insideOut_
Do inside-out.
Definition: MuonReSeeder.cc:49
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
fileCollector.seed
seed
Definition: fileCollector.py:127
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
MakerMacros.h
TrackerTopology.h
TrackerTopologyRcd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
mps_fire.end
end
Definition: mps_fire.py:242
MuonReSeeder::tTopoToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Definition: MuonReSeeder.cc:40
MuonReSeeder::selector_
StringCutObjectSelector< reco::Muon > selector_
Muon selection.
Definition: MuonReSeeder.cc:43
edm::OwnVector::front
reference front()
Definition: OwnVector.h:459
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
funct::true
true
Definition: Factorize.h:173
edm::ParameterSet
Definition: ParameterSet.h:47
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
Event.h
deltaR.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:38
TrackTransformer.h
edm::EventSetup
Definition: EventSetup.h:58
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd >
InputTag.h
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
TrackingRecHit
Definition: TrackingRecHit.h:21
TrajectoryMeasurement::recHit
ConstRecHitPointer const & recHit() const
Definition: TrajectoryMeasurement.h:190
Trajectory.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
StringCutObjectSelector.h
MuonReSeeder::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: MuonReSeeder.cc:69
StringCutObjectSelector< reco::Muon >
TrajectorySeed
Definition: TrajectorySeed.h:18
TrajectoryStateTransform.h
edm::OwnVector::push_back
void push_back(D *&d)
Definition: OwnVector.h:326
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
ConsumesCollector.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
ParameterSet.h
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
TrajectoryMeasurement
Definition: TrajectoryMeasurement.h:25
MuonReSeeder::layersToKeep_
int layersToKeep_
How many hits to keep from the muon trajectory.
Definition: MuonReSeeder.cc:46
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
alongMomentum
Definition: PropagationDirection.h:4
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
hit
Definition: SiStripHitEffFromCalibTree.cc:88
edm::OwnVector< TrackingRecHit >
TrackTransformer
Definition: TrackTransformer.h:46