CMS 3D CMS Logo

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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
static void globalEndJob (TrackstersCache *)
 
static std::unique_ptr< TrackstersCacheinitializeGlobalCache (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_
 
const std::vector< int > filter_on_categories_
 
const edm::EDGetTokenT< std::vector< float > > filtered_layerclusters_mask_token_
 
const std::string itername_
 
const edm::EDGetTokenT< TICLLayerTileslayer_clusters_tiles_token_
 
std::unique_ptr< PatternRecognitionAlgoBasemyAlgo_
 
const edm::EDGetTokenT< std::vector< float > > original_layerclusters_mask_token_
 
const double pid_threshold_
 
const edm::EDGetTokenT< std::vector< TICLSeedingRegion > > seeding_regions_token_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< TrackstersCache > >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 32 of file TrackstersProducer.cc.

Constructor & Destructor Documentation

◆ TrackstersProducer()

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

Definition at line 78 of file TrackstersProducer.cc.

79  : myAlgo_(std::make_unique<PatternRecognitionbyCA>(ps, cache)),
80  clusters_token_(consumes<std::vector<reco::CaloCluster>>(ps.getParameter<edm::InputTag>("layer_clusters"))),
81  filtered_layerclusters_mask_token_(consumes<std::vector<float>>(ps.getParameter<edm::InputTag>("filtered_mask"))),
82  original_layerclusters_mask_token_(consumes<std::vector<float>>(ps.getParameter<edm::InputTag>("original_mask"))),
84  consumes<edm::ValueMap<std::pair<float, float>>>(ps.getParameter<edm::InputTag>("time_layerclusters"))),
85  layer_clusters_tiles_token_(consumes<TICLLayerTiles>(ps.getParameter<edm::InputTag>("layer_clusters_tiles"))),
87  consumes<std::vector<TICLSeedingRegion>>(ps.getParameter<edm::InputTag>("seeding_regions"))),
88  filter_on_categories_(ps.getParameter<std::vector<int>>("filter_on_categories")),
89  pid_threshold_(ps.getParameter<double>("pid_threshold")),
90  itername_(ps.getParameter<std::string>("itername")) {
91  produces<std::vector<Trackster>>();
92  produces<std::vector<float>>(); // Mask to be applied at the next iteration
93 }

◆ ~TrackstersProducer()

TrackstersProducer::~TrackstersProducer ( )
inlineoverride

Definition at line 35 of file TrackstersProducer.cc.

35 {}

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 95 of file TrackstersProducer.cc.

95  {
96  // hgcalMultiClusters
98  desc.add<edm::InputTag>("layer_clusters", edm::InputTag("hgcalLayerClusters"));
99  desc.add<edm::InputTag>("filtered_mask", edm::InputTag("filteredLayerClusters", "iterationLabelGoesHere"));
100  desc.add<edm::InputTag>("original_mask", edm::InputTag("hgcalLayerClusters", "InitialLayerClustersMask"));
101  desc.add<edm::InputTag>("time_layerclusters", edm::InputTag("hgcalLayerClusters", "timeLayerCluster"));
102  desc.add<edm::InputTag>("layer_clusters_tiles", edm::InputTag("ticlLayerTileProducer"));
103  desc.add<edm::InputTag>("seeding_regions", edm::InputTag("ticlSeedingRegionProducer"));
104  desc.add<std::vector<int>>("filter_on_categories", {0});
105  desc.add<double>("pid_threshold", 0.); // make default such that no filtering is applied
106  desc.add<int>("algo_verbosity", 0);
107  desc.add<double>("min_cos_theta", 0.915);
108  desc.add<double>("min_cos_pointing", -1.);
109  desc.add<int>("missing_layers", 0);
110  desc.add<double>("etaLimitIncreaseWindow", 2.1);
111  desc.add<int>("min_clusters_per_ntuplet", 10);
112  desc.add<double>("max_delta_time", 3.); //nsigma
113  desc.add<bool>("out_in_dfs", true);
114  desc.add<int>("max_out_in_hops", 10);
115  desc.add<bool>("oneTracksterPerTrackSeed", false);
116  desc.add<bool>("promoteEmptyRegionToTrackster", false);
117  desc.add<std::string>("eid_graph_path", "RecoHGCal/TICL/data/tf_models/energy_id_v0.pb");
118  desc.add<std::string>("eid_input_name", "input");
119  desc.add<std::string>("eid_output_name_energy", "output/regressed_energy");
120  desc.add<std::string>("eid_output_name_id", "output/id_probabilities");
121  desc.add<std::string>("itername", "unknown");
122  desc.add<double>("eid_min_cluster_energy", 1.);
123  desc.add<int>("eid_n_layers", 50);
124  desc.add<int>("eid_n_clusters", 10);
125  descriptions.add("trackstersProducer", desc);
126 }

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), HLT_2018_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ globalEndJob()

void TrackstersProducer::globalEndJob ( TrackstersCache cache)
static

Definition at line 73 of file TrackstersProducer.cc.

73  {
74  delete cache->eidGraphDef;
75  cache->eidGraphDef = nullptr;
76 }

References utilities::cache().

◆ initializeGlobalCache()

std::unique_ptr< TrackstersCache > TrackstersProducer::initializeGlobalCache ( const edm::ParameterSet params)
static

Definition at line 59 of file TrackstersProducer.cc.

59  {
60  // this method is supposed to create, initialize and return a TrackstersCache instance
61  std::unique_ptr<TrackstersCache> cache = std::make_unique<TrackstersCache>(params);
62 
63  // load the graph def and save it
64  std::string graphPath = params.getParameter<std::string>("eid_graph_path");
65  if (!graphPath.empty()) {
66  graphPath = edm::FileInPath(graphPath).fullPath();
67  cache->eidGraphDef = tensorflow::loadGraphDef(graphPath);
68  }
69 
70  return cache;
71 }

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

◆ produce()

void TrackstersProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 128 of file TrackstersProducer.cc.

128  {
129  auto result = std::make_unique<std::vector<Trackster>>();
130  auto output_mask = std::make_unique<std::vector<float>>();
131 
133  edm::Handle<std::vector<float>> filtered_layerclusters_mask_h;
134  edm::Handle<std::vector<float>> original_layerclusters_mask_h;
136  edm::Handle<TICLLayerTiles> layer_clusters_tiles_h;
138 
139  evt.getByToken(clusters_token_, cluster_h);
140  evt.getByToken(filtered_layerclusters_mask_token_, filtered_layerclusters_mask_h);
141  evt.getByToken(original_layerclusters_mask_token_, original_layerclusters_mask_h);
142  evt.getByToken(clustersTime_token_, time_clusters_h);
143  evt.getByToken(layer_clusters_tiles_token_, layer_clusters_tiles_h);
144  evt.getByToken(seeding_regions_token_, seeding_regions_h);
145 
146  const auto& layerClusters = *cluster_h;
147  const auto& inputClusterMask = *filtered_layerclusters_mask_h;
148  const auto& layerClustersTimes = *time_clusters_h;
149  const auto& layer_clusters_tiles = *layer_clusters_tiles_h;
150  const auto& seeding_regions = *seeding_regions_h;
152  evt, es, layerClusters, inputClusterMask, layerClustersTimes, layer_clusters_tiles, seeding_regions);
153 
154  std::unordered_map<int, std::vector<int>> seedToTrackstersAssociation;
155  // if it's regional iteration and there are seeding regions
156  if (!seeding_regions.empty() and seeding_regions[0].index != -1) {
157  auto numberOfSeedingRegions = seeding_regions.size();
158  for (unsigned int i = 0; i < numberOfSeedingRegions; ++i) {
159  seedToTrackstersAssociation.emplace(seeding_regions[i].index, 0);
160  }
161  }
162  myAlgo_->makeTracksters(input, *result, seedToTrackstersAssociation);
163 
164  // Now update the global mask and put it into the event
165  output_mask->reserve(original_layerclusters_mask_h->size());
166  // Copy over the previous state
167  std::copy(std::begin(*original_layerclusters_mask_h),
168  std::end(*original_layerclusters_mask_h),
169  std::back_inserter(*output_mask));
170 
171  // Filter results based on PID criteria.
172  // We want to **keep** tracksters whose cumulative
173  // probability summed up over the selected categories
174  // is greater than the chosen threshold. Therefore
175  // the filtering function should **discard** all
176  // tracksters **below** the threshold.
177  auto filter_on_pids = [&](Trackster& t) -> bool {
178  auto cumulative_prob = 0.;
179  for (auto index : filter_on_categories_) {
180  cumulative_prob += t.id_probabilities(index);
181  }
182  return cumulative_prob <= pid_threshold_;
183  };
184 
185  // Actually filter results and shrink size to fit
186  result->erase(std::remove_if(result->begin(), result->end(), filter_on_pids), result->end());
187 
188  // Mask the used elements, accordingly
189  for (auto const& trackster : *result) {
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 }

References begin, clusters_token_, clustersTime_token_, filterCSVwithJSON::copy, end, filter_on_categories_, filtered_layerclusters_mask_token_, edm::Event::getByToken(), mps_fire::i, input, layer_clusters_tiles_token_, eostools::move(), myAlgo_, original_layerclusters_mask_token_, pid_threshold_, edm::Event::put(), mps_fire::result, EMStep_cff::seeding_regions, seeding_regions_token_, OrderedSet::t, and findQualityFiles::v.

Member Data Documentation

◆ clusters_token_

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

Definition at line 47 of file TrackstersProducer.cc.

Referenced by produce().

◆ clustersTime_token_

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

Definition at line 50 of file TrackstersProducer.cc.

Referenced by produce().

◆ filter_on_categories_

const std::vector<int> TrackstersProducer::filter_on_categories_
private

Definition at line 53 of file TrackstersProducer.cc.

Referenced by produce().

◆ filtered_layerclusters_mask_token_

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

Definition at line 48 of file TrackstersProducer.cc.

Referenced by produce().

◆ itername_

const std::string TrackstersProducer::itername_
private

Definition at line 55 of file TrackstersProducer.cc.

◆ layer_clusters_tiles_token_

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

Definition at line 51 of file TrackstersProducer.cc.

Referenced by produce().

◆ myAlgo_

std::unique_ptr<PatternRecognitionAlgoBase> TrackstersProducer::myAlgo_
private

Definition at line 45 of file TrackstersProducer.cc.

Referenced by produce().

◆ original_layerclusters_mask_token_

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

Definition at line 49 of file TrackstersProducer.cc.

Referenced by produce().

◆ pid_threshold_

const double TrackstersProducer::pid_threshold_
private

Definition at line 54 of file TrackstersProducer.cc.

Referenced by produce().

◆ seeding_regions_token_

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

Definition at line 52 of file TrackstersProducer.cc.

Referenced by produce().

mps_fire.i
i
Definition: mps_fire.py:355
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
input
static const std::string input
Definition: EdmProvDump.cc:48
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
TrackstersProducer::pid_threshold_
const double pid_threshold_
Definition: TrackstersProducer.cc:54
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ticl::PatternRecognitionAlgoBase::Inputs
Definition: PatternRecognitionAlgoBase.h:30
EMStep_cff.seeding_regions
seeding_regions
Definition: EMStep_cff.py:24
findQualityFiles.v
v
Definition: findQualityFiles.py:179
edm::Handle
Definition: AssociativeIterator.h:50
end
#define end
Definition: vmac.h:39
TrackstersProducer::clustersTime_token_
const edm::EDGetTokenT< edm::ValueMap< std::pair< float, float > > > clustersTime_token_
Definition: TrackstersProducer.cc:50
TrackstersProducer::seeding_regions_token_
const edm::EDGetTokenT< std::vector< TICLSeedingRegion > > seeding_regions_token_
Definition: TrackstersProducer.cc:52
edm::FileInPath
Definition: FileInPath.h:64
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
OrderedSet.t
t
Definition: OrderedSet.py:90
utilities.cache
def cache(function)
Definition: utilities.py:3
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
TrackstersProducer::filter_on_categories_
const std::vector< int > filter_on_categories_
Definition: TrackstersProducer.cc:53
TrackstersProducer::clusters_token_
const edm::EDGetTokenT< std::vector< reco::CaloCluster > > clusters_token_
Definition: TrackstersProducer.cc:47
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
TrackstersProducer::itername_
const std::string itername_
Definition: TrackstersProducer.cc:55
TrackstersProducer::filtered_layerclusters_mask_token_
const edm::EDGetTokenT< std::vector< float > > filtered_layerclusters_mask_token_
Definition: TrackstersProducer.cc:48
TrackstersProducer::myAlgo_
std::unique_ptr< PatternRecognitionAlgoBase > myAlgo_
Definition: TrackstersProducer.cc:45
tensorflow::loadGraphDef
GraphDef * loadGraphDef(const std::string &pbFile)
Definition: TensorFlow.cc:68
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::ValueMap
Definition: ValueMap.h:107
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
mps_fire.result
result
Definition: mps_fire.py:303
TrackstersProducer::layer_clusters_tiles_token_
const edm::EDGetTokenT< TICLLayerTiles > layer_clusters_tiles_token_
Definition: TrackstersProducer.cc:51
edm::InputTag
Definition: InputTag.h:15
begin
#define begin
Definition: vmac.h:32
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:163
ticl::Trackster
Definition: Trackster.h:19
TrackstersProducer::original_layerclusters_mask_token_
const edm::EDGetTokenT< std::vector< float > > original_layerclusters_mask_token_
Definition: TrackstersProducer.cc:49