2 #include "AnitaVersion.h" 10 #include "AnitaGeomTool.h" 20 #define DEG2RAD M_PI / 180 24 static void fillBases(std::vector<base> & baseList,
int anita)
29 fname.Form(
"%s/share/anitaCalib/baseListRestrictedA%d.root", getenv(
"ANITA_UTIL_INSTALL_DIR"), anita);
30 TString oldPwd = gDirectory->GetPath();
31 TFile fbase(fname.Data());
35 fprintf(stderr,
"Couldn't load base list for ANITA %d. Sorry :(\n", anita);
42 TIter iter(fbase.GetListOfKeys());
45 while ((k = (TKey *) iter()))
49 TClass * cl = gROOT->GetClass(k->GetClassName());
50 if (!cl->InheritsFrom(
"TTree"))
continue;
52 TTree * t = (TTree*) k->ReadObj();
53 TString source = t->GetName();
55 std::string * str_name = 0;
60 t->SetBranchAddress(
"name",&str_name);
61 t->SetBranchAddress(
"fullLat",&lat);
62 t->SetBranchAddress(
"fullLong",&lon);
63 t->SetBranchAddress(
"alt",&alt);
65 for (
int i = 0; i < t->GetEntries(); i++)
68 baseList.push_back(
base(TString(*str_name), source, lat,lon,alt));
72 gDirectory->cd(oldPwd);
76 static void fillPaths(std::vector<path> & pathList,
int anita)
80 fname.Form(
"%s/share/anitaCalib/transientListRestrictedA%d.root", getenv(
"ANITA_UTIL_INSTALL_DIR"), anita);
84 if (access(fname.Data(),R_OK))
86 fprintf(stderr,
"Couldn't find restricted list for ANITA %d (%s). Will try to load unrestricted list. \n", anita, fname.Data());
87 fname.Form(
"%s/share/anitaCalib/transientListUnrestrictedA%d.root", getenv(
"ANITA_UTIL_INSTALL_DIR"), anita);
89 TString oldPwd = gDirectory->GetPath();
91 TFile fpath(fname.Data());
95 fprintf(stderr,
"Couldn't find unrestricted list for ANITA %d (%s). Sorry :( \n", anita, fname.Data());
99 TIter iter(fpath.GetListOfKeys());
101 while ((k = (TKey *) iter()))
105 TClass * cl = gROOT->GetClass(k->GetClassName());
106 if (!cl->InheritsFrom(
"TTree"))
continue;
108 TTree * t = (TTree*) k->ReadObj();
110 TString source = t->GetName();
111 char callsign_buf[1024];
121 if(source.Contains(
"AAD") || source.Contains(
"Flight")){
126 t->SetBranchAddress(
"callSign",callsign_buf);
127 if (!t->GetBranch(
"fullLong"))
133 t->SetBranchAddress(
"fullLong",&lon);
134 t->SetBranchAddress(
"fullLat",&lat);
135 t->SetBranchAddress(
"timeUTC",&time);
137 if (t->GetBranch(
"altitude"))
139 t->SetBranchAddress(
"altitude",&alt);
142 for (
int i = 0; i < t->GetEntries(); i++)
145 TString callsign = callsign_buf;
148 UInt_t unsignedTime = time;
149 Double_t doubleAlt = alt;
153 path tempPath(TString(callsign.Data()), source, 1, &lat, &lon, &doubleAlt, &unsignedTime);
154 tempPath.isFlight = isFlight;
155 std::vector<path>::iterator it = std::find_if(pathList.begin(), pathList.end(), tempPath);
156 if(it != pathList.end()){
157 it->ts.push_back(tempPath.ts.at(0));
158 it->ps.push_back(tempPath.ps.at(0));
161 pathList.push_back(tempPath);
168 gDirectory->cd(oldPwd);
174 static std::vector<base> no_bases;
175 static std::vector<path> no_paths;
181 fillBases(bases, anita);
183 std::vector<base> bases;
191 fillPaths(paths, anita);
193 std::vector<path> paths;
199 static std::vector<base> & bases()
201 if (AnitaVersion::get() == 2)
207 else if (AnitaVersion::get() == 3)
213 else if (AnitaVersion::get() == 4)
220 fprintf(stderr,
"Don't have bases for %d\n", AnitaVersion::get());
224 static std::vector<path> & paths()
227 if (AnitaVersion::get() == 3)
233 else if (AnitaVersion::get() == 4)
239 fprintf(stderr,
"Don't have paths for %d\n", AnitaVersion::get());
245 index = index < bases().size() ? index : 0;
246 return bases().at(index);
251 index = index < paths().size() ? index : 0;
252 return paths().at(index);
257 if (index > bases().size() + paths().size()) index = 0;
262 size_t BaseList::getNumBases(){
263 return bases().size();
266 size_t BaseList::getNumPaths() {
267 return paths().size();
270 size_t BaseList::getNumAbstractBases(){
271 return bases().size() + paths().size();
276 void BaseList::makeBaseList()
279 fillBases(bases(), AnitaVersion::get());
280 fillPaths(paths(), AnitaVersion::get());
284 void BaseList::makeEmptyBaseList()
290 BaseList::path::path(
const TString & name, TString & source,
291 int npoints,
const double * lat,
const double * lon,
292 const double * alt,
const unsigned * time)
295 : name(name) , dataSource(source), ts(time, time + npoints)
299 for (
int i = 0; i < npoints; i++)
301 ps.push_back(
AntarcticCoord(AntarcticCoord::WGS84, lat[i], lon[i], alt[i]));
311 if (!isValid(t))
return AntarcticCoord(AntarcticCoord::WGS84, 90, 0, 0);
314 int l = TMath::BinarySearch(ts.size(), & ts [0], t);
316 double low_frac = double(t - ts [l]) / double(ts [u] - ts [l]);
322 double clz = (!cl.z || cl.z < 0) ? gndl : cl.z;
323 double cuz = (!cu.z || cu.z < 0) ? gndu : cu.z;
328 cl.to(AntarcticCoord::CARTESIAN), cu.to(AntarcticCoord::CARTESIAN);
334 TVector3 g = low_frac * std::abs(1 / cu.z) * cu.v() + (1 - low_frac) * std::abs(1 / cl.z) * cl.v();
335 g(0) *= GEOID_MIN / GEOID_MAX;
336 g(1) *= GEOID_MIN / GEOID_MAX;
345 if (clz == gndl && cuz == gndu) {
347 c.to(AntarcticCoord::WGS84);
349 c.to(AntarcticCoord::STEREOGRAPHIC);
353 c.to(AntarcticCoord::STEREOGRAPHIC);
354 c.z = low_frac * cuz + (1 - low_frac) * clz;
418 int BaseList::findBases(
const char * query, std::vector<int> * matches,
bool include_paths)
421 int first_found = -1;
422 for (
unsigned i = 0; i < include_paths ? getNumAbstractBases() : getNumBases(); i++)
426 if (strcasestr(a.getName(), query))
428 if (first_found < 0) first_found = i;
431 matches->push_back(i);
440 void BaseList::base::Draw(
const char * opt)
const 442 AntarcticCoord stereo = position.as(AntarcticCoord::STEREOGRAPHIC);
446 TMarker * m =
new TMarker(stereo.x, stereo.y, 2);
447 m->SetBit(kCanDelete);
453 TText * t =
new TText(stereo.x + 50e3, stereo.y, getName());
454 t->SetBit(kCanDelete);
460 void BaseList::path::Draw(
const char * opt)
const 463 if (strchr(opt,
'p') || strchr(opt,
'l'))
465 TGraph * g =
new TGraph;
466 for (
unsigned i = 0; i < ps.size(); i++)
469 g->SetPoint(i, stereo.x, stereo.y);
472 g->SetBit(kCanDelete);
479 TText * t =
new TText(stereo.x+50e3, stereo.y, getName());
480 t->SetBit(kCanDelete);
static Double_t SurfaceAboveGeoid(Double_t longitude, Double_t latitude, RampdemReader::dataSet=rampdem)
std::vector< AntarcticCoord > ps
true for flight, false for traverse