CMS 3D CMS Logo

CastorJetIDProducer.cc
Go to the documentation of this file.
3 
4 #include <vector>
5 
6 //
7 // constants, enums and typedefs
8 //
9 
10 //
11 // static data member definitions
12 //
13 
14 //
15 // constructors and destructor
16 //
18  : src_(iConfig.getParameter<edm::InputTag>("src")), helper_() {
19  produces<reco::CastorJetIDValueMap>();
20 
21  input_jet_token_ = consumes<edm::View<reco::BasicJet> >(src_);
22 }
23 
25 
26 //
27 // member functions
28 //
29 
30 // ------------ method called to produce the data ------------
32  // get the input jets
34  iEvent.getByToken(input_jet_token_, h_jets);
35 
36  // allocate the jet--->jetid value map
37  auto castorjetIdValueMap = std::make_unique<reco::CastorJetIDValueMap>();
38  // instantiate the filler with the map
39  reco::CastorJetIDValueMap::Filler filler(*castorjetIdValueMap);
40 
41  // allocate the vector of ids
42  size_t njets = h_jets->size();
43  std::vector<reco::CastorJetID> ids(njets);
44 
45  // loop over the jets
46  for (edm::View<reco::BasicJet>::const_iterator jetsBegin = h_jets->begin(), jetsEnd = h_jets->end(), ijet = jetsBegin;
47  ijet != jetsEnd;
48  ++ijet) {
49  // get the id from each jet
50  helper_.calculate(iEvent, *ijet);
51 
52  ids[ijet - jetsBegin].emEnergy = helper_.emEnergy();
53  ids[ijet - jetsBegin].hadEnergy = helper_.hadEnergy();
54  ids[ijet - jetsBegin].fem = helper_.fem();
55  ids[ijet - jetsBegin].depth = helper_.depth();
56  ids[ijet - jetsBegin].width = helper_.width();
57  ids[ijet - jetsBegin].fhot = helper_.fhot();
58  ids[ijet - jetsBegin].sigmaz = helper_.sigmaz();
59  ids[ijet - jetsBegin].nTowers = helper_.nTowers();
60  }
61 
62  // set up the map
63  filler.insert(h_jets, ids.begin(), ids.end());
64 
65  // fill the vals
66  filler.fill();
67 
68  // write map to the event
69  iEvent.put(std::move(castorjetIdValueMap));
70 }
71 
72 //define this as a plug-in
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
CastorJetIDProducer(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:224
void calculate(const edm::Event &event, const reco::BasicJet &jet)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void produce(edm::Event &, const edm::EventSetup &) override
reco::helper::CastorJetIDHelper helper_
edm::EDGetTokenT< edm::View< reco::BasicJet > > input_jet_token_
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
def move(src, dest)
Definition: eostools.py:511