|
// |
|
| 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 <TF1.h> |
| 14 |
|
|
| 15 |
#include <TTree.h> |
#include <TTree.h> |
| 16 |
#include <TClassEdit.h> |
#include <TClassEdit.h> |
| 17 |
#include <TObject.h> |
#include <TObject.h> |
| 47 |
#include <OrbitalInfoCore.h> |
#include <OrbitalInfoCore.h> |
| 48 |
#include <InclinationInfo.h> |
#include <InclinationInfo.h> |
| 49 |
|
|
| 50 |
|
|
| 51 |
using namespace std; |
using namespace std; |
| 52 |
|
|
| 53 |
// |
// |
| 131 |
// |
// |
| 132 |
// My variables. Vitaly. |
// My variables. Vitaly. |
| 133 |
// |
// |
| 134 |
// UInt_t iev = 0; |
// UInt_t oi = 0; |
|
// UInt_t j3 = 0; |
|
|
UInt_t oi = 0; |
|
| 135 |
Int_t tmpSize = 0; |
Int_t tmpSize = 0; |
| 136 |
// |
// |
| 137 |
// variables needed to handle error signals |
// variables needed to handle error signals |
| 143 |
// |
// |
| 144 |
OrbitalInfo *orbitalinfo = new OrbitalInfo(); |
OrbitalInfo *orbitalinfo = new OrbitalInfo(); |
| 145 |
OrbitalInfo *orbitalinfoclone = new OrbitalInfo(); |
OrbitalInfo *orbitalinfoclone = new OrbitalInfo(); |
| 146 |
|
|
| 147 |
// |
// |
| 148 |
// define variables for opening and reading level0 file |
// define variables for opening and reading level0 file |
| 149 |
// |
// |
| 150 |
TFile *l0File = 0; |
TFile *l0File = 0; |
| 151 |
TTree *l0tr = 0; |
TTree *l0tr = 0; |
| 152 |
TTree *l0trm = 0; |
// TTree *l0trm = 0; |
| 153 |
|
TChain *ch = 0; |
| 154 |
// EM: open also header branch |
// EM: open also header branch |
| 155 |
TBranch *l0head = 0; |
TBranch *l0head = 0; |
| 156 |
pamela::EventHeader *eh = 0; |
pamela::EventHeader *eh = 0; |
| 180 |
// |
// |
| 181 |
// IGRF stuff |
// IGRF stuff |
| 182 |
// |
// |
| 183 |
float dimo = 0.0; // dipole moment (computed from dat files) |
Float_t dimo = 0.0; // dipole moment (computed from dat files) |
| 184 |
float bnorth, beast, bdown, babs; |
Float_t bnorth, beast, bdown, babs; |
| 185 |
float xl; // L value |
Float_t xl; // L value |
| 186 |
float icode; // code value for L accuracy (see fortran code) |
Float_t icode; // code value for L accuracy (see fortran code) |
| 187 |
float bab1; // What's the difference with babs? |
Float_t bab1; // What's the difference with babs? |
| 188 |
float stps = 0.005; // step size for field line tracing |
Float_t stps = 0.005; // step size for field line tracing |
| 189 |
float bdel = 0.01; // required accuracy |
Float_t bdel = 0.01; // required accuracy |
| 190 |
float bequ; // equatorial b value (also called b_0) |
Float_t bequ; // equatorial b value (also called b_0) |
| 191 |
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 |
| 192 |
float rr0; // equatorial radius normalized to earth radius |
Float_t rr0; // equatorial radius normalized to earth radius |
| 193 |
|
|
| 194 |
// |
// |
| 195 |
// Working filename |
// Working filename |
| 213 |
OrbitalInfofolder << tempname.str().c_str(); |
OrbitalInfofolder << tempname.str().c_str(); |
| 214 |
tempname << "/OrbitalInfotree_run"; |
tempname << "/OrbitalInfotree_run"; |
| 215 |
tempname << run << ".root"; |
tempname << run << ".root"; |
| 216 |
|
UInt_t totnorun = 0; |
| 217 |
// |
// |
| 218 |
// DB classes |
// DB classes |
| 219 |
// |
// |
| 234 |
Int_t ltp2 = 0; |
Int_t ltp2 = 0; |
| 235 |
Int_t ltp3 = 0; |
Int_t ltp3 = 0; |
| 236 |
Int_t uno = 1; |
Int_t uno = 1; |
| 237 |
char *niente = " "; |
const char *niente = " "; |
| 238 |
GL_PARAM *glparam = new GL_PARAM(); |
GL_PARAM *glparam = new GL_PARAM(); |
| 239 |
GL_PARAM *glparam2 = new GL_PARAM(); |
GL_PARAM *glparam2 = new GL_PARAM(); |
| 240 |
Int_t parerror=glparam->Query_GL_PARAM(1,301,dbc); // parameters stored in DB in GL_PRAM table |
|
| 241 |
// |
// |
| 242 |
// Orientation variables |
// Orientation variables. Vitaly |
| 243 |
// |
// |
| 244 |
UInt_t evfrom = 0; |
UInt_t evfrom = 0; |
| 245 |
UInt_t jumped = 0; |
UInt_t jumped = 0; |
| 256 |
Int_t nz = 6; |
Int_t nz = 6; |
| 257 |
Float_t zin[6]; |
Float_t zin[6]; |
| 258 |
Int_t nevtofl2 = 0; |
Int_t nevtofl2 = 0; |
| 259 |
// |
if ( verbose ) cout<<"Reading quaternions external file"<<endl; |
| 260 |
|
cout.setf(ios::fixed,ios::floatfield); |
| 261 |
|
/******Reading recovered quaternions...*********/ |
| 262 |
|
//cout<<"START reading recovered quaternions..."<<endl; |
| 263 |
|
vector<Double_t> recqtime; |
| 264 |
|
vector<Float_t> recq0; |
| 265 |
|
vector<Float_t> recq1; |
| 266 |
|
vector<Float_t> recq2; |
| 267 |
|
vector<Float_t> recq3; |
| 268 |
|
Float_t Norm = 1; |
| 269 |
|
Int_t parerror=glparam->Query_GL_PARAM(1,303,dbc); // parameters stored in DB in GL_PRAM table |
| 270 |
|
if ( parerror<0 ) { |
| 271 |
|
code = parerror; |
| 272 |
|
goto closeandexit; |
| 273 |
|
}; |
| 274 |
|
ifstream in((glparam->PATH+glparam->NAME).Data(),ios::in); |
| 275 |
|
//cout<<"ifstream loaded..."<<endl; |
| 276 |
|
while(!in.eof()){ |
| 277 |
|
recqtime.resize(recqtime.size()+1); |
| 278 |
|
Int_t sizee = recqtime.size(); |
| 279 |
|
recq0.resize(sizee); |
| 280 |
|
recq1.resize(sizee); |
| 281 |
|
recq2.resize(sizee); |
| 282 |
|
recq3.resize(sizee); |
| 283 |
|
in>>recqtime[sizee-1]; |
| 284 |
|
in>>recq0[sizee-1]; |
| 285 |
|
in>>recq1[sizee-1]; |
| 286 |
|
in>>recq2[sizee-1]; |
| 287 |
|
in>>recq3[sizee-1]; |
| 288 |
|
in>>Norm; |
| 289 |
|
//cout<<recqtime[sizee]<<endl; |
| 290 |
|
} |
| 291 |
|
if ( verbose ) cout<<"We have read recovered data"<<endl; |
| 292 |
|
|
| 293 |
|
|
| 294 |
|
parerror=glparam->Query_GL_PARAM(1,301,dbc); // parameters stored in DB in GL_PRAM table |
| 295 |
if ( parerror<0 ) { |
if ( parerror<0 ) { |
| 296 |
code = parerror; |
code = parerror; |
| 297 |
goto closeandexit; |
goto closeandexit; |
| 382 |
// number of run to be processed |
// number of run to be processed |
| 383 |
// |
// |
| 384 |
numbofrun = runinfo->GetNoRun(); |
numbofrun = runinfo->GetNoRun(); |
| 385 |
UInt_t totnorun = runinfo->GetRunEntries(); |
totnorun = runinfo->GetRunEntries(); |
| 386 |
// |
// |
| 387 |
// 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 |
| 388 |
// |
// |
| 470 |
} |
} |
| 471 |
for (UInt_t j = 0; j < nobefrun; j++){ |
for (UInt_t j = 0; j < nobefrun; j++){ |
| 472 |
// |
// |
| 473 |
OrbitalInfotrclone->GetEntry(j); |
if ( OrbitalInfotrclone->GetEntry(j) <= 0 ) throw -36; |
| 474 |
// |
// |
| 475 |
// copy orbitalinfoclone to mydec |
// copy orbitalinfoclone to mydec |
| 476 |
// |
// |
| 487 |
}; |
}; |
| 488 |
}; |
}; |
| 489 |
// |
// |
| 490 |
|
// |
| 491 |
// 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. |
| 492 |
// |
// |
| 493 |
runlist = runinfo->GetRunList(); |
runlist = runinfo->GetRunList(); |
| 543 |
fname = ftmpname.str().c_str(); |
fname = ftmpname.str().c_str(); |
| 544 |
ftmpname.str(""); |
ftmpname.str(""); |
| 545 |
// |
// |
| 546 |
// print out informations |
// print nout informations |
| 547 |
// |
// |
| 548 |
totevent = runinfo->NEVENTS; |
totevent = runinfo->NEVENTS; |
| 549 |
evfrom = runinfo->EV_FROM; |
evfrom = runinfo->EV_FROM; |
| 596 |
goto closeandexit; |
goto closeandexit; |
| 597 |
}; |
}; |
| 598 |
// |
// |
| 599 |
// TTree *tp = (TTree*)l0File->Get("RunHeader"); |
// TTree *tp = (TTree*)l0File->Get("RunHeader"); |
| 600 |
// tp->SetBranchAddress("Header", &eH); |
// tp->SetBranchAddress("Header", &eH); |
| 601 |
// tp->SetBranchAddress("RunHeader", &reh); |
// tp->SetBranchAddress("RunHeader", &reh); |
| 602 |
// tp->GetEntry(0); |
// tp->GetEntry(0); |
| 603 |
// ph = eH->GetPscuHeader(); |
// ph = eH->GetPscuHeader(); |
| 604 |
// ULong_t TimeSync = reh->LAST_TIME_SYNC_INFO; |
// ULong_t TimeSync = reh->LAST_TIME_SYNC_INFO; |
| 605 |
// ULong_t ObtSync = reh->OBT_TIME_SYNC; |
// ULong_t ObtSync = reh->OBT_TIME_SYNC; |
| 606 |
// if ( debug ) printf(" 1 TimeSync %lu ObtSync %lu DeltaOBT %lu\n",TimeSync,ObtSync,TimeSync-ObtSync); |
// if ( debug ) printf(" 1 TimeSync %lu ObtSync %lu DeltaOBT %lu\n",TimeSync,ObtSync,TimeSync-ObtSync); |
| 607 |
// |
// |
| 608 |
ULong_t TimeSync = (ULong_t)dbtime->GetTimesync(); |
ULong_t TimeSync = (ULong_t)dbtime->GetTimesync(); |
| 609 |
ULong_t ObtSync = (ULong_t)(dbtime->GetObt0()/1000); |
ULong_t ObtSync = (ULong_t)(dbtime->GetObt0()/1000); |
| 610 |
ULong_t DeltaOBT = TimeSync - ObtSync; |
ULong_t DeltaOBT = TimeSync - ObtSync; |
| 611 |
|
|
| 612 |
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); |
| 613 |
|
// |
| 614 |
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 |
| 615 |
neventsm = l0trm->GetEntries(); |
// |
| 616 |
|
ch = new TChain("Mcmd","Mcmd"); |
| 617 |
|
// |
| 618 |
|
// look in the DB to find the closest files to this run |
| 619 |
|
// |
| 620 |
|
TSQLResult *pResult = 0; |
| 621 |
|
TSQLRow *Row = 0; |
| 622 |
|
stringstream myquery; |
| 623 |
|
UInt_t l0fid[10]; |
| 624 |
|
Int_t i = 0; |
| 625 |
|
memset(l0fid,0,10*sizeof(Int_t)); |
| 626 |
|
// |
| 627 |
|
myquery.str(""); |
| 628 |
|
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;"; |
| 629 |
|
// |
| 630 |
|
pResult = dbc->Query(myquery.str().c_str()); |
| 631 |
|
// |
| 632 |
|
i = 9; |
| 633 |
|
if( pResult ){ |
| 634 |
|
// |
| 635 |
|
Row = pResult->Next(); |
| 636 |
|
// |
| 637 |
|
while ( Row ){ |
| 638 |
|
// |
| 639 |
|
// store infos and exit |
| 640 |
|
// |
| 641 |
|
l0fid[i] = (UInt_t)atoll(Row->GetField(0)); |
| 642 |
|
i--; |
| 643 |
|
Row = pResult->Next(); |
| 644 |
|
// |
| 645 |
|
}; |
| 646 |
|
pResult->Delete(); |
| 647 |
|
}; |
| 648 |
|
// |
| 649 |
|
myquery.str(""); |
| 650 |
|
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;"; |
| 651 |
|
// |
| 652 |
|
pResult = dbc->Query(myquery.str().c_str()); |
| 653 |
|
// |
| 654 |
|
i = 0; |
| 655 |
|
if( pResult ){ |
| 656 |
|
// |
| 657 |
|
Row = pResult->Next(); |
| 658 |
|
// |
| 659 |
|
while ( Row ){ |
| 660 |
|
// |
| 661 |
|
// store infos and exit |
| 662 |
|
// |
| 663 |
|
l0fid[i] = (UInt_t)atoll(Row->GetField(0)); |
| 664 |
|
i++; |
| 665 |
|
Row = pResult->Next(); |
| 666 |
|
// |
| 667 |
|
}; |
| 668 |
|
pResult->Delete(); |
| 669 |
|
}; |
| 670 |
|
// |
| 671 |
|
i = 0; |
| 672 |
|
UInt_t previd = 0; |
| 673 |
|
while ( i < 10 ){ |
| 674 |
|
if ( l0fid[i] && previd != l0fid[i] ){ |
| 675 |
|
previd = l0fid[i]; |
| 676 |
|
myquery.str(""); |
| 677 |
|
myquery << "select PATH,NAME from GL_ROOT where ID=" << l0fid[i] << " ;"; |
| 678 |
|
// |
| 679 |
|
pResult = dbc->Query(myquery.str().c_str()); |
| 680 |
|
// |
| 681 |
|
if( pResult ){ |
| 682 |
|
// |
| 683 |
|
Row = pResult->Next(); |
| 684 |
|
// |
| 685 |
|
if ( debug ) printf(" Using inclination informations from file: %s \n",(((TString)gSystem->ExpandPathName(Row->GetField(0)))+"/"+(TString)Row->GetField(1)).Data()); |
| 686 |
|
ch->Add(((TString)gSystem->ExpandPathName(Row->GetField(0)))+"/"+(TString)Row->GetField(1)); |
| 687 |
|
// |
| 688 |
|
pResult->Delete(); |
| 689 |
|
}; |
| 690 |
|
}; |
| 691 |
|
i++; |
| 692 |
|
}; |
| 693 |
|
// |
| 694 |
|
// l0trm = (TTree*)l0File->Get("Mcmd"); |
| 695 |
|
// ch->ls(); |
| 696 |
|
ch->SetBranchAddress("Mcmd",&mcmdev); |
| 697 |
|
// printf(" entries %llu \n", ch->GetEntries()); |
| 698 |
|
// l0trm = ch->GetTree(); |
| 699 |
|
// neventsm = l0trm->GetEntries(); |
| 700 |
|
neventsm = ch->GetEntries(); |
| 701 |
|
if ( debug ) printf(" entries %u \n", neventsm); |
| 702 |
// neventsm = 0; |
// neventsm = 0; |
| 703 |
// |
// |
| 704 |
if (neventsm == 0){ |
if (neventsm == 0){ |
| 709 |
} |
} |
| 710 |
// |
// |
| 711 |
|
|
| 712 |
l0trm->SetBranchAddress("Mcmd", &mcmdev); |
// l0trm->SetBranchAddress("Mcmd", &mcmdev); |
| 713 |
// l0trm->SetBranchAddress("Header", &eh); |
// l0trm->SetBranchAddress("Header", &eh); |
| 714 |
// |
// |
| 715 |
// |
// |
| 716 |
// |
// |
| 717 |
UInt_t mctren = 0; |
|
| 718 |
UInt_t mcreen = 0; |
// UInt_t mctren = 0; |
| 719 |
|
// UInt_t mcreen = 0; |
| 720 |
UInt_t numrec = 0; |
UInt_t numrec = 0; |
| 721 |
// |
// |
| 722 |
Double_t upperqtime = 0; |
Double_t upperqtime = 0; |
| 723 |
Double_t lowerqtime = 0; |
Double_t lowerqtime = 0; |
| 724 |
|
|
| 725 |
Double_t incli = 0; |
// Double_t incli = 0; |
| 726 |
oi = 0; |
// oi = 0; |
| 727 |
UInt_t ooi = 0; |
// UInt_t ooi = 0; |
| 728 |
// |
// |
| 729 |
// init quaternions sync |
// init quaternions information from mcmd-packets |
| 730 |
// |
// |
| 731 |
Bool_t isf = true; |
Bool_t isf = true; |
| 732 |
Int_t fgh = 0; |
// Int_t fgh = 0; |
| 733 |
|
|
| 734 |
|
vector<Float_t> q0; |
| 735 |
|
vector<Float_t> q1; |
| 736 |
|
vector<Float_t> q2; |
| 737 |
|
vector<Float_t> q3; |
| 738 |
|
vector<Double_t> qtime; |
| 739 |
|
vector<Float_t> qPitch; |
| 740 |
|
vector<Float_t> qRoll; |
| 741 |
|
vector<Float_t> qYaw; |
| 742 |
|
vector<Int_t> qmode; |
| 743 |
|
|
| 744 |
|
Int_t nt = 0; |
| 745 |
|
|
| 746 |
|
//init sine-function interpolation |
| 747 |
|
|
| 748 |
|
//cout<<"Sine coeficient initialisation..."<<endl; |
| 749 |
|
vector<Sine> q0sine; |
| 750 |
|
vector<Sine> q1sine; |
| 751 |
|
vector<Sine> q2sine; |
| 752 |
|
vector<Sine> q3sine; |
| 753 |
|
vector<Sine> Yawsine; |
| 754 |
|
|
| 755 |
|
/*TH2F* q0testing = new TH2F(); |
| 756 |
|
TH2F* q1testing = new TH2F(); |
| 757 |
|
TH2F* q2testing = new TH2F(); |
| 758 |
|
TH2F* q3testing = new TH2F(); |
| 759 |
|
TH2F* Pitchtesting = new TH2F(); |
| 760 |
|
*/ |
| 761 |
|
UInt_t must = 0; |
| 762 |
|
|
| 763 |
// |
// |
| 764 |
// run over all the events of the run |
// run over all the events of the run |
| 765 |
// |
// |
| 766 |
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"); |
| 767 |
// |
// |
| 768 |
// |
// |
| 769 |
for ( re = runinfo->EV_FROM; re < (runinfo->EV_FROM+runinfo->NEVENTS); re++){ |
for ( re = runinfo->EV_FROM; re < (runinfo->EV_FROM+runinfo->NEVENTS); re++){ |
|
|
|
| 770 |
// |
// |
| 771 |
if ( procev%1000 == 0 && procev > 0 && verbose ) printf(" %iK \n",procev/1000); |
if ( procev%1000 == 0 && procev > 0 && verbose ) printf(" %iK \n",procev/1000); |
| 772 |
if ( debug ) printf(" %i \n",procev); |
if ( debug ) printf(" %i \n",procev); |
| 773 |
// |
// |
| 774 |
l0head->GetEntry(re); |
if ( l0head->GetEntry(re) <= 0 ) throw -36; |
| 775 |
// |
// |
| 776 |
// absolute time of this event |
// absolute time of this event |
| 777 |
// |
// |
| 778 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
| 779 |
atime = dbtime->DBabsTime(ph->GetOrbitalTime()); |
atime = dbtime->DBabsTime(ph->GetOrbitalTime()); |
| 780 |
|
if ( debug ) printf(" %i absolute time \n",procev); |
| 781 |
// |
// |
| 782 |
// paranoid check |
// paranoid check |
| 783 |
// |
// |
| 784 |
if ( (atime > (runinfo->RUNTRAILER_TIME+1)) || (atime < (runinfo->RUNHEADER_TIME-1)) ) { |
if ( (atime > (runinfo->RUNTRAILER_TIME+1)) || (atime < (runinfo->RUNHEADER_TIME-1)) ) { |
| 785 |
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"); |
| 786 |
jumped++; |
jumped++; |
| 787 |
// debug = true; |
// debug = true; |
| 788 |
continue; |
continue; |
| 789 |
} |
} |
| 790 |
|
|
| 809 |
// |
// |
| 810 |
tof->Clear(); |
tof->Clear(); |
| 811 |
// |
// |
| 812 |
ttof->GetEntry(itr); |
if ( ttof->GetEntry(itr) <= 0 ) throw -36; |
| 813 |
// |
// |
| 814 |
}; |
}; |
| 815 |
// |
// |
| 817 |
// |
// |
| 818 |
// start processing |
// start processing |
| 819 |
// |
// |
| 820 |
|
if ( debug ) printf(" %i start processing \n",procev); |
| 821 |
orbitalinfo->Clear(); |
orbitalinfo->Clear(); |
| 822 |
// |
// |
| 823 |
OrbitalInfoTrkVar *t_orb = new OrbitalInfoTrkVar(); |
OrbitalInfoTrkVar *t_orb = new OrbitalInfoTrkVar(); |
| 829 |
orbitalinfo->pkt_num = ph->GetCounter(); |
orbitalinfo->pkt_num = ph->GetCounter(); |
| 830 |
orbitalinfo->OBT = ph->GetOrbitalTime(); |
orbitalinfo->OBT = ph->GetOrbitalTime(); |
| 831 |
orbitalinfo->absTime = atime; |
orbitalinfo->absTime = atime; |
| 832 |
|
if ( debug ) printf(" %i pktnum obt abstime \n",procev); |
| 833 |
// |
// |
| 834 |
// 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. |
| 835 |
// |
// |
| 836 |
|
if ( debug ) printf(" %i sgp4 \n",procev); |
| 837 |
cCoordGeo coo; |
cCoordGeo coo; |
| 838 |
float jyear=0; |
Float_t jyear=0.; |
| 839 |
// |
// |
| 840 |
if(atime >= gltle->GetToTime()) { |
if(atime >= gltle->GetToTime()) { |
| 841 |
if ( !gltle->Query(atime, dbc) ){ |
if ( !gltle->Query(atime, dbc) ){ |
| 842 |
// |
// |
| 843 |
// Compute the magnetic dipole moment. |
// Compute the magnetic dipole moment. |
| 844 |
// |
// |
| 845 |
|
if ( debug ) printf(" %i compute magnetic dipole moment \n",procev); |
| 846 |
UInt_t year, month, day, hour, min, sec; |
UInt_t year, month, day, hour, min, sec; |
| 847 |
// |
// |
| 848 |
TTimeStamp t = TTimeStamp(atime, kTRUE); |
TTimeStamp t = TTimeStamp(atime, kTRUE); |
| 850 |
t.GetTime(kTRUE, 0, &hour, &min, &sec); |
t.GetTime(kTRUE, 0, &hour, &min, &sec); |
| 851 |
jyear = (float) year |
jyear = (float) year |
| 852 |
+ (month*31.+ (float) day)/365. |
+ (month*31.+ (float) day)/365. |
| 853 |
+ (hour*3600.+min*60.+(float)sec)/(24*3600*365.); |
+ (hour*3600.+min*60.+(float)sec)/(24.*3600.*365.); |
| 854 |
// |
// |
| 855 |
|
if ( debug ) printf(" %i compute magnetic dipole moment get dipole moment for year\n",procev); |
| 856 |
feldcof_(&jyear, &dimo); // get dipole moment for year |
feldcof_(&jyear, &dimo); // get dipole moment for year |
| 857 |
|
if ( debug ) printf(" %i compute magnetic dipole moment end\n",procev); |
| 858 |
} else { |
} else { |
| 859 |
code = -56; |
code = -56; |
| 860 |
goto closeandexit; |
goto closeandexit; |
| 869 |
// synchronize with quaternions data |
// synchronize with quaternions data |
| 870 |
// |
// |
| 871 |
if ( isf && neventsm>0 ){ |
if ( isf && neventsm>0 ){ |
|
if ( debug ) printf(" I am here \n"); |
|
| 872 |
// |
// |
| 873 |
// First event |
// First event |
| 874 |
// |
// |
| 875 |
isf = false; |
isf = false; |
| 876 |
upperqtime = atime; |
upperqtime = atime; |
| 877 |
lowerqtime = runinfo->RUNHEADER_TIME; |
lowerqtime = runinfo->RUNHEADER_TIME; |
| 878 |
for ( ik = 0; ik < neventsm; ik++){ |
for ( ik = 0; ik < neventsm; ik++){ //number of macrocommad packets |
| 879 |
l0trm->GetEntry(ik); |
if ( ch->GetEntry(ik) <= 0 ) throw -36; |
| 880 |
tmpSize = mcmdev->Records->GetEntries(); |
tmpSize = mcmdev->Records->GetEntries(); |
| 881 |
numrec = tmpSize; |
numrec = tmpSize; |
| 882 |
for (Int_t j3 = 0;j3<tmpSize;j3++){ |
for (Int_t j3 = 0;j3<tmpSize;j3++){ //number of subpackets |
| 883 |
if ( debug ) printf(" eh eh eh \n"); |
if ( debug ) printf(" ik %i j3 %i eh eh eh \n",ik,j3); |
| 884 |
mcmdrc = (pamela::McmdRecord*)mcmdev->Records->At(j3); |
mcmdrc = (pamela::McmdRecord*)mcmdev->Records->At(j3); |
| 885 |
if ((int)mcmdrc->ID1 == 226){ |
if ( mcmdrc ){ // missing inclination bug [8RED 090116] |
| 886 |
L_QQ_Q_l_upper->fill(mcmdrc->McmdData); |
if ((int)mcmdrc->ID1 == 226 && mcmdrc->Mcmd_Block_crc_ok == 1){ //Check that it is Inclination Packet |
| 887 |
for (UInt_t ui = 0; ui < 6; ui++){ |
L_QQ_Q_l_upper->fill(mcmdrc->McmdData); |
| 888 |
if (ui>0){ |
for (UInt_t ui = 0; ui < 6; ui++){ |
| 889 |
if (L_QQ_Q_l_upper->time[ui]>L_QQ_Q_l_upper->time[0]){ |
if (ui>0){ |
| 890 |
if (dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[ui]*1000-DeltaOBT*1000))<atime){ |
if (L_QQ_Q_l_upper->time[ui]>L_QQ_Q_l_upper->time[0]){ |
| 891 |
upperqtime = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[ui]*1000-DeltaOBT*1000)); |
Double_t u_time = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[ui]*1000-DeltaOBT*1000)); |
| 892 |
orbits.getPosition((double) (upperqtime - gltle->GetFromTime())/60., &eCi); |
Int_t recSize = recqtime.size(); |
| 893 |
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]); |
for(Int_t mu = nt;mu<recSize;mu++){ |
| 894 |
}else { |
if(recqtime[mu]>lowerqtime && recqtime[mu]<u_time){ |
| 895 |
lowerqtime = upperqtime; |
nt=mu; |
| 896 |
upperqtime = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[ui]*1000-DeltaOBT*1000)); |
Int_t sizeqmcmd = qtime.size(); |
| 897 |
orbits.getPosition((double) (upperqtime - gltle->GetFromTime())/60., &eCi); |
inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw); |
| 898 |
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]=recqtime[mu]; |
| 899 |
mcreen = j3; |
q0[sizeqmcmd]=recq0[mu]; |
| 900 |
mctren = ik; |
q1[sizeqmcmd]=recq1[mu]; |
| 901 |
if(fgh==0){ |
q2[sizeqmcmd]=recq2[mu]; |
| 902 |
CopyQ(L_QQ_Q_l_lower,L_QQ_Q_l_upper); |
q3[sizeqmcmd]=recq3[mu]; |
| 903 |
CopyAng(RYPang_lower,RYPang_upper); |
qmode[sizeqmcmd]=-10; |
| 904 |
|
orbits.getPosition((double) (qtime[sizeqmcmd] - gltle->GetFromTime())/60., &eCi); |
| 905 |
|
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]); |
| 906 |
|
qRoll[sizeqmcmd]=RYPang_upper->Kren; |
| 907 |
|
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
| 908 |
|
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
| 909 |
|
} |
| 910 |
|
if(recqtime[mu]>=u_time){ |
| 911 |
|
Int_t sizeqmcmd = qtime.size(); |
| 912 |
|
inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw); |
| 913 |
|
qtime[sizeqmcmd]=u_time; |
| 914 |
|
q0[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][0]; |
| 915 |
|
q1[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][1]; |
| 916 |
|
q2[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][2]; |
| 917 |
|
q3[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][3]; |
| 918 |
|
qmode[sizeqmcmd]=holeq(lowerqtime,qtime[sizeqmcmd],L_QQ_Q_l_lower,L_QQ_Q_l_upper,ui); |
| 919 |
|
lowerqtime = u_time; |
| 920 |
|
orbits.getPosition((double) (u_time - gltle->GetFromTime())/60., &eCi); |
| 921 |
|
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]); |
| 922 |
|
qRoll[sizeqmcmd]=RYPang_upper->Kren; |
| 923 |
|
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
| 924 |
|
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
| 925 |
|
break; |
| 926 |
|
} |
| 927 |
} |
} |
|
oi=ui; |
|
|
goto closethisloop; |
|
| 928 |
} |
} |
| 929 |
fgh++; |
}else{ |
| 930 |
CopyQ(L_QQ_Q_l_lower,L_QQ_Q_l_upper); |
Double_t u_time = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
| 931 |
CopyAng(RYPang_lower,RYPang_upper); |
if(lowerqtime>u_time)nt=0; |
| 932 |
} |
Int_t recSize = recqtime.size(); |
| 933 |
}else{ |
for(Int_t mu = nt;mu<recSize;mu++){ |
| 934 |
if (dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000))<atime){ |
if(recqtime[mu]>lowerqtime && recqtime[mu]<u_time){ |
| 935 |
upperqtime = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
nt=mu; |
| 936 |
orbits.getPosition((double) (upperqtime - gltle->GetFromTime())/60., &eCi); |
Int_t sizeqmcmd = qtime.size(); |
| 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[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]); |
inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw); |
| 938 |
} |
qtime[sizeqmcmd]=recqtime[mu]; |
| 939 |
else { |
q0[sizeqmcmd]=recq0[mu]; |
| 940 |
lowerqtime = upperqtime; |
q1[sizeqmcmd]=recq1[mu]; |
| 941 |
upperqtime = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
q2[sizeqmcmd]=recq2[mu]; |
| 942 |
orbits.getPosition((double) (upperqtime - gltle->GetFromTime())/60., &eCi); |
q3[sizeqmcmd]=recq3[mu]; |
| 943 |
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]); |
qmode[sizeqmcmd]=-10; |
| 944 |
mcreen = j3; |
orbits.getPosition((double) (qtime[sizeqmcmd] - gltle->GetFromTime())/60., &eCi); |
| 945 |
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,recq0[mu],recq1[mu],recq2[mu],recq3[mu]); |
| 946 |
if(fgh==0){ |
qRoll[sizeqmcmd]=RYPang_upper->Kren; |
| 947 |
CopyQ(L_QQ_Q_l_lower,L_QQ_Q_l_upper); |
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
| 948 |
CopyAng(RYPang_lower,RYPang_upper); |
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
| 949 |
lowerqtime = atime-1; |
} |
| 950 |
|
if(recqtime[mu]>=u_time){ |
| 951 |
|
Int_t sizeqmcmd = qtime.size(); |
| 952 |
|
inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw); |
| 953 |
|
qtime[sizeqmcmd]=u_time; |
| 954 |
|
q0[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][0]; |
| 955 |
|
q1[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][1]; |
| 956 |
|
q2[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][2]; |
| 957 |
|
q3[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][3]; |
| 958 |
|
qmode[sizeqmcmd]=holeq(lowerqtime,qtime[sizeqmcmd],L_QQ_Q_l_lower,L_QQ_Q_l_upper,ui); |
| 959 |
|
lowerqtime = u_time; |
| 960 |
|
orbits.getPosition((double) (u_time - gltle->GetFromTime())/60., &eCi); |
| 961 |
|
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]); |
| 962 |
|
qRoll[sizeqmcmd]=RYPang_upper->Kren; |
| 963 |
|
qYaw[sizeqmcmd]=RYPang_upper->Ryskanie; |
| 964 |
|
qPitch[sizeqmcmd]=RYPang_upper->Tangazh; |
| 965 |
|
CopyQ(L_QQ_Q_l_lower,L_QQ_Q_l_upper); |
| 966 |
|
break; |
| 967 |
|
} |
| 968 |
} |
} |
|
oi=ui; |
|
|
goto closethisloop; |
|
|
//_0 = true; |
|
| 969 |
} |
} |
| 970 |
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]); |
|
| 971 |
} |
} |
|
// re--; |
|
|
gh=true; |
|
| 972 |
} |
} |
|
}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)); |
|
| 973 |
} |
} |
| 974 |
if (tut==6){ |
} |
| 975 |
if (fabs(RYPang_lower->Kren-RYPang_upper->Kren)<0.1){ |
|
| 976 |
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))); |
sineparam(q0sine,qtime,q0,qRoll,qPitch,0.58); |
| 977 |
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)); |
sineparam(q1sine,qtime,q1,qRoll,qPitch,0.79); |
| 978 |
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))); |
sineparam(q2sine,qtime,q2,qRoll,qPitch,0.79); |
| 979 |
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)); |
sineparam(q3sine,qtime,q3,qRoll,qPitch,0.58); |
| 980 |
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))); |
sineparam(Yawsine,qtime,qYaw,qRoll,qPitch,4); |
| 981 |
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)); |
Double_t tmin = 9999999999.; |
| 982 |
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))); |
Double_t tmax = 0.; |
| 983 |
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)); |
for(UInt_t tre = 0;tre<qtime.size();tre++){ |
| 984 |
|
if(qtime[tre]>tmax)tmax = qtime[tre]; |
| 985 |
|
if(qtime[tre]<tmin)tmin = qtime[tre]; |
| 986 |
|
} |
| 987 |
|
|
| 988 |
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))); |
//q0testing->SetName("q0testing"); |
| 989 |
orbitalinfo->theta = incli*atime+RYPang_upper->Tangazh-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
//q1testing->SetName("q1testing"); |
| 990 |
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))); |
//q2testing->SetName("q2testing"); |
| 991 |
orbitalinfo->phi = incli*atime+RYPang_upper->Ryskanie-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000)); |
//q3testing->SetName("q3testing"); |
|
//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)); |
|
|
} |
|
|
} |
|
|
} 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)); |
|
| 992 |
|
|
| 993 |
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))); |
// Int_t ss=10.*(tmax-tmin); |
| 994 |
orbitalinfo->theta = incli*atime+RYPang_upper->Tangazh-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
//q0testing->SetBins(ss,tmin,tmax,1000,-1.,1.); |
| 995 |
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))); |
//Pitchtesting->SetBins(ss,tmin,tmax,1000,-40.,40.); |
| 996 |
orbitalinfo->phi = incli*atime+RYPang_upper->Ryskanie-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
|
| 997 |
//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"; |
// for(Int_t tre = 0;tre<qtime.size();tre++){ |
| 998 |
//cin>>grib; |
//cout<<"q0["<<tre<<" = "<<q0[tre]<<endl; |
| 999 |
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))); |
//q0testing->Fill(qtime[tre],q0[tre]); |
| 1000 |
orbitalinfo->etha = incli*atime+RYPang_upper->Kren-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
//q1testing->Fill(qtime[tre],q1[tre]); |
| 1001 |
} |
//Pitchtesting->Fill(qtime[tre],qPitch[tre],100); |
| 1002 |
if (tut==6){ |
//if(qmode[tre] == -10)Pitchtesting->Fill(qtime[tre],10,100); |
| 1003 |
if (fabs(RYPang_lower->Kren-RYPang_upper->Kren)<0.1){ |
//q2testing->Fill(qtime[tre],q2[tre],100); |
| 1004 |
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))); |
//q3testing->Fill(qtime[tre],q3[tre],100); |
| 1005 |
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)); |
|
| 1006 |
|
|
| 1007 |
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))); |
//for(Int_t tre=0;tre<q0sine.size();tre++)cout<<q1sine[tre].A<<"*sin("<<q1sine[tre].b<<"x+"<<q1sine[tre].c<<")\t time start: "<<q1sine[tre].startPoint<<"\ttime end: "<<q1sine[tre].finishPoint<<endl; |
| 1008 |
orbitalinfo->theta = incli*atime+RYPang_upper->Tangazh-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
//for(Int_t tre=0;tre<q0sine.size();tre++)cout<<q1sine[tre].A<<"*sin("<<q1sine[tre].b<<"x+"<<q1sine[tre].c<<")\t time start: "<<q0sine[tre].startPoint<<"\ttime end: "<<q0sine[tre].finishPoint<<endl; |
| 1009 |
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 we processed first event |
| 1010 |
orbitalinfo->phi = incli*atime+RYPang_upper->Ryskanie-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
|
| 1011 |
//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"; |
//Filling Inclination information |
| 1012 |
//cin>>grib; |
Double_t incli = 0; |
| 1013 |
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))); |
for(UInt_t mu = must;mu<qtime.size()-1;mu++){ |
| 1014 |
orbitalinfo->etha = incli*atime+RYPang_upper->Kren-incli*dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[oi]*1000-DeltaOBT*1000)); |
if(qtime[mu+1]>qtime[mu]){ |
| 1015 |
|
if(atime<=qtime[mu+1] && atime>=qtime[mu]){ |
| 1016 |
|
must = mu; |
| 1017 |
|
incli = (qPitch[mu+1]-qPitch[mu])/(qtime[mu+1]-qtime[mu]); |
| 1018 |
|
orbitalinfo->theta = incli*atime+qPitch[mu+1]-incli*qtime[mu+1]; |
| 1019 |
|
incli = (qRoll[mu+1]-qRoll[mu])/(qtime[mu+1]-qtime[mu]); |
| 1020 |
|
orbitalinfo->etha = incli*atime+qRoll[mu+1]-incli*qtime[mu+1]; |
| 1021 |
|
incli = (qYaw[mu+1]-qYaw[mu])/(qtime[mu+1]-qtime[mu]); |
| 1022 |
|
orbitalinfo->phi = incli*atime+qYaw[mu+1]-incli*qtime[mu+1]; |
| 1023 |
|
|
| 1024 |
|
incli = (q0[mu+1]-q0[mu])/(qtime[mu+1]-qtime[mu]); |
| 1025 |
|
orbitalinfo->q0t = incli*atime+q0[mu+1]-incli*qtime[mu+1]; |
| 1026 |
|
incli = (q1[mu+1]-q1[mu])/(qtime[mu+1]-qtime[mu]); |
| 1027 |
|
orbitalinfo->q1t = incli*atime+q1[mu+1]-incli*qtime[mu+1]; |
| 1028 |
|
incli = (q2[mu+1]-q2[mu])/(qtime[mu+1]-qtime[mu]); |
| 1029 |
|
orbitalinfo->q2t = incli*atime+q2[mu+1]-incli*qtime[mu+1]; |
| 1030 |
|
incli = (q3[mu+1]-q3[mu])/(qtime[mu+1]-qtime[mu]); |
| 1031 |
|
orbitalinfo->q3t = incli*atime+q3[mu+1]-incli*qtime[mu+1]; |
| 1032 |
|
|
| 1033 |
|
orbitalinfo->TimeGap = qtime[mu+1]-qtime[mu]; |
| 1034 |
|
orbitalinfo->mode = qmode[mu+1]; |
| 1035 |
|
if(qmode[mu+1]==-10) orbitalinfo->R10r = true;else orbitalinfo->R10r = false; |
| 1036 |
|
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){ |
| 1037 |
|
//linear interpolation |
| 1038 |
|
incli = (q0[mu+1]-q0[mu])/(qtime[mu+1]-qtime[mu]); |
| 1039 |
|
orbitalinfo->q0 = incli*atime+q0[mu+1]-incli*qtime[mu+1]; |
| 1040 |
|
incli = (q1[mu+1]-q1[mu])/(qtime[mu+1]-qtime[mu]); |
| 1041 |
|
orbitalinfo->q1 = incli*atime+q1[mu+1]-incli*qtime[mu+1]; |
| 1042 |
|
incli = (q2[mu+1]-q2[mu])/(qtime[mu+1]-qtime[mu]); |
| 1043 |
|
orbitalinfo->q2 = incli*atime+q2[mu+1]-incli*qtime[mu+1]; |
| 1044 |
|
incli = (q3[mu+1]-q3[mu])/(qtime[mu+1]-qtime[mu]); |
| 1045 |
|
orbitalinfo->q3 = incli*atime+q3[mu+1]-incli*qtime[mu+1]; |
| 1046 |
|
}else{ |
| 1047 |
|
//sine interpolation |
| 1048 |
|
for(UInt_t mt=0;mt<q0sine.size();mt++){ |
| 1049 |
|
if(atime<=q0sine[mt].finishPoint && atime>=q0sine[mt].startPoint){ |
| 1050 |
|
if(!q0sine[mt].NeedFit)orbitalinfo->q0=q0sine[mt].A*sin(q0sine[mt].b*atime+q0sine[mt].c);else{ |
| 1051 |
|
incli = (q0[mu+1]-q0[mu])/(qtime[mu+1]-qtime[mu]); |
| 1052 |
|
orbitalinfo->q0 = incli*atime+q0[mu+1]-incli*qtime[mu+1]; |
| 1053 |
|
} |
| 1054 |
|
} |
| 1055 |
|
if(atime<=q1sine[mt].finishPoint && atime>=q1sine[mt].startPoint){ |
| 1056 |
|
if(!q1sine[mt].NeedFit)orbitalinfo->q1=q1sine[mt].A*sin(q1sine[mt].b*atime+q1sine[mt].c);else{ |
| 1057 |
|
incli = (q1[mu+1]-q1[mu])/(qtime[mu+1]-qtime[mu]); |
| 1058 |
|
orbitalinfo->q1 = incli*atime+q1[mu+1]-incli*qtime[mu+1]; |
| 1059 |
|
} |
| 1060 |
|
} |
| 1061 |
|
if(atime<=q2sine[mt].finishPoint && atime>=q2sine[mt].startPoint){ |
| 1062 |
|
if(!q2sine[mt].NeedFit)orbitalinfo->q2=q0sine[mt].A*sin(q2sine[mt].b*atime+q2sine[mt].c);else{ |
| 1063 |
|
incli = (q2[mu+1]-q2[mu])/(qtime[mu+1]-qtime[mu]); |
| 1064 |
|
orbitalinfo->q2 = incli*atime+q2[mu+1]-incli*qtime[mu+1]; |
| 1065 |
|
} |
| 1066 |
|
} |
| 1067 |
|
if(atime<=q3sine[mt].finishPoint && atime>=q3sine[mt].startPoint){ |
| 1068 |
|
if(!q3sine[mt].NeedFit)orbitalinfo->q3=q0sine[mt].A*sin(q3sine[mt].b*atime+q3sine[mt].c);else{ |
| 1069 |
|
incli = (q3[mu+1]-q3[mu])/(qtime[mu+1]-qtime[mu]); |
| 1070 |
|
orbitalinfo->q3 = incli*atime+q3[mu+1]-incli*qtime[mu+1]; |
| 1071 |
|
} |
| 1072 |
|
} |
| 1073 |
|
if(atime<=Yawsine[mt].finishPoint && atime>=Yawsine[mt].startPoint){ |
| 1074 |
|
if(!Yawsine[mt].NeedFit)orbitalinfo->phi=Yawsine[mt].A*sin(Yawsine[mt].b*atime+Yawsine[mt].c);else{ |
| 1075 |
|
incli = (qYaw[mu+1]-qYaw[mu])/(qtime[mu+1]-qtime[mu]); |
| 1076 |
|
orbitalinfo->phi = incli*atime+qYaw[mu+1]-incli*qtime[mu+1]; |
| 1077 |
|
} |
| 1078 |
|
} |
| 1079 |
|
} |
| 1080 |
} |
} |
| 1081 |
} |
//q0testing->Fill(atime,orbitalinfo->q0,100); |
| 1082 |
|
//q1testing->Fill(atime,orbitalinfo->q1,100); |
| 1083 |
|
//Pitchtesting->Fill(atime,orbitalinfo->etha); |
| 1084 |
|
//q2testing->Fill(atime,orbitalinfo->q2); |
| 1085 |
|
//q3testing->Fill(atime,orbitalinfo->q3); |
| 1086 |
|
break; |
| 1087 |
|
} |
| 1088 |
} |
} |
| 1089 |
// |
} |
| 1090 |
orbitalinfo->mode = holeq(lowerqtime, upperqtime, L_QQ_Q_l_lower, L_QQ_Q_l_upper, oi); |
|
|
// |
|
|
} else { |
|
|
if ( debug ) printf(" ops no incl! \n"); |
|
|
orbitalinfo->mode = 10; |
|
|
}; |
|
| 1091 |
// |
// |
| 1092 |
// ops no inclination information |
// ops no inclination information |
| 1093 |
// |
// |
| 1094 |
|
|
| 1095 |
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 ){ |
| 1096 |
orbitalinfo->mode = 10; |
orbitalinfo->mode = 10; |
| 1097 |
orbitalinfo->q0 = -1000.; |
orbitalinfo->q0 = -1000.; |
| 1137 |
// |
// |
| 1138 |
}; |
}; |
| 1139 |
// |
// |
| 1140 |
|
if ( debug ) printf(" pitch angle \n"); |
| 1141 |
|
// |
| 1142 |
// pitch angles |
// pitch angles |
| 1143 |
// |
// |
| 1144 |
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 ){ |
| 1175 |
Double_t E22z = zin[3]; |
Double_t E22z = zin[3]; |
| 1176 |
if ( (E11x < 100. && E11y < 100. && E22x < 100. && E22y < 100.) || ptt->trkseqno != -1 ){ |
if ( (E11x < 100. && E11y < 100. && E22x < 100. && E22y < 100.) || ptt->trkseqno != -1 ){ |
| 1177 |
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)); |
| 1178 |
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)); |
| 1179 |
if(E22x-E11x>=0 && E22y-E11y <0) MyAzim = 360. - MyAzim; |
// if(E22x-E11x>=0 && E22y-E11y <0) MyAzim = 360. - MyAzim; |
| 1180 |
if(E22x-E11x>=0 && E22y-E11y >=0) MyAzim = MyAzim; |
// if(E22x-E11x>=0 && E22y-E11y >=0) MyAzim = MyAzim; |
| 1181 |
if(E22x-E11x<0 && E22y-E11y >0) MyAzim = 180. - MyAzim; |
// if(E22x-E11x<0 && E22y-E11y >0) MyAzim = 180. - MyAzim; |
| 1182 |
if(E22x-E11x<0 && E22y-E11y <0) MyAzim = 180. + MyAzim; |
// if(E22x-E11x<0 && E22y-E11y <0) MyAzim = 180. + MyAzim; |
| 1183 |
Px = (E22x-E11x)/norm; |
Px = (E22x-E11x)/norm; |
| 1184 |
Py = (E22y-E11y)/norm; |
Py = (E22y-E11y)/norm; |
| 1185 |
Pz = (E22z-E11z)/norm; |
Pz = (E22z-E11z)/norm; |
| 1258 |
// |
// |
| 1259 |
// Here you may want to clear some variables before processing another run |
// Here you may want to clear some variables before processing another run |
| 1260 |
// |
// |
| 1261 |
|
|
| 1262 |
|
//gStyle->SetOptStat(000000); |
| 1263 |
|
//gStyle->SetPalette(1); |
| 1264 |
|
|
| 1265 |
|
/*TCanvas* c1 = new TCanvas("c1","",1200,800); |
| 1266 |
|
//c1->Divide(1,4); |
| 1267 |
|
c1->cd(1); |
| 1268 |
|
//q0testing->Draw("colz"); |
| 1269 |
|
//c1->cd(2); |
| 1270 |
|
//q1testing->Draw("colz"); |
| 1271 |
|
//c1->cd(3); |
| 1272 |
|
Pitchtesting->Draw("colz"); |
| 1273 |
|
//c1->cd(4); |
| 1274 |
|
//q3testing->Draw("colz"); |
| 1275 |
|
c1->SaveAs("9.Rollhyst.png"); |
| 1276 |
|
delete c1;*/ |
| 1277 |
|
|
| 1278 |
delete dbtime; |
delete dbtime; |
| 1279 |
if ( L_QQ_Q_l_upper ) delete L_QQ_Q_l_upper; |
if ( L_QQ_Q_l_upper ) delete L_QQ_Q_l_upper; |
| 1280 |
if ( L_QQ_Q_l_lower ) delete L_QQ_Q_l_lower; |
if ( L_QQ_Q_l_lower ) delete L_QQ_Q_l_lower; |
| 1299 |
// |
// |
| 1300 |
// Get entry from old tree |
// Get entry from old tree |
| 1301 |
// |
// |
| 1302 |
OrbitalInfotrclone->GetEntry(j); |
if ( OrbitalInfotrclone->GetEntry(j) <= 0 ) throw -36; |
| 1303 |
// |
// |
| 1304 |
// copy orbitalinfoclone to OrbitalInfo |
// copy orbitalinfoclone to OrbitalInfo |
| 1305 |
// |
// |
| 1391 |
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){ |
| 1392 |
|
|
| 1393 |
UInt_t hole = 10; |
UInt_t hole = 10; |
| 1394 |
bool R10l = false; // Sign of R10 mode in lower quaternions array |
Bool_t R10l = false; // Sign of R10 mode in lower quaternions array |
| 1395 |
bool R10u = false; // Sign of R10 mode in upper quaternions array |
Bool_t R10u = false; // Sign of R10 mode in upper quaternions array |
| 1396 |
bool insm = false; // Sign that we inside quaternions array |
Bool_t insm = false; // Sign that we inside quaternions array |
| 1397 |
bool mxtml = false; // Sign of mixt mode in lower quaternions array |
Bool_t mxtml = false; // Sign of mixt mode in lower quaternions array |
| 1398 |
bool mxtmu = false; // Sign of mixt mode in upper quaternions array |
Bool_t mxtmu = false; // Sign of mixt mode in upper quaternions array |
| 1399 |
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 |
| 1400 |
UInt_t NCQl = 6; // Number of correct quaternions in lower array |
UInt_t NCQl = 6; // Number of correct quaternions in lower array |
| 1401 |
UInt_t NCQu = 6; // Number of correct quaternions in upper array |
UInt_t NCQu = 6; // Number of correct quaternions in upper array |
| 1402 |
if (f>0){ |
if (f>0){ |
| 1439 |
return hole; |
return hole; |
| 1440 |
} |
} |
| 1441 |
|
|
| 1442 |
|
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){ |
| 1443 |
|
Int_t sizee = t.size()+1; |
| 1444 |
|
t.resize(sizee); |
| 1445 |
|
q0.resize(sizee); |
| 1446 |
|
q1.resize(sizee); |
| 1447 |
|
q2.resize(sizee); |
| 1448 |
|
q3.resize(sizee); |
| 1449 |
|
mode.resize(sizee); |
| 1450 |
|
Roll.resize(sizee); |
| 1451 |
|
Pitch.resize(sizee); |
| 1452 |
|
Yaw.resize(sizee); |
| 1453 |
|
} |
| 1454 |
|
|
| 1455 |
|
//Find fitting sine functions for q0,q1,q2,q3 and Yaw-angle; |
| 1456 |
|
void sineparam(vector<Sine>& qsine, vector<Double_t>& qtime, vector<Float_t>& q, vector<Float_t>& Roll, vector<Float_t>& Pitch, Float_t limsin){ |
| 1457 |
|
UInt_t mulast = 0; |
| 1458 |
|
UInt_t munow = 0; |
| 1459 |
|
UInt_t munext = 0; |
| 1460 |
|
Bool_t increase = false; |
| 1461 |
|
Bool_t decrease = false; |
| 1462 |
|
Bool_t Max_is_defined = false; |
| 1463 |
|
Bool_t Start_point_is_defined = false; |
| 1464 |
|
Bool_t Period_is_defined = false; |
| 1465 |
|
Bool_t Large_gap = false; |
| 1466 |
|
Bool_t normal_way = true; |
| 1467 |
|
Bool_t small_gap_on_ridge = false; |
| 1468 |
|
Double_t t1 = 0; |
| 1469 |
|
Double_t t1A = 0; |
| 1470 |
|
Int_t sinesize = 0; |
| 1471 |
|
Int_t nfi = 0; |
| 1472 |
|
for(UInt_t mu = 0;mu<qtime.size();mu++){ |
| 1473 |
|
if(Roll[mu]<1. && Pitch[mu]<1.){ |
| 1474 |
|
if(munext==0 && munow!=0)munext=mu; |
| 1475 |
|
if(munow==0 && mulast!=0)munow=mu; |
| 1476 |
|
if(mulast==0)mulast=mu; |
| 1477 |
|
if(mulast!=0 && munow!=0 && munext!=0){mulast=munow;munow=munext;munext=mu;} |
| 1478 |
|
if(TMath::Abs(q[munow])>TMath::Abs(q[mulast]) && TMath::Abs(q[munow])>TMath::Abs(q[munext]) && TMath::Abs(q[munow])>limsin && qtime[munext]-qtime[mulast]>400)small_gap_on_ridge = true; |
| 1479 |
|
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; |
| 1480 |
|
if(Large_gap || small_gap_on_ridge){ |
| 1481 |
|
//cout<<"Large gap..."<<endl; |
| 1482 |
|
//if(small_gap_on_ridge)cout<<"small gap..."<<endl; |
| 1483 |
|
increase = false; |
| 1484 |
|
decrease = false; |
| 1485 |
|
if(nfi>0){ |
| 1486 |
|
qsine.resize(qsine.size()-1); |
| 1487 |
|
sinesize = qsine.size(); |
| 1488 |
|
}else{ |
| 1489 |
|
if(!Period_is_defined){ |
| 1490 |
|
if(qsine.size()>1){ |
| 1491 |
|
qsine[sinesize-1].b = qsine[sinesize-2].b; |
| 1492 |
|
qsine[sinesize-1].c = qsine[sinesize-2].c; |
| 1493 |
|
}else{ |
| 1494 |
|
qsine[sinesize-1].b = TMath::Pi()/1591.54; |
| 1495 |
|
qsine[sinesize-1].c = qsine[sinesize-1].startPoint; |
| 1496 |
|
} |
| 1497 |
|
} |
| 1498 |
|
if(!Max_is_defined){ |
| 1499 |
|
if(qsine.size()>1)qsine[sinesize-1].A = qsine[sinesize-2].A;else qsine[sinesize-1].A = limsin; |
| 1500 |
|
} |
| 1501 |
|
qsine[sinesize-1].NeedFit = true; |
| 1502 |
|
} |
| 1503 |
|
qsine[sinesize-1].finishPoint = qtime[munow]; |
| 1504 |
|
nfi = 0; |
| 1505 |
|
Max_is_defined = false; |
| 1506 |
|
Start_point_is_defined = false; |
| 1507 |
|
Period_is_defined = false; |
| 1508 |
|
small_gap_on_ridge = false; |
| 1509 |
|
} |
| 1510 |
|
if(munext > munow && munow > mulast && normal_way){ |
| 1511 |
|
if(!increase && !decrease){ |
| 1512 |
|
qsine.resize(qsine.size()+1); |
| 1513 |
|
sinesize = qsine.size(); |
| 1514 |
|
qsine[sinesize-1].startPoint=qtime[mulast]; |
| 1515 |
|
if(q[munext]>q[munow] && q[munow]>q[mulast]) increase = true; |
| 1516 |
|
if(q[munext]<q[munow] && q[munow]<q[mulast]) decrease = true; |
| 1517 |
|
} |
| 1518 |
|
//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;} |
| 1519 |
|
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){ |
| 1520 |
|
//cout<<"Max point is qtime = "<<qtime[munow]<<"\tq = "<<q[munow]<<endl; |
| 1521 |
|
if(q[munow]>q[mulast]){ |
| 1522 |
|
increase = false; |
| 1523 |
|
decrease = true; |
| 1524 |
|
} |
| 1525 |
|
if(q[munow]<q[mulast]){ |
| 1526 |
|
increase = true; |
| 1527 |
|
decrease = false; |
| 1528 |
|
} |
| 1529 |
|
if(Max_is_defined && !Start_point_is_defined){ |
| 1530 |
|
Double_t qPer = qtime[munow]-t1A; |
| 1531 |
|
if(qPer>1000){ |
| 1532 |
|
//cout<<"qsine["<<sinesize-1<<"] = "<<qPer<<" = "<<qtime[munow]<<" - "<<t1A<<"\tlim = "<<limsin<<endl; |
| 1533 |
|
qsine[sinesize-1].b=TMath::Pi()/qPer; |
| 1534 |
|
if(decrease)qsine[sinesize-1].c=-qsine[sinesize-1].b*t1A; |
| 1535 |
|
if(increase)qsine[sinesize-1].c=-qsine[sinesize-1].b*(t1A-qPer); |
| 1536 |
|
Period_is_defined = true; |
| 1537 |
|
} |
| 1538 |
|
} |
| 1539 |
|
Max_is_defined = true; |
| 1540 |
|
qsine[sinesize-1].A = TMath::Abs(q[munow]); |
| 1541 |
|
if(Start_point_is_defined && Period_is_defined){ |
| 1542 |
|
qsine[sinesize-1].finishPoint = qtime[munow]; |
| 1543 |
|
nfi++; |
| 1544 |
|
qsine[sinesize-1].NeedFit = false; |
| 1545 |
|
Max_is_defined = false; |
| 1546 |
|
Start_point_is_defined = false; |
| 1547 |
|
Period_is_defined = false; |
| 1548 |
|
qsine.resize(qsine.size()+1); |
| 1549 |
|
sinesize = qsine.size(); |
| 1550 |
|
qsine[sinesize-1].startPoint = qtime[munow]; |
| 1551 |
|
} |
| 1552 |
|
if(!Start_point_is_defined) t1A=qtime[munow]; |
| 1553 |
|
} |
| 1554 |
|
//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; |
| 1555 |
|
if(((q[munow]>=0 && q[mulast]<=0) || (q[munow]<=0 && q[mulast]>=0)) && qtime[munow]-qtime[mulast]<2000 && qtime[munext]-qtime[munow]<2000){ |
| 1556 |
|
Double_t tcrosszero = 0; |
| 1557 |
|
//cout<<"cross zero point...qtime = "<<qtime[munow]<<endl; |
| 1558 |
|
if(q[munow]==0.) tcrosszero = qtime[munow];else |
| 1559 |
|
if(q[mulast]==0.)tcrosszero = qtime[mulast];else{ |
| 1560 |
|
Double_t k_ = (q[munow]-q[mulast])/(qtime[munow]-qtime[mulast]); |
| 1561 |
|
Double_t b_ = q[munow]-k_*qtime[munow]; |
| 1562 |
|
tcrosszero = -b_/k_; |
| 1563 |
|
} |
| 1564 |
|
if(Start_point_is_defined){ |
| 1565 |
|
//cout<<"Start Point allready defined"<<endl; |
| 1566 |
|
Double_t qPer = tcrosszero - t1; |
| 1567 |
|
qsine[sinesize-1].b = TMath::Pi()/qPer; |
| 1568 |
|
//cout<<"qsine["<<sinesize-1<<"].b = "<<TMath::Pi()/qPer<<endl; |
| 1569 |
|
Period_is_defined = true; |
| 1570 |
|
Float_t x0 = 0; |
| 1571 |
|
if(decrease)x0 = t1; |
| 1572 |
|
if(increase)x0 = tcrosszero; |
| 1573 |
|
qsine[sinesize-1].c = -qsine[sinesize-1].b*x0; |
| 1574 |
|
if(Max_is_defined){ |
| 1575 |
|
//cout<<"Max was previous defined"<<endl; |
| 1576 |
|
qsine[sinesize-1].finishPoint = qtime[munow]; |
| 1577 |
|
nfi++; |
| 1578 |
|
qsine[sinesize-1].NeedFit = false; |
| 1579 |
|
Max_is_defined = false; |
| 1580 |
|
t1 = tcrosszero; |
| 1581 |
|
Start_point_is_defined = true; |
| 1582 |
|
Period_is_defined = false; |
| 1583 |
|
qsine.resize(qsine.size()+1); |
| 1584 |
|
sinesize = qsine.size(); |
| 1585 |
|
qsine[sinesize-1].startPoint = qtime[munow]; |
| 1586 |
|
} |
| 1587 |
|
}else{ |
| 1588 |
|
t1 = tcrosszero; |
| 1589 |
|
Start_point_is_defined = true; |
| 1590 |
|
} |
| 1591 |
|
} |
| 1592 |
|
} |
| 1593 |
|
} |
| 1594 |
|
} |
| 1595 |
|
|
| 1596 |
|
//cout<<"FINISH SINE INTERPOLATION FUNCTION..."<<endl<<endl; |
| 1597 |
|
} |