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


C++ TTree类代码示例

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


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

示例1: makeLongTracksonlyunnormalized

//=============================================================================
// Standard constructor, initializes variables
//=============================================================================
void makeLongTracksonlyunnormalized(  ) {
  gROOT->SetBatch(kTRUE);
  TString tuplelocation = "/afs/cern.ch/work/m/mwilkins/b_b-bar_cross-section/";
  TString data2011tuple = tuplelocation+"Strp20r1_SL_D0andDp_MD.root";
  TString MC2011tuple = tuplelocation+"MC_2011_Bu_D0Xmunu_cocktail_12873441_MC2011_S20r1_noPID_Tuples.root";
  TString data2015tuple = tuplelocation+"B2DMuNuX_tuples_05082015.root";
  TString MC2015tuple = tuplelocation+"MC_2015_Bu_D0Xmunu_cocktail_12873441_MC2015_S22_noPID_Tuples.root";
  TFile *f[4];
  f[0] = TFile::Open(data2011tuple);
  f[1] = TFile::Open(MC2011tuple);
  f[2] = TFile::Open(data2015tuple);
  f[3] = TFile::Open(MC2015tuple);
  cout<<"files opened"<<endl;
  
  const int nhpc = 2; //number of histograms per canvas
  const int ncanvases = 4;
  const int nstacks = ncanvases;
  THStack *hs[nstacks];
  TCanvas *c[ncanvases];
  TH1F *h[ncanvases][nhpc];
  TLegend *leg[ncanvases];
  TString outputlocation = "output/longtracksplotsunnormalized/";//where the output will be saved
  TString plotfilename = "longtracksplotsunnormalized.pdf";//name of file that will hold drawn plots

  TCanvas *cf = new TCanvas("cf","combined");//canvas to hold everything
  float sqnc = sqrt(ncanvases), sqncu = ceil(sqnc), sqncd = floor(sqnc);
  while(sqncu*sqncd<ncanvases) sqncu++;
  cf->Divide(sqncu,sqncd);
  TLegend *legf = new TLegend(0.84, 0.84, .99, .95);

  TString placeholder; //to avoid adding strings within functions; assign immediately before use
  TString placeholder2;
  
  cout<<"starting canvas loop..."<<endl;
  for(int ci =0; ci<ncanvases; ci++){ //loop over canvases
    //create indicators and strings:
    int year;
    if(ci<(ncanvases/2)){//2011 for 1st half canvases, 2015 for 2nd half
      year = 2011;
    }else year = 2015;
    TString yearstring = Form("%d",year);
    TString filetype; //assigned in histogram loop
    TString tracktype = "nLongTracks";
    int B0;//assigned in histogram loop
    TString Bdecay;
    TString branch;

    TString cistring = Form("%d",ci);
    cout<<"loop "<<ci<<" indicators and strings created:"<<endl<<"year: "<<year<<endl;

    //create the plots
    placeholder = "c"+cistring;
    placeholder2=yearstring+filetype+tracktype;
    c[ci] = new TCanvas(placeholder,placeholder2,1200,800); //create the canvases
    c[ci]->cd();
    gStyle->SetOptStat("");
    leg[ci] = new TLegend(0.7, 0.7, .97, .93);//create legend
    placeholder = "hs"+cistring;
    hs[ci] = new THStack(placeholder,placeholder2); //create the stack to hold the histograms
    cout<<"starting histogram loop..."<<endl;
    for(int hi=0;hi<nhpc;hi++){ //loop over histograms in a canvas; B0=0 and B0=1
      if(hi%2==0){//true every other histogram
        filetype = "data";
      }else filetype = "MC";
      int file_num=-1000;//assign file_num based on combinations of data and MC
      if(year==2011){
        if(filetype=="data") file_num=0;
        if(filetype=="MC") file_num=1;
      }
      if(year==2015){
        if(filetype=="data") file_num=2;
        if(filetype=="MC") file_num=3;
      }
      cout<<"file_num: "<<file_num<<endl;
      if(ci%2 ==0){//every other canvas
        B0=0;
        Bdecay = "B^{-}->(D^{0}->K^{-} #pi^{+})#mu^{-}";
        if((filetype=="data")&&(year==2011)){
          branch="tupleb2D0Mu/tupleb2D0Mu"; 
        } else branch="Tuple_b2D0MuX/DecayTree"; 
      } else{
        B0=1;
        Bdecay = "B^{0}->(D^{-}->K^{+} #pi^{-} #pi^{-})#mu^{+}";
        if((filetype=="data")&&(year==2011)){
          branch="tupleb2DpMu/tupleb2DpMu"; 
        } else branch="Tuple_b2DpMuX/DecayTree"; 
      }
      //create convenient strings
      TString histring = Form("%d",hi);
      TString hname = "h"+cistring+histring;
      
      //create histograms
      if(tracktype=="nLongTracks") h[ci][hi] = new TH1F(hname,tracktype,131,0,262);
      cout<<"histogram loop "<<hi<<" strings and histograms created"<<endl;
      //navigate files
      cout<<"navigating file..."<<endl;
      TTree *MyTree;
//.........这里部分代码省略.........
开发者ID:goi42,项目名称:b-bbar-cross-section-GEC,代码行数:101,代码来源:makeLongTracksonlyunnormalized.C

示例2: main

int main (int argc, char **argv) {
    
    std::string type = argv[1];   // type "gg" or "qq"
    int bin = atoi(argv[2]);
    int binp1 = bin+100;          // pt bin
    int min = atoi(argv[3]);      // events to run over
    int max = atoi(argv[4]);      // events to run over
    std::string tag = argv[5];
    float rVal = atof(argv[6]);
    
    char inName[192];
    //sprintf( inName, "dataProcessedFinal/LHEFiles/%s-pt%04i-%04i-100k.lhe", type.c_str(), bin, bin+100 );
    // sprintf( inName, "dataProcessedFinal/LHEFiles/%s.lhe", type.c_str() );
    sprintf( inName, "dataLHE/%s-pt%04i-%04i-100k.lhe", type.c_str(), bin, bin+100 );
    std::cout << "fname = " << inName << std::endl;
    std::ifstream ifsbkg (inName) ;
    LHEF::Reader reader(ifsbkg) ;

    char outName[192];
    int rInt = (int) (rVal*10.);
    sprintf( outName, "dataProcessedFinalSCOT/boost2013-%s-pt%04i-%04i%s_ak%02i.root", type.c_str(), bin, bin+100, tag.c_str(), rInt );
    TFile *f = TFile::Open(outName,"RECREATE");
    TTree *t = new TTree("t","Tree with vectors");
    t->Branch("njets"      , &njets      );
    t->Branch("jpt"        , &jpt        );
    t->Branch("jeta"       , &jeta       );
    t->Branch("jmass"      , &jmass      );
    t->Branch("jtau1_b1"   , &jtau1_b1   );
    t->Branch("jtau2_b1"   , &jtau2_b1   );
    t->Branch("jtau1_b2"   , &jtau1_b2   );
    t->Branch("jtau2_b2"   , &jtau2_b2   );
    t->Branch("jtau21_b1"   , &jtau21_b1   );
    t->Branch("jtau21_b2"   , &jtau21_b2   );
    t->Branch("jc1_b0"      , &jc1_b0      );
    t->Branch("jc1_b1"      , &jc1_b1      );
    t->Branch("jc1_b2"      , &jc1_b2      );
    t->Branch("jc2_b1"      , &jc2_b1      );
    t->Branch("jc2_b2"      , &jc2_b2      );
    t->Branch("jd2_b1"      , &jd2_b1      );
    t->Branch("jd2_b2"      , &jd2_b2      );
    t->Branch("j_qjetVol"   , &j_qjetVol      );
    t->Branch("j_mass_trim"      , &j_mass_trim      );
    t->Branch("j_mass_mmdt"      , &j_mass_mmdt      );
    t->Branch("j_mass_prun"      , &j_mass_prun      );
    t->Branch("j_mass_sdb2"      , &j_mass_sdb2      );
    t->Branch("j_mass_sdm1"      , &j_mass_sdm1      );
    t->Branch("j_multiplicity"   , &j_multiplicity      );
            
    evtCtr = 0;
    std::vector < fastjet::PseudoJet > particles;

    // loop over events
    while ( reader.readEvent () ) {
        ++evtCtr;
        if (evtCtr % 1000 == 0) std::cout << "event " << evtCtr << "\n";
        if (evtCtr < min) continue;
        if (evtCtr > max) break;
        
        // per event
        particles.clear();
        jpt.clear();
        jeta.clear();
        jmass.clear();
        jtau1_b1.clear();
        jtau2_b1.clear();
        jtau1_b2.clear();
        jtau2_b2.clear();
        jtau21_b1.clear();
        jtau21_b2.clear();
        jc1_b0.clear();
        jc1_b1.clear();
        jc1_b2.clear();
        jc2_b1.clear();
        jc2_b2.clear();
        jd2_b1.clear();
        jd2_b2.clear();
        j_qjetVol.clear();
        j_mass_trim.clear();
        j_mass_mmdt.clear();
        j_mass_prun.clear();
        j_mass_sdb2.clear();
        j_mass_sdm1.clear();
        j_multiplicity.clear();
        
        for (unsigned int i = 0 ; i < reader.hepeup.IDUP.size(); ++i){

            if (reader.hepeup.ISTUP.at(i) == 1){
                float px = reader.hepeup.PUP.at(i).at(0);
                float py = reader.hepeup.PUP.at(i).at(1);
                float pz = reader.hepeup.PUP.at(i).at(2);
                float e  = reader.hepeup.PUP.at(i).at(3);                                    
                particles.push_back( fastjet::PseudoJet( px, py, pz, e ) );
            }   
        }
        analyzeEvent( particles, rVal );
        t->Fill();
        
    }
    
    std::cout << "finish loop" << std::endl;
//.........这里部分代码省略.........
开发者ID:nhanvtran,项目名称:boost2013WG1,代码行数:101,代码来源:anaSubstructure.cpp

示例3: skimTree

void skimTree(std::string inputFile_)
{

  
  TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(inputFile_.data());
  if (!f) {
    f = new TFile(inputFile_.data());
    f->cd(Form("%s:/tree",inputFile_.data()));
  }
  TTree* fChain = (TTree*)gDirectory->Get("tree");
  cout << "Input file is " << inputFile_ << endl;

  // rename the output file
  std::string remword=".root";
  size_t pos = inputFile_.find(remword);
  std::string forOutput = inputFile_;  
  if(pos!= std::string::npos)
    forOutput.swap(forOutput.erase(pos,remword.length()));   
  std::string endfix = "_filteredtree.root";
  std::string outputFile = forOutput + endfix;
  // now open new root file
  TFile* newfile_data = new TFile(outputFile.data(),"recreate");
  cout << "Output file " << outputFile << endl;

  // clone tree
  TTree* newtree = fChain->CloneTree(0);
  newtree->SetMaxTreeSize(4000000000);
  cout << "Saving "  << endfix << " tree" << endl;

  Long64_t nentries = fChain->GetEntries();
  cout << "nentries = " << nentries << endl;

  Int_t           eventNo=-1;
  Int_t           runNo=-1;

  vector<int>*     trigResults;
  vector<string>*  trigName;


  bool isData=false;
  if(forOutput.find("DoubleElectron")!= std::string::npos || forOutput.find("DoubleMu")!= std::string::npos)
    isData=true;


  fChain->SetBranchAddress("EvtInfo_EventNum",&eventNo);
  fChain->SetBranchAddress("EvtInfo_RunNum",&runNo);
  if(isData){
    fChain->SetBranchAddress("trigResults", &trigResults);
    fChain->SetBranchAddress("trigName", &trigName);
  }

  Long64_t nlines=0;

  vector<runInfo> myList;

  ifstream fin;

  if(forOutput.find("DoubleElectron")!= std::string::npos)
    fin.open("/data4/syu/52X_533_validation/DoubleElectron_common.txt");
  else if(forOutput.find("DoubleMu")!= std::string::npos)
    fin.open("/data4/syu/52X_533_validation/DoubleMu_common.txt");
  else if(forOutput.find("GluGlu")!= std::string::npos)
    fin.open("/data4/syu/52X_533_validation/MC_common.txt");
  runInfo tempInfo;
  fin >> tempInfo.run >> tempInfo.evt;
  while(!fin.eof())
    {
      nlines++;
      myList.push_back(tempInfo);
      fin >> tempInfo.run >> tempInfo.evt;
    }
  fin.close();

  cout << "There are " << nlines << " lines" << endl;

  ofstream fout;
  fout.open(Form("%s_updated",forOutput.data()));

  Long64_t nPassEvt=0;

  for (Long64_t jentry=0; jentry<nentries;jentry++) {

    
    eventNo = -1;
    runNo = -1;
    trigName = 0;
    trigResults = 0;
    
    fChain->GetEntry(jentry);


    bool passTrigger=false;
    if(isData){

      for(int it=0; it< trigName->size(); it++)
	{
	  std::string thisTrig= trigName->at(it);
	  int results = trigResults->at(it);
//   	  cout << thisTrig << "\t" << results << endl;

//.........这里部分代码省略.........
开发者ID:ramankhurana,项目名称:usercode,代码行数:101,代码来源:skimTree.C

示例4: bit_combinations

void bit_combinations(const char * filename="counts.root")
{
  TFile * infile = new TFile(filename,"READ");
  TTree * acc = (TTree*) infile->Get("acc");

  // set branch addresses
  Int_t index,runnum,fill_index,fill;
  Double_t t;
  Double_t bbc[8];
  Double_t zdc[8];
  //Double_t vpd[4];
  Double_t vpd[8];
  Double_t tot_bx;
  Int_t blue,yell;
  acc->SetBranchAddress("i",&index);
  acc->SetBranchAddress("runnum",&runnum);
  acc->SetBranchAddress("fi",&fill_index);
  acc->SetBranchAddress("fill",&fill);
  acc->SetBranchAddress("t",&t);
  acc->SetBranchAddress("tot_bx",&tot_bx);
  acc->SetBranchAddress("blue",&blue);
  acc->SetBranchAddress("yell",&yell);
  char bbc_br[8][16];
  char zdc_br[8][16];
  //char vpd_br[4][16];
  char vpd_br[8][16];
  for(Int_t i=0; i<8; i++)
  {
    sprintf(bbc_br[i],"bbc_%d",i);
    sprintf(zdc_br[i],"zdc_%d",i);
    acc->SetBranchAddress(bbc_br[i],&(bbc[i]));
    acc->SetBranchAddress(zdc_br[i],&(zdc[i]));
    //if(i<4) 
    //{
      sprintf(vpd_br[i],"vpd_%d",i);
      acc->SetBranchAddress(vpd_br[i],&(vpd[i]));
    //};
  };

  // ----------------------------------------------

  // total counts vs. scaler bit bar charts
  TH1F * ntot_vs_bits_bbc = new TH1F();
  TH1F * ntot_vs_bits_zdc = new TH1F();
  TH1F * ntot_vs_bits_vpd = new TH1F();


  // scaler bit combination names
  char comb[8][16];
  strcpy(comb[0],"none");
  strcpy(comb[1],"e");
  strcpy(comb[2],"w");
  strcpy(comb[3],"w+e");
  strcpy(comb[4],"x");
  strcpy(comb[5],"x+e");
  strcpy(comb[6],"x+w");
  strcpy(comb[7],"x+w+e");

  // fill bar charts
  for(Int_t i=0; i<acc->GetEntries(); i++)
  {
    acc->GetEntry(i);
    for(Int_t j=0; j<8; j++)
    {
      ntot_vs_bits_bbc->Fill(comb[j],bbc[j]);
      ntot_vs_bits_zdc->Fill(comb[j],zdc[j]);
      //if(j<4) ntot_vs_bits_vpd->Fill(comb[j],vpd[j]);
      ntot_vs_bits_vpd->Fill(comb[j],vpd[j]);
    };
  };

  ntot_vs_bits_bbc->SetStats(0);
  ntot_vs_bits_bbc->SetTitle("total bbc counts vs. scaler bits");
  ntot_vs_bits_bbc->SetBarWidth(0.4);
  ntot_vs_bits_bbc->SetBarOffset(0.55);
  ntot_vs_bits_bbc->SetFillColor(50);
  TCanvas * c_bbc_bits = new TCanvas("c_bbc_bits","c_bbc_bits",700,500);
  c_bbc_bits->SetGrid(0,1);
  c_bbc_bits->SetLogy();
  ntot_vs_bits_bbc->Draw("bar2");

  ntot_vs_bits_zdc->SetStats(0);
  ntot_vs_bits_zdc->SetTitle("total zdc counts vs. scaler bits");
  ntot_vs_bits_zdc->SetBarWidth(0.4);
  ntot_vs_bits_zdc->SetBarOffset(0.55);
  ntot_vs_bits_zdc->SetFillColor(50);
  TCanvas * c_zdc_bits = new TCanvas("c_zdc_bits","c_zdc_bits",700,500);
  c_zdc_bits->SetGrid(0,1);
  c_zdc_bits->SetLogy();
  ntot_vs_bits_zdc->Draw("bar2");

  ntot_vs_bits_vpd->SetStats(0);
  ntot_vs_bits_vpd->SetTitle("total vpd counts vs. scaler bits");
  ntot_vs_bits_vpd->SetBarWidth(0.4);
  ntot_vs_bits_vpd->SetBarOffset(0.55);
  ntot_vs_bits_vpd->SetFillColor(50);
  TCanvas * c_vpd_bits = new TCanvas("c_vpd_bits","c_vpd_bits",700,500);
  c_vpd_bits->SetGrid(0,1);
  c_vpd_bits->SetLogy();
  ntot_vs_bits_vpd->Draw("bar2");
//.........这里部分代码省略.........
开发者ID:c-dilks,项目名称:scalers11t,代码行数:101,代码来源:bit_combinations.C

示例5: main

////////////////////////////////////
//     M      A     I     N      //
///////////////////////////////////
int main(int argc, char **argv)
{

  bool verbose = true;
  bool higgsDecay = true;

  // Define tree to fill
  TFile file(argv[2],"RECREATE");
  TTree* tree = new TTree("tree","tree");

  float mZ, mH, mVH, mT; //masses
  float costheta1, costheta2, costhetastar, phi, phi1; //angles
  float rapidityVH;
  int isLeptonic;
  int isUpTypeQuark;
  int passEta;
  int isWplus;  
  int decayMode;
  float b0_e, b0_eta, b0_phi, b0_pt;
  float b1_e, b1_eta, b1_phi, b1_pt;
  float f0_e, f0_eta, f0_phi, f0_pt;
  float f1_e, f1_eta, f1_phi, f1_pt;
  float V_e, V_eta, V_phi, V_pt;
  float H_e, H_eta, H_phi, H_pt;
  //float VH_e, VH_eta, VH_phi, VH_pt;


  tree->Branch("b0_e",   &b0_e,   "b0_e/F");
  tree->Branch("b0_eta", &b0_eta, "b0_eta/F");
  tree->Branch("b0_phi", &b0_phi, "b0_phi/F");
  tree->Branch("b0_pt",  &b0_pt,  "b0_pt/F");
  tree->Branch("b1_e",   &b1_e,   "b1_e/F");
  tree->Branch("b1_eta", &b1_eta, "b1_eta/F");
  tree->Branch("b1_phi", &b1_phi, "b1_phi/F");
  tree->Branch("b1_pt",  &b1_pt,  "b1_pt/F");
  tree->Branch("f0_e",   &f0_e,   "f0_e/F");
  tree->Branch("f0_eta", &f0_eta, "f0_eta/F");
  tree->Branch("f0_phi", &f0_phi, "f0_phi/F");
  tree->Branch("f0_pt",  &f0_pt,  "f0_pt/F");
  tree->Branch("f1_e",   &f1_e,   "f1_e/F");
  tree->Branch("f1_eta", &f1_eta, "f1_eta/F");
  tree->Branch("f1_phi", &f1_phi, "f1_phi/F");
  tree->Branch("f1_pt",  &f1_pt,  "f1_pt/F");
  tree->Branch("V_e",    &V_e,   "V_e/F");
  tree->Branch("V_eta",  &V_eta, "V_eta/F");
  tree->Branch("V_phi",  &V_phi, "V_phi/F");
  tree->Branch("V_pt",   &V_pt,  "V_pt/F");
  tree->Branch("H_e",    &H_e,   "H_e/F");
  tree->Branch("H_eta",  &H_eta, "H_eta/F");
  tree->Branch("H_phi",  &H_phi, "H_phi/F");
  tree->Branch("H_pt",   &H_pt,  "H_pt/F");
  //tree->Branch("VH_e",   &VH_e,   "VH_e/F");
  //tree->Branch("VH_eta", &VH_eta, "VH_eta/F");
  //tree->Branch("VH_phi", &VH_phi, "VH_phi/F");
  //tree->Branch("VH_pt",  &VH_pt,  "VH_pt/F");
  tree->Branch("mT",     &mT,     "mT/F");
  tree->Branch("mZ",     &mZ,     "mZ/F");
  tree->Branch("mH",     &mH,     "mH/F");
  tree->Branch("mVH",    &mVH,    "mVH/F");
  tree->Branch("costheta1",    &costheta1,    "costheta1/F");
  tree->Branch("costheta2",    &costheta2,    "costheta2/F");
  tree->Branch("costhetastar", &costhetastar, "costhetastar/F");
  tree->Branch("phi",          &phi,          "phi/F");
  tree->Branch("phi1",         &phi1,         "phi1/F");
  tree->Branch("rapidityVH",   &rapidityVH,   "rapidityVH/F");
  tree->Branch("isLeptonic",   &isLeptonic,   "isLeptonic/I");
  tree->Branch("isUpTypeQuark",&isUpTypeQuark,"isUpTypeQuark/I");
  tree->Branch("passEta",      &passEta,      "passEta/I");
  tree->Branch("isWplus",      &isWplus,      "isWplus/I");
  tree->Branch("decayMode",    &decayMode,    "decayMode/I");
  //Zee=0, Zmm=1, Ztt=2, Zuu=3, Zcc=4, Zdd=5, Zss=6, Zbb=7
  //Wen=8, Wmn=9, Wtn=10, Wud=11, Wcs=12
  //Znene=13, Znmnm=14, Zntnt=15

  // Reader object
  cout << "Creating reader object for input LHE file " << argv[1] << endl;
  std::ifstream ifsLHE (argv[1]) ;
  LHEF::Reader lheReader (ifsLHE) ;

  // Loop over events
  int eventCount = 0;
  int hadronicWCount = 0;
  int leptonicWCount = 0;
  int hadronicZCount = 0;
  int leptonicZCount = 0;
  int BR_Zee=0, BR_Zmm=0, BR_Ztt=0, BR_Znn=0, BR_Zuu=0, BR_Zcc=0, BR_Zdd=0, BR_Zss=0, BR_Zbb=0;
  int BR_Wen=0, BR_Wmn=0, BR_Wtn=0, BR_Wud=0, BR_Wcs=0;
  int BR_Znene=0, BR_Znmnm=0, BR_Zntnt=0;

  while ( lheReader.readEvent() ) 
    {
      eventCount++;
      if (eventCount % 100000 == 0 && verbose) std::cout << "Event " << eventCount << "\n" ;

      //Sanity check on number of particles
      if( higgsDecay==1 && lheReader.hepeup.IDUP.size() != 8 ) 
	{
//.........这里部分代码省略.........
开发者ID:benjaminkreis,项目名称:usercode,代码行数:101,代码来源:hbbTreeMaker.cpp

示例6: s_TEST_IdTree

static void s_TEST_IdTree()
{
    typedef CTreePair<int, int>::TTreePair     TTreePair;
    typedef CTreePair<int, int>::TPairTreeNode TTree;

    TTree* tr = new TTree(TTreePair(0, 0));
    
    tr->AddNode(TTreePair(1, 10));
    tr->AddNode(TTreePair(100, 110));
    TTree* tr2 = tr->AddNode(TTreePair(2, 20));
    tr2->AddNode(TTreePair(20, 21));    
    TTree* tr3 =tr2->AddNode(TTreePair(22, 22));
    tr3->AddNode(TTreePair(222, 222));

    {{
    const TTree* tnd = tr->FindSubNode(100);
    assert(tnd);
    assert(tnd->GetValue().id == 100);
    assert(tnd->GetValue().value == 110);
    const TTree& tv = tnd->GetValue();
    assert(tv.GetValue().value == 110);

    }}

    {{
    list<int> npath;
    npath.push_back(2);
    npath.push_back(22);

    TTree::TConstNodeList res;
    tr->FindNodes(npath, &res);
    assert(!res.empty());
    TTree::TConstNodeList::const_iterator it = res.begin();
    const TTree* ftr = *it;

    assert(ftr->GetValue().value == 22);
    }}

    {{
    list<int> npath;
    npath.push_back(2);
    npath.push_back(32);

    TTree::TConstNodeList res;
    tr->FindNodes(npath, &res);
    assert(res.empty());
    }}

    {{
    list<int> npath;
    npath.push_back(2);
    npath.push_back(22);
    npath.push_back(222);
    npath.push_back(100);

    const TTree* node = PairTreeTraceNode(*tr, npath);
    assert(node);
    cout << node->GetValue().id << " " << node->GetValue().value << endl;
    assert(node->GetValue().value == 110);


    node = PairTreeBackTraceNode(*tr3, 1);
    assert(node);
    cout << node->GetValue().id << " " << node->GetValue().value << endl;
    assert(node->GetValue().value == 10);
    }}

    {{
    list<int> npath;
    npath.push_back(2);
    npath.push_back(22);
    npath.push_back(222);

    const TTree* node = PairTreeTraceNode(*tr, npath);
    assert(node);
    cout << node->GetValue().id << " " << node->GetValue().value << endl;
    assert(node->GetValue().value == 222);
    }}

    delete tr;
}
开发者ID:jackgopack4,项目名称:pico-blast,代码行数:81,代码来源:test_algo_tree.cpp

示例7: TFile

void DCTPCTree::Loop()
{
  TStopwatch timer;
  gROOT->SetStyle("Plain");
  gStyle->SetEndErrorSize(3);
  gStyle->SetPalette(1,0);
  gStyle->SetLineWidth(2);
  gStyle->SetHistLineWidth(2);
  gStyle->SetOptStat(kTRUE);
  gStyle->SetOptFit(kTRUE);
  TH1::AddDirectory(false);
  
  TFile *outtree = new TFile("../input_files/hadd_01041_01158.root");//$LittleDCTPC_physics_input
  TTree *dctreepc = (TTree*)outtree->Get("dctpc_eventinfo");
  DCTPCTree aStep(dctreepc);

  Int_t Exposure_sec;
  TTree *dctreepc2 = (TTree*)outtree->Get("dctpc_runinfo");       
  dctreepc2->SetBranchAddress("Exposure_sec", &Exposure_sec);
  Int_t nentries2 = (Int_t)dctreepc2->GetEntries();  
  double totalexposure=0.;
  
  for (int runcounter = 0; runcounter<nentries2; runcounter++)
    {
      dctreepc2->GetEntry(runcounter);
      totalexposure+=Exposure_sec;
    }
  
  ofstream file_passccd;
  file_passccd.open("Pass_CCD.txt");
  ofstream file_passwfandccd;
  file_passwfandccd.open("Pass_WF_and_CCD.txt");
  
  
  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  
  
  double seqcalib [19] = {0.955114 , 1.06241 , 1.07105 , 1.07669 , 1.02827 , 1.15574 , 1.18828 , 1.08779 , 0.998239 , 1.05118 , 1.03128 , 1.02639 , 0.992746 , 0.925486 , 1.1664 , 1.05791, 0.989169};
  
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  
  //create event loop
  Long64_t nentries = dctreepc->GetEntries();
  cout << "Number of Entries: " << nentries << endl;
  
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  
  int cutnum=-1;
  int neutronnumber=0;
  int passall=0;
  int passccd=0;
  int passwf=0;
  int passwfandccd=0;

  TH1D *hist_time_ccd=new TH1D("CCD Pass Rate", "CCD Pass Rate", 100, 1374000000, 1396000000);
  TH1D *hist_time_wf=new TH1D("WF Pass Rate", "WF Pass Rate", 100, 1374000000, 1396000000);
  TH1D *hist_time_wfandccd=new TH1D("CCD and WF Pass Rate", "CCD and WF Pass Rate", 100, 1374000000, 1396000000);

  TH1D *hist_time_ccd_percent = new TH1D("% Events Pass CCD", "% Events Pass CCD", 100, 1374000000, 1396000000);
  TH1D *hist_time_wfandccd_percent = new TH1D("% Events Pass WF and CCD", "% Events Pass WF and CCD", 100, 1374000000, 1396000000);

  TH2D *hist_ccdpass_rate=new TH2D("CCD Pass", "CCD Pass", 100, 1374000000, 1386000000, 2000, 0, 2000);
  TH2D *hist_wfpass_rate=new TH2D("WF Pass", "WF Pass", 100, 1374000000, 1386000000, 2000, 0, 2000);
  TH2D *hist_wfandccdpass_rate=new TH2D("CCD and WF Pass", "CCD and WF Pass", 100, 1374000000, 1386000000, 2000, 0, 2000);

  TH2D *hist_ccdpass_rate_percent=new TH2D("% CCD Pass", "% CCD Pass", 100, 1374000000, 1396000000, 100, 0, 100);
  TH2D *hist_wfandccdpass_rate_percent=new TH2D("% WF and CCD Pass", "% WF and CCD Pass", 100, 1374000000, 1396000000, 100, 0, 100);

  TH2D *hist_pass_rate=new TH2D("Pass", "Pass", 100, 1374000000, 1386000000, 100, 0, 1);

  TH1D *hist_eff_vs_eccd_ccd=new TH1D("Efficiency vs CCD Energy - CCD Only", "Efficiency vs CCD Energy - CCD Only", 60, 0, 6000);
  TH1D *hist_eff_vs_eccd_ccd2=new TH1D("Efficiency vs CCD Energy - CCD Only 2", "Efficiency vs CCD Energy - CCD Only 2", 25, 0, 1000);
  TH1D *hist_eff_vs_eccd_wfandccd=new TH1D("Efficiency vs CCD Energy - CCD and WF", "Efficiency vs CCD Energy - CCD and WF", 60, 0, 6000);
  TH1D *hist_eff_vs_eccd_wfandccd2=new TH1D("Efficiency vs CCD Energy - CCD and WF 2", "Efficiency vs CCD Energy - CCD and WF 2", 25, 0, 1000);

  TH1D *hist_eff_vs_elength=new TH1D("Efficiency vs Length Energy", "Efficiency vs Length Energy", 60, 0, 6000);
  TH1D *hist_eff_vs_elength2=new TH1D("Efficiency vs Length Energy 2", "Efficiency vs Length Energy 2", 25, 0, 1000);
  TH1D *hist_eff_vs_elength_ccd=new TH1D("Efficiency vs Length Energy - CCD Only", "Efficiency vs Length Energy - CCD Only", 60, 0, 6000);
  TH1D *hist_eff_vs_elength_ccd2=new TH1D("Efficiency vs Length Energy - CCD Only 2", "Efficiency vs Length Energy - CCD Only 2", 25, 0, 1000);
  TH1D *hist_eff_vs_elength_wf=new TH1D("Efficiency vs Length Energy - WF Only", "Efficiency vs Length Energy - WF Only", 60, 0, 6000);
  TH1D *hist_eff_vs_elength_wfandccd=new TH1D("Efficiency vs Length Energy - CCD and WF", "Efficiency vs Length Energy - CCD and WF", 60, 0, 6000);
  TH1D *hist_eff_vs_elength_wfandccd2=new TH1D("Efficiency vs Length Energy - CCD and WF 2", "Efficiency vs Length Energy - CCD and WF 2", 25, 0, 1000);

  /*TH1D *hist_eff_vs_eccd_ccd_percent=new TH1D("%CCD vs Energy", "%CCD vs Energy", 1000, 0, 10000);
  TH1D *hist_eff_vs_eccd_wfandccd_percent = new TH1D("%WF and CCD vs Energy", "%WF and CCD vs Energy", 1000, 0, 10000);
  TH1D *hist_eff_vs_eccd=new TH1D("Efficiency vs CCD Energy", "Efficiency vs CCD Energy", 1000, 0, 10000);*/
  
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////

  for (int event = 0; event<nentries; event++)
    {
      
      aStep.GetEntry(event); 
      if(event%1000000==0)
	cout<<((double)event/(double)nentries)*100.<<"%"<<endl;
      
      r2 = (aStep.Track_x_pix*aStep.Track_x_pix+aStep.Track_y_pix*aStep.Track_y_pix)*pow(MMPERPIXEL/10.,2);
      weight=1./pow(RADIAL_PARAM0_CALIB/(RADIAL_PARAM1_CALIB+r2),RADIAL_PARAM2_CALIB);//radial calibration 
      rho_start=(sqrt(((aStep.Track_x_start_pix*MMPERPIXEL)*(aStep.Track_x_start_pix*MMPERPIXEL))+((aStep.Track_y_start_pix*MMPERPIXEL)*(aStep.Track_y_start_pix*MMPERPIXEL))));
      rho_end=(sqrt(((aStep.Track_x_end_pix*MMPERPIXEL)*(aStep.Track_x_end_pix*MMPERPIXEL))+((aStep.Track_y_end_pix*MMPERPIXEL)*(aStep.Track_y_end_pix*MMPERPIXEL))));
//.........这里部分代码省略.........
开发者ID:tjjjjjjj,项目名称:OLIVIA-DCTPC,代码行数:101,代码来源:DCTPCTree_efficiency_neutronrun.C

示例8: JetResponseMacro_TheDeadlyEagle_Eta

void  JetResponseMacro_TheDeadlyEagle_Eta(){

  gROOT->ProcessLine(".x rootlogon.C");
  gROOT->ProcessLine(".L format1Dhisto.C");
  gROOT->ProcessLine(".L formatTGraph.C");
  gROOT->ProcessLine(".x betterColors.C");

TFile *FileA = TFile::Open(Form("../JEC/Corrected_dijet_pp_mergedpthatbins_2013MCV2.root"));
  //TFile *FileA = TFile::Open(Form("~/rootFiles/JEC/Files/20120521/Correcteddijet_pp_mergedpthatbins_2012MC.root"));
  TString outname = "JetResponse_Plots.root"; 
  TFile* outf = new TFile(outname,"recreate");

  const char* AlgoNames[] = {"ak1PF","ak2PF","ak3PF","ak4PF","ak5PF","ak6PF","ak1Calo","ak2Calo","ak3Calo","ak4Calo","ak5Calo","ak6Calo","icPu5"};
  
  TCanvas *c1 = new TCanvas("c1","c1",1100,700);
  makeMultiPanelCanvas(c1,3,2,0.0,0.0,0.2,0.15,0.07);
  TCanvas *c1B = new TCanvas("c1B","c1B",1100,700);
  makeMultiPanelCanvas(c1B,3,2,0.0,0.0,0.2,0.15,0.07);
  TCanvas *c1C = new TCanvas("c1C","c1C",1100,700);
  makeMultiPanelCanvas(c1C,3,2,0.0,0.0,0.2,0.15,0.07);
  const int cCanDiv = 13;
  int nCanvDiv = cCanDiv;
  const int CnXbins = 30;
  int nXbins = CnXbins;

  TH2D* iHistoCorrEta[cCanDiv];
  TH2D* iHistoRefEta[cCanDiv];
  TH2D* iHistoJtEta[cCanDiv];
  TH2D* iHistoRawEta[cCanDiv];
  TH1D* h1[cCanDiv][CnXbins];
  TF1* Gauss6[cCanDiv][CnXbins];
  double mean[cCanDiv][CnXbins];
  double sigma[cCanDiv][CnXbins];
  double meanErr[cCanDiv][CnXbins];
  double sigmaErr[cCanDiv][CnXbins];
  double xPoint[cCanDiv][CnXbins];
  double xPointErr[cCanDiv][CnXbins];
  TLegend*  leg[cCanDiv];

  for(int i =0; i<nCanvDiv; i++)
    {
if(i==0 || i==6) continue;//skip the ak1 algos
if(i==12) continue;//skip the icpU5 algos
    if(i<=5)c1->cd(i+1);
    if(i>5 && i<12)c1B->cd(i-5);
    if(i>=12)c1C->cd(i-12);
    if(i==0)  TTree* t      = (TTree*)FileA->Get("ak1PFJetAnalyzer/t");
    if(i==1)  TTree* t      = (TTree*)FileA->Get("ak2PFJetAnalyzer/t");
    if(i==2)  TTree* t      = (TTree*)FileA->Get("ak3PFJetAnalyzer/t");
    if(i==3)  TTree* t      = (TTree*)FileA->Get("ak4PFJetAnalyzer/t");
    if(i==4)  TTree* t      = (TTree*)FileA->Get("ak5PFJetAnalyzer/t");
    if(i==5)  TTree* t      = (TTree*)FileA->Get("ak6PFJetAnalyzer/t");
    if(i==6)  TTree* t      = (TTree*)FileA->Get("ak1CaloJetAnalyzer/t");
    if(i==7)  TTree* t      = (TTree*)FileA->Get("ak2CaloJetAnalyzer/t");
    if(i==8)  TTree* t      = (TTree*)FileA->Get("ak3CaloJetAnalyzer/t");
    if(i==9)  TTree* t      = (TTree*)FileA->Get("ak4CaloJetAnalyzer/t");
    if(i==10) TTree* t      = (TTree*)FileA->Get("ak5CaloJetAnalyzer/t");
    if(i==11) TTree* t      = (TTree*)FileA->Get("ak6CaloJetAnalyzer/t");
    if(i==12) TTree* t      = (TTree*)FileA->Get("icPu5JetAnalyzer/t");
      
      leg[i]= new TLegend(0.22,0.63,0.45,0.90);//top right
      leg[i]->SetFillColor(0);
      leg[i]->SetTextSize(0.05);
      leg[i]->SetBorderSize(0);
      
      iHistoCorrEta[i] = new TH2D(Form("%s_CorrEta",AlgoNames[i]),Form("%s_CorrEta",AlgoNames[i]),nXbins,-2,2,500,0,5);
      //t->Draw(Form("corrpt/refpt:jteta>>%s_CorrEta",AlgoNames[i]),Form("corrpt>0 && fabs(jteta)<2.0"),"goff");
      t->Draw(Form("corrpt/refpt:jteta>>%s_CorrEta",AlgoNames[i]),Form("corrpt>5 && refpt>5 && fabs(jteta)<2.0"),"goff");
      iHistoCorrEta[i]->Draw("colz");
      leg[i]->AddEntry(iHistoCorrEta[i],Form("%s |#eta|<2.0",AlgoNames[i]),"");
      leg[i]->AddEntry(iHistoCorrEta[i],Form("Corrected / ref p_{T}"),"");
      format1Dhisto(*iHistoCorrEta[i],250,-1,2,20,2,1,"Jet #eta","Corrected p_{T}/ ref p_{T}");//Red      
      leg[i]->Draw();
      for(int iX=iHistoCorrEta[i]->GetXaxis()->GetFirst(); iX<iHistoCorrEta[i]->GetXaxis()->GetLast(); iX++ )
	{
	  //cout<<"bin ( "<<iX<<" ) --limits ["<<iHistoCorrEta[i]->GetXaxis()->GetBinLowEdge(iX)<<" , "<<iHistoCorrEta[i]->GetXaxis()->GetBinUpEdge(iX)<<" ] "<<endl;
	  h1[i][iX] = new TH1D(Form("h1_%d_%d_py",i,iX),Form("h1_%d_%d_py",i,iX),500,0,5);
	  h1[i][iX] =(TH1D*)iHistoCorrEta[i]->ProjectionY(Form("h1_%d_%d_py",i,iX),iX,iX,"e");
	  Gauss6[i][iX] = new TF1(Form("F6_c%d_d%d",i,iX),"gaus",0,5);
	  Gauss6[i][iX]->SetParLimits(1,0.7,1.5);
	  h1[i][iX]->Fit(Form("F6_c%d_d%d",i,iX),"0Q");
	  mean[i][iX] = Gauss6[i][iX]->GetParameter(1);
	  sigma[i][iX] = Gauss6[i][iX]->GetParameter(2);
	  meanErr[i][iX] = Gauss6[i][iX]->GetParError(1);
	  sigmaErr[i][iX] = Gauss6[i][iX]->GetParError(2);
	  xPoint[i][iX] =iHistoCorrEta[i]->GetXaxis()->GetBinCenter(iX);
	  xPointErr[i][iX] = 0;
	  
	  if(i==0 && iX==1)//Just to test 
	    {
	      TCanvas *c11 = new TCanvas("c11","c11",500,400);
	      c11->cd();	    
	      h1[i][iX]->Draw();
	      Gauss6[i][iX]->Draw("same");
	    }	  
	}

      
    }
  
//.........这里部分代码省略.........
开发者ID:maoyx,项目名称:MITBackup2014July,代码行数:101,代码来源:JetResponseMacro_TheDeadlyEagle_Eta.C

示例9: main


//.........这里部分代码省略.........
     s.SetGlobalStringOption("1DStack",           "includeSignal",    "superimposed");
     s.SetGlobalFloatOption ("1DStack",           "factorSignal",     100.0    );

     s.SetGlobalFloatOption ("DataMCRatio",       "min",              0.0    );
     s.SetGlobalFloatOption ("DataMCRatio",       "max",              2.0    );

     s.SetGlobalStringOption("Plot",              "infoTopRight",     "CMS Preliminary");
     s.SetGlobalStringOption("Plot",              "infoTopLeft",      "#sqrt{s} = 8 TeV, L = 19.5 fb^{-1}");

     s.SetGlobalBoolOption  ("Plot",              "exportPdf",        true);
     s.SetGlobalBoolOption  ("Plot",              "exportEps",        false);
     s.SetGlobalBoolOption  ("Plot",              "exportPng",        false);

  // ########################################
  // ##       Run over the datasets        ##
  // ########################################

  vector<string> datasetsList;
  s.GetDatasetList(&datasetsList);

  cout << "   > Reading datasets... " << endl;
  cout << endl;

  for (unsigned int d = 0 ; d < datasetsList.size() ; d++)
  {
     string currentDataset = datasetsList[d];
     string currentProcessClass = s.GetProcessClass(currentDataset);

     sampleName = currentDataset;
     sampleType = s.GetProcessClassType(currentProcessClass);

     // Open the tree
     TFile f((string(FOLDER_BABYTUPLES)+currentDataset+".root").c_str());
     TTree* theTree = (TTree*) f.Get("babyTuple");

     intermediatePointers pointers;
     InitializeBranchesForReading(theTree,&myEvent,&pointers);

     if (sampleType == "signal")
     {
        theTree->SetBranchAddress("mStop",       &(myEvent.mStop));
        theTree->SetBranchAddress("mNeutralino", &(myEvent.mNeutralino));
     }
     else
     {
         myEvent.mStop       = -1;
         myEvent.mNeutralino = -1;
     }

  // ########################################
  // ##        Run over the events         ##
  // ########################################

     bool ttbarDatasetToBeSplitted = false;
      if (findSubstring(currentDataset,"ttbar"))
          ttbarDatasetToBeSplitted = true;

      int nEntries = theTree->GetEntries();
      for (int i = 0 ; i < nEntries ; i++)
      {
          //if (i > float(nEntries) * 0.1) break;

          if (i % (nEntries / 50) == 0) printProgressBar(i,nEntries,currentDataset);

          // Get the i-th entry
          ReadEvent(theTree,i,&pointers,&myEvent);
开发者ID:dtbinh,项目名称:PhDThesisPlotsAndSketches,代码行数:67,代码来源:METresolution.C

示例10: TH2D

void ManagerNucleiCollisions::generateEvents( NucleiCollision *fPtrNuclStruct, int nEvents )
{
    cout << "generating events..." << endl;
    
    //reset all hists
//    fHistSources->Reset();

    TH2D *fHist2D_impParVSnStrings = new TH2D("fHist2D_impParVSnStrings", ";impact parameter, fm;n strings"
                                                , 400, 0, 20, 2001, -0.5 , 2000.5 );



    // ##### 10.07.2016 - save NucleiCollision info into the tree
    TTree *fNucleiCollisionsTree = new TTree("NucleiCollisionsTree","NucleiCollisionsTree");
    const int NMaxStrings = 35000;//8000;

    Float_t fImpactParameter = 0;
    Float_t fNuclTreeRandomEventPlanePhi = 0;
    Float_t fNuclTreeNu = 0;
    Int_t fNuclTreeNumberOfStrings = 0;
    Int_t fMultFromAllStringsFictiveV0 = 0;
    Int_t fMultFromAllStringsFictiveMidEta = 0;
//    Float_t fNuclTreeStringBoostAngle[NMaxStrings];
//    Float_t fNuclTreeStringBoostMagn[NMaxStrings];
    Float_t fDistanceBetweenPartonsForString[NMaxStrings];
    Float_t fNuclTreeStringRadiusVectorAngle[NMaxStrings];
    Float_t fNuclTreeStringX[NMaxStrings];
    Float_t fNuclTreeStringY[NMaxStrings];
    short fStringOrigin[NMaxStrings];
//    Bool_t fNuclTreeIsHardInteractionString[NMaxStrings];

    fNucleiCollisionsTree->Branch("impactParameter",&fImpactParameter,"fImpactParameter/F");
    fNucleiCollisionsTree->Branch("randomEventPlanePhi",&fNuclTreeRandomEventPlanePhi,"fNuclTreeRandomEventPlanePhi/F");
    fNucleiCollisionsTree->Branch("nu",&fNuclTreeNu,"fNuclTreeNu/F");
    fNucleiCollisionsTree->Branch("numberOfStrings",&fNuclTreeNumberOfStrings,"fNuclTreeNumberOfStrings/I");

//    fNucleiCollisionsTree->Branch("stringBoostAngle", fNuclTreeStringBoostAngle,"fNuclTreeStringBoostAngle[fNuclTreeNumberOfStrings]/F");
//    fNucleiCollisionsTree->Branch("stringBoostMagn", fNuclTreeStringBoostMagn,"fNuclTreeStringBoostMagn[fNuclTreeNumberOfStrings]/F");
    fNucleiCollisionsTree->Branch("stringX", fNuclTreeStringX,"fNuclTreeStringX[fNuclTreeNumberOfStrings]/F");
    fNucleiCollisionsTree->Branch("stringY", fNuclTreeStringY,"fNuclTreeStringY[fNuclTreeNumberOfStrings]/F");
    fNucleiCollisionsTree->Branch("distanceBetweenPartonsForString", fDistanceBetweenPartonsForString,"fDistanceBetweenPartonsForString[fNuclTreeNumberOfStrings]/F");
    fNucleiCollisionsTree->Branch("stringRadiusVectorAngle", fNuclTreeStringRadiusVectorAngle,"fNuclTreeStringRadiusVectorAngle[fNuclTreeNumberOfStrings]/F");
    fNucleiCollisionsTree->Branch("stringOrigin", fStringOrigin,"fStringOrigin[fNuclTreeNumberOfStrings]/S");
//    fNucleiCollisionsTree->Branch("isHardInteraction",fNuclTreeIsHardInteractionString,"fNuclTreeIsHardInteractionString[fNuclTreeNumberOfStrings]/O");

    fNucleiCollisionsTree->Branch( "multFromAllStringsFictiveV0", &fMultFromAllStringsFictiveV0,"fMultFromAllStringsFictiveV0/I");
    fNucleiCollisionsTree->Branch( "multFromAllStringsFictiveMidEta", &fMultFromAllStringsFictiveMidEta,"fMultFromAllStringsFictiveMidEta/I");


    // ##### event loop
    for ( int iEvent = 0; iEvent < nEvents; iEvent++)
    {
        if ( iEvent % 10 == 0 )
            cout <<"generating " << (int)iEvent << "\r"; cout.flush();

        //building event, spec impact parameter if requested:
        fPtrNuclStruct->setEventId( iEvent ); //to be used in fPtrNuclStruct for output files (tmp?)
        fPtrNuclStruct->buildEvent();
        //        fPtrNuclStruct->drawEventStructure();

        //need some event checks/triggers here?..
        if ( !fPtrNuclStruct->isMBcollision() )
        {
            iEvent--;
            continue;
        }

        fImpactParameter = fPtrNuclStruct->getImpactParameter();
        fNuclTreeNumberOfStrings = fPtrNuclStruct->getNstrings();
        fNuclTreeRandomEventPlanePhi = fPtrNuclStruct->getRandomEventPlanePhi();
        fNuclTreeNu = fPtrNuclStruct->getNu();
        fMultFromAllStringsFictiveV0 = fPtrNuclStruct->getMultFromAllStringsFictiveV0();
        fMultFromAllStringsFictiveMidEta = fPtrNuclStruct->getMultFromAllStringsFictiveMidEta();
        //cout << fMultFromAllStringsFictive << endl;

        if ( fNuclTreeNumberOfStrings >= NMaxStrings )
        {
            cout << "AHTUNG: fNuclTreeNumberOfStrings >= NMaxStrings!!!" << endl;
            return;
        }

        // ##### loop over strings
        for ( int iString = 0; iString < fNuclTreeNumberOfStrings; iString++)
        {
//            fNuclTreeStringBoostAngle[iString] = fPtrNuclStruct->getStringBoostAngle(iString);
//            fNuclTreeStringBoostMagn[iString] = fPtrNuclStruct->getStringBoostMagn(iString);
            fNuclTreeStringRadiusVectorAngle[iString] = fPtrNuclStruct->getStringRadiusVectorAngle(iString);
            fNuclTreeStringX[iString] = fPtrNuclStruct->getStringXminusBover2(iString);
            fNuclTreeStringY[iString] = fPtrNuclStruct->getStringY(iString);
            fStringOrigin[iString] = fPtrNuclStruct->getStringOrigin(iString);
            fDistanceBetweenPartonsForString[iString] = fPtrNuclStruct->getDistanceBetweenPartonsForString(iString);
//            fNuclTreeIsHardInteractionString[iString] = fPtrNuclStruct->isHardInteractionString(iString);
        }

        fHist2D_impParVSnStrings->Fill( fImpactParameter, fNuclTreeNumberOfStrings );

        fNucleiCollisionsTree->Fill();

    } // end of the event loop

//.........这里部分代码省略.........
开发者ID:altsybee,项目名称:MISE,代码行数:101,代码来源:ManagerNucleiCollisions.cpp

示例11: loop

void loop(){

	TFile *F=new TFile("TTree_SingleMu_Onia2MuMu_v20_PromptReco_AB.root","READ"); 
	TTree *tree = (TTree*)F->FindObjectAny("data"); 
	int entries = tree->GetEntries(); 
	set_branches(tree);
	
	double pt_bins[]={10,20,30,40,50,60,70,100};
	double dR_bins[]={0,0.25,0.3,0.35,0.4,0.8,1,1.5};
	int ndR=sizeof(dR_bins)/sizeof(double)-1; 
	int npT=sizeof(pt_bins)/sizeof(double)-1;
	//TEfficiency *rho = new TEfficiency("TEff_rho_pt","#rho p_{T}; p_{T}(#mu#mu) [GeV]; #rho",7,pt_bins); 
	
	CreateHistogram("hpt_lead","p_{T}(#mu) of higher p_{T} muon","p_{T}(#mu) [GeV]","#rho",100,0,100); 
	CreateHistogram("hpt_trail","p_{T}(#mu) of lower p_{T} muon","p_{T}(#mu) [GeV]","#rho",100,0,100); 

	CreateHistogram("h_mass_pt0","M_{#mu#mu}, p_{T}<35","M_{#mu#mu}","Events",100,8.5,11.5); 
	CreateHistogram("h_mass_pt1","M_{#mu#mu}, p_{T}>35","M_{#mu#mu}","Events",100,8.5,11.5); 

	CreateHistogram("h_massTrig_pt0","M_{#mu#mu}, p_{T}<35","M_{#mu#mu}","Events",100,8.5,11.5); 
	CreateHistogram("h_massTrig_pt1","M_{#mu#mu}, p_{T}>35","M_{#mu#mu}","Events",100,8.5,11.5); 
	
	CreateHistogram("DeltaRPtE_num","#DeltaR_p_{T}^{ellpictic}","#DeltaR_p_{T}^{ellpictic}","",100,0,3); 
	CreateHistogram("DeltaRPtE_num_uW","#DeltaR_p_{T}^{ellpictic}","#DeltaR_p_{T}^{ellpictic}","",100,0,3); 
	CreateHistogram("DeltaRPtE_den","#DeltaR_p_{T}^{ellpictic}","#DeltaR_p_{T}^{ellpictic}","",100,0,3); 

	
	CreateHistogram("hpt_den","#rho denominator","p_{T} [GeV]","",9,10,100); 
	CreateHistogram("hpt_num_uW","#rho numerator","p_{T} [GeV]","",9,10,100); 
	CreateHistogram("hpt_num","#rho numerator","p_{T} [GeV]","",9,10,100); 

	CreateHistogram("mass","mass","M_{#mu#mu}","",100,8.5,11.5); 
	
	CreateHistogram("mass_DeltaRPtE_num","M_{#mu#mu}","M_{#mu#mu}","#DeltaR_p_{T}^{ellpictic}",100,8.5,11.5,100,0,3);
	CreateHistogram("mass_DeltaRPtE_den","M_{#mu#mu}","M_{#mu#mu}","#DeltaR_p_{T}^{ellpictic}",100,8.5,11.5,100,0,3);

	
	CreateHistogram("mass_y0_DeltaRPtE_numBin","M_{#mu#mu}","M_{#mu#mu}","#DeltaR_p_{T}^{ellpictic}",100,8.5,11.5,ndR,dR_bins);
	CreateHistogram("mass_y0_DeltaRPtE_numBin_uW","M_{#mu#mu}","M_{#mu#mu}","#DeltaR_p_{T}^{ellpictic}",100,8.5,11.5,ndR,dR_bins);
	CreateHistogram("mass_y0_DeltaRPtE_denBin","M_{#mu#mu}","M_{#mu#mu}","#DeltaR_p_{T}^{ellpictic}",100,8.5,11.5,ndR,dR_bins);

	CreateHistogram("mass_y1_DeltaRPtE_numBin","M_{#mu#mu}","M_{#mu#mu}","#DeltaR_p_{T}^{ellpictic}",100,8.5,11.5,ndR,dR_bins);
	CreateHistogram("mass_y1_DeltaRPtE_numBin_uW","M_{#mu#mu}","M_{#mu#mu}","#DeltaR_p_{T}^{ellpictic}",100,8.5,11.5,ndR,dR_bins);
	CreateHistogram("mass_y1_DeltaRPtE_denBin","M_{#mu#mu}","M_{#mu#mu}","#DeltaR_p_{T}^{ellpictic}",100,8.5,11.5,ndR,dR_bins);


	CreateHistogram("mass_pt","M_{#mu#mu}","p_{T} [GeV]","",100,8.5,11.5,npT,pt_bins);
	CreateHistogram("mass_pt_num","M_{#mu#mu}","p_{T} [GeV]","",100,8.5,11.5,npT,pt_bins);
	CreateHistogram("mass_pt_num_uW","M_{#mu#mu}","p_{T} [GeV]","",100,8.5,11.5,npT,pt_bins);

	CreateHistogram("DeltaRPtE_pt","#DeltaR_p_{T}^{ellpictic} vs p_{T}","p_{T} [GeV]", "#DeltaR_p_{T}^{ellpictic}",9,10,100,20,0,3); 
	CreateHistogram("DeltaRPtE_pt_Trig","#DeltaR_p_{T}^{ellpictic} vs p_{T}","p_{T} [GeV]", "#DeltaR_p_{T}^{ellpictic}",9,10,100,20,0,3); 


	cout << "Entries: " << entries << endl;
	//entries=1000;
	for(int i=0; i<entries;i++){
		if(i%100000==0) {
			cout << "Event: " << i << endl;
			cout << "Run Nb: " << runNb << endl; 
		}
		tree->GetEntry(i); 

		if(D0_v1==1 || D0_v2==1 || D0_v3==1 || D0_v5==1 || D0_v6==1 || D0_v9==1 || DMu3_v1==1 || DUM0_v1==1 || DUM0_v2==1 || DUM0_v3==1 || DUM0_v4==1 || DUM0_v6==1) continue;
		if(runNb<165088 || runNb>179889) continue;
		if(Mu1_P->X()>900 || Mu2_P->X()>900) continue;
		fill_tree();
		if(!select_upsilons()) continue; 
//		if(!select_jpsi()) continue; 

		double DeltaPhi=TMath::Abs(Mu1_P->DeltaPhi(*Mu2_P)); 
		double DeltaEta=TMath::Abs(Mu1_P->Eta()-Mu2_P->Eta());
		double DeltaR=Mu1_P->DeltaR(*Mu2_P);
		double DeltaPt=TMath::Abs(Mu1_P->Perp()-Mu2_P->Perp());
		double DeltaRPtE=TMath::Sqrt(TMath::Power(0.00157*DeltaPt,2)+TMath::Power(1.2*DeltaPhi,2)+TMath::Power(DeltaEta,2));//deltaR elliptic_deltaPt

		if(Ups_P->Perp()<35)hName["h_mass_pt0"]->Fill(Ups_P->M()); 
		else hName["h_mass_pt1"]->Fill(Ups_P->M()); 
		
		hName["mass"]->Fill(Ups_P->M()); 
		hName2D["DeltaRPtE_pt"]->Fill(Ups_P->Perp(),DeltaRPtE); 
		
		hName2D["mass_pt"]->Fill(Ups_P->M(),Ups_P->Perp()); 
		int iy=-1;
		if(fabs(Ups_P->Rapidity()<0.6)) iy=0; 
		else iy=1; 
		hName2D["mass_DeltaRPtE_den"]->Fill(Ups_P->M(),DeltaRPtE); 
		hName2D[Form("mass_y%d_DeltaRPtE_denBin",iy)]->Fill(Ups_P->M(),DeltaRPtE); 
		if(Ups_P->M()>9.26 && Ups_P->M()<9.66){
			hName["hpt_den"]->Fill(Ups_P->Perp());
			hName["DeltaRPtE_den"]->Fill(DeltaRPtE);
		}


		double ptmin=TMath::Min(Mu1_P->Perp(),Mu2_P->Perp());
		double ptmax=TMath::Max(Mu1_P->Perp(),Mu2_P->Perp()); 
		
		hName["hpt_lead"]->Fill(ptmax);
		hName["hpt_trail"]->Fill(ptmin); 

//.........这里部分代码省略.........
开发者ID:btcarlso,项目名称:UserCode,代码行数:101,代码来源:rho_script.c

示例12: GetEventWeightsv2

void GetEventWeightsv2(Int_t incentmin=15, Int_t incentmax = 20, Int_t inRunMin=0, Int_t inRunMax=59){
  SetStyle();
  gStyle->SetOptTitle(1);
 
  centmin = incentmin;
  centmax = incentmax;
  runmin = inRunMin;
  runmax = inRunMax;
  
  for(Int_t ireg = 0;ireg<3;ireg++){
    Char_t hname[30];
    sprintf(hname,"hVz_Cent_Reg%i",ireg+1);
    hVz_Cent[ireg]=new TH2F(hname,hname,10,-5.0,5.0,centmax-centmin,centmin,centmax);
  }

  Int_t nevent1 = 0, nevent2 =0, nevent3=0;
  for(Int_t irun = runmin;irun<=runmax;irun++){
    nfile = 1;
    cout<<" Runnumber is "<<RunNumber[irun]<<endl;
    Char_t fname[120];
    sprintf(fname,"/Users/rashmiraniwala/ToALICE/ANALYSIS/V0MCentrality/Cent%3.3dto%3.3d/AsymRun%dCent%3.3dto%3.3d.root",centmin,centmax,RunNumber[irun],centmin,centmax);
    cout<<" Reading root file "<<fname<<" for asymTree "<<endl;
    
    TFile * f = new TFile(fname,"READ");
    TTree* asymTree = (TTree*)f->Get("asymTree");
    asymTree->SetBranchAddress("zdcasym",&zdcasym);
    asymTree->SetBranchAddress("fCentPercentile",fCentPercentile);
    asymTree->SetBranchAddress("fVertexZ",&fVertexZ);
    cout<<" Got asymTree with entries "<<asymTree->GetEntries()<<endl;
    for(Int_t iev = 0;iev<asymTree->GetEntries();iev++){
      asymTree->GetEntry(iev);
      //      cout<<" zdcasym, vertex, cent = "<<iev<<" "<<zdcasym<<" "<<fVertexZ<<" "<<fCentPercentile[0]<<endl;
      if(zdcasym>-1.0 && zdcasym<-0.1){
	nevent1++;
	hVz_Cent[0]->Fill(fVertexZ,fCentPercentile[0]);
      }
      if(zdcasym>0.1 && zdcasym<1.0){
	nevent2++;
	hVz_Cent[1]->Fill(fVertexZ,fCentPercentile[0]);
      }
      if(zdcasym>-0.1 && zdcasym<0.1){
	nevent3++;
	hVz_Cent[2]->Fill(fVertexZ,fCentPercentile[0]);
      }
    }
    f->Close();
    cout<<"nevent 1,2,3 = "<<nevent1<<" "<<nevent2<<" "<<nevent3<<endl;
  }
  for(Int_t ireg = 0;ireg<3;ireg++){
    cout<<" Number of events in region "<<ireg+1<<" = "<<hVz_Cent[ireg]->GetEntries()<<endl;
    hVz_Cent[ireg]->Scale(1.0/hVz_Cent[ireg]->GetEntries());
  }

  hRatio1=(TH2F*)hVz_Cent[0]->Clone("hRatio1");
  hRatio1->Divide(hVz_Cent[2]);

  hRatio2=(TH2F*)hVz_Cent[1]->Clone("hRatio2");
  hRatio2->Divide(hVz_Cent[2]);
  
  
  TCanvas * c = new TCanvas("c","c",1000,600);
  c->Divide(3,1);
  c->cd(1);
  hVz_Cent[0]->SetXTitle("Vz");
  hVz_Cent[0]->SetYTitle("Centrality %");
  hVz_Cent[0]->SetZTitle(" Number of Events");
  hVz_Cent[0]->Draw("lego");
  c->cd(2);
  hVz_Cent[1]->SetXTitle("Vz");
  hVz_Cent[1]->SetYTitle("Centrality %");
  hVz_Cent[1]->SetZTitle(" Number of Events");
  hVz_Cent[1]->Draw("lego");
  c->cd(3);
  hVz_Cent[2]->SetXTitle("Vz");
  hVz_Cent[2]->SetYTitle("Centrality %");
  hVz_Cent[2]->SetZTitle(" Number of Events");
  hVz_Cent[2]->Draw("lego");
  
  TCanvas * c1 = new TCanvas("c1","c1",900,500);
  c1->Divide(2,1);

  c1->cd(1);
  hRatio1->SetTitle("Event Weights for correction of Centrality and Vertex-Z distribution: Reg1");
  hRatio1->SetLineColor(4);
  hRatio1->SetXTitle("Vz");
  hRatio1->SetYTitle("Centrality %");
  hRatio1->SetZTitle("Ratio of Reg1/Reg3");
  hRatio1->Draw("lego");

  hRatio2->SetTitle("Event Weights for correction of Centrality and Vertex-Z distribution: Reg2");
  
  c1->cd(2);
  hRatio2->SetLineColor(2);
  hRatio2->SetXTitle("Vz");
  hRatio2->SetYTitle("Centrality %");
  hRatio2->SetZTitle("Ratio of Reg2/Reg3");
  hRatio2->Draw("lego");

  TLatex * l = new TLatex(-10,20,"Vertex-Z and Centrality Correction Weights: Region 2");
  l->SetTextSize(0.7);
//.........这里部分代码省略.........
开发者ID:ktf,项目名称:AliPhysics,代码行数:101,代码来源:GetEventWeightsv2.C

示例13: TMVAtest1


//.........这里部分代码省略.........
  TString TTGFileTrain ="TTG.root";
  TString WWFileTrain ="WW.root";
  TString WZFileTrain ="WZ.root";
  TString ZZFileTrain ="ZZ.root";
  TString ZGAMMAFileTrain ="ZGAMMA.root";


//  TString bkgFileTrain = "TTG.root";
  
  TFile *inputSTrain  = TFile::Open( sigFileTrain );
 if (!inputSTrain) {
      std::cout << "ERROR: could not open data file" << std::endl;
      exit(1);
   } 
  TFile *inputBTrain = TFile::Open( bkgFileTrain );
  TFile *inputBttbar1 = TFile::Open( ttbarFileTrain1);
  TFile *inputBttbar2 = TFile::Open( ttbarFileTrain2);
  TFile *inputBttbar3 = TFile::Open( ttbarFileTrain3);
  TFile *inputTTG= TFile::Open(TTGFileTrain );
  TFile *inputWW= TFile::Open(WWFileTrain );
  TFile *inputWZ= TFile::Open(WZFileTrain );
  TFile *inputZZ= TFile::Open(ZZFileTrain );
  TFile *inputZGAMMA= TFile::Open( ZGAMMAFileTrain);

if (!inputBTrain) {
      std::cout << "ERROR: could not open data file" << std::endl;
      exit(1);
   }

 
  std::cout << "--- TMVAnalysis    : Accessing Signal Train: " << sigFileTrain << std::endl;
  std::cout << "--- TMVAnalysis    : Accessing Background Train: " << bkgFileTrain << std::endl;
  
  TTree *signalTrain      = (TTree*)inputSTrain->FindObjectAny("atq");
  TTree *backgroundTrain = (TTree*)inputBTrain->FindObjectAny("atq");
  TTree *ttbarbackground1 = (TTree*)inputBttbar1->FindObjectAny("atq");
  TTree *ttbarbackground2 = (TTree*)inputBttbar2->FindObjectAny("atq");
  TTree *ttbarbackground3 = (TTree*)inputBttbar3->FindObjectAny("atq");
  TTree *TTGbackground = (TTree*)inputTTG->FindObjectAny("atq");
  TTree *WWbackground = (TTree*)inputWW->FindObjectAny("atq");
  TTree *WZbackground = (TTree*)inputWZ->FindObjectAny("atq");
  TTree *ZZbackground = (TTree*)inputZZ->FindObjectAny("atq");
  TTree *ZGAMMAbackground = (TTree*)inputZGAMMA->FindObjectAny("atq");

//  TTree *signalTrain      = (TTree*)inputSTrain->FindObjectAny("insidetopmass");
//  TTree *backgroundTrain = (TTree*)inputBTrain->FindObjectAny("insidetopmass");
  
 // factory->AddSignalTree( signalTrain, 1);
//cout<<"reza1";
  
 // factory->AddBackgroundTree( backgroundTrain, 1, );
//cout<<"reza2";

 factory->SetInputTrees(signalTrain,backgroundTrain,1,1);
 factory->AddBackgroundTree( ttbarbackground1, 1.1);
 factory->AddBackgroundTree( ttbarbackground2, 1.1);
// factory->AddBackgroundTree( ttbarbackground3, 0.3);
 factory->AddBackgroundTree( TTGbackground, 1);
 factory->AddBackgroundTree( WWbackground, 1);
 factory->AddBackgroundTree(WZbackground , 1);
 factory->AddBackgroundTree(ZZbackground , 1);
 factory->AddBackgroundTree(ZGAMMAbackground , 1);

  // Set xs-weight
//  factory->SetSignalWeightExpression    ("weight");
  //factory->SetBackgroundWeightExpression("weight");
开发者ID:rgoldouz,项目名称:tqA,代码行数:67,代码来源:TMVAtest1(asl).C

示例14: plot_HE

// Commands executed in a GLOBAL scope, e.g. created hitograms aren't erased...
void plot_HE(TString  inputfile="simevent_HE.root",
	     TString outputfile="HE_histo.root",
	     Int_t drawmode = 2,
             TString    reffile="../data/HE_ref.root"){
 
  // Option to no-action(0)/draw(1)/save(2) (default = 0) histograms in gif.
  //int doDraw = 0; 
  int doDraw = drawmode;

  char * treename = "Events";        //The Title of Tree.
  
  delete gROOT->GetListOfFiles()->FindObject(inputfile);

  TFile * myf  = new TFile(inputfile);
  
  TTree * tree = dynamic_cast<TTree*>(myf->Get("Events"));
  assert(tree != 0);

  TBranch * branchLayer = tree->GetBranch("PHcalValidInfoLayer_g4SimHits_HcalInfoLayer_CaloTest.obj");
  assert(branchLayer != 0);

  TBranch * branchNxN = tree->GetBranch("PHcalValidInfoNxN_g4SimHits_HcalInfoNxN_CaloTest.obj");
  assert(branchNxN != 0);

  TBranch * branchJets = tree->GetBranch( "PHcalValidInfoJets_g4SimHits_HcalInfoJets_CaloTest.obj");  assert(branchJets != 0);

  // Just number of entries (same for all branches)
  int  nent = branchLayer->GetEntries();
  cout << "Entries branchLayer : " << nent << endl;
  nent = branchJets->GetEntries();
  cout << "Entries branchJets  : " << nent << endl;
  nent = branchNxN->GetEntries();
  cout << "Entries branchNxN   : " << nent << endl;

  // Variables from branches
  PHcalValidInfoJets infoJets;
  branchJets->SetAddress( &infoJets); 
  PHcalValidInfoLayer infoLayer;
  branchLayer->SetAddress( &infoLayer); 
  PHcalValidInfoNxN infoNxN;
  branchNxN->SetAddress( &infoNxN); 
  
  //***************************************************************************
  // Histo titles-labels

  const int Nhist1     = 47, Nhist2 = 1;  // N simple and N combined histos
  const int Nhist1spec =  7;              // N special out of Nsimple total 
  const int nLayersMAX = 20;
  const int nDepthsMAX =  5;

  TH1F *h;                              // just a pointer
  TH1F *h1[Nhist1];
  TH1F *h1l[nLayersMAX];                // + all scint. layers separately
  TH1F *h1d[nDepthsMAX];                // + all depths  

  TH2F *h2[Nhist2];
  TH2F *h2g[5];         // +  eta-phi grid -related for all depthes
  
  char *label1[Nhist1], *label2[Nhist2], *label1l[nLayersMAX ];
  char *label1d[nDepthsMAX], *label2g[5];
  

  // simple histos  
  label1[0]  = &"rJetHits.gif";
  label1[1]  = &"tJetHits.gif";
  label1[2]  = &"eJetHits.gif";
  label1[3]  = &"ecalJet.gif";
  label1[4]  = &"hcalJet.gif";
  label1[5]  = &"hoJet.gif";
  label1[6]  = &"etotJet.gif";
  label1[7]  = &"detaJet.gif";
  label1[8]  = &"dphiJet.gif";
  label1[9]  = &"drJet.gif";
  label1[10] = &"jetE.gif";
  label1[11] = &"jetEta.gif";
  label1[12] = &"jetPhi.gif";
  label1[13] = &"dijetM.gif";
  label1[14] = &"ecalNxNr.gif";
  label1[15] = &"hcalNxNr.gif";
  label1[16] = &"hoNxNr.gif";
  label1[17] = &"etotNxNr.gif";
  label1[18] = &"ecalNxN.gif";
  label1[19] = &"hcalNxN.gif";
  label1[20] = &"hoNxN.gif";
  label1[21] = &"etotNxN.gif";
  label1[22] = &"layerHits.gif";
  label1[23] = &"etaHits.gif";          
  label1[24] = &"phiHits.gif";
  label1[25] = &"eHits.gif";
  label1[26] = &"tHits.gif";
  label1[27] = &"idHits.gif";
  label1[28] = &"jitterHits.gif";
  label1[29] = &"eIxI.gif";
  label1[30] = &"tIxI.gif";
  label1[31] = &"eLayer.gif";
  label1[32] = &"eDepth.gif";
  label1[33] = &"eHO.gif";
  label1[34] = &"eHBHE.gif";
  label1[35] = &"elongHF.gif";
//.........这里部分代码省略.........
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:101,代码来源:plot_HE.C

示例15: s_TEST_Tree

static void s_TEST_Tree()
{
    typedef CTreeNode<int>  TTree;
    
    TTree* tr = new TTree(0);
    TTree* tr10 = tr->AddNode(10);
    tr->AddNode(11);
    tr10->AddNode(20);
    tr10->AddNode(21);
   
    TTree* sr = new TTree(0);
    sr->AddNode(10);
    sr->AddNode(11);

    TTree* ur = new TTree(0);
    ur->AddNode(10);
    ur->AddNode(11);
    ur->AddNode(20);
    ur->AddNode(21);
    

//    TreePrint(cout, *tr, (IntConvType) NStr::IntToString);
//    TreeReRoot(*tr10);
//    TreePrint(cout, *tr10, (IntConvType) NStr::IntToString);

    cout << "Testing Breadth First Traversal" << endl;
    TreeBreadthFirstTraverse(*tr, TestFunctor2);
    cout << endl;

    cout << "Testing Depth First Traversal" << endl;
    TreeDepthFirstTraverse(*tr, TestFunctor1);
    cout << endl;

    cout << "Testing Tree Comparison" << endl;
    cout << "tr and tr10 are ";
    if(!TreeCompare(*tr, *tr10, TestFunctor3)) cout << "not ";
    cout << "the same." << endl;
    cout << "tr and tr are ";
    if(!TreeCompare(*tr, *tr, TestFunctor3)) cout << "not ";
    cout << "the same." << endl;
    cout << "tr and sr are ";
    if(!TreeCompare(*tr, *sr, TestFunctor3)) cout << "not ";
    cout << "the same." << endl;
    cout << "tr and ur are ";
    if(!TreeCompare(*tr, *ur, TestFunctor3)) cout << "not ";
    cout << "the same." << endl;
    cout << "sr and ur are ";
    if(!TreeCompare(*sr, *ur, TestFunctor3)) cout << "not ";
    cout << "the same." << endl;
    cout << endl;

    {{
    unsigned int cnt;
    TTree::TNodeList_CI it = tr->SubNodeBegin();
    TTree::TNodeList_CI it_end = tr->SubNodeEnd();
    
    for (cnt = 0; it != it_end; ++it, ++cnt) {
        const TTree* t = *it;
        int v = t->GetValue();
        assert(v == 10 || v == 11);
    }
    assert(cnt == 2);
    }}
    
    {{
    TTree* tr2 = new TTree(*tr);
    unsigned int cnt;
    TTree::TNodeList_CI it = tr2->SubNodeBegin();
    TTree::TNodeList_CI it_end = tr2->SubNodeEnd();
    
    for (cnt = 0; it != it_end; ++it, ++cnt) {
        const TTree* t = *it;
        int v = t->GetValue();
        assert(v == 10 || v == 11);
    }
    assert(cnt == 2);
    delete tr2;
    }}
    
    
    {{
    TTree::TNodeList_I it = tr->SubNodeBegin();
    TTree::TNodeList_I it_end = tr->SubNodeEnd();
    
    for (; it != it_end; ++it) {
        TTree* t = *it;
        int v = t->GetValue();
        if (v == 10)
        {
            tr->RemoveNode(t);
            break;
        }
    }
    }}

    TreeDepthFirstTraverse(*tr, TestFunctor1);
    cout << endl;

    {{
    unsigned int cnt;
//.........这里部分代码省略.........
开发者ID:jackgopack4,项目名称:pico-blast,代码行数:101,代码来源:test_algo_tree.cpp


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