CMS 3D CMS Logo

Multi5x5ClusterProducer.cc
Go to the documentation of this file.
1 // C/C++ headers
2 #include <iostream>
3 #include <vector>
4 #include <memory>
5 
6 // Framework
14 
15 // Reconstruction Classes
22 
23 // Geometry
30 
31 // EgammaCoreTools
33 
34 // Class header file
36 
37 
39 {
40 
41  // Parameters to identify the hit collections
43  consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("barrelHitTag"));
44 
46  consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("endcapHitTag"));
47 
48 
49  // should cluster algo be run in barrel and endcap?
50  doEndcap_ = ps.getParameter<bool>("doEndcap");
51  doBarrel_ = ps.getParameter<bool>("doBarrel");
52 
53  // The names of the produced cluster collections
54  barrelClusterCollection_ = ps.getParameter<std::string>("barrelClusterCollection");
55  endcapClusterCollection_ = ps.getParameter<std::string>("endcapClusterCollection");
56 
57  // Island algorithm parameters
58  double barrelSeedThreshold = ps.getParameter<double>("IslandBarrelSeedThr");
59  double endcapSeedThreshold = ps.getParameter<double>("IslandEndcapSeedThr");
60 
61  const std::vector<std::string> flagnames =
62  ps.getParameter<std::vector<std::string> >("RecHitFlagToBeExcluded");
63 
64  const std::vector<int> v_chstatus=
65  StringToEnumValue<EcalRecHit::Flags>(flagnames);
66 
67  // Parameters for the position calculation:
69  ps.getParameter<edm::ParameterSet>("posCalcParameters");
70  posCalculator_ = PositionCalc(posCalcParameters);
71 
72  // Produces a collection of barrel and a collection of endcap clusters
73  produces< reco::BasicClusterCollection >(endcapClusterCollection_);
74  produces< reco::BasicClusterCollection >(barrelClusterCollection_);
75 
77  if(ps.exists("reassignSeedCrysToClusterItSeeds")) reassignSeedCrysToClusterItSeeds = ps.getParameter<bool>("reassignSeedCrysToClusterItSeeds");
78 
79 
80 
81  island_p = new Multi5x5ClusterAlgo(barrelSeedThreshold, endcapSeedThreshold, v_chstatus, posCalculator_,reassignSeedCrysToClusterItSeeds);
82 
83  nEvt_ = 0;
84 }
85 
86 
88 {
89  delete island_p;
90 }
91 
92 
94 {
95 
96  if (doEndcap_) {
98  }
99  if (doBarrel_) {
101  }
102 
103  nEvt_++;
104 }
105 
106 
108 {
110  evt.getByToken(token, rhcHandle);
111  return rhcHandle.product();
112 }
113 
114 
117  const std::string& clusterCollection,
119 {
120  // get the hit collection from the event:
121  const EcalRecHitCollection *hitCollection_p = getCollection(evt, token);
122 
123  // get the geometry and topology from the event setup:
124  edm::ESHandle<CaloGeometry> geoHandle;
125  es.get<CaloGeometryRecord>().get(geoHandle);
126 
127  const CaloSubdetectorGeometry *geometry_p;
128  std::unique_ptr<CaloSubdetectorTopology> topology_p;
129 
130  if (detector == reco::CaloID::DET_ECAL_BARREL)
131  {
132  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
133  topology_p = std::make_unique<EcalBarrelTopology>(*geoHandle);
134  }
135  else
136  {
137  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
138  topology_p = std::make_unique<EcalEndcapTopology>(*geoHandle);
139  }
140 
141  const CaloSubdetectorGeometry *geometryES_p;
142  geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
143 
144  // Run the clusterization algorithm:
146  clusters = island_p->makeClusters(hitCollection_p, geometry_p, topology_p.get(), geometryES_p, detector);
147 
148  // create a unique_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event:
149  auto clusters_p = std::make_unique<reco::BasicClusterCollection>();
150  clusters_p->assign(clusters.begin(), clusters.end());
152  if (detector == reco::CaloID::DET_ECAL_BARREL)
153  bccHandle = evt.put(std::move(clusters_p), barrelClusterCollection_);
154  else
155  bccHandle = evt.put(std::move(clusters_p), endcapClusterCollection_);
156 }
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
Multi5x5ClusterProducer(const edm::ParameterSet &ps)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< EcalRecHitCollection > barrelHitToken_
edm::EDGetTokenT< EcalRecHitCollection > endcapHitToken_
void produce(edm::Event &, const edm::EventSetup &) override
Multi5x5ClusterAlgo * island_p
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 >())
T const * product() const
Definition: Handle.h:74
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
const EcalRecHitCollection * getCollection(edm::Event &evt, const edm::EDGetTokenT< EcalRecHitCollection > &token)
T get() const
Definition: EventSetup.h:71
def move(src, dest)
Definition: eostools.py:511