CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HIProtoTrackSelector.h
Go to the documentation of this file.
1 #ifndef HIProtoTrackSelection_h
2 #define HIProtoTrackSelection_h
3 
6 
9 
12 
14 
15 #include <algorithm>
16 #include <iostream>
17 
23 {
24 
25  public:
26  // input collection type
28 
29  // output collection type
30  typedef std::vector<const reco::Track *> container;
31 
32  // iterator over result collection type.
33  typedef container::const_iterator const_iterator;
34 
35  // constructor from parameter set configurability
37  vertexCollection_(iConfig.getParameter<edm::InputTag>("VertexCollection")),
38  beamSpotLabel_(iConfig.getParameter<edm::InputTag>("beamSpotLabel")),
39  ptMin_(iConfig.getParameter<double>("ptMin")),
40  nSigmaZ_(iConfig.getParameter<double>("nSigmaZ")),
41  minZCut_(iConfig.getParameter<double>("minZCut")),
42  maxD0Significance_(iConfig.getParameter<double>("maxD0Significance"))
43  {};
44 
45  // select object from a collection and possibly event content
47  {
48  selected_.clear();
49 
50  const collection & c = *(TCH.product());
51 
52  // Get fast reco vertex
54  iEvent.getByLabel(vertexCollection_, vc);
55  const reco::VertexCollection * vertices = vc.product();
56 
57  math::XYZPoint vtxPoint(0.0,0.0,0.0);
58  double vzErr =0.0;
59 
60  if(vertices->size()>0) {
61  vtxPoint=vertices->begin()->position();
62  vzErr=vertices->begin()->zError();
63  edm::LogInfo("HeavyIonVertexing") << "Select prototracks compatible with median vertex"
64  << "\n vz = " << vtxPoint.Z()
65  << "\n " << nSigmaZ_ << " vz sigmas = " << vzErr*nSigmaZ_
66  << "\n cut at = " << std::max(vzErr*nSigmaZ_,minZCut_);
67  }
68  // Supress this warning, since events w/ no vertex are expected
69  //else {
70  //edm::LogError("HeavyIonVertexing") << "No vertex found in collection '" << vertexCollection_ << "'";
71  //}
72 
73  // Get beamspot
75  edm::Handle<reco::BeamSpot> beamSpotHandle;
76  iEvent.getByLabel(beamSpotLabel_, beamSpotHandle);
77 
78  math::XYZPoint bsPoint(0.0,0.0,0.0);
79  double bsWidth = 0.0;
80 
81  if ( beamSpotHandle.isValid() ) {
82  beamSpot = *beamSpotHandle;
83  bsPoint = beamSpot.position();
84  bsWidth = sqrt(beamSpot.BeamWidthX()*beamSpot.BeamWidthY());
85  edm::LogInfo("HeavyIonVertexing") << "Select prototracks compatible with beamspot"
86  << "\n (x,y,z) = (" << bsPoint.X() << "," << bsPoint.Y() << "," << bsPoint.Z() << ")"
87  << "\n width = " << bsWidth
88  << "\n cut at d0/d0sigma = " << maxD0Significance_;
89  } else {
90  edm::LogError("HeavyIonVertexing") << "No beam spot available from '" << beamSpotLabel_ << "\n";
91  }
92 
93 
94  // Do selection
95  int nSelected=0;
96  int nRejected=0;
97  double d0=0.0;
98  double d0sigma=0.0;
99  for (reco::TrackCollection::const_iterator trk = c.begin(); trk != c.end(); ++ trk)
100  {
101 
102  d0 = -1.*trk->dxy(bsPoint);
103  d0sigma = sqrt(trk->d0Error()*trk->d0Error() + bsWidth*bsWidth);
104  if ( trk->pt() > ptMin_ // keep only tracks above ptMin
105  && fabs(d0/d0sigma) < maxD0Significance_ // keep only tracks with D0 significance less than cut
106  && fabs(trk->dz(vtxPoint)) < std::max(vzErr*nSigmaZ_,minZCut_) // within minZCut, nSigmaZ of fast vertex
107  )
108  {
109  nSelected++;
110  selected_.push_back( & * trk );
111  }
112  else
113  nRejected++;
114  }
115 
116  edm::LogInfo("HeavyIonVertexing") << "selected " << nSelected << " prototracks out of " << nRejected+nSelected << "\n";
117 
118  }
119 
120  // iterators over selected objects: collection begin
121  const_iterator begin() const { return selected_.begin(); }
122 
123  // iterators over selected objects: collection end
124  const_iterator end() const { return selected_.end(); }
125 
126  // true if no object has been selected
127  size_t size() const { return selected_.size(); }
128 
129 
130  private:
134  double ptMin_;
135  double nSigmaZ_;
136  double minZCut_;
138 
139 };
140 
141 
142 #endif
HIProtoTrackSelector(const edm::ParameterSet &iConfig)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
const_iterator begin() const
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
int iEvent
Definition: GenABIO.cc:243
const T & max(const T &a, const T &b)
T sqrt(T t)
Definition: SSEVec.h:48
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:87
void select(edm::Handle< reco::TrackCollection > &TCH, const edm::Event &iEvent, const edm::EventSetup &iSetup)
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
std::vector< const reco::Track * > container
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
reco::TrackCollection collection
const_iterator end() const
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:89
T const * product() const
Definition: Handle.h:74
const Point & position() const
position
Definition: BeamSpot.h:63
container::const_iterator const_iterator