tabulatedata.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <fstream>
3 #include <string>
4 #include <TCanvas.h>
5 #include <TH2F.h>
6 #include <TMath.h>
7 #include <TFile.h>
8 #include <TGraph.h>
9 #include <TROOT.h>
10 #include <TStyle.h>
11 #include <TColor.h>
12 #include <TTimeStamp.h>
13 #define AUGER_RADIO_ENABLED
14 #include "RecEventFile.h"
15 #include "RecEvent.h"
16 #include "RdEvent.h"
17 #include "DetectorGeometry.h"
18 #include "SDEvent.h"
19 #include "DetectorGeometry.h"
20 #include "SdRecStation.h"
23 #include "PolarHist.h"
24 
25 //Added
26 #include <TVector3.h>
27 #include <TProfile.h>
28 
29 #include <RdTrace.h>
30 
31 const int kGPS_UTC_Offset = 315957587; // To be updated
32 
33 using namespace std;
34 
35 //Nice Colours
37  const Int_t NRGBs = 5;
38  const Int_t NCont = 255;
39  Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
40  Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
41  Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
42  Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
43  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
44  gStyle->SetNumberContours(NCont);
45 }
46 
47 struct antenna {
48  int id;
49  float dist_axis;
50 };
51 
52 bool compDist (antenna i, antenna j) {
53  return (i.dist_axis<j.dist_axis);
54 };
55 
56 int main() {
58 
59  vector<string> v_filename;
60  ifstream fileList ("./dataADSTlist.txt");
61  char filename[10000] ;
62  while (fileList >> filename) {
63  v_filename.push_back(filename);
64  }
65 
66  const TVector3 vmag(-884.62,-19699.87,+14154.43);
67  RecEventFile *file = new RecEventFile(v_filename);
68  RecEvent* theevent= new RecEvent();
69  int nevents=file->GetNEvents();
70  cout << nevents << endl;
71  file->SetBuffers(&theevent);
72  DetectorGeometry *geo =new DetectorGeometry();
73  file->ReadDetectorGeometry(*geo);
74 
75  ofstream File_data("Amplitude_data.txt");
76 
77  float distance=0;
78  float distance_before=0;
79  int distance_stadtion_id=0;
80 
81  //Loop over events
82  while(file->ReadNextEvent()==RecEventFile::eSuccess) {
83  const RdEvent& theradio= theevent->GetRdEvent();
84  const RdRecShower& rshow=theradio.GetRdRecShower();
85 
86  if (!theradio.HasRdStations()) continue ;
87  const std::vector<RdRecStation>& vecRstat=theradio.GetRdStationVector();
88  const SDEvent& sdev=theevent->GetSDEvent();
89  const SdRecShower& sshow= sdev.GetSdRecShower();
90 
91  const TVector3& score=sshow.GetCoreSiteCS();
92  const TVector3& rcore=rshow.GetCoreSiteCS();
93  const TVector3& saxis=sshow.GetAxisSiteCS();
94 
95  double rtheta=TMath::RadToDeg()*rshow.GetZenith();
96  double rphi=TMath::RadToDeg()*rshow.GetAzimuth();
97  double stheta=TMath::RadToDeg()*sshow.GetZenith();
98  double sphi=TMath::RadToDeg()*sshow.GetAzimuth();
99  TVector3 raxis=rshow.GetAxisSiteCS();
100  float scal=saxis.Dot(raxis);
101  float snrm=saxis.Mag();
102 
103  scal=saxis.Dot(vmag);
104  float mnrm=vmag.Mag();
105 
106  //SD quality check
107  const int minRecLevel=3; // has reconstructed energy
108  const int minCandidateStations=4;
109  const int T4Trigger=2; // has T4 and SD triggered independently of FD
110  const int T5Trigger=3; //has T5 Posterior, which is the T5 HAS in this case
111 
112  const float minZenithSD=62;
113  const float maxZenithSD=80;
114 
115  if (sdev.GetRecLevel()<minRecLevel) continue;// alle events
116  if (sdev.GetNumberOfCandidates()<minCandidateStations) continue; //alle events
117  if (sdev.GetT4Trigger()<T4Trigger) continue;
118  if (sdev.GetT5Trigger()<T5Trigger) continue;
119  if (stheta>maxZenithSD) continue;
120  if (stheta<minZenithSD) continue;
121 
122  //Calculate closest station
123 
124  antenna arr[160] ;
125  for (int i=0; i<160; i++) {
126  arr[i].dist_axis=100000000;
127  arr[i].id=101+i;
128  }
129  for (int i=0; i<160; i++) {
130  if(theradio.HasRdStation(101+i)) {
131  arr[i].dist_axis=geo->GetRdStationAxisDistance(101+i,raxis,rcore);
132  }
133  }
134  sort(arr, arr + 160, compDist);
135 
136  int how_many_stations_participate=0;
137  for (int i=0; i<160; i++) {
138  if(arr[i].dist_axis < 10000000) {
139  how_many_stations_participate++;
140  }
141  }
142 
143  distance_stadtion_id=arr[0].id;
144  distance_before=arr[0].dist_axis;
145 
146  //Average Amplitude
147  float average_amp=0;
148  float max_amp=0;
149 
150  double minDist2 = -1;
151  unsigned int closestRdStationId = 0;
152 
153  int contained=-1000;
154 
155  int dutch_stations[46]= {102, 104, 105, 108, 109, 112, 134, 135, 136, 143, 144, 149, 158, 159, 160, 169, 170, 183, 184, 185, 188, 192, 193, 194, 200, 201, 202, 203, 210, 211, 212, 213, 222, 223, 224, 225, 226, 235, 236, 237, 244, 245, 246, 251, 252, 257};
156 
157  for (vector<RdRecStation>::const_iterator stiter=vecRstat.begin(); stiter!=vecRstat.end(); ++stiter) { //loop stations
158 
159  for(int i=0; i<46; i++) {
160  if(((stiter->GetId())-100)==dutch_stations[i]) {
161  continue;
162  }
163  }
164 
165  TVector3 rd_station_coordinate=geo->GetRdStationPosition(stiter->GetId());
166  double dist2 = (rd_station_coordinate.X()-score.X())*(rd_station_coordinate.X()-score.X()) + (rd_station_coordinate.Y()-score.Y())*(rd_station_coordinate.Y()-score.Y());
167 
168  if (closestRdStationId == 0 || sqrt(dist2) < minDist2) {
169  closestRdStationId = stiter->GetId();
170  minDist2 = sqrt(dist2);
171  }
172 
173  double distance_to_closest_rd_station=minDist2;
174 
175  if(distance_to_closest_rd_station<= 500.0) {
176  contained = 1;
177  } else {
178  contained = 0;
179  }
180  }
181 
182  for (vector<RdRecStation>::const_iterator stiter=vecRstat.begin(); stiter!=vecRstat.end(); ++stiter) { //loop stations
183 
184  if (stiter->IsRejected()) {
185  continue; // Do not draw stations which are rejected
186  }
187 
188  float axis_distance_to_sd=geo->GetStationAxisDistance(geo->GetRdStationPosition(stiter->GetId()), saxis , score);
189 
190  if(stiter->GetParameter(revt::eSignalToNoise)>10.0) {
191  File_data << theradio.GetRdRunNumber() << " "
192  << theradio.GetRdEventId() << " "
193  << stiter->GetId() << " "
194  << stiter->GetParameter(revt::ePeakAmplitudeMag)*1e6 << " "
195  << stheta << " " << TMath::Log10(sshow.GetEnergy()) << " "
196  << contained << " " << axis_distance_to_sd << endl;
197  }
198  }
199  }//loop over events
200 }
static const G4Colour green(0.0, 1.0, 0.0)
bool compDist(antenna i, antenna j)
Definition: tabulatedata.cc:52
void set_plot_style()
Definition: tabulatedata.cc:36
int main(int argc, char *argv[])
Definition: DBSync.cc:58
static const G4Colour red(1.0, 0.0, 0.0)
const string file
const int kGPS_UTC_Offset
Definition: tabulatedata.cc:31
float dist_axis
Definition: tabulatedata.cc:49
char * filename
Definition: dump1090.h:266
static const G4Colour blue(0.0, 0.0, 1.0)

, generated on Tue Sep 26 2023.