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

Runs after LEM on the high-mem node, returns results to the server. More...

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

Public Types

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

Public Member Functions

 LEMWorkerOutput (const Parameters &params)
 
 ~LEMWorkerOutput ()
 
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

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

Protected Attributes

LEMWorkerOutputParams fParams
 
std::string fWorkerID
 

Detailed Description

Runs after LEM on the high-mem node, returns results to the server.

Definition at line 50 of file LEMWorkerOutput_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

Definition at line 54 of file LEMWorkerOutput_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::LEMWorkerOutput::LEMWorkerOutput ( const Parameters params)
explicit

Definition at line 71 of file LEMWorkerOutput_module.cc.

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

72  : fParams(params())
73  {
74  // Generate a unique ID so that the server can identify us.
75  char host[1024];
76  gethostname(host, 1023);
77  host[1023] = 0;
78  const char* user = getenv("USER");
79  if(!user) user = "(unknown)";
80  fWorkerID = TString::Format("%s@%s.%d.%ld",
81  user, host, getpid(), time(0)).Data();
82 
83  curl_global_init(CURL_GLOBAL_ALL);
84  }
::xsd::cxx::tree::time< char, simple_type > time
Definition: Database.h:194
std::string getenv(std::string const &name)
LEMWorkerOutputParams fParams
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
lem::LEMWorkerOutput::~LEMWorkerOutput ( )

Definition at line 87 of file LEMWorkerOutput_module.cc.

88  {
89  curl_global_cleanup();
90  }

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  }
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::LEMWorkerOutput::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 158 of file LEMWorkerOutput_module.cc.

References ana::assert(), DEFINE_ART_MODULE(), art::Handle< T >::failedToGet(), fParams, art::DataViewImpl::getByLabel(), ReturnResults(), string, and getGoodRuns4SAM::tag.

159  {
161  evt.getByLabel(fParams.pidLabel(), pidcol);
162  assert(!pidcol.failedToGet());
163  assert(!pidcol->empty());
164 
166  evt.getByLabel(fParams.inputLabel(), inputcol);
167  assert(inputcol->size() == 1);
168  const std::string tag = (*inputcol)[0].tag;
169  assert(pidcol->size() == 1);
170 
171  ReturnResults(tag, (*pidcol)[0]);
172  }
void ReturnResults(const std::string &tag, const PIDDetails &pid) const
LEMWorkerOutputParams fParams
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
assert(nhit_max >=nhit_nbins)
bool failedToGet() const
Definition: Handle.h:196
enum BeamMode string
void lem::LEMWorkerOutput::ReturnResults ( const std::string tag,
const PIDDetails pid 
) const
protected

Definition at line 123 of file LEMWorkerOutput_module.cc.

References make_syst_table_plots::args, genie::utils::style::Format(), fParams, fWorkerID, lem::ReturnResultsArgs::params, lem::ReturnResultsArgs::postdata, lem::LEMWebSettings::queryTimeout, lem::ReturnResultsThreadFunc(), string, lem::PIDDetails::ToString(), and lem::ReturnResultsArgs::web.

Referenced by produce().

125  {
126  // Don't hang around waiting for the server to receive our results when we
127  // could be getting started on the next event to ID. Implement a "fire and
128  // forget" scheme.
129 
130  static bool once = true;
131  static pthread_t thread;
132  if(once){
133  once = false;
134  }
135  else{
136  // Always make sure the previous result was received so that we don't try
137  // to have multiple in flight. In case eg there really is a problem with
138  // our connectivity.
139  pthread_join(thread, 0);
140  }
141 
142  const LEMWebSettings& web = fParams.web();
143 
144  const std::string params = TString::Format("return_results?tag=%s&id=%s&timeout=%d",
145  tag.c_str(),
146  fWorkerID.c_str(),
147  web.queryTimeout()).Data();
148 
149  ReturnResultsArgs* args = new ReturnResultsArgs;
150  args->params = params;
151  args->postdata = pid.ToString();
152  args->web = web;
153 
154  pthread_create(&thread, 0, ReturnResultsThreadFunc, args);
155  }
void * ReturnResultsThreadFunc(void *x)
LEMWorkerOutputParams fParams
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
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

LEMWorkerOutputParams lem::LEMWorkerOutput::fParams
protected

Definition at line 65 of file LEMWorkerOutput_module.cc.

Referenced by produce(), and ReturnResults().

std::string lem::LEMWorkerOutput::fWorkerID
protected

Definition at line 67 of file LEMWorkerOutput_module.cc.

Referenced by LEMWorkerOutput(), and ReturnResults().


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