1 #ifndef CandAlgos_NamedCandCombiner_h 2 #define CandAlgos_NamedCandCombiner_h 25 #include "CommonTools/Utilities/interface/cutParser.h" 45 setMassConstraint_(
false),
51 for(vector<ConjInfo>::iterator
label = labels_.begin();
54 dauCharge_.push_back( 1 );
55 else if (
label->mode_ == ConjInfo::kMinus)
56 dauCharge_.push_back(-1);
58 dauCharge_.push_back(0);
61 "failed to parse \"" + decay +
"\"");
63 int lists = labels_.size();
64 if(lists != 2 && lists != 3)
66 "invalid number of collections");
68 const string setLongLived(
"setLongLived");
70 found =
find(vBoolParams.begin(), vBoolParams.end(), setLongLived) != vBoolParams.end();
71 if(found) setLongLived_ = cfg.
getParameter<
bool>(
"setLongLived");
72 const string setMassConstraint(
"setMassConstraint");
73 found =
find(vBoolParams.begin(), vBoolParams.end(), setMassConstraint) != vBoolParams.end();
74 if(found) setMassConstraint_ = cfg.
getParameter<
bool>(
"setMassConstraint");
75 const string setPdgId(
"setPdgId");
77 found =
find(vIntParams.begin(), vIntParams.end(), setPdgId) != vIntParams.end();
78 if(found) { setPdgId_ =
true; pdgId_ = cfg.
getParameter<
int>(
"setPdgId"); }
82 roles_= cfg.
getParameter<std::vector<std::string> > (
"roles" );
86 std::vector<cand::parser::ConjInfo>
labels_;
87 std::vector<EDGetTokenT<CandidateView> >
tokens_;
119 cfg.existsAs<
bool>(
"checkCharge") ? cfg.getParameter<
bool>(
"checkCharge") :
true,
120 cfg.existsAs<
bool>(
"checkOverlap") ? cfg.getParameter<
bool>(
"checkOverlap") :
true,
122 produces<reco::NamedCompositeCandidateCollection>();
131 using namespace reco;
133 int n = labels_.size();
134 std::vector<edm::Handle<CandidateView> > colls(n);
135 for(
int i = 0;
i <
n; ++
i) {
138 std::vector<CandidatePtrVector>
cv;
140 c != colls.end(); ++
c) {
149 std::unique_ptr<NamedCompositeCandidateCollection>
out = combiner_.combine(cv, roles_);
150 if(setLongLived_ || setMassConstraint_ || setPdgId_) {
151 typename NamedCompositeCandidateCollection::iterator
i = out->begin(),
e = out->end();
154 i->setRoles( roles_ );
156 if(setLongLived_) i->setLongLived();
157 if(setMassConstraint_) i->setMassConstraint();
158 if(setPdgId_) i->setPdgId(pdgId_);
T getParameter(std::string const &) const
std::string name_
Name of this candidate.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
NamedCandCombinerBase(const edm::ParameterSet &cfg)
bool setMassConstraint_
set mass constraint flag
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void push_back(Ptr< T > const &iPtr)
S make(const edm::ParameterSet &cfg)
std::vector< int > dauCharge_
daughter charges
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< std::string > roles_
virtual ~NamedCandCombiner()
destructor
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
std::vector< cand::parser::ConjInfo > labels_
label vector
std::vector< edm::EDGetTokenT< int > > tokens_
bool decayParser(const std::string &iValue, std::vector< ConjInfo > &oStrings)
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 >
bool setPdgId_
set pdgId flag
int pdgId_
which pdgId to set
NamedCandCombiner(const edm::ParameterSet &cfg)
constructor from parameter settypedef
void produce(edm::Event &evt, const edm::EventSetup &es)
process an event
bool setLongLived_
set long lived flag
::NamedCandCombiner< Selector, PairSelector, Cloner, Setup > combiner_
combiner utility
std::vector< EDGetTokenT< CandidateView > > tokens_