本文整理汇总了C++中TString::ReadLine方法的典型用法代码示例。如果您正苦于以下问题:C++ TString::ReadLine方法的具体用法?C++ TString::ReadLine怎么用?C++ TString::ReadLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TString
的用法示例。
在下文中一共展示了TString::ReadLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckAvailable
Bool_t KVAvailableRunsFile::CheckAvailable(Int_t run)
{
//Look for a given run number in the file
//If run not found, returns kFALSE
//If available runs file does not exist, Update() is called to create it.
//does runlist exist ?
if (!OpenAvailableRunsFile()) {
Error("CheckAvailable", "Error opening available runs file");
return kFALSE;
}
//loop over lines in runlist file
//look for line beginning with 'run|'
Bool_t found = kFALSE;
TString line;
line.ReadLine(fRunlist);
while (fRunlist.good()) {
if (line.BeginsWith(Form("%d|", run))) {
CloseAvailableRunsFile();
return kTRUE;
}
line.ReadLine(fRunlist);
}
CloseAvailableRunsFile();
return found;
}
示例2: GetJobUrl
/**
* Get the job url.
*
* @param name Production name
* @param mc Should be true for MC
* @param url On return, the job url
*
* @return true on success
*/
Bool_t GetJobUrl(const TString& name, Bool_t mc, TString& url)
{
url = "";
TString index("raw.jsp");
if (!Download((mc ? "job_details.jsp" : "production/raw.jsp"), index))
return false;
std::ifstream in(index.Data());
TString line;
TString tgt(Form("<td class=\"table_row\">%s</td>", name.Data()));
do {
line.ReadLine(in);
if (!line.Contains(tgt)) continue;
line.ReadLine(in);
Int_t first = line.Index("href=\"");
Int_t last = line.Index("\"", first+7);
url = line(first+6,last-first-6);
break;
} while (!in.eof());
in.close();
if (url.IsNull()) {
Error("GetJobUrl", "Production %s not found", name.Data());
return false;
}
return true;
}
示例3: in
RDKConfig::RDKConfig(TString path){
if(!config_map.empty()){
config_map.clear();
}
ifstream in(path);
if(in.is_open()){
TString line;
line.ReadLine(in);
while(!in.eof()){
line.ReadLine(in);
TStringToken token(line,",",kTRUE);
token.NextToken();
UInt_t series=token.Atoi();
token.NextToken();
token.NextToken();
token.NextToken();
token.NextToken();
token.NextToken();
TString temp(token);
if(temp.BeginsWith("0x")){
temp.Remove(0,2);
temp=TString::BaseConvert(temp,16,10);
}
UInt_t config=temp.Atoi();
config_map[series]=config;
}
}else{
cerr<<"No configuration file found"<<endl;
}
}
示例4: GetRunInfos
void KVAvailableRunsFile::GetRunInfos(Int_t run, KVList * dates,
KVList * files)
{
//Look for a given run number in the file, and read the file's modification date/time and filename
//These informations are stored in the two TList as TObjString objects (these objects belong to the
//lists and will be deleted by them).
//We do not stop at the first run found, but continue until the end of the file, adding
//informations for every occurence of the run in the file.
//If available runs file does not exist, Update() is called to create it.
//does runlist exist ?
if (!OpenAvailableRunsFile()) {
Error("GetRunInfos", "Error opening available runs file");
return;
}
//clear lists - delete objects
dates->Delete();
files->Delete();
//loop over lines in fRunlist file
//look for line beginning with 'run|'
TString line;
line.ReadLine(fRunlist);
while (fRunlist.good()) {
if (line.BeginsWith(Form("%d|", run))) {
//found it
TObjArray *toks = line.Tokenize('|'); // split into fields
// check date is not identical to a previous entry
// i.e. there are spurious duplicate entries
TObjString* rundate = (TObjString*)toks->At(1)->Clone();
if(dates->FindObject(rundate->GetName())){
delete toks;
delete rundate;
line.ReadLine(fRunlist);
continue;
}
//add date string
dates->Add(toks->At(1)->Clone());
//backwards compatibility
//an old available_runs file will not have the filename field
//in this case we assume that the name of the file is given by the
//dataset's base file name (i.e. with no date/time suffix)
if (toks->GetEntries() > 2) {
files->Add(toks->At(2)->Clone());
} else {
files->
Add(new
TObjString(fDataSet->
GetBaseFileName(GetDataType(), run)));
}
delete toks;
}
line.ReadLine(fRunlist);
}
CloseAvailableRunsFile();
}
示例5: Add
void KVAvailableRunsFile::Add(Int_t run, const Char_t * filename)
{
//Add to the file an entry corresponding to this run, assumed to be present in the repository
//with the given filename.
//write in temporary runlist file '[run number]|[date of modification]|[name of file]|KaliVeda version|username
//does runlist exist ?
if (!OpenAvailableRunsFile()) {
Error("Add", "Error opening available runs file");
return;
}
//open temporary file
TString tmp_file_path(GetFileName());
ofstream tmp_file;
KVBase::OpenTempFile(tmp_file_path, tmp_file);
//copy all lines in runlist file
TString line;
line.ReadLine(fRunlist);
while (fRunlist.good()) {
tmp_file << line.Data() << endl;
line.ReadLine(fRunlist);
}
CloseAvailableRunsFile();
TString runlist_path;
AssignAndDelete(runlist_path,
gSystem->ConcatFileName(fDataSet->GetDataSetDir(),
GetFileName()));
// keep lock on runsfile
if( !runlist_lock.Lock( runlist_path.Data() ) ) return;
//add entry for run
FileStat_t fs;
//get file modification date
if (fDataSet->GetRepository()->
GetFileInfo(fDataSet, GetDataType(), filename,
fs)) {
//runfile exists in repository
//write in temporary runlist file '[run number]|[date of modification]|[name of file]|KaliVeda version|username
TDatime modt(fs.fMtime);
UserGroup_t *userinfo = gSystem->GetUserInfo();
tmp_file << run << '|' << modt.
AsSQLString() << '|' << filename << '|' << GetKVVersion() << '|' << userinfo->fUser << endl;
delete userinfo;
}
//close temp file
tmp_file.close();
//copy temporary file to KVFiles directory, overwrite previous
gSystem->CopyFile(tmp_file_path, runlist_path, kTRUE);
//set access permissions to 664
gSystem->Chmod(runlist_path.Data(), CHMODE(6,6,4));
//delete temp file
gSystem->Unlink(tmp_file_path);
//unlock runsfile
runlist_lock.Release();
}
示例6: RemoveDuplicateLines
void KVAvailableRunsFile::RemoveDuplicateLines(KVNumberList lines_to_be_removed)
{
// Remove from available runs file all lines whose numbers are in the list
//does runlist exist ?
if (!OpenAvailableRunsFile()) {
Error("Remove", "Error opening available runs file");
return;
}
//open temporary file
TString tmp_file_path(GetFileName());
ofstream tmp_file;
KVBase::OpenTempFile(tmp_file_path, tmp_file);
//loop over lines in fRunlist file
//all lines which are not in list are directly copied to temp file
TString line;
Int_t line_number=1;
line.ReadLine(fRunlist);
lines_to_be_removed.Begin();
Int_t next_line_to_remove = 0;
if(!lines_to_be_removed.End()) next_line_to_remove = lines_to_be_removed.Next();
while (fRunlist.good()) {
if(line_number!=next_line_to_remove)
tmp_file << line.Data() << endl;
else {
if(!lines_to_be_removed.End()) next_line_to_remove = lines_to_be_removed.Next();
}
line_number++;
line.ReadLine(fRunlist);
}
CloseAvailableRunsFile();
TString fRunlist_path;
AssignAndDelete(fRunlist_path,
gSystem->ConcatFileName(GetFilePath(),
GetFileName()));
//keep lock on runsfile
if( !runlist_lock.Lock( fRunlist_path.Data() ) ) return;
//close temp file
tmp_file.close();
//copy temporary file to KVFiles directory, overwrite previous
gSystem->CopyFile(tmp_file_path, fRunlist_path, kTRUE);
//set access permissions to 664
gSystem->Chmod(fRunlist_path.Data(), CHMODE(6,6,4));
//delete temp file
gSystem->Unlink(tmp_file_path);
//unlock runsfile
runlist_lock.Release();
}
示例7: GetRunList
KVNumberList KVAvailableRunsFile::GetRunList(const KVDBSystem * sys)
{
//Returns list of available run numbers for this data type.
//If 'sys' gives the address of a valid database reaction system, only runs
//corresponding to the system will be included.
KVNumberList runs;
//does runlist exist ?
if (!OpenAvailableRunsFile()) {
Error("GetRunList", "Cannot open available runs file");
return runs;
}
TString fLine;
fLine.ReadLine(fRunlist);
Int_t fRunNumber;
KVDBTable *runs_table = 0;
KVDataBase* db = fDataSet->GetDataBase();
if (!db){
db = new KVDataBase();
db->AddTable("Runs","List of Runs");
}
runs_table = db->GetTable("Runs");
//KVDBTable *runs_table = fDataSet->GetDataBase()->GetTable("Runs");
while (fRunlist.good()) {
TObjArray *toks = fLine.Tokenize('|'); // split into fields
KVString kvs(((TObjString *) toks->At(0))->GetString());
fRunNumber = kvs.Atoi();
delete toks;
if (sys) {
// check run is from right system
KVDBRun *a_run = (KVDBRun *) runs_table->GetRecord(fRunNumber);
if (a_run) {
if (a_run->GetSystem() == sys)
runs.Add(fRunNumber);
}
} else {
// add all runs to list
runs.Add(fRunNumber);
}
fLine.ReadLine(fRunlist);
}
CloseAvailableRunsFile();
return runs;
}
示例8: SetGGtoPGConversionFactors
void KVINDRA::SetGGtoPGConversionFactors()
{
// Sets the parameters for linear conversion of silicon & ChIo coder values
// between GG and PG, using the following formula:
//
// PG = alpha + beta*(GG - GG_0) + PG_0
//
// where GG_0 and PG_0 are respectively GG and PG pedestals
//
// We look for the file whose name is given by the .kvrootrc variable
// [dataset].INDRADB.GGtoPGFactors:
// or by default
// INDRADB.GGtoPGFactors:
// and expect to find in it a line for each detector of the form:
// Det_Name alpha beta
// Comments in the file can be written on lines beginning with the character '#'
ifstream datfile;
if (!gDataSet->OpenDataSetFile(gDataSet->GetDataSetEnv("INDRADB.GGtoPGFactors", ""), datfile)) {
Info("SetGGtoPGConversionFactors", "Cannot open file with parameters for conversion (%s).",
gDataSet->GetDataSetEnv("INDRADB.GGtoPGFactors", ""));
return;
}
else {
Info("SetGGtoPGConversionFactors", "Reading parameters from file %s",
gDataSet->GetDataSetEnv("INDRADB.GGtoPGFactors", ""));
Char_t detname[30];
Double_t a, b;
TString aline;
aline.ReadLine(datfile);
while (datfile.good()) {
if (aline[0] != '#') { //skip comments
sscanf(aline.Data(), "%s %lf %lf", detname, &a, &b);
KVINDRADetector* det = (KVINDRADetector*)GetDetector(detname);
if (!det) {
//no detector found with cou, mod and type
Error("SetGGtoPGConversionFactors", "Unknown detector : %s", detname);
}
else {
det->SetGGtoPGConversionFactors(a, b);
//Info("SetGGtoPGConversionFactors", "%s : PG = %f + %f * GG", detname, a, b);
}
}
aline.ReadLine(datfile);
} //while( datfile.good()
datfile.close();
}
}
示例9: readAbbyTimeFile
void readAbbyTimeFile()
{
ifstream CsvFile("/home/rjn/saltStuff/abbyTimeWindows.csv");
int numLines=0;
TString line;
line.ReadLine(CsvFile); // Get rid of inital headings
Int_t depthIndex[3]={-1,-1,-1};
Int_t lastDepth[3]={0,0,0};
while(line.ReadLine(CsvFile)) {
// cout << line.Data() << endl;
TObjArray *vals = (TObjArray*) line.Tokenize(",");
// vals->Dump();
TObjString *firstField=vals->At(0);
// exit(0);
TObjString *antenna=vals->At(1);
TObjString *disk=vals->At(2);
TObjString *file=vals->At(3);
TObjString *hole=vals->At(6);
TObjString *peakTimeStr=vals->At(7);
TObjString *minTimeStr=vals->At(8);
TObjString *maxTimeStr=vals->At(9);
// cout << vals[0].Data() << "\t" << vals[1].Data() << endl;
// cout << x->GetString()->Data() << "\t" << y->GetString()->Data() << endl;
Int_t antIndex=antenna->GetString().Atoi()-1;
Int_t holeIndex=hole->GetString().Atoi()-2;
Int_t depth=firstField->GetString().Atoi();
if(lastDepth[antIndex]!=depth) {
depthIndex[antIndex]++;
depths[antIndex][depthIndex[antIndex]]=depth;
lastDepth[antIndex]=depth;
}
// cout << antIndex << "\t" << depthIndex[antIndex] << "\t" << holeIndex << "\t" << depth << endl;
// cout << numLines << "\t" << index << "\t" << depths[depthIndex[antIndex]] << endl;
disks[antIndex][depthIndex[antIndex]][holeIndex]=disk->GetString().Atoi()+1;
files[antIndex][depthIndex[antIndex]][holeIndex]=file->GetString().Atoi();
peakTime[antIndex][depthIndex[antIndex]][holeIndex]=peakTimeStr->GetString().Atof();
minTime[antIndex][depthIndex[antIndex]][holeIndex]=minTimeStr->GetString().Atof();
maxTime[antIndex][depthIndex[antIndex]][holeIndex]=maxTimeStr->GetString().Atof();
numLines++;
}
}
示例10: if
TChain * GetAnalysisChain(const char * incollection){
// Builds a chain of esd files
// incollection can be
// - a single root file
// - an xml collection of files on alien
// - a ASCII containing a list of local root files
TChain* analysisChain = 0;
// chain
analysisChain = new TChain("esdTree");
if (TString(incollection).Contains(".root")){
analysisChain->Add(incollection);
}
else if (TString(incollection).Contains("xml")){
TGrid::Connect("alien://");
TAlienCollection * coll = TAlienCollection::Open (incollection);
while(coll->Next()){
analysisChain->Add(TString("alien://")+coll->GetLFN());
}
} else {
ifstream file_collect(incollection);
TString line;
while (line.ReadLine(file_collect) ) {
analysisChain->Add(line.Data());
}
}
analysisChain->GetListOfFiles()->Print();
return analysisChain;
}
示例11: TREEendlog
void TREEendlog(TString filename)
{ gROOT->Reset(); // reset ROOT
ifstream edfile; // new stream 'edfile' to the data file
edfile.open(filename, ios_base::in); // read and write access to the data file
if (edfile.good()){
TString treename = filename + ".root";
cout << "Creating tree " << treename << endl;
TFile* file=TFile::Open(treename.Data(), "RECREATE"); // recreating a new file wherein the tree will be saved.
//++++++++ options: "CREATE" ~ create and open a new file if it does not already exist ++++++++++++++++++++++++++++++
//+++++++++++++++++ "RECREATE" ~ create and overwrite if existing +++++++++++++++++++++++++++++++++++++++++++++++++++
cout << "Reading data from " << filename << endl;
TString bdescriptor; // branch descriptor 'bdescriptor' as a empty string
bdescriptor.ReadLine(edfile); // read branch descriptor from file
bdescriptor.ReplaceAll(" ",":"); // format branch descriptor for root ("x y z" -> "x:y:z")
TNtupleD* tree=new TNtupleD("mytree", "mytree", bdescriptor.Data()); // creating a new TTree([treename],[treetitle])
Int_t n = tree->GetNvar();
while (1){
for (int i = 0; i < n; i++) edfile >> tree->GetArgs()[i]; // read values into Arg-array of tree
if (!edfile.good()) break;
tree->Fill(tree->GetArgs()); // fill Args into tree
}
edfile.close(); // closing the stream 'edfile'
file->Write();
tree->Print(); // output of the tree overview
delete tree;
delete file;
}
示例12: fin
//------------------------------
void KVINDRADB_e475s::ReadCalibrations()
//------------------------------
{
ifstream finput;
if (!OpenCalibFile("CalibFile", finput)) {
Error("ReadCalibrations()", "Could not open file %s",
GetCalibFileName("CalibFile"));
return;
}
Info("ReadCalibrations()",
"Reading calibration parameters...");
TString sline;
TString stit;
TString calib_det,calib_gain,calib_file;
TObjArray *toks=NULL;
while (finput.good()) {
sline.ReadLine(finput);
if (!sline.IsNull()){
cout << sline << endl;
toks = sline.Tokenize(" ");
calib_det = ((TObjString*)(*toks)[0])->GetString();
calib_gain = ((TObjString*)(*toks)[1])->GetString();
calib_file = ((TObjString*)(*toks)[2])->GetString();
stit.Form("%s/%s",gDataSet->GetDataSetDir(),calib_file.Data());
ifstream fin(stit.Data());
ReadCalibFile(fin,calib_det,calib_gain);
fin.close();
}
}
finput.close();
}
示例13: main
//________________________________________________________________________________________
int main(int argc, char* argv[]) {
// Default options
bool isList = false;
TString outputdir = "TempOutput/";
int verbose = 0;
// Parse options
char ch;
while ((ch = getopt(argc, argv, "d:v:lh?")) != -1 ) {
switch (ch) {
case 'd': outputdir = TString(optarg); break;
case 'v': verbose = atoi(optarg); break;
case 'l': isList = true; break;
case '?':
case 'h': usage(0); break;
default:
cerr << "*** Error: unknown option " << optarg << std::endl;
usage(-1);
}
}
argc -= optind;
argv += optind;
// Check arguments
if( argc<1 ) {
usage(-1);
}
TChain *theChain = new TChain("analyze/Analysis");
for(int i = 0; i < argc; i++){
if( !isList ){
theChain->Add(argv[i]);
printf(" Adding file: %s\n",argv[i]);
} else {
TString rootFile;
ifstream is(argv[i]);
while(rootFile.ReadLine(is) && (!rootFile.IsNull())){
if(rootFile[0] == '#') continue;
theChain->Add(rootFile);
printf(" Adding file: %s\n", rootFile.Data());
}
}
}
cout << "--------------" << endl;
cout << "OutputDir is: " << outputdir << endl;
cout << "Verbose level is: " << verbose << endl;
cout << "Number of events: " << theChain->GetEntries() << endl;
cout << "--------------" << endl;
UserAnalyzer *tA = new UserAnalyzer(theChain);
tA->SetOutputDir(outputdir);
tA->SetVerbose(verbose);
tA->BeginJob();
tA->Loop();
tA->EndJob();
delete tA;
return 0;
}
示例14: CsvFile
TGraph *getScopePeriodiogram(char *fileName)
{
ifstream CsvFile(fileName);
int numLines=0;
int numLines2=0;
TString line;
Double_t xVals[100000];
Double_t yVals[100000];
while(line.ReadLine(CsvFile)) {
// cout << line.Data() << endl;
TObjArray *vals = (TObjArray*) line.Tokenize(",");
// vals.Dump();
TObjString *x=vals->At(0);
TObjString *y=vals->At(1);
// cout << vals[0].Data() << "\t" << vals[1].Data() << endl;
// cout << x->GetString()->Data() << "\t" << y->GetString()->Data() << endl;
xVals[numLines]=x->GetString().Atof();
yVals[numLines]=y->GetString().Atof();
numLines++;
}
Double_t N=numLines*2;
Double_t deltaF=(xVals[1]-xVals[0]);
Double_t deltaT=1./(N*deltaF);
// cout << deltaT << endl;
for(int i=0;i<numLines;i++) {
xVals[i]=i*deltaF;
}
// cout << xVals[0] << "\t" << xVals[numLines-1] << "\t" << xVals[1]-xVals[0] << "\n";
TGraph *grWave = new TGraph(numLines,xVals,yVals);
return grWave;
}
示例15: TxtFile
TGraph *getWaveFromTxt(char *fileName)
{
ifstream TxtFile(fileName);
int numLines=0;
int numLines2=0;
TString line;
Double_t xVals[100000];
Double_t yVals[100000];
Double_t xVals2[100000];
Double_t yVals2[100000];
while(line.ReadLine(TxtFile)) {
// cout << line.Data() << endl;
TObjArray *vals = (TObjArray*) line.Tokenize(" ");
// vals.Dump();
TObjString *x=vals->At(0);
TObjString *y=vals->At(1);
// cout << vals[0].Data() << "\t" << vals[1].Data() << endl;
// cout << x->GetString()->Data() << "\t" << y->GetString()->Data() << endl;
xVals[numLines]=x->GetString().Atof();
yVals[numLines]=y->GetString().Atof();
// yVals[numLines]=TMath::Sin(TMath::TwoPi()*500e6*xVals[numLines]);
if(numLines%2==0) {
xVals2[numLines2]=xVals[numLines];
yVals2[numLines2]=yVals[numLines];
numLines2++;
}
numLines++;
}
TGraph *grWave = new TGraph(numLines,xVals,yVals);
return grWave;
}