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


C++ TFile::mkdir方法代码示例

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


在下文中一共展示了TFile::mkdir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: KinematicsComparison

/**
 * This function draws histograms of kinematic characteristics of the Z, Y and J/Psi samples
 */
void KinematicsComparison() {
  gROOT->SetBatch(true);
  gROOT->SetStyle("Plain");

  TFile * inputFileList[3] = {
    new TFile("ResolutionAnalyzer_JPsi.root","READ"),
    new TFile("ResolutionAnalyzer_Y.root","READ"),
    new TFile("ResolutionAnalyzer_Z.root","READ")
  };

  TFile * outputFile = new TFile("KinematicsComparison.root", "RECREATE");

  int inputScaleList[3] = { 126629, 48122, 1667 };

  outputFile->cd();

  // Resonance comparison histograms
  // -------------------------------
  TDirectory * resonancesDir = outputFile->mkdir("Resonances");
  resonancesDir->cd();
  // drawKinematics( inputFileList, 0, "RecoResonance_Pt", "resonance Pt", "Pt(GeV)", "arbitrary units", "expected number of events in 3.3/pb" );
  // Pt
  drawKinematics( inputFileList, inputScaleList, "RecoResonance_Pt", "resonance Pt", "pt(GeV)", "arbitrary units", "expected number of events in 3.3/pb" );
  // Eta
  drawKinematics( inputFileList, inputScaleList, "RecoResonance_Eta", "resonance #eta", "#eta", "arbitrary units", "expected number of events in 3.3/pb" );
  // Phi
  drawKinematics( inputFileList, inputScaleList, "RecoResonance_Phi", "resonance #phi", "#phi", "arbitrary units", "expected number of events in 3.3/pb" );

  // Histograms of muons from the resonances
  // ---------------------------------------
  TDirectory * resonancesMuonsDir = outputFile->mkdir("ResonanceMuons");
  resonancesMuonsDir->cd();
  // DeltaPt
  drawKinematics( inputFileList, 0, "RecoResonanceMuons_Pt", "pt of muons from resonance", "pt(GeV)", "arbitrary units", "", "muons from " );
  // Eta
  drawKinematics( inputFileList, 0, "RecoResonanceMuons_Eta", "#eta of muons from resonance", "#eta", "arbitrary units", "", "muons from " );
  // Phi
  drawKinematics( inputFileList, 0, "RecoResonanceMuons_Phi", "#phi of muons from resonance", "#phi", "arbitrary units", "", "muons from " );

  // Histograms of Deltas of muons from the resonances
  // -------------------------------------------------
  TDirectory * resonancesMuonsDeltasDir = outputFile->mkdir("ResonanceMuonsDeltas");
  resonancesMuonsDeltasDir->cd();
  // DeltaCotgTheta
  drawKinematics( inputFileList, 0, "DeltaRecoResonanceMuons_DeltaCotgTheta", "#Delta Cotg(#theta) of muons from resonance", "Cotg(#theta)", "arbitrary units", "", "muons from " );
  // DeltaTheta
  drawKinematics( inputFileList, 0, "DeltaRecoResonanceMuons_DeltaTheta", "#Delta#theta of muons from resonance", "#Delta#theta", "arbitrary units", "", "muons from " );
  // DeltaEta
  drawKinematics( inputFileList, 0, "DeltaRecoResonanceMuons_DeltaEta", "|#Delta#eta| of muons from resonance", "|#Delta#eta|", "arbitrary units", "", "muons from " );
  // DeltaEtaSign
  drawKinematics( inputFileList, 0, "DeltaRecoResonanceMuons_DeltaEtaSign", "#Delta#eta with sign of muons from resonance", "#Delta#eta", "arbitrary units", "", "muons from " );
  // DeltaPhi
  drawKinematics( inputFileList, 0, "DeltaRecoResonanceMuons_DeltaPhi", "#Delta#phi of muons from resonance", "#Delta#phi", "arbitrary units", "", "muons from " );
  // DeltaR
  drawKinematics( inputFileList, 0, "DeltaRecoResonanceMuons_DeltaR", "#Delta R of muons from resonance", "#Delta R", "arbitrary units", "", "muons from " );
}
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:59,代码来源:KinematicsComparison.C

示例3: main

int main(int argc, char *argv[])
{
    std::auto_ptr<TRint> application(new TRint("histInMemory", 0, 0));

    TH1F *hist1 = new TH1F("hist1", "hist1", 50, 0, 10);
    TH1F *hist2 = new TH1F("hist2", "hist2", 50, 0, 10);
    TH1F *hist3 = new TH1F("hist3", "hist3", 50, 0, 10);
    TH1F *hist4 = new TH1F("hist4", "hist4", 50, 0, 10);
    TH1F *hist5 = new TH1F("hist5", "hist5", 50, 0, 10);

    {
        TRandom3 *random = new TRandom3(1);
        for(int i = 0; 10000 > i; ++i)
        {
            hist1->Fill(random->Gaus(5, 1));
            hist2->Fill(random->Poisson(5));
            hist3->Fill(random->Uniform(0, 10));
            hist4->Fill(random->Gaus(4, 1));
            hist5->Fill(random->Poisson(3));
        }
        delete random;
    }

    TFile *output = new TFile("output.root", "RECREATE");
    TDirectory *group1 = output->mkdir("group1");
    group1->cd();

    hist1->Write();
    hist2->Write();

    TDirectory *group2 = output->mkdir("group2");
    group2->cd();

    hist3->Write();
    hist4->Write();
    hist5->Write();

    delete output;

    application->Run(true);

    delete hist1;
    delete hist2;
    delete hist3;
    delete hist4;
    delete hist5;

    return 0;
}
开发者ID:skhal,项目名称:ROOT,代码行数:49,代码来源:directory.cpp

示例4: config

void ControlPlotter::config() 
{ 
  if (baseName_!="")
    {
      outFile_->mkdir(baseName_.c_str());
      outFile_->cd(baseName_.c_str());
      system(string("mkdir -p results/plots/" + fileName_ + "/" + baseName_).c_str());
    }

  string name  = (baseName_ + "_hTrkHits");
  hTH1_["hTrkHits"] = new TH1F(name.c_str(),name.c_str(),20,0.5,20.5);

  name  = (baseName_ + "_hChi2");
  hTH1_["hChi2"] = new TH1F(name.c_str(),name.c_str(),20,0.5,20.5);

  name  = (baseName_ + "_hGmtMatchedCands");
  hTH1_["hGmtMatchedCands"] = new TH1F(name.c_str(),name.c_str(),11,-0.5,10.5);

  name  = (baseName_ + "_hGmtDeltaPhi");
  hTH1_["hGmtDeltaPhi"] = new TH1F(name.c_str(),name.c_str(),100,0.,TMath::Pi());

  name  = (baseName_ + "_hGmtDeltaEta");
  hTH1_["hGmtDeltaEta"] = new TH1F(name.c_str(),name.c_str(),100,-1.,1.);

  name  = (baseName_ + "_hGmtDeltaPhiVsEta");
  hTH1_["hGmtDeltaPhiVsEta"] = new TH2F(name.c_str(),name.c_str(),24,-2.4,2.4,200,0.,TMath::Pi());

  name  = (baseName_ + "_hGmtDeltaEtaVsEta");
  hTH1_["hGmtDeltaEtaVsEta"] = new TH2F(name.c_str(),name.c_str(),24,-2.4,2.4,200,-1.,1.);
  
}
开发者ID:battibass,项目名称:L1MuonTriggerAnalysis,代码行数:31,代码来源:ControlPlotter.C

示例5: createRootFile

int createRootFile()
{

    TFile* pRootFile = new TFile("myfile.root", "RECREATE");
    if (pRootFile == NULL) {
        std::cout << "Error creating ROOT file" << std::endl;
        return 1;
    }

    TDirectory* pTestDir = pRootFile->mkdir("TestDir");
    if (pTestDir == NULL) {
        std::cout << "Error creating directory in ROOT file" << std::endl;
        delete pRootFile;
        return 1;
    }
    
    std::string name = "testobj";
    MyROOTObject* pMyObj = new MyROOTObject(17, 1.2e3, name);
    std::cout << *pMyObj << std::endl;

    pTestDir->cd();
    pMyObj->Write(pMyObj->GetName());

    if (pMyObj != NULL) {
        delete pMyObj;
    }

    if (pRootFile != NULL) {
        if (pRootFile->IsOpen() && !pRootFile->IsZombie()) {
            pRootFile->Close();
            delete pRootFile;
        }
    }

}
开发者ID:niklask,项目名称:ROOTexample,代码行数:35,代码来源:rootExample.cpp

示例6: real_emission_jackknife

void real_emission_jackknife(TString dir="real_aajj_splitted_for_jackknife", TString nameroot="outphoton_aajj_effunf_mu1", int N=20){

  TFile *outfile = new TFile(Form("%s/%s_jackknifed.root",dir.Data(),nameroot.Data()),"recreate");
  outfile->mkdir("effunf");

  vector<TFile*> files;
  for (int i=1; i<=N; i++){
    files.push_back(new TFile(Form("%s/%s_splitted_%d.root",dir.Data(),nameroot.Data(),i),"read"));
  }

  for (std::vector<TString>::const_iterator it = diffvariables_list.begin(); it!=diffvariables_list.end(); it++){
    for (int reg=0; reg<3; reg++)
      {
	TString diffvar = *it;
	vector<TH1F*> histos;
	TString thisname = Form("htruth_%s_%d",diffvar.Data(),reg);
	TString thisnamedir = Form("effunf/%s",thisname.Data());
	for (uint i=0; i<files.size(); i++){
	  histos.push_back((TH1F*)(files.at(i)->Get(thisnamedir.Data())));
	}
	TH1F *out = JackknifammiStiHistos(histos);
	out->SetName(thisname.Data());
	out->Print();
	outfile->cd("effunf");
	out->Write();
#ifdef DEBUG
	return;
#endif
      } 
  }
  
  outfile->Close();
};
开发者ID:peruzzim,项目名称:diphoton,代码行数:33,代码来源:real_emission_jackknife.C

示例7: writeObjsInFolder

void FileSaver::writeObjsInFolder(string folder, bool recreate)
{
	cout<<"*** Updating "<<filename.c_str()<<" file in "<< folder << endl;
	TFile * fileFinalPlots;

	if(recreate) fileFinalPlots=TFile::Open(filename.c_str(), "RECREATE");
	else fileFinalPlots=TFile::Open(filename.c_str(), "UPDATE");

	if (!fileFinalPlots->GetDirectory(folder.c_str()))
		fileFinalPlots->mkdir(folder.c_str());
	fileFinalPlots->cd   (folder.c_str());
	cout<<"vrce: "<<fArr->At(0)<<endl;
	if(fArr->At(0)){
		cout<<fArr->At(0)->GetName()<<endl; 	
		for (int i = 0; i <= fArr->GetLast(); i++){
			cout<<fArr->At(i)<<" "<<fArr->At(i)->GetName()<<endl;
			fArr->At(i)->Write(fArr->At(i)->GetName(),2);
			cout<<"Object saved ..."<<endl;
		}
	}
	fileFinalPlots->Flush();
	fileFinalPlots->Write();
        fileFinalPlots->Close();
        fArr->Clear();
        return;
}
开发者ID:francescodimiccoli,项目名称:Deutons,代码行数:26,代码来源:filesaver.cpp

示例8: FillHistograms

void FillHistograms(TString SAMPLE)
{
  cout<<"Processing sample "<<SAMPLE<<endl;
  //TString PATH("root://eoscms//eos/cms/store/cmst3/user/kkousour/ttH/flat/");
  TString PATH("/afs/cern.ch/work/k/kkousour/private/CMSSW_7_4_12/src/KKousour/TopAnalysis/prod/ttH/");
  TFile *inf  = TFile::Open(PATH+"flatTree_"+SAMPLE+".root");
  TFile *outf = TFile::Open(TString::Format("Histo_%s.root",SAMPLE.Data()),"RECREATE");

  TIter nextKey(inf->GetListOfKeys());
  TKey *key;
  while ((key = (TKey*)nextKey())) {
    TString dirName(key->GetName());
    cout<<"Found directory "<<dirName<<endl;
    
    TH1F *hPass = (TH1F*)inf->Get(dirName+"/TriggerPass");
    outf->mkdir(dirName);  
    TDirectory *dir = (TDirectory*)outf->Get(dirName); 
    TTree *tr   = (TTree*)inf->Get(dirName+"/events");
    
    TreeClass myTree(tr);
    dir->cd();
    hPass->Write("TriggerPass");
    myTree.Loop(dir);
    cout<<"Loop finished"<<endl;
    dir->Close();
    delete tr;
  }
  outf->Close();
  inf->Close();
}
开发者ID:isildakbora,项目名称:UserCode,代码行数:30,代码来源:FillHistograms.C

示例9: nsubvsV2

void nsubvsV2(){
	const int N=16;
	ofstream fstrVns;	TFile *f;
	if(isSum==0){
		fstrVns.open("nsV2_Prod.txt");
		f= new TFile("V2_nsvssub_Prod.root","Recreate");
	}
	else {
		fstrVns.open("nsV2_Sum.txt");
		f= new TFile("V2_nsvssub_Sum.root","Recreate");
	}
	
	const int nsamples[N]={1,2,3,4,5,6,8,10,15,20,30,75,50,100,150,300};
	double nsamples_[N], Vmeanmean[N], deltaVmeanmean[N];
	TVectorD vecVmeanmean_, vecnsamples, vecdeltaVmeanmean_, vecsigmaVmeanmean;
	vecVmeanmean_.ResizeTo(N);vecnsamples.ResizeTo(N);vecdeltaVmeanmean_.ResizeTo(N);vecsigmaVmeanmean.ResizeTo(N);
	for(int ibin=0; ibin<nbin ;ibin++){
		TDirectory *dir0 = f->mkdir(Form("D_%d",ibin));	
	for(int i=0;i<N;i++){
		TVectorD vecVmeanmean = getResVsub(nsamples[i]);
		vecnsamples[i]=(double)nsamples[i];
		vecVmeanmean_[i] = vecVmeanmean[ibin];
		vecdeltaVmeanmean_[i] = vecVmeanmean[ibin+nbin]/TMath::Sqrt(nsamples[i]);
		vecsigmaVmeanmean[i] = vecVmeanmean[ibin+nbin*2]/TMath::Sqrt(nsamples[i]);
		fstrVns<<nsamples[i]<<"\t"<<vecVmeanmean_[i]<<"\t"<<vecdeltaVmeanmean_[i]<<"\t"<<vecsigmaVmeanmean[i]<<endl;
	}
	dir0->cd();
	vecVmeanmean_.Write("Vmeanmean");
	vecdeltaVmeanmean_.Write("deltaVmeanmean");
	vecnsamples.Write("nsamples");
	}
	f->Close();
}
开发者ID:XuQiao,项目名称:HI,代码行数:33,代码来源:nsubvsV2.C

示例10: beffAnalysis

void beffAnalysis(const char* input, const char* output) {
  // input
  TFile* inputFile = TFile::Open(input);
  TTree* btagEff = (TTree*)inputFile->Get("btagEff");

  // output
  TFile* outputFile = TFile::Open(output,"RECREATE");

  // histogram with proper binning... cloned later on 
  Double_t binning[23] = {20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,120,140,160,180,200,1000};
  TH1F* ptSpectrum = new TH1F("PtSpectrum","PtSpectrum",22,binning);
  ptSpectrum->Sumw2();

  // produce the ratio plot for the 12 combinations of (CSVL,CSVM,CSVT),(Barrel,Endcap),(b,c,l)
  TClonesArray algorithms("TCut",3);
  new(algorithms[0]) TCut("CSVL","csv>0.244");
  new(algorithms[1]) TCut("CSVM","csv>0.679");
  new(algorithms[2]) TCut("CSVT","csv>0.898");

  TClonesArray etaRegions("TCut",2);
  new(etaRegions[0]) TCut("Barrel","abs(eta)<=1.2");
  new(etaRegions[1]) TCut("Endcaps","abs(eta)>1.2");

  TClonesArray flavor("TCut",3);
  new(flavor[0]) TCut("l","abs(flavor)!=4 && abs(flavor)!=5");
  new(flavor[1]) TCut("c","abs(flavor)==4");
  new(flavor[2]) TCut("b","abs(flavor)==5");

  for(int i=0; i< algorithms.GetEntries() ; ++i) {
    outputFile->mkdir(((TCut*)algorithms.At(i))->GetName());
    outputFile->cd(((TCut*)algorithms.At(i))->GetName());
    for(int j=0; j< etaRegions.GetEntries() ; ++j) {
      for(int k=0; k< flavor.GetEntries() ; ++k) {
        // histogram before tagging
        TH1F* pretag = ptSpectrum->Clone("pretag");
        btagEff->Draw("pt>>pretag",((*(TCut*)etaRegions.At(j))&&(*(TCut*)flavor.At(k)))*"eventWeight");
        // histogram after tagging
        TH1F* posttag = ptSpectrum->Clone("posttag");
        btagEff->Draw("pt>>posttag",((*(TCut*)algorithms.At(i))&&(*(TCut*)etaRegions.At(j))&&(*(TCut*)flavor.At(k)))*"eventWeight");
        // ratio
        TH1F* ratio = posttag->Clone(Form("h_eff_bTagOverGoodJet_pt%s_%s",((TCut*)flavor.At(k))->GetName(),
                                                                          ((TCut*)etaRegions.At(j))->GetName()));
        ratio->Divide(pretag);
        // cleanup
        delete pretag;
        delete posttag;
      }
    }
  }

  // cleanup
  algorithms.Delete();
  etaRegions.Delete();
  flavor.Delete();
  ptSpectrum->SetDirectory(0);
  outputFile->Write();
  outputFile->Close();
  inputFile->Close();
}
开发者ID:camillebeluffi,项目名称:zbb_louvain,代码行数:59,代码来源:beffAnalysis.C

示例11: store

void store(){
	 if (!TClass::GetDict("NBD")) {
                gROOT->ProcessLine(".L /afs/cern.ch/user/q/qixu/CMSSW_6_2_5/src/Centrality/NBD_Glauber_fit/NBD/NBDclass.C+");
        }
	TH1::AddDirectory(kFALSE); 
	int Gth=atoi(getenv("GTH"));
	int sth=atoi(getenv("STH"));
	NBD *l;
	struct para1 var;
        if(sth==0){TString dirname = "std"; var = var1; if(Gth<nGlau) l = new NBD(datafile,stdGlaulist[Gth],histoname);else l = new NBD(datafile,stdGlaulist[0],histoname);}
        else if(sth==1){TString dirname ="Gri055"; var = var2; if(Gth<nGlau) l = new NBD(datafile,Gri055Glaulist[Gth],histoname);else l = new NBD(datafile,Gri055Glaulist[0],histoname);}
        else {TString dirname ="Gri101"; var = var3; if(Gth<nGlau) l = new NBD(datafile,Gri101Glaulist[Gth],histoname);else l = new NBD(datafile,Gri101Glaulist[0],histoname);}
	l->initmu(var.mumin,var.mumax,var.mustep);
     	l->initk(var.kmin,var.kmax,var.kstep);
	if(Gth<nGlau)
        	l->initx(var.xmin,var.xmax);
	else if(Gth-nGlau==0)
		l->initx(var.xmin-binshift,var.xmax);
	else
		l->initx(var.xmin+binshift,var.xmax);
//	l->fit();

 	if(sth==0) l->assign(bestlist1[Gth].mubest,bestlist1[Gth].kbest);
	else if(sth==1) l->assign(bestlist2[Gth].mubest,bestlist2[Gth].kbest);
	else l->assign(bestlist3[Gth].mubest,bestlist3[Gth].kbest);

        l->initN(bin,N,method);
        l->calcvar();
	TFile *outfile = new TFile(outG,"Update");
	if(Gth==0 && sth==0){
	l->dataname.Write("dataname",TObject::kOverwrite);
	l->histoname.Write("histoname",TObject::kOverwrite);
	}
	TDirectory *dir = outfile->GetDirectory(dirname);
	if (!dir) {outfile->mkdir(dirname);	TDirectory *dir = outfile->GetDirectory(dirname);}
	dir->cd();
	TString name;
	if(Gth==0)
		name = "G0";
	else if(Gth<nGlau)
		name = Form("Glau_%d",Gth);
	else
		name = Form("bin_%d",Gth-nGlau+1);
	TDirectory *subdir = dir->GetDirectory(name);
	if(!subdir) {dir->mkdir(name);	TDirectory *subdir = dir->GetDirectory(name);}
	subdir->cd();
	l->method.Write("method",TObject::kOverwrite);
	l->Glaubername.Write("Glaubername",TObject::kOverwrite);
	l->xmin.Write("xmin",TObject::kOverwrite);l->xmax.Write("xmax",TObject::kOverwrite);
	l->mubest.Write("mubest",TObject::kOverwrite);l->kbest.Write("kbest",TObject::kOverwrite);
	l->chis.Write("chis",TObject::kOverwrite);l->Ndf.Write("Ndf",TObject::kOverwrite);
	l->NcollAver.Write("NcollAver",TObject::kOverwrite);l->NpartAver.Write("NpartAver",TObject::kOverwrite);l->BAver.Write("BAver",TObject::kOverwrite);
	l->centbin.Write("centbin",TObject::kOverwrite);	l->kpoint.Write("kpoint",TObject::kOverwrite);
	l->centbin_.Write("centbin_",TObject::kOverwrite);	l->kpoint_.Write("kpoint_",TObject::kOverwrite);
	l->Npartdis->Write();
        l->Grgrid->Write("Grgrid",TObject::kOverwrite);
        outfile->Close();

}
开发者ID:XuQiao,项目名称:HI,代码行数:59,代码来源:store.C

示例12: finish

void FakeAnalysis::finish() {
  TFile *file = histfiles::initializeTFile( this );
  if(file==NULL) return;
  string directory_name("Fake_Hist");
  file->mkdir(directory_name.c_str());
  _histos.save(file, directory_name);
  file->Close();
}
开发者ID:hengne,项目名称:d0wmass,代码行数:8,代码来源:FakeAnalysis.cpp

示例13: merge

void merge(){
	TVectorD Nevent;	Nevent.ResizeTo(nbin);  Nevent.Zero();
     //   TVectorD totmultall;	totmultall.ResizeTo(nbin);      totmultall.Zero();
     //   TVectorD avgmultall;	avgmultall.ResizeTo(nbin);      avgmultall.Zero();
        TVectorD tottrk;	tottrk.ResizeTo(nbin);      tottrk.Zero();
//	TVectorD totptall;      totptall.ResizeTo(nbin);    totptall.Zero();
//	TVectorD totetaall;      totetaall.ResizeTo(nbin);    totetaall.Zero();
        TVectorD avgtrk;	avgtrk.ResizeTo(nbin);      avgtrk.Zero();
//	TVectorD avgmult;       avgmult.ResizeTo(nbin);
            
        TH2F* s[nbin];
        TH2F* b[nbin];
        for(int ibin=0;ibin<nbin;ibin++){
            s[ibin] = new TH2F(Form("s_%d",ibin),Form("signal",ibin),detastep,detamin,detamax,dphistep,dphimin,dphimax);
            s[ibin]->Sumw2();
            b[ibin]  = new TH2F(Form("b_%d",ibin), "background",detastep,detamin,detamax,dphistep,dphimin,dphimax);
            b[ibin]->Sumw2();
        }
        TFile *fout = new TFile(Form("Anav3_merged.root"),"Recreate");
        TFile *f[nFileAll];
        for(int ifile=; ifile<63; ifile++){
                f[ifile] = TFile::Open(Form("%s/Anav3_%d.root",outdir.Data(),ifile));
                if(!f[ifile]) continue;
		TVectorD* Nevent_t =  (TVectorD*)f[ifile]->Get(Form("Nevent"));
	//	TVectorD* totmultall_t =  (TVectorD*)f[ifile]->Get(Form("totmultall"));
		TVectorD* tottrk_t =  (TVectorD*)f[ifile]->Get(Form("tottrk"));
	//	TVectorD* totptall_t =  (TVectorD*)f[ifile]->Get(Form("totptall"));
//		TVectorD* totetaall_t =  (TVectorD*)f[ifile]->Get(Form("totetaall"));
		for(int ibin=0;ibin<nbin;ibin++){
			//	totptall[ibin] += (*totptall_t)[ibin];
			//	totetaall[ibin] += (*totetaall_t)[ibin];
			        Nevent[ibin] += (*Nevent_t)[ibin];
			  //      totmultall[ibin] += (*totmultall_t)[ibin];	
			        tottrk[ibin] += (*tottrk_t)[ibin];	
                                TH1D* s_t = (TH1D*)f[ifile]->Get(Form("signal_%d",ibin));
                                TH1D* b_t = (TH1D*)f[ifile]->Get(Form("background_%d",ibin));
                                s[ibin]->Add(s_t);
                                b[ibin]->Add(b_t);
		}
		f[ifile]->Close();
        }
    for(int ibin=0;ibin<nbin;ibin++){
    avgtrk[ibin] = tottrk[ibin]/Nevent[ibin];
    TH1D* hr = (TH1D*)s[ibin]->Clone("hr");
    hr->Divide(b[ibin]);
    hr->Scale(b[ibin]->GetBinContent(b[ibin]->FindBin(0,0)));

    fout->cd();
    Nevent.Write("Nevent");
    avgtrk.Write("avgtrk");
    TDirectory *dir0 = (TDirectory*)fout->mkdir(Form("D_%d",ibin));
    dir0->cd();
    s[ibin]->Write("s");
    b[ibin]->Write("b");
    hr->Write();
    }
}
开发者ID:XuQiao,项目名称:HI,代码行数:57,代码来源:merge.C

示例14: produceEnergyHistos

int produceEnergyHistos(CSPrereqs& csp)
{
    cout << endl << "Mapping " << csp.name << " TOF histogram to energy domain..." << endl;

    // open input file
    TFile* inputFile = new TFile(inputFileName.c_str(),"READ");
    if(!inputFile->IsOpen())
    {
        cerr << "Error: failed to open " << inputFileName << "  to fill histos." << endl;
        return 1;
    }

    // create output file
    TFile* outputFile = new TFile(outputFileName.c_str(),"RECREATE");

    for(auto& channelName : config.cs.DETECTOR_NAMES)
    {
        TDirectory* detectorDirectory = inputFile->GetDirectory(channelName.c_str());
        if(!detectorDirectory)
        {
            cerr << "Error: failed to find " << channelName << " directory in " << inputFileName << "." << endl;
            return 1;
        }

        TDirectory* outputDirectory = outputFile->mkdir(channelName.c_str(),channelName.c_str());

        // find TOF histograms in input file
        for(int i=0; i<config.target.TARGET_ORDER.size(); i++)
        {
            string targetName = config.target.TARGET_ORDER[i];
            string TOFHistoName = targetName + "TOFCorrected";

            detectorDirectory->cd();

            TH1D* TOF = (TH1D*)detectorDirectory->Get(TOFHistoName.c_str());
            if(!TOF)
            {
                cerr << "Error: failed to open " << TOFHistoName << " in " << inputFileName << endl;
                return 1;
            }

            outputDirectory->cd();

            TH1D* correctedEnergy = convertTOFtoEnergy(TOF, targetName + "Energy");
            TOF->Write();
            correctedEnergy->Write();
        }
    }

    outputFile->Close();
    inputFile->Close();

    return 0;
}
开发者ID:cdpruitt,项目名称:total-neutron-cross-sections,代码行数:54,代码来源:produceEnergyHistos.cpp

示例15: takeHist

void takeHist(TString fname){
	TFile * in = TFile::Open(fname);
	TH1D * h2 = ((TH2D*)in->Get("Default_allW/Default_allWcosTheta2D"))->ProjectionY();
	h2->Add((TH1D*)in->Get("Default_allW/Default_allWcosTheta"));
	TH3D * h1 = new TH3D("tmp","", 1000, -1., 1., 100, -1., 1., 10, -1. ,1.);
	TFile * out =  new TFile(fname+"Sec", "recreate");
	out->mkdir("Default_allW")->cd();
	h2->Write("Default_allWcosTheta");
	h1->Write("Default_allWcosTheta3D");
	out->Close();
}
开发者ID:nadjieh,项目名称:work,代码行数:11,代码来源:makeBuggy.C


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