Jpp
Functions
JDetector.cc File Reference
#include <stdlib.h>
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include <deque>
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JDetectorParameters.hh"
#include "JDetector/JAnchor.hh"
#include "JDetector/JDetectorAddressMapToolkit.hh"
#include "JSupport/JMeta.hh"
#include "Jeep/JeepToolkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to generate detector files.

The footprint of the detector can be provided through an input file (option -f).

When no input file for the footprint is specified, the footprint is according the so-called WPD reference detector which is subsequently scaled according the specified line distance (JDETECTOR::JDetectorParameters::lineDistance_m).
The specified number of lines (JDETECTOR::JDetectorParameters::numberOfLines) is then selected from this footprint according the specified detector type (JDETECTOR::JDetectorParameters::detectorType).
The list of options includes:

  1. remove outer positions (massive);
  2. remove inner positions (hollow);
    Author
    mdejong

Definition in file JDetector.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 38 of file JDetector.cc.

39 {
40  using namespace std;
41  using namespace JPP;
42 
43  string inputFile;
44  string outputFile;
45  int detectorID;
46  string variant;
47  JDetectorParameters parameters;
48  double Zmin_m;
49  string option;
50  int debug;
51 
52  // default values
53 
54  parameters.detectorType = 1; //
55  parameters.floorDistance_m = 36.0; // [m]
56  parameters.numberOfFloors = 18; //
57  parameters.lineDistance_m = 90.0; // [m]
58  parameters.numberOfLines = 115; //
59 
60  try {
61 
62  JParser<> zap("Auxiliary program to generate detector files.");
63 
64  JDetectorParametersHelper helper(parameters);
65 
66  zap['f'] = make_field(inputFile) = "";
67  zap['o'] = make_field(outputFile);
68  zap['D'] = make_field(detectorID);
69  zap['V'] = make_field(variant) = getDetectorVersions<string>();
70  zap['@'] = make_field(helper) = JPARSER::initialised();
71  zap['z'] = make_field(Zmin_m) = 100.;
72  zap['O'] = make_field(option) = "ARCA", "ORCA", "Antares";
73  zap['d'] = make_field(debug) = 0;
74 
75  zap(argc, argv);
76  }
77  catch(const exception &error) {
78  FATAL(error.what() << endl);
79  }
80 
81 
82  JDetectorHeader header;
83 
84  if (option == "ARCA")
85  header = getARCADetectorHeader();
86  else if (option == "ORCA")
87  header = getORCADetectorHeader();
88  else if (option == "Antares")
89  ;
90  else
91  FATAL("Invalid option " << option << endl);
92 
93 
94  JDetector detector(detectorID, variant, header);
95 
96  if (!hasDetectorAddressMap(detector.getID())) {
97  FATAL("No detector address map for detector identifier " << detector.getID() << endl);
98  }
99 
100  detector.comment.add(JMeta(argc,argv));
101 
102  const JDetectorAddressMap& demo = getDetectorAddressMap(detector.getID());
103 
104 
105  deque<JAnchor> footprint;
106 
107  if (inputFile != "") {
108 
109  ifstream in(getFullFilename(LD_LIBRARY_PATH, inputFile).c_str());
110 
111  if (in) {
112 
113  for (JAnchor anchor; in >> anchor && footprint.size() < parameters.numberOfLines; ) {
114  footprint.push_back(anchor);
115  }
116 
117  in.close();
118 
119  } else {
120 
121  FATAL("Error opening file " << inputFile);
122  }
123 
124  } else {
125 
126  // WPD footprint
127 
128  footprint.push_back(JAnchor( 1, 6, -7));
129  footprint.push_back(JAnchor( 2, 188, 9));
130  footprint.push_back(JAnchor( 3, 131, 153));
131  footprint.push_back(JAnchor( 4, -85, 120));
132  footprint.push_back(JAnchor( 5, -175, 39));
133  footprint.push_back(JAnchor( 6, -64, -181));
134  footprint.push_back(JAnchor( 7, 90, -178));
135  footprint.push_back(JAnchor( 8, 368, 20));
136  footprint.push_back(JAnchor( 9, 251, 159));
137  footprint.push_back(JAnchor( 10, 264, -146));
138  footprint.push_back(JAnchor( 11, 189, 293));
139  footprint.push_back(JAnchor( 12, 12, 309));
140  footprint.push_back(JAnchor( 13, -176, 338));
141  footprint.push_back(JAnchor( 14, -266, 149));
142  footprint.push_back(JAnchor( 15, -336, -1));
143  footprint.push_back(JAnchor( 16, -248, -174));
144  footprint.push_back(JAnchor( 17, -196, -348));
145  footprint.push_back(JAnchor( 18, -18, -350));
146  footprint.push_back(JAnchor( 19, 211, -339));
147  footprint.push_back(JAnchor( 20, 541, -12));
148  footprint.push_back(JAnchor( 21, 442, 183));
149  footprint.push_back(JAnchor( 22, 422, -125));
150  footprint.push_back(JAnchor( 23, 364, 287));
151  footprint.push_back(JAnchor( 24, 342, -323));
152  footprint.push_back(JAnchor( 25, 297, 499));
153  footprint.push_back(JAnchor( 26, 51, 452));
154  footprint.push_back(JAnchor( 27, -78, 488));
155  footprint.push_back(JAnchor( 28, -281, 508));
156  footprint.push_back(JAnchor( 29, -325, 304));
157  footprint.push_back(JAnchor( 30, -455, 128));
158  footprint.push_back(JAnchor( 31, -541, 15));
159  footprint.push_back(JAnchor( 32, -429, -142));
160  footprint.push_back(JAnchor( 33, -327, -316));
161  footprint.push_back(JAnchor( 34, -255, -488));
162  footprint.push_back(JAnchor( 35, -103, -508));
163  footprint.push_back(JAnchor( 36, 74, -469));
164  footprint.push_back(JAnchor( 37, 289, -452));
165  footprint.push_back(JAnchor( 38, 715, 0));
166  footprint.push_back(JAnchor( 39, 653, 154));
167  footprint.push_back(JAnchor( 40, 614, -141));
168  footprint.push_back(JAnchor( 41, 530, 269));
169  footprint.push_back(JAnchor( 42, 512, -323));
170  footprint.push_back(JAnchor( 43, 473, 472));
171  footprint.push_back(JAnchor( 44, 458, -473));
172  footprint.push_back(JAnchor( 45, 395, 632));
173  footprint.push_back(JAnchor( 46, 205, 630));
174  footprint.push_back(JAnchor( 47, 1, 667));
175  footprint.push_back(JAnchor( 48, -160, 644));
176  footprint.push_back(JAnchor( 49, -352, 639));
177  footprint.push_back(JAnchor( 50, -413, 460));
178  footprint.push_back(JAnchor( 51, -564, 286));
179  footprint.push_back(JAnchor( 52, -636, 125));
180  footprint.push_back(JAnchor( 53, -717, 23));
181  footprint.push_back(JAnchor( 54, -605, -139));
182  footprint.push_back(JAnchor( 55, -518, -279));
183  footprint.push_back(JAnchor( 56, -482, -448));
184  footprint.push_back(JAnchor( 57, -379, -595));
185  footprint.push_back(JAnchor( 58, -211, -619));
186  footprint.push_back(JAnchor( 59, 8, -652));
187  footprint.push_back(JAnchor( 60, 214, -619));
188  footprint.push_back(JAnchor( 61, 395, -617));
189  footprint.push_back(JAnchor( 62, 886, -12));
190  footprint.push_back(JAnchor( 63, 802, 155));
191  footprint.push_back(JAnchor( 64, 844, -128));
192  footprint.push_back(JAnchor( 65, 697, 285));
193  footprint.push_back(JAnchor( 66, 731, -275));
194  footprint.push_back(JAnchor( 67, 621, 450));
195  footprint.push_back(JAnchor( 68, 600, -497));
196  footprint.push_back(JAnchor( 69, 568, 593));
197  footprint.push_back(JAnchor( 70, 517, -586));
198  footprint.push_back(JAnchor( 71, 430, 776));
199  footprint.push_back(JAnchor( 72, 240, 758));
200  footprint.push_back(JAnchor( 73, 70, 783));
201  footprint.push_back(JAnchor( 74, -75, 803));
202  footprint.push_back(JAnchor( 75, -252, 809));
203  footprint.push_back(JAnchor( 76, -478, 771));
204  footprint.push_back(JAnchor( 77, -510, 590));
205  footprint.push_back(JAnchor( 78, -643, 468));
206  footprint.push_back(JAnchor( 79, -741, 284));
207  footprint.push_back(JAnchor( 80, -845, 175));
208  footprint.push_back(JAnchor( 81, -907, -6));
209  footprint.push_back(JAnchor( 82, -792, -142));
210  footprint.push_back(JAnchor( 83, -737, -340));
211  footprint.push_back(JAnchor( 84, -639, -492));
212  footprint.push_back(JAnchor( 85, -518, -596));
213  footprint.push_back(JAnchor( 86, -455, -751));
214  footprint.push_back(JAnchor( 87, -260, -814));
215  footprint.push_back(JAnchor( 88, -103, -819));
216  footprint.push_back(JAnchor( 89, 106, -764));
217  footprint.push_back(JAnchor( 90, 274, -754));
218  footprint.push_back(JAnchor( 91, 417, -762));
219  footprint.push_back(JAnchor( 92, 1094, -4));
220  footprint.push_back(JAnchor( 93, 1010, 120));
221  footprint.push_back(JAnchor( 94, 992, -171));
222  footprint.push_back(JAnchor( 95, 898, 324));
223  footprint.push_back(JAnchor( 96, 901, -298));
224  footprint.push_back(JAnchor( 97, 768, 471));
225  footprint.push_back(JAnchor( 98, 818, -477));
226  footprint.push_back(JAnchor( 99, 731, 632));
227  footprint.push_back(JAnchor(100, 713, -633));
228  footprint.push_back(JAnchor(101, 625, 772));
229  footprint.push_back(JAnchor(102, 661, -759));
230  footprint.push_back(JAnchor(103, 530, 949));
231  footprint.push_back(JAnchor(104, 345, 960));
232  footprint.push_back(JAnchor(105, 221, 931));
233  footprint.push_back(JAnchor(106, -29, 962));
234  footprint.push_back(JAnchor(107, -155, 967));
235  footprint.push_back(JAnchor(108, -382, 917));
236  footprint.push_back(JAnchor(109, -545, 965));
237  footprint.push_back(JAnchor(110, -634, 779));
238  footprint.push_back(JAnchor(111, -731, 600));
239  footprint.push_back(JAnchor(112, -852, 471));
240  footprint.push_back(JAnchor(113, -903, 322));
241  footprint.push_back(JAnchor(114, -976, 166));
242  footprint.push_back(JAnchor(115, -1100, 11));
243  footprint.push_back(JAnchor(116, -1006, -131));
244  footprint.push_back(JAnchor(117, -867, -332));
245  footprint.push_back(JAnchor(118, -800, -504));
246  footprint.push_back(JAnchor(119, -706, -593));
247  footprint.push_back(JAnchor(120, -604, -800));
248  footprint.push_back(JAnchor(121, -503, -933));
249  footprint.push_back(JAnchor(122, -318, -927));
250  footprint.push_back(JAnchor(123, -177, -926));
251  footprint.push_back(JAnchor(124, -10, -894));
252  footprint.push_back(JAnchor(125, 155, -919));
253  footprint.push_back(JAnchor(126, 381, -967));
254  footprint.push_back(JAnchor(127, 531, -900));
255  footprint.push_back(JAnchor(128, 1091, 311));
256  footprint.push_back(JAnchor(129, 1061, -285));
257  footprint.push_back(JAnchor(130, 966, 481));
258  footprint.push_back(JAnchor(131, 958, -457));
259  footprint.push_back(JAnchor(132, 905, 658));
260  footprint.push_back(JAnchor(133, 863, -630));
261  footprint.push_back(JAnchor(134, 788, 742));
262  footprint.push_back(JAnchor(135, 686, 911));
263  footprint.push_back(JAnchor(136, 277, 1113));
264  footprint.push_back(JAnchor(137, 92, 1094));
265  footprint.push_back(JAnchor(138, -84, 1127));
266  footprint.push_back(JAnchor(139, -302, 1062));
267  footprint.push_back(JAnchor(140, -732, 892));
268  footprint.push_back(JAnchor(141, -793, 761));
269  footprint.push_back(JAnchor(142, -901, 661));
270  footprint.push_back(JAnchor(143, -1012, 456));
271  footprint.push_back(JAnchor(144, -1101, 280));
272  footprint.push_back(JAnchor(145, -1077, -326));
273  footprint.push_back(JAnchor(146, -973, -457));
274  footprint.push_back(JAnchor(147, -883, -602));
275  footprint.push_back(JAnchor(148, -822, -771));
276  footprint.push_back(JAnchor(149, -689, -910));
277  footprint.push_back(JAnchor(150, -457, -1066));
278  footprint.push_back(JAnchor(151, -268, -1067));
279  footprint.push_back(JAnchor(152, -58, -1080));
280  footprint.push_back(JAnchor(153, 72, -1100));
281  footprint.push_back(JAnchor(154, 280, -1081));
282 
283  // scale positions to specified distance
284 
285  for (deque<JAnchor>::iterator i = footprint.begin(); i != footprint.end(); ++i) {
286  i->mul(parameters.lineDistance_m * 0.5 / 90.0);
287  }
288 
289  if (parameters.numberOfLines > footprint.size()) {
290  FATAL("Available footprint inconsistent with specified number of lines "
291  << parameters.numberOfLines << " > " << footprint.size() << endl);
292  }
293 
294  // select specified number of lines
295 
296  sort(footprint.begin(), footprint.end());
297 
298  if (parameters.detectorType == 2) { // hollow detector
299  while (parameters.numberOfLines < footprint.size()) {
300  footprint.pop_front();
301  }
302  } else { // massive detector
303  while (parameters.numberOfLines < footprint.size()) {
304  footprint.pop_back();
305  }
306  }
307 
308  // reset object identifiers
309 
310  for (deque<JAnchor>::iterator i = footprint.begin(); i != footprint.end(); ++i) {
311  static_cast<JObjectID&>(*i) = JObjectID(distance(footprint.begin(),i) + 1);
312  }
313  }
314 
315 
316  for (deque<JAnchor>::iterator i = footprint.begin(); i != footprint.end(); ++i) {
317  DEBUG(i->getID() << ' ' << i->getX() << ' ' << i->getY() << endl);
318  }
319 
320 
321  // build detector
322 
323  int PMT = 1;
324 
325  for (deque<JAnchor>::const_iterator anchor = footprint.begin(); anchor != footprint.end(); ++anchor) {
326 
327  //const double R = anchor->getLength();
328 
329  for (unsigned int floor = 1; floor <= parameters.numberOfFloors; ++floor) {
330 
331  const JVector3D position(anchor->getX(),
332  anchor->getY(),
333  Zmin_m + (floor - 1) * parameters.floorDistance_m);
334 
335  const JModuleLocation location(anchor->getID(), floor);
336 
337  const int id = demo.getModuleID(location);
338 
339  JModule module;
340 
341  if (option == "ARCA" || option == "ORCA")
342  module = getModule(demo.get(id), id, location);
343  else if (option == "Antares")
344  module = getModule(id, location);
345  else
346  FATAL("Invalid option " << option << endl);
347 
348  module.add(position);
349 
350  for (JModule::iterator pmt = module.begin(); pmt != module.end(); ++pmt, ++PMT) {
351  pmt->setID(PMT++);
352  //pmt->setCalibration(JCalibration((R + position.getZ())/C));
353  }
354 
355  detector.push_back(module);
356  }
357  }
358 
359 
360  // Store detector.
361 
362  try {
363  store(outputFile, detector);
364  }
365  catch(const JException& error) {
366  FATAL(error);
367  }
368 
369  return 0;
370 }
JPARSER::initialised
Empty structure for specification of parser element that is initialised (i.e.
Definition: JParser.hh:63
getModule
const JModule & getModule(const JDetector &detector, const JModuleLocation &location)
find module with a given string and floor number
Definition: JBeaconSimulator.cc:927
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
distance
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Definition: PhysicsEvent.hh:434
PMT
JDAQPMTIdentifier PMT
Command line options.
Definition: JDAQTimesliceSelector.cc:35
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
debug
int debug
debug level
Definition: JSirene.cc:59
JDETECTOR::getORCADetectorHeader
JDetectorHeader getORCADetectorHeader()
Get detector header for ORCA.
Definition: JDetectorHeader.hh:235
JEEP::LD_LIBRARY_PATH
static const char *const LD_LIBRARY_PATH
Nick names of environment variables.
Definition: JeepToolkit.hh:29
JDETECTOR::getARCADetectorHeader
JDetectorHeader getARCADetectorHeader()
Get detector header for ARCA.
Definition: JDetectorHeader.hh:223
JDETECTOR::store
void store(const JString &file_name, const JDetector &detector)
Store detector to output file.
Definition: JDetectorToolkit.hh:532
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
JDETECTOR::hasDetectorAddressMap
bool hasDetectorAddressMap(const int id)
Check if detector address map is available.
Definition: JDetectorAddressMapToolkit.hh:499
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37
JEEP::getFullFilename
std::string getFullFilename(const std::string &variable, const std::string &file_name)
Get full file name (see JEEP::getPath).
Definition: JeepToolkit.hh:211
JDETECTOR::getDetectorAddressMap
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
Definition: JDetectorAddressMapToolkit.hh:363