Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JModuleMapper.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5
6#include "TROOT.h"
7#include "TFile.h"
8#include "TProfile.h"
9
13
14#include "Jeep/JParser.hh"
15#include "Jeep/JMessage.hh"
16
17
18/**
19 * \file
20 *
21 * Example program to test JDETECTOR::JModuleMapper.
22 * \author mdejong
23 */
24int main(int argc, char **argv)
25{
26 using namespace std;
27
28 string outputFile;
29 string detectorFile;
30 int debug;
31
32 try {
33
34 JParser<> zap("Example program to test module mapping.");
35
36 zap['o'] = make_field(outputFile) = "mapper.root";
37 zap['a'] = make_field(detectorFile);
38 zap['d'] = make_field(debug) = 1;
39
40 zap(argc, argv);
41 }
42 catch(const exception& error) {
43 FATAL(error.what() << endl);
44 }
45
46
47 using namespace JPP;
48
49
51
52 try {
53 load(detectorFile, detector);
54 }
55 catch(const JException& error) {
56 FATAL(error);
57 }
58
59
60 TFile out(outputFile.c_str(), "recreate");
61
62 TProfile h1("h1", NULL, 1001,-0.5, 1000.5);
63
65
66 for (int i = 1; i <= h1.GetNbinsX(); ++i) {
67
68 const double x = h1.GetBinCenter(i);
69
70 mapper.configure(JMaximalDistance(x));
71
72 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
73 h1.Fill(x, (Double_t) mapper.getList(*module).size());
74 }
75 }
76
77 out.Write();
78 out.Close();
79}
string outputFile
Data structure for detector geometry and calibration.
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
int main(int argc, char **argv)
Map of associated modules in detector.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Detector data structure.
Definition JDetector.hh:96
Mapper for directly addressing of associated modules in the detector data structure.
const container_type & getList(const JObjectID &id) const
Get list with module data matching given module.
void configure(JMatch_t match)
Configure this module mapper.
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Detector file.
Definition JHead.hh:227
Auxiliary class to match modules according maximal distance.