Go to the documentation of this file.00001 #include <memory>
00002 #include "RecoParticleFlow/PFTracking/interface/LightPFTrackProducer.h"
00003 #include "RecoParticleFlow/PFTracking/interface/PFTrackTransformer.h"
00004 #include "DataFormats/ParticleFlowReco/interface/PFRecTrack.h"
00005 #include "DataFormats/ParticleFlowReco/interface/PFRecTrackFwd.h"
00006 #include "DataFormats/TrackReco/interface/Track.h"
00007 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00008 #include "TrackingTools/PatternTools/interface/Trajectory.h"
00009 #include "FWCore/Framework/interface/ESHandle.h"
00010 #include "MagneticField/Engine/interface/MagneticField.h"
00011 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00012
00013 using namespace std;
00014 using namespace edm;
00015 LightPFTrackProducer::LightPFTrackProducer(const ParameterSet& iConfig):
00016 pfTransformer_(0)
00017 {
00018 produces<reco::PFRecTrackCollection>();
00019
00020 tracksContainers_ =
00021 iConfig.getParameter< vector < InputTag > >("TkColList");
00022
00023
00024 useQuality_ = iConfig.getParameter<bool>("UseQuality");
00025 trackQuality_=reco::TrackBase::qualityByName(iConfig.getParameter<std::string>("TrackQuality"));
00026
00027 }
00028
00029 LightPFTrackProducer::~LightPFTrackProducer()
00030 {
00031 delete pfTransformer_;
00032 }
00033
00034 void
00035 LightPFTrackProducer::produce(Event& iEvent, const EventSetup& iSetup)
00036 {
00037
00038
00039 auto_ptr< reco::PFRecTrackCollection >
00040 PfTrColl (new reco::PFRecTrackCollection);
00041
00042 for (unsigned int istr=0; istr<tracksContainers_.size();istr++){
00043
00044
00045 Handle<reco::TrackCollection> tkRefCollection;
00046 iEvent.getByLabel(tracksContainers_[istr], tkRefCollection);
00047 reco::TrackCollection Tk=*(tkRefCollection.product());
00048 for(unsigned int i=0;i<Tk.size();i++){
00049 if (useQuality_ &&
00050 (!(Tk[i].quality(trackQuality_)))) continue;
00051 reco::TrackRef trackRef(tkRefCollection, i);
00052 reco::PFRecTrack pftrack( trackRef->charge(),
00053 reco::PFRecTrack::KF,
00054 i, trackRef );
00055 Trajectory FakeTraj;
00056 bool mymsgwarning = false;
00057 bool valid = pfTransformer_->addPoints( pftrack, *trackRef, FakeTraj, mymsgwarning);
00058 if(valid)
00059 PfTrColl->push_back(pftrack);
00060
00061 }
00062 }
00063 iEvent.put(PfTrColl);
00064 }
00065
00066
00067 void
00068 LightPFTrackProducer::beginRun(edm::Run& run,
00069 const EventSetup& iSetup)
00070 {
00071 ESHandle<MagneticField> magneticField;
00072 iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
00073 pfTransformer_= new PFTrackTransformer(math::XYZVector(magneticField->inTesla(GlobalPoint(0,0,0))));
00074 pfTransformer_->OnlyProp();
00075 }
00076
00077
00078 void
00079 LightPFTrackProducer::endRun() {
00080 delete pfTransformer_;
00081 }