CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
42  barrelHitProducer_ = ps.getParameter<std::string>("barrelHitProducer");
43  endcapHitProducer_ = ps.getParameter<std::string>("endcapHitProducer");
44  barrelHitCollection_ = ps.getParameter<std::string>("barrelHitCollection");
45  endcapHitCollection_ = ps.getParameter<std::string>("endcapHitCollection");
46 
47  // should cluster algo be run in barrel and endcap?
48  doEndcap_ = ps.getParameter<bool>("doEndcap");
49  doBarrel_ = ps.getParameter<bool>("doBarrel");
50 
51  // The names of the produced cluster collections
52  barrelClusterCollection_ = ps.getParameter<std::string>("barrelClusterCollection");
53  endcapClusterCollection_ = ps.getParameter<std::string>("endcapClusterCollection");
54 
55  // Island algorithm parameters
56  double barrelSeedThreshold = ps.getParameter<double>("IslandBarrelSeedThr");
57  double endcapSeedThreshold = ps.getParameter<double>("IslandEndcapSeedThr");
58 
59  const std::vector<std::string> flagnames =
60  ps.getParameter<std::vector<std::string> >("RecHitFlagToBeExcluded");
61 
62  const std::vector<int> v_chstatus=
63  StringToEnumValue<EcalRecHit::Flags>(flagnames);
64 
65  // Parameters for the position calculation:
66  edm::ParameterSet posCalcParameters =
67  ps.getParameter<edm::ParameterSet>("posCalcParameters");
68  posCalculator_ = PositionCalc(posCalcParameters);
69 
70  // Produces a collection of barrel and a collection of endcap clusters
71  produces< reco::BasicClusterCollection >(endcapClusterCollection_);
72  produces< reco::BasicClusterCollection >(barrelClusterCollection_);
73 
74  bool reassignSeedCrysToClusterItSeeds=false;
75  if(ps.exists("reassignSeedCrysToClusterItSeeds")) reassignSeedCrysToClusterItSeeds = ps.getParameter<bool>("reassignSeedCrysToClusterItSeeds");
76 
77 
78 
79  island_p = new Multi5x5ClusterAlgo(barrelSeedThreshold, endcapSeedThreshold, v_chstatus, posCalculator_,reassignSeedCrysToClusterItSeeds);
80 
81  nEvt_ = 0;
82 }
83 
84 
86 {
87  delete island_p;
88 }
89 
90 
92 {
93 
94  if (doEndcap_) {
96  }
97  if (doBarrel_) {
99  }
100 
101  nEvt_++;
102 }
103 
104 
106  const std::string& hitProducer_,
107  const std::string& hitCollection_)
108 {
110  evt.getByLabel(hitProducer_, hitCollection_, rhcHandle);
111  if (!(rhcHandle.isValid()))
112  {
113  edm::LogError("MissingProduct") << "could not get a handle on the EcalRecHitCollection! : " ;;
114  return 0;
115  }
116 
117  return rhcHandle.product();
118 }
119 
120 
122  const std::string& hitProducer,
123  const std::string& hitCollection,
124  const std::string& clusterCollection,
125  const reco::CaloID::Detectors detector)
126 {
127  // get the hit collection from the event:
128  const EcalRecHitCollection *hitCollection_p = getCollection(evt, hitProducer, hitCollection);
129 
130  // get the geometry and topology from the event setup:
131  edm::ESHandle<CaloGeometry> geoHandle;
132  es.get<CaloGeometryRecord>().get(geoHandle);
133 
134  const CaloSubdetectorGeometry *geometry_p;
135  CaloSubdetectorTopology *topology_p;
136 
137  if (detector == reco::CaloID::DET_ECAL_BARREL)
138  {
139  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
140  topology_p = new EcalBarrelTopology(geoHandle);
141  }
142  else
143  {
144  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
145  topology_p = new EcalEndcapTopology(geoHandle);
146  }
147 
148  const CaloSubdetectorGeometry *geometryES_p;
149  geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
150 
151  // Run the clusterization algorithm:
153  clusters = island_p->makeClusters(hitCollection_p, geometry_p, topology_p, geometryES_p, detector);
154 
155  // create an auto_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event:
156  std::auto_ptr< reco::BasicClusterCollection > clusters_p(new reco::BasicClusterCollection);
157  clusters_p->assign(clusters.begin(), clusters.end());
159  if (detector == reco::CaloID::DET_ECAL_BARREL)
160  bccHandle = evt.put(clusters_p, barrelClusterCollection_);
161  else
162  bccHandle = evt.put(clusters_p, endcapClusterCollection_);
163 
164  delete topology_p;
165 }
T getParameter(std::string const &) const
Multi5x5ClusterProducer(const edm::ParameterSet &ps)
void clusterizeECALPart(edm::Event &evt, const edm::EventSetup &es, const std::string &hitProducer, const std::string &hitCollection, 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< EcalEtaPhiRegion > &regions=std::vector< EcalEtaPhiRegion >())
bool exists(std::string const &parameterName) const
checks if a parameter exists
const EcalRecHitCollection * getCollection(edm::Event &evt, const std::string &hitProducer_, const std::string &hitCollection_)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
virtual void produce(edm::Event &, const edm::EventSetup &)
bool isValid() const
Definition: HandleBase.h:76
Multi5x5ClusterAlgo * island_p
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
const T & get() const
Definition: EventSetup.h:55
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
T const * product() const
Definition: Handle.h:74