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