CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

PFConversionProducer Class Reference

#include <PFConversionProducer.h>

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

List of all members.

Public Member Functions

 PFConversionProducer (const edm::ParameterSet &)
 Constructor.
 ~PFConversionProducer ()
 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

edm::InputTag pfConversionContainer_
edm::InputTag pfTrackContainer_
PFTrackTransformerpfTransformer_
 PFTrackTransformer.

Detailed Description

Definition at line 11 of file PFConversionProducer.h.


Constructor & Destructor Documentation

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

Constructor.

Definition at line 14 of file PFConversionProducer.cc.

References edm::ParameterSet::getParameter(), and pfConversionContainer_.

                                                                     :
  pfTransformer_(0)
{
  produces<reco::PFRecTrackCollection>();
  produces<reco::PFConversionCollection>();

  pfConversionContainer_ = 
    iConfig.getParameter< InputTag >("conversionCollection");

}
PFConversionProducer::~PFConversionProducer ( )

Destructor.

Definition at line 25 of file PFConversionProducer.cc.

References pfTransformer_.

{
  delete pfTransformer_;
}

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 94 of file PFConversionProducer.cc.

References edm::EventSetup::get(), PFTrackTransformer::OnlyProp(), and pfTransformer_.

{
  ESHandle<MagneticField> magneticField;
  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
  pfTransformer_= new PFTrackTransformer(math::XYZVector(magneticField->inTesla(GlobalPoint(0,0,0))));
  pfTransformer_->OnlyProp();
}
void PFConversionProducer::endRun ( void  ) [private, virtual]

Definition at line 105 of file PFConversionProducer.cc.

References pfTransformer_.

                             {
  delete pfTransformer_;
}
void PFConversionProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Produce the PFRecTrack collection.

Implements edm::EDProducer.

Definition at line 31 of file PFConversionProducer.cc.

References PFTrackTransformer::addPoints(), reco::Conversion::generalTracksOnly, edm::Event::getByLabel(), edm::Event::getRefBeforePut(), icoll, edm::Ref< C, T, F >::key(), reco::PFRecTrack::KF, pfConversionContainer_, pfTrackContainer_, pfTransformer_, edm::Event::put(), and TrackValidation_HighPurity_cff::valid.

{

  //create the empty collections 
  auto_ptr< reco::PFConversionCollection > 
    pfConversionColl (new reco::PFConversionCollection);
  auto_ptr< reco::PFRecTrackCollection > 
    pfRecTrackColl (new reco::PFRecTrackCollection);
  
  reco::PFRecTrackRefProd pfTrackRefProd = iEvent.getRefBeforePut<reco::PFRecTrackCollection>();


    
  Handle<reco::ConversionCollection> convCollH;
  iEvent.getByLabel(pfConversionContainer_, convCollH);
  const reco::ConversionCollection& convColl = *(convCollH.product());

  Handle<reco::TrackCollection> trackColl;
  iEvent.getByLabel(pfTrackContainer_, trackColl);

  int idx = 0;

  //  cout << "Size of Displaced Vertices " 
  //     <<  convColl.size() << endl;

  // loop on all NuclearInteraction 
  for( unsigned int icoll=0; icoll < convColl.size(); icoll++) {
    if ( !convColl[icoll].quality(reco::Conversion::generalTracksOnly) ) continue;
    std::vector<reco::PFRecTrackRef> pfRecTkcoll;

    std::vector<edm::RefToBase<reco::Track> > tracksRefColl = convColl[icoll].tracks();

    // convert the secondary tracks
    for(unsigned it = 0; it < tracksRefColl.size(); it++){

      reco::TrackRef trackRef = (tracksRefColl[it]).castTo<reco::TrackRef>();

      reco::PFRecTrack pfRecTrack( trackRef->charge(), 
                                   reco::PFRecTrack::KF, 
                                   trackRef.key(), 
                                   trackRef );

      // cout << pfRecTrack << endl;

      Trajectory FakeTraj;
      bool valid = pfTransformer_->addPoints( pfRecTrack, *trackRef, FakeTraj);
      if(valid) {
        pfRecTkcoll.push_back(reco::PFRecTrackRef( pfTrackRefProd, idx++));     
        pfRecTrackColl->push_back(pfRecTrack);
        //      cout << "after "<< pfRecTrack << endl;
          
      }
    }
    reco::ConversionRef niRef(convCollH, icoll);
    pfConversionColl->push_back( reco::PFConversion( niRef, pfRecTkcoll ));
  }
 
  iEvent.put(pfRecTrackColl);
  iEvent.put(pfConversionColl);
}

Member Data Documentation

Definition at line 29 of file PFConversionProducer.h.

Referenced by PFConversionProducer(), and produce().

Definition at line 30 of file PFConversionProducer.h.

Referenced by produce().