Jpp  master_rocky
the software that should make you happy
Public Types | Public Member Functions | Friends | List of all members
JAANET::JEvtCategoryHelper Struct Reference

Helper class for event categories. More...

#include <JEvtCategoryHelper.hh>

Inheritance diagram for JAANET::JEvtCategoryHelper:
JLANG::JComparable< JFirst_t, JSecond_t >

Public Types

typedef std::shared_ptr< JEvtCategorypointer_type
 

Public Member Functions

 JEvtCategoryHelper ()
 Default constructor. More...
 
 JEvtCategoryHelper (const pointer_type &p)
 Constructor. More...
 
 JEvtCategoryHelper (const JEvtCategory &category)
 Constructor. More...
 
 JEvtCategoryHelper (const JHead &header)
 Constructor. More...
 
 JEvtCategoryHelper (const int type)
 Constructor. More...
 
void configure (const pointer_type &p)
 Configuration. More...
 
void configure (const JEvtCategory &category)
 Configuration. More...
 
void configure (const JHead &header)
 Configuration. More...
 
void configure (const int type)
 Configuration. More...
 
JEvtCategorygetEvtCategory () const
 Get reference to event category. More...
 
bool is_valid () const
 Check if event category is valid. More...
 
bool match (const JHead &header) const
 Check whether given MC header matches with this event category. More...
 
bool match (const Evt &event) const
 Check whether given event matches with this event category. More...
 
bool less (const JEvtCategory &category) const
 Less-than method. More...
 
bool less (const JEvtCategoryHelper &helper) const
 Less-than method. More...
 
JProperties getProperties (const JEquationParameters &equation=JEvtCategory::getEquationParameters()) const
 Get properties of this class. More...
 

Friends

std::istream & operator>> (std::istream &in, JEvtCategoryHelper &object)
 Read event category from input. More...
 
std::ostream & operator<< (std::ostream &out, const JEvtCategoryHelper &object)
 Write event category to output. More...
 

Detailed Description

Helper class for event categories.

Definition at line 32 of file JEvtCategoryHelper.hh.

Member Typedef Documentation

◆ pointer_type

Definition at line 36 of file JEvtCategoryHelper.hh.

Constructor & Destructor Documentation

◆ JEvtCategoryHelper() [1/5]

JAANET::JEvtCategoryHelper::JEvtCategoryHelper ( )
inline

Default constructor.

Definition at line 41 of file JEvtCategoryHelper.hh.

41  :
42  pointer_type()
43  {}
std::shared_ptr< JEvtCategory > pointer_type

◆ JEvtCategoryHelper() [2/5]

JAANET::JEvtCategoryHelper::JEvtCategoryHelper ( const pointer_type p)
inline

Constructor.

Parameters
pshared pointer to event category

Definition at line 51 of file JEvtCategoryHelper.hh.

51  :
52  pointer_type(p)
53  {}

◆ JEvtCategoryHelper() [3/5]

JAANET::JEvtCategoryHelper::JEvtCategoryHelper ( const JEvtCategory category)
inline

Constructor.

Parameters
categoryevent category

Definition at line 61 of file JEvtCategoryHelper.hh.

62  {
63  this->configure(category);
64  }
void configure(const pointer_type &p)
Configuration.

◆ JEvtCategoryHelper() [4/5]

JAANET::JEvtCategoryHelper::JEvtCategoryHelper ( const JHead header)
inline

Constructor.

Parameters
headerMC header

Definition at line 72 of file JEvtCategoryHelper.hh.

73  {
74  this->configure(header);
75  }

◆ JEvtCategoryHelper() [5/5]

JAANET::JEvtCategoryHelper::JEvtCategoryHelper ( const int  type)
inline

Constructor.

Parameters
typePDG type

Definition at line 83 of file JEvtCategoryHelper.hh.

84  {
85  this->configure(type);
86  }

Member Function Documentation

◆ configure() [1/4]

void JAANET::JEvtCategoryHelper::configure ( const pointer_type p)
inline

Configuration.

Parameters
pshared pointer to event category

Definition at line 94 of file JEvtCategoryHelper.hh.

95  {
96  static_cast<pointer_type&>(*this) = p;
97  }

◆ configure() [2/4]

void JAANET::JEvtCategoryHelper::configure ( const JEvtCategory category)
inline

Configuration.

Parameters
categoryevent category

Definition at line 105 of file JEvtCategoryHelper.hh.

106  {
107  reset(category.clone());
108  }
void reset(T &value)
Reset value.
virtual clone_type clone() const override
Get clone of this object.
Definition: JClonable.hh:69

◆ configure() [3/4]

void JAANET::JEvtCategoryHelper::configure ( const JHead header)
inline

Configuration.

Parameters
categoryevent category

Definition at line 116 of file JEvtCategoryHelper.hh.

117  {
118  using namespace JPP;
119 
120  if (is_neutrino_primary(header.primary.type)) {
121  reset(new JNeutrinoInteractionCategory(header));
122  } else if (is_muon_bundle_primary(header.primary.type)) {
123  reset(new JMuonBundleCategory(header));
124  } else {
125  THROW(JValueOutOfRange, "JEvtCategoryHelper::configure(): Cannot construct event category for given header with primary ID " << header.primary.type);
126  }
127  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
JAANET::primary primary
Definition: JHead.hh:1611
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:180
bool is_neutrino_primary(const int type)
Auxiliary function to check if given PDG code corresponds to a neutrino.
bool is_muon_bundle_primary(const int type)
Auxiliary function to check if given PDG code corresponds to a valid muon bundle primary type.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Class for muon bundle categories.
Class for neutrino interaction categories.
int type
Particle type.
Definition: JHead.hh:1204

◆ configure() [4/4]

void JAANET::JEvtCategoryHelper::configure ( const int  type)
inline

Configuration.

Parameters
typePDG type

Definition at line 135 of file JEvtCategoryHelper.hh.

136  {
137  using namespace JPP;
138 
139  if (is_neutrino_primary(type)) {
141  } else if (is_muon_bundle_primary(type)) {
142  reset(new JMuonBundleCategory(type));
143  } else {
144  THROW(JValueOutOfRange, "JEvtCategoryHelper::configure(): Cannot construct event category for PDG type " << type);
145  }
146  }

◆ getEvtCategory()

JEvtCategory& JAANET::JEvtCategoryHelper::getEvtCategory ( ) const
inline

Get reference to event category.

Returns
reference to event category

Definition at line 154 of file JEvtCategoryHelper.hh.

155  {
156  using namespace JPP;
157 
158  if (static_cast<const JEvtCategoryHelper&>(*this)) {
159  return *(this->get());
160  } else {
161  THROW(JNullPointerException, "JEvtCategoryHelper::getEvtCategory(): Event category is not set.");
162  }
163  }
Exception for null pointer operation.
Definition: JException.hh:234
Helper class for event categories.

◆ is_valid()

bool JAANET::JEvtCategoryHelper::is_valid ( ) const
inline

Check if event category is valid.

Returns
true if event category is valid; else false

Definition at line 171 of file JEvtCategoryHelper.hh.

172  {
173  return static_cast<const JEvtCategoryHelper&>(*this) && this->get()->is_valid();
174  }
bool is_valid() const
Check if event category is valid.

◆ match() [1/2]

bool JAANET::JEvtCategoryHelper::match ( const JHead header) const
inline

Check whether given MC header matches with this event category.

Parameters
headerMC header
Returns
true if matching; else false

Definition at line 183 of file JEvtCategoryHelper.hh.

184  {
185  const JEvtCategory& category = getEvtCategory();
186 
187  return category.match(header);
188  }
JEvtCategory & getEvtCategory() const
Get reference to event category.
Low-level interface for event categories.
Definition: JEvtCategory.hh:38
virtual bool match(const JHead &header) const =0
Check whether given MC header matches with this event category.

◆ match() [2/2]

bool JAANET::JEvtCategoryHelper::match ( const Evt event) const
inline

Check whether given event matches with this event category.

Parameters
eventevent
Returns
true if matching; else false

Definition at line 197 of file JEvtCategoryHelper.hh.

198  {
199  const JEvtCategory& category = getEvtCategory();
200 
201  return category.match(event);
202  }

◆ less() [1/2]

bool JAANET::JEvtCategoryHelper::less ( const JEvtCategory category) const
inline

Less-than method.

Parameters
categoryevent category
Returns
true if this event category is less than given event category; else false

Definition at line 211 of file JEvtCategoryHelper.hh.

212  {
213  const JEvtCategory& cat = getEvtCategory();
214 
215  return cat.less(category);
216  }
virtual bool less(const JEvtCategory &category) const
Less-than method.

◆ less() [2/2]

bool JAANET::JEvtCategoryHelper::less ( const JEvtCategoryHelper helper) const
inline

Less-than method.

Parameters
helpershared pointer to event category
Returns
true if this event category is less than given event category; else false

Definition at line 225 of file JEvtCategoryHelper.hh.

226  {
227  return this->less(helper.getEvtCategory());
228  }
bool less(const JEvtCategory &category) const
Less-than method.

◆ getProperties()

JProperties JAANET::JEvtCategoryHelper::getProperties ( const JEquationParameters equation = JEvtCategory::getEquationParameters()) const
inline

Get properties of this class.

Parameters
equationequation parameters

Definition at line 236 of file JEvtCategoryHelper.hh.

237  {
238  const JEvtCategory& cat = getEvtCategory();
239 
240  return cat.getProperties();
241  }
virtual JProperties getProperties(const JEquationParameters &eqpars=JEvtCategory::getEquationParameters())
Get properties of this class.

Friends And Related Function Documentation

◆ operator>>

std::istream& operator>> ( std::istream &  in,
JEvtCategoryHelper object 
)
friend

Read event category from input.

Parameters
ininput stream
objectevent category
Returns
input stream

Definition at line 251 of file JEvtCategoryHelper.hh.

252  {
253  using namespace std;
254 
255  if (object) {
256 
257  return object.get()->read(in);
258 
259  } else {
260 
261  streampos pos = in.tellg();
262 
263  int type = 0;
264 
265  if (in >> type) {
266  object.configure(type);
267  return in;
268  }
269 
270  in.clear();
271  in.seekg(pos);
272 
273  JNeutrinoInteractionCategory neutrinoInteraction;
274  neutrinoInteraction.getProperties().read(in);
275 
276  if (neutrinoInteraction.is_valid()) {
277  object.configure(neutrinoInteraction);
278  return in;
279  }
280 
281  in.clear();
282  in.seekg(pos);
283 
284  JMuonBundleCategory muonBundle;
285  muonBundle.getProperties().read(in);
286 
287  if (muonBundle.is_valid()) {
288  object.configure(muonBundle);
289  }
290 
291  return in;
292  }
293  }
bool read(const JEquation &equation)
Read equation.
Definition: JProperties.hh:679
Definition: JSTDTypes.hh:14
bool is_valid() const override final
Check if muon bundle category is valid.
JProperties getProperties(const JEquationParameters &equation=JEvtCategory::getEquationParameters()) override final
Get properties of this class.
bool is_valid() const override final
Check if neutrino interaction categories is valid.
JProperties getProperties(const JEquationParameters &eqpars=JEvtCategory::getEquationParameters()) override final
Get properties of this class.

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const JEvtCategoryHelper object 
)
friend

Write event category to output.

Parameters
outoutput stream
objectevent category
Returns
output stream

Definition at line 303 of file JEvtCategoryHelper.hh.

304  {
305  if (object.is_valid()) {
306  return out << object.getEvtCategory();
307  } else {
308  return out << 0;
309  }
310  }

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