Skip to content

Commit a71d8ca

Browse files
committed
apply code-format changes
1 parent fad42d6 commit a71d8ca

File tree

5 files changed

+59
-54
lines changed

5 files changed

+59
-54
lines changed

CommonTools/Utils/interface/TypedStringObjectMethodCaller.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ struct TypedStringObjectMethodCaller {
2424
}
2525
} catch (reco::parser::BaseException& e) {
2626
throw edm::Exception(edm::errors::Configuration)
27-
<< "MethodChainGrammer parse error:" << reco::parser::baseExceptionWhat(e) << " (char " << e.where - startingFrom << ")\n";
27+
<< "MethodChainGrammer parse error:" << reco::parser::baseExceptionWhat(e) << " (char "
28+
<< e.where - startingFrom << ")\n";
2829
}
2930
}
3031

31-
R operator()(const T &t) const {
32-
edm::ObjectWithDict o(type_, const_cast<T *>(&t));
32+
R operator()(const T& t) const {
33+
edm::ObjectWithDict o(type_, const_cast<T*>(&t));
3334
edm::ObjectWithDict ret = methodchain_->value(o);
3435
return *static_cast<R*>(ret.address());
3536
}

CommonTools/Utils/interface/parser/MethodChain.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
namespace reco {
1818
namespace parser {
19-
19+
2020
/// Based on Expression, but its value method returns an edm::ObjectWithDict instead of a double
2121
class MethodChainBase {
22-
public: // Public Methods
22+
public: // Public Methods
2323
virtual ~MethodChainBase() {}
24-
virtual edm::ObjectWithDict value(const edm::ObjectWithDict&) const = 0;
24+
virtual edm::ObjectWithDict value(const edm::ObjectWithDict&) const = 0;
2525
};
26-
26+
2727
/// Shared ptr to MethodChainBase
2828
typedef std::shared_ptr<MethodChainBase> MethodChainPtr;
2929

@@ -41,7 +41,6 @@ namespace reco {
4141
void returnObjects(Objects&&) const;
4242

4343
public: // Public Static Methods
44-
4544
/// allocate an object to hold the result of a given member (if needed)
4645
/// this method is used also from the LazyInvoker code
4746
/// returns true if objects returned from this will require a destructor

CommonTools/Utils/interface/parser/MethodChainGrammar.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
namespace reco {
2626
namespace parser {
2727
struct MethodChainGrammar : public boost::spirit::classic::grammar<MethodChainGrammar> {
28-
MethodChainPtr *methchain_;
29-
bool lazy_;
28+
MethodChainPtr* methchain_;
29+
bool lazy_;
3030
mutable MethodStack methStack;
3131
mutable LazyMethodStack lazyMethStack;
3232
mutable MethodArgumentStack methArgStack;
3333
mutable TypeStack typeStack;
3434

35-
MethodChainGrammar(MethodChainPtr &methchain, const edm::TypeWithDict& iType, bool lazy = false)
35+
MethodChainGrammar(MethodChainPtr& methchain, const edm::TypeWithDict& iType, bool lazy = false)
3636
: methchain_(&methchain), lazy_(lazy) {
3737
typeStack.push_back(iType);
3838
}
@@ -59,18 +59,18 @@ namespace reco {
5959
metharg = (strict_real_p[methodArg_s]) | (int_p[methodArg_s]) |
6060
(ch_p('"') >> *(~ch_p('"')) >> ch_p('"'))[methodArg_s] |
6161
(ch_p('\'') >> *(~ch_p('\'')) >> ch_p('\''))[methodArg_s];
62-
method = // alnum_p doesn't accept underscores, so we use chset<>; lexeme_d needed to avoid whitespace skipping within method names
63-
(lexeme_d[alpha_p >> *chset<>("a-zA-Z0-9_")] >> ch_p('(') >> metharg >> *(ch_p(',') >> metharg) >>
64-
expectParenthesis(ch_p(')')))[method_s] |
65-
((lexeme_d[alpha_p >> *chset<>("a-zA-Z0-9_")])[method_s] >> !(ch_p('(') >> ch_p(')')));
62+
method = // alnum_p doesn't accept underscores, so we use chset<>; lexeme_d needed to avoid whitespace skipping within method names
63+
(lexeme_d[alpha_p >> *chset<>("a-zA-Z0-9_")] >> ch_p('(') >> metharg >> *(ch_p(',') >> metharg) >>
64+
expectParenthesis(ch_p(')')))[method_s] |
65+
((lexeme_d[alpha_p >> *chset<>("a-zA-Z0-9_")])[method_s] >> !(ch_p('(') >> ch_p(')')));
6666
arrayAccess = (ch_p('[') >> metharg >> *(ch_p(',') >> metharg) >> expectParenthesis(ch_p(']')))[method_s];
6767
methodchain = (method >> *(arrayAccess | (ch_p('.') >> expect(method))))[methodchain_s];
6868
}
6969

7070
rule const& start() const { return methodchain; }
7171
};
7272
};
73-
}
74-
}
73+
} // namespace parser
74+
} // namespace reco
7575

7676
#endif

CommonTools/Utils/src/MethodChain.cc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,9 @@ MethodChain::Objects MethodChain::initObjects_() const {
2828
return objects;
2929
}
3030

31-
MethodChain::MethodChain(const vector<MethodInvoker>& methods)
32-
: methods_(methods) {
33-
returnObjects(initObjects_());
34-
}
31+
MethodChain::MethodChain(const vector<MethodInvoker>& methods) : methods_(methods) { returnObjects(initObjects_()); }
3532

36-
MethodChain::MethodChain(const MethodChain& rhs) : methods_(rhs.methods_) {
37-
returnObjects(initObjects_());
38-
}
33+
MethodChain::MethodChain(const MethodChain& rhs) : methods_(rhs.methods_) { returnObjects(initObjects_()); }
3934

4035
MethodChain::Objects MethodChain::borrowObjects() const {
4136
Objects objects;

PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ template <typename ObjType, typename CollectionStringFunctor, typename Precision
8787
class FuncCollectionVariable : public CollectionVariable<ObjType> {
8888
public:
8989
FuncCollectionVariable(const std::string &aname, const edm::ParameterSet &cfg)
90-
: CollectionVariable<ObjType>(aname, cfg),
91-
func_(cfg.getParameter<std::string>("expr"), cfg.getUntrackedParameter<bool>("lazyEval")),
92-
precisionFunc_(cfg.existsAs<std::string>("precision") ? cfg.getParameter<std::string>("precision") : "23",
93-
cfg.getUntrackedParameter<bool>("lazyEval")) {}
90+
: CollectionVariable<ObjType>(aname, cfg),
91+
func_(cfg.getParameter<std::string>("expr"), cfg.getUntrackedParameter<bool>("lazyEval")),
92+
precisionFunc_(cfg.existsAs<std::string>("precision") ? cfg.getParameter<std::string>("precision") : "23",
93+
cfg.getUntrackedParameter<bool>("lazyEval")) {}
9494
~FuncCollectionVariable() override {}
95-
96-
std::unique_ptr<std::vector<unsigned int>> getCounts(std::vector<const ObjType *> &selobjs) const override{
95+
96+
std::unique_ptr<std::vector<unsigned int>> getCounts(std::vector<const ObjType *> &selobjs) const override {
9797
auto counts = std::make_unique<std::vector<unsigned int>>();
9898
for (auto const &obj : selobjs)
9999
counts->push_back(func_(*obj).size());
@@ -119,8 +119,8 @@ class FuncCollectionVariable : public CollectionVariable<ObjType> {
119119
}
120120

121121
protected:
122-
CollectionStringFunctor func_; // functor to get collection objects
123-
PrecisionStringFunctor precisionFunc_; // functor to get output precision
122+
CollectionStringFunctor func_; // functor to get collection objects
123+
PrecisionStringFunctor precisionFunc_; // functor to get output precision
124124
};
125125

126126
// External variables: i.e. variables that are not member or methods of the object
@@ -538,19 +538,21 @@ class SimpleTypedExternalFlatTableProducer : public SimpleFlatTableProducer<T> {
538538

539539
template <typename T>
540540
class SimpleCollectionFlatTableProducer : public SimpleFlatTableProducer<T> {
541-
public:
541+
public:
542542
SimpleCollectionFlatTableProducer(edm::ParameterSet const &params) : SimpleFlatTableProducer<T>(params) {
543543
if (params.existsAs<edm::ParameterSet>("collectionVariables")) {
544544
edm::ParameterSet const &collectionVarsPSet = params.getParameter<edm::ParameterSet>("collectionVariables");
545-
for (const std::string &coltablename : collectionVarsPSet.getParameterNamesForType<edm::ParameterSet>()) { // tables of variables
545+
for (const std::string &coltablename :
546+
collectionVarsPSet.getParameterNamesForType<edm::ParameterSet>()) { // tables of variables
546547
const auto &coltablePSet = collectionVarsPSet.getParameter<edm::ParameterSet>(coltablename);
547548
CollectionVariableTableInfo coltable;
548-
coltable.name = coltablePSet.existsAs<std::string>("name") ? coltablePSet.getParameter<std::string>("name") : coltablename;
549+
coltable.name =
550+
coltablePSet.existsAs<std::string>("name") ? coltablePSet.getParameter<std::string>("name") : coltablename;
549551
coltable.doc = coltablePSet.getParameter<std::string>("doc");
550552
coltable.useCount = coltablePSet.getParameter<bool>("useCount");
551553
coltable.useOffset = coltablePSet.getParameter<bool>("useOffset");
552554
const auto &colvarsPSet = coltablePSet.getParameter<edm::ParameterSet>("variables");
553-
for (const std::string &colvarname : colvarsPSet.getParameterNamesForType<edm::ParameterSet>()) { // variables
555+
for (const std::string &colvarname : colvarsPSet.getParameterNamesForType<edm::ParameterSet>()) { // variables
554556
const auto &colvarPSet = colvarsPSet.getParameter<edm::ParameterSet>(colvarname);
555557
const std::string &type = colvarPSet.getParameter<std::string>("type");
556558
if (type == "int")
@@ -568,7 +570,8 @@ class SimpleCollectionFlatTableProducer : public SimpleFlatTableProducer<T> {
568570
else if (type == "uint16")
569571
coltable.colvars.push_back(std::make_unique<UInt16VectorVar>(colvarname, colvarPSet));
570572
else
571-
throw cms::Exception("Configuration", "unsupported type " + type + " for variable " + colvarname + " in " + coltablename);
573+
throw cms::Exception("Configuration",
574+
"unsupported type " + type + " for variable " + colvarname + " in " + coltablename);
572575
}
573576
this->coltables.push_back(std::move(coltable));
574577
edm::stream::EDProducer<>::produces<nanoaod::FlatTable>(coltables.back().name + "Table");
@@ -581,14 +584,14 @@ class SimpleCollectionFlatTableProducer : public SimpleFlatTableProducer<T> {
581584
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
582585
edm::ParameterSetDescription desc = SimpleFlatTableProducer<T>::baseDescriptions();
583586
edm::ParameterSetDescription colvariable;
584-
colvariable.add<std::string>("expr")->setComment("a function to define the content of the branch in the flat table");
587+
colvariable.add<std::string>("expr")->setComment(
588+
"a function to define the content of the branch in the flat table");
585589
colvariable.add<std::string>("doc")->setComment("few words of self documentation");
586590
colvariable.addUntracked<bool>("lazyEval", false)
587591
->setComment("if true, can use methods of inheriting classes in `expr`. Can cause problems with threading.");
588-
colvariable.ifValue(
589-
edm::ParameterDescription<std::string>(
590-
"type", "int", true, edm::Comment("the c++ type of the branch in the flat table")),
591-
edm::allowedValues<std::string>("int", "uint", "float", "double", "uint8", "int16", "uint16"));
592+
colvariable.ifValue(edm::ParameterDescription<std::string>(
593+
"type", "int", true, edm::Comment("the c++ type of the branch in the flat table")),
594+
edm::allowedValues<std::string>("int", "uint", "float", "double", "uint8", "int16", "uint16"));
592595
colvariable.addOptionalNode(
593596
edm::ParameterDescription<int>(
594597
"precision", true, edm::Comment("the precision with which to store the value in the flat table")) xor
@@ -599,10 +602,12 @@ class SimpleCollectionFlatTableProducer : public SimpleFlatTableProducer<T> {
599602
colvariables.setComment("a parameters set to define all variable to fill the flat table");
600603
colvariables.addNode(
601604
edm::ParameterWildcard<edm::ParameterSetDescription>("*", edm::RequireAtLeastOne, true, colvariable));
602-
605+
603606
edm::ParameterSetDescription coltable;
604-
coltable.addOptional<std::string>("name")->setComment("name of the branch in the flat table containing flatten collections of variables");
605-
coltable.add<std::string>("doc")->setComment("few words description of the table containing flatten collections of variables");
607+
coltable.addOptional<std::string>("name")->setComment(
608+
"name of the branch in the flat table containing flatten collections of variables");
609+
coltable.add<std::string>("doc")->setComment(
610+
"few words description of the table containing flatten collections of variables");
606611
coltable.add<bool>("useCount", true)
607612
->setComment("whether to use count for the main table to index table with flatten collections of variables");
608613
coltable.add<bool>("useOffset", false)
@@ -674,27 +679,32 @@ class SimpleCollectionFlatTableProducer : public SimpleFlatTableProducer<T> {
674679
out->template addColumn<uint16_t>("o" + coltable.name, offsets, "offsets for " + coltable.name);
675680
}
676681

677-
std::unique_ptr<nanoaod::FlatTable> outcoltable = std::make_unique<nanoaod::FlatTable>(coltablesize, coltable.name, false, false);
682+
std::unique_ptr<nanoaod::FlatTable> outcoltable =
683+
std::make_unique<nanoaod::FlatTable>(coltablesize, coltable.name, false, false);
678684
for (const auto &colvar : coltable.colvars) {
679685
colvar->fill(selobjs, *outcoltable);
680686
}
681687
outcoltable->setDoc(coltable.doc);
682688
iEvent.put(std::move(outcoltable), coltable.name + "Table");
683689
}
684-
690+
685691
// put the main table into the event
686692
out->setDoc(this->doc_);
687693
iEvent.put(std::move(out));
688694
}
689695

690696
protected:
691-
typedef FuncCollectionVariable<T, TypedStringObjectMethodCaller<T, std::vector<int32_t>>, StringObjectFunction<T>, int32_t> IntVectorVar;
692-
typedef FuncCollectionVariable<T, TypedStringObjectMethodCaller<T, std::vector<uint32_t>>, StringObjectFunction<T>, uint32_t> UIntVectorVar;
693-
typedef FuncCollectionVariable<T, TypedStringObjectMethodCaller<T, std::vector<float>>, StringObjectFunction<T>, float> FloatVectorVar;
694-
typedef FuncCollectionVariable<T, TypedStringObjectMethodCaller<T, std::vector<double>>, StringObjectFunction<T>, double> DoubleVectorVar;
695-
typedef FuncCollectionVariable<T, TypedStringObjectMethodCaller<T, std::vector<uint8_t>>, StringObjectFunction<T>, uint8_t> UInt8VectorVar;
696-
typedef FuncCollectionVariable<T, TypedStringObjectMethodCaller<T, std::vector<int16_t>>, StringObjectFunction<T>, int16_t> Int16VectorVar;
697-
typedef FuncCollectionVariable<T, TypedStringObjectMethodCaller<T, std::vector<uint16_t>>, StringObjectFunction<T>, uint16_t> UInt16VectorVar;
697+
template <typename R>
698+
using VectorVar =
699+
FuncCollectionVariable<T, TypedStringObjectMethodCaller<T, std::vector<R>>, StringObjectFunction<T>, R>;
700+
701+
using IntVectorVar = VectorVar<int32_t>;
702+
using UIntVectorVar = VectorVar<uint32_t>;
703+
using FloatVectorVar = VectorVar<float>;
704+
using DoubleVectorVar = VectorVar<double>;
705+
using UInt8VectorVar = VectorVar<uint8_t>;
706+
using Int16VectorVar = VectorVar<int16_t>;
707+
using UInt16VectorVar = VectorVar<uint16_t>;
698708

699709
struct CollectionVariableTableInfo {
700710
std::string name;

0 commit comments

Comments
 (0)