CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 HIMultiTrackSelector ()
 constructor More...
 
 HIMultiTrackSelector (const edm::ParameterSet &cfg)
 
virtual ~HIMultiTrackSelector ()
 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)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Types

typedef math::XYZPoint Point
 

Protected Member Functions

void beginStream (edm::StreamID) overridefinal
 
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) overridefinal
 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_
 
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
< TrackingRecHitCollection
hSrc_
 
std::vector< bool > keepAllTracks_
 
std::vector< double > max_d0_
 Impact parameter absolute cuts. More...
 
std::vector< double > max_d0NoPV_
 
std::vector< double > max_eta_
 
std::vector< int32_t > max_lostHitFraction_
 
std::vector< uint32_t > max_lostLayers_
 
std::vector< int32_t > max_minMissHitOutOrIn_
 
std::vector< double > max_relpterr_
 
std::vector< double > max_z0_
 
std::vector< double > max_z0NoPV_
 
std::vector< uint32_t > min_3Dlayers_
 
std::vector< double > min_eta_
 
std::vector< uint32_t > min_hits_bypass_
 
std::vector< uint32_t > min_layers_
 Cuts on numbers of layers with hits/3D hits/lost hits. More...
 
std::vector< double > min_MVA_
 
std::vector< uint32_t > min_nhits_
 
std::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::TrackQuality
qualityToSet_
 
std::vector< std::vector
< double > > 
res_par_
 
std::vector< bool > setQualityBit_
 do I have to set a quality bit? More...
 
edm::EDGetTokenT
< reco::TrackCollection
src_
 source collection label More...
 
bool useAnyMVA_
 
bool useForestFromDB_
 
std::vector< bool > useMVA_
 
bool useVertices_
 
bool useVtxError_
 
std::vector
< StringCutObjectSelector
< reco::Vertex > > 
vertexCut_
 
edm::EDGetTokenT
< reco::VertexCollection
vertices_
 
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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
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
 
- 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 52 of file HIMultiTrackSelector.h.

Member Typedef Documentation

Definition at line 70 of file HIMultiTrackSelector.h.

Constructor & Destructor Documentation

HIMultiTrackSelector::HIMultiTrackSelector ( )
explicit

constructor

Definition at line 58 of file HIMultiTrackSelector.cc.

59 {
60  useForestFromDB_ = true;
61  forest_ = nullptr;
62 }
HIMultiTrackSelector::HIMultiTrackSelector ( const edm::ParameterSet cfg)
explicit

Definition at line 94 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(), i, 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_.

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

destructor

Definition at line 273 of file HIMultiTrackSelector.cc.

References forest_.

273  {
274  delete forest_;
275 }

Member Function Documentation

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

Reimplemented from edm::stream::EDProducerBase.

Definition at line 278 of file HIMultiTrackSelector.cc.

References dbFileName_, forest_, forestLabel_, and useForestFromDB_.

278  {
279  if(!useForestFromDB_){
280  TFile gbrfile(dbFileName_.c_str());
281  forest_ = (GBRForest*)gbrfile.Get(forestLabel_.c_str());
282  }
283 
284 }
void HIMultiTrackSelector::ParseForestVars ( )
protected

Definition at line 64 of file HIMultiTrackSelector.cc.

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

Referenced by HIMultiTrackSelector().

65 {
66  mvavars_indices.clear();
67  for (unsigned i=0;i<forestVars_.size();i++)
68  {
70  int ind = -1;
71  if (v=="chi2perdofperlayer") ind=chi2perdofperlayer;
72  if (v=="dxyperdxyerror") ind=dxyperdxyerror;
73  if (v=="dzperdzerror") ind=dzperdzerror;
74  if (v=="relpterr") ind=relpterr;
75  if (v=="lostmidfrac") ind=lostmidfrac;
76  if (v=="minlost") ind=minlost;
77  if (v=="nhits") ind=nhits;
78  if (v=="eta") ind=eta;
79  if (v=="chi2n_no1dmod") ind=chi2n_no1dmod;
80  if (v=="chi2n") ind=chi2n ;
81  if (v=="nlayerslost") ind=nlayerslost ;
82  if (v=="nlayers3d") ind=nlayers3d ;
83  if (v=="nlayers") ind=nlayers ;
84  if (v=="ndof") ind=ndof ;
85  if (v=="etaerror") ind=etaerror;
86 
87  if (ind==-1) edm::LogWarning("HIMultiTrackSelector") << "Unknown forest variable "<<v<<". Please make sure it's in the list of supported variables\n";
88 
89  mvavars_indices.push_back(ind);
90  }
91 
92 }
int i
Definition: DBlmapReader.cc:9
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 593 of file HIMultiTrackSelector.cc.

References assert(), reco::TrackBase::chi2(), beam_dqm_sourceclient-live_cfg::chi2, chi2n, chi2n_no1dmod, chi2perdofperlayer, TrackingRecHit::dimension(), reco::TrackBase::dxy(), reco::TrackBase::dxyError(), dxyperdxyerror, reco::TrackBase::dz(), reco::TrackBase::dzError(), dzperdzerror, eta, reco::TrackBase::eta(), etaerror, reco::TrackBase::etaError(), reco::Track::extra(), f, spr::find(), forest_, forestLabel_, edm::EventSetup::get(), edm::Event::getByToken(), GBRForest::GetClassifier(), reco::TrackBase::hitPattern(), hSrc_, i, lostmidfrac, bookConverter::max, min(), minlost, reco::HitPattern::MISSING_INNER_HITS, reco::HitPattern::MISSING_OUTER_HITS, 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< class >::product(), reco::TrackBase::pt(), reco::TrackBase::ptError(), edm::Event::put(), reco::Track::recHitsSize(), dt_dqm_sourceclient_common_cff::reco, relpterr, mathSSE::sqrt(), src_, reco::HitPattern::TRACK_HITS, reco::HitPattern::trackerLayersWithMeasurement(), reco::HitPattern::trackerLayersWithoutMeasurement(), useAnyMVA_, and useForestFromDB_.

Referenced by run().

594 {
595 
596  using namespace std;
597  using namespace edm;
598  using namespace reco;
599 
600  // Get tracks
601  Handle<TrackCollection> hSrcTrack;
602  evt.getByToken( src_, hSrcTrack );
603  const TrackCollection& srcTracks(*hSrcTrack);
604  assert(mvaVals_.size()==srcTracks.size());
605 
606  // get hits in track..
608  evt.getByToken( hSrc_, hSrcHits );
609  const TrackingRecHitCollection & srcHits(*hSrcHits);
610 
611 
612  auto_ptr<edm::ValueMap<float> >mvaValValueMap = auto_ptr<edm::ValueMap<float> >(new edm::ValueMap<float>);
613  edm::ValueMap<float>::Filler mvaFiller(*mvaValValueMap);
614 
615 
616  if(!useAnyMVA_){
617  // mvaVals_ already initalized...
618  mvaFiller.insert(hSrcTrack,mvaVals_.begin(),mvaVals_.end());
619  mvaFiller.fill();
620  evt.put(mvaValValueMap,"MVAVals");
621  return;
622  }
623 
624  bool checkvertex = std::find(mvavars_indices.begin(), mvavars_indices.end(),dxyperdxyerror)!=mvavars_indices.end()
626 
627  size_t current = 0;
628  for (TrackCollection::const_iterator it = srcTracks.begin(), ed = srcTracks.end(); it != ed; ++it, ++current) {
629  const Track & trk = * it;
630 
631  float mvavalues[15];
632  mvavalues[ndof] = trk.ndof();
633  mvavalues[nlayers] = trk.hitPattern().trackerLayersWithMeasurement();
636  mvavalues[chi2n_no1dmod] = trk.normalizedChi2();
637  mvavalues[chi2perdofperlayer] = mvavalues[chi2n_no1dmod]/mvavalues[nlayers];
638 
639 
640  float chi2n1d = trk.normalizedChi2();
641  int count1dhits = 0;
642  auto ith = trk.extra()->firstRecHit();
643  auto edh = ith + trk.recHitsSize();
644  for (; ith<edh; ++ith) {
645  const TrackingRecHit & hit = srcHits[ith];
646  if (hit.dimension()==1) ++count1dhits;
647  }
648  if (count1dhits > 0) {
649  float chi2 = trk.chi2();
650  float ndof = trk.ndof();
651  chi2n1d = (chi2+count1dhits)/float(ndof+count1dhits);
652  }
653 
654  mvavalues[chi2n] = chi2n1d;//chi2 and 1d modes
655 
656  mvavalues[eta] = trk.eta();
657  mvavalues[relpterr] = float(trk.ptError())/std::max(float(trk.pt()),0.000001f);
658  mvavalues[nhits] = trk.numberOfValidHits();
659 
662  mvavalues[minlost] = std::min(lostIn,lostOut);
663  mvavalues[lostmidfrac] = trk.numberOfLostHits() / (trk.numberOfValidHits() + trk.numberOfLostHits());
664 
665  mvavalues[etaerror] = trk.etaError();
666 
667  float reldz = 0;
668  float reldxy = 0;
669  if (checkvertex) {
670  int vtxind = 0; // only first vertex is taken into account for the speed purposes
671  float dxy = trk.dxy(vertices[vtxind].position()), dxyE = sqrt(trk.dxyError()*trk.dxyError()+vertices[vtxind].xError()*vertices[vtxind].yError());
672  float dz = trk.dz(vertices[vtxind].position()), dzE = sqrt(trk.dzError()*trk.dzError()+vertices[vtxind].zError()*vertices[vtxind].zError());
673  reldz = dz/dzE;
674  reldxy = dxy/dxyE;
675 
676  }
677  mvavalues[dxyperdxyerror] = reldxy;
678  mvavalues[dzperdzerror] = reldz;
679 
680  std::vector<float> gbrValues;
681 
682  //fill in the gbrValues vector with the necessary variables
683  for (unsigned i=0;i<mvavars_indices.size();i++) {
684  gbrValues.push_back(mvavalues[mvavars_indices[i]]);
685  }
686 
687 
688  GBRForest const * forest = forest_;
689  if(useForestFromDB_){
690  edm::ESHandle<GBRForest> forestHandle;
691  es.get<GBRWrapperRcd>().get(forestLabel_,forestHandle);
692  forest = forestHandle.product();
693  }
694 
695  auto gbrVal = forest->GetClassifier(&gbrValues[0]);
696  mvaVals_[current] = gbrVal;
697  }
698  mvaFiller.insert(hSrcTrack,mvaVals_.begin(),mvaVals_.end());
699  mvaFiller.fill();
700  evt.put(mvaValValueMap,"MVAVals");
701 
702 }
int i
Definition: DBlmapReader.cc:9
virtual int dimension() const =0
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:189
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:462
double dxyError() const
error on dxy
Definition: TrackBase.h:791
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:119
assert(m_qm.get())
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
double etaError() const
error on eta
Definition: TrackBase.h:779
unsigned short numberOfLostHits() const
number of cases where track crossed a layer without getting a hit.
Definition: TrackBase.h:821
int pixelLayersWithMeasurement() const
Definition: HitPattern.cc:508
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:527
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:350
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:544
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
double ndof() const
number of degrees of freedom of the fit
Definition: TrackBase.h:550
T sqrt(T t)
Definition: SSEVec.h:18
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
double f[11][100]
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:815
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:604
double dzError() const
error on dz
Definition: TrackBase.h:809
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:445
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
int trackerLayersWithoutMeasurement(HitCategory category) const
Definition: HitPattern.cc:544
static int position[264][3]
Definition: ReadPGInfo.cc:509
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
void HIMultiTrackSelector::produce ( edm::Event evt,
const edm::EventSetup es 
)
inlinefinaloverrideprotectedvirtual

process one event

Implements edm::stream::EDProducerBase.

Definition at line 72 of file HIMultiTrackSelector.h.

References DTTTrigCorrFirst::run.

72  {
73  run(evt,es);
74  }
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 288 of file HIMultiTrackSelector.cc.

References beamspot_, edm::Event::getByToken(), hSrc_, i, j, keepAllTracks_, LogTrace, name_, convertSQLiteXML::ok, preFilter_, processMVA(), reco::TrackBase::pt(), edm::Event::put(), reco::TrackBase::qualityMask(), qualityToSet_, dt_dqm_sourceclient_common_cff::reco, select(), selectVertices(), setQualityBit_, src_, useAnyMVA_, useVertices_, and vertices_.

289 {
290  using namespace std;
291  using namespace edm;
292  using namespace reco;
293 
294  // Get tracks
295  Handle<TrackCollection> hSrcTrack;
296  evt.getByToken(src_, hSrcTrack );
297  const TrackCollection& srcTracks(*hSrcTrack);
298 
299  // get hits in track..
301  evt.getByToken(hSrc_, hSrcHits );
302  const TrackingRecHitCollection & srcHits(*hSrcHits);
303 
304 
305  // looking for the beam spot
307  evt.getByToken(beamspot_, hBsp);
308  const reco::BeamSpot& vertexBeamSpot(*hBsp);
309 
310 
311  // Select good primary vertices for use in subsequent track selection
313  if (useVertices_) evt.getByToken(vertices_, hVtx);
314 
315  unsigned int trkSize=srcTracks.size();
316  std::vector<int> selTracksSave( qualityToSet_.size()*trkSize,0);
317 
318  std::vector<float> mvaVals_(srcTracks.size(),-99.f);
319  processMVA(evt,es, mvaVals_, *hVtx);
320 
321  for (unsigned int i=0; i<qualityToSet_.size(); i++) {
322  std::vector<int> selTracks(trkSize,0);
323  auto_ptr<edm::ValueMap<int> > selTracksValueMap = auto_ptr<edm::ValueMap<int> >(new edm::ValueMap<int>);
324  edm::ValueMap<int>::Filler filler(*selTracksValueMap);
325 
326  std::vector<Point> points;
327  std::vector<float> vterr, vzerr;
328  if (useVertices_) selectVertices(i,*hVtx, points, vterr, vzerr);
329 
330  // Loop over tracks
331  size_t current = 0;
332  for (TrackCollection::const_iterator it = srcTracks.begin(), ed = srcTracks.end(); it != ed; ++it, ++current) {
333  const Track & trk = * it;
334  // Check if this track passes cuts
335 
336  LogTrace("TrackSelection") << "ready to check track with pt="<< trk.pt() ;
337 
338  //already removed
339  bool ok=true;
340  float mvaVal = 0;
341  if (preFilter_[i]<i && selTracksSave[preFilter_[i]*trkSize+current] < 0) {
342  selTracks[current]=-1;
343  ok=false;
344  if ( !keepAllTracks_[i])
345  continue;
346  }
347  else {
348  if(useAnyMVA_) mvaVal = mvaVals_[current];
349  ok = select(i,vertexBeamSpot, srcHits, trk, points, vterr, vzerr,mvaVal);
350  if (!ok) {
351  LogTrace("TrackSelection") << "track with pt="<< trk.pt() << " NOT selected";
352  if (!keepAllTracks_[i]) {
353  selTracks[current]=-1;
354  continue;
355  }
356  }
357  else
358  LogTrace("TrackSelection") << "track with pt="<< trk.pt() << " selected";
359  }
360 
361  if (preFilter_[i]<i ) {
362  selTracks[current]=selTracksSave[preFilter_[i]*trkSize+current];
363  }
364  else {
365  selTracks[current]=trk.qualityMask();
366  }
367  if ( ok && setQualityBit_[i]) {
368  selTracks[current]= (selTracks[current] | (1<<qualityToSet_[i]));
369  if (qualityToSet_[i]==TrackBase::tight) {
370  selTracks[current]=(selTracks[current] | (1<<TrackBase::loose));
371  }
372  else if (qualityToSet_[i]==TrackBase::highPurity) {
373  selTracks[current]=(selTracks[current] | (1<<TrackBase::loose));
374  selTracks[current]=(selTracks[current] | (1<<TrackBase::tight));
375  }
376 
377  if (!points.empty()) {
378  if (qualityToSet_[i]==TrackBase::loose) {
379  selTracks[current]=(selTracks[current] | (1<<TrackBase::looseSetWithPV));
380  }
381  else if (qualityToSet_[i]==TrackBase::highPurity) {
382  selTracks[current]=(selTracks[current] | (1<<TrackBase::looseSetWithPV));
383  selTracks[current]=(selTracks[current] | (1<<TrackBase::highPuritySetWithPV));
384  }
385  }
386  }
387  }
388  for ( unsigned int j=0; j< trkSize; j++ ) selTracksSave[j+i*trkSize]=selTracks[j];
389  filler.insert(hSrcTrack, selTracks.begin(),selTracks.end());
390  filler.fill();
391 
392  // evt.put(selTracks,name_[i]);
393  evt.put(selTracksValueMap,name_[i]);
394  }
395 }
std::vector< std::string > name_
int i
Definition: DBlmapReader.cc:9
bool select(unsigned tsNum, const reco::BeamSpot &vertexBeamSpot, const TrackingRecHitCollection &recHits, const reco::Track &tk, const std::vector< Point > &points, std::vector< float > &vterr, std::vector< float > &vzerr, double mvaVal) const
return class, or -1 if rejected
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
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_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
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
int j
Definition: DBlmapReader.cc:9
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_
std::vector< bool > keepAllTracks_
std::vector< unsigned int > preFilter_
std::vector< reco::TrackBase::TrackQuality > qualityToSet_
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 398 of file HIMultiTrackSelector.cc.

References funct::abs(), applyAbsCutsIfNoPV_, applyAdaptedPVCuts_, applyPixelMergingCuts_, reco::TrackBase::chi2(), beam_dqm_sourceclient-live_cfg::chi2, chi2n, chi2n_no1Dmod_par_, chi2n_par_, d0_par1_, d0_par2_, reco::TrackBase::d0Error(), TrackingRecHit::dimension(), reco::TrackBase::dxy(), reco::TrackBase::dz(), dz_par1_, dz_par2_, reco::TrackBase::dzError(), HLT_25ns10e33_v2_cff::dzPV, end, eta, reco::TrackBase::eta(), reco::Track::extra(), f, reco::TrackBase::hitPattern(), LogDebug, LogTrace, bookConverter::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(), 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_, and useVtxError_.

Referenced by run().

405  {
406  // Decide if the given track passes selection cuts.
407 
408  using namespace std;
409 
410  //cuts on number of valid hits
411  auto nhits = tk.numberOfValidHits();
412  if(nhits>=min_hits_bypass_[tsNum]) return true;
413  if(nhits < min_nhits_[tsNum]) return false;
414 
415  if ( tk.ndof() < 1E-5 ) return false;
416 
417 
419  //Adding the MVA selection before any other cut//
421  if(useAnyMVA_ && useMVA_[tsNum]){
422  if(mvaVal < min_MVA_[tsNum])return false; else return true;
423  }
425  //End of MVA selection section//
427 
428 
429  // Cuts on numbers of layers with hits/3D hits/lost hits.
431  uint32_t nlayers3D = tk.hitPattern().pixelLayersWithMeasurement() +
434  LogDebug("TrackSelection") << "cuts on nlayers: " << nlayers << " " << nlayers3D << " " << nlayersLost << " vs "
435  << min_layers_[tsNum] << " " << min_3Dlayers_[tsNum] << " " << max_lostLayers_[tsNum];
436  if (nlayers < min_layers_[tsNum]) return false;
437  if (nlayers3D < min_3Dlayers_[tsNum]) return false;
438  if (nlayersLost > max_lostLayers_[tsNum]) return false;
439  LogTrace("TrackSelection") << "cuts on nlayers passed";
440 
441  float chi2n = tk.normalizedChi2();
442  float chi2n_no1Dmod = chi2n;
443 
444  int count1dhits = 0;
445  auto ith = tk.extra()->firstRecHit();
446  auto edh = ith + tk.recHitsSize();
447  for (; ith<edh; ++ith) {
448  const TrackingRecHit & hit = recHits[ith];
449  if (hit.dimension()==1) ++count1dhits;
450  }
451  if (count1dhits > 0) {
452  float chi2 = tk.chi2();
453  float ndof = tk.ndof();
454  chi2n = (chi2+count1dhits)/float(ndof+count1dhits);
455  }
456  // For each 1D rechit, the chi^2 and ndof is increased by one. This is a way of retaining approximately
457  // the same normalized chi^2 distribution as with 2D rechits.
458  if (chi2n > chi2n_par_[tsNum]*nlayers) return false;
459 
460  if (chi2n_no1Dmod > chi2n_no1Dmod_par_[tsNum]*nlayers) return false;
461 
462  // Get track parameters
463  float pt = std::max(float(tk.pt()),0.000001f);
464  float eta = tk.eta();
465  if (eta<min_eta_[tsNum] || eta>max_eta_[tsNum]) return false;
466 
467  //cuts on relative error on pt
468  float relpterr = float(tk.ptError())/pt;
469  if(relpterr > max_relpterr_[tsNum]) return false;
470 
473  int minLost = std::min(lostIn,lostOut);
474  if (minLost > max_minMissHitOutOrIn_[tsNum]) return false;
475  float lostMidFrac = tk.numberOfLostHits() / (tk.numberOfValidHits() + tk.numberOfLostHits());
476  if (lostMidFrac > max_lostHitFraction_[tsNum]) return false;
477 
478  // Pixel Track Merging pT dependent cuts
480  {
481  // hard cut at absolute min/max pt
482  if( pt < pixel_pTMinCut_[tsNum][0] ) return false;
483  if( pt > pixel_pTMaxCut_[tsNum][0] ) return false;
484  // tapering cuts with chi2n_no1Dmod
485  double pTMaxCutPos = ( pixel_pTMaxCut_[tsNum][0] - pt ) /
486  ( pixel_pTMaxCut_[tsNum][0] - pixel_pTMaxCut_[tsNum][1] );
487  double pTMinCutPos = ( pt - pixel_pTMinCut_[tsNum][0] ) /
488  ( pixel_pTMinCut_[tsNum][1] - pixel_pTMinCut_[tsNum][0] );
489  if( pt > pixel_pTMaxCut_[tsNum][1] &&
490  chi2n_no1Dmod > pixel_pTMaxCut_[tsNum][2]*nlayers*pow(pTMaxCutPos,pixel_pTMaxCut_[tsNum][3]) )
491  return false;
492  if( pt < pixel_pTMinCut_[tsNum][1] &&
493  chi2n_no1Dmod > pixel_pTMinCut_[tsNum][2]*nlayers*pow(pTMinCutPos,pixel_pTMinCut_[tsNum][3]) )
494  return false;
495  }
496 
497  //other track parameters
498  float d0 = -tk.dxy(vertexBeamSpot.position()), d0E = tk.d0Error(),
499  dz = tk.dz(vertexBeamSpot.position()), dzE = tk.dzError();
500 
501  // parametrized d0 resolution for the track pt
502  float nomd0E = sqrt(res_par_[tsNum][0]*res_par_[tsNum][0]+(res_par_[tsNum][1]/pt)*(res_par_[tsNum][1]/pt));
503  // parametrized z0 resolution for the track pt and eta
504  float nomdzE = nomd0E*(std::cosh(eta));
505 
506  float dzCut = std::min( powN(dz_par1_[tsNum][0]*nlayers,int(dz_par1_[tsNum][1]+0.5))*nomdzE,
507  powN(dz_par2_[tsNum][0]*nlayers,int(dz_par2_[tsNum][1]+0.5))*dzE );
508  float d0Cut = std::min( powN(d0_par1_[tsNum][0]*nlayers,int(d0_par1_[tsNum][1]+0.5))*nomd0E,
509  powN(d0_par2_[tsNum][0]*nlayers,int(d0_par2_[tsNum][1]+0.5))*d0E );
510 
511 
512  // ---- PrimaryVertex compatibility cut
513  bool primaryVertexZCompatibility(false);
514  bool primaryVertexD0Compatibility(false);
515 
516  if (points.empty()) { //If not primaryVertices are reconstructed, check just the compatibility with the BS
517  //z0 within (n sigma + dzCut) of the beam spot z, if no good vertex is found
518  if ( abs(dz) < hypot(vertexBeamSpot.sigmaZ()*nSigmaZ_[tsNum],dzCut) ) primaryVertexZCompatibility = true;
519  // d0 compatibility with beam line
520  if (abs(d0) < d0Cut) primaryVertexD0Compatibility = true;
521  }
522 
523  int iv=0;
524  for (std::vector<Point>::const_iterator point = points.begin(), end = points.end(); point != end; ++point) {
525  LogTrace("TrackSelection") << "Test track w.r.t. vertex with z position " << point->z();
526  if(primaryVertexZCompatibility && primaryVertexD0Compatibility) break;
527  float dzPV = tk.dz(*point); //re-evaluate the dz with respect to the vertex position
528  float d0PV = tk.dxy(*point); //re-evaluate the dxy with respect to the vertex position
529  if(useVtxError_){
530  float dzErrPV = std::sqrt(dzE*dzE+vzerr[iv]*vzerr[iv]); // include vertex error in z
531  float d0ErrPV = std::sqrt(d0E*d0E+vterr[iv]*vterr[iv]); // include vertex error in xy
532  iv++;
533  if (abs(dzPV) < dz_par1_[tsNum][0]*pow(nlayers,dz_par1_[tsNum][1])*nomdzE &&
534  abs(dzPV) < dz_par2_[tsNum][0]*pow(nlayers,dz_par2_[tsNum][1])*dzErrPV &&
535  abs(dzPV) < max_z0_[tsNum]) primaryVertexZCompatibility = true;
536  if (abs(d0PV) < d0_par1_[tsNum][0]*pow(nlayers,d0_par1_[tsNum][1])*nomd0E &&
537  abs(d0PV) < d0_par2_[tsNum][0]*pow(nlayers,d0_par2_[tsNum][1])*d0ErrPV &&
538  abs(d0PV) < max_d0_[tsNum]) primaryVertexD0Compatibility = true;
539  }else{
540  if (abs(dzPV) < dzCut) primaryVertexZCompatibility = true;
541  if (abs(d0PV) < d0Cut) primaryVertexD0Compatibility = true;
542  }
543  LogTrace("TrackSelection") << "distances " << dzPV << " " << d0PV << " vs " << dzCut << " " << d0Cut;
544  }
545 
546  if (points.empty() && applyAbsCutsIfNoPV_[tsNum]) {
547  if ( abs(dz) > max_z0NoPV_[tsNum] || abs(d0) > max_d0NoPV_[tsNum]) return false;
548  } else {
549  // Absolute cuts on all tracks impact parameters with respect to beam-spot.
550  // If BS is not compatible, verify if at least the reco-vertex is compatible (useful for incorrect BS settings)
551  if (abs(d0) > max_d0_[tsNum] && !primaryVertexD0Compatibility) return false;
552  LogTrace("TrackSelection") << "absolute cuts on d0 passed";
553  if (abs(dz) > max_z0_[tsNum] && !primaryVertexZCompatibility) return false;
554  LogTrace("TrackSelection") << "absolute cuts on dz passed";
555  }
556 
557  LogTrace("TrackSelection") << "cuts on PV: apply adapted PV cuts? " << applyAdaptedPVCuts_[tsNum]
558  << " d0 compatibility? " << primaryVertexD0Compatibility
559  << " z compatibility? " << primaryVertexZCompatibility ;
560 
561  if (applyAdaptedPVCuts_[tsNum]) {
562  return (primaryVertexD0Compatibility && primaryVertexZCompatibility);
563  } else {
564  return true;
565  }
566 
567 }
#define LogDebug(id)
virtual int dimension() const =0
double d0Error() const
error on d0
Definition: TrackBase.h:797
std::vector< uint32_t > max_lostLayers_
std::vector< uint32_t > min_hits_bypass_
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:189
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
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:119
std::vector< bool > useMVA_
std::vector< std::vector< double > > dz_par1_
std::vector< double > chi2n_par_
unsigned short numberOfLostHits() const
number of cases where track crossed a layer without getting a hit.
Definition: TrackBase.h:821
std::vector< std::vector< double > > res_par_
std::vector< int32_t > max_minMissHitOutOrIn_
std::vector< double > chi2n_no1Dmod_par_
std::vector< uint32_t > min_3Dlayers_
int pixelLayersWithMeasurement() const
Definition: HitPattern.cc:508
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:527
std::vector< double > min_eta_
int numberOfLostTrackerHits(HitCategory category) const
Definition: HitPattern.h:907
std::vector< double > max_eta_
std::vector< std::vector< double > > d0_par2_
std::vector< double > max_d0NoPV_
std::vector< std::vector< double > > d0_par1_
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:646
int numberOfValidStripLayersWithMonoAndStereo(uint16_t stripdet, uint16_t layer) const
Definition: HitPattern.cc:350
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
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< double > max_z0_
double f[11][100]
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:815
#define end
Definition: vmac.h:37
T min(T a, T b)
Definition: MathUtil.h:58
std::vector< std::vector< double > > dz_par2_
#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:604
double dzError() const
error on dz
Definition: TrackBase.h:809
std::vector< double > max_relpterr_
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
std::vector< int32_t > max_lostHitFraction_
std::vector< bool > applyAbsCutsIfNoPV_
int trackerLayersWithoutMeasurement(HitCategory category) const
Definition: HitPattern.cc:544
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:62
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< double > min_MVA_
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
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 569 of file HIMultiTrackSelector.cc.

References LogDebug, LogTrace, dt_dqm_sourceclient_common_cff::reco, mathSSE::sqrt(), vertexCut_, and vtxNumber_.

Referenced by run().

573  {
574  // Select good primary vertices
575  using namespace reco;
576  int32_t toTake = vtxNumber_[tsNum];
577  for (VertexCollection::const_iterator it = vtxs.begin(), ed = vtxs.end(); it != ed; ++it) {
578 
579  LogDebug("SelectVertex") << " select vertex with z position " << it->z() << " "
580  << it->chi2() << " " << it->ndof() << " " << TMath::Prob(it->chi2(), static_cast<int32_t>(it->ndof()));
581  Vertex vtx = *it;
582  bool pass = vertexCut_[tsNum]( vtx );
583  if( pass ) {
584  points.push_back(it->position());
585  vterr.push_back(sqrt(it->yError()*it->xError()));
586  vzerr.push_back(it->zError());
587  LogTrace("SelectVertex") << " SELECTED vertex with z position " << it->z();
588  toTake--; if (toTake == 0) break;
589  }
590  }
591 }
#define LogDebug(id)
std::vector< StringCutObjectSelector< reco::Vertex > > vertexCut_
T sqrt(T t)
Definition: SSEVec.h:18
std::vector< int32_t > vtxNumber_
vertex cuts
#define LogTrace(id)

Member Data Documentation

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

Definition at line 159 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 99 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 181 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 177 of file HIMultiTrackSelector.h.

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

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

Definition at line 178 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector().

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

Definition at line 98 of file HIMultiTrackSelector.h.

Referenced by processMVA(), and run().

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

Definition at line 161 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 157 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

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

Definition at line 154 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

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

Definition at line 151 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

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

Definition at line 143 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

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

Definition at line 150 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

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

Definition at line 147 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 158 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

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

Definition at line 142 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

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

Definition at line 153 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

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

Definition at line 144 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 141 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

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

Definition at line 173 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

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

Definition at line 148 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

std::string HIMultiTrackSelector::mvaType_
protected

Definition at line 176 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector().

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

Definition at line 171 of file HIMultiTrackSelector.h.

Referenced by processMVA().

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

Definition at line 165 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 137 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

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

Definition at line 136 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

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

Definition at line 164 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 97 of file HIMultiTrackSelector.h.

Referenced by processMVA(), and run().

bool HIMultiTrackSelector::useAnyMVA_
protected

Definition at line 102 of file HIMultiTrackSelector.h.

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

bool HIMultiTrackSelector::useForestFromDB_
protected

Definition at line 180 of file HIMultiTrackSelector.h.

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

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

Definition at line 168 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and select().

bool HIMultiTrackSelector::useVertices_
protected

Definition at line 100 of file HIMultiTrackSelector.h.

Referenced by HIMultiTrackSelector(), and run().

bool HIMultiTrackSelector::useVtxError_
protected

Definition at line 101 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 103 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().