/[PAMELA software]/DarthVader/OrbitalInfo/src/OrbitalInfoCore.cpp
ViewVC logotype

Diff of /DarthVader/OrbitalInfo/src/OrbitalInfoCore.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.60 by pam-mep, Thu Jun 7 14:04:00 2012 UTC revision 1.68 by mocchiut, Wed Feb 26 13:01:05 2014 UTC
# Line 122  int OrbitalInfoCore(UInt_t run, TFile *f Line 122  int OrbitalInfoCore(UInt_t run, TFile *f
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;
# Line 182  int OrbitalInfoCore(UInt_t run, TFile *f Line 183  int OrbitalInfoCore(UInt_t run, TFile *f
183    //    //
184    // IGRF stuff    // IGRF stuff
185    //    //
186    Float_t 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_t bnorth, beast, bdown, babs;    Float_t bnorth, beast, bdown, babs;
188    Float_t xl; // L value    Float_t xl; // L value
189    Float_t icode; // code value for L accuracy (see fortran code)    Float_t icode; // code value for L accuracy (see fortran code)
# Line 248  int OrbitalInfoCore(UInt_t run, TFile *f Line 249  int OrbitalInfoCore(UInt_t run, TFile *f
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;  
# Line 590  int OrbitalInfoCore(UInt_t run, TFile *f Line 591  int OrbitalInfoCore(UInt_t run, TFile *f
591      //      //
592      // open IGRF files and do it only once if we are processing a full level2 file      // open IGRF files and do it only once if we are processing a full level2 file
593      //      //
594      if ( irun == 0 ){      if ( !igrfloaded ){
595        if ( l0head->GetEntry(runinfo->EV_FROM) <= 0 ) throw -36;  
596        //        if ( l0head->GetEntry(runinfo->EV_FROM) > 0 ){
597        // absolute time of first event of the run (it should not matter a lot)          igrfloaded = true;
598        //          //
599        ph = eh->GetPscuHeader();          // absolute time of first event of the run (it should not matter a lot)
600        atime = dbtime->DBabsTime(ph->GetOrbitalTime());          //
601                  ph = eh->GetPscuHeader();
602        parerror=glparam->Query_GL_PARAM(atime-anni5,301,dbc); // parameters stored in DB in GL_PRAM table            atime = dbtime->DBabsTime(ph->GetOrbitalTime());
603        if ( parerror<0 ) {          
604          code = parerror;          parerror=glparam->Query_GL_PARAM(atime-anni5,301,dbc); // parameters stored in DB in GL_PRAM table  
605          goto closeandexit;          if ( parerror<0 ) {
606      };            code = parerror;
607        ltp1 = (Int_t)(glparam->PATH+glparam->NAME).Length();            goto closeandexit;
608        if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam->PATH+glparam->NAME).Data());          }
609        //          ltp1 = (Int_t)(glparam->PATH+glparam->NAME).Length();
610        parerror=glparam2->Query_GL_PARAM(atime,301,dbc); // parameters stored in DB in GL_PRAM table            if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam->PATH+glparam->NAME).Data());
611        if ( parerror<0 ) {          //
612          code = parerror;          parerror=glparam2->Query_GL_PARAM(atime,301,dbc); // parameters stored in DB in GL_PRAM table  
613          goto closeandexit;          if ( parerror<0 ) {
614        };            code = parerror;
615        ltp2 = (Int_t)(glparam2->PATH+glparam->NAME).Length();            goto closeandexit;
616        if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam2->PATH+glparam2->NAME).Data());          }
617        //          ltp2 = (Int_t)(glparam2->PATH+glparam2->NAME).Length();
618        parerror=glparam3->Query_GL_PARAM(atime,302,dbc); // parameters stored in DB in GL_PRAM table          if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam2->PATH+glparam2->NAME).Data());
619        if ( parerror<0 ) {          //
620          code = parerror;          parerror=glparam3->Query_GL_PARAM(atime,302,dbc); // parameters stored in DB in GL_PRAM table
621          goto closeandexit;          if ( parerror<0 ) {
622        };            code = parerror;
623        ltp3 = (Int_t)(glparam3->PATH+glparam2->NAME).Length();            goto closeandexit;
624        if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam3->PATH+glparam3->NAME).Data());          }
625        //          ltp3 = (Int_t)(glparam3->PATH+glparam3->NAME).Length();
626        initize_((char *)(glparam->PATH+glparam->NAME).Data(),&ltp1,(char *)(glparam2->PATH+glparam2->NAME).Data(),&ltp2,(char *)(glparam3->PATH+glparam3->NAME).Data(),&ltp3);          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(),&ltp1,(char *)(glparam2->PATH+glparam2->NAME).Data(),&ltp2,(char *)(glparam3->PATH+glparam3->NAME).Data(),&ltp3);
629            //
630          }
631      }      }
632      //      //
633      // End IGRF stuff//      // End IGRF stuff//
# Line 751  int OrbitalInfoCore(UInt_t run, TFile *f Line 755  int OrbitalInfoCore(UInt_t run, TFile *f
755    
756  //    UInt_t mctren = 0;      //    UInt_t mctren = 0;    
757  //    UInt_t mcreen = 0;          //    UInt_t mcreen = 0;        
758      UInt_t numrec = 0;  //    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 information from mcmd-packets      // 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;      vector<Float_t> q0;
773      vector<Float_t> q1;      vector<Float_t> q1;
# Line 843  int OrbitalInfoCore(UInt_t run, TFile *f Line 847  int OrbitalInfoCore(UInt_t run, TFile *f
847          //          //
848          tof->Clear();          tof->Clear();
849          //          //
850          if ( ttof->GetEntry(itr) <= 0 ) throw -36;          if ( ttof->GetEntry(itr) <= 0 ){
851             if ( verbose ) printf(" problems with tof tree entries... entry = %i in Level2 file\n",itr);
852             if ( verbose ) printf(" nobefrun %u re %u evfrom %u jumped %u reprocall %i \n",nobefrun,re,evfrom,jumped,reprocall);
853             throw -36;
854            }
855          //          //
856        };        };
857        //        //
# Line 908  int OrbitalInfoCore(UInt_t run, TFile *f Line 916  int OrbitalInfoCore(UInt_t run, TFile *f
916          // First event          // First event
917          //          //
918          isf = false;          isf = false;
919          upperqtime = atime;          //      upperqtime = atime;
920          lowerqtime = runinfo->RUNHEADER_TIME;          lowerqtime = runinfo->RUNHEADER_TIME;
921          for ( ik = 0; ik < neventsm; ik++){  //number of macrocommad packets          for ( ik = 0; ik < neventsm; ik++){  //number of macrocommad packets
922            if ( ch->GetEntry(ik) <= 0 ) throw -36;            if ( ch->GetEntry(ik) <= 0 ) throw -36;
923            tmpSize = mcmdev->Records->GetEntries();            tmpSize = mcmdev->Records->GetEntries();
924            numrec = tmpSize;            //      numrec = tmpSize;
925            for (Int_t j3 = 0;j3<tmpSize;j3++){  //number of subpackets            for (Int_t j3 = 0;j3<tmpSize;j3++){  //number of subpackets
926              if ( debug ) printf(" ik %i j3 %i eh eh eh \n",ik,j3);              if ( debug ) printf(" ik %i j3 %i eh eh eh \n",ik,j3);
927              mcmdrc = (pamela::McmdRecord*)mcmdev->Records->At(j3);              mcmdrc = (pamela::McmdRecord*)mcmdev->Records->At(j3);
# Line 924  int OrbitalInfoCore(UInt_t run, TFile *f Line 932  int OrbitalInfoCore(UInt_t run, TFile *f
932                  for (UInt_t ui = 0; ui < 6; ui++){                  for (UInt_t ui = 0; ui < 6; ui++){
933                    if (ui>0){                    if (ui>0){
934                      if (L_QQ_Q_l_upper->time[ui]>L_QQ_Q_l_upper->time[0]){                      if (L_QQ_Q_l_upper->time[ui]>L_QQ_Q_l_upper->time[0]){
935                          if ( debug ) printf(" here1 %i \n",ui);                        if ( debug ) printf(" here1 %i \n",ui);
936                        Double_t u_time = 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));
937                        Int_t recSize = recqtime.size();                        Int_t recSize = recqtime.size();
938                        if(lowerqtime > recqtime[recSize-1]){                        if(lowerqtime > recqtime[recSize-1]){
939                            Int_t sizeqmcmd = qtime.size();                          Int_t sizeqmcmd = qtime.size();
940                            inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw);                          inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw);
941                            qtime[sizeqmcmd]=u_time;                          qtime[sizeqmcmd]=u_time;
942                            q0[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][0];                          q0[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][0];
943                            q1[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][1];                          q1[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][1];
944                            q2[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][2];                          q2[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][2];
945                            q3[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][3];                          q3[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][3];
946                            qmode[sizeqmcmd]=holeq(lowerqtime,qtime[sizeqmcmd],L_QQ_Q_l_lower,L_QQ_Q_l_upper,ui);                          qmode[sizeqmcmd]=holeq(lowerqtime,qtime[sizeqmcmd],L_QQ_Q_l_lower,L_QQ_Q_l_upper,ui);
947                            lowerqtime = u_time;                          lowerqtime = u_time;
948                            orbits.getPosition((double) (u_time - gltle->GetFromTime())/60., &eCi);                          orbits.getPosition((double) (u_time - gltle->GetFromTime())/60., &eCi);
949                            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]);                          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]);
950                            qRoll[sizeqmcmd]=RYPang_upper->Kren;                          qRoll[sizeqmcmd]=RYPang_upper->Kren;
951                            qYaw[sizeqmcmd]=RYPang_upper->Ryskanie;                          qYaw[sizeqmcmd]=RYPang_upper->Ryskanie;
952                            qPitch[sizeqmcmd]=RYPang_upper->Tangazh;                          qPitch[sizeqmcmd]=RYPang_upper->Tangazh;
953                        }                        }
954                        for(Int_t mu = nt;mu<recSize;mu++){                        for(Int_t mu = nt;mu<recSize;mu++){
955                          if(recqtime[mu]>lowerqtime && recqtime[mu]<u_time){                          if(recqtime[mu]>lowerqtime && recqtime[mu]<u_time){
# Line 980  int OrbitalInfoCore(UInt_t run, TFile *f Line 988  int OrbitalInfoCore(UInt_t run, TFile *f
988                        }                        }
989                      }                      }
990                    }else{                    }else{
991                          if ( debug ) printf(" here2 %i \n",ui);                      if ( debug ) printf(" here2 %i \n",ui);
992                      Double_t u_time = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000));                      Double_t u_time = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000));
993                      if(lowerqtime>u_time)nt=0;                      if(lowerqtime>u_time)nt=0;
994                      Int_t recSize = recqtime.size();                      Int_t recSize = recqtime.size();
995                      if(lowerqtime > recqtime[recSize-1]){                      if(lowerqtime > recqtime[recSize-1]){
996                          Int_t sizeqmcmd = qtime.size();                        Int_t sizeqmcmd = qtime.size();
997                          inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw);                        inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw);
998                          qtime[sizeqmcmd]=u_time;                        qtime[sizeqmcmd]=u_time;
999                          q0[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][0];                        q0[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][0];
1000                          q1[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][1];                        q1[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][1];
1001                          q2[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][2];                        q2[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][2];
1002                          q3[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][3];                        q3[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][3];
1003                          qmode[sizeqmcmd]=holeq(lowerqtime,qtime[sizeqmcmd],L_QQ_Q_l_lower,L_QQ_Q_l_upper,ui);                        qmode[sizeqmcmd]=holeq(lowerqtime,qtime[sizeqmcmd],L_QQ_Q_l_lower,L_QQ_Q_l_upper,ui);
1004                          lowerqtime = u_time;                        lowerqtime = u_time;
1005                          orbits.getPosition((double) (u_time - gltle->GetFromTime())/60., &eCi);                        orbits.getPosition((double) (u_time - gltle->GetFromTime())/60., &eCi);
1006                          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]);                        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]);
1007                          qRoll[sizeqmcmd]=RYPang_upper->Kren;                        qRoll[sizeqmcmd]=RYPang_upper->Kren;
1008                          qYaw[sizeqmcmd]=RYPang_upper->Ryskanie;                        qYaw[sizeqmcmd]=RYPang_upper->Ryskanie;
1009                          qPitch[sizeqmcmd]=RYPang_upper->Tangazh;                        qPitch[sizeqmcmd]=RYPang_upper->Tangazh;
1010                      }                      }
1011                      for(Int_t mu = nt;mu<recSize;mu++){                      for(Int_t mu = nt;mu<recSize;mu++){
1012                        if(recqtime[mu]>lowerqtime && recqtime[mu]<u_time){                        if(recqtime[mu]>lowerqtime && recqtime[mu]<u_time){
# Line 1045  int OrbitalInfoCore(UInt_t run, TFile *f Line 1053  int OrbitalInfoCore(UInt_t run, TFile *f
1053          }          }
1054                    
1055          if(qtime.size()==0){          if(qtime.size()==0){
1056              for(UInt_t my=0;my<recqtime.size();my++){            for(UInt_t my=0;my<recqtime.size();my++){
1057                  Int_t sizeqmcmd = qtime.size();              Int_t sizeqmcmd = qtime.size();
1058                  inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw);              inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw);
1059                  qtime[sizeqmcmd]=recqtime[my];              qtime[sizeqmcmd]=recqtime[my];
1060                  q0[sizeqmcmd]=recq0[my];              q0[sizeqmcmd]=recq0[my];
1061                  q1[sizeqmcmd]=recq1[my];              q1[sizeqmcmd]=recq1[my];
1062                  q2[sizeqmcmd]=recq2[my];              q2[sizeqmcmd]=recq2[my];
1063                  q3[sizeqmcmd]=recq3[my];              q3[sizeqmcmd]=recq3[my];
1064                  qmode[sizeqmcmd]=-10;              qmode[sizeqmcmd]=-10;
1065                  orbits.getPosition((double) (qtime[sizeqmcmd] - gltle->GetFromTime())/60., &eCi);              orbits.getPosition((double) (qtime[sizeqmcmd] - gltle->GetFromTime())/60., &eCi);
1066                  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]);              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]);
1067                  qRoll[sizeqmcmd]=RYPang_upper->Kren;              qRoll[sizeqmcmd]=RYPang_upper->Kren;
1068                  qYaw[sizeqmcmd]=RYPang_upper->Ryskanie;              qYaw[sizeqmcmd]=RYPang_upper->Ryskanie;
1069                  qPitch[sizeqmcmd]=RYPang_upper->Tangazh;              qPitch[sizeqmcmd]=RYPang_upper->Tangazh;
1070              }            }
1071          }          }
1072                    
1073          if ( debug ) printf(" fuffi \n");          if ( debug ) printf(" fuffi \n");
# Line 1079  int OrbitalInfoCore(UInt_t run, TFile *f Line 1087  int OrbitalInfoCore(UInt_t run, TFile *f
1087        //Filling Inclination information        //Filling Inclination information
1088        Double_t incli = 0;        Double_t incli = 0;
1089        if ( qtime.size() > 1 ){        if ( qtime.size() > 1 ){
1090        for(UInt_t mu = must;mu<qtime.size()-1;mu++){          for(UInt_t mu = must;mu<qtime.size()-1;mu++){
1091          if ( debug ) printf(" ??grfuffi %i sixe %i must %i \n",mu,qtime.size()-1,must);            if ( debug ) printf(" ??grfuffi %i sixe %i must %i \n",mu,qtime.size()-1,must);
1092          if(qtime[mu+1]>qtime[mu]){            if(qtime[mu+1]>qtime[mu]){
1093            if ( debug ) printf(" grfuffi2 %i \n",mu);              if ( debug ) printf(" grfuffi2 %i \n",mu);
1094            if(atime<=qtime[mu+1] && atime>=qtime[mu]){              if(atime<=qtime[mu+1] && atime>=qtime[mu]){
1095              must = mu;                must = mu;
1096              incli = (qPitch[mu+1]-qPitch[mu])/(qtime[mu+1]-qtime[mu]);                if ( debug ) printf(" grfuffi3 %i \n",mu);
1097              orbitalinfo->theta =  incli*atime+qPitch[mu+1]-incli*qtime[mu+1];                incli = (qPitch[mu+1]-qPitch[mu])/(qtime[mu+1]-qtime[mu]);
1098              incli = (qRoll[mu+1]-qRoll[mu])/(qtime[mu+1]-qtime[mu]);                orbitalinfo->theta =  incli*atime+qPitch[mu+1]-incli*qtime[mu+1];
1099              orbitalinfo->etha =  incli*atime+qRoll[mu+1]-incli*qtime[mu+1];                incli = (qRoll[mu+1]-qRoll[mu])/(qtime[mu+1]-qtime[mu]);
1100              incli = (qYaw[mu+1]-qYaw[mu])/(qtime[mu+1]-qtime[mu]);                orbitalinfo->etha =  incli*atime+qRoll[mu+1]-incli*qtime[mu+1];
1101              orbitalinfo->phi =  incli*atime+qYaw[mu+1]-incli*qtime[mu+1];                incli = (qYaw[mu+1]-qYaw[mu])/(qtime[mu+1]-qtime[mu]);
1102                              orbitalinfo->phi =  incli*atime+qYaw[mu+1]-incli*qtime[mu+1];
1103              incli = (q0[mu+1]-q0[mu])/(qtime[mu+1]-qtime[mu]);                
1104              orbitalinfo->q0 =  incli*atime+q0[mu+1]-incli*qtime[mu+1];                incli = (q0[mu+1]-q0[mu])/(qtime[mu+1]-qtime[mu]);
1105              incli = (q1[mu+1]-q1[mu])/(qtime[mu+1]-qtime[mu]);                orbitalinfo->q0 =  incli*atime+q0[mu+1]-incli*qtime[mu+1];
1106              orbitalinfo->q1 =  incli*atime+q1[mu+1]-incli*qtime[mu+1];                incli = (q1[mu+1]-q1[mu])/(qtime[mu+1]-qtime[mu]);
1107              incli = (q2[mu+1]-q2[mu])/(qtime[mu+1]-qtime[mu]);                orbitalinfo->q1 =  incli*atime+q1[mu+1]-incli*qtime[mu+1];
1108              orbitalinfo->q2 =  incli*atime+q2[mu+1]-incli*qtime[mu+1];                incli = (q2[mu+1]-q2[mu])/(qtime[mu+1]-qtime[mu]);
1109              incli = (q3[mu+1]-q3[mu])/(qtime[mu+1]-qtime[mu]);                orbitalinfo->q2 =  incli*atime+q2[mu+1]-incli*qtime[mu+1];
1110              orbitalinfo->q3 =  incli*atime+q3[mu+1]-incli*qtime[mu+1];                incli = (q3[mu+1]-q3[mu])/(qtime[mu+1]-qtime[mu]);
1111                              orbitalinfo->q3 =  incli*atime+q3[mu+1]-incli*qtime[mu+1];
1112              orbitalinfo->TimeGap = qtime[mu+1]-qtime[mu];                
1113              orbitalinfo->mode = qmode[mu+1];                orbitalinfo->TimeGap = qtime[mu+1]-qtime[mu];
1114              //if(qmode[mu+1]==-10) orbitalinfo->R10r = true;else orbitalinfo->R10r = false;                orbitalinfo->mode = qmode[mu+1];
1115              //reserved for next versions Vitaly.                //if(qmode[mu+1]==-10) orbitalinfo->R10r = true;else orbitalinfo->R10r = false;
1116              /*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){                //reserved for next versions Vitaly.
1117                  /*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){
1118                //linear interpolation                //linear interpolation
1119                incli = (q0[mu+1]-q0[mu])/(qtime[mu+1]-qtime[mu]);                incli = (q0[mu+1]-q0[mu])/(qtime[mu+1]-qtime[mu]);
1120                orbitalinfo->q0 =  incli*atime+q0[mu+1]-incli*qtime[mu+1];                orbitalinfo->q0 =  incli*atime+q0[mu+1]-incli*qtime[mu+1];
# Line 1115  int OrbitalInfoCore(UInt_t run, TFile *f Line 1124  int OrbitalInfoCore(UInt_t run, TFile *f
1124                orbitalinfo->q2 =  incli*atime+q2[mu+1]-incli*qtime[mu+1];                orbitalinfo->q2 =  incli*atime+q2[mu+1]-incli*qtime[mu+1];
1125                incli = (q3[mu+1]-q3[mu])/(qtime[mu+1]-qtime[mu]);                incli = (q3[mu+1]-q3[mu])/(qtime[mu+1]-qtime[mu]);
1126                orbitalinfo->q3 =  incli*atime+q3[mu+1]-incli*qtime[mu+1];                orbitalinfo->q3 =  incli*atime+q3[mu+1]-incli*qtime[mu+1];
1127              }else{                }else{
1128                //sine interpolation                //sine interpolation
1129                for(UInt_t mt=0;mt<q0sine.size();mt++){                for(UInt_t mt=0;mt<q0sine.size();mt++){
1130                  if(atime<=q0sine[mt].finishPoint && atime>=q0sine[mt].startPoint){                if(atime<=q0sine[mt].finishPoint && atime>=q0sine[mt].startPoint){
1131                    if(!q0sine[mt].NeedFit)orbitalinfo->q0=q0sine[mt].A*sin(q0sine[mt].b*atime+q0sine[mt].c);else{                if(!q0sine[mt].NeedFit)orbitalinfo->q0=q0sine[mt].A*sin(q0sine[mt].b*atime+q0sine[mt].c);else{
1132                      incli = (q0[mu+1]-q0[mu])/(qtime[mu+1]-qtime[mu]);                incli = (q0[mu+1]-q0[mu])/(qtime[mu+1]-qtime[mu]);
1133                      orbitalinfo->q0 =  incli*atime+q0[mu+1]-incli*qtime[mu+1];                orbitalinfo->q0 =  incli*atime+q0[mu+1]-incli*qtime[mu+1];
1134                    }                }
1135                  }                }
1136                  if(atime<=q1sine[mt].finishPoint && atime>=q1sine[mt].startPoint){                if(atime<=q1sine[mt].finishPoint && atime>=q1sine[mt].startPoint){
1137                    if(!q1sine[mt].NeedFit)orbitalinfo->q1=q1sine[mt].A*sin(q1sine[mt].b*atime+q1sine[mt].c);else{                if(!q1sine[mt].NeedFit)orbitalinfo->q1=q1sine[mt].A*sin(q1sine[mt].b*atime+q1sine[mt].c);else{
1138                      incli = (q1[mu+1]-q1[mu])/(qtime[mu+1]-qtime[mu]);                incli = (q1[mu+1]-q1[mu])/(qtime[mu+1]-qtime[mu]);
1139                      orbitalinfo->q1 =  incli*atime+q1[mu+1]-incli*qtime[mu+1];                orbitalinfo->q1 =  incli*atime+q1[mu+1]-incli*qtime[mu+1];
1140                    }                }
1141                  }                }
1142                  if(atime<=q2sine[mt].finishPoint && atime>=q2sine[mt].startPoint){                if(atime<=q2sine[mt].finishPoint && atime>=q2sine[mt].startPoint){
1143                    if(!q2sine[mt].NeedFit)orbitalinfo->q2=q0sine[mt].A*sin(q2sine[mt].b*atime+q2sine[mt].c);else{                if(!q2sine[mt].NeedFit)orbitalinfo->q2=q0sine[mt].A*sin(q2sine[mt].b*atime+q2sine[mt].c);else{
1144                      incli = (q2[mu+1]-q2[mu])/(qtime[mu+1]-qtime[mu]);                incli = (q2[mu+1]-q2[mu])/(qtime[mu+1]-qtime[mu]);
1145                      orbitalinfo->q2 =  incli*atime+q2[mu+1]-incli*qtime[mu+1];                orbitalinfo->q2 =  incli*atime+q2[mu+1]-incli*qtime[mu+1];
1146                    }                }
1147                  }                }
1148                  if(atime<=q3sine[mt].finishPoint && atime>=q3sine[mt].startPoint){                if(atime<=q3sine[mt].finishPoint && atime>=q3sine[mt].startPoint){
1149                    if(!q3sine[mt].NeedFit)orbitalinfo->q3=q0sine[mt].A*sin(q3sine[mt].b*atime+q3sine[mt].c);else{                if(!q3sine[mt].NeedFit)orbitalinfo->q3=q0sine[mt].A*sin(q3sine[mt].b*atime+q3sine[mt].c);else{
1150                      incli = (q3[mu+1]-q3[mu])/(qtime[mu+1]-qtime[mu]);                incli = (q3[mu+1]-q3[mu])/(qtime[mu+1]-qtime[mu]);
1151                      orbitalinfo->q3 =  incli*atime+q3[mu+1]-incli*qtime[mu+1];                orbitalinfo->q3 =  incli*atime+q3[mu+1]-incli*qtime[mu+1];
1152                    }                }
1153                  }                }
1154                  if(atime<=Yawsine[mt].finishPoint && atime>=Yawsine[mt].startPoint){                if(atime<=Yawsine[mt].finishPoint && atime>=Yawsine[mt].startPoint){
1155                    if(!Yawsine[mt].NeedFit)orbitalinfo->phi=Yawsine[mt].A*sin(Yawsine[mt].b*atime+Yawsine[mt].c);else{                if(!Yawsine[mt].NeedFit)orbitalinfo->phi=Yawsine[mt].A*sin(Yawsine[mt].b*atime+Yawsine[mt].c);else{
1156                      incli = (qYaw[mu+1]-qYaw[mu])/(qtime[mu+1]-qtime[mu]);                incli = (qYaw[mu+1]-qYaw[mu])/(qtime[mu+1]-qtime[mu]);
1157                      orbitalinfo->phi =  incli*atime+qYaw[mu+1]-incli*qtime[mu+1];                orbitalinfo->phi =  incli*atime+qYaw[mu+1]-incli*qtime[mu+1];
1158                    }                }
1159                  }                }
1160                }                }
1161              }*/                }*/
1162              //q0testing->Fill(atime,orbitalinfo->q0,100);                //q0testing->Fill(atime,orbitalinfo->q0,100);
1163              //q1testing->Fill(atime,orbitalinfo->q1,100);                //q1testing->Fill(atime,orbitalinfo->q1,100);
1164              //Pitchtesting->Fill(atime,orbitalinfo->etha);                //Pitchtesting->Fill(atime,orbitalinfo->etha);
1165              //q2testing->Fill(atime,orbitalinfo->q2);                //q2testing->Fill(atime,orbitalinfo->q2);
1166              //q3testing->Fill(atime,orbitalinfo->q3);                //q3testing->Fill(atime,orbitalinfo->q3);
1167              break;                if ( debug ) printf(" grfuffi4 %i \n",mu);
1168            }                break;
1169          }              }
1170        }            }
1171            }
1172        }        }
1173          if ( debug ) printf(" grfuffi5  \n");
1174        //        //
1175        // ops no inclination information        // ops no inclination information
1176        //        //
1177          
1178        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 ){
1179          orbitalinfo->mode = 10;          orbitalinfo->mode = 10;
1180          orbitalinfo->q0 = -1000.;          orbitalinfo->q0 = -1000.;
# Line 1173  int OrbitalInfoCore(UInt_t run, TFile *f Line 1184  int OrbitalInfoCore(UInt_t run, TFile *f
1184          orbitalinfo->etha = -1000.;          orbitalinfo->etha = -1000.;
1185          orbitalinfo->phi = -1000.;          orbitalinfo->phi = -1000.;
1186          orbitalinfo->theta = -1000.;          orbitalinfo->theta = -1000.;
1187        };          if ( debug ) printf(" grfuffi6 \n");
1188          }
1189        //        //
1190          if ( debug ) printf(" filling \n");
1191        // #########################################################################################################################          // #########################################################################################################################  
1192        //        //
1193        // fill orbital positions        // fill orbital positions
# Line 1185  int OrbitalInfoCore(UInt_t run, TFile *f Line 1198  int OrbitalInfoCore(UInt_t run, TFile *f
1198        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);
1199        lat = rad2deg(coo.m_Lat);        lat = rad2deg(coo.m_Lat);
1200        alt = coo.m_Alt;        alt = coo.m_Alt;
1201          if ( debug ) printf(" coord done \n");
1202        //        //
1203        if( lon<180 && lon>-180 && lat<90 && lat>-90 && alt>0 ){          if( lon<180 && lon>-180 && lat<90 && lat>-90 && alt>0 ){  
1204          //                //      
# Line 1194  int OrbitalInfoCore(UInt_t run, TFile *f Line 1208  int OrbitalInfoCore(UInt_t run, TFile *f
1208          //          //
1209          // compute mag field components and L shell.          // compute mag field components and L shell.
1210          //          //
1211            if ( debug ) printf(" call igrf feldg \n");
1212          feldg_(&lat, &lon, &alt, &bnorth, &beast, &bdown, &babs);          feldg_(&lat, &lon, &alt, &bnorth, &beast, &bdown, &babs);
1213            if ( debug ) printf(" call igrf shellg \n");
1214          shellg_(&lat, &lon, &alt, &dimo, &xl, &icode, &bab1);          shellg_(&lat, &lon, &alt, &dimo, &xl, &icode, &bab1);
1215            if ( debug ) printf(" call igrf findb \n");
1216          findb0_(&stps, &bdel, &value, &bequ, &rr0);          findb0_(&stps, &bdel, &value, &bequ, &rr0);
1217          //          //
1218            if ( debug ) printf(" done igrf \n");
1219          orbitalinfo->Bnorth = bnorth;          orbitalinfo->Bnorth = bnorth;
1220          orbitalinfo->Beast = beast;          orbitalinfo->Beast = beast;
1221          orbitalinfo->Bdown = bdown;          orbitalinfo->Bdown = bdown;
# Line 1208  int OrbitalInfoCore(UInt_t run, TFile *f Line 1226  int OrbitalInfoCore(UInt_t run, TFile *f
1226          // Set Stormer vertical cutoff using L shell.          // Set Stormer vertical cutoff using L shell.
1227          orbitalinfo->cutoffsvl = 14.295 / (xl*xl); //          orbitalinfo->cutoffsvl = 14.295 / (xl*xl); //
1228          /*          /*
1229  ---------- Forwarded message ----------            ---------- Forwarded message ----------
1230  Date: Wed, 09 May 2012 12:16:47 +0200            Date: Wed, 09 May 2012 12:16:47 +0200
1231  From: Alessandro Bruno <alessandro.bruno@ba.infn.it>            From: Alessandro Bruno <alessandro.bruno@ba.infn.it>
1232  To: Mirko Boezio <mirko.boezio@ts.infn.it>            To: Mirko Boezio <mirko.boezio@ts.infn.it>
1233  Cc: Francesco S. Cafagna <Francesco.Cafagna@ba.infn.it>            Cc: Francesco S. Cafagna <Francesco.Cafagna@ba.infn.it>
1234  Subject: Störmer vertical cutoff            Subject: Störmer vertical cutoff
1235    
1236  Ciao Mirko,            Ciao Mirko,
1237  volevo segnalarti che il valore dello Störmer vertical cutoff nel Level2 č            volevo segnalarti che il valore dello Störmer vertical cutoff nel Level2 č
1238  sovrastimato di circa il 4%.            sovrastimato di circa il 4%.
1239  Dopo un'approfondita analisi con l'IGRF-05 abbiamo ricavano un valore pari            Dopo un'approfondita analisi con l'IGRF-05 abbiamo ricavano un valore pari
1240  a: 14.295 / L^2 anzichč 14.9 / L^2, valore obsoleto in quanto riferito agli            a: 14.295 / L^2 anzichč 14.9 / L^2, valore obsoleto in quanto riferito agli
1241  anni '50.            anni '50.
1242  */          */
1243          //14.9/(xl*xl);          //14.9/(xl*xl);
1244          orbitalinfo->igrf_icode = icode;          orbitalinfo->igrf_icode = icode;
1245          //          //
1246        };              }      
1247        //        //
1248        if ( debug ) printf(" pitch angle \n");        if ( debug ) printf(" pitch angle \n");
1249        //        //
# Line 1234  anni '50. Line 1252  anni '50.
1252        //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 ){
1253        if( orbitalinfo->TimeGap>0 && orbitalinfo->TimeGap<2000000){        if( orbitalinfo->TimeGap>0 && orbitalinfo->TimeGap<2000000){
1254          //          //
1255            if ( debug ) printf(" timegap %f \n",orbitalinfo->TimeGap);
1256          Float_t Bx = -orbitalinfo->Bdown;          Float_t Bx = -orbitalinfo->Bdown;
1257          Float_t By = orbitalinfo->Beast;          Float_t By = orbitalinfo->Beast;
1258          Float_t Bz = orbitalinfo->Bnorth;          Float_t Bz = orbitalinfo->Bnorth;
# Line 1246  anni '50. Line 1265  anni '50.
1265          orbitalinfo->Iij.ResizeTo(Iij);          orbitalinfo->Iij.ResizeTo(Iij);
1266          orbitalinfo->Iij = Iij;          orbitalinfo->Iij = Iij;
1267          //          //
1268          A1 = Iij(0,2);          //      A1 = Iij(0,2);
1269          A2 = Iij(1,2);          //      A2 = Iij(1,2);
1270          A3 = Iij(2,2);          //      A3 = Iij(2,2);
1271          //          //
1272          //      orbitalinfo->pamzenitangle = (Float_t)PO->GetPitchAngle(1,0,0,A1,A2,A3);                        // Angle between zenit and Pamela's main axiz          //      orbitalinfo->pamzenitangle = (Float_t)PO->GetPitchAngle(1,0,0,A1,A2,A3);                        // Angle between zenit and Pamela's main axiz
1273          //      orbitalinfo->pamBangle = (Float_t)PO->GetPitchAngle(A1,A2,A3,Bx,By,Bz);                 // Angle between Pamela's main axiz and B          //      orbitalinfo->pamBangle = (Float_t)PO->GetPitchAngle(A1,A2,A3,Bx,By,Bz);                 // Angle between Pamela's main axiz and B
1274          //          //
1275            if ( debug ) printf(" matrixes done  \n");
1276          if ( !standalone && tof->ntrk() > 0 ){          if ( !standalone && tof->ntrk() > 0 ){
1277              if ( debug ) printf(" !standalone \n");
1278            //            //
1279            Int_t nn = 0;            Int_t nn = 0;
1280            for(Int_t nt=0; nt < tof->ntrk(); nt++){              for(Int_t nt=0; nt < tof->ntrk(); nt++){  
# Line 1307  anni '50. Line 1328  anni '50.
1328              //              //
1329            };            };
1330          } else {          } else {
1331            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);
1332          };          }
1333          //          //
1334        } else {        } else {
1335          if ( !standalone && tof->ntrk() > 0 ){          if ( !standalone && tof->ntrk() > 0 ){
# Line 1370  anni '50. Line 1391  anni '50.
1391      if ( verbose ) printf(" Clear before new run \n");      if ( verbose ) printf(" Clear before new run \n");
1392      delete dbtime;      delete dbtime;
1393    
1394      mcmdrc->Clear();      if ( mcmdrc ) mcmdrc->Clear();
1395      mcmdrc = 0;      mcmdrc = 0;
1396            
1397      if ( verbose ) printf(" Clear before new run1 \n");      if ( verbose ) printf(" Clear before new run1 \n");
# Line 1432  anni '50. Line 1453  anni '50.
1453    //    //
1454    if ( file ){    if ( file ){
1455      file->cd();      file->cd();
1456      OrbitalInfotr->Write("OrbitalInfo", TObject::kOverwrite);      if ( OrbitalInfotr ) OrbitalInfotr->Write("OrbitalInfo", TObject::kOverwrite); // 10 RED bug fixed
1457    };    };
1458    //    //
1459    if (verbose) printf("\n Exiting...\n");    if (verbose) printf("\n Exiting...\n");
# Line 1516  UInt_t holeq(Double_t lower,Double_t upp Line 1537  UInt_t holeq(Double_t lower,Double_t upp
1537    Bool_t R10l = false;     // Sign of R10 mode in lower quaternions array    Bool_t R10l = false;     // Sign of R10 mode in lower quaternions array
1538    Bool_t R10u = false;     // Sign of R10 mode in upper quaternions array    Bool_t R10u = false;     // Sign of R10 mode in upper quaternions array
1539    Bool_t insm = false;     // Sign that we inside quaternions array    Bool_t insm = false;     // Sign that we inside quaternions array
1540    Bool_t mxtml = false;    // Sign of mixt mode in lower quaternions array    //  Bool_t mxtml = false;    // Sign of mixt mode in lower quaternions array
1541    Bool_t mxtmu = false;    // Sign of mixt mode in upper quaternions array    //  Bool_t mxtmu = false;    // Sign of mixt mode in upper quaternions array
1542    Bool_t 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
1543    UInt_t NCQl = 6;       // Number of correct quaternions in lower array    UInt_t NCQl = 6;       // Number of correct quaternions in lower array
1544    UInt_t NCQu = 6;       // Number of correct quaternions in upper array    //  UInt_t NCQu = 6;       // Number of correct quaternions in upper array
1545    if (f>0){    if (f>0){
1546      insm = true;      insm = true;
1547      if(Qupper->time[f]-Qupper->time[f-1]==30) R10u = false;      if(Qupper->time[f]-Qupper->time[f-1]==30) R10u = false;
# Line 1532  UInt_t holeq(Double_t lower,Double_t upp Line 1553  UInt_t holeq(Double_t lower,Double_t upp
1553      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;
1554      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;
1555      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)){
1556        mxtml = true;        //      mxtml = true;
1557        for(UInt_t i = 1; i < 6; i++){        for(UInt_t i = 1; i < 6; i++){
1558          if(Qlower->time[i]-Qlower->time[0]==30*i) NCQl=i;          if(Qlower->time[i]-Qlower->time[0]==30*i) NCQl=i;
1559        }        }
1560      }      }
1561      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)){
1562        mxtmu = true;        //      mxtmu = true;
1563        for(UInt_t i = 1; i < 6; i++){        //      for(UInt_t i = 1; i < 6; i++){
1564          if(Qupper->time[i]-Qupper->time[0]==30*i) NCQu=i;        //        if(Qupper->time[i]-Qupper->time[0]==30*i) NCQu=i;
1565        }        //      }
1566      }      //    }
1567    }    }
1568        
1569    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;

Legend:
Removed from v.1.60  
changed lines
  Added in v.1.68

  ViewVC Help
Powered by ViewVC 1.1.23