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


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

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


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

示例1: TotXSBin

void TotXSBin()
{
	Int_t ebin, i, count, chan;
	Double_t eg[27], deg[27], xs[27], dxs[27];
	Double_t egam, xxs, junk;
	TString name;

	c1 = new TCanvas( "c1", "Total Cross Sections", 200, 10, 700, 500);
	c1->SetGrid();
	c1->GetFrame()->SetFillColor( 21);
	c1->GetFrame()->SetBorderSize( 12);

	// Calculate the bin cross sections
	// For total cross sections, the theta bin is 0 for 0-180 deg.
	for ( ebin = 0; ebin < 24; BinXS( ebin+=2, 0));

	name = "xs/compton/xs/tot_xs_ebin.out";
	ofstream outFile( name);
	if ( !outFile.is_open()) {
		cout << "Error opening file ";
		cout << name;
		cout << endl;
		break;
	}
	count = 0;
	for ( ebin = 0; ebin < 24; ebin+=2) {
		eg[count] = tcdbin[ebin].energy;
		deg[count] = 0;
		xs[count] = tcdbin[ebin].xs[0];
		dxs[count] = tcdbin[ebin].dxs[0];
		outFile << eg[count] << "  " << xs[count] << "  " << dxs[count++]
			<< endl ;
	}
	outFile.close();

	// Plot Results
	gr = new TGraphErrors( count-1, eg, xs, deg, dxs);
	gr->SetTitle( "Preliminary #gamma p #rightarrow #gamma p Total Cross Section");
	gr->SetMarkerStyle( 20);
	gr->SetMarkerSize( 1.0);
	gr->SetLineWidth( 3);
	gr->GetXaxis()->SetTitleOffset( 1.1);
	gr->GetYaxis()->SetTitleOffset( 1.0);
	gr->GetYaxis()->SetTitleSize( 0.05);
	gr->GetXaxis()->SetTitle( "E_{#gamma} (MeV)");
	gr->GetYaxis()->SetTitle( "#sigma (#mub)");
	gr->GetXaxis()->SetLabelSize( 0.03);
	gr->GetYaxis()->SetLabelSize( 0.03);
	gr->GetXaxis()->CenterTitle();
	gr->GetYaxis()->CenterTitle();
	gr->GetXaxis()->SetRangeUser( 220, 310);
	gr->SetMaximum( 3);
	gr->SetMinimum( -0.1);
	gr->Draw( "AP");

	pt = new TLegend( 0.3, 0.7, 0.6, 0.85);
	pt->SetFillColor( 0);
	pt->SetBorderSize( 0);
	pt->SetTextSize( 0.04);

	pt->AddEntry( gr, "This Work", "p");

	// Theory
	name = "xs/compton/theory/totxs_params.dat";
	ifstream inFile( name);
	if ( !inFile.is_open()) {
		cout << "Error opening file ";
		cout << name;
		cout << endl;
		break;
	}
	i = 0;
	while( !inFile.eof()) {
		inFile >> egam >> xxs >> junk >> junk >> junk;
		eg[i] = egam;
		xs[i++] = xxs;
	}
	inFile.close();
	count = i-1;

	// Plot Results
	gr1 = new TGraph( count, eg, xs);
	gr1->SetLineWidth( 2);
//	gr1->SetLineStyle( 2);
//	gr1->SetLineColor( 2);
	gr1->Draw( "Lsame");

	pt->AddEntry( gr1, "Pasquini", "l");

	pt->Draw();

	name = "plots/Compton/xstot_ebin";
	name.Append( ".pdf");
	c1->Print( name);
}
开发者ID:collicott,项目名称:old-working-acqu,代码行数:95,代码来源:XSTry.C

示例2: TMVAMulticlass


//.........这里部分代码省略.........
         }
         Use[regMethod] = 1;
      }
   }

   // Create a new root output file.
   TString outfileName = "TMVAMulticlass.root";
   TFile* outputFile = TFile::Open( outfileName, "RECREATE" );

   TMVA::Factory *factory = new TMVA::Factory( "TMVAMulticlass", outputFile,
                                               "!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D:AnalysisType=multiclass" );
   TMVA::DataLoader *dataloader=new TMVA::DataLoader("dataset");

   dataloader->AddVariable( "var1", 'F' );
   dataloader->AddVariable( "var2", "Variable 2", "", 'F' );
   dataloader->AddVariable( "var3", "Variable 3", "units", 'F' );
   dataloader->AddVariable( "var4", "Variable 4", "units", 'F' );

   TFile *input(0);
   TString fname = "./tmva_example_multiple_background.root";
   if (!gSystem->AccessPathName( fname )) {
      // first we try to find the file in the local directory
      std::cout << "--- TMVAMulticlass   : Accessing " << fname << std::endl;
      input = TFile::Open( fname );
   }
   else {
      std::cout << "Creating testdata...." << std::endl;
      TString createDataMacro = TString(gROOT->GetTutorialsDir()) + "/tmva/createData.C";
      gROOT->ProcessLine(TString::Format(".L %s",createDataMacro.Data()));
      gROOT->ProcessLine("create_MultipleBackground(2000)");
      std::cout << " created tmva_example_multiple_background.root for tests of the multiclass features"<<std::endl;
      input = TFile::Open( fname );
   }
   if (!input) {
      std::cout << "ERROR: could not open data file" << std::endl;
      exit(1);
   }

   TTree *signalTree  = (TTree*)input->Get("TreeS");
   TTree *background0 = (TTree*)input->Get("TreeB0");
   TTree *background1 = (TTree*)input->Get("TreeB1");
   TTree *background2 = (TTree*)input->Get("TreeB2");

   gROOT->cd( outfileName+TString(":/") );
   dataloader->AddTree    (signalTree,"Signal");
   dataloader->AddTree    (background0,"bg0");
   dataloader->AddTree    (background1,"bg1");
   dataloader->AddTree    (background2,"bg2");

   dataloader->PrepareTrainingAndTestTree( "", "SplitMode=Random:NormMode=NumEvents:!V" );

   if (Use["BDTG"]) // gradient boosted decision trees
      factory->BookMethod( dataloader,  TMVA::Types::kBDT, "BDTG", "!H:!V:NTrees=1000:BoostType=Grad:Shrinkage=0.10:UseBaggedBoost:BaggedSampleFraction=0.50:nCuts=20:MaxDepth=2");
   if (Use["MLP"]) // neural network
      factory->BookMethod( dataloader,  TMVA::Types::kMLP, "MLP", "!H:!V:NeuronType=tanh:NCycles=1000:HiddenLayers=N+5,5:TestRate=5:EstimatorType=MSE");
   if (Use["FDA_GA"]) // functional discriminant with GA minimizer
      factory->BookMethod( dataloader,  TMVA::Types::kFDA, "FDA_GA", "H:!V:Formula=(0)+(1)*x0+(2)*x1+(3)*x2+(4)*x3:ParRanges=(-1,1);(-10,10);(-10,10);(-10,10);(-10,10):FitMethod=GA:PopSize=300:Cycles=3:Steps=20:Trim=True:SaveBestGen=1" );
   if (Use["PDEFoam"]) // PDE-Foam approach
      factory->BookMethod( dataloader,  TMVA::Types::kPDEFoam, "PDEFoam", "!H:!V:TailCut=0.001:VolFrac=0.0666:nActiveCells=500:nSampl=2000:nBin=5:Nmin=100:Kernel=None:Compress=T" );

   if (Use["DNN"]) {
       TString layoutString ("Layout=TANH|100,TANH|50,TANH|10,LINEAR");
       TString training0 ("LearningRate=1e-1, Momentum=0.5, Repetitions=1, ConvergenceSteps=10,"
                          " BatchSize=256, TestRepetitions=10, Multithreading=True");
       TString training1 ("LearningRate=1e-2, Momentum=0.0, Repetitions=1, ConvergenceSteps=10,"
                          " BatchSize=256, TestRepetitions=7, Multithreading=True");
       TString trainingStrategyString ("TrainingStrategy=");
       trainingStrategyString += training0 + "|" + training1;
       TString nnOptions ("!H:V:ErrorStrategy=CROSSENTROPY:VarTransform=N:"
                          "WeightInitialization=XAVIERUNIFORM:Architecture=STANDARD");
       nnOptions.Append (":"); nnOptions.Append (layoutString);
       nnOptions.Append (":"); nnOptions.Append (trainingStrategyString);
       factory->BookMethod(dataloader, TMVA::Types::kDNN, "DNN", nnOptions );
   }

   // Train MVAs using the set of training events
   factory->TrainAllMethods();

   // Evaluate all MVAs using the set of test events
   factory->TestAllMethods();

   // Evaluate and compare performance of all configured MVAs
   factory->EvaluateAllMethods();

   // --------------------------------------------------------------

   // Save the output
   outputFile->Close();

   std::cout << "==> Wrote root file: " << outputFile->GetName() << std::endl;
   std::cout << "==> TMVAClassification is done!" << std::endl;

   delete factory;
   delete dataloader;

   // Launch the GUI for the root macros
   if (!gROOT->IsBatch()) TMVAMultiClassGui( outfileName );


}
开发者ID:gbitzes,项目名称:root,代码行数:101,代码来源:TMVAMulticlass.C

示例3: MC_Ratio

int MC_Ratio(int leptonId, double* par1, int npar1bins, double* par2, int npar2bins, TString sel_den , TString sel_num, double cut_num , TString par_x , TString par_y , TString option ){

  setTDRStyle();

  ///////////////
  //Get the TTree
  ///////////////

  //Location of the .root file
  TString location2 = "/Users/GLP/Desktop/CERN_data/dyjetsnew/postprocessed/";

  //Reading the tree 
  //
  TChain* tree = new TChain("treeProducerSusyMultilepton");

  //DY events
  //tree->Add(location+"DYJetsToLLM50_PU_S14_POSTLS170.root");
  tree->Add(location2+"dyjets_good.root");

  //Plot the result

  Long64_t n = tree->GetEntries();

  //Path for input and output file. Written in FitDataPath.txt
  TString _path = "/Users/GLP/Dropbox/Physique/Master_Thesis/plots_root/MC_eff/";

  //////////////////////
  //Name for the plots//
  //////////////////////

  TString _filetag = "";

  TString pname;
  TString _pname;
  TString _par;
  TString _sel_num;
  TString _sel_den;
  TString _option;

  ////Writing string
  //particle string
  if(abs(leptonId) == 11){pname = "e"; _pname = "e";}
  if(abs(leptonId) == 13){pname = " #mu"; _pname = "mu";}
  //Parameter string
  if(par_x == "Pt"){_par = "P_{t}";}
  else if(par_x == "eta"){_par = "#eta";}
  else if(par_x == "phi"){_par = "#phi";}
  //sel_den string
  if((sel_den == "tightmva")&&(leptonId == 13)){cout<<"ERROR: no tightId MVA defined for the muon !"<<endl;return 1;}
  if(sel_den == "tightcut"){_sel_den = "tightcut";}
  else if(sel_den == "tightmva"){_sel_den = "tightmva";}
  else if(sel_den == "loose"){_sel_den = "loose";}
  else if(sel_den == ""){_sel_den = "";}
  else{cout<<"ERROR: wrong sel_denion !";return 1;}
  //sel_num string
  if((sel_num == "tightmva")&&(leptonId == 13)){cout<<"ERROR: no tightId MVA defined for the muon !"<<endl;return 1;}
  if(sel_num == "tightcut"){_sel_num = "tightcut";}
  else if(sel_num == "tightmva"){_sel_num = "tightmva";}
  else if(sel_num == ""){_sel_num = "";}
  else if(sel_num == "loose"){_sel_num = "loose";}
  else if(sel_num == "reliso3"){_sel_num = Form("reliso3_%0.3lf",cut_num);}
  else if(sel_num == "reliso4"){_sel_num = Form("reliso4_%0.3lf",cut_num);}
  else if(sel_num == "chiso3"){_sel_num = Form("chiso3_%0.3lf",cut_num);}
  else if(sel_num == "chiso4"){_sel_num = Form("chiso4_%0.3lf",cut_num);}
  else if(sel_num == "dxy"){_sel_num = Form("dxy_%0.3lf",cut_num);}
  else if(sel_num == "dz"){_sel_num = Form("dz_%0.3lf",cut_num);}
  else{cout<<"ERROR: wrong numerator name !";return 1;}
  //option string
  option.Append(" ");
  option.Prepend(" ");
  if(option.Contains(" ll ")){_option += "_ll";}
  if(option.Contains(" unmatched ")){_option += "_unmatched";}
  if(option.Contains(" alleta ")){_option += "_alleta";}
  if(option.Contains(" short ")){_option += "_short";}
  _option += "_";
  //parameter range string
  TString _par1range;
  _par1range = Form("%0.3f_"+par_x+"%0.3f",par1[0],par1[npar1bins]);
  TString _par2range;
  _par2range = Form("%0.3f_"+par_y+"%0.3f",par2[0],par2[npar2bins]);

  /////////////////////////////////////
  //Write the name of the output file//
  /////////////////////////////////////

  TString _fname = "MCeff"+_filetag+_option+_pname+_par1range+"_"+_par2range+"_den_"+_sel_den+"_num_"+_sel_num;

  //Output file
  cout<<"going to create the file"<<endl;
  //Check if the file exists
  TFile *fcheck = TFile::Open(_path+_fname+".root", "READ");
  if (fcheck) {
    cout << "File "<<_fname<<" exists ! Please change name" << endl;
    return 1;
  }

  TFile* file_out = new TFile(_path+_fname+".root","recreate");
  cout<<"done ! "<<endl;

  //Declaration of histogram
//.........这里部分代码省略.........
开发者ID:ETHZ,项目名称:SSDLBkgEstimationTP,代码行数:101,代码来源:MC_Ratio2.C

示例4: initIntWght

// iSyst =  0 : Cent
//         +1 :
//         -1 : 
void initIntWght(std::string wFile , int iType , int iSyst, float Hmass = 350, float cprime = 1.0) { // c'=1.0 --> SM

   if ( iType == 0 ) { //---- ggH 
     TFile* f = new TFile(wFile.c_str() , "READ");
     gROOT->cd();
     if (hInt_ggH) hInt_ggH->Delete();
     hInt_ggH = new TH1F("h_MWW_rel_NNLO_cen","h_MWW_rel_NNLO_cen",2000,0.,4000.);
     TH1F* hCen = (TH1F*) f->Get("h_MWW_rel_NNLO_cen");
     TH1F* hUp  = (TH1F*) f->Get("h_MWW_rel_NNLO_mul");
     TH1F* hDo  = (TH1F*) f->Get("h_MWW_rel_NNLO_add");
     // low/high Mass -> no value
     float firstM    = 9999.;
     float lastM     = -1.  ;
     float firstVal  = -1;
     float lastVal   = -1;
     bool  foundFirst=false;
     bool  foundLast =false;
     for ( int iBin = 1 ; iBin <= hCen->GetNbinsX() ; ++iBin ) {
       float m  = hCen->GetBinCenter(iBin);
       float v  = hCen->GetBinContent(iBin);
       if (v != 0 && ! foundFirst && m < Hmass ) {
         firstVal   = v ;
         firstM     = m ;
         foundFirst = true;
       }
       if ( m > Hmass && v==0) foundLast = true;
       if (!foundLast) {
         lastVal   = v ;
         lastM     = m ;
       }
     }
     // Create Histograms 
     for ( int iBin = 1 ; iBin <= hInt_ggH->GetNbinsX() ; ++iBin ) {
       float m = hInt_ggH->GetBinCenter(iBin);
       if ( m >= hCen->GetXaxis()->GetXmin() && m <= hCen->GetXaxis()->GetXmax() ) {
         int jBin = hCen->FindBin(m);
         if (iSyst ==  0) hInt_ggH->SetBinContent(iBin,hCen->GetBinContent(jBin));
         if (iSyst ==  1) hInt_ggH->SetBinContent(iBin,hUp->GetBinContent(jBin));
         if (iSyst == -1) hInt_ggH->SetBinContent(iBin,hDo->GetBinContent(jBin));
       } 
       if ( m < firstM || m < hCen->GetXaxis()->GetXmin() ) {
         if (iSyst ==  0) hInt_ggH->SetBinContent(iBin,firstVal);
         if (iSyst ==  1) hInt_ggH->SetBinContent(iBin,firstVal*2);
         if (iSyst == -1) hInt_ggH->SetBinContent(iBin,0.        );
       }
       if ( m > lastM  || m > hCen->GetXaxis()->GetXmax() ) {
         if (iSyst ==  0) hInt_ggH->SetBinContent(iBin,lastVal);
         if (iSyst ==  1) hInt_ggH->SetBinContent(iBin,0.     );
         if (iSyst == -1) hInt_ggH->SetBinContent(iBin,lastVal*2);
       }

     } 
     //hInt_ggH->Draw();
     //hUp->Draw("same");
     wInt_ggH = new TSpline3(hInt_ggH) ;
     wInt_ggH->SetLineColor(kRed); 
     wInt_ggH->Draw("same");
     //gPad->WaitPrimitive();
     f->Close();
   }
   else if ( iType ==1 ) { //---- qqH

    TString *readfile = new TString ("data/InterferenceVBF/file_for_interpolation.root"); //file with the values of the all parameters
    TFile* SI = new TFile(readfile->Data());
    Double_t fill_param[16]; // 9 + 7 = 16

    for (int i=0; i<9; i++) {
     TString *name = new TString (parameters_normal[i]);
     name->Append("_SI.txt");
     variables_SI[i] = (TGraph2D*)SI->Get(name->Data());
    }
    for (int i=0; i<7; i++) {
     TString *name = new TString (parameters_normal[i]);
     name->Append("_S.txt");
     variables_S[i] = (TGraph2D*)SI->Get(name->Data());
    }

    crystal_Icorr_qqH = new TF1("crystal_Icorr_qqH",CrystalBallLowHighPlusExpDividedByCrystalBallLowHigh,0,3000,16);

    for (int iVar = 0; iVar<9; iVar++) {
     crystal_Icorr_qqH->SetParameter(iVar, variables_SI[iVar]->Interpolate(Hmass, cprime));
    }
    for (int iVar = 0; iVar<7; iVar++) {
     crystal_Icorr_qqH->SetParameter(iVar+9, variables_S[iVar]->Interpolate(Hmass, cprime));
    }

   }

}
开发者ID:d4space,项目名称:HWWAnalysis,代码行数:92,代码来源:getIntWght.C

示例5: plot


//.........这里部分代码省略.........
  input.open(inName.Data());

  // Second loop to fill histograms
  while (1) {

    // Read file
    input >> file >> content >> version >> n1 >> tRequest >> n2 >> tReceived
	  >> tComplete >> size >> machine;

    // Good file?
    if (! input.good())
      break;

    // During time interval?
    if (xStart > tReceived)
      continue;
    if (xStop 	< tComplete)
      continue;

    // Filter invalid older data
    if (rejectT3btch(machine))
      continue;

    tLag  = tReceived - tRequest;
    tDown = tComplete - tReceived;
    rate  = size/double(tDown);

    if (tDown <= 0)
      continue;

    if (size <= 0)
      continue;

    if (tLag != 0)
      h1->Fill(float(tLag));

    h2->Fill(rate,size);

    for (int i=0; i<machines.size(); i++) {
      TString machineName = TString(machines[i]);
      if (machineName == machine) {
        h[i]->Fill(rate,size);
        break;
      }
    }

    i++;
  }
  input.close();

 go:

  if (empty) {
    h1->Fill(null,null);
    h2->Fill(null,null);
  }

  if (empty) {
    for (int i=0; i<machines.size(); i++) {
      h[i]->Fill(null,null);
    }
  }

  // Draw the histograms, each to its own canvas
  TCanvas *c1 = new TCanvas("c1","Overall lag time between request and receipt");
  TCanvas *c2 = new TCanvas("c2","Overall average download speed");

  c1->cd();
  h1->GetXaxis()->SetTitle("Lag time [sec]");
  h1->GetYaxis()->SetTitle("Number of requests");
  h1->Draw();
  //overlayFrame(TString("t3 cluster"),1);
  overlayFrame(text,0);
  c1->SaveAs(sc1.Data());

  c2->cd();
  h2->GetXaxis()->SetTitle("Speed [GB/sec]");
  h2->GetYaxis()->SetTitle("Data downloaded [GB]");
  h2->Draw();
  overlayFrame(TString("t3 cluster"),1);
  overlayFrame(text,0);
  c2->SaveAs(sc2.Data());

  for (int i=0; i<machines.size(); i++) {
    TString machineName = TString(machines[i]);

    TCanvas *c = new TCanvas("c",machineName.Data());

    TString s = machineName.Append(sc.Data());
    c->cd();
    h[i]->GetXaxis()->SetTitle("Speed [GB/sec]");
    h[i]->GetYaxis()->SetTitle("Data downloaded [GB]");
    h[i]->Draw();
    overlayFrame(TString(machines[i]),1);
    overlayFrame(text,0);
    c->SaveAs(s.Data());
  }

  return;
}
开发者ID:BambuPhysics,项目名称:MitPlots,代码行数:101,代码来源:plotSmartCacheRequests.C

示例6: RestoreXML

void RestoreXML( vector<string> input_filenames, vector<string> other_params )
{
	string SaveAs="--SaveAs";
	string SaveAs2="-SaveAs";

	TString XMLName = "XMLFile_";

	for( unsigned int i=0; i< other_params.size(); ++i )
	{
		string thisString = other_params[i];
		size_t found = thisString.find(SaveAs);
		size_t found2 = thisString.find(SaveAs2);

		if( found2 != string::npos )
		{
			found = found2;
		}

		if( found != string::npos )
		{
			string newName = StringOperations::SplitString( thisString, ':' )[1];
			string xmlext=".xml";
			size_t foundext = newName.find(xmlext);
			if( foundext != string::npos ) newName = StringOperations::SplitString( thisString, '.' )[0];

			XMLName = newName.c_str();
			XMLName.Append("_");
		}
	}

	for( unsigned int i=0; i< input_filenames.size(); ++i )
	{
		TString thisXMLName = XMLName;

		thisXMLName+=i; thisXMLName.Append("_");

		thisXMLName.Append( StringOperations::TimeString() );

		thisXMLName.Append( ".xml" );

		TTree* runtimeXML = ROOT_File_Processing::GetTree( input_filenames[i], "FittingXML" );

		vector<string>* thisXML = new vector<string>();

		runtimeXML->SetBranchAddress( "FittingXML", &thisXML );

		runtimeXML->GetEntry(0);

		cout << "Saving output XML to file:\t" << thisXMLName << endl;
		cout << endl;

		stringstream full_xml;

		for( unsigned int j=0; j< thisXML->size(); ++j )
		{
			full_xml << (*thisXML)[j] << endl;
		}

		ofstream output_xmlFile;
		output_xmlFile.open( thisXMLName.Data() );

		output_xmlFile << full_xml.str();

		output_xmlFile.close();
	}
}
开发者ID:gcowan,项目名称:mphys-parallel,代码行数:66,代码来源:RapidPlot.C

示例7: SetupReweighting

  /** 
   * Analyse the reweighting option string and set options on task
   * appropriately.  The string is a comma or space separated list of
   * what to reweigh and how to do it. 
   *
   * What to reweigh can be specfied using one or more of the strings 
   *
   * - pt  Reweight in pT 
   * - pid Reweight particle abundance of pi, K, proton 
   * - str Reweight particles from strange weak decays 
   *
   * How to reweigh can be specifed as 
   *
   * - + or up   Increase weights (for pt < 0.05 by +30%)
   * - - or down Decrease weights (for pt < 0.05 by -30%)
   * - If none of these are given, then the weights are used as is. 
   * 
   * If pid rewighting is done and one of up or down are given, then
   * one can specify which particle type to reweigh
   *
   * - pi or pion    Reweight (up or down) pions 
   * - K  or kaon    Reweight (up or down) kaons
   * - p  or proton  Reweight (up or down) protons 
   *
   * Note, if PID, with explicit selection of pions, and strangeness
   * reweighting are specified, then the up/down flag applies to both
   * PID reweighting and the strangeness reweighting
   * 
   * @param task The task to modify 
   */
  void SetupReweighting(AliAnalysisTaskSE* task)
  {
    TString sel = fOptions.AsString("reweight");
    sel.ToLower();
    if (sel.IsNull() || sel.BeginsWith("no"))
      return;

    TList       files;
    Int_t       what = 0;
    Int_t       opt  = 0;
    TObjArray*  tokens = sel.Tokenize(", ");
    TIter       next(tokens);
    TObjString* ostr;
    // First find what should be done 
    while ((ostr = static_cast<TObjString*>(next()))) {
      const TString& token = ostr->String();
      
      if      (token.EqualTo("pt"))   {
	what |= 0x1;
	files.Add(new TObjString("REWEIGHTpt.root"));
	Printf("Will reweigh in pT");
      }
      else if (token.EqualTo("pid")) {
	what |= 0x2;
	Printf("Will reweigh particle species");
      }
      else if (token.EqualTo("str"))  {
	what |= 0x4;
	Printf("Will reweight particles from strange weak decays");
      }
    }
    if (what == 0x0) return;
    
    // Now figure out how to do it 
    next.Reset();
    TString part;
    while ((ostr = static_cast<TObjString*>(next()))) {
      const TString& token = ostr->String();
      Int_t aOpt = TMath::Abs(opt);
      if      (token.EqualTo("up")   || token.EqualTo("+")) 
	opt = (aOpt==0 ? +1 : +aOpt); 
      else if (token.EqualTo("down") || token.EqualTo("-"))
	opt = (aOpt==0 ? -1 : -aOpt);
      else if (token.EqualTo("pi")   || token.EqualTo("pion")){
	  opt = 1; part = "pi";
      }
      else if (token.EqualTo("k")    || token.EqualTo("kaon")) {
	opt = 2; part = "ka";
      }
      else if (token.EqualTo("p")    || token.EqualTo("proton")) {	  
	opt = 3; part = "pr";
      }
    }
    if (opt != 0)
      Printf("Will reweigh %s (%c30%% for pT<0.05)",
	     opt < 0 ? "down" : "up", opt < 0 ? '-' : '+');
    if (what & 0x2) {
      if (!part.IsNull()) {
	Printf("Will reweight %s in particular", part.Data());
	part.Prepend("_");
	part.Append(opt < 0 ? "-" : "+");
      }
      files.Add(new TObjString(Form("REWEIGHTpid%s.root", part.Data())));
    }
    if (what & 0x4)
      files.Add(new TObjString(Form("REWEIGHTstr%s.root",
				    opt == -1 ? "-" :
				    opt == +1 ? "+" : "")));
    delete tokens;

//.........这里部分代码省略.........
开发者ID:ktf,项目名称:AliPhysics,代码行数:101,代码来源:TrackletdNdetaTrain.C

示例8: cernstaff

/// \file
/// \ingroup tutorial_tree
/// \notebook
/// Playing with a Tree containing variables of type character
/// \macro_image
/// \macro_code
/// \author Rene Brun
void cernstaff () {
   TString dir = gROOT->GetTutorialsDir();
   dir.Append("/tree/cernstaff.C");
   if (gSystem->AccessPathName("cernstaff.root")) {
      gROOT->SetMacroPath(dir);
      gROOT->ProcessLine(".x cernbuild.C");
   }
   TFile *f = new TFile("cernstaff.root");
   TTree *T = (TTree*)f->Get("T");
   TCanvas *c1 = new TCanvas("c1","CERN staff",10,10,1000,750);
   c1->Divide(2,2);
   // make table of number of people per Nation & Division
   c1->cd(1); gPad->SetGrid();
   T->Draw("Nation:Division>>hN","","text");
   TH2F *hN = (TH2F*)gDirectory->Get("hN");
   hN->SetMarkerSize(1.6);
   hN->SetStats(0);

   //make profile of Average cost per Nation
   c1->cd(2); gPad->SetGrid();
   gPad->SetLeftMargin(0.12);
   T->Draw("Cost:Nation>>hNation","","prof,goff");
   TH1F *hNation = (TH1F*)gDirectory->Get("hNation");
   hNation->SetTitle("Average Cost per Nation");
   hNation->LabelsOption(">"); //sort by decreasing bin contents
   hNation->SetMaximum(13000);
   hNation->SetMinimum(7000);
   hNation->SetStats(0);
   hNation->SetMarkerStyle(21);
   hNation->Draw();

   //make stacked plot of Nations versus Grade
   c1->cd(3); gPad->SetGrid();
   THStack *hGrades = new THStack("hGrades","Nations versus Grade");
   TH1F *hFR = new TH1F("hFR","FR",12,3,15);
    hFR->SetFillColor(kCyan);
    hGrades->Add(hFR);
    T->Draw("Grade>>hFR","Nation==\"FR\"");
   TH1F *hCH = new TH1F("hCH","CH",12,3,15);
    hCH->SetFillColor(kRed);
    hGrades->Add(hCH);
    T->Draw("Grade>>hCH","Nation==\"CH\"");
   TH1F *hIT = new TH1F("hIT","IT",12,3,15);
    hIT->SetFillColor(kGreen);
    hGrades->Add(hIT);
    T->Draw("Grade>>hIT","Nation==\"IT\"");
   TH1F *hDE = new TH1F("hDE","DE",12,3,15);
    hDE->SetFillColor(kYellow);
    hGrades->Add(hDE);
    T->Draw("Grade>>hDE","Nation==\"DE\"");
   TH1F *hGB = new TH1F("hGB","GB",12,3,15);
    hGB->SetFillColor(kBlue);
    hGrades->Add(hGB);
    T->Draw("Grade>>hGB","Nation==\"GB\"");
   hGrades->Draw();
   TLegend *legend = new TLegend(0.7,0.65,0.86,0.88);
   legend->AddEntry(hGB,"GB","f");
   legend->AddEntry(hDE,"DE","f");
   legend->AddEntry(hIT,"IT","f");
   legend->AddEntry(hCH,"CH","f");
   legend->AddEntry(hFR,"FR","f");
   legend->Draw();

   //make histogram of age distribution
   c1->cd(4); gPad->SetGrid();
   T->Draw("Age");
   T->Draw("Age>>hRetired","Age>(65-2002+1988)","same");
   TH1F *hRetired = (TH1F*)gDirectory->Get("hRetired");
   hRetired->SetFillColor(kRed);
   hRetired->SetFillStyle(3010);

   TArrow *arrow = new TArrow(32,169,55,74,0.03,"|>");
   arrow->SetFillColor(1);
   arrow->SetFillStyle(1001);
   arrow->Draw();

   TPaveText *pt = new TPaveText(0.12,0.8,0.55,0.88,"brNDC");
   pt->SetFillColor(kWhite);
   pt->AddText("People at CERN in 1988");
   pt->AddText("and retired in 2002");
   pt->Draw();

   c1->cd();
}
开发者ID:bbannier,项目名称:root-1,代码行数:91,代码来源:cernstaff.C

示例9: plotAll

int plotAll(){

  TFile *file = new TFile("/hadoop/cms/store/group/snt/phys14/TTJets_MSDecaysCKM_central_Tune4C_13TeV-madgraph-tauola_Phys14DR-PU20bx25_PHYS14_25_V1-v1/V07-02-08/merged_ntuple_4.root");
  TTree *tree = (TTree*)file->Get("Events");

  int nEntries = tree->GetEntries();

  TList *t_list = tree->GetListOfAliases();

  for(int i = 0; i < t_list->GetSize(); i++) {
    TString aliasname(t_list->At(i)->GetName());
    cout << aliasname.Data() << endl;
    TString command = aliasname;

    //Support Lorentz Vectors
    TBranch *branch = tree->GetBranch(tree->GetAlias(aliasname.Data()));
    TString branchname(branch->GetName());
    if( branchname.Contains("LorentzVector") ) {
      command.Append(".Pt()");
    }
 
    //Don't support vectors of vectors
    if(branchname.BeginsWith("intss") || branchname.BeginsWith("floatss") || branchname.BeginsWith("doubless") || branchname.Contains("LorentzVectorss") || branchname.Contains("timestamp") ){
      cout << "Sorry, I dont support vector of vectors of objects, will be skipping " << aliasname << endl;
      continue;
    }

    //Don't support TStrings
    if(branchname.Contains("TString") ) {
      cout << "Sorry, I dont support strings, will be skipping " << aliasname << endl;
      continue;
    }

    TString histname = "hist_" + aliasname + ".pdf";
    TH1F* null = new TH1F("","",1,0,1);
    command.Append(">>hist");
    tree->Draw(command.Data(), (aliasname)+"!=-9999 &&"+(aliasname)+"!=-999");
    TH1F *hist = (TH1F*)gDirectory->Get("hist");
    if (hist->Integral() == 0) tree->Draw(command.Data());
    hist = (TH1F*)gDirectory->Get("hist");
    vector <TH1F*> hists; 
    hists.push_back(hist);
    vector <string> titles;
    titles.push_back("");
  
    //Overflow and Underflow
    hist->SetBinContent(1, hist->GetBinContent(1)+hist->GetBinContent(0));
    hist->SetBinContent(hist->GetNbinsX(), hist->GetBinContent(hist->GetNbinsX())+hist->GetBinContent(hist->GetNbinsX()+1));

    if (hist->GetXaxis()->GetXmax() == hist->GetXaxis()->GetXmin()){
      ofstream myfile;
      myfile.open("names.txt", ios_base::app);
      myfile << aliasname.Data() << "\n"; 
      myfile.close();  
    }

    float max = hist->GetMaximum()*100;

    string subtitle = aliasname.Data();
    string histname2 = histname.Data(); 

    dataMCplotMaker(null, hists, titles, subtitle, "CMS3 4.02 Validation", Form("--outputName %s --noFill --noLegend --setMaximum %f --energy 13 --lumi 0 --xAxisLabel %s --noXaxisUnit --noDivisionLabel", subtitle.c_str(), max, histname2.c_str())); 

  }
 
  system("mkdir plots");
  system("mv *.pdf plots/"); 
  system("gs -sDEVICE=pdfwrite     -dNOPAUSE -dBATCH -dSAFER     -sOutputFile=merged.pdf  plots/*pdf"); 

  return 0;

}
开发者ID:cmstas,项目名称:NtupleTools,代码行数:72,代码来源:plotAll.C

示例10: Config


//.........这里部分代码省略.........
      gener = MbPhojet();
  }
  
  

  // PRIMARY VERTEX
  //
  gener->SetOrigin(0., 0., 0.);    // vertex position
  //
  //
  // Size of the interaction diamond
  // Longitudinal
  Float_t sigmaz  = 5.4 / TMath::Sqrt(2.); // [cm]
  if (energy == 900)
    sigmaz  = 10.5 / TMath::Sqrt(2.); // [cm]
  //
  // Transverse
  Float_t betast  = 10;                 // beta* [m]
  Float_t eps     = 3.75e-6;            // emittance [m]
  Float_t gamma   = energy / 2.0 / 0.938272;  // relativistic gamma [1]
  Float_t sigmaxy = TMath::Sqrt(eps * betast / gamma) / TMath::Sqrt(2.) * 100.;  // [cm]
  printf("\n \n Diamond size x-y: %10.3e z: %10.3e\n \n", sigmaxy, sigmaz);
    
  gener->SetSigma(sigmaxy, sigmaxy, sigmaz);      // Sigma in (X,Y,Z) (cm) on IP position
  gener->SetCutVertexZ(3.);        // Truncate at 3 sigma
  gener->SetVertexSmear(kPerEvent);

  gener->Init();

  // FIELD
  //
  AliMagWrapCheb* field = 0x0;
  if (mag == kNoField) {
    comment = comment.Append(" | L3 field 0.0 T");
    field = new AliMagWrapCheb("Maps","Maps", 2, 0., 10., AliMagWrapCheb::k2kG);
  } else if (mag == k5kG) {
    comment = comment.Append(" | L3 field 0.5 T");
    field = new AliMagWrapCheb("Maps","Maps", 2, 1., 10., AliMagWrapCheb::k5kG);
  }
  printf("\n \n Comment: %s \n \n", comment.Data());
    
  rl->CdGAFile();
  gAlice->SetField(field);    



  Int_t iABSO  = 1;
  Int_t iACORDE= 0;
  Int_t iDIPO  = 1;
  Int_t iEMCAL = 0;
  Int_t iFMD   = 1;
  Int_t iFRAME = 1;
  Int_t iHALL  = 1;
  Int_t iITS   = 1;
  Int_t iMAG   = 1;
  Int_t iMUON  = 1;
  Int_t iPHOS  = 1;
  Int_t iPIPE  = 1;
  Int_t iPMD   = 0;
  Int_t iHMPID = 1;
  Int_t iSHIL  = 1;
  Int_t iT0    = 1;
  Int_t iTOF   = 1;
  Int_t iTPC   = 1;
  Int_t iTRD   = 1;
  Int_t iVZERO = 1;
开发者ID:JanFSchulte,项目名称:monalisa,代码行数:67,代码来源:Config.C

示例11: MbPythiaTuneATLAS_Flat

AliGenerator* MbPythiaTuneATLAS_Flat()
{
      AliGenPythia* pythia = MbPythiaTuneATLAS();

      comment = comment.Append("; flat multiplicity distribution");

      // set high multiplicity trigger
      // this weight achieves a flat multiplicity distribution
      TH1 *weight = new TH1D("weight","weight",201,-0.5,200.5);
      weight->SetBinContent(1,5.49443);
      weight->SetBinContent(2,8.770816);
      weight->SetBinContent(6,0.4568624);
      weight->SetBinContent(7,0.2919915);
      weight->SetBinContent(8,0.6674189);
      weight->SetBinContent(9,0.364737);
      weight->SetBinContent(10,0.8818444);
      weight->SetBinContent(11,0.531885);
      weight->SetBinContent(12,1.035197);
      weight->SetBinContent(13,0.9394057);
      weight->SetBinContent(14,0.9643193);
      weight->SetBinContent(15,0.94543);
      weight->SetBinContent(16,0.9426507);
      weight->SetBinContent(17,0.9423649);
      weight->SetBinContent(18,0.789456);
      weight->SetBinContent(19,1.149026);
      weight->SetBinContent(20,1.100491);
      weight->SetBinContent(21,0.6350525);
      weight->SetBinContent(22,1.351941);
      weight->SetBinContent(23,0.03233504);
      weight->SetBinContent(24,0.9574557);
      weight->SetBinContent(25,0.868133);
      weight->SetBinContent(26,1.030998);
      weight->SetBinContent(27,1.08897);
      weight->SetBinContent(28,1.251382);
      weight->SetBinContent(29,0.1391099);
      weight->SetBinContent(30,1.192876);
      weight->SetBinContent(31,0.448944);
      weight->SetBinContent(32,1);
      weight->SetBinContent(33,1);
      weight->SetBinContent(34,1);
      weight->SetBinContent(35,1);
      weight->SetBinContent(36,0.9999997);
      weight->SetBinContent(37,0.9999997);
      weight->SetBinContent(38,0.9999996);
      weight->SetBinContent(39,0.9999996);
      weight->SetBinContent(40,0.9999995);
      weight->SetBinContent(41,0.9999993);
      weight->SetBinContent(42,1);
      weight->SetBinContent(43,1);
      weight->SetBinContent(44,1);
      weight->SetBinContent(45,1);
      weight->SetBinContent(46,1);
      weight->SetBinContent(47,0.9999999);
      weight->SetBinContent(48,0.9999998);
      weight->SetBinContent(49,0.9999998);
      weight->SetBinContent(50,0.9999999);
      weight->SetBinContent(51,0.9999999);
      weight->SetBinContent(52,0.9999999);
      weight->SetBinContent(53,0.9999999);
      weight->SetBinContent(54,0.9999998);
      weight->SetBinContent(55,0.9999998);
      weight->SetBinContent(56,0.9999998);
      weight->SetBinContent(57,0.9999997);
      weight->SetBinContent(58,0.9999996);
      weight->SetBinContent(59,0.9999995);
      weight->SetBinContent(60,1);
      weight->SetBinContent(61,1);
      weight->SetBinContent(62,1);
      weight->SetBinContent(63,1);
      weight->SetBinContent(64,1);
      weight->SetBinContent(65,0.9999999);
      weight->SetBinContent(66,0.9999998);
      weight->SetBinContent(67,0.9999998);
      weight->SetBinContent(68,0.9999999);
      weight->SetBinContent(69,1);
      weight->SetBinContent(70,1);
      weight->SetBinContent(71,0.9999997);
      weight->SetBinContent(72,0.9999995);
      weight->SetBinContent(73,0.9999994);
      weight->SetBinContent(74,1);
      weight->SetBinContent(75,1);
      weight->SetBinContent(76,1);
      weight->SetBinContent(77,1);
      weight->SetBinContent(78,0.9999999);
      weight->SetBinContent(79,1);
      weight->SetBinContent(80,1);
      weight->SetEntries(526);

      Int_t limit = weight->GetRandom();
      pythia->SetTriggerChargedMultiplicity(limit, 1.4);

      comment = comment.Append(Form("; multiplicity threshold set to %d in |eta| < 1.4", limit));

      return pythia;
}
开发者ID:JanFSchulte,项目名称:monalisa,代码行数:95,代码来源:Config.C

示例12: DiffXSChan

void DiffXSChan( UInt_t i)
{
	UInt_t i, j, k, eg;
	Double_t tageff, deteff;
	Double_t tth[9], dtth[9], xxs[9], dxxs[9];
	TString name;

	eg = tcd[i].egamma;

	cout << "Energy = " << eg << endl;

	// Output results to a file
	name = Form( "xs/compton/xs/diff_xs_%d.out", eg);
	ofstream outFile( name);
	if ( !outFile.is_open()) {
		cout << "Error opening file ";
		cout << name;
		cout << endl;
		break;
	}
	k = 0;
	for (  j = 1; j <= 9; j++) {
		ChanXS( i, j);
		name = Form( "%3d  %6.4f  %5.4f", tbin[j].th, tcd[i].xs[j],
				tcd[i].dxs[j]);
		outFile << name << endl;
		tth[k] = tbin[j].theta;
		dtth[k] = 0;
		xxs[k] = tcd[i].xs[j];
		dxxs[k++] = tcd[i].dxs[j];
	}
	outFile.close();

	c1 = new TCanvas( "c1", "Differential Sections", 200, 10, 700, 500);
	c1->SetGrid();
	c1->GetFrame()->SetFillColor( 21);
	c1->GetFrame()->SetBorderSize( 12);

	// Plot Results
	gr = new TGraphErrors( 9, tth, xxs, dtth, dxxs);
	name = Form( "#gammap#rightarrow#gammap Differential Cross Section"
			" E_{#gamma} = %5.1f MeV", tcd[i].energy);
	gr->SetTitle( name);
	gr->SetMarkerColor( 4);
	gr->SetMarkerStyle( 21);
	gr->SetLineWidth( 2);
	gr->SetLineColor( 4);
	gr->GetXaxis()->SetTitleOffset( 1.1);
	gr->GetYaxis()->SetTitleOffset( 0.8);
	gr->GetYaxis()->SetTitleSize( 0.05);
	gr->GetXaxis()->SetTitle("#theta^{*}_{#pi^{0}} (MeV)");
	gr->GetYaxis()->SetTitle("d#sigma/d#Omega (#mub/sr)");
	gr->GetXaxis()->SetLabelSize( 0.03);
	gr->GetYaxis()->SetLabelSize( 0.03);
	gr->GetXaxis()->CenterTitle();
	gr->GetYaxis()->CenterTitle();
	gr->SetMinimum( 0);
	gr->Draw( "AP");

/*
	c1->cd();
	TPad *npad = new TPad( "npad", "Transparent Pad", 0, 0, 1, 1);
	npad->SetFillStyle( 4000);
	npad->Draw();
	npad->cd();

	// "Preliminary"
//	TPaveLabel *pl = new TPaveLabel( 100, 50, 380, 380, "PRELIMINARY");
	TPaveLabel *pl = new TPaveLabel( 0, 0, 1, 1, "PRELIMINARY");
	pl->SetTextAngle(30);
	pl->SetTextColor(14);
//	pl->SetTextFont(82);
	pl->SetBorderSize(0);
	pl->SetFillStyle(4000);
	pl->Draw();
*/

	name = Form( "plots/Compton/diff_xs_chan%d", i);
//	name.Append( ".eps");
	name.Append( ".pdf");
	c1->Print( name);
}
开发者ID:collicott,项目名称:old-working-acqu,代码行数:82,代码来源:XSTry.C

示例13: DiffComp


//.........这里部分代码省略.........
	// Theory results
	name = Form( "xs/compton/theory/compton_%d.dat", eg);
	ifstream inFile( name);
	if ( !inFile.is_open()) {
		cout << "Error opening file ";
		cout << name;
		cout << endl;
		break;
	}
	i = 0;
	while( !inFile.eof()) {
		inFile >> th >> cth >> x;
		cmth[i] = cth;
		xs[i++] = x;
		cout << i-1;
		cout << " " << th;
		cout << " " << cth;
		cout << " " << x;
		cout << endl;
	}
	inFile.close();
	ct = i-1;

	if ( ebin <= 4) max = 0.18;
	else if ( ebin <= 6) max = 0.25;
	else if ( ebin <= 7) max = 0.3;
	else if ( ebin <= 8) max = 0.4;
	else if ( ebin <= 10) max = 0.5;

	// Plot Theory Results
	gr = new TGraph( ct, cmth, xs);
	name = Form( "Preliminary #gammap#rightarrow#gammap "
			"Differential Cross Section for E_{#gamma} = %d MeV", eg);
	gr->SetTitle( name);
	gr->GetXaxis()->SetTitleOffset( 1.1);
	gr->GetYaxis()->SetTitleOffset( 1.0);
	gr->GetYaxis()->SetTitleSize( 0.05);
	gr->GetXaxis()->SetTitle( "#theta^{cm}_{#gamma} (deg)");
	gr->GetYaxis()->SetTitle( "d#sigma/d#Omega (#mub/sr)");
	gr->GetXaxis()->SetLabelSize( 0.03);
	gr->GetYaxis()->SetLabelSize( 0.03);
	gr->GetXaxis()->CenterTitle();
	gr->GetYaxis()->CenterTitle();
	gr->GetXaxis()->SetRangeUser( 0, 180);
	gr->SetLineWidth( 2);
//	gr->SetLineColor( 2);
	gr->SetMinimum( 0.0);
	gr->SetMaximum( max);
	gr->Draw( "AL");

	// My results
	i = 0;
	name = Form( "xs/compton/xs/diff_xs_ebin%d.out", ebin);
	ifstream inFile( name);
	if ( !inFile.is_open()) {
		cout << "Error opening file ";
		cout << name;
		cout << endl;
		break;
	}
	ifstream inFile( name);
	while( !inFile.eof()) {
		inFile >> th >> x >> dx;
		cout << i;
		cout << " " << th;
		cout << " " << x;
		cout << " " << dx;
		cout << endl;
		if ( dx != 0) {
			cmth[i] = th;
			dth[i] = 0;
			xs[i] = x;
			dxs[i++] = dx;
		}
	}
	inFile.close();
	ct = i-1;

	// Plot Results
	gr1 = new TGraphErrors( ct, cmth, xs, dth, dxs);
	gr1->SetLineWidth( 2);
//	gr1->SetLineColor( 4);
//	gr1->SetMarkerColor( 4);
	gr1->SetMarkerSize( 1.0);
	gr1->SetMarkerStyle( 20);
	gr1->Draw( "Psame");

	pt = new TLegend( 0.4, 0.65, 0.6, 0.80);
	pt->SetTextSize( 0.04);
	pt->SetFillColor( 0);
	pt->SetBorderSize( 0);
	pt->AddEntry( gr, "Pasquini", "l");
	pt->AddEntry( gr1, "This Work", "p");
	pt->Draw();

	name = Form( "plots/Compton/dxs_comp_%d", eg);
//	name.Append( ".eps");
	name.Append( ".pdf");
	c1->Print( name);
}
开发者ID:collicott,项目名称:old-working-acqu,代码行数:101,代码来源:XSTry.C

示例14: DiffXSBin

void DiffXSBin( UInt_t ebin)
{
	UInt_t start, stop;
	UInt_t j, k, chan_lo, chan_hi;
	Double_t temin, temax;
	Double_t tageff, deteff;
	Double_t th[9], dth[9], xs[9], dxs[9];
	TString name;
	TFile* file;

	chan_lo = tchan[ebin] - 2;
	chan_hi = tchan[ebin] + 2;

	temin = tcd[chan_hi].energy - tcd[chan_hi].denergy/2;
	temax = tcd[chan_lo].energy + tcd[chan_lo].denergy/2;

	if ( ebin <= 6) start = 6;
	else start = 5;
	stop = 8;

	name = Form( "xs/compton/xs/diff_xs_ebin%d.out", ebin);
	ofstream outFile( name);
	if ( !outFile.is_open()) {
		cout << "Error opening file ";
		cout << name;
		cout << endl;
		break;
	}
	k = 0;
	for (  j = start; j <= stop; j++) {
		if ( BinXS( ebin, j) == kTRUE)
		{
			name = Form( "%3d  %6.4f  %5.4f", tbin[j].th, tcdbin[ebin].xs[j],
				tcdbin[ebin].dxs[j]);
			outFile << name << endl;
			th[k] = tbin[j].theta;
			dth[k] = 0;
			xs[k] = tcdbin[ebin].xs[j];
			dxs[k++] = tcdbin[ebin].dxs[j];
		}
	}
	outFile.close();

	cout << "Weighted Energy = " << tcdbin[ebin].energy << endl;

	// Output results to a file
	c1 = new TCanvas( "c1", "Differential Sections", 200, 10, 700, 500);
	c1->SetGrid();
	c1->GetFrame()->SetFillColor( 21);
	c1->GetFrame()->SetBorderSize( 12);

	// Plot Results
	gr = new TGraphErrors( k, th, xs, dth, dxs);
	name = Form( "#gammap#rightarrow#gammap Differential Cross Section"
			" E_{#gamma} = %5.1f (%5.1f - %5.1f) MeV", tcdbin[ebin].energy,
			temin, temax);
	gr->SetTitle( name);
	gr->SetMarkerColor( 4);
	gr->SetMarkerStyle( 21);
	gr->SetLineWidth( 2);
	gr->SetLineColor( 4);
	gr->GetXaxis()->SetTitleOffset( 1.1);
	gr->GetYaxis()->SetTitleOffset( 0.8);
	gr->GetYaxis()->SetTitleSize( 0.05);
	gr->GetXaxis()->SetTitle("#theta^{*}_{#pi^{0}} (MeV)");
	gr->GetYaxis()->SetTitle("d#sigma/d#Omega (#mub/sr)");
	gr->GetXaxis()->SetLabelSize( 0.03);
	gr->GetYaxis()->SetLabelSize( 0.03);
	gr->GetXaxis()->CenterTitle();
	gr->GetYaxis()->CenterTitle();
	gr->SetMinimum( 0);
	gr->Draw( "AP");

/*
	c1->cd();
	TPad *npad = new TPad( "npad", "Transparent Pad", 0, 0, 1, 1);
	npad->SetFillStyle( 4000);
	npad->Draw();
	npad->cd();

	// "Preliminary"
//	TPaveLabel *pl = new TPaveLabel( 100, 50, 380, 380, "PRELIMINARY");
	TPaveLabel *pl = new TPaveLabel( 0, 0, 1, 1, "PRELIMINARY");
	pl->SetTextAngle(30);
	pl->SetTextColor(14);
//	pl->SetTextFont(82);
	pl->SetBorderSize(0);
	pl->SetFillStyle(4000);
	pl->Draw();
*/

	name = Form( "plots/Compton/diff_xs_ebin%d", ebin);
//	name.Append( ".eps");
	name.Append( ".pdf");
//	c1->Print( name);
}
开发者ID:collicott,项目名称:old-working-acqu,代码行数:96,代码来源:XSTry.C

示例15: createPlot

void createPlot(TCanvas *canvas, TFile *file,  TString type, TString name, int nbins, double xMin, double xMax, 
		bool runSecTrackColl, TText* te, char * option, 
		double startingY, double startingX = .1, bool fit = false, 
		bool logx=false, bool logy=false, int normScale){
  TTree *tree;
  tree = file->GetObject("tree",tree);
  
  TH1F *h1; // for ctf trk
  h1 = new TH1F("h1", "h1", nbins, xMin, xMax);
  
  TH1F *h2; // for sectrk
  h2 = new TH1F("h2","h2",nbins,xMin,xMax);
  

  TString x_title = "";
  TString y_title = "Number of Tracks";
  
  // If the histogram is filled per track, cut on the event and track.
  // Otherwise, cut only on the event level

  TString basecut="isTechBit40&&!isBeamHalo&&hasGoodPvtx==1";
  TString evtcutstring=basecut;
  evtcutstring.Append("&&EVTSELECTION");
  TString trkcutstring=basecut;
  trkcutstring.Append("&&EVTSELECTION&&TRKSELECTION");
  
  TString ctf_name =  "ctf_";

  if( name.Contains("cluster_charge",TString::kExact) ) {
    ctf_name = "ctf"; 
    ctf_name.Append(name);   
    tree->Project("h1",ctf_name, evtcutstring);
  }
  else if (name == "recz_pxlpvtx") {
    tree->Project("h1",name, evtcutstring);
    y_title="Number of pixelVertices";
  }
  else if( name.Contains("pvtx")) {
    if(name.Contains("rec")) {  
      y_title="Number of Real PrimaryVertices";
      TString vtxcutstring=evtcutstring;
      tree->Project("h1",name, vtxcutstring.Append("&&isFake_pvtx==0")); 
    }
    else { 
      y_title="Number of Valid PrimaryVertices";
      tree->Project("h1",name, evtcutstring);
    }
  }
  else if ( name.Contains("nVertices",TString::kExact) 
	    || name.Contains("hasGoodPvtx",TString::kExact) 
	    || name.Contains("nPixelVertices",TString::kExact) 
	    || name.Contains("isTechBit40",TString::kExact)
            || name.Contains("isBSC",TString::kExact)  
	    || name.Contains("bsX0",TString::kExact)
	    || name.Contains("bsY0",TString::kExact)
	    || name.Contains("bsZ0",TString::kExact)
	    || name.Contains("glob_ls",TString::kExact) 
	    || name.Contains("glob_bx",TString::kExact)   
	    ) {
    tree->Project("h1",name, evtcutstring);
    y_title = "Number of Events";
  }
  else { 
    ctf_name.Append(name); 
    tree->Project("h1",ctf_name, trkcutstring);
  }

  if(runSecTrackColl && ctf_name.Contains("ctf")) {
    TString sectrk_name = ctf_name.ReplaceAll("ctf","sectrk");
    tree->Project("h2",sectrk_name,evtcutstring);
  }
 
  // Set the x_tile 
  if( name == "n" ) {
    x_title = "Tracks per Event" ;
    y_title = "Number of Events";
  }
  
  // All Clusters
  if( name.Contains("clusterCharge_all",TString::kExact) )  x_title = "All Cluster Charge (ADC Counts)";
  if( name.Contains("clusterCharge_TIB",TString::kExact) )  x_title = "All TIB Cluster Charge (ADC Counts)";
  if( name.Contains("clusterCharge_TID",TString::kExact) )  x_title = "All TID Cluster Charge (ADC Counts)";
  if( name.Contains("clusterCharge_TOB",TString::kExact) )  x_title = "All TOB Cluster Charge (ADC Counts)";
  if( name.Contains("clusterCharge_TEC",TString::kExact) )  x_title = "All TEC Cluster Charge (ADC Counts)";
  
  if( name.Contains("cluster_charge",TString::kExact) ) {
    x_title = " Strip Cluster Charge (ADC Counts)";
    y_title = "Number of Clusters";
  }
    
  // Histograms filled per Track
  if( name.Contains("nHit",TString::kExact) )  x_title = "Number of Valid Hits per Track" ;
  if( name.Contains("nLostHit",TString::kExact) )  x_title = "Number of Lost Hits per Track" ; 
  if( name.Contains("nPXBhit",TString::kExact) )  x_title = "Number of PixelBarrel Hits per Track" ;
  if( name.Contains("nPXFhit",TString::kExact) )  x_title = "Number of PixEndcap Hits per Track" ;
  if( name.Contains("nTIBhit",TString::kExact) )  x_title = "Number of TIB Hits per Track" ;
  if( name.Contains("nTOBhit",TString::kExact) )  x_title = "Number of TOB Hits per Track" ;
  if( name.Contains("nTIDhit",TString::kExact) )  x_title = "Number of TID Hits per Track" ;
  if( name.Contains("nTEChit",TString::kExact) )  x_title = "Number of TEC Hits per Track" ;
  if( name.Contains("nPixelHit",TString::kExact) )  x_title = "Number of Pixel Hits per Track" ;
//.........这里部分代码省略.........
开发者ID:yanyangao,项目名称:usercode,代码行数:101,代码来源:trackingPlotFirstCollision.C


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