CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FakeTrackProducers.cc
Go to the documentation of this file.
1 
2 //
3 // $Id: FakeTrackProducers.cc,v 1.2 2013/02/27 14:58:17 muzaffar Exp $
4 //
5 
20 
37 
38 
39 
40 template<class T>
42  public:
43  explicit FakeTrackProducer(const edm::ParameterSet & iConfig);
44  virtual ~FakeTrackProducer() { }
45 
46  virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup) override;
47  private:
50 
52  //StringCutObjectSelector<T> selector_;
53 
54  // EventSetup
57 
58  const PTrajectoryStateOnDet & getState(const TrajectorySeed &seed) const { return seed.startingState(); }
59  const PTrajectoryStateOnDet & getState(const TrackCandidate &seed) const { return seed.trajectoryStateOnDet(); }
60  TrajectorySeed::range getHits (const TrajectorySeed &seed) const { return seed.recHits(); }
61  TrajectorySeed::range getHits (const TrackCandidate &seed) const { return seed.recHits(); }
62 };
63 
64 
65 template<typename T>
67  src_(iConfig.getParameter<edm::InputTag>("src"))
68  //,selector_(iConfig.existsAs<std::string>("cut") ? iConfig.getParameter<std::string>("cut") : "", true)
69 {
70  produces<std::vector<reco::Track> >();
71  produces<std::vector<reco::TrackExtra> >();
72  produces<edm::OwnVector<TrackingRecHit> >();
73 }
74 
75 template<typename T>
76 void
78  using namespace edm;
79  using namespace std;
80 
81 
82  iSetup.get<TrackerDigiGeometryRecord>().get(theGeometry);
83  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
84 
86  iEvent.getByLabel(src_, src);
87 
88  auto_ptr<vector<reco::Track> > out(new vector<reco::Track>());
89  out->reserve(src->size());
90  auto_ptr<vector<reco::TrackExtra> > outEx(new vector<reco::TrackExtra>());
91  outEx->reserve(src->size());
92  auto_ptr<OwnVector<TrackingRecHit> > outHits(new OwnVector<TrackingRecHit>());
93 
96  for (typename vector<T>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
97  const T &mu = *it;
98  //if (!selector_(mu)) continue;
99  const PTrajectoryStateOnDet & pstate = getState(mu);
100  const GeomDet *det = theGeometry->idToDet(DetId(pstate.detId()));
101  if (det == 0) { std::cerr << "ERROR: bogus detid " << pstate.detId() << std::endl; continue; }
103  GlobalPoint gx = state.globalPosition();
104  GlobalVector gp = state.globalMomentum();
105  reco::Track::Point x(gx.x(), gx.y(), gx.z());
106  reco::Track::Vector p(gp.x(), gp.y(), gp.z());
107  int charge = state.localParameters().charge();
108  out->push_back(reco::Track(1.0,1.0,x,p,charge,reco::Track::CovarianceMatrix()));
109  TrajectorySeed::range hits = getHits(mu);
110  out->back().setHitPattern(hits.first, hits.second);
111  // Now Track Extra
112  const TrackingRecHit *hit0 = &*hits.first;
113  const TrackingRecHit *hit1 = &*(hits.second-1);
114  const GeomDet *det0 = theGeometry->idToDet(hit0->geographicalId());
115  const GeomDet *det1 = theGeometry->idToDet(hit1->geographicalId());
116  if (det0 == 0 || det1 == 0) { std::cerr << "ERROR: bogus detids at beginning or end of range" << std::endl; continue; }
117  GlobalPoint gx0 = det0->toGlobal(hit0->localPosition());
118  GlobalPoint gx1 = det1->toGlobal(hit1->localPosition());
119  reco::Track::Point x0(gx0.x(), gx0.y(), gx0.z());
120  reco::Track::Point x1(gx1.x(), gx1.y(), gx1.z());
121  if (x0.R() > x1.R()) std::swap(x0,x1);
122  outEx->push_back( reco::TrackExtra(x1, p, true, x0, p, true,
125  alongMomentum) );
126  out->back().setExtra( reco::TrackExtraRef( rTrackExtras, outEx->size()-1 ) );
127  reco::TrackExtra &ex = outEx->back();
128  for (OwnVector<TrackingRecHit>::const_iterator it2 = hits.first; it2 != hits.second; ++it2) {
129  outHits->push_back(*it2);
130  ex.add( TrackingRecHitRef( rHits, outHits->size()-1 ) );
131  }
132  }
133 
134  iEvent.put(out);
135  iEvent.put(outEx);
136  iEvent.put(outHits);
137 }
138 
const LocalTrajectoryParameters & localParameters() const
range recHits() const
edm::ESHandle< MagneticField > theMagField
TrajectorySeed::range getHits(const TrackCandidate &seed) const
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
T y() const
Definition: PV3DBase.h:63
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
GlobalPoint globalPosition() const
DEFINE_FWK_MODULE(HiMixingModule)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
double charge(const std::vector< uint8_t > &Ampls)
FakeTrackProducer< TrajectorySeed > FakeTrackProducerFromSeed
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
const PTrajectoryStateOnDet & getState(const TrackCandidate &seed) const
PTrajectoryStateOnDet const & trajectoryStateOnDet() const
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
edm::Ref< TrackingRecHitCollection > TrackingRecHitRef
persistent reference to a TrackingRecHit
const PTrajectoryStateOnDet & getState(const TrajectorySeed &seed) const
TrajectorySeed::range getHits(const TrajectorySeed &seed) const
T z() const
Definition: PV3DBase.h:64
std::pair< const_iterator, const_iterator > range
unsigned int detId() const
const int mu
Definition: Constants.h:23
math::XYZPoint Point
point in the space
Definition: TrackBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
RefProd< PROD > getRefBeforePut()
Definition: Event.h:106
tuple out
Definition: dbtoconf.py:99
FakeTrackProducer(const edm::ParameterSet &iConfig)
Definition: DetId.h:20
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:9
PTrajectoryStateOnDet const & startingState() const
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
const T & get() const
Definition: EventSetup.h:55
range recHits() const
void add(const TrackingRecHitRef &r)
add a reference to a RecHit
TrackCharge charge() const
Charge (-1, 0 or 1)
char state
Definition: procUtils.cc:75
edm::InputTag src_
Labels for input collections.
edm::ESHandle< TrackerGeometry > theGeometry
Muon selection.
GlobalVector globalMomentum() const
FakeTrackProducer< TrackCandidate > FakeTrackProducerFromCandidate
DetId geographicalId() const
Definition: DDAxes.h:10
long double T
T x() const
Definition: PV3DBase.h:62
virtual LocalPoint localPosition() const =0
math::XYZVector Vector
spatial vector
Definition: TrackBase.h:74
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:72