CMS 3D CMS Logo

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

#include <MultiTrackSelector.h>

Inheritance diagram for MultiTrackSelector:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper AnalyticalTrackSelector

Public Types

using MVACollection = std::vector< float >
 
using QualityMaskCollection = std::vector< unsigned char >
 
- 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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 MultiTrackSelector ()
 constructor More...
 
 MultiTrackSelector (const edm::ParameterSet &cfg)
 
virtual ~MultiTrackSelector ()
 destructor More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Types

typedef math::XYZPoint Point
 

Protected Member Functions

void beginStream (edm::StreamID) override 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) override 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 Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Protected Attributes

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_
 
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::vector< std::string > mvaType_
 
std::vector< std::string > name_
 
std::vector< double > nSigmaZ_
 
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_
 
std::vector< bool > useMVAonly_
 
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

- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Detailed Description

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

Author
David Lange

Definition at line 35 of file MultiTrackSelector.h.

Member Typedef Documentation

using MultiTrackSelector::MVACollection = std::vector<float>

Definition at line 44 of file MultiTrackSelector.h.

Definition at line 57 of file MultiTrackSelector.h.

using MultiTrackSelector::QualityMaskCollection = std::vector<unsigned char>

Definition at line 45 of file MultiTrackSelector.h.

Constructor & Destructor Documentation

MultiTrackSelector::MultiTrackSelector ( )
explicit

constructor

Definition at line 17 of file MultiTrackSelector.cc.

18 {
19  useForestFromDB_ = true;
20 }
MultiTrackSelector::MultiTrackSelector ( const edm::ParameterSet cfg)
explicit

Definition at line 22 of file MultiTrackSelector.cc.

References applyAbsCutsIfNoPV_, applyAdaptedPVCuts_, chi2n_no1Dmod_par_, chi2n_par_, d0_par1_, d0_par2_, dbFileName_, dz_par1_, dz_par2_, Exception, edm::ParameterSet::exists(), forest_, forestLabel_, edm::ParameterSet::getParameter(), mps_fire::i, 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_, preFilter_, qualityToSet_, res_par_, setQualityBit_, AlCaHLTBitMon_QueryRunRegistry::string, useAnyMVA_, useForestFromDB_, useMVA_, useMVAonly_, useVertices_, useVtxError_, vertexCut_, vertices_, and vtxNumber_.

22  :
23  src_( consumes<reco::TrackCollection>( cfg.getParameter<edm::InputTag>( "src" ) ) ),
24  hSrc_(consumes<TrackingRecHitCollection>( cfg.getParameter<edm::InputTag>( "src" ) ) ),
25  beamspot_( consumes<reco::BeamSpot>( cfg.getParameter<edm::InputTag>( "beamspot" ) ) ),
26  useVertices_( cfg.getParameter<bool>( "useVertices" ) ),
27  useVtxError_( cfg.getParameter<bool>( "useVtxError" ) )
28  // now get the pset for each selector
29 {
30  if (useVertices_) vertices_ = consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>( "vertices" ));
31  if(useVtxError_){
32  edm::LogWarning("MultiTRackSelector") << "you are executing buggy code, if intentional please help to fix it";
33  }
34  useAnyMVA_ = false;
35  useForestFromDB_ = true;
36  dbFileName_ = "";
37 
38  if(cfg.exists("useAnyMVA")) useAnyMVA_ = cfg.getParameter<bool>("useAnyMVA");
39 
40  if(useAnyMVA_){
41  if(cfg.exists("GBRForestFileName")){
42  dbFileName_ = cfg.getParameter<std::string>("GBRForestFileName");
43  useForestFromDB_ = false;
44  }
45  }
46  std::vector<edm::ParameterSet> trkSelectors( cfg.getParameter<std::vector< edm::ParameterSet> >("trackSelectors") );
47  qualityToSet_.reserve(trkSelectors.size());
48  vtxNumber_.reserve(trkSelectors.size());
49  vertexCut_.reserve(trkSelectors.size());
50  res_par_.reserve(trkSelectors.size());
51  chi2n_par_.reserve(trkSelectors.size());
52  chi2n_no1Dmod_par_.reserve(trkSelectors.size());
53  d0_par1_.reserve(trkSelectors.size());
54  dz_par1_.reserve(trkSelectors.size());
55  d0_par2_.reserve(trkSelectors.size());
56  dz_par2_.reserve(trkSelectors.size());
57  applyAdaptedPVCuts_.reserve(trkSelectors.size());
58  max_d0_.reserve(trkSelectors.size());
59  max_z0_.reserve(trkSelectors.size());
60  nSigmaZ_.reserve(trkSelectors.size());
61  min_layers_.reserve(trkSelectors.size());
62  min_3Dlayers_.reserve(trkSelectors.size());
63  max_lostLayers_.reserve(trkSelectors.size());
64  min_hits_bypass_.reserve(trkSelectors.size());
65  applyAbsCutsIfNoPV_.reserve(trkSelectors.size());
66  max_d0NoPV_.reserve(trkSelectors.size());
67  max_z0NoPV_.reserve(trkSelectors.size());
68  preFilter_.reserve(trkSelectors.size());
69  max_relpterr_.reserve(trkSelectors.size());
70  min_nhits_.reserve(trkSelectors.size());
71  max_minMissHitOutOrIn_.reserve(trkSelectors.size());
72  max_lostHitFraction_.reserve(trkSelectors.size());
73  min_eta_.reserve(trkSelectors.size());
74  max_eta_.reserve(trkSelectors.size());
75  useMVA_.reserve(trkSelectors.size());
76  useMVAonly_.reserve(trkSelectors.size());
77  //mvaReaders_.reserve(trkSelectors.size());
78  min_MVA_.reserve(trkSelectors.size());
79  mvaType_.reserve(trkSelectors.size());
80  forestLabel_.reserve(trkSelectors.size());
81  forest_.reserve(trkSelectors.size());
82 
83  produces<edm::ValueMap<float> >("MVAVals");
84 
85  //foward compatibility
86  produces<MVACollection>("MVAValues");
87 
88 
89  for ( unsigned int i=0; i<trkSelectors.size(); i++) {
90 
91  qualityToSet_.push_back( TrackBase::undefQuality );
92  // parameters for vertex selection
93  vtxNumber_.push_back( useVertices_ ? trkSelectors[i].getParameter<int32_t>("vtxNumber") : 0 );
94  vertexCut_.push_back( useVertices_ ? trkSelectors[i].getParameter<std::string>("vertexCut") : 0);
95  // parameters for adapted optimal cuts on chi2 and primary vertex compatibility
96  res_par_.push_back(trkSelectors[i].getParameter< std::vector<double> >("res_par") );
97  chi2n_par_.push_back( trkSelectors[i].getParameter<double>("chi2n_par") );
98  chi2n_no1Dmod_par_.push_back( trkSelectors[i].getParameter<double>("chi2n_no1Dmod_par") );
99  d0_par1_.push_back(trkSelectors[i].getParameter< std::vector<double> >("d0_par1"));
100  dz_par1_.push_back(trkSelectors[i].getParameter< std::vector<double> >("dz_par1"));
101  d0_par2_.push_back(trkSelectors[i].getParameter< std::vector<double> >("d0_par2"));
102  dz_par2_.push_back(trkSelectors[i].getParameter< std::vector<double> >("dz_par2"));
103  // Boolean indicating if adapted primary vertex compatibility cuts are to be applied.
104  applyAdaptedPVCuts_.push_back(trkSelectors[i].getParameter<bool>("applyAdaptedPVCuts"));
105  // Impact parameter absolute cuts.
106  max_d0_.push_back(trkSelectors[i].getParameter<double>("max_d0"));
107  max_z0_.push_back(trkSelectors[i].getParameter<double>("max_z0"));
108  nSigmaZ_.push_back(trkSelectors[i].getParameter<double>("nSigmaZ"));
109  // Cuts on numbers of layers with hits/3D hits/lost hits.
110  min_layers_.push_back(trkSelectors[i].getParameter<uint32_t>("minNumberLayers") );
111  min_3Dlayers_.push_back(trkSelectors[i].getParameter<uint32_t>("minNumber3DLayers") );
112  max_lostLayers_.push_back(trkSelectors[i].getParameter<uint32_t>("maxNumberLostLayers"));
113  min_hits_bypass_.push_back(trkSelectors[i].getParameter<uint32_t>("minHitsToBypassChecks"));
114  // Flag to apply absolute cuts if no PV passes the selection
115  applyAbsCutsIfNoPV_.push_back(trkSelectors[i].getParameter<bool>("applyAbsCutsIfNoPV"));
116  keepAllTracks_.push_back( trkSelectors[i].getParameter<bool>("keepAllTracks"));
117  max_relpterr_.push_back(trkSelectors[i].getParameter<double>("max_relpterr"));
118  min_nhits_.push_back(trkSelectors[i].getParameter<uint32_t>("min_nhits"));
119  max_minMissHitOutOrIn_.push_back(
120  trkSelectors[i].existsAs<int32_t>("max_minMissHitOutOrIn") ?
121  trkSelectors[i].getParameter<int32_t>("max_minMissHitOutOrIn") : 99);
122  max_lostHitFraction_.push_back(
123  trkSelectors[i].existsAs<double>("max_lostHitFraction") ?
124  trkSelectors[i].getParameter<double>("max_lostHitFraction") : 1.0);
125  min_eta_.push_back(trkSelectors[i].existsAs<double>("min_eta") ?
126  trkSelectors[i].getParameter<double>("min_eta"):-9999);
127  max_eta_.push_back(trkSelectors[i].existsAs<double>("max_eta") ?
128  trkSelectors[i].getParameter<double>("max_eta"):9999);
129 
130  setQualityBit_.push_back( false );
131  std::string qualityStr = trkSelectors[i].getParameter<std::string>("qualityBit");
132  if (qualityStr != "") {
133  setQualityBit_[i] = true;
134  qualityToSet_[i] = TrackBase::qualityByName(trkSelectors[i].getParameter<std::string>("qualityBit"));
135  }
136 
137  if (setQualityBit_[i] && (qualityToSet_[i] == TrackBase::undefQuality)) throw cms::Exception("Configuration") <<
138  "You can't set the quality bit " << trkSelectors[i].getParameter<std::string>("qualityBit") << " as it is 'undefQuality' or unknown.\n";
139 
140  if (applyAbsCutsIfNoPV_[i]) {
141  max_d0NoPV_.push_back(trkSelectors[i].getParameter<double>("max_d0NoPV"));
142  max_z0NoPV_.push_back(trkSelectors[i].getParameter<double>("max_z0NoPV"));
143  }
144  else{//dummy values
145  max_d0NoPV_.push_back(0.);
146  max_z0NoPV_.push_back(0.);
147  }
148 
149  name_.push_back( trkSelectors[i].getParameter<std::string>("name") );
150 
151  preFilter_[i]=trkSelectors.size(); // no prefilter
152 
153  std::string pfName=trkSelectors[i].getParameter<std::string>("preFilterName");
154  if (pfName!="") {
155  bool foundPF=false;
156  for ( unsigned int j=0; j<i; j++)
157  if (name_[j]==pfName ) {
158  foundPF=true;
159  preFilter_[i]=j;
160  }
161  if ( !foundPF)
162  throw cms::Exception("Configuration") << "Invalid prefilter name in MultiTrackSelector "
163  << trkSelectors[i].getParameter<std::string>("preFilterName");
164 
165  }
166 
167  // produces<std::vector<int> >(name_[i]).setBranchAlias( name_[i] + "TrackQuals");
168  produces<edm::ValueMap<int> >(name_[i]).setBranchAlias( name_[i] + "TrackQuals");
169  produces<QualityMaskCollection>(name_[i]).setBranchAlias( name_[i] + "QualityMasks");
170  if(useAnyMVA_){
171  bool thisMVA = false;
172  if(trkSelectors[i].exists("useMVA"))thisMVA = trkSelectors[i].getParameter<bool>("useMVA");
173  useMVA_.push_back(thisMVA);
174  if(thisMVA){
175  double minVal = -1;
176  if(trkSelectors[i].exists("minMVA"))minVal = trkSelectors[i].getParameter<double>("minMVA");
177  min_MVA_.push_back(minVal);
178  mvaType_.push_back(trkSelectors[i].exists("mvaType") ? trkSelectors[i].getParameter<std::string>("mvaType") : "Detached");
179  forestLabel_.push_back(trkSelectors[i].exists("GBRForestLabel") ? trkSelectors[i].getParameter<std::string>("GBRForestLabel") : "MVASelectorIter0");
180  useMVAonly_.push_back(trkSelectors[i].exists("useMVAonly") ? trkSelectors[i].getParameter<bool>("useMVAonly") : false);
181  }else{
182  min_MVA_.push_back(-9999.0);
183  useMVAonly_.push_back(false);
184  mvaType_.push_back("Detached");
185  forestLabel_.push_back("MVASelectorIter0");
186  }
187  }else{
188  useMVA_.push_back(false);
189  useMVAonly_.push_back(false);
190  min_MVA_.push_back(-9999.0);
191  mvaType_.push_back("Detached");
192  forestLabel_.push_back("MVASelectorIter0");
193  }
194 
195  }
196 }
std::vector< double > chi2n_no1Dmod_par_
T getParameter(std::string const &) const
std::vector< uint32_t > min_nhits_
std::vector< double > chi2n_par_
std::vector< std::vector< double > > d0_par1_
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.
std::vector< std::string > name_
std::vector< double > max_z0NoPV_
std::vector< bool > useMVA_
std::vector< bool > keepAllTracks_
std::vector< uint32_t > min_hits_bypass_
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< bool > applyAdaptedPVCuts_
std::vector< double > nSigmaZ_
std::vector< std::string > mvaType_
std::vector< unsigned int > preFilter_
edm::EDGetTokenT< TrackingRecHitCollection > hSrc_
edm::EDGetTokenT< reco::VertexCollection > vertices_
std::vector< uint32_t > min_3Dlayers_
std::vector< uint32_t > max_lostLayers_
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 > > dz_par2_
std::vector< std::vector< double > > res_par_
std::vector< double > max_relpterr_
std::vector< int32_t > vtxNumber_
vertex cuts
std::vector< reco::TrackBase::TrackQuality > qualityToSet_
std::vector< std::string > forestLabel_
std::vector< StringCutObjectSelector< reco::Vertex > > vertexCut_
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< std::vector< double > > d0_par2_
std::vector< double > max_d0_
Impact parameter absolute cuts.
std::vector< bool > useMVAonly_
std::vector< double > max_eta_
std::vector< GBRForest * > forest_
MultiTrackSelector::~MultiTrackSelector ( )
virtual

destructor

Definition at line 198 of file MultiTrackSelector.cc.

References forest_.

198  {
199  for(auto forest : forest_)delete forest;
200 }
std::vector< GBRForest * > forest_

Member Function Documentation

void MultiTrackSelector::beginStream ( edm::StreamID  )
finaloverrideprotectedvirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 203 of file MultiTrackSelector.cc.

References dbFileName_, forest_, forestLabel_, mps_fire::i, createfilelist::int, and useForestFromDB_.

203  {
204  if(!useForestFromDB_){
205  TFile gbrfile(dbFileName_.c_str());
206  for(int i = 0; i < (int)forestLabel_.size(); i++){
207  forest_[i] = (GBRForest*)gbrfile.Get(forestLabel_[i].c_str());
208  }
209  }
210 
211 }
std::vector< std::string > forestLabel_
std::vector< GBRForest * > forest_
MultiTrackSelector::Point MultiTrackSelector::getBestVertex ( const reco::TrackBaseRef  track,
const reco::VertexCollection  vertices 
) const
protected

Definition at line 636 of file MultiTrackSelector.cc.

References DEFINE_FWK_MODULE, allConversions_cfi::dz, reco::TrackBase::dz(), edm::RefToBase< T >::get(), AlCaHLTBitMon_ParallelJobs::p, and w.

Referenced by processMVA().

636  {
637  Point p(0,0,-99999);
638  Point p_dz(0,0,-99999);
639  float bestWeight = 0;
640  float dzmin = 10000;
641  bool weightMatch = false;
642  for(auto const & vertex : vertices){
643  float w = vertex.trackWeight(track);
644  Point v_pos = vertex.position();
645  if(w > bestWeight){
646  p = v_pos;
647  bestWeight = w;
648  weightMatch = true;
649  }
650  float dz = fabs(track.get()->dz(v_pos));
651  if(dz < dzmin){
652  p_dz = v_pos;
653  dzmin = dz;
654  }
655  }
656  if(weightMatch)return p;
657  else return p_dz;
658 }
value_type const * get() const
Definition: RefToBase.h:234
const double w
Definition: UKUtility.cc:23
math::XYZPoint Point
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:604
void MultiTrackSelector::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
protected

Definition at line 513 of file MultiTrackSelector.cc.

References HiEvtPlane_cfi::chi2, reco::TrackBase::chi2(), chi2n, TrackingRecHit::dimension(), reco::TrackBase::dxy(), reco::TrackBase::dz(), reco::TrackBase::eta(), reco::Track::extra(), f, objects.autophobj::float, forest_, forestLabel_, edm::EventSetup::get(), getBestVertex(), edm::Event::getByToken(), GBRForest::GetClassifier(), reco::TrackBase::hitPattern(), hSrc_, hpstanc_transforms::max, min(), reco::HitPattern::MISSING_INNER_HITS, reco::HitPattern::MISSING_OUTER_HITS, eostools::move(), RecoTauHPSTancTauProdcuer_cfi::mvas, mvaType_, ndof, reco::TrackBase::ndof(), reco::TrackBase::normalizedChi2(), reco::TrackBase::numberOfLostHits(), reco::HitPattern::numberOfLostTrackerHits(), reco::TrackBase::numberOfValidHits(), reco::HitPattern::numberOfValidStripLayersWithMonoAndStereo(), reco::HitPattern::pixelLayersWithMeasurement(), reco::BeamSpot::position(), edm::ESHandle< T >::product(), reco::TrackBase::pt(), reco::TrackBase::ptError(), edm::Event::put(), reco::Track::recHitsSize(), src_, HiCentrality_cfi::srcTracks, reco::HitPattern::TRACK_HITS, reco::HitPattern::trackerLayersWithMeasurement(), reco::HitPattern::trackerLayersWithoutMeasurement(), useAnyMVA_, useForestFromDB_, and useMVA_.

Referenced by AnalyticalTrackSelector::run(), and run().

514 {
515 
516  using namespace std;
517  using namespace edm;
518  using namespace reco;
519 
520  // Get tracks
521  Handle<TrackCollection> hSrcTrack;
522  evt.getByToken( src_, hSrcTrack );
523  const TrackCollection& srcTracks(*hSrcTrack);
524  RefToBaseProd<Track> rtbpTrackCollection(hSrcTrack);
525  assert(mvaVals_.size()==srcTracks.size());
526 
527  // get hits in track..
529  evt.getByToken( hSrc_, hSrcHits );
530  const TrackingRecHitCollection & srcHits(*hSrcHits);
531 
532 
533  auto mvaValValueMap = std::make_unique<edm::ValueMap<float>>();
534  edm::ValueMap<float>::Filler mvaFiller(*mvaValValueMap);
535 
536 
537  if(!useAnyMVA_ && writeIt){
538  // mvaVals_ already initalized...
539  mvaFiller.insert(hSrcTrack,mvaVals_.begin(),mvaVals_.end());
540  mvaFiller.fill();
541  evt.put(std::move(mvaValValueMap),"MVAVals");
542  auto mvas = std::make_unique<MVACollection>(mvaVals_.begin(),mvaVals_.end());
543  evt.put(std::move(mvas),"MVAValues");
544  return;
545  }
546 
547  if(!useMVA_[selIndex] && !writeIt)return;
548 
549 
550  size_t current = 0;
551  for (TrackCollection::const_iterator it = srcTracks.begin(), ed = srcTracks.end(); it != ed; ++it, ++current) {
552  const Track & trk = * it;
553  RefToBase<Track> trackRef(rtbpTrackCollection,current);
554  auto tmva_ndof_ = trk.ndof();
555  auto tmva_nlayers_ = trk.hitPattern().trackerLayersWithMeasurement();
556  auto tmva_nlayers3D_ = trk.hitPattern().pixelLayersWithMeasurement()
559  float chi2n = trk.normalizedChi2();
560  float chi2n_no1Dmod = chi2n;
561 
562  int count1dhits = 0;
563  auto ith = trk.extra()->firstRecHit();
564  auto edh = ith + trk.recHitsSize();
565  for (; ith<edh; ++ith) {
566  const TrackingRecHit & hit = srcHits[ith];
567  if (hit.dimension()==1) ++count1dhits;
568  }
569  if (count1dhits > 0) {
570  float chi2 = trk.chi2();
571  float ndof = trk.ndof();
572  chi2n = (chi2+count1dhits)/float(ndof+count1dhits);
573  }
574  auto tmva_chi2n_ = chi2n;
575  auto tmva_chi2n_no1dmod_ = chi2n_no1Dmod;
576  auto tmva_eta_ = trk.eta();
577  auto tmva_relpterr_ = float(trk.ptError())/std::max(float(trk.pt()),0.000001f);
578  auto tmva_nhits_ = trk.numberOfValidHits();
581  auto tmva_minlost_ = std::min(lostIn,lostOut);
582  auto tmva_lostmidfrac_ = trk.numberOfLostHits() / (trk.numberOfValidHits() + trk.numberOfLostHits());
583  auto tmva_absd0_ = fabs(-trk.dxy(beamspot.position()));
584  auto tmva_absdz_ = fabs(trk.dz(beamspot.position()));
585  Point bestVertex = getBestVertex(trackRef,vertices);
586  auto tmva_absd0PV_ = fabs(trk.dxy(bestVertex));
587  auto tmva_absdzPV_ = fabs(trk.dz(bestVertex));
588  auto tmva_pt_ = trk.pt();
589 
590  GBRForest const * forest = forest_[selIndex];
591  if(useForestFromDB_){
592  edm::ESHandle<GBRForest> forestHandle;
593  es.get<GBRWrapperRcd>().get(forestLabel_[selIndex],forestHandle);
594  forest = forestHandle.product();
595  }
596 
597  float gbrVals_[16];
598  gbrVals_[0] = tmva_pt_;
599  gbrVals_[1] = tmva_lostmidfrac_;
600  gbrVals_[2] = tmva_minlost_;
601  gbrVals_[3] = tmva_nhits_;
602  gbrVals_[4] = tmva_relpterr_;
603  gbrVals_[5] = tmva_eta_;
604  gbrVals_[6] = tmva_chi2n_no1dmod_;
605  gbrVals_[7] = tmva_chi2n_;
606  gbrVals_[8] = tmva_nlayerslost_;
607  gbrVals_[9] = tmva_nlayers3D_;
608  gbrVals_[10] = tmva_nlayers_;
609  gbrVals_[11] = tmva_ndof_;
610  gbrVals_[12] = tmva_absd0PV_;
611  gbrVals_[13] = tmva_absdzPV_;
612  gbrVals_[14] = tmva_absdz_;
613  gbrVals_[15] = tmva_absd0_;
614 
615  if (mvaType_[selIndex] == "Prompt"){
616  auto gbrVal = forest->GetClassifier(gbrVals_);
617  mvaVals_[current] = gbrVal;
618  }else{
619  float detachedGbrVals_[12];
620  for(int jjj = 0; jjj < 12; jjj++)detachedGbrVals_[jjj] = gbrVals_[jjj];
621  auto gbrVal = forest->GetClassifier(detachedGbrVals_);
622  mvaVals_[current] = gbrVal;
623  }
624  }
625 
626  if(writeIt){
627  mvaFiller.insert(hSrcTrack,mvaVals_.begin(),mvaVals_.end());
628  mvaFiller.fill();
629  evt.put(std::move(mvaValValueMap),"MVAVals");
630  auto mvas = std::make_unique<MVACollection>(mvaVals_.begin(),mvaVals_.end());
631  evt.put(std::move(mvas),"MVAValues");
632  }
633 
634 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
const TrackExtraRef & extra() const
reference to "extra" object
Definition: Track.h:189
std::vector< bool > useMVA_
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:556
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:119
Point getBestVertex(const reco::TrackBaseRef, const reco::VertexCollection) const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
unsigned short numberOfLostHits() const
number of cases where track crossed a layer without getting a hit.
Definition: TrackBase.h:821
std::vector< std::string > mvaType_
int pixelLayersWithMeasurement() const
Definition: HitPattern.cc:499
edm::EDGetTokenT< TrackingRecHitCollection > hSrc_
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:518
int numberOfLostTrackerHits(HitCategory category) const
Definition: HitPattern.h:907
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:646
int numberOfValidStripLayersWithMonoAndStereo(uint16_t stripdet, uint16_t layer) const
Definition: HitPattern.cc:341
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:544
double ndof() const
number of degrees of freedom of the fit
Definition: TrackBase.h:550
virtual int dimension() const =0
double pt() const
track transverse momentum
Definition: TrackBase.h:616
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:758
math::XYZPoint Point
double f[11][100]
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:815
T min(T a, T b)
Definition: MathUtil.h:58
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:604
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:445
const T & get() const
Definition: EventSetup.h:56
std::vector< std::string > forestLabel_
int trackerLayersWithoutMeasurement(HitCategory category) const
Definition: HitPattern.cc:535
fixed size matrix
HLT enums.
const Point & position() const
position
Definition: BeamSpot.h:62
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
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:586
double GetClassifier(const float *vector) const
Definition: GBRForest.h:43
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510
std::vector< GBRForest * > forest_
void MultiTrackSelector::produce ( edm::Event evt,
const edm::EventSetup es 
)
inlinefinaloverrideprotected

process one event

Definition at line 59 of file MultiTrackSelector.h.

References hiMultiTrackSelector_cfi::beamspot, getBestVertex(), findQualityFiles::run, TauGenJetsDecayModeSelectorAllHadrons_cfi::select, and primaryVertexAssociation_cfi::vertices.

59  {
60  run(evt,es);
61  }
virtual void run(edm::Event &evt, const edm::EventSetup &es) const
void MultiTrackSelector::run ( edm::Event evt,
const edm::EventSetup es 
) const
protectedvirtual

Reimplemented in AnalyticalTrackSelector.

Definition at line 215 of file MultiTrackSelector.cc.

References beamspot_, edm::HandleBase::failedToGet(), objects.autophobj::filler, edm::Event::getByToken(), tkConvValidator_cfi::highPurity, hSrc_, mps_fire::i, keepAllTracks_, LogTrace, hpstanc_transforms::max, eostools::move(), name_, convertSQLiteXML::ok, preFilter_, processMVA(), edm::Handle< T >::product(), reco::TrackBase::pt(), edm::Event::put(), lumiQueryAPI::q, reco::TrackBase::qualityMask(), qualityToSet_, select(), selectVertices(), setQualityBit_, src_, HiCentrality_cfi::srcTracks, useAnyMVA_, useVertices_, and vertices_.

216 {
217  using namespace std;
218  using namespace edm;
219  using namespace reco;
220 
221  // Get tracks
222  Handle<TrackCollection> hSrcTrack;
223  evt.getByToken(src_, hSrcTrack );
224 
225  const TrackCollection& srcTracks(*hSrcTrack);
226  if (hSrcTrack.failedToGet())
227  edm::LogWarning("MultiTrackSelector")<<"could not get Track collection";
228 
229  // get hits in track..
231  evt.getByToken(hSrc_, hSrcHits );
232  const TrackingRecHitCollection & srcHits(*hSrcHits);
233 
234 
235  // looking for the beam spot
237  evt.getByToken(beamspot_, hBsp);
238  const reco::BeamSpot& vertexBeamSpot(*hBsp);
239 
240  // Select good primary vertices for use in subsequent track selection
242  if (useVertices_) {
243  evt.getByToken(vertices_, hVtx);
244  if (hVtx.failedToGet())
245  edm::LogWarning("MultiTrackSelector")<<"could not get Vertex collection";
246  }
247 
248  unsigned int trkSize=srcTracks.size();
249  std::vector<int> selTracksSave( qualityToSet_.size()*trkSize,0);
250 
251  std::vector<Point> points;
252  std::vector<float> vterr, vzerr;
253  if (useVertices_) selectVertices(0,*hVtx, points, vterr, vzerr);
254  //auto vtxP = points.empty() ? vertexBeamSpot.position() : points[0]; // rare, very rare, still happens!
255  for (unsigned int i=0; i<qualityToSet_.size(); i++) {
256  std::vector<float> mvaVals_(srcTracks.size(),-99.f);
257  processMVA(evt,es,vertexBeamSpot,*(hVtx.product()), i, mvaVals_, i == 0 ? true : false);
258  std::vector<int> selTracks(trkSize,0);
259  auto selTracksValueMap = std::make_unique<edm::ValueMap<int>>();
260  edm::ValueMap<int>::Filler filler(*selTracksValueMap);
261 
262  if (useVertices_) selectVertices(i,*hVtx, points, vterr, vzerr);
263 
264  // Loop over tracks
265  size_t current = 0;
266  for (TrackCollection::const_iterator it = srcTracks.begin(), ed = srcTracks.end(); it != ed; ++it, ++current) {
267  const Track & trk = * it;
268  // Check if this track passes cuts
269 
270  LogTrace("TrackSelection") << "ready to check track with pt="<< trk.pt() ;
271 
272  //already removed
273  bool ok=true;
274  if (preFilter_[i]<i && selTracksSave[preFilter_[i]*trkSize+current] < 0) {
275  selTracks[current]=-1;
276  ok=false;
277  if ( !keepAllTracks_[i])
278  continue;
279  }
280  else {
281  float mvaVal = 0;
282  if(useAnyMVA_) mvaVal = mvaVals_[current];
283  ok = select(i,vertexBeamSpot, srcHits, trk, points, vterr, vzerr,mvaVal);
284  if (!ok) {
285  LogTrace("TrackSelection") << "track with pt="<< trk.pt() << " NOT selected";
286  if (!keepAllTracks_[i]) {
287  selTracks[current]=-1;
288  continue;
289  }
290  }
291  else
292  LogTrace("TrackSelection") << "track with pt="<< trk.pt() << " selected";
293  }
294 
295  if (preFilter_[i]<i ) {
296  selTracks[current]=selTracksSave[preFilter_[i]*trkSize+current];
297  }
298  else {
299  selTracks[current]=trk.qualityMask();
300  }
301  if ( ok && setQualityBit_[i]) {
302  selTracks[current]= (selTracks[current] | (1<<qualityToSet_[i]));
303  if (qualityToSet_[i]==TrackBase::tight) {
304  selTracks[current]=(selTracks[current] | (1<<TrackBase::loose));
305  }
306  else if (qualityToSet_[i]==TrackBase::highPurity) {
307  selTracks[current]=(selTracks[current] | (1<<TrackBase::loose));
308  selTracks[current]=(selTracks[current] | (1<<TrackBase::tight));
309  }
310  if (!points.empty()) {
311  if (qualityToSet_[i]==TrackBase::loose) {
312  selTracks[current]=(selTracks[current] | (1<<TrackBase::looseSetWithPV));
313  }
314  else if (qualityToSet_[i]==TrackBase::highPurity) {
315  selTracks[current]=(selTracks[current] | (1<<TrackBase::looseSetWithPV));
316  selTracks[current]=(selTracks[current] | (1<<TrackBase::highPuritySetWithPV));
317  }
318  }
319  }
320  }
321  for ( unsigned int j=0; j< trkSize; j++ ) selTracksSave[j+i*trkSize]=selTracks[j];
322  filler.insert(hSrcTrack, selTracks.begin(),selTracks.end());
323  filler.fill();
324 
325  // evt.put(std::move(selTracks),name_[i]);
326  evt.put(std::move(selTracksValueMap),name_[i]);
327  for (auto & q : selTracks) q=std::max(q,0);
328  auto quals = std::make_unique<QualityMaskCollection>(selTracks.begin(),selTracks.end());
329  evt.put(std::move(quals),name_[i]);
330  }
331 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
std::vector< std::string > name_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
std::vector< bool > keepAllTracks_
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
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
std::vector< unsigned int > preFilter_
edm::EDGetTokenT< TrackingRecHitCollection > hSrc_
edm::EDGetTokenT< reco::VertexCollection > vertices_
edm::EDGetTokenT< reco::BeamSpot > beamspot_
std::vector< bool > setQualityBit_
do I have to set a quality bit?
double pt() const
track transverse momentum
Definition: TrackBase.h:616
int qualityMask() const
Definition: TrackBase.h:857
#define LogTrace(id)
bool failedToGet() const
Definition: HandleBase.h:78
void selectVertices(unsigned int tsNum, const reco::VertexCollection &vtxs, std::vector< Point > &points, std::vector< float > &vterr, std::vector< float > &vzerr) const
T const * product() const
Definition: Handle.h:81
std::vector< reco::TrackBase::TrackQuality > qualityToSet_
fixed size matrix
HLT enums.
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
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
def move(src, dest)
Definition: eostools.py:510
bool MultiTrackSelector::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 334 of file MultiTrackSelector.cc.

References funct::abs(), applyAbsCutsIfNoPV_, applyAdaptedPVCuts_, HiEvtPlane_cfi::chi2, reco::TrackBase::chi2(), chi2n, chi2n_no1Dmod_par_, chi2n_par_, allConversions_cfi::d0, d0_par1_, d0_par2_, reco::TrackBase::d0Error(), TrackingRecHit::dimension(), reco::TrackBase::dxy(), allConversions_cfi::dz, reco::TrackBase::dz(), dz_par1_, dz_par2_, pfChMet_cfi::dzCut, reco::TrackBase::dzError(), particleFlow_cfi::dzPV, end, stringResolutionProvider_cfi::eta, reco::TrackBase::eta(), reco::Track::extra(), f, objects.autophobj::float, reco::TrackBase::hitPattern(), LogDebug, LogTrace, hpstanc_transforms::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(), reco::HitPattern::pixelLayersWithMeasurement(), point, reco::BeamSpot::position(), funct::pow(), EnergyCorrector::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_, useMVAonly_, and useVtxError_.

Referenced by AnalyticalTrackSelector::run(), and run().

341  {
342  // Decide if the given track passes selection cuts.
343 
344  using namespace std;
345 
346  //cuts on number of valid hits
347  auto nhits = tk.numberOfValidHits();
348  if(nhits>=min_hits_bypass_[tsNum]) return true;
349  if(nhits < min_nhits_[tsNum]) return false;
350 
351  if ( tk.ndof() < 1E-5 ) return false;
352 
353 
355  //Adding the MVA selection before any other cut//
357  if(useAnyMVA_ && useMVA_[tsNum]){
358  if (useMVAonly_[tsNum]) return mvaVal > min_MVA_[tsNum];
359  if(mvaVal < min_MVA_[tsNum])return false;
360  }
362  //End of MVA selection section//
364 
365 
366  // Cuts on numbers of layers with hits/3D hits/lost hits.
368  uint32_t nlayers3D = tk.hitPattern().pixelLayersWithMeasurement() +
371  LogDebug("TrackSelection") << "cuts on nlayers: " << nlayers << " " << nlayers3D << " " << nlayersLost << " vs "
372  << min_layers_[tsNum] << " " << min_3Dlayers_[tsNum] << " " << max_lostLayers_[tsNum];
373  if (nlayers < min_layers_[tsNum]) return false;
374  if (nlayers3D < min_3Dlayers_[tsNum]) return false;
375  if (nlayersLost > max_lostLayers_[tsNum]) return false;
376  LogTrace("TrackSelection") << "cuts on nlayers passed";
377 
378  float chi2n = tk.normalizedChi2();
379  float chi2n_no1Dmod = chi2n;
380 
381  int count1dhits = 0;
382  auto ith = tk.extra()->firstRecHit();
383  auto edh = ith + tk.recHitsSize();
384  for (; ith<edh; ++ith) {
385  const TrackingRecHit & hit = recHits[ith];
386  if (hit.dimension()==1) ++count1dhits;
387  }
388  if (count1dhits > 0) {
389  float chi2 = tk.chi2();
390  float ndof = tk.ndof();
391  chi2n = (chi2+count1dhits)/float(ndof+count1dhits);
392  }
393  // For each 1D rechit, the chi^2 and ndof is increased by one. This is a way of retaining approximately
394  // the same normalized chi^2 distribution as with 2D rechits.
395  if (chi2n > chi2n_par_[tsNum]*nlayers) return false;
396 
397  if (chi2n_no1Dmod > chi2n_no1Dmod_par_[tsNum]*nlayers) return false;
398 
399  // Get track parameters
400  float pt = std::max(float(tk.pt()),0.000001f);
401  float eta = tk.eta();
402  if (eta<min_eta_[tsNum] || eta>max_eta_[tsNum]) return false;
403 
404  //cuts on relative error on pt
405  float relpterr = float(tk.ptError())/pt;
406  if(relpterr > max_relpterr_[tsNum]) return false;
407 
410  int minLost = std::min(lostIn,lostOut);
411  if (minLost > max_minMissHitOutOrIn_[tsNum]) return false;
412  float lostMidFrac = tk.numberOfLostHits() / (tk.numberOfValidHits() + tk.numberOfLostHits());
413  if (lostMidFrac > max_lostHitFraction_[tsNum]) return false;
414 
415 
416 
417  //other track parameters
418  float d0 = -tk.dxy(vertexBeamSpot.position()), d0E = tk.d0Error(),
419  dz = tk.dz(vertexBeamSpot.position()), dzE = tk.dzError();
420 
421  // parametrized d0 resolution for the track pt
422  float nomd0E = sqrt(res_par_[tsNum][0]*res_par_[tsNum][0]+(res_par_[tsNum][1]/pt)*(res_par_[tsNum][1]/pt));
423  // parametrized z0 resolution for the track pt and eta
424  float nomdzE = nomd0E*(std::cosh(eta));
425 
426  float dzCut = std::min( powN(dz_par1_[tsNum][0]*nlayers,int(dz_par1_[tsNum][1]+0.5))*nomdzE,
427  powN(dz_par2_[tsNum][0]*nlayers,int(dz_par2_[tsNum][1]+0.5))*dzE );
428  float d0Cut = std::min( powN(d0_par1_[tsNum][0]*nlayers,int(d0_par1_[tsNum][1]+0.5))*nomd0E,
429  powN(d0_par2_[tsNum][0]*nlayers,int(d0_par2_[tsNum][1]+0.5))*d0E );
430 
431 
432  // ---- PrimaryVertex compatibility cut
433  bool primaryVertexZCompatibility(false);
434  bool primaryVertexD0Compatibility(false);
435 
436  if (points.empty()) { //If not primaryVertices are reconstructed, check just the compatibility with the BS
437  //z0 within (n sigma + dzCut) of the beam spot z, if no good vertex is found
438  if ( abs(dz) < hypot(vertexBeamSpot.sigmaZ()*nSigmaZ_[tsNum],dzCut) ) primaryVertexZCompatibility = true;
439  // d0 compatibility with beam line
440  if (abs(d0) < d0Cut) primaryVertexD0Compatibility = true;
441  }
442 
443  int iv=0;
444  for (std::vector<Point>::const_iterator point = points.begin(), end = points.end(); point != end; ++point) {
445  LogTrace("TrackSelection") << "Test track w.r.t. vertex with z position " << point->z();
446  if(primaryVertexZCompatibility && primaryVertexD0Compatibility) break;
447  float dzPV = tk.dz(*point); //re-evaluate the dz with respect to the vertex position
448  float d0PV = tk.dxy(*point); //re-evaluate the dxy with respect to the vertex position
449  if(useVtxError_){
450  float dzErrPV = std::sqrt(dzE*dzE+vzerr[iv]*vzerr[iv]); // include vertex error in z
451  float d0ErrPV = std::sqrt(d0E*d0E+vterr[iv]*vterr[iv]); // include vertex error in xy
452  iv++;
453  if (abs(dzPV) < dz_par1_[tsNum][0]*pow(nlayers,dz_par1_[tsNum][1])*nomdzE &&
454  abs(dzPV) < dz_par2_[tsNum][0]*pow(nlayers,dz_par2_[tsNum][1])*dzErrPV &&
455  abs(dzPV) < max_z0_[tsNum]) primaryVertexZCompatibility = true;
456  if (abs(d0PV) < d0_par1_[tsNum][0]*pow(nlayers,d0_par1_[tsNum][1])*nomd0E &&
457  abs(d0PV) < d0_par2_[tsNum][0]*pow(nlayers,d0_par2_[tsNum][1])*d0ErrPV &&
458  abs(d0PV) < max_d0_[tsNum]) primaryVertexD0Compatibility = true;
459  }else{
460  if (abs(dzPV) < dzCut) primaryVertexZCompatibility = true;
461  if (abs(d0PV) < d0Cut) primaryVertexD0Compatibility = true;
462  }
463  LogTrace("TrackSelection") << "distances " << dzPV << " " << d0PV << " vs " << dzCut << " " << d0Cut;
464  }
465 
466  if (points.empty() && applyAbsCutsIfNoPV_[tsNum]) {
467  if ( abs(dz) > max_z0NoPV_[tsNum] || abs(d0) > max_d0NoPV_[tsNum]) return false;
468  } else {
469  // Absolute cuts on all tracks impact parameters with respect to beam-spot.
470  // If BS is not compatible, verify if at least the reco-vertex is compatible (useful for incorrect BS settings)
471  if (abs(d0) > max_d0_[tsNum] && !primaryVertexD0Compatibility) return false;
472  LogTrace("TrackSelection") << "absolute cuts on d0 passed";
473  if (abs(dz) > max_z0_[tsNum] && !primaryVertexZCompatibility) return false;
474  LogTrace("TrackSelection") << "absolute cuts on dz passed";
475  }
476 
477  LogTrace("TrackSelection") << "cuts on PV: apply adapted PV cuts? " << applyAdaptedPVCuts_[tsNum]
478  << " d0 compatibility? " << primaryVertexD0Compatibility
479  << " z compatibility? " << primaryVertexZCompatibility ;
480 
481  if (applyAdaptedPVCuts_[tsNum]) {
482  return (primaryVertexD0Compatibility && primaryVertexZCompatibility);
483  } else {
484  return true;
485  }
486 
487 }
#define LogDebug(id)
std::vector< double > chi2n_no1Dmod_par_
std::vector< uint32_t > min_nhits_
std::vector< double > chi2n_par_
std::vector< std::vector< double > > d0_par1_
std::vector< double > max_d0NoPV_
double d0Error() const
error on d0
Definition: TrackBase.h:797
std::vector< double > max_z0_
std::vector< uint32_t > min_layers_
Cuts on numbers of layers with hits/3D hits/lost hits.
std::vector< double > max_z0NoPV_
const TrackExtraRef & extra() const
reference to "extra" object
Definition: Track.h:189
std::vector< bool > useMVA_
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:556
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:119
std::vector< uint32_t > min_hits_bypass_
std::vector< bool > applyAdaptedPVCuts_
unsigned short numberOfLostHits() const
number of cases where track crossed a layer without getting a hit.
Definition: TrackBase.h:821
std::vector< double > nSigmaZ_
int pixelLayersWithMeasurement() const
Definition: HitPattern.cc:499
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:518
std::vector< uint32_t > min_3Dlayers_
int numberOfLostTrackerHits(HitCategory category) const
Definition: HitPattern.h:907
std::vector< uint32_t > max_lostLayers_
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:646
int numberOfValidStripLayersWithMonoAndStereo(uint16_t stripdet, uint16_t layer) const
Definition: HitPattern.cc:341
std::vector< int32_t > max_lostHitFraction_
std::vector< double > min_eta_
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:544
double ndof() const
number of degrees of freedom of the fit
Definition: TrackBase.h:550
T sqrt(T t)
Definition: SSEVec.h:18
virtual int dimension() const =0
double pt() const
track transverse momentum
Definition: TrackBase.h:616
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:758
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< std::vector< double > > dz_par1_
double f[11][100]
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:815
#define end
Definition: vmac.h:37
std::vector< std::vector< double > > dz_par2_
std::vector< std::vector< double > > res_par_
T min(T a, T b)
Definition: MathUtil.h:58
#define LogTrace(id)
std::vector< double > max_relpterr_
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:604
double dzError() const
error on dz
Definition: TrackBase.h:809
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:445
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
int trackerLayersWithoutMeasurement(HitCategory category) const
Definition: HitPattern.cc:535
std::vector< bool > applyAbsCutsIfNoPV_
const Point & position() const
position
Definition: BeamSpot.h:62
std::vector< int32_t > max_minMissHitOutOrIn_
std::vector< double > min_MVA_
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:586
std::vector< std::vector< double > > d0_par2_
std::vector< double > max_d0_
Impact parameter absolute cuts.
std::vector< bool > useMVAonly_
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
*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
std::vector< double > max_eta_
void MultiTrackSelector::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 489 of file MultiTrackSelector.cc.

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

Referenced by AnalyticalTrackSelector::run(), and run().

493  {
494  // Select good primary vertices
495  using namespace reco;
496  int32_t toTake = vtxNumber_[tsNum];
497  for (VertexCollection::const_iterator it = vtxs.begin(), ed = vtxs.end(); it != ed; ++it) {
498 
499  LogDebug("SelectVertex") << " select vertex with z position " << it->z() << " "
500  << it->chi2() << " " << it->ndof() << " " << TMath::Prob(it->chi2(), static_cast<int32_t>(it->ndof()));
501  Vertex vtx = *it;
502  bool pass = vertexCut_[tsNum]( vtx );
503  if( pass ) {
504  points.push_back(it->position());
505  vterr.push_back(sqrt(it->yError()*it->xError()));
506  vzerr.push_back(it->zError());
507  LogTrace("SelectVertex") << " SELECTED vertex with z position " << it->z();
508  toTake--; if (toTake == 0) break;
509  }
510  }
511 }
#define LogDebug(id)
T sqrt(T t)
Definition: SSEVec.h:18
#define LogTrace(id)
std::vector< int32_t > vtxNumber_
vertex cuts
fixed size matrix
std::vector< StringCutObjectSelector< reco::Vertex > > vertexCut_

Member Data Documentation

std::vector<bool> MultiTrackSelector::applyAbsCutsIfNoPV_
protected
std::vector<bool> MultiTrackSelector::applyAdaptedPVCuts_
protected
edm::EDGetTokenT<reco::BeamSpot> MultiTrackSelector::beamspot_
protected
std::vector< double > MultiTrackSelector::chi2n_no1Dmod_par_
protected
std::vector< double > MultiTrackSelector::chi2n_par_
protected
std::vector< std::vector<double> > MultiTrackSelector::d0_par1_
protected
std::vector< std::vector<double> > MultiTrackSelector::d0_par2_
protected
std::string MultiTrackSelector::dbFileName_
protected

Definition at line 153 of file MultiTrackSelector.h.

Referenced by beginStream(), and MultiTrackSelector().

std::vector< std::vector<double> > MultiTrackSelector::dz_par1_
protected
std::vector< std::vector<double> > MultiTrackSelector::dz_par2_
protected
std::vector<GBRForest*> MultiTrackSelector::forest_
protected
std::vector<std::string> MultiTrackSelector::forestLabel_
protected
edm::EDGetTokenT<TrackingRecHitCollection> MultiTrackSelector::hSrc_
protected
std::vector<bool> MultiTrackSelector::keepAllTracks_
protected
std::vector<double> MultiTrackSelector::max_d0_
protected

Impact parameter absolute cuts.

Definition at line 112 of file MultiTrackSelector.h.

Referenced by AnalyticalTrackSelector::AnalyticalTrackSelector(), MultiTrackSelector(), and select().

std::vector<double> MultiTrackSelector::max_d0NoPV_
protected
std::vector<double> MultiTrackSelector::max_eta_
protected
std::vector<int32_t> MultiTrackSelector::max_lostHitFraction_
protected
std::vector<uint32_t> MultiTrackSelector::max_lostLayers_
protected
std::vector<int32_t> MultiTrackSelector::max_minMissHitOutOrIn_
protected
std::vector<double> MultiTrackSelector::max_relpterr_
protected
std::vector<double> MultiTrackSelector::max_z0_
protected
std::vector<double> MultiTrackSelector::max_z0NoPV_
protected
std::vector<uint32_t> MultiTrackSelector::min_3Dlayers_
protected
std::vector<double> MultiTrackSelector::min_eta_
protected
std::vector<uint32_t> MultiTrackSelector::min_hits_bypass_
protected
std::vector<uint32_t> MultiTrackSelector::min_layers_
protected

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

Definition at line 117 of file MultiTrackSelector.h.

Referenced by AnalyticalTrackSelector::AnalyticalTrackSelector(), MultiTrackSelector(), and select().

std::vector<double> MultiTrackSelector::min_MVA_
protected
std::vector<uint32_t> MultiTrackSelector::min_nhits_
protected
std::vector<std::string> MultiTrackSelector::mvaType_
protected
std::vector<std::string> MultiTrackSelector::name_
protected

Definition at line 141 of file MultiTrackSelector.h.

Referenced by MultiTrackSelector(), and run().

std::vector<double> MultiTrackSelector::nSigmaZ_
protected
std::vector<unsigned int> MultiTrackSelector::preFilter_
protected
std::vector<reco::TrackBase::TrackQuality> MultiTrackSelector::qualityToSet_
protected
std::vector< std::vector<double> > MultiTrackSelector::res_par_
protected
std::vector<bool> MultiTrackSelector::setQualityBit_
protected

do I have to set a quality bit?

Definition at line 92 of file MultiTrackSelector.h.

Referenced by AnalyticalTrackSelector::AnalyticalTrackSelector(), MultiTrackSelector(), AnalyticalTrackSelector::run(), and run().

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

source collection label

Definition at line 83 of file MultiTrackSelector.h.

Referenced by AnalyticalTrackSelector::AnalyticalTrackSelector(), processMVA(), AnalyticalTrackSelector::run(), and run().

bool MultiTrackSelector::useAnyMVA_
protected
bool MultiTrackSelector::useForestFromDB_
protected

Definition at line 152 of file MultiTrackSelector.h.

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

std::vector<bool> MultiTrackSelector::useMVA_
protected
std::vector<bool> MultiTrackSelector::useMVAonly_
protected
bool MultiTrackSelector::useVertices_
protected
bool MultiTrackSelector::useVtxError_
protected
std::vector<StringCutObjectSelector<reco::Vertex> > MultiTrackSelector::vertexCut_
protected
edm::EDGetTokenT<reco::VertexCollection> MultiTrackSelector::vertices_
protected
std::vector<int32_t> MultiTrackSelector::vtxNumber_
protected