test
CMS 3D CMS Logo

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

Public Member Functions

 AnalyticalTrackSelector (const edm::ParameterSet &cfg)
 constructor More...
 
virtual ~AnalyticalTrackSelector ()
 destructor More...
 
- Public Member Functions inherited from MultiTrackSelector
 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 (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 ()
 

Private Types

typedef math::XYZPoint Point
 

Private Member Functions

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

Private Attributes

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

Additional Inherited Members

- Public Types inherited from MultiTrackSelector
using MVACollection = std::vector< float >
 
using QualityMaskCollection = std::vector< unsigned char >
 
- Public Types inherited from edm::stream::EDProducer<>
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)
 
- Protected Types inherited from MultiTrackSelector
typedef math::XYZPoint Point
 
- Protected Member Functions inherited from MultiTrackSelector
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...
 
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 inherited from MultiTrackSelector
std::vector< bool > applyAbsCutsIfNoPV_
 
std::vector< bool > applyAdaptedPVCuts_
 
edm::EDGetTokenT< reco::BeamSpotbeamspot_
 
std::vector< double > chi2n_no1Dmod_par_
 
std::vector< double > chi2n_par_
 
std::vector< std::vector
< double > > 
d0_par1_
 
std::vector< std::vector
< double > > 
d0_par2_
 
std::string dbFileName_
 
std::vector< std::vector
< double > > 
dz_par1_
 
std::vector< std::vector
< double > > 
dz_par2_
 
std::vector< GBRForest * > forest_
 
std::vector< std::string > forestLabel_
 
edm::EDGetTokenT
< TrackingRecHitCollection
hSrc_
 
std::vector< bool > keepAllTracks_
 
std::vector< double > max_d0_
 Impact parameter absolute cuts. More...
 
std::vector< double > max_d0NoPV_
 
std::vector< double > max_eta_
 
std::vector< int32_t > max_lostHitFraction_
 
std::vector< uint32_t > max_lostLayers_
 
std::vector< int32_t > max_minMissHitOutOrIn_
 
std::vector< double > max_relpterr_
 
std::vector< double > max_z0_
 
std::vector< double > max_z0NoPV_
 
std::vector< uint32_t > min_3Dlayers_
 
std::vector< double > min_eta_
 
std::vector< uint32_t > min_hits_bypass_
 
std::vector< uint32_t > min_layers_
 Cuts on numbers of layers with hits/3D hits/lost hits. More...
 
std::vector< double > min_MVA_
 
std::vector< uint32_t > min_nhits_
 
std::vector< std::string > mvaType_
 
std::vector< std::string > name_
 
std::vector< double > nSigmaZ_
 
std::vector< unsigned int > preFilter_
 
std::vector
< reco::TrackBase::TrackQuality
qualityToSet_
 
std::vector< std::vector
< double > > 
res_par_
 
std::vector< bool > setQualityBit_
 do I have to set a quality bit? More...
 
edm::EDGetTokenT
< reco::TrackCollection
src_
 source collection label More...
 
bool useAnyMVA_
 
bool useForestFromDB_
 
std::vector< bool > useMVA_
 
std::vector< bool > useMVAonly_
 
bool useVertices_
 
bool useVtxError_
 
std::vector
< StringCutObjectSelector
< reco::Vertex > > 
vertexCut_
 
edm::EDGetTokenT
< reco::VertexCollection
vertices_
 
std::vector< int32_t > vtxNumber_
 vertex cuts More...
 

Detailed Description

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

Author
Paolo Azzurri, Giovanni Petrucciani

Definition at line 36 of file AnalyticalTrackSelector.cc.

Member Typedef Documentation

Definition at line 45 of file AnalyticalTrackSelector.cc.

Constructor & Destructor Documentation

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

constructor

Definition at line 73 of file AnalyticalTrackSelector.cc.

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

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

destructor

Definition at line 237 of file AnalyticalTrackSelector.cc.

237  {
238 }

Member Function Documentation

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

process one event

Reimplemented from MultiTrackSelector.

Definition at line 241 of file AnalyticalTrackSelector.cc.

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

242 {
243 
244  // storage....
245  std::auto_ptr<reco::TrackCollection> selTracks_;
246  std::auto_ptr<reco::TrackExtraCollection> selTrackExtras_;
247  std::auto_ptr< TrackingRecHitCollection> selHits_;
248  std::auto_ptr< std::vector<Trajectory> > selTrajs_;
249  std::auto_ptr< std::vector<const Trajectory *> > selTrajPtrs_;
250  std::auto_ptr< TrajTrackAssociationCollection > selTTAss_;
251  reco::TrackRefProd rTracks_;
252  reco::TrackExtraRefProd rTrackExtras_;
253  TrackingRecHitRefProd rHits_;
254  edm::RefProd< std::vector<Trajectory> > rTrajectories_;
255  std::vector<reco::TrackRef> trackRefs_;
256 
257 
258  using namespace std;
259  using namespace edm;
260  using namespace reco;
261 
262  Handle<TrackCollection> hSrcTrack;
266 
267  // looking for the beam spot
269  evt.getByToken(beamspot_, hBsp);
270  reco::BeamSpot vertexBeamSpot;
271  vertexBeamSpot = *hBsp;
272 
273  // Select good primary vertices for use in subsequent track selection
275  std::vector<Point> points;
276  std::vector<float> vterr, vzerr;
277  if (useVertices_) {
278  evt.getByToken(vertices_, hVtx);
279  selectVertices(0,*hVtx, points, vterr, vzerr);
280  // Debug
281  LogDebug("SelectVertex") << points.size() << " good pixel vertices";
282  }
283 
284  // Get tracks
285  evt.getByToken( src_, hSrcTrack );
286  // get hits in track..
288  evt.getByToken( hSrc_, hSrcHits );
289  const TrackingRecHitCollection & srcHits(*hSrcHits);
290 
291 
292 
293  selTracks_ = auto_ptr<TrackCollection>(new TrackCollection());
294  rTracks_ = evt.getRefBeforePut<TrackCollection>();
295  if (copyExtras_) {
296  selTrackExtras_ = auto_ptr<TrackExtraCollection>(new TrackExtraCollection());
297  selHits_ = auto_ptr<TrackingRecHitCollection>(new TrackingRecHitCollection());
299  rTrackExtras_ = evt.getRefBeforePut<TrackExtraCollection>();
300  }
301 
302  if (copyTrajectories_) trackRefs_.resize(hSrcTrack->size());
303 
304  std::vector<float> mvaVals_(hSrcTrack->size(),-99.f);
305  processMVA(evt,es,vertexBeamSpot,*(hVtx.product()),0,mvaVals_,true);
306 
307  // Loop over tracks
308  size_t current = 0;
309  for (TrackCollection::const_iterator it = hSrcTrack->begin(), ed = hSrcTrack->end(); it != ed; ++it, ++current) {
310  const Track & trk = * it;
311  // Check if this track passes cuts
312 
313  LogTrace("TrackSelection") << "ready to check track with pt="<< trk.pt() ;
314 
315  float mvaVal = 0;
316  if(useAnyMVA_)mvaVal = mvaVals_[current];
317  bool ok = select(0,vertexBeamSpot, srcHits, trk, points, vterr, vzerr,mvaVal);
318  if (!ok) {
319 
320  LogTrace("TrackSelection") << "track with pt="<< trk.pt() << " NOT selected";
321 
322  if (copyTrajectories_) trackRefs_[current] = reco::TrackRef();
323  if (!keepAllTracks_[0]) continue;
324  }
325  LogTrace("TrackSelection") << "track with pt="<< trk.pt() << " selected";
326  selTracks_->push_back( Track( trk ) ); // clone and store
327  if (ok && setQualityBit_[0]) {
328  selTracks_->back().setQuality(qualityToSet_[0]);
329  if (qualityToSet_[0]==TrackBase::tight) {
330  selTracks_->back().setQuality(TrackBase::loose);
331  }
332  else if (qualityToSet_[0]==TrackBase::highPurity) {
333  selTracks_->back().setQuality(TrackBase::loose);
334  selTracks_->back().setQuality(TrackBase::tight);
335  }
336  if (!points.empty()) {
337  if (qualityToSet_[0]==TrackBase::loose) {
338  selTracks_->back().setQuality(TrackBase::looseSetWithPV);
339  }
340  else if (qualityToSet_[0]==TrackBase::highPurity) {
341  selTracks_->back().setQuality(TrackBase::looseSetWithPV);
342  selTracks_->back().setQuality(TrackBase::highPuritySetWithPV);
343  }
344  }
345  }
346  if (copyExtras_) {
347  // TrackExtras
348  selTrackExtras_->push_back( TrackExtra( trk.outerPosition(), trk.outerMomentum(), trk.outerOk(),
349  trk.innerPosition(), trk.innerMomentum(), trk.innerOk(),
350  trk.outerStateCovariance(), trk.outerDetId(),
351  trk.innerStateCovariance(), trk.innerDetId(),
352  trk.seedDirection(), trk.seedRef() ) );
353  selTracks_->back().setExtra( TrackExtraRef( rTrackExtras_, selTrackExtras_->size() - 1) );
354  TrackExtra & tx = selTrackExtras_->back();
355  tx.setResiduals(trk.residuals());
356  // TrackingRecHits
357  auto const firstHitIndex = selHits_->size();
358  for( trackingRecHit_iterator hit = trk.recHitsBegin(); hit != trk.recHitsEnd(); ++ hit ) {
359  selHits_->push_back( (*hit)->clone() );
360  }
361  tx.setHits( rHits_, firstHitIndex, selHits_->size() - firstHitIndex);
362  }
363  if (copyTrajectories_) {
364  trackRefs_[current] = TrackRef(rTracks_, selTracks_->size() - 1);
365  }
366  }
367  if ( copyTrajectories_ ) {
370  evt.getByToken(srcTass_, hTTAss);
371  evt.getByToken(srcTraj_, hTraj);
372  selTrajs_ = auto_ptr< vector<Trajectory> >(new vector<Trajectory>());
373  rTrajectories_ = evt.getRefBeforePut< vector<Trajectory> >();
374  selTTAss_ = auto_ptr< TrajTrackAssociationCollection >(new TrajTrackAssociationCollection(rTrajectories_, rTracks_));
375  for (size_t i = 0, n = hTraj->size(); i < n; ++i) {
376  Ref< vector<Trajectory> > trajRef(hTraj, i);
378  if (match != hTTAss->end()) {
379  const Ref<TrackCollection> &trkRef = match->val;
380  short oldKey = static_cast<short>(trkRef.key());
381  if (trackRefs_[oldKey].isNonnull()) {
382  selTrajs_->push_back( Trajectory(*trajRef) );
383  selTTAss_->insert ( Ref< vector<Trajectory> >(rTrajectories_, selTrajs_->size() - 1), trackRefs_[oldKey] );
384  }
385  }
386  }
387  }
388 
389  evt.put(selTracks_);
390  if (copyExtras_ ) {
391  evt.put(selTrackExtras_);
392  evt.put(selHits_);
393  }
394  if ( copyTrajectories_ ) {
395  evt.put(selTrajs_);
396  evt.put(selTTAss_);
397  }
398 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
std::vector< bool > keepAllTracks_
void setHits(TrackingRecHitRefProd const &prod, unsigned firstH, unsigned int nH)
bool select(unsigned tsNum, const reco::BeamSpot &vertexBeamSpot, const TrackingRecHitCollection &recHits, const reco::Track &tk, const std::vector< Point > &points, std::vector< float > &vterr, std::vector< float > &vzerr, double mvaVal) const
return class, or -1 if rejected
bool copyTrajectories_
copy also trajectories and trajectory-&gt;track associations
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
bool innerOk() const
return true if the innermost hit is valid
Definition: Track.h:50
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:17
key_type key() const
Accessor for product key.
Definition: Ref.h:264
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:65
edm::EDGetTokenT< TrackingRecHitCollection > hSrc_
edm::EDGetTokenT< std::vector< Trajectory > > srcTraj_
edm::EDGetTokenT< reco::VertexCollection > vertices_
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:55
edm::EDGetTokenT< reco::BeamSpot > beamspot_
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?
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
Definition: Track.h:75
double pt() const
track transverse momentum
Definition: TrackBase.h:616
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:94
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:104
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
#define LogTrace(id)
RefProd< PROD > getRefBeforePut()
Definition: Event.h:141
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:11
edm::OwnVector< TrackingRecHit > TrackingRecHitCollection
collection of TrackingRecHits
edm::RefToBase< TrajectorySeed > seedRef() const
Definition: Track.h:213
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:70
void selectVertices(unsigned int tsNum, const reco::VertexCollection &vtxs, std::vector< Point > &points, std::vector< float > &vterr, std::vector< float > &vzerr) const
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:45
std::vector< reco::TrackBase::TrackQuality > qualityToSet_
edm::EDGetTokenT< TrajTrackAssociationCollection > srcTass_
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
Definition: Track.h:80
bool copyExtras_
copy only the tracks, not extras and rechits (for AOD)
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:60
const TrackResiduals & residuals() const
Definition: Track.h:220
PropagationDirection seedDirection() const
direction of how the hits were sorted in the original seed
Definition: Track.h:204
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:99
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
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:109
void setResiduals(const TrackResiduals &r)
set the residuals
Definition: TrackExtra.h:179

Member Data Documentation

bool AnalyticalTrackSelector::copyExtras_
private

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

Definition at line 50 of file AnalyticalTrackSelector.cc.

Referenced by AnalyticalTrackSelector(), and run().

bool AnalyticalTrackSelector::copyTrajectories_
private

copy also trajectories and trajectory->track associations

Definition at line 52 of file AnalyticalTrackSelector.cc.

Referenced by AnalyticalTrackSelector(), and run().

double AnalyticalTrackSelector::maxEta_
private

Definition at line 55 of file AnalyticalTrackSelector.cc.

double AnalyticalTrackSelector::minEta_
private

eta restrictions

Definition at line 54 of file AnalyticalTrackSelector.cc.

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

Definition at line 58 of file AnalyticalTrackSelector.cc.

Referenced by AnalyticalTrackSelector(), and run().

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

Definition at line 57 of file AnalyticalTrackSelector.cc.

Referenced by AnalyticalTrackSelector(), and run().