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 }
edm::EDGetTokenT< reco::BasicClusterCollection > eeClustersToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void produce(edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
T const * product() const
Definition: Handle.h:70
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::unique_ptr< Multi5x5BremRecoveryClusterAlgo > bremAlgo_p
void produceSuperclustersForECALPart(edm::Event &evt, const edm::EDGetTokenT< reco::BasicClusterCollection > &clustersToken, const edm::EDPutTokenT< reco::SuperClusterCollection > &putToken)
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Multi5x5SuperClusterProducer(const edm::ParameterSet &ps)
edm::EDPutTokenT< reco::SuperClusterCollection > endcapPutToken_
edm::EDPutTokenT< reco::SuperClusterCollection > barrelPutToken_
edm::EDGetTokenT< reco::BasicClusterCollection > ebClustersToken_
reco::CaloClusterPtrVector getClusterPtrVector(edm::Event &evt, const edm::EDGetTokenT< reco::BasicClusterCollection > &clustersToken) const
Log< level::Info, false > LogInfo
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&... args)
puts a new product
Definition: Event.h:433
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
void outputValidationInfo(reco::SuperClusterCollection &superclusterCollection)
void reserve(size_type n)
Reserve space for RefVector.
Definition: PtrVectorBase.h:95
#define str(s)
def move(src, dest)
Definition: eostools.py:511