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


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

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


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

示例1: RecoQA

void RecoQA(const char* inFile) {
  gROOT->LoadMacro("bfcread_hist_prefixes_add_to_ps.C");

  TString baseName = inFile;
  if (baseName.EndsWith(".daq"))
    baseName.ReplaceAll(".daq",".hist.root");
  else if (baseName.EndsWith(".event.root"))
    baseName.ReplaceAll(".event.root",".hist.root");
  else if (baseName.EndsWith(".MuDst.root"))
    baseName.ReplaceAll(".MuDst.root",".hist.root");

  TString histFile = baseName;

  baseName.Remove(0,baseName.Last('/')+1);

  TString outputName = baseName;
  outputName.ReplaceAll(".root",".CC");

  TString histList = "StRoot/St_QA_Maker/QAhlist_Reco.h";
  if (! gSystem->Which(".",histList.Data()))
    histList.Prepend(gSystem->ExpandPathName("$STAR/"));
  
  bfcread_hist_prefixes_add_to_ps(histFile.Data(),"EventQA",
    "bfcTree",outputName.Data(),baseName.Data(),histList.Data());
}
开发者ID:star-bnl,项目名称:star-macros,代码行数:25,代码来源:RecoQA.C

示例2: GetMode

//______________________________________________________________________________
Int_t GetMode(TString inputFileName)
{
  if ( inputFileName.EndsWith(".xml") ) return kInteractif_xml;
  else if ( inputFileName.EndsWith(".txt") ) return kInteractif_ESDList;
  else if ( inputFileName.EndsWith(".root") ) return kLocal;
  return -1;
}
开发者ID:ktf,项目名称:AliPhysics,代码行数:8,代码来源:runNorm.C

示例3: PrintResults

void KVElasticCountRates::PrintResults(Double_t beam_intensity)
{
   // Print mean energy deposit & counting rate for given beam intensity in particles per second

   TIter it(&fHistos);
   TH1F* h;
   fRates.clear();

   std::vector<count_rate> count_rates;

   while ((h = (TH1F*)it())) {
      TString name = h->GetName();
      if (!name.EndsWith("_dW") && !name.EndsWith("_map")) {
         TH2F* map = (TH2F*)fHistos.FindObject(name + "_map");
         double rate = h->Integral() * fAtomicDensity * beam_intensity * fVolume / fNtirages;
         double emean = h->GetMean();
         KVDetector* det = gMultiDetArray->GetDetector(name);
         double fluence = rate / det->GetEntranceWindowSurfaceArea();
         double dissipation = emean * rate / det->GetEntranceWindowSurfaceArea();
         count_rates.push_back(
            count_rate(name, rate, emean, map->GetMean(), map->GetMean(2), fluence, dissipation)
         );
         fRates[name.Data()] = KVElasticCountRate(rate, emean, fluence, dissipation);
      }
   }
   std::sort(count_rates.begin(), count_rates.end(), compare_count_rates);

   for (std::vector<count_rate>::iterator it = count_rates.begin(); it != count_rates.end(); ++it) {
      it->print();
   }
}
开发者ID:GiuseppePast,项目名称:kaliveda,代码行数:31,代码来源:KVElasticCountRates.cpp

示例4: make_histos_syst_rawyield

void make_histos_syst_rawyield(TString file_syst, TString file_default, TString out_tag){

  TFile *f1 = new TFile(file_syst.Data(),"read");
  TFile *f2 = new TFile(file_default.Data(),"read");
  TDirectoryFile *dir1 = (TDirectoryFile*)(f1->Get("effunf"));
  TDirectoryFile *dir2 = (TDirectoryFile*)(f2->Get("effunf"));
  TList *list = dir1->GetListOfKeys();

  TFile *f = new TFile(Form("plots/ratiosyst_%s.root",out_tag.Data()),"recreate");

  for (int i=0; i<list->GetSize(); i++){
    TString name = dir1->GetListOfKeys()->At(i)->GetName();
    if (!(name.Contains("hreco_"))) continue;
    TObject *obj1 = dir1->Get(name.Data());
    assert(obj1);
    TObject *obj2 = dir2->Get(name.Data());
    assert(obj2);
    TString newname = name;
    newname.Append("_ratiosyst");
    if (name.EndsWith("_0")) newname.ReplaceAll("_0_","_EBEB_");
    if (name.EndsWith("_1")) newname.ReplaceAll("_1_","_EBEE_");
    if (name.EndsWith("_2")) newname.ReplaceAll("_2_","_EEEE_");
    TH1F *h = (TH1F*)(((TH1F*)obj1)->Clone(newname.Data()));
    h->SetTitle(h->GetName());
    h->Divide((TH1F*)obj2);
    for (int j=0; j<h->GetNbinsX(); j++) h->SetBinError(j+1,0);
    for (int j=0; j<h->GetNbinsX(); j++) h->SetBinContent(j+1,1+fabs(1-h->GetBinContent(j+1)));
    f->cd();
    h->Write();
  }

}
开发者ID:peruzzim,项目名称:diphoton,代码行数:32,代码来源:make_histos_syst_rawyield.C

示例5: takeDirectlyFromMC

void takeDirectlyFromMC(TFile* fin, TFile* fout, TString gentype) {

  TList* listOfDirs = fin->GetListOfKeys();
  for (auto k : *listOfDirs) {
    TString srname = k->GetName();
    if (!srname.Contains("sr")) continue;
    if (srname.Contains("base") || srname.Contains("incl") || srname.Contains("sb")) continue;
    if (gentype == "_1lepW" && !srname.EndsWith("2") && !srname.EndsWith("3")) continue;

    auto indir = (TDirectoryFile*) fin->Get(srname);
    auto outdir = (TDirectory*) fout->mkdir(srname);
    auto hlist = indir->GetListOfKeys();

    for (auto h : *hlist) {
      TString hname = h->GetName();
      if (!hname.BeginsWith("h_metbins" + gentype)) continue;
      TH1D* hin = (TH1D*) indir->Get(hname);
      outdir->cd();
      TH1D* hout = (TH1D*) hin->Clone(TString(hname).ReplaceAll(gentype, ""));
      for (int i = 1; i <= hout->GetNbinsX(); ++i) {
        // zero out negative yields
        if (hout->GetBinContent(i) < 0) {
          hout->SetBinContent(i, 0);
          hout->SetBinError(i, 0);
        }
      }
      hout->Write();

      if (yearSeparateSyst && (hname.EndsWith("Up") || hname.EndsWith("Dn"))) {
        for (int i = 1; i < 4; ++i) {
          TH1D* hcen_yi = (TH1D*) fbkgs[i]->Get(srname+"/h_metbins"+gentype);
          TH1D* hsys_yi = (TH1D*) fbkgs[i]->Get(srname+"/"+hname);
          if (hsys_yi && !hcen_yi) {
            cout << "Find " << srname+"/"+hname << " from " << fbkgs[i]->GetName() << " but not hcen " << srname+"/h_metbins"+gentype << " Should not happen?" << endl;
          }
          TH1D* hout_yi = (TH1D*) fin->Get(srname+"/h_metbins"+gentype)->Clone(TString(hname).Insert(hname.Length()-2, Form("%d", 15+i)).ReplaceAll(gentype, ""));
          if (hcen_yi) hout_yi->Add(hcen_yi, -1);
          if (hsys_yi) hout_yi->Add(hsys_yi);
          hout_yi->Write();
        }
      }
    }
    if (!outdir->Get("h_metbins")) {
      cout << "Didn't find yield hist for " << gentype << " in " << fin->GetName() << ":" << srname << "/. Faking a 0 one!" << endl;
      outdir->cd();
      // Get the MET binning from h_metbins, which shall always exist, and then set all bins to 0
      TH1D* hout = (TH1D*) fin->Get(srname + "/h_metbins")->Clone("h_metbins");
      for (int i = 1; i <= hout->GetNbinsX(); ++i) {
        hout->SetBinContent(i, 0);
        hout->SetBinError(i, 0);
      }
      hout->Write();
    }
  }
}
开发者ID:cmstas,项目名称:StopAnalysis,代码行数:55,代码来源:makeBkgEstimates.C

示例6: FindAny

void FindAny(bool found, const TString& fsname, TClass* cl, TString baseexpected, const char* ext, const char* tag) {

   if (baseexpected == "") {
      baseexpected = cl->GetName();
      Ssiz_t posCol = baseexpected.First('<');
      if (posCol != -1) {
         baseexpected.Remove(posCol, baseexpected.Length());
      }
      posCol = baseexpected.Last(':');
      if (posCol != -1) {
         baseexpected.Remove(0, posCol + 1);
      }
      baseexpected += ext;
   }

   if (!found) {
      if (baseexpected != "FAIL") {
         printf("FAIL: %s file for class %s not found\n", tag, cl->GetName());
      }
      return;
   } else {
      if (baseexpected == "FAIL") {
         printf("FAIL: expected to not find %s file for class %s but got %s\n",
                tag, cl->GetName(), fsname.Data());
         return;
      }
   }
   if (!fsname.EndsWith(baseexpected)) {
      printf("FAIL: class %s expected %s file %s, got %s\n",
             cl->GetName(), tag, baseexpected.Data(), fsname.Data());
      return;
   }
}
开发者ID:asmagina1995,项目名称:roottest,代码行数:33,代码来源:runFindSource.C

示例7: getTriggerTowerMap

int getTriggerTowerMap(TString src, std::map<unsigned, std::vector<unsigned> >& ttmap) {
   if (!src.EndsWith(".csv")) {
      std::cout << "Input filename must be .csv" << std::endl;
      return 1;
   }
   std::vector<unsigned> values;
   unsigned j = 0;
   std::string line, issline;
   std::ifstream ifs(src.Data());
   while (std::getline(ifs, line)) {
      std::istringstream iss(line);
      while (std::getline(iss, issline, ',')) { // split by commas
         if (j == 0) continue; // skip the first line
         values.push_back(std::stoi(issline));
      }
      ++j;
   }
   if (values.empty()) {
      std::cout << "Failed to read any trigger tower" << std::endl;
      return 1;
   }
   ttmap.clear();
   unsigned ttId = 0;
   for (unsigned i=0; i<values.size(); ++i) {
      if (i == 0) continue; // skip the first index
      if (values.at(i-1) <= 6 && values.at(i) <= 8) { // eta_idx, phi_idx
         ttId = (values.at(i-1)-1) * 8 + (values.at(i)-1); // mapped to 0-47
         ttmap.insert(std::make_pair(ttId, std::vector<unsigned>()));
      } else if (values.at(i) > 10000) {
         ttmap.at(ttId).push_back(values.at(i));
      }
   }
   return 0;
}
开发者ID:casarsa,项目名称:SLHCL1TrackTriggerSimulations,代码行数:34,代码来源:MakeHists.C

示例8: CompareResults

/** 
 * Compare results  
 * 
 * @param argv Commmand line parameters 
 *
 * @relates Compare 
 * @ingroup pwglf_forward_tracklets
 */
void CompareResults(const char** argv)
{
  TString newFile;
  TString oldFile;
  TString newTit("");
  TString oldTit("");
  const char** ptr = argv;
  while ((*ptr)) {
    TString argi = *ptr;
    ptr++;
    if (argi.Contains("help")) {
      Printf("Usage: CompareResults AFILE BFILE [ATITLTE [BTITLE]]");
      return;
    }
    if (argi.Contains("CompareResults.C")) continue;
    if (argi.BeginsWith("-")) continue;
    if (argi.EndsWith(".root")) {
      if (newFile.IsNull()) newFile = argi;
      else                  oldFile = argi;
    }
    else {
      if (newTit.IsNull())  newTit = argi;
      else  	            oldTit = argi;
    }
  }
  if (newTit.IsNull()) newTit = "New";
  if (oldTit.IsNull()) oldTit = "Old";
  
      
  CompareResults(newFile, oldFile, newTit, oldTit);
}
开发者ID:ktf,项目名称:AliPhysics,代码行数:39,代码来源:CompareResults.C

示例9: SETUP_LoadLibraries

Bool_t SETUP_LoadLibraries(const TString &libs) {

  // Loads a list of colon-separated libraries. Returns kTRUE on success, kFALSE
  // if at least one library couldn't load properly. Does not check for double
  // loads (but ROOT does).

  TString l;
  Ssiz_t from;

  while ( libs.Tokenize(l, from, ":") ) {
    if (l.IsNull()) continue;
    if (!l.BeginsWith("lib")) l.Prepend("lib");
    if (l.EndsWith(".so")) l.Remove(l.Length()-3, l.Length());

    ::Info(gMessTag.Data(), ">> Loading library %s...", l.Data());

    if (gSystem->Load(l.Data()) < 0) {
       ::Error(gMessTag.Data(), "Error loading %s, aborting", l.Data());
       return kFALSE;  // failure
    }
  }

  return kTRUE;  // success

  return 0;
}
开发者ID:MycrofD,项目名称:cern-alice-setup,代码行数:26,代码来源:AliRoot_SETUP.C

示例10: 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

示例11: 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

示例12: mergeFiles

void mergeFiles(const char* outputFile, const char* inputFilesDirectory) {
  // In an interactive ROOT session
  // Do the following
  // root > .L mergeFiles.C
  // root > mergeFiles("<outputFile>", "<inputFilesDirectory>")

  Target = TFile::Open(outputFile, "RECREATE");

  if(strncmp(inputFilesDirectory,"list-in-file:",13)==0) {
	  // Read input file list from a file
	  char const *list_in_file = inputFilesDirectory+13;
	  FILE *fp = fopen(list_in_file,"r");
	  if( !fp ) {
		  int the_errno = errno;
		  cerr << "Failed to open " << list_in_file << ": errno=" << the_errno << " " << strerror(errno) << endl;
		  return;
	  }
	  char fname[2048];
	  while( fgets(fname,sizeof(fname),fp)!=NULL ) {
		  char *newline = strchr(fname,'\n');
		  if( newline ) *newline = '\0';
		  if( !fname[0] ) continue;

          cout << "Merging root file: " << fname << endl;
          MergeRootfile( Target, fname );
	  }
	  fclose(fp);
  }
  else {
	void* dirp = gSystem->OpenDirectory(inputFilesDirectory);
	const char *entry = gSystem->GetDirEntry(dirp);
	while(entry != 0)
	{
		int len = strlen(entry);
		if(len >= 5 && strcmp(&entry[len - 5], ".root") == 0)
		{
			TString fileName;
			if(strncmp(inputFilesDirectory, "/pnfs", 5) == 0)
			{
				fileName = "dcap://";
            }
			fileName += inputFilesDirectory;
			if( !fileName.EndsWith("/") ) fileName += "/";
			fileName += entry;

			cout << "Merging root file: " << fileName << endl;
			MergeRootfile( Target, fileName );
        }
		entry = gSystem->GetDirEntry(dirp);
    }
  }

  // save modifications to target file
  WriteMergeObjects( Target );

  delete Target;
  Target = NULL;
}
开发者ID:ekfriis,项目名称:farmout,代码行数:58,代码来源:mergeFiles.C

示例13: checkConsistency

///
/// Perform a couple of consistency checks to make it easier
/// to find bugs:
/// - check if all observables end with '_obs'
/// - check if all predicted observables end with '_th'
/// - check if the 'observables' and 'theory' lists are correctly ordered
///
bool PDF_Abs::checkConsistency()
{
	if ( m_isCrossCorPdf ) return true;
	bool allOk = true;

	// check if all observables end with '_obs'
	TIterator* it = observables->createIterator();
	while ( RooRealVar* p = (RooRealVar*)it->Next() ){
		TString pObsName = p->GetName();
		pObsName.ReplaceAll(uniqueID,"");
		if ( !pObsName.EndsWith("_obs") ){
			cout << "PDF_Abs::checkConsistency() : " << name << " : observable " << p->GetName() << " doesn't end with '_obs'" << endl;
			allOk = false;
		}
	}

	// check if all predicted observables end with '_th'
	delete it; it = theory->createIterator();
	while ( RooRealVar* p = (RooRealVar*)it->Next() ){
		TString pThName = p->GetName();
		pThName.ReplaceAll(uniqueID,"");
		if ( !pThName.EndsWith("_th") ){
			cout << "PDF_Abs::checkConsistency() : " << name << " : theory " << p->GetName() << " doesn't end with '_th'" << endl;
			allOk = false;
		}
	}

	// check if the 'observables' and 'theory' lists are correctly ordered
	for ( int i=0; i<nObs; i++ ){
		RooAbsArg* pTh = theory->at(i);
		TString base = pTh->GetName();
		base.ReplaceAll("_th","");
		base.ReplaceAll(uniqueID,"");
		TString pObsName = observables->at(i)->GetName();
		pObsName.ReplaceAll(uniqueID,"");
		if ( pObsName != base+"_obs"){
			cout << "PDF_Abs::checkConsistency() : " << name << " : " << pTh->GetName() << " doesn't match its observable." << endl;
			cout << "                              Expected '" << base+"_obs" << "'. Found '" << pObsName << "'." << endl;
			cout << "                              Check ordering of the 'theory' and 'observables' lists!" << endl;
			allOk = false;
		}
	}

	return allOk;
}
开发者ID:gammacombo,项目名称:gammacombo,代码行数:52,代码来源:PDF_Abs.cpp

示例14: MakeOutputDir

inline TString MakeOutputDir(TString dir){
  if(!dir.EndsWith("/")) dir += "/";
  // Create directory if needed
  //  >> NOTE: This function needs to be called before the booking functions!
  char cmd[100];
  sprintf(cmd,"mkdir -p %s", dir.Data());
  system(cmd);
  return dir;
}
开发者ID:haweber,项目名称:StopAnalysis,代码行数:9,代码来源:Make2DSignifHistos.C

示例15: selectevents

long selectevents(const TString &fileName) {
    TChain* chain = new TChain("MVATree");
    if( fileName.EndsWith(".root") ) {
        chain->Add(fileName);
    }

    int N_Jets;
    chain->SetBranchAddress("N_Jets",&N_Jets);
    float* Jet_Pt = new float[120];
    chain->SetBranchAddress("Jet_Pt",Jet_Pt);
    float* Jet_Phi = new float[120];
    chain->SetBranchAddress("Jet_Phi",Jet_Phi);
    float DeltaPhi;
    chain->SetBranchAddress("DeltaPhi",&DeltaPhi);
    float PtAve;
    chain->SetBranchAddress("PtAve",&PtAve);
    float* Jet_Eta = new float[120];
    chain->SetBranchAddress("Jet_Eta",Jet_Eta);
    float* Jet_CSV = new float[120];
    chain->SetBranchAddress("Jet_CSV",Jet_CSV);
    float* Jet_HadFlav = new float[120];
    chain->SetBranchAddress("Jet_HadronFlav",Jet_HadFlav);
    float* Jet_PartFlav = new float[120];
    chain->SetBranchAddress("Jet_PartonFlav",Jet_PartFlav);
    float Weight_XS;
    chain->SetBranchAddress("Weight_XS",&Weight_XS);

    long nentries=0;
    long n_selected=0;
    float dphicut=2.7;
    float pt3cut=0.1;
    float etamin=2.1;

    nentries = chain->GetEntries();
    cout <<"counting events in "<< fileName << endl;
    cout << "total number of MC events: " << nentries << endl;
    for (long iEntry=0; iEntry<nentries; iEntry++) {
        if(iEntry%100000==0) cout << "analyzing event " << iEntry << endl;
//     if(iEntry>1000000) break;
        chain->GetEntry(iEntry);
        double ptave=PtAve;
        if(N_Jets >=2) {
            if (DeltaPhi> dphicut ) {
                if (abs(Jet_Eta[0])<etamin && abs(Jet_Eta[1])<etamin) {
                    if (N_Jets >=3) {
                        if (Jet_Pt[2]/ptave < pt3cut) n_selected++;
                    }
                    else if (N_Jets==2) n_selected++;
                }
            }
        }
    }
    cout << n_selected<< " Events selected" << endl;
    return n_selected;
}
开发者ID:sebwieland,项目名称:qcd_dijets,代码行数:55,代码来源:yieldstudy.C


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