[2095] | 1 | // ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
|
---|
| 2 | // Eric Aubourg
|
---|
| 3 | // Christophe Magneville
|
---|
| 4 | // Reza Ansari
|
---|
[2102] | 5 | // $Id: toi2toi_addsp.cc,v 1.3 2002-07-16 16:38:48 cecile Exp $
|
---|
[2095] | 6 |
|
---|
| 7 | #include "machdefs.h"
|
---|
| 8 | #include "toimanager.h"
|
---|
| 9 | #include "pexceptions.h"
|
---|
| 10 | #include "ctimer.h"
|
---|
[2099] | 11 | #include "toi2toi_addsp.h"
|
---|
[2095] | 12 | // La valeur "Pi" doit etre celle de smathconst.h a cause du test sur theta
|
---|
| 13 | #include "smathconst.h"
|
---|
| 14 |
|
---|
| 15 | ////////////////////////////////////////////////////////////////////////
|
---|
[2099] | 16 | Toi2toi_Addsp::Toi2toi_Addsp(Info_src* info, int_4 ns)
|
---|
| 17 | : src(info), nb_src(ns)
|
---|
[2095] | 18 | {
|
---|
| 19 | SetEquinox();
|
---|
| 20 | SetCoorIn();
|
---|
| 21 | SetCoorMap();
|
---|
| 22 | SetTestFlag();
|
---|
| 23 | SetTestMin();
|
---|
| 24 | SetTestMax();
|
---|
| 25 |
|
---|
| 26 | }
|
---|
| 27 |
|
---|
[2099] | 28 | Toi2toi_Addsp::~Toi2toi_Addsp()
|
---|
[2095] | 29 | {
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | ////////////////////////////////////////////////////////////////////////
|
---|
[2099] | 33 | void Toi2toi_Addsp::Print(::ostream & os)
|
---|
[2095] | 34 | {
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | ////////////////////////////////////////////////////////////////////////
|
---|
[2099] | 38 | void Toi2toi_Addsp::init() {
|
---|
| 39 | cout << "Toi2toi_Addsp::init" << endl;
|
---|
| 40 | declareInput("BoloIn");
|
---|
[2095] | 41 | declareInput("Coord1In");
|
---|
| 42 | declareInput("Coord2In");
|
---|
| 43 | declareInput("utc");
|
---|
| 44 | declareInput("lon");
|
---|
| 45 | declareInput("lat");
|
---|
| 46 |
|
---|
[2102] | 47 | declareOutput("BoloOut");
|
---|
[2095] | 48 | }
|
---|
| 49 |
|
---|
| 50 | ////////////////////////////////////////////////////////////////////////
|
---|
[2099] | 51 | void Toi2toi_Addsp::run()
|
---|
[2095] | 52 | {
|
---|
| 53 | long snb = getMinIn();
|
---|
| 54 | long sne = getMaxIn();
|
---|
| 55 |
|
---|
| 56 | if(snb>sne) {
|
---|
[2099] | 57 | cout<<"Toi2toi_Addsp::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
|
---|
| 58 | throw ParmError("Toi2toi_Addsp::run() - Bad sample interval");
|
---|
[2095] | 59 | }
|
---|
| 60 | if(!checkInputTOIIndex(0) || !checkInputTOIIndex(1) || !checkInputTOIIndex(2)) {
|
---|
[2099] | 61 | cout<<"Toi2toi_Addsp::run() - Input TOI (Coord1In or Coord2In or BoloIn) not connected! "<<endl;
|
---|
| 62 | throw ParmError("Toi2toi_Addsp::run() Output TOI (Coord1In or Coord2In or BoloIn) not connected!");
|
---|
[2095] | 63 | }
|
---|
| 64 | if( !(mTypCoorIn&TypCoordEq || mTypCoorIn&TypCoordGal) ) {
|
---|
[2099] | 65 | cout<<"Toi2toi_Addsp::run() - Input Coordinates not Eq or Gal! "<<endl;
|
---|
| 66 | throw ParmError("Toi2toi_Addsp::run() - Input Coordinates not Eq or Gal!");
|
---|
[2095] | 67 | }
|
---|
| 68 | if( !(mTypCoorMap&TypCoordEq || mTypCoorMap&TypCoordGal) ) {
|
---|
[2099] | 69 | cout<<"Toi2toi_Addsp::run() - Output Coordinates not Eq or Gal! "<<endl;
|
---|
| 70 | throw ParmError("Toi2toi_Addsp::run() - Output Coordinates not Eq or Gal!");
|
---|
[2095] | 71 | }
|
---|
| 72 |
|
---|
| 73 | //---------------------------------------------------------
|
---|
| 74 | #define NFILL 25
|
---|
| 75 | try {
|
---|
| 76 |
|
---|
| 77 | double mjd = MJDfrYear(mActualYear);
|
---|
| 78 |
|
---|
[2099] | 79 | cout<<"Toi2toi_Addsp::run() from "<<snb<<" to "<<sne;
|
---|
[2095] | 80 |
|
---|
| 81 | for(int s=snb;s<=sne;s++) {
|
---|
| 82 | uint_8 fgbolo = 0;
|
---|
[2099] | 83 | double bolo,bolo_sp,coord1,coord2;
|
---|
[2095] | 84 | // Equatoriales / Galactiques
|
---|
| 85 | // coord1,2 = alpha,delta / gLon,gLat
|
---|
| 86 |
|
---|
[2099] | 87 | getData(0,s,bolo,fgbolo);
|
---|
| 88 | coord1 = getData(1,s);
|
---|
| 89 | coord2 = getData(2,s);
|
---|
[2095] | 90 |
|
---|
| 91 | // Comme il n'y a pas de toi en sortie, il faut dire
|
---|
| 92 | // aux processeur/toi que l'on a plus besoin des donnees.
|
---|
| 93 | if (s%100 == 0) wontNeedBefore(s-1);
|
---|
| 94 | if(mTFlag && fgbolo&mBadFlag) continue;
|
---|
| 95 | if(mTMin && bolo<mValMin) continue;
|
---|
| 96 | if(mTMax && bolo>mValMax) continue;
|
---|
| 97 |
|
---|
| 98 | // sphere phi entre [0,2*Pi] en radians
|
---|
| 99 | // sphere theta entre [0,Pi] en radians
|
---|
| 100 | double phi=-1.;
|
---|
| 101 | CoordConvertToStd(mTypCoorIn,&coord1,&coord2);
|
---|
| 102 |
|
---|
| 103 | if(mTypCoorIn&TypCoordEq && mTypCoorMap&TypCoordGal) { // Eq -> Gal
|
---|
| 104 | EqtoGal(mjd,coord1,coord2,&coord1,&coord2);
|
---|
| 105 | phi = coord1 * Pi/180.;
|
---|
| 106 | } else if(mTypCoorIn&TypCoordGal && mTypCoorMap&TypCoordEq) { // Gal -> Eq
|
---|
| 107 | GaltoEq(mjd,coord1,coord2,&coord1,&coord2);
|
---|
| 108 | phi = coord1 * Pi/12.;
|
---|
| 109 | } else if(mTypCoorMap&TypCoordGal) { // Gal -> Gal
|
---|
| 110 | phi = coord1 * Pi/180.;
|
---|
| 111 | } else if(mTypCoorMap&TypCoordEq) { // Eq -> Eq
|
---|
| 112 | phi = coord1 * Pi/12.;
|
---|
| 113 | }
|
---|
| 114 | ToCoLat(&coord2,TypUniteD);
|
---|
[2099] | 115 | bolo_sp=bolo;
|
---|
| 116 |
|
---|
[2095] | 117 | putData(0,s,bolo_sp,fgbolo);
|
---|
| 118 |
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 |
|
---|
[2099] | 122 | cout<<"Toi2toi_Addsp::run(): Fin de boucle sur les sampleNum"<<endl;
|
---|
[2095] | 123 |
|
---|
| 124 |
|
---|
| 125 | //---------------------------------------------------------
|
---|
| 126 | } catch (PException & exc) {
|
---|
[2099] | 127 | cout<<"Toi2toi_Addsp: Catched Exception "<<(string)typeid(exc).name()
|
---|
[2095] | 128 | <<"\n .... Msg= "<<exc.Msg()<<endl;
|
---|
| 129 | }
|
---|
| 130 |
|
---|
[2099] | 131 | return;
|
---|
[2095] | 132 | }
|
---|
[2102] | 133 |
|
---|
| 134 | //--------------------------------------------------------------------
|
---|
| 135 | //--------------------------------------------------------------------
|
---|
| 136 | //--------------------------------------------------------------------
|
---|
| 137 | //--------------------------------------------------------------------
|
---|
| 138 | //--------------------------------------------------------------------
|
---|
| 139 | //--------------------------------------------------------------------
|
---|
| 140 | void Fill_Info_scr(Info_src* scr, int_4 ns)
|
---|
| 141 | {
|
---|
| 142 | for (int i=0; i<ns ; i++){
|
---|
| 143 | scr[i].glon = 80.+i*10.;
|
---|
| 144 | scr[i].glat = 0.;
|
---|
| 145 | scr[i].amp = 1.;
|
---|
| 146 | scr[i].tau1 = 0.5;
|
---|
| 147 | scr[i].tau2 = 0.5;
|
---|
| 148 | }
|
---|
| 149 | }
|
---|