CMS 3D CMS Logo

Multi5x5SuperClusterProducer.cc
Go to the documentation of this file.
1 // C/C++ headers
2 #include <iostream>
3 #include <vector>
4 #include <memory>
5 #include <sstream>
6 
7 // Framework
13 
14 // Reconstruction Classes
16 
19 
20 // Class header file
22 
24  : barrelEtaSearchRoad_{static_cast<float>(ps.getParameter<double>("barrelEtaSearchRoad"))},
25  barrelPhiSearchRoad_{static_cast<float>(ps.getParameter<double>("barrelPhiSearchRoad"))},
26  endcapEtaSearchRoad_{static_cast<float>(ps.getParameter<double>("endcapEtaSearchRoad"))},
27  endcapPhiSearchRoad_{static_cast<float>(ps.getParameter<double>("endcapPhiSearchRoad"))},
28  seedTransverseEnergyThreshold_{static_cast<float>(ps.getParameter<double>("seedTransverseEnergyThreshold"))},
29  doBarrel_{ps.getParameter<bool>("doBarrel")},
30  doEndcaps_{ps.getParameter<bool>("doEndcaps")},
31  totalE{0.},
32  noSuperClusters{0} {
33  if (doEndcaps_) {
34  eeClustersToken_ = consumes<reco::BasicClusterCollection>(ps.getParameter<edm::InputTag>("endcapClusterTag"));
35  }
36  if (doBarrel_) {
37  ebClustersToken_ = consumes<reco::BasicClusterCollection>(ps.getParameter<edm::InputTag>("barrelClusterTag"));
38  }
39 
40  const edm::ParameterSet bremRecoveryPset = ps.getParameter<edm::ParameterSet>("bremRecoveryPset");
41  bool dynamicPhiRoad = ps.getParameter<bool>("dynamicPhiRoad");
42 
43  bremAlgo_p = std::make_unique<Multi5x5BremRecoveryClusterAlgo>(bremRecoveryPset,
50 
51  if (doEndcaps_) {
53  produces<reco::SuperClusterCollection>(ps.getParameter<std::string>("endcapSuperclusterCollection"));
54  }
55  if (doBarrel_) {
57  produces<reco::SuperClusterCollection>(ps.getParameter<std::string>("barrelSuperclusterCollection"));
58  }
59 }
60 
62  double averEnergy = 0.;
63  std::ostringstream str;
64  str << "Multi5x5SuperClusterProducer::endJob()\n"
65  << " total # reconstructed super clusters: " << noSuperClusters << "\n"
66  << " total energy of all clusters: " << totalE << "\n";
67  if (noSuperClusters > 0) {
68  averEnergy = totalE / noSuperClusters;
69  str << " average SuperCluster energy = " << averEnergy << "\n";
70  }
71  edm::LogInfo("Multi5x5SuperClusterProducerInfo") << str.str() << "\n";
72 }
73 
75  if (doEndcaps_)
77 
78  if (doBarrel_)
80 }
81 
83  edm::Event& evt,
86  // get the cluster collection out and turn it to a BasicClusterRefVector:
87  reco::CaloClusterPtrVector clusterPtrVector_p = getClusterPtrVector(evt, clustersToken);
88 
89  // run the brem recovery and get the SC collection
90  reco::SuperClusterCollection superclusters_ap(bremAlgo_p->makeSuperClusters(clusterPtrVector_p));
91 
92  // count the total energy and the number of superclusters
93  for (auto const& sc : superclusters_ap) {
94  totalE += sc.energy();
96  }
97 
98  // put the SC collection in the event
99  evt.emplace(putToken, std::move(superclusters_ap));
100 }
101 
103  edm::Event& evt, const edm::EDGetTokenT<reco::BasicClusterCollection>& clustersToken) const {
104  reco::CaloClusterPtrVector clusterPtrVector_p;
106  evt.getByToken(clustersToken, bccHandle);
107 
108  const reco::BasicClusterCollection* clusterCollection_p = bccHandle.product();
109  clusterPtrVector_p.reserve(clusterCollection_p->size());
110  for (unsigned int i = 0; i < clusterCollection_p->size(); i++) {
111  clusterPtrVector_p.push_back(reco::CaloClusterPtr(bccHandle, i));
112  }
113  return clusterPtrVector_p;
114 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::BasicClusterCollection > eeClustersToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void produce(edm::Event &, const edm::EventSetup &) override
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
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_
float energy() const
Energy. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:104
edm::EDPutTokenT< reco::SuperClusterCollection > barrelPutToken_
edm::EDGetTokenT< reco::BasicClusterCollection > ebClustersToken_
T const * product() const
Definition: Handle.h:69
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:421
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
void reserve(size_type n)
Reserve space for RefVector.
Definition: PtrVectorBase.h:93
reco::CaloClusterPtrVector getClusterPtrVector(edm::Event &evt, const edm::EDGetTokenT< reco::BasicClusterCollection > &clustersToken) const
#define str(s)
def move(src, dest)
Definition: eostools.py:511