BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
fun.cpp File Reference
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <vector>
#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/share/distAlign/src/fun.cpp.

14 {
15 vector<string> fnames;
16
17 string command( "JobOutputDir=`/bin/ls -dt1 joboutput-* 2>/dev/null | head -1`\n"
18 "if [ -d \"${JobOutputDir}\" ]; then\n"
19 " find ${JobOutputDir} -name hist.root\n"
20 "fi\n" );
21
22 stringstream fnstream;
23
24 char* fnbuf = new char[1024];
25 FILE* fstream = popen( command.c_str(), "r" );
26
27 while ( fgets( fnbuf, 1024, fstream ) != NULL ) { fnstream << fnbuf; }
28
29 string fname;
30 while ( !( fnstream >> fname ).eof() ) { fnames.push_back( fname ); }
31
32 pclose( fstream );
33 delete[] fnbuf;
34
35 if ( fnames.empty() )
36 {
37 cout << "WARNING: Failed to retrieve hist files in the current directory!" << endl;
38 // exit(1);
39 }
40 return fnames;
41}

Referenced by main().

◆ getHistList() [2/2]

vector< string > getHistList ( string path)

Definition at line 43 of file MdcAlignAlg/share/distAlign/src/fun.cpp.

43 {
44 vector<string> fnames;
45 string newpath = path;
46 string::size_type strl = newpath.length();
47 if ( ( strl > 1 ) && ( '/' == newpath[strl - 1] ) ) newpath.erase( strl - 1 );
48
49 char com1[500];
50 sprintf( com1, "JobOutputDir=`/bin/ls -dt1 %s/joboutput-* 2>/dev/null | head -1`\n",
51 newpath.c_str() );
52 string command1( com1 );
53 string command2( "if [ -d \"${JobOutputDir}\" ]; then\n"
54 " find ${JobOutputDir} -name hist.root\n"
55 "fi\n" );
56 string command = command1 + command2;
57 stringstream fnstream;
58
59 char* fnbuf = new char[1024];
60 FILE* fstream = popen( command.c_str(), "r" );
61
62 while ( fgets( fnbuf, 1024, fstream ) != NULL ) { fnstream << fnbuf; }
63
64 string fname;
65 while ( !( fnstream >> fname ).eof() ) { fnames.push_back( fname ); }
66
67 pclose( fstream );
68 delete[] fnbuf;
69
70 if ( fnames.empty() )
71 {
72 cout << "ERROR: Failed to retrieve hist files!" << endl;
73 exit( 1 );
74 }
75 return fnames;
76}
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)