BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcAlignAlg/MdcAlignAlg-00-01-04/share/distAlign/src/fun.cpp
Go to the documentation of this file.
1#include <iostream>
2#include <sstream>
3#include <cstdio>
4#include <vector>
5#include <cstdlib>
6
7#include "TFile.h"
8#include "TTree.h"
9
10#include "include/fun.h"
11
12using namespace std;
13
14vector<string> getHistList()
15{
16 vector<string> fnames;
17
18 string command(
19 "JobOutputDir=`/bin/ls -dt1 joboutput-* 2>/dev/null | head -1`\n"
20 "if [ -d \"${JobOutputDir}\" ]; then\n"
21 " find ${JobOutputDir} -name hist.root\n"
22 "fi\n"
23 );
24
25 stringstream fnstream;
26
27 char* fnbuf = new char[1024];
28 FILE* fstream = popen(command.c_str(), "r");
29
30 while ( fgets(fnbuf, 1024, fstream) != NULL ) {
31 fnstream << fnbuf;
32 }
33
34 string fname;
35 while ( ! (fnstream>>fname).eof() ) {
36 fnames.push_back(fname);
37 }
38
39 pclose(fstream);
40 delete [] fnbuf;
41
42 if ( fnames.empty() ) {
43 cout << "WARNING: Failed to retrieve hist files in the current directory!" << endl;
44// exit(1);
45 }
46 return fnames;
47}
48
49vector<string> getHistList(string path)
50{
51 vector<string> fnames;
52 string newpath = path;
53 string::size_type strl = newpath.length();
54 if((strl>1) && ('/'==newpath[strl-1])) newpath.erase(strl-1);
55
56 char com1[500];
57 sprintf(com1, "JobOutputDir=`/bin/ls -dt1 %s/joboutput-* 2>/dev/null | head -1`\n", newpath.c_str());
58 string command1(com1);
59 string command2(
60 "if [ -d \"${JobOutputDir}\" ]; then\n"
61 " find ${JobOutputDir} -name hist.root\n"
62 "fi\n"
63 );
64 string command = command1 + command2;
65 stringstream fnstream;
66
67 char* fnbuf = new char[1024];
68 FILE* fstream = popen(command.c_str(), "r");
69
70 while ( fgets(fnbuf, 1024, fstream) != NULL ) {
71 fnstream << fnbuf;
72 }
73
74 string fname;
75 while ( ! (fnstream>>fname).eof() ) {
76 fnames.push_back(fname);
77 }
78
79 pclose(fstream);
80 delete [] fnbuf;
81
82 if ( fnames.empty() ) {
83 cout << "ERROR: Failed to retrieve hist files!" << endl;
84 exit(1);
85 }
86 return fnames;
87}
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)