| [3308] | 1 | /*
 | 
|---|
 | 2 | - Creation de NTuple et de courbes de lumieres:
 | 
|---|
 | 3 | nbsreadu_squel fichier.dataccd -prt 1 \
 | 
|---|
 | 4 |            -mc 2 -u0 0.01,0.5 -t0 1,-1,-1 -tau 2,10,-1 -tf 2,0,2 -bl 1
 | 
|---|
 | 5 | */
 | 
|---|
 | 6 | #include "sopnamsp.h"
 | 
|---|
 | 7 | #include "machdefs.h"
 | 
|---|
 | 8 | #include <iostream>
 | 
|---|
 | 9 | #include <stdlib.h>
 | 
|---|
 | 10 | #include <math.h>
 | 
|---|
 | 11 | #include <stdio.h>
 | 
|---|
 | 12 | #include <string.h>
 | 
|---|
 | 13 | 
 | 
|---|
 | 14 | #include "fsvcache.h"
 | 
|---|
 | 15 | #include "fsvst.h"
 | 
|---|
 | 16 | #include "fmath.h"
 | 
|---|
 | 17 | #include "nbmath.h"
 | 
|---|
 | 18 | #include "nbrandom.h"
 | 
|---|
 | 19 | #include "nbsread.h"
 | 
|---|
 | 20 | #include "nbgene.h"
 | 
|---|
 | 21 | 
 | 
|---|
 | 22 | #include "ntuple.h"
 | 
|---|
 | 23 | #include "tvector.h"
 | 
|---|
 | 24 | 
 | 
|---|
 | 25 | POutPersist *pos_ = NULL;
 | 
|---|
 | 26 | NTuple *ntsti_[2] = {NULL,NULL};
 | 
|---|
 | 27 | 
 | 
|---|
 | 28 | /*================================================================*/
 | 
|---|
 | 29 | void UINIT(void)
 | 
|---|
 | 30 | {
 | 
|---|
 | 31 |  printf("UINIT\n");
 | 
|---|
 | 32 |  pos_ = new POutPersist("nbsread_ppf.ppf");
 | 
|---|
 | 33 | }
 | 
|---|
 | 34 | 
 | 
|---|
 | 35 | /*=================== ============================================*/
 | 
|---|
 | 36 | void UDATCLEAN(int coul)
 | 
|---|
 | 37 | /*
 | 
|---|
 | 38 |   Attention ici coul = 1,2
 | 
|---|
 | 39 |     donc pour tuer une image pour la couleur coul:
 | 
|---|
 | 40 |     date[coul-1][...] = GRAND2;
 | 
|---|
 | 41 | */
 | 
|---|
 | 42 | {
 | 
|---|
 | 43 |  int ic = coul - 1;
 | 
|---|
 | 44 |  cout<<"UDATCLEAN: couleur "<<coul<<", indice tableau "<<ic<<endl;
 | 
|---|
 | 45 |  if(nmes[ic]<=0) return;
 | 
|---|
 | 46 | 
 | 
|---|
 | 47 |  TVector<r_8> vdate(nmes[ic]); vdate = 0;
 | 
|---|
 | 48 |  for(int i=0;i<nmes[ic];i++) {
 | 
|---|
 | 49 |    vdate(i) = date[ic][i];
 | 
|---|
 | 50 |    if(date[ic][i]<0.)  date[ic][i] = GRAND2;
 | 
|---|
 | 51 |    if(timeu[ic][i].FgCalib<=0) date[ic][i] = GRAND2;
 | 
|---|
 | 52 |  }
 | 
|---|
 | 53 | 
 | 
|---|
 | 54 |  char str[16]; sprintf(str,"date%d",ic);
 | 
|---|
 | 55 |  pos_->PutObject(vdate,str);
 | 
|---|
 | 56 | 
 | 
|---|
 | 57 | }
 | 
|---|
 | 58 | 
 | 
|---|
 | 59 | /*================================================================*/
 | 
|---|
 | 60 | void UINITCCD(void)
 | 
|---|
 | 61 | {
 | 
|---|
 | 62 |  printf("UINITCCD: Debut de l'etude du CCD %d %d\n",numccd,ccdnum);
 | 
|---|
 | 63 | 
 | 
|---|
 | 64 |  // Fill TimeInfoU into NTuple
 | 
|---|
 | 65 |  const int nxtn = 12;
 | 
|---|
| [3572] | 66 |  const char *nament[nxtn] =
 | 
|---|
| [3308] | 67 |    {"ts","texp","fd","sfd","sx","sy","rho","dx","dy","absor","amass","fgcal"};
 | 
|---|
 | 68 |  r_8 xnt[nxtn];
 | 
|---|
 | 69 |  NTuple nttinf(nxtn,nament);
 | 
|---|
 | 70 |  
 | 
|---|
 | 71 |  for(int ic=0;ic<NCOULMX;ic++) {
 | 
|---|
 | 72 |    if(nmesure[ic]<=0) continue;
 | 
|---|
 | 73 |    NTuple nttinf(nxtn,nament);
 | 
|---|
 | 74 |    for(int j=0;j<nmesure[ic];j++) {
 | 
|---|
 | 75 |      int i = indexu[ic][j];
 | 
|---|
 | 76 |      xnt[0] = timeu[ic][i].TStart/86400.;
 | 
|---|
 | 77 |      xnt[1] = timeu[ic][i].Expose;
 | 
|---|
 | 78 |      xnt[2] = timeu[ic][i].Fond;
 | 
|---|
 | 79 |      xnt[3] = timeu[ic][i].SigFond;
 | 
|---|
 | 80 |      xnt[4] = timeu[ic][i].SigX;
 | 
|---|
 | 81 |      xnt[5] = timeu[ic][i].SigY;
 | 
|---|
 | 82 |      xnt[6] = timeu[ic][i].Rho;
 | 
|---|
 | 83 |      xnt[7] = timeu[ic][i].DelX;
 | 
|---|
 | 84 |      xnt[8] = timeu[ic][i].DelY;
 | 
|---|
 | 85 |      xnt[9] = timeu[ic][i].Absorption;
 | 
|---|
 | 86 |      xnt[10] = timeu[ic][i].AirMass;
 | 
|---|
 | 87 |      xnt[11] = timeu[ic][i].FgCalib;
 | 
|---|
 | 88 |      nttinf.Fill(xnt);
 | 
|---|
 | 89 |    }
 | 
|---|
 | 90 |    char str[16]; sprintf(str,"tinf%d",ic);
 | 
|---|
 | 91 |    pos_->PutObject(nttinf,str);
 | 
|---|
 | 92 |  }
 | 
|---|
 | 93 | 
 | 
|---|
 | 94 |  // Create NTuple for StarInfo
 | 
|---|
 | 95 |  const int nsti = 12;
 | 
|---|
| [3572] | 96 |  const char *namentsti[nsti] =
 | 
|---|
| [3308] | 97 |    {"net","xref","fmean","fsig","fref","xp","yp","dm","dm2","dm2r","fgref","nbvois"};
 | 
|---|
 | 98 |  for(int ic=0;ic<NCOULMX;ic++) {
 | 
|---|
 | 99 |    cout<<"...Creating NTuple for StarInfo ic="<<ic<<endl;
 | 
|---|
 | 100 |    if(ntsti_[ic] == NULL) delete ntsti_[ic];
 | 
|---|
 | 101 |    ntsti_[ic] = new NTuple(nsti,namentsti);
 | 
|---|
 | 102 |  }
 | 
|---|
 | 103 | 
 | 
|---|
 | 104 | }
 | 
|---|
 | 105 | 
 | 
|---|
 | 106 | /*================================================================*/
 | 
|---|
 | 107 | void UEVT(void)
 | 
|---|
 | 108 | {
 | 
|---|
 | 109 |  printf("****> Et=%d (%d) %d (%d)  fref=%g %g  nmes=%d %d  nmesure=%d %d\n"
 | 
|---|
 | 110 |        ,iet[0],staru[0].XRef,iet[1],staru[1].XRef,staru[0].FluxRef,staru[1].FluxRef
 | 
|---|
 | 111 |        ,nmes[0],nmes[1],nmesure[0],nmesure[1]);
 | 
|---|
 | 112 | 
 | 
|---|
 | 113 |  // Fill StarInfo information into NTuple
 | 
|---|
 | 114 |  for(int ic=0;ic<NCOULMX;ic++) {
 | 
|---|
 | 115 |    if(iet[ic]<=0) continue;   // pas d'etoile associee
 | 
|---|
 | 116 |    int n = ntsti_[ic]->NVar();
 | 
|---|
 | 117 |    if(n<=0) continue;
 | 
|---|
 | 118 |    r_8 *xnt = new r_8[n];
 | 
|---|
 | 119 |    xnt[0] = staru[ic].NumEt;
 | 
|---|
 | 120 |    xnt[1] = staru[ic].XRef;
 | 
|---|
 | 121 |    xnt[2] = staru[ic].FlxMean;
 | 
|---|
 | 122 |    xnt[3] = staru[ic].FlxSig;
 | 
|---|
 | 123 |    xnt[4] = staru[ic].FluxRef;
 | 
|---|
 | 124 |    xnt[5] = staru[ic].XPos;
 | 
|---|
 | 125 |    xnt[6] = staru[ic].YPos;
 | 
|---|
 | 126 |    xnt[7] = staru[ic].DisMin;
 | 
|---|
 | 127 |    xnt[8] = staru[ic].DisM2;
 | 
|---|
 | 128 |    xnt[9] = staru[ic].DisM2R;
 | 
|---|
 | 129 |    xnt[10] = staru[ic].FgRef;
 | 
|---|
 | 130 |    xnt[11] = staru[ic].NbVois;
 | 
|---|
 | 131 |    ntsti_[ic]->Fill(xnt);
 | 
|---|
 | 132 |    delete [] xnt;
 | 
|---|
 | 133 |  }
 | 
|---|
 | 134 | 
 | 
|---|
 | 135 |  // Fill light curve into NTuple
 | 
|---|
 | 136 |  if(FgSelSt==iet[0]) {
 | 
|---|
 | 137 |    cout<<"...Writing light curve for "<<iet[0]<<" "<<iet[1]<<endl;
 | 
|---|
 | 138 | 
 | 
|---|
 | 139 |    const int nxtn = 15;
 | 
|---|
| [3572] | 140 |    const char *nament[nxtn] =
 | 
|---|
| [3308] | 141 |      {"ic",
 | 
|---|
 | 142 |       "ts","fd","sx","sy","rho",
 | 
|---|
 | 143 |       "f","fb","xi2","ef","efb","fdl","s9p","pxm",
 | 
|---|
 | 144 |       "fr"
 | 
|---|
 | 145 |      };
 | 
|---|
 | 146 |    r_8 xnt[nxtn];
 | 
|---|
 | 147 |    NTuple nt(nxtn,nament);
 | 
|---|
 | 148 | 
 | 
|---|
 | 149 |    for(int ic=0;ic<NCOULMX;ic++) {
 | 
|---|
 | 150 |      if(iet[ic]<=0) continue;   // pas d'etoile associee
 | 
|---|
 | 151 |      if(nmesure[ic]<=0) continue;
 | 
|---|
 | 152 |      for(int j=0;j<nmesure[ic];j++) {
 | 
|---|
 | 153 |        int i = indexu[ic][j];
 | 
|---|
 | 154 |        xnt[0] = ic;
 | 
|---|
 | 155 |        xnt[1] = timeu[ic][i].TStart/24.;
 | 
|---|
 | 156 |        xnt[2] = timeu[ic][i].Fond;
 | 
|---|
 | 157 |        xnt[3] = timeu[ic][i].SigX;
 | 
|---|
 | 158 |        xnt[4] = timeu[ic][i].SigY;
 | 
|---|
 | 159 |        xnt[5] = timeu[ic][i].Rho;
 | 
|---|
 | 160 |        xnt[6] = mesu[ic][i].Flux;
 | 
|---|
 | 161 |        xnt[7] = mesu[ic][i].FluxB;
 | 
|---|
 | 162 |        xnt[8] = mesu[ic][i].Xi2;
 | 
|---|
 | 163 |        xnt[9] = mesu[ic][i].ErrFlux;
 | 
|---|
 | 164 |        xnt[10] = mesu[ic][i].ErrFluxB;
 | 
|---|
 | 165 |        xnt[11] = mesu[ic][i].Fond;
 | 
|---|
 | 166 |        xnt[12] = mesu[ic][i].S9Pix;
 | 
|---|
 | 167 |        xnt[13] = mesu[ic][i].PixMax;
 | 
|---|
 | 168 |        xnt[14] = staru[ic].FluxRef;
 | 
|---|
 | 169 |        nt.Fill(xnt);
 | 
|---|
 | 170 |      }
 | 
|---|
 | 171 |    }
 | 
|---|
 | 172 |    if(nt.NEntry()>0) {
 | 
|---|
 | 173 |      char str[64]; sprintf(str,"e%d",iet[0]);
 | 
|---|
 | 174 |      pos_->PutObject(nt,str);
 | 
|---|
 | 175 |    }
 | 
|---|
 | 176 | 
 | 
|---|
 | 177 |  }
 | 
|---|
 | 178 | 
 | 
|---|
 | 179 | }
 | 
|---|
 | 180 | 
 | 
|---|
 | 181 | /*================================================================*/
 | 
|---|
 | 182 | void UENDCCD(void)
 | 
|---|
 | 183 | {
 | 
|---|
 | 184 |  printf("UENDCCD: Fin de l'etude du CCD %d %d\n",numccd,ccdnum);
 | 
|---|
 | 185 |  if(ntsti_[0]->NEntry()>0) pos_->PutObject(*ntsti_[0],"sti0");
 | 
|---|
 | 186 |  if(ntsti_[1]->NEntry()>0) pos_->PutObject(*ntsti_[1],"sti1");
 | 
|---|
 | 187 |  if(ntsti_[0]!=NULL) delete ntsti_[0]; ntsti_[0] = NULL;
 | 
|---|
 | 188 |  if(ntsti_[1]!=NULL) delete ntsti_[1]; ntsti_[1] = NULL;
 | 
|---|
 | 189 | }
 | 
|---|
 | 190 | 
 | 
|---|
 | 191 | /*================================================================*/
 | 
|---|
 | 192 | void UEND(void)
 | 
|---|
 | 193 | {
 | 
|---|
 | 194 |  printf("UEND: Fin du job\n");
 | 
|---|
 | 195 |  if(pos_!=NULL) delete pos_; pos_ = NULL;
 | 
|---|
 | 196 | }
 | 
|---|
 | 197 | 
 | 
|---|
 | 198 | 
 | 
|---|
 | 199 | /*
 | 
|---|
 | 200 | 
 | 
|---|
 | 201 | openppf nbsread_ppf.ppf
 | 
|---|
 | 202 | 
 | 
|---|
 | 203 | zone 1 2
 | 
|---|
 | 204 | n/plot date0.val%n val>0
 | 
|---|
 | 205 | n/plot date1.val%n val>0
 | 
|---|
 | 206 | 
 | 
|---|
 | 207 | #### timeinfo
 | 
|---|
 | 208 | zone 1 2
 | 
|---|
 | 209 | 
 | 
|---|
 | 210 | n/plot tinf0.fd%ts ! ! "circlemarker3 red"
 | 
|---|
 | 211 | n/plot tinf1.fd%ts ! ! "circlemarker3 blue"
 | 
|---|
 | 212 | 
 | 
|---|
 | 213 | n/plot tinf0.sx%ts ! ! "circlemarker3 red"
 | 
|---|
 | 214 | n/plot tinf1.sx%ts ! ! "circlemarker3 blue"
 | 
|---|
 | 215 | 
 | 
|---|
 | 216 | n/plot tinf0.sy%ts ! ! "circlemarker3 red"
 | 
|---|
 | 217 | n/plot tinf1.sy%ts ! ! "circlemarker3 blue"
 | 
|---|
 | 218 | 
 | 
|---|
 | 219 | n/plot tinf0.rho%ts ! ! "circlemarker3 red"
 | 
|---|
 | 220 | n/plot tinf1.rho%ts ! ! "circlemarker3 blue"
 | 
|---|
 | 221 | 
 | 
|---|
 | 222 | n/plot tinf0.dx%ts ! ! "circlemarker3 red"
 | 
|---|
 | 223 | n/plot tinf1.dx%ts ! ! "circlemarker3 blue"
 | 
|---|
 | 224 | 
 | 
|---|
 | 225 | n/plot tinf0.dy%ts ! ! "circlemarker3 red"
 | 
|---|
 | 226 | n/plot tinf1.dy%ts ! ! "circlemarker3 blue"
 | 
|---|
 | 227 | 
 | 
|---|
 | 228 | n/plot tinf0.absor%ts ! ! "circlemarker3 red"
 | 
|---|
 | 229 | n/plot tinf1.absor%ts ! ! "circlemarker3 blue"
 | 
|---|
 | 230 | 
 | 
|---|
 | 231 | n/plot tinf0.amass%ts ! ! "circlemarker3 red"
 | 
|---|
 | 232 | n/plot tinf1.amass%ts ! ! "circlemarker3 blue"
 | 
|---|
 | 233 | 
 | 
|---|
 | 234 | n/plot tinf0.fgcal%ts ! ! "circlemarker3 red"
 | 
|---|
 | 235 | n/plot tinf1.fgcal%ts ! ! "circlemarker3 blue"
 | 
|---|
 | 236 | 
 | 
|---|
 | 237 | #### starinfo
 | 
|---|
 | 238 | zone
 | 
|---|
 | 239 | 
 | 
|---|
 | 240 | n/plot sti0.yp%xp ! ! "nsta red crossmarker5"
 | 
|---|
 | 241 | n/plot sti1.yp%xp  ! ! "nsta blue circlemarker5 same"
 | 
|---|
 | 242 | 
 | 
|---|
 | 243 | n/plot sti0.log10(fref) fref>0 ! ! "red"
 | 
|---|
 | 244 | n/plot sti1.log10(fref) fref>0 ! ! "blue keepbin same"
 | 
|---|
 | 245 | 
 | 
|---|
 | 246 | n/plot sti0.dm xref>0 ! ! "red"
 | 
|---|
 | 247 | n/plot sti1.dm xref>0 ! ! "blue keepbin same"
 | 
|---|
 | 248 | 
 | 
|---|
 | 249 | n/plot sti0.dm2 xref>0 ! ! "red"
 | 
|---|
 | 250 | n/plot sti1.dm2 xref>0 ! ! "blue keepbin same"
 | 
|---|
 | 251 | 
 | 
|---|
 | 252 | n/plot sti0.nbvois ! ! ! "red"
 | 
|---|
 | 253 | n/plot sti1.nbvois ! ! ! "blue keepbin same"
 | 
|---|
 | 254 | 
 | 
|---|
 | 255 | n/plot sti0.dm2%dm xref>0 ! "nsta red crossmarker5"
 | 
|---|
 | 256 | n/plot sti1.dm2%dm  xref>0 ! "nsta blue circlemarker5"
 | 
|---|
 | 257 | 
 | 
|---|
 | 258 | #### light curve
 | 
|---|
 | 259 | set et 2005
 | 
|---|
 | 260 | 
 | 
|---|
 | 261 | zone 1 2
 | 
|---|
 | 262 | n/plot e$et.f%ts ic==0 ! "nsta connectpoints red circlemarker3"
 | 
|---|
 | 263 | n/plot e$et.f%ts ic==1 ! "nsta connectpoints blue circlemarker3"
 | 
|---|
 | 264 | 
 | 
|---|
 | 265 | n/plot e$et.ef%ts ic==0 ! "nsta connectpoints red circlemarker3"
 | 
|---|
 | 266 | n/plot e$et.ef%ts ic==1 ! "nsta connectpoints blue circlemarker3"
 | 
|---|
 | 267 | 
 | 
|---|
 | 268 | n/plot e$et.fb%ts ic==0 ! "nsta connectpoints red circlemarker3"
 | 
|---|
 | 269 | n/plot e$et.fb%ts ic==1 ! "nsta connectpoints blue circlemarker3"
 | 
|---|
 | 270 | 
 | 
|---|
 | 271 | n/plot e$et.efb%ts ic==0 ! "nsta connectpoints red circlemarker3"
 | 
|---|
 | 272 | n/plot e$et.efb%ts ic==1 ! "nsta connectpoints blue circlemarker3"
 | 
|---|
 | 273 | 
 | 
|---|
 | 274 | n/plot e$et.(f-fb)/f%ts ic==0&&f>0 ! "nsta connectpoints red circlemarker3"
 | 
|---|
 | 275 | n/plot e$et.(f-fb)/f%ts ic==1&&f>0 ! "nsta connectpoints blue circlemarker3"
 | 
|---|
 | 276 | 
 | 
|---|
 | 277 | n/plot e$et.fd%ts ic==0 ! "nsta connectpoints red circlemarker3"
 | 
|---|
 | 278 | n/plot e$et.fd%ts ic==1 ! "nsta connectpoints blue circlemarker3"
 | 
|---|
 | 279 | 
 | 
|---|
 | 280 | n/plot e$et.fdl%ts ic==0 ! "nsta connectpoints red circlemarker3"
 | 
|---|
 | 281 | n/plot e$et.fdl%ts ic==1 ! "nsta connectpoints blue circlemarker3"
 | 
|---|
 | 282 | 
 | 
|---|
 | 283 | n/plot e$et.s9p%ts ic==0 ! "nsta connectpoints red circlemarker3"
 | 
|---|
 | 284 | n/plot e$et.s9p%ts ic==1 ! "nsta connectpoints blue circlemarker3"
 | 
|---|
 | 285 | 
 | 
|---|
 | 286 | n/plot e$et.pxm%ts ic==0 ! "nsta connectpoints red circlemarker3"
 | 
|---|
 | 287 | n/plot e$et.pxm%ts ic==1 ! "nsta connectpoints blue circlemarker3"
 | 
|---|
 | 288 | 
 | 
|---|
 | 289 | # Distributions
 | 
|---|
 | 290 | zone
 | 
|---|
 | 291 | 
 | 
|---|
 | 292 | n/plot e$et.fb ic==0
 | 
|---|
 | 293 | n/plot e$et.f ic==0 ! ! "keepbin same red"
 | 
|---|
 | 294 | n/plot e$et.fb ic==1
 | 
|---|
 | 295 | n/plot e$et.f ic==1 ! ! "keepbin same blue"
 | 
|---|
 | 296 | 
 | 
|---|
 | 297 | n/plot e$et.fdl ic==0 ! ! "red"
 | 
|---|
 | 298 | n/plot e$et.fdl ic==1 ! ! "keepbin same blue"
 | 
|---|
 | 299 | 
 | 
|---|
 | 300 | n/plot e$et.s9p ic==0 ! ! "red"
 | 
|---|
 | 301 | n/plot e$et.s9p ic==1 ! ! "keepbin same blue"
 | 
|---|
 | 302 | 
 | 
|---|
 | 303 | n/plot e$et.pxm ic==0 ! ! "red"
 | 
|---|
 | 304 | n/plot e$et.pxm ic==1 ! ! "keepbin same blue"
 | 
|---|
 | 305 | 
 | 
|---|
 | 306 | # Correlations
 | 
|---|
 | 307 | zone
 | 
|---|
 | 308 | 
 | 
|---|
 | 309 | n/plot e$et.f%fb ic==0 ! "red circlemarker3"
 | 
|---|
 | 310 | func x 0 1000 10000 "same"
 | 
|---|
 | 311 | n/plot e$et.f%fb ic==1 ! "blue circlemarker3"
 | 
|---|
 | 312 | func x 0 1000 10000 "same"
 | 
|---|
 | 313 | 
 | 
|---|
 | 314 | n/plot e$et.s9p%fb ic==0 ! "red circlemarker3"
 | 
|---|
 | 315 | func x 0 1000 10000 "same"
 | 
|---|
 | 316 | n/plot e$et.s9p%fb ic==1 ! "blue circlemarker3"
 | 
|---|
 | 317 | func x 0 1000 10000 "same"
 | 
|---|
 | 318 | 
 | 
|---|
 | 319 | n/plot e$et.pxm%fb ic==0 ! "red circlemarker3"
 | 
|---|
 | 320 | func x 0 1000 10000 "same"
 | 
|---|
 | 321 | n/plot e$et.pxm%fb ic==1 ! "blue circlemarker3"
 | 
|---|
 | 322 | func x 0 1000 10000 "same"
 | 
|---|
 | 323 | func x 0 1000 10000 "same"
 | 
|---|
 | 324 | 
 | 
|---|
 | 325 |  */
 | 
|---|