Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 //----------------------------------------------------------------------------
0002 //!  \brief Cluster pixels.
0003 //!  This method operates on a matrix of pixels
0004 //!  and finds the largest contiguous cluster around
0005 //!  each seed pixel.
0006 //!  Input and output data stored in DetSet
0007 //----------------------------------------------------------------------------
0008 template <typename T>
0009 void PixelThresholdClusterizer::clusterizeDetUnitT(const T& input,
0010                                                    const PixelGeomDetUnit* pixDet,
0011                                                    const TrackerTopology* tTopo,
0012                                                    const std::vector<short>& badChannels,
0013                                                    edmNew::DetSetVector<SiPixelCluster>::FastFiller& output) {
0014   typename T::const_iterator begin = input.begin();
0015   typename T::const_iterator end = input.end();
0016 
0017   // this should never happen and the raw2digi does not create empty detsets
0018   if (begin == end) {
0019     edm::LogError("PixelThresholdClusterizer") << "@SUB=PixelThresholdClusterizer::clusterizeDetUnitT()"
0020                                                << " No digis to clusterize";
0021   }
0022 
0023   //  Set up the clusterization on this DetId.
0024   if (!setup(pixDet))
0025     return;
0026 
0027   theDetid = input.detId();
0028 
0029   // Set separate cluster threshold for L1 (needed for phase1)
0030   auto clusterThreshold = theClusterThreshold;
0031   theLayer = (DetId(theDetid).subdetId() == 1) ? tTopo->pxbLayer(theDetid) : 0;
0032   if (theLayer == 1)
0033     clusterThreshold = theClusterThreshold_L1;
0034 
0035   //  Copy PixelDigis to the buffer array; select the seed pixels
0036   //  on the way, and store them in theSeeds.
0037   if (end > begin)
0038     copy_to_buffer(begin, end);
0039 
0040   assert(output.empty());
0041   //  Loop over all seeds.  TO DO: wouldn't using iterators be faster?
0042   for (unsigned int i = 0; i < theSeeds.size(); i++) {
0043     // Gavril : The charge of seeds that were already inlcuded in clusters is set to 1 electron
0044     // so we don't want to call "make_cluster" for these cases
0045     if (theBuffer(theSeeds[i]) >= theSeedThreshold) {  // Is this seed still valid?
0046       //  Make a cluster around this seed
0047       SiPixelCluster&& cluster = make_cluster(theSeeds[i], output);
0048 
0049       //  Check if the cluster is above threshold
0050       // (TO DO: one is signed, other unsigned, gcc warns...)
0051       if (cluster.charge() >= clusterThreshold) {
0052         // sort by row (x)
0053         output.push_back(std::move(cluster));
0054         std::push_heap(output.begin(), output.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
0055           return cl1.minPixelRow() < cl2.minPixelRow();
0056         });
0057       }
0058     }
0059   }
0060   // sort by row (x)   maybe sorting the seed would suffice....
0061   std::sort_heap(output.begin(), output.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
0062     return cl1.minPixelRow() < cl2.minPixelRow();
0063   });
0064 
0065   // Erase the seeds.
0066   theSeeds.clear();
0067 
0068   //  Need to clean unused pixels from the buffer array.
0069   clear_buffer(begin, end);
0070 
0071   theFakePixels.clear();
0072 
0073   thePixelOccurrence.clear();
0074 }