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