Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
List2RootEBBH.C
Go to the documentation of this file.
1 // Convert eBBH parms file list to a root file which contains the eBBH waveforms.
2 
3 void
5 
6  if(!ifName.EndsWith(".lst")) {
7  cout << "List2RootEBBH - bad file extension : " << ifName << endl;
8  cout << "Extention must be .lst" << endl;
9  gSystem->Exit(1);
10  }
11 
12  // the distance of source is G*M/c^2 meters
14  double M = watconstants::SolarMass();
16  double pc = watconstants::Parsec();
17  double distance_source_Kpc = G*M/(c*c)/pc/1.e3;
18 
19  TString ofName = ifName;
20  ofName.ReplaceAll(".lst",".root");
21 
22  TFile efile(ofName,"RECREATE");
23 
24  int id;
25  double m1,m2,rp0,e0;
28 
29  TTree etree("ebbh","ebbh");
30  etree.Branch("id",&id,"id/I");
31  etree.Branch("m1",&m1,"m1/D");
32  etree.Branch("m2",&m2,"m2/D");
33  etree.Branch("rp0",&rp0,"rp0/D");
34  etree.Branch("e0",&e0,"e0/D");
35  etree.Branch("hp","wavearray<double>",&hp,32000,0);
36  etree.Branch("hx","wavearray<double>",&hx,32000,0);
37 
38  ifstream in;
39  in.open(ifName,ios::in);
40  if (!in.good()) {cout << "List2RootEBBH - Error Opening File : " << ifName << endl;exit(1);}
41 
42  // get number of entries
43  int entries=0;
44  char str[1024];
45  while(true) {
46  in.getline(str,1024);
47  if (!in.good()) break;
48  if(str[0] != '#') entries++;
49  }
50  cout << "entries " << entries << endl;
51  in.clear(ios::goodbit);
52  in.seekg(0, ios::beg);
53 
54  int fpos=0;
55  while (1) {
56  fpos=in.tellg();
57  in.getline(str,1024);
58  if(str[0] == '#') continue;
59  if (!in.good()) break;
60 
61  std::stringstream linestream(str);
62  if(!(linestream >> id >> m1 >> m2 >> rp0 >> e0)) {
63  cout << "List2RootEBBH - Wrong Format for File : " << ifName << endl;
64  cout << "input line : " << endl;
65  cout << str << endl;
66  cout << "must be : " << endl;
67  cout << "event# " << " m1 " << " m2 " << " rp0 " << " e0 " << endl;
68  exit(1);
69  }
70 
71  cout << "Create eBBH with parms : " << id << " " << m1 << " " << m2 << " " << rp0 << " " << e0 << " " << endl;
72  getEBBH(m1,m2,rp0,e0,*hp,*hx);
73 
74  // rescale hp,hx to 10 Kpc
75  (*hp)*=distance_source_Kpc/10.;
76  (*hx)*=distance_source_Kpc/10.;
77 
78  etree.Fill();
79  }
80 
81  in.close();
82 
83  etree.Write();
84  efile.Close();
85 
86  gSystem->Exit(0);
87 }
double pc
Definition: DrawEBHH.C:15
TString ofName
void List2RootEBBH(TString ifName)
Definition: List2RootEBBH.C:4
TString("c")
double SolarMass()
Definition: constants.hh:184
wavearray< double > hp
Definition: DrawInspiral.C:43
#define M
Definition: UniqSLagsList.C:3
char str[1024]
double G
Definition: DrawEBHH.C:12
wavearray< double > hx
Definition: DrawInspiral.C:44
m1
Definition: cbc_plots.C:606
double Parsec()
Definition: constants.hh:188
double GravitationalConstant()
Definition: constants.hh:113
double e0
Definition: RescaleEBBH.C:17
ifstream in
int getEBBH(double m1, double m2, double rmin0, double e0, wavearray< double > &Hp, wavearray< double > &Hx, double t_end)
Definition: eBBH.cc:53
double distance_source_Kpc
Definition: DrawEBHH.C:16
Long_t id
double rp0
Definition: RescaleEBBH.C:16
exit(0)
double SpeedOfLightInVacuo()
Definition: constants.hh:96
m2
Definition: cbc_plots.C:607