CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

PFTrackProducer Class Reference

#include <PFTrackProducer.h>

Inheritance diagram for PFTrackProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

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_
PFTrackTransformerpfTransformer_
 PFTrackTransformer.
reco::TrackBase::TrackQuality trackQuality_
std::vector< edm::InputTagtracksContainers_
bool trajinev_
bool useQuality_
 TRACK QUALITY.

Detailed Description

Definition at line 20 of file PFTrackProducer.h.


Constructor & Destructor Documentation

PFTrackProducer::PFTrackProducer ( const edm::ParameterSet iConfig) [explicit]

Constructor.

Definition at line 23 of file PFTrackProducer.cc.

References edm::ParameterSet::getParameter(), gsfinev_, gsfTrackLabel_, muonColl_, reco::TrackBase::qualityByName(), trackQuality_, tracksContainers_, trajinev_, and useQuality_.

                                                           :
  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");

}
PFTrackProducer::~PFTrackProducer ( )

Destructor.

Definition at line 46 of file PFTrackProducer.cc.

References pfTransformer_.

{
  delete pfTransformer_;
}

Member Function Documentation

void PFTrackProducer::beginRun ( edm::Run run,
const edm::EventSetup iSetup 
) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 184 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 196 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 52 of file PFTrackProducer.cc.

References PFTrackTransformer::addPoints(), newFWLiteAna::found, edm::Event::getByLabel(), gsfinev_, gsfTrackLabel_, i, edm::Ref< C, T, F >::isNonnull(), edm::Ref< C, T, F >::isNull(), edm::HandleBase::isValid(), j, reco::PFRecTrack::KF, reco::PFRecTrack::KF_ELCAND, muonColl_, pfTransformer_, edm::Handle< T >::product(), edm::Event::put(), trackQuality_, tracksContainers_, trajinev_, useQuality_, and TrackValidation_HighPurity_cff::valid.

{

  //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;
  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;
              }
          }
        }

        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) {
          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) {
          PfTrColl->push_back(pftrack);
        }
      }
    }
  }
  iEvent.put(PfTrColl);
}

Member Data Documentation

bool PFTrackProducer::gsfinev_ [private]

Definition at line 46 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

Definition at line 39 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

Definition at line 40 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

PFTrackTransformer.

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().

Definition at line 38 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

Definition at line 45 of file PFTrackProducer.h.

Referenced by beginRun(), PFTrackProducer(), and produce().

TRACK QUALITY.

Definition at line 43 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().