11 #include "TFitResult.h"
53 int main(
int argc,
char **argv)
72 disable_container disable;
75 int numberOfEntries = 21;
80 JParser<> zap(
"Example program to plot acoustic fit results.");
86 zap[
'f'] =
make_field(inputFile,
"input file (output of JKatoomba[.sh])");
87 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
95 zap[
'E'] =
make_field(
id,
"emitter identifier (-1 = all)") = -1;
97 zap[
'r'] =
make_field(revert,
"revert disabling of transmissions");
98 zap[
'O'] =
make_field(option,
"ROOT fit option, see TH1::Fit.") =
"LS";
104 catch(
const exception &error) {
105 FATAL(error.what() << endl);
124 receivers[
i->getID()] =
i->getLocation();
127 for (tripods_container::const_iterator
i =
tripods.begin();
i !=
tripods.end(); ++
i) {
129 i->getUTMPosition() -
detector.getUTMPosition());
132 for (transmitters_container::const_iterator
i = transmitters.begin();
i != transmitters.end(); ++
i) {
136 catch(
const exception&) {}
146 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
148 if (
id ==
i->first ||
id == -1) {
158 JTreeScanner_t::iterator p = in.begin();
160 while (inputFile.hasNext()) {
162 STATUS(
"event: " << setw(10) << inputFile.getCounter() <<
'\r');
DEBUG(endl);
164 const JEvt* evt = inputFile.next();
167 DEBUG(
"model" << endl << model << endl);
169 for ( ; p != in.end() && p-> begin()->getToA() < evt->
UNIXTimeStart - 0.5; ++p) {}
171 JTreeScanner_t::iterator q = p;
173 for ( ; q != in.end() && q->rbegin()->getToA() <= evt->
UNIXTimeStop + 0.5; ++q) {}
177 for (JTreeScanner_t::iterator
i = p;
i != q; ++
i) {
179 if (
id ==
i->getID() ||
id == -1) {
181 if (emitters.has(
i->getID())) {
183 const JEmitter& emitter = emitters[
i->getID()];
185 for (JEvent::const_iterator hit =
i->begin(); hit !=
i->end(); ++hit) {
187 if (receivers.has(hit->getID()) && geometry.
hasLocation(receivers[hit->getID()])) {
192 const JLocation& location = receivers[hit->getID()];
194 if (geometry .has(location.
getString()) &&
202 const double Vi =
V.getInverseVelocity(D, emitter.
getZ(), position.
getZ());
203 const double toa = hit->getToE() + D * Vi;
223 range.getLength() + 1,
range.getLowerLimit() - 0.5,
range.getUpperLimit() + 0.5));
227 range.getLength() + 1,
range.getLowerLimit() - 0.5,
range.getUpperLimit() + 0.5));
229 for (Int_t
i = 1;
i <= HA->GetXaxis()->GetNbins(); ++
i) {
230 HA->GetXaxis()->SetBinLabel(
i,
MAKE_CSTRING(geometry.at(
i-1).first));
231 HB->GetXaxis()->SetBinLabel(
i,
MAKE_CSTRING(geometry.at(
i-1).first));
236 TF1
f1(
"f1",
"[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2]))");
246 if (h1->GetEntries() >= numberOfEntries) {
250 h1->GetQuantiles(
Q.size(), X.data(),
Q.data());
252 f1.SetParameter(0, h1->GetMaximum());
253 f1.SetParameter(1, X[1]);
254 f1.SetParameter(2, 0.5*(X[2] - X[0]));
256 f1.SetParError(0, 0.1);
257 f1.SetParError(1, 1.0e-6);
258 f1.SetParError(2, 1.0e-6);
260 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 if (result.Get() == NULL) {
264 ERROR(
"Invalid TFitResultPtr " << h1->GetName() << endl);
281 out << H2 << HA << HB;
JModel getModel(const JEvt &evt)
Get model.
Utility class to parse command line options.
Q(UTCMax_s-UTCMin_s)-livetime_s
int main(int argc, char *argv[])
int getFloor() const
Get floor number.
const JModule & getModule(const JObjectID &id) const
Get module parameters.
JContainer< std::vector< JTransmitter > > transmitters_container
static JDetectorMechanics getMechanics
Function object to get string mechanics.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
ROOT TTree parameter settings.
Router for direct addressing of module data in detector data structure.
Utility class to parse parameter values.
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
#define MAKE_CSTRING(A)
Make C-string.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Dynamic ROOT object management.
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
double getDistance(const JVector3D &pos) const
Get distance to point.
floor_range getRangeOfFloors(const JDetector &detector)
Get range of floors.
Template definition for direct access of elements in ROOT TChain.
Data structure for detector geometry and calibration.
Utility class to parse parameter values.
Data structure for hydrophone.
const JPolynome f1(1.0, 2.0, 3.0)
Function.
Model for fit to acoustics data.
double UNIXTimeStop
stop time
Auxiliary class for defining the range of iterations of objects.
static const JSoundVelocity getSoundVelocity(1541.0,-17.0e-3,-2000.0)
Function object for velocity of sound.
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
I/O formatting auxiliaries.
JContainer< std::vector< JHydrophone > > hydrophones_container
Data structure for transmitter.
Logical location of module.
const JLocation & getLocation() const
Get location.
Auxiliary wrapper for I/O of container with optional comment (see JComment).
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
JPosition3D getPosition(const Vec &pos)
Get position.
void Write(TDirectory &out, const bool wm=false)
Write objects to file.
const JPosition3D & getPosition() const
Get position.
JContainer< std::vector< JTripod > > tripods_container
General purpose messaging.
static const JStringCounter getNumberOfStrings
Function object to count unique strings.
Implementation for depth dependend velocity of sound.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Base class for JTreeScanner.
Direct access to module in detector data structure.
JACOUSTICS::JModel::string_type string
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
int getString() const
Get string number.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
double UNIXTimeStart
start time
General purpose class for object reading from a list of file names.
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Utility class to parse command line options.
Acoustic transmission identifier.
bool hasLocation(const JLocation &location) const
Check if this detector has given location.
no fit printf nominal n $STRING awk v X
Data structure for position in three dimensions.
const JLimit & getLimit() const
Get limit.
do set_variable DETECTOR_TXT $WORKDIR detector
Data structure for tripod.
Acoustic transmission identifier.
do echo Generating $dir eval D
double getZ() const
Get z position.
#define DEBUG(A)
Message macros.
Data structure for optical module.