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 theTimeThreshold( conf.
getParameter<
double>(
"TimeThreshold") ),
35 theNumOfRows(0), theNumOfCols(0), theCurrentId(0),
36 theBuffer(theNumOfRows, theNumOfCols ),
37 bufferAlreadySet(
false)
47 desc.
add<
double>(
"HitThreshold", 0.);
48 desc.
add<
double>(
"SeedThreshold", 0.);
49 desc.
add<
double>(
"ClusterThreshold", 0.);
50 desc.
add<
double>(
"TimeThreshold", 10.);
61 const auto& thedet = geom->
idToDet(
id);
62 if( thedet ==
nullptr ) {
63 throw cms::Exception(
"MTDThresholdClusterizer") <<
"GeographicalID: " << std::hex
73 unsigned int nrows = topol.
nrows();
79 DEBUG(
"Buffer size [" << theNumOfRows+1 <<
"," << theNumOfCols+1 <<
"]");
81 if ( nrows > theBuffer.rows() ||
82 ncols > theBuffer.columns() )
85 theBuffer.setSize(nrows+1,ncols+1);
86 bufferAlreadySet =
true;
109 edm::LogInfo(
"MTDThresholdClusterizer") <<
"No hits to clusterize";
113 DEBUG(
"Input collection " << input.
size());
114 assert(output.
empty());
116 std::set<unsigned> geoIds;
117 std::multimap<unsigned, unsigned> geoIdToIdx;
120 for(
const auto&
hit : input)
125 throw cms::Exception(
"MTDThresholdClusterizer") <<
"MTDDetId: " << std::hex
135 geoIdToIdx.emplace(geoId,index);
136 geoIds.emplace(geoId);
142 DetId geoId = hitId.geographicalId();
143 geoIdToIdx.emplace(geoId,index);
144 geoIds.emplace(geoId);
149 throw cms::Exception(
"MTDThresholdClusterizer") <<
"MTDDetId: " << std::hex
157 for(
unsigned id : geoIds) {
162 auto range = geoIdToIdx.equal_range(
id);
163 DEBUG(
"Matching Ids for " << std::hex <<
id <<
std::dec <<
" [" << range.first->second <<
"," << range.second->second <<
"]");
167 for(
auto itr = range.first; itr != range.second; ++itr) {
168 const unsigned hitidx = itr->second;
169 copy_to_buffer(begin+hitidx);
174 for (
unsigned int i = 0;
i < theSeeds.size();
i++)
176 if ( theBuffer.energy(theSeeds[
i]) > theSeedThreshold )
179 const FTLCluster & cluster = make_cluster( theSeeds[i] );
182 if ( cluster.
energy() > theClusterThreshold)
184 DEBUG(
"putting in this cluster " << i <<
" #hits:" << cluster.
size()
185 <<
" E:" << cluster.
energy()
186 <<
" T:" << cluster.
time()
187 <<
" X:" << cluster.
x()
188 <<
" Y:" << cluster.
y());
197 for(
auto itr = range.first; itr != range.second; ++itr) {
198 const unsigned hitidx = itr->second;
199 clear_buffer(begin+hitidx);
213 theBuffer.clear( itr->row(), itr->column() );
221 int row = itr->row();
222 int col = itr->column();
223 float energy = itr->energy();
224 float time = itr->time();
225 float timeError = itr->timeError();
227 DEBUG(
"ROW " << row <<
" COL " << col <<
" ENERGY " << energy <<
" TIME " << time);
228 if ( energy > theHitThreshold) {
229 theBuffer.set( row, col, energy , time, timeError);
244 float seed_energy= theBuffer.
energy(hit.
row(), hit.
col());
245 float seed_time= theBuffer.time(hit.
row(), hit.
col());
246 float seed_time_error= theBuffer.time_error(hit.
row(), hit.
col());
247 theBuffer.clear(hit);
250 acluster.
add(hit, seed_energy, seed_time, seed_time_error);
254 while ( ! acluster.
empty() && ! stopClus)
257 auto curInd = acluster.
top(); acluster.
pop();
258 for (
auto c =
std::max(0,
int(acluster.
y[curInd]-1));
c <
std::min(
int(acluster.
y[curInd]+2),
int(theBuffer.columns())) && !stopClus; ++
c) {
259 for (
auto r =
std::max(0,
int(acluster.
x[curInd]-1));
r <
std::min(
int(acluster.
x[curInd]+2),
int(theBuffer.rows())) && !stopClus; ++
r) {
260 if ( theBuffer.energy(
r,
c) > theHitThreshold) {
261 if (
std::abs(theBuffer.time(
r,
c) - seed_time) > theTimeThreshold*
sqrt( theBuffer.time_error(
r,
c)*theBuffer.time_error(
r,
c) + seed_time_error*seed_time_error))
264 if (!acluster.
add( newhit, theBuffer.energy(
r,
c), theBuffer.time(
r,
c), theBuffer.time_error(
r,
c)))
269 theBuffer.clear(newhit);
277 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
void push_back(data_type const &d)
~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< T >::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
Abs< T >::type abs(const T &t)
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