25{
28
30 double P;
31 size_t size;
34
35 try {
36
37 JParser<> zap(
"Example program to test policy method for missing module data.");
38
44
46 }
47 catch(const exception &error) {
49 }
50
52
54 FATAL(
"Invalid probability " << P <<
endl);
55 }
56
58
59 try {
61 }
64 }
65
67
68 struct counter_type {
69 counter_type() :
70 count(0)
71 {}
72
73 int count;
74 };
75
77
79 strings[module->getString()].count += 1;
80 }
81
83
85 if (
gRandom->Rndm() <= P || strings[
module->getString()].count == 1)
86 buffer.insert(module->getID());
87 else
88 strings[module->getString()].count -= 1;
89 }
90
92
93
94 const JPolicy policy(router, buffer.begin(), buffer.end(), size);
95
97
98 const int id = module->getID();
99
100 if (
debug >= debug_t || buffer.count(
id) == 0) {
101
102 cout <<
"module: " <<
setw(10) <<
id <<
' '
104 << buffer.count(id) << flush;
105
106 if (buffer.count(id) == 0) {
107
109
110 if (
module->getFloor() != 0) {
111
112 const JPolicy::mapped_type
result = policy.at(
id);
113
114 for (JPolicy::mapped_type::const_iterator i =
result.begin(); i !=
result.end(); ++i) {
115 cout <<
' ' <<
getLabel(router.getModule(*i).getLocation());
116 }
117
118 } else {
119
120 cout <<
' ' <<
"skip";
121 }
122 }
123
125 }
126
127 if (
module->getFloor() != 0) {
128 ASSERT(buffer.count(
id) != 0 || !policy.at(
id).empty(),
"Test policy module at " <<
module->getLocation());
129 }
130 }
131
132 return 0;
133}
#define DEBUG(A)
Message macros.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Router for direct addressing of module data in detector data structure.
Template definition of a multi-dimensional oscillation probability interpolation table.
Utility class to parse command line options.
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary class to define policy for invalid modules.