File indexing completed on 2024-04-06 12:11:22
0001 #include "FastSimulation/Tracking/plugins/ConversionTrackRefFix.h"
0002
0003 #include "DataFormats/TrackReco/interface/Track.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "DataFormats/EgammaTrackReco/interface/ConversionTrack.h"
0006
0007 using namespace std;
0008 using namespace reco;
0009 using namespace edm;
0010
0011 ConversionTrackRefFix::ConversionTrackRefFix(const edm::ParameterSet& iConfig) {
0012 InputTag conversionTracksTag = iConfig.getParameter<InputTag>("src");
0013 InputTag newTracksTag = iConfig.getParameter<InputTag>("newTrackCollection");
0014
0015 produces<ConversionTrackCollection>();
0016
0017 conversionTracksToken = consumes<ConversionTrackCollection>(conversionTracksTag);
0018 newTracksToken = consumes<TrackCollection>(newTracksTag);
0019 }
0020
0021 ConversionTrackRefFix::~ConversionTrackRefFix() {}
0022
0023 void ConversionTrackRefFix::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0024 Handle<ConversionTrackCollection> conversionTracks;
0025 iEvent.getByToken(conversionTracksToken, conversionTracks);
0026
0027 Handle<TrackCollection> newTracks;
0028 iEvent.getByToken(newTracksToken, newTracks);
0029
0030 unique_ptr<ConversionTrackCollection> output(new ConversionTrackCollection);
0031
0032 for (const ConversionTrack& conversion : *(conversionTracks.product())) {
0033 size_t trackIndex = conversion.trackRef().key();
0034 output->push_back(ConversionTrack(TrackBaseRef(TrackRef(newTracks, trackIndex))));
0035 output->back().setTrajRef(conversion.trajRef());
0036 output->back().setIsTrackerOnly(conversion.isTrackerOnly());
0037 output->back().setIsArbitratedEcalSeeded(conversion.isArbitratedEcalSeeded());
0038 output->back().setIsArbitratedMerged(conversion.isArbitratedMerged());
0039 output->back().setIsArbitratedMergedEcalGeneral(conversion.isArbitratedMergedEcalGeneral());
0040 }
0041
0042 iEvent.put(std::move(output));
0043 }
0044
0045 #include "FWCore/Framework/interface/MakerMacros.h"
0046 DEFINE_FWK_MODULE(ConversionTrackRefFix);