CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
VertexCompositeCandidateCollectionSelector Class Reference
Inheritance diagram for VertexCompositeCandidateCollectionSelector:
edm::stream::EDProducer<>

Public Member Functions

 VertexCompositeCandidateCollectionSelector (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpotbsToken_
 
bool debug_
 
std::string label_
 
float lxyCUT_
 
float lxyWRTbsCUT_
 
int pvNDOF_
 
edm::EDGetTokenT< reco::VertexCollectionpvToken_
 
edm::EDGetTokenT< reco::VertexCompositeCandidateCollectionv0Token_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 27 of file VertexCompositeCandidateCollectionSelector.cc.

Constructor & Destructor Documentation

VertexCompositeCandidateCollectionSelector::VertexCompositeCandidateCollectionSelector ( const edm::ParameterSet iConfig)
explicit

Definition at line 63 of file VertexCompositeCandidateCollectionSelector.cc.

References gather_cfg::cout, and debug_.

64  : v0Token_(consumes<reco::VertexCompositeCandidateCollection>(iConfig.getParameter<edm::InputTag>("v0"))),
65  bsToken_(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot"))),
66  pvToken_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("primaryVertex"))),
67  pvNDOF_(iConfig.getParameter<int>("pvNDOF")),
68  label_(iConfig.getParameter<edm::InputTag>("v0").instance()),
69  lxyCUT_(iConfig.getParameter<double>("lxyCUT")),
70  lxyWRTbsCUT_(iConfig.getParameter<double>("lxyWRTbsCUT")),
71  debug_(iConfig.getUntrackedParameter<bool>("debug")) {
72  if (debug_)
73  std::cout << "VertexCompositeCandidateCollectionSelector::VertexCompositeCandidateCollectionSelector" << std::endl;
74  // product
75  produces<reco::VertexCompositeCandidateCollection>();
76 
77  //now do what ever other initialization is needed
78 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > v0Token_
std::string const & instance() const
Definition: InputTag.h:37

Member Function Documentation

void VertexCompositeCandidateCollectionSelector::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 151 of file VertexCompositeCandidateCollectionSelector.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), and DEFINE_FWK_MODULE.

151  {
152  //The following says we do not know what parameters are allowed so do no validation
153  // Please change this to state exactly what you do use, even if it is no parameters
155  desc.add<edm::InputTag>("v0");
156  desc.add<edm::InputTag>("beamSpot");
157  desc.add<edm::InputTag>("primaryVertex");
158  desc.add<int>("pvNDOF");
159  desc.add<double>("lxyCUT", 16.); // cm (2016 pixel layer3:10.2 cm ; 2017 pixel layer4: 16.0 cm)
160  desc.add<double>("lxyWRTbsCUT", 0.); // cm
161  desc.addUntracked<bool>("debug", false);
162  descriptions.add("VertexCompositeCandidateCollectionSelector", desc);
163 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void VertexCompositeCandidateCollectionSelector::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 85 of file VertexCompositeCandidateCollectionSelector.cc.

References bsToken_, gather_cfg::cout, debug_, edm::Event::getByToken(), reco::Vertex::isFake(), edm::HandleBase::isValid(), lxyCUT_, lxyWRTbsCUT_, eostools::move(), dqmiodumpmetadata::n, reco::Vertex::ndof(), PV3DBase< T, PVType, FrameType >::perp(), edm::Handle< T >::product(), edm::Event::put(), MetAnalyzer::pv(), pvNDOF_, pvToken_, mps_fire::result, reco::Vertex::tracksSize(), V0Monitor_cff::v0, v0Token_, reco::BeamSpot::x(), reco::Vertex::x(), reco::BeamSpot::y(), reco::Vertex::y(), and reco::Vertex::z().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

85  {
86  using namespace edm;
87 
88  if (debug_)
89  std::cout << "VertexCompositeCandidateCollectionSelector::produce" << std::endl;
90 
91  // Create auto_ptr for each collection to be stored in the Event
92  auto result = std::make_unique<reco::VertexCompositeCandidateCollection>();
93 
94  edm::Handle<reco::BeamSpot> beamspotHandle;
95  iEvent.getByToken(bsToken_, beamspotHandle);
96  reco::BeamSpot const* bs = nullptr;
97  if (beamspotHandle.isValid())
98  bs = &(*beamspotHandle);
99 
101  iEvent.getByToken(pvToken_, pvHandle);
102  reco::Vertex const* pv = nullptr;
103  if (pvHandle.isValid()) {
104  pv = &pvHandle->front();
105  //--- pv fake (the pv collection should have size==1 and the pv==beam spot)
106  if (pv->isFake() ||
107  pv->tracksSize() == 0
108  // definition of goodOfflinePrimaryVertex
109  || pv->ndof() < pvNDOF_ || pv->z() > 24.)
110  pv = nullptr;
111  }
112 
114  iEvent.getByToken(v0Token_, v0Handle);
115  int n = (v0Handle.isValid() ? v0Handle->size() : -1);
116  if (debug_)
117  std::cout << "n: " << n << std::endl;
118  if (n > 0) {
119  auto const& v0s = *v0Handle.product();
120  for (auto const& v0 : v0s) {
121  GlobalPoint displacementFromPV2D =
122  (pv == nullptr ? dummyGP : GlobalPoint((pv->x() - v0.vx()), (pv->y() - v0.vy()), 0.));
123  GlobalPoint displacementFromBS2D =
124  (bs == nullptr ? dummyGP : GlobalPoint(v0.vx() - bs->x(v0.vz()), v0.vy() - bs->y(v0.vz()), 0.));
125  float abslxy = (pv == nullptr ? dummy : displacementFromPV2D.perp());
126  float abslxyWRTbs = (bs == nullptr ? dummy : displacementFromBS2D.perp());
127 
128  if (debug_)
129  std::cout << "abslxy: " << abslxy << " w.r.t. " << lxyCUT_ << " ==> " << (abslxy >= lxyCUT_ ? "OK" : "KO")
130  << std::endl;
131  if (debug_)
132  std::cout << "abslxyWRTbs: " << abslxyWRTbs << " w.r.t. " << lxyWRTbsCUT_ << " ==> "
133  << (abslxyWRTbs >= lxyWRTbsCUT_ ? "OK" : "KO") << std::endl;
134  if (abslxy < lxyCUT_)
135  continue;
136  if (abslxyWRTbs < lxyWRTbsCUT_)
137  continue;
138  result->push_back(v0);
139  }
140  }
141 
142  if (debug_)
143  std::cout << "result: " << result->size() << std::endl;
144  // put into the Event
145  // Write the collections to the Event
146  result->shrink_to_fit();
147  iEvent.put(std::move(result));
148 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
T perp() const
Definition: PV3DBase.h:69
edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > v0Token_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
double y() const
y coordinate
Definition: Vertex.h:117
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
def pv(vc)
Definition: MetAnalyzer.py:7
double z() const
z coordinate
Definition: Vertex.h:119
bool isValid() const
Definition: HandleBase.h:70
double ndof() const
Definition: Vertex.h:109
double x() const
x coordinate
Definition: Vertex.h:115
bool isFake() const
Definition: Vertex.h:75
T const * product() const
Definition: Handle.h:69
double x(const double z) const
x coordinate of the beeam spot position at a given z value (it takes into account the dxdz slope) ...
Definition: BeamSpot.h:68
HLT enums.
double y(const double z) const
y coordinate of the beeam spot position at a given z value (it takes into account the dydz slope) ...
Definition: BeamSpot.h:70
def move(src, dest)
Definition: eostools.py:511
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:69

Member Data Documentation

edm::EDGetTokenT<reco::BeamSpot> VertexCompositeCandidateCollectionSelector::bsToken_
private

Definition at line 39 of file VertexCompositeCandidateCollectionSelector.cc.

Referenced by produce().

bool VertexCompositeCandidateCollectionSelector::debug_
private
std::string VertexCompositeCandidateCollectionSelector::label_
private
float VertexCompositeCandidateCollectionSelector::lxyCUT_
private

Definition at line 47 of file VertexCompositeCandidateCollectionSelector.cc.

Referenced by produce().

float VertexCompositeCandidateCollectionSelector::lxyWRTbsCUT_
private

Definition at line 48 of file VertexCompositeCandidateCollectionSelector.cc.

Referenced by produce().

int VertexCompositeCandidateCollectionSelector::pvNDOF_
private

Definition at line 42 of file VertexCompositeCandidateCollectionSelector.cc.

Referenced by produce().

edm::EDGetTokenT<reco::VertexCollection> VertexCompositeCandidateCollectionSelector::pvToken_
private

Definition at line 40 of file VertexCompositeCandidateCollectionSelector.cc.

Referenced by produce().

edm::EDGetTokenT<reco::VertexCompositeCandidateCollection> VertexCompositeCandidateCollectionSelector::v0Token_
private

Definition at line 38 of file VertexCompositeCandidateCollectionSelector.cc.

Referenced by produce().