本文整理汇总了C++中TString::Tokenize方法的典型用法代码示例。如果您正苦于以下问题:C++ TString::Tokenize方法的具体用法?C++ TString::Tokenize怎么用?C++ TString::Tokenize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TString
的用法示例。
在下文中一共展示了TString::Tokenize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DecodeDataString
//___________________________________________________________
void DecodeDataString(const TString &datastring, TString &sample, TArrayI &listofruns){
TObjArray *toks = datastring.Tokenize(":");
sample = (dynamic_cast<TObjString *>(toks->At(0)))->String();
TString &listrunstring = (dynamic_cast<TObjString *>(toks->At(1)))->String();
TObjArray *runstrings = listrunstring.Tokenize(",");
TIter runiter(runstrings);
listofruns.Set(runstrings->GetEntriesFast());
TObjString *myrunstring = NULL;
Int_t counter = 0;
while((myrunstring = dynamic_cast<TObjString *>(runiter()))) listofruns[counter++] = myrunstring->String().Atoi();
// Print summary:
printf("Selected sample: %s\n", sample.Data());
printf("========================================\n");
for(Int_t irun = 0; irun < listofruns.GetSize(); irun++){
printf("\trun %d\n", listofruns[irun]);
}
printf("\n");
delete toks; delete runstrings;
}
示例2: DrawNetworkMovie
void DrawNetworkMovie( TFile* file, const TString& methodType, const TString& methodTitle )
{
TString dirname = methodType + "/" + methodTitle + "/" + "EpochMonitoring";
TDirectory *epochDir = (TDirectory*)file->Get( dirname );
if (!epochDir) {
cout << "Big troubles: could not find directory \"" << dirname << "\"" << endl;
exit(1);
}
epochDir->cd();
// loop over all epoch-wise monitoring histograms
TIter keyIt(epochDir->GetListOfKeys());
TKey *key;
vector<TString> epochList;
Int_t ic = 0;
while ((key = (TKey*)keyIt())) {
if (!gROOT->GetClass(key->GetClassName())->InheritsFrom("TH2F")) continue;
TString name = key->GetName();
if (!name.BeginsWith("epochmonitoring___")) continue;
// extract epoch
TObjArray* tokens = name.Tokenize("_");
TString es = ((TObjString*)tokens->At(2))->GetString();
// check if done already
Bool_t isOld = kFALSE;
for (vector<TString>::const_iterator it = epochList.begin(); it < epochList.end(); it++) {
if (*it == es) isOld = kTRUE;
}
if (isOld) continue;
epochList.push_back( es );
// create bulk file name
TString bulkname = Form( "epochmonitoring___epoch_%s_weights_hist", es.Data() );
// draw the network
if (ic <= 60) draw_network( file, epochDir, bulkname, kTRUE, es );
ic++;
}
}
示例3: Browser
void TGo4TreeViewer::ProcessDropEvent(QGo4LineEdit* edt, bool caninit)
{
QString value = edt->text();
TGo4BrowserProxy* br = Browser();
if (br==0) return;
if (fxTreeName.length()==0) {
if (!caninit) {
StatusMessage("First drop something on X, Y or Z field");
edt->setText("");
return;
}
TString treename;
if (!br->DefineTreeName(value.toLatin1().constData(), treename)) {
StatusMessage(QString("Invalid tree ") + value);
edt->setText("");
return;
}
fxTreeName = treename.Data();
setToolTip(QString("Selected tree: ") + fxTreeName);
TreeDrawBtn->setEnabled(true);
AddLink(treename.Data(), "Tree");
}
TString leafname;
if (!br->DefineLeafName(value.toLatin1().constData(), fxTreeName.toLatin1().constData(), leafname)) {
edt->setText("");
StatusMessage(QString("Invalid leaf name ") + value);
return;
}
// count number of [ and replace by []
// this means, by default accumulate over all members
TObjArray* it=leafname.Tokenize("[");
leafname=((TObjString *)it->First())->GetName();
for(Int_t i=1;i<it->GetEntriesFast();i++) leafname.Append("[]");
edt->setText(leafname.Data());
edt->setFocus();
it->Delete();
}
示例4: GetTerminateOptions
//_______________________________________
TObjArray* GetTerminateOptions ( TString taskOpt, Bool_t isMC )
{
TObjArray* terminateList = 0x0;
if ( ! taskOpt.IsNull() ) {
TObjArray* optList = taskOpt.Tokenize(";");
for ( Int_t iopt=0; iopt<optList->GetEntries(); iopt++ ) {
TString currOpt = (static_cast<TObjString*>(optList->At(iopt)))->GetString();
if ( ! currOpt.Contains("@") ) continue;
TObjArray* tmpList = currOpt.Tokenize("@");
if ( tmpList->GetEntries() == 4 ) {
terminateList = tmpList;
break;
}
delete tmpList;
}
delete optList;
}
else {
terminateList = new TObjArray(4);
terminateList->SetOwner();
TString physSel = "", trigClasses = "", centr = "", furtherOpt = "";
if ( isMC ) {
physSel = "PhysSelPass,PhysSelReject";
trigClasses = "ANY";
centr = "-5_105";
furtherOpt = "MC verbose";
}
//TString GetPeriod(opt);
terminateList->AddAt(new TObjString(physSel),0);
terminateList->AddAt(new TObjString(trigClasses),1);
terminateList->AddAt(new TObjString(centr),2);
terminateList->AddAt(new TObjString(furtherOpt),3);
}
// if ( terminateList ) {
// printf("Printing terminate list\n"); // REMEMBER TO CUT
// PrintNames("Terminate options", terminateList);
// printf(" ***************:\n");
// }
return terminateList;
}
示例5: PlotSignalFits
void MakeSpinPlots::PlotSignalFits(TString tag, TString mcName,TString cosThetaBin){
TCanvas cv;
TString cat=tag;
if(cosThetaBin!="") tag = tag+"_"+cosThetaBin;
float mean = ws->var(Form("%s_FIT_%s_mean",mcName.Data(),tag.Data()))->getVal();
RooPlot *frame = ws->var("mass")->frame(105,140,70);//mean-10,mean+10,40);
RooAbsData *d = ws->data(mcName+"_Combined")->reduce(TString("evtcat==evtcat::")+cat);
if(cosThetaBin!=""){
TObjArray *arr = cosThetaBin.Tokenize("_");
float low = atof(arr->At(1)->GetName());
float high = atof(arr->At(2)->GetName());
d = d->reduce( Form("cosT < %0.2f && cosT >= %0.2f",high,low) );
delete arr;
}
d->plotOn(frame);
RooFitResult *res = (RooFitResult*)ws->obj(Form("%s_FIT_%s_fitResult",mcName.Data(),tag.Data()));
RooAbsPdf * pdf = ws->pdf(Form("%s_FIT_%s",mcName.Data(),tag.Data())); //signal model
std::cout << pdf << "\t" << res << std::endl;
pdf->plotOn(frame,RooFit::FillColor(kGreen),RooFit::VisualizeError(*res,2.0));
pdf->plotOn(frame,RooFit::FillColor(kYellow),RooFit::VisualizeError(*res,1.0));
pdf->plotOn(frame,RooFit::LineColor(kRed));
d->plotOn(frame); //data
tPair lbl(mcName,tag);
TLatex *prelim = new TLatex(0.18,0.9,"CMS Preliminary Simulation");
TLatex *sigL = new TLatex(0.18,0.6,Form("#sigma_{eff} = %0.2f GeV",fitSigEff[lbl].first,fitSigEff[lbl].second));
prelim->SetNDC();
sigL->SetNDC();
prelim->SetTextSize(0.05);
sigL->SetTextSize(0.05);
frame->addObject(prelim);
frame->addObject(sigL);
frame->Draw();
cv.SaveAs(basePath+Form("/signalModels/sig_%s_%s_%s.png",mcName.Data(),outputTag.Data(),tag.Data()));
cv.SaveAs(basePath+Form("/signalModels/C/sig_%s_%s_%s.C",mcName.Data(),outputTag.Data(),tag.Data()));
cv.SaveAs(basePath+Form("/signalModels/sig_%s_%s_%s.pdf",mcName.Data(),outputTag.Data(),tag.Data()));
}
示例6: DrawSysWatchTime
void DrawSysWatchTime(){
TString prefix="/hera/alice/marsland/MAF/MAFbenchmark/mcmaker/workdir/test_6_375000_25_20140713_20/";
TString listSyswatch = gSystem->GetFromPipe(Form("ls %s/*/mult_10000/event_1/simwatch.log",prefix.Data()));
TObjArray * arraySyswatch= listSyswatch.Tokenize("\n");
Int_t nfiles= arraySyswatch->GetEntries();
TTree * treeSyswatch[] = new TTree*[nfiles];
for (Int_t ifile=0; ifile<nfiles; ifile++){
treeSyswatch[ifile] = AliSysInfo::MakeTree(arraySyswatch->At(ifile)->GetName());
treeSyswatch[0]->AddFriend( treeSyswatch[ifile],Form("T%d",ifile));
}
treeSyswatch[0]->Draw("deltaT:sname","deltaT>1","");
for (Int_t ifile=1; ifile<nfiles; ifile++){
treeSyswatch[0]->SetMarkerStyle(25);
treeSyswatch[0]->SetMarkerColor(1+ifile);
treeSyswatch[0]->Draw(Form("T%d.stampSec-T%d.stampOldSec:sname",ifile,ifile),"deltaT>1","same");
}
}
示例7: Begin
//_____________________________________________________________________________
void ProofSimpleFile::Begin(TTree * /*tree*/)
{
// The Begin() function is called at the start of the query.
// When running with PROOF Begin() is only called on the client.
// The tree argument is deprecated (on PROOF 0 is passed).
TString option = GetOption();
// Number of histograms (needed in terminate)
Ssiz_t iopt = kNPOS;
if (fInput->FindObject("ProofSimpleFile_NHist")) {
TParameter<Long_t> *p =
dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimpleFile_NHist"));
fNhist = (p) ? (Int_t) p->GetVal() : fNhist;
} else if ((iopt = option.Index("nhist=")) != kNPOS) {
TString s;
Ssiz_t from = iopt + strlen("nhist=");
if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist = s.Atoi();
}
}
示例8:
Bool_t h10looper::Notify()
{
// The Notify() function is called when a new file is opened. This
// can be either for a new TTree in a TChain or when when a new TTree
// is started when using PROOF. It is normally not necessary to make changes
// to the generated code, but the routine can be extended by the
// user if needed. The return value is currently not used.
int tn = fChain->GetTreeNumber();
if (tn != fTreeNumber) {
TString fullfn = ((TChain*)fChain)->GetFile()->GetName();
TObjArray *tokens = fullfn.Tokenize("/");
TObjString *tok = (TObjString*)tokens->At(tokens->GetLast());
TString fn = tok->GetString();
data->run = ((TString)fn(*fRegExp_run)).Atoi();
data->file_anum = ((TString)((TString)fn(*fRegExp_Anum))(1,2)).Atoi();
data->filename = fn.Data();
delete tokens;
}
return kTRUE;
}
示例9: cacheGeometry
void cacheGeometry( const Char_t *tag, const Char_t *addons )
{
TFile *file = new TFile(Form("%s.root",tag));
if ( file->IsZombie() || nocache )
{
delete file;
const Char_t *path = ".:./StarVMC/Geometry/macros/:$STAR/StarVMC/Geometry/macros/";
Char_t *file = gSystem->Which(path,"loadStarGeometry.C",kReadPermission);
cout << "Loading macro: " << file << endl;
gROOT -> ProcessLine(Form(".L %s",file));
// Load development geometry
// loadDevStarGeometry(tag);
loadStarGeometry(tag);
TString addOns = addons;
TObjArray *array = addOns.Tokenize(" ,;");
for ( Int_t i = 0; i<array->GetEntries(); i++ )
{
TObjString *str = (TObjString *)array->At(i);
cout << "Adding module " << str->String().Data() << endl;
addModule ( str->String() );
}
// Close the geometry
gGeoManager->CloseGeometry();
ColorScheme();
gGeoManager->Export(Form("%s.root",tag));
}
delete file;
// gROOT -> Reset();
}
示例10: Proc_hYW
void ProcYields::Proc_hYW(){
Info("Proc_hYW()", "");
TDirectory* dirhYW = _fout->mkdir("hYW");
TH1F* hYW[nVARSET];
TDirectory* dirVarset=NULL;
for(Int_t iVarset=0;iVarset<nVARSET;iVarset++){
Info("Proc_hYW()","Varset = Varset%d", iVarset+1);
dirVarset=dirhYW->mkdir(TString::Format("Varset%d",iVarset+1));
dirVarset->cd();
hYW[iVarset] = new TH1F("hYW","hYW", _user.nWbins, _user.Wmin, _user.Wmax);
hYW[iVarset]->SetXTitle("W[GeV]");
//!Loop over Q2W dirs, get h5Ds and their yields
TIter nextkey(_fout->GetListOfKeys());
TKey *key;
while (key = (TKey*)nextkey()) {
TString Q2Wdirname = key->GetName();
if(Q2Wdirname.EqualTo("hYW_Dir") || Q2Wdirname.EqualTo("hYW"))continue;
Info("Proc_hYW()","Q2Wdir = %s", Q2Wdirname.Data());
TString wrange = Q2Wdirname.Tokenize("_")->At(1)->GetName();
TString wlow = wrange.Tokenize(",")->At(0)->GetName();
wlow.Remove(0,1); //remove "["
//Float_t w = wlow.Atof();
Double_t w = wlow.Atof();
sprintf(_hname, "%s/hY5D/Varset%d/hY5D_FULL", Q2Wdirname.Data(),iVarset+1);
THnSparse* hY5D_FULL = (THnSparse*)_fout->Get(_hname);
if (hY5D_FULL == NULL) cout <<"could not get h5D" << endl;
//Float_t yield = getIntegral(hY5D_FULL);
Double_t yield = getIntegral(hY5D_FULL);
//hYW[iVarset]->Fill(w, yield);
hYW[iVarset]->SetBinContent(hYW[iVarset]->FindBin(w+_intrinsic.Wbinw), yield);
Info("Proc_hYW()","W = %f, bin# = %d, yield = %f\n", w, hYW[iVarset]->FindBin(w+_intrinsic.Wbinw), yield);
}
}
Info("Proc_hYW()", "done\n");
}
示例11: RunTrain
/**
* Function to run a train.
*
* @param name Name of the train.
* @param cls class name of train setup
* @param uri Exection URI
* @param opts Optons
*
* @return true on success
*
* @ingroup pwglf_forward_trains
*/
Bool_t RunTrain(const TString& name, const TString& cls,
const TUrl& uri, const TString& opts)
{
// Check for help
if (name.IsNull() || name.EqualTo("help", TString::kIgnoreCase) ||
cls.IsNull() || cls.EqualTo("help", TString::kIgnoreCase) ||
!uri.IsValid()) {
PlainUsage();
return true;
}
Bool_t verb = opts.Contains("verbose");
// Build our helpers
if (!BuildRailways(verb, false, true)) return false;
// Tokenize options
if (!opts.EndsWith(",")) opts.Append(",");
opts.Append("url=");
opts.Append(uri.GetUrl());
TObjArray* optList = opts.Tokenize(",");
return TrainSetup::Main(name, cls, optList, false);
}
示例12: getFileMultiStringValue
bool getFileMultiStringValue( const char* inFile,
const char* parameterName,
int& nvals,
char returnVals[][1000] ) {
// Include a blank space at the end to avoid multiple
// matches in grep when target is a substring found in other lines.
char command[10000] ;
sprintf( command, "grep \"%s \" %s\n", parameterName, inFile ) ;
TString commandOutput = gSystem->GetFromPipe( command ) ;
/// printf( " Output of command is : %s\n", commandOutput.Data() ) ;
char label[1000] ;
sscanf( commandOutput.Data(), "%s", label ) ;
if ( strcmp( label, parameterName ) == 0 ) {
printf(" Found %s. \n", parameterName ) ;
TObjArray* strings = commandOutput.Tokenize(" ") ;
printf(" Breaks into %d tokens.\n", strings -> GetEntries() ) ;
nvals = strings -> GetEntries() - 1 ;
for ( int i=0; i<nvals; i++ ) {
TObjString* str = (TObjString*) (strings->At(i+1)) ;
printf( " string %d : %s\n", i, str->GetString().Data() ) ;
sprintf( returnVals[i], "%s", str->GetString().Data() ) ;
}
return true ;
}
printf("\n\n *** Could not find parameter %s in file %s.\n\n", parameterName, inFile ) ;
return false ;
}
示例13: ParseAndFindLimits
void KVNumberList::ParseAndFindLimits(TString & string, const Char_t delim)
{
//Takes a string and breaks it up into its constituent parts,
//which were initially separated by white space or a comma.
//Any part which contains "-" will be sent to AddLimits().
TObjArray *toks1 = string.Tokenize(delim);
Int_t n_toks = toks1->GetEntries();
for (register int i = 0; i < n_toks; i++) {
TString tok = ((TObjString *) (*toks1)[i])->GetString();
KVString kvtok(tok);
if (tok.Contains(','))
ParseAndFindLimits(tok, ',');
else if (tok.Contains(' '))
ParseAndFindLimits(tok, ' ');
else if (tok.Contains('-')) {
AddLimits(tok);
} else if (kvtok.IsDigit()) {
Int_t val = kvtok.Atoi();
AddLimits(val, val);
}
}
delete toks1;
}
示例14: LoadLibList
//##################################################
bool LoadLibList ( const TString& list, TString& listlibs, TString& listlibsextra ) {
TObjArray* arr = list.Tokenize(" ");
TObjString *objstr = NULL;
cout << "Loading library list (-2 = version mismatch, -1 = not found or error, 0 = success, 1 = already loaded) :" << endl;
TIter next(arr);
while ( (objstr=(TObjString*)next()) ) {
TString module = objstr->GetString();
if (module.IsNull()) { continue; }
module.Prepend("lib");
if(module.EndsWith(".so")) { module.Remove( module.Index(".so")); }
std::cout << "loading module :" << module.Data() << " ... " ;
int result = gSystem->Load(module.Data(), "", kTRUE);
std::cout << result << std::endl; ;
if (result < 0) { std::cout << "EmcalJetCDF::LoadLibList - Could not load library >>>" << module.Data() << "<<< ; Error = " << result << std::endl; return false; }
TString lib_in_list = module + ".so "; // blank after .so
listlibs += lib_in_list;
listlibsextra += lib_in_list;
}
delete arr;
return true;
}
示例15: AODmerge
//______________________________________________________________________________
void AODmerge()
{
// Merging method. No staging and no terminate phase.
TStopwatch timer;
timer.Start();
TString outputDir = "wn.xml";
TString outputFiles = "EventStat_temp.root,AODQA.root,AliAOD.root,AliAOD.VertexingHF.root,AliAODGammaConversion.root,FilterEvents_Trees.root,AliAOD.Muons.root";
TString mergeExcludes = "";
TObjArray *list = outputFiles.Tokenize(",");
TIter *iter = new TIter(list);
TObjString *str;
TString outputFile;
Bool_t merged = kTRUE;
while((str=(TObjString*)iter->Next())) {
outputFile = str->GetString();
// Skip already merged outputs
if (!gSystem->AccessPathName(outputFile)) {
printf("Output file <%s> found. Not merging again.",outputFile.Data());
continue;
}
if (mergeExcludes.Contains(outputFile.Data())) continue;
merged = AliAnalysisAlien::MergeOutput(outputFile, outputDir, 10, 0);
if (!merged) {
printf("ERROR: Cannot merge %s\n", outputFile.Data());
continue;
}
}
// all outputs merged, validate
AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
mgr->InitAnalysis();
mgr->SetGridHandler(new AliAnalysisAlien);
mgr->StartAnalysis("gridterminate",0);
ofstream out;
out.open("outputs_valid", ios::out);
out.close();
timer.Print();
}