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 
25 
27 {
28 }
29 
30 
31 //
32 // member functions
33 //
34 
35 // ------------ method called to produce the data ------------
36 void
38 {
39 
40  // get the input jets
42  iEvent.getByLabel( src_, h_jets );
43 
44  // allocate the jet--->jetid value map
45  std::auto_ptr<reco::CastorJetIDValueMap> castorjetIdValueMap( new reco::CastorJetIDValueMap );
46  // instantiate the filler with the map
47  reco::CastorJetIDValueMap::Filler filler(*castorjetIdValueMap);
48 
49  // allocate the vector of ids
50  size_t njets = h_jets->size();
51  std::vector<reco::CastorJetID> ids (njets);
52 
53  // loop over the jets
54  for ( edm::View<reco::BasicJet>::const_iterator jetsBegin = h_jets->begin(),
55  jetsEnd = h_jets->end(),
56  ijet = jetsBegin;
57  ijet != jetsEnd; ++ijet ) {
58 
59  // get the id from each jet
60  helper_.calculate( iEvent, *ijet );
61 
62  ids[ijet-jetsBegin].emEnergy = helper_.emEnergy();
63  ids[ijet-jetsBegin].hadEnergy = helper_.hadEnergy();
64  ids[ijet-jetsBegin].fem = helper_.fem();
65  ids[ijet-jetsBegin].depth = helper_.depth();
66  ids[ijet-jetsBegin].width = helper_.width();
67  ids[ijet-jetsBegin].fhot = helper_.fhot();
68  ids[ijet-jetsBegin].sigmaz = helper_.sigmaz();
69  ids[ijet-jetsBegin].nTowers = helper_.nTowers();
70 
71 
72  }
73 
74  // set up the map
75  filler.insert( h_jets, ids.begin(), ids.end() );
76 
77  // fill the vals
78  filler.fill();
79 
80  // write map to the event
81  iEvent.put( castorjetIdValueMap );
82 }
83 
84 // ------------ method called once each job just before starting event loop ------------
85 void
87 {
88 }
89 
90 // ------------ method called once each job just after ending the event loop ------------
91 void
93 }
94 
95 //define this as a plug-in
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
virtual void produce(edm::Event &, const edm::EventSetup &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
CastorJetIDProducer(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:243
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:85
reco::helper::CastorJetIDHelper helper_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356