CMS 3D CMS Logo

Multi5x5SuperClusterProducer.cc
Go to the documentation of this file.
13 
14 #include <iostream>
15 #include <memory>
16 #include <sstream>
17 #include <vector>
18 
20 public:
22 
23  void produce(edm::Event&, const edm::EventSetup&) override;
24  void endStream() override;
25 
26 private:
31 
32  const float barrelEtaSearchRoad_;
33  const float barrelPhiSearchRoad_;
34  const float endcapEtaSearchRoad_;
35  const float endcapPhiSearchRoad_;
37 
38  const bool doBarrel_;
39  const bool doEndcaps_;
40 
41  std::unique_ptr<Multi5x5BremRecoveryClusterAlgo> bremAlgo_p;
42 
43  double totalE;
45 
47  edm::Event& evt, const edm::EDGetTokenT<reco::BasicClusterCollection>& clustersToken) const;
48 
52 
54 };
55 
58 
60  : barrelEtaSearchRoad_{static_cast<float>(ps.getParameter<double>("barrelEtaSearchRoad"))},
61  barrelPhiSearchRoad_{static_cast<float>(ps.getParameter<double>("barrelPhiSearchRoad"))},
62  endcapEtaSearchRoad_{static_cast<float>(ps.getParameter<double>("endcapEtaSearchRoad"))},
63  endcapPhiSearchRoad_{static_cast<float>(ps.getParameter<double>("endcapPhiSearchRoad"))},
64  seedTransverseEnergyThreshold_{static_cast<float>(ps.getParameter<double>("seedTransverseEnergyThreshold"))},
65  doBarrel_{ps.getParameter<bool>("doBarrel")},
66  doEndcaps_{ps.getParameter<bool>("doEndcaps")},
67  totalE{0.},
68  noSuperClusters{0} {
69  if (doEndcaps_) {
70  eeClustersToken_ = consumes<reco::BasicClusterCollection>(ps.getParameter<edm::InputTag>("endcapClusterTag"));
71  }
72  if (doBarrel_) {
73  ebClustersToken_ = consumes<reco::BasicClusterCollection>(ps.getParameter<edm::InputTag>("barrelClusterTag"));
74  }
75 
76  const edm::ParameterSet bremRecoveryPset = ps.getParameter<edm::ParameterSet>("bremRecoveryPset");
77  bool dynamicPhiRoad = ps.getParameter<bool>("dynamicPhiRoad");
78 
79  bremAlgo_p = std::make_unique<Multi5x5BremRecoveryClusterAlgo>(bremRecoveryPset,
80  barrelEtaSearchRoad_,
81  barrelPhiSearchRoad_,
82  endcapEtaSearchRoad_,
83  endcapPhiSearchRoad_,
85  seedTransverseEnergyThreshold_);
86 
87  if (doEndcaps_) {
88  endcapPutToken_ =
89  produces<reco::SuperClusterCollection>(ps.getParameter<std::string>("endcapSuperclusterCollection"));
90  }
91  if (doBarrel_) {
92  barrelPutToken_ =
93  produces<reco::SuperClusterCollection>(ps.getParameter<std::string>("barrelSuperclusterCollection"));
94  }
95 }
96 
98  double averEnergy = 0.;
99  std::ostringstream str;
100  str << "Multi5x5SuperClusterProducer::endJob()\n"
101  << " total # reconstructed super clusters: " << noSuperClusters << "\n"
102  << " total energy of all clusters: " << totalE << "\n";
103  if (noSuperClusters > 0) {
104  averEnergy = totalE / noSuperClusters;
105  str << " average SuperCluster energy = " << averEnergy << "\n";
106  }
107  edm::LogInfo("Multi5x5SuperClusterProducerInfo") << str.str() << "\n";
108 }
109 
111  if (doEndcaps_)
113 
114  if (doBarrel_)
116 }
117 
119  edm::Event& evt,
122  // get the cluster collection out and turn it to a BasicClusterRefVector:
123  reco::CaloClusterPtrVector clusterPtrVector_p = getClusterPtrVector(evt, clustersToken);
124 
125  // run the brem recovery and get the SC collection
126  reco::SuperClusterCollection superclusters_ap(bremAlgo_p->makeSuperClusters(clusterPtrVector_p));
127 
128  // count the total energy and the number of superclusters
129  for (auto const& sc : superclusters_ap) {
130  totalE += sc.energy();
131  noSuperClusters++;
132  }
133 
134  // put the SC collection in the event
135  evt.emplace(putToken, std::move(superclusters_ap));
136 }
137 
139  edm::Event& evt, const edm::EDGetTokenT<reco::BasicClusterCollection>& clustersToken) const {
140  reco::CaloClusterPtrVector clusterPtrVector_p;
142  evt.getByToken(clustersToken, bccHandle);
143 
144  const reco::BasicClusterCollection* clusterCollection_p = bccHandle.product();
145  clusterPtrVector_p.reserve(clusterCollection_p->size());
146  for (unsigned int i = 0; i < clusterCollection_p->size(); i++) {
147  clusterPtrVector_p.push_back(reco::CaloClusterPtr(bccHandle, i));
148  }
149  return clusterPtrVector_p;
150 }
Multi5x5SuperClusterProducer::ebClustersToken_
edm::EDGetTokenT< reco::BasicClusterCollection > ebClustersToken_
Definition: Multi5x5SuperClusterProducer.cc:28
Handle.h
Multi5x5SuperClusterProducer::Multi5x5SuperClusterProducer
Multi5x5SuperClusterProducer(const edm::ParameterSet &ps)
Definition: Multi5x5SuperClusterProducer.cc:59
mps_fire.i
i
Definition: mps_fire.py:428
Multi5x5SuperClusterProducer::endcapPutToken_
edm::EDPutTokenT< reco::SuperClusterCollection > endcapPutToken_
Definition: Multi5x5SuperClusterProducer.cc:29
Multi5x5BremRecoveryClusterAlgo.h
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
Multi5x5SuperClusterProducer::endcapEtaSearchRoad_
const float endcapEtaSearchRoad_
Definition: Multi5x5SuperClusterProducer.cc:34
BasicCluster.h
Multi5x5SuperClusterProducer::totalE
double totalE
Definition: Multi5x5SuperClusterProducer.cc:43
Multi5x5SuperClusterProducer::barrelEtaSearchRoad_
const float barrelEtaSearchRoad_
Definition: Multi5x5SuperClusterProducer.cc:32
Multi5x5SuperClusterProducer::barrelPutToken_
edm::EDPutTokenT< reco::SuperClusterCollection > barrelPutToken_
Definition: Multi5x5SuperClusterProducer.cc:30
edm::EDGetTokenT< reco::BasicClusterCollection >
Multi5x5SuperClusterProducer::getClusterPtrVector
reco::CaloClusterPtrVector getClusterPtrVector(edm::Event &evt, const edm::EDGetTokenT< reco::BasicClusterCollection > &clustersToken) const
Definition: Multi5x5SuperClusterProducer.cc:138
edm::EDPutTokenT< reco::SuperClusterCollection >
EDProducer.h
Multi5x5SuperClusterProducer::outputValidationInfo
void outputValidationInfo(reco::SuperClusterCollection &superclusterCollection)
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
BasicClusterFwd.h
Multi5x5SuperClusterProducer::seedTransverseEnergyThreshold_
const float seedTransverseEnergyThreshold_
Definition: Multi5x5SuperClusterProducer.cc:36
reco::SuperClusterCollection
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Definition: SuperClusterFwd.h:9
MakerMacros.h
Multi5x5SuperClusterProducer
Definition: Multi5x5SuperClusterProducer.cc:19
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::PtrVector< CaloCluster >
str
#define str(s)
Definition: TestProcessor.cc:53
Multi5x5SuperClusterProducer::doEndcaps_
const bool doEndcaps_
Definition: Multi5x5SuperClusterProducer.cc:39
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::Event::emplace
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&... args)
puts a new product
Definition: Event.h:433
reco::BasicClusterCollection
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
Definition: BasicClusterFwd.h:16
edm::PtrVector::push_back
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
Multi5x5SuperClusterProducer::eeClustersToken_
edm::EDGetTokenT< reco::BasicClusterCollection > eeClustersToken_
Definition: Multi5x5SuperClusterProducer.cc:27
Multi5x5SuperClusterProducer::doBarrel_
const bool doBarrel_
Definition: Multi5x5SuperClusterProducer.cc:38
Multi5x5SuperClusterProducer::endcapPhiSearchRoad_
const float endcapPhiSearchRoad_
Definition: Multi5x5SuperClusterProducer.cc:35
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
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Multi5x5SuperClusterProducer::endStream
void endStream() override
Definition: Multi5x5SuperClusterProducer.cc:97
edm::Ptr< CaloCluster >
Multi5x5SuperClusterProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: Multi5x5SuperClusterProducer.cc:110
Multi5x5SuperClusterProducer::noSuperClusters
int noSuperClusters
Definition: Multi5x5SuperClusterProducer.cc:44
eostools.move
def move(src, dest)
Definition: eostools.py:511
SuperClusterFwd.h
Multi5x5SuperClusterProducer::bremAlgo_p
std::unique_ptr< Multi5x5BremRecoveryClusterAlgo > bremAlgo_p
Definition: Multi5x5SuperClusterProducer.cc:41
SuperCluster.h
hybridSuperClusters_cfi.superclusterCollection
superclusterCollection
Definition: hybridSuperClusters_cfi.py:31
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
Multi5x5SuperClusterProducer::barrelPhiSearchRoad_
const float barrelPhiSearchRoad_
Definition: Multi5x5SuperClusterProducer.cc:33
ParameterSet.h
Multi5x5SuperClusterProducer::produceSuperclustersForECALPart
void produceSuperclustersForECALPart(edm::Event &evt, const edm::EDGetTokenT< reco::BasicClusterCollection > &clustersToken, const edm::EDPutTokenT< reco::SuperClusterCollection > &putToken)
Definition: Multi5x5SuperClusterProducer.cc:118
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
edm::PtrVectorBase::reserve
void reserve(size_type n)
Reserve space for RefVector.
Definition: PtrVectorBase.h:93