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


C++ TChain::AddFile方法代码示例

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


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

示例1: TChain

TChain *make_mc_tree(const char *fname = NULL)
{
	int i;
//	const char files[4][256] = {
//		"mc_ibd_235U_transcode_pair.root",
//		"mc_ibd_238U_transcode_pair.root",
//		"mc_ibd_239Pu_transcode_pair.root",
//		"mc_ibd_241Pu_transcode_pair.root"
//	};
	const char files[4][256] = {
		"mc_ibdNewGd_235U_transcode_pair.root",
		"mc_ibdNewGd_238U_transcode_pair.root",
		"mc_ibdNewGd_239Pu_transcode_pair.root",
		"mc_ibdNewGd_241Pu_transcode_pair.root"
	};

	TChain *tMC = new TChain("DanssPair", "DanssPair");
	if (fname != NULL && strcasecmp(fname, "all")) {
		tMC->AddFile(fname);
	} else {
		for (i=0; i<4; i++) tMC->AddFile(files[i]);
	}
	if (!tMC->GetEntries()) return NULL;
	return tMC;
}
开发者ID:lab305itep,项目名称:digi,代码行数:25,代码来源:mc2ibd.C

示例2: pre

void pre(Int_t setID)
{
    TChain* pstr = new TChain("PSTree","root");
    if (setID==1) {
        for (Int_t i=1; i<10; i++)
            pstr->AddFile(Form("/remote/pclg-10/SIEGFRIED_II/Cd_SII_PS/Cd_In_SII_PS000%d.root",i));
        for (Int_t i=70; i<85; i++)
            pstr->AddFile(Form("/remote/pclg-10/SIEGFRIED_II/Cd_SII_PS/Cd_In_SII_PS00%d.root",i));
    }
    else if (setID==2)
        for (Int_t i=10; i<30; i++)
            pstr->AddFile(Form("/remote/pclg-10/SIEGFRIED_II/Cd_SII_PS/Cd_In_SII_PS00%d.root",i));
    else if (setID==3)
        for (Int_t i=30; i<50; i++)
            pstr->AddFile(Form("/remote/pclg-10/SIEGFRIED_II/Cd_SII_PS/Cd_In_SII_PS00%d.root",i));
    else if (setID==4)
        for (Int_t i=50; i<70; i++)
            pstr->AddFile(Form("/remote/pclg-10/SIEGFRIED_II/Cd_SII_PS/Cd_In_SII_PS00%d.root",i));

    Int_t Cha_MCAEnergy[8];
    pstr->SetBranchAddress("Cha_MCAEnergy",Cha_MCAEnergy);

    TFile* foutput = new TFile(Form("Run4pre%d.root",setID),"recreate");
    TTree *newtree = pstr->CloneTree(0);

    const Int_t Ncha = 7;

    Int_t Nevt = pstr->GetEntries();
    cout<<"Total Events: "<<Nevt<<endl;

    for (Int_t i=0; i<Nevt; i++) {
        if (i%10000==0)
            cout<<"Now event: "<<i<<endl;

        pstr->GetEntry(i);

        Int_t Nseg=0;
        for (Int_t j=1; j<Ncha-1; j++) {
            if (Cha_MCAEnergy[j]>1000 && Cha_MCAEnergy[j]<7000) {
                Nseg++;
            }
        }
        if (Nseg==1) {
            newtree->Fill();
        }
        if (i%10000==0) newtree->Write();
    }

    newtree->Write();
    foutput->Close();
}
开发者ID:jintonic,项目名称:gerdalinchenII,代码行数:51,代码来源:Run4select.C

示例3: mca

void mca()
{
    TChain* pstr = new TChain("PSTree","root");
    pstr->AddFile("Run4selected.root");

    Int_t Cha_MCAEnergy[8];
    pstr->SetBranchAddress("Cha_MCAEnergy",Cha_MCAEnergy);

    const Int_t Ncha = 7;
    TH1F *MCA[Ncha];
    MCA[0] = new TH1F("MCA0","MCA Spectrum for the core",3000,1000,7000);
    MCA[1] = new TH1F("MCA1","MCA Spectrum for segment 1",700,3800,5200);
    for (Int_t i=2; i<=3; i++)
        MCA[i] = new TH1F(Form("MCA%d",i),Form("MCA Spectrum for segment %d",i),500,2200,3200);
    for (Int_t i=4; i<=5; i++)
        MCA[i] = new TH1F(Form("MCA%d",i),Form("MCA Spectrum for segment %d",i+12),700,3000,4400);
    MCA[6] = new TH1F("MCA6","MCA Spectrum for segment 18",10000,1000,21000);

    Int_t Nevt = pstr->GetEntries();
    cout<<"Total Events: "<<Nevt<<endl;

    for (Int_t i=0; i<Nevt; i++) {
        if (i%10000==0)
            cout<<"Now event: "<<i<<endl;

        pstr->GetEntry(i);

        for (Int_t j=0; j<Ncha; j++)
            MCA[j]->Fill((Float_t) Cha_MCAEnergy[j]);
    }

    TFile* foutput = new TFile("Run4mca.root","recreate");
    for (Int_t i=0; i<Ncha; i++) MCA[i]->Write();
    foutput->Close();
}
开发者ID:jintonic,项目名称:gerdalinchenII,代码行数:35,代码来源:Run4select.C

示例4: main

int main() {
   TChain* chain = new TChain("treeCreator/vhtree");
   //WH
chain->AddFile("/lustre/cms/store/user/rosma/TauIsoUpgrade/WH_ZH_HToMuMu_M-125_13TeV_PU40bx25_2/tree_1_1_EUG.root");
chain->AddFile("/lustre/cms/store/user/rosma/TauIsoUpgrade/WH_ZH_HToMuMu_M-125_13TeV_PU40bx25_2/tree_12_1_axt.root");
std::string histo_fname ="/lustre/cms/store/user/rvenditti/PostLS2/FullSim/AnalisiGEM/WH_PU40CMS2012_ProvaAnalisi/histo_file_WH_PU40CMS2012_ProvaAnalisi0.root";
  VHAnalyser_Jan13* myanal = new VHAnalyser_Jan13(chain, histo_fname);
  myanal->bookHistograms();
  myanal->Loop();
  myanal->saveHistograms();
  //file->Close();
//  delete chain;
//  delete myanal;
gSystem->Exit(0);
return 0;
}
开发者ID:rvenditti,项目名称:H2tau_GEMAnalysis,代码行数:16,代码来源:histograms_MC_WH_PU40CMS2012_ProvaAnalisi0.C

示例5: morestrict

void morestrict()
{
    const Int_t Ncha = 6;

    Float_t N[Ncha]  = {0};
    Float_t dN[Ncha] = {0};

    Float_t ADC[Ncha]  = {0};
    Float_t dADC[Ncha] = {0};

    Float_t ADCw[Ncha]  = {0};
    Float_t dADCw[Ncha] = {0};

    ifstream dat;
    dat.open("Run4Nseg.txt");
    cout<<"channel \t ADC \t dADC \t ADCw \t dADCw \t N \t dN"<<endl;
    for (Int_t i=1; i<Ncha; i++) {
        dat>>ADC[i]>>dADC[i]>>ADCw[i]>>dADCw[i]>>N[i]>>dN[i];
        cout<<i<<" \t "<<ADC[i]<<" \t "<<dADC[i]<<" \t "
            <<ADCw[i]<<" \t "<<dADCw[i]<<" \t "
            <<N[i]<<" \t "<<dN[i]<<endl;
    }
    dat.close();

    TChain* pstr = new TChain("pstree","root");
    pstr->AddFile("Run4selected.root");

    Int_t Cha_MCAEnergy[8];
    pstr->SetBranchAddress("Cha_MCAEnergy",Cha_MCAEnergy);

    TFile* foutput = new TFile("Run4smaller.root","recreate");
    TTree *newtree = pstr->CloneTree(0);

    Int_t Nevt = pstr->GetEntries();
    cout<<"total events: "<<Nevt<<endl;

    for (Int_t i=0; i<Nevt; i++) {
        if (i%10000==0)
            cout<<"now event: "<<i<<endl;

        pstr->GetEntry(i);

        Int_t Nseg=0;
        for (Int_t j=1; j<Ncha; j++) {
            if (Cha_MCAEnergy[j]>ADC[j]-ADCw[j] &&
                    Cha_MCAEnergy[j]<ADC[j]+ADCw[j]) {
                Nseg++;
            }
        }

        if (Nseg==1) {
            newtree->Fill();
        }
    }

    newtree->Write();
    foutput->Close();
}
开发者ID:jintonic,项目名称:gerdalinchenII,代码行数:58,代码来源:Run4select.C

示例6: runmergeWithDir

void runmergeWithDir()
#endif
{
  TChain *tph;
   tph = new TChain("CBNT/t3333");
   tph->AddFile("file1.root");
   tph->AddFile("file2.root");
   tph->Merge("merged.root");
   TFile *fil = new TFile("merged.root");
   fil->ls();
}
开发者ID:xvallspl,项目名称:roottest,代码行数:11,代码来源:runmergeWithDir.C

示例7: CreateChainTXT

//________________________________________________________________________________
TChain* CreateChainTXT(const char* inpData)
{
  const char* chName="esdTree";
  TChain* chain = new TChain(chName);
  //
  TString inpDtStr = inpData;
  if (inpDtStr.EndsWith(".root")) {
    chain->AddFile(inpData);
  }
  else {
    //
    ifstream inpf(inpData);
    if (!inpf.good()) {
      printf("Failed on input filename %s\n",inpData);
      return kFALSE;
    }
    //
    TString flName;
    flName.ReadLine(inpf);
    while ( !flName.IsNull() ) {
      flName = flName.Strip(TString::kBoth,' ');
      if (flName.BeginsWith("//") || flName.BeginsWith("#")) {flName.ReadLine(inpf); continue;}
      flName = flName.Strip(TString::kBoth,',');
      flName = flName.Strip(TString::kBoth,'"');
      if (flName.EndsWith("Barrel.root")) barrelFlag = kTRUE;
      printf("Adding %s\n",flName.Data());
      chain->AddFile(flName.Data());
      flName.ReadLine(inpf);
    }
  }
  //
  int n = chain->GetEntries();
  if (n<1) {
    printf("Obtained chain is empty\n");
    return kFALSE;
  }
  printf("Created chain with %d entries in %d trees from %s\n",chain->GetEntries(),chain->GetNtrees(),inpData);
  return chain;
}
开发者ID:shahor02,项目名称:align,代码行数:40,代码来源:runGloAlgTask.C

示例8: runLocal

void runLocal(TString dataset, TString treename = "", Long64_t nentries=TChain::kBigNumber,  Long64_t firstentry = 0)
{
	ProofAna* ana = new ProofAna();

	//Need to provide a TList for local running
	TList* list = new TList();
	ana->SetInputList(list);

	// Load dataset manager stuff, uses same local datasets as PROOF-Lite by design
	TString defaultdir(gSystem->HomeDirectory());
	defaultdir.Append("/.proof");
	TString dsetdir(gEnv->GetValue("ProofLite.Sandbox",defaultdir.Data()));
	dsetdir.Append("/datasets");
	dsetdir.Prepend("dir:");
	TDataSetManagerFile mgr(dsetdir);

	TString dsetfile(dataset);
	dsetfile.Append(".txt");
	dsetfile.Prepend("../filelists/");

	//Register dataset, if non-existent
	if(!mgr.ExistsDataSet(dataset)) {
		TFileCollection* dset = new TFileCollection(dataset,"",dsetfile);
		mgr.RegisterDataSet(dataset,dset,"V"); //This seems to return true regardless of success or failure at the moment
		if(treename.CompareTo("")!=0) {
			cout << "Setting default tree to " << treename << " (local and lite running)" << endl;
			TProof* lite = TProof::Open("lite://");
			if(lite->SetDataSetTreeName(dataset,treename)) {
				cout << "Failure to set default tree to " << treename << endl;
				return;
			}
			delete lite;
		}
	}
	mgr.ShowDataSets();

	// And yes, all this dataset garbage was to get the default tree name
	TFileCollection* dset = mgr.GetDataSet(dataset);
	TString defaultTree = dset->GetDefaultTreeName();

	// Make TChain from TFileCollection...doesn't seem like there is a more direct way
	if(defaultTree.First("/")==0) defaultTree.Remove(0,1);
	TChain* T = new TChain(defaultTree);
	TList* filelist = (TList*)dset->GetList();
	TIter next(filelist);
	TFileInfo* fileinfo = 0;
	while ((fileinfo = (TFileInfo*)next())) T->AddFile(fileinfo->GetCurrentUrl()->GetUrl());

	// Process TChain
	T->Process(ana,"", nentries, firstentry);
}
开发者ID:bartbutler,项目名称:ProofAna,代码行数:51,代码来源:runLocal.C

示例9: main

int main() {
   TChain* chain = new TChain("treeCreator/vhtree");
   //WH
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1073_2_vbl.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1075_2_M4c.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1078_2_lm2.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1079_1_uox.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1080_2_fAf.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1084_2_XeU.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1085_2_lv8.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1087_2_wo7.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1088_1_Ff7.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1089_2_Et5.root");
std::string histo_fname ="/lustre/cms/store/user/rvenditti/PostLS2/FullSim/AnalisiGEM/QCDPU50GEM2019/histo_file_QCDPU50GEM20195.root";
  VHAnalyser_Jan13* myanal = new VHAnalyser_Jan13(chain, histo_fname);
  myanal->bookHistograms();
  myanal->Loop();
  myanal->saveHistograms();
  //file->Close();
//  delete chain;
//  delete myanal;
gSystem->Exit(0);
return 0;
}
开发者ID:rvenditti,项目名称:H2tau_GEMAnalysis,代码行数:24,代码来源:histograms_MC_QCDPU50GEM20195.C

示例10: again

void again()
{
    TChain* pstr = new TChain("PSTree","root");
    for (Int_t i=1; i<5; i++) pstr->AddFile(Form("Run4pre%d.root",i));

    Int_t Cha_MCAEnergy[8];
    pstr->SetBranchAddress("Cha_MCAEnergy",Cha_MCAEnergy);

    TFile* foutput = new TFile("Run4selected.root","recreate");
    TTree *newtree = pstr->CloneTree(0);

    Int_t Nevt = pstr->GetEntries();
    cout<<"Total Events: "<<Nevt<<endl;

    for (Int_t i=0; i<Nevt; i++) {
        if (i%10000==0)
            cout<<"Now event: "<<i<<endl;

        pstr->GetEntry(i);

        Int_t Nseg=0;
        if (Cha_MCAEnergy[1]>3800 && Cha_MCAEnergy[1]<5200) {
            Nseg++;
        }
        for (Int_t j=2; j<=3; j++) {
            if (Cha_MCAEnergy[j]>2200 && Cha_MCAEnergy[j]<3200) {
                Nseg++;
            }
        }
        for (Int_t j=4; j<=5; j++) {
            if (Cha_MCAEnergy[j]>3000 && Cha_MCAEnergy[j]<4400) {
                Nseg++;
            }
        }

        if (Nseg==1) {
            newtree->Fill();
        }
    }

    newtree->Write();
    foutput->Close();

}
开发者ID:jintonic,项目名称:gerdalinchenII,代码行数:44,代码来源:Run4select.C

示例11: TChain

 TChain *get_chain(char *tree_name)
 {
   if (chains.find(tree_name) == chains.end())
   {
     TChain *chain = new TChain(tree_name);
     if (!chain)
     {
       return NULL;
     }
     for (vector<string>::iterator it = files.begin();
          it != files.end(); it++)
     {
       if (!chain->AddFile(it->c_str()))
       {
         delete chain;
         return NULL;
       }
     }
     chains[tree_name] = chain;
   }
   return chains[tree_name];
 }
开发者ID:miguel-branco,项目名称:librootcursor,代码行数:22,代码来源:rootcursor.cpp

示例12: Improve_PID2

void Improve_PID2(Char_t* path, Char_t* filename, short aoq, short var=0,
		  Float_t A_Lin = 0, Float_t A_Squ = 0,
		  Float_t X_Lin = 0, Float_t X_Squ = 0,
		  Float_t Y_Lin = 0, Float_t Y_Squ = 0,
		  Float_t D_Lin = 0, Float_t D_Squ = 0,

		  Float_t A_Lin1 = 0, Float_t A_Squ1 = 0,
		  Float_t X_Lin1 = 0, Float_t X_Squ1 = 0,
		  Float_t Y_Lin1 = 0, Float_t Y_Squ1 = 0,
		  Float_t D_Lin1 = 0, Float_t D_Squ1 = 0,

		  Float_t B_Lin = 0, Float_t B_Squ = 0
){



  TChain* tree = new TChain("tree");
  std::cout<< Form("%s%s",path,filename) <<std::endl;
  tree->AddFile(Form("%s%s",path,filename));


  short beta_;
  vector<Char_t*> names;
  names = vector<Char_t*> (9);
  Float_t corr[2][9] = { {A_Lin, X_Lin, Y_Lin,D_Lin, A_Lin1, X_Lin1, Y_Lin1, D_Lin, B_Lin},
		      {A_Squ, X_Squ, Y_Squ,D_Squ, A_Squ1, X_Squ1, Y_Squ1, D_Squ, B_Squ} };
  Float_t plane_[2], delta_[2];


  if(aoq == 0){
    names[0]="FA[0]",  names[1]="FX[0]",  names[2]="FY[0]",  names[3]="delta[0]";//First detector
    names[4]="FA[1]",  names[5]="FX[1]",  names[6]="FY[1]",  names[7]="delta[1]";//Second detector
    names[8]="BETA[0]";                                                       //Beta before ([0]) or after ([1]) the target
    beta_ = 0;
    plane_[0] = 0;
    plane_[1] = 1;
    delta_[0] = 0;
    delta_[1] = 1;
  }else if(aoq == 2){
    names[0]="FA[4]",  names[1]="FX[4]",  names[2]="FY[4]",  names[3]="delta[2]";//First detector
    names[4]="FA[5]",  names[5]="FX[5]",  names[6]="FY[5]",  names[7]="delta[4]";//Second detector
    names[8]="BETA[1]";                                                       //Beta before ([0]) or afte
    beta_ = 0;
    plane_[0] = 4;
    plane_[1] = 5;
    delta_[0] = 2;
    delta_[1] = 4;
  }else if(aoq == 5){
    names[0]="FA[3]",  names[1]="FX[3]",  names[2]="FY[3]",  names[3]="delta[2]";//First detector
    names[4]="FA[5]",  names[5]="FX[5]",  names[6]="FY[5]",  names[7]="delta[4]";//Second detector
    names[8]="BETA[1]";                                                      //Beta before ([0]) or after
    beta_ = 0;
    plane_[0] = 3;
    plane_[1] = 5;
    delta_[0] = 2;
    delta_[1] = 4;
  }

  Char_t* LinCorr = "",* SquCorr = "",*cut = "";
  if(aoq != 0) cut = "ZET[0]>49.5 && ZET[0] < 50.5 && TMath::Abs(AOQ[0]-2.56)<0.01";
  for(short ii = 0; ii < 9; ii++){
    LinCorr = Form("%s+%f*%s"   ,LinCorr,corr[0][ii],names[ii]);
    SquCorr = Form("%s+%f*%s*%s",SquCorr,corr[1][ii],names[ii],names[ii]);
  }
  TH2F* h2_aoq;
  if(var == 8) h2_aoq = new TH2F("h2_aoq",Form("AOQ[%i] vs %s",aoq,names[var]),200, 0.5,0.6,200,2.54,2.58);
  else if(var == 3 || var == 7)h2_aoq = new TH2F("h2_aoq",Form("AOQ[%i] vs %s",aoq,names[var]),200,-2,2, 200,2.54,2.58);
  else  h2_aoq = new TH2F("h2_aoq",Form("AOQ[%i] vs %s",aoq, names[var]),200,-10,10,200,2.54,2.58);
  tree->Draw(Form("AOQ[%i]+%s+%s:%s>>h2_aoq",aoq,LinCorr,SquCorr,names[var]),cut,"colz");



  tree->Draw(Form("AOQ[2]+%s+%s:ZET[3]>>h50(100,45,55,200,2.5,2.7)",LinCorr,SquCorr),cut,"colz");

}
开发者ID:jtscheuschner,项目名称:riken,代码行数:75,代码来源:Imp_PID2.C

示例13: PDFSystCalculator_Powheg12Bin

void PDFSystCalculator_Powheg12Bin()
{
  typedef std::pair<double,double> pairOfDouble;
  set<pairOfDouble> uniqueEventsTrue;

  typedef std::pair<int,int> pairOfInt;
  set<pairOfInt> uniqueEventsReco;

  double mLow = 60.; // Z mass
  double mHigh = 120.; // Z mass
  double ptLow = 0.;
  double ptHigh = 4000.;

  //variable related PDF systematic uncertainty
  //double weightedSelectedEvents[18][53];
  //double weighted2SelectedEvents[18][53];
  double weightedSelectedEvents[12][53];
  double weighted2SelectedEvents[12][53];
  
  double events_central[nptBins] = {0.0};
  double events2_central[nptBins] = {0.0};
  double wa[nptBins] = {0.0};
  double wb[nptBins] = {0.0};
  double wplus[nptBins] = {0.0};
  double wminus[nptBins] = {0.0};

  char tmpName[30];


 // std::ofstream Fout;
 // TString FoutName = "Zpt_12BinWeightedSelectedEvents.txt";
 // Fout.open(FoutName);
 // Fout << fixed << setprecision(3);



  // read input root file
  TChain* tree = new TChain("tree");
  for(int i(1);i<95;i++)
  {
    //sprintf(tmpName,"DYJetsToLL_%d.root",i);
    //sprintf(tmpName,"/d1/scratch/sangilpark/Zpt/CMSSW_5_3_14_patch1/src/TerraNova/NtupleMaker/test/ZpT_Powheg_LowPU/DYJetsToLL_%d.root",i);
    sprintf(tmpName,"/d2/scratch/Storage_Area/ZpT8TeV_Powheg_LowPU/DYJetsToLL_%d.root",i);
    tree->AddFile(tmpName);  // Powheg Ntuple
  }

  TH1D* hPtMCTot = new TH1D("hPtMCTot", "", nptBins, xbins_pt); // no cut
  TH1D* hPtMCAcc = new TH1D("hPtMCAcc", "", nptBins, xbins_pt); // acc.cuts
  TH1D* hPtMCEff = new TH1D("hPtMCEff", "", nptBins, xbins_pt); // acc + all selection cuts


  //Hammid MC truth information pre FSR
  _TrackInfo true1PreFSR, true2PreFSR;
  tree->SetBranchAddress("true1PreFSR", &true1PreFSR);
  tree->SetBranchAddress("true2PreFSR", &true2PreFSR);

  float trueMassPreFSR, truePtPreFSR;
  tree->SetBranchAddress("trueMassPreFSR",	&trueMassPreFSR);
  tree->SetBranchAddress("truePtPreFSR",	&truePtPreFSR);

  vector<float> *weights_CT10;
  TBranch *b_weights_CT10;
  weights_CT10 = 0;
  tree->SetBranchAddress("weights_CT10", &weights_CT10, &b_weights_CT10);


  // Initialize variable
  for(int iBin(0); iBin<nptBins; iBin++)
  {
    {
      for(int j=0; j<53; j++)
      {
	weightedSelectedEvents[iBin][j] = 0;
	weighted2SelectedEvents[iBin][j] = 0;
//	cout << "initialized weightedSelectedEvents : " << weightedSelectedEvents[iBin][j] << endl;
      }
    }
  }

  // Print # of events
  cout << "Loop over the " << tree->GetEntries() << " entries ...\n";

  // Fill histogram
  for(int iEvt(0); iEvt<tree->GetEntries(); iEvt++)
  //for(int iEvt(0); iEvt<20; iEvt++)
  {
    if ( (iEvt % 100000)==0 ) cout << "event " << iEvt << endl;
    tree -> GetEntry(iEvt);

    //nocut start
    pairOfDouble trueMassPtPreFSR(trueMassPreFSR,truePtPreFSR);
    if( !uniqueEventsTrue.insert( trueMassPtPreFSR ).second ) continue;

    if (trueMassPreFSR <  mLow) continue;
    if (trueMassPreFSR > mHigh) continue;

    hPtMCTot -> Fill( truePtPreFSR );

    // acc cut start
    if (true1PreFSR.charge == -999) continue;
//.........这里部分代码省略.........
开发者ID:d4space,项目名称:TerraNova,代码行数:101,代码来源:PDFSystCalculator_Powheg12Bin.C

示例14: xSection

int xSection(string recotype="HI"){

  TH1::SetDefaultSumw2();

  // https://twiki.cern.ch/twiki/bin/viewauth/CMS/HiForest2015#5_02_TeV_pp_MC

  double pthats[] = {15       , 30       , 50       , 80       , 120      , 170      , 220      , 280      , 370      , 460      , 540      , 9999};
  double xs502[]  = {5.269e-01, 3.455e-02, 4.068e-03, 4.959e-04, 7.096e-05, 1.223e-05, 3.031e-06, 7.746e-07, 1.410e-07, 3.216e-08, 1.001e-08, 0.0};

  //double xs276[]  = {2.034e-01, 1.075e-02, 1.025e-03, 9.865e-05, 1.129e-05, 1.465e-06, 2.837e-07, 5.323e-08, 5.934e-09, 8.125e-10, 1.467e-10, 0.0};


  //double pthats[] = {15       , 30       , 50       , 80       , 120      , 170      , 220      , 280      , 9999};
  //double xs502[]  = {5.269e-01, 3.455e-02, 4.068e-03, 4.959e-04, 7.096e-05, 1.223e-05, 3.031e-06, 7.746e-07, 0.0};

  //double pthats[] = {15       , 30       , 50       , 80       , 120      , 170      , 220      , 280      , 460      , 540      , 9999};
  //double xs502 [] = {5.269e-01, 3.455e-02, 4.068e-03, 4.959e-04, 7.096e-05, 1.223e-05, 3.031e-06, 7.746e-07, 3.216e-08, 1.001e-08, 0.0};


  const int Npt = sizeof(pthats)/sizeof(double) - 1;
  double n[Npt]={0};

  // double n  [Npt] = {279441,909299,939442,790651,482031,120627,422180,764369,1143728};
  // double wtf[Npt] = {1.07364e-07,3.66964e-09,4.04208e-10,6.48706e-11,2.06051e-11,
  double *xs = xs502;
  for(int i=0; i<Npt; i++){
    cout << pthats[i] << "\t" << xs[i] << " " << xs502[i] << endl;
  }
  cout << "Npt :  " << Npt << endl;
  //return 0;

  //! Read the files and get the effective # of events

  TChain* nt;
  //TChain* evt;
  // TFile* outf[Nfiles];
  
  nt  = new TChain("ak3PFJetAnalyzer/t");
  //nt  = new TChain("akPu3PFJetAnalyzer/t");

  std::string infile_Forest;
  infile_Forest="filelist_PP_Signal_758_HcalRespCorr_v4.txt";
  //infile_Forest="filelist_PbPb_hcalv4.txt";
  //infile_Forest="filelist_ppJEC2015_"+recotype+"Reco_757p1_HcalRespCorrs_v4_00_mc.txt";
  std::ifstream infile(infile_Forest.c_str(),std::ifstream::in);
  std::string filename_Forest;

  while(1){
    infile>>filename_Forest;
    if( !infile.good() )break;
    //cout << filename_Forest.c_str() << endl;
    nt->AddFile(filename_Forest.c_str());
  }

  for(int i = 0; i < Npt; i++){
    TCut pthatCut(Form("pthat >= %f && pthat < %f",pthats[i],pthats[i+1]));
    n[i] = 1.0*nt->GetEntries(pthatCut);
    //cout<<"no of events in pthat = "<<pthats[i]<<" = "<<n[i]<<endl;
    //xs[i] = xs502[i] - xs502[i+1];
    xs[i]-= xs[i+1];
    cout << "{" << pthats[i] << "," << std::setprecision (std::numeric_limits<double>::digits10 + 1) 
	 << n[i]  << "," << std::setprecision (std::numeric_limits<double>::digits10 + 1) 
	 << xs[i] << "," << std::setprecision (std::numeric_limits<double>::digits10 + 1)  
	 << xs[i]/n[i] << "}," 
	 << endl;
  }

  //TFile *fout = new TFile(Form("xsec_weight_PbPb_%sreco_757p1_HcalRespCorrs_v4_00_mc.root",recotype.c_str()),"RECREATE");
  //TFile *fout = new TFile("xsec_weight_PbPb.root","RECREATE");
  TFile *fout = new TFile(Form("xsec_weight_pp_%sreco_758_HcalRespCorrs_v4_mc.root",recotype.c_str()),"RECREATE");
  TH1D *hpthat_comb = new TH1D("hpthat","pt hat combined",500,0,1500);
  hpthat_comb->Sumw2();

  float pthat;
  nt->SetBranchAddress("pthat",&pthat);
  nt->SetBranchStatus("*",0,0);
  nt->SetBranchStatus("pthat",1);  

  for(int i=0; i<nt->GetEntries(); i++){
    nt->GetEntry(i);
    double pthatwt=-1.0;
    for(int j = 0; j < Npt; j++){
      if(n[j] > 0 && pthat >= pthats[j]){
	pthatwt = xs[j]/n[j];
      }
    }
    if( pthatwt > 0 )hpthat_comb->Fill(pthat,pthatwt);
  }

  fout->cd();
  fout->Write();
  fout->Close();

  return 0;
}
开发者ID:pawannetrakanti,项目名称:UserCode,代码行数:95,代码来源:xSection.C

示例15: main


//.........这里部分代码省略.........
  else std::cout << pNevts << " events." << std::endl;

  TRandom3 lRndm(1);
  std::cout << " -- Random number seed: " << lRndm.GetSeed() << std::endl;

  /////////////////////////////////////////////////////////////
  //input
  /////////////////////////////////////////////////////////////

  std::ostringstream inputsim;
  inputsim << filePath << "/" << simFileName;
  std::ostringstream inputrec;
  if (digifilePath.size()==0)
    inputrec << filePath << "/" << recoFileName;
  else 
    inputrec << digifilePath << "/" << recoFileName;

  //std::cout << inputsim.str() << " " << inputrec.str() << std::endl;

  HGCSSInfo * info;

  TChain *lSimTree = new TChain("HGCSSTree");
  TChain *lRecTree = 0;
  
  TFile * simFile = 0;
  TFile * recFile = 0;

  if (recoFileName.find("Digi") != recoFileName.npos) 
    lRecTree = new TChain("RecoTree");
  else lRecTree = new TChain("PUTree");

  if (nRuns == 0){
    if (!testInputFile(inputsim.str(),simFile)) return 1;
    lSimTree->AddFile(inputsim.str().c_str());
    if (!testInputFile(inputrec.str(),recFile)) return 1;
    lRecTree->AddFile(inputrec.str().c_str());
  }
  else {
    for (unsigned i(0);i<nRuns;++i){
      std::ostringstream lstr;
      lstr << inputsim.str() << "_run" << i << ".root";
      if (testInputFile(lstr.str(),simFile)){  
	if (simFile) info =(HGCSSInfo*)simFile->Get("Info");
	else {
	  std::cout << " -- Error in getting information from simfile!" << std::endl;
	  return 1;
	}
      }
      else continue;
      lSimTree->AddFile(lstr.str().c_str());
      lstr.str("");
      lstr << inputrec.str() << "_run" << i << ".root";
      if (!testInputFile(lstr.str(),recFile)) continue;
      lRecTree->AddFile(lstr.str().c_str());
    }
  }

  if (!lSimTree){
    std::cout << " -- Error, tree HGCSSTree cannot be opened. Exiting..." << std::endl;
    return 1;
  }

  if (!lRecTree){
    std::cout << " -- Error, tree RecoTree cannot be opened. Exiting..." << std::endl;
    return 1;
  }
开发者ID:J-C-Wright,项目名称:PFCal,代码行数:67,代码来源:egammaResolution.cpp


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