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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 27 of file VertexCompositeCandidateCollectionSelector.cc.

Constructor & Destructor Documentation

◆ VertexCompositeCandidateCollectionSelector()

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
Definition: ParameterSet.h:303
edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > v0Token_
std::string const & instance() const
Definition: InputTag.h:37
T getUntrackedParameter(std::string const &, T const &) const

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 151 of file VertexCompositeCandidateCollectionSelector.cc.

References edm::ConfigurationDescriptions::add(), and submitPVResolutionJobs::desc.

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 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void VertexCompositeCandidateCollectionSelector::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 85 of file VertexCompositeCandidateCollectionSelector.cc.

References cms::cuda::bs, bsToken_, gather_cfg::cout, debug_, iEvent, edm::HandleBase::isValid(), lxyCUT_, lxyWRTbsCUT_, eostools::move(), dqmiodumpmetadata::n, PV3DBase< T, PVType, FrameType >::perp(), edm::Handle< T >::product(), MetAnalyzer::pv(), pvNDOF_, pvToken_, mps_fire::result, V0Monitor_cff::v0, and v0Token_.

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 }
T perp() const
Definition: PV3DBase.h:69
edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > v0Token_
T const * product() const
Definition: Handle.h:70
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
int iEvent
Definition: GenABIO.cc:224
def pv(vc)
Definition: MetAnalyzer.py:7
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ bsToken_

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

Definition at line 39 of file VertexCompositeCandidateCollectionSelector.cc.

Referenced by produce().

◆ debug_

bool VertexCompositeCandidateCollectionSelector::debug_
private

◆ label_

std::string VertexCompositeCandidateCollectionSelector::label_
private

◆ lxyCUT_

float VertexCompositeCandidateCollectionSelector::lxyCUT_
private

Definition at line 47 of file VertexCompositeCandidateCollectionSelector.cc.

Referenced by produce().

◆ lxyWRTbsCUT_

float VertexCompositeCandidateCollectionSelector::lxyWRTbsCUT_
private

Definition at line 48 of file VertexCompositeCandidateCollectionSelector.cc.

Referenced by produce().

◆ pvNDOF_

int VertexCompositeCandidateCollectionSelector::pvNDOF_
private

Definition at line 42 of file VertexCompositeCandidateCollectionSelector.cc.

Referenced by produce().

◆ pvToken_

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

Definition at line 40 of file VertexCompositeCandidateCollectionSelector.cc.

Referenced by produce().

◆ v0Token_

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

Definition at line 38 of file VertexCompositeCandidateCollectionSelector.cc.

Referenced by produce().