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
30 
31 // EgammaCoreTools
36 
37 // Class header file
39 
41  // The verbosity level
42  std::string verbosityString = ps.getParameter<std::string>("VerbosityLevel");
43  if (verbosityString == "DEBUG")
45  else if (verbosityString == "WARNING")
47  else if (verbosityString == "INFO")
49  else
51 
52  // Parameters to identify the hit collections
53  barrelRecHits_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("barrelHits"));
54  endcapRecHits_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("endcapHits"));
55 
56  // The names of the produced cluster collections
57  barrelClusterCollection_ = ps.getParameter<std::string>("barrelClusterCollection");
58  endcapClusterCollection_ = ps.getParameter<std::string>("endcapClusterCollection");
59 
60  // Island algorithm parameters
61  double barrelSeedThreshold = ps.getParameter<double>("IslandBarrelSeedThr");
62  double endcapSeedThreshold = ps.getParameter<double>("IslandEndcapSeedThr");
63 
64  // Parameters for the position calculation:
68 
69  clustershapecollectionEB_ = ps.getParameter<std::string>("clustershapecollectionEB");
70  clustershapecollectionEE_ = ps.getParameter<std::string>("clustershapecollectionEE");
71 
72  //AssociationMap
73  barrelClusterShapeAssociation_ = ps.getParameter<std::string>("barrelShapeAssociation");
74  endcapClusterShapeAssociation_ = ps.getParameter<std::string>("endcapShapeAssociation");
75 
76  const std::vector<std::string> seedflagnamesEB =
77  ps.getParameter<std::vector<std::string>>("SeedRecHitFlagToBeExcludedEB");
78  const std::vector<int> seedflagsexclEB = StringToEnumValue<EcalRecHit::Flags>(seedflagnamesEB);
79 
80  const std::vector<std::string> seedflagnamesEE =
81  ps.getParameter<std::vector<std::string>>("SeedRecHitFlagToBeExcludedEE");
82  const std::vector<int> seedflagsexclEE = StringToEnumValue<EcalRecHit::Flags>(seedflagnamesEE);
83 
84  const std::vector<std::string> flagnamesEB = ps.getParameter<std::vector<std::string>>("RecHitFlagToBeExcludedEB");
85  const std::vector<int> flagsexclEB = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
86 
87  const std::vector<std::string> flagnamesEE = ps.getParameter<std::vector<std::string>>("RecHitFlagToBeExcludedEE");
88  const std::vector<int> flagsexclEE = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
89 
90  // Produces a collection of barrel and a collection of endcap clusters
91 
92  produces<reco::ClusterShapeCollection>(clustershapecollectionEE_);
93  produces<reco::BasicClusterCollection>(endcapClusterCollection_);
94  produces<reco::ClusterShapeCollection>(clustershapecollectionEB_);
95  produces<reco::BasicClusterCollection>(barrelClusterCollection_);
96  produces<reco::BasicClusterShapeAssociationCollection>(barrelClusterShapeAssociation_);
97  produces<reco::BasicClusterShapeAssociationCollection>(endcapClusterShapeAssociation_);
98 
99  island_p = new IslandClusterAlgo(barrelSeedThreshold,
100  endcapSeedThreshold,
102  seedflagsexclEB,
103  seedflagsexclEE,
104  flagsexclEB,
105  flagsexclEE,
106  verbosity);
107 
108  nEvt_ = 0;
109 }
110 
112 
115  desc.add<std::string>("VerbosityLevel", "ERROR");
116  desc.add<edm::InputTag>("barrelHits", edm::InputTag("ecalRecHit", "EcalRecHitsEB"));
117  desc.add<edm::InputTag>("endcapHits", edm::InputTag("ecalRecHit", "EcalRecHitsEE"));
118  desc.add<std::string>("barrelClusterCollection", "islandBarrelBasicClusters");
119  desc.add<std::string>("endcapClusterCollection", "islandEndcapBasicClusters");
120  desc.add<double>("IslandBarrelSeedThr", 0.5);
121  desc.add<double>("IslandEndcapSeedThr", 0.18);
122 
124  posCalcParameters.add<bool>("LogWeighted", true);
125  posCalcParameters.add<double>("T0_barl", 7.4);
126  posCalcParameters.add<double>("T0_endc", 3.1);
127  posCalcParameters.add<double>("T0_endcPresh", 1.2);
128  posCalcParameters.add<double>("W0", 4.2);
129  posCalcParameters.add<double>("X0", 0.89);
130  desc.add<edm::ParameterSetDescription>("posCalcParameters", posCalcParameters);
131 
132  desc.add<std::string>("clustershapecollectionEE", "islandEndcapShape");
133  desc.add<std::string>("clustershapecollectionEB", "islandBarrelShape");
134  desc.add<std::string>("barrelShapeAssociation", "islandBarrelShapeAssoc");
135  desc.add<std::string>("endcapShapeAssociation", "islandEndcapShapeAssoc");
136  desc.add<std::vector<std::string>>("SeedRecHitFlagToBeExcludedEB", {});
137  desc.add<std::vector<std::string>>("SeedRecHitFlagToBeExcludedEE", {});
138  desc.add<std::vector<std::string>>("RecHitFlagToBeExcludedEB", {});
139  desc.add<std::vector<std::string>>("RecHitFlagToBeExcludedEE", {});
140  descriptions.add("IslandClusterProducer", desc);
141 }
142 
148  nEvt_++;
149 }
150 
154  evt.getByToken(token, rhcHandle);
155  return rhcHandle.product();
156 }
157 
159  const edm::EventSetup& es,
161  const std::string& clusterCollection,
162  const std::string& clusterShapeAssociation,
163  const IslandClusterAlgo::EcalPart& ecalPart) {
164  // get the hit collection from the event:
165  const EcalRecHitCollection* hitCollection_p = getCollection(evt, token);
166 
167  // get the geometry and topology from the event setup:
168  edm::ESHandle<CaloGeometry> geoHandle;
169  es.get<CaloGeometryRecord>().get(geoHandle);
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:43
IslandClusterProducer::verbosity
IslandClusterAlgo::VerbosityLevel verbosity
Definition: IslandClusterProducer.h:38
Handle.h
mps_fire.i
i
Definition: mps_fire.py:355
PositionCalc.h
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
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
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
EBDetId.h
IslandClusterAlgo::EcalPart
EcalPart
Definition: IslandClusterAlgo.h:28
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
IslandClusterProducer::posCalculator_
PositionCalc posCalculator_
Definition: IslandClusterProducer.h:53
EcalBarrelTopology.h
IslandClusterProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: IslandClusterProducer.cc:113
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:54
IslandClusterProducer::island_p
IslandClusterAlgo * island_p
Definition: IslandClusterProducer.h:55
IslandClusterProducer::nEvt_
int nEvt_
Definition: IslandClusterProducer.h:36
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:47
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:143
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
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:44
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:528
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
CaloGeometryRecord.h
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
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
IslandClusterProducer::getCollection
const EcalRecHitCollection * getCollection(edm::Event &evt, const edm::EDGetTokenT< EcalRecHitCollection > &token)
Definition: IslandClusterProducer.cc:151
Event.h
IslandClusterProducer::IslandClusterProducer
IslandClusterProducer(const edm::ParameterSet &ps)
Definition: IslandClusterProducer.cc:40
IslandClusterProducer::endcapClusterShapeAssociation_
std::string endcapClusterShapeAssociation_
Definition: IslandClusterProducer.h:51
EcalEndcapTopology.h
IslandClusterProducer::clustershapecollectionEB_
std::string clustershapecollectionEB_
Definition: IslandClusterProducer.h:46
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:132
IslandClusterAlgo::pERROR
Definition: IslandClusterAlgo.h:29
IslandClusterProducer::endcapRecHits_
edm::EDGetTokenT< EcalRecHitCollection > endcapRecHits_
Definition: IslandClusterProducer.h:41
edm::EventSetup
Definition: EventSetup.h:57
DetId::Ecal
Definition: DetId.h:27
get
#define get
EcalRecHit.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
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
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:40
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
CaloGeometry.h
IslandClusterAlgo::pINFO
Definition: IslandClusterAlgo.h:29
EventSetup.h
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
Exception.h
IslandClusterProducer::barrelClusterShapeAssociation_
std::string barrelClusterShapeAssociation_
Definition: IslandClusterProducer.h:50
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:158
edm::InputTag
Definition: InputTag.h:15
BasicClusterShapeAssociation.h
IslandClusterProducer::~IslandClusterProducer
~IslandClusterProducer() override
Definition: IslandClusterProducer.cc:111
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316