1 #include "OutputConvention.h" 40 outFileName = getOutputDir();
43 outFileName += TString::Format(
"%sPlots", argv[0]);
47 for(
int argInd=1; argInd < argc; argInd++){
48 outFileName += TString::Format(
"_%s", argv[argInd]);
53 outFileName += getDateTimeSuffix();
57 outFileName +=
".root";
60 if(strncmp(ext.Data(),
".", 1)!=0){
61 ext = TString::Format(
".%s", ext.Data());
82 TString OutputConvention::getDateTimeSuffix(){
83 if(dateTimeSuffix==
""){
92 dateTimeSuffix = TString::Format(
"_%d", dateTime.GetYear());
94 Int_t m = dateTime.GetMonth();
96 dateTimeSuffix += TString::Format(
"-0%d", m);
99 dateTimeSuffix += TString::Format(
"-%d", m);
102 Int_t d = dateTime.GetDay();
104 dateTimeSuffix += TString::Format(
"-0%d", d);
107 dateTimeSuffix += TString::Format(
"-%d", d);
110 Int_t h = dateTime.GetHour();
112 dateTimeSuffix += TString::Format(
"_0%d", h);
115 dateTimeSuffix += TString::Format(
"_%d", h);
118 Int_t m2 = dateTime.GetMinute();
120 dateTimeSuffix += TString::Format(
"-0%d", m2);
123 dateTimeSuffix += TString::Format(
"-%d", m2);
126 Int_t s = dateTime.GetSecond();
128 dateTimeSuffix += TString::Format(
"-0%d", s);
131 dateTimeSuffix += TString::Format(
"-%d", s);
134 return dateTimeSuffix;
147 TString OutputConvention::getOutputDir(){
150 const char* outputDirPoss = getenv(
"OUTPUT_DIR");
151 if(outputDirPoss!=NULL){
152 outputDir += TString::Format(
"%s/", outputDirPoss);
174 TFile* theFile = NULL;
176 TChain* tempChain =
new TChain(
"tempChain");
177 tempChain->Add(fileNameWithWildcards);
179 TObjArray* fileList = tempChain->GetListOfFiles();
181 const int numFiles = fileList->GetEntries();
184 std::vector<TString> fileNames(numFiles,
"");;
186 for(
int fileInd=0; fileInd < numFiles; fileInd++){
187 fileNames.at(fileInd) = TString::Format(
"%s", fileList->At(fileInd)->GetTitle());
189 std::sort(fileNames.begin(), fileNames.end(), std::greater<TString>());
190 for(
int fileInd=0; fileInd < numFiles; fileInd++){
193 theFile = TFile::Open(fileNames.at(0));
TString getOutputFileName(TString ext="")
Get the name of the output file from the program name (and system time).
OutputConvention(int argcIn, char *argvIn[])
Constructor.
static TFile * getFile(TString fileNameWithWildcards)
Opens a TFile matching a fileName with wildcards. If multiple matches gets the "greatest" TString...