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


C++ TH1::GetName方法代码示例

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


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

示例1: fancyMerge

void fancyMerge( std::string beam, std::string target, std::string energy, std::string physlist, bool doScale=false )
{
      
   std::string output = beam + target + energy + "GeV" + physlist + ".root" ;
   
   targetFile = TFile::Open( output.c_str(), "RECREATE" );
   
   double scale = 1./32.;
   
   // std::string input = beam + target + model + energy + "GeV-1.root";
   // std::string input = "../t23-bld/harp-histo-no-res-decays/" + beam + target + energy + "GeV" + physlist +"-1.root";

   // std::string input = "../t23-bld/harp-histo/" + beam + target + energy + "GeV" + physlist +"-1.root";

   std::string input = "../t23-bld/na49-histo/" + beam + target + energy + "GeV" + physlist +"-1.root";
   
   TFile* iFile1 = TFile::Open( input.c_str() );
   TIter  next( iFile1->GetListOfKeys() );
   TKey*  key = (TKey*)next();
   TH1* h = 0;
   while ( key )
   {   
         if ( !(TClass::GetClass(key->GetClassName())->InheritsFrom(TH1::Class())) ) continue;
         const char* kName = key->GetName();
         h = (TH1*)key->ReadObj();
         const char* hName = h->GetName();
         std::cout << " histoname = " << hName << std::endl;
	 TH1F* h1 = h->Clone();
	 for ( int id=2; id<=32; id++ )
	 {
	    // std::string input_t = "../t23-bld/harp-histo-no-res-decays/" + beam + target + energy + "GeV" + physlist + "-" ;
	    // std::string input_t = "../t23-bld/harp-histo/" + beam + target + energy + "GeV" + physlist + "-" ;
	    std::string input_t = "../t23-bld/na49-histo/" + beam + target + energy + "GeV" + physlist + "-" ;
            char buf[5];
            sprintf( buf, "%i", id );
            input_t.append( buf ); 
            input_t += ".root"; 
	    TFile* iFile_t = TFile::Open( input_t.c_str() );
	    TH1F* h_t = (TH1F*)iFile_t->Get( h->GetName() );
	    h1->Add( h_t );  
	    iFile_t->Close();
	 }
	 if ( doScale )
	 {
	    if (!(strcmp(key->GetClassName(),"TProfile"))) h1->Scale( scale );
	 }
	 targetFile->cd();
	 h1->Write();
         key = (TKey*)next();
   }
   
   targetFile->Close();
     
   return;

}
开发者ID:gpestana,项目名称:thesis,代码行数:56,代码来源:PlotHARPAnalysis.C

示例2: counts

void counts(int run, int lumistart, int lumiend, string type, map<string,vector<tripletI> > &cnt, vector<tripletD> &cntref, string hlttype, bool docnt, bool doref) {
   TString filename = basedir + Form("/DQM_V0001_HLTpb_R000%i.root",run);
   TFile *f = new TFile(filename);
   if (!f->IsOpen()) {
      cout << "Error, could not open " << filename << endl;
      return;
   }
   TString tdirname = Form("DQMData/Run %i/HLT/Run summary/TriggerRates/",run) + TString(type);
   f->cd(tdirname);
   TProfile *hlumi = (TProfile*) f->Get(Form("DQMData/Run %i/HLT/Run summary/LumiMonitoring/lumiVsLS",run));
   if (extrapol) extrapolate(hlumi);

   // if HLT: accept, error, pass L1 seed, pass prescaler, reject

   TIter next(gDirectory->GetListOfKeys());
   TKey *key;
   while ((key = (TKey*)next())) {
      TClass *cl = gROOT->GetClass(key->GetClassName());
      
      // it must be an histogram
      if (!cl->InheritsFrom("TH1")) continue;
      TH1 *h = (TH1*)key->ReadObj();

      // the name must match one of the requested patterns
      bool match=false; TString hname(h->GetName());
      for (vector<TRegexp>::const_iterator it=patterns.begin(); it!=patterns.end(); it++) {
         if (hname(*it).Length()!=0) {
            match=true;
            break;
         }
      }
      if (!match) continue;

      int nlumis = (lumiend+1-lumistart);

      if (extrapol) extrapolate(h);

      if (type != "HLT") fill(cnt[h->GetName()], h, run, lumistart, lumiend, docnt);
      else {
         string htitle(h->GetTitle());
         if (htitle.find(hlttype) == string::npos) continue;
         else {
            TString thepath; Ssiz_t from=0; TString(htitle).Tokenize(thepath,from," ");
            fill(cnt[thepath.Data()], h, run, lumistart, lumiend, docnt);
         }
      }
   }

   if (doref) {
      fill(cntref, hlumi, run, lumistart, lumiend);
   }

   f->Close();
   delete f;
}
开发者ID:CMS-HIN-dilepton,项目名称:RunPreparation,代码行数:55,代码来源:recorded_by_hltpath_fromDQM.C

示例3: exec1

// echo object at mouse position
void exec1()
{
   //example of macro called when a pad is redrawn
   //one must create a TExec object in the following way
   // TExec ex("ex",".x exec1.C");
   // ex.Draw();
   // this macro prints the bin number and the bin content when one clicks
   //on the histogram contour of any histogram in a pad
   //Author: Rene Brun
   
   if (!gPad) {
      Error("exec1", "gPad is null, you are not supposed to run this macro");
      return;
   }
   
   int event = gPad->GetEvent();
   if (event != 11) return;
   int px = gPad->GetEventX();
   TObject *select = gPad->GetSelected();
   if (!select) return;
   if (select->InheritsFrom(TH1::Class())) {
      TH1 *h = (TH1*)select;
      Float_t xx = gPad->AbsPixeltoX(px);
      Float_t x  = gPad->PadtoX(xx);
      Int_t binx = h->GetXaxis()->FindBin(x);
      printf("event=%d, hist:%s, bin=%d, content=%f\n",event,h->GetName(),binx,h->GetBinContent(binx));
   }
}
开发者ID:adevress,项目名称:root-1,代码行数:29,代码来源:exec1.C

示例4: GetOne

TH1* GetOne(UShort_t sNN, const TString& trigger)
{
  Long_t   p = gROOT->ProcessLine(Form("Drawer::GetStack(0, \"pp\", %d, "
				       "\"%s\", false, true)", 
				       sNN, trigger.Data()));
  THStack* s = (THStack*)p;
  TList*   l = s->GetHists();
  TH1*     h = 0;
  TIter    n(l);
  l->ls();
  while ((h = static_cast<TH1*>(n()))) {
    TString m(h->GetName());
    if (m.EqualTo("dndetaForward_all")) break;
  }

  if (h) {
    switch (sNN) { 
    case  900: h->SetTitle("900GeV");  h->SetMarkerColor(kRed+2);   break;
    case 2760: h->SetTitle("2.76TeV"); h->SetMarkerColor(kGreen+2); break;
    case 7000: h->SetTitle("7TeV");    h->SetMarkerColor(kBlue+2);  break;
    case 8000: h->SetTitle("8TeV");    h->SetMarkerColor(kBlack);   break;
    }
  }

  return h;
}
开发者ID:ktf,项目名称:AliPhysics,代码行数:26,代码来源:Interpolate.C

示例5: initialize

  void initialize( const char* countdbfn = "counts.root" )
  {
    XSWeightTool::update( "Xsection8TeV_bkg_v4.txt" );
    XSWeightTool::update( "Xsection8TeV_sig_v4.txt" );
    // XSWeightTool::print();

    using namespace std;

    TFile* f = TFile::Open( countdbfn, "read" );
    if( f == NULL || f->IsZombie() )
    {
      return;
    }

    TIter next( f->GetListOfKeys() ); 
    TKey *key;
    int nhist = 0;
    while( (key = (TKey*)next()) ) {
      nhist++;
      // cout << "Key " << nhist << endl;
      // cout << " Classname " << key->GetClassName() << endl;
      // cout << " Title " <<key->GetTitle() << endl;
      if( key->ReadObj()->InheritsFrom( TH1::Class() ) )
      {
	TH1* h = (TH1*)( key->ReadObj() );
	long run_num = TString( h->GetName() ).Atoi();
	num_events[run_num] = h->GetBinContent( 1 );
	// cout << " Run, # of events : " << run_num << ", " <<  h->GetBinContent( 21 ) << endl;
      }
    }
    // cout << "Done" << endl;
  }
开发者ID:dtmori,项目名称:HWW,代码行数:32,代码来源:mcweights.c

示例6: getHisto

// -----------------------------------------------------------------------------
//
TH1* getHisto( std::string nameFile,
	       std::string nameHist,
	       std::string Dirname, 
	       int rebin ) {
  std::string name = nameFile;
  TFile* file =  new TFile(name.c_str());
  if (file) { std::cout << "Opened file: " << file->GetName() << std::endl; }
  else { 
    std::cout << "Could not find file: " << name << std::endl; 
    return 0; 
  }
  
  TDirectory* dir = (TDirectory*)file->Get(Dirname.c_str());
  if (dir) { std::cout << "Opened dir: " << dir->GetName() << std::endl; }
  else { 
    std::cout << "Could not find dir: " << Dirname << std::endl; 
    return 0; 
  }
  
  int low = 375;
  TH1* hist = 0;
  if ( false || nameHist.find("HtMultiplicity_HT375") == std::string::npos ) { 
    hist = (TH1*)dir->Get(nameHist.c_str());
  } else {
    
    for ( uint ii = low; ii <= 975; ii+=100 ) {
      std::stringstream tmp; tmp << "HtMultiplicity_HT" << ii << nameHist.substr(20);
      if ( !hist ) { 
	dir->cd();
	TH1D* temp = (TH1D*)dir->Get( "HtMultiplicity_HT375_aT0" );
	//TH1D* temp = (TH1D*)file->Get( tmp.str().c_str() );
	if (temp) { hist = (TH1D*)temp->Clone(); } 
	else { std::cout << "1 Unable to retrieve histo with name " << tmp.str() << std::endl; }
      } else { 
	dir->cd();
	TH1D* temp = (TH1D*)dir->Get( tmp.str().c_str() );
	if (temp) { hist->Add( (TH1D*)temp ); } 
	else { std::cout << "2 Unable to retrieve histo with name " << tmp.str() << std::endl; }
      }
    }

  }
  if (hist) { std::cout << "Opened histo: " << hist->GetName() << std::endl; }
  else { 
    std::cout << "Could not find histo: " << nameHist << std::endl; 
    return 0; 
  }

  hist->SetLineWidth(3);
  if ( rebin > 0 ) { hist->Rebin(rebin); }
  hist->GetXaxis()->SetTitleSize(0.055);
  hist->GetYaxis()->SetTitleSize(0.055);
  hist->GetXaxis()->SetLabelSize(0.05);
  hist->GetYaxis()->SetLabelSize(0.05);
  hist->SetStats(kFALSE);
  return hist;
}
开发者ID:bluejelibaby,项目名称:AnalysisV2,代码行数:59,代码来源:overlay.C

示例7: TGraphAsymmErrors

RooHistN::RooHistN(const TH1 &data1, const TH1 &data2, Double_t nominalBinWidth, Double_t nSigma, Double_t xErrorFrac) :
  TGraphAsymmErrors(), _nominalBinWidth(nominalBinWidth), _nSigma(nSigma), _rawEntries(-1)
{
  // Create a histogram from the asymmetry between the specified TH1 objects
  // which may have fixed or variable bin widths, but which must both have
  // the same binning. The asymmetry is calculated as (1-2)/(1+2). Error bars are
  // calculated using Binomial statistics. Prints a warning and rounds
  // any bins with non-integer contents. Use the optional parameter to
  // specify the confidence level in units of sigma to use for
  // calculating error bars. The nominal bin width specifies the
  // default used by addAsymmetryBin(), and is used to set the relative
  // normalization of bins with different widths. If not set, the
  // nominal bin width is calculated as range/nbins.

  initialize();
  // copy the first input histogram's name and title
  SetName(data1.GetName());
  SetTitle(data1.GetTitle());
  // calculate our nominal bin width if necessary
  if(_nominalBinWidth == 0) {
    const TAxis *axis= ((TH1&)data1).GetXaxis();
    if(axis->GetNbins() > 0) _nominalBinWidth= (axis->GetXmax() - axis->GetXmin())/axis->GetNbins();
  }
  setYAxisLabel(Form("Asymmetry (%s - %s)/(%s + %s)",
		     data1.GetName(),data2.GetName(),data1.GetName(),data2.GetName()));
  // initialize our contents from the input histogram contents
  Int_t nbin= data1.GetNbinsX();
  if(data2.GetNbinsX() != nbin) {
    coutE(InputArguments) << "RooHistN::RooHistN: histograms have different number of bins" << endl;
    return;
  }
  for(Int_t bin= 1; bin <= nbin; bin++) {
    Axis_t x= data1.GetBinCenter(bin);
    if(fabs(data2.GetBinCenter(bin)-x)>1e-10) {
      coutW(InputArguments) << "RooHistN::RooHistN: histograms have different centers for bin " << bin << endl;
    }
    Stat_t y1= data1.GetBinContent(bin);
    Stat_t y2= data2.GetBinContent(bin);
    addAsymmetryBin(x,roundBin(y1),roundBin(y2),data1.GetBinWidth(bin),xErrorFrac);
  }
  // we do not have a meaningful number of entries
  _entries= -1;
}
开发者ID:benitezj,项目名称:PhDAnalysisSoftware,代码行数:43,代码来源:RooHistN.C

示例8:

TH1 *MillePedeTrees::CreateHist(const char *exp, const char *selection, const char *hDef,
                                Option_t* opt)
{
  TH1 *h = this->Draw(exp, selection, hDef, "goff");

  TH1 *hResult = static_cast<TH1*>(h->Clone(Form("%sC", h->GetName())));
  if (opt) hResult->SetOption(opt);

  return hResult;
}
开发者ID:ANSH0712,项目名称:cmssw,代码行数:10,代码来源:MillePedeTrees.C

示例9: DrawTree

void DrawTree( TTree& tree, TH1& hist, const char* branchname, 
               const std::string condition, const char* append = "") {

  gROOT->cd();

  std::string plot = std::string(branchname);
  plot.append(append);
  plot.append(hist.GetName());

  tree.Draw( plot.c_str(), condition.c_str(), "goff" );
}
开发者ID:ajaykumar649,项目名称:scripts,代码行数:11,代码来源:plotSpectrum.C

示例10: combExpr

TProfile *MillePedeTrees::CreateHistProf(const char *expX, const char *expY, const char *selection,
                                         const char *hDef, Option_t* opt)
{

  const TString combExpr(Form("%s:%s", expY, expX));
  TH1 *h = this->Draw(combExpr, selection, hDef, "goff prof");

  TProfile *hResult = static_cast<TProfile*>(h->Clone(Form("%sClone", h->GetName())));
  if (opt) hResult->SetOption(opt);

  return hResult;
}
开发者ID:ANSH0712,项目名称:cmssw,代码行数:12,代码来源:MillePedeTrees.C

示例11: printRes

void
HistoCompare::PVCompute(TH1 * oldHisto , TH1 * newHisto , TText * te )
{

  myoldHisto1 = oldHisto;
  mynewHisto1 = newHisto;
  myte = te;

  Double_t *res;

  Double_t mypv = myoldHisto1->Chi2Test(mynewHisto1,"WW",res);
  TString title = myoldHisto1->GetName();
  printRes(title, mypv, myte);
  return;

}
开发者ID:DesyTau,项目名称:cmssw,代码行数:16,代码来源:MECompare.C

示例12: merge_histos

TH1* merge_histos(TList *sourcelist){
  TH1 *htot;

  TFile *first_source = (TFile*)sourcelist->First();
  TDirectory *current_sourcedir = gDirectory;
  //gain time, do not add the objects in the list in memory
  Bool_t status = TH1::AddDirectoryStatus();
  TH1::AddDirectory(kFALSE);
  
  
  // loop over all keys in this directory
  TChain *globChain = 0;
  TIter nextkey( current_sourcedir->GetListOfKeys() );
  TKey *key, *oldkey=0;
  while ( (key = (TKey*)nextkey())) {

    //keep only the highest cycle number for each key
    if (oldkey && !strcmp(oldkey->GetName(),key->GetName())) continue;
    
    // read object from first source file
    TObject *obj = key->ReadObj();
    
    // if the object is named "tot_edp_hbcoil" merge it
    if ( obj->FindObject("Tot_Edep_HBCoil")) {

      //      cout << "Merging histogram " << obj->GetName() << endl;
      htot = (TH1*)obj;
      
      // loop over all source files and add the content of the
      // correspondant histogram to the one pointed to by "h1"
      TFile *nextsource = (TFile*)sourcelist->After( first_source );
      while ( nextsource ) {
	// make sure we are at the correct directory level by cd'ing to path
	TKey *key2 = (TKey*)gDirectory->GetListOfKeys()->FindObject(htot->GetName());
	if (key2) {
	  TH1 *htemp = (TH1*)key2->ReadObj();
	  htot->Add(htemp);
	  delete htemp;
	}
	
	nextsource = (TFile*)sourcelist->After( nextsource );
      }
    }   
  }

  return htot;
}
开发者ID:buddhiniw,项目名称:shms_geant,代码行数:47,代码来源:draw_sim_bender.C

示例13: showTauIsolation

void showTauIsolation(TFile* inputFile, const TString& dqmDirectory, const TString& meName,
		      const char* dqmSubDirectoryTauJet, const char* dqmSubDirectoryMuon, const char* dqmSubDirectoryElectron,
		      TCanvas* canvas, TPostScript* ps, const char* outputFileLabel, bool useLogScale)
{
  canvas->SetLogy(useLogScale);

  TLegend legend(0.74, 0.71, 0.89, 0.89, "", "brNDC"); 
  legend.SetBorderSize(0);
  legend.SetFillColor(0);

  TH1* meTauJet = getMonitorElement(inputFile, dqmDirectory, dqmSubDirectoryTauJet, meName);
  meTauJet->SetMarkerStyle(20);
  meTauJet->SetMarkerColor(kRed);
  meTauJet->SetLineColor(kRed);
  meTauJet->Draw("e1p");
  legend.AddEntry(meTauJet, "#tau-Jet", "p");

  if ( dqmSubDirectoryMuon != "" ) {
    TH1* meMuon = getMonitorElement(inputFile, dqmDirectory, dqmSubDirectoryMuon, meName);
    meMuon->SetMarkerStyle(21);
    meMuon->SetMarkerColor(kBlue);
    meMuon->SetLineColor(kBlue);
    meMuon->Draw("e1psame");
    legend.AddEntry(meMuon, "#mu", "p");
  }

  if ( dqmSubDirectoryElectron != "" ) {
    TH1* meElectron = getMonitorElement(inputFile, dqmDirectory, dqmSubDirectoryElectron, meName);
    meElectron->SetMarkerStyle(23);
    meElectron->SetMarkerColor(kGreen);
    meElectron->SetLineColor(kGreen);
    meElectron->Draw("e1psame");
    legend.AddEntry(meElectron, "e", "p");
  }

  legend.Draw();

  canvas->Update();
  TString outputFileName = TString("plot").Append(meTauJet->GetName()).Append("_").Append(outputFileLabel).Append(".png");
  canvas->Print(outputFileName.Data());
  //ps->NewPage();
}
开发者ID:akalinow,项目名称:TauAnalysis-TauIdEfficiency,代码行数:42,代码来源:makeTauIsolationPlots.C

示例14: exec1

void exec1()
{
   if (!gPad) {
      Error("exec1", "gPad is null, you are not supposed to run this macro");
      return;
   }

   int event = gPad->GetEvent();
   if (event != 11) return;
   int px = gPad->GetEventX();
   TObject *select = gPad->GetSelected();
   if (!select) return;
   if (select->InheritsFrom(TH1::Class())) {
      TH1 *h = (TH1*)select;
      Float_t xx = gPad->AbsPixeltoX(px);
      Float_t x  = gPad->PadtoX(xx);
      Int_t binx = h->GetXaxis()->FindBin(x);
      printf("event=%d, hist:%s, bin=%d, content=%f\n",event,h->GetName(),binx,h->GetBinContent(binx));
   }
}
开发者ID:MycrofD,项目名称:root,代码行数:20,代码来源:exec1.C

示例15: Draw

  // Do the loop here, so that we can use options like "errors"
  void Draw( const TString & xTitle = "", const TString & yTitle = "", const bool errors = false ) {

    // Create a new THStack so that it handle tha maximum
    // THStack stack(name_, title_);
    THStack * stack = new THStack(name_, title_);

    int colorIndex = 0;
    if( !(histoList_.empty()) ) {
      std::vector<TH1*>::iterator histoIter = histoList_.begin();
      for( ; histoIter != histoList_.end(); ++histoIter, ++colorIndex ) {
        TH1 * histo = *histoIter;
        if(errors) histo->Sumw2();
        // histo->SetNormFactor(1);
        if( colorIndex < 4 ) histo->SetLineColor(colors_[colorIndex]);
        else histo->SetLineColor(colorIndex);
        // Draw and get the maximum value
        TString normalizedHistoName(histo->GetName());
        TH1 * normalizedHisto = (TH1*)histo->Clone(normalizedHistoName+"clone");
        normalizedHisto->Scale(1/normalizedHisto->Integral());
        stack->Add(normalizedHisto);
      }
      // Take the maximum of all the drawed histograms
      // First we need to draw the histogram, or getAxis() will return 0... (see root code...)
      canvas_->Draw();
      canvas_->cd();
      stack->Draw("nostack");
      stack->GetYaxis()->SetTitleOffset(1.2);
      stack->GetYaxis()->SetTitle(yTitle);
      stack->GetXaxis()->SetTitle(xTitle);
      stack->GetXaxis()->SetTitleColor(kBlack);
      stack->Draw("nostack");
      legend_->Draw("same");

      canvas_->Update();
      canvas_->Draw();
      canvas_->ForceUpdate();
      //canvas_->Print("test.pdf");
      canvas_->Write();

    }
  }
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:42,代码来源:KinematicsComparison.C


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