forked from SiWECAL-TestBeam/SiWECAL-TB-analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConvertDirectory.cc
56 lines (50 loc) · 1.28 KB
/
ConvertDirectory.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "TSystemDirectory.h"
#include "TCanvas.h"
#include "TROOT.h"
#include "TGraph.h"
#include "TF1.h"
#include "TLatex.h"
#include <sstream>
#include <iostream>
#include <fstream>
#include "RAW2ROOT.cc"
using namespace std;
// fonction qui fait la liste de tous les fichiers *by_dif0.raw d'un dossier et qui renvoie la liste sous filenames. Écrit par Floris Thiant (LLR).
vector<TString>* list_files(const char *dirname, const char *ext=".raw")
{
TSystemDirectory dir(dirname, dirname);
TList* files = dir.GetListOfFiles();
vector<TString>* filenames = new vector<TString>();
if (files)
{
TSystemFile *file;
TString fname;
TIter next(files);
while ((file=(TSystemFile*)next()))
{
fname = file->GetName();
if (!file->IsDirectory() && fname.EndsWith(ext))
{
filenames->push_back(dirname+fname);
}
}
}
return filenames;
}
void ConvertDirectory(string dirname,const char *ext=".raw", int bcidthres=15)
{
vector<TString>* filenames = list_files(dirname.c_str(),ext);
RAW2ROOT *ss;
unsigned int nbCrb = filenames->size();
for (int i = 0 ; i<nbCrb ; i++)
{
ss = new RAW2ROOT();
ss->ReadFile((*filenames)[i], true, bcidthres);
delete ss;
}
for (int i = 0 ; i<nbCrb ; i++)
{
std::cout << (*filenames)[i] << std::endl;
}
gSystem->Exit(0);
}