34 |
#include "TStyle.h" |
#include "TStyle.h" |
35 |
#include "TPaletteAxis.h" |
#include "TPaletteAxis.h" |
36 |
#include "TROOT.h" |
#include "TROOT.h" |
37 |
|
#include <sys/stat.h> |
38 |
|
#include <fstream> |
39 |
|
|
40 |
#define TRUE 1 |
#define TRUE 1 |
41 |
#define FALSE 0 |
#define FALSE 0 |
45 |
* @param outDirectory |
* @param outDirectory |
46 |
* @param xslPath |
* @param xslPath |
47 |
*/ |
*/ |
48 |
|
using namespace std; |
49 |
|
|
50 |
void InitStyle() { |
void InitStyle() { |
51 |
gROOT->SetStyle("Plain"); |
gROOT->SetStyle("Plain"); |
105 |
|
|
106 |
} |
} |
107 |
|
|
108 |
void Rate(TString base, TString outDirectory = "", TString format = "jpg"){ |
void Rate(TString base, TString outDirectory = "", TString format = "jpg", TString mapFile = "", TString tleFile = ""){ |
109 |
TTree *tr = 0; |
TTree *tr = 0; |
110 |
pamela::McmdEvent *mcmdev = 0; |
pamela::McmdEvent *mcmdev = 0; |
111 |
pamela::McmdRecord *mcmdrc = 0; |
pamela::McmdRecord *mcmdrc = 0; |
119 |
double absTime; |
double absTime; |
120 |
UInt_t i = 0; |
UInt_t i = 0; |
121 |
UInt_t j = 0; |
UInt_t j = 0; |
122 |
|
struct stat buf; |
123 |
|
|
124 |
|
i = stat (mapFile.Data(), &buf ); |
125 |
|
// If the file does not exists |
126 |
|
if (i != 0){ |
127 |
|
printf("The %s file does not exists.", mapFile.Data()); |
128 |
|
exit(0); |
129 |
|
} |
130 |
|
|
131 |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
132 |
filename = ((TObjString*)filename.Tokenize('.')->First())->GetString(); |
filename = ((TObjString*)filename.Tokenize('.')->First())->GetString(); |
133 |
// Test SGP4 |
// Test SGP4 |
134 |
string str1 = "SGP4 Test"; |
string str1 = "SGP4 Test"; |
135 |
string str2 = "1 25544U 98067A 06117.32388940 .00009459 00000-0 64427-4 0 8131"; |
string str2 = "1 25544U 98067A 06117.32388940 .00009459 00000-0 64427-4 0 8131"; |
136 |
string str3 = "2 25544 51.6388 89.2928 0009043 155.3293 354.6512 15.75673697425143"; |
string str3 = "2 25544 51.6388 89.2928 0009043 155.3293 354.6512 15.75673697425143"; |
137 |
|
if (tleFile != ""){ |
138 |
|
fstream fileTle(tleFile.Data(),ios::in); |
139 |
|
if (fileTle.is_open()) { |
140 |
|
getline (fileTle,str1); |
141 |
|
getline (fileTle,str2); |
142 |
|
getline (fileTle,str3); |
143 |
|
} |
144 |
|
fileTle.close(); |
145 |
|
} |
146 |
|
|
147 |
cTle tle1(str1, str2, str3); |
cTle tle1(str1, str2, str3); |
148 |
cOrbit orbit(tle1); |
cOrbit orbit(tle1); |
165 |
nevents = tr->GetEntries(); |
nevents = tr->GetEntries(); |
166 |
|
|
167 |
bool timeFound = FALSE; |
bool timeFound = FALSE; |
168 |
while ((i < nevents) | !timeFound){ |
while (i < nevents) { |
169 |
tr->GetEntry(i); |
tr->GetEntry(i); |
170 |
recEntries = mcmdev->Records->GetEntries(); |
recEntries = mcmdev->Records->GetEntries(); |
171 |
while ((j < recEntries) | !timeFound){ |
while (j < recEntries){ |
172 |
mcmdrc = (pamela::McmdRecord*)mcmdev->Records->At(j); |
mcmdrc = (pamela::McmdRecord*)mcmdev->Records->At(j); |
173 |
if (mcmdrc->ID1 == 0xE0){ |
if (not (mcmdrc == NULL) && mcmdrc->ID1 == 0xE0){ |
174 |
mcmddata = mcmdrc->McmdData; |
mcmddata = mcmdrc->McmdData; |
175 |
timesync = (((ULong64_t)mcmddata->At(0)<<24)&0xFF000000) + |
timesync = (((ULong64_t)mcmddata->At(0)<<24)&0xFF000000) + |
176 |
(((ULong64_t)mcmddata->At(1)<<16)&0x00FF0000) + |
(((ULong64_t)mcmddata->At(1)<<16)&0x00FF0000) + |
184 |
i++; |
i++; |
185 |
} |
} |
186 |
|
|
187 |
|
if (!timeFound) { |
188 |
|
printf("No timesync info have been found in the file %s", base.Data()); |
189 |
|
exit(0); |
190 |
|
} |
191 |
tr = (TTree*)rootFile->Get("Physics"); |
tr = (TTree*)rootFile->Get("Physics"); |
192 |
TBranch *headBr = tr->GetBranch("Header"); |
TBranch *headBr = tr->GetBranch("Header"); |
193 |
tr->SetBranchAddress("Header", &eh); |
tr->SetBranchAddress("Header", &eh); |
214 |
TLine *tli=NULL; |
TLine *tli=NULL; |
215 |
double step=0; |
double step=0; |
216 |
|
|
217 |
TImage *tImage=TImage::Open("Data/terra4.png"); |
|
218 |
|
TImage *tImage=TImage::Open(mapFile); |
219 |
int width=(int)(tImage->GetWidth()*0.80); |
int width=(int)(tImage->GetWidth()*0.80); |
220 |
int height=(int)(tImage->GetHeight()*0.80); |
int height=(int)(tImage->GetHeight()*0.80); |
221 |
InitStyle(); |
InitStyle(); |
240 |
forpal->SetAxisColor(kBlack); //Delete the stat box |
forpal->SetAxisColor(kBlack); //Delete the stat box |
241 |
forpal->SetStats(0); //Delete the stat box |
forpal->SetStats(0); //Delete the stat box |
242 |
forpal->SetMinimum(0.1); |
forpal->SetMinimum(0.1); |
243 |
forpal->SetMaximum(200); |
forpal->SetMaximum(15); |
244 |
forpal->SetBinContent(5,1); // just to initialize the histo |
forpal->SetBinContent(5,1); // just to initialize the histo |
245 |
forpal->SetContour(50); |
forpal->SetContour(50); |
246 |
TPaletteAxis *tpp=(TPaletteAxis*)((forpal->GetListOfFunctions())->FindObject("palette")); |
TPaletteAxis *tpp=(TPaletteAxis*)((forpal->GetListOfFunctions())->FindObject("palette")); |
292 |
} |
} |
293 |
|
|
294 |
int main(int argc, char* argv[]){ |
int main(int argc, char* argv[]){ |
295 |
TString outDir = "./"; |
TString outDir = "./"; |
296 |
TString format = "jpg"; |
TString mapFile = ""; |
297 |
|
TString tleFile = ""; |
298 |
|
TString format = "jpg"; |
299 |
|
|
300 |
if (argc < 2){ |
if (argc < 2){ |
301 |
printf("You have to insert at least the file to analyze \n"); |
printf("You have to insert at least the file to analyze and the mapFile \n"); |
302 |
printf("Try '--help' for more information. \n"); |
printf("Try '--help' for more information. \n"); |
303 |
exit(1); |
exit(1); |
304 |
} |
} |
305 |
|
|
306 |
if (!strcmp(argv[1], "--help")){ |
if (!strcmp(argv[1], "--help")){ |
307 |
printf( "Usage: LogToXML FILE [OPTION] \n"); |
printf( "Usage: OrbitRate FILE -map mapFile [OPTION] \n"); |
308 |
|
printf( "mapFile have to be a mercator map image [gif|jpg|png] \n"); |
309 |
printf( "\t --help Print this help and exit \n"); |
printf( "\t --help Print this help and exit \n"); |
310 |
|
printf( "\t -tleFile[path] Path where to find the tle infos [default dummyOrbit] \n"); |
311 |
|
printf( "\t\tThe tle file have to satisfy a 3-line structure like (this is the included dummyOrbit)\n "); |
312 |
|
printf( "\t\t\tGP4 Test\n"); |
313 |
|
printf( "\t\t\t1 25544U 98067A 06117.32388940 .00009459 00000-0 64427-4 0 8131\n"); |
314 |
|
printf( "\t\t\t2 25544 51.6388 89.2928 0009043 155.3293 354.6512 15.75673697425143\n"); |
315 |
printf( "\t -outDir[path] Path where to put the output [default ~/tmp] \n"); |
printf( "\t -outDir[path] Path where to put the output [default ~/tmp] \n"); |
316 |
printf( "\t -format[jpg|gif|ps] Format for output files [default 'jpg'] \n"); |
printf( "\t -format[jpg|gif|ps] Format for output files [default 'jpg'] \n"); |
317 |
exit(1); |
exit(1); |
329 |
} |
} |
330 |
} |
} |
331 |
|
|
332 |
if (!strcmp(argv[i], "-format")) |
if (!strcmp(argv[i], "-tle")){ |
333 |
|
if (++i >= argc){ |
334 |
|
printf( "-tle needs arguments. \n"); |
335 |
|
printf( "Try '--help' for more information. \n"); |
336 |
|
exit(1); |
337 |
|
} else { |
338 |
|
tleFile = argv[i]; |
339 |
|
continue; |
340 |
|
} |
341 |
|
} |
342 |
|
|
343 |
|
if (!strcmp(argv[i], "-map")){ |
344 |
|
if (++i >= argc){ |
345 |
|
printf( "-map needs arguments. \n"); |
346 |
|
printf( "Try '--help' for more information. \n"); |
347 |
|
exit(1); |
348 |
|
} else { |
349 |
|
mapFile = argv[i]; |
350 |
|
continue; |
351 |
|
} |
352 |
|
} |
353 |
|
|
354 |
|
if (!strcmp(argv[i], "-format")) { |
355 |
if (++i >= argc){ |
if (++i >= argc){ |
356 |
printf( "-format needs arguments. \n"); |
printf( "-format needs arguments. \n"); |
357 |
printf( "Try '--help' for more information. \n"); |
printf( "Try '--help' for more information. \n"); |
361 |
continue; |
continue; |
362 |
} |
} |
363 |
} |
} |
|
Rate(argv[1], outDir, format); |
|
364 |
} |
} |
365 |
|
if (mapFile != ""){ |
366 |
|
Rate(argv[1], outDir, format, mapFile); |
367 |
|
} else { |
368 |
|
printf("You have to insert at least the file to analyze and the mapFile \n"); |
369 |
|
printf("Try '--help' for more information. \n"); |
370 |
|
} |
371 |
|
} |
372 |
|
|
373 |
|
|
374 |
|
|
375 |
|
|