BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
fun.cpp File Reference
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include "TFile.h"
#include "TTree.h"
#include "include/fun.h"

Go to the source code of this file.

Functions

vector< string > getHistList ()
 
vector< string > getHistList (string path)
 

Function Documentation

◆ getHistList() [1/2]

vector< string > getHistList ( )

Definition at line 14 of file MdcAlignAlg/MdcAlignAlg-00-02-00/share/distAlign/src/fun.cpp.

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}
#define NULL

Referenced by main().

◆ getHistList() [2/2]

vector< string > getHistList ( string path)

Definition at line 49 of file MdcAlignAlg/MdcAlignAlg-00-02-00/share/distAlign/src/fun.cpp.

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)