CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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, 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
 

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)
 
 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 (const std::string &iProcessName, std::vector< const char * > &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
 
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) 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_
 
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
< TrackingRecHitCollection
hSrc_
 
std::vector< bool > keepAllTracks_
 
std::vector< double > max_d0_
 Impact parameter absolute cuts. More...
 
std::vector< double > max_d0NoPV_
 
std::vector< double > max_eta_
 
std::vector< int32_t > max_lostHitFraction_
 
std::vector< uint32_t > max_lostLayers_
 
std::vector< int32_t > max_minMissHitOutOrIn_
 
std::vector< double > max_relpterr_
 
std::vector< double > max_z0_
 
std::vector< double > max_z0NoPV_
 
std::vector< uint32_t > min_3Dlayers_
 
std::vector< double > min_eta_
 
std::vector< uint32_t > min_hits_bypass_
 
std::vector< uint32_t > min_layers_
 Cuts on numbers of layers with hits/3D hits/lost hits. More...
 
std::vector< double > min_MVA_
 
std::vector< uint32_t > min_nhits_
 
std::vector< std::string > mvaType_
 
std::vector< std::string > name_
 
std::vector< double > nSigmaZ_
 
std::vector< unsigned int > preFilter_
 
std::vector
< reco::TrackBase::TrackQuality
qualityToSet_
 
std::vector< std::vector
< double > > 
res_par_
 
std::vector< bool > setQualityBit_
 do I have to set a quality bit? More...
 
edm::EDGetTokenT
< reco::TrackCollection
src_
 source collection label More...
 
bool useAnyMVA_
 
bool useForestFromDB_
 
std::vector< bool > useMVA_
 
std::vector< bool > useMVAonly_
 
bool useVertices_
 
bool useVtxError_
 
std::vector
< StringCutObjectSelector
< reco::Vertex > > 
vertexCut_
 
edm::EDGetTokenT
< reco::VertexCollection
vertices_
 
std::vector< int32_t > vtxNumber_
 vertex cuts More...
 

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 58 of file MultiTrackSelector.cc.

59 {
60  useForestFromDB_ = true;
61 }
MultiTrackSelector::MultiTrackSelector ( const edm::ParameterSet cfg)
explicit

Definition at line 63 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(), 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_, preFilter_, qualityToSet_, res_par_, setQualityBit_, AlCaHLTBitMon_QueryRunRegistry::string, useAnyMVA_, useForestFromDB_, useMVA_, useMVAonly_, useVertices_, useVtxError_, vertexCut_, vertices_, and vtxNumber_.

63  :
64  src_( consumes<reco::TrackCollection>( cfg.getParameter<edm::InputTag>( "src" ) ) ),
65  hSrc_(consumes<TrackingRecHitCollection>( cfg.getParameter<edm::InputTag>( "src" ) ) ),
66  beamspot_( consumes<reco::BeamSpot>( cfg.getParameter<edm::InputTag>( "beamspot" ) ) ),
67  useVertices_( cfg.getParameter<bool>( "useVertices" ) ),
68  useVtxError_( cfg.getParameter<bool>( "useVtxError" ) )
69  // now get the pset for each selector
70 {
71  if (useVertices_) vertices_ = consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>( "vertices" ));
72  if(useVtxError_){
73  edm::LogWarning("MultiTRackSelector") << "you are executing buggy code, if intentional please help to fix it";
74  }
75  useAnyMVA_ = false;
76  useForestFromDB_ = true;
77  dbFileName_ = "";
78 
79  if(cfg.exists("useAnyMVA")) useAnyMVA_ = cfg.getParameter<bool>("useAnyMVA");
80 
81  if(useAnyMVA_){
82  if(cfg.exists("GBRForestFileName")){
83  dbFileName_ = cfg.getParameter<std::string>("GBRForestFileName");
84  useForestFromDB_ = false;
85  }
86  }
87  std::vector<edm::ParameterSet> trkSelectors( cfg.getParameter<std::vector< edm::ParameterSet> >("trackSelectors") );
88  qualityToSet_.reserve(trkSelectors.size());
89  vtxNumber_.reserve(trkSelectors.size());
90  vertexCut_.reserve(trkSelectors.size());
91  res_par_.reserve(trkSelectors.size());
92  chi2n_par_.reserve(trkSelectors.size());
93  chi2n_no1Dmod_par_.reserve(trkSelectors.size());
94  d0_par1_.reserve(trkSelectors.size());
95  dz_par1_.reserve(trkSelectors.size());
96  d0_par2_.reserve(trkSelectors.size());
97  dz_par2_.reserve(trkSelectors.size());
98  applyAdaptedPVCuts_.reserve(trkSelectors.size());
99  max_d0_.reserve(trkSelectors.size());
100  max_z0_.reserve(trkSelectors.size());
101  nSigmaZ_.reserve(trkSelectors.size());
102  min_layers_.reserve(trkSelectors.size());
103  min_3Dlayers_.reserve(trkSelectors.size());
104  max_lostLayers_.reserve(trkSelectors.size());
105  min_hits_bypass_.reserve(trkSelectors.size());
106  applyAbsCutsIfNoPV_.reserve(trkSelectors.size());
107  max_d0NoPV_.reserve(trkSelectors.size());
108  max_z0NoPV_.reserve(trkSelectors.size());
109  preFilter_.reserve(trkSelectors.size());
110  max_relpterr_.reserve(trkSelectors.size());
111  min_nhits_.reserve(trkSelectors.size());
112  max_minMissHitOutOrIn_.reserve(trkSelectors.size());
113  max_lostHitFraction_.reserve(trkSelectors.size());
114  min_eta_.reserve(trkSelectors.size());
115  max_eta_.reserve(trkSelectors.size());
116  useMVA_.reserve(trkSelectors.size());
117  useMVAonly_.reserve(trkSelectors.size());
118  //mvaReaders_.reserve(trkSelectors.size());
119  min_MVA_.reserve(trkSelectors.size());
120  mvaType_.reserve(trkSelectors.size());
121  forestLabel_.reserve(trkSelectors.size());
122  forest_.reserve(trkSelectors.size());
123 
124  produces<edm::ValueMap<float> >("MVAVals");
125 
126  //foward compatibility
127  produces<MVACollection>("MVAValues");
128 
129 
130  for ( unsigned int i=0; i<trkSelectors.size(); i++) {
131 
132  qualityToSet_.push_back( TrackBase::undefQuality );
133  // parameters for vertex selection
134  vtxNumber_.push_back( useVertices_ ? trkSelectors[i].getParameter<int32_t>("vtxNumber") : 0 );
135  vertexCut_.push_back( useVertices_ ? trkSelectors[i].getParameter<std::string>("vertexCut") : 0);
136  // parameters for adapted optimal cuts on chi2 and primary vertex compatibility
137  res_par_.push_back(trkSelectors[i].getParameter< std::vector<double> >("res_par") );
138  chi2n_par_.push_back( trkSelectors[i].getParameter<double>("chi2n_par") );
139  chi2n_no1Dmod_par_.push_back( trkSelectors[i].getParameter<double>("chi2n_no1Dmod_par") );
140  d0_par1_.push_back(trkSelectors[i].getParameter< std::vector<double> >("d0_par1"));
141  dz_par1_.push_back(trkSelectors[i].getParameter< std::vector<double> >("dz_par1"));
142  d0_par2_.push_back(trkSelectors[i].getParameter< std::vector<double> >("d0_par2"));
143  dz_par2_.push_back(trkSelectors[i].getParameter< std::vector<double> >("dz_par2"));
144  // Boolean indicating if adapted primary vertex compatibility cuts are to be applied.
145  applyAdaptedPVCuts_.push_back(trkSelectors[i].getParameter<bool>("applyAdaptedPVCuts"));
146  // Impact parameter absolute cuts.
147  max_d0_.push_back(trkSelectors[i].getParameter<double>("max_d0"));
148  max_z0_.push_back(trkSelectors[i].getParameter<double>("max_z0"));
149  nSigmaZ_.push_back(trkSelectors[i].getParameter<double>("nSigmaZ"));
150  // Cuts on numbers of layers with hits/3D hits/lost hits.
151  min_layers_.push_back(trkSelectors[i].getParameter<uint32_t>("minNumberLayers") );
152  min_3Dlayers_.push_back(trkSelectors[i].getParameter<uint32_t>("minNumber3DLayers") );
153  max_lostLayers_.push_back(trkSelectors[i].getParameter<uint32_t>("maxNumberLostLayers"));
154  min_hits_bypass_.push_back(trkSelectors[i].getParameter<uint32_t>("minHitsToBypassChecks"));
155  // Flag to apply absolute cuts if no PV passes the selection
156  applyAbsCutsIfNoPV_.push_back(trkSelectors[i].getParameter<bool>("applyAbsCutsIfNoPV"));
157  keepAllTracks_.push_back( trkSelectors[i].getParameter<bool>("keepAllTracks"));
158  max_relpterr_.push_back(trkSelectors[i].getParameter<double>("max_relpterr"));
159  min_nhits_.push_back(trkSelectors[i].getParameter<uint32_t>("min_nhits"));
160  max_minMissHitOutOrIn_.push_back(
161  trkSelectors[i].existsAs<int32_t>("max_minMissHitOutOrIn") ?
162  trkSelectors[i].getParameter<int32_t>("max_minMissHitOutOrIn") : 99);
163  max_lostHitFraction_.push_back(
164  trkSelectors[i].existsAs<double>("max_lostHitFraction") ?
165  trkSelectors[i].getParameter<double>("max_lostHitFraction") : 1.0);
166  min_eta_.push_back(trkSelectors[i].existsAs<double>("min_eta") ?
167  trkSelectors[i].getParameter<double>("min_eta"):-9999);
168  max_eta_.push_back(trkSelectors[i].existsAs<double>("max_eta") ?
169  trkSelectors[i].getParameter<double>("max_eta"):9999);
170 
171  setQualityBit_.push_back( false );
172  std::string qualityStr = trkSelectors[i].getParameter<std::string>("qualityBit");
173  if (qualityStr != "") {
174  setQualityBit_[i] = true;
175  qualityToSet_[i] = TrackBase::qualityByName(trkSelectors[i].getParameter<std::string>("qualityBit"));
176  }
177 
178  if (setQualityBit_[i] && (qualityToSet_[i] == TrackBase::undefQuality)) throw cms::Exception("Configuration") <<
179  "You can't set the quality bit " << trkSelectors[i].getParameter<std::string>("qualityBit") << " as it is 'undefQuality' or unknown.\n";
180 
181  if (applyAbsCutsIfNoPV_[i]) {
182  max_d0NoPV_.push_back(trkSelectors[i].getParameter<double>("max_d0NoPV"));
183  max_z0NoPV_.push_back(trkSelectors[i].getParameter<double>("max_z0NoPV"));
184  }
185  else{//dummy values
186  max_d0NoPV_.push_back(0.);
187  max_z0NoPV_.push_back(0.);
188  }
189 
190  name_.push_back( trkSelectors[i].getParameter<std::string>("name") );
191 
192  preFilter_[i]=trkSelectors.size(); // no prefilter
193 
194  std::string pfName=trkSelectors[i].getParameter<std::string>("preFilterName");
195  if (pfName!="") {
196  bool foundPF=false;
197  for ( unsigned int j=0; j<i; j++)
198  if (name_[j]==pfName ) {
199  foundPF=true;
200  preFilter_[i]=j;
201  }
202  if ( !foundPF)
203  throw cms::Exception("Configuration") << "Invalid prefilter name in MultiTrackSelector "
204  << trkSelectors[i].getParameter<std::string>("preFilterName");
205 
206  }
207 
208  // produces<std::vector<int> >(name_[i]).setBranchAlias( name_[i] + "TrackQuals");
209  produces<edm::ValueMap<int> >(name_[i]).setBranchAlias( name_[i] + "TrackQuals");
210  produces<QualityMaskCollection>(name_[i]).setBranchAlias( name_[i] + "QualityMasks");
211  if(useAnyMVA_){
212  bool thisMVA = false;
213  if(trkSelectors[i].exists("useMVA"))thisMVA = trkSelectors[i].getParameter<bool>("useMVA");
214  useMVA_.push_back(thisMVA);
215  if(thisMVA){
216  double minVal = -1;
217  if(trkSelectors[i].exists("minMVA"))minVal = trkSelectors[i].getParameter<double>("minMVA");
218  min_MVA_.push_back(minVal);
219  mvaType_.push_back(trkSelectors[i].exists("mvaType") ? trkSelectors[i].getParameter<std::string>("mvaType") : "Detached");
220  forestLabel_.push_back(trkSelectors[i].exists("GBRForestLabel") ? trkSelectors[i].getParameter<std::string>("GBRForestLabel") : "MVASelectorIter0");
221  useMVAonly_.push_back(trkSelectors[i].exists("useMVAonly") ? trkSelectors[i].getParameter<bool>("useMVAonly") : false);
222  }else{
223  min_MVA_.push_back(-9999.0);
224  useMVAonly_.push_back(false);
225  mvaType_.push_back("Detached");
226  forestLabel_.push_back("MVASelectorIter0");
227  }
228  }else{
229  useMVA_.push_back(false);
230  useMVAonly_.push_back(false);
231  min_MVA_.push_back(-9999.0);
232  mvaType_.push_back("Detached");
233  forestLabel_.push_back("MVASelectorIter0");
234  }
235 
236  }
237 }
std::vector< double > chi2n_no1Dmod_par_
T getParameter(std::string const &) const
std::vector< uint32_t > min_nhits_
std::vector< double > chi2n_par_
int i
Definition: DBlmapReader.cc:9
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?
int j
Definition: DBlmapReader.cc:9
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 239 of file MultiTrackSelector.cc.

References forest_.

239  {
240  for(auto forest : forest_)delete forest;
241 }
std::vector< GBRForest * > forest_

Member Function Documentation

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

Reimplemented from edm::stream::EDProducerBase.

Definition at line 244 of file MultiTrackSelector.cc.

References dbFileName_, forest_, forestLabel_, i, and useForestFromDB_.

244  {
245  if(!useForestFromDB_){
246  TFile gbrfile(dbFileName_.c_str());
247  for(int i = 0; i < (int)forestLabel_.size(); i++){
248  forest_[i] = (GBRForest*)gbrfile.Get(forestLabel_[i].c_str());
249  }
250  }
251 
252 }
int i
Definition: DBlmapReader.cc:9
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 677 of file MultiTrackSelector.cc.

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

Referenced by processMVA().

677  {
678  Point p(0,0,-99999);
679  Point p_dz(0,0,-99999);
680  float bestWeight = 0;
681  float dzmin = 10000;
682  bool weightMatch = false;
683  for(auto const & vertex : vertices){
684  float w = vertex.trackWeight(track);
685  Point v_pos = vertex.position();
686  if(w > bestWeight){
687  p = v_pos;
688  bestWeight = w;
689  weightMatch = true;
690  }
691  float dz = fabs(track.get()->dz(v_pos));
692  if(dz < dzmin){
693  p_dz = v_pos;
694  dzmin = dz;
695  }
696  }
697  if(weightMatch)return p;
698  else return p_dz;
699 }
value_type const * get() const
Definition: RefToBase.h:225
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:596
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 554 of file MultiTrackSelector.cc.

References assert(), reco::TrackBase::chi2(), chi2n, cond::rpcobimon::current, TrackingRecHit::dimension(), reco::TrackBase::dxy(), reco::TrackBase::dz(), reco::TrackBase::eta(), reco::Track::extra(), f, forest_, forestLabel_, edm::EventSetup::get(), getBestVertex(), edm::Event::getByToken(), GBRForest::GetClassifier(), reco::TrackBase::hitPattern(), hSrc_, bookConverter::max, min(), reco::HitPattern::MISSING_INNER_HITS, reco::HitPattern::MISSING_OUTER_HITS, 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< class >::product(), reco::TrackBase::pt(), reco::TrackBase::ptError(), edm::Event::put(), reco::Track::recHitsSize(), dt_dqm_sourceclient_common_cff::reco, src_, reco::HitPattern::TRACK_HITS, reco::HitPattern::trackerLayersWithMeasurement(), reco::HitPattern::trackerLayersWithoutMeasurement(), useAnyMVA_, useForestFromDB_, and useMVA_.

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

555 {
556 
557  using namespace std;
558  using namespace edm;
559  using namespace reco;
560 
561  // Get tracks
562  Handle<TrackCollection> hSrcTrack;
563  evt.getByToken( src_, hSrcTrack );
564  const TrackCollection& srcTracks(*hSrcTrack);
565  RefToBaseProd<Track> rtbpTrackCollection(hSrcTrack);
566  assert(mvaVals_.size()==srcTracks.size());
567 
568  // get hits in track..
570  evt.getByToken( hSrc_, hSrcHits );
571  const TrackingRecHitCollection & srcHits(*hSrcHits);
572 
573 
574  auto_ptr<edm::ValueMap<float> >mvaValValueMap = auto_ptr<edm::ValueMap<float> >(new edm::ValueMap<float>);
575  edm::ValueMap<float>::Filler mvaFiller(*mvaValValueMap);
576 
577 
578  if(!useAnyMVA_ && writeIt){
579  // mvaVals_ already initalized...
580  mvaFiller.insert(hSrcTrack,mvaVals_.begin(),mvaVals_.end());
581  mvaFiller.fill();
582  evt.put(mvaValValueMap,"MVAVals");
583  auto mvas = std::make_unique<MVACollection>(mvaVals_.begin(),mvaVals_.end());
584  evt.put(std::move(mvas),"MVAValues");
585  return;
586  }
587 
588  if(!useMVA_[selIndex] && !writeIt)return;
589 
590 
591  size_t current = 0;
592  for (TrackCollection::const_iterator it = srcTracks.begin(), ed = srcTracks.end(); it != ed; ++it, ++current) {
593  const Track & trk = * it;
594  RefToBase<Track> trackRef(rtbpTrackCollection,current);
595  auto tmva_ndof_ = trk.ndof();
596  auto tmva_nlayers_ = trk.hitPattern().trackerLayersWithMeasurement();
597  auto tmva_nlayers3D_ = trk.hitPattern().pixelLayersWithMeasurement()
600  float chi2n = trk.normalizedChi2();
601  float chi2n_no1Dmod = chi2n;
602 
603  int count1dhits = 0;
604  auto ith = trk.extra()->firstRecHit();
605  auto edh = ith + trk.recHitsSize();
606  for (; ith<edh; ++ith) {
607  const TrackingRecHit & hit = srcHits[ith];
608  if (hit.dimension()==1) ++count1dhits;
609  }
610  if (count1dhits > 0) {
611  float chi2 = trk.chi2();
612  float ndof = trk.ndof();
613  chi2n = (chi2+count1dhits)/float(ndof+count1dhits);
614  }
615  auto tmva_chi2n_ = chi2n;
616  auto tmva_chi2n_no1dmod_ = chi2n_no1Dmod;
617  auto tmva_eta_ = trk.eta();
618  auto tmva_relpterr_ = float(trk.ptError())/std::max(float(trk.pt()),0.000001f);
619  auto tmva_nhits_ = trk.numberOfValidHits();
622  auto tmva_minlost_ = std::min(lostIn,lostOut);
623  auto tmva_lostmidfrac_ = trk.numberOfLostHits() / (trk.numberOfValidHits() + trk.numberOfLostHits());
624  auto tmva_absd0_ = fabs(-trk.dxy(beamspot.position()));
625  auto tmva_absdz_ = fabs(trk.dz(beamspot.position()));
626  Point bestVertex = getBestVertex(trackRef,vertices);
627  auto tmva_absd0PV_ = fabs(trk.dxy(bestVertex));
628  auto tmva_absdzPV_ = fabs(trk.dz(bestVertex));
629  auto tmva_pt_ = trk.pt();
630 
631  GBRForest const * forest = forest_[selIndex];
632  if(useForestFromDB_){
633  edm::ESHandle<GBRForest> forestHandle;
634  es.get<GBRWrapperRcd>().get(forestLabel_[selIndex],forestHandle);
635  forest = forestHandle.product();
636  }
637 
638  float gbrVals_[16];
639  gbrVals_[0] = tmva_pt_;
640  gbrVals_[1] = tmva_lostmidfrac_;
641  gbrVals_[2] = tmva_minlost_;
642  gbrVals_[3] = tmva_nhits_;
643  gbrVals_[4] = tmva_relpterr_;
644  gbrVals_[5] = tmva_eta_;
645  gbrVals_[6] = tmva_chi2n_no1dmod_;
646  gbrVals_[7] = tmva_chi2n_;
647  gbrVals_[8] = tmva_nlayerslost_;
648  gbrVals_[9] = tmva_nlayers3D_;
649  gbrVals_[10] = tmva_nlayers_;
650  gbrVals_[11] = tmva_ndof_;
651  gbrVals_[12] = tmva_absd0PV_;
652  gbrVals_[13] = tmva_absdzPV_;
653  gbrVals_[14] = tmva_absdz_;
654  gbrVals_[15] = tmva_absd0_;
655 
656  if (mvaType_[selIndex] == "Prompt"){
657  auto gbrVal = forest->GetClassifier(gbrVals_);
658  mvaVals_[current] = gbrVal;
659  }else{
660  float detachedGbrVals_[12];
661  for(int jjj = 0; jjj < 12; jjj++)detachedGbrVals_[jjj] = gbrVals_[jjj];
662  auto gbrVal = forest->GetClassifier(detachedGbrVals_);
663  mvaVals_[current] = gbrVal;
664  }
665  }
666 
667  if(writeIt){
668  mvaFiller.insert(hSrcTrack,mvaVals_.begin(),mvaVals_.end());
669  mvaFiller.fill();
670  evt.put(mvaValValueMap,"MVAVals");
671  auto mvas = std::make_unique<MVACollection>(mvaVals_.begin(),mvaVals_.end());
672  evt.put(std::move(mvas),"MVAValues");
673  }
674 
675 }
virtual int dimension() const =0
const TrackExtraRef & extra() const
reference to &quot;extra&quot; 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:548
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
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
assert(m_qm.get())
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:813
std::vector< std::string > mvaType_
int pixelLayersWithMeasurement() const
Definition: HitPattern.cc:497
edm::EDGetTokenT< TrackingRecHitCollection > hSrc_
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:516
int numberOfLostTrackerHits(HitCategory category) const
Definition: HitPattern.h:881
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:638
int numberOfValidStripLayersWithMonoAndStereo(uint16_t stripdet, uint16_t layer) const
Definition: HitPattern.cc:339
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:536
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
double ndof() const
number of degrees of freedom of the fit
Definition: TrackBase.h:542
double pt() const
track transverse momentum
Definition: TrackBase.h:608
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:750
math::XYZPoint Point
double f[11][100]
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:807
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:596
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:437
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
std::vector< std::string > forestLabel_
int trackerLayersWithoutMeasurement(HitCategory category) const
Definition: HitPattern.cc:533
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:578
double GetClassifier(const float *vector) const
Definition: GBRForest.h:43
std::vector< GBRForest * > forest_
void MultiTrackSelector::produce ( edm::Event evt,
const edm::EventSetup es 
)
inlinefinaloverrideprotectedvirtual

process one event

Implements edm::stream::EDProducerBase.

Definition at line 59 of file MultiTrackSelector.h.

References DTTTrigCorrFirst::run.

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 256 of file MultiTrackSelector.cc.

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

257 {
258  using namespace std;
259  using namespace edm;
260  using namespace reco;
261 
262  // Get tracks
263  Handle<TrackCollection> hSrcTrack;
264  evt.getByToken(src_, hSrcTrack );
265 
266  const TrackCollection& srcTracks(*hSrcTrack);
267  if (hSrcTrack.failedToGet())
268  edm::LogWarning("MultiTrackSelector")<<"could not get Track collection";
269 
270  // get hits in track..
272  evt.getByToken(hSrc_, hSrcHits );
273  const TrackingRecHitCollection & srcHits(*hSrcHits);
274 
275 
276  // looking for the beam spot
278  evt.getByToken(beamspot_, hBsp);
279  const reco::BeamSpot& vertexBeamSpot(*hBsp);
280 
281  // Select good primary vertices for use in subsequent track selection
283  if (useVertices_) {
284  evt.getByToken(vertices_, hVtx);
285  if (hVtx.failedToGet())
286  edm::LogWarning("MultiTrackSelector")<<"could not get Vertex collection";
287  }
288 
289  unsigned int trkSize=srcTracks.size();
290  std::vector<int> selTracksSave( qualityToSet_.size()*trkSize,0);
291 
292  std::vector<Point> points;
293  std::vector<float> vterr, vzerr;
294  if (useVertices_) selectVertices(0,*hVtx, points, vterr, vzerr);
295  //auto vtxP = points.empty() ? vertexBeamSpot.position() : points[0]; // rare, very rare, still happens!
296  for (unsigned int i=0; i<qualityToSet_.size(); i++) {
297  std::vector<float> mvaVals_(srcTracks.size(),-99.f);
298  processMVA(evt,es,vertexBeamSpot,*(hVtx.product()), i, mvaVals_, i == 0 ? true : false);
299  std::vector<int> selTracks(trkSize,0);
300  auto_ptr<edm::ValueMap<int> > selTracksValueMap = auto_ptr<edm::ValueMap<int> >(new edm::ValueMap<int>);
301  edm::ValueMap<int>::Filler filler(*selTracksValueMap);
302 
303  if (useVertices_) selectVertices(i,*hVtx, points, vterr, vzerr);
304 
305  // Loop over tracks
306  size_t current = 0;
307  for (TrackCollection::const_iterator it = srcTracks.begin(), ed = srcTracks.end(); it != ed; ++it, ++current) {
308  const Track & trk = * it;
309  // Check if this track passes cuts
310 
311  LogTrace("TrackSelection") << "ready to check track with pt="<< trk.pt() ;
312 
313  //already removed
314  bool ok=true;
315  if (preFilter_[i]<i && selTracksSave[preFilter_[i]*trkSize+current] < 0) {
316  selTracks[current]=-1;
317  ok=false;
318  if ( !keepAllTracks_[i])
319  continue;
320  }
321  else {
322  float mvaVal = 0;
323  if(useAnyMVA_) mvaVal = mvaVals_[current];
324  ok = select(i,vertexBeamSpot, srcHits, trk, points, vterr, vzerr,mvaVal);
325  if (!ok) {
326  LogTrace("TrackSelection") << "track with pt="<< trk.pt() << " NOT selected";
327  if (!keepAllTracks_[i]) {
328  selTracks[current]=-1;
329  continue;
330  }
331  }
332  else
333  LogTrace("TrackSelection") << "track with pt="<< trk.pt() << " selected";
334  }
335 
336  if (preFilter_[i]<i ) {
337  selTracks[current]=selTracksSave[preFilter_[i]*trkSize+current];
338  }
339  else {
340  selTracks[current]=trk.qualityMask();
341  }
342  if ( ok && setQualityBit_[i]) {
343  selTracks[current]= (selTracks[current] | (1<<qualityToSet_[i]));
344  if (qualityToSet_[i]==TrackBase::tight) {
345  selTracks[current]=(selTracks[current] | (1<<TrackBase::loose));
346  }
347  else if (qualityToSet_[i]==TrackBase::highPurity) {
348  selTracks[current]=(selTracks[current] | (1<<TrackBase::loose));
349  selTracks[current]=(selTracks[current] | (1<<TrackBase::tight));
350  }
351  if (!points.empty()) {
352  if (qualityToSet_[i]==TrackBase::loose) {
353  selTracks[current]=(selTracks[current] | (1<<TrackBase::looseSetWithPV));
354  }
355  else if (qualityToSet_[i]==TrackBase::highPurity) {
356  selTracks[current]=(selTracks[current] | (1<<TrackBase::looseSetWithPV));
357  selTracks[current]=(selTracks[current] | (1<<TrackBase::highPuritySetWithPV));
358  }
359  }
360  }
361  }
362  for ( unsigned int j=0; j< trkSize; j++ ) selTracksSave[j+i*trkSize]=selTracks[j];
363  filler.insert(hSrcTrack, selTracks.begin(),selTracks.end());
364  filler.fill();
365 
366  // evt.put(selTracks,name_[i]);
367  evt.put(selTracksValueMap,name_[i]);
368  for (auto & q : selTracks) q=std::max(q,0);
369  auto quals = std::make_unique<QualityMaskCollection>(selTracks.begin(),selTracks.end());
370  evt.put(std::move(quals),name_[i]);
371  }
372 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > name_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
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_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
std::vector< bool > setQualityBit_
do I have to set a quality bit?
double pt() const
track transverse momentum
Definition: TrackBase.h:608
int qualityMask() const
Definition: TrackBase.h:849
int j
Definition: DBlmapReader.cc:9
#define LogTrace(id)
void selectVertices(unsigned int tsNum, const reco::VertexCollection &vtxs, std::vector< Point > &points, std::vector< float > &vterr, std::vector< float > &vzerr) const
std::vector< reco::TrackBase::TrackQuality > qualityToSet_
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
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 375 of file MultiTrackSelector.cc.

References funct::abs(), applyAbsCutsIfNoPV_, applyAdaptedPVCuts_, reco::TrackBase::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_25ns14e33_v1_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(), 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().

382  {
383  // Decide if the given track passes selection cuts.
384 
385  using namespace std;
386 
387  //cuts on number of valid hits
388  auto nhits = tk.numberOfValidHits();
389  if(nhits>=min_hits_bypass_[tsNum]) return true;
390  if(nhits < min_nhits_[tsNum]) return false;
391 
392  if ( tk.ndof() < 1E-5 ) return false;
393 
394 
396  //Adding the MVA selection before any other cut//
398  if(useAnyMVA_ && useMVA_[tsNum]){
399  if (useMVAonly_[tsNum]) return mvaVal > min_MVA_[tsNum];
400  if(mvaVal < min_MVA_[tsNum])return false;
401  }
403  //End of MVA selection section//
405 
406 
407  // Cuts on numbers of layers with hits/3D hits/lost hits.
409  uint32_t nlayers3D = tk.hitPattern().pixelLayersWithMeasurement() +
412  LogDebug("TrackSelection") << "cuts on nlayers: " << nlayers << " " << nlayers3D << " " << nlayersLost << " vs "
413  << min_layers_[tsNum] << " " << min_3Dlayers_[tsNum] << " " << max_lostLayers_[tsNum];
414  if (nlayers < min_layers_[tsNum]) return false;
415  if (nlayers3D < min_3Dlayers_[tsNum]) return false;
416  if (nlayersLost > max_lostLayers_[tsNum]) return false;
417  LogTrace("TrackSelection") << "cuts on nlayers passed";
418 
419  float chi2n = tk.normalizedChi2();
420  float chi2n_no1Dmod = chi2n;
421 
422  int count1dhits = 0;
423  auto ith = tk.extra()->firstRecHit();
424  auto edh = ith + tk.recHitsSize();
425  for (; ith<edh; ++ith) {
426  const TrackingRecHit & hit = recHits[ith];
427  if (hit.dimension()==1) ++count1dhits;
428  }
429  if (count1dhits > 0) {
430  float chi2 = tk.chi2();
431  float ndof = tk.ndof();
432  chi2n = (chi2+count1dhits)/float(ndof+count1dhits);
433  }
434  // For each 1D rechit, the chi^2 and ndof is increased by one. This is a way of retaining approximately
435  // the same normalized chi^2 distribution as with 2D rechits.
436  if (chi2n > chi2n_par_[tsNum]*nlayers) return false;
437 
438  if (chi2n_no1Dmod > chi2n_no1Dmod_par_[tsNum]*nlayers) return false;
439 
440  // Get track parameters
441  float pt = std::max(float(tk.pt()),0.000001f);
442  float eta = tk.eta();
443  if (eta<min_eta_[tsNum] || eta>max_eta_[tsNum]) return false;
444 
445  //cuts on relative error on pt
446  float relpterr = float(tk.ptError())/pt;
447  if(relpterr > max_relpterr_[tsNum]) return false;
448 
451  int minLost = std::min(lostIn,lostOut);
452  if (minLost > max_minMissHitOutOrIn_[tsNum]) return false;
453  float lostMidFrac = tk.numberOfLostHits() / (tk.numberOfValidHits() + tk.numberOfLostHits());
454  if (lostMidFrac > max_lostHitFraction_[tsNum]) return false;
455 
456 
457 
458  //other track parameters
459  float d0 = -tk.dxy(vertexBeamSpot.position()), d0E = tk.d0Error(),
460  dz = tk.dz(vertexBeamSpot.position()), dzE = tk.dzError();
461 
462  // parametrized d0 resolution for the track pt
463  float nomd0E = sqrt(res_par_[tsNum][0]*res_par_[tsNum][0]+(res_par_[tsNum][1]/pt)*(res_par_[tsNum][1]/pt));
464  // parametrized z0 resolution for the track pt and eta
465  float nomdzE = nomd0E*(std::cosh(eta));
466 
467  float dzCut = std::min( powN(dz_par1_[tsNum][0]*nlayers,int(dz_par1_[tsNum][1]+0.5))*nomdzE,
468  powN(dz_par2_[tsNum][0]*nlayers,int(dz_par2_[tsNum][1]+0.5))*dzE );
469  float d0Cut = std::min( powN(d0_par1_[tsNum][0]*nlayers,int(d0_par1_[tsNum][1]+0.5))*nomd0E,
470  powN(d0_par2_[tsNum][0]*nlayers,int(d0_par2_[tsNum][1]+0.5))*d0E );
471 
472 
473  // ---- PrimaryVertex compatibility cut
474  bool primaryVertexZCompatibility(false);
475  bool primaryVertexD0Compatibility(false);
476 
477  if (points.empty()) { //If not primaryVertices are reconstructed, check just the compatibility with the BS
478  //z0 within (n sigma + dzCut) of the beam spot z, if no good vertex is found
479  if ( abs(dz) < hypot(vertexBeamSpot.sigmaZ()*nSigmaZ_[tsNum],dzCut) ) primaryVertexZCompatibility = true;
480  // d0 compatibility with beam line
481  if (abs(d0) < d0Cut) primaryVertexD0Compatibility = true;
482  }
483 
484  int iv=0;
485  for (std::vector<Point>::const_iterator point = points.begin(), end = points.end(); point != end; ++point) {
486  LogTrace("TrackSelection") << "Test track w.r.t. vertex with z position " << point->z();
487  if(primaryVertexZCompatibility && primaryVertexD0Compatibility) break;
488  float dzPV = tk.dz(*point); //re-evaluate the dz with respect to the vertex position
489  float d0PV = tk.dxy(*point); //re-evaluate the dxy with respect to the vertex position
490  if(useVtxError_){
491  float dzErrPV = std::sqrt(dzE*dzE+vzerr[iv]*vzerr[iv]); // include vertex error in z
492  float d0ErrPV = std::sqrt(d0E*d0E+vterr[iv]*vterr[iv]); // include vertex error in xy
493  iv++;
494  if (abs(dzPV) < dz_par1_[tsNum][0]*pow(nlayers,dz_par1_[tsNum][1])*nomdzE &&
495  abs(dzPV) < dz_par2_[tsNum][0]*pow(nlayers,dz_par2_[tsNum][1])*dzErrPV &&
496  abs(dzPV) < max_z0_[tsNum]) primaryVertexZCompatibility = true;
497  if (abs(d0PV) < d0_par1_[tsNum][0]*pow(nlayers,d0_par1_[tsNum][1])*nomd0E &&
498  abs(d0PV) < d0_par2_[tsNum][0]*pow(nlayers,d0_par2_[tsNum][1])*d0ErrPV &&
499  abs(d0PV) < max_d0_[tsNum]) primaryVertexD0Compatibility = true;
500  }else{
501  if (abs(dzPV) < dzCut) primaryVertexZCompatibility = true;
502  if (abs(d0PV) < d0Cut) primaryVertexD0Compatibility = true;
503  }
504  LogTrace("TrackSelection") << "distances " << dzPV << " " << d0PV << " vs " << dzCut << " " << d0Cut;
505  }
506 
507  if (points.empty() && applyAbsCutsIfNoPV_[tsNum]) {
508  if ( abs(dz) > max_z0NoPV_[tsNum] || abs(d0) > max_d0NoPV_[tsNum]) return false;
509  } else {
510  // Absolute cuts on all tracks impact parameters with respect to beam-spot.
511  // If BS is not compatible, verify if at least the reco-vertex is compatible (useful for incorrect BS settings)
512  if (abs(d0) > max_d0_[tsNum] && !primaryVertexD0Compatibility) return false;
513  LogTrace("TrackSelection") << "absolute cuts on d0 passed";
514  if (abs(dz) > max_z0_[tsNum] && !primaryVertexZCompatibility) return false;
515  LogTrace("TrackSelection") << "absolute cuts on dz passed";
516  }
517 
518  LogTrace("TrackSelection") << "cuts on PV: apply adapted PV cuts? " << applyAdaptedPVCuts_[tsNum]
519  << " d0 compatibility? " << primaryVertexD0Compatibility
520  << " z compatibility? " << primaryVertexZCompatibility ;
521 
522  if (applyAdaptedPVCuts_[tsNum]) {
523  return (primaryVertexD0Compatibility && primaryVertexZCompatibility);
524  } else {
525  return true;
526  }
527 
528 }
#define LogDebug(id)
std::vector< double > chi2n_no1Dmod_par_
std::vector< uint32_t > min_nhits_
std::vector< double > chi2n_par_
virtual int dimension() const =0
std::vector< std::vector< double > > d0_par1_
std::vector< double > max_d0NoPV_
double d0Error() const
error on d0
Definition: TrackBase.h:789
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 &quot;extra&quot; 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:548
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:813
std::vector< double > nSigmaZ_
int pixelLayersWithMeasurement() const
Definition: HitPattern.cc:497
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:516
std::vector< uint32_t > min_3Dlayers_
int numberOfLostTrackerHits(HitCategory category) const
Definition: HitPattern.h:881
std::vector< uint32_t > max_lostLayers_
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:638
int numberOfValidStripLayersWithMonoAndStereo(uint16_t stripdet, uint16_t layer) const
Definition: HitPattern.cc:339
std::vector< int32_t > max_lostHitFraction_
std::vector< double > min_eta_
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:536
double ndof() const
number of degrees of freedom of the fit
Definition: TrackBase.h:542
T sqrt(T t)
Definition: SSEVec.h:48
double pt() const
track transverse momentum
Definition: TrackBase.h:608
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:750
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:807
#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:596
double dzError() const
error on dz
Definition: TrackBase.h:801
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:437
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
int trackerLayersWithoutMeasurement(HitCategory category) const
Definition: HitPattern.cc:533
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:578
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 530 of file MultiTrackSelector.cc.

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

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

534  {
535  // Select good primary vertices
536  using namespace reco;
537  int32_t toTake = vtxNumber_[tsNum];
538  for (VertexCollection::const_iterator it = vtxs.begin(), ed = vtxs.end(); it != ed; ++it) {
539 
540  LogDebug("SelectVertex") << " select vertex with z position " << it->z() << " "
541  << it->chi2() << " " << it->ndof() << " " << TMath::Prob(it->chi2(), static_cast<int32_t>(it->ndof()));
542  Vertex vtx = *it;
543  bool pass = vertexCut_[tsNum]( vtx );
544  if( pass ) {
545  points.push_back(it->position());
546  vterr.push_back(sqrt(it->yError()*it->xError()));
547  vzerr.push_back(it->zError());
548  LogTrace("SelectVertex") << " SELECTED vertex with z position " << it->z();
549  toTake--; if (toTake == 0) break;
550  }
551  }
552 }
#define LogDebug(id)
T sqrt(T t)
Definition: SSEVec.h:48
#define LogTrace(id)
std::vector< int32_t > vtxNumber_
vertex cuts
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