1 #include "NoiseMonitor.h" 2 #include "FilteredAnitaEvent.h" 3 #include "RawAnitaHeader.h" 4 #include "FilterStrategy.h" 5 #include "FilterOperation.h" 6 #include "AnitaDataset.h" 11 #include "TProfile2D.h" 14 void NoiseMonitor::getRmsDirEnv(){
15 fRmsDir = getenv(
"ANITA_RMS_DIR");
17 std::cerr <<
"Warning in " << __PRETTY_FUNCTION__
18 <<
", can't see env ANITA_RMS_DIR. " 19 <<
"Will look for/make rms profiles in pwd" 25 UInt_t NoiseMonitor::makeStratHashFromDesc(
const FilterStrategy* fs){
30 UInt_t hash = hasher.Hash();
35 TString NoiseMonitor::getFileName(
int run){
36 return TString::Format(
"%s/rms_anita%d_run%d_hash%u.root", fRmsDir, AnitaVersion::get(), run, fHash);
39 void NoiseMonitor::getProfilesFromFileRun(
int run){
41 TString theRootPwd = gDirectory->GetPath();
42 TString fileName = getFileName(run);
46 fFile = TFile::Open(fileName);
55 std::cerr <<
"Warning in " << __PRETTY_FUNCTION__ <<
", couldn't find file " << fileName <<
", will need to generate it. This may take some time." << std::endl;
59 std::cerr <<
"Error! unable to get the profiles I just tried to read for run " << run <<
", " 63 fFile = TFile::Open(fileName);
70 std::cerr <<
"Warning in " << __PRETTY_FUNCTION__
71 <<
", unable to find RMS profiles for run " << run
72 <<
". Something bad is about to happen!" 79 gDirectory->cd(theRootPwd);
84 TString name = TString::Format(
"rms?_%d_%u", run, fHash);
85 const Ssiz_t namePolCharPos = name.First(
'?');
91 void NoiseMonitor::makeProfiles(
int run){
93 TString fileName = getFileName(run);
95 std::cout <<
"Info in " << __PRETTY_FUNCTION__ <<
", generating minimim bias RMS profiles for run " << run <<
" in file " << fileName << std::endl;
96 TFile* f = TFile::Open(fileName,
"recreate");
104 double startTime = header->
realTime;
108 double endTime = header->
realTime + 1;
110 const int nBin = (endTime - startTime)/
double(defaultTimeScaleSeconds);
113 std::vector<bool> original_enable_outputs = fFilterStrat->enable_outputs;
114 for(
unsigned i=0; i < fFilterStrat->enable_outputs.size(); i++){
115 fFilterStrat->enable_outputs.at(i) =
false;
118 TString name = TString::Format(
"rms?_%d_%u", run, fHash);
119 TString title = TString::Format(
"RMS for each ?Pol for run %d (FilterStrategy operations descriptions hash = %u);Antenna;realTime", run, fHash);
121 const Ssiz_t titlePolCharPos = title.First(
'?');
127 TString name = getHistName(pol, run);
130 profs.at(pol) =
new TProfile2D(name, title, NUM_SEAVEYS, -0.5, NUM_SEAVEYS-0.5, nBin, startTime, endTime);
133 const double deltaPrint = double(n)/1000;
134 double nextPrint = 0;
136 for(
int entry=0; entry < n; entry++){
145 for(
int ant=0; ant < NUM_SEAVEYS; ant++){
148 double rms = TMath::RMS(gr->GetN(), gr->GetY());
149 profs.at(pol)->Fill(ant, header->
realTime, rms);
153 if(entry >= nextPrint){
155 int m = nm*nextPrint/n;
156 fprintf(stderr,
"\r%4.2f %% complete", 100*nextPrint/n);
158 for(
int i=0; i < m; i++) std::cerr <<
"=";
159 for(
int i=m; i < nm; i++) std::cerr <<
" ";
161 nextPrint += deltaPrint;
162 if(nextPrint >= n){std::cerr << std::endl;}
176 fFilterStrat->enable_outputs = original_enable_outputs;
181 std::cout <<
"Info in " << __PRETTY_FUNCTION__ <<
", complete!" << std::endl;
193 : fFilterStrat(fs), fFile(NULL)
196 fHash = makeStratHashFromDesc(fs);
208 : fFilterStrat(NULL), fFile(NULL)
268 getProfilesFromFileRun(run);
274 AnitaVersion::setVersionFromUnixTime(realTime);
276 const TProfile2D* p = fCurrent.get(pol);
278 if(!(p && realTime >= fCurrent.startTime() && realTime < fCurrent.endTime())){
280 p = fCurrent.get(pol);
286 Int_t bin = ((TProfile2D*)p)->FindBin(ant, realTime);
287 rms = p->GetBinContent(bin);
293 void NoiseMonitor::ProfPair::set(
const TProfile2D* h,
const TProfile2D* v){
295 H =
const_cast<TProfile2D*
>(h);
296 V =
const_cast<TProfile2D*
>(v);
299 fStartTime = H->GetYaxis()->GetBinLowEdge(1);
300 fEndTime = V->GetYaxis()->GetBinLowEdge(V->GetNbinsY());
304 H->GetYaxis()->SetTimeDisplay(1);
305 V->GetYaxis()->SetTimeDisplay(1);
307 const char* timeFormat =
"#splitline{%H:%M}{%d/%m/%Y}";
308 H->GetYaxis()->SetTimeFormat(timeFormat);
309 V->GetYaxis()->SetTimeFormat(timeFormat);
311 H->GetYaxis()->SetTimeOffset(0);
312 V->GetYaxis()->SetTimeOffset(0);
314 H->GetYaxis()->SetLabelSize(0.02);
315 V->GetYaxis()->SetLabelSize(0.02);
317 fStartTime = H->GetYaxis()->GetBinLowEdge(1);
318 fEndTime = V->GetYaxis()->GetBinLowEdge(V->GetNbinsY());
330 void NoiseMonitor::ProfPair::set(
const ProfPair& other){
static int getRunAtTime(double t)
NoiseMonitor(FilterStrategy *fs)
virtual const char * description() const =0
A filter strategy defines the sets of filters that are used and provides some introspection abilities...
size_t nOperations() const
void getProfilesFromFileTime(UInt_t realTime)
char polAsChar(AnitaPol::AnitaPol_t pol)
Returns the polarisation as a character string.
This class is intended to store all the necessary data about an ANITA event for filtering and analysi...
enum AnitaPol::EAnitaPol AnitaPol_t
Polarisation enumeration.
const FilterOperation * getOperation(size_t i) const