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,
44  barrelEtaSearchRoad_,
45  barrelPhiSearchRoad_,
46  endcapEtaSearchRoad_,
47  endcapPhiSearchRoad_,
49  seedTransverseEnergyThreshold_);
50 
51  if (doEndcaps_) {
52  endcapPutToken_ =
53  produces<reco::SuperClusterCollection>(ps.getParameter<std::string>("endcapSuperclusterCollection"));
54  }
55  if (doBarrel_) {
56  barrelPutToken_ =
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 }
Multi5x5SuperClusterProducer::ebClustersToken_
edm::EDGetTokenT< reco::BasicClusterCollection > ebClustersToken_
Definition: Multi5x5SuperClusterProducer.h:27
Handle.h
Multi5x5SuperClusterProducer::Multi5x5SuperClusterProducer
Multi5x5SuperClusterProducer(const edm::ParameterSet &ps)
Definition: Multi5x5SuperClusterProducer.cc:23
mps_fire.i
i
Definition: mps_fire.py:428
Multi5x5SuperClusterProducer::endcapPutToken_
edm::EDPutTokenT< reco::SuperClusterCollection > endcapPutToken_
Definition: Multi5x5SuperClusterProducer.h:28
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
BasicCluster.h
Multi5x5SuperClusterProducer::totalE
double totalE
Definition: Multi5x5SuperClusterProducer.h:42
Multi5x5SuperClusterProducer::barrelPutToken_
edm::EDPutTokenT< reco::SuperClusterCollection > barrelPutToken_
Definition: Multi5x5SuperClusterProducer.h:29
edm::EDGetTokenT< reco::BasicClusterCollection >
Multi5x5SuperClusterProducer::getClusterPtrVector
reco::CaloClusterPtrVector getClusterPtrVector(edm::Event &evt, const edm::EDGetTokenT< reco::BasicClusterCollection > &clustersToken) const
Definition: Multi5x5SuperClusterProducer.cc:102
edm::EDPutTokenT< reco::SuperClusterCollection >
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
reco::SuperClusterCollection
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Definition: SuperClusterFwd.h:9
edm::PtrVector< CaloCluster >
str
#define str(s)
Definition: TestProcessor.cc:51
Multi5x5SuperClusterProducer::doEndcaps_
const bool doEndcaps_
Definition: Multi5x5SuperClusterProducer.h:38
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
edm::Event::emplace
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&... args)
puts a new product
Definition: Event.h:425
reco::BasicClusterCollection
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
Definition: BasicClusterFwd.h:16
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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.h:26
Multi5x5SuperClusterProducer::doBarrel_
const bool doBarrel_
Definition: Multi5x5SuperClusterProducer.h:37
cosmicSuperClusters_cfi.dynamicPhiRoad
dynamicPhiRoad
Definition: cosmicSuperClusters_cfi.py:25
edm::EventSetup
Definition: EventSetup.h:57
cosmicSuperClusters_cfi.bremRecoveryPset
bremRecoveryPset
Definition: cosmicSuperClusters_cfi.py:26
Multi5x5SuperClusterProducer::endStream
void endStream() override
Definition: Multi5x5SuperClusterProducer.cc:61
edm::Ptr< CaloCluster >
Multi5x5SuperClusterProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: Multi5x5SuperClusterProducer.cc:74
Multi5x5SuperClusterProducer::noSuperClusters
int noSuperClusters
Definition: Multi5x5SuperClusterProducer.h:43
eostools.move
def move(src, dest)
Definition: eostools.py:511
SuperClusterFwd.h
Multi5x5SuperClusterProducer::bremAlgo_p
std::unique_ptr< Multi5x5BremRecoveryClusterAlgo > bremAlgo_p
Definition: Multi5x5SuperClusterProducer.h:40
SuperCluster.h
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
Multi5x5SuperClusterProducer.h
Multi5x5SuperClusterProducer::produceSuperclustersForECALPart
void produceSuperclustersForECALPart(edm::Event &evt, const edm::EDGetTokenT< reco::BasicClusterCollection > &clustersToken, const edm::EDPutTokenT< reco::SuperClusterCollection > &putToken)
Definition: Multi5x5SuperClusterProducer.cc:82
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