Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
slid::SPIDBuilder Class Reference
Inheritance diagram for slid::SPIDBuilder:
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

 SPIDBuilder (const fhicl::ParameterSet &pset)
 
 ~SPIDBuilder ()
 
virtual void produce (art::Event &evt)
 
virtual void reconfigure (const fhicl::ParameterSet &pset)
 
virtual void beginRun (art::Run &run)
 
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
 

Protected Attributes

std::string fShowerLabel
 
std::string fSlicerLabel
 
std::string fVertexLabel
 
std::vector< std::stringfFilterLabels
 
bool fPIDOnlyForHighestEShower
 
bool fObeyPreselection
 
bool fSkipNoiseSlices
 
bool fTrainingMode
 
std::string fLibPath
 
int kIDNuE = 12
 
ParticleIDAlgfParticleIDAlg
 Particle ID alorithm (loglikelihoods and dE/dx) More...
 
NuEEnergyAlgfNuEEnergyAlg
 
slid::SPIDAlgfMVAAlgEPi0
 
slid::SPIDAlgfMVAAlgEPi0EL
 
fhicl::ParameterSet fNuEEnergyAlgPSet
 FCL parameters for NuE Energy alorithm. More...
 
fhicl::ParameterSet fParticleIDAlgPSet
 FCL parameters for particle ID alorithm (loglikelihoods and dE/dx) More...
 
fhicl::ParameterSet fSPIDAlgPSet
 FCL parameters for SPID alorithm. More...
 
bool libLoad = false
 determine if library load is necessary or not when moving to a new run More...
 

Detailed Description

Definition at line 55 of file SPIDBuilder_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

slid::SPIDBuilder::SPIDBuilder ( const fhicl::ParameterSet pset)
explicit

Definition at line 116 of file SPIDBuilder_module.cc.

References reconfigure().

117  : fParticleIDAlg(0), fNuEEnergyAlg(0),
118  fMVAAlgEPi0(0),
119  fMVAAlgEPi0EL(0),
120  fNuEEnergyAlgPSet(pset.get< fhicl::ParameterSet >("NuEEnergyAlgPSet")),
121  fParticleIDAlgPSet(pset.get< fhicl::ParameterSet >("ParticleIDAlgPSet")),
122  fSPIDAlgPSet(pset.get< fhicl::ParameterSet >("SPIDAlgPSet"))
123  {
124  reconfigure(pset);
125  // Define output structures produced.
126  produces<std::vector<slid::ShowerPID> >();
127  produces< art::Assns<slid::ShowerPID, rb::Shower> >();
128  produces< art::Assns<slid::ShowerPID, rb::Cluster> >();
129  }
fhicl::ParameterSet fSPIDAlgPSet
FCL parameters for SPID alorithm.
fhicl::ParameterSet fParticleIDAlgPSet
FCL parameters for particle ID alorithm (loglikelihoods and dE/dx)
slid::SPIDAlg * fMVAAlgEPi0
ParticleIDAlg * fParticleIDAlg
Particle ID alorithm (loglikelihoods and dE/dx)
slid::SPIDAlg * fMVAAlgEPi0EL
T get(std::string const &key) const
Definition: ParameterSet.h:231
fhicl::ParameterSet fNuEEnergyAlgPSet
FCL parameters for NuE Energy alorithm.
NuEEnergyAlg * fNuEEnergyAlg
virtual void reconfigure(const fhicl::ParameterSet &pset)
slid::SPIDBuilder::~SPIDBuilder ( )

Definition at line 133 of file SPIDBuilder_module.cc.

References fMVAAlgEPi0, fMVAAlgEPi0EL, fNuEEnergyAlg, and fParticleIDAlg.

134  {
135  if (fParticleIDAlg) delete fParticleIDAlg;
136  if (fNuEEnergyAlg) delete fNuEEnergyAlg;
137  if (fMVAAlgEPi0) delete fMVAAlgEPi0;
138  if (fMVAAlgEPi0EL) delete fMVAAlgEPi0EL;
139  }
slid::SPIDAlg * fMVAAlgEPi0
ParticleIDAlg * fParticleIDAlg
Particle ID alorithm (loglikelihoods and dE/dx)
slid::SPIDAlg * fMVAAlgEPi0EL
NuEEnergyAlg * fNuEEnergyAlg

Member Function Documentation

void slid::SPIDBuilder::beginRun ( art::Run run)
virtual

Reimplemented from art::EDProducer.

Definition at line 162 of file SPIDBuilder_module.cc.

References geo::GeometryBase::DetId(), runNovaSAM::detId, fMVAAlgEPi0, fMVAAlgEPi0EL, fNuEEnergyAlg, fNuEEnergyAlgPSet, fParticleIDAlg, fParticleIDAlgPSet, fSPIDAlgPSet, fTrainingMode, and libLoad.

163  {
165  novadaq::cnv::DetId detId = fGeom->DetId();
166 
167  //NOTE: This code is here because the geometry service only becomes available to determine the
168  //detector id at the begin run step. However at the present moment the libraries being loaded
169  //by the particle id and ann algorithms will not very from run to run and only depend on the detector id.
170  //If there are more then one run in a file this loading process takes a lot of time, only do it once per job.
171  if (!libLoad){
172  if (fParticleIDAlg) delete fParticleIDAlg;
173  if (fNuEEnergyAlg) delete fNuEEnergyAlg;
174  if (fMVAAlgEPi0) delete fMVAAlgEPi0;
175  if (fMVAAlgEPi0EL) delete fMVAAlgEPi0EL;
176  fNuEEnergyAlg = new NuEEnergyAlg(fNuEEnergyAlgPSet);
177  fParticleIDAlg = new ParticleIDAlg(fParticleIDAlgPSet, detId, fNuEEnergyAlg);
178 
179  if (!fTrainingMode){
180  fMVAAlgEPi0 = new SPIDAlg(fSPIDAlgPSet, fNuEEnergyAlg, 2);
181  fMVAAlgEPi0EL = new SPIDAlg(fSPIDAlgPSet, fNuEEnergyAlg, 3);
182  }
183  libLoad = true;
184  }
185  }
fhicl::ParameterSet fSPIDAlgPSet
FCL parameters for SPID alorithm.
bool libLoad
determine if library load is necessary or not when moving to a new run
fhicl::ParameterSet fParticleIDAlgPSet
FCL parameters for particle ID alorithm (loglikelihoods and dE/dx)
slid::SPIDAlg * fMVAAlgEPi0
ParticleIDAlg * fParticleIDAlg
Particle ID alorithm (loglikelihoods and dE/dx)
slid::SPIDAlg * fMVAAlgEPi0EL
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
fhicl::ParameterSet fNuEEnergyAlgPSet
FCL parameters for NuE Energy alorithm.
NuEEnergyAlg * fNuEEnergyAlg
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 slid::SPIDBuilder::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 190 of file SPIDBuilder_module.cc.

References slid::SPIDAlg::CalcMVAResult(), slid::CompareByE(), std::cos(), util::CreateAssn(), slid::ParticleIDAlg::DedxLongLL(), slid::ParticleIDAlg::DedxTransLL(), e, evt, fFilterLabels, PandAna.Demos.pi0_spectra::fmt, fMVAAlgEPi0, fMVAAlgEPi0EL, fNuEEnergyAlg, fObeyPreselection, fParticleIDAlg, slid::ParticleIDAlg::fPartLongLL, slid::ShowerLID::fPartLongLL, slid::ParticleIDAlg::fPartTransLL, slid::ShowerLID::fPartTransLL, fPIDOnlyForHighestEShower, fShowerLabel, fSkipNoiseSlices, fSlicerLabel, fTrainingMode, fVertexLabel, art::DataViewImpl::getByLabel(), MECModelEnuComparisons::i, rb::IsFiltered(), std::isinf(), std::isnan(), slid::kELECTRON, slid::kMUON, slid::kNEUTRON, slid::kPHOTON, slid::kPI0, slid::kPION, slid::kPROTON, LOG_DEBUG, make_pair(), geo::GeometryBase::NuMIBeamDirection(), slid::ParticleIDAlg::PlaneLongDedx(), slid::ParticleIDAlg::PointDoca(), art::PtrVector< T >::push_back(), art::Event::put(), moon_position_table_new3::second, slid::ShowerLID::SetAlgDescription(), slid::ShowerLID::SetCosTheta(), slid::ShowerPID::SetDedx0(), slid::ShowerPID::SetDedx1(), slid::ShowerPID::SetDedx2(), slid::ShowerPID::SetDedx3(), slid::ShowerPID::SetDedx4(), slid::ShowerPID::SetDedx5(), slid::ShowerPID::SetELLL(), slid::ShowerPID::SetELLT(), slid::ShowerPID::SetGLLL(), slid::ShowerPID::SetGLLT(), slid::ShowerPID::SetMuLLL(), slid::ShowerPID::SetMuLLT(), slid::ShowerPID::SetNLLL(), slid::ShowerPID::SetNLLT(), slid::ShowerPID::SetPi0LLL(), slid::ShowerPID::SetPi0LLT(), slid::ShowerPID::SetPiLLL(), slid::ShowerPID::SetPiLLT(), slid::ShowerPID::SetPLLL(), slid::ShowerPID::SetPLLT(), slid::ParticleIDAlg::SetShower(), slid::ShowerLID::SetShowerEnergy(), slid::ShowerPID::SetValEPi0(), slid::ShowerPID::SetValEPi0EL(), slid::ShowerLID::SetVtxDoca(), slid::NuEEnergyAlg::ShowerEnergy(), slid::ShowerLID::ShowerEnergy(), art::PtrVector< T >::size(), and chisquared::theta.

191  {
192 
194 
195  LOG_DEBUG("SPIDBuilderDEBUG") << "In SPIDBuilder::produce" << '\n';
196 
197  std::unique_ptr< std::vector<slid::ShowerPID> > showerpidcol(new std::vector<slid::ShowerPID>);
198  std::unique_ptr< art::Assns<slid::ShowerPID, rb::Shower> > assnSpidShower(new art::Assns<slid::ShowerPID, rb::Shower>);
199  std::unique_ptr< art::Assns<slid::ShowerPID, rb::Cluster> > assnSpidSlice(new art::Assns<slid::ShowerPID, rb::Cluster>);
200 
202  evt.getByLabel(fSlicerLabel, slicecol);
203  art::PtrVector<rb::Cluster> slicelist;
204  for (unsigned int i = 0; i < slicecol->size(); ++i) {
205  art::Ptr<rb::Cluster> slice(slicecol, i);
206  slicelist.push_back(slice);
207  }
208  //
209  // Grab list of rb::Shower* for calculations and reading and list of art::Ptr<rb::Shower>
210  // for writing the output data products. Since these **should** be indexed the same, this
211  // should be OK.
212  //
213  art::FindManyP<rb::Shower> fmtP(slicecol, evt, fShowerLabel);
215  art::FindManyP<rb::Vertex> fmv(slicecol, evt, fVertexLabel);
216 
217  // loop over all of the slices
218  for (unsigned int iSlice = 0; iSlice < slicelist.size(); ++iSlice) {
219  const size_t nextShwIdx = showerpidcol->size();
220  //
221  // Skip noise slices if this option is selected in FCL
222  //
223  if (fSkipNoiseSlices && slicelist[iSlice]->IsNoise()) continue;
224  //
225  // If there was nue preselection, skip slice if it failed if this option is selected in FCL
226  //
227  if (fObeyPreselection &&
228  rb::IsFiltered(evt, slicecol, iSlice, fFilterLabels))
229  continue;
230 
231  // get all of the showers in this slice
232  if ((!fmt.isValid())||(!fmtP.isValid())) continue;
233  const std::vector< const rb::Shower* > showerCollection = fmt.at(iSlice);
234  const std::vector < art::Ptr < rb::Shower >> showerCollectionPtr = fmtP.at(iSlice);
235  if ((showerCollection.empty())||(showerCollectionPtr.empty())) continue;
236 
237  //hold spid objects temporarily before sorting
238  std::vector<slid::ShowerPID> tempspidcol;
239  //keep track of shower index associationed with the spid object after sorting
240  std::vector<std::pair<double,int> > associationlist;
241 
242 
243  //get the vertex for the slice
244  const std::vector<art::Ptr<rb::Vertex>> vertCol = fmv.at(iSlice);
245  //currently only one vertex per slice
246  TVector3 vert = vertCol[0]->GetXYZ();
247 
248  //
249  // Get indices of highest and second-highest energy showers
250  //
251  double eShHighest = 0;
252  double sliceShwE = 0;
253  unsigned int iHighestEnergySh = -1;
254  for (unsigned int jShower = 0; jShower < showerCollection.size(); ++jShower) {
255  double thisESh = fNuEEnergyAlg->ShowerEnergy(showerCollection[jShower], showerCollection, evt);
256  sliceShwE += thisESh;
257  if (thisESh > eShHighest) {
258  eShHighest = thisESh;
259  iHighestEnergySh = jShower;
260  }
261  }
262 
263  TLorentzVector evtP4(0.0,0.0,0.0,0.0);
264  //
265  // Loop over showers to fill PID info
266  //
267  std::map<int, int> showerLidToShower;
268  unsigned int nShowers = showerCollection.size();
269  for (unsigned int iShower = 0; iShower < nShowers; ++iShower) {
270 
271 
272  slid::ShowerPID showerpid;
273 
274  double shwE = fNuEEnergyAlg->ShowerEnergy(showerCollection.at(iShower), showerCollection, evt);
275  if (std::isnan(sliceShwE) || std::isnan(shwE) || std::isinf(sliceShwE) || std::isinf(shwE)) {
276  mf::LogError("LIDBuilder")<< "sliceShwE/shwE is nan or inf";
277  continue;
278  }
279  if (shwE < 1e-10) shwE = 0.0;
280  showerpid.SetShowerEnergy(shwE);
281 
282  showerpid.SetDedx0(0);
283  showerpid.SetDedx1(0);
284  showerpid.SetDedx2(0);
285  showerpid.SetDedx3(0);
286  showerpid.SetDedx4(0);
287  showerpid.SetDedx5(0);
288  fParticleIDAlg->SetShower(showerCollection[iShower], showerCollection, evt);
289 
290  showerpid.SetELLL(fParticleIDAlg->DedxLongLL(slid::DedxParticleType::kELECTRON, showerCollection[iShower], showerCollection, evt));
291  showerpid.SetELLT(fParticleIDAlg->DedxTransLL(slid::DedxParticleType::kELECTRON, showerCollection[iShower], showerCollection, evt));
292  showerpid.SetGLLL(fParticleIDAlg->DedxLongLL(slid::DedxParticleType::kPHOTON, showerCollection[iShower], showerCollection, evt));
293  showerpid.SetGLLT(fParticleIDAlg->DedxTransLL(slid::DedxParticleType::kPHOTON, showerCollection[iShower], showerCollection, evt));
294  showerpid.SetMuLLL(fParticleIDAlg->DedxLongLL(slid::DedxParticleType::kMUON, showerCollection[iShower], showerCollection, evt));
295  showerpid.SetMuLLT(fParticleIDAlg->DedxTransLL(slid::DedxParticleType::kMUON, showerCollection[iShower],showerCollection, evt));
296  showerpid.SetPi0LLL(fParticleIDAlg->DedxLongLL(slid::DedxParticleType::kPI0, showerCollection[iShower],showerCollection, evt));
297  showerpid.SetPi0LLT(fParticleIDAlg->DedxTransLL(slid::DedxParticleType::kPI0, showerCollection[iShower],showerCollection, evt));
298  showerpid.SetPLLL(fParticleIDAlg->DedxLongLL(slid::DedxParticleType::kPROTON, showerCollection[iShower],showerCollection, evt));
299  showerpid.SetPLLT(fParticleIDAlg->DedxTransLL(slid::DedxParticleType::kPROTON, showerCollection[iShower], showerCollection, evt));
300  showerpid.SetNLLL(fParticleIDAlg->DedxLongLL(slid::DedxParticleType::kNEUTRON, showerCollection[iShower], showerCollection, evt));
301  showerpid.SetNLLT(fParticleIDAlg->DedxTransLL(slid::DedxParticleType::kNEUTRON, showerCollection[iShower],showerCollection, evt));
302  showerpid.SetPiLLL(fParticleIDAlg->DedxLongLL(slid::DedxParticleType::kPION, showerCollection[iShower],showerCollection, evt));
303  showerpid.SetPiLLT(fParticleIDAlg->DedxTransLL(slid::DedxParticleType::kPION, showerCollection[iShower],showerCollection, evt));
304 
305  if(showerCollection[iShower]->ExtentPlane()>0)showerpid.SetDedx0(fParticleIDAlg->PlaneLongDedx(0));
306  if(showerCollection[iShower]->ExtentPlane()>1)showerpid.SetDedx1(fParticleIDAlg->PlaneLongDedx(1));
307  if(showerCollection[iShower]->ExtentPlane()>2)showerpid.SetDedx2(fParticleIDAlg->PlaneLongDedx(2));
308  if(showerCollection[iShower]->ExtentPlane()>3)showerpid.SetDedx3(fParticleIDAlg->PlaneLongDedx(3));
309  if(showerCollection[iShower]->ExtentPlane()>4)showerpid.SetDedx4(fParticleIDAlg->PlaneLongDedx(4));
310  if(showerCollection[iShower]->ExtentPlane()>5)showerpid.SetDedx5(fParticleIDAlg->PlaneLongDedx(5));
311 //std::cout<<"SPID fParticleIDAlg dedx0 "<<fParticleIDAlg->PlaneLongDedx(0)<<std::endl;
312 //std::cout<<"SPID fParticleIDAlg ELLL, ELLT "<<showerpid.ELLL()<<" "<<showerpid.ELLT()<<std::endl;
313 //std::cout<<"SPID fParticleIDAlg GLLL, GLLT "<<showerpid.GLLL()<<" "<<showerpid.GLLT()<<std::endl;
314 
315 
316  TLorentzVector showerptrk(showerCollection[iShower]->Dir()[0]*shwE,
317  showerCollection[iShower]->Dir()[1]*shwE,
318  showerCollection[iShower]->Dir()[2]*shwE,
319  shwE);
320  TVector3 nuDir = fGeom->NuMIBeamDirection();
321  double theta = showerptrk.Angle(nuDir);
322  showerpid.SetCosTheta(cos(theta));
323 
324 
325  showerpid.SetVtxDoca(fParticleIDAlg->PointDoca(vertCol.at(0)->GetXYZ(),showerCollection[iShower]->Start(),showerCollection[iShower]->Stop()));
326 
327 
328  if (!fPIDOnlyForHighestEShower || iShower == iHighestEnergySh){
329  //in training mode just write -5, since the ann weights have not been determined
330  if (fTrainingMode){
331  showerpid.SetAlgDescription(""); // not needed?
332  showerpid.SetValEPi0(-5);
333  showerpid.SetValEPi0EL(-5);
334  }
335  //standard running, calculate the ann
336  else{
337  showerpid.SetValEPi0(fMVAAlgEPi0->CalcMVAResult(showerpid));
338  showerpid.SetValEPi0EL(fMVAAlgEPi0EL->CalcMVAResult(showerpid));
339  }
340  }
341 
342  showerpid.SetVtxDoca(fParticleIDAlg->PointDoca(vertCol.at(0)->GetXYZ(),showerCollection[iShower]->Start(),showerCollection[iShower]->Stop()));
343 
346  tempspidcol.push_back(showerpid);
347  associationlist.push_back(std::make_pair(showerpid.ShowerEnergy(),iShower));
348  }// end loop over showers
349 
350  std::sort( tempspidcol.begin(), tempspidcol.end(), CompareByE);
351  std::sort(associationlist.rbegin(), associationlist.rend());
352 
353  for (unsigned int ispid=0; ispid<tempspidcol.size(); ++ispid){
354  showerpidcol->push_back(tempspidcol[ispid]);
355  util::CreateAssn(*this, evt, *(showerpidcol.get()), showerCollectionPtr[associationlist[ispid].second], *(assnSpidShower.get()));
356  }
357 
358  //if we have added new showers, make event pid and associations to slice
359  if (showerpidcol->size() > nextShwIdx){
360  //create new associations for the most recent set of showers
361  util::CreateAssn(*this, evt, *showerpidcol, slicelist[iSlice], *(assnSpidSlice.get()), nextShwIdx, showerpidcol->size());
362  }
363 
364  } //end loop over slices
365 
366  evt.put(std::move(showerpidcol));
367  evt.put(std::move(assnSpidShower));
368  evt.put(std::move(assnSpidSlice));
369 
370  }// end of producer
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
void SetPLLL(float in)
Definition: ShowerPID.h:48
int isinf(const stan::math::var &a)
Definition: std_isinf.hpp:16
void SetDedx5(float in)
Definition: ShowerPID.h:38
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.
void SetVtxDoca(float in)
Definition: ShowerLID.h:84
void SetDedx4(float in)
Definition: ShowerPID.h:37
double DedxTransLL(const slid::DedxParticleType partHyp, const rb::Shower *vShower, const std::vector< const rb::Shower * > showercol, const art::Event &evt)
Calculate transverse dE/dx log-likelihood for specific particle hypothesis.
void SetDedx1(float in)
Definition: ShowerPID.h:34
std::map< int, float > fPartLongLL
Map of the longitudinal ll by paricle type.
Definition: ShowerLID.h:238
void SetPiLLT(float in)
Definition: ShowerPID.h:53
std::vector< std::string > fFilterLabels
void SetShowerEnergy(float in)
Definition: ShowerLID.h:94
void SetDedx3(float in)
Definition: ShowerPID.h:36
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
bool CompareByE(const slid::ShowerLID &a, const slid::ShowerLID &b)
void SetValEPi0(float in)
Setters.
Definition: ShowerPID.h:30
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
void SetPi0LLL(float in)
Definition: ShowerPID.h:46
double PlaneLongDedx(unsigned int pIdx)
return longitudinal dedx for a specified plane index
void SetNLLT(float in)
Definition: ShowerPID.h:51
slid::SPIDAlg * fMVAAlgEPi0
int isnan(const stan::math::var &a)
Definition: std_isnan.hpp:18
void SetAlgDescription(const std::string &algDescription)
set algorithm description
Definition: ShowerLID.h:90
double CalcMVAResult(slid::ShowerPID &showerspid)
Calculate value of predictors for MVA Algorithm using candidate rb::Shower. A pointer to the object o...
Definition: SPIDAlg.cxx:247
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
ParticleIDAlg * fParticleIDAlg
Particle ID alorithm (loglikelihoods and dE/dx)
slid::SPIDAlg * fMVAAlgEPi0EL
void SetMuLLT(float in)
Definition: ShowerPID.h:45
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
void SetPi0LLT(float in)
Definition: ShowerPID.h:47
int evt
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
std::map< int, float > fPartTransLL
Map of the transverse ll by particle type.
Definition: ShowerLID.h:241
void SetCosTheta(float in)
Definition: ShowerLID.h:47
std::map< int, float > fPartTransLL
Map of the transverse ll by particle type.
double PointDoca(TVector3 vtx, TVector3 start, TVector3 stop)
Get distance of closest approach between shower and vertex.
size_type size() const
Definition: PtrVector.h:308
void SetPiLLL(float in)
Definition: ShowerPID.h:52
double ShowerEnergy(const rb::Shower *shower, const std::vector< const rb::Shower * > showercol, const art::Event &evt)
Returns the total energy of a shower. along with corrections due to dead material and threshold effec...
TVector3 NuMIBeamDirection() const
Direction of neutrinos from the NuMI beam (unit vector)
void SetDedx2(float in)
Definition: ShowerPID.h:35
NuEEnergyAlg * fNuEEnergyAlg
float ShowerEnergy() const
Definition: ShowerLID.h:157
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void SetMuLLL(float in)
Definition: ShowerPID.h:44
void SetELLL(float in)
Definition: ShowerPID.h:40
void SetValEPi0EL(float in)
Definition: ShowerPID.h:31
void SetGLLL(float in)
Definition: ShowerPID.h:42
T cos(T number)
Definition: d0nt_math.hpp:78
Float_t e
Definition: plot.C:35
std::map< int, float > fPartLongLL
Map of the longitudinal ll by paricle type.
void SetPLLT(float in)
Definition: ShowerPID.h:49
void SetELLT(float in)
Definition: ShowerPID.h:41
void SetGLLT(float in)
Definition: ShowerPID.h:43
void SetNLLL(float in)
Definition: ShowerPID.h:50
void SetDedx0(float in)
Definition: ShowerPID.h:33
double DedxLongLL(const slid::DedxParticleType partHyp, const rb::Shower *vShower, const std::vector< const rb::Shower * > showercol, const art::Event &evt)
Calculate longitudinal dE/dx log-likelihood for specific particle hypothesis.
void SetShower(const rb::Shower *vShower, const std::vector< const rb::Shower * > showercol, const art::Event &evt)
Set rb::Prong to be analyzed. This must be set before any calculations can be done.
void slid::SPIDBuilder::reconfigure ( const fhicl::ParameterSet pset)
virtual

Definition at line 143 of file SPIDBuilder_module.cc.

References util::EnvExpansion(), fFilterLabels, fLibPath, fNuEEnergyAlgPSet, fObeyPreselection, fParticleIDAlgPSet, fPIDOnlyForHighestEShower, fShowerLabel, fSkipNoiseSlices, fSlicerLabel, fSPIDAlgPSet, fTrainingMode, fVertexLabel, fhicl::ParameterSet::get(), and string.

Referenced by SPIDBuilder().

144  {
145  //
146  // Read FCL parameters
147  //
148  fNuEEnergyAlgPSet = pset.get< fhicl::ParameterSet >("NuEEnergyAlgPSet");
149  fParticleIDAlgPSet = pset.get< fhicl::ParameterSet >("ParticleIDAlgPSet");
150  fSPIDAlgPSet = pset.get< fhicl::ParameterSet >("SPIDAlgPSet");
151  fLibPath = util::EnvExpansion(pset.get< std::string >("LibraryPath"));
152  fSlicerLabel = pset.get< std::string >("SlicerLabel");
153  fShowerLabel = pset.get< std::string >("ShowerLabel");
154  fVertexLabel = pset.get< std::string >("VertexLabel");
155  fPIDOnlyForHighestEShower = pset.get<bool>("PIDOnlyForHighestEShower");
156  fObeyPreselection = pset.get<bool>("ObeyPreselection");
157  fSkipNoiseSlices = pset.get<bool>("SkipNoiseSlices");
158  fTrainingMode = pset.get<bool>("TrainingMode");
159  fFilterLabels = pset.get< std::vector<std::string> >("FilterLabels");
160  }
fhicl::ParameterSet fSPIDAlgPSet
FCL parameters for SPID alorithm.
std::string EnvExpansion(const std::string &inString)
Function to expand environment variables.
Definition: EnvExpand.cxx:8
fhicl::ParameterSet fParticleIDAlgPSet
FCL parameters for particle ID alorithm (loglikelihoods and dE/dx)
std::vector< std::string > fFilterLabels
T get(std::string const &key) const
Definition: ParameterSet.h:231
fhicl::ParameterSet fNuEEnergyAlgPSet
FCL parameters for NuE Energy alorithm.
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

std::vector<std::string> slid::SPIDBuilder::fFilterLabels
protected

Definition at line 72 of file SPIDBuilder_module.cc.

Referenced by produce(), and reconfigure().

std::string slid::SPIDBuilder::fLibPath
protected

Definition at line 82 of file SPIDBuilder_module.cc.

Referenced by reconfigure().

slid::SPIDAlg* slid::SPIDBuilder::fMVAAlgEPi0
protected

MVAAlgorithm (Neural Net, KNN, etc. May include any algorithm that is a subclass of slid::SPIDAlg)

Definition at line 90 of file SPIDBuilder_module.cc.

Referenced by beginRun(), produce(), and ~SPIDBuilder().

slid::SPIDAlg* slid::SPIDBuilder::fMVAAlgEPi0EL
protected

Definition at line 91 of file SPIDBuilder_module.cc.

Referenced by beginRun(), produce(), and ~SPIDBuilder().

NuEEnergyAlg* slid::SPIDBuilder::fNuEEnergyAlg
protected

Definition at line 86 of file SPIDBuilder_module.cc.

Referenced by beginRun(), produce(), and ~SPIDBuilder().

fhicl::ParameterSet slid::SPIDBuilder::fNuEEnergyAlgPSet
protected

FCL parameters for NuE Energy alorithm.

Definition at line 93 of file SPIDBuilder_module.cc.

Referenced by beginRun(), and reconfigure().

bool slid::SPIDBuilder::fObeyPreselection
protected

Definition at line 75 of file SPIDBuilder_module.cc.

Referenced by produce(), and reconfigure().

ParticleIDAlg* slid::SPIDBuilder::fParticleIDAlg
protected

Particle ID alorithm (loglikelihoods and dE/dx)

Definition at line 85 of file SPIDBuilder_module.cc.

Referenced by beginRun(), produce(), and ~SPIDBuilder().

fhicl::ParameterSet slid::SPIDBuilder::fParticleIDAlgPSet
protected

FCL parameters for particle ID alorithm (loglikelihoods and dE/dx)

Definition at line 96 of file SPIDBuilder_module.cc.

Referenced by beginRun(), and reconfigure().

bool slid::SPIDBuilder::fPIDOnlyForHighestEShower
protected

Definition at line 74 of file SPIDBuilder_module.cc.

Referenced by produce(), and reconfigure().

std::string slid::SPIDBuilder::fShowerLabel
protected

Definition at line 69 of file SPIDBuilder_module.cc.

Referenced by produce(), and reconfigure().

bool slid::SPIDBuilder::fSkipNoiseSlices
protected

Definition at line 76 of file SPIDBuilder_module.cc.

Referenced by produce(), and reconfigure().

std::string slid::SPIDBuilder::fSlicerLabel
protected

Definition at line 70 of file SPIDBuilder_module.cc.

Referenced by produce(), and reconfigure().

fhicl::ParameterSet slid::SPIDBuilder::fSPIDAlgPSet
protected

FCL parameters for SPID alorithm.

Definition at line 99 of file SPIDBuilder_module.cc.

Referenced by beginRun(), and reconfigure().

bool slid::SPIDBuilder::fTrainingMode
protected

Definition at line 77 of file SPIDBuilder_module.cc.

Referenced by beginRun(), produce(), and reconfigure().

std::string slid::SPIDBuilder::fVertexLabel
protected

Definition at line 71 of file SPIDBuilder_module.cc.

Referenced by produce(), and reconfigure().

int slid::SPIDBuilder::kIDNuE = 12
protected

Definition at line 83 of file SPIDBuilder_module.cc.

bool slid::SPIDBuilder::libLoad = false
protected

determine if library load is necessary or not when moving to a new run

Definition at line 102 of file SPIDBuilder_module.cc.

Referenced by beginRun().


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