CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorJetIDProducer.cc
Go to the documentation of this file.
3 
4 #include <vector>
5 
6 //
7 // constants, enums and typedefs
8 //
9 
10 
11 //
12 // static data member definitions
13 //
14 
15 //
16 // constructors and destructor
17 //
19  src_ ( iConfig.getParameter<edm::InputTag>("src") ),
20  helper_ ( )
21 {
22  produces< reco::CastorJetIDValueMap >();
23 
24  input_jet_token_ = consumes<edm::View<reco::BasicJet> >(src_);
25 
26 }
27 
28 
30 {
31 }
32 
33 
34 //
35 // member functions
36 //
37 
38 // ------------ method called to produce the data ------------
39 void
41 {
42 
43  // get the input jets
45  iEvent.getByToken( input_jet_token_, h_jets );
46 
47  // allocate the jet--->jetid value map
48  std::auto_ptr<reco::CastorJetIDValueMap> castorjetIdValueMap( new reco::CastorJetIDValueMap );
49  // instantiate the filler with the map
50  reco::CastorJetIDValueMap::Filler filler(*castorjetIdValueMap);
51 
52  // allocate the vector of ids
53  size_t njets = h_jets->size();
54  std::vector<reco::CastorJetID> ids (njets);
55 
56  // loop over the jets
57  for ( edm::View<reco::BasicJet>::const_iterator jetsBegin = h_jets->begin(),
58  jetsEnd = h_jets->end(),
59  ijet = jetsBegin;
60  ijet != jetsEnd; ++ijet ) {
61 
62  // get the id from each jet
63  helper_.calculate( iEvent, *ijet );
64 
65  ids[ijet-jetsBegin].emEnergy = helper_.emEnergy();
66  ids[ijet-jetsBegin].hadEnergy = helper_.hadEnergy();
67  ids[ijet-jetsBegin].fem = helper_.fem();
68  ids[ijet-jetsBegin].depth = helper_.depth();
69  ids[ijet-jetsBegin].width = helper_.width();
70  ids[ijet-jetsBegin].fhot = helper_.fhot();
71  ids[ijet-jetsBegin].sigmaz = helper_.sigmaz();
72  ids[ijet-jetsBegin].nTowers = helper_.nTowers();
73 
74 
75  }
76 
77  // set up the map
78  filler.insert( h_jets, ids.begin(), ids.end() );
79 
80  // fill the vals
81  filler.fill();
82 
83  // write map to the event
84  iEvent.put( castorjetIdValueMap );
85 }
86 
87 //define this as a plug-in
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
CastorJetIDProducer(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:230
void calculate(const edm::Event &event, const reco::BasicJet &jet)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
virtual void produce(edm::Event &, const edm::EventSetup &) override
reco::helper::CastorJetIDHelper helper_
edm::EDGetTokenT< edm::View< reco::BasicJet > > input_jet_token_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:85