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


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

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


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

示例1: getXrootdPid

Int_t getXrootdPid(Int_t port, const char *subdir)
{
#ifdef WIN32
   // No support for Xrootd/Proof on Win32 (yet; the optimized local Proof will work there too)
   Printf("getXrootdPid: Xrootd/Proof not supported on Windows, sorry!");
   return -1;
#else
   // Get the pid of the started xrootd process
   Int_t pid = -1;
#if defined(__sun)
   const char *com = "-eo pid,comm";
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
   const char *com = "ax -w -w";
#else
   const char *com = "-w -w -eo pid,command";
#endif
   TString cmd;
   if (subdir && strlen(subdir) > 0) {
      cmd.Form("ps %s | grep xrootd | grep \"\\-p %d\" | grep %s", com, port, subdir);
   } else {
      cmd.Form("ps %s | grep xrootd | grep \"\\-p %d\"", com, port);
   }
   FILE *fp = gSystem->OpenPipe(cmd.Data(), "r");
   if (fp) {
      char line[2048], rest[2048];
      while (fgets(line, sizeof(line), fp)) {
         sscanf(line,"%d %s", &pid, rest);
         break;
      }
      gSystem->ClosePipe(fp);
   }
   // Done
   return pid;
#endif
}
开发者ID:MycrofD,项目名称:root,代码行数:35,代码来源:getProof.C

示例2: tablesFile

void SampleDiagnostics::report(TString tablesPrefix, const Char_t* errata) const
{
  if (passedRate == 0) {
    std::cerr << "WARNING :  No accumulated rate for " << name << ". Maybe you just didn't run over it/them?" << std::endl;
    return;
  }


  TString           blurb;        blurb.Form("These results are for %s. %s", name.Data(), errata ? errata : "");
  std::ofstream     tablesFile    (tablesPrefix + ".tex");
  tablesFile << "\\documentclass[amsmath,amssymb]{revtex4}" << std::endl;
  tablesFile << "\\usepackage{longtable}" << std::endl;
  tablesFile << "\\usepackage{color}" << std::endl;
  tablesFile << "\\begin{document}" << std::endl;
  tablesFile << "\\tableofcontents" << std::endl;
  tablesFile << "\\clearpage" << std::endl << std::endl << std::endl;

  const UInt_t      numDatasets   = size();
  for (UInt_t iSet = 0; iSet < numDatasets; ++iSet)
    if (at(iSet).isNewTrigger)    at(iSet).report(tablesFile, *this, blurb);

  tablesFile << std::endl << std::endl << "\\end{document}" << std::endl;
  tablesFile.close();
  TString     pdfIt;
  pdfIt.Form("latex %s.tex ; latex %s.tex ; latex %s.tex ; dvipdf %s.dvi %s.pdf", tablesPrefix.Data(), tablesPrefix.Data(), tablesPrefix.Data(), tablesPrefix.Data(), tablesPrefix.Data());
  //pdfIt       += TString::Format(" & (rm %s.aux %s.dvi %s.tex %s.log %s.toc)", tablesPrefix.Data(), tablesPrefix.Data(), tablesPrefix.Data(), tablesPrefix.Data(), tablesPrefix.Data(), tablesPrefix.Data());
  pdfIt       += TString::Format(" ; rm %s.aux %s.dvi %s.log %s.toc", tablesPrefix.Data(), tablesPrefix.Data(), tablesPrefix.Data(), tablesPrefix.Data(), tablesPrefix.Data());
	//RR commenting the latex compilation for now
//   if (gSystem->Exec(pdfIt) == 0)   std::clog << "  +  " << tablesPrefix << ".pdf" << std::endl;
//   else  std::clog << "  -  " << tablesPrefix << ".pdf  ---  FAILED to compile tex file!" << std::endl;
}
开发者ID:CmsHI,项目名称:CVS_SavedFMa,代码行数:31,代码来源:HLTDatasets.cpp

示例3: Correct

void
Correct(UShort_t    flags=0x3,
	const char* side="middle",
	const char* var="none",
	Bool_t      forceK=false)
{
  const char* fwd = "$ALICE_PHYSICS/PWGLF/FORWARD/analysis2";
  if (gSystem->Getenv("ANA_SRC")) fwd = gSystem->Getenv("ANA_SRC");
  CorrectNS::AddPath(TString::Format("%s/dndeta/tracklets", fwd));
  if (!gROOT->GetListOfGlobals()->FindObject("kSimpleCorrectLoaded"))
    gROOT->LoadMacro("SimpleCorrect.C");
  TString v(var);
  if (v.EqualTo("PtPidStrK")) { forceK = true; v = "PtPidStr"; }
  Printf("Processing dt_%s_%s/trdt.root and mc_%s_%s/trmc.root",
	 side, "none", side, v.Data());
  SimpleCorrect(flags, TString(var).EqualTo("none") || forceK ? 2 : 3,
		Form("dt_%s_%s/trdt.root", side, "none"),
		Form("mc_%s_%s/trmc.root", side, v.Data()),
		9,
		"");
  TString resFile;
  resFile.Form("result_0x%x.root", flags & 0x3);
  TObject* resObj = gROOT->GetListOfFiles()->FindObject(resFile);
  if (resObj) {
    TFile* tmp = static_cast<TFile*>(resObj);
    Printf("Closing %s", tmp->GetName());
    tmp->Close();
  }
  gSystem->mkdir("partial", 1);
  TString dest;
  dest.Form("partial/%s_%s_0x%x.root", side, var, flags&0x3);
  Printf("%s -> %s", resFile.Data(), dest.Data());
  gSystem->Rename(resFile, dest);
}
开发者ID:ktf,项目名称:AliPhysics,代码行数:34,代码来源:Correct.C

示例4: make_scan_results

void make_scan_results()
{
  TFile *f = TFile::Open("scan_results.root", "UPDATE");

  f->Delete("SR;*");

  T = new TTree("SR", "Scanning results");

  TClonesArray* ts = new TClonesArray("IlcESDtrack", 32);
  TBranch * tb = T->Branch("T", &ts);
  delete ts;

  IlcMultiplicity *ms = 0;
  TBranch *mb = T->Branch("M", &ms);

  for (Int_t v = 0; v < 3; ++v)
  {
    vvv[v].vert   = 0;
    vvv[v].branch = T->Branch(vvv[v].bname, &vvv[v].vert);
  }

  for (Int_t i=0; i<=9999; ++i)
  {
    TString name;

    name.Form("Tracks_%04d", i);
    ts = (TClonesArray*) f->Get(name);
    if (ts == 0)
      continue;

    name.Form("Tracklets_%04d", i);
    ms = (IlcMultiplicity*) f->Get(name);
    if (ms == 0)
      Error("make_scan_results", "'%s' not found.", name.Data());

    tb->SetAddress(&ts);
    mb->SetAddress(&ms);

    for (Int_t v = 0; v < 3; ++v)
    {
      name.Form("%s_%04d", vvv[v].oname, i);
      vvv[v].vert = (IlcESDVertex*) f->Get(name);
      if (vvv[v].vert == 0)
        Error("make_scan_results", "'%s' not found.", name.Data());
      vvv[v].branch->SetAddress(&vvv[v].vert);
    }

    T->Fill();

    delete ts;
    delete ms;
    for (Int_t v = 0; v < 3; ++v) delete vvv[v].vert;
  }

  T->Write();

  f->Close();
  delete f;
}
开发者ID:brettviren,项目名称:ORKA-ILCRoot,代码行数:59,代码来源:make_scan_results.C

示例5: plot_mc

void plot_mc(string name="g", double q2=1.9, Int_t n=0)
{
//    SetAtlasStyle();
    TGraphErrors *p;

    TString nn;
    nn.Form("ave_%s_vs_x_for_Q2=%g",name.c_str(),q2);
    gDirectory->GetObject(nn,p);

//    p->Print();

    Double_t ratsize = 0.0;

    TCanvas *c = new TCanvas("PDF","pdf",600,600);
    TPad *pad1 = new TPad("pad1","pad1",0.,ratsize,1.,1.);
    pad1->SetLogx();
    pad1->Draw();
    pad1->cd();
    p->GetXaxis()->Set(101,0.0001,1.);
    p->SetFillColor(kRed-2);
    p->SetFillStyle(3001);
    p->SetLineWidth(1);
    p->SetLineColor(kRed);
    p->GetYaxis()->SetTitle(name.c_str());

    p->GetYaxis()->SetTitleSize(0.06);
    p->GetYaxis()->SetTitleOffset(1.);
    p->GetXaxis()->Set(101,0.0001,1.);
    p->Draw("ALE3");

    Double_t av = 0;
    Double_t av2 = 0;

    for (Int_t i = 1; i<n+1 ; i++) {
        nn.Form("%s_vs_x_for_Q^{2}=%g_%i",name.c_str(),q2,i);
        TGraph *pp = NULL;
        gDirectory->GetObject(nn,pp);
        if (pp != NULL) {
            pp->SetLineColor(kGreen);
            pp->Draw("L");

            av  += pp->GetY()[0];
            av2 += pp->GetY()[0]*pp->GetY()[0];
            cout << i << " "<<pp->GetY()[0] << endl;


        }
    }

    av  /= n;
    av2 = sqrt(av2/n - av*av);
//    cout << n << " "<<av << " "<< av2<<endl;


    p->Draw("E3C");


}
开发者ID:hep-mirrors,项目名称:h1fitter,代码行数:58,代码来源:plot_pdf.C

示例6: readBoard

Bool_t RawFileReader::readBoard(Entry &entry,RawData &rdata,Int_t N){
	if(N!=0 && N!=1){
		throw RDKException("Index out of range");
	}
	if(!bboard[N].good()){
		return false;
	}
	bboard[N].read();
	Bool_t startEntry=true;
	TString line;
	for(Int_t j=0;j<2;j++){
		if(!startEntry){
			break;
		}
		line=bboard[N].getString(4);
		startEntry&=line=="****";
	}
	if(!startEntry){
		return false;
	}
	entry.nseries=nseries;
	entry.nrun=nrun;
	bboard[N].getInt();
	entry.timestamp[N]=bboard[N].getDouble();
	Int_t n=bboard[N].getInt();
	if(n!=NCHANNELS/2){
		TString temp;
		temp.Form("Unknown file format: %X != %X in board %i at %X",n,NCHANNELS/2,N+1,(Int_t)bboard[N].tellg()-4);
		throw RDKException(temp);
	}
	Int_t hp=bboard[N].getInt();
	if(hp!=0xFF){
		TString temp;
		temp.Form("Unknown file format: %X != FF in board %i at %X",hp,N+1,(Int_t)bboard[N].tellg()-4);
		throw RDKException(temp);
	}
	Int_t min,max;
	if(N==0){
		min=0;
		max=NGAMMA/2;
	}else{
		min=NGAMMA/2;
		max=NGAMMA;
	}
	for(Int_t i=min;i<max;i++){
		bboard[N].copyShort(rdata.ch[i],NPOINTS);
	}
	Int_t mult=(NCHANNELS-NGAMMA)/2;
	for(Int_t i=0;i<mult;i++){
		bboard[N].copyShort(rdata.ch[NGAMMA+2*i+1-N],NPOINTS);
	}
	return true;
}
开发者ID:bwoneill,项目名称:rdk,代码行数:53,代码来源:RawFileReader.cpp

示例7: readBoard

Bool_t RDKReader::readBoard(Entry &entry,RawData &rdata,Int_t N){
	if(N!=0 && N!=1){
		throw RDKException("Index out of range");
	}
	if(!board[N]->good()){
		return false;
	}
	Bool_t startEntry=true;
	TString line;
	for(Int_t j=0;j<2;j++){
		if(!startEntry){
			break;
		}
		line=board[N]->readString(4);
		startEntry&=line=="****";
	}
	if(!startEntry){
		return false;
	}
	entry.nseries=nseries;
	entry.nrun=nrun;
	entry.nevent=board[N]->readInt();
	entry.timestamp[N]=board[N]->readDouble();
	//Double_t timestamp=board[1]->readDouble();
	Int_t n=board[N]->readInt();	//number of waves=8
	if(n!=NCHANNELS/2){
		TString temp;
		temp.Form("Unknown file format: %X != %X in board %i at %X",n,NCHANNELS/2,N+1,(Int_t)board[N]->tellg()-4);
		throw RDKException(temp);
	}
	Int_t hp=board[N]->readInt();
	if(hp!=0xFF){
		TString temp;
		temp.Form("Unknown file format: %X != FF in board %i at %X",hp,N+1,(Int_t)board[N]->tellg()-4);
		throw RDKException(temp);
	}
	Int_t min,max;
	if(N==0){
		min=0;
		max=NGAMMA/2;
	}else{
		min=NGAMMA/2;
		max=NGAMMA;
	}
	for(Int_t i=min;i<max;i++){
		board[N]->readData(NPOINTS,rdata.ch[i]);
	}
	Int_t mult=(NCHANNELS-NGAMMA)/2;
	for(Int_t i=0;i<mult;i++){
		board[N]->readData(NPOINTS,rdata.ch[NGAMMA+2*i+1-N]);
	}
	return true;
}
开发者ID:bwoneill,项目名称:rdk,代码行数:53,代码来源:RDKReader.cpp

示例8: GetName

const Char_t *KVSpectroDetector::GetDetectorEnv(const Char_t * type, const Char_t* defval, TEnv *env) const
{
   //Will look for env->GetValue "name_of_detector.type" if defined or "type_of_detector.type" if not.
   //If neither resource is defined, return the "defval" default value (="" by default).
   //If env is null then it looks for in gEnv.

	if( !env ) env = gEnv;

   TString temp;
   temp.Form("%s.%s", GetName(), type);
   if( !env->Defined(temp.Data()) )  temp.Form("%s.%s", GetType(), type);
   return env->GetValue(temp.Data(), defval);
}
开发者ID:pwigg,项目名称:kaliveda,代码行数:13,代码来源:KVSpectroDetector.cpp

示例9: open

void RawFileReader::open(Char_t t,Int_t series,Int_t run){
	if(isOpen){
		close();
	}
	bboard=new BufferedReader[2];
	bboard[0].resize(eventSize);
	bboard[1].resize(eventSize);
	header=new Header[2];
	size=new Long64_t[2];
	foot_size=new Long64_t[2];
	nseries=series;
	nrun=run;
	type=t;
	if(type=='S'){
		current=-1;
	}else if(type=='C' || type=='D'){
		current=0;
	}
	TString path;
	if(type){
		FileStat_t stats;
		for(Int_t i=0;i<2;i++){
			path.Form("%s/ss%i/%c%ir%ib%i.dat",RDKRAW,nseries,type,nseries,nrun,i+1);
			if(!gSystem->GetPathInfo(path,stats)){
				size[i]=stats.fSize;
				bboard[i].open(path);
				header[i].getHeader()->DeleteAll();
			}else{
				path.Form("Unable to stat ss%i/%c%ir%ib%i.dat",nseries,type,nseries,nrun,i+1);
				throw RDKException(path);
			}
		}
		if(type=='S' && size[0]!=size[1]){
			close();
			path.Form("File error: sizes of ss%i/S%ir%i*.dat do not match",nseries,nseries,nrun);
			throw RDKException(path);
		}
		for(Int_t i=0;i<2;i++){
			foot_size[i]=size[i];
			size[i]=(size[i]-5000)/eventSize;
			foot_size[i]-=5000+size[i]*eventSize;
		}
		isOpen=kTRUE;
		readHeader();
	}else{
		path.Form("Unable to type ss%i/*%ir%i",nseries,nseries,nrun);
		throw RDKException(path);
	}
}
开发者ID:bwoneill,项目名称:rdk,代码行数:49,代码来源:RawFileReader.cpp

示例10: next

KVTGID *KVRTGIDManager::GetTGID(const Char_t * ,
                               const Char_t * id_type,
                               const Char_t * grid_type){
   //Overrides the same method of KVTGIDManager. This method
   //Retrieve the identification object using:
   //      id_type   = type of identification ("Z", "A", "A_for_Z=3", etc.)
   //      grid_type = type of identification grid ("GG", "PG1", etc.)
   // but the name of ID telescope is not used anymore because identification
   // object can be associated to several ID telescopes.
   // If any object is found then it returns the first:
   //      - KVTGIDZA object if id_type contains "A"
   //      - KVTGIDZ  object else.

	Char_t  cname[9] = "KVTGIDZ";
	TString buff     = id_type;

	if(buff.Contains("A")) strcpy(cname,"KVTGIDZA");

	buff.Form("_%s_%s",id_type, grid_type);

	TIter next(&fIDList);
	KVTGID *tgid  = NULL;
	KVTGID *tgid2 = NULL;
	TString name;

	while( (tgid = (KVTGID *)next()) ){
		name = tgid->GetName();
		if(name.Contains(buff)) return tgid;
		if(!tgid2 && !strcmp(tgid->ClassName(),cname)) tgid2 = tgid;
	}

   return tgid2;
}
开发者ID:pwigg,项目名称:kaliveda,代码行数:33,代码来源:KVRTGIDManager.cpp

示例11: SetACQParams

void KVHarpeeIC::SetACQParams()
{
   // Setup acquisition parameters of this ionisation chamber.
   // ACQ parameters with type 'E':
   // E[detector type]_[A,B,C]_[detector number]
   //
   // WARNING: actually only the acquisition parameters with indice 'A'
   // are defined ('B' and 'C' were not coded in e494s and e503 experiment ).

   TString name;
   Char_t idx[] = {'A', 'B', 'C'};

   for (Int_t num = 1; num <= ARPEEIC_NSEG; num++) {
//    for(Int_t i = 0; i<3; i++){
      for (Int_t i = 0; i < 1; i++) {
         KVACQParam* par = new KVACQParam;
         name.Form("E%s_%c_%d", GetType(), idx[i], num);
         par->SetName(name);
         par->SetType("E");
         par->SetLabel(Form("%c", idx[i]));
         par->SetNumber(num);
         par->SetUniqueID(CalculateUniqueID(par));
         AddACQParam(par);
      }
   }
}
开发者ID:GiuseppePast,项目名称:kaliveda,代码行数:26,代码来源:KVHarpeeIC.cpp

示例12: seek

Bool_t RawFileReader::seek(Int_t i){
	Bool_t success=kFALSE;
	if(type=='S'){
		if(i>=0 && i<=size[0]){
			Long64_t position=5000+eventSize*i;
			bboard[0].seekg(position);
			bboard[1].seekg(position);
			success=kTRUE;
		}
	}else if(type=='C' || type=='D'){
		if(i>=0 && i<size[0]){
			current=0;
			Long64_t position=5000+eventSize*i;
			bboard[0].seekg(position);
			bboard[1].seekg(5000);
		}else if(i<=size[0]+size[1]){
			current=1;
			Long64_t position0=5000+size[0]*eventSize;
			Long64_t position1=5000+(i-size[0])*eventSize;
			bboard[0].seekg(position0);
			bboard[1].seekg(position1);
		}else{
			current=-1;
			TString temp;
			temp.Form("Out of bounds error: %ll",i);
			throw RDKException(temp);
		}
		success=kTRUE;
	}
	return success;
}
开发者ID:bwoneill,项目名称:rdk,代码行数:31,代码来源:RawFileReader.cpp

示例13: pulseHeights

void pulseHeights(Int_t board=112, TString file="latest.root", 
		  Int_t xmin=300, Int_t xmax=50){

  TFile *f = new TFile(file);
  // create a pointer to an event object for reading the branch values.
  TBEvent *event = new TBEvent();
  TTree *t1041 = (TTree*) f->Get("t1041");
  TBranch *bevent = t1041->GetBranch("tbevent");
  bevent->SetAddress(&event);
  
  TH1F *hpulse[32];
  for (int i=0; i<32; i++){
    TString name;
    name.Form("h%d_%2d",board,i);
    hpulse[i]=new TH1F(name,name,xmax-xmin,xmin,xmax);
  }


  // loop over events
  for (Int_t i=0; i< t1041->GetEntries(); i++) {
    t1041->GetEntry(i);
    // loop over PADE channels
    for (Int_t j=0; j<event->NPadeChan(); j++){
      if (event->GetPadeChan(j).GetBoardID() != board) continue;
      int chan=event->GetPadeChan(j).GetChannelID();
      hpulse[chan]->Fill(event->GetPadeChan(j).GetMax());
    }
  }
  
}
开发者ID:ShashlikTB,项目名称:T1041,代码行数:30,代码来源:pulseHeights.C

示例14: s

std::vector<int> getruns(const char * inputdir, int chip, string list = "") {

  std::vector<int> runs;

  gSystem->OpenDirectory(inputdir);
  ifstream in;
  string line;
  TString name;
  name.Form("runlist-%i%s.csv",chip,list.c_str());
  std::cout << "Opening " << name << endl;
  in.open(name);

  // Skip first line:
  getline(in,line);

  while(std::getline(in,line)){
    // Skip reading comments:
    if (line[0] == '#') continue;
    if(line.empty()) continue;

    istringstream s( line );
    int i = 0;
    int run;
    while (s) {
      string str;
      if(!getline( s, str, ',' )) break;
      if(i == 0) run = atoi(str.c_str()); // Read run number
      if(i == 4 && chip == atoi(str.c_str())) { runs.push_back(run); } // Read DUT chip id
      i++;
    }
  }

  in.close();
  return runs;
}
开发者ID:schuetzepaul,项目名称:testbeam-analysis,代码行数:35,代码来源:tools.C

示例15: StartXrootd

  /** 
   * Start a unique XRootd server and return it's access URL 
   * 
   * @param url On return, the access url 
   * 
   * @return true if successful, false otherwise 
   */
  static Bool_t StartXrootd(TString& url)
  {
    url = "";
    Int_t port = FindPort();
    if (port < 0) return false;

    // Get host, current directory, and user name for unique name
    TString host(gSystem->HostName());
    TString dir(gSystem->WorkingDirectory());
    TString name(gSystem->GetUserInfo()->fUser.Data());

    // Form the command line.  Note, we put the PID file one level up,
    // so we know where to look for it. Otherwise it would be put in a
    // sub-directory based on the name of the server.  Since we later
    // on don't know the name of the server we wouldn't now where to
    // look for the PID file
    TString exec;
    exec.Form("xrootd -p %d -l xrd.log -s ../xrd.pid -b -n %s %s",
	      port, name.Data(), dir.Data());
    Info("StartXrootd", "Starting XRootD to serve %s on port %d",
	 dir.Data(), port);
    Info("StartXrootd", "%s", exec.Data());
    int ret = gSystem->Exec(exec);
    if (ret != 0) {
      Warning("StartXrootd", "Failed to start XRootd server");
      return false;
    }
    
    // Form the access URL
    url = Form("root://%[email protected]%s:%d/%s",
	       name.Data(), host.Data(), port, dir.Data());
    Info("StartXrootd", "Access URL is \"%s\"", url.Data());

    return true;
  }
开发者ID:ktf,项目名称:AliPhysics,代码行数:42,代码来源:OutputUtilities.C


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