CMS 3D CMS Logo

IslandClusterProducer.cc
Go to the documentation of this file.
1 // C/C++ headers
2 #include <iostream>
3 #include <vector>
4 #include <memory>
5 
6 // Framework
15 
16 // Reconstruction Classes
22 
23 // Geometry
28 
29 // EgammaCoreTools
34 
35 // Class header file
37 
39  // The verbosity level
40  std::string verbosityString = ps.getParameter<std::string>("VerbosityLevel");
41  if (verbosityString == "DEBUG")
43  else if (verbosityString == "WARNING")
45  else if (verbosityString == "INFO")
47  else
49 
50  // Parameters to identify the hit collections
51  barrelRecHits_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("barrelHits"));
52  endcapRecHits_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("endcapHits"));
53 
54  //EventSetup Token for CaloGeometry
55  caloGeometryToken_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
56 
57  // The names of the produced cluster collections
58  barrelClusterCollection_ = ps.getParameter<std::string>("barrelClusterCollection");
59  endcapClusterCollection_ = ps.getParameter<std::string>("endcapClusterCollection");
60 
61  // Island algorithm parameters
62  double barrelSeedThreshold = ps.getParameter<double>("IslandBarrelSeedThr");
63  double endcapSeedThreshold = ps.getParameter<double>("IslandEndcapSeedThr");
64 
65  // Parameters for the position calculation:
69 
70  clustershapecollectionEB_ = ps.getParameter<std::string>("clustershapecollectionEB");
71  clustershapecollectionEE_ = ps.getParameter<std::string>("clustershapecollectionEE");
72 
73  //AssociationMap
74  barrelClusterShapeAssociation_ = ps.getParameter<std::string>("barrelShapeAssociation");
75  endcapClusterShapeAssociation_ = ps.getParameter<std::string>("endcapShapeAssociation");
76 
77  const std::vector<std::string> seedflagnamesEB =
78  ps.getParameter<std::vector<std::string>>("SeedRecHitFlagToBeExcludedEB");
79  const std::vector<int> seedflagsexclEB = StringToEnumValue<EcalRecHit::Flags>(seedflagnamesEB);
80 
81  const std::vector<std::string> seedflagnamesEE =
82  ps.getParameter<std::vector<std::string>>("SeedRecHitFlagToBeExcludedEE");
83  const std::vector<int> seedflagsexclEE = StringToEnumValue<EcalRecHit::Flags>(seedflagnamesEE);
84 
85  const std::vector<std::string> flagnamesEB = ps.getParameter<std::vector<std::string>>("RecHitFlagToBeExcludedEB");
86  const std::vector<int> flagsexclEB = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
87 
88  const std::vector<std::string> flagnamesEE = ps.getParameter<std::vector<std::string>>("RecHitFlagToBeExcludedEE");
89  const std::vector<int> flagsexclEE = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
90 
91  // Produces a collection of barrel and a collection of endcap clusters
92 
93  produces<reco::ClusterShapeCollection>(clustershapecollectionEE_);
94  produces<reco::BasicClusterCollection>(endcapClusterCollection_);
95  produces<reco::ClusterShapeCollection>(clustershapecollectionEB_);
96  produces<reco::BasicClusterCollection>(barrelClusterCollection_);
97  produces<reco::BasicClusterShapeAssociationCollection>(barrelClusterShapeAssociation_);
98  produces<reco::BasicClusterShapeAssociationCollection>(endcapClusterShapeAssociation_);
99 
100  island_p = new IslandClusterAlgo(barrelSeedThreshold,
101  endcapSeedThreshold,
103  seedflagsexclEB,
104  seedflagsexclEE,
105  flagsexclEB,
106  flagsexclEE,
107  verbosity);
108 
109  nEvt_ = 0;
110 }
111 
113 
116  desc.add<std::string>("VerbosityLevel", "ERROR");
117  desc.add<edm::InputTag>("barrelHits", edm::InputTag("ecalRecHit", "EcalRecHitsEB"));
118  desc.add<edm::InputTag>("endcapHits", edm::InputTag("ecalRecHit", "EcalRecHitsEE"));
119  desc.add<std::string>("barrelClusterCollection", "islandBarrelBasicClusters");
120  desc.add<std::string>("endcapClusterCollection", "islandEndcapBasicClusters");
121  desc.add<double>("IslandBarrelSeedThr", 0.5);
122  desc.add<double>("IslandEndcapSeedThr", 0.18);
123 
125  posCalcParameters.add<bool>("LogWeighted", true);
126  posCalcParameters.add<double>("T0_barl", 7.4);
127  posCalcParameters.add<double>("T0_endc", 3.1);
128  posCalcParameters.add<double>("T0_endcPresh", 1.2);
129  posCalcParameters.add<double>("W0", 4.2);
130  posCalcParameters.add<double>("X0", 0.89);
131  desc.add<edm::ParameterSetDescription>("posCalcParameters", posCalcParameters);
132 
133  desc.add<std::string>("clustershapecollectionEE", "islandEndcapShape");
134  desc.add<std::string>("clustershapecollectionEB", "islandBarrelShape");
135  desc.add<std::string>("barrelShapeAssociation", "islandBarrelShapeAssoc");
136  desc.add<std::string>("endcapShapeAssociation", "islandEndcapShapeAssoc");
137  desc.add<std::vector<std::string>>("SeedRecHitFlagToBeExcludedEB", {});
138  desc.add<std::vector<std::string>>("SeedRecHitFlagToBeExcludedEE", {});
139  desc.add<std::vector<std::string>>("RecHitFlagToBeExcludedEB", {});
140  desc.add<std::vector<std::string>>("RecHitFlagToBeExcludedEE", {});
141  descriptions.add("IslandClusterProducer", desc);
142 }
143 
149  nEvt_++;
150 }
151 
155  evt.getByToken(token, rhcHandle);
156  return rhcHandle.product();
157 }
158 
160  const edm::EventSetup& es,
162  const std::string& clusterCollection,
163  const std::string& clusterShapeAssociation,
164  const IslandClusterAlgo::EcalPart& ecalPart) {
165  // get the hit collection from the event:
166  const EcalRecHitCollection* hitCollection_p = getCollection(evt, token);
167 
168  // get the geometry and topology from the event setup:
170 
171  const CaloSubdetectorGeometry* geometry_p;
172  std::unique_ptr<CaloSubdetectorTopology> topology_p;
173 
174  std::string clustershapetag;
175  if (ecalPart == IslandClusterAlgo::barrel) {
176  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
177  topology_p = std::make_unique<EcalBarrelTopology>(*geoHandle);
178  } else {
179  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
180  topology_p = std::make_unique<EcalEndcapTopology>(*geoHandle);
181  }
182 
183  const CaloSubdetectorGeometry* geometryES_p;
184  geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
185 
186  // Run the clusterization algorithm:
188  clusters = island_p->makeClusters(hitCollection_p, geometry_p, topology_p.get(), geometryES_p, ecalPart);
189 
190  //Create associated ClusterShape objects.
191  std::vector<reco::ClusterShape> ClusVec;
192  for (int erg = 0; erg < int(clusters.size()); ++erg) {
193  reco::ClusterShape TestShape = shapeAlgo_.Calculate(clusters[erg], hitCollection_p, geometry_p, topology_p.get());
194  ClusVec.push_back(TestShape);
195  }
196 
197  //Put clustershapes in event, but retain a Handle on them.
198  auto clustersshapes_p = std::make_unique<reco::ClusterShapeCollection>();
199  clustersshapes_p->assign(ClusVec.begin(), ClusVec.end());
201  if (ecalPart == IslandClusterAlgo::barrel)
202  clusHandle = evt.put(std::move(clustersshapes_p), clustershapecollectionEB_);
203  else
204  clusHandle = evt.put(std::move(clustersshapes_p), clustershapecollectionEE_);
205 
206  // create a unique_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event:
207  auto clusters_p = std::make_unique<reco::BasicClusterCollection>();
208  clusters_p->assign(clusters.begin(), clusters.end());
210  if (ecalPart == IslandClusterAlgo::barrel)
211  bccHandle = evt.put(std::move(clusters_p), barrelClusterCollection_);
212  else
213  bccHandle = evt.put(std::move(clusters_p), endcapClusterCollection_);
214 
215  // BasicClusterShapeAssociationMap
216  auto shapeAssocs_p = std::make_unique<reco::BasicClusterShapeAssociationCollection>(bccHandle, clusHandle);
217  for (unsigned int i = 0; i < clusHandle->size(); i++) {
218  shapeAssocs_p->insert(edm::Ref<reco::BasicClusterCollection>(bccHandle, i),
220  }
221  evt.put(std::move(shapeAssocs_p), clusterShapeAssociation);
222 }
ConfigurationDescriptions.h
IslandClusterAlgo::pDEBUG
Definition: IslandClusterAlgo.h:29
IslandClusterProducer::barrelClusterCollection_
std::string barrelClusterCollection_
Definition: IslandClusterProducer.h:47
IslandClusterProducer::verbosity
IslandClusterAlgo::VerbosityLevel verbosity
Definition: IslandClusterProducer.h:41
Handle.h
mps_fire.i
i
Definition: mps_fire.py:428
PositionCalc.h
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
IslandClusterAlgo::endcap
Definition: IslandClusterAlgo.h:28
ESHandle.h
BasicCluster.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
EBDetId.h
IslandClusterAlgo::EcalPart
EcalPart
Definition: IslandClusterAlgo.h:28
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
IslandClusterProducer::posCalculator_
PositionCalc posCalculator_
Definition: IslandClusterProducer.h:57
EcalBarrelTopology.h
IslandClusterProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: IslandClusterProducer.cc:114
CaloGeometry::getSubdetectorGeometry
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
edm::SortedCollection< EcalRecHit >
IslandClusterProducer::shapeAlgo_
ClusterShapeAlgo shapeAlgo_
Definition: IslandClusterProducer.h:58
IslandClusterProducer::island_p
IslandClusterAlgo * island_p
Definition: IslandClusterProducer.h:59
IslandClusterProducer::caloGeometryToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
Definition: IslandClusterProducer.h:45
IslandClusterProducer::nEvt_
int nEvt_
Definition: IslandClusterProducer.h:39
IslandClusterProducer.h
MonitorAlCaEcalPi0_cfi.posCalcParameters
posCalcParameters
Definition: MonitorAlCaEcalPi0_cfi.py:72
ClusterShapeAlgo.h
edm::Handle
Definition: AssociativeIterator.h:50
IslandClusterProducer::clustershapecollectionEE_
std::string clustershapecollectionEE_
Definition: IslandClusterProducer.h:51
EcalBarrel
Definition: EcalSubdetector.h:10
BasicClusterFwd.h
edm::Ref
Definition: AssociativeIterator.h:58
IslandClusterProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: IslandClusterProducer.cc:144
ClusterShapeFwd.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
IslandClusterProducer::endcapClusterCollection_
std::string endcapClusterCollection_
Definition: IslandClusterProducer.h:48
reco::ClusterShape
Definition: ClusterShape.h:21
edm::ESHandle< CaloGeometry >
StringToEnumValue.h
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
ClusterShapeAlgo
Definition: ClusterShapeAlgo.h:35
reco::BasicClusterCollection
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
Definition: BasicClusterFwd.h:16
IslandClusterAlgo::barrel
Definition: IslandClusterAlgo.h:28
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalEndcap
Definition: EcalSubdetector.h:10
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
ClusterShape.h
CaloSubdetectorGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:47
IslandClusterProducer::getCollection
const EcalRecHitCollection * getCollection(edm::Event &evt, const edm::EDGetTokenT< EcalRecHitCollection > &token)
Definition: IslandClusterProducer.cc:152
Event.h
IslandClusterProducer::IslandClusterProducer
IslandClusterProducer(const edm::ParameterSet &ps)
Definition: IslandClusterProducer.cc:38
IslandClusterProducer::endcapClusterShapeAssociation_
std::string endcapClusterShapeAssociation_
Definition: IslandClusterProducer.h:55
EcalEndcapTopology.h
IslandClusterProducer::clustershapecollectionEB_
std::string clustershapecollectionEB_
Definition: IslandClusterProducer.h:50
IslandClusterAlgo
Definition: IslandClusterAlgo.h:26
PositionCalc
Definition: PositionCalc.h:29
createfilelist.int
int
Definition: createfilelist.py:10
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:148
IslandClusterAlgo::pERROR
Definition: IslandClusterAlgo.h:29
IslandClusterProducer::endcapRecHits_
edm::EDGetTokenT< EcalRecHitCollection > endcapRecHits_
Definition: IslandClusterProducer.h:44
edm::EventSetup
Definition: EventSetup.h:57
DetId::Ecal
Definition: DetId.h:27
EcalRecHit.h
EcalPreshower
Definition: EcalSubdetector.h:10
CaloCellGeometry.h
ClusterShapeAlgo::Calculate
reco::ClusterShape Calculate(const reco::BasicCluster &passedCluster, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry, const CaloSubdetectorTopology *topology)
Definition: ClusterShapeAlgo.cc:21
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::OrphanHandle
Definition: EDProductfwd.h:39
IslandClusterProducer::barrelRecHits_
edm::EDGetTokenT< EcalRecHitCollection > barrelRecHits_
Definition: IslandClusterProducer.h:43
IslandClusterAlgo::makeClusters
std::vector< reco::BasicCluster > makeClusters(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry, const CaloSubdetectorTopology *topology_p, const CaloSubdetectorGeometry *geometryES_p, EcalPart ecalPart, bool regional=false, const std::vector< RectangularEtaPhiRegion > &regions=std::vector< RectangularEtaPhiRegion >())
Definition: IslandClusterAlgo.cc:17
IslandClusterAlgo::pINFO
Definition: IslandClusterAlgo.h:29
EventSetup.h
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
IslandClusterProducer::barrelClusterShapeAssociation_
std::string barrelClusterShapeAssociation_
Definition: IslandClusterProducer.h:54
IslandClusterAlgo::pWARNING
Definition: IslandClusterAlgo.h:29
edm::Event
Definition: Event.h:73
IslandClusterProducer::clusterizeECALPart
void clusterizeECALPart(edm::Event &evt, const edm::EventSetup &es, const edm::EDGetTokenT< EcalRecHitCollection > &token, const std::string &clusterCollection, const std::string &clusterShapeAssociation, const IslandClusterAlgo::EcalPart &ecalPart)
Definition: IslandClusterProducer.cc:159
edm::InputTag
Definition: InputTag.h:15
BasicClusterShapeAssociation.h
IslandClusterProducer::~IslandClusterProducer
~IslandClusterProducer() override
Definition: IslandClusterProducer.cc:112
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:318