CMS 3D CMS Logo

IslandClusterProducer.cc
Go to the documentation of this file.
31 
32 #include <ctime>
33 #include <iostream>
34 #include <memory>
35 #include <vector>
36 
38 public:
40 
41  ~IslandClusterProducer() override;
42  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
43  void produce(edm::Event&, const edm::EventSetup&) override;
44 
45 private:
46  int nMaxPrintout_; // max # of printouts
47  int nEvt_; // internal counter of events
48 
50 
54 
57 
60 
61  //BasicClusterShape AssociationMap
64 
65  PositionCalc posCalculator_; // position calculation algorithm
66  ClusterShapeAlgo shapeAlgo_; // cluster shape algorithm
68 
69  bool counterExceeded() const { return ((nEvt_ > nMaxPrintout_) || (nMaxPrintout_ < 0)); }
70 
72 
74  const edm::EventSetup& es,
76  const std::string& clusterCollection,
77  const std::string& clusterShapeAssociation,
78  const IslandClusterAlgo::EcalPart& ecalPart);
79 
80  void outputValidationInfo(reco::CaloClusterPtrVector& clusterPtrVector);
81 };
82 
85 
87  // The verbosity level
88  std::string verbosityString = ps.getParameter<std::string>("VerbosityLevel");
89  if (verbosityString == "DEBUG")
91  else if (verbosityString == "WARNING")
93  else if (verbosityString == "INFO")
95  else
97 
98  // Parameters to identify the hit collections
99  barrelRecHits_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("barrelHits"));
100  endcapRecHits_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("endcapHits"));
101 
102  //EventSetup Token for CaloGeometry
103  caloGeometryToken_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
104 
105  // The names of the produced cluster collections
106  barrelClusterCollection_ = ps.getParameter<std::string>("barrelClusterCollection");
107  endcapClusterCollection_ = ps.getParameter<std::string>("endcapClusterCollection");
108 
109  // Island algorithm parameters
110  double barrelSeedThreshold = ps.getParameter<double>("IslandBarrelSeedThr");
111  double endcapSeedThreshold = ps.getParameter<double>("IslandEndcapSeedThr");
112 
113  // Parameters for the position calculation:
117 
118  clustershapecollectionEB_ = ps.getParameter<std::string>("clustershapecollectionEB");
119  clustershapecollectionEE_ = ps.getParameter<std::string>("clustershapecollectionEE");
120 
121  //AssociationMap
122  barrelClusterShapeAssociation_ = ps.getParameter<std::string>("barrelShapeAssociation");
123  endcapClusterShapeAssociation_ = ps.getParameter<std::string>("endcapShapeAssociation");
124 
125  const std::vector<std::string> seedflagnamesEB =
126  ps.getParameter<std::vector<std::string>>("SeedRecHitFlagToBeExcludedEB");
127  const std::vector<int> seedflagsexclEB = StringToEnumValue<EcalRecHit::Flags>(seedflagnamesEB);
128 
129  const std::vector<std::string> seedflagnamesEE =
130  ps.getParameter<std::vector<std::string>>("SeedRecHitFlagToBeExcludedEE");
131  const std::vector<int> seedflagsexclEE = StringToEnumValue<EcalRecHit::Flags>(seedflagnamesEE);
132 
133  const std::vector<std::string> flagnamesEB = ps.getParameter<std::vector<std::string>>("RecHitFlagToBeExcludedEB");
134  const std::vector<int> flagsexclEB = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
135 
136  const std::vector<std::string> flagnamesEE = ps.getParameter<std::vector<std::string>>("RecHitFlagToBeExcludedEE");
137  const std::vector<int> flagsexclEE = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
138 
139  // Produces a collection of barrel and a collection of endcap clusters
140 
141  produces<reco::ClusterShapeCollection>(clustershapecollectionEE_);
142  produces<reco::BasicClusterCollection>(endcapClusterCollection_);
143  produces<reco::ClusterShapeCollection>(clustershapecollectionEB_);
144  produces<reco::BasicClusterCollection>(barrelClusterCollection_);
145  produces<reco::BasicClusterShapeAssociationCollection>(barrelClusterShapeAssociation_);
146  produces<reco::BasicClusterShapeAssociationCollection>(endcapClusterShapeAssociation_);
147 
148  island_p = new IslandClusterAlgo(barrelSeedThreshold,
149  endcapSeedThreshold,
151  seedflagsexclEB,
152  seedflagsexclEE,
153  flagsexclEB,
154  flagsexclEE,
155  verbosity);
156 
157  nEvt_ = 0;
158 }
159 
161 
164  desc.add<std::string>("VerbosityLevel", "ERROR");
165  desc.add<edm::InputTag>("barrelHits", edm::InputTag("ecalRecHit", "EcalRecHitsEB"));
166  desc.add<edm::InputTag>("endcapHits", edm::InputTag("ecalRecHit", "EcalRecHitsEE"));
167  desc.add<std::string>("barrelClusterCollection", "islandBarrelBasicClusters");
168  desc.add<std::string>("endcapClusterCollection", "islandEndcapBasicClusters");
169  desc.add<double>("IslandBarrelSeedThr", 0.5);
170  desc.add<double>("IslandEndcapSeedThr", 0.18);
171 
173  posCalcParameters.add<bool>("LogWeighted", true);
174  posCalcParameters.add<double>("T0_barl", 7.4);
175  posCalcParameters.add<double>("T0_endc", 3.1);
176  posCalcParameters.add<double>("T0_endcPresh", 1.2);
177  posCalcParameters.add<double>("W0", 4.2);
178  posCalcParameters.add<double>("X0", 0.89);
179  desc.add<edm::ParameterSetDescription>("posCalcParameters", posCalcParameters);
180 
181  desc.add<std::string>("clustershapecollectionEE", "islandEndcapShape");
182  desc.add<std::string>("clustershapecollectionEB", "islandBarrelShape");
183  desc.add<std::string>("barrelShapeAssociation", "islandBarrelShapeAssoc");
184  desc.add<std::string>("endcapShapeAssociation", "islandEndcapShapeAssoc");
185  desc.add<std::vector<std::string>>("SeedRecHitFlagToBeExcludedEB", {});
186  desc.add<std::vector<std::string>>("SeedRecHitFlagToBeExcludedEE", {});
187  desc.add<std::vector<std::string>>("RecHitFlagToBeExcludedEB", {});
188  desc.add<std::vector<std::string>>("RecHitFlagToBeExcludedEE", {});
189  descriptions.add("IslandClusterProducer", desc);
190 }
191 
197  nEvt_++;
198 }
199 
203  evt.getByToken(token, rhcHandle);
204  return rhcHandle.product();
205 }
206 
208  const edm::EventSetup& es,
210  const std::string& clusterCollection,
211  const std::string& clusterShapeAssociation,
212  const IslandClusterAlgo::EcalPart& ecalPart) {
213  // get the hit collection from the event:
214  const EcalRecHitCollection* hitCollection_p = getCollection(evt, token);
215 
216  // get the geometry and topology from the event setup:
218 
219  const CaloSubdetectorGeometry* geometry_p;
220  std::unique_ptr<CaloSubdetectorTopology> topology_p;
221 
222  std::string clustershapetag;
223  if (ecalPart == IslandClusterAlgo::barrel) {
224  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
225  topology_p = std::make_unique<EcalBarrelTopology>(*geoHandle);
226  } else {
227  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
228  topology_p = std::make_unique<EcalEndcapTopology>(*geoHandle);
229  }
230 
231  const CaloSubdetectorGeometry* geometryES_p;
232  geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
233 
234  // Run the clusterization algorithm:
236  clusters = island_p->makeClusters(hitCollection_p, geometry_p, topology_p.get(), geometryES_p, ecalPart);
237 
238  //Create associated ClusterShape objects.
239  std::vector<reco::ClusterShape> ClusVec;
240  for (int erg = 0; erg < int(clusters.size()); ++erg) {
241  reco::ClusterShape TestShape = shapeAlgo_.Calculate(clusters[erg], hitCollection_p, geometry_p, topology_p.get());
242  ClusVec.push_back(TestShape);
243  }
244 
245  //Put clustershapes in event, but retain a Handle on them.
246  auto clustersshapes_p = std::make_unique<reco::ClusterShapeCollection>();
247  clustersshapes_p->assign(ClusVec.begin(), ClusVec.end());
249  if (ecalPart == IslandClusterAlgo::barrel)
250  clusHandle = evt.put(std::move(clustersshapes_p), clustershapecollectionEB_);
251  else
252  clusHandle = evt.put(std::move(clustersshapes_p), clustershapecollectionEE_);
253 
254  // create a unique_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event:
255  auto clusters_p = std::make_unique<reco::BasicClusterCollection>();
256  clusters_p->assign(clusters.begin(), clusters.end());
258  if (ecalPart == IslandClusterAlgo::barrel)
259  bccHandle = evt.put(std::move(clusters_p), barrelClusterCollection_);
260  else
261  bccHandle = evt.put(std::move(clusters_p), endcapClusterCollection_);
262 
263  // BasicClusterShapeAssociationMap
264  auto shapeAssocs_p = std::make_unique<reco::BasicClusterShapeAssociationCollection>(bccHandle, clusHandle);
265  for (unsigned int i = 0; i < clusHandle->size(); i++) {
266  shapeAssocs_p->insert(edm::Ref<reco::BasicClusterCollection>(bccHandle, i),
268  }
269  evt.put(std::move(shapeAssocs_p), clusterShapeAssociation);
270 }
ConfigurationDescriptions.h
IslandClusterAlgo::pDEBUG
Definition: IslandClusterAlgo.h:29
IslandClusterProducer::barrelClusterCollection_
std::string barrelClusterCollection_
Definition: IslandClusterProducer.cc:55
IslandClusterProducer::verbosity
IslandClusterAlgo::VerbosityLevel verbosity
Definition: IslandClusterProducer.cc:49
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
IslandClusterAlgo::VerbosityLevel
VerbosityLevel
Definition: IslandClusterAlgo.h:29
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:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
IslandClusterProducer::posCalculator_
PositionCalc posCalculator_
Definition: IslandClusterProducer.cc:65
EcalBarrelTopology.h
IslandClusterProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: IslandClusterProducer.cc:162
CaloGeometry::getSubdetectorGeometry
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
IslandClusterAlgo.h
EDProducer.h
edm::SortedCollection< EcalRecHit >
IslandClusterProducer::shapeAlgo_
ClusterShapeAlgo shapeAlgo_
Definition: IslandClusterProducer.cc:66
IslandClusterProducer::island_p
IslandClusterAlgo * island_p
Definition: IslandClusterProducer.cc:67
IslandClusterProducer::caloGeometryToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
Definition: IslandClusterProducer.cc:53
IslandClusterProducer::nEvt_
int nEvt_
Definition: IslandClusterProducer.cc:47
MonitorAlCaEcalPi0_cfi.posCalcParameters
posCalcParameters
Definition: MonitorAlCaEcalPi0_cfi.py:72
ClusterShapeAlgo.h
edm::Handle
Definition: AssociativeIterator.h:50
IslandClusterProducer::clustershapecollectionEE_
std::string clustershapecollectionEE_
Definition: IslandClusterProducer.cc:59
ESGetToken.h
EcalBarrel
Definition: EcalSubdetector.h:10
EcalRecHitCollections.h
BasicClusterFwd.h
edm::Ref
Definition: AssociativeIterator.h:58
IslandClusterProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: IslandClusterProducer.cc:192
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ClusterShapeFwd.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
IslandClusterProducer::nMaxPrintout_
int nMaxPrintout_
Definition: IslandClusterProducer.cc:46
edm::PtrVector< CaloCluster >
IslandClusterProducer::endcapClusterCollection_
std::string endcapClusterCollection_
Definition: IslandClusterProducer.cc:56
reco::ClusterShape
Definition: ClusterShape.h:21
edm::ESHandle< CaloGeometry >
CaloClusterFwd.h
EcalRecHit.h
StringToEnumValue.h
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
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
IslandClusterProducer::counterExceeded
bool counterExceeded() const
Definition: IslandClusterProducer.cc:69
CaloGeometryRecord.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
EcalEndcap
Definition: EcalSubdetector.h:10
IslandClusterProducer::outputValidationInfo
void outputValidationInfo(reco::CaloClusterPtrVector &clusterPtrVector)
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:200
Event.h
IslandClusterProducer::IslandClusterProducer
IslandClusterProducer(const edm::ParameterSet &ps)
Definition: IslandClusterProducer.cc:86
IslandClusterProducer::endcapClusterShapeAssociation_
std::string endcapClusterShapeAssociation_
Definition: IslandClusterProducer.cc:63
EcalEndcapTopology.h
IslandClusterProducer::clustershapecollectionEB_
std::string clustershapecollectionEB_
Definition: IslandClusterProducer.cc:58
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:155
IslandClusterAlgo::pERROR
Definition: IslandClusterAlgo.h:29
edm::stream::EDProducer
Definition: EDProducer.h:36
IslandClusterProducer::endcapRecHits_
edm::EDGetTokenT< EcalRecHitCollection > endcapRecHits_
Definition: IslandClusterProducer.cc:52
edm::EventSetup
Definition: EventSetup.h:58
DetId::Ecal
Definition: DetId.h:27
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< CaloGeometry, CaloGeometryRecord >
EcalPreshower
Definition: EcalSubdetector.h:10
CaloSubdetectorTopology.h
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.cc:51
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
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
IslandClusterProducer
Definition: IslandClusterProducer.cc:37
IslandClusterProducer::barrelClusterShapeAssociation_
std::string barrelClusterShapeAssociation_
Definition: IslandClusterProducer.cc:62
IslandClusterAlgo::pWARNING
Definition: IslandClusterAlgo.h:29
ParameterSet.h
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:207
edm::InputTag
Definition: InputTag.h:15
BasicClusterShapeAssociation.h
IslandClusterProducer::~IslandClusterProducer
~IslandClusterProducer() override
Definition: IslandClusterProducer.cc:160
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316