Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
lem::LEMWorker Class Reference

This runs on a high-mem node and reconstitutes LEMSummary events. More...

Inheritance diagram for lem::LEMWorker:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using Parameters = art::EDProducer::Table< LEMWorkerParams >
 
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 LEMWorker (const Parameters &params)
 
 ~LEMWorker ()
 
virtual void produce (art::Event &evt)
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< Tconsumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< Tconsumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TconsumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< TmayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< TmayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TmayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

std::string GetWork () const
 
CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Protected Attributes

LEMWorkerParams fParams
 
std::string fWorkerID
 

Detailed Description

This runs on a high-mem node and reconstitutes LEMSummary events.

Definition at line 48 of file LEMWorker_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

Definition at line 52 of file LEMWorker_module.cc.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

lem::LEMWorker::LEMWorker ( const Parameters params)
explicit

Definition at line 68 of file LEMWorker_module.cc.

References genie::utils::style::Format(), fWorkerID, cet::getenv(), drop_table::host, and drop_table::user.

69  : fParams(params())
70  {
71  produces<std::vector<LEMInput>>();
72 
73  // Randomize ports and so on properly
74  srand(getpid());
75 
76  // Generate a unique ID so that the server can identify us, eg to detect
77  // duplicate requests.
78  char host[1024];
79  gethostname(host, 1023);
80  host[1023] = 0;
81  const char* user = getenv("USER");
82  if(!user) user = "(unknown)";
83  fWorkerID = TString::Format("%s@%s.%d.%ld",
84  user, host, getpid(), time(0)).Data();
85 
86  curl_global_init(CURL_GLOBAL_ALL);
87  }
LEMWorkerParams fParams
::xsd::cxx::tree::time< char, simple_type > time
Definition: Database.h:194
std::string fWorkerID
std::string getenv(std::string const &name)
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
lem::LEMWorker::~LEMWorker ( )

Definition at line 90 of file LEMWorker_module.cc.

91  {
92  curl_global_cleanup();
93  }

Member Function Documentation

template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 146 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

147 {
148  if (!moduleContext_)
149  return ProductToken<T>::invalid();
150 
151  consumables_[BT].emplace_back(ConsumableType::Product,
152  TypeID{typeid(T)},
153  it.label(),
154  it.instance(),
155  it.process());
156  return ProductToken<T>{it};
157 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 161 of file Consumer.h.

References T.

162 {
163  if (!moduleContext_)
164  return;
165 
166  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
167 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 171 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

172 {
173  if (!moduleContext_)
174  return ViewToken<T>::invalid();
175 
176  consumables_[BT].emplace_back(ConsumableType::ViewElement,
177  TypeID{typeid(T)},
178  it.label(),
179  it.instance(),
180  it.process());
181  return ViewToken<T>{it};
182 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited
CurrentProcessingContext const* art::EDProducer::currentContext ( ) const
protectedinherited
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

Referenced by skim::NueSkimmer::CopyMichelSlice(), and skim::NueSkimmer::CopyMichelTrack().

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
std::string lem::LEMWorker::GetWork ( ) const
protected

Definition at line 125 of file LEMWorker_module.cc.

References make_syst_table_plots::args, genie::utils::style::Format(), fParams, fWorkerID, lem::get_release(), lem::GetWorkThreadFunc(), lem::GetWorkArgs::params, febshutoff_auto::query, lem::LEMWebSettings::queryTimeout, shutoffs::rel, runNovaSAM::ret, string, and lem::GetWorkArgs::web.

Referenced by produce().

126  {
127  // Instead of hanging around wasting valuable computation time waiting for
128  // the server to give us the next event, fetch the next one in parallel
129  // with ID'ing the previous event and hopefully have it ready when
130  // produce() wants it.
131 
132  static bool once = true;
133  static pthread_t thread;
134 
135  const LEMWebSettings& web = fParams.web();
136 
137  const std::string rel = fParams.releaseOverride().empty() ? get_release() : fParams.releaseOverride();
138 
139  const std::string query = TString::Format("get_work?rel=%s&id=%s&timeout=%d",
140  rel.c_str(),
141  fWorkerID.c_str(),
142  web.queryTimeout()).Data();
143 
144  GetWorkArgs* args = new GetWorkArgs;
145 
146  args->params = query;
147  args->web = web;
148 
149  void* ret;
150  if(once){
151  once = false;
152  // First time out just make a synchronous call to get the ball rolling.
153  // Clone the args since the thread function deletes them
154  ret = GetWorkThreadFunc(new GetWorkArgs(*args));
155  }
156  else{
157  // Otherwise, fetch the result from the thread, wait for it if necessary.
158  pthread_join(thread, &ret);
159  }
160 
161  // Get ahold of the result more safely.
162  const std::string work = *((std::string*)ret);
163  delete (std::string*)ret;
164 
165  // And fire up a new request, ready for next time.
166  pthread_create(&thread, 0, GetWorkThreadFunc, args);
167 
168  return work;
169  }
LEMWorkerParams fParams
std::string fWorkerID
void * GetWorkThreadFunc(void *x)
std::string get_release()
Figure out the current release. TODO: does this belong somewhere else?
Definition: WebUtils.cxx:178
string rel
Definition: shutoffs.py:11
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
enum BeamMode string
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 189 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

190 {
191  if (!moduleContext_)
192  return ProductToken<T>::invalid();
193 
194  consumables_[BT].emplace_back(ConsumableType::Product,
195  TypeID{typeid(T)},
196  it.label(),
197  it.instance(),
198  it.process());
199  return ProductToken<T>{it};
200 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 204 of file Consumer.h.

References T.

205 {
206  if (!moduleContext_)
207  return;
208 
209  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
210 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 214 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

215 {
216  if (!moduleContext_)
217  return ViewToken<T>::invalid();
218 
219  consumables_[BT].emplace_back(ConsumableType::ViewElement,
220  TypeID{typeid(T)},
221  it.label(),
222  it.instance(),
223  it.process());
224  return ViewToken<T>{it};
225 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID(), and string.

41  {
42  return true;
43  }
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void lem::LEMWorker::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 172 of file LEMWorker_module.cc.

References ana::assert(), lem::LiteHit::cellIdx, DEFINE_ART_MODULE(), GetWork(), getGoodRuns4SAM::n, lem::LiteHit::pecorr, art::Event::put(), string, and lem::LEMInput::tag.

173  {
174  const std::string work = GetWork();
175 
176  char workstr[work.size()+1];
177  strcpy(workstr, work.c_str());
178 
179  LEMInput input;
180 
181  input.tag = &strtok(workstr, "\n")[4]; // skip over "tag="
182 
183  char* estr = strtok(0, "\n");
184  assert(estr);
185  int n = sscanf(estr, "E=%lf", &input.totalGeV);
186  assert(n == 1);
187 
188  while(char* chanqstr = strtok(0, "\n")){
189  LiteHit hit;
190  n = sscanf(chanqstr, "%hu %f", &hit.cellIdx, &hit.pecorr);
191  assert(n == 2);
192  input.hits.push_back(hit);
193  }
194 
195  std::unique_ptr<std::vector<LEMInput>> sumcol(new std::vector<LEMInput>(1, input));
196  evt.put(std::move(sumcol));
197  }
std::string GetWork() const
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
Definition: structs.h:12
assert(nhit_max >=nhit_nbins)
enum BeamMode string
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Referenced by art::RootOutput::endJob().

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Member Data Documentation

LEMWorkerParams lem::LEMWorker::fParams
protected

Definition at line 62 of file LEMWorker_module.cc.

Referenced by GetWork().

std::string lem::LEMWorker::fWorkerID
protected

Definition at line 64 of file LEMWorker_module.cc.

Referenced by GetWork(), and LEMWorker().


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