CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
TrackstersProducer Class Reference
Inheritance diagram for TrackstersProducer:
edm::stream::EDProducer< edm::GlobalCache< TrackstersCache > >

Public Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
 TrackstersProducer (const edm::ParameterSet &, const TrackstersCache *)
 
 ~TrackstersProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< TrackstersCache > >
 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
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
static void globalEndJob (TrackstersCache *)
 
static std::unique_ptr
< TrackstersCache
initializeGlobalCache (const edm::ParameterSet &)
 

Private Attributes

const edm::EDGetTokenT
< std::vector
< reco::CaloCluster > > 
clusters_token_
 
const edm::EDGetTokenT
< edm::ValueMap< std::pair
< float, float > > > 
clustersTime_token_
 
std::string detector_
 
bool doNose_
 
const edm::EDGetTokenT
< std::vector< float > > 
filtered_layerclusters_mask_token_
 
ticl::Trackster::IterationIndex iterIndex_ = ticl::Trackster::IterationIndex(0)
 
const std::string itername_
 
edm::EDGetTokenT
< TICLLayerTilesHFNose
layer_clusters_tiles_hfnose_token_
 
edm::EDGetTokenT< TICLLayerTileslayer_clusters_tiles_token_
 
std::unique_ptr
< PatternRecognitionAlgoBaseT
< TICLLayerTiles > > 
myAlgo_
 
std::unique_ptr
< PatternRecognitionAlgoBaseT
< TICLLayerTilesHFNose > > 
myAlgoHFNose_
 
const edm::EDGetTokenT
< std::vector< float > > 
original_layerclusters_mask_token_
 
const edm::EDGetTokenT
< std::vector
< TICLSeedingRegion > > 
seeding_regions_token_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< TrackstersCache > >
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 32 of file TrackstersProducer.cc.

Constructor & Destructor Documentation

TrackstersProducer::TrackstersProducer ( const edm::ParameterSet ps,
const TrackstersCache cache 
)
explicit

Definition at line 81 of file TrackstersProducer.cc.

References doNose_, ticl::Trackster::EM, get, edm::ParameterSet::getParameter(), ticl::Trackster::HAD, iterIndex_, itername_, layer_clusters_tiles_hfnose_token_, layer_clusters_tiles_token_, ticl::Trackster::MIP, myAlgo_, myAlgoHFNose_, fwrapper::plugin, AlCaHLTBitMon_QueryRunRegistry::string, ticl::Trackster::TRKEM, and ticl::Trackster::TRKHAD.

82  : detector_(ps.getParameter<std::string>("detector")),
83  doNose_(detector_ == "HFNose"),
84  clusters_token_(consumes<std::vector<reco::CaloCluster>>(ps.getParameter<edm::InputTag>("layer_clusters"))),
85  filtered_layerclusters_mask_token_(consumes<std::vector<float>>(ps.getParameter<edm::InputTag>("filtered_mask"))),
86  original_layerclusters_mask_token_(consumes<std::vector<float>>(ps.getParameter<edm::InputTag>("original_mask"))),
88  consumes<edm::ValueMap<std::pair<float, float>>>(ps.getParameter<edm::InputTag>("time_layerclusters"))),
90  consumes<std::vector<TICLSeedingRegion>>(ps.getParameter<edm::InputTag>("seeding_regions"))),
91  itername_(ps.getParameter<std::string>("itername")) {
92  auto plugin = ps.getParameter<std::string>("patternRecognitionBy");
93  auto pluginPSet = ps.getParameter<edm::ParameterSet>("pluginPatternRecognitionBy" + plugin);
94  if (doNose_) {
96  ps.getParameter<std::string>("patternRecognitionBy"), pluginPSet, cache, consumesCollector());
98  consumes<TICLLayerTilesHFNose>(ps.getParameter<edm::InputTag>("layer_clusters_hfnose_tiles"));
99  } else {
101  ps.getParameter<std::string>("patternRecognitionBy"), pluginPSet, cache, consumesCollector());
102  layer_clusters_tiles_token_ = consumes<TICLLayerTiles>(ps.getParameter<edm::InputTag>("layer_clusters_tiles"));
103  }
104 
105  if (itername_ == "TrkEM")
107  else if (itername_ == "EM")
109  else if (itername_ == "Trk")
111  else if (itername_ == "HAD")
113  else if (itername_ == "MIP")
115 
116  produces<std::vector<Trackster>>();
117  produces<std::vector<float>>(); // Mask to be applied at the next iteration
118 }
ticl::Trackster::IterationIndex iterIndex_
edm::EDGetTokenT< TICLLayerTilesHFNose > layer_clusters_tiles_hfnose_token_
const edm::EDGetTokenT< std::vector< reco::CaloCluster > > clusters_token_
const edm::EDGetTokenT< std::vector< float > > original_layerclusters_mask_token_
edm::EDGetTokenT< TICLLayerTiles > layer_clusters_tiles_token_
const std::string itername_
const edm::EDGetTokenT< std::vector< TICLSeedingRegion > > seeding_regions_token_
unique_ptr< JetDefinition::Plugin > plugin
const edm::EDGetTokenT< edm::ValueMap< std::pair< float, float > > > clustersTime_token_
std::unique_ptr< PatternRecognitionAlgoBaseT< TICLLayerTiles > > myAlgo_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDGetTokenT< std::vector< float > > filtered_layerclusters_mask_token_
#define get
std::unique_ptr< PatternRecognitionAlgoBaseT< TICLLayerTilesHFNose > > myAlgoHFNose_
TrackstersProducer::~TrackstersProducer ( )
inlineoverride

Definition at line 35 of file TrackstersProducer.cc.

35 {}

Member Function Documentation

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

Definition at line 120 of file TrackstersProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addNode(), submitPVResolutionJobs::desc, HLT_FULL_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

120  {
121  // hgcalMultiClusters
123  desc.add<std::string>("detector", "HGCAL");
124  desc.add<edm::InputTag>("layer_clusters", edm::InputTag("hgcalLayerClusters"));
125  desc.add<edm::InputTag>("filtered_mask", edm::InputTag("filteredLayerClusters", "iterationLabelGoesHere"));
126  desc.add<edm::InputTag>("original_mask", edm::InputTag("hgcalLayerClusters", "InitialLayerClustersMask"));
127  desc.add<edm::InputTag>("time_layerclusters", edm::InputTag("hgcalLayerClusters", "timeLayerCluster"));
128  desc.add<edm::InputTag>("layer_clusters_tiles", edm::InputTag("ticlLayerTileProducer"));
129  desc.add<edm::InputTag>("layer_clusters_hfnose_tiles", edm::InputTag("ticlLayerTileHFNose"));
130  desc.add<edm::InputTag>("seeding_regions", edm::InputTag("ticlSeedingRegionProducer"));
131  desc.add<std::string>("patternRecognitionBy", "CA");
132  desc.add<std::string>("eid_graph_path", "RecoHGCal/TICL/data/tf_models/energy_id_v0.pb");
133  desc.add<std::string>("itername", "unknown");
134 
135  // CA Plugin
136  edm::ParameterSetDescription pluginDesc;
137  pluginDesc.addNode(edm::PluginDescription<PatternRecognitionFactory>("type", "CA", true));
138 
139  // CLUE3D Plugin
140  desc.add<edm::ParameterSetDescription>("pluginPatternRecognitionByCA", pluginDesc);
141  edm::ParameterSetDescription pluginDescClue3D;
142  pluginDescClue3D.addNode(edm::PluginDescription<PatternRecognitionFactory>("type", "CLUE3D", true));
143  desc.add<edm::ParameterSetDescription>("pluginPatternRecognitionByCLUE3D", pluginDescClue3D);
144 
145  descriptions.add("trackstersProducer", desc);
146 }
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void TrackstersProducer::globalEndJob ( TrackstersCache cache)
static

Definition at line 76 of file TrackstersProducer.cc.

References ticl::TrackstersCache::eidGraphDef.

76  {
77  delete cache->eidGraphDef;
78  cache->eidGraphDef = nullptr;
79 }
std::atomic< tensorflow::GraphDef * > eidGraphDef
Definition: GlobalCache.h:25
std::unique_ptr< TrackstersCache > TrackstersProducer::initializeGlobalCache ( const edm::ParameterSet params)
static

Definition at line 62 of file TrackstersProducer.cc.

References utilities::cache(), edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), tensorflow::loadGraphDef(), submitPVValidationJobs::params, and AlCaHLTBitMon_QueryRunRegistry::string.

62  {
63  // this method is supposed to create, initialize and return a TrackstersCache instance
64  std::unique_ptr<TrackstersCache> cache = std::make_unique<TrackstersCache>(params);
65 
66  // load the graph def and save it
67  std::string graphPath = params.getParameter<std::string>("eid_graph_path");
68  if (!graphPath.empty()) {
69  graphPath = edm::FileInPath(graphPath).fullPath();
70  cache->eidGraphDef = tensorflow::loadGraphDef(graphPath);
71  }
72 
73  return cache;
74 }
GraphDef * loadGraphDef(const std::string &pbFile)
Definition: TensorFlow.cc:68
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::string fullPath() const
Definition: FileInPath.cc:161
def cache
Definition: utilities.py:3
void TrackstersProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 148 of file TrackstersProducer.cc.

References SplitLinear::begin, clusters_token_, clustersTime_token_, filterCSVwithJSON::copy, doNose_, dataset::end, filtered_layerclusters_mask_token_, edm::Event::get(), mps_fire::i, input, iterIndex_, layer_clusters_tiles_hfnose_token_, layer_clusters_tiles_token_, eostools::move(), myAlgo_, myAlgoHFNose_, original_layerclusters_mask_token_, edm::Event::put(), mps_fire::result, seeding_regions_token_, and findQualityFiles::v.

148  {
149  auto result = std::make_unique<std::vector<Trackster>>();
150  auto output_mask = std::make_unique<std::vector<float>>();
151 
152  const std::vector<float>& original_layerclusters_mask = evt.get(original_layerclusters_mask_token_);
153  const auto& layerClusters = evt.get(clusters_token_);
154  const auto& inputClusterMask = evt.get(filtered_layerclusters_mask_token_);
155  const auto& layerClustersTimes = evt.get(clustersTime_token_);
156  const auto& seeding_regions = evt.get(seeding_regions_token_);
157 
158  std::unordered_map<int, std::vector<int>> seedToTrackstersAssociation;
159  // if it's regional iteration and there are seeding regions
160  if (!seeding_regions.empty() and seeding_regions[0].index != -1) {
161  auto numberOfSeedingRegions = seeding_regions.size();
162  for (unsigned int i = 0; i < numberOfSeedingRegions; ++i) {
163  seedToTrackstersAssociation.emplace(seeding_regions[i].index, 0);
164  }
165  }
166 
167  if (doNose_) {
168  const auto& layer_clusters_hfnose_tiles = evt.get(layer_clusters_tiles_hfnose_token_);
170  evt, es, layerClusters, inputClusterMask, layerClustersTimes, layer_clusters_hfnose_tiles, seeding_regions);
171 
172  myAlgoHFNose_->makeTracksters(inputHFNose, *result, seedToTrackstersAssociation);
173 
174  } else {
175  const auto& layer_clusters_tiles = evt.get(layer_clusters_tiles_token_);
177  evt, es, layerClusters, inputClusterMask, layerClustersTimes, layer_clusters_tiles, seeding_regions);
178 
179  myAlgo_->makeTracksters(input, *result, seedToTrackstersAssociation);
180  }
181  // Now update the global mask and put it into the event
182  output_mask->reserve(original_layerclusters_mask.size());
183  // Copy over the previous state
184  std::copy(
185  std::begin(original_layerclusters_mask), std::end(original_layerclusters_mask), std::back_inserter(*output_mask));
186 
187  for (auto& trackster : *result) {
188  trackster.setIteration(iterIndex_);
189  // Mask the used elements, accordingly
190  for (auto const v : trackster.vertices()) {
191  // TODO(rovere): for the moment we mask the layer cluster completely. In
192  // the future, properly compute the fraction of usage.
193  (*output_mask)[v] = 0.;
194  }
195  }
196 
197  evt.put(std::move(result));
198  evt.put(std::move(output_mask));
199 }
ticl::Trackster::IterationIndex iterIndex_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EDGetTokenT< TICLLayerTilesHFNose > layer_clusters_tiles_hfnose_token_
const edm::EDGetTokenT< std::vector< reco::CaloCluster > > clusters_token_
const edm::EDGetTokenT< std::vector< float > > original_layerclusters_mask_token_
static std::string const input
Definition: EdmProvDump.cc:47
tuple result
Definition: mps_fire.py:311
edm::EDGetTokenT< TICLLayerTiles > layer_clusters_tiles_token_
const edm::EDGetTokenT< std::vector< TICLSeedingRegion > > seeding_regions_token_
def move
Definition: eostools.py:511
const edm::EDGetTokenT< edm::ValueMap< std::pair< float, float > > > clustersTime_token_
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
std::unique_ptr< PatternRecognitionAlgoBaseT< TICLLayerTiles > > myAlgo_
const edm::EDGetTokenT< std::vector< float > > filtered_layerclusters_mask_token_
string end
Definition: dataset.py:937
std::unique_ptr< PatternRecognitionAlgoBaseT< TICLLayerTilesHFNose > > myAlgoHFNose_

Member Data Documentation

const edm::EDGetTokenT<std::vector<reco::CaloCluster> > TrackstersProducer::clusters_token_
private

Definition at line 50 of file TrackstersProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<edm::ValueMap<std::pair<float, float> > > TrackstersProducer::clustersTime_token_
private

Definition at line 53 of file TrackstersProducer.cc.

Referenced by produce().

std::string TrackstersProducer::detector_
private

Definition at line 45 of file TrackstersProducer.cc.

bool TrackstersProducer::doNose_
private

Definition at line 46 of file TrackstersProducer.cc.

Referenced by produce(), and TrackstersProducer().

const edm::EDGetTokenT<std::vector<float> > TrackstersProducer::filtered_layerclusters_mask_token_
private

Definition at line 51 of file TrackstersProducer.cc.

Referenced by produce().

ticl::Trackster::IterationIndex TrackstersProducer::iterIndex_ = ticl::Trackster::IterationIndex(0)
private

Definition at line 58 of file TrackstersProducer.cc.

Referenced by produce(), and TrackstersProducer().

const std::string TrackstersProducer::itername_
private

Definition at line 57 of file TrackstersProducer.cc.

Referenced by TrackstersProducer().

edm::EDGetTokenT<TICLLayerTilesHFNose> TrackstersProducer::layer_clusters_tiles_hfnose_token_
private

Definition at line 55 of file TrackstersProducer.cc.

Referenced by produce(), and TrackstersProducer().

edm::EDGetTokenT<TICLLayerTiles> TrackstersProducer::layer_clusters_tiles_token_
private

Definition at line 54 of file TrackstersProducer.cc.

Referenced by produce(), and TrackstersProducer().

std::unique_ptr<PatternRecognitionAlgoBaseT<TICLLayerTiles> > TrackstersProducer::myAlgo_
private

Definition at line 47 of file TrackstersProducer.cc.

Referenced by produce(), and TrackstersProducer().

std::unique_ptr<PatternRecognitionAlgoBaseT<TICLLayerTilesHFNose> > TrackstersProducer::myAlgoHFNose_
private

Definition at line 48 of file TrackstersProducer.cc.

Referenced by produce(), and TrackstersProducer().

const edm::EDGetTokenT<std::vector<float> > TrackstersProducer::original_layerclusters_mask_token_
private

Definition at line 52 of file TrackstersProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<std::vector<TICLSeedingRegion> > TrackstersProducer::seeding_regions_token_
private

Definition at line 56 of file TrackstersProducer.cc.

Referenced by produce().