39 cerr <<
"Add amplitude files with a phase between and a branching ratio." << endl;
40 cerr <<
"usage single amp mode:" << endl;
41 cerr <<
" " << prog <<
" inputfile1 inputfile2 outputfile [phase [ratio]]" << endl;
42 cerr <<
"usage multiple amp mode:" << endl;
43 cerr <<
" " << prog <<
" filelist <backup dir>" << endl;
44 cerr <<
" filelist format: " << endl;
45 cerr <<
" <file1>" << endl;
46 cerr <<
" <file2>" << endl;
47 cerr <<
" <outfile>" << endl;
48 cerr <<
" <phase>" << endl;
49 cerr <<
" <amplitude ratio>" <<endl;
53 int main(
int argc,
char** argv)
56 vector<string> file1v;
57 vector<string> file2v;
58 vector<string> outfilev;
59 vector<double> phasev;
60 vector<double> branchv;
61 string backupDir(
"./");
65 ifstream flist(argv[1]);
69 flist.getline(f1,200);
71 flist.getline(f2,200);
73 flist.getline(f3,200);
77 outfilev.push_back(f3);
82 if(
string(ph)==
"pi")p=3.14159592654;
89 branchv.push_back(atof(br));
92 else if (argc > 3 && argc <= 6) {
93 file1v.push_back(argv[1]);
94 file2v.push_back(argv[2]);
95 outfilev.push_back(argv[3]);
98 if (
string(argv[4]) ==
"pi")
99 phase = 3.14159592654;
101 phase = atof(argv[4]);
102 phasev.push_back(phase);
107 branchv.push_back(atof(argv[5]));
109 branchv.push_back(1);
118 unsigned int n=file1v.size();
119 cerr << n <<
" amplitudes in list" << endl;
120 for(
unsigned int i=0;
i<
n;++
i){
125 file1.open(file1v[
i].c_str());
126 cout << file1v[
i] << endl;
128 cerr <<
"*** Cannot open inputfile! Skipping!" << endl;
131 cout << file2v[
i] << endl;
133 file2.open(file2v[
i].c_str());
135 cerr <<
"*** Cannot open inputfile! Skipping!" << endl;
139 if(outfilev[
i]==file1v[
i] || outfilev[
i]==file2v[
i]){
140 cerr <<
"Overwriting of files not allowed! Skipping" << endl;
144 ofstream out(outfilev[i].c_str());
146 cout <<
"Phase=" <<phasev[
i] <<
" Br=" << branchv[
i] << endl;
147 cout <<
"---> " << outfilev[
i] << endl;
152 complex<double> phase(1,0);
153 double phi=phasev[
i];
154 phase.real()=cos(phi);
155 phase.imag()=sin(phi);
161 while (file1.read((
char*) &a1,
sizeof(complex<double>))){
163 file2.read((
char*) &a2,
sizeof(a2));
164 amp=1./sqrt(1+R)*(a1+R*phase*a2);
165 out.write((
char*)&,
sizeof(amp));
173 if (backupDir !=
"./") {
175 com.append(file1v[i].c_str());
177 com.append(backupDir);
178 int ret = system(com.c_str());
180 cerr <<
"command '" << com <<
"' was not successful." << endl;
183 com.append(file2v[i].c_str());
185 com.append(backupDir);
186 ret = system(com.c_str());
188 cerr <<
"command '" << com <<
"' was not successful." << endl;