5 #define DEBUG_CLUSTERS_ALPAKA 0 37 #if DEBUG_CLUSTERS_ALPAKA 72 std::unique_ptr<HGCalClusteringAlgoBase>
algo_;
84 #if DEBUG_CLUSTERS_ALPAKA 101 const std::vector<std::pair<DetId, float>>& hitsAndFractions);
110 std::pair<float, float>
calculateTime(std::unordered_map<uint32_t, const HGCRecHit*>& hitmap,
111 const std::vector<std::pair<DetId, float>>& hitsAndFractions,
117 detector_(ps.getParameter<
std::
string>(
"detector")),
118 timeClname_(ps.getParameter<
std::
string>(
"timeClname")),
119 hitsTime_(ps.getParameter<unsigned
int>(
"nHitsTime")),
121 calculatePositionInAlgo_(ps.getParameter<
bool>(
"calculatePositionInAlgo")) {
122 #if DEBUG_CLUSTERS_ALPAKA 136 thresholdW0_ = pluginPSet.getParameter<std::vector<double>>(
"thresholdW0");
139 produces<std::vector<float>>(
"InitialLayerClustersMask");
140 produces<std::vector<reco::BasicCluster>>();
142 produces<edm::ValueMap<std::pair<float, float>>>(
timeClname_);
152 desc.add<
std::string>(
"detector",
"EE")->setComment(
"options EE, FH, BH, HFNose; other value defaults to EE");
155 desc.add<
unsigned int>(
"nHitsTime", 3);
156 desc.add<
bool>(
"calculatePositionInAlgo",
true);
157 descriptions.
add(
"hgcalLayerClusters",
desc);
161 std::unordered_map<uint32_t, const HGCRecHit*>& hitmap,
162 const std::vector<std::pair<DetId, float>>& hitsAndFractions) {
163 float total_weight = 0.f;
164 float maxEnergyValue = 0.f;
165 DetId maxEnergyIndex;
169 for (
auto const&
hit : hitsAndFractions) {
172 total_weight += rechit->
energy();
173 if (rechit->
energy() > maxEnergyValue) {
174 maxEnergyValue = rechit->
energy();
175 maxEnergyIndex = rechit->
detid();
178 float total_weight_log = 0.f;
181 for (
auto const&
hit : hitsAndFractions) {
189 const float d1 =
position.x() - positionMaxEnergy.x();
190 const float d2 =
position.y() - positionMaxEnergy.y();
197 total_weight_log += Wi;
204 total_weight = total_weight_log;
206 if (total_weight != 0.) {
207 float inv_tot_weight = 1.f / total_weight;
208 return math::XYZPoint(
x * inv_tot_weight,
y * inv_tot_weight, positionMaxEnergy.z());
210 return {positionMaxEnergy.x(), positionMaxEnergy.y(), positionMaxEnergy.z()};
215 std::unordered_map<uint32_t, const HGCRecHit*>& hitmap,
216 const std::vector<std::pair<DetId, float>>& hitsAndFractions,
217 size_t sizeCluster) {
218 std::pair<float, float> timeCl(-99., -1.);
221 std::vector<float> timeClhits;
222 std::vector<float> timeErrorClhits;
224 for (
auto const&
hit : hitsAndFractions) {
232 timeClhits.push_back(rechit->
time());
233 timeErrorClhits.push_back(1.
f / (rhTimeE * rhTimeE));
243 std::unique_ptr<std::vector<reco::BasicCluster>>
clusters(
new std::vector<reco::BasicCluster>);
252 std::unordered_map<uint32_t, const HGCRecHit*> hitmap;
256 for (
auto const&
it : *
hits) {
257 hitmap[
it.detid().rawId()] = &(
it);
260 algo_->makeClusters();
263 std::vector<std::pair<float, float>> times;
274 times.push_back(std::pair<float, float>(-99.
f, -1.
f));
278 #if DEBUG_CLUSTERS_ALPAKA 290 std::unique_ptr<std::vector<float>> layerClustersMask(
new std::vector<float>);
291 layerClustersMask->resize(clusterHandle->size(), 1.0);
292 evt.
put(
std::move(layerClustersMask),
"InitialLayerClustersMask");
295 auto timeCl = std::make_unique<edm::ValueMap<std::pair<float, float>>>();
297 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_
LuminosityBlockNumber_t luminosityBlock() const
void setPosition(const math::XYZPoint &p)
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
void dumpInfos(const T &clusters, const std::string &moduleLabel, edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event, bool dumpCellsDetId=false) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
EventAuxiliary const & eventAuxiliary() const override
constexpr float energy() const
EventID const & id() 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
const bool calculatePositionInAlgo_
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
EventNumber_t event() const