CMS 3D CMS Logo

HybridClusterProducer.cc
Go to the documentation of this file.
28 
29 #include <iostream>
30 #include <memory>
31 #include <vector>
32 
34 public:
36 
37  ~HybridClusterProducer() override;
38 
39  void produce(edm::Event&, const edm::EventSetup&) override;
40 
41 private:
42  int nEvt_; // internal counter of events
43 
46 
50 
51  HybridClusterAlgo* hybrid_p; // clustering algorithm
52  PositionCalc posCalculator_; // position calculation algorithm
53 };
54 
57 
59  basicclusterCollection_ = ps.getParameter<std::string>("basicclusterCollection");
60  superclusterCollection_ = ps.getParameter<std::string>("superclusterCollection");
61  hitsToken_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("recHitsCollection"));
62  geoToken_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
63  sevLvToken_ = esConsumes<EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd>();
64 
65  //Setup for core tools objects.
67 
69 
70  const std::vector<std::string> flagnames = ps.getParameter<std::vector<std::string> >("RecHitFlagToBeExcluded");
71 
72  const std::vector<int> flagsexcl = StringToEnumValue<EcalRecHit::Flags>(flagnames);
73 
74  const std::vector<std::string> severitynames =
75  ps.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcluded");
76 
77  const std::vector<int> severitiesexcl = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynames);
78 
79  hybrid_p = new HybridClusterAlgo(ps.getParameter<double>("HybridBarrelSeedThr"),
80  ps.getParameter<int>("step"),
81  ps.getParameter<double>("ethresh"),
82  ps.getParameter<double>("eseed"),
83  ps.getParameter<double>("xi"),
84  ps.getParameter<bool>("useEtForXi"),
85  ps.getParameter<double>("ewing"),
86  flagsexcl,
88  ps.getParameter<bool>("dynamicEThresh"),
89  ps.getParameter<double>("eThreshA"),
90  ps.getParameter<double>("eThreshB"),
91  severitiesexcl,
92  ps.getParameter<bool>("excludeFlagged"));
93  //bremRecoveryPset,
94 
95  // get brem recovery parameters
96  bool dynamicPhiRoad = ps.getParameter<bool>("dynamicPhiRoad");
97  if (dynamicPhiRoad) {
100  }
101 
102  produces<reco::BasicClusterCollection>(basicclusterCollection_);
103  produces<reco::SuperClusterCollection>(superclusterCollection_);
104  nEvt_ = 0;
105 }
106 
108 
110  // get the hit collection from the event:
112 
113  evt.getByToken(hitsToken_, rhcHandle);
114  if (!(rhcHandle.isValid())) {
115  edm::LogError("MissingProduct") << "could not get a handle on the EcalRecHitCollection!";
116  return;
117  }
118  const EcalRecHitCollection* hit_collection = rhcHandle.product();
119 
120  // get the collection geometry:
122  const CaloGeometry& geometry = *geoHandle;
123  const CaloSubdetectorGeometry* geometry_p;
124  std::unique_ptr<const CaloSubdetectorTopology> topology;
125 
127 
128  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
129  topology = std::make_unique<EcalBarrelTopology>(*geoHandle);
130 
131  // make the Basic clusters!
132  reco::BasicClusterCollection basicClusters;
134  hit_collection, geometry_p, basicClusters, sevLv.product(), false, std::vector<RectangularEtaPhiRegion>());
135 
136  LogTrace("EcalClusters") << "Finished clustering - BasicClusterCollection returned to producer...";
137 
138  // create a unique_ptr to a BasicClusterCollection, copy the clusters into it and put in the Event:
139  auto basicclusters_p = std::make_unique<reco::BasicClusterCollection>();
140  basicclusters_p->assign(basicClusters.begin(), basicClusters.end());
142  evt.put(std::move(basicclusters_p), basicclusterCollection_);
143 
144  //Basic clusters now in the event.
145  LogTrace("EcalClusters") << "Basic Clusters now put into event.";
146 
147  //Weird though it is, get the BasicClusters back out of the event. We need the
148  //edm::Ref to these guys to make our superclusters for Hybrid.
149 
150  if (!(bccHandle.isValid())) {
151  edm::LogError("Missing Product") << "could not get a handle on the BasicClusterCollection!";
152  return;
153  }
154 
155  reco::BasicClusterCollection clusterCollection = *bccHandle;
156 
157  LogTrace("EcalClusters") << "Got the BasicClusterCollection" << std::endl;
158 
159  reco::CaloClusterPtrVector clusterPtrVector;
160  for (unsigned int i = 0; i < clusterCollection.size(); i++) {
161  clusterPtrVector.push_back(reco::CaloClusterPtr(bccHandle, i));
162  }
163 
165  LogTrace("EcalClusters") << "Found: " << superClusters.size() << " superclusters.";
166 
167  auto superclusters_p = std::make_unique<reco::SuperClusterCollection>();
168  superclusters_p->assign(superClusters.begin(), superClusters.end());
169 
170  evt.put(std::move(superclusters_p), superclusterCollection_);
171  LogTrace("EcalClusters") << "Hybrid Clusters (Basic/Super) added to the Event! :-)";
172 
173  nEvt_++;
174 }
HybridClusterProducer::hybrid_p
HybridClusterAlgo * hybrid_p
Definition: HybridClusterProducer.cc:51
EcalPreshowerTopology.h
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
Handle.h
mps_fire.i
i
Definition: mps_fire.py:428
PositionCalc.h
MessageLogger.h
HybridClusterAlgo::makeClusters
void makeClusters(const EcalRecHitCollection *, const CaloSubdetectorGeometry *geometry, reco::BasicClusterCollection &basicClusters, const EcalSeverityLevelAlgo *sevLv, bool regional=false, const std::vector< RectangularEtaPhiRegion > &regions=std::vector< RectangularEtaPhiRegion >())
Definition: HybridClusterAlgo.cc:60
edm::Handle::product
T const * product() const
Definition: Handle.h:70
HybridClusterProducer
Definition: HybridClusterProducer.cc:33
ESHandle.h
HybridClusterProducer::sevLvToken_
edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd > sevLvToken_
Definition: HybridClusterProducer.cc:49
EcalSeverityLevelAlgoRcd.h
BasicCluster.h
RectangularEtaPhiRegion.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
HybridClusterAlgo.h
geometry
Definition: geometry.py:1
EBDetId.h
EcalBarrelTopology.h
EDProducer.h
edm::SortedCollection< EcalRecHit >
MonitorAlCaEcalPi0_cfi.posCalcParameters
posCalcParameters
Definition: MonitorAlCaEcalPi0_cfi.py:72
edm::Handle
Definition: AssociativeIterator.h:50
ESGetToken.h
EcalBarrel
Definition: EcalSubdetector.h:10
EcalRecHitCollections.h
BasicClusterFwd.h
HLT_FULL_cff.superClusters
superClusters
Definition: HLT_FULL_cff.py:15191
reco::SuperClusterCollection
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Definition: SuperClusterFwd.h:9
MakerMacros.h
CaloGeometry
Definition: CaloGeometry.h:21
HybridClusterProducer::~HybridClusterProducer
~HybridClusterProducer() override
Definition: HybridClusterProducer.cc:107
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::PtrVector< CaloCluster >
HybridClusterProducer::hitsToken_
edm::EDGetTokenT< EcalRecHitCollection > hitsToken_
Definition: HybridClusterProducer.cc:47
edm::ESHandle< CaloGeometry >
HybridClusterProducer::superclusterCollection_
std::string superclusterCollection_
Definition: HybridClusterProducer.cc:45
EcalRecHit.h
StringToEnumValue.h
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
EcalSeverityLevelAlgo.h
reco::BasicClusterCollection
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
Definition: BasicClusterFwd.h:16
HybridClusterProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HybridClusterProducer.cc:109
CaloGeometryRecord.h
HybridClusterProducer::nEvt_
int nEvt_
Definition: HybridClusterProducer.cc:42
edm::PtrVector::push_back
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
CaloSubdetectorGeometry.h
HybridClusterAlgo
Definition: HybridClusterAlgo.h:26
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
EcalEndcapTopology.h
PositionCalc
Definition: PositionCalc.h:29
HybridClusterAlgo::setDynamicPhiRoad
void setDynamicPhiRoad(const edm::ParameterSet &bremRecoveryPset)
Definition: HybridClusterAlgo.h:143
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
HybridClusterAlgo::makeSuperClusters
reco::SuperClusterCollection makeSuperClusters(const reco::CaloClusterPtrVector &)
Definition: HybridClusterAlgo.cc:450
edm::stream::EDProducer
Definition: EDProducer.h:36
cosmicSuperClusters_cfi.dynamicPhiRoad
dynamicPhiRoad
Definition: cosmicSuperClusters_cfi.py:25
edm::EventSetup
Definition: EventSetup.h:58
cosmicSuperClusters_cfi.bremRecoveryPset
bremRecoveryPset
Definition: cosmicSuperClusters_cfi.py:26
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
DetId::Ecal
Definition: DetId.h:27
edm::ESGetToken< CaloGeometry, CaloGeometryRecord >
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::OrphanHandleBase::isValid
bool isValid() const
Definition: OrphanHandleBase.h:53
HybridClusterProducer::HybridClusterProducer
HybridClusterProducer(const edm::ParameterSet &ps)
Definition: HybridClusterProducer.cc:58
edm::Ptr< CaloCluster >
CaloCellGeometry.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::OrphanHandle
Definition: EDProductfwd.h:39
HybridClusterProducer::geoToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geoToken_
Definition: HybridClusterProducer.cc:48
HybridClusterProducer::basicclusterCollection_
std::string basicclusterCollection_
Definition: HybridClusterProducer.cc:44
HybridClusterProducer::posCalculator_
PositionCalc posCalculator_
Definition: HybridClusterProducer.cc:52
SuperCluster.h
CaloGeometry.h
EventSetup.h
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15