CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
MuonReSeeder Class Reference
Inheritance diagram for MuonReSeeder:
edm::stream::EDProducer<>

Public Member Functions

 MuonReSeeder (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~MuonReSeeder () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

bool debug_
 Dump deug information. More...
 
bool insideOut_
 Do inside-out. More...
 
int layersToKeep_
 How many hits to keep from the muon trajectory. More...
 
TrackTransformer refitter_
 Track Transformer. More...
 
StringCutObjectSelector
< reco::Muon
selector_
 Muon selection. More...
 
edm::EDGetTokenT< edm::View
< reco::Muon > > 
src_
 Labels for input collections. More...
 
const edm::ESGetToken
< TrackerTopology,
TrackerTopologyRcd
tTopoToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 30 of file MuonReSeeder.cc.

Constructor & Destructor Documentation

MuonReSeeder::MuonReSeeder ( const edm::ParameterSet iConfig)
explicit

Definition at line 58 of file MuonReSeeder.cc.

59  : src_(consumes<edm::View<reco::Muon>>(iConfig.getParameter<edm::InputTag>("src"))),
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 }
T getUntrackedParameter(std::string const &, T const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
TrackTransformer refitter_
Track Transformer.
Definition: MuonReSeeder.cc:55
StringCutObjectSelector< reco::Muon > selector_
Muon selection.
Definition: MuonReSeeder.cc:43
bool debug_
Dump deug information.
Definition: MuonReSeeder.cc:52
int layersToKeep_
How many hits to keep from the muon trajectory.
Definition: MuonReSeeder.cc:46
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Definition: MuonReSeeder.cc:40
bool insideOut_
Do inside-out.
Definition: MuonReSeeder.cc:49
edm::EDGetTokenT< edm::View< reco::Muon > > src_
Labels for input collections.
Definition: MuonReSeeder.cc:39
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
MuonReSeeder::~MuonReSeeder ( )
inlineoverride

Definition at line 33 of file MuonReSeeder.cc.

33 {}

Member Function Documentation

void MuonReSeeder::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 69 of file MuonReSeeder.cc.

References funct::abs(), alongMomentum, gather_cfg::cout, debug_, dataset::end, reco::LeafCandidate::eta(), edm::OwnVector< T, P >::front(), TrackingRecHit::geographicalId(), edm::Event::getByToken(), edm::EventSetup::getData(), TrajectoryStateOnSurface::globalPosition(), TrackingRecHit::hit(), mps_fire::i, insideOut_, edm::Ref< C, T, F >::isNull(), TrajectoryStateOnSurface::isValid(), TrackingRecHit::isValid(), layersToKeep_, eostools::move(), RPCpg::mu, oppositeToMomentum, submitPVResolutionJobs::out, PV3DBase< T, PVType, FrameType >::perp(), trajectoryStateTransform::persistentState(), reco::LeafCandidate::phi(), reco::LeafCandidate::pt(), edm::OwnVector< T, P >::push_back(), edm::Event::put(), DetId::rawId(), TrajectoryMeasurement::recHit(), refitter_, fileCollector::seed, selector_, TrackTransformer::setServices(), alcazmumu_cfi::src, src_, DetId::subdetId(), reco::Muon::track(), TrackTransformer::transform(), tTopoToken_, TrajectoryMeasurement::updatedState(), and PV3DBase< T, PVType, FrameType >::z().

69  {
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;
160  out->push_back(seed);
161  }
162 
163  iEvent.put(std::move(out));
164 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
TrackTransformer refitter_
Track Transformer.
Definition: MuonReSeeder.cc:55
T perp() const
Definition: PV3DBase.h:69
void setServices(const edm::EventSetup &) override
set the services needed by the TrackTransformer
ConstRecHitPointer const & recHit() const
double pt() const final
transverse momentum
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
StringCutObjectSelector< reco::Muon > selector_
Muon selection.
Definition: MuonReSeeder.cc:43
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
GlobalPoint globalPosition() const
TrackRef track() const override
reference to a Track
Definition: Muon.h:46
bool debug_
Dump deug information.
Definition: MuonReSeeder.cc:52
int layersToKeep_
How many hits to keep from the muon trajectory.
Definition: MuonReSeeder.cc:46
bool getData(T &iHolder) const
Definition: EventSetup.h:122
void push_back(D *&d)
Definition: OwnVector.h:326
T z() const
Definition: PV3DBase.h:61
def move
Definition: eostools.py:511
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Definition: MuonReSeeder.cc:40
const int mu
Definition: Constants.h:22
bool insideOut_
Do inside-out.
Definition: MuonReSeeder.cc:49
edm::EDGetTokenT< edm::View< reco::Muon > > src_
Labels for input collections.
Definition: MuonReSeeder.cc:39
bool isNull() const
Checks for null.
Definition: Ref.h:235
virtual TrackingRecHit const * hit() const
bool isValid() const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
string end
Definition: dataset.py:937
tuple cout
Definition: gather_cfg.py:144
TrajectoryStateOnSurface const & updatedState() const
step
Definition: StallMonitor.cc:98
DetId geographicalId() const
double phi() const final
momentum azimuthal angle
std::vector< Trajectory > transform(const reco::Track &) const override
Convert a reco::Track into Trajectory.
reference front()
Definition: OwnVector.h:459
double eta() const final
momentum pseudorapidity

Member Data Documentation

bool MuonReSeeder::debug_
private

Dump deug information.

Definition at line 52 of file MuonReSeeder.cc.

Referenced by produce().

bool MuonReSeeder::insideOut_
private

Do inside-out.

Definition at line 49 of file MuonReSeeder.cc.

Referenced by produce().

int MuonReSeeder::layersToKeep_
private

How many hits to keep from the muon trajectory.

Definition at line 46 of file MuonReSeeder.cc.

Referenced by produce().

TrackTransformer MuonReSeeder::refitter_
private

Track Transformer.

Definition at line 55 of file MuonReSeeder.cc.

Referenced by produce().

StringCutObjectSelector<reco::Muon> MuonReSeeder::selector_
private

Muon selection.

Definition at line 43 of file MuonReSeeder.cc.

Referenced by produce().

edm::EDGetTokenT<edm::View<reco::Muon> > MuonReSeeder::src_
private

Labels for input collections.

Definition at line 39 of file MuonReSeeder.cc.

Referenced by produce().

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> MuonReSeeder::tTopoToken_
private

Definition at line 40 of file MuonReSeeder.cc.

Referenced by produce().