CMS 3D CMS Logo

Multi5x5ClusterProducer.cc
Go to the documentation of this file.
27 
28 #include <ctime>
29 #include <iostream>
30 #include <memory>
31 #include <vector>
32 
34 public:
36 
37  ~Multi5x5ClusterProducer() override;
38 
39  void produce(edm::Event&, const edm::EventSetup&) override;
40 
41 private:
42  int nMaxPrintout_; // max # of printouts
43  int nEvt_; // internal counter of events
44 
45  // cluster which regions
46  bool doBarrel_;
47  bool doEndcap_;
48 
52 
55 
56  PositionCalc posCalculator_; // position calculation algorithm
58 
59  bool counterExceeded() const { return ((nEvt_ > nMaxPrintout_) || (nMaxPrintout_ < 0)); }
60 
62 
64  const edm::EventSetup& es,
68 
69  void outputValidationInfo(reco::CaloClusterPtrVector& clusterPtrVector);
70 };
71 
74 
76  // Parameters to identify the hit collections
77  barrelHitToken_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("barrelHitTag"));
78 
79  endcapHitToken_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("endcapHitTag"));
80 
81  //EventSetup Token for CaloGeometry
82  caloGeometryToken_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
83 
84  // should cluster algo be run in barrel and endcap?
85  doEndcap_ = ps.getParameter<bool>("doEndcap");
86  doBarrel_ = ps.getParameter<bool>("doBarrel");
87 
88  // The names of the produced cluster collections
89  barrelClusterCollection_ = ps.getParameter<std::string>("barrelClusterCollection");
90  endcapClusterCollection_ = ps.getParameter<std::string>("endcapClusterCollection");
91 
92  // Island algorithm parameters
93  double barrelSeedThreshold = ps.getParameter<double>("IslandBarrelSeedThr");
94  double endcapSeedThreshold = ps.getParameter<double>("IslandEndcapSeedThr");
95 
96  const std::vector<std::string> flagnames = ps.getParameter<std::vector<std::string> >("RecHitFlagToBeExcluded");
97 
98  const std::vector<int> v_chstatus = StringToEnumValue<EcalRecHit::Flags>(flagnames);
99 
100  // Parameters for the position calculation:
103 
104  // Produces a collection of barrel and a collection of endcap clusters
105  produces<reco::BasicClusterCollection>(endcapClusterCollection_);
106  produces<reco::BasicClusterCollection>(barrelClusterCollection_);
107 
109  if (ps.exists("reassignSeedCrysToClusterItSeeds"))
110  reassignSeedCrysToClusterItSeeds = ps.getParameter<bool>("reassignSeedCrysToClusterItSeeds");
111 
113  barrelSeedThreshold, endcapSeedThreshold, v_chstatus, posCalculator_, reassignSeedCrysToClusterItSeeds);
114 
115  nEvt_ = 0;
116 }
117 
119 
121  if (doEndcap_) {
123  }
124  if (doBarrel_) {
126  }
127 
128  nEvt_++;
129 }
130 
134  evt.getByToken(token, rhcHandle);
135  return rhcHandle.product();
136 }
137 
139  const edm::EventSetup& es,
143  // get the hit collection from the event:
144  const EcalRecHitCollection* hitCollection_p = getCollection(evt, token);
145 
146  // get the geometry and topology from the event setup:
148 
149  const CaloSubdetectorGeometry* geometry_p;
150  std::unique_ptr<CaloSubdetectorTopology> topology_p;
151 
153  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
154  topology_p = std::make_unique<EcalBarrelTopology>(*geoHandle);
155  } else {
156  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
157  topology_p = std::make_unique<EcalEndcapTopology>(*geoHandle);
158  }
159 
160  const CaloSubdetectorGeometry* geometryES_p;
161  geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
162 
163  // Run the clusterization algorithm:
165  clusters = island_p->makeClusters(hitCollection_p, geometry_p, topology_p.get(), geometryES_p, detector);
166 
167  // create a unique_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event:
168  auto clusters_p = std::make_unique<reco::BasicClusterCollection>();
169  clusters_p->assign(clusters.begin(), clusters.end());
172  bccHandle = evt.put(std::move(clusters_p), barrelClusterCollection_);
173  else
174  bccHandle = evt.put(std::move(clusters_p), endcapClusterCollection_);
175 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
Multi5x5ClusterProducer(const edm::ParameterSet &ps)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool exists(std::string const &parameterName) const
checks if a parameter exists
T const * product() const
Definition: Handle.h:70
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::EDGetTokenT< EcalRecHitCollection > barrelHitToken_
edm::EDGetTokenT< EcalRecHitCollection > endcapHitToken_
void outputValidationInfo(reco::CaloClusterPtrVector &clusterPtrVector)
void produce(edm::Event &, const edm::EventSetup &) override
Multi5x5ClusterAlgo * island_p
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
void clusterizeECALPart(edm::Event &evt, const edm::EventSetup &es, const edm::EDGetTokenT< EcalRecHitCollection > &token, const std::string &clusterCollection, const reco::CaloID::Detectors detector)
std::vector< reco::BasicCluster > makeClusters(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry, const CaloSubdetectorTopology *topology_p, const CaloSubdetectorGeometry *geometryES_p, reco::CaloID::Detectors detector, bool regional=false, const std::vector< RectangularEtaPhiRegion > &regions=std::vector< RectangularEtaPhiRegion >())
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
const EcalRecHitCollection * getCollection(edm::Event &evt, const edm::EDGetTokenT< EcalRecHitCollection > &token)
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
def move(src, dest)
Definition: eostools.py:511