20 #define DEBUG(x) do { std::cout << x << std::endl; } while (0) 31 theHitThreshold( conf.
getParameter<
double>(
"HitThreshold") ),
32 theSeedThreshold( conf.
getParameter<
double>(
"SeedThreshold") ),
33 theClusterThreshold( conf.
getParameter<
double>(
"ClusterThreshold") ),
34 theNumOfRows(0), theNumOfCols(0), theCurrentId(0),
35 theBuffer(theNumOfRows, theNumOfCols ),
36 bufferAlreadySet(
false)
46 desc.
add<
double>(
"HitThreshold", 0.);
47 desc.
add<
double>(
"SeedThreshold", 0.);
48 desc.
add<
double>(
"ClusterThreshold", 0.);
59 const auto& thedet = geom->
idToDet(
id);
60 if( thedet ==
nullptr ) {
61 throw cms::Exception(
"MTDThresholdClusterizer") <<
"GeographicalID: " << std::hex
71 unsigned int nrows = topol.
nrows();
77 DEBUG(
"Buffer size [" << theNumOfRows+1 <<
"," << theNumOfCols+1 <<
"]");
79 if ( nrows > theBuffer.rows() ||
80 ncols > theBuffer.columns() )
83 theBuffer.setSize(nrows+1,ncols+1);
84 bufferAlreadySet =
true;
107 edm::LogInfo(
"MTDThresholdClusterizer") <<
"No hits to clusterize";
111 DEBUG(
"Input collection " << input.
size());
112 assert(output.
empty());
114 std::set<unsigned> geoIds;
115 std::multimap<unsigned, unsigned> geoIdToIdx;
118 for(
const auto&
hit : input)
123 throw cms::Exception(
"MTDThresholdClusterizer") <<
"MTDDetId: " << std::hex
133 geoIdToIdx.emplace(geoId,index);
134 geoIds.emplace(geoId);
140 DetId geoId = hitId.geographicalId();
141 geoIdToIdx.emplace(geoId,index);
142 geoIds.emplace(geoId);
147 throw cms::Exception(
"MTDThresholdClusterizer") <<
"MTDDetId: " << std::hex
155 for(
unsigned id : geoIds) {
160 auto range = geoIdToIdx.equal_range(
id);
161 DEBUG(
"Matching Ids for " << std::hex <<
id <<
std::dec <<
" [" << range.first->second <<
"," << range.second->second <<
"]");
165 for(
auto itr = range.first; itr != range.second; ++itr) {
166 const unsigned hitidx = itr->second;
167 copy_to_buffer(begin+hitidx);
172 for (
unsigned int i = 0;
i < theSeeds.size();
i++)
174 if ( theBuffer.energy(theSeeds[
i]) > theSeedThreshold )
177 const FTLCluster & cluster = make_cluster( theSeeds[i] );
180 if ( cluster.
energy() > theClusterThreshold)
182 DEBUG(
"putting in this cluster " << i <<
" #hits:" << cluster.
size()
183 <<
" E:" << cluster.
energy()
184 <<
" T:" << cluster.
time()
185 <<
" X:" << cluster.
x()
186 <<
" Y:" << cluster.
y());
187 clustersOnDet.push_back( cluster );
195 for(
auto itr = range.first; itr != range.second; ++itr) {
196 const unsigned hitidx = itr->second;
197 clear_buffer(begin+hitidx);
211 theBuffer.clear( itr->row(), itr->column() );
219 int row = itr->row();
220 int col = itr->column();
221 float energy = itr->energy();
222 float time = itr->time();
223 float timeError = itr->timeError();
225 DEBUG(
"ROW " << row <<
" COL " << col <<
" ENERGY " << energy <<
" TIME " << time);
226 if ( energy > theHitThreshold) {
227 theBuffer.set( row, col, energy , time, timeError);
242 float seed_energy= theBuffer.
energy(hit.
row(), hit.
col());
243 float seed_time= theBuffer.time(hit.
row(), hit.
col());
244 float seed_time_error= theBuffer.time_error(hit.
row(), hit.
col());
245 theBuffer.clear(hit);
248 acluster.
add(hit, seed_energy, seed_time, seed_time_error);
252 while ( ! acluster.
empty() && ! stopClus)
255 auto curInd = acluster.
top(); acluster.
pop();
256 for (
auto c =
std::max(0,
int(acluster.
y[curInd]-1));
c <
std::min(
int(acluster.
y[curInd]+2),
int(theBuffer.columns())) && !stopClus; ++
c) {
257 for (
auto r =
std::max(0,
int(acluster.
x[curInd]-1));
r <
std::min(
int(acluster.
x[curInd]+2),
int(theBuffer.rows())) && !stopClus; ++
r) {
258 if ( theBuffer.energy(
r,
c) > theHitThreshold) {
260 if (!acluster.
add( newhit, theBuffer.energy(
r,
c), theBuffer.time(
r,
c), theBuffer.time_error(
r,
c)))
265 theBuffer.clear(newhit);
273 acluster.
x.data(), acluster.
y.data(),
void clusterize(const FTLRecHitCollection &input, const MTDGeometry *geom, const MTDTopology *topo, FTLClusterCollection &output) override
Cluster hits. This method operates on a matrix of hits and finds the largest contiguous cluster aroun...
T getParameter(std::string const &) const
~MTDThresholdClusterizer() override
std::array< float, MAXSIZE > time
std::array< float, MAXSIZE > timeError
FTLRecHitCollection::const_iterator RecHitIterator
int getMTDTopologyMode() const
constexpr uint32_t rawId() const
get the raw id
std::vector< FTLRecHit >::const_iterator const_iterator
def setup(process, global_tag, zero_tesla=False)
int ncolumns() const override
MTDThresholdClusterizer(edm::ParameterSet const &conf)
Constructor:
bool add(FTLCluster::FTLHitPos const &p, float const ienergy, float const itime, float const itimeError)
int nrows() const override
Detector identifier base class for the MIP Timing Layer.
std::array< UShort, MAXSIZE > y
static std::string const input
static void fillDescriptions(edm::ParameterSetDescription &desc)
const MTDGeomDet * idToDet(DetId) const override
bool setup(const MTDGeometry *geometry, const MTDTopology *topo, const DetId &id)
virtual const PixelTopology & specificTopology() const
constexpr int row() const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void copy_to_buffer(RecHitIterator itr)
Copy FTLRecHit into the buffer, identify seeds.
const_iterator end() const
std::array< float, MAXSIZE > energy
SubDetector subDetector() const
FTLCluster make_cluster(const FTLCluster::FTLHitPos &hit)
The actual clustering algorithm: group the neighboring hits around the seed.
Detector identifier class for the Endcap Timing Layer.
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
std::array< UShort, MAXSIZE > x
int mtdSubDetector() const
void clear_buffer(RecHitIterator itr)
Clear the internal buffer array.
constexpr int col() const
const_iterator begin() const