CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Attributes
CaloTauSelectorDefinition Struct Reference

#include <CaloTauSelectorDefinition.h>

Classes

struct  TDiscCutPair
 

Public Types

typedef reco::CaloTauCollection collection
 
typedef container::const_iterator const_iterator
 
typedef std::vector< reco::CaloTau * > container
 
typedef edm::Handle< collectionHandleToCollection
 
typedef std::vector< TDiscCutPairTDiscCutPairVec
 

Public Member Functions

const_iterator begin () const
 
 CaloTauSelectorDefinition (const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
 
const_iterator end () const
 
void select (const HandleToCollection &hc, const edm::Event &e, const edm::EventSetup &s)
 
size_t size () const
 
 ~CaloTauSelectorDefinition ()
 

Private Attributes

StringCutObjectSelector< reco::CaloTau > * cut_
 
TDiscCutPairVec discriminators_
 
std::vector< edm::ParameterSetdiscriminatorsPSets_
 
std::vector< edm::EDGetTokenT< reco::CaloTauDiscriminator > > discriminatorTokens_
 
container selected_
 

Detailed Description

Definition at line 14 of file CaloTauSelectorDefinition.h.

Member Typedef Documentation

Definition at line 16 of file CaloTauSelectorDefinition.h.

typedef container::const_iterator CaloTauSelectorDefinition::const_iterator

Definition at line 19 of file CaloTauSelectorDefinition.h.

Definition at line 18 of file CaloTauSelectorDefinition.h.

Definition at line 17 of file CaloTauSelectorDefinition.h.

Definition at line 25 of file CaloTauSelectorDefinition.h.

Constructor & Destructor Documentation

CaloTauSelectorDefinition::CaloTauSelectorDefinition ( const edm::ParameterSet cfg,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 27 of file CaloTauSelectorDefinition.h.

References cut_, discriminatorsPSets_, discriminatorTokens_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, and edm::vector_transform().

27  {
28  discriminatorsPSets_ = cfg.getParameter< std::vector<edm::ParameterSet> >( "discriminators" );
30  cut_ = ( cfg.exists("cut") ) ? new StringCutObjectSelector<reco::CaloTau>( cfg.getParameter<std::string>( "cut" ) ) : nullptr;
31  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
StringCutObjectSelector< reco::CaloTau > * cut_
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
std::vector< edm::EDGetTokenT< reco::CaloTauDiscriminator > > discriminatorTokens_
std::vector< edm::ParameterSet > discriminatorsPSets_
CaloTauSelectorDefinition::~CaloTauSelectorDefinition ( )
inline

Definition at line 33 of file CaloTauSelectorDefinition.h.

References cut_.

33 { delete cut_; }
StringCutObjectSelector< reco::CaloTau > * cut_

Member Function Documentation

const_iterator CaloTauSelectorDefinition::begin ( void  ) const
inline

Definition at line 35 of file CaloTauSelectorDefinition.h.

References selected_.

35 { return selected_.begin(); }
const_iterator CaloTauSelectorDefinition::end ( void  ) const
inline

Definition at line 37 of file CaloTauSelectorDefinition.h.

References selected_.

37 { return selected_.end(); }
void CaloTauSelectorDefinition::select ( const HandleToCollection hc,
const edm::Event e,
const edm::EventSetup s 
)
inline

Definition at line 39 of file CaloTauSelectorDefinition.h.

References cut_, TtSemiLepEvtBuilder_cfi::disc, discriminators_, discriminatorsPSets_, discriminatorTokens_, edm::Event::getByToken(), edm::HandleBase::isValid(), crabWrapper::key, CaloTauSelectorDefinition::TDiscCutPair::m_cut, CaloTauSelectorDefinition::TDiscCutPair::m_discHandle, selected_, and edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::size().

42  {
43 
44  selected_.clear();
45  assert( hc.isValid() ); // collection of CaloTaus
46 
47  // get discriminators and coresponding cuts from stored vpset
48  discriminators_.clear();
49 
50  std::vector< edm::EDGetTokenT<reco::CaloTauDiscriminator> >::iterator itToken = discriminatorTokens_.begin();
51  for(std::vector< edm::ParameterSet >::iterator it = discriminatorsPSets_.begin();
52  it != discriminatorsPSets_.end();
53  ++it, ++itToken)
54  {
55  TDiscCutPair disc;
56  // get discriminator, check if valid
57  // assert isn't a good method to do it
58  if(!(e.getByToken( *itToken, disc.m_discHandle))) assert(0);
59  disc.m_cut = it->getParameter<double>("selectionCut");
60  // the discriminator collection and the CaloTau collection
61  // must have the same size
62  assert( disc.m_discHandle->size() == hc->size());
63  discriminators_.push_back(disc);
64  }
65 
66  unsigned key=0;
67  bool passedAllCuts;
68  for( collection::const_iterator calotau = hc->begin();
69  calotau != hc->end();
70  ++calotau, ++key)
71  {
72  passedAllCuts = true;
73  reco::CaloTauRef calotauRef(hc, key);
74 
75  //iterate over all discriminators, check the cuts
76  for (TDiscCutPairVec::iterator discIt = discriminators_.begin();
77  discIt!=discriminators_.end();
78  ++discIt)
79  {
80  if ( (*(discIt->m_discHandle))[calotauRef] <= discIt->m_cut)
81  passedAllCuts = false;
82  }
83 
84  if ( cut_ ) passedAllCuts &= (*cut_)(*calotau);
85 
86  if(passedAllCuts)
87  selected_.push_back( new reco::CaloTau(*calotau) );
88  } // end collection iteration
89  } // end select()
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
StringCutObjectSelector< reco::CaloTau > * cut_
std::vector< edm::EDGetTokenT< reco::CaloTauDiscriminator > > discriminatorTokens_
std::vector< edm::ParameterSet > discriminatorsPSets_
susybsm::HSCParticleCollection hc
Definition: classes.h:25
size_t CaloTauSelectorDefinition::size ( void  ) const
inline

Member Data Documentation

StringCutObjectSelector<reco::CaloTau>* CaloTauSelectorDefinition::cut_
private
TDiscCutPairVec CaloTauSelectorDefinition::discriminators_
private

Definition at line 94 of file CaloTauSelectorDefinition.h.

Referenced by select().

std::vector< edm::ParameterSet > CaloTauSelectorDefinition::discriminatorsPSets_
private

Definition at line 96 of file CaloTauSelectorDefinition.h.

Referenced by CaloTauSelectorDefinition(), and select().

std::vector< edm::EDGetTokenT<reco::CaloTauDiscriminator> > CaloTauSelectorDefinition::discriminatorTokens_
private

Definition at line 97 of file CaloTauSelectorDefinition.h.

Referenced by CaloTauSelectorDefinition(), and select().

container CaloTauSelectorDefinition::selected_
private

Definition at line 95 of file CaloTauSelectorDefinition.h.

Referenced by begin(), end(), select(), and size().