FairRoot/PandaRoot
PndHypGeReader.cxx
Go to the documentation of this file.
1 //
3 // PndHypGeReader
4 //
5 // Reader of HypGe geometry file (ASCII)
6 //
7 // roginal Author: S.Spataro
8 // modified 15/05/07 by A.Sanchez
9 //
11 
12 #include <iostream>
13 #include <fstream>
14 #include <string>
15 #include "TString.h"
16 #include <algorithm>
17 
18 #include "PndHypGeReader.h"
19 
20 using namespace std;
21 
23 {
24  sName = name;
26 }
27 
29 {g4data.clear();
30 }
31 
33 {
34  fstream f;
35  string str;
36  DataG4 data;
37  int line_nr;
38 
39  f.open(sName.Data(), ios::in);
40  //f.open(sName, ios::in);
41  cout<<sName<<endl;
42  if(!f) {
43  cout<<"PndHypGeReader Error: Data file cannot be open!"<<endl;
44  exit(1);
45  } else
46  {
47  //line_nr = 1;
48  //while(line_nr<=3) {getline(f,str,'\n'); line_nr++;};
49  while(f)
50  {
51  f>>data.crystal>>data.posX>>data.posY>>data.posZ;
52  PndHypGeReader::g4data.push_back(data);
53  };
54  f.close();
55  };
56  f.clear();
57 
58  return;
59 }
60 
61 
62 
64 {
65  DataG4 data;
66 
67  for(unsigned int i=0; i<PndHypGeReader::g4data.size(); i++)
68  {
69  if(crystal==PndHypGeReader::g4data[i].crystal)
70  {
71 
72  data.crystal = PndHypGeReader::g4data[i].crystal;
73 
74  data.posX = PndHypGeReader::g4data[i].posX;
75  data.posY = PndHypGeReader::g4data[i].posY;
76  data.posZ = PndHypGeReader::g4data[i].posZ;
77  //pos.SetXYZ(data.posX, data.posY, data.posZ);
78 
79 
80  };
81  };
82 
83  return data;
84  //return pos;
85 }
86 
87 
Int_t i
Definition: run_full.C:25
exit(0)
int crystal
Definition: PndEmcReader.h:19
PndHypGeReader(TString name)
TFile * f
Definition: bump_analys.C:12
vector< DataG4 > g4data
TString name
double posX
Definition: PndEmcReader.h:21
double posZ
Definition: PndEmcReader.h:21
double posY
Definition: PndEmcReader.h:21
DataG4 GetData(int crystal)