adstReading.cc
Go to the documentation of this file.
1 #include "adstReading.h"
2 
3 #include <iostream>
4 #include <iomanip>
5 #include <sstream>
6 #include <string>
7 #include <map>
8 
9 #include <TFile.h>
10 #include <TDirectory.h>
11 
12 #include <adst/RecEventFile.h>
13 #include <adst/DetectorGeometry.h>
14 #include <adst/FileInfo.h>
15 #include <adst/RecEvent.h>
16 
17 #include "testlib.h"
18 
19 using namespace std;
20 
22 DetectorGeometry*
23 readDetectorGeometry(const RecEventFile& file, const std::string& title)
24 {
25  TDirectory* const save = gDirectory;
26 
27  TFile tFile(file.GetActiveFileName().c_str());
28  tFile.cd();
29  DetectorGeometry* thisGeo = (DetectorGeometry*)tFile.Get("detectorGeometry");
30 
31  if (ok(thisGeo != 0, string("detector geometry exists in ") + title + string(" file")))
32  {
33  DetectorGeometry testGeo;
34  try { file.ReadDetectorGeometry(testGeo); }
35  catch (...) {
36  fail(string("Could not read DetectorGeometry from ") + title + string("file"));
37  save->cd();
38  return NULL;
39  }
40  }
41  else {
42  fail(string("Could not read DetectorGeometry from ") + title + string("file"));
43  }
44 
45  save->cd();
46  return thisGeo;
47 }
48 
50 FileInfo*
51 readFileInfo(const RecEventFile& file, const std::string& title)
52 {
53  FileInfo* info = new FileInfo;
54 
55  if (!ok(file.ReadFileInfo(*info) == RecEventFile::eSuccess,
56  string("FileInfo exists in ") + title + string(" file")))
57  {
58  delete info;
59  return NULL;
60  }
61 
62  return info;
63 }
64 
bool ok(bool okay)
Definition: testlib.cc:89
FileInfo * readFileInfo(const RecEventFile &file, const std::string &title)
Definition: adstReading.cc:51
void fail(const std::string &name)
Definition: testlib.cc:83
const string file
DetectorGeometry * readDetectorGeometry(const RecEventFile &file, const std::string &title)
Definition: adstReading.cc:23

, generated on Tue Sep 26 2023.