Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
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.
 
 JEvtCategoryHelper (const pointer_type &p)
 Constructor.
 
 JEvtCategoryHelper (const JEvtCategory &category)
 Constructor.
 
 JEvtCategoryHelper (const JHead &header)
 Constructor.
 
 JEvtCategoryHelper (const int type)
 Constructor.
 
void configure (const pointer_type &p)
 Configuration.
 
void configure (const JEvtCategory &category)
 Configuration.
 
void configure (const JHead &header)
 Configuration.
 
void configure (const int type)
 Configuration.
 
JEvtCategorygetEvtCategory () const
 Get reference to event category.
 
bool is_valid () const
 Check if event category is valid.
 
bool match (const JHead &header) const
 Check whether given MC header matches with this event category.
 
bool match (const Evt &event) const
 Check whether given event matches with this event category.
 
bool less (const JEvtCategory &category) const
 Less-than method.
 
bool less (const JEvtCategoryHelper &helper) const
 Less-than method.
 
JProperties getProperties (const JEquationParameters &equation=JEvtCategory::getEquationParameters())
 Get properties of this class.
 
JProperties getProperties (const JEquationParameters &equation=JEvtCategory::getEquationParameters()) const
 Get properties of this class.
 

Friends

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

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 :
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 :
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.

◆ configure() [3/4]

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

Configuration.

Parameters
headerheader

Definition at line 116 of file JEvtCategoryHelper.hh.

117 {
118 using namespace JPP;
119
120 if (is_neutrino_primary(header.primary.type)) {
122 } else if (is_mupage(header) || 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.
Exception for accessing a value in a collection that is outside of its range.
bool is_neutrino_primary(const int type)
Auxiliary function to check if given PDG code corresponds to a neutrino.
bool is_mupage(const JHead &header)
Check for generator.
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.

◆ 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.
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 }
JEvtCategoryHelper()
Default constructor.

◆ 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.

◆ 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 }

◆ 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() [1/2]

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

Get properties of this class.

Parameters
equationequation parameters

Definition at line 236 of file JEvtCategoryHelper.hh.

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

◆ getProperties() [2/2]

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

Get properties of this class.

Parameters
equationequation parameters

Definition at line 247 of file JEvtCategoryHelper.hh.

248 {
249 return getEvtCategory().getProperties(equation);
250 }

Friends And Related Symbol 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 260 of file JEvtCategoryHelper.hh.

261 {
262 using namespace std;
263
264 if (object) {
265
266 return object.get()->read(in);
267
268 } else {
269
270 streampos pos = in.tellg();
271
272 int type = 0;
273
274 if (in >> type) {
275 object.configure(type);
276 return in;
277 }
278
279 in.clear();
280 in.seekg(pos);
281
282 JNeutrinoInteractionCategory neutrinoInteraction;
283 neutrinoInteraction.getProperties().read(in);
284
285 if (neutrinoInteraction.is_valid()) {
286 object.configure(neutrinoInteraction);
287 return in;
288 }
289
290 in.clear();
291 in.seekg(pos);
292
293 JMuonBundleCategory muonBundle;
294 muonBundle.getProperties().read(in);
295
296 if (muonBundle.is_valid()) {
297 object.configure(muonBundle);
298 }
299
300 return in;
301 }
302 }

◆ 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 312 of file JEvtCategoryHelper.hh.

313 {
314 if (object.is_valid()) {
315 return out << object.getEvtCategory();
316 } else {
317 return out << 0;
318 }
319 }
bool is_valid() const
Check if event category is valid.

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