tabulatesims.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() {
57 
59 
60  vector<string> v_filename;
61  ifstream filelist("./simADSTlist.txt");
62  char filename[1000];
63  while(filelist >> filename){
64  v_filename.push_back(filename);
65  }
66 
67  const TVector3 vmag(-884.62,-19699.87,+14154.43);
68  RecEventFile *file = new RecEventFile(v_filename);
69  RecEvent* theevent= new RecEvent();
70  int nevents=file->GetNEvents();
71  cout << nevents << endl;
72  file->SetBuffers(&theevent);
73  DetectorGeometry *geo =new DetectorGeometry();
74  file->ReadDetectorGeometry(*geo);
75 
76  ofstream File_data("Amplitude_sim.txt");
77 
78  float distance=0;
79  float distance_before=0;
80  int distance_stadtion_id=0;
81 
82  //Loop over events
83  while(file->ReadNextEvent()==RecEventFile::eSuccess) {
84  const RdEvent& theradio= theevent->GetRdEvent();
85  const RdRecShower& rshow=theradio.GetRdRecShower();
86 
87  if (!theradio.HasRdStations()) continue ;
88  const std::vector<RdRecStation>& vecRstat=theradio.GetRdStationVector();
89  const SDEvent& sdev=theevent->GetSDEvent();
90 
91  const SdRecShower& sshow= sdev.GetSdRecShower();
92  const TVector3& score=sshow.GetCoreSiteCS();
93  const TVector3& rcore=rshow.GetCoreSiteCS();
94  const TVector3& saxis=sshow.GetAxisSiteCS();
95 
96  double rtheta=TMath::RadToDeg()*rshow.GetZenith();
97  double rphi=TMath::RadToDeg()*rshow.GetAzimuth();
98  double stheta=TMath::RadToDeg()*sshow.GetZenith();
99  double sphi=TMath::RadToDeg()*sshow.GetAzimuth();
100  TVector3 raxis=rshow.GetAxisSiteCS();
101  float scal=saxis.Dot(raxis);
102  float snrm=saxis.Mag();
103 
104  scal=saxis.Dot(vmag);
105  float mnrm=vmag.Mag();
106 
107  //Calculate closest station
108 
109  antenna arr[160] ;
110  for (int i=0; i<160; i++) {
111  arr[i].dist_axis=100000000;
112  arr[i].id=101+i;
113  }
114  for (int i=0; i<160; i++) {
115  if(theradio.HasRdStation(101+i)) {
116  arr[i].dist_axis=geo->GetRdStationAxisDistance(101+i,raxis,rcore);
117  }
118  }
119  sort(arr, arr + 160, compDist);
120 
121  int how_many_stations_participate=0;
122  for (int i=0; i<160; i++) {
123  if(arr[i].dist_axis < 10000000) {
124  how_many_stations_participate++;
125  }
126  }
127 
128  int stations_with_signal=0;
129  distance_stadtion_id=arr[0].id;
130  distance_before=arr[0].dist_axis;
131 
132  //Average Amplitude
133  float average_amp=0;
134  float max_amp=0;
135 
136  double minDist2 = -1;
137  unsigned int closestRdStationId = 0;
138 
139  int contained=-1000;
140 
141  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};
142 
143  for (vector<RdRecStation>::const_iterator stiter=vecRstat.begin(); stiter!=vecRstat.end(); ++stiter) { //loop stations
144 
145  for(int i=0; i<46; i++) {
146  if(((stiter->GetId())-100)==dutch_stations[i]) {
147  continue;
148  }
149  }
150 
151  TVector3 rd_station_coordinate=geo->GetRdStationPosition(stiter->GetId());
152  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());
153 
154  if (closestRdStationId == 0 || sqrt(dist2) < minDist2) {
155  closestRdStationId = stiter->GetId();
156  minDist2 = sqrt(dist2);
157  }
158 
159  double distance_to_closest_rd_station=minDist2;
160 
161  if(distance_to_closest_rd_station<= 500.0) {
162  contained = 1;
163  } else {
164  contained = 0;
165  }
166 
167  }
168 
169  for (vector<RdRecStation>::const_iterator stiter=vecRstat.begin(); stiter!=vecRstat.end(); ++stiter) { //loop stations
170 
171  if (stiter->IsRejected()) {
172  continue; // Do not draw stations which are rejected
173  }
174 
175  const Shower& mcev=theevent->GetGenShower();
176  const TVector3& mccore=theevent->GetGenShower().GetCoreSiteCS();
177  const TVector3& mcaxis=theevent->GetGenShower().GetAxisSiteCS();
178 
179  float axis_distance_to_mc=geo->GetStationAxisDistance(geo->GetRdStationPosition(stiter->GetId()), mcaxis , mccore);
180 
181  if(stiter->GetParameter(revt::eSignalToNoise)>10.0) {
182  File_data << theradio.GetRdRunNumber() << " "
183  << theradio.GetRdEventId() << " "
184  << stiter->GetId() << " "
185  << stiter->GetParameter(revt::ePeakAmplitudeMag)*1e6 << " "
186  << rtheta << " "
187  << TMath::Log10(theevent->GetGenShower().GetEnergy()) << " "
188  << contained << " " << axis_distance_to_mc << endl;
189  }
190  }
191  }//loop over events
192 }
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.