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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 64 of file VertexCompositeCandidateCollectionSelector.cc.

References gather_cfg::cout, and debug_.

Referenced by fillDescriptions().

65  : v0Token_ ( consumes<reco::VertexCompositeCandidateCollection>(iConfig.getParameter<edm::InputTag>("v0") ) )
66  , bsToken_ ( consumes<reco::BeamSpot> (iConfig.getParameter<edm::InputTag>("beamSpot") ) )
67  , pvToken_ ( consumes<reco::VertexCollection> (iConfig.getParameter<edm::InputTag>("primaryVertex") ) )
68  , pvNDOF_ ( iConfig.getParameter<int> ("pvNDOF") )
69  , label_ ( iConfig.getParameter<edm::InputTag>("v0").instance() )
70  , lxyCUT_ ( iConfig.getParameter<double>("lxyCUT") )
71  , lxyWRTbsCUT_ ( iConfig.getParameter<double>("lxyWRTbsCUT") )
72  , debug_ ( iConfig.getUntrackedParameter<bool>("debug") )
73 {
74  if (debug_) std::cout << "VertexCompositeCandidateCollectionSelector::VertexCompositeCandidateCollectionSelector" << std::endl;
75  // product
76  produces<reco::VertexCompositeCandidateCollection>();
77 
78  //now do what ever other initialization is needed
79 
80 }
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 150 of file VertexCompositeCandidateCollectionSelector.cc.

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

150  {
151  //The following says we do not know what parameters are allowed so do no validation
152  // Please change this to state exactly what you do use, even if it is no parameters
154  desc.add<edm::InputTag>("v0");
155  desc.add<edm::InputTag>("beamSpot");
156  desc.add<edm::InputTag>("primaryVertex");
157  desc.add<int>("pvNDOF");
158  desc.add<double>("lxyCUT", 16.); // cm (2016 pixel layer3:10.2 cm ; 2017 pixel layer4: 16.0 cm)
159  desc.add<double>("lxyWRTbsCUT", 0.); // cm
160  desc.addUntracked<bool>("debug",false);
161  descriptions.add("VertexCompositeCandidateCollectionSelector",desc);
162 }
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 89 of file VertexCompositeCandidateCollectionSelector.cc.

References bsToken_, gather_cfg::cout, debug_, edm::Event::getByToken(), reco::Vertex::isFake(), edm::HandleBase::isValid(), lxyCUT_, lxyWRTbsCUT_, eostools::move(), gen::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(), 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().

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

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().