/[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.1 by mocchiut, Fri May 19 13:15:57 2006 UTC revision 1.59 by mocchiut, Sat May 19 06:25:27 2012 UTC
# Line 1  Line 1 
 //  
1  // C/C++ headers  // C/C++ headers
2  //  //
3  #include <fstream>  #include <fstream>
# Line 9  Line 8 
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>
18  #include <TList.h>  #include <TList.h>
19  #include <TArrayL.h>  #include <TArrayI.h>
20  #include <TSystem.h>  #include <TSystem.h>
21  #include <TSystemDirectory.h>  #include <TSystemDirectory.h>
22  #include <TString.h>  #include <TString.h>
# Line 23  Line 26 
26  #include <TSQLRow.h>  #include <TSQLRow.h>
27  #include <TSQLResult.h>  #include <TSQLResult.h>
28  //  //
29    // RunInfo header
30    //
31    #include <RunInfo.h>
32    #include <GLTables.h>
33    //
34  // YODA headers  // YODA headers
35  //  //
36  #include <PamelaRun.h>  #include <PamelaRun.h>
 #include <RegistryEvent.h>  
37  #include <PscuHeader.h>  #include <PscuHeader.h>
38  #include <PscuEvent.h>  #include <PscuEvent.h>
39  #include <EventHeader.h>  #include <EventHeader.h>
40  #include <RegistryEvent.h>  #include <mcmd/McmdEvent.h>
41  //  #include <mcmd/McmdRecord.h>
 // RunInfo header  
 //  
 #include <RunInfo.h>  
 #include <GLTables.h>  
42  //  //
43  // This program headers  // This program headers
44  //  //
45  #include <OrbitalInfo.h>  #include <OrbitalInfo.h>
 #include <OrbitalInfoCore.h>  
46  #include <OrbitalInfoVerl2.h>  #include <OrbitalInfoVerl2.h>
47    #include <OrbitalInfoCore.h>
48    #include <InclinationInfo.h>
49    
50    
51  using namespace std;  using namespace std;
52    
# Line 49  using namespace std; Line 54  using namespace std;
54  // CORE ROUTINE  // CORE ROUTINE
55  //  //
56  //  //
57    int OrbitalInfoCore(UInt_t run, TFile *file, GL_TABLES *glt, Int_t OrbitalInfoargc, char *OrbitalInfoargv[]){
58  int OrbitalInfoCore(ULong64_t run, TFile *file, TSQLServer *dbc, Int_t OrbitalInfoargc, char *OrbitalInfoargv[]){    //
59    Int_t i = 0;    Int_t i = 0;
60      TString host = glt->CGetHost();
61      TString user = glt->CGetUser();
62      TString psw = glt->CGetPsw();
63      TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
64      //
65      stringstream myquery;
66      myquery.str("");
67      myquery << "SET time_zone='+0:00'";
68      delete dbc->Query(myquery.str().c_str());
69    //    //
70    TString processFolder = "OrbitalInfoFolder";    TString processFolder = Form("OrbitalInfoFolder_%u",run);
71    //    //
72    // Set these to true to have a very verbose output.    // Set these to true to have a very verbose output.
73    //    //
74    Bool_t debug = false;    Bool_t debug = false;
75    //    //
76    Bool_t verbose = false;    Bool_t verbose = false;
77      //
78      Bool_t standalone = false;
79      //
80    if ( OrbitalInfoargc > 0 ){    if ( OrbitalInfoargc > 0 ){
81      i = 0;      i = 0;
82      while ( i < OrbitalInfoargc ){      while ( i < OrbitalInfoargc ){
# Line 73  int OrbitalInfoCore(ULong64_t run, TFile Line 89  int OrbitalInfoCore(ULong64_t run, TFile
89        };        };
90        if ( (!strcmp(OrbitalInfoargv[i],"--debug")) || (!strcmp(OrbitalInfoargv[i],"-g")) ) {        if ( (!strcmp(OrbitalInfoargv[i],"--debug")) || (!strcmp(OrbitalInfoargv[i],"-g")) ) {
91          verbose = true;          verbose = true;
92            debug = true;
93        };        };
94        if ( (!strcmp(OrbitalInfoargv[i],"--verbose")) || (!strcmp(OrbitalInfoargv[i],"-v")) ) {        if ( (!strcmp(OrbitalInfoargv[i],"--verbose")) || (!strcmp(OrbitalInfoargv[i],"-v")) ) {
95          verbose = true;          verbose = true;
96        };        };
97          if ( (!strcmp(OrbitalInfoargv[i],"--standalone")) ) {
98            standalone = true;
99          };
100          if ( (!strcmp(OrbitalInfoargv[i],"--calculate-pitch")) ) {
101            standalone = false;
102          };
103        i++;        i++;
104      };      };
105    };    };
# Line 84  int OrbitalInfoCore(ULong64_t run, TFile Line 107  int OrbitalInfoCore(ULong64_t run, TFile
107    const char* outDir = gSystem->DirName(gSystem->DirName(file->GetPath()));    const char* outDir = gSystem->DirName(gSystem->DirName(file->GetPath()));
108    //    //
109    TTree *OrbitalInfotr = 0;    TTree *OrbitalInfotr = 0;
110    Long64_t nevents = 0LL;    UInt_t nevents = 0;
111      UInt_t neventsm = 0;
112    //    //
113    // variables needed to reprocess data    // variables needed to reprocess data
114    //    //
115      Long64_t maxsize = 10000000000LL;  
116      TTree::SetMaxTreeSize(maxsize);
117      //
118    TString OrbitalInfoversion;    TString OrbitalInfoversion;
119    ItoRunInfo *runinfo = 0;    ItoRunInfo *runinfo = 0;
120    TArrayL *runlist = 0;    TArrayI *runlist = 0;
121    TTree *OrbitalInfotrclone = 0;    TTree *OrbitalInfotrclone = 0;
122    Bool_t reproc = false;    Bool_t reproc = false;
123    Bool_t reprocall = false;    Bool_t reprocall = false;
# Line 99  int OrbitalInfoCore(ULong64_t run, TFile Line 126  int OrbitalInfoCore(ULong64_t run, TFile
126    UInt_t numbofrun = 0;    UInt_t numbofrun = 0;
127    stringstream ftmpname;    stringstream ftmpname;
128    TString fname;    TString fname;
129    Long64_t totfileentries = 0ULL;    UInt_t totfileentries = 0;
130    Long64_t idRun = 0LL;    UInt_t idRun = 0;
131      UInt_t anni5 = 60 * 60 * 24 * 365 * 5 ;//1576800
132      //
133      // My variables. Vitaly.
134      //
135    //  UInt_t oi = 0;
136      Int_t tmpSize = 0;
137    //    //
138    // variables needed to handle error signals    // variables needed to handle error signals
139    //    //
# Line 111  int OrbitalInfoCore(ULong64_t run, TFile Line 144  int OrbitalInfoCore(ULong64_t run, TFile
144    //    //
145    OrbitalInfo *orbitalinfo = new OrbitalInfo();    OrbitalInfo *orbitalinfo = new OrbitalInfo();
146    OrbitalInfo *orbitalinfoclone = new OrbitalInfo();    OrbitalInfo *orbitalinfoclone = new OrbitalInfo();
147    
148    //    //
149    // define variables for opening and reading level0 file    // define variables for opening and reading level0 file
150    //    //
151    TFile *l0File = 0;    TFile *l0File = 0;
152    TTree *l0tr = 0;    TTree *l0tr = 0;
153    TBranch *l0registry = 0;    //  TTree *l0trm = 0;
154    pamela::RegistryEvent *l0reg=0;    TChain *ch = 0;
155      // EM: open also header branch
156      TBranch *l0head = 0;
157      pamela::EventHeader *eh = 0;
158      pamela::PscuHeader *ph = 0;
159      pamela::McmdEvent *mcmdev = 0;
160      pamela::McmdRecord *mcmdrc = 0;
161      // end EM
162      
163      //  pamela::RunHeaderEvent *reh = new pamela::RunHeaderEvent;
164      //  pamela::EventHeader    *eH  = new pamela::EventHeader;
165      
166    //    //
167    // Define other basic variables    // Define other basic variables
168    //    //
# Line 126  int OrbitalInfoCore(ULong64_t run, TFile Line 171  int OrbitalInfoCore(ULong64_t run, TFile
171    stringstream file3;    stringstream file3;
172    stringstream qy;    stringstream qy;
173    Int_t totevent = 0;    Int_t totevent = 0;
174    ULong64_t atime = 0ULL;    UInt_t atime = 0;
175    Int_t ei = 0;    UInt_t re = 0;
176    Int_t re = 0;    UInt_t ik = 0;
177    
178      // Position
179      Float_t lon, lat, alt;
180    
181      //
182      // IGRF stuff
183      //
184      Float_t dimo = 0.0; // dipole moment (computed from dat files)
185      Float_t bnorth, beast, bdown, babs;
186      Float_t xl; // L value
187      Float_t icode; // code value for L accuracy (see fortran code)
188      Float_t bab1; // What's  the difference with babs?
189      Float_t stps = 0.005; // step size for field line tracing
190      Float_t bdel = 0.01; // required accuracy
191      Float_t bequ;  // equatorial b value (also called b_0)
192      Bool_t value = 0; // false if bequ is not the minimum b value
193      Float_t rr0; // equatorial radius normalized to earth radius
194    
195    //    //
196    // Working filename    // Working filename
197    //    //
# Line 143  int OrbitalInfoCore(ULong64_t run, TFile Line 206  int OrbitalInfoCore(ULong64_t run, TFile
206    TTree *tempOrbitalInfo = 0;    TTree *tempOrbitalInfo = 0;
207    stringstream tempname;    stringstream tempname;
208    stringstream OrbitalInfofolder;    stringstream OrbitalInfofolder;
209      Bool_t myfold = false;
210    tempname.str("");    tempname.str("");
211    tempname << outDir;    tempname << outDir;
212    tempname << "/" << processFolder.Data();    tempname << "/" << processFolder.Data();
213    OrbitalInfofolder.str("");    OrbitalInfofolder.str("");
214    OrbitalInfofolder << tempname.str().c_str();    OrbitalInfofolder << tempname.str().c_str();
   gSystem->MakeDirectory(OrbitalInfofolder.str().c_str());  
215    tempname << "/OrbitalInfotree_run";    tempname << "/OrbitalInfotree_run";
216    tempname << run << ".root";      tempname << run << ".root";  
217      UInt_t totnorun = 0;
218    //    //
219    // DB classes    // DB classes
220    //    //
221    GL_ROOT *glroot = new GL_ROOT();    GL_ROOT *glroot = new GL_ROOT();
222      GL_TIMESYNC *dbtime = 0;
223      GL_TLE *gltle = new GL_TLE();
224      //
225      //Quaternions classes
226      //
227      Quaternions *L_QQ_Q_l_lower = 0;
228      InclinationInfo *RYPang_lower = 0;
229      Quaternions *L_QQ_Q_l_upper = 0;
230      InclinationInfo *RYPang_upper = 0;
231      
232      cEci eCi;
233      
234      // Initialize fortran routines!!!
235      Int_t ltp1 = 0;
236      Int_t ltp2 = 0;
237      Int_t ltp3 = 0;
238      //  Int_t uno = 1;
239      //  const char *niente = " ";
240      GL_PARAM *glparam = new GL_PARAM();
241      GL_PARAM *glparam2 = new GL_PARAM();
242      GL_PARAM *glparam3 = new GL_PARAM();
243    
244      //
245      // Orientation variables. Vitaly
246      //
247      UInt_t evfrom = 0;
248      UInt_t jumped = 0;
249      Int_t itr = -1;    
250      Double_t A1;
251      Double_t A2;
252      Double_t A3;
253      Double_t Px = 0;
254      Double_t Py = 0;      
255      Double_t Pz = 0;  
256      TTree *ttof = 0;
257      ToFLevel2 *tof = new ToFLevel2();
258      OrientationInfo *PO = new OrientationInfo();
259      Int_t nz = 6;
260      Float_t zin[6];
261      Int_t nevtofl2 = 0;
262      if ( verbose ) cout<<"Reading quaternions external file"<<endl;
263      cout.setf(ios::fixed,ios::floatfield);  
264      /******Reading recovered quaternions...*********/
265      vector<Double_t> recqtime;
266      vector<Float_t> recq0;
267      vector<Float_t> recq1;
268      vector<Float_t> recq2;
269      vector<Float_t> recq3;
270      Float_t Norm = 1;
271      Int_t parerror=glparam->Query_GL_PARAM(1,303,dbc); // parameters stored in DB in GL_PRAM table  
272      ifstream in((glparam->PATH+glparam->NAME).Data(),ios::in);
273      if ( parerror<0 ) {
274        code = parerror;
275        goto closeandexit;
276      }
277      while(!in.eof()){
278        recqtime.resize(recqtime.size()+1);
279        Int_t sizee = recqtime.size();
280        recq0.resize(sizee);
281        recq1.resize(sizee);
282        recq2.resize(sizee);
283        recq3.resize(sizee);
284        in>>recqtime[sizee-1];
285        in>>recq0[sizee-1];
286        in>>recq1[sizee-1];
287        in>>recq2[sizee-1];
288        in>>recq3[sizee-1];
289        in>>Norm;
290      }
291      if ( verbose ) cout<<"We have read recovered data"<<endl;
292    
293    
294      // IGRF stuff moved inside run loop!  
295    
296      for (Int_t ip=0;ip<nz;ip++){
297        zin[ip] = tof->GetZTOF(tof->GetToFPlaneID(ip));
298      };
299      //
300      if ( !standalone ){
301        //
302        // Does it contain the Tracker tree?
303        //
304        ttof = (TTree*)file->Get("ToF");
305        if ( !ttof ) {
306          if ( verbose ) printf(" OrbitalInfo - ERROR: no tof tree\n");
307          code = -900;
308          goto closeandexit;
309        };
310        ttof->SetBranchAddress("ToFLevel2",&tof);  
311        nevtofl2 = ttof->GetEntries();
312      };
313    //    //
314    // Let's start!    // Let's start!
315    //    //
# Line 162  int OrbitalInfoCore(ULong64_t run, TFile Line 317  int OrbitalInfoCore(ULong64_t run, TFile
317    // if run != 0 we must process only that run but first we have to check if the tree MyDetector2 already exist in the file    // if run != 0 we must process only that run but first we have to check if the tree MyDetector2 already exist in the file
318    // if it exists we are reprocessing data and we must delete that entries, if not we must create it.    // if it exists we are reprocessing data and we must delete that entries, if not we must create it.
319    //    //
320    if ( run == 0ULL )  reproc = true;    if ( run == 0 )  reproc = true;
321    //    //
322    //    //
323    // Output file is "outputfile"    // Output file is "outputfile"
# Line 209  int OrbitalInfoCore(ULong64_t run, TFile Line 364  int OrbitalInfoCore(ULong64_t run, TFile
364    // number of run to be processed    // number of run to be processed
365    //    //
366    numbofrun = runinfo->GetNoRun();    numbofrun = runinfo->GetNoRun();
367      totnorun = runinfo->GetRunEntries();
368    //    //
369    // 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
370    //    //
# Line 219  int OrbitalInfoCore(ULong64_t run, TFile Line 375  int OrbitalInfoCore(ULong64_t run, TFile
375      // tree does not exist, we are not reprocessing      // tree does not exist, we are not reprocessing
376      //      //
377      reproc = false;      reproc = false;
378      if ( run == 0ULL ){      if ( run == 0 ){
379        if (verbose) printf(" OrbitalInfo - WARNING: you are reprocessing data but OrbitalInfo tree does not exist!\n");        if (verbose) printf(" OrbitalInfo - WARNING: you are reprocessing data but OrbitalInfo tree does not exist!\n");
380      }      }
381      if ( runinfo->IsReprocessing() && run != 0ULL ) {      if ( runinfo->IsReprocessing() && run != 0 ) {
382        if (verbose) printf(" OrbitalInfo - WARNING: it seems you are not reprocessing data but OrbitalInfo\n versioning information already exists in RunInfo.\n");        if (verbose) printf(" OrbitalInfo - WARNING: it seems you are not reprocessing data but OrbitalInfo\n versioning information already exists in RunInfo.\n");
383      }      }
384    } else {    } else {
385      //      //
386      // tree exists, we are reprocessing data. Are we reprocessing a single run or all the file?      // tree exists, we are reprocessing data. Are we reprocessing a single run or all the file?
387      //      //
388        OrbitalInfotrclone->SetAutoSave(900000000000000LL);
389      reproc = true;      reproc = true;
390      //      //
391      //      //
392      if (verbose) printf("\n Preparing the pre-processing...\n");      if (verbose) printf("\n Preparing the pre-processing...\n");
393      //      //
394      if ( run == 0ULL ){      if ( run == 0 || totnorun == 1 ){
395        //        //
396        // we are reprocessing all the file        // we are reprocessing all the file
397        // if we are reprocessing everything we don't need to copy any old event and we can just work with the new tree and delete the old one immediately        // if we are reprocessing everything we don't need to copy any old event and we can just work with the new tree and delete the old one immediately
398        //        //
399        reprocall = true;        reprocall = true;
400        //        //
401        if (verbose) printf("\n OrbitalInfo - WARNING: Reprocessing all runs\n");        if (verbose) printf("\n OrbitalInfo - WARNING: Reprocessing all runs\n Deleting old tree...\n");
402        //        //
403      } else {      } else {
404        //        //
# Line 249  int OrbitalInfoCore(ULong64_t run, TFile Line 406  int OrbitalInfoCore(ULong64_t run, TFile
406        //        //
407        reprocall = false;        reprocall = false;
408        //        //
409        if (verbose) printf("\n OrbitalInfo - WARNING: Reprocessing run number %llu \n",run);        if (verbose) printf("\n OrbitalInfo - WARNING: Reprocessing run number %u \n",run);
410        //        //
411        // copying old tree to a new file        // copying old tree to a new file
412        //        //
413          gSystem->MakeDirectory(OrbitalInfofolder.str().c_str());
414          myfold = true;
415        tempfile = new TFile(tempname.str().c_str(),"RECREATE");        tempfile = new TFile(tempname.str().c_str(),"RECREATE");
416        tempOrbitalInfo = OrbitalInfotrclone->CloneTree(-1,"fast");        tempOrbitalInfo = OrbitalInfotrclone->CloneTree(-1,"fast");
417        tempOrbitalInfo->SetName("OrbitalInfo-old");        tempOrbitalInfo->SetName("OrbitalInfo-old");
418        tempfile->Write();        tempfile->Write();
419          tempOrbitalInfo->Delete();
420        tempfile->Close();          tempfile->Close();  
421      }      }
422      //      //
423      // Delete the old tree from old file and memory      // Delete the old tree from old file and memory
424      //      //
425        OrbitalInfotrclone->Clear();
426      OrbitalInfotrclone->Delete("all");      OrbitalInfotrclone->Delete("all");
427      //      //
428      if (verbose) printf(" ...done!\n");      if (verbose) printf(" ...done!\n");
# Line 272  int OrbitalInfoCore(ULong64_t run, TFile Line 433  int OrbitalInfoCore(ULong64_t run, TFile
433    //    //
434    file->cd();    file->cd();
435    OrbitalInfotr = new TTree("OrbitalInfo-new","PAMELA OrbitalInfo data");    OrbitalInfotr = new TTree("OrbitalInfo-new","PAMELA OrbitalInfo data");
436      OrbitalInfotr->SetAutoSave(900000000000000LL);
437      orbitalinfo->Set();//ELENA **TEMPORANEO?**
438    OrbitalInfotr->Branch("OrbitalInfo","OrbitalInfo",&orbitalinfo);    OrbitalInfotr->Branch("OrbitalInfo","OrbitalInfo",&orbitalinfo);
439    //    //
440    if ( reproc && !reprocall ){    if ( reproc && !reprocall ){
# Line 280  int OrbitalInfoCore(ULong64_t run, TFile Line 443  int OrbitalInfoCore(ULong64_t run, TFile
443      //      //
444      tempfile = new TFile(tempname.str().c_str(),"READ");      tempfile = new TFile(tempname.str().c_str(),"READ");
445      OrbitalInfotrclone = (TTree*)tempfile->Get("OrbitalInfo-old");      OrbitalInfotrclone = (TTree*)tempfile->Get("OrbitalInfo-old");
446        OrbitalInfotrclone->SetAutoSave(900000000000000LL);
447      OrbitalInfotrclone->SetBranchAddress("OrbitalInfo",&orbitalinfoclone);      OrbitalInfotrclone->SetBranchAddress("OrbitalInfo",&orbitalinfoclone);
448      //            //      
449      if ( nobefrun > 0 ){      if ( nobefrun > 0 ){
450        if (verbose){        if (verbose){
451        printf("\n Pre-processing: copying events from the old tree before the processed run\n");            printf("\n Pre-processing: copying events from the old tree before the processed run\n");  
452        printf(" Copying %u events in the file which are before the beginning of the run %llu \n",nobefrun,run);          printf(" Copying %u events in the file which are before the beginning of the run %u \n",nobefrun,run);
453        printf(" Start copying at event number 0, end copying at event number %u \n",nobefrun);          printf(" Start copying at event number 0, end copying at event number %u \n",nobefrun);
454        }        }
455        for (UInt_t j = 0; j < nobefrun; j++){        for (UInt_t j = 0; j < nobefrun; j++){
456          //          //
457          OrbitalInfotrclone->GetEntry(j);                    if ( OrbitalInfotrclone->GetEntry(j) <= 0 ) throw -36;    
458          //          //
459          // copy orbitalinfoclone to mydec          // copy orbitalinfoclone to mydec
460          //          //
461          orbitalinfo = new OrbitalInfo();          orbitalinfo->Clear();
462            //
463          memcpy(&orbitalinfo,&orbitalinfoclone,sizeof(orbitalinfoclone));          memcpy(&orbitalinfo,&orbitalinfoclone,sizeof(orbitalinfoclone));
464          //          //
465          // Fill entry in the new tree          // Fill entry in the new tree
# Line 303  int OrbitalInfoCore(ULong64_t run, TFile Line 468  int OrbitalInfoCore(ULong64_t run, TFile
468          //          //
469        };        };
470        if (verbose) printf(" Finished successful copying!\n");        if (verbose) printf(" Finished successful copying!\n");
471      };                };
472    };    };
473    //    //
474      //
475    // 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.
476    //    //
477    runlist = runinfo->GetRunList();    runlist = runinfo->GetRunList();
# Line 313  int OrbitalInfoCore(ULong64_t run, TFile Line 479  int OrbitalInfoCore(ULong64_t run, TFile
479    // Loop over the run to be processed    // Loop over the run to be processed
480    //    //
481    for (UInt_t irun=0; irun < numbofrun; irun++){    for (UInt_t irun=0; irun < numbofrun; irun++){
482    
483        L_QQ_Q_l_lower = new Quaternions();
484        RYPang_lower = new InclinationInfo();
485        L_QQ_Q_l_upper = new Quaternions();
486        RYPang_upper = new InclinationInfo();
487    
488      //      //
489      // retrieve the first run ID to be processed using the RunInfo list      // retrieve the first run ID to be processed using the RunInfo list
490      //      //
491        
492      idRun = runlist->At(irun);      idRun = runlist->At(irun);
493      if (verbose){      if (verbose){
494        printf("\n\n\n ####################################################################### \n");        printf("\n\n\n ####################################################################### \n");
# Line 323  int OrbitalInfoCore(ULong64_t run, TFile Line 496  int OrbitalInfoCore(ULong64_t run, TFile
496        printf(" ####################################################################### \n\n\n");        printf(" ####################################################################### \n\n\n");
497      }      }
498      //      //
499      runinfo->ID_REG_RUN = 0ULL;      runinfo->ID_ROOT_L0 = 0;
500      //      //
501      // store in the runinfo class the GL_RUN variables for our run      // store in the runinfo class the GL_RUN variables for our run
502      //      //
503      sgnl = 0;      sgnl = 0;
504      sgnl = runinfo->GetRunInfo(idRun);      sgnl = runinfo->GetRunInfo(idRun);
505      if ( sgnl ){      if ( sgnl ){
506        //printf("\n OrbitalInfo - ERROR: RunInfo exited with non-zero status\n");        if ( debug ) printf("\n OrbitalInfo - ERROR: RunInfo exited with non-zero status\n");
507        code = sgnl;        code = sgnl;
508        goto closeandexit;        goto closeandexit;
509      } else {      } else {
# Line 339  int OrbitalInfoCore(ULong64_t run, TFile Line 512  int OrbitalInfoCore(ULong64_t run, TFile
512      //      //
513      // now you can access that variables using the RunInfo class this way runinfo->ID_REG_RUN      // now you can access that variables using the RunInfo class this way runinfo->ID_REG_RUN
514      //      //
515      if ( runinfo->ID_REG_RUN == 0 ){      if ( runinfo->ID_ROOT_L0 == 0 ){
516        //printf("\n OrbitalInfo - ERROR: no run with ID_RUN = %i \n\n Exiting... \n\n",(int)idRun);        if ( debug ) printf("\n OrbitalInfo - ERROR: no run with ID_RUN = %u \n\n Exiting... \n\n",idRun);
517        code = -5;        code = -5;
518        goto closeandexit;            goto closeandexit;    
519      };      };
520      //      //
521        // prepare the timesync for the db
522        //
523        dbtime = new GL_TIMESYNC(runinfo->ID_ROOT_L0,"ID",dbc);
524      
525        //
526      // Search in the DB the path and name of the LEVEL0 file to be processed.      // Search in the DB the path and name of the LEVEL0 file to be processed.
527      //      //
528      glroot->Query_GL_ROOT(runinfo->ID_REG_RUN,dbc);      glroot->Query_GL_ROOT(runinfo->ID_ROOT_L0,dbc);
529      //      //
530      ftmpname.str("");      ftmpname.str("");
531      ftmpname << glroot->PATH.Data() << "/";      ftmpname << glroot->PATH.Data() << "/";
532      ftmpname << glroot->NAME.Data();      ftmpname << glroot->NAME.Data();
533      fname = ftmpname.str().c_str();      fname = ftmpname.str().c_str();
534        ftmpname.str("");
535      //      //
536      // print out informations      // print nout informations
537      //      //
538      totevent = runinfo->EV_REG_PHYS_TO - runinfo->EV_REG_PHYS_FROM + 1;      totevent = runinfo->NEVENTS;
539        evfrom = runinfo->EV_FROM;
540        //cout<<"totevents = "<<totevent<<"\n";
541      if (verbose){      if (verbose){
542        printf("\n LEVEL0 data file: %s \n",fname.Data());        printf("\n LEVEL0 data file: %s \n",fname.Data());
543        printf(" RUN HEADER absolute time is:  %llu \n",runinfo->RUNHEADER_TIME);        printf(" RUN HEADER absolute time is:  %u \n",runinfo->RUNHEADER_TIME);
544        printf(" RUN TRAILER absolute time is: %llu \n",runinfo->RUNTRAILER_TIME);        printf(" RUN TRAILER absolute time is: %u \n",runinfo->RUNTRAILER_TIME);
545        printf(" %i events to be processed for run %llu: from %i to %i (reg entries)\n\n",totevent,idRun,runinfo->EV_REG_PHYS_FROM,runinfo->EV_REG_PHYS_TO);        printf(" %i events to be processed for run %u: from %i to %i \n\n",totevent,idRun,runinfo->EV_FROM+1,runinfo->EV_FROM+totevent);
546      }//      }//
547        //
548        //    if ( !totevent ) goto closeandexit;
549      // Open Level0 file      // Open Level0 file
550        if ( l0File ) l0File->Close();
551      l0File = new TFile(fname.Data());      l0File = new TFile(fname.Data());
552      if ( !l0File ) {      if ( !l0File ) {
553        //printf(" OrbitalInfo - ERROR: problems opening Level0 file\n");        if ( debug ) printf(" OrbitalInfo - ERROR: problems opening Level0 file\n");
554        code = -6;        code = -6;
555        goto closeandexit;        goto closeandexit;
556      };      };
557      l0tr = (TTree*)l0File->Get("Physics");      l0tr = (TTree*)l0File->Get("Physics");
558      if ( !l0tr ) {      if ( !l0tr ) {
559        //printf(" OrbitalInfo - ERROR: no Physics tree in Level0 file\n");        if ( debug ) printf(" OrbitalInfo - ERROR: no Physics tree in Level0 file\n");
560        l0File->Close();        l0File->Close();
561        code = -7;        code = -7;
562        goto closeandexit;        goto closeandexit;
563      };      };
564      l0registry = l0tr->GetBranch("Registry");      // EM: open header branch as well
565      if ( !l0registry ) {      l0head = l0tr->GetBranch("Header");
566        //printf(" OrbitalInfo - ERROR: no Registry branch in Level0 tree\n");      if ( !l0head ) {
567          if ( debug ) printf(" OrbitalInfo - ERROR: no Header branch in Level0 tree\n");
568        l0File->Close();        l0File->Close();
569        code = -9;        code = -8;
570        goto closeandexit;            goto closeandexit;    
571      };      };
572        l0tr->SetBranchAddress("Header", &eh);
573        // end EM
574        nevents = l0head->GetEntries();
575      //      //
576      l0tr->SetBranchAddress("Registry", &l0reg);      if ( nevents < 1 && totevent ) {
577      //        if ( debug ) printf(" OrbitalInfo - ERROR: Level0 file is empty\n\n");
     nevents = l0registry->GetEntries();  
     //  
     if ( nevents < 1 ) {  
       //printf(" OrbitalInfo - ERROR: Level0 file is empty\n\n");  
578        l0File->Close();        l0File->Close();
579        code = -11;        code = -11;
580        goto closeandexit;        goto closeandexit;
581      };      };
582      //      //
583      if ( runinfo->EV_REG_PHYS_TO > nevents-1 ) {      if ( runinfo->EV_TO > nevents-1 && totevent ) {
584        //printf(" OrbitalInfo - ERROR: too few entries in the registry tree\n");        if ( debug ) printf(" OrbitalInfo - ERROR: too few entries in the registry tree\n");
585        l0File->Close();        l0File->Close();
586        code = -12;        code = -12;
587        goto closeandexit;        goto closeandexit;
588      };      };
589    
590        //
591        // open IGRF files and do it only once if we are processing a full level2 file
592        //
593        if ( irun == 0 ){
594          if ( l0head->GetEntry(runinfo->EV_FROM) <= 0 ) throw -36;
595          //
596          // absolute time of first event of the run (it should not matter a lot)
597          //
598          ph = eh->GetPscuHeader();
599          atime = dbtime->DBabsTime(ph->GetOrbitalTime());
600          
601          parerror=glparam->Query_GL_PARAM(atime-anni5,301,dbc); // parameters stored in DB in GL_PRAM table  
602          if ( parerror<0 ) {
603            code = parerror;
604            goto closeandexit;
605        };
606          ltp1 = (Int_t)(glparam->PATH+glparam->NAME).Length();
607          if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam->PATH+glparam->NAME).Data());
608          //
609          parerror=glparam2->Query_GL_PARAM(atime,301,dbc); // parameters stored in DB in GL_PRAM table  
610          if ( parerror<0 ) {
611            code = parerror;
612            goto closeandexit;
613          };
614          ltp2 = (Int_t)(glparam2->PATH+glparam->NAME).Length();
615          if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam2->PATH+glparam2->NAME).Data());
616          //
617          parerror=glparam3->Query_GL_PARAM(atime,302,dbc); // parameters stored in DB in GL_PRAM table
618          if ( parerror<0 ) {
619            code = parerror;
620            goto closeandexit;
621          };
622          ltp3 = (Int_t)(glparam3->PATH+glparam2->NAME).Length();
623          if ( verbose ) printf(" Reading Earth's Magnetic Field parameter file: %s \n",(glparam3->PATH+glparam3->NAME).Data());
624          //
625          initize_((char *)(glparam->PATH+glparam->NAME).Data(),&ltp1,(char *)(glparam2->PATH+glparam2->NAME).Data(),&ltp2,(char *)(glparam3->PATH+glparam3->NAME).Data(),&ltp3);
626          //
627        }
628        //
629        // End IGRF stuff//
630        //
631    
632        //
633        //     TTree *tp = (TTree*)l0File->Get("RunHeader");
634        //     tp->SetBranchAddress("Header", &eH);
635        //     tp->SetBranchAddress("RunHeader", &reh);
636        //     tp->GetEntry(0);
637        //     ph = eH->GetPscuHeader();
638        //     ULong_t TimeSync = reh->LAST_TIME_SYNC_INFO;
639        //     ULong_t ObtSync = reh->OBT_TIME_SYNC;    
640        //     if ( debug ) printf(" 1 TimeSync %lu ObtSync %lu DeltaOBT %lu\n",TimeSync,ObtSync,TimeSync-ObtSync);
641        //
642        ULong_t TimeSync = (ULong_t)dbtime->GetTimesync();
643        ULong_t ObtSync = (ULong_t)(dbtime->GetObt0()/1000);
644        ULong_t DeltaOBT = TimeSync - ObtSync;
645    
646        if ( debug ) printf(" 2 TimeSync %lu ObtSync %lu DeltaOBT %lu\n",(ULong_t)(dbtime->GetTimesync()/1000),(ULong_t)dbtime->GetObt0(),TimeSync-ObtSync);
647        //
648        // Read MCMDs from up to 11 files, 5 before and 5 after the present one in order to have some kind of inclination information
649        //
650        ch = new TChain("Mcmd","Mcmd");
651        //
652        // look in the DB to find the closest files to this run
653        //
654        TSQLResult *pResult = 0;
655        TSQLRow *Row = 0;
656        stringstream myquery;
657        UInt_t l0fid[10];
658        Int_t i = 0;
659        memset(l0fid,0,10*sizeof(Int_t));
660        //
661        myquery.str("");
662        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;";
663        //
664        pResult = dbc->Query(myquery.str().c_str());
665        //
666        i = 9;
667        if( pResult ){
668          //
669          Row = pResult->Next();
670          //
671          while ( Row ){
672            //
673            // store infos and exit
674            //
675            l0fid[i] = (UInt_t)atoll(Row->GetField(0));
676            i--;
677            Row = pResult->Next();  
678            //
679          };
680          pResult->Delete();
681        };
682        //
683        myquery.str("");
684        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;";
685        //
686        pResult = dbc->Query(myquery.str().c_str());
687        //
688        i = 0;
689        if( pResult ){
690          //
691          Row = pResult->Next();
692          //
693          while ( Row ){
694            //
695            // store infos and exit
696            //
697            l0fid[i] = (UInt_t)atoll(Row->GetField(0));
698            i++;
699            Row = pResult->Next();  
700            //
701          };
702          pResult->Delete();
703        };
704        //
705        i = 0;
706        UInt_t previd = 0;
707        while ( i < 10 ){
708          if ( l0fid[i] && previd != l0fid[i] ){
709            previd = l0fid[i];
710            myquery.str("");
711            myquery << "select PATH,NAME from GL_ROOT where ID=" << l0fid[i] << " ;";
712            //
713            pResult = dbc->Query(myquery.str().c_str());
714            //
715            if( pResult ){
716              //
717              Row = pResult->Next();
718              //
719              if ( debug ) printf(" Using inclination informations from file: %s \n",(((TString)gSystem->ExpandPathName(Row->GetField(0)))+"/"+(TString)Row->GetField(1)).Data());
720              ch->Add(((TString)gSystem->ExpandPathName(Row->GetField(0)))+"/"+(TString)Row->GetField(1));
721              //
722              pResult->Delete();
723            };
724          };
725          i++;
726        };
727        //
728        //    l0trm = (TTree*)l0File->Get("Mcmd");
729        //    ch->ls();
730        ch->SetBranchAddress("Mcmd",&mcmdev);
731        //    printf(" entries %llu \n", ch->GetEntries());
732        //    l0trm = ch->GetTree();
733        //    neventsm = l0trm->GetEntries();
734        neventsm = ch->GetEntries();
735        if ( debug ) printf(" entries %u \n", neventsm);
736        //    neventsm = 0;
737        //
738        if (neventsm == 0){
739          if ( debug ) printf("InclinationInfo - WARNING: No quaternions in this File");
740          //      l0File->Close();
741          code = 900;
742          //      goto closeandexit;
743        }
744        //
745        
746        //    l0trm->SetBranchAddress("Mcmd", &mcmdev);
747        //    l0trm->SetBranchAddress("Header", &eh);
748        //
749        //
750        //
751    
752    //    UInt_t mctren = 0;    
753    //    UInt_t mcreen = 0;        
754        UInt_t numrec = 0;
755        //
756        Double_t upperqtime = 0;
757        Double_t lowerqtime = 0;
758        
759    //    Double_t incli = 0;
760    //    oi = 0;
761    //    UInt_t ooi = 0;
762        //
763        // init quaternions information from mcmd-packets
764        //
765        Bool_t isf = true;
766    //    Int_t fgh = 0;
767    
768        vector<Float_t> q0;
769        vector<Float_t> q1;
770        vector<Float_t> q2;
771        vector<Float_t> q3;
772        vector<Double_t> qtime;
773        vector<Float_t> qPitch;
774        vector<Float_t> qRoll;
775        vector<Float_t> qYaw;
776        vector<Int_t> qmode;
777    
778        Int_t nt = 0;
779        
780        //init sine-function interpolation
781        
782        //cout<<"Sine coeficient initialisation..."<<endl;
783        vector<Sine> q0sine;
784        vector<Sine> q1sine;
785        vector<Sine> q2sine;
786        vector<Sine> q3sine;
787        vector<Sine> Yawsine;
788    
789        /*TH2F* q0testing = new TH2F();
790          TH2F* q1testing = new TH2F();
791          TH2F* q2testing = new TH2F();
792          TH2F* q3testing = new TH2F();
793          TH2F* Pitchtesting = new TH2F();
794        */
795        UInt_t must = 0;
796    
797      //      //
798      // run over all the events of the run      // run over all the events of the run
799      //      //
800      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");
801      //      //
802      for ( re = runinfo->EV_REG_PHYS_FROM; re <= runinfo->EV_REG_PHYS_TO; re++){      //
803        for ( re = runinfo->EV_FROM; re < (runinfo->EV_FROM+runinfo->NEVENTS); re++){
804        //        //
805        if ( procev%1000 == 0 && procev > 0 && verbose) printf(" %iK \n",procev/1000);            if ( procev%1000 == 0 && procev > 0 && verbose ) printf(" %iK \n",procev/1000);  
806          if ( debug ) printf(" %i \n",procev);      
807        //        //
808        l0registry->GetEntry(re);        if ( l0head->GetEntry(re) <= 0 ) throw -36;
809        //        //
810        // absolute time of this event        // absolute time of this event
811        //        //
812        atime = l0reg->absTime;        ph = eh->GetPscuHeader();
813        //        atime = dbtime->DBabsTime(ph->GetOrbitalTime());
814        // physics events is at entry number ei where        if ( debug ) printf(" %i absolute time \n",procev);      
       //  
       ei = l0reg->event;  
815        //        //
816        // paranoid check        // paranoid check
817        //        //
818        if ( (atime > runinfo->RUNTRAILER_TIME) || (atime < runinfo->RUNHEADER_TIME)  ) {        if ( (atime > (runinfo->RUNTRAILER_TIME+1)) || (atime < (runinfo->RUNHEADER_TIME-1))  ) {
819          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");
820          goto jumpev;          jumped++;
821            //      debug = true;
822            continue;
823          }
824    
825          //
826          // retrieve tof informations
827          //
828          if ( !reprocall ){
829            itr = nobefrun + (re - evfrom - jumped);
830            //itr = re-(46438+200241);
831          } else {
832            itr = runinfo->GetFirstEntry() + (re - evfrom - jumped);
833          };
834          //
835          if ( !standalone ){
836            if ( itr > nevtofl2 ){  
837              if ( verbose ) printf(" OrbitalInfo - ERROR: no tof events with entry = %i in Level2 file\n",itr);
838              if ( debug ) printf(" nobefrun %u re %u evfrom %u jumped %u reprocall %i \n",nobefrun,re,evfrom,jumped,reprocall);
839              l0File->Close();
840              code = -901;
841              goto closeandexit;
842            };
843            //
844            tof->Clear();
845            //
846            if ( ttof->GetEntry(itr) <= 0 ) throw -36;
847            //
848        };        };
849        //        //
850        procev++;        procev++;
851        //        //
852        // start processing        // start processing
853        //        //
854        orbitalinfo = new OrbitalInfo();        if ( debug ) printf(" %i start processing \n",procev);      
855        orbitalinfo->absTime = l0reg->absTime;        orbitalinfo->Clear();
856          //
857          OrbitalInfoTrkVar *t_orb = new OrbitalInfoTrkVar();
858          if( !(orbitalinfo->OrbitalInfoTrk) ) orbitalinfo->OrbitalInfoTrk = new TClonesArray("OrbitalInfoTrkVar",2);
859          TClonesArray &tor = *orbitalinfo->OrbitalInfoTrk;
860          //
861          // Fill OBT, pkt_num and absTime
862          //      
863          orbitalinfo->pkt_num = ph->GetCounter();
864          orbitalinfo->OBT = ph->GetOrbitalTime();
865          orbitalinfo->absTime = atime;
866          if ( debug ) printf(" %i pktnum obt abstime \n",procev);      
867          //
868          // Propagate the orbit from the tle time to atime, using SGP(D)4.
869          //
870          if ( debug ) printf(" %i sgp4 \n",procev);      
871          cCoordGeo coo;
872          Float_t jyear=0.;    
873          //
874          if(atime >= gltle->GetToTime()) {
875            if ( !gltle->Query(atime, dbc) ){
876              //      
877              // Compute the magnetic dipole moment.
878              //
879              if ( debug ) printf(" %i compute magnetic dipole moment \n",procev);      
880              UInt_t year, month, day, hour, min, sec;
881              //
882              TTimeStamp t = TTimeStamp(atime, kTRUE);
883              t.GetDate(kTRUE, 0, &year, &month, &day);
884              t.GetTime(kTRUE, 0, &hour, &min, &sec);
885              jyear = (float) year
886                + (month*31.+ (float) day)/365.
887                + (hour*3600.+min*60.+(float)sec)/(24.*3600.*365.);
888              //
889              if ( debug ) printf(" %i compute magnetic dipole moment get dipole moment for year\n",procev);      
890              if ( debug ) printf(" %i jyear %f dimo %f \n",procev,jyear,dimo);      
891              feldcof_(&jyear, &dimo); // get dipole moment for year
892              if ( debug ) printf(" %i compute magnetic dipole moment end\n",procev);      
893            } else {
894              code = -56;
895              goto closeandexit;
896            };
897          }
898          coo = getCoo(atime, gltle->GetFromTime(), gltle->GetTle());
899          //
900          cOrbit orbits(*gltle->GetTle());
901          //
902          if ( debug ) printf(" I am Here \n");
903          //
904          // synchronize with quaternions data
905          //
906          if ( isf && neventsm>0 ){
907            //
908            // First event
909            //
910            isf = false;
911            upperqtime = atime;
912            lowerqtime = runinfo->RUNHEADER_TIME;
913            for ( ik = 0; ik < neventsm; ik++){  //number of macrocommad packets
914              if ( ch->GetEntry(ik) <= 0 ) throw -36;
915              tmpSize = mcmdev->Records->GetEntries();
916              numrec = tmpSize;
917              for (Int_t j3 = 0;j3<tmpSize;j3++){  //number of subpackets
918                if ( debug ) printf(" ik %i j3 %i eh eh eh \n",ik,j3);
919                mcmdrc = (pamela::McmdRecord*)mcmdev->Records->At(j3);
920                if ( mcmdrc ){ // missing inclination bug [8RED 090116]
921                  if ( debug ) printf(" pluto \n");
922                  if ((int)mcmdrc->ID1 == 226 && mcmdrc->Mcmd_Block_crc_ok == 1){ //Check that it is Inclination Packet
923                    L_QQ_Q_l_upper->fill(mcmdrc->McmdData);
924                    for (UInt_t ui = 0; ui < 6; ui++){
925                      if (ui>0){
926                        if (L_QQ_Q_l_upper->time[ui]>L_QQ_Q_l_upper->time[0]){
927                            if ( debug ) printf(" here1 %i \n",ui);
928                          Double_t u_time = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[ui]*1000-DeltaOBT*1000));
929                          Int_t recSize = recqtime.size();
930                          if(lowerqtime > recqtime[recSize-1]){
931                              Int_t sizeqmcmd = qtime.size();
932                              inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw);
933                              qtime[sizeqmcmd]=u_time;
934                              q0[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][0];
935                              q1[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][1];
936                              q2[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][2];
937                              q3[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][3];
938                              qmode[sizeqmcmd]=holeq(lowerqtime,qtime[sizeqmcmd],L_QQ_Q_l_lower,L_QQ_Q_l_upper,ui);
939                              lowerqtime = u_time;
940                              orbits.getPosition((double) (u_time - gltle->GetFromTime())/60., &eCi);
941                              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]);
942                              qRoll[sizeqmcmd]=RYPang_upper->Kren;
943                              qYaw[sizeqmcmd]=RYPang_upper->Ryskanie;
944                              qPitch[sizeqmcmd]=RYPang_upper->Tangazh;
945                          }
946                          for(Int_t mu = nt;mu<recSize;mu++){
947                            if(recqtime[mu]>lowerqtime && recqtime[mu]<u_time){
948                              nt=mu;
949                              Int_t sizeqmcmd = qtime.size();
950                              inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw);
951                              qtime[sizeqmcmd]=recqtime[mu];
952                              q0[sizeqmcmd]=recq0[mu];
953                              q1[sizeqmcmd]=recq1[mu];
954                              q2[sizeqmcmd]=recq2[mu];
955                              q3[sizeqmcmd]=recq3[mu];
956                              qmode[sizeqmcmd]=-10;
957                              orbits.getPosition((double) (qtime[sizeqmcmd] - gltle->GetFromTime())/60., &eCi);
958                              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]);
959                              qRoll[sizeqmcmd]=RYPang_upper->Kren;
960                              qYaw[sizeqmcmd]=RYPang_upper->Ryskanie;
961                              qPitch[sizeqmcmd]=RYPang_upper->Tangazh;
962                            }
963                            if(recqtime[mu]>=u_time){
964                              Int_t sizeqmcmd = qtime.size();
965                              inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw);
966                              qtime[sizeqmcmd]=u_time;
967                              q0[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][0];
968                              q1[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][1];
969                              q2[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][2];
970                              q3[sizeqmcmd]=L_QQ_Q_l_upper->quat[ui][3];
971                              qmode[sizeqmcmd]=holeq(lowerqtime,qtime[sizeqmcmd],L_QQ_Q_l_lower,L_QQ_Q_l_upper,ui);
972                              lowerqtime = u_time;
973                              orbits.getPosition((double) (u_time - gltle->GetFromTime())/60., &eCi);
974                              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]);
975                              qRoll[sizeqmcmd]=RYPang_upper->Kren;
976                              qYaw[sizeqmcmd]=RYPang_upper->Ryskanie;
977                              qPitch[sizeqmcmd]=RYPang_upper->Tangazh;
978                              break;
979                            }
980                          }
981                        }
982                      }else{
983                            if ( debug ) printf(" here2 %i \n",ui);
984                        Double_t u_time = dbtime->DBabsTime((UInt_t)(L_QQ_Q_l_upper->time[0]*1000-DeltaOBT*1000));
985                        if(lowerqtime>u_time)nt=0;
986                        Int_t recSize = recqtime.size();
987                        if(lowerqtime > recqtime[recSize-1]){
988                            Int_t sizeqmcmd = qtime.size();
989                            inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw);
990                            qtime[sizeqmcmd]=u_time;
991                            q0[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][0];
992                            q1[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][1];
993                            q2[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][2];
994                            q3[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][3];
995                            qmode[sizeqmcmd]=holeq(lowerqtime,qtime[sizeqmcmd],L_QQ_Q_l_lower,L_QQ_Q_l_upper,ui);
996                            lowerqtime = u_time;
997                            orbits.getPosition((double) (u_time - gltle->GetFromTime())/60., &eCi);
998                            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]);
999                            qRoll[sizeqmcmd]=RYPang_upper->Kren;
1000                            qYaw[sizeqmcmd]=RYPang_upper->Ryskanie;
1001                            qPitch[sizeqmcmd]=RYPang_upper->Tangazh;
1002                        }
1003                        for(Int_t mu = nt;mu<recSize;mu++){
1004                          if(recqtime[mu]>lowerqtime && recqtime[mu]<u_time){
1005                            nt=mu;
1006                            Int_t sizeqmcmd = qtime.size();
1007                            inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw);
1008                            qtime[sizeqmcmd]=recqtime[mu];
1009                            q0[sizeqmcmd]=recq0[mu];
1010                            q1[sizeqmcmd]=recq1[mu];
1011                            q2[sizeqmcmd]=recq2[mu];
1012                            q3[sizeqmcmd]=recq3[mu];
1013                            qmode[sizeqmcmd]=-10;
1014                            orbits.getPosition((double) (qtime[sizeqmcmd] - gltle->GetFromTime())/60., &eCi);
1015                            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]);
1016                            qRoll[sizeqmcmd]=RYPang_upper->Kren;
1017                            qYaw[sizeqmcmd]=RYPang_upper->Ryskanie;
1018                            qPitch[sizeqmcmd]=RYPang_upper->Tangazh;
1019                          }
1020                          if(recqtime[mu]>=u_time){
1021                            Int_t sizeqmcmd = qtime.size();
1022                            inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw);
1023                            qtime[sizeqmcmd]=u_time;
1024                            q0[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][0];
1025                            q1[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][1];
1026                            q2[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][2];
1027                            q3[sizeqmcmd]=L_QQ_Q_l_upper->quat[0][3];
1028                            qmode[sizeqmcmd]=holeq(lowerqtime,qtime[sizeqmcmd],L_QQ_Q_l_lower,L_QQ_Q_l_upper,ui);
1029                            lowerqtime = u_time;
1030                            orbits.getPosition((double) (u_time - gltle->GetFromTime())/60., &eCi);
1031                            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]);
1032                            qRoll[sizeqmcmd]=RYPang_upper->Kren;
1033                            qYaw[sizeqmcmd]=RYPang_upper->Ryskanie;
1034                            qPitch[sizeqmcmd]=RYPang_upper->Tangazh;
1035                            CopyQ(L_QQ_Q_l_lower,L_QQ_Q_l_upper);
1036                            break;
1037                          }
1038                        }
1039                      }
1040                    }
1041                  }
1042                }
1043                if ( debug ) printf(" ciccio \n");
1044              }
1045            }
1046            
1047            if(qtime.size()==0){
1048                for(UInt_t my=0;my<recqtime.size();my++){
1049                    Int_t sizeqmcmd = qtime.size();
1050                    inclresize(qtime,q0,q1,q2,q3,qmode,qRoll,qPitch,qYaw);
1051                    qtime[sizeqmcmd]=recqtime[my];
1052                    q0[sizeqmcmd]=recq0[my];
1053                    q1[sizeqmcmd]=recq1[my];
1054                    q2[sizeqmcmd]=recq2[my];
1055                    q3[sizeqmcmd]=recq3[my];
1056                    qmode[sizeqmcmd]=-10;
1057                    orbits.getPosition((double) (qtime[sizeqmcmd] - gltle->GetFromTime())/60., &eCi);
1058                    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]);
1059                    qRoll[sizeqmcmd]=RYPang_upper->Kren;
1060                    qYaw[sizeqmcmd]=RYPang_upper->Ryskanie;
1061                    qPitch[sizeqmcmd]=RYPang_upper->Tangazh;
1062                }
1063            }
1064            
1065            if ( debug ) printf(" fuffi \n");
1066    
1067            //sineparam(q0sine,qtime,q0,qRoll,qPitch,0.60);
1068            //sineparam(q1sine,qtime,q1,qRoll,qPitch,0.82);
1069            //sineparam(q2sine,qtime,q2,qRoll,qPitch,0.82);
1070            //sineparam(q3sine,qtime,q3,qRoll,qPitch,0.60);
1071            //sineparam(Yawsine,qtime,qYaw,qRoll,qPitch,4);
1072    
1073            if ( debug ) printf(" puffi \n");
1074            Double_t tmin = 9999999999.;
1075            Double_t tmax = 0.;
1076            for(UInt_t tre = 0;tre<qtime.size();tre++){
1077              if(qtime[tre]>tmax)tmax = qtime[tre];
1078              if(qtime[tre]<tmin)tmin = qtime[tre];
1079            }
1080            if ( debug ) printf(" gnfuffi \n");
1081    
1082            //q0testing->SetName("q0testing");
1083            //q1testing->SetName("q1testing");
1084            //q2testing->SetName("q2testing");
1085            //q3testing->SetName("q3testing");
1086            
1087    //      Int_t ss=10.*(tmax-tmin);
1088            //q0testing->SetBins(ss,tmin,tmax,1000,-1.,1.);
1089            //Pitchtesting->SetBins(ss,tmin,tmax,1000,-40.,40.);
1090    
1091    //      for(Int_t tre = 0;tre<qtime.size();tre++){
1092              //cout<<"q0["<<tre<<" = "<<q0[tre]<<endl;
1093              //q0testing->Fill(qtime[tre],q0[tre]);
1094              //q1testing->Fill(qtime[tre],q1[tre]);
1095              //Pitchtesting->Fill(qtime[tre],qPitch[tre],100);
1096              //if(qmode[tre] == -10)Pitchtesting->Fill(qtime[tre],10,100);
1097              //q2testing->Fill(qtime[tre],q2[tre],100);
1098              //q3testing->Fill(qtime[tre],q3[tre],100);
1099    //      }
1100            
1101            //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;
1102            //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;
1103          } // if we processed first event
1104          
1105          //Filling Inclination information
1106          Double_t incli = 0;
1107          if ( qtime.size() > 1 ){
1108          for(UInt_t mu = must;mu<qtime.size()-1;mu++){
1109            if ( debug ) printf(" ??grfuffi %i sixe %i must %i \n",mu,qtime.size()-1,must);
1110            if(qtime[mu+1]>qtime[mu]){
1111              if ( debug ) printf(" grfuffi2 %i \n",mu);
1112              if(atime<=qtime[mu+1] && atime>=qtime[mu]){
1113                must = mu;
1114                incli = (qPitch[mu+1]-qPitch[mu])/(qtime[mu+1]-qtime[mu]);
1115                orbitalinfo->theta =  incli*atime+qPitch[mu+1]-incli*qtime[mu+1];
1116                incli = (qRoll[mu+1]-qRoll[mu])/(qtime[mu+1]-qtime[mu]);
1117                orbitalinfo->etha =  incli*atime+qRoll[mu+1]-incli*qtime[mu+1];
1118                incli = (qYaw[mu+1]-qYaw[mu])/(qtime[mu+1]-qtime[mu]);
1119                orbitalinfo->phi =  incli*atime+qYaw[mu+1]-incli*qtime[mu+1];
1120                
1121                incli = (q0[mu+1]-q0[mu])/(qtime[mu+1]-qtime[mu]);
1122                orbitalinfo->q0 =  incli*atime+q0[mu+1]-incli*qtime[mu+1];
1123                incli = (q1[mu+1]-q1[mu])/(qtime[mu+1]-qtime[mu]);
1124                orbitalinfo->q1 =  incli*atime+q1[mu+1]-incli*qtime[mu+1];
1125                incli = (q2[mu+1]-q2[mu])/(qtime[mu+1]-qtime[mu]);
1126                orbitalinfo->q2 =  incli*atime+q2[mu+1]-incli*qtime[mu+1];
1127                incli = (q3[mu+1]-q3[mu])/(qtime[mu+1]-qtime[mu]);
1128                orbitalinfo->q3 =  incli*atime+q3[mu+1]-incli*qtime[mu+1];
1129                
1130                orbitalinfo->TimeGap = qtime[mu+1]-qtime[mu];
1131                orbitalinfo->mode = qmode[mu+1];
1132                //if(qmode[mu+1]==-10) orbitalinfo->R10r = true;else orbitalinfo->R10r = false;
1133                //reserved for next versions Vitaly.
1134                /*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){
1135                  //linear interpolation
1136                  incli = (q0[mu+1]-q0[mu])/(qtime[mu+1]-qtime[mu]);
1137                  orbitalinfo->q0 =  incli*atime+q0[mu+1]-incli*qtime[mu+1];
1138                  incli = (q1[mu+1]-q1[mu])/(qtime[mu+1]-qtime[mu]);
1139                  orbitalinfo->q1 =  incli*atime+q1[mu+1]-incli*qtime[mu+1];
1140                  incli = (q2[mu+1]-q2[mu])/(qtime[mu+1]-qtime[mu]);
1141                  orbitalinfo->q2 =  incli*atime+q2[mu+1]-incli*qtime[mu+1];
1142                  incli = (q3[mu+1]-q3[mu])/(qtime[mu+1]-qtime[mu]);
1143                  orbitalinfo->q3 =  incli*atime+q3[mu+1]-incli*qtime[mu+1];
1144                }else{
1145                  //sine interpolation
1146                  for(UInt_t mt=0;mt<q0sine.size();mt++){
1147                    if(atime<=q0sine[mt].finishPoint && atime>=q0sine[mt].startPoint){
1148                      if(!q0sine[mt].NeedFit)orbitalinfo->q0=q0sine[mt].A*sin(q0sine[mt].b*atime+q0sine[mt].c);else{
1149                        incli = (q0[mu+1]-q0[mu])/(qtime[mu+1]-qtime[mu]);
1150                        orbitalinfo->q0 =  incli*atime+q0[mu+1]-incli*qtime[mu+1];
1151                      }
1152                    }
1153                    if(atime<=q1sine[mt].finishPoint && atime>=q1sine[mt].startPoint){
1154                      if(!q1sine[mt].NeedFit)orbitalinfo->q1=q1sine[mt].A*sin(q1sine[mt].b*atime+q1sine[mt].c);else{
1155                        incli = (q1[mu+1]-q1[mu])/(qtime[mu+1]-qtime[mu]);
1156                        orbitalinfo->q1 =  incli*atime+q1[mu+1]-incli*qtime[mu+1];
1157                      }
1158                    }
1159                    if(atime<=q2sine[mt].finishPoint && atime>=q2sine[mt].startPoint){
1160                      if(!q2sine[mt].NeedFit)orbitalinfo->q2=q0sine[mt].A*sin(q2sine[mt].b*atime+q2sine[mt].c);else{
1161                        incli = (q2[mu+1]-q2[mu])/(qtime[mu+1]-qtime[mu]);
1162                        orbitalinfo->q2 =  incli*atime+q2[mu+1]-incli*qtime[mu+1];
1163                      }
1164                    }
1165                    if(atime<=q3sine[mt].finishPoint && atime>=q3sine[mt].startPoint){
1166                      if(!q3sine[mt].NeedFit)orbitalinfo->q3=q0sine[mt].A*sin(q3sine[mt].b*atime+q3sine[mt].c);else{
1167                        incli = (q3[mu+1]-q3[mu])/(qtime[mu+1]-qtime[mu]);
1168                        orbitalinfo->q3 =  incli*atime+q3[mu+1]-incli*qtime[mu+1];
1169                      }
1170                    }
1171                    if(atime<=Yawsine[mt].finishPoint && atime>=Yawsine[mt].startPoint){
1172                      if(!Yawsine[mt].NeedFit)orbitalinfo->phi=Yawsine[mt].A*sin(Yawsine[mt].b*atime+Yawsine[mt].c);else{
1173                        incli = (qYaw[mu+1]-qYaw[mu])/(qtime[mu+1]-qtime[mu]);
1174                        orbitalinfo->phi =  incli*atime+qYaw[mu+1]-incli*qtime[mu+1];
1175                      }
1176                    }
1177                  }
1178                }*/
1179                //q0testing->Fill(atime,orbitalinfo->q0,100);
1180                //q1testing->Fill(atime,orbitalinfo->q1,100);
1181                //Pitchtesting->Fill(atime,orbitalinfo->etha);
1182                //q2testing->Fill(atime,orbitalinfo->q2);
1183                //q3testing->Fill(atime,orbitalinfo->q3);
1184                break;
1185              }
1186            }
1187          }
1188          }
1189          //
1190          // ops no inclination information
1191          //
1192    
1193          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 ){
1194            orbitalinfo->mode = 10;
1195            orbitalinfo->q0 = -1000.;
1196            orbitalinfo->q1 = -1000.;
1197            orbitalinfo->q2 = -1000.;
1198            orbitalinfo->q3 = -1000.;
1199            orbitalinfo->etha = -1000.;
1200            orbitalinfo->phi = -1000.;
1201            orbitalinfo->theta = -1000.;
1202          };
1203          //
1204          // #########################################################################################################################  
1205          //
1206          // fill orbital positions
1207          //        
1208          // Build coordinates in the right range.  We want to convert,
1209          // longitude from (0, 2*pi) to (-180deg, 180deg).  Altitude is
1210          // in meters.
1211          lon = (coo.m_Lon > M_PI) ? rad2deg(coo.m_Lon - 2*M_PI) : rad2deg(coo.m_Lon);
1212          lat = rad2deg(coo.m_Lat);
1213          alt = coo.m_Alt;
1214          //
1215          if( lon<180 && lon>-180 && lat<90 && lat>-90 && alt>0 ){  
1216            //      
1217            orbitalinfo->lon = lon;
1218            orbitalinfo->lat = lat;
1219            orbitalinfo->alt = alt ;
1220            //
1221            // compute mag field components and L shell.
1222            //
1223            feldg_(&lat, &lon, &alt, &bnorth, &beast, &bdown, &babs);
1224            shellg_(&lat, &lon, &alt, &dimo, &xl, &icode, &bab1);
1225            findb0_(&stps, &bdel, &value, &bequ, &rr0);
1226            //
1227            orbitalinfo->Bnorth = bnorth;
1228            orbitalinfo->Beast = beast;
1229            orbitalinfo->Bdown = bdown;
1230            orbitalinfo->Babs = babs;
1231            orbitalinfo->BB0 = babs/bequ;
1232            orbitalinfo->L = xl;      
1233            // Set Stormer vertical cutoff using L shell.
1234            orbitalinfo->cutoffsvl = 14.295 / (xl*xl); //
1235            /*
1236    ---------- Forwarded message ----------
1237    Date: Wed, 09 May 2012 12:16:47 +0200
1238    From: Alessandro Bruno <alessandro.bruno@ba.infn.it>
1239    To: Mirko Boezio <mirko.boezio@ts.infn.it>
1240    Cc: Francesco S. Cafagna <Francesco.Cafagna@ba.infn.it>
1241    Subject: Störmer vertical cutoff
1242    
1243    Ciao Mirko,
1244    volevo segnalarti che il valore dello Störmer vertical cutoff nel Level2 è
1245    sovrastimato di circa il 4%.
1246    Dopo un'approfondita analisi con l'IGRF-05 abbiamo ricavano un valore pari
1247    a: 14.295 / L^2 anzichè 14.9 / L^2, valore obsoleto in quanto riferito agli
1248    anni '50.
1249    */
1250            //14.9/(xl*xl);
1251            orbitalinfo->igrf_icode = icode;
1252            //
1253          };      
1254          //
1255          if ( debug ) printf(" pitch angle \n");
1256          //
1257          // pitch angles
1258          //
1259          //if ( orbitalinfo->mode != 10 && orbitalinfo->mode != 5 && orbitalinfo->mode !=7 && orbitalinfo->mode != 9 ){
1260          if( orbitalinfo->TimeGap>0 && orbitalinfo->TimeGap<2000000){
1261            //
1262            Float_t Bx = -orbitalinfo->Bdown;
1263            Float_t By = orbitalinfo->Beast;
1264            Float_t Bz = orbitalinfo->Bnorth;
1265            //
1266            TMatrixD Fij = PO->ECItoGreenwich(PO->QuatoECI(orbitalinfo->q0,orbitalinfo->q1,orbitalinfo->q2,orbitalinfo->q3),orbitalinfo->absTime);
1267            TMatrixD Gij = PO->ColPermutation(Fij);
1268            TMatrixD Dij = PO->GreenwichtoGEO(orbitalinfo->lat,orbitalinfo->lon,Fij);
1269            TMatrixD Iij = PO->ColPermutation(Dij);
1270            //
1271            orbitalinfo->Iij.ResizeTo(Iij);
1272            orbitalinfo->Iij = Iij;
1273            //
1274            A1 = Iij(0,2);
1275            A2 = Iij(1,2);
1276            A3 = Iij(2,2);
1277            //
1278            //      orbitalinfo->pamzenitangle = (Float_t)PO->GetPitchAngle(1,0,0,A1,A2,A3);                        // Angle between zenit and Pamela's main axiz
1279            //      orbitalinfo->pamBangle = (Float_t)PO->GetPitchAngle(A1,A2,A3,Bx,By,Bz);                 // Angle between Pamela's main axiz and B
1280            //
1281            if ( !standalone && tof->ntrk() > 0 ){
1282              //
1283              Int_t nn = 0;
1284              for(Int_t nt=0; nt < tof->ntrk(); nt++){  
1285                //
1286                ToFTrkVar *ptt = tof->GetToFTrkVar(nt);
1287                Double_t E11x = ptt->xtr_tof[0]; // tr->x[0];
1288                Double_t E11y = ptt->ytr_tof[0]; //tr->y[0];
1289                Double_t E11z = zin[0];
1290                Double_t E22x = ptt->xtr_tof[3];//tr->x[3];
1291                Double_t E22y = ptt->ytr_tof[3];//tr->y[3];
1292                Double_t E22z = zin[3];
1293                if ( (E11x < 100. && E11y < 100. && E22x < 100. && E22y < 100.) || ptt->trkseqno != -1  ){
1294                  Double_t norm = sqrt(pow(E22x-E11x,2)+pow(E22y-E11y,2)+pow(E22z-E11z,2));
1295                  //              Double_t MyAzim = TMath::RadToDeg()*atan(TMath::Abs(E22y-E11y)/TMath::Abs(E22x-E11x));
1296                  //              if(E22x-E11x>=0 && E22y-E11y <0) MyAzim =  360. - MyAzim;
1297                  //              if(E22x-E11x>=0 && E22y-E11y >=0) MyAzim = MyAzim;
1298                  //              if(E22x-E11x<0 && E22y-E11y >0) MyAzim = 180. - MyAzim;
1299                  //              if(E22x-E11x<0 && E22y-E11y <0) MyAzim = 180. + MyAzim;
1300                  Px = (E22x-E11x)/norm;
1301                  Py = (E22y-E11y)/norm;
1302                  Pz = (E22z-E11z)/norm;
1303                  //
1304                  t_orb->trkseqno = ptt->trkseqno;
1305                  //
1306                  TMatrixD Eij = PO->PamelatoGEO(Iij,Px,Py,Pz);
1307                  t_orb->Eij.ResizeTo(Eij);
1308                  t_orb->Eij = Eij;
1309                  //
1310                  TMatrixD Sij = PO->PamelatoGEO(Gij,Px,Py,Pz);
1311                  t_orb->Sij.ResizeTo(Sij);
1312                  t_orb->Sij = Sij;
1313                  //            
1314                  t_orb->pitch = (Float_t)PO->GetPitchAngle(Eij(0,0),Eij(1,0),Eij(2,0),Bx,By,Bz);
1315                  //
1316                  //
1317                  Double_t omega = PO->GetPitchAngle(Eij(0,0),Eij(1,0),Eij(2,0),cos(orbitalinfo->lon+TMath::Pi()/2)-sin(orbitalinfo->lon+TMath::Pi()/2),cos(orbitalinfo->lon+TMath::Pi()/2)+sin(orbitalinfo->lon+TMath::Pi()/2),1);
1318                  //
1319                  t_orb->cutoff = 59.3/(pow(orbitalinfo->L,2)*pow((1+sqrt(1-pow(orbitalinfo->L,-3/2)*cos(omega))),2));
1320                  //
1321                  if ( t_orb->pitch != t_orb->pitch ) t_orb->pitch = -1000.;
1322                  if ( t_orb->cutoff != t_orb->cutoff ) t_orb->cutoff = -1000.;
1323                  //
1324                  if ( debug ) printf(" orbitalinfo->cutoffsvl %f vitaly %f \n",orbitalinfo->cutoffsvl,t_orb->cutoff);
1325                  //
1326                  new(tor[nn]) OrbitalInfoTrkVar(*t_orb);
1327                  nn++;
1328                  //
1329                  t_orb->Clear();
1330                  //
1331                };
1332                //
1333              };
1334            } else {
1335              if ( debug ) printf(" mmm... mode %u standalone %i ntrk %i \n",orbitalinfo->mode,standalone,tof->ntrk());
1336            };
1337            //
1338          } else {
1339            if ( !standalone && tof->ntrk() > 0 ){
1340              //
1341              Int_t nn = 0;
1342              for(Int_t nt=0; nt < tof->ntrk(); nt++){  
1343                //
1344                ToFTrkVar *ptt = tof->GetToFTrkVar(nt);
1345                if ( ptt->trkseqno != -1  ){
1346                  //
1347                  t_orb->trkseqno = ptt->trkseqno;
1348                  //
1349                  t_orb->Eij = 0;  
1350                  //
1351                  t_orb->Sij = 0;
1352                  //            
1353                  t_orb->pitch = -1000.;
1354                  //
1355                  t_orb->cutoff = -1000.;
1356                  //
1357                  new(tor[nn]) OrbitalInfoTrkVar(*t_orb);
1358                  nn++;
1359                  //
1360                  t_orb->Clear();
1361                  //
1362                };
1363                //
1364              };    
1365            };
1366          };
1367          //
1368          // Fill the class
1369          //
1370        OrbitalInfotr->Fill();        OrbitalInfotr->Fill();
       //      
1371        //        //
1372      jumpev:        delete t_orb;
       debug = false;  
1373        //        //
1374      };      }; // loop over the events in the run
1375      //      //
1376      // Here you may want to clear some variables before processing another run        // Here you may want to clear some variables before processing another run  
1377      //      //
1378      ei = 0;  
1379        //gStyle->SetOptStat(000000);
1380        //gStyle->SetPalette(1);
1381        
1382        /*TCanvas* c1 = new TCanvas("c1","",1200,800);
1383        //c1->Divide(1,4);
1384        c1->cd(1);
1385        //q0testing->Draw("colz");
1386        //c1->cd(2);
1387        //q1testing->Draw("colz");
1388        //c1->cd(3);
1389        Pitchtesting->Draw("colz");
1390        //c1->cd(4);
1391        //q3testing->Draw("colz");
1392        c1->SaveAs("9.Rollhyst.png");
1393        delete c1;*/
1394    
1395        if ( verbose ) printf(" Clear before new run \n");
1396        delete dbtime;
1397    
1398        mcmdrc->Clear();
1399        mcmdrc = 0;
1400        
1401        if ( verbose ) printf(" Clear before new run1 \n");
1402        if ( L_QQ_Q_l_lower ) delete L_QQ_Q_l_lower;
1403        if ( verbose ) printf(" Clear before new run2 \n");
1404        if ( L_QQ_Q_l_upper ) delete L_QQ_Q_l_upper;
1405        if ( verbose ) printf(" Clear before new run3 \n");
1406        if ( RYPang_upper ) delete RYPang_upper;
1407        if ( verbose ) printf(" Clear before new run4 \n");
1408        if ( RYPang_lower ) delete RYPang_lower;
1409    
1410        if ( l0tr ) l0tr->Delete();
1411        
1412        if ( verbose ) printf(" End run \n");
1413    
1414    }; // process all the runs    }; // process all the runs
1415    //    
1416    if (verbose) printf("\n Finished processing data \n");    if (verbose) printf("\n Finished processing data \n");
1417    //    //
1418   closeandexit:   closeandexit:
# Line 464  int OrbitalInfoCore(ULong64_t run, TFile Line 1430  int OrbitalInfoCore(ULong64_t run, TFile
1430          //          //
1431          // Get entry from old tree          // Get entry from old tree
1432          //          //
1433          OrbitalInfotrclone->GetEntry(j);                    if ( OrbitalInfotrclone->GetEntry(j) <= 0 ) throw -36;    
1434          //          //
1435          // copy orbitalinfoclone to OrbitalInfo          // copy orbitalinfoclone to OrbitalInfo
1436          //          //
1437          orbitalinfo = new OrbitalInfo();          orbitalinfo->Clear();
1438            //
1439          memcpy(&orbitalinfo,&orbitalinfoclone,sizeof(orbitalinfoclone));          memcpy(&orbitalinfo,&orbitalinfoclone,sizeof(orbitalinfoclone));
1440          //          //
1441          // Fill entry in the new tree          // Fill entry in the new tree
# Line 477  int OrbitalInfoCore(ULong64_t run, TFile Line 1444  int OrbitalInfoCore(ULong64_t run, TFile
1444        };        };
1445        if (verbose) printf(" Finished successful copying!\n");        if (verbose) printf(" Finished successful copying!\n");
1446      };      };
1447        //if ( OrbitalInfotrclone )    OrbitalInfotrclone->Clear();        
1448        //if ( OrbitalInfotrclone )    OrbitalInfotrclone->Delete();        
1449    };    };
1450    //    //
1451    // Close files, delete old tree(s), write and close level2 file    // Close files, delete old tree(s), write and close level2 file
1452    //    //
1453    if ( l0File ) l0File->Close();    if ( l0File ) l0File->Close();
1454    if ( tempfile ) tempfile->Close();                if ( myfold ) gSystem->Unlink(tempname.str().c_str());
1455    gSystem->Unlink(tempname.str().c_str());    //
   
   //if ( code < 0 ) printf("\n OrbitalInfo - ERROR: an error occurred, try to save anyway...\n");  
   //printf("\n Writing and closing rootple\n");  
   if ( runinfo ) runinfo->Close();      
1456    if ( OrbitalInfotr ) OrbitalInfotr->SetName("OrbitalInfo");        if ( OrbitalInfotr ) OrbitalInfotr->SetName("OrbitalInfo");    
1457      //
1458    if ( file ){    if ( file ){
1459      file->cd();      file->cd();
1460      file->Write();      OrbitalInfotr->Write("OrbitalInfo", TObject::kOverwrite);
1461    };    };
1462    //    //
1463    gSystem->Unlink(OrbitalInfofolder.str().c_str());    if (verbose) printf("\n Exiting...\n");
1464    
1465      if ( myfold ) gSystem->Unlink(OrbitalInfofolder.str().c_str());
1466    //    //
1467    // the end    // the end
1468    //    //
1469      if ( dbc ){
1470        dbc->Close();
1471        delete dbc;
1472      };
1473      //
1474    if (verbose) printf("\n Exiting...\n");    if (verbose) printf("\n Exiting...\n");
1475    if(OrbitalInfotr)OrbitalInfotr->Delete();    if ( tempfile ) tempfile->Close();            
1476      
1477      if ( PO ) delete PO;
1478      if ( gltle ) delete gltle;
1479      if ( glparam ) delete glparam;
1480      if ( glparam2 ) delete glparam2;
1481      if ( glparam3 ) delete glparam3;
1482      if (verbose) printf("\n Exiting3...\n");
1483      if ( glroot ) delete glroot;
1484      if (verbose) printf("\n Exiting4...\n");
1485      if ( runinfo ) runinfo->Close();    
1486      if ( runinfo ) delete runinfo;
1487    
1488      if ( debug ){  
1489      cout << "1   0x" << OrbitalInfotr << endl;
1490      cout << "2   0x" << OrbitalInfotrclone << endl;
1491      cout << "3   0x" << l0tr << endl;
1492      cout << "4   0x" << tempOrbitalInfo << endl;
1493      cout << "5   0x" << ttof << endl;
1494      }
1495      //
1496      if ( debug )  file->ls();
1497      //
1498    if(code < 0)  throw code;    if(code < 0)  throw code;
1499    return(code);    return(code);
1500  }  }
1501    
1502    
1503    //
1504    // Returns the cCoordGeo structure holding the geographical
1505    // coordinates for the event (see sgp4.h).
1506    //
1507    // atime is the abstime of the event in UTC unix time.
1508    // tletime is the time of the tle in UTC unix time.
1509    // tle is the previous and nearest tle (compared to atime).
1510    cCoordGeo getCoo(UInt_t atime, UInt_t tletime, cTle *tle)
1511    {
1512      cEci eci;
1513      cOrbit orbit(*tle);
1514      orbit.getPosition((double) (atime - tletime)/60., &eci);
1515      
1516      return eci.toGeo();
1517    }
1518    
1519    // function of copyng of quatrnions classes
1520    
1521    void CopyQ(Quaternions *Q1, Quaternions *Q2){
1522      for(UInt_t i = 0; i < 6; i++){
1523        Q1->time[i]=Q2->time[i];
1524        for (UInt_t j = 0; j < 4; j++)Q1->quat[i][j]=Q2->quat[i][j];
1525      }
1526      return;
1527    }
1528    
1529    // functions of copyng InclinationInfo classes
1530    
1531    void CopyAng(InclinationInfo *A1, InclinationInfo *A2){
1532      A1->Tangazh = A2->Tangazh;
1533      A1->Ryskanie = A2->Ryskanie;
1534      A1->Kren = A2->Kren;
1535      return;
1536    }
1537    
1538    UInt_t holeq(Double_t lower,Double_t upper,Quaternions *Qlower, Quaternions *Qupper, UInt_t f){
1539      
1540      UInt_t hole = 10;
1541      Bool_t R10l = false;     // Sign of R10 mode in lower quaternions array
1542      Bool_t R10u = false;     // Sign of R10 mode in upper quaternions array
1543      Bool_t insm = false;     // Sign that we inside quaternions array
1544      Bool_t mxtml = false;    // Sign of mixt mode in lower quaternions array
1545      Bool_t mxtmu = false;    // Sign of mixt mode in upper quaternions array
1546      Bool_t npasm = false;     // Sign of normall pass between R10 and non R10 or between non R10 and R10
1547      UInt_t NCQl = 6;       // Number of correct quaternions in lower array
1548      UInt_t NCQu = 6;       // Number of correct quaternions in upper array
1549      if (f>0){
1550        insm = true;
1551        if(Qupper->time[f]-Qupper->time[f-1]==30) R10u = false;
1552        if(Qupper->time[f]-Qupper->time[f-1]<1) R10u = true;
1553      }else{
1554        insm = false;
1555        if((Qlower->time[5]-Qlower->time[0]<2)&&(Qlower->time[1]-Qlower->time[0]<2)) R10l = true;
1556        if((Qupper->time[5]-Qupper->time[0]<2)&&(Qupper->time[1]-Qupper->time[0]<2)) R10u = true;
1557        if((Qlower->time[5]-Qlower->time[0]==150)&&(Qlower->time[1]-Qlower->time[0]==30)) R10l = false;
1558        if((Qupper->time[5]-Qupper->time[0]==150)&&(Qupper->time[1]-Qupper->time[0]==30)) R10u = false;
1559        if((Qlower->time[5]-Qlower->time[0]<2)&&(Qlower->time[1]-Qlower->time[0]==30)){
1560          mxtml = true;
1561          for(UInt_t i = 1; i < 6; i++){
1562            if(Qlower->time[i]-Qlower->time[0]==30*i) NCQl=i;
1563          }
1564        }
1565        if((Qupper->time[5]-Qupper->time[0]<2)&&(Qupper->time[1]-Qupper->time[0]==30)){
1566          mxtmu = true;
1567          for(UInt_t i = 1; i < 6; i++){
1568            if(Qupper->time[i]-Qupper->time[0]==30*i) NCQu=i;
1569          }
1570        }
1571      }
1572      
1573      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;
1574      
1575      
1576      if (R10u&&insm) hole=0; // best event R10
1577      if ((upper-lower<=5)&&(!insm)&&R10l&&R10u) hole = 1; // when first of 6 quaternions in array is correct
1578      if (((!R10u)&&insm)||((!insm)&&(!R10u)&&(!R10l)&&((upper-lower==210+(6-NCQl)*30)||(upper-lower==30)))) hole = 2; //non R10
1579      if (npasm&&(!insm)&&((R10l&&!R10u)||(R10u&&!R10l))) hole = 3; //normall pass from R10 to non R10 or from non R10 to R10
1580      if ((!npasm)&&(upper-lower<=300)&&(!insm)&&((R10l&&!R10u)||(R10u&&!R10l))) hole = 4; // eliminable hole between R10 and non R10 or between non R10 and R10
1581      if ((upper-lower>=300)&&(!insm)&&((R10l&&!R10u)||(R10u&&!R10l))) hole = 5; //uneliminable hole between R10 and non R10 or between non R10 and R10
1582      if ((upper-lower>5)&&(upper-lower<=300)&&R10u&&R10l) hole = 6; // eliminable hole inside R10
1583      if ((upper-lower>300)&&R10u&&R10l) hole = 7; //uneliminable hole inside R10
1584      if ((upper-lower>210)&&(upper-lower<=1200)&&(!R10u)&&(!R10l)) hole = 8; //eliminable hole inside non R10
1585      if ((upper-lower>1200)&&!R10u&&!R10l) hole = 9; // uneliminable hole inside non R10
1586      return hole;
1587    }
1588    
1589    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){
1590      Int_t sizee = t.size()+1;
1591      t.resize(sizee);
1592      q0.resize(sizee);
1593      q1.resize(sizee);
1594      q2.resize(sizee);
1595      q3.resize(sizee);
1596      mode.resize(sizee);
1597      Roll.resize(sizee);
1598      Pitch.resize(sizee);
1599      Yaw.resize(sizee);
1600    }
1601    
1602    //Find fitting sine functions for q0,q1,q2,q3 and Yaw-angle;
1603    void sineparam(vector<Sine>& qsine, vector<Double_t>& qtime, vector<Float_t>& q, vector<Float_t>& Roll, vector<Float_t>& Pitch, Float_t limsin){
1604      UInt_t mulast = 0;
1605      UInt_t munow = 0;
1606      UInt_t munext = 0;
1607      Bool_t increase = false;
1608      Bool_t decrease = false;
1609      Bool_t Max_is_defined = false;
1610      Bool_t Start_point_is_defined = false;
1611      Bool_t Period_is_defined = false;
1612      Bool_t Large_gap = false;
1613      Bool_t normal_way = true;
1614      Bool_t small_gap_on_ridge = false;
1615      Double_t t1 = 0;
1616      Double_t t1A = 0;
1617      Int_t sinesize = 0;
1618      Int_t nfi = 0;
1619      for(UInt_t mu = 0;mu<qtime.size();mu++){
1620        //cout<<"Roll["<<mu<<"] = "<<Roll[mu]<<endl;
1621        if(TMath::Abs(Roll[mu])<1. && TMath::Abs(Pitch[mu])<1. && TMath::Abs(q[mu])<limsin){
1622        //cout<<"q["<<mu<<endl<<"] = "<<q[mu]<<endl;
1623        if(mulast!=0 && munow!=0 && munext!=0){mulast=munow;munow=munext;munext=mu;}
1624        if(munext==0 && munow!=0)munext=mu;
1625        if(munow==0 && mulast!=0)munow=mu;
1626        if(mulast==0)mulast=mu;
1627        
1628        //cout<<"mulast = "<<mulast<<"\tmunow = "<<munow<<"\tmunext = "<<munext<<endl;
1629        //Int_t ref;
1630        //cin>>ref;
1631        if(TMath::Abs(q[munow])>TMath::Abs(q[mulast]) && TMath::Abs(q[munow])>TMath::Abs(q[munext]) && q[mulast]*q[munext]>0 && qtime[munext]-qtime[mulast]>400)small_gap_on_ridge = true;
1632        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;
1633        //if(normal_way)cout<<"Normal_Way"<<endl;
1634        if(Large_gap || small_gap_on_ridge){
1635          //cout<<"Large gap..."<<endl;
1636          //if(small_gap_on_ridge)cout<<"small gap..."<<endl;
1637          //cout<<"q["<<mulast<<"] = "<<q[mulast]<<"\tq["<<munow<<"] = "<<q[munow]<<"\tq["<<munext<<"] = "<<q[munext]<<endl;
1638          //cout<<"qtime["<<mulast<<"] = "<<qtime[mulast]<<"\tqtime["<<munow<<"] = "<<qtime[munow]<<"\tqtime["<<munext<<"] = "<<qtime[munext]<<endl;
1639          increase = false;
1640          decrease = false;
1641          if(nfi>0){
1642            qsine.resize(qsine.size()-1);
1643            sinesize = qsine.size();
1644            //cout<<"nfi was larger then zero"<<endl;
1645          }else{
1646            //cout<<"nfi was not larger then zero :( nfi = "<<nfi<<endl;
1647            //cout<<"qsine.size = "<<qsine.size()<<endl;
1648            if(!Period_is_defined){
1649              //cout<<"Period was defined"<<endl;
1650              if(qsine.size()>1){
1651                qsine[sinesize-1].b = qsine[sinesize-2].b;
1652                qsine[sinesize-1].c = qsine[sinesize-2].c;
1653              }else{
1654                qsine[sinesize-1].b = TMath::Pi()/1591.54;
1655                qsine[sinesize-1].c = qsine[sinesize-1].startPoint;
1656              }
1657            }
1658            if(!Max_is_defined){
1659              //cout<<"Max was already defined"<<endl;
1660              if(qsine.size()>1)qsine[sinesize-1].A = qsine[sinesize-2].A;else qsine[sinesize-1].A = limsin;
1661            }
1662            qsine[sinesize-1].NeedFit = true;
1663          }
1664          qsine[sinesize-1].finishPoint = qtime[munow];
1665          //cout<<"finish point before large gap = "<<qtime[munow]<<endl;
1666          nfi = 0;
1667          Max_is_defined = false;
1668          Start_point_is_defined = false;
1669          Period_is_defined = false;
1670          small_gap_on_ridge = false;
1671        }
1672        //cout<<"Slope "<<increase<<"\t"<<decrease<<endl;
1673        //cout<<"mulast = "<<mulast<<"\tmunow = "<<munow<<"\tmunext = "<<munext<<endl;
1674        if((munext>munow) && (munow>mulast) && normal_way){
1675          if(!increase && !decrease){
1676            //cout<<"Normal way have started"<<endl;
1677            qsine.resize(qsine.size()+1);
1678            sinesize = qsine.size();
1679            qsine[sinesize-1].startPoint=qtime[mulast];
1680            if(q[munext]>q[munow] && q[munow]>q[mulast]) increase = true;
1681            if(q[munext]<q[munow] && q[munow]<q[mulast]) decrease = true;
1682          }
1683          //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;}
1684          if(TMath::Abs(q[munow])>TMath::Abs(q[mulast]) && TMath::Abs(q[munow])>TMath::Abs(q[munext]) && TMath::Abs(q[munow])>0.9*limsin && qtime[munow]-qtime[mulast]<400 && qtime[munext]-qtime[munow]<400){
1685            //cout<<"Max point is qtime = "<<qtime[munow]<<"\tq = "<<q[munow]<<endl;
1686            if(q[munow]>q[mulast]){
1687              increase = false;
1688              decrease = true;
1689            }
1690            if(q[munow]<q[mulast]){
1691              increase = true;
1692              decrease = false;
1693            }
1694            if(Max_is_defined && !Start_point_is_defined){
1695              Double_t qPer = qtime[munow]-t1A;
1696              if(qPer>1000){
1697                //cout<<"qsine["<<sinesize-1<<"] = "<<qPer<<" = "<<qtime[munow]<<" - "<<t1A<<"\tlim = "<<limsin<<endl;
1698                qsine[sinesize-1].b=TMath::Pi()/qPer;
1699                if(decrease)qsine[sinesize-1].c=-qsine[sinesize-1].b*t1A;
1700                if(increase)qsine[sinesize-1].c=-qsine[sinesize-1].b*(t1A-qPer);
1701                Period_is_defined = true;
1702              }
1703            }
1704            Max_is_defined = true;
1705            qsine[sinesize-1].A = TMath::Abs(q[munow]);
1706            if(Start_point_is_defined && Period_is_defined){
1707              qsine[sinesize-1].finishPoint = qtime[munow];
1708              nfi++;
1709              qsine[sinesize-1].NeedFit = false;
1710              Max_is_defined = false;
1711              Start_point_is_defined = false;
1712              Period_is_defined = false;
1713              qsine.resize(qsine.size()+1);
1714              sinesize = qsine.size();
1715              qsine[sinesize-1].startPoint = qtime[munow];
1716            }
1717            if(!Start_point_is_defined) t1A=qtime[munow];
1718          }
1719          //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;
1720          if(((q[munow]>=0 && q[mulast]<=0) || (q[munow]<=0 && q[mulast]>=0)) && qtime[munow]-qtime[mulast]<2000 && qtime[munext]-qtime[munow]<2000){
1721            Double_t tcrosszero = 0;
1722            //cout<<"cross zero point...qtime = "<<qtime[munow]<<endl;
1723            if(q[munow]==0.) tcrosszero = qtime[munow];else
1724              if(q[mulast]==0.)tcrosszero = qtime[mulast];else{
1725                Double_t k_ = (q[munow]-q[mulast])/(qtime[munow]-qtime[mulast]);
1726                Double_t b_ = q[munow]-k_*qtime[munow];
1727                tcrosszero = -b_/k_;
1728              }
1729            if(Start_point_is_defined){
1730              //cout<<"Start Point allready defined"<<endl;
1731              Double_t qPer = tcrosszero - t1;
1732              qsine[sinesize-1].b = TMath::Pi()/qPer;
1733              //cout<<"qsine["<<sinesize-1<<"].b = "<<TMath::Pi()/qPer<<endl;
1734              Period_is_defined = true;
1735              Float_t x0 = 0;
1736              if(decrease)x0 = t1;
1737              if(increase)x0 = tcrosszero;
1738              qsine[sinesize-1].c = -qsine[sinesize-1].b*x0;
1739              if(Max_is_defined){
1740                //cout<<"Max was previous defined"<<endl;
1741                qsine[sinesize-1].finishPoint = qtime[munow];
1742                nfi++;
1743                qsine[sinesize-1].NeedFit = false;
1744                Max_is_defined = false;
1745                t1 = tcrosszero;
1746                Start_point_is_defined = true;
1747                Period_is_defined = false;
1748                qsine.resize(qsine.size()+1);
1749                sinesize = qsine.size();
1750                qsine[sinesize-1].startPoint = qtime[munow];
1751              }
1752            }else{
1753              t1 = tcrosszero;
1754              Start_point_is_defined = true;
1755            }
1756          }
1757        }
1758        }
1759      }
1760    
1761      //cout<<"FINISH SINE INTERPOLATION FUNCTION..."<<endl<<endl;
1762    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.59

  ViewVC Help
Powered by ViewVC 1.1.23