Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JCOMPASS::JPolicy Struct Reference

Auxiliary class to define policy for invalid modules. More...

#include <JPolicy.hh>

Inheritance diagram for JCOMPASS::JPolicy:
std::map< int, std::vector< int > >

Public Member Functions

template<class T >
 JPolicy (const JModuleRouter &router, T __begin, T __end, const size_t size=1)
 Constructor.
 

Detailed Description

Auxiliary class to define policy for invalid modules.

The policy is defined as a map of the identifier of a module to a list of identifiers of valid modules.
For invalid modules, the valid modules in the nearest floors in the same string are selected.

Definition at line 31 of file JPolicy.hh.

Constructor & Destructor Documentation

◆ JPolicy()

template<class T >
JCOMPASS::JPolicy::JPolicy ( const JModuleRouter & router,
T __begin,
T __end,
const size_t size = 1 )
inline

Constructor.

Parameters
routermodule router
__beginbegin of list with identifiers of valid modules
__endend of list with identifiers of valid modules
sizeminimum number of valid modules in case of an invalid module

Definition at line 44 of file JPolicy.hh.

45 {
46 using namespace std;
47 using namespace JPP;
48
49 map<int, set<int> > zmap; // valid floors per string
50
51 for (T i = __begin; i != __end; ++i) {
52
53 if (router.hasModule(*i)) {
54
55 const JLocation& location = router.getModule(*i);
56
57 zmap[location.getString()].insert(location.getFloor());
58 }
59 }
60
61 map<JLocation, int> detector; // inverse router
62
63 for (JModuleRouter::const_iterator module = router->begin(); module != router->end(); ++module) {
64 detector[module->getLocation()] = module->getID();
65 }
66
67 for (JModuleRouter::const_iterator module = router->begin(); module != router->end(); ++module) {
68
69 if (module->getFloor() != 0) {
70
71 const int id = module->getID();
72 const int string = module->getString();
73
74 if (!zmap[string].empty()) {
75
76 if (zmap[string].count(module->getFloor()) != 0) {
77
78 (*this)[id].push_back(id);
79
80 } else {
81
82 for (size_t step = 1; (*this)[id].size() < size && (module->getFloor() + (int) step <= *zmap[string].rbegin() ||
83 module->getFloor() - (int) step >= *zmap[string]. begin()); ++step) {
84 for (int sign : { -1, +1 }) {
85
86 const int floor = module->getFloor() + sign * step;
87
88 if (zmap[string].count(floor) != 0) {
89 (*this)[id].push_back(detector[JLocation(string,floor)]);
90 }
91 }
92 }
93 }
94 }
95 }
96 }
97 }
Logical location of module.
Definition JLocation.hh:40
int getFloor() const
Get floor number.
Definition JLocation.hh:146
int getString() const
Get string number.
Definition JLocation.hh:135
JDetector::const_iterator const_iterator
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Detector file.
Definition JHead.hh:227

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