CMS 3D CMS Logo

Public Member Functions | Private Attributes

SeedGeneratorFromProtoTracksEDProducer Class Reference

#include <SeedGeneratorFromProtoTracksEDProducer.h>

Inheritance diagram for SeedGeneratorFromProtoTracksEDProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

virtual void produce (edm::Event &ev, const edm::EventSetup &es) override
 SeedGeneratorFromProtoTracksEDProducer (const edm::ParameterSet &cfg)
virtual ~SeedGeneratorFromProtoTracksEDProducer ()

Private Attributes

std::string builderName
double originHalfLength
double originRadius
edm::ParameterSet theConfig
edm::InputTag theInputCollectionTag
edm::InputTag theInputVertexCollectionTag
bool useEventsWithNoVertex
bool useProtoTrackKinematics

Detailed Description

Definition at line 11 of file SeedGeneratorFromProtoTracksEDProducer.h.


Constructor & Destructor Documentation

SeedGeneratorFromProtoTracksEDProducer::SeedGeneratorFromProtoTracksEDProducer ( const edm::ParameterSet cfg)

Definition at line 35 of file SeedGeneratorFromProtoTracksEDProducer.cc.

  : theConfig(cfg), 
    theInputCollectionTag(cfg.getParameter<InputTag>("InputCollection")),
    theInputVertexCollectionTag(cfg.getParameter<InputTag>("InputVertexCollection")),
    originHalfLength(cfg.getParameter<double>("originHalfLength")),
    originRadius(cfg.getParameter<double>("originRadius")),
    useProtoTrackKinematics(cfg.getParameter<bool>("useProtoTrackKinematics")),
    useEventsWithNoVertex(cfg.getParameter<bool>("useEventsWithNoVertex")),
    builderName(cfg.getParameter<std::string>("TTRHBuilder"))

{
  produces<TrajectorySeedCollection>();
}
virtual SeedGeneratorFromProtoTracksEDProducer::~SeedGeneratorFromProtoTracksEDProducer ( ) [inline, virtual]

Definition at line 14 of file SeedGeneratorFromProtoTracksEDProducer.h.

{}

Member Function Documentation

void SeedGeneratorFromProtoTracksEDProducer::produce ( edm::Event ev,
const edm::EventSetup es 
) [override, virtual]

need optimization: all es stuff should go out of the loop

Implements edm::EDProducer.

Definition at line 49 of file SeedGeneratorFromProtoTracksEDProducer.cc.

References builderName, edm::EventSetup::get(), edm::Event::getByLabel(), SeedFromConsecutiveHitsCreator::init(), SeedFromProtoTrack::isValid(), SeedFromConsecutiveHitsCreator::makeSeed(), reco::TrackBase::momentum(), SeedingHitSet::nullPtr(), originHalfLength, originRadius, edm::Handle< T >::product(), edm::Event::put(), reco::Track::recHit(), reco::Track::recHitsSize(), query::result, python::multivaluedict::sort(), funct::sqr(), mathSSE::sqrt(), theInputCollectionTag, theInputVertexCollectionTag, SeedFromProtoTrack::trajectorySeed(), useEventsWithNoVertex, useProtoTrackKinematics, and reco::TrackBase::vertex().

{
  std::auto_ptr<TrajectorySeedCollection> result(new TrajectorySeedCollection());
  Handle<reco::TrackCollection> trks;
  ev.getByLabel(theInputCollectionTag, trks);

  const TrackCollection &protos = *(trks.product());
  
  edm::Handle<reco::VertexCollection> vertices;
  bool foundVertices = ev.getByLabel(theInputVertexCollectionTag, vertices);
  //const reco::VertexCollection & vertices = *(h_vertices.product());

  for (TrackCollection::const_iterator it=protos.begin(); it!= protos.end(); ++it) {
    const Track & proto = (*it);
    GlobalPoint vtx(proto.vertex().x(), proto.vertex().y(), proto.vertex().z());

    // check the compatibility with a primary vertex
    bool keepTrack = false;
    if ( !foundVertices ) { 
          if (useEventsWithNoVertex) keepTrack = true;
    } else { 
      for (reco::VertexCollection::const_iterator iv=vertices->begin(); iv!= vertices->end(); ++iv) {
        GlobalPoint aPV(iv->position().x(),iv->position().y(),iv->position().z());
        double distR2 = sqr(vtx.x()-aPV.x()) +sqr(vtx.y()-aPV.y());
        double distZ = fabs(vtx.z()-aPV.z());
        if ( distR2 < sqr(originRadius) && distZ < originHalfLength ) { 
          keepTrack = true;
          break;
        }
      }
    }
    if (!keepTrack) continue;

    if ( useProtoTrackKinematics ) {
      SeedFromProtoTrack seedFromProtoTrack( proto, es);
      if (seedFromProtoTrack.isValid()) (*result).push_back( seedFromProtoTrack.trajectorySeed() );
    } else {
      edm::ESHandle<TransientTrackingRecHitBuilder> ttrhbESH;
      es.get<TransientRecHitRecord>().get(builderName,ttrhbESH);
      std::vector<Hit> hits;
      for (unsigned int iHit = 0, nHits = proto.recHitsSize(); iHit < nHits; ++iHit) {
        TrackingRecHitRef refHit = proto.recHit(iHit);
        if(refHit->isValid()) hits.push_back(ttrhbESH->build(  &(*refHit) ));
      }
      sort(hits.begin(), hits.end(), HitLessByRadius());
      assert(hits.size()<4);
      if (hits.size() > 1) {
        double mom_perp = sqrt(proto.momentum().x()*proto.momentum().x()+proto.momentum().y()*proto.momentum().y());
        GlobalTrackingRegion region(mom_perp, vtx, 0.2, 0.2);
        SeedFromConsecutiveHitsCreator seedCreator;
        seedCreator.init(region, es, 0);
        seedCreator.makeSeed(*result, SeedingHitSet(hits[0], hits[1], hits.size() >2 ? hits[2] : SeedingHitSet::nullPtr() ));
      }
    }
  } 

  ev.put(result);
}

Member Data Documentation

Definition at line 24 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

Definition at line 20 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

Definition at line 21 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

Definition at line 17 of file SeedGeneratorFromProtoTracksEDProducer.h.

Definition at line 18 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

Definition at line 19 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

Definition at line 23 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

Definition at line 22 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().