Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:25:31

0001 #include "RecoJets/JetProducers/plugins/CastorJetIDProducer.h"
0002 #include "DataFormats/JetReco/interface/CastorJetID.h"
0003 
0004 #include <vector>
0005 
0006 //
0007 // constants, enums and typedefs
0008 //
0009 
0010 //
0011 // static data member definitions
0012 //
0013 
0014 //
0015 // constructors and destructor
0016 //
0017 CastorJetIDProducer::CastorJetIDProducer(const edm::ParameterSet& iConfig)
0018     : src_(iConfig.getParameter<edm::InputTag>("src")), helper_() {
0019   produces<reco::CastorJetIDValueMap>();
0020 
0021   input_jet_token_ = consumes<edm::View<reco::BasicJet> >(src_);
0022 }
0023 
0024 CastorJetIDProducer::~CastorJetIDProducer() {}
0025 
0026 //
0027 // member functions
0028 //
0029 
0030 // ------------ method called to produce the data  ------------
0031 void CastorJetIDProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0032   // get the input jets
0033   edm::Handle<edm::View<reco::BasicJet> > h_jets;
0034   iEvent.getByToken(input_jet_token_, h_jets);
0035 
0036   // allocate the jet--->jetid value map
0037   auto castorjetIdValueMap = std::make_unique<reco::CastorJetIDValueMap>();
0038   // instantiate the filler with the map
0039   reco::CastorJetIDValueMap::Filler filler(*castorjetIdValueMap);
0040 
0041   // allocate the vector of ids
0042   size_t njets = h_jets->size();
0043   std::vector<reco::CastorJetID> ids(njets);
0044 
0045   // loop over the jets
0046   for (edm::View<reco::BasicJet>::const_iterator jetsBegin = h_jets->begin(), jetsEnd = h_jets->end(), ijet = jetsBegin;
0047        ijet != jetsEnd;
0048        ++ijet) {
0049     // get the id from each jet
0050     helper_.calculate(iEvent, *ijet);
0051 
0052     ids[ijet - jetsBegin].emEnergy = helper_.emEnergy();
0053     ids[ijet - jetsBegin].hadEnergy = helper_.hadEnergy();
0054     ids[ijet - jetsBegin].fem = helper_.fem();
0055     ids[ijet - jetsBegin].depth = helper_.depth();
0056     ids[ijet - jetsBegin].width = helper_.width();
0057     ids[ijet - jetsBegin].fhot = helper_.fhot();
0058     ids[ijet - jetsBegin].sigmaz = helper_.sigmaz();
0059     ids[ijet - jetsBegin].nTowers = helper_.nTowers();
0060   }
0061 
0062   // set up the map
0063   filler.insert(h_jets, ids.begin(), ids.end());
0064 
0065   // fill the vals
0066   filler.fill();
0067 
0068   // write map to the event
0069   iEvent.put(std::move(castorjetIdValueMap));
0070 }
0071 
0072 //define this as a plug-in
0073 DEFINE_FWK_MODULE(CastorJetIDProducer);