InterferometryCache.cxx
1 #include "InterferometryCache.h"
2 #include "CrossCorrelator.h"
3 #include "AnalysisReco.h"
4 
6  fInitialized = false;
7  fNumCombos = 0;
8  fNCoarseBinsPhi = 0;
10 }
11 
13  fInitialized = false;
14  fNumCombos = 0;
15  fNCoarseBinsPhi = 0;
16  fNCoarseBinsTheta = 0;
17  populateCache(cc, reco);
18  populateFineCache(cc, reco);
19 }
20 
21 void Acclaim::InterferometryCache::init(CrossCorrelator* cc, const AnalysisReco* reco, bool forceCacheRecalculation){
22  if(!fInitialized || forceCacheRecalculation){
23  populateCache(cc, reco);
24  populateFineCache(cc, reco);
25  }
26  fInitialized = true;
27 }
28 
30 
31  fUseOffAxisDelay = reco->GetUseOffAxisDelay();
32  // std::cout << "in cache fUseOffAxisDelay " << fUseOffAxisDelay << std::endl;
33  fNumCombos = cc->numCombos;
34 
35  const std::vector<Double_t> coarsePhiBinEdges = InterferometricMap::getCoarseBinEdgesPhi();
36  fNCoarseBinsPhi = coarsePhiBinEdges.size()-1;
37 
38  const std::vector<Double_t> coarseThetaBinEdges = InterferometricMap::getCoarseBinEdgesTheta();
39  fNCoarseBinsTheta = coarseThetaBinEdges.size()-1;
40 
41 
42  std::vector<Double_t> phiWaveLookup(fNCoarseBinsPhi);
43  for(Int_t phiIndex=0; phiIndex < fNCoarseBinsPhi; phiIndex++){
44  Double_t phiDeg = coarsePhiBinEdges.at(phiIndex);
45  Double_t phiWave = TMath::DegToRad()*phiDeg;
46  phiWaveLookup[phiIndex] = phiWave;
47  }
48 
49  std::vector<Double_t> thetaWaves(fNCoarseBinsTheta);
50 
51  for(Int_t thetaIndex=0; thetaIndex < fNCoarseBinsTheta; thetaIndex++){
52  Double_t thetaWaveDeg = coarseThetaBinEdges.at(thetaIndex);
53  Double_t thetaWave = thetaWaveDeg*TMath::DegToRad();
54  thetaWaves[thetaIndex] = thetaWave;
55  }
56 
57  int numDeltaTs = AnitaPol::kNotAPol*fNumCombos*fNCoarseBinsTheta*fNCoarseBinsPhi;
58  fDeltaTs.resize(numDeltaTs); // reserve memory and set the correct size so we use .at() in the loop
59 
60  for(Int_t polInd=0; polInd<AnitaPol::kNotAPol; polInd++){
62 
63  for(Int_t combo=0; combo<fNumCombos; combo++){
64  Int_t ant1 = cc->comboToAnt1s.at(combo);
65  Int_t ant2 = cc->comboToAnt2s.at(combo);
66 
67  for(Int_t phiBin = 0; phiBin < fNCoarseBinsPhi; phiBin++){
68  Double_t phiWave = phiWaveLookup[phiBin];
69 
70  for(Int_t thetaBin = 0; thetaBin < fNCoarseBinsTheta; thetaBin++){
71  Double_t thetaWave = thetaWaves[thetaBin];
72  fDeltaTs.at(coarseIndex(pol, combo, phiBin, thetaBin)) = reco->getDeltaTExpected(pol, ant1, ant2, phiWave, thetaWave);
73  }
74  }
75  }
76  }
77 }
78 
80 
81  std::vector<double> fineBinsTheta = InterferometricMap::getFineBinEdgesTheta();
82  std::vector<double> fineBinsPhi = InterferometricMap::getFineBinEdgesPhi();
83 
84  fNFineBinsTheta = fineBinsTheta.size() - 1;
85  fNFineBinsPhi = fineBinsPhi.size() - 1;
86 
87  // reserve cache and populate with 0s
88  fZoomedPhiWaveLookup.resize(fNFineBinsPhi);
89  for(unsigned phiIndex=0; phiIndex < fZoomedPhiWaveLookup.size(); phiIndex++){
90  Double_t phiDeg = fineBinsPhi.at(phiIndex);
91  // Double_t phiDeg = minPhiDegZoom + phiIndex*ZOOM_BIN_SIZE_PHI;
92  // zoomedPhiWaveLookup[phiIndex] = phiDeg*TMath::DegToRad();
93  fZoomedPhiWaveLookup.at(phiIndex) = phiDeg*TMath::DegToRad();
94  }
95 
96  fZoomedThetaWaves.resize(fNFineBinsTheta);
97  fZoomedTanThetaWaves.resize(fNFineBinsTheta);
98  fZoomedCosThetaWaves.resize(fNFineBinsTheta);
99  fDtFactors.resize(fNFineBinsTheta);
100 
101 
102  for(unsigned thetaIndex=0; thetaIndex < fZoomedThetaWaves.size(); thetaIndex++){
103  // Double_t thetaWaveDeg = minThetaDegZoom + thetaIndex*ZOOM_BIN_SIZE_THETA;
104  Double_t thetaWaveDeg = fineBinsTheta.at(thetaIndex);
105  Double_t thetaWave = -1*thetaWaveDeg*TMath::DegToRad();
106  fZoomedThetaWaves[thetaIndex] = thetaWave;
107  fZoomedTanThetaWaves[thetaIndex] = tan(thetaWave);
108  fZoomedCosThetaWaves[thetaIndex] = cos(thetaWave);
109  fDtFactors[thetaIndex] = fZoomedCosThetaWaves[thetaIndex]/(SPEED_OF_LIGHT_NS*cc->correlationDeltaT);
110  }
111 
112 
113  // std::cerr << "here" << std::endl;
114 
115  fPartBAsZoom.resize(AnitaPol::kNotAPol*fNumCombos*fNFineBinsTheta);
116  for(Int_t pol=0; pol<AnitaPol::kNotAPol; pol++){
117  for(Int_t combo=0; combo < NUM_COMBOS; combo++){
118  Int_t ant1 = cc->comboToAnt1s.at(combo);
119  Int_t ant2 = cc->comboToAnt2s.at(combo);
120  for(Int_t thetaIndex=0; thetaIndex < fNFineBinsTheta; thetaIndex++){
121  fPartBAsZoom[partBAsIndex(pol, combo, thetaIndex)] = fZoomedTanThetaWaves[thetaIndex]*(reco->fZArray[pol].at(ant2)-reco->fZArray[pol].at(ant1));
122  }
123  }
124  }
125 
126  fZoomedCosPartLookup.resize(AnitaPol::kNotAPol*NUM_SEAVEYS*fNFineBinsPhi);
127 
128  fOffAxisDelays.resize(AnitaPol::kNotAPol*fNumCombos*fNFineBinsPhi);
129  fOffAxisDelaysDivided.resize(AnitaPol::kNotAPol*fNumCombos*fNFineBinsPhi);
130  fPart21sZoom.resize(AnitaPol::kNotAPol*fNumCombos*fNFineBinsPhi);
131 
132 
133  for(Int_t pol=0; pol<AnitaPol::kNotAPol; pol++){
134  for(Int_t ant=0; ant<NUM_SEAVEYS; ant++){
135  for(Int_t phiIndex=0; phiIndex < fNFineBinsPhi; phiIndex++){
136  Double_t phiDeg = fineBinsPhi.at(phiIndex);
137  Double_t phiWave = phiDeg*TMath::DegToRad();
138  fZoomedCosPartLookup.at(zoomedCosPartIndex(pol, ant, phiIndex)) = reco->fRArray[pol].at(ant)*cos(phiWave-TMath::DegToRad()*reco->fPhiArrayDeg[pol].at(ant));
139  }
140  }
141 
142  for(Int_t combo=0; combo < NUM_COMBOS; combo++){
143  Int_t ant1 = cc->comboToAnt1s.at(combo);
144  Int_t ant2 = cc->comboToAnt2s.at(combo);
145 
146  for(Int_t phiIndex=0; phiIndex < fNFineBinsPhi; phiIndex++){
147  Double_t phiDeg = fineBinsPhi.at(phiIndex);
148  Double_t offAxisDelay = reco->relativeOffAxisDelay((AnitaPol::AnitaPol_t)pol, ant2, ant1, phiDeg);
149 
150  int p21 = part21sIndex(pol, combo, phiIndex);
151  fOffAxisDelays[p21] = offAxisDelay;
152  fOffAxisDelaysDivided[p21] = offAxisDelay/cc->correlationDeltaT;
153  fPart21sZoom[p21] = fZoomedCosPartLookup.at((zoomedCosPartIndex(pol, ant2, phiIndex))) - fZoomedCosPartLookup.at((zoomedCosPartIndex(pol, ant1, phiIndex)));
154  }
155  }
156  }
157 }
158 
159 
static const std::vector< Double_t > & getFineBinEdgesTheta()
int fNCoarseBinsPhi
The number of phi bins in the coarsely binned interferometric map.
std::vector< Double_t > fPhiArrayDeg[AnitaPol::kNotAPol]
Local copies of the antenna azimuth positions (in degrees) from AnitaGeomTool.
Definition: AnalysisReco.h:443
std::vector< Int_t > comboToAnt1s
Vector mapping combo index to ant1.
std::vector< Double_t > fZArray[AnitaPol::kNotAPol]
Local copies of the antenna z positions (metres) from AnitaGeomTool.
Definition: AnalysisReco.h:444
static const std::vector< Double_t > & getFineBinEdgesPhi()
Does the event reconstruction, and produces a summary of it.
Definition: AnalysisReco.h:30
static const std::vector< Double_t > & getCoarseBinEdgesTheta()
Double_t correlationDeltaT
nominalSamplingDeltaT/UPSAMPLE_FACTOR, deltaT of for interpolation.
Double_t relativeOffAxisDelay(AnitaPol::AnitaPol_t pol, Int_t ant1, Int_t ant2, Double_t phiDeg) const
Get the off axis delay between two antennas for a given phi angle.
std::vector< Int_t > comboToAnt2s
Vector mapping combo index to ant2.
Double_t getDeltaTExpected(AnitaPol::AnitaPol_t pol, Int_t ant1, Int_t ant2, Double_t phiWave, Double_t thetaWave) const
Get the expected delay between antenna pairs for a given direction.
Int_t numCombos
Number of possible antenna pairs, counted during initialization. Should equal NUM_COMBOS.
USeful in for loops.
void populateCache(CrossCorrelator *cc, const AnalysisReco *reco)
std::vector< Double_t > fRArray[AnitaPol::kNotAPol]
Local copies of the antenna radial positions (metres) from AnitaGeomTool.
Definition: AnalysisReco.h:442
void init(CrossCorrelator *cc, const AnalysisReco *reco, bool forceCacheRecalculation=false)
Initialize the cache, only needs to be done once.
int fNumCombos
The number of possible antenna pairs to be correlated.
void populateFineCache(CrossCorrelator *cc, const AnalysisReco *reco)
int fNCoarseBinsTheta
The number of theta bins in the coarsely binned interferometric map.
A class to take in FiteredAnitaEvents and cross-correlate nearby channels.
static const std::vector< Double_t > & getCoarseBinEdgesPhi()
bool fInitialized
Has the cache been initialized?
enum AnitaPol::EAnitaPol AnitaPol_t
Polarisation enumeration.
Int_t GetUseOffAxisDelay() const
Get the value of fUseOffAxisDelay.
Definition: AnalysisReco.h:536