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

Last change on this file since 3196 was 3196, checked in by cmv, 18 years ago

les AGN selon C.Jackson, une premiere approche simplifiee, recodage from Jim Rich. cmv 03/04/2007

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