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 16 of file CaloTauSelectorDefinition.h.

Member Typedef Documentation

Definition at line 18 of file CaloTauSelectorDefinition.h.

typedef container::const_iterator CaloTauSelectorDefinition::const_iterator

Definition at line 21 of file CaloTauSelectorDefinition.h.

Definition at line 20 of file CaloTauSelectorDefinition.h.

Definition at line 19 of file CaloTauSelectorDefinition.h.

Definition at line 27 of file CaloTauSelectorDefinition.h.

Constructor & Destructor Documentation

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

Definition at line 29 of file CaloTauSelectorDefinition.h.

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

29  {
30  discriminatorsPSets_ = cfg.getParameter< std::vector<edm::ParameterSet> >( "discriminators" );
32  cut_ = ( cfg.exists("cut") ) ? new StringCutObjectSelector<reco::CaloTau>( cfg.getParameter<std::string>( "cut" ) ) : nullptr;
33  }
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_
std::vector< edm::EDGetTokenT< reco::CaloTauDiscriminator > > discriminatorTokens_
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::ParameterSet > discriminatorsPSets_
CaloTauSelectorDefinition::~CaloTauSelectorDefinition ( )
inline

Definition at line 35 of file CaloTauSelectorDefinition.h.

References cut_.

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

Member Function Documentation

const_iterator CaloTauSelectorDefinition::begin ( void  ) const
inline

Definition at line 37 of file CaloTauSelectorDefinition.h.

References selected_.

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

Definition at line 39 of file CaloTauSelectorDefinition.h.

References selected_.

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

Definition at line 41 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().

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

Referenced by select().

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

Definition at line 98 of file CaloTauSelectorDefinition.h.

Referenced by CaloTauSelectorDefinition(), and select().

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

Definition at line 99 of file CaloTauSelectorDefinition.h.

Referenced by CaloTauSelectorDefinition(), and select().

container CaloTauSelectorDefinition::selected_
private

Definition at line 97 of file CaloTauSelectorDefinition.h.

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