#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main()
{
	char fileout[20], fileout2[20], num[10];
	ofstream stream3,stream4;
    FILE *runname;
    
    // reading run number from file
    runname = fopen("/home/user/re4data/TDC/run","r");
    fscanf (runname, "%s\n", &num);
    fclose(runname);
    
    strcpy(fileout,"/srv/www/htdocs/dqm/");
    strcat(fileout,num);
	strcat(fileout,"f.html");
	//cout << fileout << endl;
    
	stream3.open(fileout);
    
	//Writing into the file
    
	stream3 << " <html> " << endl;
	stream3 << " <head> " << endl;
	stream3 << " <meta http-equiv=""Content-Type""  " << endl;
	stream3 << " content=""text/html; charset=iso-8859-1"">  " << endl;
	stream3 << " <title>Run " << num << " </title> " << endl;
	stream3 << " </head>  " << endl;
    
	stream3 << "  <frameset rows=""15%,85%"" frameborder=""no""> " << endl;
	stream3 << " <frame src=""http://cms904cr1/cgi-bin/dqm""> " << endl;
	stream3 << " <frame src=""http://cms904cr1/dqm/"<< num <<".html""> " << endl;
	stream3 << "</frameset> " << endl;
	stream3 << "</html>"  << endl;
	stream3.close();
    
    
    strcpy(fileout2,"/srv/www/htdocs/dqm/");
    strcat(fileout2,num);
	strcat(fileout2,".html");
    //cout << fileout2 << endl;
    
	stream4.open(fileout2);
    
	stream4 << "<html> " << endl;
    
	stream4 << "<head> " << endl;
	stream4 << "<meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1""> " << endl;
	stream4 << "<title>Run " << num << " </title> " << endl;
	stream4 << "</head> " << endl;
    
	stream4 << "<body> " << endl;
	stream4 << "<p align=""center"">&nbsp;</p> " << endl;
	stream4 << "<div align=""center""><center> " << endl;
	stream4 << "<table border=""0""> " << endl;
    
    stream4 << "<tr> " << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "stripprofile1.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "noisestripprofile1.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeA1.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeB1.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeC1.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustermultiplicity1.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "hitmultiplicity1.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << "</tr> " << endl;
    
    stream4 << "<tr> " << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "stripprofile2.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "noisestripprofile2.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeA2.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeB2.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeC2.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustermultiplicity2.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "hitmultiplicity2.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << "</tr> " << endl;
    
    stream4 << "<tr> " << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "stripprofile3.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "noisestripprofile3.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeA3.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeB3.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeC3.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustermultiplicity3.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "hitmultiplicity3.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << "</tr> " << endl;
    
    stream4 << "<tr> " << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "stripprofile4.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "noisestripprofile4.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeA4.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeB4.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeC4.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustermultiplicity4.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "hitmultiplicity4.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << "</tr> " << endl;
    
    stream4 << "<tr> " << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "stripprofile5.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "noisestripprofile5.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeA5.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeB5.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeC5.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustermultiplicity5.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "hitmultiplicity5.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << "</tr> " << endl;
    
    stream4 << "<tr> " << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "stripprofile6.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "noisestripprofile6.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeA6.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeB6.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeC6.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustermultiplicity6.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "hitmultiplicity6.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << "</tr> " << endl;
    
    stream4 << "<tr> " << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "stripprofile7.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "noisestripprofile7.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeA7.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeB7.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeC7.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustermultiplicity7.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "hitmultiplicity7.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << "</tr> " << endl;
    
    stream4 << "<tr> " << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "stripprofile8.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "noisestripprofile8.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeA8.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeB8.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeC8.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustermultiplicity8.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "hitmultiplicity8.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << "</tr> " << endl;
    
    stream4 << "<tr> " << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "stripprofile9.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "noisestripprofile9.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeA9.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeB9.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeC9.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustermultiplicity9.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "hitmultiplicity9.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << "</tr> " << endl;
    
    stream4 << "<tr> " << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "stripprofile10.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "noisestripprofile10.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeA10.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeB10.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustersizeC10.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "clustermultiplicity10.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << " <td><img src=""http://cms904cr1/dqm/plot/" << num << "hitmultiplicity10.gif"" alt=""run_not_yet_analyzed"" width=""600"" height=""360"">" << endl;
    stream4 << "</tr> " << endl;
    
    stream4.close();
}
