AnitaTemplates.h
1 #ifndef ANITA_TEMPLATES
2 #define ANITA_TEMPLATES
3 
4 #include "TObject.h"
5 #include "AnitaEventSummary.h"
6 #include "FFTtools.h"
7 #include "TFile.h"
8 #include "AnalysisWaveform.h"
9 #include "SystemResponse.h"
10 #include "AnitaVersion.h"
11 
12 
13 /* * * * * * * * *
14 
15 
16  Be careful using templates, we might not know what we're looking for
17 
18 
19  Anyway this is where all the template stuff will live
20 
21 
22  * * * * * * * * * */
23 
24 
34 //they rely on each other so you gotta define it here
36 
37 class AnitaTemplateMachine : public TObject {
38 
39  public:
41  AnitaTemplateMachine(const int inLength=2048);
42 
45 
47  void zeroInternals();
48 
50  const int length;
51  const double dT;// = 0.1; //in ns
52 
54  //impulse response
56  TGraph *theImpTemplate;
57  //ANITA3 averaged wais pulses
58  FFTWComplex *theWaisTemplateFFT;
59  TGraph *theWaisTemplate;
60  //ZHAires simulated CRs at various angles
61  static const int numCRTemplates = 10; //this is the place it is defined for everything
62  FFTWComplex *theCRTemplateFFTs[numCRTemplates];
63  TGraph *theCRTemplates[numCRTemplates];
64 
65  //deconvolved versions for all those
66  //impulse response
67  FFTWComplex *theImpTemplateFFT_deconv;
68  TGraph *theImpTemplate_deconv;
69  //ANITA3 averaged wais pulses
70  FFTWComplex *theWaisTemplateFFT_deconv;
71  TGraph *theWaisTemplate_deconv;
72  //ZHAires simulated CRs at various angles
73  FFTWComplex *theCRTemplateFFTs_deconv[numCRTemplates];
74  TGraph *theCRTemplates_deconv[numCRTemplates];
75 
76 
78  void loadTemplates( unsigned int evTime = 0, int version = AnitaVersion::get());
80 
81 
83  //Check to see if the templates are loaded in bad english
84  bool isTmpltsLoaded() { return kTmpltsLoaded; };
85  //Check to see if you filled the deconvolved templates too
86  bool isTmpltsDeconv() { return kTmpltsDeconv; };
87 
89  void doTemplateAnalysis(const AnalysisWaveform *waveform, int poli, int dir, AnitaTemplateSummary *summary, bool do_impulse = true, bool do_wais = true, bool do_cr = true);
90  void doDeconvolvedTemplateAnalysis(const AnalysisWaveform *waveform, const AnitaResponse::DeconvolutionMethod *deconv,
91  int poli, int dir, AnitaTemplateSummary *summary,bool do_impulse = true, bool do_wais = true, bool do_cr = true );
92 
93 
95  void writeTemplatesToFile(TFile *outFile);
96 
97  void setUseAverageCRTemplate(bool opt) { fUseAverageCRTemplate = opt; }
98  void setDoWindow(bool opt) { fDoWindow = opt; }
99  std::string getNotchStr() { return fNotchStr ;}
100 
101  private:
102  /* flags to see what you still might need to do */
103  bool kTmpltsLoaded;
104  bool kTmpltsDeconv;
105  bool fUseAverageCRTemplate;
106  bool fDoWindow;
107 
108  std::string fNotchStr;
109  std::vector<int> payloadTimes;
110  std::vector<std::string> notchConfigs;
111 
112  void fillNotchConfigs();
113 
114  /* hidden functions for filling the templates one at a time */
115  void getImpulseResponseTemplate(int version);
116  void getWaisTemplate(int version);
117  void getCRTemplates(int version);
118 
119 
120  ClassDefNV(AnitaTemplateMachine, 1);
121 
122 };
123 
124 
134 {
135  public:
136 
139 
141  virtual ~AnitaTemplateSummary();
142 
144  static const Int_t maxDirectionsPerPol = AnitaEventSummary::maxDirectionsPerPol;
145 
146  /* Number of points on the cone */
147  static const int numCRTemplates = AnitaTemplateMachine::numCRTemplates;
148 
149  /*The template correlatin values for a single coherent waveform comparison*/
151  {
152  public:
153  SingleTemplateResult() {; }
154  //impulse response
155  Double_t impulse; //peak
156  Double_t impulse_loc; //location
157  bool impulse_pol; //max(1) or min(0)
158 
159  //one for the WAIS template too
160  Double_t wais;
161  Double_t wais_loc;
162  bool wais_pol;
163 
164  //and for the bigger multi-coherence-angle one
165  Double_t cRay[numCRTemplates];
166  Double_t cRay_loc[numCRTemplates];
167  bool cRay_pol[numCRTemplates];
168 
169 
170  ClassDefNV(SingleTemplateResult,3);
171  };
172 
173 
174  SingleTemplateResult coherent[NUM_POLS][maxDirectionsPerPol];
175 
176  SingleTemplateResult deconvolved[NUM_POLS][maxDirectionsPerPol];
177 
178 
179  void zeroInternals();
180 
181  private:
182  ClassDefNV(AnitaTemplateSummary, 3);
183 };
184 
185 
186 
187 
188 //-----------------
189 //random utilities
190 // vvvvvvvvvvvv
191 
192 
199 namespace FFTtools{
200  TGraph *normalizeWaveform(TGraph* inGraph);
201  double *getCorrelationFromFFT(int length,const FFTWComplex *theFFT1, const FFTWComplex *theFFT2);
202 }
203 
204 
205 
206 
207 
208 
209 
216 namespace WindowingTools {
217 
218  TGraph *windowWave(TGraph*, int&, const int, const int, const int, const int);
219 
220 
221  TGraph *windowCut(TGraph *inGraph,int length);
222 
223  TGraph *windowDispersed(TGraph *inGraph, int &peakHilbertLoc);
224  TGraph *windowDispersed(TGraph *inGraph);
225 
226  TGraph *windowEField(TGraph *inGraph, int &peakHilbertLoc);
227  TGraph *windowEField(TGraph *inGraph);
228 
229 
230  TGraph *windowWave(TGraph *inGraph, int &peakHilbertLoc,
231  const int upRampLoc = 50, const int downRampLoc = 600,
232  const int upRampLen = 100, const int downRampLen = 400);
233 
234 }
235 
236 
237 
238 
239 
240 
241 #endif
FFTWComplex * theImpTemplateFFT
virtual ~AnitaTemplateSummary()
static const Int_t maxDirectionsPerPol
AnitaTemplateMachine(const int inLength=2048)
Default Constructor.
void loadTemplates(unsigned int evTime=0, int version=AnitaVersion::get())
void deconvolveTemplates(AnitaResponse::DeconvolutionMethod *deconv)
This is a wrapper class for a complex number.
Definition: FFTWComplex.h:12
TGraph * windowCut(TGraph *inGraph, int length)
TGraph * normalizeWaveform(TGraph *inGraph)
void doTemplateAnalysis(const AnalysisWaveform *waveform, int poli, int dir, AnitaTemplateSummary *summary, bool do_impulse=true, bool do_wais=true, bool do_cr=true)
void writeTemplatesToFile(TFile *outFile)
This class is intended to be the main storage vessel for ANITA waveforms. It is similar in principle ...
AnitaTemplateSummary()
Default Constructor.