Imperial Analysis
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ICSuperClusterProducer.cc
Go to the documentation of this file.
2 #include <memory>
3 #include <string>
4 #include <vector>
5 #include "FWCore/Framework/interface/Event.h"
6 #include "FWCore/Framework/interface/EventSetup.h"
7 #include "FWCore/Framework/interface/MakerMacros.h"
8 #include "FWCore/ParameterSet/interface/ParameterSet.h"
9 #include "FWCore/Utilities/interface/InputTag.h"
10 #include "DataFormats/Common/interface/Handle.h"
11 #include "DataFormats/Common/interface/View.h"
12 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
18 
19 ICSuperClusterProducer::ICSuperClusterProducer(const edm::ParameterSet& config)
20  : input_barrel_(config.getParameter<edm::InputTag>("inputBarrel")),
21  input_endcap_(config.getParameter<edm::InputTag>("inputEndcap")),
22  branch_(config.getParameter<std::string>("branch")) {
23  consumes<edm::View<reco::SuperCluster>>(input_barrel_);
24  consumes<edm::View<reco::SuperCluster>>(input_endcap_);
25  scs_ = new std::vector<ic::SuperCluster>();
26  PrintHeaderWithBranch(config, branch_);
27 }
28 
30 
31 void ICSuperClusterProducer::produce(edm::Event& event,
32  const edm::EventSetup& setup) {
33  edm::Handle<edm::View<reco::SuperCluster> > sc_b_handle;
34  edm::Handle<edm::View<reco::SuperCluster> > sc_e_handle;
35 
36  event.getByLabel(input_barrel_, sc_b_handle);
37  event.getByLabel(input_endcap_, sc_e_handle);
38 
39  scs_->clear();
40  scs_->resize(sc_b_handle->size() + sc_e_handle->size());
41 
42  for (unsigned i = 0; i < sc_b_handle->size(); ++i) {
43  reco::SuperCluster const& src = sc_b_handle->at(i);
44  ic::SuperCluster& dest = scs_->at(i);
45  dest.set_vx(src.x());
46  dest.set_vy(src.y());
47  dest.set_vz(src.z());
48  dest.set_energy(src.energy());
49  dest.set_raw_energy(src.rawEnergy());
50  dest.set_is_barrel(true);
51  dest.set_id(sc_hasher_(&src));
52  }
53 
54  for (unsigned i = 0; i < sc_e_handle->size(); ++i) {
55  reco::SuperCluster const& src = sc_e_handle->at(i);
56  ic::SuperCluster& dest = scs_->at(i + sc_b_handle->size());
57  dest.set_vx(src.x());
58  dest.set_vy(src.y());
59  dest.set_vz(src.z());
60  dest.set_energy(src.energy());
61  dest.set_raw_energy(src.rawEnergy());
62  dest.set_is_barrel(false);
63  dest.set_id(sc_hasher_(&src));
64  }
65 }
66 
67 void ICSuperClusterProducer::beginJob() {
68  ic::StaticTree::tree_->Branch(branch_.c_str(), &scs_);
69 }
70 
71 void ICSuperClusterProducer::endJob() {}
72 
73 // define this as a plug-in
void set_raw_energy(double const &raw_energy)
Raw supercluster energy.
Definition: SuperCluster.hh:89
Produces an ic::SuperCluster collection from the separate barrel and endcap collections, which must be compatible with an edm::View
void set_vy(double const &y)
The supercluster y-coordinate.
Definition: SuperCluster.hh:77
void set_is_barrel(bool const &is_barrel)
True if the supercluster is in the EB, false otherwise.
Definition: SuperCluster.hh:94
void set_energy(double const &energy)
Corrected supercluster energy.
Definition: SuperCluster.hh:86
void PrintHeaderWithBranch(edm::ParameterSet const &config, std::string branch)
ICSuperClusterProducer(const edm::ParameterSet &)
static TTree * tree_
Definition: StaticTree.hh:13
void set_vx(double const &x)
The supercluster x-coordinate.
Definition: SuperCluster.hh:74
See documentation here.
Definition: SuperCluster.hh:17
DEFINE_FWK_MODULE(ICSuperClusterProducer)
Definition: Consumes.h:19
void set_vz(double const &z)
The supercluster z-coordinate.
Definition: SuperCluster.hh:80
void set_id(std::size_t const &id)
Unique identifier.
Definition: SuperCluster.hh:83