CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
TSGForOIDNN Class Reference

Create L3MuonTrajectorySeeds from L2 Muons in an outside-in manner. More...

Inheritance diagram for TSGForOIDNN:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  StrategyParameters
 Container for DNN outupts. More...
 

Public Member Functions

void beginJob () override
 
void produce (edm::StreamID sid, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
 
 TSGForOIDNN (const edm::ParameterSet &iConfig)
 
 ~TSGForOIDNN () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

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

Private Member Functions

void evaluateClassifier (const std::unordered_map< std::string, float > &feature_map, tensorflow::Session *session, const pt::ptree &metadata, StrategyParameters &out, bool &dnnSuccess) const
 Evaluate DNN classifier. More...
 
void evaluateRegressor (const std::unordered_map< std::string, float > &feature_map, tensorflow::Session *session_HB, const pt::ptree &metadata_HB, tensorflow::Session *session_HLIP, const pt::ptree &metadata_HLIP, tensorflow::Session *session_HLMuS, const pt::ptree &metadata_HLMuS, StrategyParameters &out, bool &dnnSuccess) const
 Evaluate DNN regressor. More...
 
void initializeTensorflow () const
 
void makeSeedsFromHitDoublets (const GeometricSearchDet &layer, const TrajectoryStateOnSurface &tsos, const Propagator &propagatorAlong, const Chi2MeasurementEstimatorBase &estimator, const MeasurementTrackerEvent &measurementTracker, const NavigationSchool &navSchool, unsigned int &hitDoubletSeedsMade, unsigned int &numSeedsMade, const unsigned int &maxHitDoubletSeeds, unsigned int &layerCount, std::vector< TrajectorySeed > &out) const
 Similar to makeSeedsFromHits, but seed is created only if there are compatible hits on two adjacent layers. More...
 
void makeSeedsFromHits (const GeometricSearchDet &layer, const TrajectoryStateOnSurface &tsos, const Propagator &propagatorAlong, const Chi2MeasurementEstimatorBase &estimator, const MeasurementTrackerEvent &measurementTracker, unsigned int &hitSeedsMade, unsigned int &numSeedsMade, const unsigned int &maxHitSeeds, unsigned int &layerCount, std::vector< TrajectorySeed > &out) const
 Find hits on a given layer (TOB or TEC) and create seeds from updated TSOS with hit. More...
 
void makeSeedsWithoutHits (const GeometricSearchDet &layer, const TrajectoryStateOnSurface &tsos, const Propagator &propagatorAlong, const Chi2MeasurementEstimatorBase &estimator, double errorSF, unsigned int &hitlessSeedsMade, unsigned int &numSeedsMade, std::vector< TrajectorySeed > &out) const
 Create seeds without hits on a given layer (TOB or TEC) More...
 
void updateFeatureMap (std::unordered_map< std::string, float > &the_map, const reco::Track &l2, const TrajectoryStateOnSurface &tsos_IP, const TrajectoryStateOnSurface &tsos_MuS) const
 Update dictionary of inputs for DNN. More...
 

Private Attributes

const std::string dnnMetadataPath_
 DNN metadata. More...
 
std::string dnnModelPath_
 Settings for classifier. More...
 
std::string dnnModelPath_HB_
 Settings for regressor. More...
 
std::string dnnModelPath_HLIP_
 
std::string dnnModelPath_HLMuS_
 
const std::string estimatorName_
 Estimator used to find dets and TrajectoryMeasurements. More...
 
const double fixedErrorRescalingForHitless_
 Rescale L2 parameter uncertainties (fixed error vs pT, eta) More...
 
const bool getStrategyFromDNN_
 Get number of seeds to use from DNN output instead of "max..Seeds" parameters. More...
 
std::unique_ptr< tensorflow::GraphDef > graphDef_
 
std::unique_ptr< tensorflow::GraphDef > graphDef_HB_
 
std::unique_ptr< tensorflow::GraphDef > graphDef_HLIP_
 
std::unique_ptr< tensorflow::GraphDef > graphDef_HLMuS_
 
const double maxEtaForTOB_
 Maximum eta value to activate searching in the TOB. More...
 
const unsigned int maxHitDoubletSeeds_
 
const unsigned int maxHitlessSeeds_
 Maximum number of hitless seeds for each L2. More...
 
const unsigned int maxHitlessSeedsIP_
 
const unsigned int maxHitlessSeedsMuS_
 
const unsigned int maxHitSeeds_
 Maximum number of hitbased seeds for each L2. More...
 
const unsigned int maxSeeds_
 Maximum number of seeds for each L2. More...
 
const edm::EDGetTokenT< MeasurementTrackerEventmeasurementTrackerTag_
 
pt::ptree metadata_
 
const double minEtaForTEC_
 Minimum eta value to activate searching in the TEC. More...
 
const unsigned int numOfHitsToTry_
 How many hits to try per layer. More...
 
const unsigned int numOfLayersToTry_
 How many layers to try. More...
 
const edm::EDGetTokenT< reco::TrackCollectionsrc_
 Labels for input collections. More...
 
const edm::ESGetToken< Chi2MeasurementEstimatorBase, TrackingComponentsRecordt_estimatorH_
 Tokens for ESHandle. More...
 
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecordt_geometryH_
 
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecordt_magfieldH_
 
const edm::ESGetToken< NavigationSchool, NavigationSchoolRecordt_navSchool_
 
const edm::ESGetToken< Propagator, TrackingComponentsRecordt_propagatorAlongH_
 
const edm::ESGetToken< Propagator, TrackingComponentsRecordt_propagatorOppositeH_
 
const edm::ESGetToken< Propagator, TrackingComponentsRecordt_SHPOpposite_
 
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordt_tmpTkGeometryH_
 
tensorflow::Session * tf_session_
 
tensorflow::Session * tf_session_HB_
 
tensorflow::Session * tf_session_HLIP_
 
tensorflow::Session * tf_session_HLMuS_
 
const std::string theCategory_
 
const std::unique_ptr< TrajectoryStateUpdatorupdator_
 
const bool useRegressor_
 Whether to use DNN regressor (if false, will use classifier) More...
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Create L3MuonTrajectorySeeds from L2 Muons in an outside-in manner.

Author
Dmitry Kondratyev, Arnab Purohit, Jan-Frederik Schulte (Purdue University, West Lafayette, USA)

Definition at line 40 of file TSGForOIDNN.cc.

Constructor & Destructor Documentation

◆ TSGForOIDNN()

TSGForOIDNN::TSGForOIDNN ( const edm::ParameterSet iConfig)
explicit

Definition at line 181 of file TSGForOIDNN.cc.

References tensorflow::createSession(), HLT_2024v14_cff::dnnMetadataPath, dnnMetadataPath_, dnnModelPath_, dnnModelPath_HB_, dnnModelPath_HLIP_, dnnModelPath_HLMuS_, getStrategyFromDNN_, graphDef_, graphDef_HB_, graphDef_HLIP_, graphDef_HLMuS_, tensorflow::loadGraphDef(), metadata_, AlCaHLTBitMon_QueryRunRegistry::string, tf_session_, tf_session_HB_, tf_session_HLIP_, tf_session_HLMuS_, and useRegressor_.

182  : src_(consumes(iConfig.getParameter<edm::InputTag>("src"))),
183  t_estimatorH_(esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("estimator")))),
185  t_propagatorAlongH_(esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("propagatorName")))),
189  t_navSchool_(esConsumes(edm::ESInputTag("", "SimpleNavigationSchool"))),
190  t_SHPOpposite_(esConsumes(edm::ESInputTag("", "hltESPSteppingHelixPropagatorOpposite"))),
191  updator_(new KFUpdator()),
192  measurementTrackerTag_(consumes(iConfig.getParameter<edm::InputTag>("MeasurementTrackerEvent"))),
193  theCategory_(std::string("Muon|RecoMuon|TSGForOIDNN")),
194  maxSeeds_(iConfig.getParameter<uint32_t>("maxSeeds")),
195  maxHitSeeds_(iConfig.getParameter<uint32_t>("maxHitSeeds")),
196  maxHitlessSeeds_(iConfig.getParameter<uint32_t>("maxHitlessSeeds")),
197  numOfLayersToTry_(iConfig.getParameter<int32_t>("layersToTry")),
198  numOfHitsToTry_(iConfig.getParameter<int32_t>("hitsToTry")),
199  fixedErrorRescalingForHitless_(iConfig.getParameter<double>("fixedErrorRescaleFactorForHitless")),
200  minEtaForTEC_(iConfig.getParameter<double>("minEtaForTEC")),
201  maxEtaForTOB_(iConfig.getParameter<double>("maxEtaForTOB")),
202  maxHitlessSeedsIP_(iConfig.getParameter<uint32_t>("maxHitlessSeedsIP")),
203  maxHitlessSeedsMuS_(iConfig.getParameter<uint32_t>("maxHitlessSeedsMuS")),
204  maxHitDoubletSeeds_(iConfig.getParameter<uint32_t>("maxHitDoubletSeeds")),
205  getStrategyFromDNN_(iConfig.getParameter<bool>("getStrategyFromDNN")),
206  useRegressor_(iConfig.getParameter<bool>("useRegressor")),
207  dnnMetadataPath_(iConfig.getParameter<std::string>("dnnMetadataPath")) {
208  if (getStrategyFromDNN_) {
210  pt::read_json(dnnMetadataPath.fullPath(), metadata_);
211 
212  if (useRegressor_) {
213  // use regressor
214  dnnModelPath_HB_ = metadata_.get<std::string>("HB.dnnmodel_path");
215  edm::FileInPath dnnPath_HB(dnnModelPath_HB_);
216  graphDef_HB_ = std::unique_ptr<tensorflow::GraphDef>(tensorflow::loadGraphDef(dnnPath_HB.fullPath()));
218 
219  dnnModelPath_HLIP_ = metadata_.get<std::string>("HLIP.dnnmodel_path");
220  edm::FileInPath dnnPath_HLIP(dnnModelPath_HLIP_);
221  graphDef_HLIP_ = std::unique_ptr<tensorflow::GraphDef>(tensorflow::loadGraphDef(dnnPath_HLIP.fullPath()));
223 
224  dnnModelPath_HLMuS_ = metadata_.get<std::string>("HLMuS.dnnmodel_path");
225  edm::FileInPath dnnPath_HLMuS(dnnModelPath_HLMuS_);
226  graphDef_HLMuS_ = std::unique_ptr<tensorflow::GraphDef>(tensorflow::loadGraphDef(dnnPath_HLMuS.fullPath()));
228  } else {
229  // use classifier (default)
230  dnnModelPath_ = metadata_.get<std::string>("dnnmodel_path");
232  graphDef_ = std::unique_ptr<tensorflow::GraphDef>(tensorflow::loadGraphDef(dnnPath.fullPath()));
234  }
235  }
236  produces<std::vector<TrajectorySeed> >();
237 }
const unsigned int numOfHitsToTry_
How many hits to try per layer.
Definition: TSGForOIDNN.cc:73
std::string dnnModelPath_HLIP_
Definition: TSGForOIDNN.cc:101
const unsigned int maxSeeds_
Maximum number of seeds for each L2.
Definition: TSGForOIDNN.cc:65
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::string dnnModelPath_HLMuS_
Definition: TSGForOIDNN.cc:102
tensorflow::Session * tf_session_HLMuS_
Definition: TSGForOIDNN.cc:108
const edm::ESGetToken< NavigationSchool, NavigationSchoolRecord > t_navSchool_
Definition: TSGForOIDNN.cc:58
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > t_geometryH_
Definition: TSGForOIDNN.cc:57
const edm::EDGetTokenT< MeasurementTrackerEvent > measurementTrackerTag_
Definition: TSGForOIDNN.cc:61
GraphDef * loadGraphDef(const std::string &pbFile)
Definition: TensorFlow.cc:119
tensorflow::Session * tf_session_HB_
Definition: TSGForOIDNN.cc:104
const unsigned int maxHitlessSeedsMuS_
Definition: TSGForOIDNN.cc:86
const edm::EDGetTokenT< reco::TrackCollection > src_
Labels for input collections.
Definition: TSGForOIDNN.cc:50
const unsigned int maxHitlessSeedsIP_
Definition: TSGForOIDNN.cc:85
std::unique_ptr< tensorflow::GraphDef > graphDef_HLIP_
Definition: TSGForOIDNN.cc:105
const edm::ESGetToken< Chi2MeasurementEstimatorBase, TrackingComponentsRecord > t_estimatorH_
Tokens for ESHandle.
Definition: TSGForOIDNN.cc:52
const double minEtaForTEC_
Minimum eta value to activate searching in the TEC.
Definition: TSGForOIDNN.cc:79
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const double fixedErrorRescalingForHitless_
Rescale L2 parameter uncertainties (fixed error vs pT, eta)
Definition: TSGForOIDNN.cc:75
const std::string dnnMetadataPath_
DNN metadata.
Definition: TSGForOIDNN.cc:111
const std::string theCategory_
Definition: TSGForOIDNN.cc:62
const edm::ESGetToken< Propagator, TrackingComponentsRecord > t_propagatorOppositeH_
Definition: TSGForOIDNN.cc:55
const unsigned int maxHitSeeds_
Maximum number of hitbased seeds for each L2.
Definition: TSGForOIDNN.cc:67
const unsigned int maxHitDoubletSeeds_
Definition: TSGForOIDNN.cc:87
std::string dnnModelPath_
Settings for classifier.
Definition: TSGForOIDNN.cc:95
const bool useRegressor_
Whether to use DNN regressor (if false, will use classifier)
Definition: TSGForOIDNN.cc:92
Session * createSession()
Definition: TensorFlow.cc:136
const edm::ESGetToken< Propagator, TrackingComponentsRecord > t_SHPOpposite_
Definition: TSGForOIDNN.cc:59
const double maxEtaForTOB_
Maximum eta value to activate searching in the TOB.
Definition: TSGForOIDNN.cc:81
std::string dnnModelPath_HB_
Settings for regressor.
Definition: TSGForOIDNN.cc:100
std::unique_ptr< tensorflow::GraphDef > graphDef_
Definition: TSGForOIDNN.cc:96
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > t_magfieldH_
Definition: TSGForOIDNN.cc:53
std::unique_ptr< tensorflow::GraphDef > graphDef_HB_
Definition: TSGForOIDNN.cc:103
tensorflow::Session * tf_session_
Definition: TSGForOIDNN.cc:97
const edm::ESGetToken< Propagator, TrackingComponentsRecord > t_propagatorAlongH_
Definition: TSGForOIDNN.cc:54
const unsigned int numOfLayersToTry_
How many layers to try.
Definition: TSGForOIDNN.cc:71
const bool getStrategyFromDNN_
Get number of seeds to use from DNN output instead of "max..Seeds" parameters.
Definition: TSGForOIDNN.cc:90
std::unique_ptr< tensorflow::GraphDef > graphDef_HLMuS_
Definition: TSGForOIDNN.cc:107
pt::ptree metadata_
Definition: TSGForOIDNN.cc:112
const std::unique_ptr< TrajectoryStateUpdator > updator_
Definition: TSGForOIDNN.cc:60
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > t_tmpTkGeometryH_
Definition: TSGForOIDNN.cc:56
const unsigned int maxHitlessSeeds_
Maximum number of hitless seeds for each L2.
Definition: TSGForOIDNN.cc:69
tensorflow::Session * tf_session_HLIP_
Definition: TSGForOIDNN.cc:106

◆ ~TSGForOIDNN()

TSGForOIDNN::~TSGForOIDNN ( )
override

Definition at line 239 of file TSGForOIDNN.cc.

References tensorflow::closeSession(), getStrategyFromDNN_, tf_session_, tf_session_HB_, tf_session_HLIP_, tf_session_HLMuS_, and useRegressor_.

239  {
240  if (getStrategyFromDNN_) {
241  if (useRegressor_) {
245  } else {
247  }
248  }
249 }
tensorflow::Session * tf_session_HLMuS_
Definition: TSGForOIDNN.cc:108
tensorflow::Session * tf_session_HB_
Definition: TSGForOIDNN.cc:104
bool closeSession(Session *&session)
Definition: TensorFlow.cc:233
const bool useRegressor_
Whether to use DNN regressor (if false, will use classifier)
Definition: TSGForOIDNN.cc:92
tensorflow::Session * tf_session_
Definition: TSGForOIDNN.cc:97
const bool getStrategyFromDNN_
Get number of seeds to use from DNN output instead of "max..Seeds" parameters.
Definition: TSGForOIDNN.cc:90
tensorflow::Session * tf_session_HLIP_
Definition: TSGForOIDNN.cc:106

Member Function Documentation

◆ beginJob()

void TSGForOIDNN::beginJob ( void  )
overridevirtual

Reimplemented from edm::global::EDProducerBase.

Definition at line 251 of file TSGForOIDNN.cc.

References initializeTensorflow().

void initializeTensorflow() const
Definition: TSGForOIDNN.cc:286

◆ evaluateClassifier()

void TSGForOIDNN::evaluateClassifier ( const std::unordered_map< std::string, float > &  feature_map,
tensorflow::Session *  session,
const pt::ptree &  metadata,
StrategyParameters out,
bool &  dnnSuccess 
) const
private

Evaluate DNN classifier.

Definition at line 878 of file TSGForOIDNN.cc.

References nano_mu_digi_cff::float, alignmentValidation::fname, mps_fire::i, input, label, OccupancyTask_cfi::metadata, MillePedeFileConverter_cfg::out, PatBasicFWLiteJetAnalyzer_Selector_cfg::outputs, tensorflow::run(), AlCaHLTBitMon_QueryRunRegistry::string, and to_string().

Referenced by initializeTensorflow(), and produce().

882  {
883  int n_features = metadata.get<int>("n_features", 0);
884 
885  // Prepare tensor for DNN inputs
886  tensorflow::Tensor input(tensorflow::DT_FLOAT, {1, n_features});
888  int i_feature = 0;
889  for (const pt::ptree::value_type& feature : metadata.get_child("feature_names")) {
890  fname = feature.second.data();
891  if (feature_map.find(fname) == feature_map.end()) {
892  // don't evaluate DNN if any input feature is missing
893  dnnSuccess = false;
894  } else {
895  input.matrix<float>()(0, i_feature) = float(feature_map.at(fname));
896  i_feature++;
897  }
898  }
899 
900  // Prepare tensor for DNN outputs
901  std::vector<tensorflow::Tensor> outputs;
902 
903  // Evaluate DNN and put results in output tensor
904  std::string inputLayer = metadata.get<std::string>("input_layer");
905  std::string outputLayer = metadata.get<std::string>("output_layer");
906 
907  tensorflow::run(session, {{inputLayer, input}}, {outputLayer}, &outputs);
908  tensorflow::Tensor out_tensor = outputs[0];
909  tensorflow::TTypes<float, 1>::Matrix dnn_outputs = out_tensor.matrix<float>();
910 
911  // Find output with largest prediction
912  int imax = 0;
913  float out_max = 0;
914  for (long long int i = 0; i < out_tensor.dim_size(1); i++) {
915  float ith_output = dnn_outputs(0, i);
916  if (ith_output > out_max) {
917  imax = i;
918  out_max = ith_output;
919  }
920  }
921 
922  // Decode output
923  const std::string label = "output_labels.label_" + std::to_string(imax);
924  out.nHBd = metadata.get<int>(label + ".nHBd");
925  out.nHLIP = metadata.get<int>(label + ".nHLIP");
926  out.nHLMuS = metadata.get<int>(label + ".nHLMuS");
927  out.sf = metadata.get<int>(label + ".SF");
928 
929  dnnSuccess = true;
930 }
static std::string to_string(const XMLCh *ch)
static std::string const input
Definition: EdmProvDump.cc:50
char const * label
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
Definition: TensorFlow.cc:271
string fname
main script
portabletest::Matrix Matrix

◆ evaluateRegressor()

void TSGForOIDNN::evaluateRegressor ( const std::unordered_map< std::string, float > &  feature_map,
tensorflow::Session *  session_HB,
const pt::ptree &  metadata_HB,
tensorflow::Session *  session_HLIP,
const pt::ptree &  metadata_HLIP,
tensorflow::Session *  session_HLMuS,
const pt::ptree &  metadata_HLMuS,
StrategyParameters out,
bool &  dnnSuccess 
) const
private

Evaluate DNN regressor.

Definition at line 935 of file TSGForOIDNN.cc.

References nano_mu_digi_cff::float, alignmentValidation::fname, input, MillePedeFileConverter_cfg::out, tensorflow::run(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by produce().

943  {
944  int n_features = metadata_HB.get<int>("n_features", 0);
945 
946  // Prepare tensor for DNN inputs
947  tensorflow::Tensor input(tensorflow::DT_FLOAT, {1, n_features});
949  int i_feature = 0;
950  for (const pt::ptree::value_type& feature : metadata_HB.get_child("feature_names")) {
951  fname = feature.second.data();
952  if (feature_map.find(fname) == feature_map.end()) {
953  // don't evaluate DNN if any input feature is missing
954  dnnSuccess = false;
955  } else {
956  input.matrix<float>()(0, i_feature) = float(feature_map.at(fname));
957  i_feature++;
958  }
959  }
960 
961  // Prepare tensor for DNN outputs
962  std::vector<tensorflow::Tensor> outputs_HB;
963  // Evaluate DNN and put results in output tensor
964  std::string inputLayer_HB = metadata_HB.get<std::string>("input_layer");
965  std::string outputLayer_HB = metadata_HB.get<std::string>("output_layer");
966  tensorflow::run(session_HB, {{inputLayer_HB, input}}, {outputLayer_HB}, &outputs_HB);
967  tensorflow::Tensor out_tensor_HB = outputs_HB[0];
968  tensorflow::TTypes<float, 1>::Matrix dnn_outputs_HB = out_tensor_HB.matrix<float>();
969 
970  // Prepare tensor for DNN outputs
971  std::vector<tensorflow::Tensor> outputs_HLIP;
972  // Evaluate DNN and put results in output tensor
973  std::string inputLayer_HLIP = metadata_HLIP.get<std::string>("input_layer");
974  std::string outputLayer_HLIP = metadata_HLIP.get<std::string>("output_layer");
975  tensorflow::run(session_HLIP, {{inputLayer_HLIP, input}}, {outputLayer_HLIP}, &outputs_HLIP);
976  tensorflow::Tensor out_tensor_HLIP = outputs_HLIP[0];
977  tensorflow::TTypes<float, 1>::Matrix dnn_outputs_HLIP = out_tensor_HLIP.matrix<float>();
978 
979  // Prepare tensor for DNN outputs
980  std::vector<tensorflow::Tensor> outputs_HLMuS;
981  // Evaluate DNN and put results in output tensor
982  std::string inputLayer_HLMuS = metadata_HLMuS.get<std::string>("input_layer");
983  std::string outputLayer_HLMuS = metadata_HLMuS.get<std::string>("output_layer");
984  tensorflow::run(session_HLMuS, {{inputLayer_HLMuS, input}}, {outputLayer_HLMuS}, &outputs_HLMuS);
985  tensorflow::Tensor out_tensor_HLMuS = outputs_HLMuS[0];
986  tensorflow::TTypes<float, 1>::Matrix dnn_outputs_HLMuS = out_tensor_HLMuS.matrix<float>();
987 
988  // Decode output
989  out.nHBd = round(dnn_outputs_HB(0, 0));
990  out.nHLIP = round(dnn_outputs_HLIP(0, 0));
991  out.sf = round(dnn_outputs_HLIP(0, 1));
992  out.nHLMuS = round(dnn_outputs_HLMuS(0, 0));
993 
994  // Prevent prediction of negative number of seeds or too many seeds
995  out.nHBd = std::clamp(out.nHBd, 0, 10);
996  out.nHLIP = std::clamp(out.nHLIP, 0, 10);
997  out.nHLMuS = std::clamp(out.nHLMuS, 0, 10);
998 
999  // Prevent prediction of 0 seeds in total
1000  if (out.nHBd == 0 && out.nHLIP == 0 && out.nHLMuS == 0) {
1001  // default strategy, similar to Run 2
1002  out.nHBd = 1;
1003  out.nHLIP = 5;
1004  }
1005 
1006  // Prevent extreme predictions for scale factors
1007  // (on average SF=2 was found to be optimal)
1008  if (out.sf <= 0)
1009  out.sf = 2;
1010  if (out.sf > 10)
1011  out.sf = 10;
1012 
1013  dnnSuccess = true;
1014 }
static std::string const input
Definition: EdmProvDump.cc:50
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
Definition: TensorFlow.cc:271
string fname
main script
portabletest::Matrix Matrix

◆ fillDescriptions()

void TSGForOIDNN::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 1019 of file TSGForOIDNN.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

1019  {
1021  desc.add<edm::InputTag>("src", edm::InputTag("hltL2Muons", "UpdatedAtVtx"));
1022  desc.add<int>("layersToTry", 2);
1023  desc.add<double>("fixedErrorRescaleFactorForHitless", 2.0);
1024  desc.add<int>("hitsToTry", 1);
1025  desc.add<edm::InputTag>("MeasurementTrackerEvent", edm::InputTag("hltSiStripClusters"));
1026  desc.add<std::string>("estimator", "hltESPChi2MeasurementEstimator100");
1027  desc.add<double>("maxEtaForTOB", 1.8);
1028  desc.add<double>("minEtaForTEC", 0.7);
1029  desc.addUntracked<bool>("debug", false);
1030  desc.add<unsigned int>("maxSeeds", 20);
1031  desc.add<unsigned int>("maxHitlessSeeds", 5);
1032  desc.add<unsigned int>("maxHitSeeds", 1);
1033  desc.add<std::string>("propagatorName", "PropagatorWithMaterialParabolicMf");
1034  desc.add<unsigned int>("maxHitlessSeedsIP", 5);
1035  desc.add<unsigned int>("maxHitlessSeedsMuS", 0);
1036  desc.add<unsigned int>("maxHitDoubletSeeds", 0);
1037  desc.add<bool>("getStrategyFromDNN", false);
1038  desc.add<bool>("useRegressor", false);
1039  desc.add<std::string>("dnnMetadataPath", "");
1040  descriptions.add("tsgForOIDNN", desc);
1041 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ initializeTensorflow()

void TSGForOIDNN::initializeTensorflow ( ) const
private

Definition at line 286 of file TSGForOIDNN.cc.

References evaluateClassifier(), getStrategyFromDNN_, metadata_, tf_session_, and useRegressor_.

Referenced by beginJob().

286  {
287  if (getStrategyFromDNN_ and not useRegressor_) {
288  // Container for DNN outputs
289  StrategyParameters strPars;
290  bool dnnSuccess = false;
291  evaluateClassifier(dummyFeatureMap(), tf_session_, metadata_, strPars, dnnSuccess);
292  }
293 }
const bool useRegressor_
Whether to use DNN regressor (if false, will use classifier)
Definition: TSGForOIDNN.cc:92
tensorflow::Session * tf_session_
Definition: TSGForOIDNN.cc:97
const bool getStrategyFromDNN_
Get number of seeds to use from DNN output instead of "max..Seeds" parameters.
Definition: TSGForOIDNN.cc:90
pt::ptree metadata_
Definition: TSGForOIDNN.cc:112
void evaluateClassifier(const std::unordered_map< std::string, float > &feature_map, tensorflow::Session *session, const pt::ptree &metadata, StrategyParameters &out, bool &dnnSuccess) const
Evaluate DNN classifier.
Definition: TSGForOIDNN.cc:878

◆ makeSeedsFromHitDoublets()

void TSGForOIDNN::makeSeedsFromHitDoublets ( const GeometricSearchDet layer,
const TrajectoryStateOnSurface tsos,
const Propagator propagatorAlong,
const Chi2MeasurementEstimatorBase estimator,
const MeasurementTrackerEvent measurementTracker,
const NavigationSchool navSchool,
unsigned int &  hitDoubletSeedsMade,
unsigned int &  numSeedsMade,
const unsigned int &  maxHitDoubletSeeds,
unsigned int &  layerCount,
std::vector< TrajectorySeed > &  out 
) const
private

Similar to makeSeedsFromHits, but seed is created only if there are compatible hits on two adjacent layers.

Definition at line 629 of file TSGForOIDNN.cc.

References alongMomentum, MeasurementDetWithData::fastMeasurements(), newFWLiteAna::found, TrajectoryStateOnSurface::freeState(), MeasurementDetWithData::isNull(), TrajectoryStateOnSurface::isValid(), nano_mu_digi_cff::layer, LogTrace, HLT_2024v14_cff::maxHitDoubletSeeds, HLTSiStripMonitoring_cff::measurementTracker, eostools::move(), HLT_2024v14_cff::navSchool, numOfHitsToTry_, oppositeToMomentum, MillePedeFileConverter_cfg::out, trajectoryStateTransform::persistentState(), L1TMuonDQMOffline_cfi::propagatorAlong, edm::OwnVector< T, P >::push_back(), fileCollector::seed, edm::OwnVector< T, P >::size(), jetUpdater_cfi::sort, and updator_.

Referenced by produce().

639  {
640  // This method is similar to makeSeedsFromHits, but the seed is created
641  // only when in addition to a hit on a given layer, there are more compatible hits
642  // on next layers (going from outside inwards), compatible with updated TSOS.
643  // If that's the case, multiple compatible hits are used to create a single seed.
644 
645  // Configured to only check the immideately adjacent layer and add one more hit
646  int max_addtnl_layers = 1; // max number of additional layers to scan
647  int max_meas = 1; // number of measurements to consider on each additional layer
648 
649  // // // First, regular procedure to find a compatible hit - like in makeSeedsFromHits // // //
650 
651  const TrajectoryStateOnSurface& onLayer(tsos);
652 
653  // Find dets compatible with original TSOS
654  std::vector<GeometricSearchDet::DetWithState> dets;
655  layer.compatibleDetsV(onLayer, propagatorAlong, estimator, dets);
656 
657  LogTrace("TSGForOIDNN") << "TSGForOIDNN::makeSeedsFromHitDoublets: Find measurements on each detWithState "
658  << dets.size();
659  std::vector<TrajectoryMeasurement> meas;
660 
661  // Loop over dets
662  for (auto const& detI : dets) {
663  MeasurementDetWithData det = measurementTracker.idToDet(detI.first->geographicalId());
664 
665  if (det.isNull())
666  continue; // skip if det does not exist
667  if (!detI.second.isValid())
668  continue; // skip if TSOS is invalid
669 
670  // Find measurements on this det
671  std::vector<TrajectoryMeasurement> mymeas = det.fastMeasurements(detI.second, onLayer, propagatorAlong, estimator);
672 
673  // Save valid measurements
674  for (auto const& measurement : mymeas) {
675  if (measurement.recHit()->isValid())
676  meas.push_back(measurement);
677  } // end loop over meas
678  } // end loop over dets
679 
680  LogTrace("TSGForOIDNN") << "TSGForOIDNN::makeSeedsFromHitDoublets: Update TSOS using TMs after sorting, then create "
681  "Trajectory Seed, number of TM = "
682  << meas.size();
683 
684  // sort valid measurements found on the first layer
685  std::sort(meas.begin(), meas.end(), TrajMeasLessEstim());
686 
687  unsigned int found = 0;
688 
689  // Loop over all valid measurements compatible with original TSOS
690  //for (std::vector<TrajectoryMeasurement>::const_iterator mea = meas.begin(); mea != meas.end(); ++mea) {
691  for (auto const& measurement : meas) {
692  if (hitDoubletSeedsMade >= maxHitDoubletSeeds)
693  return; // abort if enough seeds created
694 
695  // Update TSOS with measurement on first considered layer
696  TrajectoryStateOnSurface updatedTSOS = updator_->update(measurement.forwardPredictedState(), *measurement.recHit());
697 
698  LogTrace("TSGForOIDNN") << "TSGForOIDNN::makeSeedsFromHitDoublets: TSOS for TM " << found;
699  if (not updatedTSOS.isValid())
700  continue; // Skip if updated TSOS is invalid
701 
703 
704  // Save hit on first layer
705  seedHits.push_back(*measurement.recHit()->hit());
706  const DetLayer* detLayer = dynamic_cast<const DetLayer*>(&layer);
707 
708  // // // Now for this measurement we will loop over additional layers and try to update the TSOS again // // //
709 
710  // find layers compatible with updated TSOS
711  auto const& compLayers = navSchool.nextLayers(*detLayer, *updatedTSOS.freeState(), alongMomentum);
712 
713  int addtnl_layers_scanned = 0;
714  int found_compatible_on_next_layer = 0;
715  int det_id = 0;
716 
717  // Copy updated TSOS - we will update it again with a measurement from the next layer, if we find it
718  TrajectoryStateOnSurface updatedTSOS_next(updatedTSOS);
719 
720  // loop over layers compatible with updated TSOS
721  for (auto compLayer : compLayers) {
722  int nmeas = 0;
723 
724  if (addtnl_layers_scanned >= max_addtnl_layers)
725  break; // break if we already looped over enough layers
726  if (found_compatible_on_next_layer > 0)
727  break; // break if we already found additional hit
728 
729  // find dets compatible with updated TSOS
730  std::vector<GeometricSearchDet::DetWithState> dets_next;
731  TrajectoryStateOnSurface onLayer_next(updatedTSOS);
732 
733  compLayer->compatibleDetsV(onLayer_next, propagatorAlong, estimator, dets_next);
734 
735  //if (!detWithState.size()) continue;
736  std::vector<TrajectoryMeasurement> meas_next;
737 
738  // find measurements on dets_next and save the valid ones
739  for (auto const& detI_next : dets_next) {
740  MeasurementDetWithData det = measurementTracker.idToDet(detI_next.first->geographicalId());
741 
742  if (det.isNull())
743  continue; // skip if det does not exist
744  if (!detI_next.second.isValid())
745  continue; // skip if TSOS is invalid
746 
747  // Find measurements on this det
748  std::vector<TrajectoryMeasurement> mymeas_next =
749  det.fastMeasurements(detI_next.second, onLayer_next, propagatorAlong, estimator);
750 
751  for (auto const& mea_next : mymeas_next) {
752  // save valid measurements
753  if (mea_next.recHit()->isValid())
754  meas_next.push_back(mea_next);
755 
756  } // end loop over mymeas_next
757  } // end loop over dets_next
758 
759  // sort valid measurements found on this layer
760  std::sort(meas_next.begin(), meas_next.end(), TrajMeasLessEstim());
761 
762  // loop over valid measurements compatible with updated TSOS (TSOS updated with a hit on the first layer)
763  for (auto const& mea_next : meas_next) {
764  if (nmeas >= max_meas)
765  break; // skip if we already found enough hits
766 
767  // try to update TSOS again, with an additional hit
768  updatedTSOS_next = updator_->update(mea_next.forwardPredictedState(), *mea_next.recHit());
769 
770  if (not updatedTSOS_next.isValid())
771  continue; // skip if TSOS updated with additional hit is not valid
772 
773  // If there was a compatible hit on this layer, we end up here.
774  // An additional compatible hit is saved.
775  seedHits.push_back(*mea_next.recHit()->hit());
776  det_id = mea_next.recHit()->geographicalId().rawId();
777  nmeas++;
778  found_compatible_on_next_layer++;
779 
780  } // end loop over meas_next
781 
782  addtnl_layers_scanned++;
783 
784  } // end loop over compLayers (additional layers scanned after the original layer)
785 
786  if (found_compatible_on_next_layer == 0)
787  continue;
788  // only consider the hit if there was a compatible hit on one of the additional scanned layers
789 
790  // Create a seed from two saved hits
791  PTrajectoryStateOnDet const& pstate = trajectoryStateTransform::persistentState(updatedTSOS_next, det_id);
792  TrajectorySeed seed(pstate, std::move(seedHits), oppositeToMomentum);
793 
794  LogTrace("TSGForOIDNN") << "TSGForOIDNN::makeSeedsFromHitDoublets: Number of seedHits: " << seedHits.size();
795  out.push_back(seed);
796 
797  found++;
798  numSeedsMade++;
799  hitDoubletSeedsMade++;
800 
801  if (found == numOfHitsToTry_)
802  break; // break if enough measurements scanned
803 
804  } // end loop over measurements compatible with original TSOS
805 
806  if (found)
807  layerCount++;
808 }
const unsigned int numOfHitsToTry_
How many hits to try per layer.
Definition: TSGForOIDNN.cc:73
std::vector< TrajectoryMeasurement > fastMeasurements(const TrajectoryStateOnSurface &stateOnThisDet, const TrajectoryStateOnSurface &tsos2, const Propagator &prop, const MeasurementEstimator &est) const
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
#define LogTrace(id)
void push_back(D *&d)
Definition: OwnVector.h:326
size_type size() const
Definition: OwnVector.h:300
FreeTrajectoryState const * freeState(bool withErrors=true) const
const std::unique_ptr< TrajectoryStateUpdator > updator_
Definition: TSGForOIDNN.cc:60
def move(src, dest)
Definition: eostools.py:511

◆ makeSeedsFromHits()

void TSGForOIDNN::makeSeedsFromHits ( const GeometricSearchDet layer,
const TrajectoryStateOnSurface tsos,
const Propagator propagatorAlong,
const Chi2MeasurementEstimatorBase estimator,
const MeasurementTrackerEvent measurementTracker,
unsigned int &  hitSeedsMade,
unsigned int &  numSeedsMade,
const unsigned int &  maxHitSeeds,
unsigned int &  layerCount,
std::vector< TrajectorySeed > &  out 
) const
private

Find hits on a given layer (TOB or TEC) and create seeds from updated TSOS with hit.

Definition at line 557 of file TSGForOIDNN.cc.

References MeasurementDetWithData::fastMeasurements(), newFWLiteAna::found, MeasurementDetWithData::isNull(), TrajectoryStateOnSurface::isValid(), nano_mu_digi_cff::layer, LogTrace, HLT_2024v14_cff::maxHitSeeds, HLTSiStripMonitoring_cff::measurementTracker, eostools::move(), numOfHitsToTry_, numOfLayersToTry_, oppositeToMomentum, MillePedeFileConverter_cfg::out, trajectoryStateTransform::persistentState(), L1TMuonDQMOffline_cfi::propagatorAlong, edm::OwnVector< T, P >::push_back(), fileCollector::seed, edm::OwnVector< T, P >::size(), jetUpdater_cfi::sort, and updator_.

Referenced by produce().

566  {
567  if (layerCount > numOfLayersToTry_)
568  return;
569 
570  const TrajectoryStateOnSurface& onLayer(tsos);
571 
572  std::vector<GeometricSearchDet::DetWithState> dets;
573  layer.compatibleDetsV(onLayer, propagatorAlong, estimator, dets);
574 
575  // Find Measurements on each DetWithState
576  LogTrace("TSGForOIDNN") << "TSGForOIDNN::makeSeedsFromHits: Find measurements on each detWithState " << dets.size();
577  std::vector<TrajectoryMeasurement> meas;
578  for (auto const& detI : dets) {
579  MeasurementDetWithData det = measurementTracker.idToDet(detI.first->geographicalId());
580  if (det.isNull())
581  continue;
582  if (!detI.second.isValid())
583  continue; // Skip if TSOS is not valid
584 
585  std::vector<TrajectoryMeasurement> mymeas =
586  det.fastMeasurements(detI.second, onLayer, propagatorAlong, estimator); // Second TSOS is not used
587  for (auto const& measurement : mymeas) {
588  if (measurement.recHit()->isValid())
589  meas.push_back(measurement); // Only save those which are valid
590  }
591  }
592 
593  // Update TSOS using TMs after sorting, then create Trajectory Seed and put into vector
594  LogTrace("TSGForOIDNN") << "TSGForOIDNN::makeSeedsFromHits: Update TSOS using TMs after sorting, then create "
595  "Trajectory Seed, number of TM = "
596  << meas.size();
597  std::sort(meas.begin(), meas.end(), TrajMeasLessEstim());
598 
599  unsigned int found = 0;
600  for (auto const& measurement : meas) {
601  if (hitSeedsMade >= maxHitSeeds)
602  return;
603  TrajectoryStateOnSurface updatedTSOS = updator_->update(measurement.forwardPredictedState(), *measurement.recHit());
604  LogTrace("TSGForOIDNN") << "TSGForOIDNN::makeSeedsFromHits: TSOS for TM " << found;
605  if (not updatedTSOS.isValid())
606  continue;
607 
609  seedHits.push_back(*measurement.recHit()->hit());
610  PTrajectoryStateOnDet const& pstate =
611  trajectoryStateTransform::persistentState(updatedTSOS, measurement.recHit()->geographicalId().rawId());
612  LogTrace("TSGForOIDNN") << "TSGForOIDNN::makeSeedsFromHits: Number of seedHits: " << seedHits.size();
613  TrajectorySeed seed(pstate, std::move(seedHits), oppositeToMomentum);
614  out.push_back(seed);
615  found++;
616  numSeedsMade++;
617  hitSeedsMade++;
618  if (found == numOfHitsToTry_)
619  break;
620  }
621 
622  if (found)
623  layerCount++;
624 }
const unsigned int numOfHitsToTry_
How many hits to try per layer.
Definition: TSGForOIDNN.cc:73
std::vector< TrajectoryMeasurement > fastMeasurements(const TrajectoryStateOnSurface &stateOnThisDet, const TrajectoryStateOnSurface &tsos2, const Propagator &prop, const MeasurementEstimator &est) const
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
#define LogTrace(id)
void push_back(D *&d)
Definition: OwnVector.h:326
size_type size() const
Definition: OwnVector.h:300
const unsigned int numOfLayersToTry_
How many layers to try.
Definition: TSGForOIDNN.cc:71
const std::unique_ptr< TrajectoryStateUpdator > updator_
Definition: TSGForOIDNN.cc:60
def move(src, dest)
Definition: eostools.py:511

◆ makeSeedsWithoutHits()

void TSGForOIDNN::makeSeedsWithoutHits ( const GeometricSearchDet layer,
const TrajectoryStateOnSurface tsos,
const Propagator propagatorAlong,
const Chi2MeasurementEstimatorBase estimator,
double  errorSF,
unsigned int &  hitlessSeedsMade,
unsigned int &  numSeedsMade,
std::vector< TrajectorySeed > &  out 
) const
private

Create seeds without hits on a given layer (TOB or TEC)

Definition at line 523 of file TSGForOIDNN.cc.

References nano_mu_digi_cff::layer, LogTrace, oppositeToMomentum, MillePedeFileConverter_cfg::out, trajectoryStateTransform::persistentState(), L1TMuonDQMOffline_cfi::propagatorAlong, and theCategory_.

Referenced by produce().

530  {
531  // create hitless seeds
532  LogTrace("TSGForOIDNN") << "TSGForOIDNN::makeSeedsWithoutHits: Start hitless";
533  std::vector<GeometricSearchDet::DetWithState> dets;
534  layer.compatibleDetsV(tsos, propagatorAlong, estimator, dets);
535  if (!dets.empty()) {
536  auto const& detOnLayer = dets.front().first;
537  auto& tsosOnLayer = dets.front().second;
538  LogTrace("TSGForOIDNN") << "TSGForOIDNN::makeSeedsWithoutHits: tsosOnLayer " << tsosOnLayer;
539  if (!tsosOnLayer.isValid()) {
540  edm::LogInfo(theCategory_) << "ERROR!: Hitless TSOS is not valid!";
541  } else {
542  tsosOnLayer.rescaleError(errorSF);
543  PTrajectoryStateOnDet const& ptsod =
544  trajectoryStateTransform::persistentState(tsosOnLayer, detOnLayer->geographicalId().rawId());
546  out.push_back(TrajectorySeed(ptsod, rHC, oppositeToMomentum));
547  LogTrace("TSGForOIDNN") << "TSGForOIDNN::makeSeedsWithoutHits: TSOS (Hitless) done ";
548  hitlessSeedsMade++;
549  numSeedsMade++;
550  }
551  }
552 }
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
#define LogTrace(id)
const std::string theCategory_
Definition: TSGForOIDNN.cc:62
Log< level::Info, false > LogInfo

◆ produce()

void TSGForOIDNN::produce ( edm::StreamID  sid,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overridevirtual

Implements edm::global::EDProducerBase.

Definition at line 298 of file TSGForOIDNN.cc.

References funct::abs(), alongMomentum, Plane::build(), evaluateClassifier(), evaluateRegressor(), fixedErrorRescalingForHitless_, edm::EventSetup::getData(), edm::EventSetup::getHandle(), getStrategyFromDNN_, iEvent, trajectoryStateTransform::initialFreeState(), trajectoryStateTransform::innerStateOnSurface(), TrackerGeometry::isThere(), TrajectoryStateOnSurface::isValid(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, HLTObjectMonitor_cfi::l2muonEta, nano_mu_digi_cff::layer, hgcalTBTopologyTester_cfi::layers, LogTrace, volumeBasedMagneticField_160812_cfi::magfield, makeSeedsFromHitDoublets(), makeSeedsFromHits(), makeSeedsWithoutHits(), maxEtaForTOB_, HLT_2024v14_cff::maxHitDoubletSeeds, maxHitDoubletSeeds_, HLT_2024v14_cff::maxHitlessSeedsIP, maxHitlessSeedsIP_, HLT_2024v14_cff::maxHitlessSeedsMuS, maxHitlessSeedsMuS_, HLT_2024v14_cff::maxHitSeeds, maxHitSeeds_, maxSeeds_, HLTSiStripMonitoring_cff::measurementTracker, measurementTrackerTag_, metadata_, minEtaForTEC_, eostools::move(), HLT_2024v14_cff::navSchool, TSGForOIDNN::StrategyParameters::nHBd, TSGForOIDNN::StrategyParameters::nHLIP, TSGForOIDNN::StrategyParameters::nHLMuS, oppositeToMomentum, MillePedeFileConverter_cfg::out, GeomDetEnumerators::P2OTEC, FreeTrajectoryState::position(), L1TMuonDQMOffline_cfi::propagatorAlong, L1TMuonDQMOffline_cfi::propagatorOpposite, mps_fire::result, groupFilesInBlocks::reverse, SetPropagationDirection(), TSGForOIDNN::StrategyParameters::sf, src_, t_estimatorH_, t_geometryH_, t_magfieldH_, t_navSchool_, t_propagatorAlongH_, t_propagatorOppositeH_, t_SHPOpposite_, t_tmpTkGeometryH_, tf_session_, tf_session_HB_, tf_session_HLIP_, tf_session_HLMuS_, theCategory_, updateFeatureMap(), and useRegressor_.

298  {
299  // Initialize variables
300  unsigned int numSeedsMade = 0;
301  unsigned int layerCount = 0;
302  unsigned int hitlessSeedsMadeIP = 0;
303  unsigned int hitlessSeedsMadeMuS = 0;
304  unsigned int hitSeedsMade = 0;
305  unsigned int hitDoubletSeedsMade = 0;
306 
307  // Container for DNN inputs
308  std::unordered_map<std::string, float> feature_map;
309 
310  // Container for DNN outputs
311  StrategyParameters strPars;
312 
313  // Surface used to make a TSOS at the PCA to the beamline
315 
316  // Get setup objects
317  const MagneticField& magfield = iEventSetup.getData(t_magfieldH_);
318  const Chi2MeasurementEstimatorBase& estimator = iEventSetup.getData(t_estimatorH_);
319  const Propagator& tmpPropagatorAlong = iEventSetup.getData(t_propagatorAlongH_);
320  const Propagator& tmpPropagatorOpposite = iEventSetup.getData(t_propagatorOppositeH_);
321  const TrackerGeometry& tmpTkGeometry = iEventSetup.getData(t_tmpTkGeometryH_);
322  const GlobalTrackingGeometry& geometry = iEventSetup.getData(t_geometryH_);
323  const NavigationSchool& navSchool = iEventSetup.getData(t_navSchool_);
325 
326  // Read L2 track collection
327  auto const& l2TrackCol = iEvent.get(src_);
328 
329  // The product
330  std::unique_ptr<std::vector<TrajectorySeed> > result(new std::vector<TrajectorySeed>());
331 
332  // Get vector of Detector layers
333  auto const* gsTracker = measurementTracker.geometricSearchTracker();
334  std::vector<BarrelDetLayer const*> const& tob = gsTracker->tobLayers();
335  std::vector<ForwardDetLayer const*> const& tecPositive =
336  tmpTkGeometry.isThere(GeomDetEnumerators::P2OTEC) ? gsTracker->posTidLayers() : gsTracker->posTecLayers();
337  std::vector<ForwardDetLayer const*> const& tecNegative =
338  tmpTkGeometry.isThere(GeomDetEnumerators::P2OTEC) ? gsTracker->negTidLayers() : gsTracker->negTecLayers();
339 
340  // Get suitable propagators
341  std::unique_ptr<Propagator> propagatorAlong = SetPropagationDirection(tmpPropagatorAlong, alongMomentum);
342  std::unique_ptr<Propagator> propagatorOpposite = SetPropagationDirection(tmpPropagatorOpposite, oppositeToMomentum);
343 
344  // Stepping Helix Propagator for propogation from muon system to tracker
345  edm::ESHandle<Propagator> shpOpposite = iEventSetup.getHandle(t_SHPOpposite_);
346 
347  // Loop over the L2's and make seeds for all of them
348  LogTrace(theCategory_) << "TSGForOIDNN::produce: Number of L2's: " << l2TrackCol.size();
349 
350  for (auto const& l2 : l2TrackCol) {
351  // Container of Seeds
352  std::vector<TrajectorySeed> out;
353  LogTrace("TSGForOIDNN") << "TSGForOIDNN::produce: L2 muon pT, eta, phi --> " << l2.pt() << " , " << l2.eta()
354  << " , " << l2.phi();
355 
357 
358  dummyPlane->move(fts.position() - dummyPlane->position());
359  TrajectoryStateOnSurface tsosAtIP = TrajectoryStateOnSurface(fts, *dummyPlane);
360  LogTrace("TSGForOIDNN") << "TSGForOIDNN::produce: Created TSOSatIP: " << tsosAtIP;
361 
362  // Get the TSOS on the innermost layer of the L2
364  LogTrace("TSGForOIDNN") << "TSGForOIDNN::produce: Created TSOSatMuonSystem: " << tsosAtMuonSystem;
365 
366  LogTrace("TSGForOIDNN")
367  << "TSGForOIDNN::produce: Check the error of the L2 parameter and use hit seeds if big errors";
368 
369  StateOnTrackerBound fromInside(propagatorAlong.get());
370  TrajectoryStateOnSurface outerTkStateInside = fromInside(fts);
371 
372  StateOnTrackerBound fromOutside(&*shpOpposite);
373  TrajectoryStateOnSurface outerTkStateOutside = fromOutside(tsosAtMuonSystem);
374 
375  // Check if the two positions (using updated and not-updated TSOS) agree withing certain extent.
376  // If both TSOSs agree, use only the one at vertex, as it uses more information. If they do not agree, search for seeds based on both.
377  double l2muonEta = l2.eta();
378  double absL2muonEta = std::abs(l2muonEta);
379 
380  // make non-const copies of parameters, so they can be overriden for individual L2 muons
381  unsigned int maxHitSeeds = maxHitSeeds_;
383  unsigned int maxHitlessSeedsIP = maxHitlessSeedsIP_;
385 
386  float errorSFHitless = fixedErrorRescalingForHitless_;
387 
388  // update strategy parameters by evaluating DNN
389  if (getStrategyFromDNN_) {
390  bool dnnSuccess = false;
391 
392  // Update feature map with parameters of the current muon
393  updateFeatureMap(feature_map, l2, tsosAtIP, outerTkStateOutside);
394 
395  if (useRegressor_) {
396  // Use regressor
397  evaluateRegressor(feature_map,
399  metadata_.get_child("HB"),
401  metadata_.get_child("HLIP"),
403  metadata_.get_child("HLMuS"),
404  strPars,
405  dnnSuccess);
406  } else {
407  // Use classifier
408  evaluateClassifier(feature_map, tf_session_, metadata_, strPars, dnnSuccess);
409  }
410  if (!dnnSuccess)
411  break;
412 
413  maxHitSeeds = 0;
414  maxHitDoubletSeeds = strPars.nHBd;
415  maxHitlessSeedsIP = strPars.nHLIP;
416  maxHitlessSeedsMuS = strPars.nHLMuS;
417  errorSFHitless = strPars.sf;
418  }
419 
420  numSeedsMade = 0;
421  hitlessSeedsMadeIP = 0;
422  hitlessSeedsMadeMuS = 0;
423  hitSeedsMade = 0;
424  hitDoubletSeedsMade = 0;
425 
426  auto createSeeds = [&](auto const& layers) {
427  for (auto const& layer : boost::adaptors::reverse(layers)) {
428  if (hitlessSeedsMadeIP < maxHitlessSeedsIP && numSeedsMade < maxSeeds_)
430  tsosAtIP,
431  *(propagatorAlong.get()),
432  estimator,
433  errorSFHitless,
434  hitlessSeedsMadeIP,
435  numSeedsMade,
436  out);
437 
438  if (outerTkStateInside.isValid() && outerTkStateOutside.isValid() && hitlessSeedsMadeMuS < maxHitlessSeedsMuS &&
439  numSeedsMade < maxSeeds_)
441  outerTkStateOutside,
442  *(propagatorOpposite.get()),
443  estimator,
444  errorSFHitless,
445  hitlessSeedsMadeMuS,
446  numSeedsMade,
447  out);
448 
449  if (hitSeedsMade < maxHitSeeds && numSeedsMade < maxSeeds_)
451  tsosAtIP,
452  *(propagatorAlong.get()),
453  estimator,
455  hitSeedsMade,
456  numSeedsMade,
457  maxHitSeeds,
458  layerCount,
459  out);
460 
461  if (hitDoubletSeedsMade < maxHitDoubletSeeds && numSeedsMade < maxSeeds_)
463  tsosAtIP,
464  *(propagatorAlong.get()),
465  estimator,
467  navSchool,
468  hitDoubletSeedsMade,
469  numSeedsMade,
471  layerCount,
472  out);
473  };
474  };
475 
476  // BARREL
477  if (absL2muonEta < maxEtaForTOB_) {
478  layerCount = 0;
479  createSeeds(tob);
480  LogTrace("TSGForOIDNN") << "TSGForOIDNN:::produce: NumSeedsMade = " << numSeedsMade
481  << " , layerCount = " << layerCount;
482  }
483 
484  // Reset number of seeds if in overlap region
485  if (absL2muonEta > minEtaForTEC_ && absL2muonEta < maxEtaForTOB_) {
486  numSeedsMade = 0;
487  hitlessSeedsMadeIP = 0;
488  hitlessSeedsMadeMuS = 0;
489  hitSeedsMade = 0;
490  hitDoubletSeedsMade = 0;
491  }
492 
493  // ENDCAP+
494  if (l2muonEta > minEtaForTEC_) {
495  layerCount = 0;
496  createSeeds(tecPositive);
497  LogTrace("TSGForOIDNN") << "TSGForOIDNN:::produce: NumSeedsMade = " << numSeedsMade
498  << " , layerCount = " << layerCount;
499  }
500 
501  // ENDCAP-
502  if (l2muonEta < -minEtaForTEC_) {
503  layerCount = 0;
504  createSeeds(tecNegative);
505  LogTrace("TSGForOIDNN") << "TSGForOIDNN:::produce: NumSeedsMade = " << numSeedsMade
506  << " , layerCount = " << layerCount;
507  }
508 
509  for (std::vector<TrajectorySeed>::iterator it = out.begin(); it != out.end(); ++it) {
510  result->push_back(*it);
511  }
512 
513  } // L2Collection
514 
515  edm::LogInfo(theCategory_) << "TSGForOIDNN::produce: number of seeds made: " << result->size();
516 
517  iEvent.put(std::move(result));
518 }
const unsigned int maxSeeds_
Maximum number of seeds for each L2.
Definition: TSGForOIDNN.cc:65
void evaluateRegressor(const std::unordered_map< std::string, float > &feature_map, tensorflow::Session *session_HB, const pt::ptree &metadata_HB, tensorflow::Session *session_HLIP, const pt::ptree &metadata_HLIP, tensorflow::Session *session_HLMuS, const pt::ptree &metadata_HLMuS, StrategyParameters &out, bool &dnnSuccess) const
Evaluate DNN regressor.
Definition: TSGForOIDNN.cc:935
void updateFeatureMap(std::unordered_map< std::string, float > &the_map, const reco::Track &l2, const TrajectoryStateOnSurface &tsos_IP, const TrajectoryStateOnSurface &tsos_MuS) const
Update dictionary of inputs for DNN.
Definition: TSGForOIDNN.cc:813
tensorflow::Session * tf_session_HLMuS_
Definition: TSGForOIDNN.cc:108
const edm::ESGetToken< NavigationSchool, NavigationSchoolRecord > t_navSchool_
Definition: TSGForOIDNN.cc:58
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > t_geometryH_
Definition: TSGForOIDNN.cc:57
const edm::EDGetTokenT< MeasurementTrackerEvent > measurementTrackerTag_
Definition: TSGForOIDNN.cc:61
void makeSeedsFromHitDoublets(const GeometricSearchDet &layer, const TrajectoryStateOnSurface &tsos, const Propagator &propagatorAlong, const Chi2MeasurementEstimatorBase &estimator, const MeasurementTrackerEvent &measurementTracker, const NavigationSchool &navSchool, unsigned int &hitDoubletSeedsMade, unsigned int &numSeedsMade, const unsigned int &maxHitDoubletSeeds, unsigned int &layerCount, std::vector< TrajectorySeed > &out) const
Similar to makeSeedsFromHits, but seed is created only if there are compatible hits on two adjacent l...
Definition: TSGForOIDNN.cc:629
tensorflow::Session * tf_session_HB_
Definition: TSGForOIDNN.cc:104
const unsigned int maxHitlessSeedsMuS_
Definition: TSGForOIDNN.cc:86
const edm::EDGetTokenT< reco::TrackCollection > src_
Labels for input collections.
Definition: TSGForOIDNN.cc:50
const unsigned int maxHitlessSeedsIP_
Definition: TSGForOIDNN.cc:85
const edm::ESGetToken< Chi2MeasurementEstimatorBase, TrackingComponentsRecord > t_estimatorH_
Tokens for ESHandle.
Definition: TSGForOIDNN.cc:52
const double minEtaForTEC_
Minimum eta value to activate searching in the TEC.
Definition: TSGForOIDNN.cc:79
#define LogTrace(id)
static PlanePointer build(Args &&... args)
Definition: Plane.h:33
GlobalPoint position() const
std::unique_ptr< Propagator > SetPropagationDirection(Propagator const &iprop, PropagationDirection dir)
int iEvent
Definition: GenABIO.cc:224
const double fixedErrorRescalingForHitless_
Rescale L2 parameter uncertainties (fixed error vs pT, eta)
Definition: TSGForOIDNN.cc:75
bool isThere(GeomDetEnumerators::SubDetector subdet) const
const std::string theCategory_
Definition: TSGForOIDNN.cc:62
const edm::ESGetToken< Propagator, TrackingComponentsRecord > t_propagatorOppositeH_
Definition: TSGForOIDNN.cc:55
const unsigned int maxHitSeeds_
Maximum number of hitbased seeds for each L2.
Definition: TSGForOIDNN.cc:67
const unsigned int maxHitDoubletSeeds_
Definition: TSGForOIDNN.cc:87
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const bool useRegressor_
Whether to use DNN regressor (if false, will use classifier)
Definition: TSGForOIDNN.cc:92
void makeSeedsWithoutHits(const GeometricSearchDet &layer, const TrajectoryStateOnSurface &tsos, const Propagator &propagatorAlong, const Chi2MeasurementEstimatorBase &estimator, double errorSF, unsigned int &hitlessSeedsMade, unsigned int &numSeedsMade, std::vector< TrajectorySeed > &out) const
Create seeds without hits on a given layer (TOB or TEC)
Definition: TSGForOIDNN.cc:523
Log< level::Info, false > LogInfo
const edm::ESGetToken< Propagator, TrackingComponentsRecord > t_SHPOpposite_
Definition: TSGForOIDNN.cc:59
const double maxEtaForTOB_
Maximum eta value to activate searching in the TOB.
Definition: TSGForOIDNN.cc:81
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > t_magfieldH_
Definition: TSGForOIDNN.cc:53
tensorflow::Session * tf_session_
Definition: TSGForOIDNN.cc:97
const edm::ESGetToken< Propagator, TrackingComponentsRecord > t_propagatorAlongH_
Definition: TSGForOIDNN.cc:54
const bool getStrategyFromDNN_
Get number of seeds to use from DNN output instead of "max..Seeds" parameters.
Definition: TSGForOIDNN.cc:90
pt::ptree metadata_
Definition: TSGForOIDNN.cc:112
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > t_tmpTkGeometryH_
Definition: TSGForOIDNN.cc:56
FreeTrajectoryState initialFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
void evaluateClassifier(const std::unordered_map< std::string, float > &feature_map, tensorflow::Session *session, const pt::ptree &metadata, StrategyParameters &out, bool &dnnSuccess) const
Evaluate DNN classifier.
Definition: TSGForOIDNN.cc:878
def move(src, dest)
Definition: eostools.py:511
void makeSeedsFromHits(const GeometricSearchDet &layer, const TrajectoryStateOnSurface &tsos, const Propagator &propagatorAlong, const Chi2MeasurementEstimatorBase &estimator, const MeasurementTrackerEvent &measurementTracker, unsigned int &hitSeedsMade, unsigned int &numSeedsMade, const unsigned int &maxHitSeeds, unsigned int &layerCount, std::vector< TrajectorySeed > &out) const
Find hits on a given layer (TOB or TEC) and create seeds from updated TSOS with hit.
Definition: TSGForOIDNN.cc:557
TrajectoryStateOnSurface innerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field, bool withErr=true)
tensorflow::Session * tf_session_HLIP_
Definition: TSGForOIDNN.cc:106

◆ updateFeatureMap()

void TSGForOIDNN::updateFeatureMap ( std::unordered_map< std::string, float > &  the_map,
const reco::Track l2,
const TrajectoryStateOnSurface tsos_IP,
const TrajectoryStateOnSurface tsos_MuS 
) const
private

Update dictionary of inputs for DNN.

Definition at line 813 of file TSGForOIDNN.cc.

References TrajectoryStateOnSurface::curvilinearError(), PV3DBase< T, PVType, FrameType >::eta(), reco::TrackBase::eta(), reco::Track::found(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), CurvilinearTrajectoryError::matrix(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), reco::TrackBase::phi(), reco::TrackBase::pt(), and mathSSE::sqrt().

Referenced by produce().

816  {
817  the_map["pt"] = l2.pt();
818  the_map["eta"] = l2.eta();
819  the_map["phi"] = l2.phi();
820  the_map["validHits"] = l2.found();
821  if (tsos_IP.isValid()) {
822  the_map["tsos_IP_eta"] = tsos_IP.globalPosition().eta();
823  the_map["tsos_IP_phi"] = tsos_IP.globalPosition().phi();
824  the_map["tsos_IP_pt"] = tsos_IP.globalMomentum().perp();
825  the_map["tsos_IP_pt_eta"] = tsos_IP.globalMomentum().eta();
826  the_map["tsos_IP_pt_phi"] = tsos_IP.globalMomentum().phi();
827  const AlgebraicSymMatrix55& matrix_IP = tsos_IP.curvilinearError().matrix();
828  the_map["err0_IP"] = sqrt(matrix_IP[0][0]);
829  the_map["err1_IP"] = sqrt(matrix_IP[1][1]);
830  the_map["err2_IP"] = sqrt(matrix_IP[2][2]);
831  the_map["err3_IP"] = sqrt(matrix_IP[3][3]);
832  the_map["err4_IP"] = sqrt(matrix_IP[4][4]);
833  the_map["tsos_IP_valid"] = 1.0;
834  } else {
835  the_map["tsos_IP_eta"] = -999;
836  the_map["tsos_IP_phi"] = -999;
837  the_map["tsos_IP_pt"] = -999;
838  the_map["tsos_IP_pt_eta"] = -999;
839  the_map["tsos_IP_pt_phi"] = -999;
840  the_map["err0_IP"] = -999;
841  the_map["err1_IP"] = -999;
842  the_map["err2_IP"] = -999;
843  the_map["err3_IP"] = -999;
844  the_map["err4_IP"] = -999;
845  the_map["tsos_IP_valid"] = 0.0;
846  }
847  if (tsos_MuS.isValid()) {
848  the_map["tsos_MuS_eta"] = tsos_MuS.globalPosition().eta();
849  the_map["tsos_MuS_phi"] = tsos_MuS.globalPosition().phi();
850  the_map["tsos_MuS_pt"] = tsos_MuS.globalMomentum().perp();
851  the_map["tsos_MuS_pt_eta"] = tsos_MuS.globalMomentum().eta();
852  the_map["tsos_MuS_pt_phi"] = tsos_MuS.globalMomentum().phi();
853  const AlgebraicSymMatrix55& matrix_MuS = tsos_MuS.curvilinearError().matrix();
854  the_map["err0_MuS"] = sqrt(matrix_MuS[0][0]);
855  the_map["err1_MuS"] = sqrt(matrix_MuS[1][1]);
856  the_map["err2_MuS"] = sqrt(matrix_MuS[2][2]);
857  the_map["err3_MuS"] = sqrt(matrix_MuS[3][3]);
858  the_map["err4_MuS"] = sqrt(matrix_MuS[4][4]);
859  the_map["tsos_MuS_valid"] = 1.0;
860  } else {
861  the_map["tsos_MuS_eta"] = -999;
862  the_map["tsos_MuS_phi"] = -999;
863  the_map["tsos_MuS_pt"] = -999;
864  the_map["tsos_MuS_pt_eta"] = -999;
865  the_map["tsos_MuS_pt_phi"] = -999;
866  the_map["err0_MuS"] = -999;
867  the_map["err1_MuS"] = -999;
868  the_map["err2_MuS"] = -999;
869  the_map["err3_MuS"] = -999;
870  the_map["err4_MuS"] = -999;
871  the_map["tsos_MuS_valid"] = 0.0;
872  }
873 }
T perp() const
Definition: PV3DBase.h:69
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T eta() const
Definition: PV3DBase.h:73
unsigned short found() const
Number of valid hits on track.
Definition: Track.h:142
double pt() const
track transverse momentum
Definition: TrackBase.h:637
GlobalPoint globalPosition() const
T sqrt(T t)
Definition: SSEVec.h:23
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:649
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:652
const CurvilinearTrajectoryError & curvilinearError() const
const AlgebraicSymMatrix55 & matrix() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
GlobalVector globalMomentum() const

Member Data Documentation

◆ dnnMetadataPath_

const std::string TSGForOIDNN::dnnMetadataPath_
private

DNN metadata.

Definition at line 111 of file TSGForOIDNN.cc.

Referenced by TSGForOIDNN().

◆ dnnModelPath_

std::string TSGForOIDNN::dnnModelPath_
private

Settings for classifier.

Definition at line 95 of file TSGForOIDNN.cc.

Referenced by TSGForOIDNN().

◆ dnnModelPath_HB_

std::string TSGForOIDNN::dnnModelPath_HB_
private

Settings for regressor.

Definition at line 100 of file TSGForOIDNN.cc.

Referenced by TSGForOIDNN().

◆ dnnModelPath_HLIP_

std::string TSGForOIDNN::dnnModelPath_HLIP_
private

Definition at line 101 of file TSGForOIDNN.cc.

Referenced by TSGForOIDNN().

◆ dnnModelPath_HLMuS_

std::string TSGForOIDNN::dnnModelPath_HLMuS_
private

Definition at line 102 of file TSGForOIDNN.cc.

Referenced by TSGForOIDNN().

◆ estimatorName_

const std::string TSGForOIDNN::estimatorName_
private

Estimator used to find dets and TrajectoryMeasurements.

Definition at line 77 of file TSGForOIDNN.cc.

◆ fixedErrorRescalingForHitless_

const double TSGForOIDNN::fixedErrorRescalingForHitless_
private

Rescale L2 parameter uncertainties (fixed error vs pT, eta)

Definition at line 75 of file TSGForOIDNN.cc.

Referenced by produce().

◆ getStrategyFromDNN_

const bool TSGForOIDNN::getStrategyFromDNN_
private

Get number of seeds to use from DNN output instead of "max..Seeds" parameters.

Definition at line 90 of file TSGForOIDNN.cc.

Referenced by initializeTensorflow(), produce(), TSGForOIDNN(), and ~TSGForOIDNN().

◆ graphDef_

std::unique_ptr<tensorflow::GraphDef> TSGForOIDNN::graphDef_
private

Definition at line 96 of file TSGForOIDNN.cc.

Referenced by TSGForOIDNN().

◆ graphDef_HB_

std::unique_ptr<tensorflow::GraphDef> TSGForOIDNN::graphDef_HB_
private

Definition at line 103 of file TSGForOIDNN.cc.

Referenced by TSGForOIDNN().

◆ graphDef_HLIP_

std::unique_ptr<tensorflow::GraphDef> TSGForOIDNN::graphDef_HLIP_
private

Definition at line 105 of file TSGForOIDNN.cc.

Referenced by TSGForOIDNN().

◆ graphDef_HLMuS_

std::unique_ptr<tensorflow::GraphDef> TSGForOIDNN::graphDef_HLMuS_
private

Definition at line 107 of file TSGForOIDNN.cc.

Referenced by TSGForOIDNN().

◆ maxEtaForTOB_

const double TSGForOIDNN::maxEtaForTOB_
private

Maximum eta value to activate searching in the TOB.

Definition at line 81 of file TSGForOIDNN.cc.

Referenced by produce().

◆ maxHitDoubletSeeds_

const unsigned int TSGForOIDNN::maxHitDoubletSeeds_
private

Definition at line 87 of file TSGForOIDNN.cc.

Referenced by produce().

◆ maxHitlessSeeds_

const unsigned int TSGForOIDNN::maxHitlessSeeds_
private

Maximum number of hitless seeds for each L2.

Definition at line 69 of file TSGForOIDNN.cc.

◆ maxHitlessSeedsIP_

const unsigned int TSGForOIDNN::maxHitlessSeedsIP_
private

IP refers to TSOS at interaction point, MuS refers to TSOS at muon system

Definition at line 85 of file TSGForOIDNN.cc.

Referenced by produce().

◆ maxHitlessSeedsMuS_

const unsigned int TSGForOIDNN::maxHitlessSeedsMuS_
private

Definition at line 86 of file TSGForOIDNN.cc.

Referenced by produce().

◆ maxHitSeeds_

const unsigned int TSGForOIDNN::maxHitSeeds_
private

Maximum number of hitbased seeds for each L2.

Definition at line 67 of file TSGForOIDNN.cc.

Referenced by produce().

◆ maxSeeds_

const unsigned int TSGForOIDNN::maxSeeds_
private

Maximum number of seeds for each L2.

Definition at line 65 of file TSGForOIDNN.cc.

Referenced by produce().

◆ measurementTrackerTag_

const edm::EDGetTokenT<MeasurementTrackerEvent> TSGForOIDNN::measurementTrackerTag_
private

Definition at line 61 of file TSGForOIDNN.cc.

Referenced by produce().

◆ metadata_

pt::ptree TSGForOIDNN::metadata_
private

Definition at line 112 of file TSGForOIDNN.cc.

Referenced by initializeTensorflow(), produce(), and TSGForOIDNN().

◆ minEtaForTEC_

const double TSGForOIDNN::minEtaForTEC_
private

Minimum eta value to activate searching in the TEC.

Definition at line 79 of file TSGForOIDNN.cc.

Referenced by produce().

◆ numOfHitsToTry_

const unsigned int TSGForOIDNN::numOfHitsToTry_
private

How many hits to try per layer.

Definition at line 73 of file TSGForOIDNN.cc.

Referenced by makeSeedsFromHitDoublets(), and makeSeedsFromHits().

◆ numOfLayersToTry_

const unsigned int TSGForOIDNN::numOfLayersToTry_
private

How many layers to try.

Definition at line 71 of file TSGForOIDNN.cc.

Referenced by makeSeedsFromHits().

◆ src_

const edm::EDGetTokenT<reco::TrackCollection> TSGForOIDNN::src_
private

Labels for input collections.

Definition at line 50 of file TSGForOIDNN.cc.

Referenced by produce().

◆ t_estimatorH_

const edm::ESGetToken<Chi2MeasurementEstimatorBase, TrackingComponentsRecord> TSGForOIDNN::t_estimatorH_
private

Tokens for ESHandle.

Definition at line 52 of file TSGForOIDNN.cc.

Referenced by produce().

◆ t_geometryH_

const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> TSGForOIDNN::t_geometryH_
private

Definition at line 57 of file TSGForOIDNN.cc.

Referenced by produce().

◆ t_magfieldH_

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> TSGForOIDNN::t_magfieldH_
private

Definition at line 53 of file TSGForOIDNN.cc.

Referenced by produce().

◆ t_navSchool_

const edm::ESGetToken<NavigationSchool, NavigationSchoolRecord> TSGForOIDNN::t_navSchool_
private

Definition at line 58 of file TSGForOIDNN.cc.

Referenced by produce().

◆ t_propagatorAlongH_

const edm::ESGetToken<Propagator, TrackingComponentsRecord> TSGForOIDNN::t_propagatorAlongH_
private

Definition at line 54 of file TSGForOIDNN.cc.

Referenced by produce().

◆ t_propagatorOppositeH_

const edm::ESGetToken<Propagator, TrackingComponentsRecord> TSGForOIDNN::t_propagatorOppositeH_
private

Definition at line 55 of file TSGForOIDNN.cc.

Referenced by produce().

◆ t_SHPOpposite_

const edm::ESGetToken<Propagator, TrackingComponentsRecord> TSGForOIDNN::t_SHPOpposite_
private

Definition at line 59 of file TSGForOIDNN.cc.

Referenced by produce().

◆ t_tmpTkGeometryH_

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> TSGForOIDNN::t_tmpTkGeometryH_
private

Definition at line 56 of file TSGForOIDNN.cc.

Referenced by produce().

◆ tf_session_

tensorflow::Session* TSGForOIDNN::tf_session_
private

Definition at line 97 of file TSGForOIDNN.cc.

Referenced by initializeTensorflow(), produce(), TSGForOIDNN(), and ~TSGForOIDNN().

◆ tf_session_HB_

tensorflow::Session* TSGForOIDNN::tf_session_HB_
private

Definition at line 104 of file TSGForOIDNN.cc.

Referenced by produce(), TSGForOIDNN(), and ~TSGForOIDNN().

◆ tf_session_HLIP_

tensorflow::Session* TSGForOIDNN::tf_session_HLIP_
private

Definition at line 106 of file TSGForOIDNN.cc.

Referenced by produce(), TSGForOIDNN(), and ~TSGForOIDNN().

◆ tf_session_HLMuS_

tensorflow::Session* TSGForOIDNN::tf_session_HLMuS_
private

Definition at line 108 of file TSGForOIDNN.cc.

Referenced by produce(), TSGForOIDNN(), and ~TSGForOIDNN().

◆ theCategory_

const std::string TSGForOIDNN::theCategory_
private

Definition at line 62 of file TSGForOIDNN.cc.

Referenced by makeSeedsWithoutHits(), and produce().

◆ updator_

const std::unique_ptr<TrajectoryStateUpdator> TSGForOIDNN::updator_
private

Definition at line 60 of file TSGForOIDNN.cc.

Referenced by makeSeedsFromHitDoublets(), and makeSeedsFromHits().

◆ useRegressor_

const bool TSGForOIDNN::useRegressor_
private

Whether to use DNN regressor (if false, will use classifier)

Definition at line 92 of file TSGForOIDNN.cc.

Referenced by initializeTensorflow(), produce(), TSGForOIDNN(), and ~TSGForOIDNN().