CMS 3D CMS Logo

HybridClusterProducer.cc
Go to the documentation of this file.
1 // C/C++ headers
2 #include <iostream>
3 #include <vector>
4 #include <memory>
5 
6 // Framework
13 
14 // Reconstruction Classes
21 
22 // Geometry
28 
29 // Class header file
32 
34  basicclusterCollection_ = ps.getParameter<std::string>("basicclusterCollection");
35  superclusterCollection_ = ps.getParameter<std::string>("superclusterCollection");
36  hitsToken_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("recHitsCollection"));
37  geoToken_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
38  sevLvToken_ = esConsumes<EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd>();
39 
40  //Setup for core tools objects.
42 
44 
45  const std::vector<std::string> flagnames = ps.getParameter<std::vector<std::string> >("RecHitFlagToBeExcluded");
46 
47  const std::vector<int> flagsexcl = StringToEnumValue<EcalRecHit::Flags>(flagnames);
48 
49  const std::vector<std::string> severitynames =
50  ps.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcluded");
51 
52  const std::vector<int> severitiesexcl = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynames);
53 
54  hybrid_p = new HybridClusterAlgo(ps.getParameter<double>("HybridBarrelSeedThr"),
55  ps.getParameter<int>("step"),
56  ps.getParameter<double>("ethresh"),
57  ps.getParameter<double>("eseed"),
58  ps.getParameter<double>("xi"),
59  ps.getParameter<bool>("useEtForXi"),
60  ps.getParameter<double>("ewing"),
61  flagsexcl,
63  ps.getParameter<bool>("dynamicEThresh"),
64  ps.getParameter<double>("eThreshA"),
65  ps.getParameter<double>("eThreshB"),
66  severitiesexcl,
67  ps.getParameter<bool>("excludeFlagged"));
68  //bremRecoveryPset,
69 
70  // get brem recovery parameters
71  bool dynamicPhiRoad = ps.getParameter<bool>("dynamicPhiRoad");
72  if (dynamicPhiRoad) {
75  }
76 
77  produces<reco::BasicClusterCollection>(basicclusterCollection_);
78  produces<reco::SuperClusterCollection>(superclusterCollection_);
79  nEvt_ = 0;
80 }
81 
83 
85  // get the hit collection from the event:
87 
88  evt.getByToken(hitsToken_, rhcHandle);
89  if (!(rhcHandle.isValid())) {
90  edm::LogError("MissingProduct") << "could not get a handle on the EcalRecHitCollection!";
91  return;
92  }
93  const EcalRecHitCollection* hit_collection = rhcHandle.product();
94 
95  // get the collection geometry:
97  const CaloGeometry& geometry = *geoHandle;
98  const CaloSubdetectorGeometry* geometry_p;
99  std::unique_ptr<const CaloSubdetectorTopology> topology;
100 
102 
103  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
104  topology = std::make_unique<EcalBarrelTopology>(*geoHandle);
105 
106  // make the Basic clusters!
107  reco::BasicClusterCollection basicClusters;
109  hit_collection, geometry_p, basicClusters, sevLv.product(), false, std::vector<RectangularEtaPhiRegion>());
110 
111  LogTrace("EcalClusters") << "Finished clustering - BasicClusterCollection returned to producer...";
112 
113  // create a unique_ptr to a BasicClusterCollection, copy the clusters into it and put in the Event:
114  auto basicclusters_p = std::make_unique<reco::BasicClusterCollection>();
115  basicclusters_p->assign(basicClusters.begin(), basicClusters.end());
117  evt.put(std::move(basicclusters_p), basicclusterCollection_);
118 
119  //Basic clusters now in the event.
120  LogTrace("EcalClusters") << "Basic Clusters now put into event.";
121 
122  //Weird though it is, get the BasicClusters back out of the event. We need the
123  //edm::Ref to these guys to make our superclusters for Hybrid.
124 
125  if (!(bccHandle.isValid())) {
126  edm::LogError("Missing Product") << "could not get a handle on the BasicClusterCollection!";
127  return;
128  }
129 
130  reco::BasicClusterCollection clusterCollection = *bccHandle;
131 
132  LogTrace("EcalClusters") << "Got the BasicClusterCollection" << std::endl;
133 
134  reco::CaloClusterPtrVector clusterPtrVector;
135  for (unsigned int i = 0; i < clusterCollection.size(); i++) {
136  clusterPtrVector.push_back(reco::CaloClusterPtr(bccHandle, i));
137  }
138 
140  LogTrace("EcalClusters") << "Found: " << superClusters.size() << " superclusters.";
141 
142  auto superclusters_p = std::make_unique<reco::SuperClusterCollection>();
143  superclusters_p->assign(superClusters.begin(), superClusters.end());
144 
145  evt.put(std::move(superclusters_p), superclusterCollection_);
146  LogTrace("EcalClusters") << "Hybrid Clusters (Basic/Super) added to the Event! :-)";
147 
148  nEvt_++;
149 }
HybridClusterProducer::hybrid_p
HybridClusterAlgo * hybrid_p
Definition: HybridClusterProducer.h:41
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
ESHandle.h
HybridClusterProducer::sevLvToken_
edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd > sevLvToken_
Definition: HybridClusterProducer.h:39
BasicCluster.h
RectangularEtaPhiRegion.h
geometry
Definition: geometry.py:1
EBDetId.h
EcalBarrelTopology.h
edm::SortedCollection< EcalRecHit >
MonitorAlCaEcalPi0_cfi.posCalcParameters
posCalcParameters
Definition: MonitorAlCaEcalPi0_cfi.py:72
edm::Handle
Definition: AssociativeIterator.h:50
EcalBarrel
Definition: EcalSubdetector.h:10
BasicClusterFwd.h
HLT_FULL_cff.superClusters
superClusters
Definition: HLT_FULL_cff.py:15237
reco::SuperClusterCollection
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Definition: SuperClusterFwd.h:9
CaloGeometry
Definition: CaloGeometry.h:21
HybridClusterProducer::~HybridClusterProducer
~HybridClusterProducer() override
Definition: HybridClusterProducer.cc:82
edm::PtrVector< CaloCluster >
ecaldqm::topology
const CaloTopology * topology(nullptr)
HybridClusterProducer::hitsToken_
edm::EDGetTokenT< EcalRecHitCollection > hitsToken_
Definition: HybridClusterProducer.h:37
edm::ESHandle< CaloGeometry >
HybridClusterProducer::superclusterCollection_
std::string superclusterCollection_
Definition: HybridClusterProducer.h:35
StringToEnumValue.h
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
HybridClusterProducer.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:84
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HybridClusterProducer::nEvt_
int nEvt_
Definition: HybridClusterProducer.h:32
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:148
HybridClusterAlgo::makeSuperClusters
reco::SuperClusterCollection makeSuperClusters(const reco::CaloClusterPtrVector &)
Definition: HybridClusterAlgo.cc:450
cosmicSuperClusters_cfi.dynamicPhiRoad
dynamicPhiRoad
Definition: cosmicSuperClusters_cfi.py:25
edm::EventSetup
Definition: EventSetup.h:57
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::OrphanHandleBase::isValid
bool isValid() const
Definition: OrphanHandleBase.h:53
EcalRecHit.h
HybridClusterProducer::HybridClusterProducer
HybridClusterProducer(const edm::ParameterSet &ps)
Definition: HybridClusterProducer.cc:33
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.h:38
HybridClusterProducer::basicclusterCollection_
std::string basicclusterCollection_
Definition: HybridClusterProducer.h:34
HybridClusterProducer::posCalculator_
PositionCalc posCalculator_
Definition: HybridClusterProducer.h:42
SuperCluster.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:224
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15