| 26 |
#include <TSQLServer.h> |
#include <TSQLServer.h> |
| 27 |
#include <TSQLRow.h> |
#include <TSQLRow.h> |
| 28 |
#include <TSQLResult.h> |
#include <TSQLResult.h> |
| 29 |
|
#include <TObjectTable.h> |
| 30 |
// |
// |
| 31 |
// RunInfo header |
// RunInfo header |
| 32 |
// |
// |
| 54 |
// |
// |
| 55 |
#include <ToFLevel2.h> |
#include <ToFLevel2.h> |
| 56 |
#include <TrkLevel2.h> |
#include <TrkLevel2.h> |
| 57 |
|
#include <ExtTrack.h> // new tracking code |
| 58 |
|
|
| 59 |
using namespace std; |
using namespace std; |
| 60 |
|
|
| 62 |
// CORE ROUTINE |
// CORE ROUTINE |
| 63 |
// |
// |
| 64 |
// |
// |
| 65 |
int OrbitalInfoCore(UInt_t run, TFile *file, GL_TABLES *glt, Int_t OrbitalInfoargc, char *OrbitalInfoargv[]){ |
int OrbitalInfoCore(UInt_t run, TFile *file, GL_TABLES *glt, Int_t OrbitalInfoargc, char *OrbitalInfoargv[]){ |
| 66 |
// |
// |
| 67 |
Int_t i = 0; |
Int_t i = 0; |
| 68 |
TString host = glt->CGetHost(); |
TString host = glt->CGetHost(); |
| 72 |
// |
// |
| 73 |
stringstream myquery; |
stringstream myquery; |
| 74 |
myquery.str(""); |
myquery.str(""); |
| 75 |
myquery << "SET time_zone='+0:00'"; |
myquery << "SET time_zone='+0:00';"; |
| 76 |
delete dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
| 77 |
|
delete dbc->Query("SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';"); |
| 78 |
// |
// |
| 79 |
TString processFolder = Form("OrbitalInfoFolder_%u",run); |
TString processFolder = Form("OrbitalInfoFolder_%u",run); |
| 80 |
// |
// |
| 92 |
if ( !strcmp(OrbitalInfoargv[i],"-processFolder") ) { |
if ( !strcmp(OrbitalInfoargv[i],"-processFolder") ) { |
| 93 |
if ( OrbitalInfoargc < i+1 ){ |
if ( OrbitalInfoargc < i+1 ){ |
| 94 |
throw -3; |
throw -3; |
| 95 |
}; |
} |
| 96 |
processFolder = (TString)OrbitalInfoargv[i+1]; |
processFolder = (TString)OrbitalInfoargv[i+1]; |
| 97 |
i++; |
i++; |
| 98 |
}; |
} |
| 99 |
if ( (!strcmp(OrbitalInfoargv[i],"--debug")) || (!strcmp(OrbitalInfoargv[i],"-g")) ) { |
if ( (!strcmp(OrbitalInfoargv[i],"--debug")) || (!strcmp(OrbitalInfoargv[i],"-g")) ) { |
| 100 |
verbose = true; |
verbose = true; |
| 101 |
debug = true; |
debug = true; |
| 102 |
}; |
} |
| 103 |
if ( (!strcmp(OrbitalInfoargv[i],"--verbose")) || (!strcmp(OrbitalInfoargv[i],"-v")) ) { |
if ( (!strcmp(OrbitalInfoargv[i],"--verbose")) || (!strcmp(OrbitalInfoargv[i],"-v")) ) { |
| 104 |
verbose = true; |
verbose = true; |
| 105 |
}; |
} |
| 106 |
if ( (!strcmp(OrbitalInfoargv[i],"--standalone")) ) { |
if ( (!strcmp(OrbitalInfoargv[i],"--standalone")) ) { |
| 107 |
standalone = true; |
standalone = true; |
| 108 |
}; |
} |
| 109 |
if ( (!strcmp(OrbitalInfoargv[i],"--calculate-pitch")) ) { |
if ( (!strcmp(OrbitalInfoargv[i],"--calculate-pitch")) ) { |
| 110 |
standalone = false; |
standalone = false; |
| 111 |
}; |
} |
| 112 |
i++; |
i++; |
| 113 |
}; |
} |
| 114 |
}; |
} |
| 115 |
|
if ( debug ){ |
| 116 |
|
printf("START\n"); |
| 117 |
|
gObjectTable->Print(); |
| 118 |
|
} |
| 119 |
// |
// |
| 120 |
const char* outDir = gSystem->DirName(gSystem->DirName(file->GetPath())); |
const char* outDir = gSystem->DirName(gSystem->DirName(file->GetPath())); |
| 121 |
// |
// |
| 195 |
// |
// |
| 196 |
// IGRF stuff |
// IGRF stuff |
| 197 |
// |
// |
| 198 |
Double_t dimo = 0.0; // dipole moment (computed from dat files) // EM GCC 4.7 |
Float_t dimo = 0.0; // dipole moment (computed from dat files) // EM GCC 4.7 |
| 199 |
Float_t bnorth, beast, bdown, babs; |
Float_t bnorth, beast, bdown, babs; |
| 200 |
Float_t xl; // L value |
Float_t xl; // L value |
| 201 |
Float_t icode; // code value for L accuracy (see fortran code) |
Float_t icode; // code value for L accuracy (see fortran code) |
| 248 |
// Initialize fortran routines!!! |
// Initialize fortran routines!!! |
| 249 |
Int_t ltp1 = 0; |
Int_t ltp1 = 0; |
| 250 |
Int_t ltp2 = 0; |
Int_t ltp2 = 0; |
|
Int_t ltp3 = 0; |
|
|
// Int_t uno = 1; |
|
|
// const char *niente = " "; |
|
| 251 |
GL_PARAM *glparam0 = new GL_PARAM(); |
GL_PARAM *glparam0 = new GL_PARAM(); |
| 252 |
GL_PARAM *glparam = new GL_PARAM(); |
GL_PARAM *glparam = new GL_PARAM(); |
| 253 |
GL_PARAM *glparam2 = new GL_PARAM(); |
GL_PARAM *glparam2 = new GL_PARAM(); |
|
GL_PARAM *glparam3 = new GL_PARAM(); |
|
| 254 |
|
|
| 255 |
// |
// |
| 256 |
// Orientation variables. Vitaly |
// Orientation variables. Vitaly |
| 257 |
// |
// |
| 258 |
|
|
| 259 |
UInt_t evfrom = 0; |
UInt_t evfrom = 0; |
| 260 |
UInt_t jumped = 0; |
UInt_t jumped = 0; |
| 261 |
Int_t itr = -1; |
Int_t itr = -1; |
| 283 |
vector<Float_t> recq2; |
vector<Float_t> recq2; |
| 284 |
vector<Float_t> recq3; |
vector<Float_t> recq3; |
| 285 |
Float_t Norm = 1; |
Float_t Norm = 1; |
| 286 |
|
recqtime.reserve(1500000); |
| 287 |
|
recq0.reserve(1500000); |
| 288 |
|
recq1.reserve(1500000); |
| 289 |
|
recq2.reserve(1500000); |
| 290 |
|
recq3.reserve(1500000); |
| 291 |
|
|
| 292 |
|
vector<UInt_t> RTtime1; |
| 293 |
|
vector<UInt_t> RTtime2; |
| 294 |
|
vector<Double_t> RTbank1; |
| 295 |
|
vector<Double_t> RTbank2; |
| 296 |
|
vector<Double_t> RTbpluto1; |
| 297 |
|
vector<Double_t> RTbpluto2; |
| 298 |
|
vector<Int_t> RTazim; |
| 299 |
|
vector<UInt_t> RTstart; |
| 300 |
|
vector<UInt_t> RTpluto2; |
| 301 |
|
vector<UInt_t> RTpluto1; |
| 302 |
|
vector<Int_t> RTerrq; |
| 303 |
|
vector<Int_t> RTqual; |
| 304 |
|
RTtime1.reserve(200000); |
| 305 |
|
RTtime2.reserve(200000); |
| 306 |
|
RTbank1.reserve(200000); |
| 307 |
|
RTbank2.reserve(200000); |
| 308 |
|
RTbpluto1.reserve(200000); |
| 309 |
|
RTbpluto2.reserve(200000); |
| 310 |
|
RTazim.reserve(200000); |
| 311 |
|
RTstart.reserve(200000); |
| 312 |
|
RTpluto1.reserve(200000); |
| 313 |
|
RTpluto2.reserve(200000); |
| 314 |
|
RTerrq.reserve(200000); |
| 315 |
|
RTqual.reserve(200000); |
| 316 |
|
|
| 317 |
|
TClonesArray *tcNucleiTrk = NULL; |
| 318 |
|
TClonesArray *tcExtNucleiTrk = NULL; |
| 319 |
|
TClonesArray *tcExtTrk = NULL; |
| 320 |
|
TClonesArray *tcNucleiTof = NULL; |
| 321 |
|
TClonesArray *tcExtNucleiTof = NULL; |
| 322 |
|
TClonesArray *tcExtTof = NULL; |
| 323 |
|
TClonesArray *torbNucleiTrk = NULL; |
| 324 |
|
TClonesArray *torbExtNucleiTrk = NULL; |
| 325 |
|
TClonesArray *torbExtTrk = NULL; |
| 326 |
|
Bool_t hasNucleiTrk = false; |
| 327 |
|
Bool_t hasExtNucleiTrk = false; |
| 328 |
|
Bool_t hasExtTrk = false; |
| 329 |
|
Bool_t hasNucleiTof = false; |
| 330 |
|
Bool_t hasExtNucleiTof = false; |
| 331 |
|
Bool_t hasExtTof = false; |
| 332 |
|
|
| 333 |
|
ifstream in; |
| 334 |
|
ifstream an; |
| 335 |
|
// ofstream mc; |
| 336 |
|
// TString gr; |
| 337 |
|
Int_t parerror2=0; |
| 338 |
|
|
| 339 |
Int_t parerror=glparam0->Query_GL_PARAM(1,303,dbc); // parameters stored in DB in GL_PRAM table |
Int_t parerror=glparam0->Query_GL_PARAM(1,303,dbc); // parameters stored in DB in GL_PRAM table |
| 340 |
cout<<parerror<<"\t"<<(char*)(glparam0->PATH+glparam0->NAME).Data()<<endl; |
if ( verbose ) cout<<parerror<<"\t"<<(char*)(glparam0->PATH+glparam0->NAME).Data()<<endl; |
|
ifstream in((char*)(glparam0->PATH+glparam0->NAME).Data(),ios::in); |
|
| 341 |
if ( parerror<0 ) { |
if ( parerror<0 ) { |
| 342 |
code = parerror; |
code = parerror; |
| 343 |
//goto closeandexit; |
goto closeandexit; |
| 344 |
} |
} |
| 345 |
|
in.open((char*)(glparam0->PATH+glparam0->NAME).Data(),ios::in); |
| 346 |
while(!in.eof()){ |
while(!in.eof()){ |
| 347 |
recqtime.resize(recqtime.size()+1); |
recqtime.resize(recqtime.size()+1); |
| 348 |
Int_t sizee = recqtime.size(); |
Int_t sizee = recqtime.size(); |
| 356 |
in>>recq2[sizee-1]; |
in>>recq2[sizee-1]; |
| 357 |
in>>recq3[sizee-1]; |
in>>recq3[sizee-1]; |
| 358 |
in>>Norm; |
in>>Norm; |
| 359 |
|
/* CHECK RECOVERED QUATERNIONS PROBLEM |
| 360 |
|
if(recqtime[sizee-1]>=1160987921.75 && recqtime[sizee-1]<=1160987932.00){ |
| 361 |
|
cout<<"We found it at start"<<"\t"<<recqtime[sizee-1]<<endl; |
| 362 |
|
} */ |
| 363 |
} |
} |
| 364 |
in.close(); |
in.close(); |
| 365 |
if ( verbose ) cout<<"We have read recovered data"<<endl; |
if ( verbose ) cout<<"We have read recovered data"<<endl; |
| 366 |
if (debug) cout << "size of recovered quaterions data set is " << recqtime.size() << endl; |
if (debug) cout << "size of recovered quaterions data set is " << recqtime.size() << endl; |
| 367 |
|
if ( debug ) printf(" RQ size %i RQ capacity %i \n",(int)recqtime.size(),(int)recqtime.capacity()); |
| 368 |
vector<UInt_t> RTtime1; |
|
|
vector<UInt_t> RTtime2; |
|
|
vector<Double_t> RTbank1; |
|
|
vector<Double_t> RTbank2; |
|
|
vector<Int_t> RTazim; |
|
|
vector<Int_t> RTdir1; |
|
|
vector<Int_t> RTdir2; |
|
|
vector<Int_t> RTerrq; |
|
|
|
|
|
// 10RED CHECK |
|
|
|
|
|
// TH2F* DIFFX = new TH2F("diffx","",100,0,100,90,0,90); |
|
|
// TH2F* DIFFY = new TH2F("diffy","",100,0,100,90,0,90); |
|
|
// TH2F* DIFFZ = new TH2F("diffz","",100,0,100,90,0,90); |
|
|
|
|
|
ofstream mc; |
|
|
TString gr = "methodscomparison_"; |
|
|
gr+=run; |
|
|
gr+=".txt"; |
|
|
mc.open(gr); |
|
|
mc.setf(ios::fixed,ios::floatfield); |
|
|
// 10RED CHECK END |
|
|
|
|
| 369 |
if ( verbose ) cout<<"read Rotation Table"<<endl; |
if ( verbose ) cout<<"read Rotation Table"<<endl; |
| 370 |
|
|
| 371 |
|
parerror2=glparam0->Query_GL_PARAM(1,305,dbc); |
| 372 |
|
|
| 373 |
Int_t parerror2=glparam0->Query_GL_PARAM(1,305,dbc); |
if ( verbose ) cout<<parerror2<<"\t"<<(char*)(glparam0->PATH+glparam0->NAME).Data()<<endl; |
| 374 |
ifstream an((char*)(glparam0->PATH+glparam0->NAME).Data(),ios::in); |
if ( parerror2<0 ) { |
| 375 |
cout<<parerror2<<"\t"<<(char*)(glparam0->PATH+glparam0->NAME).Data()<<endl; |
code = parerror; |
| 376 |
// if ( parerror2<0 ) { |
goto closeandexit; |
| 377 |
// code = parerror; |
} |
| 378 |
//goto closeandexit; |
an.open((char*)(glparam0->PATH+glparam0->NAME).Data(),ios::in); |
|
// } |
|
|
|
|
|
//ifstream an("/data03/Malakhov/pam9Malakhov/installed10/calib/orb-param/RDBCC.txt",ios::in); |
|
| 379 |
while(!an.eof()){ |
while(!an.eof()){ |
| 380 |
RTtime1.resize(RTtime1.size()+1); |
RTtime1.resize(RTtime1.size()+1); |
| 381 |
Int_t sizee = RTtime1.size(); |
Int_t sizee = RTtime1.size(); |
| 382 |
RTbank1.resize(sizee+1); |
RTbank1.resize(sizee+1); |
| 383 |
RTazim.resize(sizee+1); |
RTazim.resize(sizee+1); |
|
RTdir1.resize(sizee+1); |
|
| 384 |
RTerrq.resize(sizee+1); |
RTerrq.resize(sizee+1); |
| 385 |
|
RTstart.resize(sizee+1); |
| 386 |
|
RTpluto1.resize(sizee+1); |
| 387 |
|
RTbpluto1.resize(sizee+1); |
| 388 |
|
RTqual.resize(sizee+1); |
| 389 |
an>>RTtime1[sizee-1]; |
an>>RTtime1[sizee-1]; |
| 390 |
an>>RTbank1[sizee-1]; |
an>>RTbank1[sizee-1]; |
| 391 |
|
an>>RTstart[sizee-1]; |
| 392 |
|
an>>RTpluto1[sizee-1]; |
| 393 |
|
an>>RTbpluto1[sizee-1]; |
| 394 |
an>>RTazim[sizee-1]; |
an>>RTazim[sizee-1]; |
|
an>>RTdir1[sizee-1]; |
|
| 395 |
an>>RTerrq[sizee-1]; |
an>>RTerrq[sizee-1]; |
| 396 |
|
an>>RTqual[sizee-1]; |
| 397 |
if(sizee>1) { |
if(sizee>1) { |
| 398 |
RTtime2.resize(sizee+1); |
RTtime2.resize(sizee+1); |
| 399 |
RTbank2.resize(sizee+1); |
RTbank2.resize(sizee+1); |
| 400 |
RTdir2.resize(sizee+1); |
RTpluto2.resize(sizee+1); |
| 401 |
|
RTbpluto2.resize(sizee+1); |
| 402 |
RTtime2[sizee-2]=RTtime1[sizee-1]; |
RTtime2[sizee-2]=RTtime1[sizee-1]; |
| 403 |
|
RTpluto2[sizee-2]=RTpluto1[sizee-1]; |
| 404 |
RTbank2[sizee-2]=RTbank1[sizee-1]; |
RTbank2[sizee-2]=RTbank1[sizee-1]; |
| 405 |
RTdir2[sizee-2]=RTdir1[sizee-1]; |
RTbpluto2[sizee-2]=RTbpluto1[sizee-1]; |
| 406 |
} |
} |
| 407 |
} |
} |
| 408 |
an.close(); |
an.close(); |
| 412 |
|
|
| 413 |
if ( verbose ) cout<<"We have read Rotation Table"<<endl; |
if ( verbose ) cout<<"We have read Rotation Table"<<endl; |
| 414 |
//Geomagnetic coordinates calculations staff |
//Geomagnetic coordinates calculations staff |
| 415 |
|
|
| 416 |
|
if ( debug ) printf(" RT size %i RT capacity %i \n",(int)RTtime2.size(),(int)RTtime2.capacity()); |
| 417 |
|
|
| 418 |
GMtype_CoordGeodetic location; |
GMtype_CoordGeodetic location; |
| 419 |
// GMtype_CoordDipole GMlocation; |
// GMtype_CoordDipole GMlocation; |
| 424 |
// TString igpath="/data03/Malakhov/pam9Malakhov/installed10/calib/orb-param/"; |
// TString igpath="/data03/Malakhov/pam9Malakhov/installed10/calib/orb-param/"; |
| 425 |
// } |
// } |
| 426 |
|
|
|
// GM_ScanIGRF(glparam->PATH, &G0, &G1, &H1); |
|
|
GM_ScanIGRF(dbc, &G0, &G1, &H1); |
|
|
|
|
| 427 |
//cout << G0.element[0] << "\t" << G1.element[0] << "\t" << H1.element[0] << endl; |
//cout << G0.element[0] << "\t" << G1.element[0] << "\t" << H1.element[0] << endl; |
| 428 |
//cout << G0.element[5] << "\t" << G1.element[5] << "\t" << H1.element[5] << endl; |
//cout << G0.element[5] << "\t" << G1.element[5] << "\t" << H1.element[5] << endl; |
| 429 |
|
|
| 437 |
// |
// |
| 438 |
if ( !standalone ){ |
if ( !standalone ){ |
| 439 |
// |
// |
| 440 |
// Does it contain the Tracker tree? |
// Does it contain the Tracker and ToF trees? |
| 441 |
// |
// |
| 442 |
ttof = (TTree*)file->Get("ToF"); |
ttof = (TTree*)file->Get("ToF"); |
| 443 |
if ( !ttof ) { |
if ( !ttof ) { |
| 448 |
ttof->SetBranchAddress("ToFLevel2",&tof); |
ttof->SetBranchAddress("ToFLevel2",&tof); |
| 449 |
nevtofl2 = ttof->GetEntries(); |
nevtofl2 = ttof->GetEntries(); |
| 450 |
|
|
| 451 |
|
// |
| 452 |
|
// Look for extended tracking algorithm |
| 453 |
|
// |
| 454 |
|
if ( verbose ) printf("Look for extended and nuclei tracking algorithms in ToF\n"); |
| 455 |
|
// Nuclei tracking algorithm |
| 456 |
|
Int_t checkAlgo = 0; |
| 457 |
|
tcNucleiTof = new TClonesArray("ToFTrkVar"); |
| 458 |
|
checkAlgo = ttof->SetBranchAddress("TrackNuclei",&tcNucleiTof); |
| 459 |
|
if ( !checkAlgo ){ |
| 460 |
|
if ( verbose ) printf(" Nuclei tracking algorithm ToF branch found! :D \n"); |
| 461 |
|
hasNucleiTof = true; |
| 462 |
|
} else { |
| 463 |
|
if ( verbose ) printf(" Nuclei tracking algorithm ToF branch not found :( !\n"); |
| 464 |
|
printf(" ok, this is not a problem (it depends on tracker settings) \n"); |
| 465 |
|
delete tcNucleiTof; |
| 466 |
|
tcNucleiTof=NULL; // 10RED reprocessing bug |
| 467 |
|
} |
| 468 |
|
// Nuclei tracking algorithm using calorimeter points |
| 469 |
|
tcExtNucleiTof = new TClonesArray("ToFTrkVar"); |
| 470 |
|
checkAlgo = ttof->SetBranchAddress("RecoveredTrackNuclei",&tcExtNucleiTof); |
| 471 |
|
if ( !checkAlgo ){ |
| 472 |
|
if ( verbose ) printf(" Recovered nuclei tracking algorithm ToF branch found! :D \n"); |
| 473 |
|
hasExtNucleiTof = true; |
| 474 |
|
} else { |
| 475 |
|
if ( verbose ) printf(" Recovered nuclei tracking algorithm ToF branch not found :( !\n"); |
| 476 |
|
printf(" ok, this is not a problem (it depends on tracker settings) \n"); |
| 477 |
|
delete tcExtNucleiTof; |
| 478 |
|
tcExtNucleiTof=NULL; // 10RED reprocessing bug |
| 479 |
|
} |
| 480 |
|
// Tracking algorithm using calorimeter points |
| 481 |
|
tcExtTof = new TClonesArray("ToFTrkVar"); |
| 482 |
|
checkAlgo = ttof->SetBranchAddress("RecoveredTrack",&tcExtTof); |
| 483 |
|
if ( !checkAlgo ){ |
| 484 |
|
if ( verbose ) printf(" Recovered track algorithm ToF branch found! :D \n"); |
| 485 |
|
hasExtTof = true; |
| 486 |
|
} else { |
| 487 |
|
if ( verbose ) printf(" Recovered track algorithm ToF branch not found :( !\n"); |
| 488 |
|
printf(" ok, this is not a problem (it depends on tracker settings) \n"); |
| 489 |
|
delete tcExtTof; |
| 490 |
|
tcExtTof=NULL; // 10RED reprocessing bug |
| 491 |
|
} |
| 492 |
|
|
| 493 |
ttrke = (TTree*)file->Get("Tracker"); |
ttrke = (TTree*)file->Get("Tracker"); |
| 494 |
if ( !ttrke ) { |
if ( !ttrke ) { |
| 495 |
if ( verbose ) printf(" OrbitalInfo - ERROR: no trk tree\n"); |
if ( verbose ) printf(" OrbitalInfo - ERROR: no trk tree\n"); |
| 498 |
} |
} |
| 499 |
ttrke->SetBranchAddress("TrkLevel2",&trke); |
ttrke->SetBranchAddress("TrkLevel2",&trke); |
| 500 |
nevtrkl2 = ttrke->GetEntries(); |
nevtrkl2 = ttrke->GetEntries(); |
| 501 |
|
|
| 502 |
|
// |
| 503 |
|
// Look for extended tracking algorithm |
| 504 |
|
// |
| 505 |
|
if ( verbose ) printf("Look for extended and nuclei tracking algorithms\n"); |
| 506 |
|
// Nuclei tracking algorithm |
| 507 |
|
checkAlgo = 0; |
| 508 |
|
tcNucleiTrk = new TClonesArray("TrkTrack"); |
| 509 |
|
checkAlgo = ttrke->SetBranchAddress("TrackNuclei",&tcNucleiTrk); |
| 510 |
|
if ( !checkAlgo ){ |
| 511 |
|
if ( verbose ) printf(" Nuclei tracking algorithm branch found! :D \n"); |
| 512 |
|
hasNucleiTrk = true; |
| 513 |
|
} else { |
| 514 |
|
if ( verbose ) printf(" Nuclei tracking algorithm branch not found :( !\n"); |
| 515 |
|
printf(" ok, this is not a problem (it depends on tracker settings) \n"); |
| 516 |
|
delete tcNucleiTrk; |
| 517 |
|
tcNucleiTrk=NULL; // 10RED reprocessing bug |
| 518 |
|
} |
| 519 |
|
// Nuclei tracking algorithm using calorimeter points |
| 520 |
|
tcExtNucleiTrk = new TClonesArray("ExtTrack"); |
| 521 |
|
checkAlgo = ttrke->SetBranchAddress("RecoveredTrackNuclei",&tcExtNucleiTrk); |
| 522 |
|
if ( !checkAlgo ){ |
| 523 |
|
if ( verbose ) printf(" Recovered nuclei tracking algorithm branch found! :D \n"); |
| 524 |
|
hasExtNucleiTrk = true; |
| 525 |
|
} else { |
| 526 |
|
if ( verbose ) printf(" Recovered nuclei tracking algorithm branch not found :( !\n"); |
| 527 |
|
printf(" ok, this is not a problem (it depends on tracker settings) \n"); |
| 528 |
|
delete tcExtNucleiTrk; |
| 529 |
|
tcExtNucleiTrk=NULL; // 10RED reprocessing bug |
| 530 |
|
} |
| 531 |
|
// Tracking algorithm using calorimeter points |
| 532 |
|
tcExtTrk = new TClonesArray("ExtTrack"); |
| 533 |
|
checkAlgo = ttrke->SetBranchAddress("RecoveredTrack",&tcExtTrk); |
| 534 |
|
if ( !checkAlgo ){ |
| 535 |
|
if ( verbose ) printf(" Recovered track algorithm branch found! :D \n"); |
| 536 |
|
hasExtTrk = true; |
| 537 |
|
} else { |
| 538 |
|
if ( verbose ) printf(" Recovered track algorithm branch not found :( !\n"); |
| 539 |
|
printf(" ok, this is not a problem (it depends on tracker settings) \n"); |
| 540 |
|
delete tcExtTrk; |
| 541 |
|
tcExtTrk=NULL; // 10RED reprocessing bug |
| 542 |
|
} |
| 543 |
|
|
| 544 |
|
if ( (hasNucleiTrk && !hasNucleiTof) || (!hasNucleiTrk && hasNucleiTof) || |
| 545 |
|
(hasExtNucleiTrk && !hasExtNucleiTof) || (!hasExtNucleiTrk && hasExtNucleiTof) || |
| 546 |
|
(hasExtTrk && !hasExtTof) || (!hasExtTrk && hasExtTof) |
| 547 |
|
){ |
| 548 |
|
if ( verbose ) printf(" ERROR: Mismatch between tracker and tof tree branches concerning extended tracking algorithm(s)\n"); |
| 549 |
|
if ( debug ) printf("hasNucleiTrk %i hasExtNucleiTrk %i hasExtTrk %i \n",hasNucleiTrk,hasExtNucleiTrk,hasExtTrk); |
| 550 |
|
if ( debug ) printf("hasNucleiTof %i hasExtNucleiTof %i hasExtTof %i \n",hasNucleiTof,hasExtNucleiTof,hasExtTof); |
| 551 |
|
throw -901; |
| 552 |
|
} |
| 553 |
|
|
| 554 |
} |
} |
| 555 |
// |
// |
| 556 |
// Let's start! |
// Let's start! |
| 679 |
orbitalinfo->Set();//ELENA **TEMPORANEO?** |
orbitalinfo->Set();//ELENA **TEMPORANEO?** |
| 680 |
OrbitalInfotr->Branch("OrbitalInfo","OrbitalInfo",&orbitalinfo); |
OrbitalInfotr->Branch("OrbitalInfo","OrbitalInfo",&orbitalinfo); |
| 681 |
// |
// |
| 682 |
|
// create new branches for new tracking algorithms |
| 683 |
|
// |
| 684 |
|
if ( hasNucleiTrk ){ |
| 685 |
|
torbNucleiTrk = new TClonesArray("OrbitalInfoTrkVar",1); |
| 686 |
|
OrbitalInfotr->Branch("TrackNuclei",&torbNucleiTrk); |
| 687 |
|
} |
| 688 |
|
if ( hasExtNucleiTrk ){ |
| 689 |
|
torbExtNucleiTrk = new TClonesArray("OrbitalInfoTrkVar",1); |
| 690 |
|
OrbitalInfotr->Branch("RecoveredTrackNuclei",&torbExtNucleiTrk); |
| 691 |
|
} |
| 692 |
|
if ( hasExtTrk ){ |
| 693 |
|
torbExtTrk = new TClonesArray("OrbitalInfoTrkVar",1); |
| 694 |
|
OrbitalInfotr->Branch("RecoveredTrack",&torbExtTrk); |
| 695 |
|
} |
| 696 |
|
|
| 697 |
|
// |
| 698 |
if ( reproc && !reprocall ){ |
if ( reproc && !reprocall ){ |
| 699 |
// |
// |
| 700 |
// open new file and retrieve also tree informations |
// open new file and retrieve also tree informations |
| 716 |
// |
// |
| 717 |
// copy orbitalinfoclone to mydec |
// copy orbitalinfoclone to mydec |
| 718 |
// |
// |
| 719 |
orbitalinfo->Clear(); |
// orbitalinfo->Clear(); |
| 720 |
// |
// |
| 721 |
memcpy(&orbitalinfo,&orbitalinfoclone,sizeof(orbitalinfoclone)); |
memcpy(&orbitalinfo,&orbitalinfoclone,sizeof(orbitalinfoclone)); |
| 722 |
// |
// |
| 733 |
// Get the list of run to be processed, if only one run has to be processed the list will contain one entry only. |
// Get the list of run to be processed, if only one run has to be processed the list will contain one entry only. |
| 734 |
// |
// |
| 735 |
runlist = runinfo->GetRunList(); |
runlist = runinfo->GetRunList(); |
| 736 |
|
if ( debug ){ |
| 737 |
|
printf("BEFORE LOOP ON RUN\n"); |
| 738 |
|
gObjectTable->Print(); |
| 739 |
|
} |
| 740 |
// |
// |
| 741 |
// Loop over the run to be processed |
// Loop over the run to be processed |
| 742 |
// |
// |
| 743 |
for (UInt_t irun=0; irun < numbofrun; irun++){ |
for (UInt_t irun=0; irun < numbofrun; irun++){ //===> |
| 744 |
|
|
| 745 |
L_QQ_Q_l_lower = new Quaternions(); |
L_QQ_Q_l_lower = new Quaternions(); |
| 746 |
RYPang_lower = new InclinationInfo(); |
RYPang_lower = new InclinationInfo(); |
| 849 |
goto closeandexit; |
goto closeandexit; |
| 850 |
}; |
}; |
| 851 |
|
|
|
// |
|
|
// open IGRF files and do it only once if we are processing a full level2 file |
|
|
// |
|
|
if ( !igrfloaded ){ |
|
|
|
|
|
if ( l0head->GetEntry(runinfo->EV_FROM) > 0 ){ |
|
|
igrfloaded = true; |
|
|
// |
|
|
// absolute time of first event of the run (it should not matter a lot) |
|
|
// |
|
|
ph = eh->GetPscuHeader(); |
|
|
atime = dbtime->DBabsTime(ph->GetOrbitalTime()); |
|
|
|
|
|
parerror=glparam->Query_GL_PARAM(atime-anni5,301,dbc); // parameters stored in DB in GL_PRAM table |
|
|
if ( parerror<0 ) { |
|
|
code = parerror; |
|
|
goto closeandexit; |
|
|
} |
|
|
ltp1 = (Int_t)(glparam->PATH+glparam->NAME).Length(); |
|
|
if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
|
|
// |
|
|
parerror=glparam2->Query_GL_PARAM(atime,301,dbc); // parameters stored in DB in GL_PRAM table |
|
|
if ( parerror<0 ) { |
|
|
code = parerror; |
|
|
goto closeandexit; |
|
|
} |
|
|
ltp2 = (Int_t)(glparam2->PATH+glparam2->NAME).Length(); |
|
|
if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam2->PATH+glparam2->NAME).Data()); |
|
|
// |
|
|
parerror=glparam3->Query_GL_PARAM(atime,302,dbc); // parameters stored in DB in GL_PRAM table |
|
|
if ( parerror<0 ) { |
|
|
code = parerror; |
|
|
goto closeandexit; |
|
|
} |
|
|
ltp3 = (Int_t)(glparam3->PATH+glparam3->NAME).Length(); |
|
|
if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam3->PATH+glparam3->NAME).Data()); |
|
|
// |
|
|
initize_((char *)(glparam->PATH+glparam->NAME).Data(),<p1,(char *)(glparam2->PATH+glparam2->NAME).Data(),<p2,(char *)(glparam3->PATH+glparam3->NAME).Data(),<p3); |
|
|
// |
|
|
if (debug) cout<<"initize: "<<(char *)(glparam->PATH+glparam->NAME).Data()<<"\t"<<(char *)(glparam2->PATH+glparam2->NAME).Data()<<"\t"<<(char *)(glparam3->PATH+glparam3->NAME).Data()<<endl; |
|
|
} |
|
|
} |
|
|
// |
|
|
// End IGRF stuff// |
|
|
// |
|
|
|
|
|
// |
|
|
// TTree *tp = (TTree*)l0File->Get("RunHeader"); |
|
|
// tp->SetBranchAddress("Header", &eH); |
|
|
// tp->SetBranchAddress("RunHeader", &reh); |
|
|
// tp->GetEntry(0); |
|
|
// ph = eH->GetPscuHeader(); |
|
|
// ULong_t TimeSync = reh->LAST_TIME_SYNC_INFO; |
|
|
// ULong_t ObtSync = reh->OBT_TIME_SYNC; |
|
|
// if ( debug ) printf(" 1 TimeSync %lu ObtSync %lu DeltaOBT %lu\n",TimeSync,ObtSync,TimeSync-ObtSync); |
|
|
// |
|
| 852 |
ULong_t TimeSync = (ULong_t)dbtime->GetTimesync(); |
ULong_t TimeSync = (ULong_t)dbtime->GetTimesync(); |
| 853 |
ULong_t ObtSync = (ULong_t)(dbtime->GetObt0()/1000); |
ULong_t ObtSync = (ULong_t)(dbtime->GetObt0()/1000); |
| 854 |
ULong_t DeltaOBT = TimeSync - ObtSync; |
ULong_t DeltaOBT = TimeSync - ObtSync; |
| 884 |
// |
// |
| 885 |
l0fid[i] = (UInt_t)atoll(Row->GetField(0)); |
l0fid[i] = (UInt_t)atoll(Row->GetField(0)); |
| 886 |
i--; |
i--; |
| 887 |
|
if (Row){ // memleak! |
| 888 |
|
delete Row; |
| 889 |
|
Row = 0; |
| 890 |
|
} |
| 891 |
Row = pResult->Next(); |
Row = pResult->Next(); |
| 892 |
// |
// |
| 893 |
}; |
} |
| 894 |
|
if (Row) delete Row; |
| 895 |
pResult->Delete(); |
pResult->Delete(); |
| 896 |
}; |
} |
| 897 |
// |
// |
| 898 |
myquery.str(""); |
myquery.str(""); |
| 899 |
myquery << "select ID_ROOT_L0 from GL_RUN where RUNHEADER_TIME>" << runinfo->RUNHEADER_TIME << " group by ID_ROOT_L0 order by RUNHEADER_TIME asc limit 5;"; |
myquery << "select ID_ROOT_L0 from GL_RUN where RUNHEADER_TIME>" << runinfo->RUNHEADER_TIME << " group by ID_ROOT_L0 order by RUNHEADER_TIME asc limit 5;"; |
| 911 |
// |
// |
| 912 |
l0fid[i] = (UInt_t)atoll(Row->GetField(0)); |
l0fid[i] = (UInt_t)atoll(Row->GetField(0)); |
| 913 |
i++; |
i++; |
| 914 |
|
if (Row){ // memleak! |
| 915 |
|
delete Row; |
| 916 |
|
Row = 0; |
| 917 |
|
} |
| 918 |
Row = pResult->Next(); |
Row = pResult->Next(); |
| 919 |
// |
// |
| 920 |
}; |
} |
| 921 |
|
if (Row) delete Row; |
| 922 |
pResult->Delete(); |
pResult->Delete(); |
| 923 |
}; |
} |
| 924 |
// |
// |
| 925 |
i = 0; |
i = 0; |
| 926 |
UInt_t previd = 0; |
UInt_t previd = 0; |
| 939 |
if ( debug ) printf(" Using inclination informations from file: %s \n",(((TString)gSystem->ExpandPathName(Row->GetField(0)))+"/"+(TString)Row->GetField(1)).Data()); |
if ( debug ) printf(" Using inclination informations from file: %s \n",(((TString)gSystem->ExpandPathName(Row->GetField(0)))+"/"+(TString)Row->GetField(1)).Data()); |
| 940 |
ch->Add(((TString)gSystem->ExpandPathName(Row->GetField(0)))+"/"+(TString)Row->GetField(1)); |
ch->Add(((TString)gSystem->ExpandPathName(Row->GetField(0)))+"/"+(TString)Row->GetField(1)); |
| 941 |
// |
// |
| 942 |
|
if (Row) delete Row; |
| 943 |
pResult->Delete(); |
pResult->Delete(); |
| 944 |
}; |
} |
| 945 |
}; |
} |
| 946 |
i++; |
i++; |
| 947 |
}; |
} |
| 948 |
// |
// |
|
// l0trm = (TTree*)l0File->Get("Mcmd"); |
|
|
// ch->ls(); |
|
| 949 |
ch->SetBranchAddress("Mcmd",&mcmdev); |
ch->SetBranchAddress("Mcmd",&mcmdev); |
|
// printf(" entries %llu \n", ch->GetEntries()); |
|
|
// l0trm = ch->GetTree(); |
|
|
// neventsm = l0trm->GetEntries(); |
|
| 950 |
neventsm = ch->GetEntries(); |
neventsm = ch->GetEntries(); |
| 951 |
if ( debug ) printf(" entries %u \n", neventsm); |
if ( debug ) printf(" entries %u \n", neventsm); |
|
// neventsm = 0; |
|
| 952 |
// |
// |
| 953 |
if (neventsm == 0){ |
if (neventsm == 0){ |
| 954 |
if ( debug ) printf("InclinationInfo - WARNING: No quaternions in this File"); |
if ( debug ) printf("InclinationInfo - WARNING: No quaternions in this File"); |
|
// l0File->Close(); |
|
| 955 |
code = 900; |
code = 900; |
|
// goto closeandexit; |
|
| 956 |
} |
} |
| 957 |
// |
// |
| 958 |
|
Double_t lowerqtime = 0; |
|
// l0trm->SetBranchAddress("Mcmd", &mcmdev); |
|
|
// l0trm->SetBranchAddress("Header", &eh); |
|
|
// |
|
|
// |
|
|
// |
|
|
|
|
|
// UInt_t mctren = 0; |
|
|
// UInt_t mcreen = 0; |
|
|
// UInt_t numrec = 0; |
|
|
// |
|
|
// Double_t upperqtime = 0; |
|
|
Double_t lowerqtime = 0; |
|
|
|
|
|
// Double_t incli = 0; |
|
|
// oi = 0; |
|
|
// UInt_t ooi = 0; |
|
| 959 |
// |
// |
| 960 |
// init quaternions information from mcmd-packets |
// init quaternions information from mcmd-packets |
| 961 |
// |
// |
| 962 |
Bool_t isf = true; |
Bool_t isf = true; |
|
// Int_t fgh = 0; |
|
| 963 |
|
|
| 964 |
vector<Float_t> q0; |
vector<Float_t> q0; |
| 965 |
vector<Float_t> q1; |
vector<Float_t> q1; |
| 971 |
vector<Float_t> qYaw; |
vector<Float_t> qYaw; |
| 972 |
vector<Int_t> qmode; |
vector<Int_t> qmode; |
| 973 |
|
|
| 974 |
|
q0.reserve(4096); |
| 975 |
|
q1.reserve(4096); |
| 976 |
|
q2.reserve(4096); |
| 977 |
|
q3.reserve(4096); |
| 978 |
|
qtime.reserve(4096); |
| 979 |
|
qPitch.reserve(4096); |
| 980 |
|
qRoll.reserve(4096); |
| 981 |
|
qYaw.reserve(4096); |
| 982 |
|
qmode.reserve(4096); |
| 983 |
|
if ( debug ) printf(" q0 capa %i \n",(int)q0.capacity()); |
| 984 |
Int_t nt = 0; |
Int_t nt = 0; |
|
|
|
| 985 |
UInt_t must = 0; |
UInt_t must = 0; |
| 986 |
|
|
| 987 |
|
Int_t currentYear = 0; |
| 988 |
|
Int_t previousYear = 0; |
| 989 |
|
|
| 990 |
// |
// |
| 991 |
// run over all the events of the run |
// run over all the events of the run |
| 992 |
// |
// |
| 993 |
if (verbose) printf("\n Ready to start! \n\n Processed events: \n\n"); |
if (verbose) printf("\n Ready to start! \n\n Processed events: \n\n"); |
| 994 |
|
if ( debug ){ |
| 995 |
|
printf("BEFORE LOOP ON EVENTS\n"); |
| 996 |
|
gObjectTable->Print(); |
| 997 |
|
} |
| 998 |
// |
// |
| 999 |
// |
// |
| 1000 |
for ( re = runinfo->EV_FROM; re < (runinfo->EV_FROM+runinfo->NEVENTS); re++){ |
for ( re = runinfo->EV_FROM; re < (runinfo->EV_FROM+runinfo->NEVENTS); re++){ |
| 1001 |
|
//for ( re = runinfo->EV_FROM; re < (runinfo->EV_FROM+10); re++){ |
| 1002 |
|
|
| 1003 |
// |
// |
| 1004 |
if ( procev%1000 == 0 && procev > 0 && verbose ) printf(" %iK \n",procev/1000); |
if ( procev%1000 == 0 && procev > 0 && verbose ) printf(" %iK \n",procev/1000); |
| 1005 |
if ( debug ) printf(" %i \n",procev); |
if ( debug ) printf(" %i \n",procev); |
| 1021 |
continue; |
continue; |
| 1022 |
} |
} |
| 1023 |
|
|
| 1024 |
|
// just for testing: |
| 1025 |
|
// if (re >= 5+runinfo->EV_FROM) atime += anni5; |
| 1026 |
|
// if (re >= 7+runinfo->EV_FROM) atime += anni5; |
| 1027 |
|
// if (re >= 9+runinfo->EV_FROM) atime += anni5; |
| 1028 |
|
|
| 1029 |
|
// |
| 1030 |
|
// open IGRF files and do it only once if we are processing a full level2 file |
| 1031 |
|
// |
| 1032 |
|
Float_t kkyear; |
| 1033 |
|
UInt_t kyear, kmonth, kday, khour, kmin, ksec; |
| 1034 |
|
// |
| 1035 |
|
TTimeStamp kt = TTimeStamp(atime, kTRUE); |
| 1036 |
|
kt.GetDate(kTRUE, 0, &kyear, &kmonth, &kday); |
| 1037 |
|
kt.GetTime(kTRUE, 0, &khour, &kmin, &ksec); |
| 1038 |
|
kkyear = (float) kyear |
| 1039 |
|
+ (kmonth*31.+ (float) kday)/365. |
| 1040 |
|
+ (khour*3600.+kmin*60.+(float)ksec)/(24.*3600.*365.); |
| 1041 |
|
currentYear = int(kkyear/5.) * 5; |
| 1042 |
|
if ( debug ) printf(" prevy %i curry %i igrfloaded %i \n",previousYear,currentYear,igrfloaded); |
| 1043 |
|
if ( currentYear != previousYear ) igrfloaded = false; |
| 1044 |
|
previousYear = currentYear; |
| 1045 |
|
if ( debug ) printf(" prevy %i curry %i igrfloaded %i \n",previousYear,currentYear,igrfloaded); |
| 1046 |
|
// |
| 1047 |
|
if ( !igrfloaded ){ |
| 1048 |
|
|
| 1049 |
|
igrfloaded = true; |
| 1050 |
|
|
| 1051 |
|
parerror=glparam->Query_GL_PARAM(atime,302,dbc); // parameters stored in DB in GL_PRAM table |
| 1052 |
|
if ( parerror<0 ) { |
| 1053 |
|
code = parerror; |
| 1054 |
|
goto closeandexit; |
| 1055 |
|
} |
| 1056 |
|
ltp1 = (Int_t)(glparam->PATH+glparam->NAME).Length(); |
| 1057 |
|
if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
| 1058 |
|
// |
| 1059 |
|
if ( glparam->NAME.EndsWith("s.txt") || glparam->NAME.EndsWith("s.dat") ){ |
| 1060 |
|
if ( verbose ) printf("ERROR: Current date is beyond the latest secular variation file time span. Please update IGRF files to process data\n"); |
| 1061 |
|
throw -906; |
| 1062 |
|
} |
| 1063 |
|
// |
| 1064 |
|
int isSecular = false; |
| 1065 |
|
// |
| 1066 |
|
parerror=glparam2->Query_GL_PARAM(atime+anni5,302,dbc); // parameters stored in DB in GL_PRAM table |
| 1067 |
|
if ( parerror<0 ) { |
| 1068 |
|
code = parerror; |
| 1069 |
|
goto closeandexit; |
| 1070 |
|
} |
| 1071 |
|
ltp2 = (Int_t)(glparam2->PATH+glparam2->NAME).Length(); |
| 1072 |
|
if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam2->PATH+glparam2->NAME).Data()); |
| 1073 |
|
if ( glparam2->NAME.EndsWith("s.txt") || glparam2->NAME.EndsWith("s.dat") ){ |
| 1074 |
|
isSecular = true; |
| 1075 |
|
if ( verbose ) printf(" Using secular variation file and hence fortran subroutine 'extrapolation'\n"); |
| 1076 |
|
} else { |
| 1077 |
|
if ( verbose ) printf(" Using two field measurement files and hence fortran subroutine 'interpolation'\n"); |
| 1078 |
|
} |
| 1079 |
|
// |
| 1080 |
|
initize_(&isSecular,(char *)(glparam->PATH+glparam->NAME).Data(),<p1,(char *)(glparam2->PATH+glparam2->NAME).Data(),<p2); |
| 1081 |
|
// |
| 1082 |
|
if (debug) cout<<"initize: "<<(char *)(glparam->PATH+glparam->NAME).Data()<<"\t"<<(char *)(glparam2->PATH+glparam2->NAME).Data()<<"\t isSecular? "<<isSecular<<endl; |
| 1083 |
|
|
| 1084 |
|
// GM_ScanIGRF(dbc, &G0, &G1, &H1); |
| 1085 |
|
TString igrfFile1 = glparam->PATH+glparam->NAME; |
| 1086 |
|
TString igrfFile2 = glparam2->PATH+glparam2->NAME; |
| 1087 |
|
GM_SetIGRF(isSecular,igrfFile1,igrfFile2, &G0, &G1, &H1); |
| 1088 |
|
} |
| 1089 |
|
// |
| 1090 |
|
// End IGRF stuff// |
| 1091 |
|
// |
| 1092 |
|
|
| 1093 |
// |
// |
| 1094 |
// retrieve tof informations |
// retrieve tof informations |
| 1095 |
// |
// |
| 1111 |
// |
// |
| 1112 |
tof->Clear(); |
tof->Clear(); |
| 1113 |
// |
// |
| 1114 |
|
// Clones array must be cleared before going on |
| 1115 |
|
// |
| 1116 |
|
if ( hasNucleiTof ){ |
| 1117 |
|
tcNucleiTof->Delete(); |
| 1118 |
|
} |
| 1119 |
|
if ( hasExtNucleiTof ){ |
| 1120 |
|
tcExtNucleiTof->Delete(); |
| 1121 |
|
} |
| 1122 |
|
if ( hasExtTof ){ |
| 1123 |
|
tcExtTof->Delete(); |
| 1124 |
|
} |
| 1125 |
|
// |
| 1126 |
|
if ( verbose ) printf(" get tof tree entries... entry = %i in Level2 file\n",itr); |
| 1127 |
if ( ttof->GetEntry(itr) <= 0 ){ |
if ( ttof->GetEntry(itr) <= 0 ){ |
| 1128 |
if ( verbose ) printf(" problems with tof tree entries... entry = %i in Level2 file\n",itr); |
if ( verbose ) printf(" problems with tof tree entries... entry = %i in Level2 file\n",itr); |
| 1129 |
if ( verbose ) printf(" nobefrun %u re %u evfrom %u jumped %u reprocall %i \n",nobefrun,re,evfrom,jumped,reprocall); |
if ( verbose ) printf(" nobefrun %u re %u evfrom %u jumped %u reprocall %i \n",nobefrun,re,evfrom,jumped,reprocall); |
| 1130 |
throw -36; |
throw -36; |
| 1131 |
} |
} |
| 1132 |
|
if ( verbose ) printf(" gat0\n"); |
| 1133 |
// |
// |
| 1134 |
} |
} |
| 1135 |
// |
// |
| 1142 |
l0File->Close(); |
l0File->Close(); |
| 1143 |
code = -905; |
code = -905; |
| 1144 |
goto closeandexit; |
goto closeandexit; |
| 1145 |
}; |
} |
| 1146 |
// |
// |
| 1147 |
|
if ( verbose ) printf(" gat1\n"); |
| 1148 |
trke->Clear(); |
trke->Clear(); |
| 1149 |
// |
// |
| 1150 |
|
// Clones array must be cleared before going on |
| 1151 |
|
// |
| 1152 |
|
if ( hasNucleiTrk ){ |
| 1153 |
|
if ( verbose ) printf(" gat2\n"); |
| 1154 |
|
tcNucleiTrk->Delete(); |
| 1155 |
|
if ( verbose ) printf(" gat3\n"); |
| 1156 |
|
torbNucleiTrk->Delete(); |
| 1157 |
|
} |
| 1158 |
|
if ( hasExtNucleiTrk ){ |
| 1159 |
|
if ( verbose ) printf(" gat4\n"); |
| 1160 |
|
tcExtNucleiTrk->Delete(); |
| 1161 |
|
if ( verbose ) printf(" gat5\n"); |
| 1162 |
|
torbExtNucleiTrk->Delete(); |
| 1163 |
|
} |
| 1164 |
|
if ( hasExtTrk ){ |
| 1165 |
|
if ( verbose ) printf(" gat6\n"); |
| 1166 |
|
tcExtTrk->Delete(); |
| 1167 |
|
if ( verbose ) printf(" gat7\n"); |
| 1168 |
|
torbExtTrk->Delete(); |
| 1169 |
|
} |
| 1170 |
|
// |
| 1171 |
|
if ( verbose ) printf(" get trk tree entries... entry = %i in Level2 file\n",itr); |
| 1172 |
if ( ttrke->GetEntry(itr) <= 0 ) throw -36; |
if ( ttrke->GetEntry(itr) <= 0 ) throw -36; |
| 1173 |
// |
// |
| 1174 |
} |
} |
| 1175 |
|
|
|
|
|
| 1176 |
// |
// |
| 1177 |
procev++; |
procev++; |
| 1178 |
// |
// |
| 1225 |
feldcof_(&jyear, &dimo); // get dipole moment for year |
feldcof_(&jyear, &dimo); // get dipole moment for year |
| 1226 |
if ( debug ) printf(" %i compute magnetic dipole moment end\n",procev); |
if ( debug ) printf(" %i compute magnetic dipole moment end\n",procev); |
| 1227 |
|
|
| 1228 |
GM_TimeAdjustCoefs(year, jyear, G0, G1, H1, &Model); |
// GM_TimeAdjustCoefs(year, jyear, G0, G1, H1, &Model); |
| 1229 |
|
GM_TimeAdjustCoefs(GM_STARTYEAR, (jyear-currentYear+GM_STARTYEAR), G0, G1, H1, &Model); // EM: input this way due to the new way of storing data into Gn,H1 and to avoid changing GM_Time... |
| 1230 |
GM_PoleLocation(Model, &Pole); |
GM_PoleLocation(Model, &Pole); |
| 1231 |
|
|
| 1232 |
} else { |
} else { |
| 1300 |
qRoll[sizeqmcmd]=RYPang_upper->Kren; |
qRoll[sizeqmcmd]=RYPang_upper->Kren; |
| 1301 |
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
| 1302 |
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
| 1303 |
|
/* CHECK RECOVERED QUATERNIONS PROBLEM */ |
| 1304 |
|
if(recqtime[mu]>=1160987921.75 && recqtime[mu]<=1160987932.00){ |
| 1305 |
|
cout<<"We found it while checking all quaternions"<<"\t"<<recqtime[mu]<<endl; |
| 1306 |
|
} |
| 1307 |
} |
} |
| 1308 |
} |
} |
| 1309 |
if(recqtime[mu]>=u_time){ |
if(recqtime[mu]>=u_time){ |
| 1322 |
qRoll[sizeqmcmd]=RYPang_upper->Kren; |
qRoll[sizeqmcmd]=RYPang_upper->Kren; |
| 1323 |
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
| 1324 |
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
| 1325 |
|
/* CHECK RECOVERED QUATERNIONS PROBLEM */ |
| 1326 |
|
if(recqtime[mu]>=1160987921.75 && recqtime[mu]<=1160987932.00){ |
| 1327 |
|
cout<<"We found it while checking all quaternions"<<"\t"<<recqtime[mu]<<endl; |
| 1328 |
|
} |
| 1329 |
break; |
break; |
| 1330 |
} |
} |
| 1331 |
} |
} |
| 1357 |
for(Int_t mu = nt;mu<recSize;mu++){ |
for(Int_t mu = nt;mu<recSize;mu++){ |
| 1358 |
if(recqtime[mu]>lowerqtime && recqtime[mu]<u_time){ |
if(recqtime[mu]>lowerqtime && recqtime[mu]<u_time){ |
| 1359 |
if(sqrt(pow(recq0[mu],2)+pow(recq1[mu],2)+pow(recq2[mu],2)+pow(recq3[mu],2))>0.99999){ |
if(sqrt(pow(recq0[mu],2)+pow(recq1[mu],2)+pow(recq2[mu],2)+pow(recq3[mu],2))>0.99999){ |
| 1360 |
nt=mu; |
// nt=mu; |
| 1361 |
Int_t sizeqmcmd = qtime.size(); |
Int_t sizeqmcmd = qtime.size(); |
| 1362 |
inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw); |
inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw); |
| 1363 |
qtime[sizeqmcmd]=recqtime[mu]; |
qtime[sizeqmcmd]=recqtime[mu]; |
| 1371 |
qRoll[sizeqmcmd]=RYPang_upper->Kren; |
qRoll[sizeqmcmd]=RYPang_upper->Kren; |
| 1372 |
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
| 1373 |
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
| 1374 |
|
/* CHECK RECOVERED QUATERNIONS PROBLEM */ |
| 1375 |
|
if(recqtime[mu]>=1160987921.75 && recqtime[mu]<=1160987932.00){ |
| 1376 |
|
cout<<"We found it while checking all quaternions"<<"\t"<<recqtime[mu]<<endl; |
| 1377 |
|
} |
| 1378 |
} |
} |
| 1379 |
} |
} |
| 1380 |
if(recqtime[mu]>=u_time){ |
if(recqtime[mu]>=u_time){ |
| 1394 |
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
| 1395 |
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
| 1396 |
CopyQ(L_QQ_Q_l_lower,L_QQ_Q_l_upper); |
CopyQ(L_QQ_Q_l_lower,L_QQ_Q_l_upper); |
| 1397 |
|
/* CHECK RECOVERED QUATERNIONS PROBLEM */ |
| 1398 |
|
if(recqtime[mu]>=1160987921.75 && recqtime[mu]<=1160987932.00){ |
| 1399 |
|
cout<<"We found it while checking all quaternions"<<"\t"<<recqtime[mu]<<endl; |
| 1400 |
|
} |
| 1401 |
break; |
break; |
| 1402 |
} |
} |
| 1403 |
} |
} |
| 1512 |
orbitalinfo->q2 = incli*atime+q2[mu+1]-incli*qtime[mu+1]; |
orbitalinfo->q2 = incli*atime+q2[mu+1]-incli*qtime[mu+1]; |
| 1513 |
incli = (q3[mu+1]-q3[mu])/(qtime[mu+1]-qtime[mu]); |
incli = (q3[mu+1]-q3[mu])/(qtime[mu+1]-qtime[mu]); |
| 1514 |
orbitalinfo->q3 = incli*atime+q3[mu+1]-incli*qtime[mu+1]; |
orbitalinfo->q3 = incli*atime+q3[mu+1]-incli*qtime[mu+1]; |
| 1515 |
Float_t tg = (qtime[mu+1]-qtime[mu])/1000.; |
Float_t tg = (qtime[mu+1]-qtime[mu])/1000.0; |
| 1516 |
if(tg>=1) tg=0.00; |
if(tg>=1) tg=0.00; |
| 1517 |
orbitalinfo->TimeGap = TMath::Min(TMath::Abs(qtime[mu+1])-atime,TMath::Abs(atime-qtime[mu]))+tg;//qtime[mu+1]-qtime[mu]; |
orbitalinfo->TimeGap = TMath::Min(TMath::Abs(qtime[mu+1])-atime,TMath::Abs(atime-qtime[mu]))+tg;//qtime[mu+1]-qtime[mu]; |
| 1518 |
orbitalinfo->mode = qmode[mu+1]; |
orbitalinfo->mode = qmode[mu+1]; |
|
|
|
| 1519 |
//if(atime==qtime[mu] || atime==qtime[mu+1]) orbitalinfo->qkind = 0; else orbitalinfo->qkind=1; |
//if(atime==qtime[mu] || atime==qtime[mu+1]) orbitalinfo->qkind = 0; else orbitalinfo->qkind=1; |
| 1520 |
//if(qmode[mu+1]==-10) orbitalinfo->R10r = true;else orbitalinfo->R10r = false; |
//if(qmode[mu+1]==-10) orbitalinfo->R10r = true;else orbitalinfo->R10r = false; |
| 1521 |
if ( debug ) printf(" grfuffi4 %i \n",mu); |
if ( debug ) printf(" grfuffi4 %i \n",mu); |
|
|
|
| 1522 |
break; |
break; |
| 1523 |
} |
} |
| 1524 |
} |
} |
| 1579 |
|
|
| 1580 |
// 10REDNEW |
// 10REDNEW |
| 1581 |
Int_t errq=0; |
Int_t errq=0; |
| 1582 |
Int_t azim=0;; |
Int_t azim=0; |
| 1583 |
for(UInt_t mu = must;mu<RTtime2.size()-1;mu++){ |
Int_t qual=0; |
| 1584 |
if(atime<=RTtime2[mu] && atime>=RTtime1[mu]){ |
Int_t MU=0; |
| 1585 |
|
for(UInt_t mu = 0;mu<RTtime2.size()-1;mu++){ |
| 1586 |
|
if(atime<RTstart[mu+1] && atime>=RTstart[mu]){ |
| 1587 |
errq=RTerrq[mu]; |
errq=RTerrq[mu]; |
| 1588 |
azim=RTazim[mu]; |
azim=RTazim[mu]; |
| 1589 |
|
qual=RTqual[mu]; |
| 1590 |
|
MU=mu; |
| 1591 |
|
break; |
| 1592 |
} |
} |
| 1593 |
} |
} |
| 1594 |
orbitalinfo->errq = errq; |
orbitalinfo->errq = errq; |
| 1595 |
orbitalinfo->azim = azim; |
orbitalinfo->azim = azim; |
| 1596 |
|
orbitalinfo->rtqual=qual; |
| 1597 |
orbitalinfo->qkind = 0; |
orbitalinfo->qkind = 0; |
| 1598 |
|
|
| 1599 |
if ( debug ) printf(" coord done \n"); |
if ( debug ) printf(" coord done \n"); |
| 1640 |
orbitalinfo->cutoffsvl = 14.295 / (xl*xl); // |
orbitalinfo->cutoffsvl = 14.295 / (xl*xl); // |
| 1641 |
if(debug)cout << "L = " << xl << "\tM = " << dimo << "\tvertical cutoff: "<< orbitalinfo->cutoffsvl << endl; |
if(debug)cout << "L = " << xl << "\tM = " << dimo << "\tvertical cutoff: "<< orbitalinfo->cutoffsvl << endl; |
| 1642 |
|
|
| 1643 |
/* |
|
| 1644 |
---------- Forwarded message ---------- |
// ---------- Forwarded message ---------- |
| 1645 |
Date: Wed, 09 May 2012 12:16:47 +0200 |
// Date: Wed, 09 May 2012 12:16:47 +0200 |
| 1646 |
From: Alessandro Bruno <alessandro.bruno@ba.infn.it> |
// From: Alessandro Bruno <alessandro.bruno@ba.infn.it> |
| 1647 |
To: Mirko Boezio <mirko.boezio@ts.infn.it> |
// To: Mirko Boezio <mirko.boezio@ts.infn.it> |
| 1648 |
Cc: Francesco S. Cafagna <Francesco.Cafagna@ba.infn.it> |
// Cc: Francesco S. Cafagna <Francesco.Cafagna@ba.infn.it> |
| 1649 |
Subject: Störmer vertical cutoff |
// Subject: Störmer vertical cutoff |
| 1650 |
|
|
| 1651 |
Ciao Mirko, |
// Ciao Mirko, |
| 1652 |
volevo segnalarti che il valore dello Störmer vertical cutoff nel Level2 è |
// volevo segnalarti che il valore dello Störmer vertical cutoff nel Level2 è |
| 1653 |
sovrastimato di circa il 4%. |
// sovrastimato di circa il 4%. |
| 1654 |
Dopo un'approfondita analisi con l'IGRF-05 abbiamo ricavano un valore pari |
// Dopo un'approfondita analisi con l'IGRF-05 abbiamo ricavano un valore pari |
| 1655 |
a: 14.295 / L^2 anzichè 14.9 / L^2, valore obsoleto in quanto riferito agli |
// a: 14.295 / L^2 anzichè 14.9 / L^2, valore obsoleto in quanto riferito agli |
| 1656 |
anni '50. |
// anni '50. |
| 1657 |
*/ |
// |
| 1658 |
//14.9/(xl*xl); |
//14.9/(xl*xl); |
| 1659 |
orbitalinfo->igrf_icode = icode; |
orbitalinfo->igrf_icode = icode; |
| 1660 |
// |
// |
| 1671 |
Float_t By = orbitalinfo->Beast; |
Float_t By = orbitalinfo->Beast; |
| 1672 |
Float_t Bz = orbitalinfo->Bnorth; |
Float_t Bz = orbitalinfo->Bnorth; |
| 1673 |
|
|
| 1674 |
TMatrixD Qiji(3,3); |
// TMatrixD Qiji(3,3); |
| 1675 |
TMatrixD Qij = PO->QuatoECI(orbitalinfo->q0,orbitalinfo->q1,orbitalinfo->q2,orbitalinfo->q3); |
TMatrixD Qij = PO->QuatoECI(orbitalinfo->q0,orbitalinfo->q1,orbitalinfo->q2,orbitalinfo->q3); |
| 1676 |
TMatrixD Dij = PO->ECItoGEO(Qij,orbitalinfo->absTime,orbitalinfo->lat,orbitalinfo->lon); |
TMatrixD Dij = PO->ECItoGEO(Qij,orbitalinfo->absTime,orbitalinfo->lat,orbitalinfo->lon); |
| 1677 |
|
|
| 1678 |
//10REDNEW |
//10REDNEW |
| 1679 |
/* If initial orientation data have reason to be inaccurate */ |
// If initial orientation data have reason to be inaccurate |
| 1680 |
Double_t tg = 0; |
Float_t tg = 0.00; |
| 1681 |
cout<<modf(orbitalinfo->TimeGap,&tg)<<endl; |
Float_t tmptg; |
| 1682 |
|
if(MU!=0){ |
| 1683 |
// if(orbitalinfo->TimeGap>0 && errq==0 && azim==0){ // 10RED CHECK (comparison between three metod of recovering orientation) |
// if(orbitalinfo->TimeGap>0 && errq==0 && azim==0){ // 10RED CHECK (comparison between three metod of recovering orientation) |
| 1684 |
if(((orbitalinfo->TimeGap>60.0 && TMath::Abs(orbitalinfo->etha)>0.5) || errq!=0 || modf(orbitalinfo->TimeGap,&tg)*1000>700 || modf(orbitalinfo->TimeGap,&tg)*1000==0.0 ) && azim==0){ //Standard condition to use this; One of these two cases should be commented |
if((atime>=RTstart[MU] && atime<RTstart[MU+1] && RTbank1[MU]==0 && RTbank2[MU]==0 && TMath::Abs(orbitalinfo->etha)>0.1) || ((RTbank1[MU]!=0 || RTbank2[MU]!=0) && atime>=RTstart[MU] && atime<RTstart[MU+1] && azim==0 && (errq!=0 || orbitalinfo->TimeGap>10.0 || ((modf(orbitalinfo->TimeGap,&tmptg)*1000>10 || modf(orbitalinfo->TimeGap,&tmptg)*1000==0.0) && orbitalinfo->TimeGap>2.0)))){ |
| 1685 |
/* found in Rotation Table this data for this time interval*/ |
//found in Rotation Table this data for this time interval |
| 1686 |
if(atime<RTtime1[0]) |
if(atime<RTtime1[0]) |
| 1687 |
orbitalinfo->azim = 5; //means that RotationTable no started yet |
orbitalinfo->azim = 5; //means that RotationTable no started yet |
| 1688 |
else{ |
else{ |
|
for(UInt_t mu = must;mu<RTtime2.size()-1;mu++){ |
|
|
if(atime<=RTtime2[mu] && atime>=RTtime1[mu]){ |
|
| 1689 |
// search for angle betwean velosity and direction to north in tangential to Earth surfase plane in satellite position |
// search for angle betwean velosity and direction to north in tangential to Earth surfase plane in satellite position |
| 1690 |
|
Double_t bank=RTstart[MU]; |
| 1691 |
Double_t tlat=orbitalinfo->lat; |
Double_t tlat=orbitalinfo->lat; |
|
/* Double_t phint=(163.7-0.0002387*tlat-0.005802*tlat*tlat-0.005802e-7*tlat*tlat*tlat-1.776e-6*tlat*tlat*tlat*tlat+1.395e-10*tlat*tlat*tlat*tlat*tlat); |
|
|
Double_t phin=TMath::Abs(90.0*(1+diro)-phint); |
|
|
Double_t phi=TMath::Abs(90.0*(1-diro)-TMath::RadToDeg()*atan(TMath::Abs(tan(TMath::DegToRad()*phin))/sqrt(1+pow(tan(TMath::DegToRad()*tlat),2)))); |
|
|
|
|
|
//Get vectors of Satellite reference frame axis in GEO in satndard case (No rotations, all Euler angles equals to 0) |
|
|
TVector3 XDij(0,sin(TMath::DegToRad()*phi),cos(TMath::DegToRad()*phi)); |
|
|
TVector3 YDij(1,0,0); |
|
|
TVector3 ZDij(0,sin(TMath::DegToRad()*(phi+90)),cos(TMath::DegToRad()*(phi+90.0))); |
|
|
|
|
|
//Get Vectors to rotate about |
|
|
TVector3 B1 = V; |
|
|
B1.RotateZ(-lon*TMath::DegToRad()); |
|
|
B1.RotateY(lat*TMath::DegToRad()); |
|
|
Float_t elipangle=TMath::ACos((pow(B1.Y(),2)+pow(B1.Z(),2))/B1.Mag()/sqrt(pow(B1.Y(),2)+pow(B1.Z(),2))); |
|
|
TVector3 Tre(0,B1.Y(),B1.Z()); |
|
|
if(B1.X()<0) elipangle=-elipangle; |
|
|
TVector3 Vperp=B1; // axis to rotate around initial Dij on ellip and spitch angles |
|
|
Vperp.RotateX(TMath::Pi()/2.); |
|
|
Vperp.SetX(0); |
|
|
*/ Double_t kar=(RTbank2[mu]-RTbank1[mu])/(RTtime2[mu]-RTtime1[mu]); |
|
|
Double_t bak=RTbank1[mu]-kar*RTtime1[mu]; |
|
|
Double_t bank=kar*atime+bak; |
|
|
Float_t spitch = 0.00001; // temprary not zero to avoid problem with tranzition from Euler angles to orientation matrix |
|
| 1692 |
|
|
| 1693 |
//Estimations of pitch angle of satellite |
tg=modf(orbitalinfo->TimeGap,&tg)*1000; |
| 1694 |
if(TMath::Abs(bank)>0.7){ |
|
| 1695 |
Float_t spitch1=TMath::DegToRad()*0.7*RTdir1[mu]; |
if(atime>=RTpluto1[MU] && atime<=RTpluto2[MU]){ |
| 1696 |
Float_t spitch2=TMath::DegToRad()*0.7*RTdir2[mu]; |
Double_t kar=(RTbank2[MU]-RTbank1[MU])/(RTtime2[MU]-RTtime1[MU]); |
| 1697 |
Float_t kva=(spitch2-spitch1)/(RTtime2[mu]-RTtime1[mu]); |
Double_t bak=RTbank1[MU]-kar*RTtime1[MU]; |
| 1698 |
Float_t bva=spitch1-kva*RTtime1[mu]; |
bank=kar*atime+bak; |
|
spitch=kva*atime+bva; |
|
|
} |
|
|
/* //spitch=0.0; |
|
|
//Rotations future Dij matrix on ellip and spitch angles |
|
|
XDij.Rotate(-elipangle-spitch,Vperp); |
|
|
YDij.Rotate(-elipangle-spitch,Vperp); |
|
|
ZDij.Rotate(-elipangle-spitch,Vperp); |
|
|
|
|
|
//Rotation on bank angle; |
|
|
if(TMath::Abs(bank)>0.5){ |
|
|
XDij.Rotate(TMath::DegToRad()*bank,B1); |
|
|
YDij.Rotate(TMath::DegToRad()*bank,B1); |
|
|
ZDij.Rotate(TMath::DegToRad()*bank,B1); |
|
| 1699 |
} |
} |
| 1700 |
Dij(0,0)=XDij.X(); Dij(1,0)=XDij.Y(); Dij(2,0)=XDij.Z(); |
if(atime>=RTstart[MU] && atime<RTpluto1[MU]){ |
| 1701 |
Dij(0,1)=YDij.X(); Dij(1,1)=YDij.Y(); Dij(2,1)=YDij.Z(); |
Double_t s_dBdt2=(RTbpluto1[MU]-RTbank1[MU])/(Int_t)(RTpluto1[MU]-RTstart[MU]); |
| 1702 |
Dij(0,2)=ZDij.X(); Dij(1,2)=ZDij.Y(); Dij(2,2)=ZDij.Z(); |
Double_t s_t2=((Double_t)RTpluto1[MU]+(Double_t)RTstart[MU])/2. - RTstart[MU]; |
| 1703 |
*/ |
Double_t s_t1=RTstart[MU]-RTstart[MU]; |
| 1704 |
//Calculate Yaw angle accordingly with fit, see picture FitYaw.jpg |
Double_t s_k=s_dBdt2/(s_t2-s_t1); |
| 1705 |
Double_t yaw=0.00001; // temprary not zero to avoid problem with tranzition from Euler angles to orientation matrix |
Double_t s_b=-s_k*s_t1; |
| 1706 |
if(TMath::Abs(tlat)<70) |
Double_t s_t3=RTpluto1[MU]-RTstart[MU]; |
| 1707 |
yaw = -3.7e-8*tlat*tlat*tlat*tlat + 1.4e-7*tlat*tlat*tlat - 0.0005*tlat*tlat - 0.00025*tlat + 3.6; |
Double_t s_b3=RTbpluto1[MU]; |
| 1708 |
yaw = diro*yaw; //because should be different sign for ascending and descending orbits! |
Double_t s_c=s_b3-0.5*s_k*s_t3*s_t3 -s_b*s_t3; |
| 1709 |
|
bank=0.5*s_k*(atime-RTstart[MU])*(atime-RTstart[MU]) + s_b*(atime-RTstart[MU]) + s_c; |
| 1710 |
if(TMath::Abs(bank)>0.5 && TMath::Abs(yaw-orbitalinfo->phi)<3.0) yaw=orbitalinfo->phi; |
} |
| 1711 |
|
if(atime>RTpluto2[MU] && atime<=RTstart[MU+1]){ |
| 1712 |
// Qiji = PO->EulertoEci(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,bank,yaw,spitch); // 10RED CHECK |
Double_t s_dBdt2=(RTbpluto2[MU] - RTbank2[MU])/(Int_t)(RTpluto2[MU]-RTstart[MU+1]); |
| 1713 |
Qij = PO->EulertoEci(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,bank,yaw,spitch); // STANDARD |
Double_t s_t2=((Double_t)RTpluto2[MU]+(Double_t)RTstart[MU+1])/2. - RTstart[MU]; |
| 1714 |
orbitalinfo->qkind = 1; |
Double_t s_t1=RTstart[MU+1]-RTstart[MU]; |
| 1715 |
|
Double_t s_k=s_dBdt2/(s_t2-s_t1); |
| 1716 |
|
Double_t s_b=-s_k*s_t1; |
| 1717 |
|
Double_t s_t3=RTpluto2[MU]-RTstart[MU]; |
| 1718 |
|
Double_t s_b3=RTbpluto2[MU]; |
| 1719 |
|
Double_t s_c=s_b3-0.5*s_k*s_t3*s_t3 -s_b*s_t3; |
| 1720 |
|
bank=0.5*s_k*(atime-RTstart[MU])*(atime-RTstart[MU]) + s_b*(atime-RTstart[MU]) + s_c; |
| 1721 |
|
} |
| 1722 |
|
if(TMath::Abs(orbitalinfo->etha-bank)>0.1){ |
| 1723 |
|
orbitalinfo->etha=bank; |
| 1724 |
|
Double_t spitch = 0.00001; // temprary not zero to avoid problem with tranzition from Euler angles to orientation matrix |
| 1725 |
|
|
| 1726 |
break; |
//Estimations of pitch angle of satellite |
| 1727 |
} |
if(TMath::Abs(bank)>0.7){ |
| 1728 |
} // enf of loop for(UInt_t mu = must;mu<RTtime2.size()-1;mu++){ |
Float_t spitch1=TMath::DegToRad()*0.7*diro;//RTdir1[MU]; |
| 1729 |
|
Float_t spitch2=TMath::DegToRad()*0.7*diro;//RTdir2[MU]; |
| 1730 |
|
Float_t kva=(spitch2-spitch1)/(RTtime2[MU]-RTtime1[MU]); |
| 1731 |
|
Float_t bva=spitch1-kva*RTtime1[MU]; |
| 1732 |
|
spitch=kva*atime+bva; |
| 1733 |
|
} |
| 1734 |
|
|
| 1735 |
|
//Calculate Yaw angle accordingly with fit, see picture FitYaw.jpg |
| 1736 |
|
Double_t yaw=0.00001; // temprary not zero to avoid problem with tranzition from Euler angles to orientation matrix |
| 1737 |
|
if(TMath::Abs(tlat)<70) |
| 1738 |
|
yaw = -3.7e-8*tlat*tlat*tlat*tlat + 1.4e-7*tlat*tlat*tlat - 0.0005*tlat*tlat - 0.00025*tlat + 3.6; |
| 1739 |
|
yaw = diro*yaw; //because should be different sign for ascending and descending orbits! |
| 1740 |
|
orbitalinfo->phi=yaw; |
| 1741 |
|
|
| 1742 |
|
if(TMath::Abs(bank)>0.5 && TMath::Abs(yaw-orbitalinfo->phi)<3.0) yaw=orbitalinfo->phi; |
| 1743 |
|
|
| 1744 |
|
// Qiji = PO->EulertoEci(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,bank,yaw,spitch); // 10RED CHECK |
| 1745 |
|
Qij = PO->EulertoEci(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,bank,yaw,spitch); // STANDARD |
| 1746 |
|
orbitalinfo->qkind = 1; |
| 1747 |
|
} |
| 1748 |
|
|
| 1749 |
//Qij = PO->GEOtoECI(Dij,orbitalinfo->absTime,orbitalinfo->lat,orbitalinfo->lon); // to convert from Dij to Qij |
//Qij = PO->GEOtoECI(Dij,orbitalinfo->absTime,orbitalinfo->lat,orbitalinfo->lon); // to convert from Dij to Qij |
| 1750 |
|
|
| 1751 |
} // end of if(atime<RTtime1[0] |
} // end of if(atime<RTtime1[0] |
| 1752 |
} // end of f(((orbitalinfo->TimeGap>60.0 && TMath... |
} // end of (((orbitalinfo->TimeGap>60.0 && TMath... |
| 1753 |
|
} // end of MU~=0 |
| 1754 |
|
|
| 1755 |
TMatrixD qij = PO->ColPermutation(Qij); |
TMatrixD qij = PO->ColPermutation(Qij); |
| 1756 |
TMatrixD Fij = PO->ECItoGreenwich(Qij,orbitalinfo->absTime); |
TMatrixD Fij = PO->ECItoGreenwich(Qij,orbitalinfo->absTime); |
| 1781 |
// orbitalinfo->pamBangle = (Float_t)PO->GetPitchAngle(A1,A2,A3,Bx,By,Bz); // Angle between Pamela's main axiz and B |
// orbitalinfo->pamBangle = (Float_t)PO->GetPitchAngle(A1,A2,A3,Bx,By,Bz); // Angle between Pamela's main axiz and B |
| 1782 |
// |
// |
| 1783 |
if ( debug ) printf(" matrixes done \n"); |
if ( debug ) printf(" matrixes done \n"); |
| 1784 |
if ( !standalone && tof->ntrk() > 0 ){ |
if ( !standalone ){ |
| 1785 |
if ( debug ) printf(" !standalone \n"); |
if ( debug ) printf(" !standalone \n"); |
| 1786 |
// |
// |
| 1787 |
|
// Standard tracking algorithm |
| 1788 |
|
// |
| 1789 |
Int_t nn = 0; |
Int_t nn = 0; |
| 1790 |
|
if ( verbose ) printf(" standard tracking \n"); |
| 1791 |
for(Int_t nt=0; nt < tof->ntrk(); nt++){ |
for(Int_t nt=0; nt < tof->ntrk(); nt++){ |
| 1792 |
// |
// |
| 1793 |
ToFTrkVar *ptt = tof->GetToFTrkVar(nt); |
ToFTrkVar *ptt = tof->GetToFTrkVar(nt); |
| 1802 |
TrkTrack *mytrack = trke->GetStoredTrack(ptt->trkseqno); |
TrkTrack *mytrack = trke->GetStoredTrack(ptt->trkseqno); |
| 1803 |
Float_t rig=1/mytrack->GetDeflection(); |
Float_t rig=1/mytrack->GetDeflection(); |
| 1804 |
Double_t norm = sqrt(pow(E22x-E11x,2)+pow(E22y-E11y,2)+pow(E22z-E11z,2)); |
Double_t norm = sqrt(pow(E22x-E11x,2)+pow(E22y-E11y,2)+pow(E22z-E11z,2)); |
| 1805 |
// Double_t MyAzim = TMath::RadToDeg()*atan(TMath::Abs(E22y-E11y)/TMath::Abs(E22x-E11x)); |
// |
|
// if(E22x-E11x>=0 && E22y-E11y <0) MyAzim = 360. - MyAzim; |
|
|
// if(E22x-E11x>=0 && E22y-E11y >=0) MyAzim = MyAzim; |
|
|
// if(E22x-E11x<0 && E22y-E11y >0) MyAzim = 180. - MyAzim; |
|
|
// if(E22x-E11x<0 && E22y-E11y <0) MyAzim = 180. + MyAzim; |
|
| 1806 |
Px = (E22x-E11x)/norm; |
Px = (E22x-E11x)/norm; |
| 1807 |
Py = (E22y-E11y)/norm; |
Py = (E22y-E11y)/norm; |
| 1808 |
Pz = (E22z-E11z)/norm; |
Pz = (E22z-E11z)/norm; |
| 1819 |
// |
// |
| 1820 |
t_orb->pitch = (Float_t)PO->GetPitchAngle(Eij(0,0),Eij(1,0),Eij(2,0),Bx,By,Bz); |
t_orb->pitch = (Float_t)PO->GetPitchAngle(Eij(0,0),Eij(1,0),Eij(2,0),Bx,By,Bz); |
| 1821 |
// |
// |
| 1822 |
// SunPosition in instrumental reference frame |
// SunPosition in instrumental reference frame |
| 1823 |
TMatrixD Kij = PO->PamelatoGEO(qij,Px,Py,Pz); |
TMatrixD Kij = PO->PamelatoGEO(qij,Px,Py,Pz); |
| 1824 |
TMatrixD Lij = PO->PamelatoGEO(qij,0,0,1); |
TMatrixD Lij = PO->PamelatoGEO(qij,0,0,1); |
| 1825 |
t_orb->sunangle=(Float_t)PO->GetPitchAngle(Kij(0,0),Kij(1,0),Kij(2,0),-SP.X(),-SP.Y(),-SP.Z()); |
t_orb->sunangle=(Float_t)PO->GetPitchAngle(Kij(0,0),Kij(1,0),Kij(2,0),-SP.X(),-SP.Y(),-SP.Z()); |
| 1826 |
t_orb->sunmagangle=(Float_t)PO->GetPitchAngle(Kij(0,0),Kij(1,0),Kij(2,0),SunMag.X(),SunMag.Y(),SunMag.Z()); |
t_orb->sunmagangle=(Float_t)PO->GetPitchAngle(Kij(0,0),Kij(1,0),Kij(2,0),SunMag.X(),SunMag.Y(),SunMag.Z()); |
|
|
|
| 1827 |
// |
// |
| 1828 |
// |
// |
|
//Double_t omega = PO->GetPitchAngle(Eij(0,0),Eij(1,0),Eij(2,0),cos(orbitalinfo->lon+TMath::Pi()/2)-sin(orbitalinfo->lon+TMath::Pi()/2),cos(orbitalinfo->lon+TMath::Pi()/2)+sin(orbitalinfo->lon+TMath::Pi()/2),1); |
|
| 1829 |
Double_t omega = PO->GetPitchAngle(-Eij(0,0),-Eij(1,0),-Eij(2,0),1,0,0) * TMath::DegToRad(); |
Double_t omega = PO->GetPitchAngle(-Eij(0,0),-Eij(1,0),-Eij(2,0),1,0,0) * TMath::DegToRad(); |
| 1830 |
TVector3 Bxy(0,By,Bz); |
TVector3 Bxy(0,By,Bz); |
| 1831 |
TVector3 Exy(0,-Eij(1,0),-Eij(2,0)); |
TVector3 Exy(0,-Eij(1,0),-Eij(2,0)); |
| 1832 |
Double_t dzeta=Bxy.Angle(Exy); |
Double_t dzeta=Bxy.Angle(Exy); |
| 1833 |
if (-Eij(1,0) < 0) dzeta=2.0*TMath::Pi() - dzeta; |
if (-Eij(1,0) < 0) dzeta=2.0*TMath::Pi() - dzeta; |
| 1834 |
|
|
| 1835 |
|
if(debug) cout << "omega = "<<omega*TMath::RadToDeg()<<"\tdzeta = "<<dzeta*TMath::RadToDeg()<<endl; |
| 1836 |
|
|
| 1837 |
if(debug) cout << "omega = "<<omega*TMath::RadToDeg()<<"\tdzeta = "<<dzeta*TMath::RadToDeg()<<endl; |
// Formula from D.F. Smart *, M.A. Shea [2005]; A review of geomagnetic cutoff rigidities for earth-orbiting spacecraft |
|
|
|
|
// Formula from D.F. Smart *, M.A. Shea [2005]; A review of geomagnetic cutoff rigidities for earth-orbiting spacecraft |
|
| 1838 |
if(rig>=0) t_orb->cutoff = 59.3/(pow(orbitalinfo->L,2)*pow(1+sqrt(1-sin(omega)*sin(dzeta)*pow(cos(orbitalinfo->lat*TMath::DegToRad()),3)),2)); |
if(rig>=0) t_orb->cutoff = 59.3/(pow(orbitalinfo->L,2)*pow(1+sqrt(1-sin(omega)*sin(dzeta)*pow(cos(orbitalinfo->lat*TMath::DegToRad()),3)),2)); |
| 1839 |
else t_orb->cutoff = 59.3/(pow(orbitalinfo->L,2)*pow(1+sqrt(1-sin(omega)*sin(TMath::Pi()+dzeta)*pow(cos(orbitalinfo->lat*TMath::DegToRad()),3)),2)); |
else t_orb->cutoff = 59.3/(pow(orbitalinfo->L,2)*pow(1+sqrt(1-sin(omega)*sin(TMath::Pi()+dzeta)*pow(cos(orbitalinfo->lat*TMath::DegToRad()),3)),2)); |
| 1840 |
if (debug) cout << "R = " << rig << "\tcutoff = " << t_orb->cutoff << endl; |
if (debug) cout << "R = " << rig << "\tcutoff = " << t_orb->cutoff << endl; |
| 1841 |
|
|
|
//t_orb->cutoff = 59.3/(pow(orbitalinfo->L,2)*pow((1+sqrt(1-pow(orbitalinfo->L,-3/2)*cos(omega))),2)); |
|
|
|
|
| 1842 |
// |
// |
| 1843 |
if ( t_orb->pitch != t_orb->pitch ) t_orb->pitch = -1000.; |
if ( t_orb->pitch != t_orb->pitch ) t_orb->pitch = -1000.; |
| 1844 |
if ( t_orb->cutoff != t_orb->cutoff ) t_orb->cutoff = -1000.; |
if ( t_orb->cutoff != t_orb->cutoff ) t_orb->cutoff = -1000.; |
| 1852 |
// |
// |
| 1853 |
t_orb->Clear(); |
t_orb->Clear(); |
| 1854 |
// |
// |
| 1855 |
}; |
} |
| 1856 |
// |
// |
| 1857 |
}; |
} // end standard tracking algorithm |
| 1858 |
|
|
| 1859 |
|
// |
| 1860 |
|
// Code for extended tracking algorithm: |
| 1861 |
|
// |
| 1862 |
|
if ( hasNucleiTrk ){ |
| 1863 |
|
Int_t ttentry = 0; |
| 1864 |
|
if ( verbose ) printf(" hasNucleiTrk \n"); |
| 1865 |
|
for(Int_t nt=0; nt < tcNucleiTof->GetEntries() ; nt++){ |
| 1866 |
|
// |
| 1867 |
|
if ( verbose ) printf(" got1\n"); |
| 1868 |
|
ToFTrkVar *ptt = (ToFTrkVar*)(tcNucleiTof->At(nt)); |
| 1869 |
|
if (verbose) cout<<" tcNucleiTof->GetEntries() = "<<tcNucleiTof->GetEntries()<<"\tptt->trkseqno = "<<ptt->trkseqno<<endl; |
| 1870 |
|
Double_t E11x = ptt->xtr_tof[0]; // tr->x[0]; |
| 1871 |
|
Double_t E11y = ptt->ytr_tof[0]; //tr->y[0]; |
| 1872 |
|
Double_t E11z = zin[0]; |
| 1873 |
|
Double_t E22x = ptt->xtr_tof[3];//tr->x[3]; |
| 1874 |
|
Double_t E22y = ptt->ytr_tof[3];//tr->y[3]; |
| 1875 |
|
Double_t E22z = zin[3]; |
| 1876 |
|
if ( (E11x < 100. && E11y < 100. && E22x < 100. && E22y < 100.) || ptt->trkseqno != -1 ){ |
| 1877 |
|
TrkTrack *mytrack = (TrkTrack*)(tcNucleiTrk->At(ptt->trkseqno)); |
| 1878 |
|
if ( verbose ) printf(" got tcNucleiTrk \n"); |
| 1879 |
|
Float_t rig=1/mytrack->GetDeflection(); |
| 1880 |
|
Double_t norm = sqrt(pow(E22x-E11x,2)+pow(E22y-E11y,2)+pow(E22z-E11z,2)); |
| 1881 |
|
// |
| 1882 |
|
Px = (E22x-E11x)/norm; |
| 1883 |
|
Py = (E22y-E11y)/norm; |
| 1884 |
|
Pz = (E22z-E11z)/norm; |
| 1885 |
|
// |
| 1886 |
|
t_orb->trkseqno = ptt->trkseqno; |
| 1887 |
|
// |
| 1888 |
|
TMatrixD Eij = PO->PamelatoGEO(Iij,Px,Py,Pz); |
| 1889 |
|
t_orb->Eij.ResizeTo(Eij); |
| 1890 |
|
t_orb->Eij = Eij; |
| 1891 |
|
// |
| 1892 |
|
TMatrixD Sij = PO->PamelatoGEO(Gij,Px,Py,Pz); |
| 1893 |
|
t_orb->Sij.ResizeTo(Sij); |
| 1894 |
|
t_orb->Sij = Sij; |
| 1895 |
|
// |
| 1896 |
|
t_orb->pitch = (Float_t)PO->GetPitchAngle(Eij(0,0),Eij(1,0),Eij(2,0),Bx,By,Bz); |
| 1897 |
|
// |
| 1898 |
|
// SunPosition in instrumental reference frame |
| 1899 |
|
TMatrixD Kij = PO->PamelatoGEO(qij,Px,Py,Pz); |
| 1900 |
|
TMatrixD Lij = PO->PamelatoGEO(qij,0,0,1); |
| 1901 |
|
t_orb->sunangle=(Float_t)PO->GetPitchAngle(Kij(0,0),Kij(1,0),Kij(2,0),-SP.X(),-SP.Y(),-SP.Z()); |
| 1902 |
|
t_orb->sunmagangle=(Float_t)PO->GetPitchAngle(Kij(0,0),Kij(1,0),Kij(2,0),SunMag.X(),SunMag.Y(),SunMag.Z()); |
| 1903 |
|
// |
| 1904 |
|
// |
| 1905 |
|
Double_t omega = PO->GetPitchAngle(-Eij(0,0),-Eij(1,0),-Eij(2,0),1,0,0) * TMath::DegToRad(); |
| 1906 |
|
TVector3 Bxy(0,By,Bz); |
| 1907 |
|
TVector3 Exy(0,-Eij(1,0),-Eij(2,0)); |
| 1908 |
|
Double_t dzeta=Bxy.Angle(Exy); |
| 1909 |
|
if (-Eij(1,0) < 0) dzeta=2.0*TMath::Pi() - dzeta; |
| 1910 |
|
|
| 1911 |
|
if(debug) cout << "omega = "<<omega*TMath::RadToDeg()<<"\tdzeta = "<<dzeta*TMath::RadToDeg()<<endl; |
| 1912 |
|
|
| 1913 |
|
// Formula from D.F. Smart *, M.A. Shea [2005]; A review of geomagnetic cutoff rigidities for earth-orbiting spacecraft |
| 1914 |
|
if(rig>=0) t_orb->cutoff = 59.3/(pow(orbitalinfo->L,2)*pow(1+sqrt(1-sin(omega)*sin(dzeta)*pow(cos(orbitalinfo->lat*TMath::DegToRad()),3)),2)); |
| 1915 |
|
else t_orb->cutoff = 59.3/(pow(orbitalinfo->L,2)*pow(1+sqrt(1-sin(omega)*sin(TMath::Pi()+dzeta)*pow(cos(orbitalinfo->lat*TMath::DegToRad()),3)),2)); |
| 1916 |
|
if (debug) cout << "R = " << rig << "\tcutoff = " << t_orb->cutoff << endl; |
| 1917 |
|
|
| 1918 |
|
// |
| 1919 |
|
if ( t_orb->pitch != t_orb->pitch ) t_orb->pitch = -1000.; |
| 1920 |
|
if ( t_orb->cutoff != t_orb->cutoff ) t_orb->cutoff = -1000.; |
| 1921 |
|
if ( t_orb->sunangle != t_orb->sunangle ) t_orb->sunangle = -1000.; |
| 1922 |
|
if ( t_orb->sunmagangle != t_orb->sunmagangle ) t_orb->sunmagangle = -1000.; |
| 1923 |
|
// |
| 1924 |
|
if ( debug ) printf(" orbitalinfo->cutoffsvl %f vitaly %f \n",orbitalinfo->cutoffsvl,t_orb->cutoff); |
| 1925 |
|
// |
| 1926 |
|
TClonesArray &tt1 = *torbNucleiTrk; |
| 1927 |
|
new(tt1[ttentry]) OrbitalInfoTrkVar(*t_orb); |
| 1928 |
|
ttentry++; |
| 1929 |
|
// |
| 1930 |
|
t_orb->Clear(); |
| 1931 |
|
// |
| 1932 |
|
} |
| 1933 |
|
// |
| 1934 |
|
} |
| 1935 |
|
} // end standard tracking algorithm: nuclei |
| 1936 |
|
if ( hasExtNucleiTrk ){ |
| 1937 |
|
Int_t ttentry = 0; |
| 1938 |
|
if ( verbose ) printf(" hasExtNucleiTrk \n"); |
| 1939 |
|
for(Int_t nt=0; nt < tcExtNucleiTof->GetEntries() ; nt++){ |
| 1940 |
|
// |
| 1941 |
|
if ( verbose ) printf(" got2\n"); |
| 1942 |
|
ToFTrkVar *ptt = (ToFTrkVar*)(tcExtNucleiTof->At(nt)); |
| 1943 |
|
if (verbose) cout<<" tcExtNucleiTof->GetEntries() = "<<tcExtNucleiTof->GetEntries()<<"\tptt->trkseqno = "<<ptt->trkseqno<<endl; |
| 1944 |
|
Double_t E11x = ptt->xtr_tof[0]; // tr->x[0]; |
| 1945 |
|
Double_t E11y = ptt->ytr_tof[0]; //tr->y[0]; |
| 1946 |
|
Double_t E11z = zin[0]; |
| 1947 |
|
Double_t E22x = ptt->xtr_tof[3];//tr->x[3]; |
| 1948 |
|
Double_t E22y = ptt->ytr_tof[3];//tr->y[3]; |
| 1949 |
|
Double_t E22z = zin[3]; |
| 1950 |
|
if ( (E11x < 100. && E11y < 100. && E22x < 100. && E22y < 100.) || ptt->trkseqno != -1 ){ |
| 1951 |
|
ExtTrack *mytrack = (ExtTrack*)(tcExtNucleiTrk->At(ptt->trkseqno)); |
| 1952 |
|
if ( verbose ) printf(" got tcExtNucleiTrk \n"); |
| 1953 |
|
Float_t rig=1/mytrack->GetDeflection(); |
| 1954 |
|
Double_t norm = sqrt(pow(E22x-E11x,2)+pow(E22y-E11y,2)+pow(E22z-E11z,2)); |
| 1955 |
|
// |
| 1956 |
|
Px = (E22x-E11x)/norm; |
| 1957 |
|
Py = (E22y-E11y)/norm; |
| 1958 |
|
Pz = (E22z-E11z)/norm; |
| 1959 |
|
// |
| 1960 |
|
t_orb->trkseqno = ptt->trkseqno; |
| 1961 |
|
// |
| 1962 |
|
TMatrixD Eij = PO->PamelatoGEO(Iij,Px,Py,Pz); |
| 1963 |
|
t_orb->Eij.ResizeTo(Eij); |
| 1964 |
|
t_orb->Eij = Eij; |
| 1965 |
|
// |
| 1966 |
|
TMatrixD Sij = PO->PamelatoGEO(Gij,Px,Py,Pz); |
| 1967 |
|
t_orb->Sij.ResizeTo(Sij); |
| 1968 |
|
t_orb->Sij = Sij; |
| 1969 |
|
// |
| 1970 |
|
t_orb->pitch = (Float_t)PO->GetPitchAngle(Eij(0,0),Eij(1,0),Eij(2,0),Bx,By,Bz); |
| 1971 |
|
// |
| 1972 |
|
// SunPosition in instrumental reference frame |
| 1973 |
|
TMatrixD Kij = PO->PamelatoGEO(qij,Px,Py,Pz); |
| 1974 |
|
TMatrixD Lij = PO->PamelatoGEO(qij,0,0,1); |
| 1975 |
|
t_orb->sunangle=(Float_t)PO->GetPitchAngle(Kij(0,0),Kij(1,0),Kij(2,0),-SP.X(),-SP.Y(),-SP.Z()); |
| 1976 |
|
t_orb->sunmagangle=(Float_t)PO->GetPitchAngle(Kij(0,0),Kij(1,0),Kij(2,0),SunMag.X(),SunMag.Y(),SunMag.Z()); |
| 1977 |
|
// |
| 1978 |
|
// |
| 1979 |
|
Double_t omega = PO->GetPitchAngle(-Eij(0,0),-Eij(1,0),-Eij(2,0),1,0,0) * TMath::DegToRad(); |
| 1980 |
|
TVector3 Bxy(0,By,Bz); |
| 1981 |
|
TVector3 Exy(0,-Eij(1,0),-Eij(2,0)); |
| 1982 |
|
Double_t dzeta=Bxy.Angle(Exy); |
| 1983 |
|
if (-Eij(1,0) < 0) dzeta=2.0*TMath::Pi() - dzeta; |
| 1984 |
|
|
| 1985 |
|
if(debug) cout << "omega = "<<omega*TMath::RadToDeg()<<"\tdzeta = "<<dzeta*TMath::RadToDeg()<<endl; |
| 1986 |
|
|
| 1987 |
|
// Formula from D.F. Smart *, M.A. Shea [2005]; A review of geomagnetic cutoff rigidities for earth-orbiting spacecraft |
| 1988 |
|
if(rig>=0) t_orb->cutoff = 59.3/(pow(orbitalinfo->L,2)*pow(1+sqrt(1-sin(omega)*sin(dzeta)*pow(cos(orbitalinfo->lat*TMath::DegToRad()),3)),2)); |
| 1989 |
|
else t_orb->cutoff = 59.3/(pow(orbitalinfo->L,2)*pow(1+sqrt(1-sin(omega)*sin(TMath::Pi()+dzeta)*pow(cos(orbitalinfo->lat*TMath::DegToRad()),3)),2)); |
| 1990 |
|
if (debug) cout << "R = " << rig << "\tcutoff = " << t_orb->cutoff << endl; |
| 1991 |
|
|
| 1992 |
|
// |
| 1993 |
|
if ( t_orb->pitch != t_orb->pitch ) t_orb->pitch = -1000.; |
| 1994 |
|
if ( t_orb->cutoff != t_orb->cutoff ) t_orb->cutoff = -1000.; |
| 1995 |
|
if ( t_orb->sunangle != t_orb->sunangle ) t_orb->sunangle = -1000.; |
| 1996 |
|
if ( t_orb->sunmagangle != t_orb->sunmagangle ) t_orb->sunmagangle = -1000.; |
| 1997 |
|
// |
| 1998 |
|
if ( debug ) printf(" orbitalinfo->cutoffsvl %f vitaly %f \n",orbitalinfo->cutoffsvl,t_orb->cutoff); |
| 1999 |
|
// |
| 2000 |
|
TClonesArray &tt2 = *torbExtNucleiTrk; |
| 2001 |
|
new(tt2[ttentry]) OrbitalInfoTrkVar(*t_orb); |
| 2002 |
|
ttentry++; |
| 2003 |
|
// |
| 2004 |
|
t_orb->Clear(); |
| 2005 |
|
// |
| 2006 |
|
} |
| 2007 |
|
// |
| 2008 |
|
} |
| 2009 |
|
} // end standard tracking algorithm: nuclei extended |
| 2010 |
|
if ( hasExtTrk ){ |
| 2011 |
|
Int_t ttentry = 0; |
| 2012 |
|
if ( verbose ) printf(" hasExtTrk \n"); |
| 2013 |
|
for(Int_t nt=0; nt < tcExtTof->GetEntries() ; nt++){ |
| 2014 |
|
// |
| 2015 |
|
if ( verbose ) printf(" got3\n"); |
| 2016 |
|
ToFTrkVar *ptt = (ToFTrkVar*)(tcExtTof->At(nt)); |
| 2017 |
|
if (verbose) cout<<" tcExtTof->GetEntries() = "<<tcExtTof->GetEntries()<<"\tptt->trkseqno = "<<ptt->trkseqno<<endl; |
| 2018 |
|
Double_t E11x = ptt->xtr_tof[0]; // tr->x[0]; |
| 2019 |
|
Double_t E11y = ptt->ytr_tof[0]; //tr->y[0]; |
| 2020 |
|
Double_t E11z = zin[0]; |
| 2021 |
|
Double_t E22x = ptt->xtr_tof[3];//tr->x[3]; |
| 2022 |
|
Double_t E22y = ptt->ytr_tof[3];//tr->y[3]; |
| 2023 |
|
Double_t E22z = zin[3]; |
| 2024 |
|
if ( (E11x < 100. && E11y < 100. && E22x < 100. && E22y < 100.) || ptt->trkseqno != -1 ){ |
| 2025 |
|
ExtTrack *mytrack = (ExtTrack*)(tcExtTrk->At(ptt->trkseqno)); |
| 2026 |
|
if ( verbose ) printf(" got tcExtTrk \n"); |
| 2027 |
|
Float_t rig=1/mytrack->GetDeflection(); |
| 2028 |
|
Double_t norm = sqrt(pow(E22x-E11x,2)+pow(E22y-E11y,2)+pow(E22z-E11z,2)); |
| 2029 |
|
// |
| 2030 |
|
Px = (E22x-E11x)/norm; |
| 2031 |
|
Py = (E22y-E11y)/norm; |
| 2032 |
|
Pz = (E22z-E11z)/norm; |
| 2033 |
|
// |
| 2034 |
|
t_orb->trkseqno = ptt->trkseqno; |
| 2035 |
|
// |
| 2036 |
|
TMatrixD Eij = PO->PamelatoGEO(Iij,Px,Py,Pz); |
| 2037 |
|
t_orb->Eij.ResizeTo(Eij); |
| 2038 |
|
t_orb->Eij = Eij; |
| 2039 |
|
// |
| 2040 |
|
TMatrixD Sij = PO->PamelatoGEO(Gij,Px,Py,Pz); |
| 2041 |
|
t_orb->Sij.ResizeTo(Sij); |
| 2042 |
|
t_orb->Sij = Sij; |
| 2043 |
|
// |
| 2044 |
|
t_orb->pitch = (Float_t)PO->GetPitchAngle(Eij(0,0),Eij(1,0),Eij(2,0),Bx,By,Bz); |
| 2045 |
|
// |
| 2046 |
|
// SunPosition in instrumental reference frame |
| 2047 |
|
TMatrixD Kij = PO->PamelatoGEO(qij,Px,Py,Pz); |
| 2048 |
|
TMatrixD Lij = PO->PamelatoGEO(qij,0,0,1); |
| 2049 |
|
t_orb->sunangle=(Float_t)PO->GetPitchAngle(Kij(0,0),Kij(1,0),Kij(2,0),-SP.X(),-SP.Y(),-SP.Z()); |
| 2050 |
|
t_orb->sunmagangle=(Float_t)PO->GetPitchAngle(Kij(0,0),Kij(1,0),Kij(2,0),SunMag.X(),SunMag.Y(),SunMag.Z()); |
| 2051 |
|
// |
| 2052 |
|
// |
| 2053 |
|
Double_t omega = PO->GetPitchAngle(-Eij(0,0),-Eij(1,0),-Eij(2,0),1,0,0) * TMath::DegToRad(); |
| 2054 |
|
TVector3 Bxy(0,By,Bz); |
| 2055 |
|
TVector3 Exy(0,-Eij(1,0),-Eij(2,0)); |
| 2056 |
|
Double_t dzeta=Bxy.Angle(Exy); |
| 2057 |
|
if (-Eij(1,0) < 0) dzeta=2.0*TMath::Pi() - dzeta; |
| 2058 |
|
|
| 2059 |
|
if(debug) cout << "omega = "<<omega*TMath::RadToDeg()<<"\tdzeta = "<<dzeta*TMath::RadToDeg()<<endl; |
| 2060 |
|
|
| 2061 |
|
// Formula from D.F. Smart *, M.A. Shea [2005]; A review of geomagnetic cutoff rigidities for earth-orbiting spacecraft |
| 2062 |
|
if(rig>=0) t_orb->cutoff = 59.3/(pow(orbitalinfo->L,2)*pow(1+sqrt(1-sin(omega)*sin(dzeta)*pow(cos(orbitalinfo->lat*TMath::DegToRad()),3)),2)); |
| 2063 |
|
else t_orb->cutoff = 59.3/(pow(orbitalinfo->L,2)*pow(1+sqrt(1-sin(omega)*sin(TMath::Pi()+dzeta)*pow(cos(orbitalinfo->lat*TMath::DegToRad()),3)),2)); |
| 2064 |
|
if (debug) cout << "R = " << rig << "\tcutoff = " << t_orb->cutoff << endl; |
| 2065 |
|
|
| 2066 |
|
// |
| 2067 |
|
if ( t_orb->pitch != t_orb->pitch ) t_orb->pitch = -1000.; |
| 2068 |
|
if ( t_orb->cutoff != t_orb->cutoff ) t_orb->cutoff = -1000.; |
| 2069 |
|
if ( t_orb->sunangle != t_orb->sunangle ) t_orb->sunangle = -1000.; |
| 2070 |
|
if ( t_orb->sunmagangle != t_orb->sunmagangle ) t_orb->sunmagangle = -1000.; |
| 2071 |
|
// |
| 2072 |
|
if ( debug ) printf(" orbitalinfo->cutoffsvl %f vitaly %f \n",orbitalinfo->cutoffsvl,t_orb->cutoff); |
| 2073 |
|
// |
| 2074 |
|
TClonesArray &tt3 = *torbExtTrk; |
| 2075 |
|
new(tt3[ttentry]) OrbitalInfoTrkVar(*t_orb); |
| 2076 |
|
ttentry++; |
| 2077 |
|
// |
| 2078 |
|
t_orb->Clear(); |
| 2079 |
|
// |
| 2080 |
|
} |
| 2081 |
|
// |
| 2082 |
|
} |
| 2083 |
|
} // end standard tracking algorithm: extended |
| 2084 |
|
|
| 2085 |
} else { |
} else { |
| 2086 |
if ( debug ) printf(" mmm... mode %u standalone \n",orbitalinfo->mode); |
if ( debug ) printf(" mmm... mode %u standalone \n",orbitalinfo->mode); |
| 2087 |
} |
} |
| 2088 |
// |
// |
| 2089 |
} else { |
} else { // HERE IT MISS ALL CODE FOR EXTENDED TRACKING! |
| 2090 |
if ( !standalone && tof->ntrk() > 0 ){ |
if ( !standalone ){ |
| 2091 |
// |
// |
| 2092 |
|
if ( verbose ) printf(" no orb info for tracks \n"); |
| 2093 |
Int_t nn = 0; |
Int_t nn = 0; |
| 2094 |
for(Int_t nt=0; nt < tof->ntrk(); nt++){ |
for(Int_t nt=0; nt < tof->ntrk(); nt++){ |
| 2095 |
// |
// |
| 2115 |
// |
// |
| 2116 |
t_orb->Clear(); |
t_orb->Clear(); |
| 2117 |
// |
// |
| 2118 |
}; |
} |
| 2119 |
// |
// |
| 2120 |
}; |
} |
| 2121 |
}; |
// |
| 2122 |
}; // if( orbitalinfo->TimeGap>0){ |
// Code for extended tracking algorithm: |
| 2123 |
|
// |
| 2124 |
|
if ( hasNucleiTrk ){ |
| 2125 |
|
Int_t ttentry = 0; |
| 2126 |
|
if ( verbose ) printf(" hasNucleiTrk \n"); |
| 2127 |
|
for(Int_t nt=0; nt < tcNucleiTof->GetEntries() ; nt++){ |
| 2128 |
|
// |
| 2129 |
|
ToFTrkVar *ptt = (ToFTrkVar*)(tcNucleiTof->At(nt)); |
| 2130 |
|
if ( ptt->trkseqno != -1 ){ |
| 2131 |
|
// |
| 2132 |
|
t_orb->trkseqno = ptt->trkseqno; |
| 2133 |
|
// |
| 2134 |
|
t_orb->Eij = 0; |
| 2135 |
|
// |
| 2136 |
|
t_orb->Sij = 0; |
| 2137 |
|
// |
| 2138 |
|
t_orb->pitch = -1000.; |
| 2139 |
|
// |
| 2140 |
|
t_orb->sunangle = -1000.; |
| 2141 |
|
// |
| 2142 |
|
t_orb->sunmagangle = -1000; |
| 2143 |
|
// |
| 2144 |
|
t_orb->cutoff = -1000.; |
| 2145 |
|
// |
| 2146 |
|
TClonesArray &tz1 = *torbNucleiTrk; |
| 2147 |
|
new(tz1[ttentry]) OrbitalInfoTrkVar(*t_orb); |
| 2148 |
|
ttentry++; |
| 2149 |
|
// |
| 2150 |
|
t_orb->Clear(); |
| 2151 |
|
// |
| 2152 |
|
} |
| 2153 |
|
// |
| 2154 |
|
} |
| 2155 |
|
} |
| 2156 |
|
if ( hasExtNucleiTrk ){ |
| 2157 |
|
Int_t ttentry = 0; |
| 2158 |
|
if ( verbose ) printf(" hasExtNucleiTrk \n"); |
| 2159 |
|
for(Int_t nt=0; nt < tcExtNucleiTof->GetEntries() ; nt++){ |
| 2160 |
|
// |
| 2161 |
|
if ( verbose ) printf(" got2\n"); |
| 2162 |
|
ToFTrkVar *ptt = (ToFTrkVar*)(tcExtNucleiTof->At(nt)); |
| 2163 |
|
if ( ptt->trkseqno != -1 ){ |
| 2164 |
|
// |
| 2165 |
|
t_orb->trkseqno = ptt->trkseqno; |
| 2166 |
|
// |
| 2167 |
|
t_orb->Eij = 0; |
| 2168 |
|
// |
| 2169 |
|
t_orb->Sij = 0; |
| 2170 |
|
// |
| 2171 |
|
t_orb->pitch = -1000.; |
| 2172 |
|
// |
| 2173 |
|
t_orb->sunangle = -1000.; |
| 2174 |
|
// |
| 2175 |
|
t_orb->sunmagangle = -1000; |
| 2176 |
|
// |
| 2177 |
|
t_orb->cutoff = -1000.; |
| 2178 |
|
// |
| 2179 |
|
TClonesArray &tz2 = *torbExtNucleiTrk; |
| 2180 |
|
new(tz2[ttentry]) OrbitalInfoTrkVar(*t_orb); |
| 2181 |
|
ttentry++; |
| 2182 |
|
// |
| 2183 |
|
t_orb->Clear(); |
| 2184 |
|
// |
| 2185 |
|
} |
| 2186 |
|
// |
| 2187 |
|
} |
| 2188 |
|
} |
| 2189 |
|
if ( hasExtTrk ){ |
| 2190 |
|
Int_t ttentry = 0; |
| 2191 |
|
if ( verbose ) printf(" hasExtTrk \n"); |
| 2192 |
|
for(Int_t nt=0; nt < tcExtTof->GetEntries() ; nt++){ |
| 2193 |
|
// |
| 2194 |
|
if ( verbose ) printf(" got3\n"); |
| 2195 |
|
ToFTrkVar *ptt = (ToFTrkVar*)(tcExtTof->At(nt)); |
| 2196 |
|
if ( ptt->trkseqno != -1 ){ |
| 2197 |
|
// |
| 2198 |
|
t_orb->trkseqno = ptt->trkseqno; |
| 2199 |
|
// |
| 2200 |
|
t_orb->Eij = 0; |
| 2201 |
|
// |
| 2202 |
|
t_orb->Sij = 0; |
| 2203 |
|
// |
| 2204 |
|
t_orb->pitch = -1000.; |
| 2205 |
|
// |
| 2206 |
|
t_orb->sunangle = -1000.; |
| 2207 |
|
// |
| 2208 |
|
t_orb->sunmagangle = -1000; |
| 2209 |
|
// |
| 2210 |
|
t_orb->cutoff = -1000.; |
| 2211 |
|
// |
| 2212 |
|
TClonesArray &tz3 = *torbExtNucleiTrk; |
| 2213 |
|
new(tz3[ttentry]) OrbitalInfoTrkVar(*t_orb); |
| 2214 |
|
ttentry++; |
| 2215 |
|
// |
| 2216 |
|
t_orb->Clear(); |
| 2217 |
|
// |
| 2218 |
|
} |
| 2219 |
|
// |
| 2220 |
|
} |
| 2221 |
|
} |
| 2222 |
|
} |
| 2223 |
|
} // if( orbitalinfo->TimeGap>0){ |
| 2224 |
// |
// |
| 2225 |
// Fill the class |
// Fill the class |
| 2226 |
// |
// |
| 2227 |
OrbitalInfotr->Fill(); |
OrbitalInfotr->Fill(); |
| 2228 |
// |
// |
| 2229 |
|
// tor.Clear("C"); // memory leak? |
| 2230 |
|
tor.Delete(); // memory leak? |
| 2231 |
delete t_orb; |
delete t_orb; |
| 2232 |
// |
// |
| 2233 |
}; // loop over the events in the run |
// printf(" q0 size %i q0 capacity %i \n",(int)q0.size(),(int)q0.capacity()); |
| 2234 |
|
} // loop over the events in the run |
| 2235 |
|
|
| 2236 |
|
|
| 2237 |
// |
// |
| 2238 |
// Here you may want to clear some variables before processing another run |
// Here you may want to clear some variables before processing another run |
| 2239 |
// |
// |
| 2240 |
|
|
| 2241 |
|
// OrbitalInfotr->FlushBaskets(); |
| 2242 |
|
|
| 2243 |
if ( verbose ) printf(" Clear before new run \n"); |
if ( verbose ) printf(" Clear before new run \n"); |
| 2244 |
delete dbtime; |
delete dbtime; |
| 2245 |
|
|
| 2255 |
if ( verbose ) printf(" Clear before new run4 \n"); |
if ( verbose ) printf(" Clear before new run4 \n"); |
| 2256 |
if ( RYPang_lower ) delete RYPang_lower; |
if ( RYPang_lower ) delete RYPang_lower; |
| 2257 |
|
|
| 2258 |
if ( l0tr ) l0tr->Delete(); |
|
| 2259 |
|
if ( l0tr ){ |
| 2260 |
|
if ( verbose ) printf(" delete l0tr\n"); |
| 2261 |
|
l0tr->Delete(); |
| 2262 |
|
l0tr = 0; |
| 2263 |
|
} |
| 2264 |
|
// if ( l0head ){ |
| 2265 |
|
// printf(" delete l0head\n"); |
| 2266 |
|
// l0head->Reset(); |
| 2267 |
|
// delete l0head; |
| 2268 |
|
// printf(" delete l0head done\n"); |
| 2269 |
|
// l0head = 0; |
| 2270 |
|
// } |
| 2271 |
|
if (eh) { |
| 2272 |
|
if ( verbose ) printf(" delete eh\n"); |
| 2273 |
|
delete eh; |
| 2274 |
|
eh = 0; |
| 2275 |
|
} |
| 2276 |
|
|
| 2277 |
|
if ( verbose ) printf(" close file \n"); |
| 2278 |
|
if ( l0File ) l0File->Close("R"); |
| 2279 |
if ( verbose ) printf(" End run \n"); |
if ( verbose ) printf(" End run \n"); |
| 2280 |
|
|
| 2281 |
}; // process all the runs |
q0.clear(); |
| 2282 |
|
q1.clear(); |
| 2283 |
|
q2.clear(); |
| 2284 |
|
q3.clear(); |
| 2285 |
|
qtime.clear(); |
| 2286 |
|
qPitch.clear(); |
| 2287 |
|
qRoll.clear(); |
| 2288 |
|
qYaw.clear(); |
| 2289 |
|
qmode.clear(); |
| 2290 |
|
|
| 2291 |
|
if (ch){ |
| 2292 |
|
if ( verbose ) printf(" delete ch\n"); |
| 2293 |
|
ch->Delete(); |
| 2294 |
|
ch = 0; |
| 2295 |
|
} |
| 2296 |
|
} // process all the runs <=== |
| 2297 |
|
if ( debug ){ |
| 2298 |
|
printf("AFTER LOOP ON RUNs\n"); |
| 2299 |
|
gObjectTable->Print(); |
| 2300 |
|
} |
| 2301 |
|
// |
| 2302 |
if (verbose) printf("\n Finished processing data \n"); |
if (verbose) printf("\n Finished processing data \n"); |
| 2303 |
// |
// |
| 2304 |
closeandexit: |
closeandexit: |
| 2320 |
// |
// |
| 2321 |
// copy orbitalinfoclone to OrbitalInfo |
// copy orbitalinfoclone to OrbitalInfo |
| 2322 |
// |
// |
| 2323 |
orbitalinfo->Clear(); |
// orbitalinfo->Clear(); |
| 2324 |
// |
// |
| 2325 |
memcpy(&orbitalinfo,&orbitalinfoclone,sizeof(orbitalinfoclone)); |
memcpy(&orbitalinfo,&orbitalinfoclone,sizeof(orbitalinfoclone)); |
| 2326 |
// |
// |
| 2365 |
if ( gltle ) delete gltle; |
if ( gltle ) delete gltle; |
| 2366 |
if ( glparam ) delete glparam; |
if ( glparam ) delete glparam; |
| 2367 |
if ( glparam2 ) delete glparam2; |
if ( glparam2 ) delete glparam2; |
|
if ( glparam3 ) delete glparam3; |
|
| 2368 |
if (verbose) printf("\n Exiting3...\n"); |
if (verbose) printf("\n Exiting3...\n"); |
| 2369 |
if ( glroot ) delete glroot; |
if ( glroot ) delete glroot; |
| 2370 |
if (verbose) printf("\n Exiting4...\n"); |
if (verbose) printf("\n Exiting4...\n"); |
| 2371 |
if ( runinfo ) runinfo->Close(); |
if ( runinfo ) runinfo->Close(); |
| 2372 |
if ( runinfo ) delete runinfo; |
if ( runinfo ) delete runinfo; |
| 2373 |
|
|
| 2374 |
|
if ( tcNucleiTrk ){ |
| 2375 |
|
tcNucleiTrk->Delete(); |
| 2376 |
|
delete tcNucleiTrk; |
| 2377 |
|
tcNucleiTrk = NULL; |
| 2378 |
|
} |
| 2379 |
|
if ( tcExtNucleiTrk ){ |
| 2380 |
|
tcExtNucleiTrk->Delete(); |
| 2381 |
|
delete tcExtNucleiTrk; |
| 2382 |
|
tcExtNucleiTrk = NULL; |
| 2383 |
|
} |
| 2384 |
|
if ( tcExtTrk ){ |
| 2385 |
|
tcExtTrk->Delete(); |
| 2386 |
|
delete tcExtTrk; |
| 2387 |
|
tcExtTrk = NULL; |
| 2388 |
|
} |
| 2389 |
|
|
| 2390 |
|
if ( tcNucleiTof ){ |
| 2391 |
|
tcNucleiTof->Delete(); |
| 2392 |
|
delete tcNucleiTof; |
| 2393 |
|
tcNucleiTof = NULL; |
| 2394 |
|
} |
| 2395 |
|
if ( tcExtNucleiTof ){ |
| 2396 |
|
tcExtNucleiTof->Delete(); |
| 2397 |
|
delete tcExtNucleiTof; |
| 2398 |
|
tcExtNucleiTof = NULL; |
| 2399 |
|
} |
| 2400 |
|
if ( tcExtTof ){ |
| 2401 |
|
tcExtTof->Delete(); |
| 2402 |
|
delete tcExtTof; |
| 2403 |
|
tcExtTrk = NULL; |
| 2404 |
|
} |
| 2405 |
|
|
| 2406 |
|
|
| 2407 |
if ( tof ) delete tof; |
if ( tof ) delete tof; |
| 2408 |
if ( trke ) delete trke; |
if ( trke ) delete trke; |
| 2409 |
|
|
| 2417 |
// |
// |
| 2418 |
if ( debug ) file->ls(); |
if ( debug ) file->ls(); |
| 2419 |
// |
// |
| 2420 |
|
if ( debug ){ |
| 2421 |
|
printf("BEFORE EXITING\n"); |
| 2422 |
|
gObjectTable->Print(); |
| 2423 |
|
} |
| 2424 |
if(code < 0) throw code; |
if(code < 0) throw code; |
| 2425 |
return(code); |
return(code); |
| 2426 |
} |
} |
| 2527 |
|
|
| 2528 |
// geomagnetic calculation staff |
// geomagnetic calculation staff |
| 2529 |
|
|
|
//void GM_ScanIGRF(TString PATH, GMtype_Data *G0, GMtype_Data *G1, GMtype_Data *H1) |
|
| 2530 |
void GM_ScanIGRF(TSQLServer *dbc, GMtype_Data *G0, GMtype_Data *G1, GMtype_Data *H1) |
void GM_ScanIGRF(TSQLServer *dbc, GMtype_Data *G0, GMtype_Data *G1, GMtype_Data *H1) |
| 2531 |
{ |
{ |
| 2532 |
GL_PARAM *glp = new GL_PARAM(); |
GL_PARAM *glp = new GL_PARAM(); |
| 2574 |
H1->element[23] = temp * 5 + H1->element[22]; |
H1->element[23] = temp * 5 + H1->element[22]; |
| 2575 |
H1->element[24] = temp * 5 + H1->element[23]; |
H1->element[24] = temp * 5 + H1->element[23]; |
| 2576 |
if ( glp ) delete glp; |
if ( glp ) delete glp; |
| 2577 |
|
/* |
| 2578 |
|
printf("############################## SCAN IGRF ######################################\n"); |
| 2579 |
|
printf(" G0 G1 H1\n"); |
| 2580 |
|
printf(" size %10i %10i %10i \n",G0->size,G1->size,H1->size); |
| 2581 |
|
for ( i = 0; i < 30; i++){ |
| 2582 |
|
printf("%5i %10.2f %10.2f %10.2f \n",i,G0->element[i],G1->element[i],H1->element[i]); |
| 2583 |
|
} |
| 2584 |
|
printf("###############################################################################\n"); |
| 2585 |
|
*/ |
| 2586 |
|
} /*GM_ScanIGRF*/ |
| 2587 |
|
|
| 2588 |
|
|
| 2589 |
|
|
| 2590 |
|
|
| 2591 |
|
void GM_SetIGRF(Int_t isSecular, TString ifile1, TString ifile2, GMtype_Data *G0, GMtype_Data *G1, GMtype_Data *H1) |
| 2592 |
|
{ |
| 2593 |
|
/*This function scans inputs G0, G1, and H1 of the IGRF table into 3 data arrays*/ |
| 2594 |
|
int i; |
| 2595 |
|
double temp,temp2; |
| 2596 |
|
int it1,it2; |
| 2597 |
|
char buffer[200]; |
| 2598 |
|
FILE *IGRF; |
| 2599 |
|
G0->size = 2; |
| 2600 |
|
G1->size = 2; |
| 2601 |
|
H1->size = 2; |
| 2602 |
|
|
| 2603 |
|
for( i = 0; i < 30; i++){ |
| 2604 |
|
G0->element[i] = 0.; |
| 2605 |
|
G1->element[i] = 0.; |
| 2606 |
|
H1->element[i] = 0.; |
| 2607 |
|
} |
| 2608 |
|
|
| 2609 |
|
IGRF = fopen(ifile1.Data(), "r"); |
| 2610 |
|
for( i = 0; i < 2; i++){ |
| 2611 |
|
fgets(buffer, 200, IGRF); |
| 2612 |
|
} |
| 2613 |
|
fscanf(IGRF, "%3i%3i%12lf%11lf",&it1,&it2, &G0->element[0],&temp); |
| 2614 |
|
fscanf(IGRF, "%3i%3i%12lf%11lf",&it1,&it2, &G1->element[0],&H1->element[0]); |
| 2615 |
|
fclose(IGRF); |
| 2616 |
|
|
| 2617 |
|
IGRF = fopen(ifile2.Data(), "r"); |
| 2618 |
|
for( i = 0; i < 2; i++){ |
| 2619 |
|
fgets(buffer, 200, IGRF); |
| 2620 |
|
} |
| 2621 |
|
if ( isSecular ){ |
| 2622 |
|
fscanf(IGRF, "%3i%3i%12lf%11lf",&it1,&it2,&temp,&temp2); |
| 2623 |
|
G0->element[1] = temp * 5. + G0->element[0]; |
| 2624 |
|
fscanf(IGRF, "%3i%3i%12lf%11lf",&it1,&it2,&temp,&temp2); |
| 2625 |
|
G1->element[1] = temp * 5. + G1->element[0]; |
| 2626 |
|
H1->element[1] = temp2 * 5. + H1->element[0]; |
| 2627 |
|
} else { |
| 2628 |
|
fscanf(IGRF, "%3i%3i%12lf%11lf",&it1,&it2, &G0->element[1],&temp); |
| 2629 |
|
fscanf(IGRF, "%3i%3i%12lf%11lf",&it1,&it2, &G1->element[1],&H1->element[1]); |
| 2630 |
|
} |
| 2631 |
|
fclose(IGRF); |
| 2632 |
|
/* |
| 2633 |
|
printf("############################## SCAN IGRF ######################################\n"); |
| 2634 |
|
printf(" G0 G1 H1\n"); |
| 2635 |
|
printf(" size %10i %10i %10i \n",G0->size,G1->size,H1->size); |
| 2636 |
|
for ( i = 0; i < 30; i++){ |
| 2637 |
|
printf("%5i %10.2f %10.2f %10.2f \n",i,G0->element[i],G1->element[i],H1->element[i]); |
| 2638 |
|
} |
| 2639 |
|
printf("###############################################################################\n"); |
| 2640 |
|
*/ |
| 2641 |
} /*GM_ScanIGRF*/ |
} /*GM_ScanIGRF*/ |
| 2642 |
|
|
| 2643 |
void GM_SetEllipsoid(GMtype_Ellipsoid *Ellip) |
void GM_SetEllipsoid(GMtype_Ellipsoid *Ellip) |
| 2727 |
int index; |
int index; |
| 2728 |
double x; |
double x; |
| 2729 |
index = (year - GM_STARTYEAR) / 5; |
index = (year - GM_STARTYEAR) / 5; |
| 2730 |
x = (jyear - GM_STARTYEAR) / 5; |
x = (jyear - GM_STARTYEAR) / 5.; |
| 2731 |
Model->g0 = GM_LinearInterpolation(index, index+1, g0d.element[index], g0d.element[index+1], x); |
Model->g0 = GM_LinearInterpolation(index, index+1, g0d.element[index], g0d.element[index+1], x); |
| 2732 |
Model->g1 = GM_LinearInterpolation(index, index+1, g1d.element[index], g1d.element[index+1], x); |
Model->g1 = GM_LinearInterpolation(index, index+1, g1d.element[index], g1d.element[index+1], x); |
| 2733 |
Model->h1 = GM_LinearInterpolation(index, index+1, h1d.element[index], h1d.element[index+1], x); |
Model->h1 = GM_LinearInterpolation(index, index+1, h1d.element[index], h1d.element[index+1], x); |
| 2738 |
/*This function takes a linear interpolation between two given points for x*/ |
/*This function takes a linear interpolation between two given points for x*/ |
| 2739 |
double weight, y; |
double weight, y; |
| 2740 |
weight = (x - x1) / (x2 - x1); |
weight = (x - x1) / (x2 - x1); |
| 2741 |
y = y1 * (1 - weight) + y2 * weight; |
y = y1 * (1. - weight) + y2 * weight; |
| 2742 |
|
// printf(" x1 %f x2 %f y1 %f y2 %f x %f ==> y %f \n",x1,x2,y1,y2,x,y); |
| 2743 |
return y; |
return y; |
| 2744 |
}/*GM_LinearInterpolation*/ |
}/*GM_LinearInterpolation*/ |
| 2745 |
|
|