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


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

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


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

示例1: makeBSM_MCFM_single


//.........这里部分代码省略.........
    templateTree->Branch("p0_g1prime2_VAJHU", &p0_g1prime2_VAJHU);
    templateTree->Branch("p0_g1prime4_VAJHU", &p0_g1prime4_VAJHU);
    templateTree->Branch("pg1g2_VAJHU", &pg1g2_VAJHU);
    templateTree->Branch("pg1g4_VAJHU", &pg1g4_VAJHU);
    templateTree->Branch("pg1g1prime2_VAJHU", &pg1g1prime2_VAJHU);
    templateTree->Branch("pg1g1prime4_VAJHU", &pg1g1prime4_VAJHU);

    //Making templates using appropriate weights
    //    tree->SetBranchAddress("ZZMass", &ZZMass);
    //    tree->SetBranchAddress("MC_weight", &MC_weight);
    tree->SetBranchAddress("GenZZMass", &GenHMass);
    tree->SetBranchAddress("GenLep1Id", &GenLep1Id);
    tree->SetBranchAddress("GenLep2Id", &GenLep2Id);
    tree->SetBranchAddress("GenLep3Id", &GenLep3Id);
    tree->SetBranchAddress("GenLep4Id", &GenLep4Id);
    tree->SetBranchAddress("GenLep1Pt", &GenLep1Pt);
    tree->SetBranchAddress("GenLep2Pt", &GenLep2Pt);
    tree->SetBranchAddress("GenLep3Pt", &GenLep3Pt);
    tree->SetBranchAddress("GenLep4Pt", &GenLep4Pt);
    tree->SetBranchAddress("GenLep1Phi", &GenLep1Phi);
    tree->SetBranchAddress("GenLep2Phi", &GenLep2Phi);
    tree->SetBranchAddress("GenLep3Phi", &GenLep3Phi);
    tree->SetBranchAddress("GenLep4Phi", &GenLep4Phi);
    tree->SetBranchAddress("GenLep1Eta", &GenLep1Eta);
    tree->SetBranchAddress("GenLep2Eta", &GenLep2Eta);
    tree->SetBranchAddress("GenLep3Eta", &GenLep3Eta);
    tree->SetBranchAddress("GenLep4Eta", &GenLep4Eta);
    tree->SetBranchAddress("GenLep1E", &GenLep1E);
    tree->SetBranchAddress("GenLep2E", &GenLep2E);
    tree->SetBranchAddress("GenLep3E", &GenLep3E);
    tree->SetBranchAddress("GenLep4E", &GenLep4E);

    if (tFitD != 0){
      if (tree->GetBranchStatus(strFitDim[tFitD])){
        tree->SetBranchAddress("Dgg10_VAMCFM", &fitYval);
        templateTree->Branch(strFitDim[tFitD], &fitYval);
      }
      else{
        cerr << "Could NOT find branch named " << strFitDim[tFitD] << "!!! Setting strFitDim[" << tFitD << "] = 0." << endl;
        fitYval = 0;
      }
    }

    nEntries = tree->GetEntries();
    double xsec = 1./nEntries;
    if (t==0) xsec *= xsec_ggHZZ_MCFM[EnergyIndex];
    else if (t==1) xsec *= xsec_ggZZ_MCFM[EnergyIndex];
    else if (t==2) xsec *= xsec_ggHZZ_BSI_MCFM[EnergyIndex];
    else if (t==3) xsec *= xsec_ggHZZ_BSI25_MCFM[EnergyIndex];
    else xsec = 1;
    if (folder<2) xsec *= 0.25;
    else xsec *= 0.5;

    //    for (int ev = 0; ev < 100; ev++){

    for (int ev = 0; ev < nEntries; ev++){
      tree->GetEntry(ev);
      ZZMass = GenHMass;
      MC_weight = xsec;

      if (fitYval != fitYval) continue;
      // Protect against any KD exceeding boundaries
      if (tFitD!=0 && fitYval>=1){
        cout << "Found fitYval == " << fitYval;
        fitYval = 0.999;
        cout << ". Fixed to " << fitYval << endl;
开发者ID:usarica,项目名称:HiggsWidth_PostICHEP,代码行数:67,代码来源:makeBSM_MCFM.c

示例2: createPlot

void createPlot(std::vector<TString> samples, std::vector<TString> files, std::vector<TString> legend)
{

  TString y_title = "Number of Entries";
  const int nHist = files.size(); // number of files

  // Declare the histograms to be saved 
  TH1F *h_mll[nHist];
  TH1F *h_dilpt[nHist];
  TH1F *h_dphill[nHist];
  TH1F *h_leadleppt[nHist];
  TH1F *h_trailleppt[nHist];
  TH1F *h_met[nHist];
  TH1F *h_mt[nHist];
  
  // Get the histograms from the ntuples
  for (int i=0;i<nHist;i++) {
    TString treeName = "angles";
    TChain *chain = new TChain(treeName);
    chain->Add(files[i]);
    assert(chain);
    
    // declare histograms  to fill
    Color_t color = kBlack;
    TString sampleName = samples[i];
    if ( sampleName.Contains("SMHiggs",TString::kExact )) color = kBlue;
    if ( sampleName.Contains("PSHiggs", TString::kExact)) color = kMagenta;
    if ( sampleName.Contains("T",  TString::kExact)) color = kRed;
    if ( sampleName.Contains("THiggs",  TString::kExact)) color = kRed;


    
    // define the histograms to plot
    
    // dilmass 
    h_mll[i] = new TH1F(TString("HWW_"+sampleName+"_hdilmass"), TString("HWW_"+sampleName+"_hdilmass"), 20, 0, 200);
    h_mll[i]->SetLineColor(color);
    h_mll[i]->SetMarkerColor(color);
    
    // leading lepton pT
    h_leadleppt[i] = new TH1F(TString("HWW_"+sampleName+"_hleadleppt"), TString("HWW_"+sampleName+"_hleadleppt"), 20, 0, 100);
    h_leadleppt[i]->SetLineColor(color);
    h_leadleppt[i]->SetMarkerColor(color);
   
    // trailing lepton pT
    h_trailleppt[i] = new TH1F(TString("HWW_"+sampleName+"_htrailleppt"), TString("HWW_"+sampleName+"_htrailleppt"), 20, 0, 100);
    h_trailleppt[i]->SetLineColor(color);
    h_trailleppt[i]->SetMarkerColor(color);
    
    // MET
    h_met[i] = new TH1F(TString("HWW_"+sampleName+"_hmet"), TString("HWW_"+sampleName+"_hmet"), 20, 0, 100);
    h_met[i]->SetLineColor(color);
    h_met[i]->SetMarkerColor(color);
    
    
    // dilepton pT
    h_dilpt[i] = new TH1F(TString("HWW_"+sampleName+"_hdilpt"), TString("HWW_"+sampleName+"_hdilpt"), 30, 20, 100);
    h_dilpt[i]->SetLineColor(color);
    h_dilpt[i]->SetMarkerColor(color);
    
    // deltaphi (ll)
    h_dphill[i] = new TH1F(TString("HWW_"+sampleName+"_hdphi"), TString("HWW_"+sampleName+"_hdphi"), 18, 0, 180.0);
    h_dphill[i]->SetLineColor(color);
    h_dphill[i]->SetMarkerColor(color);
    
    // transverse mass
    h_mt[i] = new TH1F(TString("HWW_"+sampleName+"_hmt"), TString("HWW_"+sampleName+"_hmt"), 20, 0, 200);
    h_mt[i]->SetLineColor(color);
    h_mt[i]->SetMarkerColor(color);
    

    std::cout  << "Processing " << chain->GetEntries() << " entries. \n";
    int nEntries =  chain->GetEntries() ;
    int nSelected = 0;
    
    // mcfm variables to be used
    double mll_ = 0.0;
    double leadleppt_ = 0.0;
    double trailleppt_ = 0.0;
    double leadlepeta_ = 0.0;
    double traillepeta_ = 0.0;
    double dphill_ = 0.0;
    double met_ = 0.0;
    double mt_ = 0.0;
    double dilpt_ = 0.0;
    double wt_ = 1.0;

    if (chain->GetBranchStatus("mll"))
      chain->SetBranchAddress("mll", &mll_);

    if (chain->GetBranchStatus("leadleppt"))
      chain->SetBranchAddress("leadleppt", &leadleppt_);

    if (chain->GetBranchStatus("trailleppt"))
      chain->SetBranchAddress("trailleppt", &trailleppt_);

    if (chain->GetBranchStatus("dphill"))
      chain->SetBranchAddress("dphill", &dphill_);

    if (chain->GetBranchStatus("met"))
//.........这里部分代码省略.........
开发者ID:nhanvtran,项目名称:usercode,代码行数:101,代码来源:comparesample.C

示例3: analyzer

void analyzer (TString inputFileName,TString outputFileName, TString runPeriod, bool isData, bool isSignal, unsigned maxEvents)
{
  using namespace std;

  ///////////////////
  // Configuration

  float minMmm = 110;
  float maxMmm = 160;

  //gErrorIgnoreLevel = kError;
  const unsigned ISMEAR = 2;

  ///////////////////////////
  // Output Histograms

  setStyle();

  TH1F* dimuonMassHist = new TH1F("dimuonMass","",50,110,160);
  setHistTitles(dimuonMassHist,"M(#mu#mu) [GeV/c^{2}]","Events");
  dimuonMassHist->Sumw2();
  TH1F* nJetsHist = new TH1F("nJets","",10,0,10);
  setHistTitles(nJetsHist,"N_{Jets}","Events");
  nJetsHist->Sumw2();

  ///////////////////////////
  Double_t MASS_MUON = 0.105658367;    //GeV/c2

  //////////////////////////
  // Tree Branches
  cout << "Analyzing filename: "<< inputFileName.Data() << endl;
  if (isData)
    cout << "isData\n";
  if (isSignal)
    cout << "isSignal\n";

  TChain * tree = new TChain("tree");
  tree->Add(inputFileName);


  // These are the names of the muons (See src/DataFormats.h for definitions!)
  _MuonInfo reco1, reco2;

  tree->SetBranchAddress("reco1", &reco1);
  tree->SetBranchAddress("reco2", &reco2);

  // These are the dimuon mass, pt, rapidity, and phi
  float recoCandMass, recoCandPt, recoCandY, recoCandPhi;
  float recoCandMassRes, recoCandMassResCov;

  tree->SetBranchAddress("recoCandMass",       &recoCandMass);
  tree->SetBranchAddress("recoCandPt",         &recoCandPt);
  tree->SetBranchAddress("recoCandY",          &recoCandY);
  tree->SetBranchAddress("recoCandPhi",        &recoCandPhi);
  tree->SetBranchAddress("recoCandMassRes",    &recoCandMassRes);
  tree->SetBranchAddress("recoCandMassResCov", &recoCandMassResCov);

  // MC truth info
  float trueMass=-99999.0;
  if(!isData && tree->GetBranchStatus("trueMass"))
    tree->SetBranchAddress("trueMass", &trueMass);

  /// Higgs Boson MC truth info (after FSR)
  _genPartInfo genHpostFSR;
  if(!isData && tree->GetBranchStatus("genHpostFSR"))
    tree->SetBranchAddress("genHpostFSR", &genHpostFSR);

  _TrackInfo reco1GenPostFSR;
  if(!isData && tree->GetBranchStatus("genM1HpostFSR"))
    tree->SetBranchAddress("genM1HpostFSR", &reco1GenPostFSR);

  _TrackInfo reco2GenPostFSR;
  if(!isData && tree->GetBranchStatus("genM2HpostFSR"))
    tree->SetBranchAddress("genM2HpostFSR", &reco2GenPostFSR);

  /// the jet collection
  // these 'rawJets' already have Loose Jet ID applied, and JES corrections
  // and are cross-cleaned of tight muons
  // later, jets will have JER corrections, PUID, and basic cuts applied
  _PFJetInfo rawJets;
  tree->SetBranchAddress("pfJets",&rawJets);

  float puJetFullDisc[10];
  float puJetSimpleDisc[10];
  float puJetCutDisc[10];

  tree->SetBranchAddress("puJetFullDisc",&puJetFullDisc);
  tree->SetBranchAddress("puJetSimpleDisc",&puJetSimpleDisc);
  tree->SetBranchAddress("puJetCutDisc",&puJetCutDisc);

  float puJetFullId[10];
  float puJetSimpleId[10];
  float puJetCutId[10];

  tree->SetBranchAddress("puJetFullId",&puJetFullId);
  tree->SetBranchAddress("puJetSimpleId",&puJetSimpleId);
  tree->SetBranchAddress("puJetCutId",&puJetCutId);

  int nPU=0;
  if (!isData)
//.........这里部分代码省略.........
开发者ID:jhugon,项目名称:hmumuToyAnalysis,代码行数:101,代码来源:analyzer.C


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