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
0008
0009
0010
0011
0012
0013
0014
0015
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
0028
0029
0030
0031 void CastorJetIDProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0032
0033 edm::Handle<edm::View<reco::BasicJet> > h_jets;
0034 iEvent.getByToken(input_jet_token_, h_jets);
0035
0036
0037 auto castorjetIdValueMap = std::make_unique<reco::CastorJetIDValueMap>();
0038
0039 reco::CastorJetIDValueMap::Filler filler(*castorjetIdValueMap);
0040
0041
0042 size_t njets = h_jets->size();
0043 std::vector<reco::CastorJetID> ids(njets);
0044
0045
0046 for (edm::View<reco::BasicJet>::const_iterator jetsBegin = h_jets->begin(), jetsEnd = h_jets->end(), ijet = jetsBegin;
0047 ijet != jetsEnd;
0048 ++ijet) {
0049
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
0063 filler.insert(h_jets, ids.begin(), ids.end());
0064
0065
0066 filler.fill();
0067
0068
0069 iEvent.put(std::move(castorjetIdValueMap));
0070 }
0071
0072
0073 DEFINE_FWK_MODULE(CastorJetIDProducer);