当前位置: 首页>>代码示例>>C++>>正文


C++ TString::Index方法代码示例

本文整理汇总了C++中TString::Index方法的典型用法代码示例。如果您正苦于以下问题:C++ TString::Index方法的具体用法?C++ TString::Index怎么用?C++ TString::Index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TString的用法示例。


在下文中一共展示了TString::Index方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: catalogFile

//--------------------------------------------------------------------------------------------------
void catalogFile(const char *dir, const char *file)
{
  TString fileName = TString(dir) + slash +  + TString(file);
  //printf("Index: %d\n",fileName.Index("castor/cern.ch"));
  if (fileName.Index("castor/cern.ch") != -1)
    fileName = TString("castor:") + fileName;
  if (fileName.Index("pnfs/cmsaf.mit.edu") != -1) {
    fileName = dCacheDoor + fileName;
  }
  if (fileName.Index("mnt/hadoop/cms/store") != -1) {
    fileName.Remove(0,15);
    fileName = hadoopDoor + fileName;
  }
  
  printf("\n Opening: %s\n\n",fileName.Data());
  TFile* f       = TFile::Open(fileName.Data());

  TTree* tree = (TTree*) f->FindObjectAny("Delphes");
  if (tree) {
    printf("0000 %s %d %d\n",fileName.Data(),tree->GetEntries(),tree->GetEntries());
    return;
  }

  TTree* tree    = (TTree*) f->FindObjectAny("Events");
  if (tree)
    printf("XX-CATALOG-XX %s %d\n",fileName.Data(),tree->GetEntries());

  TTree* allTree = (TTree*) f->FindObjectAny("AllEvents");
  if (tree && allTree)
    printf("XX-CATALOG-XX %s %d %d\n",fileName.Data(),tree->GetEntries(),allTree->GetEntries());
}
开发者ID:blallen,项目名称:MitProd,代码行数:32,代码来源:runSimpleFileCataloger.C

示例2: MultiJobsMode

void KV_CCIN2P3_GE::GetBatchSystemParameterList(KVNameValueList& nl)
{
   // Fill the list with all relevant parameters for batch system,
   // set to their default values.
   //
   // Parameters defined here are:
   //   JobTime        [string]
   //   JobMemory      [string]
   //   JobDisk        [string]
   //   MultiJobsMode  [bool]
   //   RunsPerJob     [int]
   //   EMailOnStart   [bool]
   //   EMailOnEnd     [bool]
   //   EMailAddress   [string]

   KVBatchSystem::GetBatchSystemParameterList(nl);
   nl.SetValue("JobTime", fDefJobTime);
   nl.SetValue("JobMemory", fDefJobMem);
   nl.SetValue("JobDisk", fDefJobDisk);
   nl.SetValue("MultiJobsMode", MultiJobsMode());
   nl.SetValue("RunsPerJob", fRunsPerJob);
   nl.SetValue("EMailOnStart", kFALSE);
   nl.SetValue("EMailOnEnd", kFALSE);
   TString email = gSystem->GetFromPipe("email");
   if (email.Index('=') > -1) {
      email.Remove(0, email.Index('=') + 2);
      nl.SetValue("EMailAddress", email);
   }
   else
      nl.SetValue("EMailAddress", "");
}
开发者ID:FableQuentin,项目名称:kaliveda,代码行数:31,代码来源:KV_CCIN2P3_GE.cpp

示例3: 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;
  }
开发者ID:ktf,项目名称:AliPhysics,代码行数:38,代码来源:ExtractProd.C

示例4: catalogFile

//--------------------------------------------------------------------------------------------------
void catalogFile(const char *dir, const char *file)
{
  // set up the modules
  gMod->SetMetaDataString((TString(dir)+slash+TString(file)).Data());
  gMod->SetNFileSet(0);

  // set up analysis
  //hMod->Add(gMod);
  //gAna->SetSuperModule(hMod);
  gAna->SetSuperModule(gMod);
  
  TString fileName = TString(dir) + slash +  + TString(file);
  //printf("Index: %d\n",fileName.Index("castor/cern.ch"));
  if (fileName.Index("castor/cern.ch") != -1)
    fileName = TString("castor:") + fileName;
  if (fileName.Index("mnt/hadoop/cms/store") != -1) {
    fileName.Remove(0,15);
    fileName = hadoopDoor + fileName;
    gMod->SetMetaDataString(fileName.Data());
  }
  
  printf(" Adding: %s\n",fileName.Data());
  gAna->AddFile(fileName);
  gAna->SetUseHLT(0);
  gAna->SetCacheSize(64*1024*1024);

  // run the analysis after successful initialisation
  gAna->Run(false);
}
开发者ID:GuillelmoGomezCeballos,项目名称:MitProd,代码行数:30,代码来源:runFileCataloger.C

示例5: while

vector <TString> OnlineConfig::SplitString(TString instring,TString delim) 
{
  // Utility to split up a string on the deliminator.
  //  returns a vector of strings.

  vector <TString> v;

  TString remainingString = instring;
  TString tempstring = instring;
  int i;

  while (remainingString.Index(delim) != -1) {
    i = remainingString.Index(delim);
    tempstring.Remove(i);
    v.push_back(tempstring);
    remainingString.Remove(0,i+1);
    while(remainingString.Index(delim) == 0) {
      remainingString.Remove(0,1);
    }
    tempstring = remainingString;
  }

  while(tempstring.EndsWith(delim)) {
    tempstring.Chop();
  }
     
  if(!tempstring.IsNull()) v.push_back(tempstring);

  return v;
}
开发者ID:cipriangal,项目名称:pan,代码行数:30,代码来源:online.C

示例6: Begin

//_____________________________________________________________________________
void ProofSimple::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();
   Ssiz_t iopt = kNPOS;

   // Histos array
   if (fInput->FindObject("ProofSimple_NHist")) {
      TParameter<Long_t> *p =
         dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimple_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();
   }
   if (fNhist < 1) {
      Abort("fNhist must be > 0! Hint: proof->SetParameter(\"ProofSimple_NHist\","
            " (Long_t) <nhist>)", kAbortProcess);
      return;
   }

   if (fInput->FindObject("ProofSimple_NHist3")) {
      TParameter<Long_t> *p =
         dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimple_NHist3"));
      fNhist3 = (p) ? (Int_t) p->GetVal() : fNhist3;
   } else if ((iopt = option.Index("nhist3=")) != kNPOS) {
      TString s;
      Ssiz_t from = iopt + strlen("nhist3=");
      if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist3 = s.Atoi();
   }

   // Ntuple
   TNamed *nm = dynamic_cast<TNamed *>(fInput->FindObject("ProofSimple_Ntuple"));
   if (nm) {

      // Title is in the form
      //         merge                  merge via file
      //           |<fout>                      location of the output file if merge
      //           |retrieve                    retrieve to client machine
      //         dataset                create a dataset
      //           |<dsname>                    dataset name (default: dataset_ntuple)
      //         |plot                  for a final plot
      //         <empty> or other       keep in memory

      fHasNtuple = 1;
      
      TString ontp(nm->GetTitle());
      if (ontp.Contains("|plot") || ontp == "plot") {
         fPlotNtuple = kTRUE;
         ontp.ReplaceAll("|plot", "");
         if (ontp == "plot") ontp = "";
      }
      if (ontp.BeginsWith("dataset")) fHasNtuple = 2;
   }
}
开发者ID:My-Source,项目名称:root,代码行数:60,代码来源:ProofSimple.C

示例7: parseArg

// Helper functions to set argument
inline TString parseArg(const TString& input, TString arg, const TString dfval="") {
  if (!arg.EndsWith("=")) arg += "=";
  if (input.Contains(arg)) {
    int sidx = input.Index(arg) + arg.Sizeof() - 1;
    int eidx = input.Index(",", sidx);
    if (eidx < 0) eidx = input.Sizeof();
    return input(sidx, eidx-sidx);
  } else {
    return dfval;
  }
}
开发者ID:cmstas,项目名称:StopAnalysis,代码行数:12,代码来源:makeBkgEstimates.C

示例8: MakeCutLog

void MakeCutLog(const char *inputRootFile = "AnalysisResults",const char *path = "./", const char* outputDir="./Output/"){

  fstream outputFile(Form("%sCutSelection.log",outputDir),ios::out);
  if(!outputFile.is_open()){
    cout<<"Problem opening file"<<endl;
    return;
  }

  //  Char_t filename_input1[200] = (Form("%s%s",path,input1));	
  TString filename = Form("%s%s.root",path,inputRootFile);	
  TFile f(filename.Data());  

  TList *directories = f.GetListOfKeys(); // get the list of directories in the file
  
  for(Int_t entFile=0;entFile<directories->GetEntries();entFile++){

    TObject * o = f.Get(directories->At(entFile)->GetName()); // get the object in the base directory

    if(TString(o->IsA()->GetName())=="TDirectoryFile"){ // means that this is a directory (PWGGA......)
      
      TDirectory *pwg4dir =(TDirectory*)o;
 
      TString baseDirName = pwg4dir->GetName();
      
      TString reconstructionFlagString = ""; // this is for new scheme where also the flags are coded in numbers in the PWGGA.... name

      if(baseDirName.Length()>31){
	reconstructionFlagString = baseDirName(baseDirName.Index("GammaConversion_")+16,8);
      }
      
      TList *pwg4list = pwg4dir->GetListOfKeys(); // list of the yeys inside the base directory

      for(Int_t entHist=0;entHist<pwg4list->GetEntries();entHist++){
	TString name = pwg4list->At(entHist)->GetName();

	if(name.Contains("container")==0){ // does not try to read the container (get errors if tried)
	  TObject * oHist = pwg4dir->Get(pwg4list->At(entHist)->GetName()); // get the object 
	  
	  if(TString(oHist->IsA()->GetName())=="TList"){ // check if the object is a TList
	    
	    TString listname = oHist->GetName();
	    cout<<"Reading: "<<listname.Data()<<endl;
	    
	    TString cutString = listname(listname.Index("_")+1,listname.Length()) + "\n";// get the Cut string from the name


	    outputFile << cutString.Data();
	  }
	}
      }
    }
  }
  outputFile.close();
}
开发者ID:ktf,项目名称:AliPhysics,代码行数:54,代码来源:MakeCutLog.C

示例9: nPart

TString nPart(Int_t part,TString string)
{
    if (part <= 0) return "";
    for (int i = 1; i < part; i++)    //part-1 times
    {
        if (string.Index(";") < 0) return "";
        string.Replace(0,string.Index(";")+1,"",0);
    }
    if (string.Index(";") >= 0)
        string.Remove(string.Index(";"));
    return string;
}
开发者ID:awhitbeck,项目名称:usercode-JHU,代码行数:12,代码来源:axislabel.C

示例10: getFileNameAsimovPar

///
/// Compute the file name of the parameter file defining the Asimov
/// point where the Asimov toy is generated at.
/// The combiner name will be followed by the Asimov addition (getAsimovCombinerNameAddition()),
/// but without the number denoting the Asimov point in the file, as the file contains all points.
/// Format of returned filename:
///
/// plots/par/basename_combinernameAsimov[_+N][_-N]_var1[_var2]_genpoints.dat
///
/// \param c - Combiner object
/// \return - filename
///
TString FileNameBuilder::getFileNameAsimovPar(const Combiner *c)
{
	TString name = "plots/par/";
	name += getFileBaseName(c);
	// remove any string after the "Asimov" token and the first "_" after that
	// e.g.: "combinerAsimov3_" -> "combinerAsimov_"
	int startOfToken = name.Index(m_asimov);
	int startOfFirstUnderscore = name.Index("_",startOfToken);
	int length = startOfFirstUnderscore-(startOfToken+m_asimov.Sizeof())+1;
	name.Replace(startOfToken+m_asimov.Sizeof()-1, length, "");
	name += "_genpoints.dat";
	return name;
}
开发者ID:KonstantinSchubert,项目名称:gammacombo,代码行数:25,代码来源:FileNameBuilder.cpp

示例11: re

//_____________________________________________________________________________
Int_t THaDebugModule::THaDebugModule::ParseList()
{
    // Parse the list of variable/cut names and store pointers
    // to the found objects. Called from Process() the first time
    // this module is used.

    Int_t nopt = fVarString.GetNOptions();
    if( nopt > 0 ) {
        for( Int_t i=0; i<nopt; i++ ) {
            const char* opt = fVarString.GetOption(i);
            if( !strcmp(opt,"NOSTOP") )
                fFlags &= ~kStop;
            else {
                // Regexp matching
                bool found = false;
                TRegexp re( opt, kTRUE);
                TObject* obj;
                // We can inspect analysis variables and cuts/tests
                if( gHaVars ) {
                    TIter next( gHaVars );
                    while( (obj = next()) ) {
                        TString s = obj->GetName();
                        if( s.Index(re) != kNPOS ) {
                            found = true;
                            fVars.push_back(obj);
                        }
                    }
                }
                if( gHaCuts ) {
                    const TList* lst = gHaCuts->GetCutList();
                    if( lst ) {
                        TIter next( lst );
                        while( (obj = next()) ) {
                            TString s = obj->GetName();
                            if( s.Index(re) != kNPOS ) {
                                found = true;
                                fVars.push_back(obj);
                            }
                        }
                    }
                }
                if( !found ) {
                    Warning( Here("ParseList"),
                             "Global variable or cut %s not found. Skipped.", opt );
                }
            }
        }
    }
    return 0;
}
开发者ID:JeffersonLab,项目名称:d2n_analyzer,代码行数:51,代码来源:THaDebugModule.C

示例12: GetPathPass

  /** 
   * Get the pass from the path 
   * 
   * @param dir   Directory
   * @param run   Run number 
   * @param path  On return, the path 
   * @param pass  On return, the pass 
   * 
   * @return true on success 
   */
  Bool_t GetPathPass(const TString& dir, ULong_t run, 
		     TString& path, TString& pass) 
  {
    Int_t first = dir.Index(Form("%lu", run));
    Int_t last  = dir.Index("/", first);
    if (last == kNPOS) last = dir.Length();
    if (first == kNPOS) { 
      Error("GetPathPass", "Run number %lu not in path %s", run, dir.Data());
      return false;
    }
    while (dir[first-1] == '0') first--;
    path = dir(0, first);
    pass = dir(last+1,dir.Length()-last-1);
    return true;
  }
开发者ID:ktf,项目名称:AliPhysics,代码行数:25,代码来源:ExtractProd.C

示例13: ScaleError

///
/// Scale the error of a given observable.
/// Both stat and syst errors are being scaled by the same factor.
/// In order to become effective, the PDF needs to be rebuild by
/// calling buildCov() and buildPdf().
///
/// \param obsname	- observable name. It may or may not include a unique ID string, both works.
/// \param scale	- the scale factor the current error is being multiplied with
/// \return		- true if successful
///
bool PDF_Abs::ScaleError(TString obsname, float scale)
{
	// remove unique ID if necessary
	TString UID = "UID";
	if ( obsname.Contains(UID) ){
		obsname.Replace(obsname.Index(UID), obsname.Length(), ""); // delete the unique ID. That should leave just the observable name.
	}
	// find the index of the observable - if it exists at all!
	if ( !hasObservable(obsname) ){
		cout << "PDF_Abs::ScaleError() : ERROR : observable '" << obsname << "' not found." << endl;
		return false;
	}
	int index = -1;
	for ( int i=0; i<getNobs(); i++ ){
		if ( observables->at(i)->GetName()==obsname ){
			index = i;
			break;
		}
	}
	if ( index==-1 ){
		// this should never happen...
		cout << "PDF_Abs::ScaleError() : ERROR : internal self inconsistency discovered. Exit." << endl;
		assert(0);
	}
	// scale error
	StatErr[index] *= scale;
	SystErr[index] *= scale;
	// update error source string
	obsErrSource += " (PDF_Abs::ScaleError(): scaled error of " + obsname + ")";
	return true;
}
开发者ID:gammacombo,项目名称:gammacombo,代码行数:41,代码来源:PDF_Abs.cpp

示例14: Finish

void Finish(TString sDir = "")
{

  // Finishing Macro for running with Worker
  printf("Events: %d      Events Accepted: %d\n", 
	gAN->GetNEvent(), gAN->GetNEvAnalysed() );

  printf("\nEnd-of-Run macro executing\n");

  // If user has not specified output directory, pull from AR
  if(sDir.Length() == 0) sDir = gAR->GetTreeDir();
  if(sDir.Length() == 0) sDir = "~/";
  
  // Append "/" to Directory if unspecified
  if(!(sDir.EndsWith("/"))) sDir.Append("/");

  // Create output filename from input file name
  TString sFile;
  if (gAR->IsOnline()) sFile = gAR->GetFileName();
  else sFile = gAR->GetTreeFile()->GetName();
  while(sFile.Contains("/")) sFile.Remove(0,1+sFile.Index("/"));
  sFile.ReplaceAll(".dat",".root");
  sFile.Prepend("Hist_");
  sFile.Prepend(sDir);

  // Save histograms to file and close it
  TFile f(sFile, "recreate");
  f.SetCompressionLevel(4);
  gROOT->GetList()->Write();
  f.Close();
  cout << "All histograms saved to " << sFile << endl;

  gSystem->Exit(0);

}
开发者ID:LightninGreen,项目名称:acqu,代码行数:35,代码来源:FinishWorker.C

示例15: BuildBlock

//_____________________________________________________________________________
Int_t THaOutput::BuildBlock(const string& blockn)
{
  // From the block name, identify and save a specific grouping
  // of global variables by adding them to the fVarnames list.
  //
  // For efficiency, at the end of building the list we should
  // ensure that variables are listed only once.
  //
  // Eventually, we can have some specially named blocks,
  // but for now we simply will use pattern matching, such that
  //   block L.*
  // would save all variables from the left spectrometer.


  TRegexp re(blockn.c_str(),kTRUE);
  TIter next(gHaVars);
  TObject *obj;

  Int_t nvars=0;
  while ((obj = next())) {
    TString s = obj->GetName();
    if ( s.Index(re) != kNPOS ) {
      s.Append('\0');
      string vn(s.Data());
      fVarnames.push_back(vn);
      nvars++;
    }
  }
  return nvars;
}
开发者ID:hansenjo,项目名称:analyzer,代码行数:31,代码来源:THaOutput.C


注:本文中的TString::Index方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。