• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TDirectoryFile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: SaveOutput

// Save to .root file
void SaveOutput(TString name,TList &list)
{
	TFile *out = new TFile(name,"RECREATE");
	TDirectory *pwd = gDirectory;
	for(int i=0;i<list.GetSize();i++)
	{
		TDecayMode *dm = list.At(i);
		TDirectory *subdir = out->mkdir(dm->GetName());
		subdir->cd();
		subdir->Append(dm);
		subdir->Append(dm->histograms);
		pwd->cd();
	}
	if(!genDesc) cout<<"WARNING! No Generator description in files!"<<endl;
	else out->Append(genDesc);
	if(userHisto)
	{
		
		TDecayMode *uh = (TDecayMode*) userHisto;
		cout<<"INFO: Appending user histograms"<<endl;
		TDirectoryFile *histos = out->mkdir("USER_HISTOGRAMS");
		TIter  nexthist(uh->histograms);
		TKey  *key_hist=0;
		TH1D *h;
		while(h=(TH1D*)nexthist()) histos->Append(h);
	}
	out->Write();
	out->Close();
	delete out;
}
开发者ID:aashaqshah,项目名称:cmssw-1,代码行数:31,代码来源:MERGE.C


示例2: pv_dist

void pv_dist(const string& fFile, const string& fTitle, const string& fNameExt) {
  
   TH1F *h;
    
   TFile file(fFile.c_str());
   TDirectoryFile *dir = (TDirectoryFile*)file.Get("offsetAnalysis");
   TDirectoryFile *subDir = (TDirectoryFile*)dir->Get("PrimaryVertices");

   h = (TH1F*)subDir->Get("h_NofPVs"); 
   
   string name = h->GetName();
   string fileName = name + "__" + fNameExt + ".png";
   
   h->SetTitle(fTitle.c_str());
   
   TCanvas *c = new TCanvas("c","",1120,800);
   c->cd();
     
   h->SetLineWidth(2);
   h->Draw();
   
   c->SetLogy();
   c->SaveAs(fileName.c_str());
   
   delete c;
}
开发者ID:ferencek,项目名称:cms-Offset_Analysis,代码行数:26,代码来源:pvPlots.C


示例3: MakeHistsForSlides

Double_t MakeHistsForSlides(TString goodFile, TString badFile, TString rootFile)
{
  //Extracting the histogram
  TFile* f = TFile::Open(rootFile);
  TDirectoryFile* dirFile = (TDirectoryFile*)(f->Get("AliAnalysisTaskCalibEmcal"));
  TList* list = (TList*)(dirFile->Get("histogram"));
  TH2D* cellVAmplitude = (TH2D*)(list->FindObject("_histogram_cell_id_amplitude"));

    
  //Getting a Good Cell
  TH1D* goodC = new TH1D();
  ifstream myFile(goodFile);
  TString title = "";

  const int num = 500;

  if(myFile.is_open())
    {
      string line = "";
      std::getline(myFile,line);

      int index = 0;
      double chi2 = 0.0;
      
      while(myFile >> index >> chi2 && index < num)
	{
	  //cout << index << "\t" << chi2 << endl;
	  title = Form("Energy distribution of Cell %d",index);
	  TH1D* goodCell = cellVAmplitude->ProjectionY("goodCell", index+1,index+1);
	  goodC = (TH1D*)goodCell->Clone();
	}
    }
开发者ID:dhruvdixit,项目名称:emcal_tower_calibration,代码行数:32,代码来源:MakeHistsForSlides.C


示例4: getEffHists

std::pair<TH3F*,TH3F*> getEffHists(const char *file, const char *dirC, 
				     const char *histN, const char *histD){

     TFile *efile = new TFile(file,"read");
     TDirectoryFile *efileDIR = (TDirectoryFile*) efile->GetDirectory(dirC);

     TIter next(efileDIR->GetListOfKeys());
     TKey *key;

     Char_t name[100];

     TH3F *hpneff3d=0;
     TH3F *hpdeff3d=0;

     while ((key=(TKey*)next())) {
	sprintf(name,"%s",key->GetName());
	if(strcmp((key->GetName()),(histN))==0){
	  //cout<<"[getEffHists] Your numerator for Eff "<<name<<endl; 
	   hpneff3d = (TH3F*) efileDIR->Get(name);
	}
	if(strcmp((key->GetName()),(histD))==0){
	  //cout<<"[getEffHists] Your denominator for Eff "<<name<<endl; 
	   hpdeff3d = (TH3F*) efileDIR->Get(name);
	}
     }

     //efileDIR->Close(); 
     //efile->Close(); 
     return std::pair<TH3F*,TH3F*>(hpneff3d,hpdeff3d);
  }
开发者ID:CmsHI,项目名称:CVS_ASYoon,代码行数:30,代码来源:HiCorrectTypeOneNSave.C


示例5: overlay_plots

void overlay_plots(const string& fFile0, const string& fFile1, const double fYmax, const string& fPlot, const string& fLegendEnt1, const string& fLegendEnt2, const string& fName) {
  
   TProfile *p[2];
 
   TFile file0(fFile0.c_str());
   TDirectoryFile *subDir = (TDirectoryFile*)file0.Get("offsetAnalysis");
   p[0] = (TProfile*)subDir->Get(fPlot.c_str());

   TFile file1(fFile1.c_str());
   subDir = (TDirectoryFile*)file1.Get("offsetAnalysis");
   p[1] = (TProfile*)subDir->Get(fPlot.c_str()); 

   p[0]->SetTitleOffset(1.5,"Y");
   p[0]->GetXaxis()->SetTitleSize(0.04);
   p[0]->GetYaxis()->SetTitleSize(0.04);
   
   double ymax = ((p[0]->GetMaximum())>(p[1]->GetMaximum())) ? p[0]->GetMaximum() : p[1]->GetMaximum();
   
   p[0]->GetYaxis()->SetRangeUser(0.,fYmax);
   
   TCanvas *c = new TCanvas("c","",800,800);
   c->cd();
  
   p[0]->SetLineWidth(3);
   p[0]->SetLineColor(kRed);
   p[0]->SetFillColor(kRed);
   p[0]->Draw("hist");
   p[1]->SetLineWidth(3);
   p[1]->SetLineColor(kBlack);
   p[1]->SetMarkerStyle(20);
   p[1]->SetMarkerColor(kBlack);
   p[1]->Draw("sames");
   
   TLegend *legend = new TLegend(.57,.77,.9,.87);
   legend->SetBorderSize(1);
   legend->SetFillColor(0);
//    legend->SetFillStyle(0);
   legend->SetMargin(0.12);
   legend->AddEntry(p[0],fLegendEnt1.c_str(),"l");
   legend->AddEntry(p[1],fLegendEnt2.c_str(),"l");
   legend->Draw();
   
   TLatex l;
   l.SetTextAlign(12);
   l.SetTextSize(0.04);
   l.SetTextFont(62);
   l.SetNDC();
   l.DrawLatex(0.15,0.85,"CMS 2009 Preliminary");
   
   string fileName = fName;
   c->SetGridy();
   c->SaveAs(fileName.c_str());
   
   delete legend;
   delete c;
}
开发者ID:ferencek,项目名称:cms-Offset_Analysis,代码行数:56,代码来源:makePlots.C


示例6: main

int
main (int argc, char *argv[])
{
  map<string, string> opt;
  vector<string> argVector;
  parseOptions (argc, argv, opt, argVector);
  if (argVector.size () != 1 || opt.count ("help"))
    {
      printHelp (argv[0]);
      return 0;
    }
  TFile *fin;
  if (!(fin = TFile::Open (argVector.at (0).c_str (), "update")))
    {
      cout << "Failed to open " << argVector.at (0) << "!" << endl;
      return 0;
    }
  TIter next0 (fin->GetListOfKeys ());
  TObject *obj0;
  TH1D *cutFlow = 0;
  TDirectoryFile *dir = 0;
  while ((obj0 = next0 ()))
    {
      string obj0Class = ((TKey *) obj0)->GetClassName (),
             obj0Name = obj0->GetName ();

      if (obj0Class == "TDirectoryFile")
        {
          dir = (TDirectoryFile *) fin->Get (obj0Name.c_str ());
          TIter next1 (dir->GetListOfKeys ());
          TObject *obj1;
          while ((obj1 = next1 ()))
            {
              string obj1Class = ((TKey *) obj1)->GetClassName (),
                     obj1Name = obj1->GetName ();

              if (obj1Class == "TH1D" && obj1Name.length () >= 7 && ((obj1Name.substr (obj1Name.length () - 7, 7) == "CutFlow" || obj1Name.substr (obj1Name.length () - 7, 7) == "cutFlow")
               || (obj1Name.length () >= 9 && (obj1Name.substr (obj1Name.length () - 9, 9) == "Selection" || obj1Name.substr (obj1Name.length () - 9, 9) == "selection"))
               || (obj1Name.length () >= 8 && (obj1Name.substr (obj1Name.length () - 8, 8) == "MinusOne" || obj1Name.substr (obj1Name.length () - 8, 8) == "minusOne")))
               && !dir->Get ((obj1Name + "LowerLimit").c_str ()) && !dir->Get ((obj1Name + "UpperLimit").c_str ()))
                {
                  cutFlow = (TH1D *) dir->Get (obj1Name.c_str ());
                  cutFlow->SetDirectory (0);
                  getLimits (cutFlow, dir);
                }
            }
        }
    }
  fin->Close ();

  return 0;
}
开发者ID:allenji,项目名称:OSUT3Analysis,代码行数:52,代码来源:cutFlowLimits.cpp


示例7: filechk

int filechk(string fname)
{
  //TFile f("DQM_V0001_SiStrip_R000062940.root");
  TFile f(fname.c_str());

  if (f.IsZombie()){
    //cout << "File corrupted" << endl;
  return -1;
  }
  else
  {
    if ( fname.find("_SiStrip_") != string::npos ){
      TString rnStr = fname.substr(fname.find("_R") + 2, 9);
      TString runDirStr("Run ");
      runDirStr += rnStr.Atoi();
      TDirectoryFile* runDir = (TDirectoryFile*)f.FindObjectAny(runDirStr);
      if ( runDir == 0 )
        return 0; 
      
      TDirectoryFile* tracking = (TDirectoryFile*)runDir->FindObjectAny("Tracking");
      if ( tracking == 0 )
        return 0;
      
      TDirectoryFile* sistrip = (TDirectoryFile*)runDir->FindObjectAny("SiStrip");
      if ( sistrip == 0 )
        return 0;  
       
      TDirectoryFile* hist = (TDirectoryFile*)tracking->FindObjectAny("reportSummaryMap");
      if ( hist == 0 )
        return 0;
       
      hist = (TDirectoryFile*)sistrip->FindObjectAny("reportSummaryMap");
      if ( hist == 0 )
        return 0; 
      
      return 1;
    }
    
    //TH2F* hist;
    //hist = (TH2F*)f.FindObjectAny("reportSummaryMap");
    TDirectoryFile* hist;	
    //hist = (TDirectoryFile*)f.FindObjectAny("reportSummaryContents");
    hist = (TDirectoryFile*)f.FindObjectAny("reportSummaryMap");
    if (0 == hist) 
    {
      TDirectoryFile* hist2;
      hist2 = (TDirectoryFile*)f.FindObjectAny("EventInfo");
      if (0 != hist2)
        return 1;

      //cout << "File is incomplete" << endl;
      return 0;
    }
    else
    {
      //cout << "File is OK" << endl;
      return 1;
    }
  }
}
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:60,代码来源:filechk.C


示例8: next

void histoBook::loadRootDir( TDirectory* tDir, string path ){

	//cout << "histoBook.loadRootDir] Path : " << path << endl;

	TList* list;

	if ( tDir ){
		list = tDir->GetListOfKeys();  
	} else {
		cout << "[histoBook.loadRootDir] Bad Directory Given " << endl;
		return;
	}

	TIter next(list);  
	TKey* key;  
	TObject* obj;   
	
	while ( (key = (TKey*)next()) ) {    
		
		obj = key->ReadObj() ;    
		
		if ( 0 == strcmp(obj->IsA()->GetName(),"TDirectoryFile") ){
			TDirectoryFile* dir = (TDirectoryFile*)obj;
			
			string nPath = path + dir->GetName();
			if ( path == (string) "" )
				nPath = path + dir->GetName();
			else 
				nPath = path + "/" + dir->GetName();

			cd( nPath );
			loadRootDir( dir, nPath );
		} else if ( obj ){
			if (    (strcmp(obj->IsA()->GetName(),"TProfile")!=0) && (!obj->InheritsFrom("TH2") && (!obj->InheritsFrom("TH1"))) ) {      
				// not a 1d or 2d histogram
			} else {
				// add it to the book
				//cout << "Adding : " << obj->GetName() << endl;
				add( obj->GetName(), (TH1*)obj->Clone( obj->GetName() ) );
			}    
			
		}
	}	

}
开发者ID:jdbrice,项目名称:refMult,代码行数:45,代码来源:histoBook.cpp


示例9: GetCoefficient

int GetCoefficient(TString txtFile, TString rootFile)
{
  //Extracting the histogram
  TFile* f = TFile::Open(rootFile);
  TDirectoryFile* dirFile = (TDirectoryFile*)(f->Get("AliAnalysisTaskCalibEmcal"));
  TList* list = (TList*)(dirFile->Get("histogram"));
  TH2D* cellVAmplitude = (TH2D*)(list->FindObject("_histogram_cell_id_amplitude"));
  
  //cout << __FILE__ << __LINE__ << endl;

  //Cell Tower range to analyse
  const Int_t CVALow = 0;
  const Int_t CVAHigh = 17670;
  
  //cout << __FILE__ << __LINE__ << endl;

  //Obtaining a histogram of the Good cells.
  TList* goodHistList = new TList;
  ifstream goodFile(txtFile);
  int numCells = 0;
  if(goodFile.is_open())
    {

      //cout << __FILE__ << __LINE__ << endl;

      string line = "";
      std::getline(goodFile,line);
      int index = 0;
      double chi2 = 0.0;
      
      //cout << __FILE__ << __LINE__ << endl;

      //for(index = 0; index < 3; index++)
      while(goodFile >> index >> chi2)
	{
	  //cout << Form("cell%d",index) << endl;
	  TH1D* cell = cellVAmplitude->ProjectionY(Form("cell%d",index),index+1,index+1);
	  goodHistList->Add(cell);
	  numCells++;
	}
      
    }
开发者ID:dhruvdixit,项目名称:emcal_tower_calibration,代码行数:42,代码来源:GetCoefficient.C


示例10: it

// Noise section
Stat_t AnalysisClass::doHisto(Char_t * Variable, Char_t *SubDetName, Char_t *Layer,Char_t *label){
  TH1 *hHisto=0; 
  if (debug)   cout << d1->GetTitle() << " " << Variable << " " << SubDetName << endl;
  pPar[0]=0; pPar[1]=0;
  TIter it(d1->GetListOfKeys());
  TObject * o;
  while ( (o = it()))  
    {
      TObject * d =  d1->Get(o->GetName());
      if(d->IsA()->InheritsFrom("TDirectory") && strstr(d->GetName(),SubDetName)){
	if (debug) 	cout << "Found SubDet " << SubDetName << endl;
	TIter it2(((TDirectoryFile * )d)->GetListOfKeys());
	TObject *o2;
	while( ( o2 = it2()) ){
	  TObject *d2 = ((TDirectoryFile * )d)->Get(o2->GetName());
	  if(d2->IsA()->InheritsFrom("TDirectory") && strstr(d2->GetName(),Layer) ){
	    if (debug) cout << "Found Layer" << Layer << endl;
	    TIter it3(((TDirectoryFile * )d2)->GetListOfKeys());
	    TObject *o3;
	    while( ( o3 = it3()) ){
	      TObject *d3 = ((TDirectoryFile * )d2)->Get(o3->GetName());
	      if(strstr(d3->GetName(),Variable) && strstr(d3->GetName(),label)){
		hHisto = (TH1*) d3;
		if(hHisto->GetEntries()!=0) {
		  pPar[0]=hHisto->GetMean();
		  pPar[1]=hHisto->GetRMS();  
		  if (debug) cout << "Histo Title " << hHisto->GetTitle() << " mean: " << hHisto->GetMean() << " rms: " << hHisto->GetRMS() << " " << hHisto->GetEntries() << endl;
		}
		else{
		  cout<<"Empty Histogram "<< hHisto->GetTitle() << endl;
		  pPar[0]=-10; pPar[1]=-10;
		}
	      }
	    }
	  }
	}
      }
    }
  return hHisto->GetEntries();  
}
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:41,代码来源:LayerTree.cpp


示例11: GenerateTDiffPlots

// This will generate the following PDFs:
// -- hDQ_muScTDiff_[DetName]_[BankName].png
void GenerateTDiffPlots(std::string filename) {

  std::cout << "Generating pulse shape plots..." << std::endl;

  gROOT->Reset();
  gROOT->SetStyle("Plain");
  gStyle->SetCanvasBorderMode(0); // turn off canvas borders


  TFile* file = new TFile(filename.c_str(), "READ");

  // The histograms
  TH1F *hDQ_muScTDiff;

  // Loop through the histograms in the file and get the island histograms (bank and channel names may differ between runs)
  TDirectoryFile* dir = (TDirectoryFile*) file->Get("DataQuality_LowLevel");
  
  TIter nextDirKey(dir->GetListOfKeys()); // get the list of keys in the directory (all histograms should be in this folder)
  TKey *dirKey;
  
  while ( (dirKey = (TKey*)nextDirKey()) ) {
    // Get the names of all the histograms and count them up
    if (strcmp(dirKey->ReadObj()->ClassName(), "TH1F") == 0) {

      TCanvas *c1 = new TCanvas();

      std::string histogram_name = dirKey->ReadObj()->GetName();
      std::string histogram_location = "DataQuality_LowLevel/" + histogram_name;
      std::string pngname = "data_quality_figs/" + histogram_name + ".png";

      if (histogram_name.find("muScTDiff") != std::string::npos) {
	file->GetObject(histogram_location.c_str(),hDQ_muScTDiff);

	hDQ_muScTDiff->GetYaxis()->SetTitleOffset(1.3);
	hDQ_muScTDiff->Draw();
	c1->Print(pngname.c_str());
      }
    }
  }
}
开发者ID:alcap-org,项目名称:AlcapDAQ,代码行数:42,代码来源:GenerateTDiffPlots.C


示例12: plotProducer2

void plotProducer2(const string& fFile, const string& fPlot, const string& fNameExt, const string& fExt, const string& fSwitch) {
  
   TH2F *h;
    
   TFile file(fFile.c_str());
   TDirectoryFile *dir = (TDirectoryFile*)file.Get("offsetAnalysis");
   TDirectoryFile *subDir = (TDirectoryFile*)dir->Get("PrimaryVertices");

   h = (TH2F*)subDir->Get(fPlot.c_str());

   string name = h->GetName();
   string fileName = name + "__" + fNameExt + "." + fExt;
   
   TCanvas *c = new TCanvas("c","",1120,800);
   c->cd();
     
   h->Draw(fSwitch.c_str());

   c->SaveAs(fileName.c_str());
   
   delete c;
}
开发者ID:ferencek,项目名称:cms-Offset_Analysis,代码行数:22,代码来源:pvAdditionalPlots.C


示例13: plotProducer

void plotProducer(const string& fFile, const string& fPlot, const string& fNameExt, const string& fExt, const string& fSwitch) {
  
   TH1F *h;
    
   TFile file(fFile.c_str());
   TDirectoryFile *dir = (TDirectoryFile*)file.Get("offsetAnalysis");
   TDirectoryFile *subDir = (TDirectoryFile*)dir->Get("PrimaryVertices");

   h = (TH1F*)subDir->Get(fPlot.c_str());

   string name = h->GetName();
   string fileName = name + "__" + fNameExt + "." + fExt;
   
   TCanvas *c = new TCanvas("c","",1120,800);
   c->cd();
     
   //h->SetLineWidth(2);
   h->Draw();
   
   if ( fSwitch.find("log") != string::npos ) c->SetLogy();
   c->SaveAs(fileName.c_str());
   
   delete c;
}
开发者ID:ferencek,项目名称:cms-Offset_Analysis,代码行数:24,代码来源:pvAdditionalPlots.C


示例14: GetOption

void mySelector::Terminate()
{
   // The Terminate() function is the last function to be called during
   // a query. It always runs on the client, it can be used to present
   // the results graphically or save the results to file.
  TString option = GetOption();
  TString output = "gr_";
  output += option;
  output += ".root";
  TFile *hfile = new TFile(output,"RECREATE","FONLL CCbar cross section");
  
  hfile->cd();
  const Int_t npoint = eventnumber;
  Float_t x[npoint];
  Float_t y[npoint];
  Float_t ylow[npoint];
  Float_t yup[npoint];
  for(int i=0;i<npoint;i++)
    {
      x[i] = Pt[i];
      y[i] = Central[i];
      ylow[i] = Down[i];
      yup[i] = Up[i];
    }
  //TGraph *grFONLLD0 = new TGraph(npoint,Pt,Central);
  TDirectoryFile *ratioErr = new TDirectoryFile(option,"ratio error of scale pp500 to pp200 ");
  ratioErr->SetName(option);
  ratioErr->Add(hRatio);
  TGraph *grFONLLRatio = new TGraph(npoint,x,y);
  grFONLLRatio->SetName("grFONLLRatio");
  TGraph *grFONLLRatio_u = new TGraph(npoint,x,yup);
  grFONLLRatio_u->SetName("grFONLLRatio_u");
  TGraph *grFONLLRatio_d = new TGraph(npoint,x,ylow);
  grFONLLRatio_d->SetName("grFONLLRatio_d");
  grFONLLRatio->Print();
  ///grFONLLRatio->Write();
  ratioErr->Add(grFONLLRatio);
  grFONLLRatio_u->Print();
  //grFONLLRatio_u->Write();
  ratioErr->Add(grFONLLRatio_u);
  grFONLLRatio_d->Print();
  //grFONLLRatio_d->Write();
  ratioErr->Add(grFONLLRatio_d);
  ratioErr->Write();
  hfile->Print();
  hfile->Close();
  tNow.Set();
  cout<<"----------End of job----------"<<endl;
  tNow.Print();
}
开发者ID:heavyflavor,项目名称:script,代码行数:50,代码来源:UseTDirectoryFile.C


示例15: readMCPerform

void readMCPerform(TString filename="QAresults_AOD.root", Int_t drawOnlyDzerDplus = 1, Int_t runNumber=-1)
{

  const Int_t totTrending=5;
  Float_t vecForTrend[totTrending];
  TString varForTrending[totTrending]={"nDzeroCandperEv","nDplusCandperEv","nDsCandperEv","nLcCandperEv","nDstarCandperEv"};

  

  TTree* trtree=new TTree("trendingHF","tree of trending variables");
  trtree->Branch("nrun",&runNumber,"nrun/I");
  for(Int_t j=0; j<totTrending; j++){
    trtree->Branch(varForTrending[j].Data(),&vecForTrend[j],Form("%s/F",varForTrending[j].Data()));
    vecForTrend[j]=-99.;
  }

  TFile *ff = new TFile(filename.Data());

  Int_t color[5] = {kBlack, kRed, kGreen, kBlue, kOrange};

  TDirectoryFile *dirD2H = (TDirectoryFile *)ff->Get("PWG3_D2H_QA");
  if(!dirD2H){
    printf("Directory PWG3_D2H_QA not found in file %s\n",filename.Data());
    return;
  }
  TList *listD2H = (TList *)dirD2H->Get("nEntriesQA");
  if(!listD2H){
    printf("TList nEntriesQA not found in file %s\n",filename.Data());
    return;  
  }
  TH1F *hNentries = (TH1F *)listD2H->FindObject("hNentries");
  TH2F *hHasSelBit = (TH2F *)listD2H->FindObject("HasSelBit");

  TCanvas *cqa = new TCanvas("cqa", "cqa", 800, 500);
  cqa->Divide(2, 1);
  cqa->cd(1);
  hNentries->Draw();
  cqa->cd(2);
  hHasSelBit->Draw("colz");
  cqa->SaveAs("plot_D2HQA.png");

  Double_t nEv=hNentries->GetBinContent(10);
  vecForTrend[0]=hHasSelBit->GetBinContent(1)/nEv;
  vecForTrend[1]=hHasSelBit->GetBinContent(2)/nEv;
  vecForTrend[2]=hHasSelBit->GetBinContent(3)/nEv;
  vecForTrend[3]=hHasSelBit->GetBinContent(4)/nEv;
  vecForTrend[4]=hHasSelBit->GetBinContent(5)/nEv;


  TDirectoryFile *dir = (TDirectoryFile *)ff->Get("PWGHF_D2H_MCPerform");
  TList* list = 0x0;
  if (dir)
  {
    list = (TList *)dir->Get("coutputDperfQA");
    if(list){
    
      TH1F *hn = (TH1F *)list->FindObject("fHistNEvents");
      TH1F *hnGenD = (TH1F *)list->FindObject("fHistNGenD");
      Int_t entries = hn->GetBinContent(3);
      
      TH2F *fHistNCand = (TH2F *)list->FindObject("fHistNCand");
      TH1F *fHistNCandDzero = (TH1F *)fHistNCand->ProjectionY("fHistNCandDzero", 1, 1);
      TH1F *fHistNCandDplus = (TH1F *)fHistNCand->ProjectionY("fHistNCandDplus", 2, 2);
      TH1F *fHistNCandDstar = (TH1F *)fHistNCand->ProjectionY("fHistNCandDstar", 3, 3);
      TH1F *fHistNCandDs = (TH1F *)fHistNCand->ProjectionY("fHistNCandDs", 4, 4);
      TH1F *fHistNCandLc = (TH1F *)fHistNCand->ProjectionY("fHistNCandLc", 5, 5);
      
      TString names[5] = {"Dzero", "Dplus", "Dstar", "Ds", "Lc2pkpi"};
      TString type[2] = {"Prompt", "Feeddown"};
      const Int_t nDecays = 5;
      TH2F *fHistXvtxResVsPt[2 * nDecays];
      TH2F *fHistYvtxResVsPt[2 * nDecays];
      TH2F *fHistZvtxResVsPt[2 * nDecays];
      TH2F *fHistInvMassVsPt[2 * nDecays];
      TH2F *fHistDecLenVsPt[2 * nDecays];
      TH2F *fHistNormDLxyVsPt[2 * nDecays];
      TH2F *fHistCosPointVsPt[2 * nDecays];
      
      TH3F *fHistPtYMultGenDauInAcc[2 * nDecays];
      TH3F *fHistPtYMultRecoFilt[2 * nDecays];
      
      TProfile *fHistXvtxRes[2 * nDecays];
      TProfile *fHistYvtxRes[2 * nDecays];
      TProfile *fHistZvtxRes[2 * nDecays];
      TProfile *fHistXvtxMean[2 * nDecays];
      TProfile *fHistYvtxMean[2 * nDecays];
      TProfile *fHistZvtxMean[2 * nDecays];
      
      TH1F *fHistXvtxRes2[2 * nDecays];
      TH1F *fHistYvtxRes2[2 * nDecays];
      TH1F *fHistZvtxRes2[2 * nDecays];
      
      TProfile *fHistInvMass[2 * nDecays];
      TProfile *fHistDecLen[2 * nDecays];
      TProfile *fHistCosp[2 * nDecays];
      
      TH1F *fHistInvMassRes[2 * nDecays];
      
      TH1F *hEffPt[2 * nDecays];
      TH1F *htemp;
//.........这里部分代码省略.........
开发者ID:ktf,项目名称:AliPhysics,代码行数:101,代码来源:readMCPerform.C


示例16: processJpsi2eeQAplots

//______________________________________________________________________________
void processJpsi2eeQAplots(const Char_t* filename="jpsi_Default.root", 
			   TString suffix = "eps",
			   const Char_t* outfile="Jpsi2eeQAplots_output.root") {
  //
 
  //  
  TFile* file = TFile::Open(filename);
  
  // event wise histograms 
  TH1F* zDistrib = (TH1F*)GetHistogram(file, "default", "Event", "Z");
  
  // electron candidate histograms
  TH2F* tpcDedx = (TH2F*)GetHistogram(file, "default", "Track_ev1+", "P_InnerParam_TPC_signal");
  tpcDedx->Add((TH2F*)GetHistogram(file, "default", "Track_ev1-", "P_InnerParam_TPC_signal"));
  TH2F* tpcNsigmaEle = (TH2F*)GetHistogram(file, "default", "Track_ev1+", "P_InnerParam_TPC_nSigma_Electrons");
  tpcNsigmaEle->Add((TH2F*)GetHistogram(file, "default", "Track_ev1-", "P_InnerParam_TPC_nSigma_Electrons"));
  
  // pair candidate histograms
  TH1F* invmass_pp = (TH1F*)GetHistogram(file, "default", "Pair_ev1+_ev1+", "pM");
  TH1F* invmass_pm = (TH1F*)GetHistogram(file, "default", "Pair_ev1+_ev1-", "pM");
  TH1F* invmass_mm = (TH1F*)GetHistogram(file, "default", "Pair_ev1-_ev1-", "pM");
    
  // draw stuff
  TLatex* latex=new TLatex();
  latex->SetNDC();
  latex->SetTextSize(0.04);
  latex->SetTextFont(42);
  TCanvas* c1=new TCanvas("fig_dq_tpcDedx", "");
  if(tpcDedx) {
    tpcDedx->SetStats(kFALSE);
    tpcDedx->GetXaxis()->SetRangeUser(0.0,10.0);
    tpcDedx->GetYaxis()->SetRangeUser(40.0,120.0);
    tpcDedx->SetTitle("");
    tpcDedx->Draw("colz");
    latex->DrawLatex(0.12, 0.83, "J/#psi electron candidates");
  }
  
  TCanvas* c2=new TCanvas("fig_dq_tpcNsigmaElectron", "");
  if(tpcNsigmaEle) {
    tpcNsigmaEle->SetStats(kFALSE);
    tpcNsigmaEle->GetYaxis()->SetRangeUser(-5.0,5.0);
    tpcNsigmaEle->GetXaxis()->SetRangeUser(0.0,10.0);
    tpcNsigmaEle->SetTitle("");
    tpcNsigmaEle->Draw("colz");
    latex->DrawLatex(0.12, 0.83, "J/#psi electron candidates");
  }
  
  TCanvas* c3=new TCanvas("fig_dq_eeInvMass", "");
  if(invmass_pm) {
    invmass_pm->SetStats(kFALSE);
    invmass_pm->SetTitle("");
    invmass_pm->SetLineColor(1);
    invmass_pm->GetYaxis()->SetTitle(Form("Pairs per %.0f MeV/c^{2}", 1000.0*invmass_pm->GetXaxis()->GetBinWidth(1)));
    invmass_pm->GetXaxis()->SetTitle("m_{e^{+}e^{-}} (GeV/c^{2})");
    invmass_pm->Draw();
  }
  if(invmass_pp) {
    invmass_pp->SetLineColor(2);
    invmass_pp->Draw((invmass_pm ? "same" : ""));
  }
  if(invmass_mm) {
    invmass_mm->SetLineColor(4);
    invmass_mm->Draw((invmass_mm ? "same" : ""));
  }
  if(invmass_pm || invmass_mm || invmass_pp)
    latex->DrawLatex(0.12, 0.85, "J/#psi candidates");
  if(invmass_pm && zDistrib && zDistrib->Integral()>1.);
    latex->DrawLatex(0.12, 0.80, Form("candidates / event = %.3f", invmass_pm->Integral() / zDistrib->Integral()));
  TLegend* legend=new TLegend(0.7,0.7,0.89,0.89);
  legend->SetTextFont(42);
  legend->SetBorderSize(0);
  legend->SetFillColor(0);
  if(invmass_pm) legend->AddEntry(invmass_pm, "+- pairs", "l");
  if(invmass_pp) legend->AddEntry(invmass_pp, "++ pairs", "l");
  if(invmass_mm) legend->AddEntry(invmass_mm, "-- pairs", "l");
  if(invmass_mm || invmass_pm || invmass_pp) legend->Draw();
  
  c1->SaveAs(Form("fig_dq_tpcDedx.%s",suffix.Data()));
  c2->SaveAs(Form("fig_dq_tpcNsigmaElectron.%s",suffix.Data()));
  c3->SaveAs(Form("fig_dq_eeInvMass.%s",suffix.Data()));


  //  TFile* save=new TFile(outputName, "RECREATE");
  // c1->Write();
  // c2->Write();
  // c3->Write();
  // save->Close();


  // Added by jsatya

  TFile *fout = TFile::Open(outfile,"UPDATE");
  fout->ls();
  
  TDirectoryFile *cdd = NULL;
  cdd = (TDirectoryFile*)fout->Get("DQ");
  if(!cdd) {
    Printf("Warning: DQ <dir> doesn't exist, creating a new one");
    cdd = (TDirectoryFile*)fout->mkdir("DQ");
//.........这里部分代码省略.........
开发者ID:ktf,项目名称:AliPhysics,代码行数:101,代码来源:processJpsi2eeQAplots.C


示例17: stack_in_cone_contribs

void stack_in_cone_contribs(const string& fFile, const double fYmax, const string& fTitleExt, const string& fNameExt) {

   string title = "<E> in R_{cone}=0.5 -- "+ fTitleExt +";#eta;<E> [GeV]";
   
   TFile file(fFile.c_str());
   TDirectoryFile *subDir = (TDirectoryFile*)file.Get("offsetAnalysis");
   
   TProfile *p_AEC5EB  = (TProfile*)subDir->Get("p_AvgEinC5EB");
   TProfile *p_AEC5EE  = (TProfile*)subDir->Get("p_AvgEinC5EE");
   TProfile *p_AEC5HB  = (TProfile*)subDir->Get("p_AvgEinC5HB");
   TProfile *p_AEC5HE  = (TProfile*)subDir->Get("p_AvgEinC5HE");
   TProfile *p_AEC5HFl = (TProfile*)subDir->Get("p_AvgEinC5HFl");
   TProfile *p_AEC5HFs = (TProfile*)subDir->Get("p_AvgEinC5HFs");
//    TProfile *p_AEC5HO  = (TProfile*)subDir->Get("p_AvgEinC5HO");
   
   TH1D *h_AEC5EB  = p_AEC5EB->ProjectionX();
   TH1D *h_AEC5EE  = p_AEC5EE->ProjectionX();
   TH1D *h_AEC5HB  = p_AEC5HB->ProjectionX();
   TH1D *h_AEC5HE  = p_AEC5HE->ProjectionX();
   TH1D *h_AEC5HFl = p_AEC5HFl->ProjectionX();
   TH1D *h_AEC5HFs = p_AEC5HFs->ProjectionX();
   //TH1D *h_AEC5HO  = p_AEC5HO->ProjectionX();
   
   h_AEC5EB->SetFillColor(50);
   h_AEC5EE->SetFillColor(8);
   h_AEC5HB->SetFillColor(4);
   h_AEC5HE->SetFillColor(6);
   h_AEC5HFl->SetFillColor(16);
   h_AEC5HFs->SetFillColor(12);
   //h_AEC5HO->SetFillColor(7);
   
//    TCanvas *c = new TCanvas("c", "",1120,800);
   TCanvas *c = new TCanvas("c", "",800,800);
   c->cd();
   
   TH2F *h_bg = new TH2F("h_bg",title.c_str(),100,-5.,5.,100,0.,fYmax);
   h_bg->GetXaxis()->SetTitleSize(0.05);
   h_bg->GetYaxis()->SetTitleSize(0.05);
   h_bg->SetTitleOffset(1.,"X");
   h_bg->SetTitleOffset(1.3,"Y");
   h_bg->Draw();
   
   THStack *hs = new THStack("hs","");
   
   hs->Add(h_AEC5EB);
   hs->Add(h_AEC5EE);
   hs->Add(h_AEC5HB);
   hs->Add(h_AEC5HE);
   hs->Add(h_AEC5HFl);
   hs->Add(h_AEC5HFs);
   //hs->Add(h_AEC5HO);
   hs->Draw("histsame");
   
   TLegend *legend = new TLegend(.65,.6,.75,.85);
   legend->SetBorderSize(1);
   legend->SetFillColor(0);
//    legend->SetFillStyle(0);
//    legend->SetTextFont(42);
   legend->AddEntry(h_AEC5EB,"EB","f");
   legend->AddEntry(h_AEC5HB,"HB","f");
   legend->AddEntry(h_AEC5EE,"EE","f");
   legend->AddEntry(h_AEC5HE,"HE","f");
   legend->AddEntry(h_AEC5HFl,"HFl","f");
   legend->AddEntry(h_AEC5HFs,"HFs","f");
   //legend->AddEntry(h_AEC5HO,"HO","f");
   legend->Draw();
   
   string fileName = "h_AvgEinC5_stacked_" + fNameExt;
   
   c->SetGridy();
   gPad->Modified();
   gPad->Update();
   c->SaveAs(fileName.c_str());

   delete legend;
   delete hs;
   delete c;
}
开发者ID:ferencek,项目名称:cms-Offset_Analysis,代码行数:78,代码来源:makePlots.C


示例18: Slimmer


//.........这里部分代码省略.........
  chainB->SetBranchStatus("jets_AK5PF_photonEnergy",1);	
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_px",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_py",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_pz",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_energy",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_phi",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_eta",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_index",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_nconstituents",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_px",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_py",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_pz",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_energy",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_phi",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_eta",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_index",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_nconstituents",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_px",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_py",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_pz",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_energy",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_phi",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_eta",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_index",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_nconstituents",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_px",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_py",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_pz",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_energy",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_phi",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_eta",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_index",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_nconstituents",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_px",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_py",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_pz",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_energy",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_phi",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_eta",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_index",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_nconstituents",1);
  

  chainB->SetBranchStatus("pfmets_et",1);
  chainB->SetBranchStatus("pfmets_ex",1);
  chainB->SetBranchStatus("pfmets_ey",1);
  chainB->SetBranchStatus("pfmets_phi",1);
  chainB->SetBranchStatus("pfmets_sumEt",1);
  chainB->SetBranchStatus("pfmets_gen_et",1);
  chainB->SetBranchStatus("pfmets_gen_phi",1);

  chainB->SetBranchStatus("pfTypeImets_et",1);
  chainB->SetBranchStatus("pfTypeImets_ex",1);
  chainB->SetBranchStatus("pfTypeImets_ey",1);
  chainB->SetBranchStatus("pfTypeImets_phi",1);
  chainB->SetBranchStatus("pfTypeImets_sumEt",1);
  chainB->SetBranchStatus("pfTypeImets_gen_et",1);
  chainB->SetBranchStatus("pfTypeImets_gen_phi",1);

  chainB->SetBranchStatus("pv_x",1);
  chainB->SetBranchStatus("pv_y",1);
  chainB->SetBranchStatus("pv_z",1);
  chainB->SetBranchStatus("pv_tracksSize",1);
  chainB->SetBranchStatus("pv_ndof",1);
  chainB->SetBranchStatus("pv_isFake",1);
  chainB->SetBranchStatus("Npv",1);

  chainB->SetBranchStatus("run",1);
  chainB->SetBranchStatus("event",1);
  chainB->SetBranchStatus("lumiblock",1);
  chainB->SetBranchStatus("bunchCrossing",1);

  chainB->SetBranchStatus("beamSpot_y",1);
  chainB->SetBranchStatus("beamSpot_x",1);

  chainB->SetBranchStatus("weight",1);
  chainB->SetBranchStatus("model_params",1);

  // Make the new file
  TFile *newFile = new TFile(output_filename.Data(),"RECREATE");
  TDirectoryFile *dir = new TDirectoryFile("configurableAnalysis","configurableAnalysis");
  dir->cd();
  TTree *newtreeA = chainA->CloneTree(0);
  TTree *newtreeB = chainB->CloneTree(0);

  Int_t nentries = (Int_t)chainB->GetEntries();

  for (int iEnt = 0; iEnt<nentries; iEnt++) {
    chainA->GetEntry(iEnt);
    chainB->GetEntry(iEnt);
    newtreeA->Fill();
    newtreeB->Fill();
  }

  newtreeA->AutoSave();
  newtreeB->AutoSave();
  newFile->Write();
  newFile->Close();

}
开发者ID:RohanBhandari,项目名称:MJ,代码行数:101,代码来源:Slimmer.C


示例19: CreatePictureBooks

void CreatePictureBooks(const char* data_dir, int first_run, const int n_runs) {

  gROOT->Reset();
  gROOT->SetStyle("Plain");
  gStyle->SetCanvasBorderMode(0); // turn off canvas borders



  // Create the canvases
  TCanvas* trend_canvas = new TCanvas("trend_canvas", "trend_canvas");

  TFile* files[n_runs];
  TCanvas* individual_canvases[n_runs];

  // Names for opening, closing and saving to PDFs
  std::stringstream individual_basepdfname[n_runs];
  std::string individual_openpdfname[n_runs];
  std::string individual_closepdfname[n_runs];

  for (int iRun = 0; iRun < n_runs; ++iRun) {

    int run_number = first_run + iRun;

    // Open up the file for this run
    std::stringstream filename;
    filename << data_dir << "/hist/hist0" << run_number << ".root";
    files[iRun] = new TFile(filename.str().c_str(), "READ");

    // Create an individual canvas for this run
    std::stringstream canvasname;
    canvasname << "individual_canvas_run0" << run_number;
    individual_canvases[iRun] = new TCanvas(canvasname.str().c_str(),canvasname.str().c_str());

    // Open a PDF for each run
    individual_basepdfname[iRun].str("");
    individual_basepdfname[iRun] << "DQ_LowLevel_RunPlots_Run0" << run_number << ".pdf";
    
    individual_openpdfname[iRun] =  individual_basepdfname[iRun].str() + "[";
    individual_closepdfname[iRun] = individual_basepdfname[iRun].str() + "]"; 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TDocument类代码示例发布时间:2022-05-31
下一篇:
C++ TDirectory类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap