Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
AssnAnalyzer Class Reference
Inheritance diagram for AssnAnalyzer:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Types

typedef std::vector< int > intvec_t
 
typedef std::vector< std::stringstrvec_t
 
typedef art::Assns< std::string, int > strintAssns_t
 
- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 AssnAnalyzer (fhicl::ParameterSet const &p)
 
 AssnAnalyzer (AssnAnalyzer const &)=delete
 
 AssnAnalyzer (AssnAnalyzer &&)=delete
 
AssnAnalyzeroperator= (AssnAnalyzer const &)=delete
 
AssnAnalyzeroperator= (AssnAnalyzer &&)=delete
 
void analyze (art::Event const &e) override
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void for_each_associated_group_test (art::Event const &e) const
 
void associated_groups_test (art::Event const &e) const
 
void associated_groups_with_left_test (art::Event const &e) const
 

Private Attributes

art::InputTag fInputLabel
 
std::set< std::stringfEnabledTests
 

Additional Inherited Members

- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 30 of file AssnAnalyzer_module.cc.

Member Typedef Documentation

Definition at line 32 of file AssnAnalyzer_module.cc.

Definition at line 34 of file AssnAnalyzer_module.cc.

Definition at line 33 of file AssnAnalyzer_module.cc.

Constructor & Destructor Documentation

AssnAnalyzer::AssnAnalyzer ( fhicl::ParameterSet const &  p)
explicit

Definition at line 69 of file AssnAnalyzer_module.cc.

70  :
71  EDAnalyzer(p)
72  , fInputLabel(p.get<art::InputTag>("input_label"))
73 {
74  auto enableTests = p.get<std::vector<std::string>>("enableTests");
75  if (enableTests.empty()) {
76  fEnabledTests = {
77  "forEachAssociatedGroup", "associatedGroups", "associatedGroupsWithLeft"
78  };
79  }
80  else {
81  std::copy(enableTests.begin(), enableTests.end(),
82  std::inserter(fEnabledTests, fEnabledTests.begin()));
83  }
84 }
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
std::set< std::string > fEnabledTests
p
Definition: test.py:223
T copy(T const &v)
art::InputTag fInputLabel
AssnAnalyzer::AssnAnalyzer ( AssnAnalyzer const &  )
delete
AssnAnalyzer::AssnAnalyzer ( AssnAnalyzer &&  )
delete

Member Function Documentation

void AssnAnalyzer::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 87 of file AssnAnalyzer_module.cc.

88 {
89  if (fEnabledTests.count("forEachAssociatedGroup"))
91  if (fEnabledTests.count("associatedGroups"))
93  if (fEnabledTests.count("associatedGroupsWithLeft"))
95 }
void associated_groups_test(art::Event const &e) const
std::set< std::string > fEnabledTests
const double e
void associated_groups_with_left_test(art::Event const &e) const
void for_each_associated_group_test(art::Event const &e) const
void AssnAnalyzer::associated_groups_test ( art::Event const &  e) const
private

Definition at line 125 of file AssnAnalyzer_module.cc.

126 {
127  // this is the exact same test as for_each_associated_group_test(),
128  // but written with an explicit loop
129 
130  typedef typename art::Assns<int, std::string> istr_assns;
131  auto const & int_to_str_assns = *e.getValidHandle<istr_assns> (fInputLabel);
132  auto vs = strvec_t {"one", "one-a", "two", "two-a", "three", "three-a"};
133 
134  strvec_t strvec;
135  for (auto strs: util::associated_groups(int_to_str_assns)) {
136  for(art::Ptr<std::string> const& s: strs) {
137  std::cout << s << std::flush << " \"" << *s << "\"" << std::endl;
138  strvec.push_back(*s);
139  }
140  } // for associated groups
141 
142  //strings should be same as vs
143  for(auto k=0; k<6;++k) {
144  if (strvec[k] != vs[k]) {
146  << "String #" << k << " expected to be '" << vs[k]
147  << "', got '" << strvec[k] << "' instead!\n";
148  }
149  }
150 
151 } // associated_groups_test()
auto associated_groups(A const &assns)
Helper functions to access associations in order.
const double e
QTextStream & flush(QTextStream &s)
std::vector< std::string > strvec_t
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
art::InputTag fInputLabel
Definition: fwd.h:31
static QCString * s
Definition: config.cpp:1042
QTextStream & endl(QTextStream &s)
void AssnAnalyzer::associated_groups_with_left_test ( art::Event const &  e) const
private

Definition at line 154 of file AssnAnalyzer_module.cc.

155 {
156  // this is the exact same test as associated_groups_test(),
157  // but passing around also the key
158 
159  typedef typename art::Assns<int, std::string> istr_assns;
160  auto const & int_to_str_assns = *e.getValidHandle<istr_assns> (fInputLabel);
161  std::vector<std::pair<int, std::string>> vs = {
162  { 1, "one" },
163  { 1, "one-a" },
164  { 2, "two" },
165  { 2, "two-a" },
166  { 3, "three" },
167  { 3, "three-a" }
168  };
169 
170  std::vector<std::pair<int, std::string>> strvec;
171  for (auto const& group: util::associated_groups_with_left(int_to_str_assns))
172  {
173  // user code here:
174  auto const& key = std::get<0>(group); // group.first also ok
175  auto const& strs = std::get<1>(group); // group.second also ok
176 
177  std::cout << "#" << (*key) << " (" << key << ")" << std::endl;
178  for(art::Ptr<std::string> const& s: strs) {
179  std::cout << " - " << s << " \"" << *s << "\"" << std::endl;
180  strvec.emplace_back(*key, *s);
181  }
182  } // for associated groups
183 
184  //strings should be same as vs
185  for(auto k=0; k<6;++k) {
186  std::string const& s = strvec[k].second;
187  int key = 0; // (unknown)
188  if (starts_with(s, "one" )) key = 1;
189  else if (starts_with(s, "two" )) key = 2;
190  else if (starts_with(s, "three")) key = 3;
191 
192  if (key != vs[k].first) {
194  << "String #" << k << " expected to have key '" << vs[k].first
195  << "', got '" << key << "' instead!\n";
196  }
197 
198  if (s != vs[k].second) {
200  << "String #" << k << " expected to be '" << vs[k].second
201  << "', got '" << s << "' instead!\n";
202  }
203 
204  }
205 
206 } // associated_groups_test()
auto associated_groups_with_left(A const &assns)
Helper functions to access associations in order, also with key.
std::string string
Definition: nybbler.cc:12
const double e
def key(type, name=None)
Definition: graph.py:13
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
art::InputTag fInputLabel
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
Definition: fwd.h:31
static QCString * s
Definition: config.cpp:1042
QTextStream & endl(QTextStream &s)
void AssnAnalyzer::for_each_associated_group_test ( art::Event const &  e) const
private

Definition at line 97 of file AssnAnalyzer_module.cc.

98 {
99  typedef typename art::Assns<int, std::string> istr_assns;
100  auto const & int_to_str_assns = *e.getValidHandle<istr_assns> (fInputLabel);
101  auto vs = strvec_t {"one", "one-a", "two", "two-a", "three", "three-a"};
102 
103  strvec_t strvec;
104  auto strings = [&strvec](auto strs) {
105  for(auto s=begin(strs); s!=end(strs); ++s) {
106  std::cout << *s << std::flush << " \"" << **s << "\"" << std::endl;
107  strvec.push_back(**s);
108  }
109  };
110 
111  art::for_each_group(int_to_str_assns, strings);
112 
113  //strings should be same as vs
114  for(auto k=0; k<6;++k) {
115  if (strvec[k] != vs[k]) {
117  << "String #" << k << " expected to be '" << vs[k]
118  << "', got '" << strvec[k] << "' instead!\n";
119  }
120  }
121 
122 } // for_each_associated_group_test()
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
const double e
QTextStream & flush(QTextStream &s)
std::vector< std::string > strvec_t
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void for_each_group(art::Assns< A, B, D > const &assns, F func)
Helper functions to access associations in order.
art::InputTag fInputLabel
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
static QCString * s
Definition: config.cpp:1042
QTextStream & endl(QTextStream &s)
AssnAnalyzer& AssnAnalyzer::operator= ( AssnAnalyzer const &  )
delete
AssnAnalyzer& AssnAnalyzer::operator= ( AssnAnalyzer &&  )
delete

Member Data Documentation

std::set<std::string> AssnAnalyzer::fEnabledTests
private

Definition at line 52 of file AssnAnalyzer_module.cc.

art::InputTag AssnAnalyzer::fInputLabel
private

Definition at line 50 of file AssnAnalyzer_module.cc.


The documentation for this class was generated from the following file: