Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
SliceLID::ProngCVNVars Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-02-24/SliceLID/art/var_dict_builder/ProngCVNVars.h"

Public Member Functions

 ProngCVNVars (const art::Event &evt, const BasicProngVars &pngVars, const std::string &prongCVNLabel)
 
void saveToDict (std::unordered_map< std::string, std::vector< double >> &dict, const std::string &prefix) const
 

Public Attributes

std::vector< std::array< double, N_CVN > > cvnVars
 

Protected Member Functions

void init (const art::Event &evt, const BasicProngVars &pngVars)
 

Static Protected Member Functions

static std::array< double, N_CVNgetFallbackCVNVars (const BasicProngVars &pngVars, size_t pngIdx)
 
static std::array< double, N_CVNgetCVNVars (const art::FindManyP< rb::PID > &prongCVN_fmp, const BasicProngVars &pngVars, size_t pngIdx)
 

Protected Attributes

std::string prongCVNLabel
 

Detailed Description

Definition at line 34 of file ProngCVNVars.h.

Constructor & Destructor Documentation

SliceLID::ProngCVNVars::ProngCVNVars ( const art::Event evt,
const BasicProngVars pngVars,
const std::string prongCVNLabel 
)

Definition at line 106 of file ProngCVNVars.cxx.

References init().

111 {
112  init(evt, pngVars);
113 }
void init(const art::Event &evt, const BasicProngVars &pngVars)
std::string prongCVNLabel
Definition: ProngCVNVars.h:52

Member Function Documentation

std::array< double, N_CVN > SliceLID::ProngCVNVars::getCVNVars ( const art::FindManyP< rb::PID > &  prongCVN_fmp,
const BasicProngVars pngVars,
size_t  pngIdx 
)
staticprotected

Definition at line 35 of file ProngCVNVars.cxx.

References SliceLID::CVN_PNG_LIST(), getFallbackCVNVars(), SliceLID::getIndex(), allTimeWatchdog::index, and PandAna.reco_validation.prod5_pid_validation::pids.

Referenced by init().

40 {
41  std::array<double, N_CVN> pids;
42  pids.fill(0);
43 
44  if (! prongCVN_fmp.isValid()) {
45  return pids;
46  }
47 
48  auto cvnparts = prongCVN_fmp.at(pngIdx);
49  if (cvnparts.empty()) {
50  return getFallbackCVNVars(pngVars, pngIdx);
51  }
52 
53  for (auto &cvn : cvnparts)
54  {
55  auto index = getIndex(CVN_PNG_LIST, cvn->Pdg());
56  if (index.first) {
57  pids[index.second] = cvn->Value();
58  }
59  }
60 
61  return pids;
62 }
const std::array< int, N_CVN > CVN_PNG_LIST({PDG_ELECTRON, PDG_MUON, PDG_PROTON, PDG_PIPLUS, PDG_GAMMA,})
Defines an enumeration for prong classification.
std::pair< bool, size_t > getIndex(const std::array< T, N > &array, const T &value)
Definition: ProngCVNVars.cxx:8
static std::array< double, N_CVN > getFallbackCVNVars(const BasicProngVars &pngVars, size_t pngIdx)
std::array< double, N_CVN > SliceLID::ProngCVNVars::getFallbackCVNVars ( const BasicProngVars pngVars,
size_t  pngIdx 
)
staticprotected

Definition at line 18 of file ProngCVNVars.cxx.

References SliceLID::CVN_PNG_LIST(), SliceLID::getIndex(), allTimeWatchdog::index, SliceLID::BasicProngVars::len, SliceLID::PDG_MUON, and PandAna.reco_validation.prod5_pid_validation::pids.

Referenced by getCVNVars().

21 {
22  std::array<double, N_CVN> pids;
23  pids.fill(0);
24 
25  if (pngVars.len[pngIdx] > 500) {
27  if (index.first) {
28  pids[index.second] = 1;
29  }
30  }
31 
32  return pids;
33 }
const std::array< int, N_CVN > CVN_PNG_LIST({PDG_ELECTRON, PDG_MUON, PDG_PROTON, PDG_PIPLUS, PDG_GAMMA,})
std::pair< bool, size_t > getIndex(const std::array< T, N > &array, const T &value)
Definition: ProngCVNVars.cxx:8
const int PDG_MUON
Definition: ProngCVNVars.h:12
void SliceLID::ProngCVNVars::init ( const art::Event evt,
const BasicProngVars pngVars 
)
protected

Definition at line 64 of file ProngCVNVars.cxx.

References cvnVars, getCVNVars(), SliceLID::BasicProngVars::hasProngs, prongCVNLabel, and SliceLID::BasicProngVars::prongs.

Referenced by demo.App::__init__(), testem0.App::__init__(), Lesson1.App::__init__(), ExN03.App::__init__(), and ProngCVNVars().

65 {
66  if (! pngVars.hasProngs) {
67  return;
68  }
69 
70  art::FindManyP<rb::PID> prongCVN_fmp(pngVars.prongs, evt, prongCVNLabel);
71  cvnVars.reserve(pngVars.prongs.size());
72 
73  for (size_t pngIdx = 0; pngIdx < pngVars.prongs.size(); pngIdx++) {
74  cvnVars.emplace_back(getCVNVars(prongCVN_fmp, pngVars, pngIdx));
75  }
76 }
static std::array< double, N_CVN > getCVNVars(const art::FindManyP< rb::PID > &prongCVN_fmp, const BasicProngVars &pngVars, size_t pngIdx)
std::vector< std::array< double, N_CVN > > cvnVars
Definition: ProngCVNVars.h:37
std::string prongCVNLabel
Definition: ProngCVNVars.h:52
void SliceLID::ProngCVNVars::saveToDict ( std::unordered_map< std::string, std::vector< double >> &  dict,
const std::string prefix 
) const

Definition at line 78 of file ProngCVNVars.cxx.

References SliceLID::CVN_PNG_LIST(), cvnVars, SliceLID::N_CVN, SliceLID::PDG_TO_NAME_MAP(), fillBadChanDBTables::result, and string.

Referenced by SliceLID::Png3dVars::saveToDict().

82 {
83  std::array<std::vector<double>, N_CVN> result;
84 
85  for (size_t cvnIdx = 0; cvnIdx < N_CVN; cvnIdx++) {
86  result[cvnIdx].reserve(cvnVars.size());
87  }
88 
89  for (auto &cvnArray : cvnVars)
90  {
91  for (size_t cvnIdx = 0; cvnIdx < N_CVN; cvnIdx++)
92  {
93  result[cvnIdx].push_back(cvnArray[cvnIdx]);
94  }
95  }
96 
97  for (size_t cvnIdx = 0; cvnIdx < N_CVN; cvnIdx++)
98  {
99  const std::string &name =
100  prefix + "cvnpart." + PDG_TO_NAME_MAP.at(CVN_PNG_LIST[cvnIdx]);
101 
102  dict.emplace(name, std::move(result[cvnIdx]));
103  }
104 }
const std::unordered_map< int, std::string > PDG_TO_NAME_MAP({{PDG_ELECTRON,"electronid"},{PDG_MUON,"muonid"},{PDG_PROTON,"protonid"},{PDG_PIPLUS,"pionid"},{PDG_GAMMA,"photonid"},})
const XML_Char * name
Definition: expat.h:151
const std::array< int, N_CVN > CVN_PNG_LIST({PDG_ELECTRON, PDG_MUON, PDG_PROTON, PDG_PIPLUS, PDG_GAMMA,})
const size_t N_CVN
Definition: ProngCVNVars.h:9
const XML_Char * prefix
Definition: expat.h:380
std::vector< std::array< double, N_CVN > > cvnVars
Definition: ProngCVNVars.h:37
enum BeamMode string

Member Data Documentation

std::vector<std::array<double, N_CVN> > SliceLID::ProngCVNVars::cvnVars

Definition at line 37 of file ProngCVNVars.h.

Referenced by init(), and saveToDict().

std::string SliceLID::ProngCVNVars::prongCVNLabel
protected

Definition at line 52 of file ProngCVNVars.h.

Referenced by init().


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