EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PndFileNameCreator.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PndFileNameCreator.cxx
1 #include "PndFileNameCreator.h"
2 #include "PndStringSeparator.h"
3 #include <sstream>
4 #include <iostream>
5 
6 
8  fFileName(), fExtPar("par"), fExtSim("sim"), fExtDigi("digi"), fExtReco("reco"),
9  fExtTrackF("trackF"), fExtIdealTrackF("idealTrackF"), fExtKalman("kalman"),
10  fExtRiemann("riemann"),fExtCombinedRiemann("combRiemann"),fExtVertex("vertex"),
11  fVerbose(0)
12 {
13 }
14 
16  fFileName(fileName), fExtPar("par"), fExtSim("sim"), fExtDigi("digi"), fExtReco("reco"),
17  fExtTrackF("trackF"), fExtIdealTrackF("idealTrackF"), fExtKalman("kalman"),
18  fExtRiemann("riemann"),fExtCombinedRiemann("combRiemann"),fExtVertex("vertex"),
19  fVerbose(0)
20 {
21 }
22 
23 
24 
25 
26 std::string PndFileNameCreator::GetParFileName(std::string addon, bool cut)
27 {
28  return GetCustomFileName(fExtPar, addon, cut);
29 }
30 
31 std::string PndFileNameCreator::GetSimFileName(std::string addon, bool cut)
32 {
33  return GetCustomFileName(fExtSim, addon, cut);
34 }
35 
36 std::string PndFileNameCreator::GetDigiFileName(std::string addon, bool cut)
37 {
38  return GetCustomFileName(fExtDigi, addon, cut);
39 }
40 
41 std::string PndFileNameCreator::GetRecoFileName(std::string addon, bool cut)
42 {
43  return GetCustomFileName(fExtReco, addon, cut);
44 }
45 
46 std::string PndFileNameCreator::GetTrackFindingFileName(std::string addon, bool cut)
47 {
48  return GetCustomFileName(fExtTrackF, addon, cut);
49 }
50 
51 std::string PndFileNameCreator::GetIdealTrackFindingFileName(std::string addon, bool cut)
52 {
53  return GetCustomFileName(fExtIdealTrackF, addon, cut);
54 }
55 
56 std::string PndFileNameCreator::GetRiemannFileName(std::string addon, bool cut)
57 {
58  return GetCustomFileName(fExtRiemann, addon, cut);
59 }
60 
61 std::string PndFileNameCreator::GetCombinedRiemannFileName(std::string addon, bool cut)
62 {
63  return GetCustomFileName(fExtCombinedRiemann, addon, cut);
64 }
65 
66 
67 std::string PndFileNameCreator::GetKalmanFileName(std::string addon, bool cut)
68 {
69  return GetCustomFileName(fExtKalman, addon, cut);
70 }
71 
72 std::string PndFileNameCreator::GetVertexFileName(std::string addon, bool cut)
73 {
74  return GetCustomFileName(fExtVertex, addon, cut);
75 }
76 
77 // -----------------
78 
79 //std::string PndFileNameCreator::GetParFileName(std::string inputFileName, std::string addon, bool cut)
80 //{
81 // fFileName = inputFileName;
82 // return GetParFileName(addon, cut);
83 //}
84 //
85 //std::string PndFileNameCreator::GetSimFileName(std::string inputFileName, std::string addon, bool cut)
86 //{
87 // fFileName = inputFileName;
88 // return GetSimFileName(addon, cut);
89 //}
90 //
91 //std::string PndFileNameCreator::GetDigiFileName(std::string inputFileName, std::string addon, bool cut)
92 //{
93 // fFileName = inputFileName;
94 // return GetDigiFileName(addon, cut);
95 //}
96 //
97 //std::string PndFileNameCreator::GetRecoFileName(std::string inputFileName, std::string addon, bool cut)
98 //{
99 // fFileName = inputFileName;
100 // return GetRecoFileName(addon, cut);
101 //}
102 //
103 //std::string PndFileNameCreator::GetTrackFindingFileName(std::string inputFileName, std::string addon, bool cut)
104 //{
105 // fFileName = inputFileName;
106 // return GetTrackFindingFileName(addon, cut);
107 //}
108 //
109 //std::string PndFileNameCreator::GetIdealTrackFindingFileName(std::string inputFileName, std::string addon, bool cut)
110 //{
111 // fFileName = inputFileName;
112 // return GetIdealTrackFindingFileName(addon, cut);
113 //}
114 //
115 //std::string PndFileNameCreator::GetKalmanFileName(std::string inputFileName, std::string addon, bool cut)
116 //{
117 // fFileName = inputFileName;
118 // return GetKalmanFileName(addon, cut);
119 //}
120 //
121 //std::string PndFileNameCreator::GetVertexFileName(std::string inputFileName, std::string addon, bool cut)
122 //{
123 // fFileName = inputFileName;
124 // return GetVertexFileName(addon, cut);
125 //}
126 //
127 //std::string PndFileNameCreator::GetRiemannFileName(std::string inputFileName, std::string addon, bool cut)
128 //{
129 // fFileName = inputFileName;
130 // return GetRiemannFileName(addon, cut);
131 //}
132 //
133 //std::string PndFileNameCreator::GetCombinedRiemannFileName(std::string inputFileName, std::string addon, bool cut)
134 //{
135 // fFileName = inputFileName;
136 // return GetCombinedRiemannFileName(addon, cut);
137 //}
138 
139 std::string PndFileNameCreator::GetCustomFileName(std::string ext, std::string addon, bool cut)
140 {
141  std::cout << "Ext: " << ext << " addon: " << addon << " cut: " << cut;
142  std::string result = TruncateFileName(cut);
143  std::cout << " Truncated: " << result << std::endl;
144  if (addon.size() > 0){
145  result += "_";
146  result += addon;
147  }
148  if (ext.size() > 0){
149  result += "_";
150  result += ext;
151  }
152  result += ".root";
153  if(fVerbose>0) std::cout<<" -I- PndFileNameCreator file: "<<result.c_str()<<std::endl;
154  return result;
155 }
156 
157 //std::string PndFileNameCreator::GetCustomFileName(std::string inputFileName, std::string ext, std::string addon, bool cut)
158 //{
159 // fFileName = inputFileName;
160 // return GetCustomFileName(ext, addon, cut);
161 //}
162 
164 {
165  std::string result = ext;
166  result += TruncateInitial();
167 
168  if (fVerbose>0) std::cout << " -I- PndFileNameCreator::GetCustomFileNameInitial: " << result.c_str() << std::endl;
169  return result;
170 }
171 
173 {
174  std::stringstream result;
175  std::vector<std::string> resString;
176 
177  PndStringSeparator pathAna(fFileName,"/");
178  resString = pathAna.GetStringVector();
179  if(fVerbose>1) pathAna.Print();
180  if (fFileName.find("/") == 0)
181  result << "./";
182  for (UInt_t i = 0; i < resString.size()-1; i++){
183  result << resString[i] << "/";
184  }
185  return result.str();
186 }
187 
189 {
190  std::stringstream result;
191  std::vector<std::string> resString;
192 
193  PndStringSeparator pathAna(fFileName,"/");
194  resString = pathAna.GetStringVector();
195 
196  return resString[resString.size()-1];
197 }
198 
200 {
201  std::vector<std::string> resString;
202  std::stringstream result;
203  std::string path, name;
204  Int_t cutLast = 0;
205 
206 
207  path = GetPath();
208  name = GetFileName();
209  //if(fVerbose>1) std::cout << "Path: " << path << " FileName: " << name << std::endl;
210  result.str("");
211 
212  PndStringSeparator stringAna(name, "._");
213  resString = stringAna.GetStringVector();
214  //if(fVerbose>1) stringAna.Print();
215 
216  if (cut == true)
217  cutLast = 2;
218  else cutLast = 1;
219 
220  if (resString[resString.size()-1] != "root")
221  cutLast--;
222 
223  if (resString.size() - cutLast <= 0)
224  return "";
225 
226  result << path;
227  for (UInt_t i = 0; i < resString.size()-1 - cutLast; i++){
228  result << resString[i] << "_";
229  }
230  result << resString[resString.size()-1 - cutLast];
231  return result.str();
232 }
233 
235 {
236  std::vector<std::string> resString;
237  std::stringstream result;
238  std::string path, name;
239 
240  path = GetPath();
241  name = GetFileName();
242 
243  PndStringSeparator stringAna(name, "._");
244  resString = stringAna.GetStringVector();
245 
246  for (UInt_t i = 1; i < resString.size() - 1; i++){
247  result << "_" << resString[i];
248  }
249  result << ".root";
250  return result.str();
251 }
253