CMS 3D CMS Logo

Public Member Functions | Private Attributes

ConversionTrackProducer Class Reference

#include <ConversionTrackProducer.h>

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

List of all members.

Public Member Functions

 ConversionTrackProducer (const edm::ParameterSet &conf)
virtual void produce (edm::Event &e, const edm::EventSetup &c)
virtual ~ConversionTrackProducer ()

Private Attributes

edm::InputTag beamSpotInputTag
edm::ParameterSet conf_
IdealHelixParameters ConvTrackPreSelector
bool filterOnConvTrackHyp
double minConvRadius
std::auto_ptr
< reco::ConversionTrackCollection
outputTrks
bool setArbitratedEcalSeeded
bool setArbitratedMerged
bool setArbitratedMergedEcalGeneral
bool setTrackerOnly
std::string trackProducer
bool useTrajectory

Detailed Description

Definition at line 40 of file ConversionTrackProducer.h.


Constructor & Destructor Documentation

ConversionTrackProducer::ConversionTrackProducer ( const edm::ParameterSet conf) [explicit]

Definition at line 39 of file ConversionTrackProducer.cc.

                                                                            : 
  conf_(conf),
  trackProducer ( conf.getParameter<std::string>("TrackProducer") ),
  useTrajectory ( conf.getParameter<bool>("useTrajectory") ),
  setTrackerOnly ( conf.getParameter<bool>("setTrackerOnly") ),
  setArbitratedEcalSeeded ( conf.getParameter<bool>("setArbitratedEcalSeeded") ),    
  setArbitratedMerged ( conf.getParameter<bool>("setArbitratedMerged") ),
  setArbitratedMergedEcalGeneral ( conf.getParameter<bool>("setArbitratedMergedEcalGeneral") ),
  beamSpotInputTag (  conf.getParameter<edm::InputTag>("beamSpotInputTag") ),
  filterOnConvTrackHyp( conf.getParameter<bool>("filterOnConvTrackHyp") ),
  minConvRadius( conf.getParameter<double>("minConvRadius") )
{

  produces<reco::ConversionTrackCollection>();
  
}
ConversionTrackProducer::~ConversionTrackProducer ( ) [virtual]

Definition at line 58 of file ConversionTrackProducer.cc.

{ }  

Member Function Documentation

void ConversionTrackProducer::produce ( edm::Event e,
const edm::EventSetup c 
) [virtual]

Implements edm::EDProducer.

Definition at line 61 of file ConversionTrackProducer.cc.

References beamSpotInputTag, ConvTrackPreSelector, filterOnConvTrackHyp, edm::EventSetup::get(), edm::Event::getByLabel(), IdealHelixParameters::isTangentPointDistanceLessThan(), minConvRadius, outputTrks, edm::ESHandle< T >::product(), edm::Event::put(), setArbitratedEcalSeeded, setArbitratedMerged, setArbitratedMergedEcalGeneral, reco::ConversionTrack::setIsArbitratedEcalSeeded(), reco::ConversionTrack::setIsArbitratedMerged(), reco::ConversionTrack::setIsArbitratedMergedEcalGeneral(), reco::ConversionTrack::setIsTrackerOnly(), IdealHelixParameters::setMagnField(), setTrackerOnly, reco::ConversionTrack::setTrajRef(), trackProducer, and useTrajectory.

  {
    //get input collection (through edm::View)
    edm::Handle<edm::View<reco::Track> > hTrks;
    e.getByLabel(trackProducer, hTrks);

    //get association maps between trajectories and tracks and build temporary maps
    edm::Handle< TrajTrackAssociationCollection > hTTAss;
    edm::Handle< edm::AssociationMap<edm::OneToOne<std::vector<Trajectory>,
                                          reco::GsfTrackCollection,unsigned short> > > hTTAssGsf;    
                                          
    std::map<reco::TrackRef,edm::Ref<std::vector<Trajectory> > > tracktrajmap;
    std::map<reco::GsfTrackRef,edm::Ref<std::vector<Trajectory> > > gsftracktrajmap;
                                          
    if (useTrajectory) {
      if (hTrks->size()>0) {
        if (dynamic_cast<const reco::GsfTrack*>(&hTrks->at(0))) {
          //fill map for gsf tracks
          e.getByLabel(trackProducer, hTTAssGsf);     
          for ( edm::AssociationMap<edm::OneToOne<std::vector<Trajectory>,
                    reco::GsfTrackCollection,unsigned short> >::const_iterator iPair = hTTAssGsf->begin();
            iPair != hTTAssGsf->end(); ++iPair) {
        
            gsftracktrajmap[iPair->val] = iPair->key;

          }
                
        }
        else {
          //fill map for standard tracks
          e.getByLabel(trackProducer, hTTAss);
          for ( TrajTrackAssociationCollection::const_iterator iPair = hTTAss->begin();
            iPair != hTTAss->end();
            ++iPair) {
        
            tracktrajmap[iPair->val] = iPair->key;

          }
        }
      }
    }

    // Step B: create empty output collection
    outputTrks = std::auto_ptr<reco::ConversionTrackCollection>(new reco::ConversionTrackCollection);    

    //--------------------------------------------------
    //Added by D. Giordano
    // 2011/08/05
    // Reduction of the track sample based on geometric hypothesis for conversion tracks
 
    edm::Handle<reco::BeamSpot> beamSpotHandle;
    e.getByLabel(beamSpotInputTag,beamSpotHandle);
   
    edm::ESHandle<MagneticField> magFieldHandle;
    es.get<IdealMagneticFieldRecord>().get( magFieldHandle );


    if(filterOnConvTrackHyp && !beamSpotHandle.isValid()) {
      edm::LogError("Invalid Collection") << "invalid collection for the BeamSpot with InputTag " << beamSpotInputTag;
      throw;
    }

    ConvTrackPreSelector.setMagnField(magFieldHandle.product());

    //----------------------------------------------------------
   
 
    // Simple conversion of tracks to conversion tracks, setting appropriate flags from configuration
    for (edm::RefToBaseVector<reco::Track>::const_iterator it = hTrks->refVector().begin(); it != hTrks->refVector().end(); ++it) {
 
      //--------------------------------------------------
      //Added by D. Giordano
      // 2011/08/05
      // Reduction of the track sample based on geometric hypothesis for conversion tracks
      
      math::XYZVector beamSpot=  math::XYZVector(beamSpotHandle->position());

      if( filterOnConvTrackHyp && ConvTrackPreSelector.isTangentPointDistanceLessThan( minConvRadius, it->get(), beamSpot )  )
        continue;
      //--------------------------------------------------

      reco::ConversionTrack convTrack(*it);
      convTrack.setIsTrackerOnly(setTrackerOnly);
      convTrack.setIsArbitratedEcalSeeded(setArbitratedEcalSeeded);
      convTrack.setIsArbitratedMerged(setArbitratedMerged);
      convTrack.setIsArbitratedMergedEcalGeneral(setArbitratedMergedEcalGeneral);
            
      //fill trajectory association if configured, using correct map depending on track type
      if (useTrajectory) {
        if (gsftracktrajmap.size()) {
          convTrack.setTrajRef(gsftracktrajmap.find(it->castTo<reco::GsfTrackRef>())->second);
        }
        else {
          convTrack.setTrajRef(tracktrajmap.find(it->castTo<reco::TrackRef>())->second);
        }
      }
      
      outputTrks->push_back(convTrack);
    }
    
    e.put(outputTrks);
    return;

  }//end produce

Member Data Documentation

Definition at line 67 of file ConversionTrackProducer.h.

Referenced by produce().

Definition at line 53 of file ConversionTrackProducer.h.

Definition at line 70 of file ConversionTrackProducer.h.

Referenced by produce().

Definition at line 68 of file ConversionTrackProducer.h.

Referenced by produce().

Definition at line 69 of file ConversionTrackProducer.h.

Referenced by produce().

Definition at line 73 of file ConversionTrackProducer.h.

Referenced by produce().

Definition at line 58 of file ConversionTrackProducer.h.

Referenced by produce().

Definition at line 59 of file ConversionTrackProducer.h.

Referenced by produce().

Definition at line 60 of file ConversionTrackProducer.h.

Referenced by produce().

Definition at line 57 of file ConversionTrackProducer.h.

Referenced by produce().

Definition at line 55 of file ConversionTrackProducer.h.

Referenced by produce().

Definition at line 56 of file ConversionTrackProducer.h.

Referenced by produce().