CMS 3D CMS Logo

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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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::Muonselector_
 Muon selection. More...
 
edm::EDGetTokenT< edm::View< reco::Muon > > src_
 Labels for input collections. More...
 

Additional Inherited Members

- 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
 

Detailed Description

Definition at line 29 of file MuonReSeeder.cc.

Constructor & Destructor Documentation

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

Definition at line 56 of file MuonReSeeder.cc.

57  : src_(consumes<edm::View<reco::Muon>>(iConfig.getParameter<edm::InputTag>("src"))),
58  selector_(iConfig.existsAs<std::string>("cut") ? iConfig.getParameter<std::string>("cut") : "", true),
59  layersToKeep_(iConfig.getParameter<int32_t>("layersToKeep")),
60  insideOut_(iConfig.getParameter<bool>("insideOut")),
61  debug_(iConfig.getUntrackedParameter<bool>("debug", false)),
62  refitter_(iConfig) {
63  produces<std::vector<TrajectorySeed>>();
64 }
T getParameter(std::string const &) const
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:160
TrackTransformer refitter_
Track Transformer.
Definition: MuonReSeeder.cc:53
StringCutObjectSelector< reco::Muon > selector_
Muon selection.
Definition: MuonReSeeder.cc:41
bool debug_
Dump deug information.
Definition: MuonReSeeder.cc:50
int layersToKeep_
How many hits to keep from the muon trajectory.
Definition: MuonReSeeder.cc:44
bool insideOut_
Do inside-out.
Definition: MuonReSeeder.cc:47
edm::EDGetTokenT< edm::View< reco::Muon > > src_
Labels for input collections.
Definition: MuonReSeeder.cc:38
MuonReSeeder::~MuonReSeeder ( )
inlineoverride

Definition at line 32 of file MuonReSeeder.cc.

References iEvent, and produce().

32 {}

Member Function Documentation

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

Definition at line 66 of file MuonReSeeder.cc.

References funct::abs(), alongMomentum, gather_cfg::cout, debug_, DEFINE_FWK_MODULE, end, reco::LeafCandidate::eta(), edm::OwnVector< T, P >::front(), TrackingRecHit::geographicalId(), edm::EventSetup::get(), edm::Event::getByToken(), TrajectoryStateOnSurface::globalPosition(), TrackingRecHit::hit(), mps_fire::i, insideOut_, edm::Ref< C, T, F >::isNull(), TrajectoryStateOnSurface::isValid(), TrackingRecHit::isValid(), TrackerTopology::layer(), layersToKeep_, eostools::move(), amptDefaultParameters_cff::mu, oppositeToMomentum, MillePedeFileConverter_cfg::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_, SurveyInfoScenario_cff::seed, selector_, TrackTransformer::setServices(), TrackRefitter_38T_cff::src, src_, DetId::subdetId(), reco::Muon::track(), TrackTransformer::transform(), TrajectoryMeasurement::updatedState(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by ~MuonReSeeder().

66  {
67  using namespace edm;
68  using namespace std;
69 
70  refitter_.setServices(iSetup);
71 
73  iEvent.getByToken(src_, src);
74 
75  //Retrieve tracker topology from geometry
77  iSetup.get<TrackerTopologyRcd>().get(tTopo);
78 
79  auto out = std::make_unique<std::vector<TrajectorySeed>>();
80  unsigned int nsrc = src->size();
81  out->reserve(nsrc);
82 
83  for (View<reco::Muon>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
84  const reco::Muon &mu = *it;
85  if (mu.track().isNull() || !selector_(mu))
86  continue;
87  std::vector<Trajectory> traj = refitter_.transform(*mu.track());
88  if (traj.size() != 1)
89  continue;
91  const std::vector<TrajectoryMeasurement> &tms = traj.front().measurements();
93  const TrackingRecHit *hit = nullptr;
94  bool fromInside = (insideOut_ == (traj.front().direction() == alongMomentum));
95  if (debug_) {
96  std::cout << "Considering muon of pt " << mu.pt() << ", eta = " << mu.eta() << ", phi = " << mu.phi()
97  << std::endl;
98  std::cout << "Trajectory is " << (traj.front().direction() == alongMomentum ? "along" : "opposite")
99  << " to momentum, so will start from " << (fromInside ? "inside" : "outside") << std::endl;
100  }
101  const TrajectoryMeasurement &tin = (fromInside ? tms.front() : tms.back());
102  const TrajectoryMeasurement &tou = (fromInside ? tms.front() : tms.back());
103  if (debug_) {
104  std::cout << "IN state: subdetector = " << tin.recHit()->geographicalId().subdetId() << std::endl;
105  std::cout << " global pos Rho " << tin.updatedState().globalPosition().perp() << ", Z "
106  << tin.updatedState().globalPosition().z() << std::endl;
107  std::cout << "OU state: subdetector = " << tou.recHit()->geographicalId().subdetId() << std::endl;
108  std::cout << " global pos Rho " << tou.updatedState().globalPosition().perp() << ", Z "
109  << tou.updatedState().globalPosition().z() << std::endl;
110  }
111  int lastSubdet = 0, lastLayer = -1;
112  for (int i = (fromInside ? 0 : tms.size() - 1),
113  end = (fromInside ? tms.size() : -1),
114  step = (fromInside ? +1 : -1),
115  taken = 0;
116  (end - i) * step > 0;
117  i += step) {
118  const TrackingRecHit *lastHit = hit;
119  hit = tms[i].recHit()->hit();
120  if (debug_)
121  std::cout << " considering hit " << i << ": rechit on " << (hit ? hit->geographicalId().rawId() : -1)
122  << std::endl;
123  if (!hit)
124  continue;
125  int subdet = hit->geographicalId().subdetId();
126  int lay = tTopo->layer(hit->geographicalId());
127  if (subdet != lastSubdet || lay != lastLayer) {
128  // I'm on a new layer
129  if (lastHit != nullptr && taken == layersToKeep_) {
130  // I've had enough layers, I can stop here
131  hit = lastHit;
132  break;
133  }
134  lastSubdet = subdet;
135  lastLayer = lay;
136  taken++;
137  }
138  seedHits.push_back(*hit);
139  tsos = tms[i].updatedState().isValid()
140  ? tms[i].updatedState()
141  : (abs(i - end) < abs(i) ? tms[i].forwardPredictedState() : tms[i].backwardPredictedState());
142  if (debug_) {
143  std::cout << " hit : subdetector = " << tms[i].recHit()->geographicalId().subdetId() << std::endl;
144  if (hit->isValid()) {
145  std::cout << " global pos Rho " << tms[i].recHit()->globalPosition().perp() << ", Z "
146  << tms[i].recHit()->globalPosition().z() << std::endl;
147  } else {
148  std::cout << " invalid tracking rec hit, so no global position" << std::endl;
149  }
150  std::cout << " state: global pos Rho " << tsos.globalPosition().perp() << ", Z "
151  << tsos.globalPosition().z() << std::endl;
152  }
153  }
154  if (!tsos.isValid())
155  continue;
158  out->push_back(seed);
159  }
160 
161  iEvent.put(std::move(out));
162 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
TrackRef track() const override
reference to a Track
Definition: Muon.h:46
double eta() const final
momentum pseudorapidity
TrackTransformer refitter_
Track Transformer.
Definition: MuonReSeeder.cc:53
T perp() const
Definition: PV3DBase.h:69
void setServices(const edm::EventSetup &) override
set the services needed by the TrackTransformer
ConstRecHitPointer const & recHit() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
StringCutObjectSelector< reco::Muon > selector_
Muon selection.
Definition: MuonReSeeder.cc:41
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
GlobalPoint globalPosition() const
double pt() const final
transverse momentum
bool debug_
Dump deug information.
Definition: MuonReSeeder.cc:50
int layersToKeep_
How many hits to keep from the muon trajectory.
Definition: MuonReSeeder.cc:44
void push_back(D *&d)
Definition: OwnVector.h:326
T z() const
Definition: PV3DBase.h:61
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
#define end
Definition: vmac.h:39
bool insideOut_
Do inside-out.
Definition: MuonReSeeder.cc:47
edm::EDGetTokenT< edm::View< reco::Muon > > src_
Labels for input collections.
Definition: MuonReSeeder.cc:38
std::vector< Trajectory > transform(const reco::Track &) const override
Convert a reco::Track into Trajectory.
bool isNull() const
Checks for null.
Definition: Ref.h:235
virtual TrackingRecHit const * hit() const
bool isValid() const
unsigned int layer(const DetId &id) const
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
T get() const
Definition: EventSetup.h:73
TrajectoryStateOnSurface const & updatedState() const
step
Definition: StallMonitor.cc:94
DetId geographicalId() const
double phi() const final
momentum azimuthal angle
reference front()
Definition: OwnVector.h:459
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

bool MuonReSeeder::debug_
private

Dump deug information.

Definition at line 50 of file MuonReSeeder.cc.

Referenced by produce().

bool MuonReSeeder::insideOut_
private

Do inside-out.

Definition at line 47 of file MuonReSeeder.cc.

Referenced by produce().

int MuonReSeeder::layersToKeep_
private

How many hits to keep from the muon trajectory.

Definition at line 44 of file MuonReSeeder.cc.

Referenced by produce().

TrackTransformer MuonReSeeder::refitter_
private

Track Transformer.

Definition at line 53 of file MuonReSeeder.cc.

Referenced by produce().

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

Muon selection.

Definition at line 41 of file MuonReSeeder.cc.

Referenced by produce().

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

Labels for input collections.

Definition at line 38 of file MuonReSeeder.cc.

Referenced by produce().