Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,404 changes: 1,223 additions & 1,181 deletions Detector.cc

Large diffs are not rendered by default.

150 changes: 85 additions & 65 deletions Detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,25 @@ class Parameters {
int number_of_antennas_string; //antennas per string
int number_of_surfaces_station; //surface antennas per station
int number_of_channels; // number of channels for each regular (non-TestBed) station

int number_of_strings_station_TB; //number of strings in the TestBed
int number_of_antennas_string_TB; //number of antennas in each string in the Testbed
int number_of_surfaces_station_TB; //number of surface stations for the TestBed
int number_of_channels_TB; // number of channels for the TestBed

int num_of_channels[2];

int bore_hole_antenna_layout; // bore hole antenna layout, 0 : VHVH, 1 : VHV, 2 : VHVV

int number_of_strings;
int number_of_antennas;

double core_x;
double core_y;

int DeployedStations;


// static const int freq_step = 60;
// static const int ang_step = 2664;
// static const double freq_width = 16.667; // this value could be changed when Nec2 condition changes!
Expand Down Expand Up @@ -116,7 +116,7 @@ class Surface_antenna : public Position {
};



//struct Antenna : public Position, public TObject {
//class Antenna : public Position, public TObject {
class Antenna : public Position {
Expand All @@ -131,13 +131,13 @@ class Antenna : public Position {
int manual_delay; // to fit the waveform to actual TestBed waveform, added manual delay time

int manual_delay_bin; // to fit the waveform to actual TestBed waveform, added manual delay bin

double GetG(Detector *D, double freq, double theta, double phi); // read gain value from Detector class, return 2-D interpolated value


//ClassDef(Antenna,1);
ClassDef(Antenna,3);

};


Expand Down Expand Up @@ -167,7 +167,7 @@ class ARA_station : public Position {
double DATA_BIN_SIZE;

int number_of_antennas; // total number of antennas for each stations

ClassDef(ARA_station,1);
};

Expand All @@ -192,11 +192,11 @@ class InstalledStation {


//class Detector : public TObject {

class IdealStation{

public:

int nSurfaces;
int nStrings;
vector < int > surfaceChannels;
Expand All @@ -208,18 +208,22 @@ class IdealStation{
vector < int > IDSurface;
vector < int > IDAntenna;
vector < int > IDString;

ClassDef(IdealStation, 1);

};

enum EAntennaType {
eVPol, // (bottom) Vpol
eVPolTop, // top Vpol
eHPol, // Hpol
eTx // transmitter
eTx, // transmitter
eTxCross, // transmitter
eVPolCross, // Cross-pol VPol
eVPolTopCross, // Cross-pol VPol Top
eHPolCross // Cross-pol HPol
};

class Detector {
private:
static const int freq_step_max = 60;
Expand All @@ -234,29 +238,41 @@ class Detector {
vector<vector<double> > Hgain;
vector<vector<double> > Hphase;
vector<double> Freq;

vector<double> FreqCross;

// Cross-pol vectors
vector<vector<double> > VgainCross;
vector<vector<double> > VphaseCross;
vector<vector<double> > VgainTopCross;
vector<vector<double> > VphaseTopCross;
vector<vector<double> > HgainCross;
vector<vector<double> > HphaseCross;

//Define impedance and gain for receiving antenna
vector<double> impFreq;
double RealImpedanceV[freq_step_max];
double ImagImpedanceV[freq_step_max];
double ImagImpedanceV[freq_step_max];
double RealImpedanceVTop[freq_step_max];
double ImagImpedanceVTop[freq_step_max];
double ImagImpedanceVTop[freq_step_max];
double RealImpedanceH[freq_step_max];
double ImagImpedanceH[freq_step_max];
double ImagImpedanceH[freq_step_max];

//Define impedance and gain for transmitting antenna
double RealImpedanceTx[freq_step_max];
double ImagImpedanceTx[freq_step_max];
int Tx_freq_init;
int Tx_freq_width;
double Tx_freq_init;
double Tx_freq_width;
vector<double> TxFreq;
vector<double> TxFreqCross;
vector<vector<double> > Txgain;
vector<vector<double> > Txphase;
vector<vector<double> > TxgainCross;
vector<vector<double> > TxphaseCross;
void ReadImpedance(string filename, double (*TempRealImpedance)[freq_step_max], double (*TempImagImpedance)[freq_step_max]);
void ReadAllAntennaImpedance(Settings *settings1);




void ReadFilter(string filename, Settings *settings1);
double FilterGain[freq_step_max]; // Filter gain (dB) for Detector freq bin array
Expand Down Expand Up @@ -284,24 +300,24 @@ class Detector {
void CalculateElectChain(Settings *settings1); // calculate data-driven noise model
int gain_ch; // Number of channels used for gain model array population in ReadElectChain()
std::vector< std::vector <double> > ElectGain; //Elect chain gain (unitless) for Detector freq bin array
std::vector< std::vector <double> > ElectPhase; // Elect chain phase (rad) for Detector freq bin array
std::vector< std::vector <double> > ElectPhase; // Elect chain phase (rad) for Detector freq bin array

void ReadTrig_Delays_Masking(string filename, Settings *settings1);
std::vector<double> triggerDelay; //trigger delay for a given channel (seconds?)
std::vector<int> triggerMask; //trigger masking decision value (either 0 or 1)
std::vector<int> activeDelay; //decision value to activate delay (either 0 or 1)

void ReadGainOffset_TestBed(string filename, Settings *settings1);
vector <double> GainOffset_TB_ch; // constant gain offset for the TestBed chs
vector <double> GainOffset_TB_ch; // constant gain offset for the TestBed chs

void ReadThresOffset_TestBed(string filename, Settings *settings1);
vector <double> ThresOffset_TB_ch; // constant gain offset for the TestBed chs
vector <double> ThresOffset_TB_ch; // constant gain offset for the TestBed chs

void ReadThres_TestBed(string filename, Settings *settings1);
vector <double> Thres_TB_ch; // Threshold values for the TestBed chs
vector <double> Thres_TB_ch; // Threshold values for the TestBed chs

void ReadTemp_TestBed(string filename, Settings *settings1);
//vector <double> Temp_TB_ch; // constant gain offset for the TestBed chs
//vector <double> Temp_TB_ch; // constant gain offset for the TestBed chs

void ReadRFCM_TestBed(string filename, Settings *settings1);
double RFCM_TB_ch[16][freq_step_max]; // Filter gain (dB) for Detector freq bin array
Expand All @@ -323,7 +339,7 @@ class Detector {
rayleighFits_DeepStation_values holds the Rayleigh sigma.
The first dimension is for the number of channels (so this is "number of channels" long).
The second dimension is for the number of frequency bins (so this is "number of frequency bins" long).
(which goes first and which goes second is arbitrary;
(which goes first and which goes second is arbitrary;
the TestBed version does it in this order, so replicate here)

rayleighFits_DeepStation_frequencies holds the Rayleigh frequencies.
Expand All @@ -336,7 +352,7 @@ class Detector {
void ReadRayleighFit_DeepStation(string filename, Settings *settings1);


void ReadNoiseFigure(string filename, Settings *settings1);
void ReadNoiseFigure(string filename, Settings *settings1);
double NoiseFig_ch[16][freq_step_max];
vector<double> NoiseFig_freq;
vector < vector < double > > NoiseFig_databin_ch;
Expand All @@ -347,7 +363,11 @@ class Detector {
vector <double> transVTop_databin;
vector <double> transH_databin;


// Cross-pol data bins
vector <double> transVCross_databin;
vector <double> transVTopCross_databin;
vector <double> transHCross_databin;

void ReadAmplifierNoiseFigure(Settings *settings1);
vector< vector<double> > amplifierNoiseFig_ch;

Expand Down Expand Up @@ -383,17 +403,17 @@ class Detector {
double GetGain(double freq, double theta, double phi, int ant_m, int ant_o); //read antenna gain at certain angle, certain type, and certain orientation
double GetGain(double freq, double theta, double phi, int ant_m); //read antenna gain at certain angle, certain type. (orientation : default)

double GetGain_1D_OutZero(double freq, double theta, double phi, int ant_m, int string_number=0, int ant_number=0, bool useInTransmitterMode=false); //read antenna gain at certain angle, certain type. (orientation : default) and use 1-D interpolation to get gain, if freq bigger than freq range, return 0 gain
double GetGain_1D_OutZero(double freq, double theta, double phi, int ant_m, int string_number=0, int ant_number=0, bool useInTransmitterMode=false, bool useCrossPol=false); //read antenna gain at certain angle, certain type. (orientation : default) and use 1-D interpolation to get gain, if freq bigger than freq range, return 0 gain

//Creating function to interpolate antenna impedance to frequency binning.
double GetImpedance(double freq, int ant_m=0, int ant_number=0, bool useInTransmitterMode=false);

int GetTrigOffset( int ch, Settings *settings1 );
int GetTrigMasking( int ch );

double GetAntPhase(double freq, double theta, double phi, int ant_m); // return antenna phase with 2-D interpolation

double GetAntPhase_1D(double freq, double theta, double phi, int ant_m, bool useInTransmitterMode=false); // return antenna phase with 1-D interpolation
double GetAntPhase_1D(double freq, double theta, double phi, int ant_m, bool useInTransmitterMode=false, bool useCrossPol=false); // return antenna phase with 1-D interpolation


double GetFilterGain(int bin) { return FilterGain[bin]; } // same bin with Vgain, Hgain
Expand All @@ -412,7 +432,7 @@ class Detector {
double GetFOAMGain_NFOUR(int bin) { return FOAMGain_NFOUR[bin]; } // bin for FFT
double GetFOAMGain_1D_OutZero(double freq);


double GetElectGain(int bin, int gain_ch_no) { return ElectGain[gain_ch_no][bin]; } // same bin with Vgain, Hgain
double GetElectGain_1D_OutZero(double freq, int gain_ch_no);
double GetElectPhase_1D(double freq, int gain_ch_no);
Expand All @@ -428,23 +448,23 @@ class Detector {
std::vector< std::vector< double> > GetRayleighFitVector_databin(int station, Settings *settings);

double GetNoiseFig_databin(int ch, int bin) { return NoiseFig_databin_ch[ch%16][bin]; } // bin for FFT
double GetNoiseFig_OutZero(int ch, double freq);
double GetNoiseFig_OutZero(int ch, double freq);

double GetTransm_databin(int ch, int bin) { if(ch%16<4){return transVTop_databin[bin];}
else if(ch%16<8){return transV_databin[bin];}
else if(ch%16<8){return transV_databin[bin];}
else{return transH_databin[bin];} } // bin for FFT
double GetTransm_OutZero(int ch, double freq);
void ReadNoiseFig_New(Settings *settings1); // get noise Figure array with new DATA_BIN_SIZE


double GetGainOffset( int StationID, int ch, Settings *settings1 ); // returns voltage factor for specific channel gain off set

double GetThresOffset( int StationID, int ch, Settings *settings1 ); // returns voltage factor for specific channel gain off set

double GetThres( int StationID, int ch, Settings *settings1 ); // returns voltage factor threshold for specific channel
double GetThres( int StationID, int ch, Settings *settings1 ); // returns voltage factor threshold for specific channel

double GetTemp( int StationID, int ch, Settings *settings1 ); // returns voltage factor for specific channel gain off set
vector <double> Temp_TB_ch; // constant gain offset for the TestBed chs
vector <double> Temp_TB_ch; // constant gain offset for the TestBed chs


double Getfreq_init() {return freq_init;}
Expand All @@ -458,7 +478,7 @@ class Detector {
vector <double> fdiode_real_databin; // NFOUR array of f domain tunnel diode response (FFT of diode_real). also same with icemc -> anita -> fdiode_real but only full bandwidth array 4
vector <double> fdiode_real; // NFOUR/2 array of f domain tunnel diode response (FFT of diode_real). also same with icemc -> anita -> fdiode_real but only full bandwidth array 4
vector <double> fdiode_real_double; // NFOUR array of f domain tunnel diode response (FFT of diode_real). also same with icemc -> anita -> fdiode_real but only full bandwidth array 4

double TIMESTEP; // will copy TIMESTEP from Settings
int NFOUR; // also will copy NFOUR from Settings

Expand All @@ -480,23 +500,23 @@ class Detector {
// for a best performance, we can just set a new reasonable DATA_BIN_SIZE and make new values for those
void get_NewDiodeModel(Settings *settings1);

void ReadFilter_New(Settings *settings1); // get filter vector array with new DATA_BIN_SIZE
void ReadFilter_New(Settings *settings1); // get filter vector array with new DATA_BIN_SIZE

void ReadPreamp_New(Settings *settings1); // get filter vector array with new DATA_BIN_SIZE
void ReadPreamp_New(Settings *settings1); // get filter vector array with new DATA_BIN_SIZE

void ReadFOAM_New(Settings *settings1); // get filter vector array with new DATA_BIN_SIZE
void ReadFOAM_New(Settings *settings1); // get filter vector array with new DATA_BIN_SIZE

void ReadRFCM_New(Settings *settings1); // get filter vector array with new DATA_BIN_SIZE
void ReadRFCM_New(Settings *settings1); // get filter vector array with new DATA_BIN_SIZE

void ReadRayleigh_New(Settings *settings1); // get Rayleigh fit array with new DATA_BIN_SIZE



// vector < vector < vector < int > > > ChannelfromStringAntenna;
// void SetChannelStringAntennaMap();
int GetChannelfromStringAntenna (int stationNum, int stringnum, int antennanum );
void GetSSAfromChannel ( int stationNum, int channelNum, int * antennaNum, int * stringNum );

#ifdef ARA_UTIL_EXISTS
void UseAntennaInfo (int stationNum, Settings *settings1);
void ImportStationInfo (Settings *settings1, int StationIndex, int StationID);
Expand All @@ -505,8 +525,8 @@ class Detector {
// more general used function
void GetSSAfromChannel ( int stationID, int channelNum, int * antennaNum, int * stringNum, Settings *settings1);
int GetChannelfromStringAntenna ( int stationID, int stringnum, int antennanum, Settings *settings1);


/*
struct InstalledStation {
int nSurfaces;
Expand All @@ -520,13 +540,13 @@ class Detector {

};
*/

vector < InstalledStation > InstalledStations;

// class IdealStation{
//
//
// public:
//
//
// int nSurfaces;
// int nStrings;
// vector < int > surfaceChannels;
Expand All @@ -538,11 +558,11 @@ class Detector {
// vector < int > IDSurface;
// vector < int > IDAntenna;
// vector < int > IDString;
//
//
// };

vector < IdealStation > IdealStations;


void SetupInstalledStations(Settings *settings1);
void PrepareVectorsInstalled();
Expand All @@ -552,19 +572,19 @@ class Detector {

int getAntennafromArbAntID( int stationID, int ant_ID);
int getStringfromArbAntID( int stationID, int ant_ID);


vector <double> CalPulserWF_ns;
vector <double> CalPulserWF_V;


~Detector(); //destructor

ClassDef(Detector,2);




};


Expand Down
Loading
Loading