CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

PixelVertexProducerClusters Class Reference

#include <PixelVertexProducerClusters.h>

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

List of all members.

Public Member Functions

int getContainedHits (std::vector< VertexHit > hits, float z0, float &chi)
 PixelVertexProducerClusters (const edm::ParameterSet &ps)
virtual void produce (edm::Event &ev, const edm::EventSetup &es)
 ~PixelVertexProducerClusters ()

Private Member Functions

void beginRun (edm::Run const &run, edm::EventSetup const &es)

Private Attributes

edm::ParameterSet theConfig
const TrackerGeometrytheTracker

Detailed Description

Definition at line 12 of file PixelVertexProducerClusters.h.


Constructor & Destructor Documentation

PixelVertexProducerClusters::PixelVertexProducerClusters ( const edm::ParameterSet ps) [explicit]

Definition at line 47 of file PixelVertexProducerClusters.cc.

                              : theConfig(ps)
{
  // Product
  produces<reco::VertexCollection>();
}
PixelVertexProducerClusters::~PixelVertexProducerClusters ( )

Definition at line 55 of file PixelVertexProducerClusters.cc.

{ 
}

Member Function Documentation

void PixelVertexProducerClusters::beginRun ( edm::Run const &  run,
edm::EventSetup const &  es 
) [private]

Definition at line 61 of file PixelVertexProducerClusters.cc.

References edm::EventSetup::get(), and edm::ESHandle< T >::product().

{
  // Get tracker geometry
  edm::ESHandle<TrackerGeometry> trackerHandle;
  es.get<TrackerDigiGeometryRecord>().get(trackerHandle);
  theTracker = trackerHandle.product();
}
int PixelVertexProducerClusters::getContainedHits ( std::vector< VertexHit hits,
float  z0,
float &  chi 
)

Definition at line 71 of file PixelVertexProducerClusters.cc.

References n, L1TEmulatorMonitor_cff::p, and hit::z.

{
  int n = 0;
  chi = 0.;

  for(vector<VertexHit>::const_iterator hit = hits.begin();
                                        hit!= hits.end(); hit++)
  {
    // Predicted cluster width in y direction
    float p = 2 * fabs(hit->z - z0)/hit->r + 0.5; // FIXME

    if(fabs(p - hit->w) <= 1.)
    { 
      chi += fabs(p - hit->w);
      n++;
    }
  }

  return n;
}
void PixelVertexProducerClusters::produce ( edm::Event ev,
const edm::EventSetup es 
) [virtual]

Implements edm::EDProducer.

Definition at line 94 of file PixelVertexProducerClusters.cc.

References edmNew::DetSetVector< T >::data(), ExpressReco_HICollisions_FallBack::e, edm::Event::getByLabel(), PixelTopology::isItEdgePixelInX(), PixelTopology::isItEdgePixelInY(), LogTrace, evf::utils::pid, PixelSubdetector::PixelBarrel, edm::Handle< T >::product(), edm::Event::put(), VertexHit::r, edmNew::DetSetVector< T >::size(), PixelGeomDetUnit::specificTopology(), cmsDownloadME::ver, ExpressReco_HICollisions_FallBack::vertices, VertexHit::w, and VertexHit::z.

{
  // Get pixel hit collections
  edm::Handle<SiPixelRecHitCollection> pixelColl;
  ev.getByLabel("siPixelRecHits",      pixelColl);

  const SiPixelRecHitCollection* thePixelHits = pixelColl.product();

  std::auto_ptr<reco::VertexCollection> vertices(new reco::VertexCollection);

  if(thePixelHits->size() > 0)
  {
    vector<VertexHit> hits;

    for(SiPixelRecHitCollection::DataContainer::const_iterator
           recHit = thePixelHits->data().begin(),
           recHitEnd = thePixelHits->data().end();
           recHit != recHitEnd; ++recHit)
    {
      if(recHit->isValid())
      {
//      if(!(recHit->isOnEdge() || recHit->hasBadPixels()))
        DetId id = recHit->geographicalId();
        const PixelGeomDetUnit* pgdu =
          dynamic_cast<const PixelGeomDetUnit*>(theTracker->idToDetUnit(id));
        const PixelTopology* theTopol = ( &(pgdu->specificTopology()) );
        vector<SiPixelCluster::Pixel> pixels = recHit->cluster()->pixels();

        bool pixelOnEdge = false;
        for(vector<SiPixelCluster::Pixel>::const_iterator
               pixel = pixels.begin(); pixel!= pixels.end(); pixel++)
        {
          int pos_x = (int)pixel->x;
          int pos_y = (int)pixel->y;

          if(theTopol->isItEdgePixelInX(pos_x) ||
              theTopol->isItEdgePixelInY(pos_y))
          { pixelOnEdge = true; break; }
        }
    
        if(!pixelOnEdge)
        if(id.subdetId() == int(PixelSubdetector::PixelBarrel))  
        {
          PXBDetId pid(id);
 
          LocalPoint lpos = LocalPoint(recHit->localPosition().x(),
                                       recHit->localPosition().y(),
                                       recHit->localPosition().z());

          GlobalPoint gpos = theTracker->idToDet(id)->toGlobal(lpos);

          VertexHit hit;
          hit.z = gpos.z(); 
          hit.r = gpos.perp(); 
          hit.w = recHit->cluster()->sizeY();

          hits.push_back(hit);
        }
      }
    }

    int nhits; int nhits_max = 0;
    float chi; float chi_max = 1e+9;

    float zest = 0;
 
    for(float z0 = -15.9; z0 <= 15.95; z0 += 0.1)
    {
      nhits = getContainedHits(hits, z0, chi);

      if(nhits > 0)
      {
        if(nhits >  nhits_max)
        { chi_max = 1e+9; nhits_max = nhits; }

        if(nhits >= nhits_max)
        if(chi < chi_max)
        { chi_max = chi; zest = z0; }
      }
    }

    LogTrace("MinBiasTracking")
      << "  [vertex position] estimated = " << zest 
      << " | pixel barrel hits = " << thePixelHits->size();

    reco::Vertex::Error err;
    err(2,2) = 0.6 * 0.6;
    reco::Vertex ver(reco::Vertex::Point(0,0,zest), err, 0, 1, 1);
    vertices->push_back(ver);
  }

  ev.put(vertices);
}

Member Data Documentation

Definition at line 23 of file PixelVertexProducerClusters.h.

Definition at line 25 of file PixelVertexProducerClusters.h.