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


C++ TTree::SetMarkerColor方法代码示例

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


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

示例1: evtime

void evtime() {
  vector<int> runs;
  vector<int> marks;
  vector<int> mcols;
  runs.push_back(13893);
  marks.push_back(2);
  mcols.push_back(2);
  runs.push_back(14009);
  marks.push_back(24);
  mcols.push_back(4);
  runs.push_back(14085);
  marks.push_back(25);
  mcols.push_back(3);
  runs.push_back(14234);
  marks.push_back(5);
  mcols.push_back(3);
  runs.push_back(14434);
  marks.push_back(28);
  mcols.push_back(3);
  string pre = "run";
  string suf = "evt.root";
  double tmax = 160;
  double emax = 180;
  new TCanvas;
  TH1* ph = new TH2F("hevtime", "Event vs. time; Time [sec]; Event",
                     tmax, 0, tmax, emax, 0, emax);
  ph->SetStats(0);
  ph->Draw("axis");
  TLegend* pleg = new TLegend(0.65,0.15,0.85,0.37);
  pleg->SetBorderSize(0);
  for ( unsigned int isam=0; isam<runs.size(); ++isam ) {
    int run = runs[isam];
    int icol = dsindex(run);
    int col = colormap(icol);
    ostringstream ssrun;
    ssrun << run;
    string srun = ssrun.str();
    ostringstream sst0;
    sst0 << t0map(run);
    string fname = pre + srun + suf;
    TFile* pfile = TFile::Open(fname.c_str(), "READ");
    TTree* ptree = dynamic_cast<TTree*>(pfile->Get("DXDisplay/EventTree"));
    ptree->SetMarkerStyle(marks[isam]);
    ptree->SetMarkerColor(col);
cout << run << " " << col << " " << sst0.str() <<  endl;
    if ( ptree == 0 ) {
      cout << "Tree not found" << endl;
      pfile->ls();
      return;
    }
    string sarg = "event:tlo-";
    sarg += sst0.str();
    sarg += ">>hevtime";
    ptree->Draw(sarg.c_str(), "", "same");
    pleg->AddEntry(ptree, srun.c_str(), "p");
  }
  pleg->Draw();
}
开发者ID:dladams,项目名称:dune_extensions,代码行数:58,代码来源:evtime.C

示例2: striptree

void striptree(TString fileName="", Int_t nAPVs=4)
{
  //===========================================================================
  // Change the inputs
  //===========================================================================

  //TString fileName = "Raw_Data_July1_Ped_300V";
  //TString fileName = "Raw_Data_July1_Source_300V";
  //TString fileName = "Raw_Data_July1_Ped_200V";
  //TString fileName = "Raw_Data_Pedestal_300V";
  // TString fileName = "Raw_Data_Source_300V";

  // TString fileName = "Raw_Data_Sept_3_1";
  // TString fileName = "Raw_Data_test_3_7";
  // TString fileName = "Raw_Data_Albox_2011_03_31_1";
  //-- TString fileName = "Raw_Data_04_01_AL_center_1";
  // TString fileName = "Raw_Data_04_01_AL_7820_1";
  //-- TString fileName = "Raw_Data_7817_04_01_1";
  // TString fileName = "Raw_Data_7817_04_01_bkg_1";

  //int nAPVs = 4;

  //TString fileName = "Raw_Data_July1_Source_200V";
  //int nAPVs = 1;

  int nEvents = -1; // -1 means all

  TString dat = fileName;
  TString eps = fileName + "-events.eps";
  TString root = fileName + "-events.root";

  TFile* file = new TFile(root, "RECREATE");

  //===========================================================================
  // Read the data and make a 2D scatter plot
  //===========================================================================

  ifstream in(dat);
  if (!in) {
     cout<< "File " << dat << " not found" <<endl;
     return;
  }

  TString comments = "vertical --> APV0, APV1, ... of event 1, ...";
  TString s;
  while (1) {
    s.ReadLine(in);
    if (s.BeginsWith(comments))
      break;
  }
  gStyle->SetOptStat(10);
  TString title = fileName+"   ADC Counts vs Channel";
  TString title32 = fileName+"   ADC Counts vs Channel for 32 ch";
  TH2D *h2d = new TH2D("h2d", title.Data(), nAPVs*128, 0, nAPVs*128, 200, 0, 200);
  TH2D *h2d32 = new TH2D("h2d32", title.Data(), 16, 0, 16, 200, 0, 200);
  TProfile *profile = new TProfile("profile", title32.Data(), nAPVs*128, 0, nAPVs*128);

  int event, apv, channel, adc;
  // TTree* tree = new TTree("tree", "tree");
  // tree->Branch("event",   &event,   "event/I");
  // tree->Branch("apv",     &apv,     "apv/I");
  // tree->Branch("channel", &channel, "channel/I");
  // tree->Branch("adc",     &adc,     "adc/I");

  Int_t raw[512];
  TTree* etree = new TTree("etree", "etree");
  etree->Branch("raw",   &raw,   "raw[512]/I");    // etree->Draw("raw:Iteration$","Entry$==0")
  etree->SetMarkerStyle(6);
  etree->SetMarkerColor(2);

  int n = 0;
  while (1) {
    in >> s;
    if (!in.good())
      break;
    if (s.BeginsWith("]DATA]")) // last line
      break;
    n++;
    if ((nEvents != -1) && (n > nEvents))
      break;
    event = atoi(s.Data());
    if (event%100 == 0)
      cout << "Processing event " << event << endl;
    for (int i=0; i<2; i++)
      in >> s; // time

    Int_t ichannel = 0;
    for (apv=1; apv<=nAPVs; apv++) {
      in >> s; // header + analog APV data + one tick mark
      int sequenceNumber = 0;
      TString subString = "";
      int length = s.Length();
      for (int j=0; j<length; j++) {
        char c = s[j];
        if (c != ',') {
          subString += c;
        } else {
          if (sequenceNumber >= 12) {
            channel = sequenceNumber - 12;
            adc = atoi(subString.Data());
//.........这里部分代码省略.........
开发者ID:zatserkl,项目名称:root-macros,代码行数:101,代码来源:striptree.C

示例3: process

void process()
{
   Int_t raw[512];   // buffer for input signal and bkg trees
   // buffers for output trees
   Int_t sig[512];
   Int_t cmsig[512];
   Int_t cm[16];

   // pedestal
   const char* fbkg_name = "Raw_Data_FZ320P_05_MSSD_2_250V_K237_Pedestal.dat-events.root";
   TFile* fbkg = TFile::Open(fbkg_name);
   if (!fbkg) cout<< "File not found: " << fbkg <<endl<<exitl;

   TTree* tree = (TTree*) fbkg->Get("etree");
   tree->SetBranchAddress("raw", &raw);

   TH2* h2d = (TH2*) fbkg->Get("h2d");
   new TCanvas;
   h2d->Draw();

   TProfile* profile = (TProfile*) fbkg->Get("profile"); 
   //new TCanvas;
   //profile->Draw();

   Int_t pedestal[512];
   for (int i=0; i<512; i++) {
      // pedestal[i] = profile->GetBinContent(i+1) - 0.5;
      // pedestal[i] = profile->GetBinContent(i+1) + 0.5;
      pedestal[i] = profile->GetBinContent(i+1);
   }

   // cout << "\nPedestals for every channel\n" << endl;
   // for (int i=0; i<512; i++) {
   //    cout << pedestal[i] << " ";
   //    if (i>0 && (i+1)%128==0)
   //       cout << endl;
   // }

   cout<< "processing bkg" <<endl;

   // output file with tree
   const char* obfname = "FZ320P_05_MSSD_2-bkg.root";
   TFile* obfile = TFile::Open(obfname, "recreate");

   TTree* btree = new TTree("btree", "btree");
   btree->Branch("sig", &sig, "sig[512]/I");
   btree->Branch("cmsig", &cmsig, "cmsig[512]/I");
   btree->Branch("cm", &cm, "cm[16]/I");
   btree->SetMarkerStyle(6);
   btree->SetMarkerColor(2);

   for (int jentry=0; jentry<tree->GetEntries(); ++jentry)
   {
      tree->GetEvent(jentry);
      // sig
      for (int i=0; i<512; ++i) {
         sig[i] = raw[i] - pedestal[i];
      }
      // calc common mode
      Int_t group32[32];
      Int_t index32[32];
      for (int igroup=0; igroup<16; ++igroup) {
         for (int istrip=0; istrip<32; ++istrip)   // istrip is number inside group of 32
         {
            group32[istrip] = sig[igroup*32 + istrip];
         }
         // sort array group32 in ascending order
         TMath::Sort(32, group32, index32, kFALSE);
         Int_t median = group32[index32[14]];
         cm[igroup] = median;
      }
      // subtract common mode
      for (int istrip=0; istrip<512; ++istrip) {
         Int_t igroup = istrip/32;
         cmsig[istrip] = sig[istrip] - cm[igroup];
      }
      // Fill sig, cmsig, cm
      btree->Fill();
   }
   obfile->Write();

   /////////////////////////////////////////////////
   //
   // signal tree
   //
   /////////////////////////////////////////////////

   cout<< "processing signal" <<endl;
   
   TChain* chain = new TChain("etree");
   chain->Add("Raw_Data_FZ320P_05_MSSD_250V_K237_Position_1.dat-events.root");
   chain->Add("Raw_Data_FZ320P_05_MSSD_250V_K237_Position_2.dat-events.root");
   chain->Add("Raw_Data_FZ320P_05_MSSD_2_250V_K237_Position_3.dat-events.root");
   chain->Add("Raw_Data_FZ320P_05_MSSD_2_250V_K237_Position_4.dat-events.root");
   chain->SetBranchAddress("raw", &raw);

   // output file with tree
   const char* osfname = "FZ320P_05_MSSD_2-signal.root";
   TFile* osfile = TFile::Open(osfname, "recreate");

//.........这里部分代码省略.........
开发者ID:zatserkl,项目名称:root-macros,代码行数:101,代码来源:striptree.C

示例4: pulseConvert

void pulseConvert(const char* ifname)
{
   TFile* ifile = TFile::Open(ifname);
   if (!ifile) {
      cout<< "File not found: " << ifname <<endl;
      return;
   }
   TTree* itree = (TTree*) ifile->Get("pulse");
   if (!itree) {
      cout<< "Error: could not find tree \"pulse\"" <<endl;
      return;
   }

   Int_t event, tc1, tc2;
   Float_t b1_t[1024], b1_c[4096], b2_t[1024], b2_c[4096];

   Float_t* b1_c1 = b1_c;
   Float_t* b1_c2 = b1_c + 1024;
   Float_t* b1_c3 = b1_c + 2048;
   Float_t* b1_c4 = b1_c + 3072;
   Float_t* b2_c1 = b2_c;
   Float_t* b2_c2 = b2_c + 1024;
   Float_t* b2_c3 = b2_c + 2048;
   Float_t* b2_c4 = b2_c + 3072;

   itree->SetBranchAddress("event", &event);
   itree->SetBranchAddress("tc1", &tc1);
   itree->SetBranchAddress("tc2", &tc2);
   itree->SetBranchAddress("b1_t", &b1_t);
   itree->SetBranchAddress("b2_t", &b2_t);
   itree->SetBranchAddress("b1_c", &b1_c);
   itree->SetBranchAddress("b2_c", &b2_c);

   TFile* ofile = TFile::Open(Form("%s.pulse.root",ifname), "recreate");

   // TTree* otree = new TTree("pulse", "old pulse tree");
   TTree* otree = new TTree("p", "new pulse tree");
   otree->SetMarkerStyle(6);
   otree->SetMarkerColor(2);
   otree->SetLineColor(2);

   // otree->Branch("event", &event, "event/I");
   // otree->Branch("tc1", &tc1, "tc1/I");
   // otree->Branch("b1_t",  b1_t, "b1_t[1024]/F");
   // otree->Branch("b1_c1", b1_c1, "b1_c1[1024]/F");
   // otree->Branch("b1_c2", b1_c2, "b1_c2[1024]/F");
   // otree->Branch("b1_c3", b1_c3, "b1_c3[1024]/F");
   // otree->Branch("b1_c4", b1_c4, "b1_c4[1024]/F");
   // otree->Branch("tc2", &tc2, "tc2/I");
   // otree->Branch("b2_t",  b2_t, "b2_t[1024]/F");
   // otree->Branch("b2_c1", b2_c1, "b2_c1[1024]/F");
   // otree->Branch("b2_c2", b2_c2, "b2_c2[1024]/F");
   // otree->Branch("b2_c3", b2_c3, "b2_c3[1024]/F");
   // otree->Branch("b2_c4", b2_c4, "b2_c4[1024]/F");

   otree->Branch("event", &event, "event/I");
   otree->Branch("tc1", &tc1, "tc1/I");
   otree->Branch("t1",  b1_t, "t1[1024]/F");
   otree->Branch("c1", b1_c1, "c1[1024]/F");
   otree->Branch("c2", b1_c2, "c2[1024]/F");
   otree->Branch("c3", b1_c3, "c3[1024]/F");
   otree->Branch("c4", b1_c4, "c4[1024]/F");
   otree->Branch("tc2", &tc2, "tc2/I");
   otree->Branch("t2",  b2_t, "t2[1024]/F");
   otree->Branch("c5", b2_c1, "c5[1024]/F");
   otree->Branch("c6", b2_c2, "c6[1024]/F");
   otree->Branch("c7", b2_c3, "c7[1024]/F");
   otree->Branch("c8", b2_c4, "c8[1024]/F");

   for (Long64_t jentry=0; jentry<itree->GetEntries(); jentry++)
   {
      if (jentry % 1000 == 0) cout<< "jentry = " << jentry <<endl;
      itree->LoadTree(jentry);
      itree->GetEntry(jentry);

      otree->Fill();
   }

   cout<< "Write " << otree->GetEntries() << " events into file " << ofile->GetName() <<endl;
   ofile->Write();
}
开发者ID:CaltechPrecisionTiming,项目名称:DRS4DAQ,代码行数:81,代码来源:ConvertBoard2Root.C

示例5: csv

void csv(TString input="tmva.csvoutput.txt", TString par1="par2", TString par2="par3", TString par3="", TString value="eventEffScaled_5") {
  std::cout << "Usage:" << std::endl
            << ".x scripts/csv.C    with default arguments" << std::endl
            << ".x scripts/csv.C(filename, par1, par2, value)" << std::endl
            << std::endl
            << "  Optional arguments:" << std::endl
            << "    filename        path to CSV file" << std::endl
            << "    par1            name of X-parameter branch" << std::endl
            << "    par2            name of Y-parameter branch (if empty, efficiency is drawn as a function of par1)" << std::endl
            << "    value           name of result (efficiency) branch" << std::endl
            << std::endl;

  TTree *tree = new TTree("data", "data");
  tree->ReadFile(input);

  gStyle->SetPalette(1);
  gStyle->SetPadRightMargin(0.14);

  TCanvas *canvas = new TCanvas("csvoutput", "CSV Output", 1200, 900);

  tree->SetMarkerStyle(kFullDotMedium);
  tree->SetMarkerColor(kRed);
  if(par2.Length() > 0) {
    //tree->Draw(Form("%s:%s", par2.Data(), par1.Data()));
    if(par3.Length() > 0)
      tree->Draw(Form("%s:%s:%s:%s", par1.Data(), par2.Data(), par3.Data(), value.Data()), "", "COLZ"); //, "", "Z");
    else
      tree->Draw(Form("%s:%s:%s", par2.Data(), par1.Data(), value.Data()), "", "COLZ"); //, "", "Z");

    TH1 *histo = tree->GetHistogram();
    if(!histo)
      return;

    histo->SetTitle(Form("%s with different classifier parameters", value.Data()));
    histo->GetXaxis()->SetTitle(Form("Classifier parameter %s", par1.Data()));
    histo->GetYaxis()->SetTitle(Form("Classifier parameter %s", par2.Data()));
    if(par3.Length() > 0)
      histo->GetZaxis()->SetTitle(Form("Classifier parameter %s", par3.Data()));
    else
      histo->GetZaxis()->SetTitle("");

    if(par3.Length() == 0) {
      float x = 0;
      float y = 0;
      float val = 0;
      double maxVal = tree->GetMaximum(value);
      double minVal = tree->GetMinimum(value);

      tree->SetBranchAddress(par1, &x);
      tree->SetBranchAddress(par2, &y);
      tree->SetBranchAddress(value, &val);
      TLatex l;
      l.SetTextSize(0.03);
    
      Long64_t nentries = tree->GetEntries();
      for(Long64_t entry=0; entry < nentries; ++entry) {
        tree->GetEntry(entry);
    
        l.SetTextColor(textColor(val, maxVal, minVal));
        l.DrawLatex(x, y, Form("%.3f", val*100));
      }
    }
  }
  else {
    tree->Draw(Form("%s:%s", value.Data(), par1.Data()));
    TH1 *histo = tree->GetHistogram();
    if(!histo) 
      return;
    histo->SetTitle(Form("%s with different classifier parameters", value.Data()));
    histo->GetXaxis()->SetTitle(Form("Classifier parameter %s", par1.Data()));
    histo->GetYaxis()->SetTitle(value);
  }
}
开发者ID:aatos,项目名称:chep09tmva,代码行数:73,代码来源:csv.C

示例6: rs101_limitexample


//.........这里部分代码省略.........
    fcint = fc.GetInterval();  // that was easy.

    RooFitResult* fit = modelWithConstraints->fitTo(*data, Save(true));

    // Third, use a Calculator based on Markov Chain monte carlo
    // Before configuring the calculator, let's make a ProposalFunction
    // that will achieve a high acceptance rate
    ProposalHelper ph;
    ph.SetVariables((RooArgSet&)fit->floatParsFinal());
    ph.SetCovMatrix(fit->covarianceMatrix());
    ph.SetUpdateProposalParameters(true);
    ph.SetCacheSize(100);
    ProposalFunction* pdfProp = ph.GetProposalFunction();  // that was easy

    MCMCCalculator mc(*data, modelConfig);
    mc.SetNumIters(20000); // steps to propose in the chain
    mc.SetTestSize(.05); // 95% CL
    mc.SetNumBurnInSteps(40); // ignore first N steps in chain as "burn in"
    mc.SetProposalFunction(*pdfProp);
    mc.SetLeftSideTailFraction(0.5);  // find a "central" interval
    MCMCInterval* mcInt = (MCMCInterval*)mc.GetInterval();  // that was easy


    // Get Lower and Upper limits from Profile Calculator
    cout << "Profile lower limit on s = " << ((LikelihoodInterval*) lrinterval)->LowerLimit(*s) << endl;
    cout << "Profile upper limit on s = " << ((LikelihoodInterval*) lrinterval)->UpperLimit(*s) << endl;

    // Get Lower and Upper limits from FeldmanCousins with profile construction
    if (fcint != NULL) {
        double fcul = ((PointSetInterval*) fcint)->UpperLimit(*s);
        double fcll = ((PointSetInterval*) fcint)->LowerLimit(*s);
        cout << "FC lower limit on s = " << fcll << endl;
        cout << "FC upper limit on s = " << fcul << endl;
        TLine* fcllLine = new TLine(fcll, 0, fcll, 1);
        TLine* fculLine = new TLine(fcul, 0, fcul, 1);
        fcllLine->SetLineColor(kRed);
        fculLine->SetLineColor(kRed);
        fcllLine->Draw("same");
        fculLine->Draw("same");
        dataCanvas->Update();
    }

    // Plot MCMC interval and print some statistics
    MCMCIntervalPlot mcPlot(*mcInt);
    mcPlot.SetLineColor(kMagenta);
    mcPlot.SetLineWidth(2);
    mcPlot.Draw("same");

    double mcul = mcInt->UpperLimit(*s);
    double mcll = mcInt->LowerLimit(*s);
    cout << "MCMC lower limit on s = " << mcll << endl;
    cout << "MCMC upper limit on s = " << mcul << endl;
    cout << "MCMC Actual confidence level: "
         << mcInt->GetActualConfidenceLevel() << endl;

    // 3-d plot of the parameter points
    dataCanvas->cd(2);
    // also plot the points in the markov chain
    RooDataSet * chainData = mcInt->GetChainAsDataSet();

    assert(chainData);
    std::cout << "plotting the chain data - nentries = " << chainData->numEntries() << std::endl;
    TTree* chain =  RooStats::GetAsTTree("chainTreeData","chainTreeData",*chainData);
    assert(chain);
    chain->SetMarkerStyle(6);
    chain->SetMarkerColor(kRed);

    chain->Draw("s:ratioSigEff:ratioBkgEff","nll_MarkovChain_local_","box"); // 3-d box proportional to posterior

    // the points used in the profile construction
    RooDataSet * parScanData = (RooDataSet*) fc.GetPointsToScan();
    assert(parScanData);
    std::cout << "plotting the scanned points used in the frequentist construction - npoints = " << parScanData->numEntries() << std::endl;
    // getting the tree and drawing it -crashes (very strange....);
    // TTree* parameterScan =  RooStats::GetAsTTree("parScanTreeData","parScanTreeData",*parScanData);
    // assert(parameterScan);
    // parameterScan->Draw("s:ratioSigEff:ratioBkgEff","","goff");
    TGraph2D *gr = new TGraph2D(parScanData->numEntries());
    for (int ievt = 0; ievt < parScanData->numEntries(); ++ievt) {
        const RooArgSet * evt = parScanData->get(ievt);
        double x = evt->getRealValue("ratioBkgEff");
        double y = evt->getRealValue("ratioSigEff");
        double z = evt->getRealValue("s");
        gr->SetPoint(ievt, x,y,z);
        // std::cout << ievt << "  " << x << "  " << y << "  " << z << std::endl;
    }
    gr->SetMarkerStyle(24);
    gr->Draw("P SAME");


    delete wspace;
    delete lrinterval;
    delete mcInt;
    delete fcint;
    delete data;

    // print timing info
    t.Stop();
    t.Print();
}
开发者ID:Y--,项目名称:root,代码行数:101,代码来源:rs101_limitexample.C


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