Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:24

0001 #include "CommonTools/Utils/interface/StringToEnumValue.h"
0002 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
0003 #include "FWCore/Framework/interface/ConsumesCollector.h"
0004 #include "RecoParticleFlow/PFClusterProducer/interface/RecHitTopologicalCleanerBase.h"
0005 
0006 class FlagsCleanerECAL : public RecHitTopologicalCleanerBase {
0007 public:
0008   FlagsCleanerECAL(const edm::ParameterSet& conf, edm::ConsumesCollector& cc);
0009   FlagsCleanerECAL(const FlagsCleanerECAL&) = delete;
0010   FlagsCleanerECAL& operator=(const FlagsCleanerECAL&) = delete;
0011 
0012   // mark rechits which are flagged as one of the values provided in the vector
0013   void clean(const edm::Handle<reco::PFRecHitCollection>& input, std::vector<bool>& mask) override;
0014 
0015 private:
0016   std::vector<int> v_chstatus_excl_;  // list of rechit status flags to be excluded from seeding
0017   bool checkFlags(const reco::PFRecHit& hit);
0018 };
0019 
0020 DEFINE_EDM_PLUGIN(RecHitTopologicalCleanerFactory, FlagsCleanerECAL, "FlagsCleanerECAL");
0021 
0022 FlagsCleanerECAL::FlagsCleanerECAL(const edm::ParameterSet& conf, edm::ConsumesCollector& cc)
0023     : RecHitTopologicalCleanerBase(conf, cc) {
0024   const std::vector<std::string> flagnames = conf.getParameter<std::vector<std::string> >("RecHitFlagsToBeExcluded");
0025   v_chstatus_excl_ = StringToEnumValue<EcalRecHit::Flags>(flagnames);
0026 }
0027 
0028 void FlagsCleanerECAL::clean(const edm::Handle<reco::PFRecHitCollection>& input, std::vector<bool>& mask) {
0029   auto const& hits = *input;
0030 
0031   for (uint idx = 0; idx < hits.size(); ++idx) {
0032     if (!mask[idx])
0033       continue;  // don't need to re-mask things :-)
0034     const reco::PFRecHit& rechit = hits[idx];
0035     if (checkFlags(rechit))
0036       mask[idx] = false;
0037   }
0038 }
0039 
0040 // returns true if one of the flags in the exclusion list is up
0041 bool FlagsCleanerECAL::checkFlags(const reco::PFRecHit& hit) {
0042   for (auto flag : v_chstatus_excl_) {  // check if one of the flags is up
0043     if (hit.flags() & (0x1 << flag))
0044       return true;
0045   }
0046   return false;
0047 }