Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:23:18

0001 #include "CPPFClusterizer.h"
0002 
0003 CPPFClusterContainer CPPFClusterizer::doAction(const RPCDigiCollection::Range& digiRange) {
0004   CPPFClusterContainer initialCluster, finalCluster;
0005   // Return empty container for null input
0006   if (std::distance(digiRange.second, digiRange.first) == 0)
0007     return finalCluster;
0008 
0009   // Start from single digi recHits
0010   for (auto digi = digiRange.first; digi != digiRange.second; ++digi) {
0011     CPPFCluster cl(digi->strip(), digi->strip(), digi->bx());
0012     if (digi->hasTime())
0013       cl.addTime(digi->time());
0014     if (digi->hasY())
0015       cl.addY(digi->coordinateY());
0016     initialCluster.insert(cl);
0017   }
0018   if (initialCluster.empty())
0019     return finalCluster;  // Confirm the collection is valid
0020 
0021   // Start from the first initial cluster
0022   CPPFCluster prev = *initialCluster.begin();
0023 
0024   // Loop over the remaining digis
0025   // Note that the last one remains as open in this loop
0026   for (auto cl = std::next(initialCluster.begin()); cl != initialCluster.end(); ++cl) {
0027     if (prev.isAdjacent(*cl)) {
0028       // Merged digi to the previous one
0029       prev.merge(*cl);
0030     } else {
0031       // Close the previous cluster and start new cluster
0032       finalCluster.insert(prev);
0033       prev = *cl;
0034     }
0035   }
0036 
0037   // Finalize by adding the last cluster
0038   finalCluster.insert(prev);
0039 
0040   return finalCluster;
0041 }