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
SimTrackstersProducer Class Reference
Inheritance diagram for SimTrackstersProducer:
edm::stream::EDProducer<>

Public Member Functions

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

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

const edm::EDGetTokenT
< hgcal::SimToRecoCollection
associatorMapCaloParticleToReco_token_
 
const edm::EDGetTokenT
< hgcal::SimToRecoCollectionWithSimClusters
associatorMapSimClusterToReco_token_
 
const edm::EDGetTokenT
< std::vector< CaloParticle > > 
caloparticles_token_
 
const edm::EDGetTokenT
< std::vector
< reco::CaloCluster > > 
clusters_token_
 
const edm::EDGetTokenT
< edm::ValueMap< std::pair
< float, float > > > 
clustersTime_token_
 
std::string detector_
 
const bool doNose_ = false
 
const edm::EDGetTokenT
< std::vector< float > > 
filtered_layerclusters_mask_token_
 
const double fractionCut_
 
const edm::ESGetToken
< CaloGeometry,
CaloGeometryRecord
geom_token_
 
hgcal::RecHitTools rhtools_
 
const edm::EDGetTokenT
< std::vector< SimCluster > > 
simclusters_token_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
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 38 of file SimTrackstersProducer.cc.

Constructor & Destructor Documentation

SimTrackstersProducer::SimTrackstersProducer ( const edm::ParameterSet ps)
explicit

Definition at line 63 of file SimTrackstersProducer.cc.

64  : detector_(ps.getParameter<std::string>("detector")),
65  doNose_(detector_ == "HFNose"),
66  clusters_token_(consumes(ps.getParameter<edm::InputTag>("layer_clusters"))),
67  clustersTime_token_(consumes(ps.getParameter<edm::InputTag>("time_layerclusters"))),
68  filtered_layerclusters_mask_token_(consumes(ps.getParameter<edm::InputTag>("filtered_mask"))),
69  simclusters_token_(consumes(ps.getParameter<edm::InputTag>("simclusters"))),
70  caloparticles_token_(consumes(ps.getParameter<edm::InputTag>("caloparticles"))),
72  consumes(ps.getParameter<edm::InputTag>("layerClusterSimClusterAssociator"))),
74  consumes(ps.getParameter<edm::InputTag>("layerClusterCaloParticleAssociator"))),
76  fractionCut_(ps.getParameter<double>("fractionCut")) {
77  produces<TracksterCollection>();
78  produces<std::vector<float>>();
79  produces<TracksterCollection>("fromCPs");
80  produces<std::vector<float>>("fromCPs");
81  produces<std::map<uint, std::vector<uint>>>();
82 }
const edm::EDGetTokenT< hgcal::SimToRecoCollectionWithSimClusters > associatorMapSimClusterToReco_token_
const edm::EDGetTokenT< std::vector< float > > filtered_layerclusters_mask_token_
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geom_token_
const edm::EDGetTokenT< std::vector< CaloParticle > > caloparticles_token_
const edm::EDGetTokenT< std::vector< reco::CaloCluster > > clusters_token_
const edm::EDGetTokenT< edm::ValueMap< std::pair< float, float > > > clustersTime_token_
const edm::EDGetTokenT< hgcal::SimToRecoCollection > associatorMapCaloParticleToReco_token_
const edm::EDGetTokenT< std::vector< SimCluster > > simclusters_token_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283

Member Function Documentation

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

Definition at line 84 of file SimTrackstersProducer.cc.

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

84  {
85  // hgcalMultiClusters
87  desc.add<std::string>("detector", "HGCAL");
88  desc.add<edm::InputTag>("layer_clusters", edm::InputTag("hgcalLayerClusters"));
89  desc.add<edm::InputTag>("time_layerclusters", edm::InputTag("hgcalLayerClusters", "timeLayerCluster"));
90  desc.add<edm::InputTag>("filtered_mask", edm::InputTag("filteredLayerClustersSimTracksters", "ticlSimTracksters"));
91  desc.add<edm::InputTag>("simclusters", edm::InputTag("mix", "MergedCaloTruth"));
92  desc.add<edm::InputTag>("caloparticles", edm::InputTag("mix", "MergedCaloTruth"));
93  desc.add<edm::InputTag>("layerClusterSimClusterAssociator",
94  edm::InputTag("layerClusterSimClusterAssociationProducer"));
95  desc.add<edm::InputTag>("layerClusterCaloParticleAssociator",
96  edm::InputTag("layerClusterCaloParticleAssociationProducer"));
97  desc.add<double>("fractionCut", 0.);
98 
99  descriptions.addWithDefaultLabel(desc);
100 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void SimTrackstersProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 102 of file SimTrackstersProducer.cc.

References ticl::addTrackster(), ticl::assignPCAtoTracksters(), associatorMapCaloParticleToReco_token_, associatorMapSimClusterToReco_token_, SimTracksters_cff::caloparticles, caloparticles_token_, clusters_token_, clustersTime_token_, CommonMethods::cp(), doNose_, filtered_layerclusters_mask_token_, spr::find(), fractionCut_, relativeConstraints::geom, geom_token_, edm::Event::get(), edm::EventSetup::getData(), hgcal::RecHitTools::getPositionLayer(), submitPVResolutionJobs::key, hgcal::RecHitTools::lastLayerEE(), eostools::move(), edm::Event::put(), mps_fire::result, rhtools_, hgcal::RecHitTools::setGeometry(), SimTracksters_cff::simclusters, simclusters_token_, and z.

102  {
103  auto result = std::make_unique<TracksterCollection>();
104  auto output_mask = std::make_unique<std::vector<float>>();
105  auto result_fromCP = std::make_unique<TracksterCollection>();
106  auto output_mask_fromCP = std::make_unique<std::vector<float>>();
107  auto cpToSc_SimTrackstersMap = std::make_unique<std::map<uint, std::vector<uint>>>();
108  const auto& layerClusters = evt.get(clusters_token_);
109  const auto& layerClustersTimes = evt.get(clustersTime_token_);
110  const auto& inputClusterMask = evt.get(filtered_layerclusters_mask_token_);
111  output_mask->resize(layerClusters.size(), 1.f);
112  output_mask_fromCP->resize(layerClusters.size(), 1.f);
113 
114  const auto& simclusters = evt.get(simclusters_token_);
115  const auto& caloparticles = evt.get(caloparticles_token_);
116 
117  const auto& simClustersToRecoColl = evt.get(associatorMapSimClusterToReco_token_);
118  const auto& caloParticlesToRecoColl = evt.get(associatorMapCaloParticleToReco_token_);
119 
120  const auto& geom = es.getData(geom_token_);
122  const auto num_simclusters = simclusters.size();
123  result->reserve(num_simclusters); // Conservative size, will call shrink_to_fit later
124  const auto num_caloparticles = caloparticles.size();
125  result_fromCP->reserve(num_caloparticles);
126 
127  for (const auto& [key, lcVec] : caloParticlesToRecoColl) {
128  auto const& cp = *(key);
129  auto cpIndex = &cp - &caloparticles[0];
130 
131  auto regr_energy = cp.energy();
132  std::vector<uint> scSimTracksterIdx;
133  scSimTracksterIdx.reserve(cp.simClusters().size());
134 
135  // Create a Trackster from the object entering HGCal
136  if (cp.g4Tracks()[0].crossedBoundary()) {
137  regr_energy = cp.g4Tracks()[0].getMomentumAtBoundary().energy();
138 
139  addTrackster(cpIndex,
140  lcVec,
141  inputClusterMask,
142  fractionCut_,
143  regr_energy,
144  cp.pdgId(),
145  cp.charge(),
146  key.id(),
147  *output_mask,
148  *result);
149  } else {
150  for (const auto& scRef : cp.simClusters()) {
151  const auto& it = simClustersToRecoColl.find(scRef);
152  if (it == simClustersToRecoColl.end())
153  continue;
154  const auto& lcVec = it->val;
155  auto const& sc = *(scRef);
156  auto const scIndex = &sc - &simclusters[0];
157 
158  addTrackster(scIndex,
159  lcVec,
160  inputClusterMask,
161  fractionCut_,
162  sc.g4Tracks()[0].getMomentumAtBoundary().energy(),
163  sc.pdgId(),
164  sc.charge(),
165  scRef.id(),
166  *output_mask,
167  *result);
168 
169  if (result->empty())
170  continue;
171  const auto index = result->size() - 1;
172  if (std::find(scSimTracksterIdx.begin(), scSimTracksterIdx.end(), index) == scSimTracksterIdx.end()) {
173  scSimTracksterIdx.emplace_back(index);
174  }
175  }
176  scSimTracksterIdx.shrink_to_fit();
177  }
178 
179  // Create a Trackster from any CP
180  addTrackster(cpIndex,
181  lcVec,
182  inputClusterMask,
183  fractionCut_,
184  regr_energy,
185  cp.pdgId(),
186  cp.charge(),
187  key.id(),
188  *output_mask_fromCP,
189  *result_fromCP);
190 
191  if (result_fromCP->empty())
192  continue;
193  const auto index = result_fromCP->size() - 1;
194  if (cpToSc_SimTrackstersMap->find(index) == cpToSc_SimTrackstersMap->end()) {
195  (*cpToSc_SimTrackstersMap)[index] = scSimTracksterIdx;
196  }
197  }
198 
200  *result, layerClusters, layerClustersTimes, rhtools_.getPositionLayer(rhtools_.lastLayerEE(doNose_)).z());
201  result->shrink_to_fit();
203  *result_fromCP, layerClusters, layerClustersTimes, rhtools_.getPositionLayer(rhtools_.lastLayerEE(doNose_)).z());
204  result_fromCP->shrink_to_fit();
205 
206  evt.put(std::move(result));
207  evt.put(std::move(output_mask));
208  evt.put(std::move(result_fromCP), "fromCPs");
209  evt.put(std::move(output_mask_fromCP), "fromCPs");
210  evt.put(std::move(cpToSc_SimTrackstersMap));
211 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const edm::EDGetTokenT< hgcal::SimToRecoCollectionWithSimClusters > associatorMapSimClusterToReco_token_
const edm::EDGetTokenT< std::vector< float > > filtered_layerclusters_mask_token_
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geom_token_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
tuple result
Definition: mps_fire.py:311
bool getData(T &iHolder) const
Definition: EventSetup.h:128
void assignPCAtoTracksters(std::vector< Trackster > &, const std::vector< reco::CaloCluster > &, const edm::ValueMap< std::pair< float, float >> &, double, bool energyWeight=true)
static void addTrackster(const int &index, const std::vector< std::pair< edm::Ref< reco::CaloClusterCollection >, std::pair< float, float >>> &lcVec, const std::vector< float > &inputClusterMask, const float &fractionCut_, const float &energy, const int &pdgId, const int &charge, const edm::ProductID &seed, std::vector< float > &output_mask, std::vector< Trackster > &result)
Definition: commons.h:36
def move
Definition: eostools.py:511
tuple key
prepare the HTCondor submission files and eventually submit them
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
const edm::EDGetTokenT< std::vector< CaloParticle > > caloparticles_token_
const edm::EDGetTokenT< std::vector< reco::CaloCluster > > clusters_token_
const edm::EDGetTokenT< edm::ValueMap< std::pair< float, float > > > clustersTime_token_
const edm::EDGetTokenT< hgcal::SimToRecoCollection > associatorMapCaloParticleToReco_token_
const edm::EDGetTokenT< std::vector< SimCluster > > simclusters_token_
hgcal::RecHitTools rhtools_
GlobalPoint getPositionLayer(int layer, bool nose=false) const
Definition: RecHitTools.cc:141
void setGeometry(CaloGeometry const &)
Definition: RecHitTools.cc:68
unsigned int lastLayerEE(bool nose=false) const
Definition: RecHitTools.h:75

Member Data Documentation

const edm::EDGetTokenT<hgcal::SimToRecoCollection> SimTrackstersProducer::associatorMapCaloParticleToReco_token_
private

Definition at line 56 of file SimTrackstersProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<hgcal::SimToRecoCollectionWithSimClusters> SimTrackstersProducer::associatorMapSimClusterToReco_token_
private

Definition at line 55 of file SimTrackstersProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<std::vector<CaloParticle> > SimTrackstersProducer::caloparticles_token_
private

Definition at line 53 of file SimTrackstersProducer.cc.

Referenced by produce().

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

Definition at line 48 of file SimTrackstersProducer.cc.

Referenced by produce().

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

Definition at line 49 of file SimTrackstersProducer.cc.

Referenced by produce().

std::string SimTrackstersProducer::detector_
private

Definition at line 46 of file SimTrackstersProducer.cc.

const bool SimTrackstersProducer::doNose_ = false
private

Definition at line 47 of file SimTrackstersProducer.cc.

Referenced by produce().

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

Definition at line 50 of file SimTrackstersProducer.cc.

Referenced by produce().

const double SimTrackstersProducer::fractionCut_
private

Definition at line 59 of file SimTrackstersProducer.cc.

Referenced by produce().

const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> SimTrackstersProducer::geom_token_
private

Definition at line 57 of file SimTrackstersProducer.cc.

Referenced by produce().

hgcal::RecHitTools SimTrackstersProducer::rhtools_
private

Definition at line 58 of file SimTrackstersProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<std::vector<SimCluster> > SimTrackstersProducer::simclusters_token_
private

Definition at line 52 of file SimTrackstersProducer.cc.

Referenced by produce().