CMS 3D CMS Logo

HIProtoTrackSelector.h
Go to the documentation of this file.
1 #ifndef HIProtoTrackSelection_h
2 #define HIProtoTrackSelection_h
3 
7 
10 
13 
16 
18 
19 #include <algorithm>
20 #include <iostream>
21 
27 public:
28  // input collection type
30 
31  // output collection type
32  typedef std::vector<const reco::Track*> container;
33 
34  // iterator over result collection type.
35  typedef container::const_iterator const_iterator;
36 
37  // constructor from parameter set configurability
39  : vertexCollection_(iConfig.getParameter<edm::InputTag>("VertexCollection")),
41  beamSpot_(iConfig.getParameter<edm::InputTag>("beamSpotLabel")),
42  beamSpotToken_(iC.consumes<reco::BeamSpot>(beamSpot_)),
43  ptMin_(iConfig.getParameter<double>("ptMin")),
44  nSigmaZ_(iConfig.getParameter<double>("nSigmaZ")),
45  minZCut_(iConfig.getParameter<double>("minZCut")),
46  maxD0Significance_(iConfig.getParameter<double>("maxD0Significance")){};
47 
48  // select object from a collection and possibly event content
50  selected_.clear();
51 
52  const collection& c = *(TCH.product());
53 
54  // Get fast reco vertex
56  iEvent.getByToken(vertexCollectionToken_, vc);
58 
59  math::XYZPoint vtxPoint(0.0, 0.0, 0.0);
60  double vzErr = 0.0;
61 
62  if (!vertices->empty()) {
63  vtxPoint = vertices->begin()->position();
64  vzErr = vertices->begin()->zError();
65  edm::LogInfo("HeavyIonVertexing") << "Select prototracks compatible with median vertex"
66  << "\n vz = " << vtxPoint.Z() << "\n " << nSigmaZ_
67  << " vz sigmas = " << vzErr * nSigmaZ_
68  << "\n cut at = " << std::max(vzErr * nSigmaZ_, minZCut_);
69  }
70  // Supress this warning, since events w/ no vertex are expected
71  //else {
72  //edm::LogError("HeavyIonVertexing") << "No vertex found in collection '" << vertexCollection_ << "'";
73  //}
74 
75  // Get beamspot
77  edm::Handle<reco::BeamSpot> beamSpotHandle;
78  iEvent.getByToken(beamSpotToken_, beamSpotHandle);
79 
80  math::XYZPoint bsPoint(0.0, 0.0, 0.0);
81  double bsWidth = 0.0;
82 
83  if (beamSpotHandle.isValid()) {
84  beamSpot = *beamSpotHandle;
85  bsPoint = beamSpot.position();
86  bsWidth = sqrt(beamSpot.BeamWidthX() * beamSpot.BeamWidthY());
87  edm::LogInfo("HeavyIonVertexing") << "Select prototracks compatible with beamspot"
88  << "\n (x,y,z) = (" << bsPoint.X() << "," << bsPoint.Y() << "," << bsPoint.Z()
89  << ")"
90  << "\n width = " << bsWidth
91  << "\n cut at d0/d0sigma = " << maxD0Significance_;
92  } else {
93  edm::LogError("HeavyIonVertexing") << "No beam spot available from '" << beamSpot_ << "\n";
94  }
95 
96  // Do selection
97  int nSelected = 0;
98  int nRejected = 0;
99  double d0 = 0.0;
100  double d0sigma = 0.0;
101  for (reco::TrackCollection::const_iterator trk = c.begin(); trk != c.end(); ++trk) {
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  nSelected++;
109  selected_.push_back(&*trk);
110  } else
111  nRejected++;
112  }
113 
114  edm::LogInfo("HeavyIonVertexing") << "selected " << nSelected << " prototracks out of " << nRejected + nSelected
115  << "\n";
116  }
117 
118  // iterators over selected objects: collection begin
119  const_iterator begin() const { return selected_.begin(); }
120 
121  // iterators over selected objects: collection end
122  const_iterator end() const { return selected_.end(); }
123 
124  // true if no object has been selected
125  size_t size() const { return selected_.size(); }
126 
127 private:
133  double ptMin_;
134  double nSigmaZ_;
135  double minZCut_;
137 };
138 
139 #endif
HIProtoTrackSelector::selected_
container selected_
Definition: HIProtoTrackSelector.h:128
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
align::BeamSpot
Definition: StructureType.h:89
HIProtoTrackSelector::end
const_iterator end() const
Definition: HIProtoTrackSelector.h:122
HIProtoTrackSelector::beamSpot_
edm::InputTag beamSpot_
Definition: HIProtoTrackSelector.h:131
edm::EDGetTokenT< reco::VertexCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
HIProtoTrackSelector::const_iterator
container::const_iterator const_iterator
Definition: HIProtoTrackSelector.h:35
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
edm::LogInfo
Definition: MessageLogger.h:254
HIProtoTrackSelector::nSigmaZ_
double nSigmaZ_
Definition: HIProtoTrackSelector.h:134
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle< reco::TrackCollection >
HIProtoTrackSelector::begin
const_iterator begin() const
Definition: HIProtoTrackSelector.h:119
HIProtoTrackSelector::minZCut_
double minZCut_
Definition: HIProtoTrackSelector.h:135
HIProtoTrackSelector::select
void select(edm::Handle< reco::TrackCollection > &TCH, const edm::Event &iEvent, const edm::EventSetup &iSetup)
Definition: HIProtoTrackSelector.h:49
Track.h
TrackFwd.h
BeamSpot.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HIProtoTrackSelector::vertexCollectionToken_
edm::EDGetTokenT< reco::VertexCollection > vertexCollectionToken_
Definition: HIProtoTrackSelector.h:130
reco::BeamSpot
Definition: BeamSpot.h:21
HIProtoTrackSelector::vertexCollection_
edm::InputTag vertexCollection_
Definition: HIProtoTrackSelector.h:129
HIProtoTrackSelector::container
std::vector< const reco::Track * > container
Definition: HIProtoTrackSelector.h:32
Vertex.h
HIProtoTrackSelector::ptMin_
double ptMin_
Definition: HIProtoTrackSelector.h:133
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
edm::LogError
Definition: MessageLogger.h:183
Event.h
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
HIProtoTrackSelector::size
size_t size() const
Definition: HIProtoTrackSelector.h:125
InputTag.h
VertexFwd.h
HIProtoTrackSelector::HIProtoTrackSelector
HIProtoTrackSelector(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
Definition: HIProtoTrackSelector.h:38
HIProtoTrackSelector::collection
reco::TrackCollection collection
Definition: HIProtoTrackSelector.h:29
HIProtoTrackSelector
Definition: HIProtoTrackSelector.h:26
ConsumesCollector.h
HIProtoTrackSelector::beamSpotToken_
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
Definition: HIProtoTrackSelector.h:132
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
d0
static constexpr float d0
Definition: L1EGammaCrystalsEmulatorProducer.cc:85
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
HIProtoTrackSelector::maxD0Significance_
double maxD0Significance_
Definition: HIProtoTrackSelector.h:136
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7