source: Sophya/trunk/Cosmo/SimLSS/agnjackson.cc@ 3662

Last change on this file since 3662 was 3615, checked in by cmv, 16 years ago

Modifs relatives a l'introduction de RandomGeneratorInterface + delete de srandgen.c, cmv 01/05/2009

File size: 2.6 KB
Line 
1#include "sopnamsp.h"
2#include "machdefs.h"
3#include <iostream>
4#include <stdlib.h>
5#include <stdio.h>
6#include <string.h>
7#include <math.h>
8#include <vector>
9
10#include "pexceptions.h"
11
12#include "histos.h"
13#include "srandgen.h"
14
15#include "geneutils.h"
16#include "agnjackson.h"
17
18namespace SOPHYA {
19
20AGNJackson::AGNJackson(void)
21 : nobjang_(0.) , fluxang_(0.) , dndls_(NULL), tirls_(NULL)
22{
23
24 //--- Les valeurs lues sur la courbe de Jackson (from JIM)
25 const int nval = 10;
26 // log10(S en Jy)
27 double x[nval] = {-7.,-6.,-5.,-4.,-3.,-2.,-1.,0.,1.,2.};
28 // S^2.5*dN/dS (en Jy^1.5 /sr)
29 double y[nval] = {0.0035,0.14,0.95,2.5,7.,50.,260.,300.,150.,100.};
30
31 if(sizeof(x)!=sizeof(y) || sizeof(y)!=8*nval) {
32 cout<<"AGNJackson::AGNJackson_Error: incompatible x,y,nval sizes"<<endl;
33 throw SzMismatchError("AGNJackson::AGNJackson_Error: incompatible x,y,nval sizes");
34 }
35
36 xjack_.resize(0); yjack_.resize(0);
37 for(int i=0;i<nval;i++)
38 {xjack_.push_back(x[i]); yjack_.push_back(y[i]);}
39
40 // On cree l'histo: dndls = dN/dlog10(S) en fct de log10(S en Jy)
41 int nbin = nval*20;
42 double xmin = x[0], xmax=x[nval-1];
43 dndls_ = new Histo(xmin,xmax,nbin);
44 dndls_->Zero();
45
46 // On remplit les histos
47 // yjack_ = S^2.5 * dN/dS (en Jy^1.5 /sr) en fct de xjack_ = log10(S en Jy)
48 // dndls: dN/dlog10(S) (en 1/log10(Jy)/sr) en fct de log10(S en Jy)
49 // avec dN/dlog10(S) = dN/dS * dS/dlog10(S)
50 // = (S^2.5*dN/dS)*S^(-2.5) * (ln(10)*S)
51 // On va interpoler en log(dN/dlog10(S)) versus log10(S)
52 vector<double> Y;
53 for(int i=0;i<nval;i++) {
54 double v = yjack_[i]*pow(10.,-1.5*xjack_[i])*M_LN10;
55 Y.push_back(log(v));
56 }
57 for(int i=0;i<nbin;i++) {
58 double lf = dndls_->BinCenter(i);
59 // Interpolation lineaire (parabolic not OK!)
60 double v = InterpTab(lf,xjack_,Y,1);
61 (*dndls_)(i) = exp(v);
62 }
63
64 // On remplit la fonction de tirage
65 tirls_ = new FunRan(*dndls_,true);
66
67 // On calcul le nombre moyen d'AGN et le flux moyen par sr
68 // ATTENTION: dn/dlog10(S) en fct de log10(s)
69 nobjang_ = fluxang_ = 0.;
70 for(int i=0;i<nbin;i++) {
71 double lf = dndls_->BinCenter(i);
72 nobjang_ += (*dndls_)(i);
73 fluxang_ += (*dndls_)(i)*pow(10.,lf);
74 }
75 nobjang_ *= dndls_->BinWidth();
76 fluxang_ *= dndls_->BinWidth();
77
78}
79
80AGNJackson::~AGNJackson(void)
81{
82 if(dndls_!=NULL) delete dndls_;
83 if(tirls_!=NULL) delete tirls_;
84}
85
86void AGNJackson::Print(void)
87{
88 cout<<"AGNJackson::Print: nobj="<<nobjang_
89 <<" /sr, flux="<<fluxang_<<" Jy/sr"<<endl;
90 dndls_->Show();
91}
92
93void AGNJackson::OrigJack(vector<double>& xjack,vector<double>& yjack)
94{
95 xjack = xjack_;
96 yjack = yjack_;
97}
98
99} // Fin namespace SOPHYA
Note: See TracBrowser for help on using the repository browser.