Example #1
0
void geometry() {
   TString dir = gSystem->UnixPathName(__FILE__);
   dir.ReplaceAll("geometry.C","");
   dir.ReplaceAll("/./","/");
   gROOT->Macro(Form("%s/na49.C",dir.Data()));
   gROOT->Macro(Form("%s/na49geomfile.C",dir.Data()));
}
Example #2
0
TGraphErrors g(TTree *tree, TString alphaName, TString constTermName){
  Double_t alpha, constTerm;
  alphaName.ReplaceAll("-","_");
  constTermName.ReplaceAll("-","_");

  tree->SetBranchAddress(alphaName,&alpha);
  tree->SetBranchAddress(constTermName,&constTerm);

  //Long64_t nEntries=genTree->GetEntries();

  TGraphErrors graph;
  Int_t iPoint=0;

  tree->GetEntry(0);
  std::cout << alpha << "\t" << constTerm << std::endl;
  Double_t alpha2=alpha*alpha;
  Double_t const2=constTerm*constTerm;
  for(Double_t energy=20; energy<150; energy+=10){
    Double_t addSmearing = (sqrt(alpha2/energy+const2));
    
    graph.SetPoint(iPoint, energy, addSmearing);
    graph.SetPointError(iPoint,0, 0);
    iPoint++;
  }

  graph.Set(iPoint);
  tree->ResetBranchAddresses();
  graph.Draw("A L");
  graph.SetFillColor(kBlue);
  graph.SetLineColor(kYellow);
  graph.GetXaxis()->SetTitle("Energy [GeV]");
  graph.GetYaxis()->SetTitle("Additional smearing [%]");
  return graph;
}
void make_histos_syst_rawyield(TString file_syst, TString file_default, TString out_tag){

  TFile *f1 = new TFile(file_syst.Data(),"read");
  TFile *f2 = new TFile(file_default.Data(),"read");
  TDirectoryFile *dir1 = (TDirectoryFile*)(f1->Get("effunf"));
  TDirectoryFile *dir2 = (TDirectoryFile*)(f2->Get("effunf"));
  TList *list = dir1->GetListOfKeys();

  TFile *f = new TFile(Form("plots/ratiosyst_%s.root",out_tag.Data()),"recreate");

  for (int i=0; i<list->GetSize(); i++){
    TString name = dir1->GetListOfKeys()->At(i)->GetName();
    if (!(name.Contains("hreco_"))) continue;
    TObject *obj1 = dir1->Get(name.Data());
    assert(obj1);
    TObject *obj2 = dir2->Get(name.Data());
    assert(obj2);
    TString newname = name;
    newname.Append("_ratiosyst");
    if (name.EndsWith("_0")) newname.ReplaceAll("_0_","_EBEB_");
    if (name.EndsWith("_1")) newname.ReplaceAll("_1_","_EBEE_");
    if (name.EndsWith("_2")) newname.ReplaceAll("_2_","_EEEE_");
    TH1F *h = (TH1F*)(((TH1F*)obj1)->Clone(newname.Data()));
    h->SetTitle(h->GetName());
    h->Divide((TH1F*)obj2);
    for (int j=0; j<h->GetNbinsX(); j++) h->SetBinError(j+1,0);
    for (int j=0; j<h->GetNbinsX(); j++) h->SetBinContent(j+1,1+fabs(1-h->GetBinContent(j+1)));
    f->cd();
    h->Write();
  }

}
Example #4
0
void RecoQA(const char* inFile) {
  gROOT->LoadMacro("bfcread_hist_prefixes_add_to_ps.C");

  TString baseName = inFile;
  if (baseName.EndsWith(".daq"))
    baseName.ReplaceAll(".daq",".hist.root");
  else if (baseName.EndsWith(".event.root"))
    baseName.ReplaceAll(".event.root",".hist.root");
  else if (baseName.EndsWith(".MuDst.root"))
    baseName.ReplaceAll(".MuDst.root",".hist.root");

  TString histFile = baseName;

  baseName.Remove(0,baseName.Last('/')+1);

  TString outputName = baseName;
  outputName.ReplaceAll(".root",".CC");

  TString histList = "StRoot/St_QA_Maker/QAhlist_Reco.h";
  if (! gSystem->Which(".",histList.Data()))
    histList.Prepend(gSystem->ExpandPathName("$STAR/"));
  
  bfcread_hist_prefixes_add_to_ps(histFile.Data(),"EventQA",
    "bfcTree",outputName.Data(),baseName.Data(),histList.Data());
}
Example #5
0
void MakeTTreeFromBinfit() {
//  Read data from an ascii file and create a root file with an histogram and an ntuple.
//   see a variant of this macro in basic2.C
      

// read file $ROOTSYS/tutorials/tree/basic.dat
// this file has 3 columns of float data
   TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
   dir.ReplaceAll("MakeTTreeFromBinfit.C","");
   dir.ReplaceAll("/./","/");
   ifstream in;
   in.open(Form("%sBinfit_results_reco_ptGT8.txt",dir.Data()));

   Float_t fracd,fracs, fracn, chi;
   Int_t nlines;
   string result;
   TFile *f = new TFile("Binfit_results_spsdpsnlo_ptYdy_reco8gev.root","RECREATE");
   TNtuple *ntuple = new TNtuple("ntuple","data from ascii file","fracd:fracs:fracn:chi");

   while (1) {
      in >> fracd >> fracs >> fracn >> chi;
      if (!in.good()) break;
      if (nlines < 5) printf("fracd=%8f, chi=%8f \n",fracd,chi);
      ntuple->Fill(fracd,fracs,fracn,chi);
      nlines++;
   }
   printf(" found %d points\n",nlines);

   in.close();

   f->Write();
}
Example #6
0
void myfit()
{
   TString dir = gSystem->UnixPathName(__FILE__);
   dir.ReplaceAll("myfit.C","../hsimple.C");
   dir.ReplaceAll("/./","/");
   if (!gInterpreter->IsLoaded(dir.Data())) gInterpreter->LoadMacro(dir.Data());
   TFile *hsimple = (TFile*)gROOT->ProcessLineFast("hsimple(1)");
   if (!hsimple) return;

   TCanvas *c1 = new TCanvas("c1","the fit canvas",500,400);

   TH1F *hpx = (TH1F*)hsimple->Get("hpx");

// Creates a Root function based on function fitf above
   TF1 *func = new TF1("fitf",fitf,-2,2,3);

// Sets initial values and parameter names
   func->SetParameters(100,0,1);
   func->SetParNames("Constant","Mean_value","Sigma");

// Fit histogram in range defined by function
   hpx->Fit(func,"r");

// Gets integral of function between fit limits
   printf("Integral of function = %g\n",func->Integral(-2,2));
}
Example #7
0
TString KVNumberList::GetLogical(const Char_t *observable)
{
    // Get logical expression of 'this' list in the TTree:Draw condition format
    // observable is one of the leaf of the TTree
    // 12-15 20 --> ( 12<=observable&&observable<=15 || observable==20 )
    // return "" if 'this' list  is empty

    if (IsEmpty()) return "";
    GetList();
    TString tmp = fString;
    tmp.ReplaceAll(" ","||");
    TObjArray *toks = tmp.Tokenize("||");
    TString cond="( ";
    Int_t nt = toks->GetEntries();
    for (Int_t ii=0; ii<nt; ii+=1) {
        TString line = ((TObjString*)(*toks)[ii])->GetString();
        if ( line.Contains("-") ) {
            line.ReplaceAll("-",Form("<=%s&&%s<=",observable,observable));
            cond+=line;
        }
        else {
            cond+=Form("%s==",observable)+line;
        }
        if (ii!=nt-1) cond+="||";
    }
    cond += " )";
    delete toks;
    return cond;
}
Example #8
0
void basic() {
//  Read data from an ascii file and create a root file with an histogram and an ntuple.
//   see a variant of this macro in basic2.C
//Author: Rene Brun


// read file $ROOTSYS/tutorials/tree/basic.dat
// this file has 3 columns of float data
   TString dir = gSystem->UnixPathName(__FILE__);
   dir.ReplaceAll("basic.C","");
   dir.ReplaceAll("/./","/");
   ifstream in;
   in.open(Form("%sbasic.dat",dir.Data()));

   Float_t x,y,z;
   Int_t nlines = 0;
   TFile *f = new TFile("basic.root","RECREATE");
   TH1F *h1 = new TH1F("h1","x distribution",100,-4,4);
   TNtuple *ntuple = new TNtuple("ntuple","data from ascii file","x:y:z");

   while (1) {
      in >> x >> y >> z;
      if (!in.good()) break;
      if (nlines < 5) printf("x=%8f, y=%8f, z=%8f\n",x,y,z);
      h1->Fill(x);
      ntuple->Fill(x,y,z);
      nlines++;
   }
   printf(" found %d points\n",nlines);

   in.close();

   f->Write();
}
Example #9
0
TGraphErrors bestFit(TTree *tree, TString alphaName, TString constTermName){
  Double_t alpha, constTerm;
  alphaName.ReplaceAll("-","_");
  constTermName.ReplaceAll("-","_");

  tree->SetBranchAddress(alphaName,&alpha);
  tree->SetBranchAddress(constTermName,&constTerm);

  //Long64_t nEntries=genTree->GetEntries();

  TGraphErrors graph;
  Int_t iPoint=0;

  tree->GetEntry(0);
  graph.SetPoint(0, constTerm, alpha);
  graph.SetPointError(0,0, 0);
  iPoint++;

  graph.Set(iPoint);
  tree->ResetBranchAddresses();
  graph.Draw("A P");
//   graph.SetFillColor(kBlue);
//   graph.SetLineColor(kYellow);
//   graph.GetXaxis()->SetTitle("Energy [GeV]");
//   graph.GetYaxis()->SetTitle("Additional smearing [%]");
  return graph;
}
Example #10
0
  TCollection* GetEtaBin(TObject* o, Double_t& etaMin, Double_t& etaMax)
  {
    const char* re = "[pm][0-9]*d[0-9]*_[pm][0-9]*d[0-9]*";
    TRegexp     check(re);

    if (!o->IsA()->InheritsFrom(TCollection::Class())) {
      // Warning("GetEtaBin", "Don't know how to deal with %s - a %s",
      //         o->GetName(), o->ClassName());
      return 0;
    }
    TString oN(o->GetName());
    if (oN.Index(check) == kNPOS) { 
      // Warning("GetEtaBin", "Collection %s does not match %s",
      //         oN.Data(), re);
      return 0;
    }
    Int_t    ul     = oN.Index("_");
    TString  sMin   = oN(0, ul);
    TString  sMax   = oN(ul+1, oN.Length()-ul-1);
    sMin.ReplaceAll("p", "+");
    sMin.ReplaceAll("m", "-");
    sMin.ReplaceAll("d", ".");
    sMax.ReplaceAll("p", "+");
    sMax.ReplaceAll("m", "-");
    sMax.ReplaceAll("d", ".");
    etaMin = sMin.Atof();
    etaMax = sMax.Atof();

    return static_cast<TCollection*>(o);
  }
Example #11
0
void HistoTransform::mergeKFolds(TDirectory* source, SubDirectory* subDir) {
  TDirectory* savdir = gDirectory;
  TDirectory* adir = source;
  //    if (source != m_inFile) {
  //      adir = savdir -> mkdir(source -> GetName());
  //    }
  adir -> cd();
  //loop on all entries of this directory
  TKey* key;
  TIter nextkey(source -> GetListOfKeys());
  while ((key = (TKey*) nextkey())) {
    TClass* cl = gROOT -> GetClass(key -> GetClassName());
    if (!cl) continue;
    if (cl -> InheritsFrom(TDirectory::Class())) {
      cout << "INFO: going into directory '" << key -> GetName() << "'" << endl;
      source -> cd(key -> GetName());
      TDirectory* subdir = gDirectory;
      adir -> cd();
      mergeKFolds(subdir, subDir);
      adir -> cd();
    } else if (cl -> InheritsFrom(TH1::Class())) {
      string name = key -> GetName();
      TH1* histo = (TH1*) source -> Get(name.c_str());
      adir -> cd();
      KFold* kFold = getKFold(subDir, name);
      if (isFirstOfKFold(kFold, name)) {
        TString string0ofK = TString::Format("_0of%i", (int) kFold -> regions.size());
        TString nameMerged = name.c_str();
        nameMerged.ReplaceAll(string0ofK, "");
        TH1* histoMerged = (TH1*) histo -> Clone(nameMerged);
        bool foundAllFolds = true;
        for (unsigned int iRegion = 1; iRegion < kFold -> regions.size(); iRegion++) {
          //region = kFold -> regions[iRegion];
          TString foldName = name.c_str();
          //foldName.ReplaceAll(nameFirstRegion, region -> name.c_str());
          TString stringIofK = TString::Format("_%iof%i", iRegion, (int) kFold -> regions.size());
          foldName.ReplaceAll(string0ofK, stringIofK);
          TObject* objHisto = source -> Get(foldName);
          if (objHisto) {
            histo = (TH1*) objHisto;
            histoMerged -> Add(histo);
            delete histo;
            //cout << "added " << iRegion << endl;
          } else {
            cout << "WARNING: histogram '" << foldName << "' not found! Not writing merged output." << endl;
            foundAllFolds = false;
          }
        }
        if (foundAllFolds)
          histoMerged -> Write();
        delete histoMerged;
      }
    }
  }
  adir -> SaveSelf(kTRUE);
  savdir -> cd();
}
doADraw3bins(TString name, TString title){
    cout << "on va plotter le plot " << name << endl;
    drawMyPlot(name, "|#eta| <0.9",title,0.6,1.05);
    name.ReplaceAll("bin0","bin1");
	drawMyPlot(name, "0.9 <|#eta| < 1.2",title,0.6,1.05);
    name.ReplaceAll("bin1","bin2");
	drawMyPlot(name, "1.2 <|#eta| < 2.4",title,0.6,1.05);
    
}
Example #13
0
File: fit1.C Project: dawehner/root
void fit1() {
   //Simple fitting example (1-d histogram with an interpreted function)
   //To see the output of this macro, click begin_html <a href="gif/fit1.gif">here</a>. end_html
   //Author: Rene Brun
   
   TCanvas *c1 = new TCanvas("c1_fit1","The Fit Canvas",200,10,700,500);
   c1->SetGridx();
   c1->SetGridy();
   c1->GetFrame()->SetFillColor(21);
   c1->GetFrame()->SetBorderMode(-1);
   c1->GetFrame()->SetBorderSize(5);

   gBenchmark->Start("fit1");
   //
   // We connect the ROOT file generated in a previous tutorial
   // (see begin_html <a href="fillrandom.C.html">Filling histograms with random numbers from a function</a>) end_html
   //
   TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
   dir.ReplaceAll("fit1.C","");
   dir.ReplaceAll("/./","/");
   TFile *fill = TFile::Open("fillrandom.root");
   if (!fill) {
      gROOT->ProcessLine(Form(".x %s../hist/fillrandom.C",dir.Data()));
      fill = TFile::Open("fillrandom.root");
      if (!fill) return;
   }
      
   //
   // The function "ls()" lists the directory contents of this file
   //
   fill->ls();

   //
   // Get object "sqroot" from the file. Undefined objects are searched
   // for using gROOT->FindObject("xxx"), e.g.:
   // TF1 *sqroot = (TF1*) gROOT.FindObject("sqroot")
   //
   sqroot->Print();

   //
   // Now fit histogram h1f with the function sqroot
   //
   h1f->SetFillColor(45);
   h1f->Fit("sqroot");

   // We now annotate the picture by creating a PaveText object
   // and displaying the list of commands in this macro
   //
   fitlabel = new TPaveText(0.6,0.3,0.9,0.80,"NDC");
   fitlabel->SetTextAlign(12);
   fitlabel->SetFillColor(42);
   fitlabel->ReadFile(Form("%sfit1_C.C",dir.Data()));
   fitlabel->Draw();
   c1->Update();
   gBenchmark->Show("fit1");
}
Example #14
0
void KVCanvas::SaveCanvasAs()
{

   if (strcmp("", fSavedAs)) {
      Int_t ret_val;
      TString file = fSavedAs.Data();
      file.ReplaceAll(gSystem->DirName(fSavedAs.Data()), "");
      file.ReplaceAll("/", "");
      new TGMsgBox(gClient->GetDefaultRoot(), gClient->GetDefaultRoot(), "File name exist",
                   Form("File name '%s' already exists, OK to owerwrite it?", file.Data()),
                   kMBIconExclamation, kMBOk | kMBCancel, &ret_val);

      if (ret_val & kMBOk) {
         fCanvas->SaveAs(fSavedAs);
         return;
      }
   }

   const char* SaveAsTypes[] = {
      "PDF",          "*.pdf",
      "PostScript",   "*.ps",
      "Encapsulated PostScript", "*.eps",
      "SVG",          "*.svg",
      "TeX",          "*.tex",
      "GIF",          "*.gif",
      "ROOT macros",  "*.C",
      "ROOT files",   "*.root",
      "XML",          "*.xml",
      "PNG",          "*.png",
      "XPM",          "*.xpm",
      "JPEG",         "*.jpg",
      "TIFF",         "*.tiff",
      "XCF",          "*.xcf",
      "All files",    "*",
      0,              0
   };

   TString workdir = gSystem->WorkingDirectory();
   static TString dir(".");
   static Int_t typeidx = 0;
   static Bool_t overwr = kFALSE;
   TGFileInfo fi;
   fi.fFileTypes   = SaveAsTypes;
   fi.fIniDir      = StrDup(dir);
   fi.fFileTypeIdx = typeidx;
   fi.fOverwrite   = overwr;
   new TGFileDialog(gClient->GetDefaultRoot(), gClient->GetDefaultRoot(), kFDSave, &fi);
   gSystem->ChangeDirectory(workdir.Data());
   if (!fi.fFilename) return;
   TString fn = fi.fFilename;
   dir     = fi.fIniDir;
   typeidx = fi.fFileTypeIdx;
   overwr  = fi.fOverwrite;
   fCanvas->SaveAs(fn);
   fSavedAs = fn;
}
doADraw4bins(TString name, TString title){
    cout << "on va plotter le plot " << name << endl;
    drawMyPlot(name, "|#eta| < 0.8",title,0,1.2);
    name.ReplaceAll("bin0","bin1");
	drawMyPlot(name, "0.8 <|#eta| < 1.479",title,0,1.2);   
    name.ReplaceAll("bin1","bin2");
	drawMyPlot(name, "1.479 <|#eta| < 2.0",title,0,1.2);
    name.ReplaceAll("bin2","bin3");
	drawMyPlot(name, "2.0 <|#eta| < 2.5",title,,0,1.2);
    
}
Example #16
0
void demo(string infile = "data.dat"){
	TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
	dir.ReplaceAll("demo.C","");
	dir.ReplaceAll("/./","/");
	TString pathName;
	pathName = dir + "data.dat";
	infile = pathName;
	cout << infile<< endl;
	plotGood(infile);
	plotBad(infile);
}
Example #17
0
File: tasks.C Project: MycrofD/root
void tasks()
{
   TString dir = gSystem->UnixPathName(__FILE__);
   dir.ReplaceAll("tasks.C","");
   dir.ReplaceAll("/./","/");
   gROOT->LoadMacro(dir +"MyTasks.cxx+");

   gROOT->ProcessLine("#define __RUN_TASKS__ 1");
   gROOT->ProcessLine(TString("#include \"") + dir + "tasks.C\"");
   gROOT->ProcessLine("runtasks()");
   gROOT->ProcessLine("#undef __RUN_TASKS__");
}
Example #18
0
void FillShortName(TriggerLineVector & vector, TString const& particle){
  TString name;
  for(Int_t i(0);i<(Int_t)vector.size();i++){
    name = vector[i].LeafName;
    name.ReplaceAll("Decision_","");
    name.ReplaceAll(particle,"");
    name.ReplaceAll("TOS","");
    name.ReplaceAll("TIS","");
    name.ReplaceAll("Dec","");
    vector[i].ShortName = name;
  }
}
Example #19
0
/**
 * Returns a suitable epsFilename build from a file or directory name and
 * histogram name.
 *
 * @param fileOrDirectoryName
 *                            name of the file or directory
 * @param histogramNamw
 *                            name of the histogram
 * @return
 *                            a suitable epsFilename
 */
TString
epsFilename(const TString& fileOrDirectoryName, const TString& histogramName)
{
// {{{
    TString s = fileOrDirectoryName;
    if (s.EndsWith("/")) s.Remove(s.Length()-1);
    s = gSystem->BaseName(s);
    s.ReplaceAll(".root", "");
    s.Append(".").Append(histogramName);
    s.ReplaceAll(".", "_");
    return s;
// }}}
};
doADraw5bins(TString name, TString title){
    cout << "on va plotter le plot " << name << endl;
    drawMyPlot(name, "|SC #eta| < 0.8",title,0,0.9);
    name.ReplaceAll("bin0","bin1");
	drawMyPlot(name, "0.8 <|SC #eta| < 1.4442",title,0,0.9);
    name.ReplaceAll("bin1","bin2");
	drawMyPlot(name, "1.4442 <|SC #eta| < 1.556",title,0,0.9);
    name.ReplaceAll("bin2","bin3");
	drawMyPlot(name, "1.556 <|SC #eta| < 2.0",title,0,0.9);
    name.ReplaceAll("bin3","bin4");
	drawMyPlot(name, "2.0 <|SC #eta| < 2.5",title,0,0.9);
    
}
Example #21
0
void FirstContour()
{
   TString dir = gSystem->UnixPathName(__FILE__);
   dir.ReplaceAll("FirstContour.C","../hsimple.C");
   dir.ReplaceAll("/./","/");
   if (!gInterpreter->IsLoaded(dir.Data())) gInterpreter->LoadMacro(dir.Data());
   TFile *file = (TFile*)gROOT->ProcessLineFast("hsimple(1)");
   if (!file) return;
   TTree *ntuple = (TTree*)file->Get("ntuple");

   TCanvas *c1 = new TCanvas("c1","Contours",10,10,800,600);
   gStyle->SetPalette(1);
   ntuple->Draw("py:px","px*px+py*py < 20", "contz,list");

   //we must call Update to force the canvas to be painted.  When
   //painting the contour plot, the list of contours is generated
   //and a reference to it added to the Root list of special objects
   c1->Update();

   TCanvas *c2 = new TCanvas("c2","First contour",100,100,800,600);


   TObjArray *contours =
      (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
   if (!contours) return;
   TList *lcontour1 = (TList*)contours->At(0);
   if (!lcontour1) return;
   TGraph *gc1 = (TGraph*)lcontour1->First();
   if (!gc1) return;
   if (gc1->GetN() < 10) return;
   gc1->SetMarkerStyle(21);
   gc1->Draw("alp");

   //We make a TCutG object with the array obtained from this graph
   TCutG *cutg = new TCutG("cutg",gc1->GetN(),gc1->GetX(),gc1->GetY());

   //We create a polymarker object with npmax points.
   const Int_t npmax = 50000;
   TPolyMarker *pm = new TPolyMarker(npmax);
   Int_t np = 0;
   while(1) {
      Double_t x = -4 +8*gRandom->Rndm();
      Double_t y = -4 +8*gRandom->Rndm();
      if (cutg->IsInside(x,y)) {
         pm->SetPoint(np,x,y);
         np++;
         if (np == npmax) break;
      }
   }
   pm->Draw();
}
Example #22
0
void runSimBfc( Int_t nEvents=100, Int_t run=100, const char* pid="gamma", int merge=1,
		int print=0,
		TString myDir=input_dir, TString myOutDir=output_dir,
		TString myChain=input_chain, Int_t mnEvents=1){
    
  gROOT->LoadMacro("bfc.C");
  gROOT->Macro("loadMuDst.C");
  TString myDat=Form("test_%s_run%i.fzd",pid,run);
  bfc( -1, myChain, myDir+myDat );

  TString outfile = myOutDir + myDat.ReplaceAll(".fzd",".root");
  //TString outfile = myOutDir + chain->GetFileOut();    
  cout << "output file=" <<outfile<<endl;
  chain->SetOutputFile(outfile);
  
  StFmsDbMaker* fmsdb = (StFmsDbMaker*) chain->GetMaker("fmsDb");
  //fmsdb->readGainFromText();
  //fmsdb->forceUniformGain(0.038);
  //fmsdb->forceUniformGainCorrection(1.0);
  fmsdb->setDebug(2);
  fmsdb->readRecParamFromFile();

  StFmsFastSimulatorMaker *fmssim = (StFmsFastSimulatorMaker*) chain->GetMaker("fmsSim");
  fmssim->SetDebug();
  fmssim->setFpsNPhotonPerMIP(100.0);
  
  StFmsPointMaker* pointMaker = (StFmsPointMaker*) chain->GetMaker("StFmsPointMaker");
  pointMaker->setMergeSmallToLarge(merge);

  gSystem->Load("StFmsFpsMaker");
  StFmsFpsMaker* fmsfps = new StFmsFpsMaker(); 
  fmsfps->setPrint(4);
  outfile.ReplaceAll(".root",".fmsfps.root");
  fmsfps->setQA(outfile.Data());

  if(print>=9){
      gSystem->Load("StFmsEventDisplay");
      StFmsEventDisplay* fmsed = new StFmsEventDisplay();
      fmsed->setMaxEvents(100);
      //outfile.ReplaceAll(".fmsfps.root",".eventDisplay.pdf");
      outfile.ReplaceAll(".fmsfps.root",".eventDisplay.png");
      fmsed->setFileName(outfile.Data());
      if(print==10) fmsed->setFilter(1);
  }

  chain->Init();
  StMaker::lsMakers(chain);
  chain->EventLoop(mnEvents,nEvents);  
  chain->Finish(); 
}
Example #23
0
void Process(TString fname, TString myRooWS, int toMass, int fromMass, int Bin)
{

  gROOT->SetStyle("Plain");
  TFile * file = new TFile(fname.Data(), "READ");
  std::cout << "reading " << fname.Data() << std::endl;
  TString outname("newcards/");
  outname.Append(massS[toMass]);
  outname.Append("/");
  fname.ReplaceAll("110","");
  fname.ReplaceAll("115","");
  fname.ReplaceAll("120","");
  fname.ReplaceAll("125","");
  fname.ReplaceAll("130","");
  fname.ReplaceAll("135","");
  fname.ReplaceAll("140","");
  fname.ReplaceAll("145","");
  fname.ReplaceAll("150","");
  fname.ReplaceAll("/","");

  if(fname.Contains("Zn") && (Bin == 0)) fname.ReplaceAll(".root","Low.root");
  if(fname.Contains("Zn") && (Bin == 1)) fname.ReplaceAll(".root","Med.root");
  if(fname.Contains("Zn") && (Bin == 2)) fname.ReplaceAll(".root","High.root");
  
  outname.Append(fname.Data());
  outname.ReplaceAll("Wtn_BDT_newBinning_","vhbb_Wtn_8TeV");
  outname.ReplaceAll("WS_BDT_H_","");
  outname.ReplaceAll("WS_BDT_M_","");
  std::cout << "FILENAME: " << outname.Data() <<std::endl;

  TFile * outfile = new TFile(outname.Data(), "RECREATE");

  using namespace RooFit;
  RooWorkspace *myWS = new RooWorkspace(myRooWS.Data(),myRooWS.Data());

  if(fname.Contains ("Zmm") | fname.Contains ("Zee") )  {myWS->factory("CMS_vhbb_BDT_Zll_8TeV[-1.,1.]"); bins = 15;}
  else if(fname.Contains ("Zn") && (Bin == 0))  {myWS->factory("CMS_vhbb_BDT_ZnunuLowPt_8TeV[-1.,1.]"); bins = 24;}
  else if(fname.Contains ("Zn") && (Bin == 1))  {myWS->factory("CMS_vhbb_BDT_ZnunuMedPt_8TeV[-1.,1.]"); bins = 32;}
  else if(fname.Contains ("Zn") && (Bin == 2))  {myWS->factory("CMS_vhbb_BDT_ZnunuHighPt_8TeV[-1.,1.]"); bins = 40;}
  else if(fname.Contains("We") | fname.Contains("Wm")) {myWS->factory("CMS_vhbb_BDT_Wln_8TeV[-1.,1.]"); bins = 48;}
  else if(fname.Contains("Wt")) {myWS->factory("BDT[-1.,1.]"); bins = 18;}


  RooWorkspace *tempWS =  (RooWorkspace*) file->Get(myRooWS.Data());
  
  for(int s=0; s<NS; s++ ){
      makeSystPlot(tempWS, myWS,  systs[s], Bin, toMass, fromMass );
    }
  


  myWS->writeToFile(outname.Data());  
  std::cout << std::endl << std::endl << std::endl << std::endl << "///////////////////////////" << std::endl;
  std::cout << outname.Data() << " written" << std::endl;
  std::cout << "///////////////////////////" << std::endl << std::endl << std::endl;
  outfile->Write();
  outfile->Close();


}
Example #24
0
File: basic.C Project: Y--/root
void basic() {
// read file $ROOTSYS/tutorials/tree/basic.dat
// this file has 3 columns of float data
   TString dir = gROOT->GetTutorialsDir();
   dir.Append("/tree/");
   dir.ReplaceAll("/./","/");
   ifstream in;
   in.open(Form("%sbasic.dat",dir.Data()));

   Float_t x,y,z;
   Int_t nlines = 0;
   auto f = TFile::Open("basic.root","RECREATE");
   TH1F h1("h1","x distribution",100,-4,4);
   TNtuple ntuple("ntuple","data from ascii file","x:y:z");

   while (1) {
      in >> x >> y >> z;
      if (!in.good()) break;
      if (nlines < 5) printf("x=%8f, y=%8f, z=%8f\n",x,y,z);
      h1.Fill(x);
      ntuple.Fill(x,y,z);
      nlines++;
   }
   printf(" found %d points\n",nlines);

   in.close();

   f->Write();
}
Example #25
0
void KVNumberList::Remove(Int_t n)
{
    //Remove value 'n' to the list
    TString tmp = " "+TString(GetExpandedList())+" ";
    tmp.ReplaceAll(Form(" %d ",n)," ");
    SetList(tmp);
}
Example #26
0
const Char_t *KVRemoteDataRepository::GetFullPathToTransferFile(KVDataSet *
                                                                dataset,
                                                                const
                                                                Char_t *
                                                                datatype,
                                                                const
                                                                Char_t *
                                                                runfile)
{
   //Used by KVDataTransfer.
   //Returns the full path needed to transfer a runfile belonging to the given dataset
   //either from or to the repository, using sftp or bbftp etc.
   //This is a concatenation of the repository root directory with the dataset
   //subdirectories and filename.
   //However, for a remote data repository, the type of operating system may be different
   //to gSystem, i.e. the system on the local machine. In this case, gSystem->ConcatFileName
   //may not necessarily give the right paths for the remote machine: e.g. local machine
   //is Windows, remote repository is Linux, paths for Linux machine will have a mix of
   //"/" and "\" in them.
   //We try to remedy this by looking at fLocalrootdir: if it contains "/" we take the result
   //of the concatenation performed by KVDataRepository::GetFullPathToTransferFile
   //and replace any "\" by "/", and vice versa.

   static TString path;
   path =
       KVDataRepository::GetFullPathToTransferFile(dataset, datatype,
                                                   runfile);
   if (fLocalrootdir.Contains("/"))
//      path.ReplaceAll("\\", "/");
      path = gSystem->UnixPathName(path.Data());
   else if (fLocalrootdir.Contains("\\"))
      path.ReplaceAll("/", "\\");
   return path.Data();
}
//______________________________________________________________________________
void HtmlObjTable::BuildTable()
{
	// Build part of table with values.
	
	for (int i = 0; i < (fNValues+1); i++) {
		if (i%2)
			fHtml += "<tr bgcolor=e0e0ff>";
		else
			fHtml += "<tr bgcolor=ffffff>";
		
		TString name = fName;
		name.ReplaceAll(" ", "_");
		// checkboxes
		//	fHtml += "<td bgcolor=d0d0ff align=\"center\">";
		//	fHtml += "<input type=\"checkbox\" name=\"";
		//	fHtml += name;
		//	fHtml += Form("[%d]\">",i);
		//	fHtml += "</td>";
		fHtml += Form("<td> %s", fRowNames[i].Data());
		fHtml += "</td>";
		for (int j = 1; j < fNFields; j++) {
			fHtml += "<td width=";
			fHtml += Form("%d%%", 100/fNFields);
			fHtml += " align=\"center\"";
			fHtml += ">";
			if(fIsInt[j])
				fHtml += Form("%2i", (int)fValues[j][i]);
			else
				fHtml += Form("%1.2f", fValues[j][i]);
			fHtml += "</td>";
		}
		fHtml += "</tr> ";
	}
}
Example #28
0
void TREEendlog(TString filename)
{	gROOT->Reset(); // reset ROOT
	
	ifstream edfile; // new stream 'edfile' to the data file

	edfile.open(filename, ios_base::in); // read and write access to the data file	
	if (edfile.good()){
		TString treename = filename + ".root";
		cout << "Creating tree " << treename << endl;
		TFile* file=TFile::Open(treename.Data(), "RECREATE"); // recreating a new file wherein the tree will be saved.
		//++++++++ options: "CREATE" ~ create and open a new file if it does not already exist ++++++++++++++++++++++++++++++
		//+++++++++++++++++ "RECREATE" ~ create and overwrite if existing +++++++++++++++++++++++++++++++++++++++++++++++++++

		cout << "Reading data from " << filename << endl;
		TString bdescriptor; // branch descriptor 'bdescriptor' as a empty string
		bdescriptor.ReadLine(edfile); // read branch descriptor from file
		bdescriptor.ReplaceAll(" ",":"); // format branch descriptor for root ("x y z" -> "x:y:z")

		TNtupleD* tree=new TNtupleD("mytree", "mytree", bdescriptor.Data()); // creating a new TTree([treename],[treetitle])	
		Int_t n = tree->GetNvar();
		while (1){
			for (int i = 0; i < n; i++) edfile >> tree->GetArgs()[i]; // read values into Arg-array of tree
			if (!edfile.good()) break;
			tree->Fill(tree->GetArgs()); // fill Args into tree
		}
		
		edfile.close(); // closing the stream 'edfile'
		file->Write();
		tree->Print(); // output of the tree overview
		delete tree;
		delete file;
	}
Example #29
0
  /** 
   * Get the name of the registered data set
   * 
   * 
   * @return Name of the registered data set
   */
  static TString RegisteredDataset()
  {
    TString ret;

    AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
    AliVEventHandler*   oh  = mgr->GetOutputEventHandler();
    if (!oh) { 
      Warning("OutputUtilities::GetOutputDataSet", 
	      "No outout event handler defined");
      return ret;
    }
    AliAnalysisDataContainer* co  = mgr->GetCommonOutputContainer();
    if (!co) { 
      Warning("OutputUtilities::GetOutputDataSet", 
	      "No common output container defined");
      return ret;
    }
    if (!co->IsRegisterDataset()) { 
      Info("OutputUtilities::GetOutputDataSet", 
	   "Common output is not registered as dataset");
      return ret;
    }
    ret = oh->GetOutputFileName();
    // ret.ReplaceAll("TTree", "");
    ret.ReplaceAll(".root", "");
    // ret.Append(co->GetTitle());

    return ret;
  }
Example #30
0
template <class HolderClass> bool read(const char *testname, int nEntry = 0, bool readother = false) {

   // for each dirname 
   TString dirname = gROOT->GetVersion();
   dirname.ReplaceAll(".","-");
   dirname.ReplaceAll("/","-");

   bool result = true;
   result &= read<HolderClass>(dirname,testname, nEntry, /*current=*/true);

   if (readother) {
      TList listOfDirs;
      listOfDirs.SetOwner(kTRUE);
      fillListOfDir(listOfDirs);
      
      TIter next(&listOfDirs);
      while (TObjString *dir = (TObjString*)next()) {
         if (dirname != dir->GetName()) {
            std::cout << "Testing older file format from: " << dir->GetName() << std::endl;
            result &= read<HolderClass>(dir->GetName(),testname, nEntry, /*current=*/ false);         
         }
      }
   }

   return result;
}