54{
57
62
64 JLimit_t& numberOfEvents = inputFile.getLimit();
65 string detectorFile;
72 int id;
73 disable_container disable;
74 bool revert;
75 string option;
76 int numberOfEntries = 21;
78
79 try {
80
81 JParser<> zap(
"Example program to plot acoustic fit results.");
82
84
86
87 zap[
'f'] =
make_field(inputFile,
"input file (output of JKatoomba[.sh])");
96 zap[
'E'] =
make_field(
id,
"emitter identifier (-1 = all)") = -1;
98 zap[
'r'] =
make_field(revert,
"revert disabling of transmissions");
99 zap[
'O'] =
make_field(option,
"ROOT fit option, see TH1::Fit.") =
"LS";
102
103 zap(argc, argv);
104 }
105 catch(const exception &error) {
106 FATAL(error.what() << endl);
107 }
108
109
111
113
114 try {
116 }
119 }
120
123
124 for (JDetector::const_iterator i =
detector.begin(); i !=
detector.end(); ++i) {
125 receivers[i->getID()] = i->getLocation();
126 }
127
128 for (tripods_container::const_iterator i = tripods.begin(); i != tripods.end(); ++i) {
129 emitters[i->getID()] =
JEmitter(i->getID(),
130 i->getUTMPosition() -
detector.getUTMPosition());
131 }
132
133 for (transmitters_container::const_iterator i = transmitters.begin(); i != transmitters.end(); ++i) {
134 try {
135 emitters[i->getID()] =
JEmitter(i->getID(), i->getPosition() +
detector.getModule(i->getLocation()).getPosition());
136 }
137 catch(const exception&) {}
138 }
139
141
143
144
146
147 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
149 if (id == i->first || id == -1) {
151 }
152 }
153 }
154
156
158
159 JTreeScanner_t::iterator p = in.begin();
160
162
164
167
169
170 for ( ; p != in.end() && p-> begin()->getToA() < evt->
UNIXTimeStart - 0.5; ++p) {}
171
172 JTreeScanner_t::iterator q = p;
173
174 for ( ; q != in.end() && q->rbegin()->getToA() <= evt->
UNIXTimeStop + 0.5; ++q) {}
175
177
178 for (JTreeScanner_t::iterator i = p; i != q; ++i) {
179
180 if (id == i->getID() || id == -1) {
181
182 if (emitters.
has(i->getID())) {
183
184 const JEmitter& emitter = emitters[i->getID()];
185
186 for (JEvent::const_iterator hit = i->begin(); hit != i->end(); ++hit) {
187
188 if (receivers.
has(hit->getID()) && geometry.hasLocation(receivers[hit->getID()])) {
189
192
193 const JLocation& location = receivers[hit->getID()];
194
195 if (geometry .has(location.
getString()) &&
197
199 const JMODEL ::JString& parameters =
model.string[location.
getString()];
201
204 const double toa = hit->getToE() + D * Vi;
205
206 H2[
JTransmission_t(i->getID(), hit->getID())]->Fill(hit->getToA() - toa);
207 }
208 }
209 }
210 }
211 }
212 }
213 }
214
215 p = q;
216 }
218
219
221
225
229
230 for (Int_t i = 1; i <= HA->GetXaxis()->GetNbins(); ++i) {
231 HA->GetXaxis()->SetBinLabel(i,
MAKE_CSTRING(geometry.at(i-1).first));
232 HB->GetXaxis()->SetBinLabel(i,
MAKE_CSTRING(geometry.at(i-1).first));
233 }
234
236
237 TF1 f1("f1", "[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2]))");
238
240
242
243 TH1* h1 = i->second;
244
246
247 if (h1->GetEntries() >= numberOfEntries) {
248
250
251 h1->GetQuantiles(Q.size(), X.data(), Q.data());
252
253 f1.SetParameter(0, h1->GetMaximum());
254 f1.SetParameter(1, X[1]);
255 f1.SetParameter(2, 0.5*(X[2] - X[0]));
256
257 f1.SetParError(0, 0.1);
258 f1.SetParError(1, 1.0e-6);
259 f1.SetParError(2, 1.0e-6);
260
261 TFitResultPtr
result = h1->Fit(&f1, option.c_str(),
"same", X[1] - 5.0 * (X[2] - X[0]), X[1] + 5.0 * (X[2] - X[0]));
262
263 if (
result.Get() == NULL) {
264
265 ERROR(
"Invalid TFitResultPtr " << h1->GetName() << endl);
266
267 } else {
268
269 HA[i->first.tx]->Fill(geometry.getIndex(location.
getString()), location.
getFloor(), f1.GetParameter(1) * 1.0e3);
270 HB[i->first.tx]->Fill(geometry.getIndex(location.
getString()), location.
getFloor(), f1.GetParameter(2) * 1.0e3);
271 }
272
273 } else {
274
275 HA[i->first.tx]->Fill(geometry.getIndex(location.
getString()), location.
getFloor(), numeric_limits<double>::lowest());
276 }
277 }
278
279
281
282 out << H2 << HA << HB;
283
284 out.Write();
285 out.Close();
286}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
#define MAKE_CSTRING(A)
Make C-string.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Logical location of module.
const JLocation & getLocation() const
Get location.
int getFloor() const
Get floor number.
int getString() const
Get string number.
Router for direct addressing of module data in detector data structure.
Utility class to parse parameter values.
Data structure for position in three dimensions.
const JPosition3D & getPosition() const
Get position.
double getDistance(const JVector3D &pos) const
Get distance to point.
double getZ() const
Get z position.
Utility class to parse command line options.
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys.
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
Base class for JTreeScanner.
Template definition for direct access of elements in ROOT TChain.
JContainer< std::vector< JTripod > > tripods_container
JContainer< std::vector< JTransmitter > > transmitters_container
JContainer< std::vector< JHydrophone > > hydrophones_container
static const JSoundVelocity getSoundVelocity(1541.0, -17.0e-3, -2000.0)
Function object for velocity of sound.
JModel getModel(const JEvt &evt)
Get model.
floor_range getRangeOfFloors(const JDetector &detector)
Get range of floors.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
static const JStringCounter getNumberOfStrings
Function object to count unique strings.
void model(JModel_t &value)
Auxiliary function to constrain model during fit.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for mechanical model parameters with commented data.
double UNIXTimeStop
stop time
double UNIXTimeStart
start time
Model for fit to acoustics data.
Implementation for depth dependend velocity of sound.
JSoundVelocity & set(const double z0)
Set depth.
virtual double getInverseVelocity(const double D_m, const double z1, const double z2) const override
Get inverse velocity of sound.
Acoustic transmission identifier.
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary class for defining the range of iterations of objects.
static counter_type max()
Get maximum counter value.