Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
LSTME::FillLSTME Class Reference
Inheritance diagram for LSTME::FillLSTME:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

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

Public Member Functions

 FillLSTME (const fhicl::ParameterSet &pset)
 
 FillLSTME (FillLSTME const &)=delete
 
 FillLSTME (FillLSTME &&)=delete
 
FillLSTMEoperator= (FillLSTME const &)=delete
 
FillLSTMEoperator= (FillLSTME &&)=delete
 
void produce (art::Event &evt) override
 
void reconfigure (const fhicl::ParameterSet &pset)
 
void fillEnergies (art::Event &evt, std::unique_ptr< std::vector< LSTMEnergy >> &sliceEnergies, std::unique_ptr< art::Assns< LSTMEnergy, rb::Cluster >> &sliceEnergyAssoc)
 
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

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

Private Member Functions

bool getIsRHC (const art::Event &evt)
 
ModelselectModel (const art::Event &evt)
 
LSTMEnergy predictEnergy (Model &model, const art::Event &evt, const art::Handle< std::vector< rb::Cluster >> &slices_h, size_t sliceIdx, const std::vector< art::Ptr< rb::Vertex >> &elastics, const std::vector< bool > &sliceIsMC)
 

Private Attributes

Config config
 
std::string generatorLabel
 
std::string beamLabel
 
Model modelFDFHC
 
Model modelFDRHC
 
Model modelNDFHC
 
Model modelNDRHC
 
bool fObeyPreselection
 
std::vector< std::stringfPreselectionLabels
 
bool useOppositeHornCurrentNetwork
 

Detailed Description

Definition at line 33 of file FillLSTME_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

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

LSTME::FillLSTME::FillLSTME ( const fhicl::ParameterSet pset)
explicit

Definition at line 85 of file FillLSTME_module.cc.

References reconfigure().

86  : modelFDFHC(util::EnvExpansion(pset.get<std::string>("modelFDFHC"))),
87  modelFDRHC(util::EnvExpansion(pset.get<std::string>("modelFDRHC"))),
88  modelNDFHC(util::EnvExpansion(pset.get<std::string>("modelNDFHC"))),
89  modelNDRHC(util::EnvExpansion(pset.get<std::string>("modelNDRHC"))),
90  fObeyPreselection (pset.get<bool> ("ObeyPreselection" )),
91  fPreselectionLabels(pset.get<std::vector<std::string>> ("PreselectionLabels")),
92  useOppositeHornCurrentNetwork(pset.get<bool>("useOppositeHornCurrentNetwork"))
93 {
94  reconfigure(pset);
95 
96  produces<std::vector<LSTMEnergy>>();
97  produces<art::Assns<LSTMEnergy, rb::Cluster>>();
98 }
bool useOppositeHornCurrentNetwork
void reconfigure(const fhicl::ParameterSet &pset)
std::vector< std::string > fPreselectionLabels
std::string EnvExpansion(const std::string &inString)
Function to expand environment variables.
Definition: EnvExpand.cxx:8
T get(std::string const &key) const
Definition: ParameterSet.h:231
enum BeamMode string
LSTME::FillLSTME::FillLSTME ( FillLSTME const &  )
delete
LSTME::FillLSTME::FillLSTME ( FillLSTME &&  )
delete

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
void LSTME::FillLSTME::fillEnergies ( art::Event evt,
std::unique_ptr< std::vector< LSTMEnergy >> &  sliceEnergies,
std::unique_ptr< art::Assns< LSTMEnergy, rb::Cluster >> &  sliceEnergyAssoc 
)

Definition at line 193 of file FillLSTME_module.cc.

References util::CreateAssn(), allTimeWatchdog::endl, energy, fObeyPreselection, fPreselectionLabels, art::DataViewImpl::getByLabel(), getSliceIsMC(), rb::IsFiltered(), rb::Cluster::IsNoise(), predictEnergy(), and selectModel().

Referenced by produce().

198 {
200  if (! evt.getByLabel(config.sliceLabel, slices_h)) {
201  mf::LogError("FillLSTME") << "Failed to get slice info" << std::endl;
202  return;
203  }
204 
205  art::FindManyP<rb::Vertex> elasticVxt_fmp(
206  slices_h, evt, config.elasticArmsLabel
207  );
208  if (! elasticVxt_fmp.isValid()) {
209  mf::LogError("FillLSTME") << "No elastics found" << std::endl;
210  return;
211  }
212 
213  Model &model = selectModel(evt);
214  std::vector<bool> sliceIsMC = getSliceIsMC(*slices_h);
215 
216  for (size_t sliceIdx = 0; sliceIdx < slices_h->size(); ++sliceIdx)
217  {
218  const art::Ptr<rb::Cluster> slicePtr(slices_h, sliceIdx);
219 
220  if (slicePtr->IsNoise()) {
221  continue;
222  }
223 
224  if(fObeyPreselection && rb::IsFiltered(evt, slices_h, sliceIdx, fPreselectionLabels)) continue;
225 
226  auto elastics = elasticVxt_fmp.at(sliceIdx);
227 
228  LSTMEnergy energy = predictEnergy(
229  model, evt, slices_h, sliceIdx, elastics, sliceIsMC
230  );
231 
232  sliceEnergies->emplace_back(std::move(energy));
233 
235  *this, evt,
236  *(sliceEnergies.get()), slicePtr, *(sliceEnergyAssoc.get())
237  );
238  }
239 }
static bool CreateAssn(art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
Create a 1 to 1 association between a new product and one already in the event.
std::vector< std::string > fPreselectionLabels
Definition: config.py:1
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
LSTMEnergy predictEnergy(Model &model, const art::Event &evt, const art::Handle< std::vector< rb::Cluster >> &slices_h, size_t sliceIdx, const std::vector< art::Ptr< rb::Vertex >> &elastics, const std::vector< bool > &sliceIsMC)
rosenbrock_model_namespace::rosenbrock_model Model
double energy
Definition: plottest35.C:25
bool IsFiltered(const art::Event &evt, art::Ptr< T > x, const std::vector< std::string > &labels)
Is this Ptr marked "filtered out"?
Definition: FilterList.h:96
Model & selectModel(const art::Event &evt)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
std::vector< bool > getSliceIsMC(const std::vector< rb::Cluster > &slices)
Definition: utils.cxx:6
const XML_Char XML_Content * model
Definition: expat.h:151
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
bool LSTME::FillLSTME::getIsRHC ( const art::Event evt)
private

Definition at line 108 of file FillLSTME_module.cc.

References beamLabel, art::Handle< T >::failedToGet(), generatorLabel, art::DataViewImpl::getByLabel(), art::Event::isRealData(), sumdata::SpillData::isRHC, and useOppositeHornCurrentNetwork.

Referenced by selectModel().

109 {
110  /* TODO: ask if this should be cached per file/run/job/etc ? */
111 
112  /*
113  * NOTE: Won't work for CRY files.
114  * Apparently need to change config file for them and set
115  * generatorLabel = beamLabel
116  */
118  if (! evt.isRealData()) {
119  evt.getByLabel(generatorLabel, spillPot);
120  }
121  else {
122  evt.getByLabel(beamLabel, spillPot);
123  }
124 
125  if (spillPot.failedToGet())
126  {
127  mf::LogError("FillLSTME") <<
128  "Spill Data not found, aborting without horn current information";
129  abort();
130  }
131 
132  if(useOppositeHornCurrentNetwork) return !spillPot->isRHC;
133 
134  // NB - the logic here will cause 0HC to use the FHC network
135  return spillPot->isRHC;
136 }
bool isRHC
is the beam in antineutrino mode, aka RHC
Definition: SpillData.h:28
bool useOppositeHornCurrentNetwork
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
bool isRealData() const
Definition: Event.h:83
std::string generatorLabel
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
std::string beamLabel
bool failedToGet() const
Definition: Handle.h:196
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
FillLSTME& LSTME::FillLSTME::operator= ( FillLSTME const &  )
delete
FillLSTME& LSTME::FillLSTME::operator= ( FillLSTME &&  )
delete
LSTMEnergy LSTME::FillLSTME::predictEnergy ( Model model,
const art::Event evt,
const art::Handle< std::vector< rb::Cluster >> &  slices_h,
size_t  sliceIdx,
const std::vector< art::Ptr< rb::Vertex >> &  elastics,
const std::vector< bool > &  sliceIsMC 
)
private

Definition at line 169 of file FillLSTME_module.cc.

References LSTME::VarDictBuilder::build(), geo::GeometryBase::DetId(), geom(), novadaq::cnv::kFARDET, LSTME::Model::predict(), and TrackLengthCorrection::shift().

Referenced by fillEnergies().

177 {
178  VarDictBuilder builder(
179  evt, slices_h, sliceIdx, elastics, config
180  );
181  VarDict varDict = builder.build();
182 
183  /* TODO: this must be removed once geometry is fixed */
185  TrackLengthCorrection trkLenCorr(
186  sliceIsMC[sliceIdx], (geom->DetId() == novadaq::cnv::kFARDET)
187  );
188  trkLenCorr.shift(varDict);
189 
190  return model.predict(varDict);
191 }
Definition: config.py:1
Far Detector at Ash River, MN.
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
void geom(int which=0)
Definition: geom.C:163
Definition: VarDict.h:7
const XML_Char XML_Content * model
Definition: expat.h:151
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void LSTME::FillLSTME::produce ( art::Event evt)
overridevirtual

Implements art::EDProducer.

Definition at line 241 of file FillLSTME_module.cc.

References DEFINE_ART_MODULE(), fillEnergies(), and art::Event::put().

242 {
243  std::unique_ptr<std::vector<LSTMEnergy>> sliceEnergies(
244  new std::vector<LSTMEnergy>
245  );
246  std::unique_ptr<art::Assns<LSTMEnergy, rb::Cluster>> sliceEnergyAssoc(
248  );
249 
250  fillEnergies(evt, sliceEnergies, sliceEnergyAssoc);
251 
252  evt.put(std::move(sliceEnergies));
253  evt.put(std::move(sliceEnergyAssoc));
254 }
void fillEnergies(art::Event &evt, std::unique_ptr< std::vector< LSTMEnergy >> &sliceEnergies, std::unique_ptr< art::Assns< LSTMEnergy, rb::Cluster >> &sliceEnergyAssoc)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
void LSTME::FillLSTME::reconfigure ( const fhicl::ParameterSet pset)

Definition at line 100 of file FillLSTME_module.cc.

References beamLabel, generatorLabel, fhicl::ParameterSet::get(), and string.

Referenced by FillLSTME().

101 {
102  beamLabel = pset.get<std::string>("beamLabel");
103  generatorLabel = pset.get<std::string>("generatorLabel");
104 
105  config.parse(pset);
106 }
Definition: config.py:1
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::string generatorLabel
std::string beamLabel
enum BeamMode string
Model & LSTME::FillLSTME::selectModel ( const art::Event evt)
private

Definition at line 138 of file FillLSTME_module.cc.

References geo::GeometryBase::DetId(), runNovaSAM::detId, geom(), getIsRHC(), make_mec_shifts_plots::isRHC, novadaq::cnv::kFARDET, novadaq::cnv::kNEARDET, modelFDFHC, modelFDRHC, modelNDFHC, and modelNDRHC.

Referenced by fillEnergies().

139 {
141  novadaq::cnv::DetId detId = geom->DetId();
142 
143  bool isRHC = getIsRHC(evt);
144 
145  if (detId == novadaq::cnv::kFARDET)
146  {
147  if (isRHC) {
148  return modelFDRHC;
149  }
150  else {
151  return modelFDFHC;
152  }
153  }
154 
155  if (detId == novadaq::cnv::kNEARDET)
156  {
157  if (isRHC) {
158  return modelNDRHC;
159  }
160  else {
161  return modelNDFHC;
162  }
163  }
164 
165  mf::LogError("FillLSTME") << "Unsupported detector type, aborting";
166  abort();
167 }
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Far Detector at Ash River, MN.
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
Near Detector in the NuMI cavern.
void geom(int which=0)
Definition: geom.C:163
bool getIsRHC(const art::Event &evt)
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

std::string LSTME::FillLSTME::beamLabel
private

Definition at line 58 of file FillLSTME_module.cc.

Referenced by getIsRHC(), and reconfigure().

Config LSTME::FillLSTME::config
private

Definition at line 55 of file FillLSTME_module.cc.

Referenced by Controller.Controller::make_output_directory().

bool LSTME::FillLSTME::fObeyPreselection
private

Definition at line 65 of file FillLSTME_module.cc.

Referenced by fillEnergies().

std::vector<std::string> LSTME::FillLSTME::fPreselectionLabels
private

Definition at line 66 of file FillLSTME_module.cc.

Referenced by fillEnergies().

std::string LSTME::FillLSTME::generatorLabel
private

Definition at line 57 of file FillLSTME_module.cc.

Referenced by getIsRHC(), and reconfigure().

Model LSTME::FillLSTME::modelFDFHC
private

Definition at line 60 of file FillLSTME_module.cc.

Referenced by selectModel().

Model LSTME::FillLSTME::modelFDRHC
private

Definition at line 61 of file FillLSTME_module.cc.

Referenced by selectModel().

Model LSTME::FillLSTME::modelNDFHC
private

Definition at line 62 of file FillLSTME_module.cc.

Referenced by selectModel().

Model LSTME::FillLSTME::modelNDRHC
private

Definition at line 63 of file FillLSTME_module.cc.

Referenced by selectModel().

bool LSTME::FillLSTME::useOppositeHornCurrentNetwork
private

Definition at line 68 of file FillLSTME_module.cc.

Referenced by getIsRHC().


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