#include <PFTrackProducer.h>
Public Member Functions | |
PFTrackProducer (const edm::ParameterSet &) | |
Constructor. | |
~PFTrackProducer () | |
Destructor. | |
Private Member Functions | |
virtual void | beginRun (edm::Run &, const edm::EventSetup &) |
virtual void | endRun () |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
Produce the PFRecTrack collection. | |
Private Attributes | |
bool | gsfinev_ |
edm::InputTag | gsfTrackLabel_ |
edm::InputTag | muonColl_ |
PFTrackTransformer * | pfTransformer_ |
PFTrackTransformer. | |
reco::TrackBase::TrackQuality | trackQuality_ |
std::vector< edm::InputTag > | tracksContainers_ |
bool | trajinev_ |
bool | useQuality_ |
TRACK QUALITY. | |
edm::InputTag | vtx_h |
Definition at line 20 of file PFTrackProducer.h.
PFTrackProducer::PFTrackProducer | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Constructor.
Definition at line 27 of file PFTrackProducer.cc.
References edm::ParameterSet::getParameter(), gsfinev_, gsfTrackLabel_, muonColl_, reco::TrackBase::qualityByName(), trackQuality_, tracksContainers_, trajinev_, useQuality_, and vtx_h.
: pfTransformer_(0) { produces<reco::PFRecTrackCollection>(); tracksContainers_ = iConfig.getParameter< vector < InputTag > >("TkColList"); useQuality_ = iConfig.getParameter<bool>("UseQuality"); gsfTrackLabel_ = iConfig.getParameter<InputTag> ("GsfTrackModuleLabel"); trackQuality_=reco::TrackBase::qualityByName(iConfig.getParameter<std::string>("TrackQuality")); muonColl_ = iConfig.getParameter< InputTag >("MuColl"); trajinev_ = iConfig.getParameter<bool>("TrajInEvents"); gsfinev_ = iConfig.getParameter<bool>("GsfTracksInEvents"); vtx_h=iConfig.getParameter<edm::InputTag>("PrimaryVertexLabel"); }
PFTrackProducer::~PFTrackProducer | ( | ) |
Destructor.
Definition at line 50 of file PFTrackProducer.cc.
References pfTransformer_.
{ delete pfTransformer_; }
void PFTrackProducer::beginRun | ( | edm::Run & | run, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 235 of file PFTrackProducer.cc.
References edm::EventSetup::get(), PFTrackTransformer::OnlyProp(), pfTransformer_, and trajinev_.
{ ESHandle<MagneticField> magneticField; iSetup.get<IdealMagneticFieldRecord>().get(magneticField); pfTransformer_= new PFTrackTransformer(math::XYZVector(magneticField->inTesla(GlobalPoint(0,0,0)))); if(!trajinev_) pfTransformer_->OnlyProp(); }
void PFTrackProducer::endRun | ( | void | ) | [private, virtual] |
Definition at line 247 of file PFTrackProducer.cc.
References pfTransformer_.
{ delete pfTransformer_; }
void PFTrackProducer::produce | ( | edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Produce the PFRecTrack collection.
Implements edm::EDProducer.
Definition at line 56 of file PFTrackProducer.cc.
References PFTrackTransformer::addPoints(), TransientTrackBuilder::build(), alignCSCRings::e, reco::PFTrajectoryPoint::ECALEntrance, newFWLiteAna::found, edm::EventSetup::get(), edm::Event::getByLabel(), gsfinev_, gsfTrackLabel_, i, edm::Ref< C, T, F >::isNonnull(), edm::Ref< C, T, F >::isNull(), reco::PFTrajectoryPoint::isValid(), edm::HandleBase::isValid(), j, reco::PFRecTrack::KF, reco::PFRecTrack::KF_ELCAND, muonColl_, AlCaHLTBitMon_ParallelJobs::p, pfTransformer_, edm::ESHandle< T >::product(), edm::Handle< T >::product(), edm::Event::put(), edm::second(), IPTools::signedTransverseImpactParameter(), trackQuality_, tracksContainers_, trajinev_, useQuality_, TrackValidation_HighPurity_cff::valid, and vtx_h.
{ //create the empty collections auto_ptr< reco::PFRecTrackCollection > PfTrColl (new reco::PFRecTrackCollection); //read track collection Handle<GsfTrackCollection> gsftrackcoll; bool foundgsf = iEvent.getByLabel(gsfTrackLabel_,gsftrackcoll); GsfTrackCollection gsftracks; //Get PV for STIP calculation, if there is none then take the dummy Handle<reco::VertexCollection> vertex; iEvent.getByLabel(vtx_h, vertex); reco::Vertex dummy; const reco::Vertex* pv=&dummy; if (vertex.isValid()) { pv = &*vertex->begin(); } else { // create a dummy PV reco::Vertex::Error e; e(0, 0) = 0.0015 * 0.0015; e(1, 1) = 0.0015 * 0.0015; e(2, 2) = 15. * 15.; reco::Vertex::Point p(0, 0, 0); dummy = reco::Vertex(p, e, 0, 0, 0); } edm::ESHandle<TransientTrackBuilder> builder; iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder); TransientTrackBuilder thebuilder = *(builder.product()); if(gsfinev_) { if(!foundgsf ) LogError("PFTrackProducer") <<" cannot get GsfTracks (probably in HI events): " << " please set GsfTracksInEvents = False in RecoParticleFlow/PFTracking/python/pfTrack_cfi.py" << endl; else gsftracks = *(gsftrackcoll.product()); } // read muon collection Handle< reco::MuonCollection > recMuons; iEvent.getByLabel(muonColl_, recMuons); for (unsigned int istr=0; istr<tracksContainers_.size();istr++){ //Track collection Handle<reco::TrackCollection> tkRefCollection; iEvent.getByLabel(tracksContainers_[istr], tkRefCollection); reco::TrackCollection Tk=*(tkRefCollection.product()); vector<Trajectory> Tj(0); if(trajinev_) { //Trajectory collection Handle<vector<Trajectory> > tjCollection; bool found = iEvent.getByLabel(tracksContainers_[istr], tjCollection); if(!found ) LogError("PFTrackProducer") <<" cannot get Trajectories of: " << tracksContainers_[istr] << " please set TrajInEvents = False in RecoParticleFlow/PFTracking/python/pfTrack_cfi.py" << endl; Tj =*(tjCollection.product()); } for(unsigned int i=0;i<Tk.size();i++){ reco::TrackRef trackRef(tkRefCollection, i); if (useQuality_ && (!(Tk[i].quality(trackQuality_)))){ bool isMuCandidate = false; //TrackRef trackRef(tkRefCollection, i); if(recMuons.isValid() ) { for(unsigned j=0;j<recMuons->size(); j++) { reco::MuonRef muonref( recMuons, j ); if (muonref->track().isNonnull()) if( muonref->track() == trackRef && muonref->isGlobalMuon()){ isMuCandidate=true; //cout<<" SAVING TRACK "<<endl; break; } } } else{ edm::LogError("MissingInput")<<"there is no valide:"<<muonColl_<<" to be used."; } if(!isMuCandidate) { continue; } } // find the pre-id kf track bool preId = false; if(foundgsf) { for (unsigned int igsf=0; igsf<gsftracks.size();igsf++) { GsfTrackRef gsfTrackRef(gsftrackcoll, igsf); if (gsfTrackRef->seedRef().isNull()) continue; ElectronSeedRef ElSeedRef= gsfTrackRef->extra()->seedRef().castTo<ElectronSeedRef>(); if (ElSeedRef->ctfTrack().isNonnull()) { if(ElSeedRef->ctfTrack() == trackRef) preId = true; } } } if(preId) { // Set PFRecTrack of type KF_ElCAND reco::PFRecTrack pftrack( trackRef->charge(), reco::PFRecTrack::KF_ELCAND, i, trackRef ); bool valid = false; if(trajinev_) { valid = pfTransformer_->addPoints( pftrack, *trackRef, Tj[i]); } else { Trajectory FakeTraj; valid = pfTransformer_->addPoints( pftrack, *trackRef, FakeTraj); } if(valid) { //calculate STIP double stip=-999; const reco::PFTrajectoryPoint& atECAL=pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance); if(atECAL.isValid()) //if track extrapolates to ECAL { GlobalVector direction(pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().x(), pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().y(), pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().z()); stip = IPTools::signedTransverseImpactParameter(thebuilder.build(*trackRef), direction, *pv).second.significance(); } pftrack.setSTIP(stip); PfTrColl->push_back(pftrack); } } else { reco::PFRecTrack pftrack( trackRef->charge(), reco::PFRecTrack::KF, i, trackRef ); bool valid = false; if(trajinev_) { valid = pfTransformer_->addPoints( pftrack, *trackRef, Tj[i]); } else { Trajectory FakeTraj; valid = pfTransformer_->addPoints( pftrack, *trackRef, FakeTraj); } if(valid) { double stip=-999; const reco::PFTrajectoryPoint& atECAL=pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance); if(atECAL.isValid()) { GlobalVector direction(pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().x(), pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().y(), pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().z()); stip = IPTools::signedTransverseImpactParameter(thebuilder.build(*trackRef), direction, *pv).second.significance(); } pftrack.setSTIP(stip); PfTrColl->push_back(pftrack); } } } } iEvent.put(PfTrColl); }
bool PFTrackProducer::gsfinev_ [private] |
Definition at line 46 of file PFTrackProducer.h.
Referenced by PFTrackProducer(), and produce().
edm::InputTag PFTrackProducer::gsfTrackLabel_ [private] |
Definition at line 39 of file PFTrackProducer.h.
Referenced by PFTrackProducer(), and produce().
edm::InputTag PFTrackProducer::muonColl_ [private] |
Definition at line 40 of file PFTrackProducer.h.
Referenced by PFTrackProducer(), and produce().
Definition at line 37 of file PFTrackProducer.h.
Referenced by beginRun(), endRun(), produce(), and ~PFTrackProducer().
Definition at line 44 of file PFTrackProducer.h.
Referenced by PFTrackProducer(), and produce().
std::vector<edm::InputTag> PFTrackProducer::tracksContainers_ [private] |
Definition at line 38 of file PFTrackProducer.h.
Referenced by PFTrackProducer(), and produce().
bool PFTrackProducer::trajinev_ [private] |
Definition at line 45 of file PFTrackProducer.h.
Referenced by beginRun(), PFTrackProducer(), and produce().
bool PFTrackProducer::useQuality_ [private] |
TRACK QUALITY.
Definition at line 43 of file PFTrackProducer.h.
Referenced by PFTrackProducer(), and produce().
edm::InputTag PFTrackProducer::vtx_h [private] |
Definition at line 41 of file PFTrackProducer.h.
Referenced by PFTrackProducer(), and produce().