1 #ifndef __RecoLocalCalo_HGCRecProducers_HGCalLayerClusterProducer_H__
2 #define __RecoLocalCalo_HGCRecProducers_HGCalLayerClusterProducer_H__
51 std::unique_ptr<HGCalClusteringAlgoBase>
algo;
64 doSharing(ps.getParameter<bool>(
"doSharing")),
65 detector(ps.getParameter<std::
string>(
"detector")),
66 timeClname(ps.getParameter<std::
string>(
"timeClname")),
67 timeOffset(ps.getParameter<double>(
"timeOffset")),
68 nHitsTime(ps.getParameter<unsigned int>(
"nHitsTime")) {
94 pluginPSet.getParameter<
std::string>(
"type"), pluginPSet, consumesCollector());
98 produces<std::vector<float>>(
"InitialLayerClustersMask");
99 produces<std::vector<reco::BasicCluster>>();
100 produces<std::vector<reco::BasicCluster>>(
"sharing");
104 produces<edm::ValueMap<std::pair<float, float>>>(
timeClname);
115 ->setComment(
"all (does not include HFNose); other options: EE, FH, HFNose; other value defaults to BH");
116 desc.
add<
bool>(
"doSharing",
false);
122 desc.
add<
double>(
"timeOffset", 0.0);
123 desc.
add<
unsigned int>(
"nHitsTime", 3);
124 descriptions.
add(
"hgcalLayerClusters", desc);
133 std::unique_ptr<std::vector<reco::BasicCluster>>
clusters(
new std::vector<reco::BasicCluster>),
134 clusters_sharing(
new std::vector<reco::BasicCluster>);
135 auto density = std::make_unique<Density>();
137 algo->getEventSetup(es);
142 std::unordered_map<uint32_t, const HGCRecHit*> hitmap;
147 algo->populate(*hfnose_hits);
148 for (
auto const& it : *hfnose_hits)
149 hitmap[it.detid().rawId()] = &(it);
153 algo->populate(*ee_hits);
154 for (
auto const& it : *ee_hits)
155 hitmap[it.detid().rawId()] = &(it);
161 algo->populate(*fh_hits);
162 for (
auto const& it : *fh_hits)
163 hitmap[it.detid().rawId()] = &(it);
164 }
else if (bh_hits.
isValid()) {
165 algo->populate(*bh_hits);
170 algo->populate(*ee_hits);
171 for (
auto const& it : *ee_hits) {
172 hitmap[it.detid().rawId()] = &(it);
175 algo->populate(*fh_hits);
176 for (
auto const& it : *fh_hits) {
177 hitmap[it.detid().rawId()] = &(it);
180 algo->populate(*bh_hits);
185 algo->makeClusters();
188 *clusters_sharing =
algo->getClusters(
true);
191 auto clusterHandleSharing = evt.
put(
std::move(clusters_sharing),
"sharing");
194 *density =
algo->getDensity();
199 std::vector<std::pair<float, float>> times;
200 times.
reserve(clusterHandle->size());
202 for (
unsigned i = 0;
i < clusterHandle->size(); ++
i) {
206 std::pair<float, float> timeCl(-99., -1.);
210 std::vector<float> timeClhits;
211 std::vector<float> timeErrorClhits;
214 auto finder = hitmap.find(
hit.first);
215 if (finder == hitmap.end())
219 const HGCRecHit* rechit = finder->second;
225 timeErrorClhits.push_back(1. / (rhTimeE * rhTimeE));
230 times.push_back(timeCl);
232 std::unique_ptr<std::vector<float>> layerClustersMask(
new std::vector<float>);
233 layerClustersMask->resize(clusterHandle->size(), 1.0);
234 evt.
put(
std::move(layerClustersMask),
"InitialLayerClustersMask");
236 auto timeCl = std::make_unique<edm::ValueMap<std::pair<float, float>>>();
238 filler.insert(clusterHandle, times.begin(), times.end());
243 for (
unsigned i = 0;
i < clusterHandleSharing->size(); ++
i) {
251 #endif //__RecoLocalCalo_HGCRecProducers_HGCalLayerClusterProducer_H__
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void produce(edm::Event &, const edm::EventSetup &) override
reco::CaloCluster::AlgoId algoId
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
void push_back(Ptr< T > const &iPtr)
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
edm::EDGetTokenT< HGCRecHitCollection > hits_hfnose_token
std::unique_ptr< HGCalClusteringAlgoBase > algo
std::map< DetId, float > Density
edm::EDGetTokenT< HGCRecHitCollection > hits_bh_token
std::pair< float, float > fixSizeHighestDensity(std::vector< float > &time, std::vector< float > weight=std::vector< float >(), unsigned int minNhits=3, float deltaT=0.210, float timeWidthBy=0.5)
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
~HGCalLayerClusterProducer() override
constexpr float time() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< HGCRecHitCollection > hits_ee_token
T getParameter(std::string const &) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HGCalLayerClusterProducer(const edm::ParameterSet &)
void reserve(size_type n)
Reserve space for RefVector.
size_t size() const
size in number of hits (e.g. in crystals for ECAL)
edm::EDGetTokenT< HGCRecHitCollection > hits_fh_token
hgcal_clustering::Density Density