CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
AnalyticalTrackSelector Class Referencefinal
Inheritance diagram for AnalyticalTrackSelector:
MultiTrackSelector edm::stream::EDProducer<>

Public Member Functions

 AnalyticalTrackSelector (const edm::ParameterSet &cfg)
 constructor More...
 
 ~AnalyticalTrackSelector () override
 destructor More...
 
- Public Member Functions inherited from MultiTrackSelector
 MultiTrackSelector ()
 constructor More...
 
 MultiTrackSelector (const edm::ParameterSet &cfg)
 
 ~MultiTrackSelector () override
 destructor More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Types

typedef math::XYZPoint Point
 

Private Member Functions

void run (edm::Event &evt, const edm::EventSetup &es) const override
 process one event More...
 

Private Attributes

bool copyExtras_
 copy only the tracks, not extras and rechits (for AOD) More...
 
bool copyTrajectories_
 copy also trajectories and trajectory->track associations More...
 
double maxEta_
 
double minEta_
 eta restrictions More...
 
edm::EDGetTokenT
< TrajTrackAssociationCollection
srcTass_
 
edm::EDGetTokenT< std::vector
< Trajectory > > 
srcTraj_
 

Additional Inherited Members

- Public Types inherited from MultiTrackSelector
using MVACollection = std::vector< float >
 
using QualityMaskCollection = std::vector< unsigned char >
 
- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Protected Types inherited from MultiTrackSelector
typedef math::XYZPoint Point
 
- Protected Member Functions inherited from MultiTrackSelector
void beginStream (edm::StreamID) final
 
Point getBestVertex (const reco::TrackBaseRef, const reco::VertexCollection) const
 
void processMVA (edm::Event &evt, const edm::EventSetup &es, const reco::BeamSpot &beamspot, const reco::VertexCollection &vertices, int selIndex, std::vector< float > &mvaVals_, bool writeIt=false) const
 
void produce (edm::Event &evt, const edm::EventSetup &es) final
 process one event More...
 
bool select (unsigned tsNum, const reco::BeamSpot &vertexBeamSpot, const TrackingRecHitCollection &recHits, const reco::Track &tk, const std::vector< Point > &points, std::vector< float > &vterr, std::vector< float > &vzerr, double mvaVal) const
 return class, or -1 if rejected More...
 
void selectVertices (unsigned int tsNum, const reco::VertexCollection &vtxs, std::vector< Point > &points, std::vector< float > &vterr, std::vector< float > &vzerr) const
 
- Protected Attributes inherited from MultiTrackSelector
std::vector< bool > applyAbsCutsIfNoPV_
 
std::vector< bool > applyAdaptedPVCuts_
 
edm::EDGetTokenT< reco::BeamSpotbeamspot_
 
std::vector< double > chi2n_no1Dmod_par_
 
std::vector< double > chi2n_par_
 
std::vector< std::vector
< double > > 
d0_par1_
 
std::vector< std::vector
< double > > 
d0_par2_
 
std::string dbFileName_
 
std::vector< std::vector
< double > > 
dz_par1_
 
std::vector< std::vector
< double > > 
dz_par2_
 
std::vector< GBRForest * > forest_
 
std::vector< std::string > forestLabel_
 
std::vector< edm::ESGetToken
< GBRForest, GBRWrapperRcd > > 
forestToken_
 
edm::EDGetTokenT
< TrackingRecHitCollection
hSrc_
 
std::vector< bool > keepAllTracks_
 
std::vector< double > max_d0_
 Impact parameter absolute cuts. More...
 
std::vector< double > max_d0NoPV_
 
std::vector< double > max_eta_
 
std::vector< int32_t > max_lostHitFraction_
 
std::vector< uint32_t > max_lostLayers_
 
std::vector< int32_t > max_minMissHitOutOrIn_
 
std::vector< double > max_relpterr_
 
std::vector< double > max_z0_
 
std::vector< double > max_z0NoPV_
 
std::vector< uint32_t > min_3Dlayers_
 
std::vector< double > min_eta_
 
std::vector< uint32_t > min_hits_bypass_
 
std::vector< uint32_t > min_layers_
 Cuts on numbers of layers with hits/3D hits/lost hits. More...
 
std::vector< double > min_MVA_
 
std::vector< uint32_t > min_nhits_
 
std::vector< std::string > mvaType_
 
std::vector< std::string > name_
 
std::vector< double > nSigmaZ_
 
std::vector< unsigned int > preFilter_
 
std::vector
< reco::TrackBase::TrackQuality
qualityToSet_
 
std::vector< std::vector
< double > > 
res_par_
 
std::vector< bool > setQualityBit_
 do I have to set a quality bit? More...
 
edm::EDGetTokenT
< reco::TrackCollection
src_
 source collection label More...
 
bool useAnyMVA_
 
bool useForestFromDB_
 
std::vector< bool > useMVA_
 
std::vector< bool > useMVAonly_
 
bool useVertices_
 
bool useVtxError_
 
std::vector
< StringCutObjectSelector
< reco::Vertex > > 
vertexCut_
 
edm::EDGetTokenT
< reco::VertexCollection
vertices_
 
std::vector< int32_t > vtxNumber_
 vertex cuts More...
 

Detailed Description

selects a subset of a track collection, copying extra information on demand

Author
Paolo Azzurri, Giovanni Petrucciani

Definition at line 35 of file AnalyticalTrackSelector.cc.

Member Typedef Documentation

Definition at line 44 of file AnalyticalTrackSelector.cc.

Constructor & Destructor Documentation

AnalyticalTrackSelector::AnalyticalTrackSelector ( const edm::ParameterSet cfg)
explicit

constructor

Definition at line 66 of file AnalyticalTrackSelector.cc.

References HLT_FULL_cff::alias, MultiTrackSelector::applyAbsCutsIfNoPV_, MultiTrackSelector::applyAdaptedPVCuts_, MultiTrackSelector::beamspot_, MultiTrackSelector::chi2n_no1Dmod_par_, MultiTrackSelector::chi2n_par_, copyExtras_, copyTrajectories_, MultiTrackSelector::d0_par1_, MultiTrackSelector::d0_par2_, MultiTrackSelector::dz_par1_, MultiTrackSelector::dz_par2_, Exception, edm::ParameterSet::exists(), edm::ParameterSet::existsAs(), MultiTrackSelector::forest_, MultiTrackSelector::forestLabel_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), MultiTrackSelector::hSrc_, MultiTrackSelector::keepAllTracks_, MultiTrackSelector::max_d0_, MultiTrackSelector::max_d0NoPV_, MultiTrackSelector::max_eta_, MultiTrackSelector::max_lostHitFraction_, MultiTrackSelector::max_lostLayers_, MultiTrackSelector::max_minMissHitOutOrIn_, MultiTrackSelector::max_relpterr_, MultiTrackSelector::max_z0_, MultiTrackSelector::max_z0NoPV_, MultiTrackSelector::min_3Dlayers_, MultiTrackSelector::min_eta_, MultiTrackSelector::min_hits_bypass_, MultiTrackSelector::min_layers_, MultiTrackSelector::min_MVA_, MultiTrackSelector::min_nhits_, MultiTrackSelector::mvaType_, MultiTrackSelector::nSigmaZ_, MultiTrackSelector::preFilter_, pixelTrack::qualityByName(), MultiTrackSelector::qualityToSet_, MultiTrackSelector::res_par_, MultiTrackSelector::setQualityBit_, findQualityFiles::size, MultiTrackSelector::src_, srcTass_, srcTraj_, AlCaHLTBitMon_QueryRunRegistry::string, MultiTrackSelector::useAnyMVA_, MultiTrackSelector::useMVA_, MultiTrackSelector::useMVAonly_, MultiTrackSelector::useVertices_, MultiTrackSelector::useVtxError_, MultiTrackSelector::vertexCut_, MultiTrackSelector::vertices_, and MultiTrackSelector::vtxNumber_.

66  : MultiTrackSelector() {
67  //Spoof the pset for each track selector!
68  //Size is always 1!!!
69  qualityToSet_.reserve(1);
70  vtxNumber_.reserve(1);
71  vertexCut_.reserve(1);
72  res_par_.reserve(1);
73  chi2n_par_.reserve(1);
74  chi2n_no1Dmod_par_.reserve(1);
75  d0_par1_.reserve(1);
76  dz_par1_.reserve(1);
77  d0_par2_.reserve(1);
78  dz_par2_.reserve(1);
79  applyAdaptedPVCuts_.reserve(1);
80  max_d0_.reserve(1);
81  max_z0_.reserve(1);
82  nSigmaZ_.reserve(1);
83  min_layers_.reserve(1);
84  min_3Dlayers_.reserve(1);
85  max_lostLayers_.reserve(1);
86  min_hits_bypass_.reserve(1);
87  applyAbsCutsIfNoPV_.reserve(1);
88  max_d0NoPV_.reserve(1);
89  max_z0NoPV_.reserve(1);
90  preFilter_.reserve(1);
91  max_relpterr_.reserve(1);
92  min_nhits_.reserve(1);
93  max_minMissHitOutOrIn_.reserve(1);
94  max_lostHitFraction_.reserve(1);
95  min_eta_.reserve(1);
96  max_eta_.reserve(1);
97  forest_.reserve(1);
98  mvaType_.reserve(1);
99  useMVA_.reserve(1);
100 
101  produces<edm::ValueMap<float>>("MVAVals");
102  //foward compatibility
103  produces<MVACollection>("MVAValues");
104  useAnyMVA_ = false;
105  forest_[0] = nullptr;
106  if (cfg.exists("useAnyMVA"))
107  useAnyMVA_ = cfg.getParameter<bool>("useAnyMVA");
108 
109  src_ = consumes<reco::TrackCollection>(cfg.getParameter<edm::InputTag>("src"));
110  hSrc_ = consumes<TrackingRecHitCollection>(cfg.getParameter<edm::InputTag>("src"));
111  beamspot_ = consumes<reco::BeamSpot>(cfg.getParameter<edm::InputTag>("beamspot"));
112  useVertices_ = cfg.getParameter<bool>("useVertices");
113  useVtxError_ = cfg.getParameter<bool>("useVtxError");
114  if (useVertices_)
115  vertices_ = consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>("vertices"));
116  copyExtras_ = cfg.getUntrackedParameter<bool>("copyExtras", false);
117  copyTrajectories_ = cfg.getUntrackedParameter<bool>("copyTrajectories", false);
118  if (copyTrajectories_) {
119  srcTraj_ = consumes<std::vector<Trajectory>>(cfg.getParameter<edm::InputTag>("src"));
120  srcTass_ = consumes<TrajTrackAssociationCollection>(cfg.getParameter<edm::InputTag>("src"));
121  }
122 
123  qualityToSet_.push_back(TrackBase::undefQuality);
124  // parameters for vertex selection
125  vtxNumber_.push_back(useVertices_ ? cfg.getParameter<int32_t>("vtxNumber") : 0);
126  vertexCut_.push_back(useVertices_ ? cfg.getParameter<std::string>("vertexCut") : "");
127  // parameters for adapted optimal cuts on chi2 and primary vertex compatibility
128  res_par_.push_back(cfg.getParameter<std::vector<double>>("res_par"));
129  chi2n_par_.push_back(cfg.getParameter<double>("chi2n_par"));
130  chi2n_no1Dmod_par_.push_back(cfg.getParameter<double>("chi2n_no1Dmod_par"));
131  d0_par1_.push_back(cfg.getParameter<std::vector<double>>("d0_par1"));
132  dz_par1_.push_back(cfg.getParameter<std::vector<double>>("dz_par1"));
133  d0_par2_.push_back(cfg.getParameter<std::vector<double>>("d0_par2"));
134  dz_par2_.push_back(cfg.getParameter<std::vector<double>>("dz_par2"));
135 
136  // Boolean indicating if adapted primary vertex compatibility cuts are to be applied.
137  applyAdaptedPVCuts_.push_back(cfg.getParameter<bool>("applyAdaptedPVCuts"));
138  // Impact parameter absolute cuts.
139  max_d0_.push_back(cfg.getParameter<double>("max_d0"));
140  max_z0_.push_back(cfg.getParameter<double>("max_z0"));
141  nSigmaZ_.push_back(cfg.getParameter<double>("nSigmaZ"));
142  // Cuts on numbers of layers with hits/3D hits/lost hits.
143  min_layers_.push_back(cfg.getParameter<uint32_t>("minNumberLayers"));
144  min_3Dlayers_.push_back(cfg.getParameter<uint32_t>("minNumber3DLayers"));
145  max_lostLayers_.push_back(cfg.getParameter<uint32_t>("maxNumberLostLayers"));
146  min_hits_bypass_.push_back(cfg.getParameter<uint32_t>("minHitsToBypassChecks"));
147  max_relpterr_.push_back(cfg.getParameter<double>("max_relpterr"));
148  min_nhits_.push_back(cfg.getParameter<uint32_t>("min_nhits"));
149  max_minMissHitOutOrIn_.push_back(
150  cfg.existsAs<int32_t>("max_minMissHitOutOrIn") ? cfg.getParameter<int32_t>("max_minMissHitOutOrIn") : 99);
151  max_lostHitFraction_.push_back(
152  cfg.existsAs<double>("max_lostHitFraction") ? cfg.getParameter<double>("max_lostHitFraction") : 1.0);
153  min_eta_.push_back(cfg.getParameter<double>("min_eta"));
154  max_eta_.push_back(cfg.getParameter<double>("max_eta"));
155 
156  // Flag to apply absolute cuts if no PV passes the selection
157  applyAbsCutsIfNoPV_.push_back(cfg.getParameter<bool>("applyAbsCutsIfNoPV"));
158  keepAllTracks_.push_back(cfg.exists("keepAllTracks") ? cfg.getParameter<bool>("keepAllTracks") : false);
159 
160  setQualityBit_.push_back(false);
161  std::string qualityStr = cfg.getParameter<std::string>("qualityBit");
162 
163  if (d0_par1_[0].size() != 2 || dz_par1_[0].size() != 2 || d0_par2_[0].size() != 2 || dz_par2_[0].size() != 2) {
164  edm::LogError("MisConfiguration") << "vector of size less then 2";
165  throw;
166  }
167 
168  if (cfg.exists("qualityBit")) {
169  std::string qualityStr = cfg.getParameter<std::string>("qualityBit");
170  if (!qualityStr.empty()) {
171  setQualityBit_[0] = true;
173  }
174  }
175 
176  if (keepAllTracks_[0] && !setQualityBit_[0])
177  throw cms::Exception("Configuration")
178  << "If you set 'keepAllTracks' to true, you must specify which qualityBit to set.\n";
179  if (setQualityBit_[0] && (qualityToSet_[0] == TrackBase::undefQuality))
180  throw cms::Exception("Configuration")
181  << "You can't set the quality bit " << cfg.getParameter<std::string>("qualityBit")
182  << " as it is 'undefQuality' or unknown.\n";
183  if (applyAbsCutsIfNoPV_[0]) {
184  max_d0NoPV_.push_back(cfg.getParameter<double>("max_d0NoPV"));
185  max_z0NoPV_.push_back(cfg.getParameter<double>("max_z0NoPV"));
186  } else { //dummy values
187  max_d0NoPV_.push_back(0.);
188  max_z0NoPV_.push_back(0.);
189  }
190 
191  if (useAnyMVA_) {
192  bool thisMVA = false;
193  if (cfg.exists("useMVA"))
194  thisMVA = cfg.getParameter<bool>("useMVA");
195  useMVA_.push_back(thisMVA);
196  if (thisMVA) {
197  double minVal = -1;
198  if (cfg.exists("minMVA"))
199  minVal = cfg.getParameter<double>("minMVA");
200  min_MVA_.push_back(minVal);
201  mvaType_.push_back(cfg.exists("mvaType") ? cfg.getParameter<std::string>("mvaType") : "Detached");
202  forestLabel_.push_back(cfg.exists("GBRForestLabel") ? cfg.getParameter<std::string>("GBRForestLabel")
203  : "MVASelectorIter0");
204  useMVAonly_.push_back(cfg.exists("useMVAonly") ? cfg.getParameter<bool>("useMVAonly") : false);
205  } else {
206  min_MVA_.push_back(-9999.0);
207  useMVAonly_.push_back(false);
208  mvaType_.push_back("Detached");
209  forestLabel_.push_back("MVASelectorIter0");
210  }
211  } else {
212  useMVA_.push_back(false);
213  useMVAonly_.push_back(false);
214  min_MVA_.push_back(-9999.0);
215  mvaType_.push_back("Detached");
216  forestLabel_.push_back("MVASelectorIter0");
217  }
218 
219  std::string alias(cfg.getParameter<std::string>("@module_label"));
220  produces<reco::TrackCollection>().setBranchAlias(alias + "Tracks");
221  if (copyExtras_) {
222  produces<reco::TrackExtraCollection>().setBranchAlias(alias + "TrackExtras");
223  produces<TrackingRecHitCollection>().setBranchAlias(alias + "RecHits");
224  }
225  if (copyTrajectories_) {
226  produces<std::vector<Trajectory>>().setBranchAlias(alias + "Trajectories");
227  produces<TrajTrackAssociationCollection>().setBranchAlias(alias + "TrajectoryTrackAssociations");
228  }
229 }
std::vector< uint32_t > min_nhits_
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > max_d0NoPV_
std::vector< double > max_z0_
std::vector< uint32_t > min_layers_
Cuts on numbers of layers with hits/3D hits/lost hits.
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
std::vector< double > max_z0NoPV_
MultiTrackSelector()
constructor
edm::EDGetTokenT< TrajTrackAssociationCollection > srcTass_
std::vector< bool > useMVA_
Quality qualityByName(std::string const &name)
std::vector< bool > keepAllTracks_
std::vector< uint32_t > min_hits_bypass_
bool copyTrajectories_
copy also trajectories and trajectory-&gt;track associations
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< bool > applyAdaptedPVCuts_
std::vector< double > chi2n_no1Dmod_par_
std::vector< double > nSigmaZ_
std::vector< std::string > mvaType_
std::vector< unsigned int > preFilter_
Log< level::Error, false > LogError
edm::EDGetTokenT< TrackingRecHitCollection > hSrc_
edm::EDGetTokenT< std::vector< Trajectory > > srcTraj_
edm::EDGetTokenT< reco::VertexCollection > vertices_
std::vector< uint32_t > min_3Dlayers_
std::vector< uint32_t > max_lostLayers_
std::vector< GBRForest * > forest_
std::vector< int32_t > max_lostHitFraction_
edm::EDGetTokenT< reco::BeamSpot > beamspot_
std::vector< double > min_eta_
std::vector< bool > setQualityBit_
do I have to set a quality bit?
std::vector< std::vector< double > > dz_par1_
std::vector< std::vector< double > > d0_par1_
std::vector< double > max_relpterr_
std::vector< int32_t > vtxNumber_
vertex cuts
std::vector< reco::TrackBase::TrackQuality > qualityToSet_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< std::string > forestLabel_
bool copyExtras_
copy only the tracks, not extras and rechits (for AOD)
std::vector< StringCutObjectSelector< reco::Vertex > > vertexCut_
std::vector< std::vector< double > > dz_par2_
std::vector< bool > applyAbsCutsIfNoPV_
std::vector< int32_t > max_minMissHitOutOrIn_
std::vector< double > min_MVA_
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
std::vector< double > max_d0_
Impact parameter absolute cuts.
std::vector< bool > useMVAonly_
std::vector< std::vector< double > > res_par_
tuple size
Write out results.
std::vector< double > max_eta_
std::vector< double > chi2n_par_
std::vector< std::vector< double > > d0_par2_
AnalyticalTrackSelector::~AnalyticalTrackSelector ( )
override

destructor

Definition at line 231 of file AnalyticalTrackSelector.cc.

231 {}

Member Function Documentation

void AnalyticalTrackSelector::run ( edm::Event evt,
const edm::EventSetup es 
) const
overrideprivatevirtual

process one event

Reimplemented from MultiTrackSelector.

Definition at line 233 of file AnalyticalTrackSelector.cc.

References MultiTrackSelector::beamspot_, edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, copyExtras_, copyTrajectories_, reco::Track::extra(), edm::Event::get(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), MultiTrackSelector::hSrc_, mps_fire::i, reco::Track::innerDetId(), reco::Track::innerMomentum(), reco::Track::innerOk(), reco::Track::innerPosition(), reco::Track::innerStateCovariance(), MultiTrackSelector::keepAllTracks_, edm::Ref< C, T, F >::key(), LogDebug, LogTrace, loose, match(), eostools::move(), dqmiodumpmetadata::n, convertSQLiteXML::ok, reco::Track::outerDetId(), reco::Track::outerMomentum(), reco::Track::outerOk(), reco::Track::outerPosition(), reco::Track::outerStateCovariance(), MultiTrackSelector::processMVA(), reco::TrackBase::pt(), edm::Event::put(), MultiTrackSelector::qualityToSet_, reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), dt_dqm_sourceclient_common_cff::reco, reco::Track::residuals(), reco::Track::seedDirection(), reco::Track::seedRef(), MultiTrackSelector::select(), MultiTrackSelector::selectVertices(), reco::TrackExtraBase::setHits(), MultiTrackSelector::setQualityBit_, reco::TrackExtra::setResiduals(), reco::TrackExtraBase::setTrajParams(), MultiTrackSelector::src_, srcTass_, srcTraj_, MultiTrackSelector::useAnyMVA_, MultiTrackSelector::useVertices_, and MultiTrackSelector::vertices_.

233  {
234  // storage....
235  std::unique_ptr<reco::TrackCollection> selTracks_;
236  std::unique_ptr<reco::TrackExtraCollection> selTrackExtras_;
237  std::unique_ptr<TrackingRecHitCollection> selHits_;
238  std::unique_ptr<std::vector<Trajectory>> selTrajs_;
239  std::unique_ptr<std::vector<const Trajectory*>> selTrajPtrs_;
240  std::unique_ptr<TrajTrackAssociationCollection> selTTAss_;
241  reco::TrackRefProd rTracks_;
242  reco::TrackExtraRefProd rTrackExtras_;
243  TrackingRecHitRefProd rHits_;
244  edm::RefProd<std::vector<Trajectory>> rTrajectories_;
245  std::vector<reco::TrackRef> trackRefs_;
246 
247  using namespace std;
248  using namespace edm;
249  using namespace reco;
250 
251  Handle<TrackCollection> hSrcTrack;
255 
256  // looking for the beam spot
258  evt.getByToken(beamspot_, hBsp);
259  reco::BeamSpot vertexBeamSpot;
260  vertexBeamSpot = *hBsp;
261 
262  // Select good primary vertices for use in subsequent track selection
263  const reco::VertexCollection dummyVtx;
264  const reco::VertexCollection* vtxPtr = &dummyVtx;
265  std::vector<Point> points;
266  std::vector<float> vterr, vzerr;
267  if (useVertices_) {
268  vtxPtr = &evt.get(vertices_);
269  selectVertices(0, *vtxPtr, points, vterr, vzerr);
270  // Debug
271  LogDebug("SelectVertex") << points.size() << " good pixel vertices";
272  }
273 
274  // Get tracks
275  evt.getByToken(src_, hSrcTrack);
276  // get hits in track..
278  evt.getByToken(hSrc_, hSrcHits);
279  const TrackingRecHitCollection& srcHits(*hSrcHits);
280 
281  selTracks_ = std::make_unique<TrackCollection>();
282  rTracks_ = evt.getRefBeforePut<TrackCollection>();
283  if (copyExtras_) {
284  selTrackExtras_ = std::make_unique<TrackExtraCollection>();
285  selHits_ = std::make_unique<TrackingRecHitCollection>();
287  rTrackExtras_ = evt.getRefBeforePut<TrackExtraCollection>();
288  }
289 
290  if (copyTrajectories_)
291  trackRefs_.resize(hSrcTrack->size());
292 
293  std::vector<float> mvaVals_(hSrcTrack->size(), -99.f);
294  processMVA(evt, es, vertexBeamSpot, *vtxPtr, 0, mvaVals_, true);
295 
296  // Loop over tracks
297  size_t current = 0;
298  for (TrackCollection::const_iterator it = hSrcTrack->begin(), ed = hSrcTrack->end(); it != ed; ++it, ++current) {
299  const Track& trk = *it;
300  // Check if this track passes cuts
301 
302  LogTrace("TrackSelection") << "ready to check track with pt=" << trk.pt();
303 
304  float mvaVal = 0;
305  if (useAnyMVA_)
306  mvaVal = mvaVals_[current];
307  bool ok = select(0, vertexBeamSpot, srcHits, trk, points, vterr, vzerr, mvaVal);
308  if (!ok) {
309  LogTrace("TrackSelection") << "track with pt=" << trk.pt() << " NOT selected";
310 
311  if (copyTrajectories_)
312  trackRefs_[current] = reco::TrackRef();
313  if (!keepAllTracks_[0])
314  continue;
315  }
316  LogTrace("TrackSelection") << "track with pt=" << trk.pt() << " selected";
317  selTracks_->push_back(Track(trk)); // clone and store
318  if (ok && setQualityBit_[0]) {
319  selTracks_->back().setQuality(qualityToSet_[0]);
320  if (qualityToSet_[0] == TrackBase::tight) {
321  selTracks_->back().setQuality(TrackBase::loose);
322  } else if (qualityToSet_[0] == TrackBase::highPurity) {
323  selTracks_->back().setQuality(TrackBase::loose);
324  selTracks_->back().setQuality(TrackBase::tight);
325  }
326  if (!points.empty()) {
327  if (qualityToSet_[0] == TrackBase::loose) {
328  selTracks_->back().setQuality(TrackBase::looseSetWithPV);
329  } else if (qualityToSet_[0] == TrackBase::highPurity) {
330  selTracks_->back().setQuality(TrackBase::looseSetWithPV);
331  selTracks_->back().setQuality(TrackBase::highPuritySetWithPV);
332  }
333  }
334  }
335  if (copyExtras_) {
336  // TrackExtras
337  selTrackExtras_->push_back(TrackExtra(trk.outerPosition(),
338  trk.outerMomentum(),
339  trk.outerOk(),
340  trk.innerPosition(),
341  trk.innerMomentum(),
342  trk.innerOk(),
343  trk.outerStateCovariance(),
344  trk.outerDetId(),
345  trk.innerStateCovariance(),
346  trk.innerDetId(),
347  trk.seedDirection(),
348  trk.seedRef()));
349  selTracks_->back().setExtra(TrackExtraRef(rTrackExtras_, selTrackExtras_->size() - 1));
350  TrackExtra& tx = selTrackExtras_->back();
351  tx.setResiduals(trk.residuals());
352  // TrackingRecHits
353  auto const firstHitIndex = selHits_->size();
354  for (trackingRecHit_iterator hit = trk.recHitsBegin(); hit != trk.recHitsEnd(); ++hit) {
355  selHits_->push_back((*hit)->clone());
356  }
357  tx.setHits(rHits_, firstHitIndex, selHits_->size() - firstHitIndex);
358  tx.setTrajParams(trk.extra()->trajParams(), trk.extra()->chi2sX5());
359  }
360  if (copyTrajectories_) {
361  trackRefs_[current] = TrackRef(rTracks_, selTracks_->size() - 1);
362  }
363  }
364  if (copyTrajectories_) {
367  evt.getByToken(srcTass_, hTTAss);
368  evt.getByToken(srcTraj_, hTraj);
369  selTrajs_ = std::make_unique<std::vector<Trajectory>>();
370  rTrajectories_ = evt.getRefBeforePut<vector<Trajectory>>();
371  selTTAss_ = std::make_unique<TrajTrackAssociationCollection>(rTrajectories_, rTracks_);
372  for (size_t i = 0, n = hTraj->size(); i < n; ++i) {
373  Ref<vector<Trajectory>> trajRef(hTraj, i);
375  if (match != hTTAss->end()) {
376  const Ref<TrackCollection>& trkRef = match->val;
377  short oldKey = static_cast<short>(trkRef.key());
378  if (trackRefs_[oldKey].isNonnull()) {
379  selTrajs_->push_back(Trajectory(*trajRef));
380  selTTAss_->insert(Ref<vector<Trajectory>>(rTrajectories_, selTrajs_->size() - 1), trackRefs_[oldKey]);
381  }
382  }
383  }
384  }
385 
386  evt.put(std::move(selTracks_));
387  if (copyExtras_) {
388  evt.put(std::move(selTrackExtras_));
389  evt.put(std::move(selHits_));
390  }
391  if (copyTrajectories_) {
392  evt.put(std::move(selTrajs_));
393  evt.put(std::move(selTTAss_));
394  }
395 }
const edm::RefToBase< TrajectorySeed > & seedRef() const
Definition: Track.h:155
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EDGetTokenT< TrajTrackAssociationCollection > srcTass_
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:139
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::vector< bool > keepAllTracks_
void setHits(TrackingRecHitRefProd const &prod, unsigned firstH, unsigned int nH)
bool select(unsigned tsNum, const reco::BeamSpot &vertexBeamSpot, const TrackingRecHitCollection &recHits, const reco::Track &tk, const std::vector< Point > &points, std::vector< float > &vterr, std::vector< float > &vzerr, double mvaVal) const
return class, or -1 if rejected
bool copyTrajectories_
copy also trajectories and trajectory-&gt;track associations
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
bool innerOk() const
return true if the innermost hit is valid
Definition: Track.h:53
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:16
key_type key() const
Accessor for product key.
Definition: Ref.h:250
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:62
edm::EDGetTokenT< TrackingRecHitCollection > hSrc_
edm::EDGetTokenT< std::vector< Trajectory > > srcTraj_
edm::EDGetTokenT< reco::VertexCollection > vertices_
#define LogTrace(id)
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:56
edm::EDGetTokenT< reco::BeamSpot > beamspot_
std::vector< bool > setQualityBit_
do I have to set a quality bit?
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
Definition: Track.h:68
double pt() const
track transverse momentum
Definition: TrackBase.h:637
def move
Definition: eostools.py:511
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:79
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:88
RefProd< PROD > getRefBeforePut()
Definition: Event.h:158
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:65
void selectVertices(unsigned int tsNum, const reco::VertexCollection &vtxs, std::vector< Point > &points, std::vector< float > &vterr, std::vector< float > &vzerr) const
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:50
const PropagationDirection & seedDirection() const
direction of how the hits were sorted in the original seed
Definition: Track.h:148
std::vector< reco::TrackBase::TrackQuality > qualityToSet_
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
Definition: Track.h:71
bool copyExtras_
copy only the tracks, not extras and rechits (for AOD)
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:59
const TrackResiduals & residuals() const
get the residuals
Definition: Track.h:158
constexpr auto loose
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:82
void processMVA(edm::Event &evt, const edm::EventSetup &es, const reco::BeamSpot &beamspot, const reco::VertexCollection &vertices, int selIndex, std::vector< float > &mvaVals_, bool writeIt=false) const
void setTrajParams(TrajParams tmps, Chi2sFive chi2s)
#define LogDebug(id)
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:91
void setResiduals(const TrackResiduals &r)
set the residuals
Definition: TrackExtra.h:132

Member Data Documentation

bool AnalyticalTrackSelector::copyExtras_
private

copy only the tracks, not extras and rechits (for AOD)

Definition at line 49 of file AnalyticalTrackSelector.cc.

Referenced by AnalyticalTrackSelector(), and run().

bool AnalyticalTrackSelector::copyTrajectories_
private

copy also trajectories and trajectory->track associations

Definition at line 51 of file AnalyticalTrackSelector.cc.

Referenced by AnalyticalTrackSelector(), and run().

double AnalyticalTrackSelector::maxEta_
private

Definition at line 54 of file AnalyticalTrackSelector.cc.

double AnalyticalTrackSelector::minEta_
private

eta restrictions

Definition at line 53 of file AnalyticalTrackSelector.cc.

edm::EDGetTokenT<TrajTrackAssociationCollection> AnalyticalTrackSelector::srcTass_
private

Definition at line 57 of file AnalyticalTrackSelector.cc.

Referenced by AnalyticalTrackSelector(), and run().

edm::EDGetTokenT<std::vector<Trajectory> > AnalyticalTrackSelector::srcTraj_
private

Definition at line 56 of file AnalyticalTrackSelector.cc.

Referenced by AnalyticalTrackSelector(), and run().