00001 #include "TH1F.h" 00002 #include "TFile.h" 00003 #include <iostream> 00004 #include <fstream> 00005 #include <string.h> 00006 #include <stdio.h> 00007 00008 void exportToCSV(char* filename, char* runNumber) { 00009 TFile* theFile = new TFile(filename); 00010 00011 TH1F* s0 = theFile->FindObjectAny("Sensor16Region0LinProfile"); 00012 TH1F* s1 = theFile->FindObjectAny("Sensor16Region1LinProfile"); 00013 TH1F* s2 = theFile->FindObjectAny("Sensor16Region2LinProfile"); 00014 TH1F* s3 = theFile->FindObjectAny("Sensor16Region3LinProfile"); 00015 00016 ofstream myfile; 00017 00018 char name[100]; 00019 strcpy(name, filename); 00020 strcat(name, runNumber); 00021 00022 myfile.open(name); 00023 00024 myfile << s0->GetName() << "\n"; 00025 for (unsigned bins(0); bins < s0->GetNbinsX(); bins++) { 00026 myfile << bins << ", " << s0->GetBinContent(bins) << "\n"; 00027 } 00028 00029 myfile << s1->GetName() << "\n"; 00030 for (unsigned bins(0); bins < s1->GetNbinsX(); bins++) { 00031 myfile << bins << ", " << s1->GetBinContent(bins) << "\n"; 00032 } 00033 00034 myfile << s2->GetName() << "\n"; 00035 for (unsigned bins(0); bins < s2->GetNbinsX(); bins++) { 00036 myfile << bins << ", " << s2->GetBinContent(bins) << "\n"; 00037 } 00038 00039 myfile << s3->GetName() << "\n"; 00040 for (unsigned bins(0); bins < s3->GetNbinsX(); bins++) { 00041 myfile << bins << ", " << s3->GetBinContent(bins) << "\n"; 00042 } 00043 00044 myfile.close(); 00045 }