|
// |
|
| 1 |
// C/C++ headers |
// C/C++ headers |
| 2 |
// |
// |
| 3 |
#include <fstream> |
#include <fstream> |
| 8 |
// |
// |
| 9 |
// ROOT headers |
// ROOT headers |
| 10 |
// |
// |
| 11 |
|
//#include <TCanvas.h> |
| 12 |
|
#include <TH2F.h> //for test only. Vitaly. |
| 13 |
|
#include <TVector3.h> |
| 14 |
|
//#include <TF1.h> |
| 15 |
|
|
| 16 |
#include <TTree.h> |
#include <TTree.h> |
| 17 |
#include <TClassEdit.h> |
#include <TClassEdit.h> |
| 18 |
#include <TObject.h> |
#include <TObject.h> |
| 48 |
#include <OrbitalInfoCore.h> |
#include <OrbitalInfoCore.h> |
| 49 |
#include <InclinationInfo.h> |
#include <InclinationInfo.h> |
| 50 |
|
|
| 51 |
|
|
| 52 |
using namespace std; |
using namespace std; |
| 53 |
|
|
| 54 |
// |
// |
| 66 |
stringstream myquery; |
stringstream myquery; |
| 67 |
myquery.str(""); |
myquery.str(""); |
| 68 |
myquery << "SET time_zone='+0:00'"; |
myquery << "SET time_zone='+0:00'"; |
| 69 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
| 70 |
// |
// |
| 71 |
TString processFolder = Form("OrbitalInfoFolder_%u",run); |
TString processFolder = Form("OrbitalInfoFolder_%u",run); |
| 72 |
// |
// |
| 122 |
TTree *OrbitalInfotrclone = 0; |
TTree *OrbitalInfotrclone = 0; |
| 123 |
Bool_t reproc = false; |
Bool_t reproc = false; |
| 124 |
Bool_t reprocall = false; |
Bool_t reprocall = false; |
| 125 |
|
Bool_t igrfloaded = false; |
| 126 |
UInt_t nobefrun = 0; |
UInt_t nobefrun = 0; |
| 127 |
UInt_t noaftrun = 0; |
UInt_t noaftrun = 0; |
| 128 |
UInt_t numbofrun = 0; |
UInt_t numbofrun = 0; |
| 130 |
TString fname; |
TString fname; |
| 131 |
UInt_t totfileentries = 0; |
UInt_t totfileentries = 0; |
| 132 |
UInt_t idRun = 0; |
UInt_t idRun = 0; |
| 133 |
|
UInt_t anni5 = 60 * 60 * 24 * 365 * 5 ;//1576800 |
| 134 |
// |
// |
| 135 |
// My variables. Vitaly. |
// My variables. Vitaly. |
| 136 |
// |
// |
| 137 |
// UInt_t iev = 0; |
// UInt_t oi = 0; |
|
// UInt_t j3 = 0; |
|
|
UInt_t oi = 0; |
|
| 138 |
Int_t tmpSize = 0; |
Int_t tmpSize = 0; |
| 139 |
// |
// |
| 140 |
// variables needed to handle error signals |
// variables needed to handle error signals |
| 146 |
// |
// |
| 147 |
OrbitalInfo *orbitalinfo = new OrbitalInfo(); |
OrbitalInfo *orbitalinfo = new OrbitalInfo(); |
| 148 |
OrbitalInfo *orbitalinfoclone = new OrbitalInfo(); |
OrbitalInfo *orbitalinfoclone = new OrbitalInfo(); |
| 149 |
|
|
| 150 |
// |
// |
| 151 |
// define variables for opening and reading level0 file |
// define variables for opening and reading level0 file |
| 152 |
// |
// |
| 153 |
TFile *l0File = 0; |
TFile *l0File = 0; |
| 154 |
TTree *l0tr = 0; |
TTree *l0tr = 0; |
| 155 |
TTree *l0trm = 0; |
// TTree *l0trm = 0; |
| 156 |
|
TChain *ch = 0; |
| 157 |
// EM: open also header branch |
// EM: open also header branch |
| 158 |
TBranch *l0head = 0; |
TBranch *l0head = 0; |
| 159 |
pamela::EventHeader *eh = 0; |
pamela::EventHeader *eh = 0; |
| 183 |
// |
// |
| 184 |
// IGRF stuff |
// IGRF stuff |
| 185 |
// |
// |
| 186 |
float dimo = 0.0; // dipole moment (computed from dat files) |
Double_t dimo = 0.0; // dipole moment (computed from dat files) // EM GCC 4.7 |
| 187 |
float bnorth, beast, bdown, babs; |
Float_t bnorth, beast, bdown, babs; |
| 188 |
float xl; // L value |
Float_t xl; // L value |
| 189 |
float icode; // code value for L accuracy (see fortran code) |
Float_t icode; // code value for L accuracy (see fortran code) |
| 190 |
float bab1; // What's the difference with babs? |
Float_t bab1; // What's the difference with babs? |
| 191 |
float stps = 0.005; // step size for field line tracing |
Float_t stps = 0.005; // step size for field line tracing |
| 192 |
float bdel = 0.01; // required accuracy |
Float_t bdel = 0.01; // required accuracy |
| 193 |
float bequ; // equatorial b value (also called b_0) |
Float_t bequ; // equatorial b value (also called b_0) |
| 194 |
bool value = 0; // false if bequ is not the minimum b value |
Bool_t value = 0; // false if bequ is not the minimum b value |
| 195 |
float rr0; // equatorial radius normalized to earth radius |
Float_t rr0; // equatorial radius normalized to earth radius |
| 196 |
|
|
| 197 |
// |
// |
| 198 |
// Working filename |
// Working filename |
| 216 |
OrbitalInfofolder << tempname.str().c_str(); |
OrbitalInfofolder << tempname.str().c_str(); |
| 217 |
tempname << "/OrbitalInfotree_run"; |
tempname << "/OrbitalInfotree_run"; |
| 218 |
tempname << run << ".root"; |
tempname << run << ".root"; |
| 219 |
|
UInt_t totnorun = 0; |
| 220 |
// |
// |
| 221 |
// DB classes |
// DB classes |
| 222 |
// |
// |
| 226 |
// |
// |
| 227 |
//Quaternions classes |
//Quaternions classes |
| 228 |
// |
// |
| 229 |
Quaternions *L_QQ_Q_l_lower = new Quaternions(); |
Quaternions *L_QQ_Q_l_lower = 0; |
| 230 |
InclinationInfo *RYPang_lower = new InclinationInfo(); |
InclinationInfo *RYPang_lower = 0; |
| 231 |
Quaternions *L_QQ_Q_l_upper = new Quaternions(); |
Quaternions *L_QQ_Q_l_upper = 0; |
| 232 |
InclinationInfo *RYPang_upper = new InclinationInfo(); |
InclinationInfo *RYPang_upper = 0; |
| 233 |
|
|
| 234 |
cEci eCi; |
cEci eCi; |
| 235 |
|
|
| 236 |
// Initialize fortran routines!!! |
// Initialize fortran routines!!! |
| 237 |
|
Int_t ltp1 = 0; |
| 238 |
Int_t ltp2 = 0; |
Int_t ltp2 = 0; |
| 239 |
Int_t ltp3 = 0; |
Int_t ltp3 = 0; |
| 240 |
Int_t uno = 1; |
// Int_t uno = 1; |
| 241 |
char *niente = " "; |
// const char *niente = " "; |
| 242 |
GL_PARAM *glparam = new GL_PARAM(); |
GL_PARAM *glparam = new GL_PARAM(); |
| 243 |
GL_PARAM *glparam2 = new GL_PARAM(); |
GL_PARAM *glparam2 = new GL_PARAM(); |
| 244 |
Int_t parerror=glparam->Query_GL_PARAM(1,301,dbc); // parameters stored in DB in GL_PRAM table |
GL_PARAM *glparam3 = new GL_PARAM(); |
| 245 |
|
|
| 246 |
// |
// |
| 247 |
// Orientation variables |
// Orientation variables. Vitaly |
| 248 |
// |
// |
| 249 |
UInt_t evfrom = 0; |
UInt_t evfrom = 0; |
| 250 |
UInt_t jumped = 0; |
UInt_t jumped = 0; |
| 251 |
Int_t itr = -1; |
Int_t itr = -1; |
| 252 |
Double_t A1; |
// Double_t A1; |
| 253 |
Double_t A2; |
// Double_t A2; |
| 254 |
Double_t A3; |
// Double_t A3; |
| 255 |
Double_t Px = 0; |
Double_t Px = 0; |
| 256 |
Double_t Py = 0; |
Double_t Py = 0; |
| 257 |
Double_t Pz = 0; |
Double_t Pz = 0; |
| 261 |
Int_t nz = 6; |
Int_t nz = 6; |
| 262 |
Float_t zin[6]; |
Float_t zin[6]; |
| 263 |
Int_t nevtofl2 = 0; |
Int_t nevtofl2 = 0; |
| 264 |
// |
if ( verbose ) cout<<"Reading quaternions external file"<<endl; |
| 265 |
|
cout.setf(ios::fixed,ios::floatfield); |
| 266 |
|
/******Reading recovered quaternions...*********/ |
| 267 |
|
vector<Double_t> recqtime; |
| 268 |
|
vector<Float_t> recq0; |
| 269 |
|
vector<Float_t> recq1; |
| 270 |
|
vector<Float_t> recq2; |
| 271 |
|
vector<Float_t> recq3; |
| 272 |
|
Float_t Norm = 1; |
| 273 |
|
Int_t parerror=glparam->Query_GL_PARAM(1,303,dbc); // parameters stored in DB in GL_PRAM table |
| 274 |
|
ifstream in((glparam->PATH+glparam->NAME).Data(),ios::in); |
| 275 |
if ( parerror<0 ) { |
if ( parerror<0 ) { |
| 276 |
code = parerror; |
code = parerror; |
| 277 |
goto closeandexit; |
goto closeandexit; |
| 278 |
}; |
} |
| 279 |
ltp2 = (Int_t)(glparam->PATH+glparam->NAME).Length(); |
while(!in.eof()){ |
| 280 |
if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
recqtime.resize(recqtime.size()+1); |
| 281 |
// |
Int_t sizee = recqtime.size(); |
| 282 |
parerror=glparam2->Query_GL_PARAM(1,302,dbc); // parameters stored in DB in GL_PRAM table |
recq0.resize(sizee); |
| 283 |
if ( parerror<0 ) { |
recq1.resize(sizee); |
| 284 |
code = parerror; |
recq2.resize(sizee); |
| 285 |
goto closeandexit; |
recq3.resize(sizee); |
| 286 |
}; |
in>>recqtime[sizee-1]; |
| 287 |
ltp3 = (Int_t)(glparam2->PATH+glparam2->NAME).Length(); |
in>>recq0[sizee-1]; |
| 288 |
if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam2->PATH+glparam2->NAME).Data()); |
in>>recq1[sizee-1]; |
| 289 |
// |
in>>recq2[sizee-1]; |
| 290 |
initize_((char *)niente,&uno,(char *)(glparam->PATH+glparam->NAME).Data(),<p2,(char *)(glparam2->PATH+glparam2->NAME).Data(),<p3); |
in>>recq3[sizee-1]; |
| 291 |
// |
in>>Norm; |
| 292 |
// End IGRF stuff// |
} |
| 293 |
// |
if ( verbose ) cout<<"We have read recovered data"<<endl; |
| 294 |
|
|
| 295 |
|
// IGRF stuff moved inside run loop! |
| 296 |
|
|
| 297 |
for (Int_t ip=0;ip<nz;ip++){ |
for (Int_t ip=0;ip<nz;ip++){ |
| 298 |
zin[ip] = tof->GetZTOF(tof->GetToFPlaneID(ip)); |
zin[ip] = tof->GetZTOF(tof->GetToFPlaneID(ip)); |
| 299 |
}; |
}; |
| 365 |
// number of run to be processed |
// number of run to be processed |
| 366 |
// |
// |
| 367 |
numbofrun = runinfo->GetNoRun(); |
numbofrun = runinfo->GetNoRun(); |
| 368 |
UInt_t totnorun = runinfo->GetRunEntries(); |
totnorun = runinfo->GetRunEntries(); |
| 369 |
// |
// |
| 370 |
// Try to access the OrbitalInfo tree in the file, if it exists we are reprocessing data if not we are processing a new run |
// Try to access the OrbitalInfo tree in the file, if it exists we are reprocessing data if not we are processing a new run |
| 371 |
// |
// |
| 399 |
// |
// |
| 400 |
reprocall = true; |
reprocall = true; |
| 401 |
// |
// |
| 402 |
if (verbose) printf("\n OrbitalInfo - WARNING: Reprocessing all runs\n"); |
if (verbose) printf("\n OrbitalInfo - WARNING: Reprocessing all runs\n Deleting old tree...\n"); |
| 403 |
// |
// |
| 404 |
} else { |
} else { |
| 405 |
// |
// |
| 417 |
tempOrbitalInfo = OrbitalInfotrclone->CloneTree(-1,"fast"); |
tempOrbitalInfo = OrbitalInfotrclone->CloneTree(-1,"fast"); |
| 418 |
tempOrbitalInfo->SetName("OrbitalInfo-old"); |
tempOrbitalInfo->SetName("OrbitalInfo-old"); |
| 419 |
tempfile->Write(); |
tempfile->Write(); |
| 420 |
|
tempOrbitalInfo->Delete(); |
| 421 |
tempfile->Close(); |
tempfile->Close(); |
| 422 |
} |
} |
| 423 |
// |
// |
| 424 |
// Delete the old tree from old file and memory |
// Delete the old tree from old file and memory |
| 425 |
// |
// |
| 426 |
|
OrbitalInfotrclone->Clear(); |
| 427 |
OrbitalInfotrclone->Delete("all"); |
OrbitalInfotrclone->Delete("all"); |
| 428 |
// |
// |
| 429 |
if (verbose) printf(" ...done!\n"); |
if (verbose) printf(" ...done!\n"); |
| 455 |
} |
} |
| 456 |
for (UInt_t j = 0; j < nobefrun; j++){ |
for (UInt_t j = 0; j < nobefrun; j++){ |
| 457 |
// |
// |
| 458 |
OrbitalInfotrclone->GetEntry(j); |
if ( OrbitalInfotrclone->GetEntry(j) <= 0 ) throw -36; |
| 459 |
// |
// |
| 460 |
// copy orbitalinfoclone to mydec |
// copy orbitalinfoclone to mydec |
| 461 |
// |
// |
| 469 |
// |
// |
| 470 |
}; |
}; |
| 471 |
if (verbose) printf(" Finished successful copying!\n"); |
if (verbose) printf(" Finished successful copying!\n"); |
| 472 |
}; |
}; |
| 473 |
}; |
}; |
| 474 |
// |
// |
| 475 |
|
// |
| 476 |
// 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. |
| 477 |
// |
// |
| 478 |
runlist = runinfo->GetRunList(); |
runlist = runinfo->GetRunList(); |
| 480 |
// Loop over the run to be processed |
// Loop over the run to be processed |
| 481 |
// |
// |
| 482 |
for (UInt_t irun=0; irun < numbofrun; irun++){ |
for (UInt_t irun=0; irun < numbofrun; irun++){ |
| 483 |
|
|
| 484 |
|
L_QQ_Q_l_lower = new Quaternions(); |
| 485 |
|
RYPang_lower = new InclinationInfo(); |
| 486 |
|
L_QQ_Q_l_upper = new Quaternions(); |
| 487 |
|
RYPang_upper = new InclinationInfo(); |
| 488 |
|
|
| 489 |
// |
// |
| 490 |
// retrieve the first run ID to be processed using the RunInfo list |
// retrieve the first run ID to be processed using the RunInfo list |
| 491 |
// |
// |
| 534 |
fname = ftmpname.str().c_str(); |
fname = ftmpname.str().c_str(); |
| 535 |
ftmpname.str(""); |
ftmpname.str(""); |
| 536 |
// |
// |
| 537 |
// print out informations |
// print nout informations |
| 538 |
// |
// |
| 539 |
totevent = runinfo->NEVENTS; |
totevent = runinfo->NEVENTS; |
| 540 |
evfrom = runinfo->EV_FROM; |
evfrom = runinfo->EV_FROM; |
| 548 |
// |
// |
| 549 |
// if ( !totevent ) goto closeandexit; |
// if ( !totevent ) goto closeandexit; |
| 550 |
// Open Level0 file |
// Open Level0 file |
| 551 |
|
if ( l0File ) l0File->Close(); |
| 552 |
l0File = new TFile(fname.Data()); |
l0File = new TFile(fname.Data()); |
| 553 |
if ( !l0File ) { |
if ( !l0File ) { |
| 554 |
if ( debug ) printf(" OrbitalInfo - ERROR: problems opening Level0 file\n"); |
if ( debug ) printf(" OrbitalInfo - ERROR: problems opening Level0 file\n"); |
| 587 |
code = -12; |
code = -12; |
| 588 |
goto closeandexit; |
goto closeandexit; |
| 589 |
}; |
}; |
| 590 |
|
|
| 591 |
|
// |
| 592 |
|
// open IGRF files and do it only once if we are processing a full level2 file |
| 593 |
|
// |
| 594 |
|
if ( reprocall && !igrfloaded ){ |
| 595 |
|
|
| 596 |
|
if ( l0head->GetEntry(runinfo->EV_FROM) > 0 ){ |
| 597 |
|
igrfloaded = true; |
| 598 |
|
// |
| 599 |
|
// absolute time of first event of the run (it should not matter a lot) |
| 600 |
|
// |
| 601 |
|
ph = eh->GetPscuHeader(); |
| 602 |
|
atime = dbtime->DBabsTime(ph->GetOrbitalTime()); |
| 603 |
|
|
| 604 |
|
parerror=glparam->Query_GL_PARAM(atime-anni5,301,dbc); // parameters stored in DB in GL_PRAM table |
| 605 |
|
if ( parerror<0 ) { |
| 606 |
|
code = parerror; |
| 607 |
|
goto closeandexit; |
| 608 |
|
} |
| 609 |
|
ltp1 = (Int_t)(glparam->PATH+glparam->NAME).Length(); |
| 610 |
|
if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
| 611 |
|
// |
| 612 |
|
parerror=glparam2->Query_GL_PARAM(atime,301,dbc); // parameters stored in DB in GL_PRAM table |
| 613 |
|
if ( parerror<0 ) { |
| 614 |
|
code = parerror; |
| 615 |
|
goto closeandexit; |
| 616 |
|
} |
| 617 |
|
ltp2 = (Int_t)(glparam2->PATH+glparam2->NAME).Length(); |
| 618 |
|
if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam2->PATH+glparam2->NAME).Data()); |
| 619 |
|
// |
| 620 |
|
parerror=glparam3->Query_GL_PARAM(atime,302,dbc); // parameters stored in DB in GL_PRAM table |
| 621 |
|
if ( parerror<0 ) { |
| 622 |
|
code = parerror; |
| 623 |
|
goto closeandexit; |
| 624 |
|
} |
| 625 |
|
ltp3 = (Int_t)(glparam3->PATH+glparam3->NAME).Length(); |
| 626 |
|
if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam3->PATH+glparam3->NAME).Data()); |
| 627 |
|
// |
| 628 |
|
initize_((char *)(glparam->PATH+glparam->NAME).Data(),<p1,(char *)(glparam2->PATH+glparam2->NAME).Data(),<p2,(char *)(glparam3->PATH+glparam3->NAME).Data(),<p3); |
| 629 |
|
// |
| 630 |
|
} |
| 631 |
|
} |
| 632 |
|
// |
| 633 |
|
// End IGRF stuff// |
| 634 |
|
// |
| 635 |
|
|
| 636 |
|
// |
| 637 |
|
// TTree *tp = (TTree*)l0File->Get("RunHeader"); |
| 638 |
|
// tp->SetBranchAddress("Header", &eH); |
| 639 |
|
// tp->SetBranchAddress("RunHeader", &reh); |
| 640 |
|
// tp->GetEntry(0); |
| 641 |
|
// ph = eH->GetPscuHeader(); |
| 642 |
|
// ULong_t TimeSync = reh->LAST_TIME_SYNC_INFO; |
| 643 |
|
// ULong_t ObtSync = reh->OBT_TIME_SYNC; |
| 644 |
|
// if ( debug ) printf(" 1 TimeSync %lu ObtSync %lu DeltaOBT %lu\n",TimeSync,ObtSync,TimeSync-ObtSync); |
| 645 |
// |
// |
|
// 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); |
|
|
// |
|
| 646 |
ULong_t TimeSync = (ULong_t)dbtime->GetTimesync(); |
ULong_t TimeSync = (ULong_t)dbtime->GetTimesync(); |
| 647 |
ULong_t ObtSync = (ULong_t)(dbtime->GetObt0()/1000); |
ULong_t ObtSync = (ULong_t)(dbtime->GetObt0()/1000); |
| 648 |
ULong_t DeltaOBT = TimeSync - ObtSync; |
ULong_t DeltaOBT = TimeSync - ObtSync; |
| 649 |
|
|
| 650 |
if ( debug ) printf(" 2 TimeSync %lu ObtSync %lu DeltaOBT %lu\n",(ULong_t)(dbtime->GetTimesync()/1000),(ULong_t)dbtime->GetObt0(),TimeSync-ObtSync); |
if ( debug ) printf(" 2 TimeSync %lu ObtSync %lu DeltaOBT %lu\n",(ULong_t)(dbtime->GetTimesync()/1000),(ULong_t)dbtime->GetObt0(),TimeSync-ObtSync); |
| 651 |
|
// |
| 652 |
l0trm = (TTree*)l0File->Get("Mcmd"); |
// Read MCMDs from up to 11 files, 5 before and 5 after the present one in order to have some kind of inclination information |
| 653 |
neventsm = l0trm->GetEntries(); |
// |
| 654 |
|
ch = new TChain("Mcmd","Mcmd"); |
| 655 |
|
// |
| 656 |
|
// look in the DB to find the closest files to this run |
| 657 |
|
// |
| 658 |
|
TSQLResult *pResult = 0; |
| 659 |
|
TSQLRow *Row = 0; |
| 660 |
|
stringstream myquery; |
| 661 |
|
UInt_t l0fid[10]; |
| 662 |
|
Int_t i = 0; |
| 663 |
|
memset(l0fid,0,10*sizeof(Int_t)); |
| 664 |
|
// |
| 665 |
|
myquery.str(""); |
| 666 |
|
myquery << "select ID_ROOT_L0 from GL_RUN where RUNHEADER_TIME<=" << runinfo->RUNHEADER_TIME << " group by ID_ROOT_L0 order by RUNHEADER_TIME desc limit 5;"; |
| 667 |
|
// |
| 668 |
|
pResult = dbc->Query(myquery.str().c_str()); |
| 669 |
|
// |
| 670 |
|
i = 9; |
| 671 |
|
if( pResult ){ |
| 672 |
|
// |
| 673 |
|
Row = pResult->Next(); |
| 674 |
|
// |
| 675 |
|
while ( Row ){ |
| 676 |
|
// |
| 677 |
|
// store infos and exit |
| 678 |
|
// |
| 679 |
|
l0fid[i] = (UInt_t)atoll(Row->GetField(0)); |
| 680 |
|
i--; |
| 681 |
|
Row = pResult->Next(); |
| 682 |
|
// |
| 683 |
|
}; |
| 684 |
|
pResult->Delete(); |
| 685 |
|
}; |
| 686 |
|
// |
| 687 |
|
myquery.str(""); |
| 688 |
|
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;"; |
| 689 |
|
// |
| 690 |
|
pResult = dbc->Query(myquery.str().c_str()); |
| 691 |
|
// |
| 692 |
|
i = 0; |
| 693 |
|
if( pResult ){ |
| 694 |
|
// |
| 695 |
|
Row = pResult->Next(); |
| 696 |
|
// |
| 697 |
|
while ( Row ){ |
| 698 |
|
// |
| 699 |
|
// store infos and exit |
| 700 |
|
// |
| 701 |
|
l0fid[i] = (UInt_t)atoll(Row->GetField(0)); |
| 702 |
|
i++; |
| 703 |
|
Row = pResult->Next(); |
| 704 |
|
// |
| 705 |
|
}; |
| 706 |
|
pResult->Delete(); |
| 707 |
|
}; |
| 708 |
|
// |
| 709 |
|
i = 0; |
| 710 |
|
UInt_t previd = 0; |
| 711 |
|
while ( i < 10 ){ |
| 712 |
|
if ( l0fid[i] && previd != l0fid[i] ){ |
| 713 |
|
previd = l0fid[i]; |
| 714 |
|
myquery.str(""); |
| 715 |
|
myquery << "select PATH,NAME from GL_ROOT where ID=" << l0fid[i] << " ;"; |
| 716 |
|
// |
| 717 |
|
pResult = dbc->Query(myquery.str().c_str()); |
| 718 |
|
// |
| 719 |
|
if( pResult ){ |
| 720 |
|
// |
| 721 |
|
Row = pResult->Next(); |
| 722 |
|
// |
| 723 |
|
if ( debug ) printf(" Using inclination informations from file: %s \n",(((TString)gSystem->ExpandPathName(Row->GetField(0)))+"/"+(TString)Row->GetField(1)).Data()); |
| 724 |
|
ch->Add(((TString)gSystem->ExpandPathName(Row->GetField(0)))+"/"+(TString)Row->GetField(1)); |
| 725 |
|
// |
| 726 |
|
pResult->Delete(); |
| 727 |
|
}; |
| 728 |
|
}; |
| 729 |
|
i++; |
| 730 |
|
}; |
| 731 |
|
// |
| 732 |
|
// l0trm = (TTree*)l0File->Get("Mcmd"); |
| 733 |
|
// ch->ls(); |
| 734 |
|
ch->SetBranchAddress("Mcmd",&mcmdev); |
| 735 |
|
// printf(" entries %llu \n", ch->GetEntries()); |
| 736 |
|
// l0trm = ch->GetTree(); |
| 737 |
|
// neventsm = l0trm->GetEntries(); |
| 738 |
|
neventsm = ch->GetEntries(); |
| 739 |
|
if ( debug ) printf(" entries %u \n", neventsm); |
| 740 |
// neventsm = 0; |
// neventsm = 0; |
| 741 |
// |
// |
| 742 |
if (neventsm == 0){ |
if (neventsm == 0){ |
| 747 |
} |
} |
| 748 |
// |
// |
| 749 |
|
|
| 750 |
l0trm->SetBranchAddress("Mcmd", &mcmdev); |
// l0trm->SetBranchAddress("Mcmd", &mcmdev); |
| 751 |
// l0trm->SetBranchAddress("Header", &eh); |
// l0trm->SetBranchAddress("Header", &eh); |
| 752 |
// |
// |
| 753 |
// |
// |
| 754 |
// |
// |
| 755 |
UInt_t mctren = 0; |
|
| 756 |
UInt_t mcreen = 0; |
// UInt_t mctren = 0; |
| 757 |
UInt_t numrec = 0; |
// UInt_t mcreen = 0; |
| 758 |
|
// UInt_t numrec = 0; |
| 759 |
// |
// |
| 760 |
Double_t upperqtime = 0; |
// Double_t upperqtime = 0; |
| 761 |
Double_t lowerqtime = 0; |
Double_t lowerqtime = 0; |
| 762 |
|
|
| 763 |
Double_t incli = 0; |
// Double_t incli = 0; |
| 764 |
oi = 0; |
// oi = 0; |
| 765 |
UInt_t ooi = 0; |
// UInt_t ooi = 0; |
| 766 |
// |
// |
| 767 |
// init quaternions sync |
// init quaternions information from mcmd-packets |
| 768 |
// |
// |
| 769 |
Bool_t isf = true; |
Bool_t isf = true; |
| 770 |
Int_t fgh = 0; |
// Int_t fgh = 0; |
| 771 |
|
|
| 772 |
|
vector<Float_t> q0; |
| 773 |
|
vector<Float_t> q1; |
| 774 |
|
vector<Float_t> q2; |
| 775 |
|
vector<Float_t> q3; |
| 776 |
|
vector<Double_t> qtime; |
| 777 |
|
vector<Float_t> qPitch; |
| 778 |
|
vector<Float_t> qRoll; |
| 779 |
|
vector<Float_t> qYaw; |
| 780 |
|
vector<Int_t> qmode; |
| 781 |
|
|
| 782 |
|
Int_t nt = 0; |
| 783 |
|
|
| 784 |
|
//init sine-function interpolation |
| 785 |
|
|
| 786 |
|
//cout<<"Sine coeficient initialisation..."<<endl; |
| 787 |
|
vector<Sine> q0sine; |
| 788 |
|
vector<Sine> q1sine; |
| 789 |
|
vector<Sine> q2sine; |
| 790 |
|
vector<Sine> q3sine; |
| 791 |
|
vector<Sine> Yawsine; |
| 792 |
|
|
| 793 |
|
/*TH2F* q0testing = new TH2F(); |
| 794 |
|
TH2F* q1testing = new TH2F(); |
| 795 |
|
TH2F* q2testing = new TH2F(); |
| 796 |
|
TH2F* q3testing = new TH2F(); |
| 797 |
|
TH2F* Pitchtesting = new TH2F(); |
| 798 |
|
*/ |
| 799 |
|
UInt_t must = 0; |
| 800 |
|
|
| 801 |
// |
// |
| 802 |
// run over all the events of the run |
// run over all the events of the run |
| 803 |
// |
// |
| 804 |
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"); |
| 805 |
// |
// |
| 806 |
// |
// |
| 807 |
for ( re = runinfo->EV_FROM; re < (runinfo->EV_FROM+runinfo->NEVENTS); re++){ |
for ( re = runinfo->EV_FROM; re < (runinfo->EV_FROM+runinfo->NEVENTS); re++){ |
|
|
|
| 808 |
// |
// |
| 809 |
if ( procev%1000 == 0 && procev > 0 && verbose ) printf(" %iK \n",procev/1000); |
if ( procev%1000 == 0 && procev > 0 && verbose ) printf(" %iK \n",procev/1000); |
| 810 |
if ( debug ) printf(" %i \n",procev); |
if ( debug ) printf(" %i \n",procev); |
| 811 |
// |
// |
| 812 |
l0head->GetEntry(re); |
if ( l0head->GetEntry(re) <= 0 ) throw -36; |
| 813 |
// |
// |
| 814 |
// absolute time of this event |
// absolute time of this event |
| 815 |
// |
// |
| 816 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
| 817 |
atime = dbtime->DBabsTime(ph->GetOrbitalTime()); |
atime = dbtime->DBabsTime(ph->GetOrbitalTime()); |
| 818 |
|
if ( debug ) printf(" %i absolute time \n",procev); |
| 819 |
// |
// |
| 820 |
// paranoid check |
// paranoid check |
| 821 |
// |
// |
| 822 |
if ( (atime > runinfo->RUNTRAILER_TIME) || (atime < runinfo->RUNHEADER_TIME) ) { |
if ( (atime > (runinfo->RUNTRAILER_TIME+1)) || (atime < (runinfo->RUNHEADER_TIME-1)) ) { |
| 823 |
if (verbose) printf(" OrbitalInfo - WARNING: event at time outside the run time window, skipping it\n"); |
if (verbose) printf(" OrbitalInfo - WARNING: event at time outside the run time window, skipping it\n"); |
| 824 |
jumped++; |
jumped++; |
| 825 |
// debug = true; |
// debug = true; |
| 826 |
continue; |
continue; |
| 827 |
} |
} |
| 828 |
|
|
| 847 |
// |
// |
| 848 |
tof->Clear(); |
tof->Clear(); |
| 849 |
// |
// |
| 850 |
ttof->GetEntry(itr); |
if ( ttof->GetEntry(itr) <= 0 ) throw -36; |
| 851 |
// |
// |
| 852 |
}; |
}; |
| 853 |
// |
// |
| 855 |
// |
// |
| 856 |
// start processing |
// start processing |
| 857 |
// |
// |
| 858 |
|
if ( debug ) printf(" %i start processing \n",procev); |
| 859 |
orbitalinfo->Clear(); |
orbitalinfo->Clear(); |
| 860 |
// |
// |
| 861 |
OrbitalInfoTrkVar *t_orb = new OrbitalInfoTrkVar(); |
OrbitalInfoTrkVar *t_orb = new OrbitalInfoTrkVar(); |
| 867 |
orbitalinfo->pkt_num = ph->GetCounter(); |
orbitalinfo->pkt_num = ph->GetCounter(); |
| 868 |
orbitalinfo->OBT = ph->GetOrbitalTime(); |
orbitalinfo->OBT = ph->GetOrbitalTime(); |
| 869 |
orbitalinfo->absTime = atime; |
orbitalinfo->absTime = atime; |
| 870 |
|
if ( debug ) printf(" %i pktnum obt abstime \n",procev); |
| 871 |
// |
// |
| 872 |
// Propagate the orbit from the tle time to atime, using SGP(D)4. |
// Propagate the orbit from the tle time to atime, using SGP(D)4. |
| 873 |
// |
// |
| 874 |
|
if ( debug ) printf(" %i sgp4 \n",procev); |
| 875 |
cCoordGeo coo; |
cCoordGeo coo; |
| 876 |
float jyear=0; |
Float_t jyear=0.; |
| 877 |
// |
// |
| 878 |
if(atime >= gltle->GetToTime()) { |
if(atime >= gltle->GetToTime()) { |
| 879 |
if ( !gltle->Query(atime, dbc) ){ |
if ( !gltle->Query(atime, dbc) ){ |
| 880 |
// |
// |
| 881 |
// Compute the magnetic dipole moment. |
// Compute the magnetic dipole moment. |
| 882 |
// |
// |
| 883 |
|
if ( debug ) printf(" %i compute magnetic dipole moment \n",procev); |
| 884 |
UInt_t year, month, day, hour, min, sec; |
UInt_t year, month, day, hour, min, sec; |
| 885 |
// |
// |
| 886 |
TTimeStamp t = TTimeStamp(atime, kTRUE); |
TTimeStamp t = TTimeStamp(atime, kTRUE); |
| 888 |
t.GetTime(kTRUE, 0, &hour, &min, &sec); |
t.GetTime(kTRUE, 0, &hour, &min, &sec); |
| 889 |
jyear = (float) year |
jyear = (float) year |
| 890 |
+ (month*31.+ (float) day)/365. |
+ (month*31.+ (float) day)/365. |
| 891 |
+ (hour*3600.+min*60.+(float)sec)/(24*3600*365.); |
+ (hour*3600.+min*60.+(float)sec)/(24.*3600.*365.); |
| 892 |
// |
// |
| 893 |
|
if ( debug ) printf(" %i compute magnetic dipole moment get dipole moment for year\n",procev); |
| 894 |
|
if ( debug ) printf(" %i jyear %f dimo %f \n",procev,jyear,dimo); |
| 895 |
feldcof_(&jyear, &dimo); // get dipole moment for year |
feldcof_(&jyear, &dimo); // get dipole moment for year |
| 896 |
|
if ( debug ) printf(" %i compute magnetic dipole moment end\n",procev); |
| 897 |
} else { |
} else { |
| 898 |
code = -56; |
code = -56; |
| 899 |
goto closeandexit; |
goto closeandexit; |
| 908 |
// synchronize with quaternions data |
// synchronize with quaternions data |
| 909 |
// |
// |
| 910 |
if ( isf && neventsm>0 ){ |
if ( isf && neventsm>0 ){ |
|
if ( debug ) printf(" I am here \n"); |
|
| 911 |
// |
// |
| 912 |
// First event |
// First event |
| 913 |
// |
// |
| 914 |
isf = false; |
isf = false; |
| 915 |
upperqtime = atime; |
// upperqtime = atime; |
| 916 |
lowerqtime = runinfo->RUNHEADER_TIME; |
lowerqtime = runinfo->RUNHEADER_TIME; |
| 917 |
for ( ik = 0; ik < neventsm; ik++){ |
for ( ik = 0; ik < neventsm; ik++){ //number of macrocommad packets |
| 918 |
l0trm->GetEntry(ik); |
if ( ch->GetEntry(ik) <= 0 ) throw -36; |
| 919 |
tmpSize = mcmdev->Records->GetEntries(); |
tmpSize = mcmdev->Records->GetEntries(); |
| 920 |
numrec = tmpSize; |
// numrec = tmpSize; |
| 921 |
for (Int_t j3 = 0;j3<tmpSize;j3++){ |
for (Int_t j3 = 0;j3<tmpSize;j3++){ //number of subpackets |
| 922 |
if ( debug ) printf(" eh eh eh \n"); |
if ( debug ) printf(" ik %i j3 %i eh eh eh \n",ik,j3); |
| 923 |
mcmdrc = (pamela::McmdRecord*)mcmdev->Records->At(j3); |
mcmdrc = (pamela::McmdRecord*)mcmdev->Records->At(j3); |
| 924 |
if ((int)mcmdrc->ID1 == 226){ |
if ( mcmdrc ){ // missing inclination bug [8RED 090116] |
| 925 |
L_QQ_Q_l_upper->fill(mcmdrc->McmdData); |
if ( debug ) printf(" pluto \n"); |
| 926 |
for (UInt_t ui = 0; ui < 6; ui++){ |
if ((int)mcmdrc->ID1 == 226 && mcmdrc->Mcmd_Block_crc_ok == 1){ //Check that it is Inclination Packet |
| 927 |
if (ui>0){ |
L_QQ_Q_l_upper->fill(mcmdrc->McmdData); |
| 928 |
if (L_QQ_Q_l_upper->time[ui]>L_QQ_Q_l_upper->time[0]){ |
for (UInt_t ui = 0; ui < 6; ui++){ |
| 929 |
if (dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[ui]*1000-DeltaOBT*1000))<atime){ |
if (ui>0){ |
| 930 |
upperqtime = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[ui]*1000-DeltaOBT*1000)); |
if (L_QQ_Q_l_upper->time[ui]>L_QQ_Q_l_upper->time[0]){ |
| 931 |
orbits.getPosition((double) (upperqtime - gltle->GetFromTime())/60., &eCi); |
if ( debug ) printf(" here1 %i \n",ui); |
| 932 |
RYPang_upper->TransAngle(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,L_QQ_Q_l_upper->quat[ui][0],L_QQ_Q_l_upper->quat[ui][1],L_QQ_Q_l_upper->quat[ui][2],L_QQ_Q_l_upper->quat[ui][3]); |
Double_t u_time = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[ui]*1000-DeltaOBT*1000)); |
| 933 |
}else { |
Int_t recSize = recqtime.size(); |
| 934 |
lowerqtime = upperqtime; |
if(lowerqtime > recqtime[recSize-1]){ |
| 935 |
upperqtime = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[ui]*1000-DeltaOBT*1000)); |
Int_t sizeqmcmd = qtime.size(); |
| 936 |
orbits.getPosition((double) (upperqtime - gltle->GetFromTime())/60., &eCi); |
inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw); |
| 937 |
RYPang_upper->TransAngle(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,L_QQ_Q_l_upper->quat[ui][0],L_QQ_Q_l_upper->quat[ui][1],L_QQ_Q_l_upper->quat[ui][2],L_QQ_Q_l_upper->quat[ui][3]); |
qtime[sizeqmcmd]=u_time; |
| 938 |
mcreen = j3; |
q0[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][0]; |
| 939 |
mctren = ik; |
q1[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][1]; |
| 940 |
if(fgh==0){ |
q2[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][2]; |
| 941 |
CopyQ(L_QQ_Q_l_lower,L_QQ_Q_l_upper); |
q3[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][3]; |
| 942 |
CopyAng(RYPang_lower,RYPang_upper); |
qmode[sizeqmcmd]=holeq(lowerqtime,qtime[sizeqmcmd],L_QQ_Q_l_lower,L_QQ_Q_l_upper,ui); |
| 943 |
|
lowerqtime = u_time; |
| 944 |
|
orbits.getPosition((double) (u_time - gltle->GetFromTime())/60., &eCi); |
| 945 |
|
RYPang_upper->TransAngle(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,L_QQ_Q_l_upper->quat[ui][0],L_QQ_Q_l_upper->quat[ui][1],L_QQ_Q_l_upper->quat[ui][2],L_QQ_Q_l_upper->quat[ui][3]); |
| 946 |
|
qRoll[sizeqmcmd]=RYPang_upper->Kren; |
| 947 |
|
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
| 948 |
|
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
| 949 |
|
} |
| 950 |
|
for(Int_t mu = nt;mu<recSize;mu++){ |
| 951 |
|
if(recqtime[mu]>lowerqtime && recqtime[mu]<u_time){ |
| 952 |
|
nt=mu; |
| 953 |
|
Int_t sizeqmcmd = qtime.size(); |
| 954 |
|
inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw); |
| 955 |
|
qtime[sizeqmcmd]=recqtime[mu]; |
| 956 |
|
q0[sizeqmcmd]=recq0[mu]; |
| 957 |
|
q1[sizeqmcmd]=recq1[mu]; |
| 958 |
|
q2[sizeqmcmd]=recq2[mu]; |
| 959 |
|
q3[sizeqmcmd]=recq3[mu]; |
| 960 |
|
qmode[sizeqmcmd]=-10; |
| 961 |
|
orbits.getPosition((double) (qtime[sizeqmcmd] - gltle->GetFromTime())/60., &eCi); |
| 962 |
|
RYPang_upper->TransAngle(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,recq0[mu],recq1[mu],recq2[mu],recq3[mu]); |
| 963 |
|
qRoll[sizeqmcmd]=RYPang_upper->Kren; |
| 964 |
|
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
| 965 |
|
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
| 966 |
|
} |
| 967 |
|
if(recqtime[mu]>=u_time){ |
| 968 |
|
Int_t sizeqmcmd = qtime.size(); |
| 969 |
|
inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw); |
| 970 |
|
qtime[sizeqmcmd]=u_time; |
| 971 |
|
q0[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][0]; |
| 972 |
|
q1[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][1]; |
| 973 |
|
q2[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][2]; |
| 974 |
|
q3[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][3]; |
| 975 |
|
qmode[sizeqmcmd]=holeq(lowerqtime,qtime[sizeqmcmd],L_QQ_Q_l_lower,L_QQ_Q_l_upper,ui); |
| 976 |
|
lowerqtime = u_time; |
| 977 |
|
orbits.getPosition((double) (u_time - gltle->GetFromTime())/60., &eCi); |
| 978 |
|
RYPang_upper->TransAngle(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,L_QQ_Q_l_upper->quat[ui][0],L_QQ_Q_l_upper->quat[ui][1],L_QQ_Q_l_upper->quat[ui][2],L_QQ_Q_l_upper->quat[ui][3]); |
| 979 |
|
qRoll[sizeqmcmd]=RYPang_upper->Kren; |
| 980 |
|
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
| 981 |
|
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
| 982 |
|
break; |
| 983 |
|
} |
| 984 |
} |
} |
|
oi=ui; |
|
|
goto closethisloop; |
|
| 985 |
} |
} |
| 986 |
fgh++; |
}else{ |
| 987 |
CopyQ(L_QQ_Q_l_lower,L_QQ_Q_l_upper); |
if ( debug ) printf(" here2 %i \n",ui); |
| 988 |
CopyAng(RYPang_lower,RYPang_upper); |
Double_t u_time = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
| 989 |
} |
if(lowerqtime>u_time)nt=0; |
| 990 |
}else{ |
Int_t recSize = recqtime.size(); |
| 991 |
if (dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000))<atime){ |
if(lowerqtime > recqtime[recSize-1]){ |
| 992 |
upperqtime = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
Int_t sizeqmcmd = qtime.size(); |
| 993 |
orbits.getPosition((double) (upperqtime - gltle->GetFromTime())/60., &eCi); |
inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw); |
| 994 |
RYPang_upper->TransAngle(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,L_QQ_Q_l_upper->quat[0][0],L_QQ_Q_l_upper->quat[0][1],L_QQ_Q_l_upper->quat[0][2],L_QQ_Q_l_upper->quat[0][3]); |
qtime[sizeqmcmd]=u_time; |
| 995 |
} |
q0[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][0]; |
| 996 |
else { |
q1[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][1]; |
| 997 |
lowerqtime = upperqtime; |
q2[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][2]; |
| 998 |
upperqtime = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
q3[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][3]; |
| 999 |
orbits.getPosition((double) (upperqtime - gltle->GetFromTime())/60., &eCi); |
qmode[sizeqmcmd]=holeq(lowerqtime,qtime[sizeqmcmd],L_QQ_Q_l_lower,L_QQ_Q_l_upper,ui); |
| 1000 |
RYPang_upper->TransAngle(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,L_QQ_Q_l_upper->quat[0][0],L_QQ_Q_l_upper->quat[0][1],L_QQ_Q_l_upper->quat[0][2],L_QQ_Q_l_upper->quat[0][3]); |
lowerqtime = u_time; |
| 1001 |
mcreen = j3; |
orbits.getPosition((double) (u_time - gltle->GetFromTime())/60., &eCi); |
| 1002 |
mctren = ik; |
RYPang_upper->TransAngle(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,L_QQ_Q_l_upper->quat[0][0],L_QQ_Q_l_upper->quat[0][1],L_QQ_Q_l_upper->quat[0][2],L_QQ_Q_l_upper->quat[0][3]); |
| 1003 |
if(fgh==0){ |
qRoll[sizeqmcmd]=RYPang_upper->Kren; |
| 1004 |
CopyQ(L_QQ_Q_l_lower,L_QQ_Q_l_upper); |
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
| 1005 |
CopyAng(RYPang_lower,RYPang_upper); |
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
| 1006 |
lowerqtime = atime-1; |
} |
| 1007 |
|
for(Int_t mu = nt;mu<recSize;mu++){ |
| 1008 |
|
if(recqtime[mu]>lowerqtime && recqtime[mu]<u_time){ |
| 1009 |
|
nt=mu; |
| 1010 |
|
Int_t sizeqmcmd = qtime.size(); |
| 1011 |
|
inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw); |
| 1012 |
|
qtime[sizeqmcmd]=recqtime[mu]; |
| 1013 |
|
q0[sizeqmcmd]=recq0[mu]; |
| 1014 |
|
q1[sizeqmcmd]=recq1[mu]; |
| 1015 |
|
q2[sizeqmcmd]=recq2[mu]; |
| 1016 |
|
q3[sizeqmcmd]=recq3[mu]; |
| 1017 |
|
qmode[sizeqmcmd]=-10; |
| 1018 |
|
orbits.getPosition((double) (qtime[sizeqmcmd] - gltle->GetFromTime())/60., &eCi); |
| 1019 |
|
RYPang_upper->TransAngle(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,recq0[mu],recq1[mu],recq2[mu],recq3[mu]); |
| 1020 |
|
qRoll[sizeqmcmd]=RYPang_upper->Kren; |
| 1021 |
|
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
| 1022 |
|
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
| 1023 |
|
} |
| 1024 |
|
if(recqtime[mu]>=u_time){ |
| 1025 |
|
Int_t sizeqmcmd = qtime.size(); |
| 1026 |
|
inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw); |
| 1027 |
|
qtime[sizeqmcmd]=u_time; |
| 1028 |
|
q0[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][0]; |
| 1029 |
|
q1[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][1]; |
| 1030 |
|
q2[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][2]; |
| 1031 |
|
q3[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][3]; |
| 1032 |
|
qmode[sizeqmcmd]=holeq(lowerqtime,qtime[sizeqmcmd],L_QQ_Q_l_lower,L_QQ_Q_l_upper,ui); |
| 1033 |
|
lowerqtime = u_time; |
| 1034 |
|
orbits.getPosition((double) (u_time - gltle->GetFromTime())/60., &eCi); |
| 1035 |
|
RYPang_upper->TransAngle(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,L_QQ_Q_l_upper->quat[0][0],L_QQ_Q_l_upper->quat[0][1],L_QQ_Q_l_upper->quat[0][2],L_QQ_Q_l_upper->quat[0][3]); |
| 1036 |
|
qRoll[sizeqmcmd]=RYPang_upper->Kren; |
| 1037 |
|
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
| 1038 |
|
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
| 1039 |
|
CopyQ(L_QQ_Q_l_lower,L_QQ_Q_l_upper); |
| 1040 |
|
break; |
| 1041 |
|
} |
| 1042 |
} |
} |
|
oi=ui; |
|
|
goto closethisloop; |
|
|
//_0 = true; |
|
| 1043 |
} |
} |
| 1044 |
fgh++; |
} |
|
CopyQ(L_QQ_Q_l_lower,L_QQ_Q_l_upper); |
|
|
CopyAng(RYPang_lower,RYPang_upper); |
|
|
//_0 = true; |
|
|
}; |
|
|
//cin>>grib; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
closethisloop: |
|
|
// |
|
|
if ( debug ) printf(" I am There \n"); |
|
|
// |
|
|
if (((atime>(UInt_t)upperqtime)||(atime<(UInt_t)lowerqtime)) && neventsm>0 ){ |
|
|
if ( debug ) printf(" I am there \n"); |
|
|
// |
|
|
lowerqtime = upperqtime; |
|
|
Long64_t maxloop = 100000000LL; |
|
|
Long64_t mn = 0; |
|
|
bool gh=false; |
|
|
ooi=oi; |
|
|
if ( verbose ) printf(" OrbitalInfoCore: sync with quaternions data upperqtime %u lowerqtime %u atime %u \n",(UInt_t)upperqtime,(UInt_t)lowerqtime,atime); |
|
|
while (!gh){ |
|
|
if ( mn > maxloop ){ |
|
|
if ( verbose ) printf(" OrbitalInfoCore: quaternions sync out of range! exiting\n"); |
|
|
gh = true; |
|
|
neventsm = 0; |
|
|
}; |
|
|
mn++; |
|
|
if (oi<5) oi++; |
|
|
else oi=0; |
|
|
if (oi==0 && numrec > 0){ |
|
|
if ( debug ) printf(" mumble \n"); |
|
|
mcreen++; |
|
|
if (mcreen == numrec){ |
|
|
mctren++; |
|
|
mcreen = 0; |
|
|
l0trm->GetEntry(mctren); |
|
|
numrec = mcmdev->Records->GetEntries(); |
|
|
} |
|
|
CopyQ(L_QQ_Q_l_lower,L_QQ_Q_l_upper); |
|
|
CopyAng(RYPang_lower,RYPang_upper); |
|
|
mcmdrc = (pamela::McmdRecord*)mcmdev->Records->At(mcreen); |
|
|
if ((int)mcmdrc->ID1 == 226){ |
|
|
L_QQ_Q_l_upper->fill(mcmdrc->McmdData); |
|
|
upperqtime = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
|
|
if (upperqtime<lowerqtime){ |
|
|
upperqtime=runinfo->RUNTRAILER_TIME; |
|
|
CopyQ(L_QQ_Q_l_upper,L_QQ_Q_l_lower); |
|
|
CopyAng(RYPang_upper,RYPang_lower); |
|
|
}else{ |
|
|
orbits.getPosition((double) (upperqtime - gltle->GetFromTime())/60., &eCi); |
|
|
RYPang_upper->TransAngle(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,L_QQ_Q_l_upper->quat[0][0],L_QQ_Q_l_upper->quat[0][1],L_QQ_Q_l_upper->quat[0][2],L_QQ_Q_l_upper->quat[0][3]); |
|
| 1045 |
} |
} |
|
// re--; |
|
|
gh=true; |
|
|
} |
|
|
}else{ |
|
|
if ((Int_t)L_QQ_Q_l_upper->time[oi]>(Int_t)L_QQ_Q_l_upper->time[0]){ |
|
|
upperqtime = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
|
|
orbits.getPosition((double) (upperqtime - gltle->GetFromTime())/60., &eCi); |
|
|
RYPang_upper->TransAngle(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,L_QQ_Q_l_upper->quat[oi][0],L_QQ_Q_l_upper->quat[oi][1],L_QQ_Q_l_upper->quat[oi][2],L_QQ_Q_l_upper->quat[oi][3]); |
|
|
orbits.getPosition((double) (lowerqtime - gltle->GetFromTime())/60., &eCi); |
|
|
RYPang_lower->TransAngle(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,L_QQ_Q_l_upper->quat[oi-1][0],L_QQ_Q_l_upper->quat[oi-1][1],L_QQ_Q_l_upper->quat[oi-1][2],L_QQ_Q_l_upper->quat[oi-1][3]); |
|
|
// re--; |
|
|
gh=true; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
if ( verbose ) printf(" OrbitalInfoCore: sync with quaternions data now we have upperqtime %u lowerqtime %u atime %u \n",(UInt_t)upperqtime,(UInt_t)lowerqtime,atime); |
|
|
}; |
|
|
// |
|
|
if ( debug ) printf(" I am THIS \n"); |
|
|
// |
|
|
// Fill in quaternions and angles |
|
|
// |
|
|
if ((atime<=(UInt_t)upperqtime)&&(atime>=(UInt_t)lowerqtime)&& neventsm>0){ |
|
|
if ( debug ) printf(" I am this \n"); |
|
|
UInt_t tut = holeq(lowerqtime, upperqtime, L_QQ_Q_l_lower, L_QQ_Q_l_upper, oi); |
|
|
if (oi == 0){ |
|
|
if ((tut!=5)||(tut!=6)){ |
|
|
incli = (L_QQ_Q_l_upper->quat[0][0]-L_QQ_Q_l_lower->quat[ooi][0])/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_lower->time[ooi]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->q0 = incli*atime+L_QQ_Q_l_upper->quat[0][0]-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
|
|
incli = (L_QQ_Q_l_upper->quat[0][1]-L_QQ_Q_l_lower->quat[ooi][1])/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_lower->time[ooi]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->q1 = incli*atime+L_QQ_Q_l_upper->quat[0][1]-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
|
|
incli = (L_QQ_Q_l_upper->quat[0][2]-L_QQ_Q_l_lower->quat[ooi][2])/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_lower->time[ooi]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->q2 = incli*atime+L_QQ_Q_l_upper->quat[0][2]-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
|
|
incli = (L_QQ_Q_l_upper->quat[0][3]-L_QQ_Q_l_lower->quat[ooi][3])/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_lower->time[ooi]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->q3 = incli*atime+L_QQ_Q_l_upper->quat[0][3]-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
|
|
|
|
|
incli = (RYPang_upper->Tangazh-RYPang_lower->Tangazh)/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_lower->time[ooi]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->theta = incli*atime+RYPang_upper->Tangazh-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
|
|
incli = (RYPang_upper->Ryskanie-RYPang_lower->Ryskanie)/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_lower->time[ooi]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->phi = incli*atime+RYPang_upper->Ryskanie-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
|
|
incli = (RYPang_upper->Kren-RYPang_lower->Kren)/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_lower->time[ooi]*1000))); |
|
|
orbitalinfo->etha = incli*atime+RYPang_upper->Kren-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
|
|
} |
|
|
if (tut==6){ |
|
|
if (fabs(RYPang_lower->Kren-RYPang_upper->Kren)<0.1){ |
|
|
incli = (L_QQ_Q_l_upper->quat[0][0]-L_QQ_Q_l_lower->quat[ooi][0])/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_lower->time[ooi]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->q0 = incli*atime+L_QQ_Q_l_upper->quat[0][0]-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
|
|
incli = (L_QQ_Q_l_upper->quat[0][1]-L_QQ_Q_l_lower->quat[ooi][1])/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_lower->time[ooi]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->q1 = incli*atime+L_QQ_Q_l_upper->quat[0][1]-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
|
|
incli = (L_QQ_Q_l_upper->quat[0][2]-L_QQ_Q_l_lower->quat[ooi][2])/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_lower->time[ooi]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->q2 = incli*atime+L_QQ_Q_l_upper->quat[0][2]-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
|
|
incli = (L_QQ_Q_l_upper->quat[0][3]-L_QQ_Q_l_lower->quat[ooi][3])/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_lower->time[ooi]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->q3 = incli*atime+L_QQ_Q_l_upper->quat[0][3]-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
|
|
|
|
|
incli = (RYPang_upper->Tangazh-RYPang_lower->Tangazh)/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_lower->time[ooi]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->theta = incli*atime+RYPang_upper->Tangazh-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
|
|
incli = (RYPang_upper->Ryskanie-RYPang_lower->Ryskanie)/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_lower->time[ooi]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->phi = incli*atime+RYPang_upper->Ryskanie-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
|
|
//cout<<"upper = "<<RYPang_upper->Ryskanie<<" lower = "<<RYPang_lower->Ryskanie<<" timeupper[0] = "<<L_QQ_Q_l_upper->time[0]-5500000<<" timelower["<<ooi<<"] = "<<L_QQ_Q_l_lower->time[ooi]-5500000<<" Ryscanie = "<<orbitalinfo->phi<<" incli = "<<incli<<" upper-lower = "<<RYPang_upper->Ryskanie-RYPang_lower->Ryskanie<<" Dtime = "<<dbtime->DBabsTime((UInt_t)L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)<<"-"<<dbtime->DBabsTime((UInt_t)L_QQ_Q_l_lower->time[ooi]*1000-DeltaOBT*1000)<<" atime = "<<atime<<"\n"; |
|
|
//cin>>grib; |
|
|
incli = (RYPang_upper->Kren-RYPang_lower->Kren)/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_lower->time[ooi]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->etha = incli*atime+RYPang_upper->Kren-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
|
| 1046 |
} |
} |
| 1047 |
|
if ( debug ) printf(" ciccio \n"); |
| 1048 |
} |
} |
| 1049 |
} else { |
} |
|
if((tut!=6)||(tut!=7)||(tut!=9)){ |
|
|
incli = (L_QQ_Q_l_upper->quat[oi][0]-L_QQ_Q_l_upper->quat[oi-1][0])/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi-1]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->q0 = incli*atime+L_QQ_Q_l_upper->quat[oi][0]-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
|
|
incli = (L_QQ_Q_l_upper->quat[oi][1]-L_QQ_Q_l_upper->quat[oi-1][1])/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi-1]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->q1 = incli*atime+L_QQ_Q_l_upper->quat[oi][1]-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
|
|
incli = (L_QQ_Q_l_upper->quat[oi][2]-L_QQ_Q_l_upper->quat[oi-1][2])/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi-1]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->q2 = incli*atime+L_QQ_Q_l_upper->quat[oi][2]-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
|
|
incli = (L_QQ_Q_l_upper->quat[oi][3]-L_QQ_Q_l_upper->quat[oi-1][3])/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi-1]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->q3 = incli*atime+L_QQ_Q_l_upper->quat[oi][3]-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
|
| 1050 |
|
|
| 1051 |
incli = (RYPang_upper->Tangazh-RYPang_lower->Tangazh)/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi-1]*1000-DeltaOBT*1000))); |
if(qtime.size()==0){ |
| 1052 |
orbitalinfo->theta = incli*atime+RYPang_upper->Tangazh-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
for(UInt_t my=0;my<recqtime.size();my++){ |
| 1053 |
incli = (RYPang_upper->Ryskanie-RYPang_lower->Ryskanie)/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi-1]*1000-DeltaOBT*1000))); |
Int_t sizeqmcmd = qtime.size(); |
| 1054 |
orbitalinfo->phi = incli*atime+RYPang_upper->Ryskanie-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw); |
| 1055 |
//cout<<"upper = "<<RYPang_upper->Ryskanie<<" lower = "<<RYPang_lower->Ryskanie<<" timeupper["<<oi<<"] = "<<L_QQ_Q_l_upper->time[oi]-5500000<<" timelower["<<oi-1<<"] = "<<L_QQ_Q_l_lower->time[oi-1]-5500000<<" Ryscanie = "<<orbitalinfo->phi<<" incli = "<<incli<<" upper-lower = "<<RYPang_upper->Ryskanie-RYPang_lower->Ryskanie<<" Dtime = "<<dbtime->DBabsTime((UInt_t)L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)<<"-"<<dbtime->DBabsTime((UInt_t)L_QQ_Q_l_lower->time[oi-1]*1000-DeltaOBT*1000)<<" atime = "<<atime<<"\n"; |
qtime[sizeqmcmd]=recqtime[my]; |
| 1056 |
//cin>>grib; |
q0[sizeqmcmd]=recq0[my]; |
| 1057 |
incli = (RYPang_upper->Kren-RYPang_lower->Kren)/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi-1]*1000-DeltaOBT*1000))); |
q1[sizeqmcmd]=recq1[my]; |
| 1058 |
orbitalinfo->etha = incli*atime+RYPang_upper->Kren-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
q2[sizeqmcmd]=recq2[my]; |
| 1059 |
} |
q3[sizeqmcmd]=recq3[my]; |
| 1060 |
if (tut==6){ |
qmode[sizeqmcmd]=-10; |
| 1061 |
if (fabs(RYPang_lower->Kren-RYPang_upper->Kren)<0.1){ |
orbits.getPosition((double) (qtime[sizeqmcmd] - gltle->GetFromTime())/60., &eCi); |
| 1062 |
incli = (L_QQ_Q_l_upper->quat[oi][0]-L_QQ_Q_l_upper->quat[oi-1][0])/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi-1]*1000-DeltaOBT*1000))); |
RYPang_upper->TransAngle(eCi.getPos().m_x,eCi.getPos().m_y,eCi.getPos().m_z,eCi.getVel().m_x,eCi.getVel().m_y,eCi.getVel().m_z,recq0[my],recq1[my],recq2[my],recq3[my]); |
| 1063 |
orbitalinfo->q0 = incli*atime+L_QQ_Q_l_upper->quat[oi][0]-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
qRoll[sizeqmcmd]=RYPang_upper->Kren; |
| 1064 |
incli = (L_QQ_Q_l_upper->quat[oi][1]-L_QQ_Q_l_upper->quat[oi-1][1])/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi-1]*1000-DeltaOBT*1000))); |
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
| 1065 |
orbitalinfo->q1 = incli*atime+L_QQ_Q_l_upper->quat[oi][1]-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
| 1066 |
incli = (L_QQ_Q_l_upper->quat[oi][2]-L_QQ_Q_l_upper->quat[oi-1][2])/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi-1]*1000-DeltaOBT*1000))); |
} |
| 1067 |
orbitalinfo->q2 = incli*atime+L_QQ_Q_l_upper->quat[oi][2]-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
} |
|
incli = (L_QQ_Q_l_upper->quat[oi][3]-L_QQ_Q_l_upper->quat[oi-1][3])/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi-1]*1000-DeltaOBT*1000))); |
|
|
orbitalinfo->q3 = incli*atime+L_QQ_Q_l_upper->quat[oi][3]-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
|
| 1068 |
|
|
| 1069 |
incli = (RYPang_upper->Tangazh-RYPang_lower->Tangazh)/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi-1]*1000-DeltaOBT*1000))); |
if ( debug ) printf(" fuffi \n"); |
| 1070 |
orbitalinfo->theta = incli*atime+RYPang_upper->Tangazh-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
|
| 1071 |
incli = (RYPang_upper->Ryskanie-RYPang_lower->Ryskanie)/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi-1]*1000-DeltaOBT*1000))); |
if ( debug ) printf(" puffi \n"); |
| 1072 |
orbitalinfo->phi = incli*atime+RYPang_upper->Ryskanie-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
Double_t tmin = 9999999999.; |
| 1073 |
//cout<<"upper = "<<RYPang_upper->Ryskanie<<" lower = "<<RYPang_lower->Ryskanie<<" timeupper["<<oi<<"] = "<<L_QQ_Q_l_upper->time[oi]-5500000<<" timelower["<<oi-1<<"] = "<<L_QQ_Q_l_lower->time[oi-1]-5500000<<" Ryscanie = "<<orbitalinfo->phi<<" incli = "<<incli<<" upper-lower = "<<RYPang_upper->Ryskanie-RYPang_lower->Ryskanie<<" Dtime = "<<dbtime->DBabsTime((UInt_t)L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)<<"-"<<dbtime->DBabsTime((UInt_t)L_QQ_Q_l_lower->time[oi-1]*1000-DeltaOBT*1000)<<" atime = "<<atime<<"\n"; |
Double_t tmax = 0.; |
| 1074 |
//cin>>grib; |
for(UInt_t tre = 0;tre<qtime.size();tre++){ |
| 1075 |
incli = (RYPang_upper->Kren-RYPang_lower->Kren)/(dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000))-dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi-1]*1000-DeltaOBT*1000))); |
if(qtime[tre]>tmax)tmax = qtime[tre]; |
| 1076 |
orbitalinfo->etha = incli*atime+RYPang_upper->Kren-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
if(qtime[tre]<tmin)tmin = qtime[tre]; |
|
} |
|
|
} |
|
| 1077 |
} |
} |
| 1078 |
// |
if ( debug ) printf(" gnfuffi \n"); |
| 1079 |
orbitalinfo->mode = holeq(lowerqtime, upperqtime, L_QQ_Q_l_lower, L_QQ_Q_l_upper, oi); |
|
| 1080 |
// |
} // if we processed first event |
| 1081 |
} else { |
|
| 1082 |
if ( debug ) printf(" ops no incl! \n"); |
|
| 1083 |
orbitalinfo->mode = 10; |
//Filling Inclination information |
| 1084 |
}; |
Double_t incli = 0; |
| 1085 |
|
if ( qtime.size() > 1 ){ |
| 1086 |
|
for(UInt_t mu = must;mu<qtime.size()-1;mu++){ |
| 1087 |
|
if ( debug ) printf(" ??grfuffi %i sixe %i must %i \n",mu,qtime.size()-1,must); |
| 1088 |
|
if(qtime[mu+1]>qtime[mu]){ |
| 1089 |
|
if ( debug ) printf(" grfuffi2 %i \n",mu); |
| 1090 |
|
if(atime<=qtime[mu+1] && atime>=qtime[mu]){ |
| 1091 |
|
must = mu; |
| 1092 |
|
if ( debug ) printf(" grfuffi3 %i \n",mu); |
| 1093 |
|
incli = (qPitch[mu+1]-qPitch[mu])/(qtime[mu+1]-qtime[mu]); |
| 1094 |
|
orbitalinfo->theta = incli*atime+qPitch[mu+1]-incli*qtime[mu+1]; |
| 1095 |
|
incli = (qRoll[mu+1]-qRoll[mu])/(qtime[mu+1]-qtime[mu]); |
| 1096 |
|
orbitalinfo->etha = incli*atime+qRoll[mu+1]-incli*qtime[mu+1]; |
| 1097 |
|
incli = (qYaw[mu+1]-qYaw[mu])/(qtime[mu+1]-qtime[mu]); |
| 1098 |
|
orbitalinfo->phi = incli*atime+qYaw[mu+1]-incli*qtime[mu+1]; |
| 1099 |
|
|
| 1100 |
|
incli = (q0[mu+1]-q0[mu])/(qtime[mu+1]-qtime[mu]); |
| 1101 |
|
orbitalinfo->q0 = incli*atime+q0[mu+1]-incli*qtime[mu+1]; |
| 1102 |
|
incli = (q1[mu+1]-q1[mu])/(qtime[mu+1]-qtime[mu]); |
| 1103 |
|
orbitalinfo->q1 = incli*atime+q1[mu+1]-incli*qtime[mu+1]; |
| 1104 |
|
incli = (q2[mu+1]-q2[mu])/(qtime[mu+1]-qtime[mu]); |
| 1105 |
|
orbitalinfo->q2 = incli*atime+q2[mu+1]-incli*qtime[mu+1]; |
| 1106 |
|
incli = (q3[mu+1]-q3[mu])/(qtime[mu+1]-qtime[mu]); |
| 1107 |
|
orbitalinfo->q3 = incli*atime+q3[mu+1]-incli*qtime[mu+1]; |
| 1108 |
|
|
| 1109 |
|
orbitalinfo->TimeGap = qtime[mu+1]-qtime[mu]; |
| 1110 |
|
orbitalinfo->mode = qmode[mu+1]; |
| 1111 |
|
//if(qmode[mu+1]==-10) orbitalinfo->R10r = true;else orbitalinfo->R10r = false; |
| 1112 |
|
//reserved for next versions Vitaly. |
| 1113 |
|
/*if(qmode[mu+1]==-10 || qmode[mu+1]==0 || qmode[mu+1]==1 || qmode[mu+1]==3 || qmode[mu+1]==4 || qmode[mu+1]==6){ |
| 1114 |
|
//linear interpolation |
| 1115 |
|
incli = (q0[mu+1]-q0[mu])/(qtime[mu+1]-qtime[mu]); |
| 1116 |
|
orbitalinfo->q0 = incli*atime+q0[mu+1]-incli*qtime[mu+1]; |
| 1117 |
|
incli = (q1[mu+1]-q1[mu])/(qtime[mu+1]-qtime[mu]); |
| 1118 |
|
orbitalinfo->q1 = incli*atime+q1[mu+1]-incli*qtime[mu+1]; |
| 1119 |
|
incli = (q2[mu+1]-q2[mu])/(qtime[mu+1]-qtime[mu]); |
| 1120 |
|
orbitalinfo->q2 = incli*atime+q2[mu+1]-incli*qtime[mu+1]; |
| 1121 |
|
incli = (q3[mu+1]-q3[mu])/(qtime[mu+1]-qtime[mu]); |
| 1122 |
|
orbitalinfo->q3 = incli*atime+q3[mu+1]-incli*qtime[mu+1]; |
| 1123 |
|
}else{ |
| 1124 |
|
//sine interpolation |
| 1125 |
|
for(UInt_t mt=0;mt<q0sine.size();mt++){ |
| 1126 |
|
if(atime<=q0sine[mt].finishPoint && atime>=q0sine[mt].startPoint){ |
| 1127 |
|
if(!q0sine[mt].NeedFit)orbitalinfo->q0=q0sine[mt].A*sin(q0sine[mt].b*atime+q0sine[mt].c);else{ |
| 1128 |
|
incli = (q0[mu+1]-q0[mu])/(qtime[mu+1]-qtime[mu]); |
| 1129 |
|
orbitalinfo->q0 = incli*atime+q0[mu+1]-incli*qtime[mu+1]; |
| 1130 |
|
} |
| 1131 |
|
} |
| 1132 |
|
if(atime<=q1sine[mt].finishPoint && atime>=q1sine[mt].startPoint){ |
| 1133 |
|
if(!q1sine[mt].NeedFit)orbitalinfo->q1=q1sine[mt].A*sin(q1sine[mt].b*atime+q1sine[mt].c);else{ |
| 1134 |
|
incli = (q1[mu+1]-q1[mu])/(qtime[mu+1]-qtime[mu]); |
| 1135 |
|
orbitalinfo->q1 = incli*atime+q1[mu+1]-incli*qtime[mu+1]; |
| 1136 |
|
} |
| 1137 |
|
} |
| 1138 |
|
if(atime<=q2sine[mt].finishPoint && atime>=q2sine[mt].startPoint){ |
| 1139 |
|
if(!q2sine[mt].NeedFit)orbitalinfo->q2=q0sine[mt].A*sin(q2sine[mt].b*atime+q2sine[mt].c);else{ |
| 1140 |
|
incli = (q2[mu+1]-q2[mu])/(qtime[mu+1]-qtime[mu]); |
| 1141 |
|
orbitalinfo->q2 = incli*atime+q2[mu+1]-incli*qtime[mu+1]; |
| 1142 |
|
} |
| 1143 |
|
} |
| 1144 |
|
if(atime<=q3sine[mt].finishPoint && atime>=q3sine[mt].startPoint){ |
| 1145 |
|
if(!q3sine[mt].NeedFit)orbitalinfo->q3=q0sine[mt].A*sin(q3sine[mt].b*atime+q3sine[mt].c);else{ |
| 1146 |
|
incli = (q3[mu+1]-q3[mu])/(qtime[mu+1]-qtime[mu]); |
| 1147 |
|
orbitalinfo->q3 = incli*atime+q3[mu+1]-incli*qtime[mu+1]; |
| 1148 |
|
} |
| 1149 |
|
} |
| 1150 |
|
if(atime<=Yawsine[mt].finishPoint && atime>=Yawsine[mt].startPoint){ |
| 1151 |
|
if(!Yawsine[mt].NeedFit)orbitalinfo->phi=Yawsine[mt].A*sin(Yawsine[mt].b*atime+Yawsine[mt].c);else{ |
| 1152 |
|
incli = (qYaw[mu+1]-qYaw[mu])/(qtime[mu+1]-qtime[mu]); |
| 1153 |
|
orbitalinfo->phi = incli*atime+qYaw[mu+1]-incli*qtime[mu+1]; |
| 1154 |
|
} |
| 1155 |
|
} |
| 1156 |
|
} |
| 1157 |
|
}*/ |
| 1158 |
|
//q0testing->Fill(atime,orbitalinfo->q0,100); |
| 1159 |
|
//q1testing->Fill(atime,orbitalinfo->q1,100); |
| 1160 |
|
//Pitchtesting->Fill(atime,orbitalinfo->etha); |
| 1161 |
|
//q2testing->Fill(atime,orbitalinfo->q2); |
| 1162 |
|
//q3testing->Fill(atime,orbitalinfo->q3); |
| 1163 |
|
if ( debug ) printf(" grfuffi4 %i \n",mu); |
| 1164 |
|
break; |
| 1165 |
|
} |
| 1166 |
|
} |
| 1167 |
|
} |
| 1168 |
|
} |
| 1169 |
|
if ( debug ) printf(" grfuffi5 \n"); |
| 1170 |
// |
// |
| 1171 |
// ops no inclination information |
// ops no inclination information |
| 1172 |
// |
// |
| 1173 |
|
|
| 1174 |
if ( orbitalinfo->q0< -999 || orbitalinfo->q1 < -999 || orbitalinfo->q2 < -999 || orbitalinfo->q3 < -999 || orbitalinfo->q0 != orbitalinfo->q0 || orbitalinfo->q1 != orbitalinfo->q1 || orbitalinfo->q2 != orbitalinfo->q2 || orbitalinfo->q3 != orbitalinfo->q3 ){ |
if ( orbitalinfo->q0< -999 || orbitalinfo->q1 < -999 || orbitalinfo->q2 < -999 || orbitalinfo->q3 < -999 || orbitalinfo->q0 != orbitalinfo->q0 || orbitalinfo->q1 != orbitalinfo->q1 || orbitalinfo->q2 != orbitalinfo->q2 || orbitalinfo->q3 != orbitalinfo->q3 ){ |
| 1175 |
orbitalinfo->mode = 10; |
orbitalinfo->mode = 10; |
| 1176 |
orbitalinfo->q0 = -1000.; |
orbitalinfo->q0 = -1000.; |
| 1180 |
orbitalinfo->etha = -1000.; |
orbitalinfo->etha = -1000.; |
| 1181 |
orbitalinfo->phi = -1000.; |
orbitalinfo->phi = -1000.; |
| 1182 |
orbitalinfo->theta = -1000.; |
orbitalinfo->theta = -1000.; |
| 1183 |
}; |
if ( debug ) printf(" grfuffi6 \n"); |
| 1184 |
|
} |
| 1185 |
// |
// |
| 1186 |
|
if ( debug ) printf(" filling \n"); |
| 1187 |
// ######################################################################################################################### |
// ######################################################################################################################### |
| 1188 |
// |
// |
| 1189 |
// fill orbital positions |
// fill orbital positions |
| 1194 |
lon = (coo.m_Lon > M_PI) ? rad2deg(coo.m_Lon - 2*M_PI) : rad2deg(coo.m_Lon); |
lon = (coo.m_Lon > M_PI) ? rad2deg(coo.m_Lon - 2*M_PI) : rad2deg(coo.m_Lon); |
| 1195 |
lat = rad2deg(coo.m_Lat); |
lat = rad2deg(coo.m_Lat); |
| 1196 |
alt = coo.m_Alt; |
alt = coo.m_Alt; |
| 1197 |
|
if ( debug ) printf(" coord done \n"); |
| 1198 |
// |
// |
| 1199 |
if( lon<180 && lon>-180 && lat<90 && lat>-90 && alt>0 ){ |
if( lon<180 && lon>-180 && lat<90 && lat>-90 && alt>0 ){ |
| 1200 |
// |
// |
| 1204 |
// |
// |
| 1205 |
// compute mag field components and L shell. |
// compute mag field components and L shell. |
| 1206 |
// |
// |
| 1207 |
|
if ( debug ) printf(" call igrf feldg \n"); |
| 1208 |
feldg_(&lat, &lon, &alt, &bnorth, &beast, &bdown, &babs); |
feldg_(&lat, &lon, &alt, &bnorth, &beast, &bdown, &babs); |
| 1209 |
|
if ( debug ) printf(" call igrf shellg \n"); |
| 1210 |
shellg_(&lat, &lon, &alt, &dimo, &xl, &icode, &bab1); |
shellg_(&lat, &lon, &alt, &dimo, &xl, &icode, &bab1); |
| 1211 |
|
if ( debug ) printf(" call igrf findb \n"); |
| 1212 |
findb0_(&stps, &bdel, &value, &bequ, &rr0); |
findb0_(&stps, &bdel, &value, &bequ, &rr0); |
| 1213 |
// |
// |
| 1214 |
|
if ( debug ) printf(" done igrf \n"); |
| 1215 |
orbitalinfo->Bnorth = bnorth; |
orbitalinfo->Bnorth = bnorth; |
| 1216 |
orbitalinfo->Beast = beast; |
orbitalinfo->Beast = beast; |
| 1217 |
orbitalinfo->Bdown = bdown; |
orbitalinfo->Bdown = bdown; |
| 1218 |
orbitalinfo->Babs = babs; |
orbitalinfo->Babs = babs; |
| 1219 |
|
orbitalinfo->M = dimo; |
| 1220 |
orbitalinfo->BB0 = babs/bequ; |
orbitalinfo->BB0 = babs/bequ; |
| 1221 |
orbitalinfo->L = xl; |
orbitalinfo->L = xl; |
| 1222 |
// Set Stormer vertical cutoff using L shell. |
// Set Stormer vertical cutoff using L shell. |
| 1223 |
orbitalinfo->cutoff[0] = 14.9/(xl*xl); |
orbitalinfo->cutoffsvl = 14.295 / (xl*xl); // |
| 1224 |
|
/* |
| 1225 |
|
---------- Forwarded message ---------- |
| 1226 |
|
Date: Wed, 09 May 2012 12:16:47 +0200 |
| 1227 |
|
From: Alessandro Bruno <alessandro.bruno@ba.infn.it> |
| 1228 |
|
To: Mirko Boezio <mirko.boezio@ts.infn.it> |
| 1229 |
|
Cc: Francesco S. Cafagna <Francesco.Cafagna@ba.infn.it> |
| 1230 |
|
Subject: Störmer vertical cutoff |
| 1231 |
|
|
| 1232 |
|
Ciao Mirko, |
| 1233 |
|
volevo segnalarti che il valore dello Störmer vertical cutoff nel Level2 è |
| 1234 |
|
sovrastimato di circa il 4%. |
| 1235 |
|
Dopo un'approfondita analisi con l'IGRF-05 abbiamo ricavano un valore pari |
| 1236 |
|
a: 14.295 / L^2 anzichè 14.9 / L^2, valore obsoleto in quanto riferito agli |
| 1237 |
|
anni '50. |
| 1238 |
|
*/ |
| 1239 |
|
//14.9/(xl*xl); |
| 1240 |
|
orbitalinfo->igrf_icode = icode; |
| 1241 |
// |
// |
| 1242 |
}; |
} |
| 1243 |
|
// |
| 1244 |
|
if ( debug ) printf(" pitch angle \n"); |
| 1245 |
// |
// |
| 1246 |
// pitch angles |
// pitch angles |
| 1247 |
// |
// |
| 1248 |
if ( orbitalinfo->mode != 10 && orbitalinfo->mode != 5 && orbitalinfo->mode !=7 && orbitalinfo->mode != 9 ){ |
//if ( orbitalinfo->mode != 10 && orbitalinfo->mode != 5 && orbitalinfo->mode !=7 && orbitalinfo->mode != 9 ){ |
| 1249 |
|
if( orbitalinfo->TimeGap>0 && orbitalinfo->TimeGap<2000000){ |
| 1250 |
// |
// |
| 1251 |
Float_t Bx = -orbitalinfo->Bdown; //don't need for PamExp ExpOnly for all geography areas |
if ( debug ) printf(" timegap %f \n",orbitalinfo->TimeGap); |
| 1252 |
Float_t By = orbitalinfo->Beast; //don't need for PamExp ExpOnly for all geography areas |
Float_t Bx = -orbitalinfo->Bdown; |
| 1253 |
Float_t Bz = orbitalinfo->Bnorth; //don't need for PamExp ExpOnly for all geography areas |
Float_t By = orbitalinfo->Beast; |
| 1254 |
|
Float_t Bz = orbitalinfo->Bnorth; |
| 1255 |
// |
// |
| 1256 |
TMatrixD Fij = PO->ECItoGreenwich(PO->QuatoECI(orbitalinfo->q0,orbitalinfo->q1,orbitalinfo->q2,orbitalinfo->q3),orbitalinfo->absTime); |
TMatrixD Fij = PO->ECItoGreenwich(PO->QuatoECI(orbitalinfo->q0,orbitalinfo->q1,orbitalinfo->q2,orbitalinfo->q3),orbitalinfo->absTime); |
| 1257 |
|
TMatrixD Gij = PO->ColPermutation(Fij); |
| 1258 |
TMatrixD Dij = PO->GreenwichtoGEO(orbitalinfo->lat,orbitalinfo->lon,Fij); |
TMatrixD Dij = PO->GreenwichtoGEO(orbitalinfo->lat,orbitalinfo->lon,Fij); |
| 1259 |
TMatrixD Iij = PO->ColPermutation(Dij); |
TMatrixD Iij = PO->ColPermutation(Dij); |
| 1260 |
// |
// |
| 1261 |
A1 = Iij(0,2); |
orbitalinfo->Iij.ResizeTo(Iij); |
| 1262 |
A2 = Iij(1,2); |
orbitalinfo->Iij = Iij; |
| 1263 |
A3 = Iij(2,2); |
// |
| 1264 |
// |
// A1 = Iij(0,2); |
| 1265 |
orbitalinfo->pamzenitangle = (Float_t)PO->GetPitchAngle(1,0,0,A1,A2,A3); // Angle between zenit and Pamela's main axiz |
// A2 = Iij(1,2); |
| 1266 |
orbitalinfo->pamBangle = (Float_t)PO->GetPitchAngle(A1,A2,A3,Bx,By,Bz); // Angle between Pamela's main axiz and B |
// A3 = Iij(2,2); |
| 1267 |
// |
// |
| 1268 |
|
// orbitalinfo->pamzenitangle = (Float_t)PO->GetPitchAngle(1,0,0,A1,A2,A3); // Angle between zenit and Pamela's main axiz |
| 1269 |
|
// orbitalinfo->pamBangle = (Float_t)PO->GetPitchAngle(A1,A2,A3,Bx,By,Bz); // Angle between Pamela's main axiz and B |
| 1270 |
|
// |
| 1271 |
|
if ( debug ) printf(" matrixes done \n"); |
| 1272 |
if ( !standalone && tof->ntrk() > 0 ){ |
if ( !standalone && tof->ntrk() > 0 ){ |
| 1273 |
|
if ( debug ) printf(" !standalone \n"); |
| 1274 |
// |
// |
| 1275 |
Int_t nn = 0; |
Int_t nn = 0; |
| 1276 |
for(Int_t nt=0; nt < tof->ntrk(); nt++){ |
for(Int_t nt=0; nt < tof->ntrk(); nt++){ |
| 1282 |
Double_t E22x = ptt->xtr_tof[3];//tr->x[3]; |
Double_t E22x = ptt->xtr_tof[3];//tr->x[3]; |
| 1283 |
Double_t E22y = ptt->ytr_tof[3];//tr->y[3]; |
Double_t E22y = ptt->ytr_tof[3];//tr->y[3]; |
| 1284 |
Double_t E22z = zin[3]; |
Double_t E22z = zin[3]; |
| 1285 |
if ( E11x < 100. && E11y < 100. && E22x < 100. && E22y < 100. ){ |
if ( (E11x < 100. && E11y < 100. && E22x < 100. && E22y < 100.) || ptt->trkseqno != -1 ){ |
| 1286 |
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)); |
| 1287 |
Double_t MyAzim = TMath::RadToDeg()*atan(TMath::Abs(E22y-E11y)/TMath::Abs(E22x-E11x)); |
// Double_t MyAzim = TMath::RadToDeg()*atan(TMath::Abs(E22y-E11y)/TMath::Abs(E22x-E11x)); |
| 1288 |
if(E22x-E11x>=0 && E22y-E11y <0) MyAzim = 360. - MyAzim; |
// if(E22x-E11x>=0 && E22y-E11y <0) MyAzim = 360. - MyAzim; |
| 1289 |
if(E22x-E11x>=0 && E22y-E11y >=0) MyAzim = MyAzim; |
// if(E22x-E11x>=0 && E22y-E11y >=0) MyAzim = MyAzim; |
| 1290 |
if(E22x-E11x<0 && E22y-E11y >0) MyAzim = 180. - MyAzim; |
// if(E22x-E11x<0 && E22y-E11y >0) MyAzim = 180. - MyAzim; |
| 1291 |
if(E22x-E11x<0 && E22y-E11y <0) MyAzim = 180. + MyAzim; |
// if(E22x-E11x<0 && E22y-E11y <0) MyAzim = 180. + MyAzim; |
| 1292 |
Px = (E22x-E11x)/norm; |
Px = (E22x-E11x)/norm; |
| 1293 |
Py = (E22y-E11y)/norm; |
Py = (E22y-E11y)/norm; |
| 1294 |
Pz = (E22z-E11z)/norm; |
Pz = (E22z-E11z)/norm; |
| 1295 |
// |
// |
|
TMatrixD Eij = PO->PamelatoGEO(Iij,Px,Py,Pz); |
|
|
// |
|
| 1296 |
t_orb->trkseqno = ptt->trkseqno; |
t_orb->trkseqno = ptt->trkseqno; |
| 1297 |
|
// |
| 1298 |
|
TMatrixD Eij = PO->PamelatoGEO(Iij,Px,Py,Pz); |
| 1299 |
|
t_orb->Eij.ResizeTo(Eij); |
| 1300 |
|
t_orb->Eij = Eij; |
| 1301 |
|
// |
| 1302 |
|
TMatrixD Sij = PO->PamelatoGEO(Gij,Px,Py,Pz); |
| 1303 |
|
t_orb->Sij.ResizeTo(Sij); |
| 1304 |
|
t_orb->Sij = Sij; |
| 1305 |
|
// |
| 1306 |
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); |
| 1307 |
|
// |
| 1308 |
|
// |
| 1309 |
|
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); |
| 1310 |
|
// |
| 1311 |
|
t_orb->cutoff = 59.3/(pow(orbitalinfo->L,2)*pow((1+sqrt(1-pow(orbitalinfo->L,-3/2)*cos(omega))),2)); |
| 1312 |
|
// |
| 1313 |
|
if ( t_orb->pitch != t_orb->pitch ) t_orb->pitch = -1000.; |
| 1314 |
|
if ( t_orb->cutoff != t_orb->cutoff ) t_orb->cutoff = -1000.; |
| 1315 |
|
// |
| 1316 |
|
if ( debug ) printf(" orbitalinfo->cutoffsvl %f vitaly %f \n",orbitalinfo->cutoffsvl,t_orb->cutoff); |
| 1317 |
// |
// |
| 1318 |
new(tor[nn]) OrbitalInfoTrkVar(*t_orb); |
new(tor[nn]) OrbitalInfoTrkVar(*t_orb); |
| 1319 |
nn++; |
nn++; |
| 1324 |
// |
// |
| 1325 |
}; |
}; |
| 1326 |
} else { |
} else { |
| 1327 |
if ( debug ) printf(" mmm... mode %u standalone %i ntrk %i \n",orbitalinfo->mode,standalone,tof->ntrk()); |
if ( debug ) printf(" mmm... mode %u standalone \n",orbitalinfo->mode); |
| 1328 |
}; |
} |
| 1329 |
// |
// |
| 1330 |
|
} else { |
| 1331 |
|
if ( !standalone && tof->ntrk() > 0 ){ |
| 1332 |
|
// |
| 1333 |
|
Int_t nn = 0; |
| 1334 |
|
for(Int_t nt=0; nt < tof->ntrk(); nt++){ |
| 1335 |
|
// |
| 1336 |
|
ToFTrkVar *ptt = tof->GetToFTrkVar(nt); |
| 1337 |
|
if ( ptt->trkseqno != -1 ){ |
| 1338 |
|
// |
| 1339 |
|
t_orb->trkseqno = ptt->trkseqno; |
| 1340 |
|
// |
| 1341 |
|
t_orb->Eij = 0; |
| 1342 |
|
// |
| 1343 |
|
t_orb->Sij = 0; |
| 1344 |
|
// |
| 1345 |
|
t_orb->pitch = -1000.; |
| 1346 |
|
// |
| 1347 |
|
t_orb->cutoff = -1000.; |
| 1348 |
|
// |
| 1349 |
|
new(tor[nn]) OrbitalInfoTrkVar(*t_orb); |
| 1350 |
|
nn++; |
| 1351 |
|
// |
| 1352 |
|
t_orb->Clear(); |
| 1353 |
|
// |
| 1354 |
|
}; |
| 1355 |
|
// |
| 1356 |
|
}; |
| 1357 |
|
}; |
| 1358 |
}; |
}; |
| 1359 |
// |
// |
| 1360 |
// Fill the class |
// Fill the class |
| 1367 |
// |
// |
| 1368 |
// Here you may want to clear some variables before processing another run |
// Here you may want to clear some variables before processing another run |
| 1369 |
// |
// |
| 1370 |
|
|
| 1371 |
|
//gStyle->SetOptStat(000000); |
| 1372 |
|
//gStyle->SetPalette(1); |
| 1373 |
|
|
| 1374 |
|
/*TCanvas* c1 = new TCanvas("c1","",1200,800); |
| 1375 |
|
//c1->Divide(1,4); |
| 1376 |
|
c1->cd(1); |
| 1377 |
|
//q0testing->Draw("colz"); |
| 1378 |
|
//c1->cd(2); |
| 1379 |
|
//q1testing->Draw("colz"); |
| 1380 |
|
//c1->cd(3); |
| 1381 |
|
Pitchtesting->Draw("colz"); |
| 1382 |
|
//c1->cd(4); |
| 1383 |
|
//q3testing->Draw("colz"); |
| 1384 |
|
c1->SaveAs("9.Rollhyst.png"); |
| 1385 |
|
delete c1;*/ |
| 1386 |
|
|
| 1387 |
|
if ( verbose ) printf(" Clear before new run \n"); |
| 1388 |
delete dbtime; |
delete dbtime; |
| 1389 |
if ( L_QQ_Q_l_upper ) delete L_QQ_Q_l_upper; |
|
| 1390 |
|
if ( mcmdrc ) mcmdrc->Clear(); |
| 1391 |
|
mcmdrc = 0; |
| 1392 |
|
|
| 1393 |
|
if ( verbose ) printf(" Clear before new run1 \n"); |
| 1394 |
if ( L_QQ_Q_l_lower ) delete L_QQ_Q_l_lower; |
if ( L_QQ_Q_l_lower ) delete L_QQ_Q_l_lower; |
| 1395 |
|
if ( verbose ) printf(" Clear before new run2 \n"); |
| 1396 |
|
if ( L_QQ_Q_l_upper ) delete L_QQ_Q_l_upper; |
| 1397 |
|
if ( verbose ) printf(" Clear before new run3 \n"); |
| 1398 |
if ( RYPang_upper ) delete RYPang_upper; |
if ( RYPang_upper ) delete RYPang_upper; |
| 1399 |
|
if ( verbose ) printf(" Clear before new run4 \n"); |
| 1400 |
if ( RYPang_lower ) delete RYPang_lower; |
if ( RYPang_lower ) delete RYPang_lower; |
| 1401 |
|
|
| 1402 |
|
if ( l0tr ) l0tr->Delete(); |
| 1403 |
|
|
| 1404 |
|
if ( verbose ) printf(" End run \n"); |
| 1405 |
|
|
| 1406 |
}; // process all the runs |
}; // process all the runs |
| 1407 |
|
|
| 1408 |
if (verbose) printf("\n Finished processing data \n"); |
if (verbose) printf("\n Finished processing data \n"); |
| 1422 |
// |
// |
| 1423 |
// Get entry from old tree |
// Get entry from old tree |
| 1424 |
// |
// |
| 1425 |
OrbitalInfotrclone->GetEntry(j); |
if ( OrbitalInfotrclone->GetEntry(j) <= 0 ) throw -36; |
| 1426 |
// |
// |
| 1427 |
// copy orbitalinfoclone to OrbitalInfo |
// copy orbitalinfoclone to OrbitalInfo |
| 1428 |
// |
// |
| 1436 |
}; |
}; |
| 1437 |
if (verbose) printf(" Finished successful copying!\n"); |
if (verbose) printf(" Finished successful copying!\n"); |
| 1438 |
}; |
}; |
| 1439 |
|
//if ( OrbitalInfotrclone ) OrbitalInfotrclone->Clear(); |
| 1440 |
|
//if ( OrbitalInfotrclone ) OrbitalInfotrclone->Delete(); |
| 1441 |
}; |
}; |
| 1442 |
// |
// |
| 1443 |
// Close files, delete old tree(s), write and close level2 file |
// Close files, delete old tree(s), write and close level2 file |
| 1444 |
// |
// |
| 1445 |
if ( l0File ) l0File->Close(); |
if ( l0File ) l0File->Close(); |
|
if ( tempfile ) tempfile->Close(); |
|
| 1446 |
if ( myfold ) gSystem->Unlink(tempname.str().c_str()); |
if ( myfold ) gSystem->Unlink(tempname.str().c_str()); |
| 1447 |
// |
// |
|
if ( runinfo ) runinfo->Close(); |
|
| 1448 |
if ( OrbitalInfotr ) OrbitalInfotr->SetName("OrbitalInfo"); |
if ( OrbitalInfotr ) OrbitalInfotr->SetName("OrbitalInfo"); |
|
if ( tof ) tof->Delete(); |
|
|
if ( ttof ) ttof->Delete(); |
|
| 1449 |
// |
// |
| 1450 |
if ( file ){ |
if ( file ){ |
| 1451 |
file->cd(); |
file->cd(); |
| 1452 |
file->Write(); |
if ( OrbitalInfotr ) OrbitalInfotr->Write("OrbitalInfo", TObject::kOverwrite); // 10 RED bug fixed |
| 1453 |
}; |
}; |
| 1454 |
// |
// |
| 1455 |
|
if (verbose) printf("\n Exiting...\n"); |
| 1456 |
|
|
| 1457 |
if ( myfold ) gSystem->Unlink(OrbitalInfofolder.str().c_str()); |
if ( myfold ) gSystem->Unlink(OrbitalInfofolder.str().c_str()); |
| 1458 |
// |
// |
| 1459 |
// the end |
// the end |
| 1462 |
dbc->Close(); |
dbc->Close(); |
| 1463 |
delete dbc; |
delete dbc; |
| 1464 |
}; |
}; |
|
if (verbose) printf("\n Exiting...\n"); |
|
|
if(OrbitalInfotr)OrbitalInfotr->Delete(); |
|
| 1465 |
// |
// |
| 1466 |
|
if (verbose) printf("\n Exiting...\n"); |
| 1467 |
|
if ( tempfile ) tempfile->Close(); |
| 1468 |
|
|
| 1469 |
if ( PO ) delete PO; |
if ( PO ) delete PO; |
| 1470 |
if ( orbitalinfo ) delete orbitalinfo; |
if ( gltle ) delete gltle; |
| 1471 |
if ( orbitalinfoclone ) delete orbitalinfoclone; |
if ( glparam ) delete glparam; |
| 1472 |
|
if ( glparam2 ) delete glparam2; |
| 1473 |
|
if ( glparam3 ) delete glparam3; |
| 1474 |
|
if (verbose) printf("\n Exiting3...\n"); |
| 1475 |
if ( glroot ) delete glroot; |
if ( glroot ) delete glroot; |
| 1476 |
|
if (verbose) printf("\n Exiting4...\n"); |
| 1477 |
|
if ( runinfo ) runinfo->Close(); |
| 1478 |
if ( runinfo ) delete runinfo; |
if ( runinfo ) delete runinfo; |
| 1479 |
|
|
| 1480 |
|
if ( debug ){ |
| 1481 |
|
cout << "1 0x" << OrbitalInfotr << endl; |
| 1482 |
|
cout << "2 0x" << OrbitalInfotrclone << endl; |
| 1483 |
|
cout << "3 0x" << l0tr << endl; |
| 1484 |
|
cout << "4 0x" << tempOrbitalInfo << endl; |
| 1485 |
|
cout << "5 0x" << ttof << endl; |
| 1486 |
|
} |
| 1487 |
|
// |
| 1488 |
|
if ( debug ) file->ls(); |
| 1489 |
// |
// |
| 1490 |
if(code < 0) throw code; |
if(code < 0) throw code; |
| 1491 |
return(code); |
return(code); |
| 1530 |
UInt_t holeq(Double_t lower,Double_t upper,Quaternions *Qlower, Quaternions *Qupper, UInt_t f){ |
UInt_t holeq(Double_t lower,Double_t upper,Quaternions *Qlower, Quaternions *Qupper, UInt_t f){ |
| 1531 |
|
|
| 1532 |
UInt_t hole = 10; |
UInt_t hole = 10; |
| 1533 |
bool R10l = false; // Sign of R10 mode in lower quaternions array |
Bool_t R10l = false; // Sign of R10 mode in lower quaternions array |
| 1534 |
bool R10u = false; // Sign of R10 mode in upper quaternions array |
Bool_t R10u = false; // Sign of R10 mode in upper quaternions array |
| 1535 |
bool insm = false; // Sign that we inside quaternions array |
Bool_t insm = false; // Sign that we inside quaternions array |
| 1536 |
bool mxtml = false; // Sign of mixt mode in lower quaternions array |
// Bool_t mxtml = false; // Sign of mixt mode in lower quaternions array |
| 1537 |
bool mxtmu = false; // Sign of mixt mode in upper quaternions array |
// Bool_t mxtmu = false; // Sign of mixt mode in upper quaternions array |
| 1538 |
bool npasm = false; // Sign of normall pass between R10 and non R10 or between non R10 and R10 |
Bool_t npasm = false; // Sign of normall pass between R10 and non R10 or between non R10 and R10 |
| 1539 |
UInt_t NCQl = 6; // Number of correct quaternions in lower array |
UInt_t NCQl = 6; // Number of correct quaternions in lower array |
| 1540 |
UInt_t NCQu = 6; // Number of correct quaternions in upper array |
// UInt_t NCQu = 6; // Number of correct quaternions in upper array |
| 1541 |
if (f>0){ |
if (f>0){ |
| 1542 |
insm = true; |
insm = true; |
| 1543 |
if(Qupper->time[f]-Qupper->time[f-1]==30) R10u = false; |
if(Qupper->time[f]-Qupper->time[f-1]==30) R10u = false; |
| 1549 |
if((Qlower->time[5]-Qlower->time[0]==150)&&(Qlower->time[1]-Qlower->time[0]==30)) R10l = false; |
if((Qlower->time[5]-Qlower->time[0]==150)&&(Qlower->time[1]-Qlower->time[0]==30)) R10l = false; |
| 1550 |
if((Qupper->time[5]-Qupper->time[0]==150)&&(Qupper->time[1]-Qupper->time[0]==30)) R10u = false; |
if((Qupper->time[5]-Qupper->time[0]==150)&&(Qupper->time[1]-Qupper->time[0]==30)) R10u = false; |
| 1551 |
if((Qlower->time[5]-Qlower->time[0]<2)&&(Qlower->time[1]-Qlower->time[0]==30)){ |
if((Qlower->time[5]-Qlower->time[0]<2)&&(Qlower->time[1]-Qlower->time[0]==30)){ |
| 1552 |
mxtml = true; |
// mxtml = true; |
| 1553 |
for(UInt_t i = 1; i < 6; i++){ |
for(UInt_t i = 1; i < 6; i++){ |
| 1554 |
if(Qlower->time[i]-Qlower->time[0]==30*i) NCQl=i; |
if(Qlower->time[i]-Qlower->time[0]==30*i) NCQl=i; |
| 1555 |
} |
} |
| 1556 |
} |
} |
| 1557 |
if((Qupper->time[5]-Qupper->time[0]<2)&&(Qupper->time[1]-Qupper->time[0]==30)){ |
// if((Qupper->time[5]-Qupper->time[0]<2)&&(Qupper->time[1]-Qupper->time[0]==30)){ |
| 1558 |
mxtmu = true; |
// mxtmu = true; |
| 1559 |
for(UInt_t i = 1; i < 6; i++){ |
// for(UInt_t i = 1; i < 6; i++){ |
| 1560 |
if(Qupper->time[i]-Qupper->time[0]==30*i) NCQu=i; |
// if(Qupper->time[i]-Qupper->time[0]==30*i) NCQu=i; |
| 1561 |
} |
// } |
| 1562 |
} |
// } |
| 1563 |
} |
} |
| 1564 |
|
|
| 1565 |
if(((upper-lower==1.5)||(upper-lower==3.)||(upper-lower==30.)||(upper-lower==31.5)||(upper-lower==33.)||(upper-lower==181.5)||(upper-lower==210.)||(upper-lower==211.5))&&!insm) npasm = true; |
if(((upper-lower==1.5)||(upper-lower==3.)||(upper-lower==30.)||(upper-lower==31.5)||(upper-lower==33.)||(upper-lower==181.5)||(upper-lower==210.)||(upper-lower==211.5))&&!insm) npasm = true; |
| 1578 |
return hole; |
return hole; |
| 1579 |
} |
} |
| 1580 |
|
|
| 1581 |
|
void inclresize(vector<Double_t>& t,vector<Float_t>& q0,vector<Float_t>& q1,vector<Float_t>& q2,vector<Float_t>& q3,vector<Int_t>& mode,vector<Float_t>& Roll,vector<Float_t>& Pitch,vector<Float_t>& Yaw){ |
| 1582 |
|
Int_t sizee = t.size()+1; |
| 1583 |
|
t.resize(sizee); |
| 1584 |
|
q0.resize(sizee); |
| 1585 |
|
q1.resize(sizee); |
| 1586 |
|
q2.resize(sizee); |
| 1587 |
|
q3.resize(sizee); |
| 1588 |
|
mode.resize(sizee); |
| 1589 |
|
Roll.resize(sizee); |
| 1590 |
|
Pitch.resize(sizee); |
| 1591 |
|
Yaw.resize(sizee); |
| 1592 |
|
} |
| 1593 |
|
|
| 1594 |
|
//Find fitting sine functions for q0,q1,q2,q3 and Yaw-angle; |
| 1595 |
|
void sineparam(vector<Sine>& qsine, vector<Double_t>& qtime, vector<Float_t>& q, vector<Float_t>& Roll, vector<Float_t>& Pitch, Float_t limsin){ |
| 1596 |
|
UInt_t mulast = 0; |
| 1597 |
|
UInt_t munow = 0; |
| 1598 |
|
UInt_t munext = 0; |
| 1599 |
|
Bool_t increase = false; |
| 1600 |
|
Bool_t decrease = false; |
| 1601 |
|
Bool_t Max_is_defined = false; |
| 1602 |
|
Bool_t Start_point_is_defined = false; |
| 1603 |
|
Bool_t Period_is_defined = false; |
| 1604 |
|
Bool_t Large_gap = false; |
| 1605 |
|
Bool_t normal_way = true; |
| 1606 |
|
Bool_t small_gap_on_ridge = false; |
| 1607 |
|
Double_t t1 = 0; |
| 1608 |
|
Double_t t1A = 0; |
| 1609 |
|
Int_t sinesize = 0; |
| 1610 |
|
Int_t nfi = 0; |
| 1611 |
|
for(UInt_t mu = 0;mu<qtime.size();mu++){ |
| 1612 |
|
//cout<<"Roll["<<mu<<"] = "<<Roll[mu]<<endl; |
| 1613 |
|
if(TMath::Abs(Roll[mu])<1. && TMath::Abs(Pitch[mu])<1. && TMath::Abs(q[mu])<limsin){ |
| 1614 |
|
//cout<<"q["<<mu<<endl<<"] = "<<q[mu]<<endl; |
| 1615 |
|
if(mulast!=0 && munow!=0 && munext!=0){mulast=munow;munow=munext;munext=mu;} |
| 1616 |
|
if(munext==0 && munow!=0)munext=mu; |
| 1617 |
|
if(munow==0 && mulast!=0)munow=mu; |
| 1618 |
|
if(mulast==0)mulast=mu; |
| 1619 |
|
|
| 1620 |
|
//cout<<"mulast = "<<mulast<<"\tmunow = "<<munow<<"\tmunext = "<<munext<<endl; |
| 1621 |
|
//Int_t ref; |
| 1622 |
|
//cin>>ref; |
| 1623 |
|
if(TMath::Abs(q[munow])>TMath::Abs(q[mulast]) && TMath::Abs(q[munow])>TMath::Abs(q[munext]) && q[mulast]*q[munext]>0 && qtime[munext]-qtime[mulast]>400)small_gap_on_ridge = true; |
| 1624 |
|
if(munext>mulast && (qtime[munext]-qtime[mulast]>=2000 || qtime[munext]-qtime[mulast]<0)){if(Large_gap){normal_way = false;Large_gap = false;}else{Large_gap = true;normal_way = false;}}else normal_way = true; |
| 1625 |
|
//if(normal_way)cout<<"Normal_Way"<<endl; |
| 1626 |
|
if(Large_gap || small_gap_on_ridge){ |
| 1627 |
|
//cout<<"Large gap..."<<endl; |
| 1628 |
|
//if(small_gap_on_ridge)cout<<"small gap..."<<endl; |
| 1629 |
|
//cout<<"q["<<mulast<<"] = "<<q[mulast]<<"\tq["<<munow<<"] = "<<q[munow]<<"\tq["<<munext<<"] = "<<q[munext]<<endl; |
| 1630 |
|
//cout<<"qtime["<<mulast<<"] = "<<qtime[mulast]<<"\tqtime["<<munow<<"] = "<<qtime[munow]<<"\tqtime["<<munext<<"] = "<<qtime[munext]<<endl; |
| 1631 |
|
increase = false; |
| 1632 |
|
decrease = false; |
| 1633 |
|
if(nfi>0){ |
| 1634 |
|
qsine.resize(qsine.size()-1); |
| 1635 |
|
sinesize = qsine.size(); |
| 1636 |
|
//cout<<"nfi was larger then zero"<<endl; |
| 1637 |
|
}else{ |
| 1638 |
|
//cout<<"nfi was not larger then zero :( nfi = "<<nfi<<endl; |
| 1639 |
|
//cout<<"qsine.size = "<<qsine.size()<<endl; |
| 1640 |
|
if(!Period_is_defined){ |
| 1641 |
|
//cout<<"Period was defined"<<endl; |
| 1642 |
|
if(qsine.size()>1){ |
| 1643 |
|
qsine[sinesize-1].b = qsine[sinesize-2].b; |
| 1644 |
|
qsine[sinesize-1].c = qsine[sinesize-2].c; |
| 1645 |
|
}else{ |
| 1646 |
|
qsine[sinesize-1].b = TMath::Pi()/1591.54; |
| 1647 |
|
qsine[sinesize-1].c = qsine[sinesize-1].startPoint; |
| 1648 |
|
} |
| 1649 |
|
} |
| 1650 |
|
if(!Max_is_defined){ |
| 1651 |
|
//cout<<"Max was already defined"<<endl; |
| 1652 |
|
if(qsine.size()>1)qsine[sinesize-1].A = qsine[sinesize-2].A;else qsine[sinesize-1].A = limsin; |
| 1653 |
|
} |
| 1654 |
|
qsine[sinesize-1].NeedFit = true; |
| 1655 |
|
} |
| 1656 |
|
qsine[sinesize-1].finishPoint = qtime[munow]; |
| 1657 |
|
//cout<<"finish point before large gap = "<<qtime[munow]<<endl; |
| 1658 |
|
nfi = 0; |
| 1659 |
|
Max_is_defined = false; |
| 1660 |
|
Start_point_is_defined = false; |
| 1661 |
|
Period_is_defined = false; |
| 1662 |
|
small_gap_on_ridge = false; |
| 1663 |
|
} |
| 1664 |
|
//cout<<"Slope "<<increase<<"\t"<<decrease<<endl; |
| 1665 |
|
//cout<<"mulast = "<<mulast<<"\tmunow = "<<munow<<"\tmunext = "<<munext<<endl; |
| 1666 |
|
if((munext>munow) && (munow>mulast) && normal_way){ |
| 1667 |
|
if(!increase && !decrease){ |
| 1668 |
|
//cout<<"Normal way have started"<<endl; |
| 1669 |
|
qsine.resize(qsine.size()+1); |
| 1670 |
|
sinesize = qsine.size(); |
| 1671 |
|
qsine[sinesize-1].startPoint=qtime[mulast]; |
| 1672 |
|
if(q[munext]>q[munow] && q[munow]>q[mulast]) increase = true; |
| 1673 |
|
if(q[munext]<q[munow] && q[munow]<q[mulast]) decrease = true; |
| 1674 |
|
} |
| 1675 |
|
//if(TMath::Abs(q[munow])>TMath::Abs(q[mulast]) && TMath::Abs(q[munow])>TMath::Abs(q[munext]) && TMath::Abs(q[munow])>limsin && qtime[munow]-qtime[mulast]>=400 || qtime[munext]-qtime[munow]>=400){small_gap_on_ridge = true;mu--;continue;} |
| 1676 |
|
if(TMath::Abs(q[munow])>TMath::Abs(q[mulast]) && TMath::Abs(q[munow])>TMath::Abs(q[munext]) && TMath::Abs(q[munow])>0.9*limsin && qtime[munow]-qtime[mulast]<400 && qtime[munext]-qtime[munow]<400){ |
| 1677 |
|
//cout<<"Max point is qtime = "<<qtime[munow]<<"\tq = "<<q[munow]<<endl; |
| 1678 |
|
if(q[munow]>q[mulast]){ |
| 1679 |
|
increase = false; |
| 1680 |
|
decrease = true; |
| 1681 |
|
} |
| 1682 |
|
if(q[munow]<q[mulast]){ |
| 1683 |
|
increase = true; |
| 1684 |
|
decrease = false; |
| 1685 |
|
} |
| 1686 |
|
if(Max_is_defined && !Start_point_is_defined){ |
| 1687 |
|
Double_t qPer = qtime[munow]-t1A; |
| 1688 |
|
if(qPer>1000){ |
| 1689 |
|
//cout<<"qsine["<<sinesize-1<<"] = "<<qPer<<" = "<<qtime[munow]<<" - "<<t1A<<"\tlim = "<<limsin<<endl; |
| 1690 |
|
qsine[sinesize-1].b=TMath::Pi()/qPer; |
| 1691 |
|
if(decrease)qsine[sinesize-1].c=-qsine[sinesize-1].b*t1A; |
| 1692 |
|
if(increase)qsine[sinesize-1].c=-qsine[sinesize-1].b*(t1A-qPer); |
| 1693 |
|
Period_is_defined = true; |
| 1694 |
|
} |
| 1695 |
|
} |
| 1696 |
|
Max_is_defined = true; |
| 1697 |
|
qsine[sinesize-1].A = TMath::Abs(q[munow]); |
| 1698 |
|
if(Start_point_is_defined && Period_is_defined){ |
| 1699 |
|
qsine[sinesize-1].finishPoint = qtime[munow]; |
| 1700 |
|
nfi++; |
| 1701 |
|
qsine[sinesize-1].NeedFit = false; |
| 1702 |
|
Max_is_defined = false; |
| 1703 |
|
Start_point_is_defined = false; |
| 1704 |
|
Period_is_defined = false; |
| 1705 |
|
qsine.resize(qsine.size()+1); |
| 1706 |
|
sinesize = qsine.size(); |
| 1707 |
|
qsine[sinesize-1].startPoint = qtime[munow]; |
| 1708 |
|
} |
| 1709 |
|
if(!Start_point_is_defined) t1A=qtime[munow]; |
| 1710 |
|
} |
| 1711 |
|
//if((q[munow]>=0 && q[mulast]<=0) || (q[munow]<=0 && q[mulast]>=0))cout<<"cross zero point diference = "<<qtime[munext] - qtime[mulast]<<"\tqlast = "<<qtime[mulast]<<"\tqnow = "<<qtime[munow]<<"\tqnext = "<<qtime[munext]<<endl; |
| 1712 |
|
if(((q[munow]>=0 && q[mulast]<=0) || (q[munow]<=0 && q[mulast]>=0)) && qtime[munow]-qtime[mulast]<2000 && qtime[munext]-qtime[munow]<2000){ |
| 1713 |
|
Double_t tcrosszero = 0; |
| 1714 |
|
//cout<<"cross zero point...qtime = "<<qtime[munow]<<endl; |
| 1715 |
|
if(q[munow]==0.) tcrosszero = qtime[munow];else |
| 1716 |
|
if(q[mulast]==0.)tcrosszero = qtime[mulast];else{ |
| 1717 |
|
Double_t k_ = (q[munow]-q[mulast])/(qtime[munow]-qtime[mulast]); |
| 1718 |
|
Double_t b_ = q[munow]-k_*qtime[munow]; |
| 1719 |
|
tcrosszero = -b_/k_; |
| 1720 |
|
} |
| 1721 |
|
if(Start_point_is_defined){ |
| 1722 |
|
//cout<<"Start Point allready defined"<<endl; |
| 1723 |
|
Double_t qPer = tcrosszero - t1; |
| 1724 |
|
qsine[sinesize-1].b = TMath::Pi()/qPer; |
| 1725 |
|
//cout<<"qsine["<<sinesize-1<<"].b = "<<TMath::Pi()/qPer<<endl; |
| 1726 |
|
Period_is_defined = true; |
| 1727 |
|
Float_t x0 = 0; |
| 1728 |
|
if(decrease)x0 = t1; |
| 1729 |
|
if(increase)x0 = tcrosszero; |
| 1730 |
|
qsine[sinesize-1].c = -qsine[sinesize-1].b*x0; |
| 1731 |
|
if(Max_is_defined){ |
| 1732 |
|
//cout<<"Max was previous defined"<<endl; |
| 1733 |
|
qsine[sinesize-1].finishPoint = qtime[munow]; |
| 1734 |
|
nfi++; |
| 1735 |
|
qsine[sinesize-1].NeedFit = false; |
| 1736 |
|
Max_is_defined = false; |
| 1737 |
|
t1 = tcrosszero; |
| 1738 |
|
Start_point_is_defined = true; |
| 1739 |
|
Period_is_defined = false; |
| 1740 |
|
qsine.resize(qsine.size()+1); |
| 1741 |
|
sinesize = qsine.size(); |
| 1742 |
|
qsine[sinesize-1].startPoint = qtime[munow]; |
| 1743 |
|
} |
| 1744 |
|
}else{ |
| 1745 |
|
t1 = tcrosszero; |
| 1746 |
|
Start_point_is_defined = true; |
| 1747 |
|
} |
| 1748 |
|
} |
| 1749 |
|
} |
| 1750 |
|
} |
| 1751 |
|
} |
| 1752 |
|
|
| 1753 |
|
//cout<<"FINISH SINE INTERPOLATION FUNCTION..."<<endl<<endl; |
| 1754 |
|
} |