CMS 3D CMS Logo

HiSuperClusterProducer.cc
Go to the documentation of this file.
14 
15 #include <iostream>
16 #include <memory>
17 #include <sstream>
18 #include <vector>
19 
21 public:
23 
24  void produce(edm::Event&, const edm::EventSetup&) override;
25  virtual void endJob();
26 
27 private:
30 
33 
34  const float barrelEtaSearchRoad_;
35  const float barrelPhiSearchRoad_;
36  const float endcapEtaSearchRoad_;
37  const float endcapPhiSearchRoad_;
41 
42  const bool doBarrel_;
43  const bool doEndcaps_;
44 
45  std::unique_ptr<HiBremRecoveryClusterAlgo> bremAlgo_p;
46 
47  double totalE = 0.0;
48  int noSuperClusters = 0;
49 
53 
57 
59 };
60 
61 //define this as a plug-in
64 
66  : endcapSuperclusterPut_{produces<reco::SuperClusterCollection>(
67  ps.getParameter<std::string>("endcapSuperclusterCollection"))},
68  barrelSuperclusterPut_{
69  produces<reco::SuperClusterCollection>(ps.getParameter<std::string>("barrelSuperclusterCollection"))},
70  eeClustersToken_{consumes<reco::BasicClusterCollection>(
71  edm::InputTag(ps.getParameter<std::string>("endcapClusterProducer"),
72  ps.getParameter<std::string>("endcapClusterCollection")))},
73  ebClustersToken_{consumes<reco::BasicClusterCollection>(
74  edm::InputTag(ps.getParameter<std::string>("barrelClusterProducer"),
75  ps.getParameter<std::string>("barrelClusterCollection")))},
76  barrelEtaSearchRoad_{float(ps.getParameter<double>("barrelEtaSearchRoad"))},
77  barrelPhiSearchRoad_{float(ps.getParameter<double>("barrelPhiSearchRoad"))},
78  endcapEtaSearchRoad_{float(ps.getParameter<double>("endcapEtaSearchRoad"))},
79  endcapPhiSearchRoad_{float(ps.getParameter<double>("endcapPhiSearchRoad"))},
80  seedTransverseEnergyThreshold_{float(ps.getParameter<double>("seedTransverseEnergyThreshold"))},
81  barrelBCEnergyThreshold_{float(ps.getParameter<double>("barrelBCEnergyThreshold"))},
82  endcapBCEnergyThreshold_{float(ps.getParameter<double>("endcapBCEnergyThreshold"))},
83  doBarrel_{ps.getParameter<bool>("doBarrel")},
84  doEndcaps_{ps.getParameter<bool>("doEndcaps")}
85 
86 {
87  // The verbosity level
89  std::string verbosityString = ps.getParameter<std::string>("VerbosityLevel");
90  if (verbosityString == "DEBUG")
92  else if (verbosityString == "WARNING")
94  else if (verbosityString == "INFO")
96  else
98 
99  if (verbosityString == "INFO") {
100  std::cout << "Barrel BC Energy threshold = " << barrelBCEnergyThreshold_ << std::endl;
101  std::cout << "Endcap BC Energy threshold = " << endcapBCEnergyThreshold_ << std::endl;
102  }
103 
104  bremAlgo_p = std::make_unique<HiBremRecoveryClusterAlgo>(barrelEtaSearchRoad_,
105  barrelPhiSearchRoad_,
106  endcapEtaSearchRoad_,
107  endcapPhiSearchRoad_,
108  seedTransverseEnergyThreshold_,
109  barrelBCEnergyThreshold_,
110  endcapBCEnergyThreshold_,
111  verbosity);
112 }
113 
115  double averEnergy = 0.;
116  std::ostringstream str;
117  str << "HiSuperClusterProducer::endJob()\n"
118  << " total # reconstructed super clusters: " << noSuperClusters << "\n"
119  << " total energy of all clusters: " << totalE << "\n";
120  if (noSuperClusters > 0) {
121  averEnergy = totalE / noSuperClusters;
122  str << " average SuperCluster energy = " << averEnergy << "\n";
123  }
124  edm::LogInfo("HiSuperClusterProducerInfo") << str.str() << "\n";
125 }
126 
128  if (doEndcaps_)
130 
131  if (doBarrel_)
133 }
134 
136  edm::Event& evt,
139  // get the cluster collection out and turn it to a BasicClusterRefVector:
140  reco::CaloClusterPtrVector clusterPtrVector_p{};
141  getClusterPtrVector(evt, clustersToken, &clusterPtrVector_p);
142 
143  // run the brem recovery and get the SC collection
144  reco::SuperClusterCollection superclusters_ap = bremAlgo_p->makeSuperClusters(clusterPtrVector_p);
145 
146  // count the total energy and the number of superclusters
147  for (auto const& cluster : superclusters_ap) {
148  totalE += cluster.energy();
149  noSuperClusters++;
150  }
151 
152  // put the SC collection in the event
153  evt.emplace(putToken, std::move(superclusters_ap));
154 }
155 
158  reco::CaloClusterPtrVector* clusterPtrVector_p) {
159  edm::Handle<reco::BasicClusterCollection> bccHandle = evt.getHandle(clustersToken);
160 
161  if (!(bccHandle.isValid())) {
162  edm::LogError("HiSuperClusterProducerError") << "could not get a handle on the BasicCluster Collection!";
163  clusterPtrVector_p = nullptr;
164  }
165 
166  const reco::BasicClusterCollection* clusterCollection_p = bccHandle.product();
167  for (unsigned int i = 0; i < clusterCollection_p->size(); i++) {
168  clusterPtrVector_p->push_back(reco::CaloClusterPtr(bccHandle, i));
169  }
170 }
std::unique_ptr< HiBremRecoveryClusterAlgo > bremAlgo_p
void produceSuperclustersForECALPart(edm::Event &evt, const edm::EDGetTokenT< reco::BasicClusterCollection > &clustersToken, edm::EDPutTokenT< reco::SuperClusterCollection > const &putToken)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDPutTokenT< reco::SuperClusterCollection > endcapSuperclusterPut_
void produce(edm::Event &, const edm::EventSetup &) override
const edm::EDGetTokenT< reco::BasicClusterCollection > ebClustersToken_
void outputValidationInfo(reco::SuperClusterCollection &superclusterCollection)
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
T const * product() const
Definition: Handle.h:70
Log< level::Error, false > LogError
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
void getClusterPtrVector(edm::Event &evt, const edm::EDGetTokenT< reco::BasicClusterCollection > &clustersToken, reco::CaloClusterPtrVector *)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HiSuperClusterProducer(const edm::ParameterSet &ps)
const edm::EDGetTokenT< reco::BasicClusterCollection > eeClustersToken_
Log< level::Info, false > LogInfo
const edm::EDPutTokenT< reco::SuperClusterCollection > barrelSuperclusterPut_
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&... args)
puts a new product
Definition: Event.h:433
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
bool isValid() const
Definition: HandleBase.h:70
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:563
#define str(s)
def move(src, dest)
Definition: eostools.py:511