CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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.

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

Definition at line 42 of file PixelVertexProducerMedian.cc.

43 {
44 }

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 48 of file PixelVertexProducerMedian.cc.

References validate-o2o-wbm::f1, edm::Event::getByLabel(), timingPdfMaker::histo, i, LogTrace, edm::Handle< T >::product(), EnergyCorrector::pt, edm::Event::put(), AlCaHLTBitMon_QueryRunRegistry::string, HLT_25ns10e33_v2_cff::trackCollection, testEve_cfg::tracks, tracks_, and HLT_25ns10e33_v2_cff::vertices.

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  std::auto_ptr<reco::VertexCollection> vertices(new 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(vertices);
142 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
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
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
#define LogTrace(id)
T const * product() const
Definition: Handle.h:81
tuple tracks
Definition: testEve_cfg.py:39

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.