Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 23:30:59

0001 /****************************************************************************
0002 *
0003 * This is a part of TOTEM offline software.
0004 * Authors:
0005 *   Hubert Niewiadomski
0006 *   Jan Kašpar (jan.kaspar@gmail.com)
0007 *
0008 ****************************************************************************/
0009 
0010 #include "RecoPPS/Local/interface/TotemRPClusterProducerAlgorithm.h"
0011 
0012 #include <iostream>
0013 
0014 //----------------------------------------------------------------------------------------------------
0015 
0016 TotemRPClusterProducerAlgorithm::TotemRPClusterProducerAlgorithm(const edm::ParameterSet &param) : param_(param) {
0017   verbosity_ = param_.getParameter<int>("verbosity");
0018 }
0019 
0020 //----------------------------------------------------------------------------------------------------
0021 
0022 TotemRPClusterProducerAlgorithm::~TotemRPClusterProducerAlgorithm() {}
0023 
0024 //----------------------------------------------------------------------------------------------------
0025 
0026 int TotemRPClusterProducerAlgorithm::buildClusters(unsigned int detId,
0027                                                    const std::vector<TotemRPDigi> &digi,
0028                                                    std::vector<TotemRPCluster> &clusters) {
0029   clusters.clear();
0030 
0031   strip_digi_set_.clear();
0032   strip_digi_set_.insert(digi.begin(), digi.end());
0033 
0034   if (strip_digi_set_.empty())
0035     return 0;
0036 
0037   bool iter_beg = true;
0038   int cluster_beg = -16;
0039   int cluster_end;
0040   int prev_strip = -16;
0041   int cur_strip;
0042 
0043   for (TotemRPDigiSet::const_iterator i = strip_digi_set_.begin(); i != strip_digi_set_.end(); ++i) {
0044     cur_strip = i->stripNumber();
0045     bool non_continuity = (cur_strip != prev_strip + 1);
0046 
0047     if (iter_beg) {
0048       cluster_beg = cur_strip;
0049       iter_beg = false;
0050     } else if (non_continuity) {
0051       cluster_end = prev_strip;
0052       clusters.emplace_back((uint16_t)cluster_beg, (uint16_t)cluster_end);
0053 
0054       cluster_beg = cur_strip;
0055     }
0056 
0057     prev_strip = cur_strip;
0058   }
0059 
0060   if (!iter_beg) {
0061     cluster_end = prev_strip;
0062     clusters.emplace_back((uint16_t)cluster_beg, (uint16_t)cluster_end);
0063   }
0064 
0065   return clusters.size();
0066 }