data analysis scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
3.3 KiB

  1. #include <string.h>
  2. #include <string>
  3. #include <TFile.h>
  4. #include <TTree.h>
  5. #include <map>
  6. #include <fstream>
  7. #include <TSystemDirectory.h>
  8. #include <iostream>
  9. using namespace std;
  10. Int_t main(Int_t argc, const char *argv[])
  11. {
  12. const char *dirname = "/mnt/g/HIT/time_aligned/20170508/";
  13. const char *ext = ".csv";
  14. TSystemDirectory dir(dirname, dirname);
  15. TList *files = dir.GetListOfFiles();
  16. if (files)
  17. {
  18. TSystemFile *file;
  19. TString fname;
  20. TIter next(files);
  21. while ((file = (TSystemFile *)next()))
  22. {
  23. fname = file->GetName();
  24. if (!file->IsDirectory() && fname.EndsWith(ext))
  25. {
  26. TString outname = TString(dirname) + fname;
  27. outname.Replace(outname.Length() - 3, 3, TString("root"));
  28. //outfile->cd();
  29. TTree *tree = new TTree("t", "t");
  30. cout << fname << endl;
  31. //192
  32. tree->ReadFile(TString(TString(dirname) + fname), "time/D:event_id:sync_out:sync_in:data_ok:led_voltage:current:ch00:ch01:ch02:ch03:ch04:ch05:ch06:ch07:ch08:ch09:ch10:ch11:ch12:ch13:ch14:ch15:ch16:ch17:ch18:ch19:ch20:ch21:ch22:ch23:ch24:ch25:ch26:ch27:ch28:ch29:ch30:ch31:ch32:ch33:ch34:ch35:ch36:ch37:ch38:ch39:ch40:ch41:ch42:ch43:ch44:ch45:ch46:ch47:ch48:ch49:ch50:ch51:ch52:ch53:ch54:ch55:ch56:ch57:ch58:ch59:ch60:ch61:ch62:ch63:ch64:ch65:ch66:ch67:ch68:ch69:ch70:ch71:ch72:ch73:ch74:ch75:ch76:ch77:ch78:ch79:ch80:ch81:ch82:ch83:ch84:ch85:ch86:ch87:ch88:ch89:ch90:ch91:ch92:ch93:ch94:ch95:ch96:ch97:ch98:ch99:ch100:ch101:ch102:ch103:ch104:ch105:ch106:ch107:ch108:ch109:ch110:ch111:ch112:ch113:ch114:ch115:ch116:ch117:ch118:ch119:ch120:ch121:ch122:ch123:ch124:ch125:ch126:ch127:ch128:ch129:ch130:ch131:ch132:ch133:ch134:ch135:ch136:ch137:ch138:ch139:ch140:ch141:ch142:ch143:ch144:ch145:ch146:ch147:ch148:ch149:ch150:ch151:ch152:ch153:ch154:ch155:ch156:ch157:ch158:ch159:ch160:ch161:ch162:ch163:ch164:ch165:ch166:ch167:ch168:ch169:ch170:ch171:ch172:ch173:ch174:ch175:ch176:ch177:ch178:ch179:ch180:ch181:ch182:ch183:ch184:ch185:ch186:ch187:ch188:ch189:ch190:ch191", '\t');
  33. //128
  34. //tree->ReadFile(TString(TString(dirname) + file->GetName()), "time/D:event_id:sync_out:sync_in:data_ok:led_voltage:current:ch00:ch01:ch02:ch03:ch04:ch05:ch06:ch07:ch08:ch09:ch10:ch11:ch12:ch13:ch14:ch15:ch16:ch17:ch18:ch19:ch20:ch21:ch22:ch23:ch24:ch25:ch26:ch27:ch28:ch29:ch30:ch31:ch32:ch33:ch34:ch35:ch36:ch37:ch38:ch39:ch40:ch41:ch42:ch43:ch44:ch45:ch46:ch47:ch48:ch49:ch50:ch51:ch52:ch53:ch54:ch55:ch56:ch57:ch58:ch59:ch60:ch61:ch62:ch63:ch64:ch65:ch66:ch67:ch68:ch69:ch70:ch71:ch72:ch73:ch74:ch75:ch76:ch77:ch78:ch79:ch80:ch81:ch82:ch83:ch84:ch85:ch86:ch87:ch88:ch89:ch90:ch91:ch92:ch93:ch94:ch95:ch96:ch97:ch98:ch99:ch100:ch101:ch102:ch103:ch104:ch105:ch106:ch107:ch108:ch109:ch110:ch111:ch112:ch113:ch114:ch115:ch116:ch117:ch118:ch119:ch120:ch121:ch122:ch123:ch124:ch125:ch126:ch127", '\t');
  35. //64
  36. //tree->ReadFile(TString(TString(dirname) + file->GetName()), "time/D:event_id:sync_out:sync_in:data_ok:led_voltage:current:ch00:ch01:ch02:ch03:ch04:ch05:ch06:ch07:ch08:ch09:ch10:ch11:ch12:ch13:ch14:ch15:ch16:ch17:ch18:ch19:ch20:ch21:ch22:ch23:ch24:ch25:ch26:ch27:ch28:ch29:ch30:ch31:ch32:ch33:ch34:ch35:ch36:ch37:ch38:ch39:ch40:ch41:ch42:ch43:ch44:ch45:ch46:ch47:ch48:ch49:ch50:ch51:ch52:ch53:ch54:ch55:ch56:ch57:ch58:ch59:ch60:ch61:ch62:ch63", '\t');
  37. TFile *outfile = new TFile(outname.Data(), "recreate");
  38. outfile->cd();
  39. tree->Write();
  40. outfile->Close();
  41. //delete tree;
  42. }
  43. }
  44. }
  45. return 0;
  46. }