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
30 
33 
34 // Class header file
37 
39  basicclusterCollection_ = ps.getParameter<std::string>("basicclusterCollection");
40  superclusterCollection_ = ps.getParameter<std::string>("superclusterCollection");
41  hitsToken_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("recHitsCollection"));
42 
43  //Setup for core tools objects.
45 
47 
48  const std::vector<std::string> flagnames = ps.getParameter<std::vector<std::string> >("RecHitFlagToBeExcluded");
49 
50  const std::vector<int> flagsexcl = StringToEnumValue<EcalRecHit::Flags>(flagnames);
51 
52  const std::vector<std::string> severitynames =
53  ps.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcluded");
54 
55  const std::vector<int> severitiesexcl = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynames);
56 
57  hybrid_p = new HybridClusterAlgo(ps.getParameter<double>("HybridBarrelSeedThr"),
58  ps.getParameter<int>("step"),
59  ps.getParameter<double>("ethresh"),
60  ps.getParameter<double>("eseed"),
61  ps.getParameter<double>("xi"),
62  ps.getParameter<bool>("useEtForXi"),
63  ps.getParameter<double>("ewing"),
64  flagsexcl,
66  ps.getParameter<bool>("dynamicEThresh"),
67  ps.getParameter<double>("eThreshA"),
68  ps.getParameter<double>("eThreshB"),
69  severitiesexcl,
70  ps.getParameter<bool>("excludeFlagged"));
71  //bremRecoveryPset,
72 
73  // get brem recovery parameters
74  bool dynamicPhiRoad = ps.getParameter<bool>("dynamicPhiRoad");
75  if (dynamicPhiRoad) {
78  }
79 
80  produces<reco::BasicClusterCollection>(basicclusterCollection_);
81  produces<reco::SuperClusterCollection>(superclusterCollection_);
82  nEvt_ = 0;
83 }
84 
86 
88  // get the hit collection from the event:
90 
91  evt.getByToken(hitsToken_, rhcHandle);
92  if (!(rhcHandle.isValid())) {
93  edm::LogError("MissingProduct") << "could not get a handle on the EcalRecHitCollection!";
94  return;
95  }
96  const EcalRecHitCollection* hit_collection = rhcHandle.product();
97 
98  // get the collection geometry:
100  es.get<CaloGeometryRecord>().get(geoHandle);
101  const CaloGeometry& geometry = *geoHandle;
102  const CaloSubdetectorGeometry* geometry_p;
103  std::unique_ptr<const CaloSubdetectorTopology> topology;
104 
106  es.get<EcalSeverityLevelAlgoRcd>().get(sevLv);
107 
108  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
109  topology = std::make_unique<EcalBarrelTopology>(*geoHandle);
110 
111  // make the Basic clusters!
112  reco::BasicClusterCollection basicClusters;
114  hit_collection, geometry_p, basicClusters, sevLv.product(), false, std::vector<RectangularEtaPhiRegion>());
115 
116  LogTrace("EcalClusters") << "Finished clustering - BasicClusterCollection returned to producer...";
117 
118  // create a unique_ptr to a BasicClusterCollection, copy the clusters into it and put in the Event:
119  auto basicclusters_p = std::make_unique<reco::BasicClusterCollection>();
120  basicclusters_p->assign(basicClusters.begin(), basicClusters.end());
122  evt.put(std::move(basicclusters_p), basicclusterCollection_);
123 
124  //Basic clusters now in the event.
125  LogTrace("EcalClusters") << "Basic Clusters now put into event.";
126 
127  //Weird though it is, get the BasicClusters back out of the event. We need the
128  //edm::Ref to these guys to make our superclusters for Hybrid.
129 
130  if (!(bccHandle.isValid())) {
131  edm::LogError("Missing Product") << "could not get a handle on the BasicClusterCollection!";
132  return;
133  }
134 
135  reco::BasicClusterCollection clusterCollection = *bccHandle;
136 
137  LogTrace("EcalClusters") << "Got the BasicClusterCollection" << std::endl;
138 
139  reco::CaloClusterPtrVector clusterPtrVector;
140  for (unsigned int i = 0; i < clusterCollection.size(); i++) {
141  clusterPtrVector.push_back(reco::CaloClusterPtr(bccHandle, i));
142  }
143 
145  LogTrace("EcalClusters") << "Found: " << superClusters.size() << " superclusters.";
146 
147  auto superclusters_p = std::make_unique<reco::SuperClusterCollection>();
148  superclusters_p->assign(superClusters.begin(), superClusters.end());
149 
150  evt.put(std::move(superclusters_p), superclusterCollection_);
151  LogTrace("EcalClusters") << "Hybrid Clusters (Basic/Super) added to the Event! :-)";
152 
153  nEvt_++;
154 }
HybridClusterProducer::hybrid_p
HybridClusterAlgo * hybrid_p
Definition: HybridClusterProducer.h:34
EcalPreshowerTopology.h
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
Handle.h
mps_fire.i
i
Definition: mps_fire.py:355
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
EcalSeverityLevelAlgoRcd.h
BasicCluster.h
RectangularEtaPhiRegion.h
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
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
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:85
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
edm::PtrVector< CaloCluster >
ecaldqm::topology
const CaloTopology * topology(nullptr)
HybridClusterProducer::hitsToken_
edm::EDGetTokenT< EcalRecHitCollection > hitsToken_
Definition: HybridClusterProducer.h:32
edm::ESHandle< CaloGeometry >
EcalSeverityLevelAlgoRcd
Definition: EcalSeverityLevelAlgoRcd.h:12
HybridClusterProducer::superclusterCollection_
std::string superclusterCollection_
Definition: HybridClusterProducer.h:30
StringToEnumValue.h
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
HybridClusterProducer.h
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:87
CaloGeometryRecord.h
HLT_2018_cff.superClusters
superClusters
Definition: HLT_2018_cff.py:13791
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HybridClusterProducer::nEvt_
int nEvt_
Definition: HybridClusterProducer.h:27
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:36
edm::LogError
Definition: MessageLogger.h:183
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:132
HybridClusterAlgo::makeSuperClusters
reco::SuperClusterCollection makeSuperClusters(const reco::CaloClusterPtrVector &)
Definition: HybridClusterAlgo.cc:449
cosmicSuperClusters_cfi.dynamicPhiRoad
dynamicPhiRoad
Definition: cosmicSuperClusters_cfi.py:25
edm::EventSetup
Definition: EventSetup.h:57
cosmicSuperClusters_cfi.bremRecoveryPset
bremRecoveryPset
Definition: cosmicSuperClusters_cfi.py:26
DetId::Ecal
Definition: DetId.h:27
get
#define get
edm::OrphanHandleBase::isValid
bool isValid() const
Definition: OrphanHandleBase.h:53
EcalRecHit.h
HybridClusterProducer::HybridClusterProducer
HybridClusterProducer(const edm::ParameterSet &ps)
Definition: HybridClusterProducer.cc:38
edm::Ptr< CaloCluster >
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
CaloCellGeometry.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::OrphanHandle
Definition: EDProductfwd.h:39
HybridClusterProducer::basicclusterCollection_
std::string basicclusterCollection_
Definition: HybridClusterProducer.h:29
HybridClusterProducer::posCalculator_
PositionCalc posCalculator_
Definition: HybridClusterProducer.h:35
SuperCluster.h
CaloGeometry.h
EventSetup.h
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15