66 std::unique_ptr<HGCalClusteringAlgoBase>
algo_;
91 const std::vector<std::pair<DetId, float>>& hitsAndFractions);
100 std::pair<float, float>
calculateTime(std::unordered_map<uint32_t, const HGCRecHit*>& hitmap,
101 const std::vector<std::pair<DetId, float>>& hitsAndFractions,
107 detector_(ps.getParameter<
std::
string>(
"detector")),
108 timeClname_(ps.getParameter<
std::
string>(
"timeClname")),
109 hitsTime_(ps.getParameter<unsigned
int>(
"nHitsTime")),
122 thresholdW0_ = pluginPSet.getParameter<std::vector<double>>(
"thresholdW0");
125 produces<std::vector<float>>(
"InitialLayerClustersMask");
126 produces<std::vector<reco::BasicCluster>>();
128 produces<edm::ValueMap<std::pair<float, float>>>(
timeClname_);
138 desc.add<
std::string>(
"detector",
"EE")->setComment(
"options EE, FH, BH, HFNose; other value defaults to EE");
141 desc.add<
unsigned int>(
"nHitsTime", 3);
142 descriptions.
add(
"hgcalLayerClusters",
desc);
146 std::unordered_map<uint32_t, const HGCRecHit*>& hitmap,
147 const std::vector<std::pair<DetId, float>>& hitsAndFractions) {
148 float total_weight = 0.f;
149 float maxEnergyValue = 0.f;
150 DetId maxEnergyIndex;
154 for (
auto const&
hit : hitsAndFractions) {
157 total_weight += rechit->
energy();
158 if (rechit->
energy() > maxEnergyValue) {
159 maxEnergyValue = rechit->
energy();
160 maxEnergyIndex = rechit->
detid();
163 float total_weight_log = 0.f;
166 for (
auto const&
hit : hitsAndFractions) {
174 const float d1 =
position.x() - positionMaxEnergy.x();
175 const float d2 =
position.y() - positionMaxEnergy.y();
182 total_weight_log += Wi;
189 total_weight = total_weight_log;
191 if (total_weight != 0.) {
192 float inv_tot_weight = 1.f / total_weight;
193 return math::XYZPoint(
x * inv_tot_weight,
y * inv_tot_weight, positionMaxEnergy.z());
200 std::unordered_map<uint32_t, const HGCRecHit*>& hitmap,
201 const std::vector<std::pair<DetId, float>>& hitsAndFractions,
202 size_t sizeCluster) {
203 std::pair<float, float> timeCl(-99., -1.);
206 std::vector<float> timeClhits;
207 std::vector<float> timeErrorClhits;
209 for (
auto const&
hit : hitsAndFractions) {
217 timeClhits.push_back(rechit->
time());
218 timeErrorClhits.push_back(1. / (rhTimeE * rhTimeE));
228 std::unique_ptr<std::vector<reco::BasicCluster>>
clusters(
new std::vector<reco::BasicCluster>);
237 std::unordered_map<uint32_t, const HGCRecHit*> hitmap;
241 for (
auto const& it : *
hits) {
242 hitmap[it.detid().rawId()] = &(it);
245 algo_->makeClusters();
248 std::vector<std::pair<float, float>> times;
257 times.push_back(std::pair<float, float>(-99., -1.));
264 std::unique_ptr<std::vector<float>> layerClustersMask(
new std::vector<float>);
265 layerClustersMask->resize(clusterHandle->size(), 1.0);
266 evt.
put(
std::move(layerClustersMask),
"InitialLayerClustersMask");
269 auto timeCl = std::make_unique<edm::ValueMap<std::pair<float, float>>>();
271 filler.insert(clusterHandle, times.begin(), times.end());
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
math::XYZPoint calculatePosition(std::unordered_map< uint32_t, const HGCRecHit *> &hitmap, const std::vector< std::pair< DetId, float >> &hitsAndFractions)
Counts position for all points in the cluster.
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
void produce(edm::Event &, const edm::EventSetup &) override
Method run the algoritm to get clusters.
constexpr const DetId & detid() const
std::pair< float, float > calculateTime(std::unordered_map< uint32_t, const HGCRecHit *> &hitmap, const std::vector< std::pair< DetId, float >> &hitsAndFractions, size_t sizeCluster)
Counts time for all points in the cluster.
hgcal::RecHitTools rhtools_
void setPosition(const math::XYZPoint &p)
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
constexpr float energy() const
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)
std::unique_ptr< HGCalClusteringAlgoBase > algo_
~HGCalLayerClusterProducer() override
double positionDeltaRho2_
reco::CaloCluster::AlgoId algoId_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Method fill description which will be used in pyhton file.
size_t size() const
size in number of hits (e.g. in crystals for ECAL)
#define DEFINE_FWK_MODULE(type)
void setAlgoId()
Sets algoId accordingly to the detector type.
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
edm::EDGetTokenT< HGCRecHitCollection > hits_token_
XYZPointD XYZPoint
point in space with cartesian internal representation
void add(std::string const &label, ParameterSetDescription const &psetDescription)
constexpr float time() const
HGCalLayerClusterProducer(const edm::ParameterSet &)
Constructor with parameter settings - which can be changed in hgcalLayerCluster_cff.py. Constructor will set all variables by input param ps. algoID variables will be set accordingly to the detector type.
static int position[264][3]
std::vector< double > thresholdW0_
static constexpr float d1