CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
PixelVertexProducerMedian Class Reference

#include <PixelVertexProducerMedian.h>

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

Public Member Functions

 PixelVertexProducerMedian (const edm::ParameterSet &ps)
 
virtual void produce (edm::Event &ev, const edm::EventSetup &es)
 
 ~PixelVertexProducerMedian ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

edm::ParameterSet theConfig
 
double thePtMin
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 9 of file PixelVertexProducerMedian.h.

Constructor & Destructor Documentation

PixelVertexProducerMedian::PixelVertexProducerMedian ( const edm::ParameterSet ps)
explicit

Definition at line 35 of file PixelVertexProducerMedian.cc.

Referenced by ComparePairs::operator()().

35  : theConfig(ps)
36 {
37  produces<reco::VertexCollection>();
38 }
PixelVertexProducerMedian::~PixelVertexProducerMedian ( )

Definition at line 42 of file PixelVertexProducerMedian.cc.

References produce().

43 {
44 }

Member Function Documentation

void PixelVertexProducerMedian::produce ( edm::Event ev,
const edm::EventSetup es 
)
virtual

Definition at line 48 of file PixelVertexProducerMedian.cc.

References connectstrParser::f1, edm::Event::getByLabel(), trackerHits::histo, mps_fire::i, LogTrace, eostools::move(), edm::Handle< T >::product(), EnergyCorrector::pt, edm::Event::put(), AlCaHLTBitMon_QueryRunRegistry::string, HiIsolationCommonParameters_cff::track, findElectronsInSiStrips_cfi::trackCollection, l1t::tracks, tracks_, and ecalDrivenElectronSeedsParameters_cff::vertices.

Referenced by ~PixelVertexProducerMedian().

49 {
50  // Get pixel tracks
52  std::string trackCollectionName =
53  theConfig.getParameter<std::string>("TrackCollection");
54  ev.getByLabel(trackCollectionName, trackCollection);
55  const reco::TrackCollection tracks_ = *(trackCollection.product());
56 
57  thePtMin = theConfig.getParameter<double>("PtMin");
58 
59  // Select tracks
60  std::vector<const reco::Track *> tracks;
61  for (unsigned int i=0; i<tracks_.size(); i++)
62  {
63  if (tracks_[i].pt() > thePtMin)
64  {
65  reco::TrackRef recTrack(trackCollection, i);
66  tracks.push_back( &(*recTrack));
67  }
68  }
69 
70  LogTrace("MinBiasTracking")
71  << " [VertexProducer] selected tracks: "
72  << tracks.size() << " (out of " << tracks_.size()
73  << ")";
74 
75  auto vertices = std::make_unique<reco::VertexCollection>();
76 
77  if(tracks.size() > 0)
78  {
79  // Sort along vertex z position
80  std::sort(tracks.begin(), tracks.end(), ComparePairs());
81 
82  // Median
83  float med;
84  if(tracks.size() % 2 == 0)
85  med = (tracks[tracks.size()/2-1]->vz() + tracks[tracks.size()/2]->vz())/2;
86  else
87  med = tracks[tracks.size()/2 ]->vz();
88 
89  LogTrace("MinBiasTracking")
90  << " [vertex position] median = " << med << " cm";
91 
92  if(tracks.size() > 10)
93  {
94  // Binning around med, halfWidth
95  int nBin = 100;
96  float halfWidth = 0.1; // cm
97 
98  // Most probable
99  TH1F histo("histo","histo", nBin, -halfWidth,halfWidth);
100 
101  for(std::vector<const reco::Track *>::const_iterator
102  track = tracks.begin(); track!= tracks.end(); track++)
103  if(fabs((*track)->vz() - med) < halfWidth)
104  histo.Fill((*track)->vz() - med);
105 
106  LogTrace("MinBiasTracking")
107  << " [vertex position] most prob = "
108  << med + histo.GetBinCenter(histo.GetMaximumBin())
109  << " cm";
110 
111  // Fit above max/2
112  histo.Sumw2();
113 
114  TF1 f1("f1","[0]*exp(-0.5 * ((x-[1])/[2])^2) + [3]");
115  f1.SetParameters(10.,0.,0.01, 1.);
116 
117  histo.Fit(&f1,"QN");
118 
119  LogTrace("MinBiasTracking")
120  << " [vertex position] fitted = "
121  << med + f1.GetParameter(1) << " +- " << f1.GetParError(1)
122  << " cm";
123 
124  // Store
126  err(2,2) = f1.GetParError(1) * f1.GetParError(1);
127  reco::Vertex ver(reco::Vertex::Point(0,0,med + f1.GetParameter(1)),
128  err, 0, 1, 1);
129  vertices->push_back(ver);
130  }
131  else
132  {
133  // Store
135  err(2,2) = 0.1 * 0.1;
136  reco::Vertex ver(reco::Vertex::Point(0,0,med),
137  err, 0, 1, 1);
138  vertices->push_back(ver);
139  }
140  }
141  ev.put(std::move(vertices));
142 }
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
const std::vector< reco::PFCandidatePtr > & tracks_
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:416
#define LogTrace(id)
T const * product() const
Definition: Handle.h:81
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

edm::ParameterSet PixelVertexProducerMedian::theConfig
private

Definition at line 17 of file PixelVertexProducerMedian.h.

double PixelVertexProducerMedian::thePtMin
private

Definition at line 18 of file PixelVertexProducerMedian.h.