Rooters,
I am still beginners in root,
I posted my problem in the root forum before, and i get some help but i still dont get the target.
this code should be show some results in the terminal, I have to Run it for more than 1000 data files in the same directory. the files in the order as follows:
file-000, file-001, file-003 … file-010, file-011, … file-100, file-101 … and so one.
when in run the code for only one file i just write this line in the terminal
root [0].x Test.C(1)
but now can you show me how can i Run this code, and it have mistakes or not?
void Code(const char *dirname = "/home/Documents/");
{
double lifetime;
TString name;
void* dirp = gSystem->OpenDirectory(dirname);
if (dirp) {
while ((name = gSystem->GetDirEntry(dirp)) != "" ){
if (name.EndsWith(".root")) {
auto Spectra = new TH1F("Area","Area",8192,0,8192);
Code(Spectra, name, lifetime);
Spectra->Draw ();
}
}
}
}
//****************************************************************************
void Code(TH1F* h, string& filename, double lifetime)
{
double d, Channel, Count, Ch1, Count1=0;
string line;
int linenumber=0, i=0;
ifstream inputfile;
ofstream outputfile;
inputfile.open(filename);
outputfile.open("Results1.txt");
while (!inputfile.eof()){
getline(inputfile,line);
linenumber++;
if (linenumber>=12){
inputfile >>d;
h->SetBinContent(linenumber-12, d);
outputfile<<linenumber-12<<" "<<d<<endl;}
if(linenumber>=8192+12)
{break;}}
inputfile.close();
outputfile.close();
inputfile.open("Results1.txt");
while (inputfile >> Channel >> Count){
if ((Channel>=400) && (Channel<=600)){
if (Count1<Count){
Count1=Count;
Ch1=Channel;}
else{}}}
cout<<"Possition 1 "<<Ch1<<endl;
cout<< "With "<<Count1<<endl;
inputfile.close();
remove("Results1.txt");
remove("Results2.txt");
}