FairRoot/PandaRoot
PndFileNameCreator.cxx
Go to the documentation of this file.
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"), fExtPid("pid"),
9  fExtTrackF("trackF"), fExtIdealTrackF("idealTrackF"), fExtRiemann("riemann"),
10  fExtCombinedRiemann("combRiemann"), fExtKalman("kalman"),fExtVertex("vertex"),
11  fVerbose(0)
12 {
13 }
14 
16  fFileName(fileName), fExtPar("par"), fExtSim("sim"), fExtDigi("digi"), fExtReco("reco"), fExtPid("pid"),
17  fExtTrackF("trackF"), fExtIdealTrackF("idealTrackF"), fExtRiemann("riemann"),
18  fExtCombinedRiemann("combRiemann"), fExtKalman("kalman"),fExtVertex("vertex"),
19  fVerbose(0)
20 {
21  std::cout << "PndFileNameCreator::fFileName " << fileName << " " << fileName.size() << std::endl;
22 }
23 
24 
25 
26 
27 std::string PndFileNameCreator::GetParFileName(std::string addon, bool cut)
28 {
29  return GetCustomFileName(fExtPar, addon, cut);
30 }
31 
32 std::string PndFileNameCreator::GetSimFileName(std::string addon, bool cut)
33 {
34  return GetCustomFileName(fExtSim, addon, cut);
35 }
36 
37 std::string PndFileNameCreator::GetDigiFileName(std::string addon, bool cut)
38 {
39  return GetCustomFileName(fExtDigi, addon, cut);
40 }
41 
42 std::string PndFileNameCreator::GetRecoFileName(std::string addon, bool cut)
43 {
44  return GetCustomFileName(fExtReco, addon, cut);
45 }
46 
47 std::string PndFileNameCreator::GetPidFileName(std::string addon, bool cut)
48 {
49  return GetCustomFileName(fExtPid, addon, cut);
50 }
51 
52 std::string PndFileNameCreator::GetTrackFindingFileName(std::string addon, bool cut)
53 {
54  return GetCustomFileName(fExtTrackF, addon, cut);
55 }
56 
57 std::string PndFileNameCreator::GetIdealTrackFindingFileName(std::string addon, bool cut)
58 {
59  return GetCustomFileName(fExtIdealTrackF, addon, cut);
60 }
61 
62 std::string PndFileNameCreator::GetRiemannFileName(std::string addon, bool cut)
63 {
64  return GetCustomFileName(fExtRiemann, addon, cut);
65 }
66 
67 std::string PndFileNameCreator::GetCombinedRiemannFileName(std::string addon, bool cut)
68 {
69  return GetCustomFileName(fExtCombinedRiemann, addon, cut);
70 }
71 
72 
73 std::string PndFileNameCreator::GetKalmanFileName(std::string addon, bool cut)
74 {
75  return GetCustomFileName(fExtKalman, addon, cut);
76 }
77 
78 std::string PndFileNameCreator::GetVertexFileName(std::string addon, bool cut)
79 {
80  return GetCustomFileName(fExtVertex, addon, cut);
81 }
82 
83 // -----------------
84 
85 //std::string PndFileNameCreator::GetParFileName(std::string inputFileName, std::string addon, bool cut)
86 //{
87 // fFileName = inputFileName;
88 // return GetParFileName(addon, cut);
89 //}
90 //
91 //std::string PndFileNameCreator::GetSimFileName(std::string inputFileName, std::string addon, bool cut)
92 //{
93 // fFileName = inputFileName;
94 // return GetSimFileName(addon, cut);
95 //}
96 //
97 //std::string PndFileNameCreator::GetDigiFileName(std::string inputFileName, std::string addon, bool cut)
98 //{
99 // fFileName = inputFileName;
100 // return GetDigiFileName(addon, cut);
101 //}
102 //
103 //std::string PndFileNameCreator::GetRecoFileName(std::string inputFileName, std::string addon, bool cut)
104 //{
105 // fFileName = inputFileName;
106 // return GetRecoFileName(addon, cut);
107 //}
108 //
109 //std::string PndFileNameCreator::GetTrackFindingFileName(std::string inputFileName, std::string addon, bool cut)
110 //{
111 // fFileName = inputFileName;
112 // return GetTrackFindingFileName(addon, cut);
113 //}
114 //
115 //std::string PndFileNameCreator::GetIdealTrackFindingFileName(std::string inputFileName, std::string addon, bool cut)
116 //{
117 // fFileName = inputFileName;
118 // return GetIdealTrackFindingFileName(addon, cut);
119 //}
120 //
121 //std::string PndFileNameCreator::GetKalmanFileName(std::string inputFileName, std::string addon, bool cut)
122 //{
123 // fFileName = inputFileName;
124 // return GetKalmanFileName(addon, cut);
125 //}
126 //
127 //std::string PndFileNameCreator::GetVertexFileName(std::string inputFileName, std::string addon, bool cut)
128 //{
129 // fFileName = inputFileName;
130 // return GetVertexFileName(addon, cut);
131 //}
132 //
133 //std::string PndFileNameCreator::GetRiemannFileName(std::string inputFileName, std::string addon, bool cut)
134 //{
135 // fFileName = inputFileName;
136 // return GetRiemannFileName(addon, cut);
137 //}
138 //
139 //std::string PndFileNameCreator::GetCombinedRiemannFileName(std::string inputFileName, std::string addon, bool cut)
140 //{
141 // fFileName = inputFileName;
142 // return GetCombinedRiemannFileName(addon, cut);
143 //}
144 
145 std::string PndFileNameCreator::GetCustomFileName(std::string ext, std::string addon, bool cut)
146 {
147 
148  std::string result = TruncateFileName(cut);
149  if (fVerbose > 0){
150  std::cout << "PndFileNameCreator::GetCustomFileName ";
151  std::cout << "Ext: " << ext << " addon: " << addon << " cut: " << cut;
152  std::cout << " Truncated: " << result << std::endl;
153  }
154  if (addon.size() > 0){
155  result += "_";
156  result += addon;
157  }
158  if (ext.size() > 0){
159  result += "_";
160  result += ext;
161  }
162  result += ".root";
163  if(fVerbose>0) std::cout<<" -I- PndFileNameCreator file: "<<result.c_str()<<std::endl;
164  return result;
165 }
166 
167 //std::string PndFileNameCreator::GetCustomFileName(std::string inputFileName, std::string ext, std::string addon, bool cut)
168 //{
169 // fFileName = inputFileName;
170 // return GetCustomFileName(ext, addon, cut);
171 //}
172 
174 {
175  std::string result = ext;
176  result += TruncateInitial();
177 
178  if (fVerbose>0) std::cout << " -I- PndFileNameCreator::GetCustomFileNameInitial: " << result.c_str() << std::endl;
179  return result;
180 }
181 
183 {
184  std::stringstream result;
185  std::vector<std::string> resString;
186 
187  PndStringSeparator pathAna(fFileName,"/");
188  resString = pathAna.GetStringVector();
189  if(fVerbose>1) pathAna.Print();
190 
191  if (fFileName.find("/") != 0){
192  if (fFileName.find("./") != 0){
193  result << "./";
194  }
195  }
196  else {
197  result << "/";
198  }
199  if (fVerbose > 0)
200  std::cout << "resString.size() " << resString.size() << std::endl;
201  if (resString.size() > 0){
202  for (size_t i = 0; i < resString.size()-1; i++){
203  result << resString[i] << "/";
204  }
205  }
206  return result.str();
207 }
208 
210 {
211  std::string result;
212  std::vector<std::string> resString;
213 
214  PndStringSeparator pathAna(fFileName,"/");
215  resString = pathAna.GetStringVector();
216  if (resString.size() > 0)
217  result = resString[resString.size()-1];
218  return result;
219 }
220 
222 {
223  std::vector<std::string> resString;
224  std::stringstream result;
225  std::string path, name;
226  Int_t cutLast = 0;
227 
228 
229  path = GetPath();
230  name = GetFileName();
231  //if(fVerbose>1) std::cout << "Path: " << path << " FileName: " << name << std::endl;
232  result.str("");
233 
234  PndStringSeparator stringAna(name, "._");
235  resString = stringAna.GetStringVector();
236  //if(fVerbose>1) stringAna.Print();
237 
238  if (cut == true)
239  cutLast = 2;
240  else cutLast = 1;
241  if (resString.size() > 0){
242  if (resString[resString.size()-1] != "root")
243  cutLast--;
244 
245  if (resString.size() - cutLast <= 0)
246  return "";
247 
248  result << path;
249  for (UInt_t i = 0; i < resString.size()-1 - cutLast; i++){
250  result << resString[i] << "_";
251  }
252  result << resString[resString.size()-1 - cutLast];
253  }
254  return result.str();
255 }
256 
258 {
259  std::vector<std::string> resString;
260  std::stringstream result;
261  std::string path, name;
262 
263  path = GetPath();
264  name = GetFileName();
265 
266  PndStringSeparator stringAna(name, "._");
267  resString = stringAna.GetStringVector();
268  if (resString.size() > 0){
269  for (UInt_t i = 1; i < resString.size() - 1; i++){
270  result << "_" << resString[i];
271  }
272  }
273  result << ".root";
274  return result.str();
275 }
277 
int fVerbose
Definition: poormantracks.C:24
std::string GetFileName() const
std::vector< std::string > GetStringVector(void)
std::string GetRiemannFileName(std::string addon="", bool cut=false)
std::string GetParFileName(std::string addon="", bool cut=false)
Int_t i
Definition: run_full.C:25
std::string GetVertexFileName(std::string addon="", bool cut=false)
std::string TruncateInitial()
std::string GetDigiFileName(std::string addon="", bool cut=false)
std::string GetCombinedRiemannFileName(std::string addon="", bool cut=false)
std::string GetSimFileName(std::string addon="", bool cut=false)
std::string fExtIdealTrackF
std::string GetIdealTrackFindingFileName(std::string addon="", bool cut=false)
double cut[MAX]
Definition: autocutx.C:36
std::string GetRecoFileName(std::string addon="", bool cut=false)
std::string TruncateFileName(bool cut)
A simple class which adds the corresponding file extensions to a given base class.
std::string GetCustomFileName(std::string ext, std::string addon="", bool cut=false)
std::string GetTrackFindingFileName(std::string addon="", bool cut=false)
TString name
std::string GetCustomFileNameInitial(std::string ext)
TNtuple * ext
Definition: reco_muo.C:24
ClassImp(PndAnaContFact)
std::string GetKalmanFileName(std::string addon="", bool cut=false)
std::string GetPidFileName(std::string addon="", bool cut=false)
std::string fExtCombinedRiemann