CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
HIMultiTrackSelector Class Reference

#include <HIMultiTrackSelector.h>

Inheritance diagram for HIMultiTrackSelector:
edm::stream::EDProducer<>

Public Member Functions

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

Protected Types

typedef math::XYZPoint Point
 

Protected Member Functions

void beginStream (edm::StreamID) final
 
void ParseForestVars ()
 
void processMVA (edm::Event &evt, const edm::EventSetup &es, std::vector< float > &mvaVals_, const reco::VertexCollection &hVtx) const
 
void produce (edm::Event &evt, const edm::EventSetup &es) final
 process one event More...
 
virtual void run (edm::Event &evt, const edm::EventSetup &es) const
 
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

std::vector< bool > applyAbsCutsIfNoPV_
 
std::vector< bool > applyAdaptedPVCuts_
 
bool applyPixelMergingCuts_
 
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_
 
GBRForestforest_
 
std::string forestLabel_
 
std::vector< std::string > forestVars_
 
edm::EDGetTokenT< TrackingRecHitCollectionhSrc_
 
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::string mvaType_
 
std::vector< int > mvavars_indices
 
std::vector< std::string > name_
 
std::vector< double > nSigmaZ_
 
std::vector< std::vector< double > > pixel_pTMaxCut_
 
std::vector< std::vector< double > > pixel_pTMinCut_
 
std::vector< unsigned int > preFilter_
 
std::vector< reco::TrackBase::TrackQualityqualityToSet_
 
std::vector< std::vector< double > > res_par_
 
std::vector< bool > setQualityBit_
 do I have to set a quality bit? More...
 
edm::EDGetTokenT< reco::TrackCollectionsrc_
 source collection label More...
 
bool useAnyMVA_
 
bool useForestFromDB_
 
std::vector< bool > useMVA_
 
bool useVertices_
 
bool useVtxError_
 
std::vector< StringCutObjectSelector< reco::Vertex > > vertexCut_
 
edm::EDGetTokenT< reco::VertexCollectionvertices_
 
std::vector< int32_t > vtxNumber_
 vertex cuts More...
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

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

Author
David Lange

Definition at line 53 of file HIMultiTrackSelector.h.

Member Typedef Documentation

Definition at line 71 of file HIMultiTrackSelector.h.

Constructor & Destructor Documentation

HIMultiTrackSelector::HIMultiTrackSelector ( )
explicit

constructor

Definition at line 74 of file HIMultiTrackSelector.cc.

74  {
75  useForestFromDB_ = true;
76  forest_ = nullptr;
77 }
HIMultiTrackSelector::HIMultiTrackSelector ( const edm::ParameterSet cfg)
explicit

Definition at line 123 of file HIMultiTrackSelector.cc.

References applyAbsCutsIfNoPV_, applyAdaptedPVCuts_, applyPixelMergingCuts_, chi2n_no1Dmod_par_, chi2n_par_, d0_par1_, d0_par2_, dbFileName_, dz_par1_, dz_par2_, Exception, edm::ParameterSet::exists(), forest_, forestLabel_, forestVars_, edm::ParameterSet::getParameter(), mps_fire::i, dqmiolumiharvest::j, keepAllTracks_, max_d0_, max_d0NoPV_, max_eta_, max_lostHitFraction_, max_lostLayers_, max_minMissHitOutOrIn_, max_relpterr_, max_z0_, max_z0NoPV_, min_3Dlayers_, min_eta_, min_hits_bypass_, min_layers_, min_MVA_, min_nhits_, mvaType_, name_, nSigmaZ_, ParseForestVars(), pixel_pTMaxCut_, pixel_pTMinCut_, preFilter_, qualityToSet_, res_par_, setQualityBit_, AlCaHLTBitMon_QueryRunRegistry::string, useAnyMVA_, useForestFromDB_, useMVA_, useVertices_, vertexCut_, vertices_, and vtxNumber_.

124  : src_(consumes<reco::TrackCollection>(cfg.getParameter<edm::InputTag>("src"))),
125  hSrc_(consumes<TrackingRecHitCollection>(cfg.getParameter<edm::InputTag>("src"))),
126  beamspot_(consumes<reco::BeamSpot>(cfg.getParameter<edm::InputTag>("beamspot"))),
127  useVertices_(cfg.getParameter<bool>("useVertices")),
128  useVtxError_(cfg.getParameter<bool>("useVtxError"))
129 // now get the pset for each selector
130 {
131  if (useVertices_)
132  vertices_ = consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>("vertices"));
133 
134  applyPixelMergingCuts_ = false;
135  if (cfg.exists("applyPixelMergingCuts"))
136  applyPixelMergingCuts_ = cfg.getParameter<bool>("applyPixelMergingCuts");
137 
138  useAnyMVA_ = false;
139  forestLabel_ = "MVASelectorIter0";
140  std::string type = "BDTG";
141  useForestFromDB_ = true;
142  dbFileName_ = "";
143 
144  forest_ = nullptr;
145 
146  if (cfg.exists("useAnyMVA"))
147  useAnyMVA_ = cfg.getParameter<bool>("useAnyMVA");
148  if (useAnyMVA_) {
149  if (cfg.exists("mvaType"))
150  type = cfg.getParameter<std::string>("mvaType");
151  if (cfg.exists("GBRForestLabel"))
152  forestLabel_ = cfg.getParameter<std::string>("GBRForestLabel");
153  if (cfg.exists("GBRForestVars")) {
154  forestVars_ = cfg.getParameter<std::vector<std::string>>("GBRForestVars");
155  ParseForestVars();
156  }
157  if (cfg.exists("GBRForestFileName")) {
158  dbFileName_ = cfg.getParameter<std::string>("GBRForestFileName");
159  useForestFromDB_ = false;
160  }
161  mvaType_ = type;
162  }
163  std::vector<edm::ParameterSet> trkSelectors(cfg.getParameter<std::vector<edm::ParameterSet>>("trackSelectors"));
164  qualityToSet_.reserve(trkSelectors.size());
165  vtxNumber_.reserve(trkSelectors.size());
166  vertexCut_.reserve(trkSelectors.size());
167  res_par_.reserve(trkSelectors.size());
168  chi2n_par_.reserve(trkSelectors.size());
169  chi2n_no1Dmod_par_.reserve(trkSelectors.size());
170  d0_par1_.reserve(trkSelectors.size());
171  dz_par1_.reserve(trkSelectors.size());
172  d0_par2_.reserve(trkSelectors.size());
173  dz_par2_.reserve(trkSelectors.size());
174  applyAdaptedPVCuts_.reserve(trkSelectors.size());
175  max_d0_.reserve(trkSelectors.size());
176  max_z0_.reserve(trkSelectors.size());
177  nSigmaZ_.reserve(trkSelectors.size());
178  pixel_pTMinCut_.reserve(trkSelectors.size());
179  pixel_pTMaxCut_.reserve(trkSelectors.size());
180  min_layers_.reserve(trkSelectors.size());
181  min_3Dlayers_.reserve(trkSelectors.size());
182  max_lostLayers_.reserve(trkSelectors.size());
183  min_hits_bypass_.reserve(trkSelectors.size());
184  applyAbsCutsIfNoPV_.reserve(trkSelectors.size());
185  max_d0NoPV_.reserve(trkSelectors.size());
186  max_z0NoPV_.reserve(trkSelectors.size());
187  preFilter_.reserve(trkSelectors.size());
188  max_relpterr_.reserve(trkSelectors.size());
189  min_nhits_.reserve(trkSelectors.size());
190  max_minMissHitOutOrIn_.reserve(trkSelectors.size());
191  max_lostHitFraction_.reserve(trkSelectors.size());
192  min_eta_.reserve(trkSelectors.size());
193  max_eta_.reserve(trkSelectors.size());
194  useMVA_.reserve(trkSelectors.size());
195  //mvaReaders_.reserve(trkSelectors.size());
196  min_MVA_.reserve(trkSelectors.size());
197  //mvaType_.reserve(trkSelectors.size());
198 
199  produces<edm::ValueMap<float>>("MVAVals");
200 
201  for (unsigned int i = 0; i < trkSelectors.size(); i++) {
202  qualityToSet_.push_back(TrackBase::undefQuality);
203  // parameters for vertex selection
204  vtxNumber_.push_back(useVertices_ ? trkSelectors[i].getParameter<int32_t>("vtxNumber") : 0);
205  vertexCut_.push_back(useVertices_ ? trkSelectors[i].getParameter<std::string>("vertexCut") : nullptr);
206  // parameters for adapted optimal cuts on chi2 and primary vertex compatibility
207  res_par_.push_back(trkSelectors[i].getParameter<std::vector<double>>("res_par"));
208  chi2n_par_.push_back(trkSelectors[i].getParameter<double>("chi2n_par"));
209  chi2n_no1Dmod_par_.push_back(trkSelectors[i].getParameter<double>("chi2n_no1Dmod_par"));
210  d0_par1_.push_back(trkSelectors[i].getParameter<std::vector<double>>("d0_par1"));
211  dz_par1_.push_back(trkSelectors[i].getParameter<std::vector<double>>("dz_par1"));
212  d0_par2_.push_back(trkSelectors[i].getParameter<std::vector<double>>("d0_par2"));
213  dz_par2_.push_back(trkSelectors[i].getParameter<std::vector<double>>("dz_par2"));
214  // Boolean indicating if adapted primary vertex compatibility cuts are to be applied.
215  applyAdaptedPVCuts_.push_back(trkSelectors[i].getParameter<bool>("applyAdaptedPVCuts"));
216  // Impact parameter absolute cuts.
217  max_d0_.push_back(trkSelectors[i].getParameter<double>("max_d0"));
218  max_z0_.push_back(trkSelectors[i].getParameter<double>("max_z0"));
219  nSigmaZ_.push_back(trkSelectors[i].getParameter<double>("nSigmaZ"));
220  // Cuts on numbers of layers with hits/3D hits/lost hits.
221  min_layers_.push_back(trkSelectors[i].getParameter<uint32_t>("minNumberLayers"));
222  min_3Dlayers_.push_back(trkSelectors[i].getParameter<uint32_t>("minNumber3DLayers"));
223  max_lostLayers_.push_back(trkSelectors[i].getParameter<uint32_t>("maxNumberLostLayers"));
224  min_hits_bypass_.push_back(trkSelectors[i].getParameter<uint32_t>("minHitsToBypassChecks"));
225  // Flag to apply absolute cuts if no PV passes the selection
226  applyAbsCutsIfNoPV_.push_back(trkSelectors[i].getParameter<bool>("applyAbsCutsIfNoPV"));
227  keepAllTracks_.push_back(trkSelectors[i].getParameter<bool>("keepAllTracks"));
228  max_relpterr_.push_back(trkSelectors[i].getParameter<double>("max_relpterr"));
229  min_nhits_.push_back(trkSelectors[i].getParameter<uint32_t>("min_nhits"));
230  max_minMissHitOutOrIn_.push_back(trkSelectors[i].existsAs<int32_t>("max_minMissHitOutOrIn")
231  ? trkSelectors[i].getParameter<int32_t>("max_minMissHitOutOrIn")
232  : 99);
233  max_lostHitFraction_.push_back(trkSelectors[i].existsAs<double>("max_lostHitFraction")
234  ? trkSelectors[i].getParameter<double>("max_lostHitFraction")
235  : 1.0);
236  min_eta_.push_back(trkSelectors[i].existsAs<double>("min_eta") ? trkSelectors[i].getParameter<double>("min_eta")
237  : -9999);
238  max_eta_.push_back(trkSelectors[i].existsAs<double>("max_eta") ? trkSelectors[i].getParameter<double>("max_eta")
239  : 9999);
240 
241  setQualityBit_.push_back(false);
242  std::string qualityStr = trkSelectors[i].getParameter<std::string>("qualityBit");
243  if (!qualityStr.empty()) {
244  setQualityBit_[i] = true;
245  qualityToSet_[i] = TrackBase::qualityByName(trkSelectors[i].getParameter<std::string>("qualityBit"));
246  }
247 
248  if (setQualityBit_[i] && (qualityToSet_[i] == TrackBase::undefQuality))
249  throw cms::Exception("Configuration")
250  << "You can't set the quality bit " << trkSelectors[i].getParameter<std::string>("qualityBit")
251  << " as it is 'undefQuality' or unknown.\n";
252 
253  if (applyAbsCutsIfNoPV_[i]) {
254  max_d0NoPV_.push_back(trkSelectors[i].getParameter<double>("max_d0NoPV"));
255  max_z0NoPV_.push_back(trkSelectors[i].getParameter<double>("max_z0NoPV"));
256  } else { //dummy values
257  max_d0NoPV_.push_back(0.);
258  max_z0NoPV_.push_back(0.);
259  }
260 
261  name_.push_back(trkSelectors[i].getParameter<std::string>("name"));
262 
263  preFilter_[i] = trkSelectors.size(); // no prefilter
264 
265  std::string pfName = trkSelectors[i].getParameter<std::string>("preFilterName");
266  if (!pfName.empty()) {
267  bool foundPF = false;
268  for (unsigned int j = 0; j < i; j++)
269  if (name_[j] == pfName) {
270  foundPF = true;
271  preFilter_[i] = j;
272  }
273  if (!foundPF)
274  throw cms::Exception("Configuration") << "Invalid prefilter name in HIMultiTrackSelector "
275  << trkSelectors[i].getParameter<std::string>("preFilterName");
276  }
277 
279  pixel_pTMinCut_.push_back(trkSelectors[i].getParameter<std::vector<double>>("pixel_pTMinCut"));
280  pixel_pTMaxCut_.push_back(trkSelectors[i].getParameter<std::vector<double>>("pixel_pTMaxCut"));
281  }
282 
283  // produces<std::vector<int> >(name_[i]).setBranchAlias( name_[i] + "TrackQuals");
284  produces<edm::ValueMap<int>>(name_[i]).setBranchAlias(name_[i] + "TrackQuals");
285  if (useAnyMVA_) {
286  bool thisMVA = false;
287  if (trkSelectors[i].exists("useMVA"))
288  thisMVA = trkSelectors[i].getParameter<bool>("useMVA");
289  useMVA_.push_back(thisMVA);
290  if (thisMVA) {
291  double minVal = -1;
292  if (trkSelectors[i].exists("minMVA"))
293  minVal = trkSelectors[i].getParameter<double>("minMVA");
294  min_MVA_.push_back(minVal);
295 
296  } else {
297  min_MVA_.push_back(-9999.0);
298  }
299  } else {
300  min_MVA_.push_back(-9999.0);
301  }
302  }
303 }
std::vector< std::string > name_
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
std::vector< std::vector< double > > dz_par2_
std::vector< uint32_t > max_lostLayers_
std::vector< std::vector< double > > dz_par1_
std::vector< double > chi2n_no1Dmod_par_
std::vector< uint32_t > min_hits_bypass_
std::vector< std::vector< double > > pixel_pTMaxCut_
std::vector< uint32_t > min_nhits_
std::vector< bool > useMVA_
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< int32_t > max_minMissHitOutOrIn_
std::vector< uint32_t > min_3Dlayers_
std::vector< double > min_eta_
std::vector< double > max_eta_
std::vector< double > max_d0NoPV_
edm::EDGetTokenT< reco::VertexCollection > vertices_
std::vector< StringCutObjectSelector< reco::Vertex > > vertexCut_
std::vector< bool > setQualityBit_
do I have to set a quality bit?
std::vector< std::vector< double > > d0_par1_
std::vector< int32_t > vtxNumber_
vertex cuts
std::vector< double > max_z0_
edm::EDGetTokenT< TrackingRecHitCollection > hSrc_
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
std::vector< double > nSigmaZ_
std::vector< double > max_d0_
Impact parameter absolute cuts.
std::vector< bool > applyAdaptedPVCuts_
std::vector< double > max_relpterr_
std::vector< std::vector< double > > d0_par2_
std::vector< std::string > forestVars_
std::vector< int32_t > max_lostHitFraction_
std::vector< double > chi2n_par_
std::vector< std::vector< double > > res_par_
edm::EDGetTokenT< reco::BeamSpot > beamspot_
std::vector< bool > applyAbsCutsIfNoPV_
std::vector< uint32_t > min_layers_
Cuts on numbers of layers with hits/3D hits/lost hits.
std::vector< std::vector< double > > pixel_pTMinCut_
std::vector< double > max_z0NoPV_
std::vector< bool > keepAllTracks_
std::vector< double > min_MVA_
std::vector< unsigned int > preFilter_
std::vector< reco::TrackBase::TrackQuality > qualityToSet_
HIMultiTrackSelector::~HIMultiTrackSelector ( )
override

destructor

Definition at line 305 of file HIMultiTrackSelector.cc.

References forest_.

305 { delete forest_; }

Member Function Documentation

void HIMultiTrackSelector::beginStream ( edm::StreamID  )
finalprotected

Definition at line 307 of file HIMultiTrackSelector.cc.

References dbFileName_, forest_, forestLabel_, and useForestFromDB_.

307  {
308  if (!useForestFromDB_) {
309  TFile gbrfile(dbFileName_.c_str());
310  forest_ = (GBRForest *)gbrfile.Get(forestLabel_.c_str());
311  }
312 }
void HIMultiTrackSelector::ParseForestVars ( )
protected

Definition at line 79 of file HIMultiTrackSelector.cc.

References chi2n, chi2n_no1dmod, chi2perdofperlayer, dxyperdxyerror, dzperdzerror, PVValHelper::eta, etaerror, mps_fire::i, lostmidfrac, minlost, ndof, nhits, nlayers, nlayers3d, nlayerslost, relpterr, AlCaHLTBitMon_QueryRunRegistry::string, and findQualityFiles::v.

Referenced by HIMultiTrackSelector().

79  {
80  mvavars_indices.clear();
81  for (unsigned i = 0; i < forestVars_.size(); i++) {
83  int ind = -1;
84  if (v == "chi2perdofperlayer")
85  ind = chi2perdofperlayer;
86  if (v == "dxyperdxyerror")
87  ind = dxyperdxyerror;
88  if (v == "dzperdzerror")
89  ind = dzperdzerror;
90  if (v == "relpterr")
91  ind = relpterr;
92  if (v == "lostmidfrac")
93  ind = lostmidfrac;
94  if (v == "minlost")
95  ind = minlost;
96  if (v == "nhits")
97  ind = nhits;
98  if (v == "eta")
99  ind = eta;
100  if (v == "chi2n_no1dmod")
101  ind = chi2n_no1dmod;
102  if (v == "chi2n")
103  ind = chi2n;
104  if (v == "nlayerslost")
105  ind = nlayerslost;
106  if (v == "nlayers3d")
107  ind = nlayers3d;
108  if (v == "nlayers")
109  ind = nlayers;
110  if (v == "ndof")
111  ind = ndof;
112  if (v == "etaerror")
113  ind = etaerror;
114 
115  if (ind == -1)
116  edm::LogWarning("HIMultiTrackSelector")
117  << "Unknown forest variable " << v << ". Please make sure it's in the list of supported variables\n";
118 
119  mvavars_indices.push_back(ind);
120  }
121 }
std::vector< int > mvavars_indices
std::vector< std::string > forestVars_
void HIMultiTrackSelector::processMVA ( edm::Event evt,
const edm::EventSetup es,
std::vector< float > &  mvaVals_,
const reco::VertexCollection hVtx 
) const
protected

Definition at line 635 of file HIMultiTrackSelector.cc.

References hltPixelTracks_cff::chi2, reco::TrackBase::chi2(), chi2n, chi2n_no1dmod, chi2perdofperlayer, DEFINE_FWK_MODULE, TrackingRecHit::dimension(), PVValHelper::dxy, reco::TrackBase::dxy(), reco::TrackBase::dxyError(), dxyperdxyerror, PVValHelper::dz, reco::TrackBase::dz(), reco::TrackBase::dzError(), dzperdzerror, PVValHelper::eta, reco::TrackBase::eta(), etaerror, reco::TrackBase::etaError(), reco::Track::extra(), f, spr::find(), dqmMemoryStats::float, forest_, forestLabel_, edm::EventSetup::get(), edm::Event::getByToken(), GBRForest::GetClassifier(), reco::TrackBase::hitPattern(), hSrc_, mps_fire::i, lostmidfrac, SiStripPI::max, min(), minlost, reco::HitPattern::MISSING_INNER_HITS, reco::HitPattern::MISSING_OUTER_HITS, eostools::move(), mvavars_indices, ndof, reco::TrackBase::ndof(), nhits, nlayers, nlayers3d, nlayerslost, reco::TrackBase::normalizedChi2(), reco::TrackBase::numberOfLostHits(), reco::HitPattern::numberOfLostTrackerHits(), reco::TrackBase::numberOfValidHits(), reco::HitPattern::numberOfValidStripLayersWithMonoAndStereo(), reco::HitPattern::pixelLayersWithMeasurement(), position, edm::ESHandle< T >::product(), reco::TrackBase::pt(), reco::TrackBase::ptError(), edm::Event::put(), reco::Track::recHitsSize(), relpterr, mathSSE::sqrt(), src_, HiCentrality_cfi::srcTracks, reco::HitPattern::TRACK_HITS, reco::HitPattern::trackerLayersWithMeasurement(), reco::HitPattern::trackerLayersWithoutMeasurement(), useAnyMVA_, and useForestFromDB_.

Referenced by run().

638  {
639  using namespace std;
640  using namespace edm;
641  using namespace reco;
642 
643  // Get tracks
644  Handle<TrackCollection> hSrcTrack;
645  evt.getByToken(src_, hSrcTrack);
646  const TrackCollection &srcTracks(*hSrcTrack);
647  assert(mvaVals_.size() == srcTracks.size());
648 
649  // get hits in track..
651  evt.getByToken(hSrc_, hSrcHits);
652  const TrackingRecHitCollection &srcHits(*hSrcHits);
653 
654  auto mvaValValueMap = std::make_unique<edm::ValueMap<float>>();
655  edm::ValueMap<float>::Filler mvaFiller(*mvaValValueMap);
656 
657  if (!useAnyMVA_) {
658  // mvaVals_ already initalized...
659  mvaFiller.insert(hSrcTrack, mvaVals_.begin(), mvaVals_.end());
660  mvaFiller.fill();
661  evt.put(std::move(mvaValValueMap), "MVAVals");
662  return;
663  }
664 
665  bool checkvertex =
668 
669  size_t current = 0;
670  for (TrackCollection::const_iterator it = srcTracks.begin(), ed = srcTracks.end(); it != ed; ++it, ++current) {
671  const Track &trk = *it;
672 
673  float mvavalues[15];
674  mvavalues[ndof] = trk.ndof();
675  mvavalues[nlayers] = trk.hitPattern().trackerLayersWithMeasurement();
676  mvavalues[nlayers3d] =
679  mvavalues[chi2n_no1dmod] = trk.normalizedChi2();
680  mvavalues[chi2perdofperlayer] = mvavalues[chi2n_no1dmod] / mvavalues[nlayers];
681 
682  float chi2n1d = trk.normalizedChi2();
683  int count1dhits = 0;
684  auto ith = trk.extra()->firstRecHit();
685  auto edh = ith + trk.recHitsSize();
686  for (; ith < edh; ++ith) {
687  const TrackingRecHit &hit = srcHits[ith];
688  if (hit.dimension() == 1)
689  ++count1dhits;
690  }
691  if (count1dhits > 0) {
692  float chi2 = trk.chi2();
693  float ndof = trk.ndof();
694  chi2n1d = (chi2 + count1dhits) / float(ndof + count1dhits);
695  }
696 
697  mvavalues[chi2n] = chi2n1d; //chi2 and 1d modes
698 
699  mvavalues[eta] = trk.eta();
700  mvavalues[relpterr] = float(trk.ptError()) / std::max(float(trk.pt()), 0.000001f);
701  mvavalues[nhits] = trk.numberOfValidHits();
702 
705  mvavalues[minlost] = std::min(lostIn, lostOut);
706  mvavalues[lostmidfrac] = trk.numberOfLostHits() / (trk.numberOfValidHits() + trk.numberOfLostHits());
707 
708  mvavalues[etaerror] = trk.etaError();
709 
710  float reldz = 0;
711  float reldxy = 0;
712  if (checkvertex) {
713  int vtxind = 0; // only first vertex is taken into account for the speed purposes
714  float dxy = trk.dxy(vertices[vtxind].position()),
715  dxyE = sqrt(trk.dxyError() * trk.dxyError() + vertices[vtxind].xError() * vertices[vtxind].yError());
716  float dz = trk.dz(vertices[vtxind].position()),
717  dzE = sqrt(trk.dzError() * trk.dzError() + vertices[vtxind].zError() * vertices[vtxind].zError());
718  reldz = dz / dzE;
719  reldxy = dxy / dxyE;
720  }
721  mvavalues[dxyperdxyerror] = reldxy;
722  mvavalues[dzperdzerror] = reldz;
723 
724  std::vector<float> gbrValues;
725 
726  //fill in the gbrValues vector with the necessary variables
727  for (unsigned i = 0; i < mvavars_indices.size(); i++) {
728  gbrValues.push_back(mvavalues[mvavars_indices[i]]);
729  }
730 
731  GBRForest const *forest = forest_;
732  if (useForestFromDB_) {
733  edm::ESHandle<GBRForest> forestHandle;
734  es.get<GBRWrapperRcd>().get(forestLabel_, forestHandle);
735  forest = forestHandle.product();
736  }
737 
738  auto gbrVal = forest->GetClassifier(&gbrValues[0]);
739  mvaVals_[current] = gbrVal;
740  }
741  mvaFiller.insert(hSrcTrack, mvaVals_.begin(), mvaVals_.end());
742  mvaFiller.fill();
743  evt.put(std::move(mvaValValueMap), "MVAVals");
744 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
const TrackExtraRef & extra() const
reference to "extra" object
Definition: Track.h:139
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
Definition: TrackBase.h:572
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
double dxyError() const
error on dxy
Definition: TrackBase.h:716
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:97
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
double etaError() const
error on eta
Definition: TrackBase.h:710
unsigned short numberOfLostHits() const
number of cases where track crossed a layer without getting a hit.
Definition: TrackBase.h:743
int pixelLayersWithMeasurement() const
Definition: HitPattern.cc:492
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:513
int numberOfLostTrackerHits(HitCategory category) const
Definition: HitPattern.h:863
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:617
int numberOfValidStripLayersWithMonoAndStereo(uint16_t stripdet, uint16_t layer) const
Definition: HitPattern.cc:348
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:566
double ndof() const
number of degrees of freedom of the fit
Definition: TrackBase.h:569
T sqrt(T t)
Definition: SSEVec.h:19
virtual int dimension() const =0
double pt() const
track transverse momentum
Definition: TrackBase.h:602
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:696
double f[11][100]
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:740
edm::EDGetTokenT< TrackingRecHitCollection > hSrc_
T min(T a, T b)
Definition: MathUtil.h:58
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:596
double dzError() const
error on dz
Definition: TrackBase.h:725
std::vector< int > mvavars_indices
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:483
int trackerLayersWithoutMeasurement(HitCategory category) const
Definition: HitPattern.cc:532
fixed size matrix
HLT enums.
static int position[264][3]
Definition: ReadPGInfo.cc:289
T get() const
Definition: EventSetup.h:73
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:587
double GetClassifier(const float *vector) const
Definition: GBRForest.h:34
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511
void HIMultiTrackSelector::produce ( edm::Event evt,
const edm::EventSetup es 
)
inlinefinalprotected

process one event

Definition at line 73 of file HIMultiTrackSelector.h.

References HLT_2018_cff::points, FastTrackerRecHitMaskProducer_cfi::recHits, writedatasetfile::run, and singleTopDQM_cfi::select.

73 { run(evt, es); }
virtual void run(edm::Event &evt, const edm::EventSetup &es) const
void HIMultiTrackSelector::run ( edm::Event evt,
const edm::EventSetup es 
) const
protectedvirtual

Definition at line 314 of file HIMultiTrackSelector.cc.

References beamspot_, trigObjTnPSource_cfi::filler, edm::Event::getByToken(), tkConvValidator_cfi::highPurity, hSrc_, mps_fire::i, dqmiolumiharvest::j, keepAllTracks_, LogTrace, eostools::move(), name_, convertSQLiteXML::ok, HLT_2018_cff::points, preFilter_, processMVA(), reco::TrackBase::pt(), edm::Event::put(), reco::TrackBase::qualityMask(), qualityToSet_, select(), selectVertices(), setQualityBit_, src_, HiCentrality_cfi::srcTracks, useAnyMVA_, useVertices_, and vertices_.

314  {
315  using namespace std;
316  using namespace edm;
317  using namespace reco;
318 
319  // Get tracks
320  Handle<TrackCollection> hSrcTrack;
321  evt.getByToken(src_, hSrcTrack);
322  const TrackCollection &srcTracks(*hSrcTrack);
323 
324  // get hits in track..
326  evt.getByToken(hSrc_, hSrcHits);
327  const TrackingRecHitCollection &srcHits(*hSrcHits);
328 
329  // looking for the beam spot
331  evt.getByToken(beamspot_, hBsp);
332  const reco::BeamSpot &vertexBeamSpot(*hBsp);
333 
334  // Select good primary vertices for use in subsequent track selection
336  if (useVertices_)
337  evt.getByToken(vertices_, hVtx);
338 
339  unsigned int trkSize = srcTracks.size();
340  std::vector<int> selTracksSave(qualityToSet_.size() * trkSize, 0);
341 
342  std::vector<float> mvaVals_(srcTracks.size(), -99.f);
343  processMVA(evt, es, mvaVals_, *hVtx);
344 
345  for (unsigned int i = 0; i < qualityToSet_.size(); i++) {
346  std::vector<int> selTracks(trkSize, 0);
347  auto selTracksValueMap = std::make_unique<edm::ValueMap<int>>();
348  edm::ValueMap<int>::Filler filler(*selTracksValueMap);
349 
350  std::vector<Point> points;
351  std::vector<float> vterr, vzerr;
352  if (useVertices_)
353  selectVertices(i, *hVtx, points, vterr, vzerr);
354 
355  // Loop over tracks
356  size_t current = 0;
357  for (TrackCollection::const_iterator it = srcTracks.begin(), ed = srcTracks.end(); it != ed; ++it, ++current) {
358  const Track &trk = *it;
359  // Check if this track passes cuts
360 
361  LogTrace("TrackSelection") << "ready to check track with pt=" << trk.pt();
362 
363  //already removed
364  bool ok = true;
365  float mvaVal = 0;
366  if (preFilter_[i] < i && selTracksSave[preFilter_[i] * trkSize + current] < 0) {
367  selTracks[current] = -1;
368  ok = false;
369  if (!keepAllTracks_[i])
370  continue;
371  } else {
372  if (useAnyMVA_)
373  mvaVal = mvaVals_[current];
374  ok = select(i, vertexBeamSpot, srcHits, trk, points, vterr, vzerr, mvaVal);
375  if (!ok) {
376  LogTrace("TrackSelection") << "track with pt=" << trk.pt() << " NOT selected";
377  if (!keepAllTracks_[i]) {
378  selTracks[current] = -1;
379  continue;
380  }
381  } else
382  LogTrace("TrackSelection") << "track with pt=" << trk.pt() << " selected";
383  }
384 
385  if (preFilter_[i] < i) {
386  selTracks[current] = selTracksSave[preFilter_[i] * trkSize + current];
387  } else {
388  selTracks[current] = trk.qualityMask();
389  }
390  if (ok && setQualityBit_[i]) {
391  selTracks[current] = (selTracks[current] | (1 << qualityToSet_[i]));
392  if (qualityToSet_[i] == TrackBase::tight) {
393  selTracks[current] = (selTracks[current] | (1 << TrackBase::loose));
394  } else if (qualityToSet_[i] == TrackBase::highPurity) {
395  selTracks[current] = (selTracks[current] | (1 << TrackBase::loose));
396  selTracks[current] = (selTracks[current] | (1 << TrackBase::tight));
397  }
398 
399  if (!points.empty()) {
400  if (qualityToSet_[i] == TrackBase::loose) {
401  selTracks[current] = (selTracks[current] | (1 << TrackBase::looseSetWithPV));
402  } else if (qualityToSet_[i] == TrackBase::highPurity) {
403  selTracks[current] = (selTracks[current] | (1 << TrackBase::looseSetWithPV));
404  selTracks[current] = (selTracks[current] | (1 << TrackBase::highPuritySetWithPV));
405  }
406  }
407  }
408  }
409  for (unsigned int j = 0; j < trkSize; j++)
410  selTracksSave[j + i * trkSize] = selTracks[j];
411  filler.insert(hSrcTrack, selTracks.begin(), selTracks.end());
412  filler.fill();
413 
414  // evt.put(std::move(selTracks),name_[i]);
415  evt.put(std::move(selTracksValueMap), name_[i]);
416  }
417 }
std::vector< std::string > name_
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
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
void selectVertices(unsigned int tsNum, const reco::VertexCollection &vtxs, std::vector< Point > &points, std::vector< float > &vterr, std::vector< float > &vzerr) const
edm::EDGetTokenT< reco::VertexCollection > vertices_
std::vector< bool > setQualityBit_
do I have to set a quality bit?
double pt() const
track transverse momentum
Definition: TrackBase.h:602
int qualityMask() const
Definition: TrackBase.h:773
edm::EDGetTokenT< TrackingRecHitCollection > hSrc_
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
#define LogTrace(id)
void processMVA(edm::Event &evt, const edm::EventSetup &es, std::vector< float > &mvaVals_, const reco::VertexCollection &hVtx) const
edm::EDGetTokenT< reco::BeamSpot > beamspot_
fixed size matrix
HLT enums.
std::vector< bool > keepAllTracks_
std::vector< unsigned int > preFilter_
std::vector< reco::TrackBase::TrackQuality > qualityToSet_
def move(src, dest)
Definition: eostools.py:511
bool HIMultiTrackSelector::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
protected

return class, or -1 if rejected

Definition at line 419 of file HIMultiTrackSelector.cc.

References funct::abs(), applyAbsCutsIfNoPV_, applyAdaptedPVCuts_, applyPixelMergingCuts_, hltPixelTracks_cff::chi2, reco::TrackBase::chi2(), chi2n, chi2n_no1Dmod_par_, chi2n_par_, HLTMuonOfflineAnalyzer_cfi::d0, d0_par1_, d0_par2_, TrackSplittingMonitor_cfi::d0Cut, reco::TrackBase::d0Error(), TrackingRecHit::dimension(), reco::TrackBase::dxy(), PVValHelper::dz, reco::TrackBase::dz(), dz_par1_, dz_par2_, TrackSplittingMonitor_cfi::dzCut, reco::TrackBase::dzError(), end, PVValHelper::eta, reco::TrackBase::eta(), reco::Track::extra(), f, dqmMemoryStats::float, reco::TrackBase::hitPattern(), LogDebug, LogTrace, SiStripPI::max, max_d0_, max_d0NoPV_, max_eta_, max_lostHitFraction_, max_lostLayers_, max_minMissHitOutOrIn_, max_relpterr_, max_z0_, max_z0NoPV_, min(), min_3Dlayers_, min_eta_, min_hits_bypass_, min_layers_, min_MVA_, min_nhits_, reco::HitPattern::MISSING_INNER_HITS, reco::HitPattern::MISSING_OUTER_HITS, ndof, reco::TrackBase::ndof(), nhits, nlayers, reco::TrackBase::normalizedChi2(), nSigmaZ_, reco::TrackBase::numberOfLostHits(), reco::HitPattern::numberOfLostTrackerHits(), reco::TrackBase::numberOfValidHits(), reco::HitPattern::numberOfValidStripLayersWithMonoAndStereo(), pixel_pTMaxCut_, pixel_pTMinCut_, reco::HitPattern::pixelLayersWithMeasurement(), point, reco::BeamSpot::position(), funct::pow(), DiDispStaMuonMonitor_cfi::pt, reco::TrackBase::pt(), reco::TrackBase::ptError(), reco::Track::recHitsSize(), relpterr, res_par_, reco::BeamSpot::sigmaZ(), mathSSE::sqrt(), reco::HitPattern::TRACK_HITS, reco::HitPattern::trackerLayersWithMeasurement(), reco::HitPattern::trackerLayersWithoutMeasurement(), useAnyMVA_, useMVA_, and useVtxError_.

Referenced by run().

426  {
427  // Decide if the given track passes selection cuts.
428 
429  using namespace std;
430 
431  //cuts on number of valid hits
432  auto nhits = tk.numberOfValidHits();
433  if (nhits >= min_hits_bypass_[tsNum])
434  return true;
435  if (nhits < min_nhits_[tsNum])
436  return false;
437 
438  if (tk.ndof() < 1E-5)
439  return false;
440 
442  //Adding the MVA selection before any other cut//
444  if (useAnyMVA_ && useMVA_[tsNum]) {
445  if (mvaVal < min_MVA_[tsNum])
446  return false;
447  else
448  return true;
449  }
451  //End of MVA selection section//
453 
454  // Cuts on numbers of layers with hits/3D hits/lost hits.
456  uint32_t nlayers3D =
459  LogDebug("TrackSelection") << "cuts on nlayers: " << nlayers << " " << nlayers3D << " " << nlayersLost << " vs "
460  << min_layers_[tsNum] << " " << min_3Dlayers_[tsNum] << " " << max_lostLayers_[tsNum];
461  if (nlayers < min_layers_[tsNum])
462  return false;
463  if (nlayers3D < min_3Dlayers_[tsNum])
464  return false;
465  if (nlayersLost > max_lostLayers_[tsNum])
466  return false;
467  LogTrace("TrackSelection") << "cuts on nlayers passed";
468 
469  float chi2n = tk.normalizedChi2();
470  float chi2n_no1Dmod = chi2n;
471 
472  int count1dhits = 0;
473  auto ith = tk.extra()->firstRecHit();
474  auto edh = ith + tk.recHitsSize();
475  for (; ith < edh; ++ith) {
476  const TrackingRecHit &hit = recHits[ith];
477  if (hit.dimension() == 1)
478  ++count1dhits;
479  }
480  if (count1dhits > 0) {
481  float chi2 = tk.chi2();
482  float ndof = tk.ndof();
483  chi2n = (chi2 + count1dhits) / float(ndof + count1dhits);
484  }
485  // For each 1D rechit, the chi^2 and ndof is increased by one. This is a way of retaining approximately
486  // the same normalized chi^2 distribution as with 2D rechits.
487  if (chi2n > chi2n_par_[tsNum] * nlayers)
488  return false;
489 
490  if (chi2n_no1Dmod > chi2n_no1Dmod_par_[tsNum] * nlayers)
491  return false;
492 
493  // Get track parameters
494  float pt = std::max(float(tk.pt()), 0.000001f);
495  float eta = tk.eta();
496  if (eta < min_eta_[tsNum] || eta > max_eta_[tsNum])
497  return false;
498 
499  //cuts on relative error on pt
500  float relpterr = float(tk.ptError()) / pt;
501  if (relpterr > max_relpterr_[tsNum])
502  return false;
503 
506  int minLost = std::min(lostIn, lostOut);
507  if (minLost > max_minMissHitOutOrIn_[tsNum])
508  return false;
509  float lostMidFrac =
510  tk.numberOfLostHits() == 0 ? 0. : tk.numberOfLostHits() / (tk.numberOfValidHits() + tk.numberOfLostHits());
511  if (lostMidFrac > max_lostHitFraction_[tsNum])
512  return false;
513 
514  // Pixel Track Merging pT dependent cuts
516  // hard cut at absolute min/max pt
517  if (pt < pixel_pTMinCut_[tsNum][0])
518  return false;
519  if (pt > pixel_pTMaxCut_[tsNum][0])
520  return false;
521  // tapering cuts with chi2n_no1Dmod
522  double pTMaxCutPos = (pixel_pTMaxCut_[tsNum][0] - pt) / (pixel_pTMaxCut_[tsNum][0] - pixel_pTMaxCut_[tsNum][1]);
523  double pTMinCutPos = (pt - pixel_pTMinCut_[tsNum][0]) / (pixel_pTMinCut_[tsNum][1] - pixel_pTMinCut_[tsNum][0]);
524  if (pt > pixel_pTMaxCut_[tsNum][1] &&
525  chi2n_no1Dmod > pixel_pTMaxCut_[tsNum][2] * nlayers * pow(pTMaxCutPos, pixel_pTMaxCut_[tsNum][3]))
526  return false;
527  if (pt < pixel_pTMinCut_[tsNum][1] &&
528  chi2n_no1Dmod > pixel_pTMinCut_[tsNum][2] * nlayers * pow(pTMinCutPos, pixel_pTMinCut_[tsNum][3]))
529  return false;
530  }
531 
532  //other track parameters
533  float d0 = -tk.dxy(vertexBeamSpot.position()), d0E = tk.d0Error(), dz = tk.dz(vertexBeamSpot.position()),
534  dzE = tk.dzError();
535 
536  // parametrized d0 resolution for the track pt
537  float nomd0E = sqrt(res_par_[tsNum][0] * res_par_[tsNum][0] + (res_par_[tsNum][1] / pt) * (res_par_[tsNum][1] / pt));
538  // parametrized z0 resolution for the track pt and eta
539  float nomdzE = nomd0E * (std::cosh(eta));
540 
541  float dzCut = std::min(powN(dz_par1_[tsNum][0] * nlayers, int(dz_par1_[tsNum][1] + 0.5)) * nomdzE,
542  powN(dz_par2_[tsNum][0] * nlayers, int(dz_par2_[tsNum][1] + 0.5)) * dzE);
543  float d0Cut = std::min(powN(d0_par1_[tsNum][0] * nlayers, int(d0_par1_[tsNum][1] + 0.5)) * nomd0E,
544  powN(d0_par2_[tsNum][0] * nlayers, int(d0_par2_[tsNum][1] + 0.5)) * d0E);
545 
546  // ---- PrimaryVertex compatibility cut
547  bool primaryVertexZCompatibility(false);
548  bool primaryVertexD0Compatibility(false);
549 
550  if (points.empty()) { //If not primaryVertices are reconstructed, check just the compatibility with the BS
551  //z0 within (n sigma + dzCut) of the beam spot z, if no good vertex is found
552  if (abs(dz) < hypot(vertexBeamSpot.sigmaZ() * nSigmaZ_[tsNum], dzCut))
553  primaryVertexZCompatibility = true;
554  // d0 compatibility with beam line
555  if (abs(d0) < d0Cut)
556  primaryVertexD0Compatibility = true;
557  }
558 
559  int iv = 0;
560  for (std::vector<Point>::const_iterator point = points.begin(), end = points.end(); point != end; ++point) {
561  LogTrace("TrackSelection") << "Test track w.r.t. vertex with z position " << point->z();
562  if (primaryVertexZCompatibility && primaryVertexD0Compatibility)
563  break;
564  float dzPV = tk.dz(*point); //re-evaluate the dz with respect to the vertex position
565  float d0PV = tk.dxy(*point); //re-evaluate the dxy with respect to the vertex position
566  if (useVtxError_) {
567  float dzErrPV = std::sqrt(dzE * dzE + vzerr[iv] * vzerr[iv]); // include vertex error in z
568  float d0ErrPV = std::sqrt(d0E * d0E + vterr[iv] * vterr[iv]); // include vertex error in xy
569  iv++;
570  if (abs(dzPV) < dz_par1_[tsNum][0] * pow(nlayers, dz_par1_[tsNum][1]) * nomdzE &&
571  abs(dzPV) < dz_par2_[tsNum][0] * pow(nlayers, dz_par2_[tsNum][1]) * dzErrPV && abs(dzPV) < max_z0_[tsNum])
572  primaryVertexZCompatibility = true;
573  if (abs(d0PV) < d0_par1_[tsNum][0] * pow(nlayers, d0_par1_[tsNum][1]) * nomd0E &&
574  abs(d0PV) < d0_par2_[tsNum][0] * pow(nlayers, d0_par2_[tsNum][1]) * d0ErrPV && abs(d0PV) < max_d0_[tsNum])
575  primaryVertexD0Compatibility = true;
576  } else {
577  if (abs(dzPV) < dzCut)
578  primaryVertexZCompatibility = true;
579  if (abs(d0PV) < d0Cut)
580  primaryVertexD0Compatibility = true;
581  }
582  LogTrace("TrackSelection") << "distances " << dzPV << " " << d0PV << " vs " << dzCut << " " << d0Cut;
583  }
584 
585  if (points.empty() && applyAbsCutsIfNoPV_[tsNum]) {
586  if (abs(dz) > max_z0NoPV_[tsNum] || abs(d0) > max_d0NoPV_[tsNum])
587  return false;
588  } else {
589  // Absolute cuts on all tracks impact parameters with respect to beam-spot.
590  // If BS is not compatible, verify if at least the reco-vertex is compatible (useful for incorrect BS settings)
591  if (abs(d0) > max_d0_[tsNum] && !primaryVertexD0Compatibility)
592  return false;
593  LogTrace("TrackSelection") << "absolute cuts on d0 passed";
594  if (abs(dz) > max_z0_[tsNum] && !primaryVertexZCompatibility)
595  return false;
596  LogTrace("TrackSelection") << "absolute cuts on dz passed";
597  }
598 
599  LogTrace("TrackSelection") << "cuts on PV: apply adapted PV cuts? " << applyAdaptedPVCuts_[tsNum]
600  << " d0 compatibility? " << primaryVertexD0Compatibility << " z compatibility? "
601  << primaryVertexZCompatibility;
602 
603  if (applyAdaptedPVCuts_[tsNum]) {
604  return (primaryVertexD0Compatibility && primaryVertexZCompatibility);
605  } else {
606  return true;
607  }
608 }
#define LogDebug(id)
std::vector< std::vector< double > > dz_par2_
double d0Error() const
error on d0
Definition: TrackBase.h:719
std::vector< uint32_t > max_lostLayers_
std::vector< std::vector< double > > dz_par1_
std::vector< double > chi2n_no1Dmod_par_
std::vector< uint32_t > min_hits_bypass_
const TrackExtraRef & extra() const
reference to "extra" object
Definition: Track.h:139
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
Definition: TrackBase.h:572
std::vector< std::vector< double > > pixel_pTMaxCut_
std::vector< uint32_t > min_nhits_
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:97
std::vector< bool > useMVA_
unsigned short numberOfLostHits() const
number of cases where track crossed a layer without getting a hit.
Definition: TrackBase.h:743
std::vector< int32_t > max_minMissHitOutOrIn_
std::vector< uint32_t > min_3Dlayers_
int pixelLayersWithMeasurement() const
Definition: HitPattern.cc:492
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:513
std::vector< double > min_eta_
int numberOfLostTrackerHits(HitCategory category) const
Definition: HitPattern.h:863
std::vector< double > max_eta_
std::vector< double > max_d0NoPV_
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:617
int numberOfValidStripLayersWithMonoAndStereo(uint16_t stripdet, uint16_t layer) const
Definition: HitPattern.cc:348
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:566
double ndof() const
number of degrees of freedom of the fit
Definition: TrackBase.h:569
T sqrt(T t)
Definition: SSEVec.h:19
virtual int dimension() const =0
double pt() const
track transverse momentum
Definition: TrackBase.h:602
std::vector< std::vector< double > > d0_par1_
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:696
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > max_z0_
double f[11][100]
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:740
#define end
Definition: vmac.h:39
T min(T a, T b)
Definition: MathUtil.h:58
#define LogTrace(id)
std::vector< double > nSigmaZ_
std::vector< double > max_d0_
Impact parameter absolute cuts.
std::vector< bool > applyAdaptedPVCuts_
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:596
double dzError() const
error on dz
Definition: TrackBase.h:725
std::vector< double > max_relpterr_
std::vector< std::vector< double > > d0_par2_
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:483
double sigmaZ() const
sigma z
Definition: BeamSpot.h:76
std::vector< int32_t > max_lostHitFraction_
std::vector< double > chi2n_par_
std::vector< std::vector< double > > res_par_
std::vector< bool > applyAbsCutsIfNoPV_
int trackerLayersWithoutMeasurement(HitCategory category) const
Definition: HitPattern.cc:532
std::vector< uint32_t > min_layers_
Cuts on numbers of layers with hits/3D hits/lost hits.
std::vector< std::vector< double > > pixel_pTMinCut_
std::vector< double > max_z0NoPV_
const Point & position() const
position
Definition: BeamSpot.h:59
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:587
std::vector< double > min_MVA_
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
void HIMultiTrackSelector::selectVertices ( unsigned int  tsNum,
const reco::VertexCollection vtxs,
std::vector< Point > &  points,
std::vector< float > &  vterr,
std::vector< float > &  vzerr 
) const
protected

Definition at line 610 of file HIMultiTrackSelector.cc.

References LogDebug, LogTrace, mathSSE::sqrt(), vertexCut_, badGlobalMuonTaggersAOD_cff::vtx, and vtxNumber_.

Referenced by run().

614  {
615  // Select good primary vertices
616  using namespace reco;
617  int32_t toTake = vtxNumber_[tsNum];
618  for (VertexCollection::const_iterator it = vtxs.begin(), ed = vtxs.end(); it != ed; ++it) {
619  LogDebug("SelectVertex") << " select vertex with z position " << it->z() << " " << it->chi2() << " " << it->ndof()
620  << " " << TMath::Prob(it->chi2(), static_cast<int32_t>(it->ndof()));
621  Vertex vtx = *it;
622  bool pass = vertexCut_[tsNum](vtx);
623  if (pass) {
624  points.push_back(it->position());
625  vterr.push_back(sqrt(it->yError() * it->xError()));
626  vzerr.push_back(it->zError());
627  LogTrace("SelectVertex") << " SELECTED vertex with z position " << it->z();
628  toTake--;
629  if (toTake == 0)
630  break;
631  }
632  }
633 }
#define LogDebug(id)
std::vector< StringCutObjectSelector< reco::Vertex > > vertexCut_
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< int32_t > vtxNumber_
vertex cuts
#define LogTrace(id)
fixed size matrix

Member Data Documentation

std::vector<bool> HIMultiTrackSelector::applyAbsCutsIfNoPV_
protected

Definition at line 157 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<bool> HIMultiTrackSelector::applyAdaptedPVCuts_
protected

Definition at line 127 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

bool HIMultiTrackSelector::applyPixelMergingCuts_
protected

Definition at line 107 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

edm::EDGetTokenT<reco::BeamSpot> HIMultiTrackSelector::beamspot_
protected

Definition at line 100 of file HIMultiTrackSelector.h.

Referenced by run().

std::vector<double> HIMultiTrackSelector::chi2n_no1Dmod_par_
protected

Definition at line 121 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<double> HIMultiTrackSelector::chi2n_par_
protected

Definition at line 120 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<std::vector<double> > HIMultiTrackSelector::d0_par1_
protected

Definition at line 122 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<std::vector<double> > HIMultiTrackSelector::d0_par2_
protected

Definition at line 124 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::string HIMultiTrackSelector::dbFileName_
protected

Definition at line 179 of file HIMultiTrackSelector.h.

Referenced by beginStream(), and HIMultiTrackSelector().

std::vector<std::vector<double> > HIMultiTrackSelector::dz_par1_
protected

Definition at line 123 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<std::vector<double> > HIMultiTrackSelector::dz_par2_
protected

Definition at line 125 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

GBRForest* HIMultiTrackSelector::forest_
protected
std::string HIMultiTrackSelector::forestLabel_
protected

Definition at line 175 of file HIMultiTrackSelector.h.

Referenced by beginStream(), HIMultiTrackSelector(), and processMVA().

std::vector<std::string> HIMultiTrackSelector::forestVars_
protected

Definition at line 176 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector().

edm::EDGetTokenT<TrackingRecHitCollection> HIMultiTrackSelector::hSrc_
protected

Definition at line 99 of file HIMultiTrackSelector.h.

Referenced by processMVA(), and run().

std::vector<bool> HIMultiTrackSelector::keepAllTracks_
protected

Definition at line 159 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and run().

std::vector<double> HIMultiTrackSelector::max_d0_
protected

Impact parameter absolute cuts.

Definition at line 130 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<double> HIMultiTrackSelector::max_d0NoPV_
protected

Definition at line 155 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<double> HIMultiTrackSelector::max_eta_
protected

Definition at line 152 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<int32_t> HIMultiTrackSelector::max_lostHitFraction_
protected

Definition at line 149 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<uint32_t> HIMultiTrackSelector::max_lostLayers_
protected

Definition at line 141 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<int32_t> HIMultiTrackSelector::max_minMissHitOutOrIn_
protected

Definition at line 148 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<double> HIMultiTrackSelector::max_relpterr_
protected

Definition at line 145 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<double> HIMultiTrackSelector::max_z0_
protected

Definition at line 131 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<double> HIMultiTrackSelector::max_z0NoPV_
protected

Definition at line 156 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<uint32_t> HIMultiTrackSelector::min_3Dlayers_
protected

Definition at line 140 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<double> HIMultiTrackSelector::min_eta_
protected

Definition at line 151 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<uint32_t> HIMultiTrackSelector::min_hits_bypass_
protected

Definition at line 142 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<uint32_t> HIMultiTrackSelector::min_layers_
protected

Cuts on numbers of layers with hits/3D hits/lost hits.

Definition at line 139 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<double> HIMultiTrackSelector::min_MVA_
protected

Definition at line 171 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<uint32_t> HIMultiTrackSelector::min_nhits_
protected

Definition at line 146 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::string HIMultiTrackSelector::mvaType_
protected

Definition at line 174 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector().

std::vector<int> HIMultiTrackSelector::mvavars_indices
protected

Definition at line 169 of file HIMultiTrackSelector.h.

Referenced by processMVA().

std::vector<std::string> HIMultiTrackSelector::name_
protected

Definition at line 163 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and run().

std::vector<double> HIMultiTrackSelector::nSigmaZ_
protected

Definition at line 132 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<std::vector<double> > HIMultiTrackSelector::pixel_pTMaxCut_
protected

Definition at line 136 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<std::vector<double> > HIMultiTrackSelector::pixel_pTMinCut_
protected

Definition at line 135 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<unsigned int> HIMultiTrackSelector::preFilter_
protected

Definition at line 162 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and run().

std::vector<reco::TrackBase::TrackQuality> HIMultiTrackSelector::qualityToSet_
protected

Definition at line 111 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and run().

std::vector<std::vector<double> > HIMultiTrackSelector::res_par_
protected

Definition at line 119 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::vector<bool> HIMultiTrackSelector::setQualityBit_
protected

do I have to set a quality bit?

Definition at line 110 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and run().

edm::EDGetTokenT<reco::TrackCollection> HIMultiTrackSelector::src_
protected

source collection label

Definition at line 98 of file HIMultiTrackSelector.h.

Referenced by processMVA(), and run().

bool HIMultiTrackSelector::useAnyMVA_
protected

Definition at line 103 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), processMVA(), run(), and select().

bool HIMultiTrackSelector::useForestFromDB_
protected

Definition at line 178 of file HIMultiTrackSelector.h.

Referenced by beginStream(), HIMultiTrackSelector(), and processMVA().

std::vector<bool> HIMultiTrackSelector::useMVA_
protected

Definition at line 166 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

bool HIMultiTrackSelector::useVertices_
protected

Definition at line 101 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and run().

bool HIMultiTrackSelector::useVtxError_
protected

Definition at line 102 of file HIMultiTrackSelector.h.

Referenced by select().

std::vector<StringCutObjectSelector<reco::Vertex> > HIMultiTrackSelector::vertexCut_
protected

Definition at line 116 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and selectVertices().

edm::EDGetTokenT<reco::VertexCollection> HIMultiTrackSelector::vertices_
protected

Definition at line 104 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and run().

std::vector<int32_t> HIMultiTrackSelector::vtxNumber_
protected

vertex cuts

Definition at line 114 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and selectVertices().