test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonReSeeder.cc
Go to the documentation of this file.
1 
2 //
3 //
4 
17 
19 
29 
30 
32  public:
33  explicit MuonReSeeder(const edm::ParameterSet & iConfig);
34  virtual ~MuonReSeeder() { }
35 
36  virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup) override;
37 
38  private:
41 
44 
47 
49  bool insideOut_;
50 
52  bool debug_;
53 
56 
57 };
58 
60  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)
66 {
67  produces<std::vector<TrajectorySeed> >();
68 }
69 
70 void
72  using namespace edm;
73  using namespace std;
74 
75  refitter_.setServices(iSetup);
76 
78  iEvent.getByToken(src_, src);
79 
80  //Retrieve tracker topology from geometry
82  iSetup.get<TrackerTopologyRcd>().get(tTopo);
83 
84  auto_ptr<vector<TrajectorySeed> > out(new vector<TrajectorySeed>());
85  unsigned int nsrc = src->size();
86  out->reserve(nsrc);
87 
88  for (View<reco::Muon>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
89  const reco::Muon &mu = *it;
90  if (mu.track().isNull() || !selector_(mu)) continue;
91  std::vector<Trajectory> traj = refitter_.transform(*mu.track());
92  if (traj.size() != 1) continue;
94  const std::vector<TrajectoryMeasurement> & tms = traj.front().measurements();
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() << std::endl;
99  std::cout << "Trajectory is " << (traj.front().direction() == alongMomentum ? "along" : "opposite") << " 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 " << tin.updatedState().globalPosition().z() << std::endl;
106  std::cout << "OU state: subdetector = " << tou.recHit()->geographicalId().subdetId() << std::endl;
107  std::cout << " global pos Rho " << tou.updatedState().globalPosition().perp() << ", Z " << tou.updatedState().globalPosition().z() << std::endl;
108  }
109  int lastSubdet = 0, lastLayer = -1;
110  for (int i = (fromInside ? 0 : tms.size()-1),
111  end = (fromInside ? tms.size() : -1),
112  step = (fromInside ? +1 : -1),
113  taken = 0; (end-i)*step > 0; i += step) {
114  const TrackingRecHit *lastHit = hit;
115  hit = tms[i].recHit()->hit();
116  if (debug_) std::cout << " considering hit " << i << ": rechit on " << (hit ? hit->geographicalId().rawId() : -1) << std::endl;
117  if (!hit) continue;
118  int subdet = hit->geographicalId().subdetId();
119  int lay = tTopo->layer(hit->geographicalId());
120  if (subdet != lastSubdet || lay != lastLayer) {
121  // I'm on a new layer
122  if (lastHit != 0 && taken == layersToKeep_) {
123  // I've had enough layers, I can stop here
124  hit = lastHit;
125  break;
126  }
127  lastSubdet = subdet; lastLayer = lay;
128  taken++;
129  }
130  seedHits.push_back(*hit);
131  tsos = tms[i].updatedState().isValid() ? tms[i].updatedState() :
132  (abs(i-end) < abs(i) ? tms[i].forwardPredictedState() : tms[i].backwardPredictedState());
133  if (debug_) {
134  std::cout << " hit : subdetector = " << tms[i].recHit()->geographicalId().subdetId() << std::endl;
135  if (hit->isValid()) {
136  std::cout << " global pos Rho " << tms[i].recHit()->globalPosition().perp() << ", Z " << tms[i].recHit()->globalPosition().z() << std::endl;
137  } else {
138  std::cout << " invalid tracking rec hit, so no global position" << std::endl;
139  }
140  std::cout << " state: global pos Rho " << tsos.globalPosition().perp() << ", Z " << tsos.globalPosition().z() << std::endl;
141  }
142  }
143  if (!tsos.isValid()) continue;
146  out->push_back(seed);
147  }
148 
149  iEvent.put(out);
150 }
151 
152 
int i
Definition: DBlmapReader.cc:9
TrackTransformer refitter_
Track Transformer.
Definition: MuonReSeeder.cc:55
T perp() const
Definition: PV3DBase.h:72
ConstRecHitPointer const & recHit() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
StringCutObjectSelector< reco::Muon > selector_
Muon selection.
Definition: MuonReSeeder.cc:43
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
virtual TrackRef track() const
reference to a Track
Definition: Muon.h:49
GlobalPoint globalPosition() const
bool debug_
Dump deug information.
Definition: MuonReSeeder.cc:52
int layersToKeep_
How many hits to keep from the muon trajectory.
Definition: MuonReSeeder.cc:46
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
virtual ~MuonReSeeder()
Definition: MuonReSeeder.cc:34
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
void push_back(D *&d)
Definition: OwnVector.h:280
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
T z() const
Definition: PV3DBase.h:64
def move
Definition: eostools.py:510
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const int mu
Definition: Constants.h:22
#define end
Definition: vmac.h:37
bool insideOut_
Do inside-out.
Definition: MuonReSeeder.cc:49
edm::EDGetTokenT< edm::View< reco::Muon > > src_
Labels for input collections.
Definition: MuonReSeeder.cc:40
virtual void setServices(const edm::EventSetup &)
set the services needed by the TrackTransformer
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
bool isNull() const
Checks for null.
Definition: Ref.h:249
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: MuonReSeeder.cc:71
tuple out
Definition: dbtoconf.py:99
virtual TrackingRecHit const * hit() const
const T & get() const
Definition: EventSetup.h:56
bool isValid() const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:85
virtual std::vector< Trajectory > transform(const reco::Track &) const
Convert a reco::Track into Trajectory.
tuple cout
Definition: gather_cfg.py:121
TrajectoryStateOnSurface const & updatedState() const
DetId geographicalId() const
volatile std::atomic< bool > shutdown_flag false
MuonReSeeder(const edm::ParameterSet &iConfig)
Definition: MuonReSeeder.cc:59
virtual double phi() const
momentum azimuthal angle
reference front()
Definition: OwnVector.h:355