4 #include "FilteredAnitaEvent.h" 6 #include "FilterStrategy.h" 7 #include "AnitaDataset.h" 8 #include "UsefulAnitaEvent.h" 10 #include "RawAnitaHeader.h" 13 #include "FFTWComplex.h" 16 #define NOMINAL_DT 1./2.6 19 static int makeBaselines(
int run, TGraph ** hpol, TGraph ** vpol,
int N = 5000)
21 char * datadir = getenv(
"ANITA_ROOT_DATA");
24 fprintf(stderr,
"The environmental variable ANITA_ROOT_DATA must be defined! Aborting.");
36 while (nevents < N && i < d.N())
41 if (d.header()-> trigType != 1 && d.header()->triggerTimeNs <= 1e6)
48 if (fae.checkSaturation())
51 for (
int ant = 0; ant < NUM_SEAVEYS; ant++)
55 hpol[ant] =
new TGraph(NSAMPLES/2+1);
56 vpol[ant] =
new TGraph(NSAMPLES/2+1);
71 for (
int j = 0; j < NSAMPLES/2+1; j++)
75 hpol[ant]->GetX()[j] = j / (NOMINAL_DT * NSAMPLES);
76 vpol[ant]->GetX()[j] = j / (NOMINAL_DT * NSAMPLES);
79 hpol[ant]->GetY()[j] += fft_h[j].getAbs() / (NSAMPLES/2.+1) * (j == 0 || j == NSAMPLES/2 ? 1 : 2);
80 vpol[ant]->GetY()[j] += fft_v[j].getAbs() / (NSAMPLES/2.+1) * (j == 0 || j == NSAMPLES/2 ? 1 : 2);
96 for (
int ant = 0; ant < NUM_SEAVEYS; ant++)
98 for (
int i = 0; i < NSAMPLES / 2 + 1; i++)
100 hpol[ant]->GetY()[i] /= nevents;
101 vpol[ant]->GetY()[i] /= nevents;
113 gSystem->mkdir(dir,
true);
114 TFile f(TString::Format(
"%s/%d_%d.root", dir, run,navg),
"RECREATE");
115 for (
int ant = 0; ant < NUM_SEAVEYS; ant++)
117 hpol[ant]->Write(TString::Format(
"h%d",ant));
118 vpol[ant]->Write(TString::Format(
"v%d",ant));
123 : navg(navg) , run(run)
125 bool foundit =
false;
128 TFile f(TString::Format(
"%s/%d_%d.root", persistdir, run,navg));
131 for (
int ant = 0; ant < NUM_SEAVEYS; ant++)
133 TGraph * found_hpol = (TGraph*) f.Get(TString::Format(
"h%d",ant));
134 hpol[ant] =
new TGraph(*found_hpol);
136 TGraph * found_vpol = (TGraph*) f.Get(TString::Format(
"v%d",ant));
137 vpol[ant] =
new TGraph(*found_vpol);
145 printf(
"Didn't find baselines... creating!\n");
148 printf(
"Define UCORRELATOR_BASELINE_DIR to persist somewhere.\n");
150 makeBaselines(run, hpol, vpol, navg);
154 hpol_avg =
new TGraph(NSAMPLES/2+1);
155 vpol_avg =
new TGraph(NSAMPLES/2+1);
157 memcpy(hpol_avg->GetX(), hpol[0]->GetX(),
sizeof(double) * hpol_avg->GetN());
158 memcpy(vpol_avg->GetX(), vpol[0]->GetX(),
sizeof(double) * vpol_avg->GetN());
160 for (
int ant = 0; ant < NUM_SEAVEYS; ant++)
162 for (
int i =0; i < NSAMPLES/2 +1; i++)
164 hpol_avg->GetY()[i] += hpol[ant]->GetY()[i] / NUM_SEAVEYS;
165 vpol_avg->GetY()[i] += vpol[ant]->GetY()[i] / NUM_SEAVEYS;
Baseline(int run, int navg=5000, const char *persistdir="")
A filter strategy defines the sets of filters that are used and provides some introspection abilities...
void saveToDir(const char *dir)
This is a wrapper class for a complex number.
This class is intended to store all the necessary data about an ANITA event for filtering and analysi...