コード例 #1
0
ファイル: utilities.cpp プロジェクト: ald77/ra4_draw
TString RoundNumber(double num, int decimals, double denom) {
    if(denom==0 || !isfinite(num) || !isfinite(denom)) return " - ";
    double neg = 1;
    if(num*denom<0) neg = -1;
    num /= neg*denom;
    num += 0.5*pow(10.,-decimals);
    if(abs(num) > 1e16) return "-";
    long num_int = static_cast<long>(num);
    long num_dec = static_cast<long>((1+num-num_int)*pow(10.,decimals));
    TString s_dec = "";
    s_dec += num_dec;
    s_dec.Remove(0,1);
    TString result="";
    if(neg<0) result+="-";
    result+= num_int;
    if(decimals>0) {
        result+=".";
        result+=s_dec;
    }

    TString afterdot = result;
    afterdot.Remove(0,afterdot.First(".")+1);
    for(int i=0; i<decimals-afterdot.Length(); i++)
        result += "0";
    if(result.Length()>15) cout<<"num "<<num<<", denom "<<denom<<"  ---->  "<<result<<endl;
    return result;
}
コード例 #2
0
ファイル: runFindSource.C プロジェクト: asmagina1995/roottest
void FindAny(bool found, const TString& fsname, TClass* cl, TString baseexpected, const char* ext, const char* tag) {

   if (baseexpected == "") {
      baseexpected = cl->GetName();
      Ssiz_t posCol = baseexpected.First('<');
      if (posCol != -1) {
         baseexpected.Remove(posCol, baseexpected.Length());
      }
      posCol = baseexpected.Last(':');
      if (posCol != -1) {
         baseexpected.Remove(0, posCol + 1);
      }
      baseexpected += ext;
   }

   if (!found) {
      if (baseexpected != "FAIL") {
         printf("FAIL: %s file for class %s not found\n", tag, cl->GetName());
      }
      return;
   } else {
      if (baseexpected == "FAIL") {
         printf("FAIL: expected to not find %s file for class %s but got %s\n",
                tag, cl->GetName(), fsname.Data());
         return;
      }
   }
   if (!fsname.EndsWith(baseexpected)) {
      printf("FAIL: class %s expected %s file %s, got %s\n",
             cl->GetName(), tag, baseexpected.Data(), fsname.Data());
      return;
   }
}
コード例 #3
0
ファイル: runLocal.C プロジェクト: bartbutler/ProofAna
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);
}
コード例 #4
0
ファイル: tag.C プロジェクト: JanFSchulte/monalisa
//_____________________________________//
GetVersions(TString &fAliroot, TString &froot, TString &fgeant) {
  const char* fver = gSystem->Getenv("ALIEN_JDL_PACKAGES");
  TString fS = fver;
  Int_t fFirst = fS.First("#");

  while(fFirst != -1) {
    Int_t fTotalLength = fS.Length();
    TString tmp = fS;
    TString fS1 = fS(0,fFirst);
    tmp = fS(fFirst+2,fTotalLength);
    fS = tmp;

    if(fS1.Contains("Root")) fAliroot = fS1;
    if(fS1.Contains("ROOT")) froot = fS1;
    if(fS1.Contains("GEANT")) fgeant = fS1;

    if(tmp.Contains("Root")) fAliroot = tmp;
    if(tmp.Contains("ROOT")) froot = tmp;
    if(tmp.Contains("GEANT")) fgeant = tmp;
    
    fFirst = tmp.First("#");
  }
}
コード例 #5
0
TString round(double n, int e, double d){
  if(d==0) return " - ";
  double b = (int)(n/d*pow(10,e)+0.5);
  b /= pow(10,e);
  TString result; result+= b;
  result.ReplaceAll(" ","");
  if(!result.Contains(".") && e != 0) result += ".";
  
  TString afterdot = result;
  afterdot.Remove(0,afterdot.First(".")+1);
  for(int i=0; i<e-afterdot.Length(); i++)
    result += "0";
  return result;
}
コード例 #6
0
ファイル: higgs_plots.cpp プロジェクト: manuelfs/babar_code
TString HiggsPlot::RoundNumber(double n, int e, double d){
  if(d==0) return " - ";
  double neg = 1; if(n*d<0) neg = -1;
  double b = static_cast<int>(neg*n/d*pow(10.,static_cast<double>(e))+0.5);
  b /= pow(10.,static_cast<double>(e))*neg;
  TString result; result+= b;
  result.ReplaceAll(" ","");
  if(!result.Contains(".") && e != 0) result += ".";
  
  TString afterdot = result;
  afterdot.Remove(0,afterdot.First(".")+1);
  for(int i=0; i<e-afterdot.Length(); i++)
    result += "0";
  return result;
}
コード例 #7
0
void Draw_BDiJetImbalance()
{
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);

  //==========================================================================//
  // SET RUNNING CONDITIONS
  //==========================================================================//
  bool print_plots = true;

  bool is_pp = false;

  // const char* inFile = "HFtag_bjet.root";
  // const char* inFile = "HFtag_bjet_pp.root";
  // const char* inFile = "/phenix/plhf/dcm07e/sPHENIX/bjetsims/test.root";
  // if (!is_pp)
  //   const char* inFile = "HFtag_bjet_AuAu0-10.root";

  const char* inDir = "/phenix/plhf/dcm07e/sPHENIX/bjetsims/ana";

  // // desired nn integrated luminosity [pb^{-1}]
  // double lumiDesired = 175;
  // if ( !is_pp )
  //   lumiDesired = 229; // AuAu 0-10% central (10B events)
  // desired nn integrated luminosity [pb^{-1}]
  double lumiDesired = 200;
  TString scol("p + p #sqrt{s_{_{NN}}} = 200 GeV");
  TString slumi(Form("#int L dt = %.0f pb^{-1} |z| < 10 cm", lumiDesired));
  if ( !is_pp )
  {
    // equivelant nn luminosity:
    // N_{evt}^{NN} / sigma_NN = N_{evt}^{AA}*Ncoll / sigma_NN
    // = 10e9 * 962 / 42e9 pb = 229 pb^-1
    double evntDesired = 24e9; // AuAu 0-10% central
    lumiDesired = evntDesired * 962 / 42e9; // AuAu 0-10% central
    scol = "0-10% Au + Au #sqrt{s_{_{NN}}}=200 GeV";
    slumi = Form("%.0fB events |z| < 10 cm", evntDesired / 1.e9);
  }

  // luminosity per file generated [pb^{-1}]
  double lumiPerFile = 99405 / (4.641e-06 * 1e12);
  double lumiRead = 0;

  double pT1min = 20;
  double pT2min = 10;
  // double etamax = 1.0;
  double etamax = 0.7;

  // double bJetEff = 0.5; // b-jet tagging efficiency
  double bJetEff = 0.60; // p+p b-jet tagging efficiency
  if ( !is_pp )
    bJetEff = 0.40;

  double bJetPur = 0.40; // b-jet tagging purity

  double RAA = 1.0;
  if (!is_pp)
    RAA = 0.6;

  const int NETACUT = 3;
  double etacut[] = {1.3, 1.0, 0.7};
  double etaColor[] = {kBlue, kRed, kBlack};

  const int PTCUT = 3;
  double ptcut[] = {10, 20, 40};
  double ptColor[] = {kBlue, kRed, kBlack};

  //==========================================================================//
  // DECLARE VARIABLES
  //==========================================================================//

  //-- tree variables
  TChain *ttree;
  Int_t           event;
  Int_t           truthjet_n;
  Int_t           truthjet_parton_flavor[100];
  Int_t           truthjet_hadron_flavor[100];
  Float_t         truthjet_pt[100];
  Float_t         truthjet_eta[100];
  Float_t         truthjet_phi[100];

  //-- histograms

  TH1D* hjet_pT = new TH1D("hjet_pT", ";p_{T}^{jet} [GeV/c]", 20, 0, 100);
  TH1D* hjet_eta = new TH1D("hjet_eta", ";#eta^{jet}", 40, -2., 2.);
  TH1D* hjet_phi = new TH1D("hjet_phi", ";#phi^{jet}", 40, -4, 4);

  TH1D* hdijet_pT1 = new TH1D("hdijet_pT1", ";p_{T,1}^{jet} [GeV/c]", 20, 0, 100);
  TH1D* hdijet_pT2 = new TH1D("hdijet_pT2", ";p_{T,2}^{jet} [GeV/c]", 20, 0, 100);
  TH1D* hdijet_xj = new TH1D("hdijet_xj", ";x_{j} = p_{T,2} / p_{T,1}; event fraction", 10, 0, 1);
  TH1D* hdijet_dphi = new TH1D("hdijet_dphi", ";|#Delta#phi_{12}|; event fraction", 10, 0, TMath::Pi());

  TH1D* hdijet_sing_pT1 = new TH1D("hdijet_sing_pT1",
                                   ";p_{T,1} [GeV/c];Fraction of Dijet / Single Accepted",
                                   20, 00, 100);
  TH1D* hdijet_sing_eta2 = new TH1D("hdijet_sing_eta2",
                                    ";#eta_{2};Fraction of Dijet / Single Accepted",
                                    15, -1.5, 1.5);
  TH1D* hdijet_eff_pT1[3];
  TH1D* hdijet_eff_eta2[3];
  for (int i = 0; i < NETACUT; i++)
  {
    hdijet_eff_pT1[i] = new TH1D(Form("hdijet_eff_pT1_%i", i),
                                 ";p_{T,1} [GeV/c];Fraction of Dijet / Single Accepted",
                                 20, 00, 100);
    hdijet_eff_pT1[i]->SetLineColor(etaColor[i]);
    hdijet_eff_pT1[i]->SetLineWidth(2);
  } // i
  for (int i = 0; i < PTCUT; i++)
  {
    hdijet_eff_eta2[i] = new TH1D(Form("hdijet_eff_eta2_%i", i),
                                  ";#eta;Fraction of Dijet / Single Accepted",
                                  15, -1.5, 1.5);
    hdijet_eff_eta2[i]->SetLineColor(etaColor[i]);
    hdijet_eff_eta2[i]->SetLineWidth(2);
  } // i

  hjet_pT->Sumw2();
  hjet_eta->Sumw2();
  hjet_phi->Sumw2();

  hdijet_pT1->Sumw2();
  hdijet_pT2->Sumw2();
  hdijet_dphi->Sumw2();
  hdijet_xj->Sumw2();

  // for fixing the uncertainties
  TH1D* hdijet_xj_fix;

  //-- other
  TRandom3 *rand = new TRandom3();

  bool acc[100];

  //==========================================================================//
  // LOAD TTREE
  //==========================================================================//
  // cout << endl;
  // cout << "--> Reading data from " << inFile << endl;

  // TFile *fin = TFile::Open(inFile);
  // if (!fin)
  // {
  //   cout << "ERROR!! Unable to open " << inFile << endl;
  //   return;
  // }

  // ttree = (TTree*) fin->Get("ttree");
  // if (!ttree)
  // {
  //   cout << "ERROR!! Unable to find ttree in " << inFile << endl;
  //   return;
  // }

  cout << endl;
  cout << "--> Reading data from dir: " << inDir << endl;

  // calculate the number of files necessary for the desired luminosity
  int nfiles = (int)(lumiDesired / lumiPerFile);
  cout << "  desired luminosity : " << lumiDesired << endl;
  cout << "  luminosity per file: " << lumiPerFile << endl;
  cout << "  N files needed     : " << nfiles << endl;


  // check the number of files found in the directory
  int nfound = (gSystem->GetFromPipe(Form("ls %s/*.root | wc -l", inDir))).Atoi();
  cout << "  N files found      : " << nfound << endl;

  if (nfound < nfiles)
  {
    cout << "WARNING!! There are not enough files for the desired luminosity." << endl;
    cout << "          Will scale the statistical uncertainties accordingly." << endl;
    // return;
  }

  // chain the desired files
  ttree = new TChain("ttree");
  int nread = 0;

  TString fileList = gSystem->GetFromPipe(Form("ls %s/*.root", inDir));

  int spos = fileList.First("\n");
  while (spos > 0 && nread < nfiles)
  {
    TString tfile = fileList(0, spos);
    // cout << tsub << endl;

    ttree->Add(tfile.Data());


    // chop off the file
    fileList = fileList(spos + 1, fileList.Length());
    spos = fileList.First("\n");
    nread++;
  }

  cout << " successfully read in " << nread << " files" << endl;
  lumiRead = lumiPerFile * nread;


  ttree->SetBranchAddress("event", &event);
  ttree->SetBranchAddress("truthjet_n", &truthjet_n);
  ttree->SetBranchAddress("truthjet_parton_flavor", truthjet_parton_flavor);
  ttree->SetBranchAddress("truthjet_hadron_flavor", truthjet_hadron_flavor);
  ttree->SetBranchAddress("truthjet_pt", truthjet_pt);
  ttree->SetBranchAddress("truthjet_eta", truthjet_eta);
  ttree->SetBranchAddress("truthjet_phi", truthjet_phi);

  Long64_t nentries = ttree->GetEntries();


  //==========================================================================//
  // GET MOMENTUM IMBALANCE
  //==========================================================================//
  cout << endl;
  cout << "--> Running over " << nentries << endl;

  int iprint = 0;
  for (Long64_t ientry = 0; ientry < nentries; ientry++)
  {
    ttree->GetEntry(ientry);

    if (ientry % 100000 == 0) cout << "----> Processing event " << ientry << endl;

    //-- apply acceptance to each jet
    for (int i = 0; i < truthjet_n; i++)
      acc[i] = (rand->Uniform() < bJetEff);
      // acc[i] = (rand->Uniform() < bJetEff) && (rand->Uniform() < RAA);

    //-- get kinematics for all b-jets
    for (int i = 0; i < truthjet_n; i++)
    {
      if (TMath::Abs(truthjet_parton_flavor[i]) != 5)
        continue;

      // single b-jet kinematics
      hjet_pT->Fill(truthjet_pt[i]);
      hjet_eta->Fill(truthjet_eta[i]);
      hjet_phi->Fill(truthjet_phi[i]);

      for (int j = i + 1; j < truthjet_n; j++)
      {
        if (TMath::Abs(truthjet_parton_flavor[j]) != 5)
          continue;


        // find the leading and subleading jets
        int i1, i2;
        double pT1, pT2;
        double phi1, phi2;
        double eta1, eta2;
        bool acc1, acc2;

        if (truthjet_pt[i] > truthjet_pt[j])
        {
          i1 = i;
          i2 = j;
        }
        else
        {
          i1 = j;
          i2 = i;
        }

        pT1 = truthjet_pt[i1];
        phi1 = truthjet_phi[i1];
        eta1 = truthjet_eta[i1];
        acc1 = acc[i1];

        pT2 = truthjet_pt[i2];
        phi2 = truthjet_phi[i2];
        eta2 = truthjet_eta[i2];
        acc2 = acc[i2];



        if (iprint < 20)
        {
          cout << " ientry: " << ientry << endl
               << "        i1:" << i1 << " pT1:" << pT1 << " eta1:" << eta1 << " acc1:" << acc1 << endl
               << "        i2:" << i2 << " pT2:" << pT2 << " eta2:" << eta2 << " acc2:" << acc2 << endl;
          iprint++;
        }



        // check if we accept the leading jet
        // only take RAA hit once
        if ( pT1 < pT1min || TMath::Abs(eta1) > etamax || !acc1  || rand->Uniform() > RAA)
          continue;

        // calculate the delta phi
        double dphi = TMath::Abs(TMath::ATan2(TMath::Sin(phi1 - phi2), TMath::Cos(phi1 - phi2)));
        if (dphi > TMath::Pi())
          cout << " " << truthjet_phi[i] << " " << truthjet_phi[j] << " " << dphi << endl;

        // calculate efficiency for finding the dijet
        hdijet_sing_pT1->Fill(pT1);

        // cut on the subleading jet
        if ( pT2 < pT2min || TMath::Abs(eta2) > etamax || !acc2 )
          continue;

        hdijet_sing_eta2->Fill(eta2);


        // fill efficiency for finding the dijet
        for (int k = 0; k < NETACUT; k++)
        {
          if ( TMath::Abs(eta2) < etacut[k])
            hdijet_eff_pT1[k]->Fill(pT1);
        }
        for (int k = 0; k < PTCUT; k++)
        {
          if (pT2 > ptcut[k])
            hdijet_eff_eta2[k]->Fill(eta2);
        }

        hdijet_dphi->Fill(dphi);

        if ( dphi < 2.*TMath::Pi() / 3)
          continue;


        // fill diagnostic histograms

        hdijet_pT1->Fill(pT1);
        hdijet_pT2->Fill(pT2);
        hdijet_xj->Fill(pT2 / pT1);

      } // j
    } // i

  } // ientry

  // first get some statistics
  cout << " N b dijets: " << hdijet_dphi->Integral() << endl;
  cout << " N b dijets w / dphi cut: " << hdijet_xj->Integral() << endl;

  // calculate efficiencies
  for (int i = 0; i < NETACUT; i++)
  {
    hdijet_eff_pT1[i]->Divide(hdijet_sing_pT1);
    cout << " i: " << hdijet_eff_pT1[i]->GetMaximum() << endl;
  }
  for (int i = 0; i < PTCUT; i++)
  {
    hdijet_eff_eta2[i]->Divide(hdijet_sing_eta2);
  }

  //-- normalize to integral 1
  hdijet_dphi->Scale(1. / hdijet_dphi->Integral());
  hdijet_xj->Scale(1. / hdijet_xj->Integral());

  //-- scale statistical uncertainties if not enough simulated events
  if ( lumiRead < lumiDesired )
  {
    cout << endl;
    cout << "-- Scaling statistical uncertainties by:" << endl;
    cout << "  sqrt(" << lumiRead << "/" << lumiDesired << ") = "
         << TMath::Sqrt(lumiRead / lumiDesired) << endl;
    for (int ix = 1; ix <= hdijet_xj->GetNbinsX(); ix++)
    {
      double be = hdijet_xj->GetBinError(ix);
      be = be * TMath::Sqrt(lumiRead / lumiDesired);
      hdijet_xj->SetBinError(ix, be);
    } // ix
  }

  //-- fix statistical uncertainties for purity
  hdijet_xj_fix = (TH1D*) hdijet_xj->Clone("hdijet_xj_fix");
  hdijet_xj_fix->SetLineColor(kRed);
  hdijet_xj_fix->SetMarkerColor(kRed);
  for (int ix = 1; ix <= hdijet_xj->GetNbinsX(); ix++)
  {
    double bc = hdijet_xj->GetBinContent(ix);
    double be = hdijet_xj->GetBinError(ix);

    // increase the bin error due to the purity
    // need to square it, once for each bjet
    be = be / TMath::Sqrt(bJetPur * bJetPur);
    hdijet_xj_fix->SetBinError(ix, be);
  } // ix



  //==========================================================================//
  // <x_j>
  //==========================================================================//
  cout << endl;
  cout << "--> Calculating <x_j>" << endl;

  double sum = 0;
  double w = 0;
  double err = 0;
  for (int i = 1; i <= hdijet_xj->GetNbinsX(); i++)
  {
    double c = hdijet_xj->GetBinContent(i);
    if (c > 0)
    {
      sum += c * hdijet_xj->GetBinCenter(i);
      w += c;
      err += TMath::Power(c * hdijet_xj->GetBinError(i), 2);
    }
  }
  double mean = sum / w;
  err = TMath::Sqrt(err) / w;

  cout << "  <x_j>=" << mean << " +/- " << err << endl;

  //==========================================================================//
  // PLOT OBJECTS
  //==========================================================================//
  cout << endl;
  cout << "-- > Plotting" << endl;

  hdijet_xj->SetMarkerStyle(kFullCircle);
  hdijet_xj->SetMarkerColor(kBlack);
  hdijet_xj->SetLineColor(kBlack);
  // hdijet_xj->GetYaxis()->SetTitleFont(63);
  // hdijet_xj->GetYaxis()->SetTitleSize(24);
  // hdijet_xj->GetYaxis()->SetTitleOffset(1.4);
  // hdijet_xj->GetYaxis()->SetLabelFont(63);
  // hdijet_xj->GetYaxis()->SetLabelSize(20);
  // hdijet_xj->GetXaxis()->SetTitleFont(63);
  // hdijet_xj->GetXaxis()->SetTitleSize(24);
  // hdijet_xj->GetXaxis()->SetTitleOffset(1.0);
  // hdijet_xj->GetXaxis()->SetLabelFont(63);
  // hdijet_xj->GetXaxis()->SetLabelSize(20);

  hdijet_xj_fix->SetMarkerStyle(kFullCircle);
  hdijet_xj_fix->SetMarkerColor(kBlack);
  hdijet_xj_fix->SetLineColor(kBlack);

  hdijet_dphi->SetMarkerStyle(kFullCircle);
  hdijet_dphi->SetMarkerColor(kBlack);
  hdijet_dphi->SetLineColor(kBlack);
  hdijet_dphi->GetYaxis()->SetTitleFont(63);
  hdijet_dphi->GetYaxis()->SetTitleSize(24);
  hdijet_dphi->GetYaxis()->SetTitleOffset(1.4);
  hdijet_dphi->GetYaxis()->SetLabelFont(63);
  hdijet_dphi->GetYaxis()->SetLabelSize(20);
  hdijet_dphi->GetXaxis()->SetTitleFont(63);
  hdijet_dphi->GetXaxis()->SetTitleSize(24);
  hdijet_dphi->GetXaxis()->SetTitleOffset(1.0);
  hdijet_dphi->GetXaxis()->SetLabelFont(63);
  hdijet_dphi->GetXaxis()->SetLabelSize(20);

  hdijet_pT1->SetLineColor(kBlue);
  hdijet_pT2->SetLineColor(kRed);

  TH1D* heff_axis_pt = new TH1D("heff_axis_pt",
                                "; p_{T, 1} [GeV / c]; Fraction of Dijet / Single Accepted",
                                20, 00, 100);
  heff_axis_pt->SetMinimum(0);
  heff_axis_pt->SetMaximum(1.);
  heff_axis_pt->GetYaxis()->SetTitleFont(63);
  heff_axis_pt->GetYaxis()->SetTitleSize(24);
  heff_axis_pt->GetYaxis()->SetTitleOffset(1.4);
  heff_axis_pt->GetYaxis()->SetLabelFont(63);
  heff_axis_pt->GetYaxis()->SetLabelSize(20);
  heff_axis_pt->GetXaxis()->SetTitleFont(63);
  heff_axis_pt->GetXaxis()->SetTitleSize(24);
  heff_axis_pt->GetXaxis()->SetTitleOffset(1.0);
  heff_axis_pt->GetXaxis()->SetLabelFont(63);
  heff_axis_pt->GetXaxis()->SetLabelSize(20);

  TH1D* heff_axis_eta = new TH1D("heff_axis_eta",
                                 "; #eta_{2}; Fraction of Dijet / Single Accepted",
                                 150, -1.5, 1.5);
  heff_axis_eta->SetMinimum(0);
  heff_axis_eta->SetMaximum(1.);
  heff_axis_eta->GetYaxis()->SetTitleFont(63);
  heff_axis_eta->GetYaxis()->SetTitleSize(24);
  heff_axis_eta->GetYaxis()->SetTitleOffset(1.4);
  heff_axis_eta->GetYaxis()->SetLabelFont(63);
  heff_axis_eta->GetYaxis()->SetLabelSize(20);
  heff_axis_eta->GetXaxis()->SetTitleFont(63);
  heff_axis_eta->GetXaxis()->SetTitleSize(24);
  heff_axis_eta->GetXaxis()->SetTitleOffset(1.0);
  heff_axis_eta->GetXaxis()->SetLabelFont(63);
  heff_axis_eta->GetXaxis()->SetLabelSize(20);

  for (int i = 0; i < NETACUT; i++)
    hdijet_eff_pT1[i]->SetLineColor(etaColor[i]);

//-- legends
  TLegend *leg_jetpt = new TLegend(0.6, 0.5, 0.95, 0.95);
  leg_jetpt->SetFillStyle(0);
  leg_jetpt->SetBorderSize(0);
  leg_jetpt->SetTextFont(63);
  leg_jetpt->SetTextSize(12);
  leg_jetpt->AddEntry(hjet_pT, "Inclusive b - jet", "L");
  leg_jetpt->AddEntry(hdijet_pT1, "leading b - jet", "L");
  leg_jetpt->AddEntry(hdijet_pT2, "subleading b - jet", "L");


//-- other
  TLatex ltxt;
  ltxt.SetNDC();
  ltxt.SetTextFont(63);
  ltxt.SetTextSize(20);

//==========================================================================//
// PLOT
//==========================================================================//

// plot b-jet kinematics
  TCanvas *cjet = new TCanvas("cjet", "b - jet", 1200, 400);
  cjet->SetMargin(0, 0, 0, 0);
  cjet->Divide(3, 1);

  cjet->GetPad(1)->SetMargin(0.12, 0.02, 0.12, 0.02);
  cjet->GetPad(2)->SetMargin(0.12, 0.02, 0.12, 0.02);
  cjet->GetPad(3)->SetMargin(0.12, 0.02, 0.12, 0.02);

  cjet->cd(1);
  gPad->SetLogy();
  hjet_pT->GetYaxis()->SetRangeUser(0.5, 1.5 * hjet_pT->GetMaximum());
  hjet_pT->GetXaxis()->SetRangeUser(0, 50);
  hjet_pT->Draw();
  // hdijet_pT1->Draw("same");
  // hdijet_pT2->Draw("same");

  // leg_jetpt->Draw("same");

  cjet->cd(2);
  hjet_eta->Draw("HIST");

  cjet->cd(3);
  hjet_phi->Draw("HIST");


// plot dijet eff
  TCanvas *ceff = new TCanvas("ceff", "eff", 1200, 600);
  ceff->Divide(2, 1);
  ceff->GetPad(1)->SetMargin(0.12, 0.02, 0.12, 0.02);
  ceff->GetPad(1)->SetTicks(1, 1);
  ceff->GetPad(2)->SetMargin(0.12, 0.02, 0.12, 0.02);
  ceff->GetPad(2)->SetTicks(1, 1);

  ceff->cd(1);

  heff_axis_pt->Draw();

  for (int i = 0; i < NETACUT; i++)
    hdijet_eff_pT1[i]->Draw("L same");

  ceff->cd(2);

  heff_axis_eta->Draw();

  for (int i = 0; i < NETACUT; i++)
    hdijet_eff_eta2[i]->Draw("L same");

// plot dijet checks
  TCanvas *cdijet2 = new TCanvas("cdijet2", "dijet", 1200, 600);
  cdijet2->SetMargin(0, 0, 0, 0);
  cdijet2->Divide(2, 1);

  cdijet2->GetPad(1)->SetMargin(0.12, 0.02, 0.12, 0.02);
  cdijet2->GetPad(2)->SetMargin(0.12, 0.02, 0.12, 0.02);

  cdijet2->cd(1);
  hdijet_xj->Draw();

  ltxt.DrawLatex(0.2, 0.92, "Di b-jets (Pythia8)");
  ltxt.DrawLatex(0.2, 0.86, "p + p #sqrt{s_{_{NN}}}=200 GeV");
  ltxt.DrawLatex(0.2, 0.80, "anti - k_ {T}, R = 0.4");
  ltxt.DrawLatex(0.2, 0.74, Form("p_{T, 1} > % .0f GeV", pT1min));
  ltxt.DrawLatex(0.2, 0.68, Form("p_{T, 2} > % .0f GeV", pT2min));
  ltxt.DrawLatex(0.2, 0.62, Form(" | #Delta#phi_{12}| > 2#pi/3"));

  cdijet2->cd(2);
  hdijet_dphi->Draw();






  // make this one consistent with sPHENIX style
  TCanvas *cdijet = new TCanvas("cdijet", "dijet", 600, 600);
  // cdijet->SetMargin(0.12, 0.02, 0.12, 0.02);
  // cdijet->SetTicks(1, 1);
  cdijet->cd();
  hdijet_xj_fix->GetYaxis()->SetRangeUser(0, 0.3);
  hdijet_xj_fix->Draw();
  // hdijet_xj->Draw("same");


  TLegend *legsphenix = new TLegend(0.15, 0.5, 0.5, 0.9);
  legsphenix->SetFillStyle(0);
  legsphenix->SetBorderSize(0);
  legsphenix->AddEntry("", "#it{#bf{sPHENIX}} Simulation", "");
  legsphenix->AddEntry("", "Di b-jets (Pythia8, CTEQ6L)", "");
  // if (is_pp)
  // {
  //   legsphenix->AddEntry("", "p + p #sqrt{s_{_{NN}}} = 200 GeV", "");
  //   legsphenix->AddEntry("", Form("#int L dt = %.0f pb^{-1} |z| < 10 cm", lumiDesired), "");
  // }
  // else
  // {
  //   legsphenix->AddEntry("", "0-10% Au + Au #sqrt{s_{_{NN}}}=200 GeV", "");
  //   legsphenix->AddEntry("", "10B events |z| < 10 cm", "");
  // }
  legsphenix->AddEntry("", scol.Data(), "");
  legsphenix->AddEntry("", slumi.Data(), "");
  legsphenix->AddEntry("", "anti-k_{T}, R = 0.4", "");
  legsphenix->AddEntry("", Form(" |#eta| < %.1f", etamax), "");
  legsphenix->AddEntry("", Form(" |#Delta#phi_{12}| > 2#pi/3"), "");
  legsphenix->AddEntry("", Form("p_{T, 1} > % .0f GeV", pT1min), "");
  legsphenix->AddEntry("", Form("p_{T, 2} > % .0f GeV", pT2min), "");
  legsphenix->AddEntry("", Form("%.0f%% b-jet Eff, %.0f%% b-jet Pur.", bJetEff * 100., bJetPur * 100.), "");
  legsphenix->Draw("same");

  // ltxt.DrawLatex(0.2, 0.92, "Di b-jets (Pythia8)");
  // if (is_pp)
  // {
  //   ltxt.DrawLatex(0.2, 0.86, "p + p #sqrt{s_{_{NN}}} = 200 GeV");
  //   ltxt.DrawLatex(0.2, 0.80, "#int L dt = 175 pb^{-1} |z| < 10 cm");
  // }
  // else
  // {
  //   ltxt.DrawLatex(0.2, 0.86, "0-10% Au + Au #sqrt{s_{_{NN}}}=200 GeV");
  //   ltxt.DrawLatex(0.2, 0.80, "10B events |z| < 10 cm");
  // }
  // ltxt.DrawLatex(0.2, 0.74, "anti-k_{T}, R = 0.4");
  // ltxt.DrawLatex(0.2, 0.68, Form("p_{T, 1} > % .0f GeV", pT1min));
  // ltxt.DrawLatex(0.2, 0.62, Form("p_{T, 2} > % .0f GeV", pT2min));
  // ltxt.DrawLatex(0.2, 0.56, Form(" |#eta| < %.0f", etamax));
  // ltxt.DrawLatex(0.2, 0.50, Form(" |#Delta#phi_{12}| > 2#pi/3"));


  //==========================================================================//
  // PRINT PLOTS
  //==========================================================================//
  if (print_plots)
  {
    if (is_pp)
    {
      // cjet->Print("bjet_kinematics_pp.pdf");
      // cdijet2->Print("dibjet_2panel_pp.pdf");
      cdijet->Print("dibjet_imbalance_pp.pdf");
      cdijet->Print("dibjet_imbalance_pp.C");
      cdijet->Print("dibjet_imbalance_pp.root");

      TFile *fout = new TFile("dibjet_imbalance_histos_pp.root","RECREATE");
      fout->cd();
      hdijet_xj->Write();
      hdijet_xj_fix->Write();
      fout->Close();
      delete fout;

    }
    else
    {
      cdijet->Print("dibjet_imbalance_AuAu0-10.pdf");
      cdijet->Print("dibjet_imbalance_AuAu0-10.C");
      cdijet->Print("dibjet_imbalance_AuAu0-10.root");

      TFile *fout = new TFile("dibjet_imbalance_histos_AuAu0-10.root","RECREATE");
      fout->cd();
      hdijet_xj->Write();
      hdijet_xj_fix->Write();
      fout->Close();
      delete fout;
    }
  }

}
コード例 #8
0
void bfcread_hist_extract(
  const Char_t *MainFile=
    "/afs/rhic.bnl.gov/star/data/samples/gstar.hist.root",
  const Char_t *MakerHistDir="EventQA",
  const Char_t *TopDirTree="bfcTree",
  Char_t *OutFile=0,
  const Char_t *PrintList="")
{

  cout << "bfcread_hist_extract.C, input hist file = " 
       << MainFile << endl;
  cout << "bfcread_hist_extract.C, directory name for hist = " 
       << MakerHistDir << endl;
  cout << "bfcread_hist_extract.C, top level directory in hist file = " 
       << TopDirTree << endl;

//
    gSystem->Load("St_base");
    gSystem->Load("StChain");
    gSystem->Load("StIOMaker");
    gSystem->Load("StarClassLibrary");
    gSystem->Load("StUtilities");
    gSystem->Load("StAnalysisUtilities");
    gSystem->Load("libglobal_Tables");

// setup chain with IOMaker - can read in .dst.root, .dst.xdf files
  StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,TopDirTree);
  IOMk->SetDebug();
  IOMk->SetIOMode("r");
  IOMk->SetBranch("*",0,"0");                 //deactivate all branches
  IOMk->SetBranch("histBranch",0,"r"); //activate dst Branch


// constructor for other maker (not used in chain)
   StHistUtil   *HU  = new StHistUtil;

// now must set pointer to StMaker so HistUtil can find histograms
//  with StHistUtil methods
// -- input any maker pointer but must cast as type StMaker
   HU->SetPntrToMaker((StMaker *)IOMk);

// ONLY use StIOMaker in chain 
// --- now execute chain member functions - 1 event (histograms) only
  IOMk->Init();
  IOMk->Clear();
  IOMk->Make();

// method to print out list of histograms
// - can do this anytime after they're booked
// - default is to print out QA hist branch
   Int_t NoHist=0;
   //NoHist = HU->ListHists(MakerHistDir);
   TList* dList = HU->FindHists(MakerHistDir);
   if (PrintList) HU->SetDefaultPrintList(MakerHistDir,PrintList);
   NoHist = HU->CopyHists(dList);
   TH1** nh = HU->getNewHist();

   TString name = MainFile;
   if (!OutFile) {
     name.Remove(0,name.Last('/')+1);
     TString name2 = MakerHistDir;
     name2.Remove(0,name2.Last('/')+1);
     name.Insert(name.First('.'),"_");
     name.Insert(name.First('.'),name2);
     OutFile = name.Data();
   }
   cout <<  "Output hist file: " << OutFile << endl;
   TFile* ofile = new TFile(OutFile,"RECREATE");
   for (int i=0; i<NoHist; i++) {
     printf("Extracting: %d. %s : %s\n",
       i+1,nh[i]->GetName(),nh[i]->GetTitle());
     nh[i]->Write();
   }
   ofile->Close();
      
}
コード例 #9
0
ファイル: GeomDraw.C プロジェクト: star-bnl/star-macros
//_____________________________________________________________________________________________________________
void GeomDraw(const char *fzFile="complete",Float_t bombFactor=1.4, const char *out = "")
{
   // Read the ZEBRA file with GEANT geometry
   // Convert it to TVolume format 
   // draw it out with OpenGL Viewer
  TString geomAccess = fzFile;
  TString geomKuipCmd;
  if (gSystem->AccessPathName(geomAccess.Data()) ) 
  {
     // Check 
     geomAccess.Strip(TString::kBoth);
     if (!geomAccess.CountChar(' ') && (geomAccess.First('y')==0 || geomAccess.First("complete") == 0 ) ) {
       geomKuipCmd = "detp geometry ";
       geomKuipCmd += geomAccess; geomAccess = "" ;
     } else {
          printf("\n *** Error ***   Wrong input parameter: <%s>\n", fzFile);
          GeomDrawUsage();
          return;              
     }
   }
   
  // Workaroung of STAR bug with ROOT 4.00.04
  //- TString unixLDPath = "$ROOT/$ROOT_LEVEL.qt/.$STAR_HOST_SYS/rootdeb/lib:";
  //-  unixLDPath += gEnv->GetValue("Root.DynamicPath","");
  //- gEnv->SetValue("Root.DynamicPath",unixLDPath.Data());
  //- gSystem->Load("$ROOT/$ROOT_LEVEL.qt/.$STAR_HOST_SYS/rootdeb/lib/libRQTGL.so");
  //- end of workaroung
  
  gSystem->Load("St_base");
  gSystem->Load("StChain");
  gSystem->Load("St_Tables");
  gSystem->Load("St_g2t.so");
  gSystem->Load("StarMagField");
  gSystem->Load("St_geant_Maker");  
  gSystem->Load("StUtilities");
  chain = new StChain(); 
  geant = new St_geant_Maker();
  geant->SetActive(kFALSE);
  if (! geomAccess.IsNull() ) {
     printf("\n ----------------------------------------------------------\n");
     printf(" Draw the GEANT geometry from <%s> file\n", geomAccess.Data());
     printf(" ----------------------------------------------------------\n\n");
     geant->SetInputFile(geomAccess.Data());
  } else {
     printf("\n ----------------------------------------------------------\n");
     printf(" Draw the GEANT generated geometry <%s> \n", geomKuipCmd.Data());
     printf(" ----------------------------------------------------------\n\n");
     gSystem->Load("geometry");
     geant->LoadGeometry(geomKuipCmd.Data());            
  }
  chain->Init();
  TVolume *v = (TVolume *)geant->Work();
  if (v) {
     // Make CAVE invisible
     TVolume *cave = (TVolume *)v->FindByName("CAVE");
     if (cave) cave->SetVisibility(2);
     TVolume *hall = (TVolume *)v->FindByName("HALL");
     GeomDrawUsage();
     if (hall) {
        hall->SetVisibility(2);
        new TBrowser("STAR Geometry", hall);
        if (bombFactor < 1)  bombFactor = 1.;
        gGeometry->SetBomb(bombFactor);        
        hall->Draw("6");        
        gPad->SetFillColor(kBlack);
    }
    gPad->Modified();
    gPad->Update();
    if (out && out[0]) {
       TFile outFile(out,"RECREATE");
       v->Write();
       outFile.Write();
       outFile.Close();      
    }   
  } else {
     fprintf(stderr,"\n\n, ** Error **, No suitable STAR geometry has been found. Abort !!! \n");   
  }
//  delete chain; chain = 0;
}
コード例 #10
0
ファイル: PlotSingle.C プロジェクト: manuelfs/babar_code
void PlotSingle(TString hname){
  TString sam = hname; sam.Remove(0,sam.First('_')+1);
  sam.Remove(sam.First('_'),sam.Length());
  TString smoo = hname;smoo.Remove(0,smoo.Last('_')+1);
  smoo.Remove(smoo.First('.'),smoo.Length());
  TString binString = hname; binString.Remove(binString.Last('_'),binString.Length());
  binString.Remove(0,binString.Last('_')+1);
  int nM2bin = binString.Atoi(); int nPlbin = nM2bin%1000;
  nM2bin = nM2bin/1000;
  TString basename(hname);
  Int_t slashpos = basename.Last('D');
  if (slashpos>=0) {
    basename.Remove(0,slashpos+1); basename.Remove(basename.First('.'),basename.Length());
  } else { cout<<hname<<" is incorrect"<<endl; return;}

  TString Base = "_"; Base += sam; Base += "_"; 
  Base += binString; Base += "_"; Base += smoo; 

  TFile hfile(hname); 
  TH2F *h2 = (TH2F *)gDirectory->Get("h2");
  TString inputfile = "fitSamples/pdfSample"; inputfile += sam; inputfile += ".root";
  cout << "File = " << inputfile << endl;	
  TChain c("ntp1");
  c.Add(inputfile);
  TCanvas mm("mm","KEYS fits to mmiss-pstarl",1200,800);
  double m2min = -4, m2max = 12, plmin = 0, plmax = 2.4;
  double xlow = m2min,xhigh = m2max, ylow = plmin,yhigh = plmax;
  Int_t nbinx = 80,nbiny = 80, Sam = sam.Atoi();
  if (Sam==0 || Sam==2 || Sam==10 || Sam==12 || Sam == 20 || Sam == 23 || Sam == 26 || Sam == 29) {
    xlow = -2; xhigh = 4;
    if (Sam > 12) {nbinx = 40; nbiny = 40;}
  } else if (Sam==1 || Sam==11) { xlow = -2; xhigh = 6;}
  if (Sam==6 || Sam==7 || Sam==16 || Sam==17) {nbinx = 40; nbiny = 40;}
  if (Sam==8 || Sam==18) {xhigh = 4; nbinx = 40; nbiny = 40;}
  if (Sam==9 || Sam==19) {nbinx = 40; nbiny = 40;}
  if (Sam==21 || Sam==22 || Sam==24 || Sam==25 || Sam==27 || Sam==28 || Sam==30 || Sam==31) {
    xhigh = 8; nbinx = 40; nbiny = 20;}
  if (Sam > 31) {nbinx = 40; nbiny = 20;}
  if(Sam==0){xlow=-1; xhigh=1;}
  double entries = c.GetEntries();
  Double_t hIntegral=h2->Integral();

  TString M2titles[] = {"0 < p*_{l} < 1 GeV","1 < p*_{l} < 1.4 GeV","1.4 < p*_{l} < 1.8 GeV",
		      "1.8 < p*_{l} < 2.4 GeV","0 < p*_{l} < 2.4 GeV"};
  TString Pltitles[] = {"-4 < m^{2}_{miss} < 1 GeV^{2}","1 < m^{2}_{miss} < 12 GeV^{2}",
			"-4 < m^{2}_{miss} < 12 GeV^{2}"};
  TCut M2cuts[] = {"candPstarLep<1","candPstarLep>1&&candPstarLep<1.4",
		      "candPstarLep>1.4&&candPstarLep<1.8","candPstarLep>1.8&&candPstarLep<2.4", ""};
  TCut Plcuts[] = {"candM2<1","candM2>=1",""};
  double PlLimits[] = {0, 1, 1.4, 1.8, 2.4};
  double M2Limits[] = {0., 5., 16.};
  int binlim[5]; int plbinlim[3];
  for(int i=0;i<5;i++) {
    PlLimits[i] = PlLimits[i]/2.4*(double)nPlbin;
    binlim[i] = (int)PlLimits[i];
    if(i<3){
      M2Limits[i] = M2Limits[i]/16.*(double)nM2bin;
      plbinlim[i] = (int)M2Limits[i];
    }
  }

  TString psname = "AWG82/results/keys/eps/Stitch/epsKeys"; psname += Base; psname += ".ps";
  mm.Print(psname+"[");
  TH1F *hm2[5], *m2[5], *hpl[3], *pl[3];
  TString M2names[5], Plnames[3];
  for(int i=0;i<5;i++){
    M2names[i] = "hm2_"; M2names[i] += i;
    hm2[i] = new TH1F(M2names[i],M2titles[i],nM2bin,m2min,m2max); 
    if(i<3) {
      Plnames[i] = "hpl_"; Plnames[i] += i;
      hpl[i] = new TH1F(Plnames[i],Pltitles[i],nPlbin,plmin,plmax); 
    }
  }
  
  hIntegral = h2->Integral();
  for(int i=0;i<5;i++){
    TString hdname = "dm2"; hdname += i;
    TString vari = "candM2>>"; vari+=hdname; vari+="("; vari+= nbinx; vari+=",";vari+= xlow; 
    vari+=",";vari+= xhigh; vari+=")";
    //M2cuts[i] += "weight<100";M2cuts[i] *= "wFF";
    c.Draw(vari,M2cuts[i]);
    m2[i] = (TH1F*)gDirectory->Get(hdname);
    m2[i]->SetXTitle("m^{2}_{miss} [GeV^{2}]");
    formatHisto(m2[i]);
    gStyle->SetOptStat(0);
    if(i<4){
      for(int j=1; j<nM2bin+1; j++){
	double binVal = 0;
	for(int binp = binlim[i]+1; binp < binlim[i+1]+1; binp++){
	  binVal+=h2->GetBinContent(j,binp)*entries*nM2bin*(xhigh-xlow)/nbinx/(m2max-m2min)/hIntegral;
	}
	hm2[i]->SetBinContent(j,binVal);
      }
    } 
    hm2[i]->SetLineColor(4);
    hm2[i]->SetLineWidth(1);
    if(i<4) hm2[4]->Add(hm2[i]);
  }
  for(int i=0;i<3;i++){
    TString hdname = "pl"; hdname += i;
    TString vari = "candPstarLep>>"; vari+=hdname; vari+="("; vari+= nbiny; vari+=",";vari+= ylow; 
    vari+=",";vari+= yhigh; vari+=")";
    cout<<vari<<"  "<<endl;
    //Plcuts[i] += "weight<100";Plcuts[i] *= "wFF";
    c.Draw(vari,Plcuts[i]);
    pl[i] = (TH1F*)gDirectory->Get(hdname);
    pl[i]->SetXTitle("p*_{l} [GeV]");
    formatHisto(pl[i]);
    gStyle->SetOptStat(0);
    if(i<2){
      for(int j=1; j<nPlbin+1; j++){
	double binVal = 0;
	for(int binp = plbinlim[i]+1; binp < plbinlim[i+1]+1; binp++){
	  binVal += h2->GetBinContent(binp,j)*entries*nPlbin/nbiny/hIntegral;	
	}
	hpl[i]->SetBinContent(j,binVal);
      }
    }
    hpl[i]->SetLineColor(4);
    hpl[i]->SetLineWidth(1);
    if(i<2) hpl[2]->Add(hpl[i]);
  }
  cout<<"End for"<<endl;
  m2[4]->Draw("e0"); m2[4]->Draw("e1 same"); hm2[4]->Draw("c same"); mm.Print(psname);
  pl[2]->Draw("e0"); pl[2]->Draw("e1 same"); hpl[2]->Draw("c same"); mm.Print(psname);
  for(int i=0;i<4;i++){
    m2[i]->Draw("e0"); m2[i]->Draw("e1 same"); hm2[i]->Draw("c same"); mm.Print(psname);
  }
  for(int i=0;i<2;i++){
    pl[i]->Draw("e0"); pl[i]->Draw("e1 same"); hpl[i]->Draw("c same"); mm.Print(psname);
  }
  mm.Print(psname+"]");

  TLatex *label = new TLatex(); label->SetNDC(kTRUE); label->SetTextSize(0.055);

  TCanvas all6("all6","KEYS fits to mmiss-pstarl",1700,1800);
  all6.cd();
  all6.Divide(2,3,0.001,0.001);
  all6.cd(1);gPad->SetTopMargin(0.004);gPad->SetRightMargin(0.003);gPad->SetBottomMargin(0.11);
  gPad->SetFillColor(10);gPad->SetFrameFillColor(10);
  m2[4]->Draw("e0");  m2[4]->Draw("e1 same"); hm2[4]->Draw("c same");
  all6.cd(2);gPad->SetTopMargin(0.004);gPad->SetRightMargin(0.003);gPad->SetBottomMargin(0.11);
  gPad->SetFillColor(10);gPad->SetFrameFillColor(10);
  pl[2]->Draw("e0");  pl[2]->Draw("e1 same"); hpl[2]->Draw("c same");
  for(int i=0;i<4;i++){
    all6.cd(i+3);gPad->SetTopMargin(0.003);gPad->SetRightMargin(0.003);gPad->SetBottomMargin(0.11);
    gPad->SetFillColor(10);gPad->SetFrameFillColor(10);
    m2[i]->Draw("e0"); label->DrawLatex(0.69,0.92,M2titles[i]);
    m2[i]->Draw("e1 same"); hm2[i]->Draw("c same"); 
  }
  TString epsname = "AWG82/results/keys/eps/Stitch/EpsKeys";
  epsname += Base; epsname += ".eps";
  all6.SaveAs(epsname);

  h2->Delete();
  return; 

}
コード例 #11
0
ファイル: HLTDatasets.cpp プロジェクト: CmsHI/CVS_SavedFMa
HLTDatasets::HLTDatasets(const std::vector<TString>& triggerNames, const Char_t* datasetDefinitionFile,
                         Bool_t preferEmulatedTriggers, TString emulationPrefix)
  :  datasetsConfig("", &timer)
{
  //...........................................................................
  // Parse input file and mark all the triggers that belong to datasets
  const UInt_t              numTriggers   = triggerNames.size();
  std::vector<Bool_t>       notInDataset  (numTriggers, kTRUE);
  if (datasetDefinitionFile && datasetDefinitionFile[0]) {
    std::ifstream           input(datasetDefinitionFile);
    if (!input.good())
      std::cerr << "ERROR : Cannot open dataset definitions file " << datasetDefinitionFile << std::endl;
    else {
      scenarioName          = gSystem->BaseName(datasetDefinitionFile);
      Int_t                 iExtension    = scenarioName.Last('.');
      if (iExtension != kNPOS)            scenarioName  = scenarioName(0, iExtension);


      // Parse dataset definition blocks
      TString               line;
      int                   lineNumber    = 0;
      while (input.good() && !input.eof()) {  ++lineNumber;

        // Get a line, strip comments and whitespace
        line.ReadLine(input);       strip(line);
        const Int_t         commentIndex  = line.First('#');
        if (commentIndex != kNPOS) {line  = line(0, commentIndex);      strip(line);}
        if (line.Length() < 1)      continue;

        // If the line ends with a semi-colon, it is the start of a dataset definition block
        if (line.EndsWith(":")) {
          TString           name          = line(0, line.Length()-1);   strip(name);
          if (indexOf(datasetsConfig, name) >= 0)
            std::cerr << "WARNING : One or more datasets have the same name '" << name 
                      << "'. Are you sure this is acceptable?" << std::endl;
          datasetsConfig.push_back(Dataset(name));
        }

        // Otherwise it is a trigger in the current dataset
        else {
          if (datasetsConfig.empty())
            std::cerr << "ERROR : Skipping unexpected line before declaration of first dataset : " << std::endl
                      << " [" << std::setw(3) << lineNumber << "]  " << line << std::endl;
          else {
            const Int_t     triggerIndex  = indexOf(triggerNames, line);
            // Also check in case there is an emulated version -- don't use both!
            TString         emulationName = emulationPrefix + line;
            const Int_t     emulationIndex= indexOf(triggerNames, emulationName);

            if (triggerIndex < 0 && emulationIndex < 0) {
              std::cerr << "WARNING : Skipping un-available trigger : " << std::endl
                        << " [" << std::setw(3) << lineNumber << "]  " << line << std::endl;
            } else {
              if (triggerIndex < 0 || (emulationIndex >= 0 && preferEmulatedTriggers))
                datasetsConfig.back().push_back(Trigger(emulationName, emulationIndex));
              else datasetsConfig.back().push_back(Trigger(line, triggerIndex));
              if (triggerIndex >= 0)      notInDataset[triggerIndex]    = kFALSE;
              if (emulationIndex >= 0)    notInDataset[emulationIndex]  = kFALSE;
            }
          }
        }
      } // end loop over lines in file
    }
  }
  // If there are no datasets defined, there's no point in marking all triggers as new
  // since the extra diagnostics will show nothing
  else {
    scenarioName  = "pertrigger";
    for (UInt_t iTrigger = 0; iTrigger < numTriggers; ++iTrigger) {
      // Prefer either the original or emulated version (but not both)
      Bool_t      isEmulated  = triggerNames[iTrigger].BeginsWith(emulationPrefix);
      if          ( preferEmulatedTriggers && !isEmulated) {
        if (indexOf(triggerNames, emulationPrefix + triggerNames[iTrigger]) >= 0)  continue;
      }
      else if     (!preferEmulatedTriggers &&  isEmulated) {
        Int_t     prefix      = emulationPrefix.Length();
        if (indexOf(triggerNames, triggerNames[iTrigger](prefix, triggerNames[iTrigger].Length()-prefix)) >= 0)  continue;
      }
      datasetsConfig.push_back(Dataset(triggerNames[iTrigger]));
      datasetsConfig.back().push_back(Trigger(triggerNames[iTrigger], iTrigger));
      notInDataset[iTrigger]  = kFALSE;
    } // end loop over triggers
  }


  //...........................................................................

  const UInt_t    numDatasets     = datasetsConfig.size();
  std::clog << "-- HLTDatasets -----------------------------------------------------------" << std::endl;
  std::clog << "There are " << numDatasets << " datasets:"            << std::endl;
  for (UInt_t iSet = 0; iSet < numDatasets; ++iSet)
    std::clog << "  " << std::left << std::setw(40) << datasetsConfig[iSet].name << " (x " 
              << std::right << std::setw(2) << datasetsConfig[iSet].size() << " triggers)"      << std::endl;

  //...........................................................................
  // Register all triggers _not_ in any dataset as new triggers
  UInt_t          numNewTriggers  = 0;
  for (UInt_t iTrigger = 0; iTrigger < numTriggers; ++iTrigger) {
    if (notInDataset[iTrigger] && 
				(!triggerNames[iTrigger].Contains("AlCa_Ecal"      ,TString::kIgnoreCase) &&
				 !triggerNames[iTrigger].Contains("AlCa_IsoTrack"  ,TString::kIgnoreCase) &&
				 !triggerNames[iTrigger].Contains("AlCa_HcalPhiSym",TString::kIgnoreCase) &&
				 !triggerNames[iTrigger].Contains("AlCa_RPC"       ,TString::kIgnoreCase))) {
      datasetsConfig.push_back(Dataset(triggerNames[iTrigger], kTRUE));
      datasetsConfig.back().push_back(Trigger(triggerNames[iTrigger], iTrigger));
      ++numNewTriggers;
    }
  } // end loop over triggers

  if (numNewTriggers) {
    std::clog << "and " << numNewTriggers << " new triggers:"                               << std::endl;
    for (UInt_t iTrigger = 0; iTrigger < numNewTriggers; ++iTrigger)
      std::clog << "  +  " << datasetsConfig[numDatasets + iTrigger].name                   << std::endl;
  }
  else                  std::clog << "There are no new triggers."                           << std::endl;
  std::clog << "==========================================================================" << std::endl << std::endl;
 
  
  datasetsConfig.setup();   // Make sure to allocate space at the end after everything is registered
}
コード例 #12
0
ファイル: MRGraphics.cpp プロジェクト: mjbales/mattroot
TCanvas* plotTGraphs(std::vector<TGraph*> theGraphs, bool autoFormat, TString titleString, bool logX, bool logY)
{
	gROOT->cd();

	TCanvas* theCanvas = new TCanvas(titleString, titleString, 1600, 1200);
	theCanvas->cd();
	theCanvas->SetLeftMargin(.13);
	theCanvas->SetRightMargin(.06);
	theCanvas->SetGrid(1, 1);
	gPad->SetTickx(1);
	gPad->SetTicky(1);
	gPad->SetLogx(logX);
	gPad->SetLogy(logY);

	//Create frame based on the min and max from all the histograms;
	double minX = minFromTGraphs(theGraphs, true, true);
	double minY = minFromTGraphs(theGraphs, true, false);
	double maxX = maxFromTGraphs(theGraphs, true, true);
	double maxY = maxFromTGraphs(theGraphs, true, false);
	double lengthX = maxX - minX;
	double lengthY = maxY - minY;
	double widen = 0.05;
	if(!logX)
	{
		minX -= widen * lengthX;
		maxX += widen * lengthX;
	}
	else
	{
		minX *= widen;
		maxX /= widen;
	}

	if(!logY)
	{
		minY -= widen * lengthY;
		maxY += widen * lengthY;
	}
	else
	{
		minY *= widen;
		maxY /= widen;
	}
	TH1F* theFrameHist = theCanvas->DrawFrame(minX, minY, maxX, maxY);
	theFrameHist->SetTitleOffset(1.5, "y");
	theFrameHist->SetTitleOffset(1.3, "X");
	theFrameHist->SetTitle(titleString);

	//If it doesn't have a title string use the first histogram
	if(TString(theFrameHist->GetXaxis()->GetTitle()) == "")
	{
		theFrameHist->SetXTitle(theGraphs[0]->GetXaxis()->GetTitle());
		theFrameHist->SetYTitle(theGraphs[0]->GetYaxis()->GetTitle());
	}

	theCanvas->Update();
	theCanvas->Modified();

	TLegend* theLegend = nullptr;

	if(theGraphs.size() > 1)
	{
		double legendSize = .05 * theGraphs.size();
		if(legendSize < .15) legendSize = .15;

//		theLegend = new TLegend(0.55, .8 - legendSize, 0.87, 0.8);  //Top Right
//		theLegend = new TLegend(0.2, .8 - legendSize, 0.47, 0.8);  //Top Left
		theLegend = new TLegend(0.55, .4 - legendSize, 0.87, 0.4); //Bottom Right
	}

	for (unsigned int i = 0; i < theGraphs.size(); i++)
	{
		if(autoFormat)
		{
			theGraphs[i]->SetLineColor(MR_GRAPH_COLOR_LIST[i % MR_GRAPH_NUMCOLORS]);
			theGraphs[i]->SetMarkerColor(MR_GRAPH_COLOR_LIST[i % MR_GRAPH_NUMCOLORS]);
			theGraphs[i]->SetMarkerStyle(MR_MARKER_STYLE_LIST[i % MR_MARKER_NUMSTYLES]);
		}
		theGraphs[i]->Draw("P E1 same");
		if(theLegend != nullptr)
		{
			TString legendString = theGraphs[i]->GetTitle();
			legendString.Resize(legendString.First(';'));
			theLegend->AddEntry(theGraphs[i], legendString, "P E1");
		}
	}

	if(theLegend != nullptr) theLegend->Draw("same");

	return theCanvas;
}
コード例 #13
0
void write_ist_pednoise() {
	gSystem->Setenv("DB_ACCESS_MODE", "write");
  	gROOT->Macro("LoadLogger.C");
  	gSystem->Load("St_base.so");
  	gSystem->Load("libStDb_Tables.so");
  	gSystem->Load("StDbLib.so");

	std::ifstream fPDlist("/star/u/ypwang/disk01/offline_hft/DB/pedNoiseTable4DB/pedNoiseFiles_Corr/pedRunList_Corr.txt");
        if(!fPDlist.is_open())
        {
                std::cout << " There is no corrected pedRunList file! " << endl;
                exit(0);
        }

        while(!fPDlist.eof()) {
                TString  sPDfile;
                fPDlist >> sPDfile;

                int found = sPDfile.Last('_');
                if(found >= 0)
                        sPDfile.Replace(0, found + 1, "");

                found = sPDfile.Last('.');
                if(found >= 0)
                        sPDfile.Replace(found, sPDfile.Length(), "");

                int runnumb = sPDfile.Atoi();
                if(runnumb)
                        pedRunNumVec.push_back(runnumb);
        }
        fPDlist.close();
	const int nPedRuns = pedRunNumVec.size();
	cout << nPedRuns << " good pedestal runs recorded! " << endl;
        if(debug) {
                for(int i=0; i<nPedRuns; i++)
                        cout << i << "th pedestal run: " << pedRunNumVec[i] << endl;
        }


  	std::ifstream fCosmicRunList("/star/u/ypwang/disk01/offline_hft/DB/pedNoiseTable4DB/cmNoise_cosmic/cosmicRunlist.txt");
        if(!fCosmicRunList.is_open())
        {
                std::cout << " There is no cosmicRunList file! " << endl;
                exit(0);
        }

        while(!fCosmicRunList.eof()) {
                TString  sCMNfile;
                fCosmicRunList >> sCMNfile;

                int found = sCMNfile.First('.');
                if(found >= 0)
                        sCMNfile.Replace(found, sCMNfile.Length(), "");

                int runnumb = sCMNfile.Atoi();
                if(runnumb)
                        cosmicRunNumVec.push_back(runnumb);
        }
        fCosmicRunList.close();
	const int nCosmicRuns = cosmicRunNumVec.size();
	cout << nCosmicRuns << " good cosmic runs recorded! " << endl;
        if(debug) {
                for(int i=0; i<nCosmicRuns; i++)
                        cout << i << "th cosmic run: " << cosmicRunNumVec[i] << endl;
        }

	Int_t   isBadChannel[110592];
        Int_t   isBadChip[864];
	//loop pedestal runs
	for(int iRun=0; iRun<nPedRuns; iRun++)
        {
                int runNumber = pedRunNumVec[iRun];
		//below only for testing
		//if(runNumber<15065020) continue;

                int TbinPD = PDTBin(runNumber);
		cout << "Reading pedestal run " << runNumber << " with " << TbinPD << " time bins! " << endl;
		
		//retrieve time stamp information
		char cmd[256];
            	sprintf(cmd, "/usr/bin/mysql -h dbbak.starp.bnl.gov --port=3413 -e \"SELECT FROM_UNIXTIME(startRunTime) as beginTime_human FROM RunLog.runDescriptor WHERE runNumber = %d\" >timeStamp_tmp", runNumber);
            	system(cmd);

            	TString mTimeStamp;
            	FILE *inR = fopen("timeStamp_tmp","r");
            	while(!feof(inR)) {
                	char buff[64];
                	if(fgets(buff,sizeof(buff),inR) == 0) continue ;
                	switch(buff[0]) {
                    		case 'b' : //beginTime_human
                        		continue ;
                	}
                	mTimeStamp = Form(buff);
            	}
            	fclose(inR);

            	sprintf(cmd, "/bin/rm timeStamp_tmp");
            	system(cmd);

		int found = 19;
            	mTimeStamp.Replace(found, mTimeStamp.Length(), "");
            	cout << iRun << ": \t" << runNumber << "\t" << mTimeStamp << endl;
	
		//find the closest cosmic run to match, and using its common-mode noise
		int diffRun = 15000000, miniDiffRun = 15000000;
		int matchedCosmicRunNumber = 15032029;
		for(int iCosmic=0; iCosmic<nCosmicRuns; iCosmic++) {
			diffRun = cosmicRunNumVec[iCosmic] - runNumber;
			if(diffRun < miniDiffRun && diffRun > 0) { //corresponding cosmic run should come after the pedestal run
				miniDiffRun = diffRun;
				matchedCosmicRunNumber = cosmicRunNumVec[iCosmic];
			}
		}
		if(runNumber>=15158006) matchedCosmicRunNumber = 15157002; //if no later cosmic runs found, then use the last one
		int TbinCMN = CMTBin(matchedCosmicRunNumber);
		cout << "Matched cosmic run " << matchedCosmicRunNumber << " with " << TbinCMN << " time bins! " << endl;
		
		StDbManager* mgr = StDbManager::Instance();
  		StDbConfigNode* node = mgr->initConfig("Calibrations_ist");
  		StDbTable* dbtable = node->addDbTable("istPedNoise");
  		mgr->setStoreTime(mTimeStamp.Data());
		
		//open matched CMN DB file
		std::ifstream inCMN(Form("/star/u/ypwang/disk01/offline_hft/DB/pedNoiseTable4DB/cmNoise_cosmic/%d.istCmNoise.dat", matchedCosmicRunNumber));
    		if (!inCMN.is_open()) {
    			std::cout << " There is no CMN DB file  " << end ;
    			exit(0);
    		}

		//open corrected pedestal/RMS DB file
		std::ifstream inPD(Form("/star/u/ypwang/disk01/offline_hft/DB/pedNoiseTable4DB/pedNoiseFiles_Corr/IST_pedestals_%d.txt", runNumber));
    		if (!inPD.is_open()) {
    			std::cout << " There is no PED/RMS DB file  " << end ;
    			exit(0);
    		}
	
		//retreive online masking chip/channel and offline channel masking
		for(int i=0; i<110592; i++) {
                    isBadChannel[i] = 0;
                }

		for(int i=0; i<864; i++) {
                    isBadChip[i] = 0;
                }
		
		//online masking-out chips
		int tem_Run, tem_Rdo, tem_Arm, tem_Group, tem_Apv, tem_Status, ChipEID;
		int deadChipsInRun14 = 31, deadChipCounter=0;
                if(runNumber<15181030) {
                    std::ifstream deadChipList("/star/u/ypwang/disk01/offline_hft/DB/pedNoiseTable4DB/ist_apv_dead.txt");
                }
                else {
                    std::ifstream deadChipList("/star/u/ypwang/disk01/offline_hft/DB/pedNoiseTable4DB/ist_apv_dead_AuHe3.txt");
                    deadChipsInRun14 = 29; //since run 15174075 (June 23, 2014), two chips (566/567) were taken out of online mask-out chip list
                }
		if(!deadChipList.is_open()) 
		{
                        cout << "ist_apv_dead file was NOT found " << endl;
                        exit(0);
                }

		int deadChipId = -1;
                while(!deadChipList.eof() && deadChipCounter<deadChipsInRun14) {
                    deadChipList >> tem_Rdo >> tem_Arm >> tem_Apv;
                    deadChipId = (tem_Rdo-1)*6*24 + tem_Arm*24 + tem_Apv; //electronics ID
                    if(deadChipId<0 || deadChipId>=864) continue;

		    int deadChipGeomIdx = elecIdToGeomId(deadChipId);
                    isBadChip[deadChipGeomIdx-1] = 1; //dead chip
                    deadChipCounter++;
                }
                deadChipList.close();
		cout << "Number of online masking-out chips: " << deadChipCounter << endl;

		//mis-configured chips
                std::ifstream misConfigChiplist("/star/u/ypwang/disk01/offline_hft/DB/pedNoiseTable4DB/ist_apv_bad.txt");
                if(!misConfigChiplist.is_open())
                {
                        cout << "ist_apv_bad file was NOT found " << endl;
                        exit(0);
                }
		
		int badChipCounter = 0;
		while(!misConfigChiplist.eof()) //mis-configured chips recorded since 15065020
                {
                        misConfigChiplist >> tem_Run >> tem_Rdo >> tem_Arm >> tem_Group >> tem_Apv >> tem_Status;
                        if(tem_Run == matchedCosmicRunNumber)
                        {
                                ChipEID = (tem_Rdo - 1) * 6 * 24 + tem_Arm * 24 + tem_Group * 12 + tem_Apv;
                                if(ChipEID<0 || ChipEID>=864) continue;

				int badChipGeomIdx = elecIdToGeomId(ChipEID);
                                isBadChip[badChipGeomIdx-1] = 2; //mis-configured chip
                                badChipCounter++;
                        }
                }
                misConfigChiplist.close();
		cout << "Number of offine masking-out chips: " << badChipCounter << endl;

		//online masking-out channel list
		Int_t   rdoIndex = -1, armIndex = -1, apvIndex = -1, chanIndex = -1;
                Int_t   channelId = -1;

		std::ifstream badChannelListOnline("/star/u/ypwang/disk01/offline_hft/DB/pedNoiseTable4DB/channelMaskingList_ist_online.txt"); //179 bad channels masked out online
		if(!badChannelListOnline.is_open()) 
		{
                        cout << "channelMaskingList_ist_online file was NOT found " << endl;
                        exit(0);
                }

		int deadChannelCounter = 0;
                while(!badChannelListOnline.eof()) {
                        badChannelListOnline >> rdoIndex >> armIndex >> apvIndex >> chanIndex;
                        channelId = (rdoIndex-1)*6*24 + armIndex*24 + apvIndex*128 + chanIndex;
                        isBadChannel[channelId] = 1;
			deadChannelCounter++;
                }
                badChannelListOnline.close();
		cout << "Number of online masking-out channels: " << deadChannelCounter << endl;

		//offline masking-out channel list
                std::ifstream badChannelListOfflineB("/star/u/ypwang/disk01/offline_hft/DB/pedNoiseTable4DB/ChannelMaskList.20140601.txt"); //336 bad channels masked out offline
		if(!badChannelListOfflineB.is_open())
		{
			cout << "ChannelMaskList.20140601 file was NOT found " << endl;
                        exit(0);
		}

		int badChannelCounter = 0;
                while(!badChannelListOfflineB.eof()) {
                        badChannelListOfflineB >> channelId;
                        isBadChannel[channelId] = 2;
			badChannelCounter++;
                }
                badChannelListOfflineB.close();
		cout << "Number of offline masking-out channels: " << badChannelCounter << endl;

		istPedNoise_st table;
		for (int i = 0; i < 110592; i++) {
    			table.pedestal[i] = 0;
    			table.rmsNoise[i] = 0;
  		}

  		for (int i = 0; i < 864; i++) {
    			table.cmNoise[i] = 0;
  		}

		//Pedestal and RMS Noise
		Float_t pedestalT, rmsT;
		Float_t averagePed = 0., averageRms = 0.;
		Int_t timebin = -1;
		channelId = -1;
		for (int counter=0; counter<110592*TbinPD; counter++){
			inPD >> rdoIndex >> armIndex >> apvIndex >> chanIndex >> timebin >> pedestalT >> rmsT;
			channelId = (rdoIndex - 1) * 6 * 24 * 128 + armIndex * 24 * 128 + apvIndex * 128 + chanIndex;
			if(channelId<0 || channelId>=110592) continue;
    			averagePed += pedestalT/TbinPD;
    			averageRms += rmsT/TbinPD;

    			if(((timebin+1)/TbinPD) && ((counter+1)/TbinPD)) {
        			//cout << counter/TbinPD << ": channelId = " << channelId<<"\t pedestal = "<<averagePed<<"\t rms = "<<averageRms<<endl;

        			table.pedestal[channelId] = (int)averagePed;
        			table.rmsNoise[channelId] = (int)(averageRms*100);
				//masking-out online/offline bad channels
				if(isBadChannel[channelId]) 
					table.rmsNoise[channelId] = 10000;
				if(debug)
					cout << counter/TbinPD << ": channelId = " << channelId << "\t pedestal = " << table.pedestal[channelId] << "\t rms = " << table.rmsNoise[channelId] <<endl;
        			averagePed = 0.;
        			averageRms = 0.;
    			}
  		}
  		inPD.close();

		//Common Mode Noise
		Float_t cmNoiseT;
		Float_t averageCmNoise = 0.;
		Int_t chipId;
		Int_t numTimeBins = 9; //IST CMN DB files output 9 time bins format in default
		for(int counter=0; counter<864*numTimeBins; counter++){
    			inCMN >> chipId >> timebin >> cmNoiseT;
    			averageCmNoise += cmNoiseT/TbinCMN;

    			if(((timebin+1)/numTimeBins) && ((counter+1)/numTimeBins)) {
        			//cout << counter/numTimeBins << ": chipId = " << chipId << " cmNoiseT = " << averageCmNoise << endl;
        			table.cmNoise[chipId] = (int)(averageCmNoise*100);
				//masking-out online/offline bad chips
				if(isBadChip[chipId])
					table.cmNoise[chipId] = 10000;
				if(debug)
					cout << counter/numTimeBins << ": chipId = " << chipId << " cmNoiseT = " << table.cmNoise[chipId] << endl;
        			averageCmNoise = 0.;
    			}
  		}
  		inCMN.close();

		// Please comment out below lines if you do testing, or it will write the DB!!!!
		// Store data to the StDbTable
		dbtable->SetTable((char*)&table, 1);

		// Store table to database
		mgr->storeDbTable(dbtable);

		//exit(0); //only for testing
	}
};
コード例 #14
0
static Calibration::VarProcessor*
getCalibration(const std::string &file, const std::vector<std::string> &names)
{
	std::auto_ptr<Calibration::ProcExternal> calib(
					new Calibration::ProcExternal);

	std::ifstream in(file.c_str(), std::ios::binary | std::ios::in);
	if (!in.good())
		throw cms::Exception("mvaWeightsToCalibration")
			<< "Weights file \"" << file << "\" "
			   "cannot be opened for reading." << std::endl;

	char buf[512];

	while(in.good() && !TString(buf).BeginsWith("Method"))
		in.getline(buf, 512);
	if (!in.good())
		throw cms::Exception("mvaWeightsToCalibration")
			<< "Weights file \"" << file << "\" "
			   "is not a TMVA weights file." << std::endl;

	TString ls(buf);
	Int_t idx1 = ls.First(':') + 2;
	Int_t idx2 = ls.Index(' ', idx1) - idx1;
	if (idx2 < 0)
		idx2 = ls.Length();
	TString fullname = ls(idx1, idx2);
	idx1 = fullname.First(':');
	Int_t idxtit = (idx1 < 0 ? fullname.Length() : idx1);
	TString methodName = fullname(0, idxtit);

	std::size_t size = getStreamSize(in) + methodName.Length();
	for(std::vector<std::string>::const_iterator iter = names.begin();
	    iter != names.end(); ++iter)
		size += iter->size() + 1;
	size += (size / 32) + 128;

	char *buffer = 0;
	try {
		buffer = new char[size];
		ext::omemstream os(buffer, size);
		/* call dtor of ozs at end */ {
			ext::ozstream ozs(&os);
			ozs << methodName << "\n";
			ozs << names.size() << "\n";
			for(std::vector<std::string>::const_iterator iter =
								names.begin();
			    iter != names.end(); ++iter)
				ozs << *iter << "\n";
			ozs << in.rdbuf();
			ozs.flush();
		}
		size = os.end() - os.begin();
		calib->store.resize(size);
		std::memcpy(&calib->store.front(), os.begin(), size);
	} catch(...) {
		delete[] buffer;
		throw;
	}
	delete[] buffer;
	in.close();

	calib->method = "ProcTMVA";

	return calib.release();
}