StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
getOutFileName.C
1 char* getOutFileName(const char* baseDir, const char* jobName,
2  const char* type, int icent = -1){
3 
4  char* jobid=gSystem->Getenv("JOBID");
5 
6  if(!jobid){
7  jobid=new char[3];
8  strcpy(jobid,"A_00");
9  }
10 
11  char* JobID=new char[strlen(jobid)+1];
12 
13  strcpy(JobID,jobid);
14  char* ptr;
15  if(ptr=strstr(JobID,"_")){
16  *ptr='\0';
17  ptr++;
18  }
19 
20  TString outArea(baseDir);
21  outArea+="/";
22  if(!jobName){
23  outArea+=JobID;
24  } else {
25  outArea+=jobName;
26  }
27  outArea+="/";
28  if (strstr(type,"centralityDefs")) {
29  outArea+="cuts";
30  } else if (strstr(type,"EStruct")) {
31  outArea+="data";
32  } else {
33  outArea+=type;
34  }
35  outArea+="/";
36 
37  TString createDir("mkdir -p ");
38  createDir+=outArea.Data();
39  system(createDir.Data());
40 
41  char* exten[]={".root",".root",".txt"};
42  int iext = 0;
43 
44  const char* centTag=NULL;
45  TString TcentTag;
46  if(icent>=0){
47  TcentTag+="_M";
48  TcentTag+=icent;
49  centTag=TcentTag.Data();
50  }
51 
52  TString outputFileFile(outArea.Data());
53  if(strstr(type,"cuts")){
54  outputFileFile+="cutHists";
55  } else if(strstr(type,"data")){
56  outputFileFile+="dataHists";
57  } else if(strstr(type,"EStruct")){
58  outputFileFile+="EStructEvents";
59  } else if(strstr(type,"QA")){
60  outputFileFile+="QA";
61  } else if(strstr(type,"stats")){
62  outputFileFile+="stats";
63  iext=2;
64  } else if(strstr(type,"centralityDefs")){
65  outputFileFile+="centralityDefs";
66  } else {
67  outputFileFile+="data";
68  iext=1;
69  }
70 
71  if(centTag)outputFileFile+=centTag;
72  outputFileFile+="_";
73  if(ptr)outputFileFile+=ptr;
74  outputFileFile+=exten[iext];
75 
76  delete [] JobID;
77  char* retVal=new char[strlen(outputFileFile.Data())+1];
78  strcpy(retVal,outputFileFile.Data());
79 
80  return retVal;
81 };
82 
83 
84