Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:12

0001 #include "RecoLocalMuon/GEMRecHit/interface/GEMClusterizer.h"
0002 
0003 GEMClusterContainer GEMClusterizer::doAction(const GEMDigiCollection::Range& digiRange, const EtaPartitionMask& mask) {
0004   GEMClusterContainer 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     if (mask.test(digi->strip()))
0012       continue;
0013     GEMCluster cl(digi->strip(), digi->strip(), digi->bx());
0014     initialCluster.insert(cl);
0015   }
0016   if (initialCluster.empty())
0017     return finalCluster;  // Confirm the collection is valid
0018 
0019   // Start from the first initial cluster
0020   GEMCluster prev = *initialCluster.begin();
0021 
0022   // Loop over the remaining digis
0023   // Note that the last one remains as open in this loop
0024   for (auto cl = std::next(initialCluster.begin()); cl != initialCluster.end(); ++cl) {
0025     if (prev.isAdjacent(*cl)) {
0026       // Merged digi to the previous one
0027       prev.merge(*cl);
0028     } else {
0029       // Close the previous cluster and start new cluster
0030       finalCluster.insert(prev);
0031       prev = *cl;
0032     }
0033   }
0034 
0035   // Finalize by adding the last cluster
0036   finalCluster.insert(prev);
0037 
0038   return finalCluster;
0039 }