TString par2latex(const TString& parname)
{
  if (parname.EqualTo("lZ") )  return "par_{1}";
  if (parname.EqualTo("dkg") ) return "par_{2}";

  return "UNKNOWN PAR "+parname;
}
float parmax(const TString& parname)
{
  if (parname.EqualTo("lZ") )  return 0.03;
  if (parname.EqualTo("dkg") ) return 0.15;

  return -999;
}
float parinc(const TString& parname)
{
  if (parname.EqualTo("lZ") )  return 0.0006;
  if (parname.EqualTo("dkg") ) return 0.003;

  return -999;
}
Example #4
0
//_______________________________________________________________________
void LoadFileNamesToCompare(TString TrackpT ="0.3to1.0",TString Sys = "pPb"){
  
  Int_t skip3to5pPb=0;
  if(Sys.EqualTo("pp")){
    nhistos=9;
  }
  else if(Sys.EqualTo("pPb")){
    nhistos=6; 
    skip3to5pPb=3;
  }
  filenames=new TString[nhistos];
  Printf(" -------------------> Adding %s in %s coll",TrackpT.Data(),Sys.Data());
  if(Sys.EqualTo("pp")){
    filenames[0] = Form("%s/CanvaAndVariedHisto%sDzeroPt3to5assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
    filenames[1] = Form("%s/CanvaAndVariedHisto%sDplusPt3to5assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
    filenames[2] = Form("%s/CanvaAndVariedHisto%sDstarPt3to5assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
  }
  filenames[3-skip3to5pPb] = Form("%s/CanvaAndVariedHisto%sDzeroPt5to8assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
  filenames[4-skip3to5pPb] = Form("%s/CanvaAndVariedHisto%sDplusPt5to8assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
  filenames[5-skip3to5pPb] = Form("%s/CanvaAndVariedHisto%sDstarPt5to8assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
  filenames[6-skip3to5pPb] = Form("%s/CanvaAndVariedHisto%sDzeroPt8to16assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
  filenames[7-skip3to5pPb] = Form("%s/CanvaAndVariedHisto%sDplusPt8to16assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
  filenames[8-skip3to5pPb] = Form("%s/CanvaAndVariedHisto%sDstarPt8to16assocPt%s.root",inputdirectory.Data(),Sys.Data(),TrackpT.Data());
  
}  
Example #5
0
  /** 
   * Create our tasks.  This uses the interpreter to make the object.
   * 
   * @param mgr 
   */
  void CreateTasks(AliAnalysisManager* mgr)
  {
    Info("CreateTasks", "Loading code");
    fRailway->LoadSource("FixPaths.C");
    fRailway->LoadSource("AliAODSimpleHeader.C");
    fRailway->LoadSource("AliAODTracklet.C");
    fRailway->LoadSource("AliTrackletWeights.C");
    fRailway->LoadSource("AliTrackletAODUtils.C");
    fRailway->LoadSource("AliTrackletAODdNdeta.C");

    // --- Create the task using interpreter -------------------------
    Bool_t   mc = fOptions.Has("mc");
    if (!mc) mc = fRailway->IsMC();     
    Long_t ret  =
      gROOT->ProcessLine(Form("AliTrackletAODdNdeta::Create(%d,\"%s\")",mc,
			      fOptions.AsString("reweigh")));
    AliAnalysisTaskSE* task = reinterpret_cast<AliAnalysisTaskSE*>(ret);
    if (!task) return;
    
    // --- Figure out the trigger options ----------------------------
    TString trg = fOptions.Get("trig"); trg.ToUpper();
    UInt_t  sel = AliVEvent::kINT7;
    if      (trg.EqualTo("MB"))    sel = AliVEvent::kMB;
    else if (trg.EqualTo("V0AND")) sel = AliVEvent::kINT7;
    else if (trg.EqualTo("V0OR"))  sel = AliVEvent::kCINT5;
    else if (trg.EqualTo("ANY"))   sel = AliVEvent::kAny;
    task->SelectCollisionCandidates(sel);

    // --- Figure out calculation mode -------------------------------
    TString calc = fOptions.Get("reweigh-calc"); calc.ToUpper();
    UChar_t mcal = 0;
    if      (calc.BeginsWith("PROD")) mcal = 0;
    else if (calc.BeginsWith("SQ"))   mcal = 1;
    else if (calc.BeginsWith("SUM"))  mcal = 2;
    else if (calc.BeginsWith("AV"))   mcal = 3;
    
    // --- Set various options on task -------------------------------
    const char* defCent = DefaultCentBins();
    FromOption(task, "CentralityMethod","cent", 	    "V0M");
    FromOption(task, "CentralityAxis",  "cent-bins",        defCent);
    FromOption(task, "AbsMinCent",      "abs-min-cent",    -1.);
    FromOption(task, "MaxNTracklet",    "max-ntracklet",    6000.);
    FromOption(task, "EtaAxis",         "eta-bins",         "r16:2");
    FromOption(task, "IPzAxis",         "ipz-bins",         "u15");
    FromOption(task, "DeltaCut",	"delta-cut",	    1.5);
    FromOption(task, "TailDelta",	"tail-delta",	    5.);
    FromOption(task, "TailMaximum",	"tail-max",	    -1);
    FromOption(task, "MaxDelta",	"max-delta",	    25.);
    FromOption(task, "DPhiShift",	"dphi-shift",	    0.0045);
    FromOption(task, "ShiftedDPhiCut",	"shifted-dphi-cut",-1.);
    FromOption(task, "WeightMask",      "reweigh-mask",     0xFF);
    FromOption(task, "WeightVeto",      "reweigh-veto",     0x0);
    SetOnTask (task, "WeightCalc",                          mcal);
    FromOption(task, "WeightInverse",   "reweigh-inv",      false);
    task->Print("");    
  }
Example #6
0
//______________________________________________________________________________
void ProcessEnvironment()
{
  //
  // Collision system configuration
  //
  iCollisionType = kpp;
  if (gSystem->Getenv("CONFIG_SYSTEM")) {
    Bool_t valid = kFALSE;
    for (Int_t icoll = 0; icoll < kNSystem; icoll++)
      if (strcmp(gSystem->Getenv("CONFIG_SYSTEM"), CollisionSystem[icoll]) == 0) {
        iCollisionType = icoll;
        valid = kTRUE;
        break;
      }
    if (!valid) {
      printf(">>>>> Unknown collision system configuration: %s \n", gSystem->Getenv("CONFIG_SYSTEM"));
      abort();
    }
  }

//   // run number
//   run_number = -1;
//   if (gSystem->Getenv("CONFIG_RUN"))
//     run_number = atoi(gSystem->Getenv("CONFIG_RUN"));
//   if (run_number <= 0) {
//     printf(">>>>> Invalid run number: %d \n", run_number);
//     abort();
//   }

  //
  // Setting this to kTRUE will disable some not needed analysis tasks for a muon_calo pass
  //
  isMuonOnly = kFALSE;
  isMuonCalo = kFALSE;
  if (gSystem->Getenv("CONFIG_QA"))
  {
    TString configstr = gSystem->Getenv("CONFIG_QA");
    if (configstr.Contains("MuonOnly")) isMuonOnly = kTRUE;
    else if (configstr.Contains("Muon")) isMuonCalo = kTRUE;
  }
  
  //
  // Figure out the run_flag
  //
  run_flag = 1500;
  if (gSystem->Getenv("CONFIG_YEAR"))
    year = atoi(gSystem->Getenv("CONFIG_YEAR"));
  if (gSystem->Getenv("CONFIG_PERIOD"))
    periodName = gSystem->Getenv("CONFIG_PERIOD");
  if(year<2015)  run_flag =1100;
  if(year<=2010) {
    run_flag =1000;
    if (periodName.EqualTo("LHC10h"))
      run_flag = 1001;
  }
}
Example #7
0
  /** 
   * Get a directory 
   * 
   * @param in    Input stream
   * @param runNo The run number 
   * @param mc    True for MC 
   * 
   * @return true on success 
   */
  Bool_t GetDir(std::istream& in, ULong_t runNo, Bool_t mc)
  {
    TString line;
    TString tgt3("/catalogue/index.jsp");
    do { 
      line.ReadLine(in);
      // Info("", "line=%s", line.Data());
      if (!line.Contains(tgt3)) continue;
      if (fDebug) Info("", line);
      Int_t tmp         = mc ? line.Index(">")+1 : 0;
      Int_t first       = line.Index(">", tmp);
      Int_t last        = line.Index("<",first+1);
      if (first == kNPOS || last == kNPOS) { 
	Error("GetDir", "Failed to get directory from %s", line.Data());
	return false;
      }
      
      TString dir = line(first+1,last-first-1);
	
      if (fDebug) Info("", "Got run %lu %s", runNo, dir.Data());
      TString path, pass;
      if (!GetPathPass(dir, runNo, path, pass)) return false;
      
      if (fDebug) Info("", "Got run %lu %s %s", runNo,path.Data(),pass.Data());

      if      (fPath.IsNull()) fPath = path;
      else if (!fPath.EqualTo(path)) { 
	Warning("GetDir", "Run %lu location %s not %s", 
	      runNo, path.Data(), fPath.Data());
	return false;
      }

      if      (fPass.IsNull()) fPass = pass;
      else if (!fPass.EqualTo(pass)) { 
	Warning("GetDir", "Run %lu pass %s not %s", 
	      runNo, pass.Data(), fPass.Data());
	return false;
      }
      break;
    } while (!in.eof());
    return true;
  }
Example #8
0
/** 
 * Function to run a train.  
 * 
 * @param name  Name of the train. 
 * @param cls   class name of train setup
 * @param uri   Exection URI  
 * @param opts  Optons 
 * 
 * @return true on success
 *
 * @ingroup pwglf_forward_trains
 */
Bool_t RunTrain(const TString& name, const TString& cls, 
		const TUrl& uri,     const TString& opts)
{
  // Check for help 
  if (name.IsNull() || name.EqualTo("help", TString::kIgnoreCase) || 
      cls.IsNull()  || cls.EqualTo("help", TString::kIgnoreCase) || 
      !uri.IsValid()) {
    PlainUsage();
    return true;
  }
  
  Bool_t verb = opts.Contains("verbose");
  // Build our helpers 
  if (!BuildRailways(verb, false, true)) return false;

  // Tokenize options 
  if (!opts.EndsWith(",")) opts.Append(",");
  opts.Append("url="); 
  opts.Append(uri.GetUrl());
  TObjArray* optList = opts.Tokenize(",");
  return TrainSetup::Main(name, cls, optList, false);
}
float parmin(const TString& parname)
{
  if (parname.EqualTo("cwww") )  return -20;
  if (parname.EqualTo("ccw") ) return -20;
  if (parname.EqualTo("cb") ) return -105;
  if (parname.EqualTo("dg1z") ) return -0.15;
  if (parname.EqualTo("dkz") ) return -0.1;
  if (parname.EqualTo("lZ") ) return -0.075;

  return -999;
}
TString par2latex(const TString& parname)
{
  if (parname.EqualTo("cwww") )  return "c_{WWW}/#Lambda^{2} (TeV^{-2})";
  if (parname.EqualTo("ccw") ) return "c_{W}/#Lambda^{2} (TeV^{-2})";
  if (parname.EqualTo("cb") ) return "c_{B}/#Lambda^{2} (TeV^{-2})";
  if (parname.EqualTo("dg1z") ) return "#Deltag_{1}^{Z}";
  if (parname.EqualTo("dkz") ) return "#Delta#kappa_{Z}";
  if (parname.EqualTo("lZ") ) return "#lambda_{Z}";

  return "UNKNOWN PAR "+parname;
}
float parinc(const TString& parname)
{
  if (parname.EqualTo("cwww") )  return 0.4;
  if (parname.EqualTo("ccw") ) return 0.6;
  if (parname.EqualTo("cb") ) return 1.2;
  if (parname.EqualTo("dg1z") ) return 0.0002;
  if (parname.EqualTo("dkz") ) return 0.0002;
  if (parname.EqualTo("lZ") ) return 0.0002;

  return -999;
}
float parmax(const TString& parname)
{
  if (parname.EqualTo("cwww") )  return 20;
  if (parname.EqualTo("ccw") ) return 35;
  if (parname.EqualTo("cb") ) return 150;
  if (parname.EqualTo("dg1z") ) return 0.2;
  if (parname.EqualTo("dkz") ) return 0.15;
  if (parname.EqualTo("lZ") ) return 0.075;


  return -999;
}
Example #13
0
//------------------------------------------------------------------------------
// AddProcess
//------------------------------------------------------------------------------
void AddProcess(TString kind, TString filename)
{
  TString fullname = inputdir + filename + ".root";

  if (gSystem->AccessPathName(fullname))
    {
      printf(" [MVA::AddProcess] Cannot access %s\n", fullname.Data());
      return;
    }

  TFile* file = new TFile(fullname, "read");

  TTree* tree = (TTree*)file->Get("latino");

  if (kind.EqualTo("signal"))
    _signaltree = tree;
  else
    _mctree.push_back(tree);
}
Example #14
0
HistoTransform::SubDirectory* HistoTransform::findSubDirs(string subDirName, bool identical) {

  if (identical && subDirName == "") {
    SubDirectory* subDir = new SubDirectory();
    subDir -> dir = m_inFile;
    m_subDirs.push_back(subDir);
    return subDir;
  }

  TKey* key;
  TIter nextkey(m_inFile -> GetListOfKeys());
  while ((key = (TKey*) nextkey())) {
    TClass* cl = gROOT -> GetClass(key -> GetClassName());
    if (!cl) continue;
    if (cl -> InheritsFrom(TDirectory::Class())) {
      TString name = key -> GetName();
      if ((name.Contains(subDirName) && !identical) || name.EqualTo(subDirName)) {
        cout << "INFO: found subdirectory '" << name.Data() << "'" << endl;
        SubDirectory* subDir = new SubDirectory();
        m_inFile -> cd(name);
        subDir -> dir = gDirectory;
        m_subDirs.push_back(subDir);
        if (identical)
          return subDir;
        else
          addBackground(subDir, "bkg");
      }
    }
  }

  if (m_subDirs.size() == 0 && !identical) {
    cout << "INFO: no subdirectory found, using root directory" << endl;
    SubDirectory* subDir = new SubDirectory();
    subDir -> dir = m_inFile;
    m_subDirs.push_back(subDir);
    addBackground(subDir, "bkg");
    return subDir;
  }
  if (identical) {
    cout << "WARNING: subdirectory '" << subDirName << "' not found!" << endl;
  }
  return 0;
}
Example #15
0
void draw_from_trees(TString var, TCut other_cuts,
		     TString weights, TString title, int nbinsx, 
		     double xlow, double xup,
		     TString options="plotSig:plotLog:plotData",
		     double cut_low=-1, double cut_high=-1,
		     TString plot_title="default")
{

  bool plotSig = options.Contains("plotSig") && (!options.Contains("!plotSig"));
  bool plotLog = options.Contains("plotLog") && (!options.Contains("!plotLog"));
  bool plotData = options.Contains("plotData") && (!options.Contains("!plotData"));
  bool sigStack = options.Contains("sigStack") && (!options.Contains("!sigStack"));

  // Book histograms
  TH1D * httbar = new TH1D("ttbar" , title, nbinsx, xlow, xup);
  TH1D * hqcd = new TH1D("qcd" , title, nbinsx, xlow, xup);
  TH1D * hznn = new TH1D("znn" , title, nbinsx, xlow, xup);
  TH1D * hwjets = new TH1D("wjets" , title, nbinsx, xlow, xup);
  TH1D * hother = new TH1D("other" , title, nbinsx, xlow, xup);
  TH1D * hmc_exp = new TH1D("mc_exp" , title, nbinsx, xlow, xup);
  TH1D * hsingle_top = new TH1D("single_top" , title, nbinsx, xlow, xup);  
  TH1D * ht1bbbb_1500_100 = new TH1D("t1bbbb_1500_100" , title, nbinsx, xlow, xup);
  TH1D * ht1bbbb_1000_900 = new TH1D("t1bbbb_1000_900" , title, nbinsx, xlow, xup);
  TH1D * ht1tttt_1500_100 = new TH1D("t1tttt_1500_100" , title, nbinsx, xlow, xup);
  TH1D * ht1tttt_1200_800 = new TH1D("t1tttt_1200_800" , title, nbinsx, xlow, xup);
  TH1D * ht1qqqq_1400_100 = new TH1D("t1qqqq_1400_100" , title, nbinsx, xlow, xup);
  TH1D * ht1qqqq_1000_800 = new TH1D("t1qqqq_1000_800" , title, nbinsx, xlow, xup);

  // Format cuts
  TCut cut(other_cuts);

  // TCut ttbar_weight("(weightppb*4000)/top_pt_weight_official");

  TCut ttbar_weight("(3.17760399999999981e-05*4000)");

  cout << "Filling histograms for " << var.Data() << endl;
  ttbar_ch->Project("ttbar",var,(cut)*ttbar_weight);
  qcd_ch->Project("qcd",var,cut*weights);
  znn_ch->Project("znn",var,cut*weights);
  wjets_ch->Project("wjets",var,(cut)*weights);
  other_ch->Project("other",var,cut*weights);
  single_top_ch->Project("single_top",var,cut*weights);
  t1bbbb_1500_100_ch->Project("t1bbbb_1500_100",var,(cut)*weights);
  t1bbbb_1000_900_ch->Project("t1bbbb_1000_900",var,(cut)*weights);
  t1tttt_1500_100_ch->Project("t1tttt_1500_100",var,(cut)*weights);
  t1tttt_1200_800_ch->Project("t1tttt_1200_800",var,(cut)*weights);
  t1qqqq_1400_100_ch->Project("t1qqqq_1400_100",var,(cut)*weights);
  t1qqqq_1000_800_ch->Project("t1qqqq_1000_800",var,(cut)*weights);


  bool addOverflow(true);
  Double_t e_overflow(0.), i_overflow(0.);
  if (addOverflow) {
    i_overflow=httbar->IntegralAndError(nbinsx,nbinsx+1,e_overflow);
    httbar->SetBinContent(nbinsx, i_overflow);
    httbar->SetBinError(nbinsx, e_overflow);
    i_overflow=hqcd->IntegralAndError(nbinsx,nbinsx+1,e_overflow);
    hqcd->SetBinContent(nbinsx, i_overflow);
    hqcd->SetBinError(nbinsx, e_overflow);
    i_overflow=hznn->IntegralAndError(nbinsx,nbinsx+1,e_overflow);
    hznn->SetBinContent(nbinsx, i_overflow);
    hznn->SetBinError(nbinsx, e_overflow);
    i_overflow=hwjets->IntegralAndError(nbinsx,nbinsx+1,e_overflow);
    hwjets->SetBinContent(nbinsx, i_overflow);
    hwjets->SetBinError(nbinsx, e_overflow);
    i_overflow=hsingle_top->IntegralAndError(nbinsx,nbinsx+1,e_overflow);
    hsingle_top->SetBinContent(nbinsx, i_overflow);
    hsingle_top->SetBinError(nbinsx, e_overflow);
    i_overflow=hother->IntegralAndError(nbinsx,nbinsx+1,e_overflow);
    hother->SetBinContent(nbinsx, i_overflow);
    hother->SetBinError(nbinsx, e_overflow);
    i_overflow=ht1bbbb_1500_100->IntegralAndError(nbinsx,nbinsx+1,e_overflow);
    ht1bbbb_1500_100->SetBinContent(nbinsx, i_overflow);
    ht1bbbb_1500_100->SetBinError(nbinsx, e_overflow);
    i_overflow=ht1bbbb_1000_900->IntegralAndError(nbinsx,nbinsx+1,e_overflow);
    ht1bbbb_1000_900->SetBinContent(nbinsx, i_overflow);
    ht1bbbb_1000_900->SetBinError(nbinsx, e_overflow);
    i_overflow=ht1tttt_1500_100->IntegralAndError(nbinsx,nbinsx+1,e_overflow);
    ht1tttt_1500_100->SetBinContent(nbinsx, i_overflow);
    ht1tttt_1500_100->SetBinError(nbinsx, e_overflow);
    i_overflow=ht1tttt_1200_800->IntegralAndError(nbinsx,nbinsx+1,e_overflow);
    ht1tttt_1200_800->SetBinContent(nbinsx, i_overflow);
    ht1tttt_1200_800->SetBinError(nbinsx, e_overflow);
    i_overflow=ht1qqqq_1400_100->IntegralAndError(nbinsx,nbinsx+1,e_overflow);
    ht1qqqq_1400_100->SetBinContent(nbinsx, i_overflow);
    ht1qqqq_1400_100->SetBinError(nbinsx, e_overflow);
    i_overflow=ht1qqqq_1000_800->IntegralAndError(nbinsx,nbinsx+1,e_overflow);
    ht1qqqq_1000_800->SetBinContent(nbinsx, i_overflow);
    ht1qqqq_1000_800->SetBinError(nbinsx, e_overflow);
  }

  
  // Add up MC histograms
  hmc_exp->Add(httbar);
  hmc_exp->Add(hqcd);
  hmc_exp->Add(hznn);
  hmc_exp->Add(hwjets);
  hmc_exp->Add(hsingle_top);
  hmc_exp->Add(hother);


  double binwidth = (xup - xlow) / nbinsx;
  TString ytitle = Form("Events / %.3f", binwidth);
  hmc_exp->GetXaxis()->SetTitle(httbar->GetXaxis()->GetTitle());
  hmc_exp->GetYaxis()->SetTitle(ytitle);
  cout << "... DONE: add all backgrounds to mc_exp." << endl;
  
  Double_t ttbar_e(0.), qcd_e(0.), znn_e(0.), wjets_e(0.), other_e(0.), single_top_e(0.), bg_tot_e(0.), t1tttt_1500_100_e(0.);
  double ttbar_n(httbar->IntegralAndError(0,nbinsx+1, ttbar_e));
  double qcd_n(hqcd->IntegralAndError(0,nbinsx+1, qcd_e));
  double znn_n(hznn->IntegralAndError(0,nbinsx+1, znn_e));
  double wjets_n(hwjets->IntegralAndError(0,nbinsx+1, wjets_e));
  double other_n(hother->IntegralAndError(0,nbinsx+1, other_e));
  double single_top_n(hsingle_top->IntegralAndError(0,nbinsx+1, single_top_e));
  double bg_tot(hmc_exp->IntegralAndError(0,nbinsx+1, bg_tot_e));
  double t1tttt_1500_100_n(ht1tttt_1500_100->IntegralAndError(0,nbinsx+1, t1tttt_1500_100_e));


  printf("Counts before cut: %s\n",var.Data());
  printf("&ttbar&qcd&znn&wjets&single top&other&t1bbbb_1500_100\\\\ \n");
  printf("%s & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f \\\\\n",
	 var.Data(),
	 ttbar_n,ttbar_e,
	 qcd_n,qcd_e,
	 znn_n,znn_e,
	 wjets_n,wjets_e,
	 single_top_n,single_top_e,
	 other_n,other_e,
	 //	 hmc_exp->GetBinContent(1), hmc_exp->GetBinError(1),
	 bg_tot,bg_tot_e,
	 t1tttt_1500_100_n,t1tttt_1500_100_e);


  cout << "... DONE: filled histograms." << endl;
 
  if (sigStack) {
    for (int bin(0); bin<nbinsx; bin++) {
      ht1bbbb_1500_100->SetBinContent(bin+1, hmc_exp->GetBinContent(bin+1));
      ht1bbbb_1000_900->SetBinContent(bin+1, hmc_exp->GetBinContent(bin+1));
      ht1tttt_1500_100->SetBinContent(bin+1, hmc_exp->GetBinContent(bin+1));
      ht1tttt_1200_800->SetBinContent(bin+1, hmc_exp->GetBinContent(bin+1));
    }
  }
 
  THStack * hs = new THStack("hs", "");
  hs->Add(hother); 
  hs->Add(hsingle_top);
  hs->Add(hwjets);
  hs->Add(hznn);
  if (httbar->Integral()>hqcd->Integral()) {
    hs->Add(hqcd);
    hs->Add(httbar);
  } else {
    hs->Add(httbar);
    hs->Add(hqcd);
  }


  //hs->GetYaxis()->SetTitle("Events / 5 fb^{-1}");
  //hs->GetXaxis()->SetTitle(httbar->GetXaxis()->GetTitle());

  // Setup histogram styles
  set_style(httbar, "ttbar");
  set_style(hqcd, "qcd");
  set_style(hznn, "znn");
  set_style(hwjets, "wjets");
  set_style(hother, "other");
  set_style(hsingle_top, "single_top");

  // Setup auxiliary histograms (ratios, errors, etc)
  TH1D * staterr = (TH1D *) hmc_exp->Clone("staterr");
  staterr->Sumw2();
  //staterr->SetFillColor(kRed);
  staterr->SetFillColor(kGray+3);
  staterr->SetMarkerSize(0);
  staterr->SetFillStyle(3013);

 
  // Setup legends
  TLegend * leg1 = new TLegend(0.48, 0.6, 0.72, 0.92);
  set_style(leg1,0.025);
  if (plotData) leg1->AddEntry(hsingle_top, "Data", "pel");
  if (plotSig) {
    leg1->AddEntry(ht1bbbb_1500_100, "#splitline{T1bbbb}{(1500,100) GeV}", "l");
    leg1->AddEntry(ht1bbbb_1000_900, "#splitline{T1bbbb}{(1000,900) GeV}", "l");
    leg1->AddEntry(ht1tttt_1500_100, "#splitline{T1tttt}{(1500,100) GeV}", "l");
    leg1->AddEntry(ht1tttt_1200_800, "#splitline{T1tttt}{(1200,800) GeV}", "l");
    leg1->AddEntry(ht1qqqq_1400_100, "#splitline{T1qqqq}{(1400,100) GeV}", "l");
    leg1->AddEntry(ht1qqqq_1000_800, "#splitline{T1qqqq}{(1000,800) GeV}", "l");
  }
 

  TLegend * leg2 = new TLegend(0.72, 0.6, 0.94, 0.92);
  set_style(leg2,0.025);
  if (httbar->Integral()>hqcd->Integral()) {
    leg2->AddEntry(httbar, "t#bar{t}", "f");
    leg2->AddEntry(hqcd, "QCD", "f");
  } else {
    leg2->AddEntry(hqcd, "QCD", "f");
    leg2->AddEntry(httbar, "t#bar{t}", "f");
  }
  leg2->AddEntry(hznn, "Z+jets", "f");
  leg2->AddEntry(hwjets, "W+jets", "f");
  leg2->AddEntry(hsingle_top, "Single Top", "f");
  leg2->AddEntry(hother, "Other", "f");
  leg2->AddEntry(staterr, "MC uncert.", "f");
    
  double ymax = hs->GetMaximum();
  if (ht1tttt_1500_100->GetMaximum()>ymax) ymax=ht1tttt_1500_100->GetMaximum();
  if (ht1bbbb_1500_100->GetMaximum()>ymax) ymax=ht1bbbb_1500_100->GetMaximum();
  if (ht1qqqq_1400_100->GetMaximum()>ymax) ymax=ht1qqqq_1400_100->GetMaximum();


  if(plotLog) {
    hs->SetMaximum(200*ymax);
    hs->SetMinimum(0.1);
  }
  else {
    hs->SetMaximum(2*ymax);
    if (plot_title.Contains("baseline")) hs->SetMaximum(1.3*ymax);
  }
  // Vertical lines for cuts
  TLine* line_low = new TLine(cut_low,0,cut_low,1.5*ymax);
  TLine* line_high = new TLine(cut_high,0,cut_high,1.5*ymax);
  set_style(line_low);
  set_style(line_high);

  // Setup canvas and pads  
  TCanvas * c1 = new TCanvas("c1", "c1", 700, 700);
  TPad * pad1 = new TPad("pad1", "top pad" , 0.0, 0.3, 1.0, 1.0);
  TPad * pad2 = new TPad("pad2", "bottom pad", 0.0, 0.0, 1.0, 0.3);
  if(plotData) {
    pad1->SetBottomMargin(0.0);
    pad1->Draw();
    pad2->SetTopMargin(0.0);
    pad2->SetBottomMargin(0.35);
    pad2->Draw();
    pad1->cd();
    pad1->SetLogy(plotLog);
  }
  else {
    c1->cd();
    c1->SetLogy(plotLog);
  }
  // Draw hists
  hs->Draw("hist");
  hs->SetTitle(hmc_exp->GetTitle());
  hs->GetXaxis()->SetTitle(httbar->GetXaxis()->GetTitle());
  hs->GetYaxis()->SetTitle(ytitle);
  hs->GetXaxis()->SetLabelSize(0.03);
  hs->GetYaxis()->SetLabelSize(0.03);
  if (plotData) 
    {
      //  hsingle_top->Draw("e1 same");
      hs->GetXaxis()->SetLabelSize(0);
    }
  staterr->Draw("e2 same");
  if (plotSig) {
    ht1bbbb_1500_100->SetLineColor(2);
    ht1bbbb_1500_100->SetLineWidth(4);
    ht1bbbb_1500_100->SetFillColor(0);
    ht1bbbb_1000_900->SetLineColor(2);
    ht1bbbb_1000_900->SetLineWidth(4);
    ht1bbbb_1000_900->SetLineStyle(7);
    ht1bbbb_1000_900->SetFillColor(0);
    ht1tttt_1500_100->SetLineColor(kGreen);
    ht1tttt_1500_100->SetLineWidth(4);
    ht1tttt_1500_100->SetFillColor(0);
    ht1tttt_1200_800->SetLineColor(kGreen);
    ht1tttt_1200_800->SetLineStyle(7);
    ht1tttt_1200_800->SetLineWidth(4);
    ht1tttt_1200_800->SetFillColor(0);
    ht1qqqq_1400_100->SetLineColor(1006);
    ht1qqqq_1400_100->SetLineWidth(4);
    ht1qqqq_1400_100->SetFillColor(0);
    ht1qqqq_1000_800->SetLineColor(1006);
    ht1qqqq_1000_800->SetLineWidth(4);
    ht1qqqq_1000_800->SetLineStyle(7);
    ht1qqqq_1000_800->SetFillColor(0);
    ht1bbbb_1500_100->Draw("hist same");
    ht1bbbb_1000_900->Draw("hist same");
    ht1tttt_1500_100->Draw("hist same");
    ht1tttt_1200_800->Draw("hist same");
    ht1qqqq_1400_100->Draw("hist same");
    ht1qqqq_1000_800->Draw("hist same");
  }
  if (cut_low>0) line_low->Draw("same");
  if (cut_high>0) line_high->Draw("same");


  // Draw legends
  leg1->Draw();
  leg2->Draw();
  TLatex * latex = new TLatex();
  latex->SetNDC();
  latex->SetTextAlign(12);
  latex->SetTextFont(62);
  latex->SetTextSize(0.042);
  latex->DrawLatex(0.19, 0.89, "CMS Simulation");
  latex->SetTextSize(0.03);
  latex->DrawLatex(0.19, 0.84, "#sqrt{s} = 13 TeV, L = 4 fb^{-1}");
  
  // Print
  cout << "MakePlots(): Printing..." << endl;

  c1->cd();
  if (plot_title.EqualTo("default")) plot_title=plotdir+var;
  gPad->Print(plotdir+plot_title+".pdf");


  // Clean up
  delete staterr;
  delete leg1;
  delete leg2;
  delete latex;
  // delete pave;
  delete hs;
  delete pad1;
  delete pad2;
  delete c1;

  delete httbar;
  delete hqcd;
  delete hznn;
  delete hwjets;
  delete hsingle_top;
  delete hother;
  delete hmc_exp;

  delete ht1bbbb_1500_100;
  delete ht1bbbb_1000_900;
  delete ht1tttt_1500_100;
  delete ht1tttt_1200_800;
  delete ht1qqqq_1400_100;
  delete ht1qqqq_1000_800;

  cout << "MakePlots(): DONE!" << endl;

  return;
}
Example #16
0
void macro_2Dhisto(TString channel, TString njmt, TString syst, TString region, TString BDT1_name, TString BDT2_name, TString lep){
  if((lep=="electron"||lep=="electronantiiso")&& channel=="QCDMuPt20toInf") return;
  if((lep=="muonantiiso"||lep=="electronantiiso") && channel=="TT_sd") return;
  if((channel.Contains("hdamp")||channel.Contains("psq2"))&&((lep=="muonantiiso"||lep=="electronantiiso")||(syst!=""))) return;
  TFile * f=TFile::Open("trees_lumi/"+lep+"/trees_"+channel+"_"+lep+".root");
  TString treename, histoname;
  TH2F * h2 = new TH2F("h2", "h2",10,-1,1,10,-1,1);
  //  Float_t BDT1, BDT2, etajprime, mtw, w, w_nominal, var_syst; 
  gStyle->SetOptStat(0);
  TString outfilename, taglio, selection;
  selection = "BDT_"+BDT1_name+":BDT_"+BDT2_name;
  if(syst.EqualTo("jesUp")||syst.EqualTo("jesDown")||syst.EqualTo("jerUp")||syst.EqualTo("jerDown")) treename = "events_"+njmt+"_"+syst;
  else treename = "events_"+njmt;
  TTree * t =(TTree*)f->Get(treename);
  if(region=="cr") taglio = "(mtw>50 && etajprime<2.4";
  else taglio = "(mtw>50 && etajprime>2.4";
  if(lep=="electronantiiso") taglio += " &&mlb>30";
  if(syst.EqualTo("")){
    histoname = "h2D_"+njmt+"_"+channel+"_"+region;
    t->Project("h2",selection,taglio+")*w*w_nominal");
  }
  else{
    if(syst.EqualTo("jesUp")||syst.EqualTo("jesDown")||syst.EqualTo("jerUp")||syst.EqualTo("jerDown")){
      histoname = "h2D_"+njmt+"_"+channel+"_"+region+"_"+syst;
      t->Project("h2",selection,taglio+")*w*w_nominal");
    }
    else{
      histoname = "h2D_"+njmt+"_"+channel+"_"+region+"_"+syst;
      t->Project("h2",selection,taglio+")*w*"+syst);
    }
  }
  h2->SetName(histoname);
  TCanvas * c = new TCanvas( "c1"," ");
  Float_t newMargin1 = 0.13;
  Float_t newMargin2 = 0.15;
  c->SetGrid();
  c->SetTicks();
  c->SetLeftMargin  ( newMargin2 );
  c->SetBottomMargin( newMargin2 );
  c->SetRightMargin ( newMargin1 );
  c->SetTopMargin   ( newMargin1 );
  gStyle->SetPalette( 1, 0 );
  gStyle->SetPaintTextFormat( "3g" );

  h2->SetMarkerSize( 1.5 );
  h2->SetMarkerColor( 0 );
  Float_t labelSize = 0.040;
  h2->GetXaxis()->SetLabelSize( labelSize );
  h2->GetYaxis()->SetLabelSize( labelSize );
  h2->GetXaxis()->SetTitle( "BDT_"+BDT1_name );
  h2->GetYaxis()->SetTitle( "BDT_"+BDT2_name );
  //  h2->LabelsOption( "d" );
  h2->SetLabelOffset( 0.011 );// label offset on x axis    
  h2->Draw("colz"); // color pads   
  c->Update();
  // modify properties of paletteAxis
  TPaletteAxis * paletteAxis = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject( "palette" );
  paletteAxis->SetLabelSize( 0.03 );
  paletteAxis->SetX1NDC( paletteAxis->GetX1NDC() + 0.02 );

  h2->Draw("textsame");  // add text
  // TMVAGlob::plot_logo( );
  c->Update();
  outfilename = "Plot/histo2D_"+lep+".root";
  TFile * fout = TFile::Open(outfilename, "UPDATE");
  h2->Write();
  c->SaveAs("Plot2D/"+histoname+"_"+lep+".pdf");
}
Example #17
0
//______________________________________________________________________________
// function to add specific data to be processed
Bool_t InputData ( const char* label ) {
TString datarun (label);

//______________________________________________________________________________
//  DEFINED INPUT DATA
if ( datarun.IsNull() ) { printf ( "InputData :: no data input" ); return kFALSE; }

// Get the pointer to the existing analysis manager via the static access method.
//==============================================================================
AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
if ( !mgr ) { ::Error ( "InputData.C", "No analysis manager to connect to." ); return kFALSE; }

// Check the analysis type using the event handlers connected to the analysis manager.
//==============================================================================
AliAnalysisAlien* plugin =  dynamic_cast <AliAnalysisAlien*> ( mgr->GetGridHandler() );
if ( !plugin ) { ::Error ( "InputData.C", "InputData :: plugin invalid" ); return kFALSE; }

TString     kGridRunPattern = "000"; // important for leading zeroes!!
Printf ( "data = %s" , datarun.Data() );

// ##################################################################################

// FILTER_p-p_113_LHC11a: Standard AODs + deltas  pp 2.76 GeV
// runlist for lego dataset LHC11a_pass4_AOD (pass4_wSDD) ; Jets_EMC_pp train
// MC anchored lhc11a : http://alimonitor.cern.ch/job_details.jsp?jt_description=LHC11a
if ( datarun.EqualTo ( "pp_lhc11a_aod" ) ) {
    plugin->SetRunPrefix ( kGridRunPattern.Data() );

    // AliEn data production directory
    plugin->SetGridDataDir ( "/alice/data/2011/LHC11a" );

    // Can be like: *AliESDs.root, */pass1/*AliESDs.root, ...
    plugin->SetDataPattern ( "*ESDs/pass4_with_SDD/AOD113/*AliAOD.root" );

    plugin->AddRunList ("146860 146859 146858 146856 146824 146817 146807 146806 146805 146804 146803 146802 146801 146748 146747 146746");
    return kTRUE;
    }

// ##################################################################################

// AOD LHC10d; 7 TeV
// MC anchored 10d :http://alimonitor.cern.ch/job_details.jsp?jt_description=LHC10d
// runlist for lego dataset LHC10d_pass4_AOD ; Jets_EMC_pp train
else if ( datarun.EqualTo ( "pp_lhc10d_aod" ) ) {
    plugin->SetRunPrefix ( kGridRunPattern.Data() );

    // AliEn data production directory
    plugin->SetGridDataDir ( "/alice/data/2010/LHC10d" );

    // Can be like: *AliESDs.root, */pass1/*AliESDs.root, ...
    plugin->SetDataPattern ( "*pass4/AOD172/*AliAOD.root" );

    TString list_lhc10d_AN_1 = "126432 126425 126424 126422 126409 126408 126407 126406 126405 126404 126403 126359 126352 126351 126350 126285 126284";
    TString list_lhc10d_AN_2 = "126283 126168 126167 126160 126158 126097 126090 126088 126082 126081 126078 126073 126008 126007 126004 125855 125851";
    TString list_lhc10d_AN_3 = "125850 125849 125848 125847 125844 125843 125842 125633 125632 125630 125628 125296 125295 125186 125156 125140 125139";
    TString list_lhc10d_AN_4 = "125134 125133 125101 125100 125097 125085 125083 125023 124751 122375 122374";

    plugin->AddRunList ( list_lhc10d_AN_1.Data() );
    plugin->AddRunList ( list_lhc10d_AN_2.Data() );
    plugin->AddRunList ( list_lhc10d_AN_3.Data() );
    plugin->AddRunList ( list_lhc10d_AN_4.Data() );
    return kTRUE;
    }

// ##################################################################################

// AOD LHC10e; 7 TeV
// MC anchored 10e : http://alimonitor.cern.ch/job_details.jsp?jt_description=LHC10e
// runlist for lego dataset LHC10e_pass4_AOD ; Jets_EMC_pp train
else if ( datarun.EqualTo ( "pp_lhc10e_aod" ) ) {
    plugin->SetRunPrefix ( kGridRunPattern.Data() );

    // AliEn data production directory
    plugin->SetGridDataDir ( "/alice/data/2010/LHC10e" );

    // Can be like: *AliESDs.root, */pass1/*AliESDs.root, ...
    plugin->SetDataPattern ( "*pass4/AOD172/*AliAOD.root" );

    TString list_lhc10e_AN_1 = "130850 130848 130847 130844 130842 130840 130834 130799 130798 130795 130793 130704 130696 130628 130623 130621 130620 130609 130608 130526";
    TString list_lhc10e_AN_2 = "130524 130520 130519 130517 130481 130480 130479 130375 130360 130358 130356 130354 130342 130178 130172 130168 130158 130157 130149 129983";
    TString list_lhc10e_AN_3 = "129966 129962 129961 129960 129744 129742 129738 129736 129735 129734 129729 129726 129725 129723 129666 129659 129653 129652 129651 129650";
    TString list_lhc10e_AN_4 = "129647 129641 129639 129599 129587 129586 129540 129536 129528 129527 129525 129524 129523 129521 129520 129519 129516 129515 129514 129513";
    TString list_lhc10e_AN_5 = "129512 129042 128913 128855 128853 128850 128843 128836 128835 128834 128833 128824 128823 128820 128819 128778 128777 128678 128677 128621";
    TString list_lhc10e_AN_6 = "128615 128611 128609 128605 128596 128594 128592 128582 128506 128505 128504 128503 128498 128495 128494 128486 128452 128366";

    plugin->AddRunList ( list_lhc10e_AN_1.Data() );
    plugin->AddRunList ( list_lhc10e_AN_2.Data() );
    plugin->AddRunList ( list_lhc10e_AN_3.Data() );
    plugin->AddRunList ( list_lhc10e_AN_4.Data() );
    plugin->AddRunList ( list_lhc10e_AN_5.Data() );
    plugin->AddRunList ( list_lhc10e_AN_6.Data() );
    return kTRUE;
    }

// ##################################################################################
// MC anchored lhc13g : http://alimonitor.cern.ch/job_details.jsp?jt_description=LHC13g
// AOD LHC13g; 2.76 TeV
// LHC13g_AOD155 Jets_EMC_pp train
else if ( datarun.EqualTo ( "pp_lhc13g_aod" ) ) {
    plugin->SetRunPrefix ( kGridRunPattern.Data() );

    // AliEn data production directory
    plugin->SetGridDataDir ( "/alice/data/2013/LHC13g" );

    // Can be like: *AliESDs.root, */pass1/*AliESDs.root, ...
    plugin->SetDataPattern ( "*pass1/AOD155/*AliAOD.root" );

    plugin->AddRunList ( "197471 197496 197497 197499 197500 197501 197529 197531 197553 197555 197583 197584 197608 197609 197610 197611 197618 197643 197669" );
    return kTRUE;
    }

// LHC12a15f pp, Jet-Jet Pythia6, 0.5T, 7000 GeV, LHC11d anchors, 11 Pt bins, ID #301
// jdl : https://alimonitor.cern.ch/jobs/jdl.jsp?pid=200443474
else if ( datarun.EqualTo ( "pp_lhc12a15f" ) ) {

    // AliEn data production directory
    plugin->SetGridDataDir ( "/alice/sim/2012/LHC12a15f" );

    // Can be like: *AliESDs.root, */pass1/*AliESDs.root, ...
    plugin->SetDataPattern ( "/*/*/AliAOD.root" );

    TString list_lhc12a15f = "158285 159582";

    plugin->AddRunList ( list_lhc12a15f.Data() );
    return kTRUE;
    }

// LHC14b7 p-p, Pythia6 simulation, LHC11c and LHC11d anchors, 7TeV (RAW OCDB), ALIROOT-5345
else if ( datarun.EqualTo ( "pp_lhc14b7" ) ) {
    // AliEn data production directory
    plugin->SetGridDataDir ( "/alice/sim/2014/LHC14b7" );

    // Can be like: *AliESDs.root, */pass1/*AliESDs.root, ...
    plugin->SetDataPattern ( "/*/*/AliAOD.root" );

    TString list_lhc14b7 = "159599 159582 157818 157569 157203 154383 154211";

    plugin->AddRunList ( list_lhc14b7.Data() );
    return kTRUE;
    }

// AOD LHC16q; p-Pb 5.02 TeV
else if ( datarun.EqualTo ( "pp_lhc16q_aod" ) ) {
    plugin->SetRunPrefix ( kGridRunPattern.Data() );

    // AliEn data production directory
    plugin->SetGridDataDir ( "/alice/data/2016/LHC16q" );
// /alice/data/2016/LHC16q/000265521/pass1_CENT_wSDD/AOD190

    // Can be like: *AliESDs.root, */pass1/*AliESDs.root, ...
    plugin->SetDataPattern ( "*pass1_CENT_wSDD/AOD190/*AliAOD.root" );

    // https://twiki.cern.ch/twiki/bin/view/ALICE/AliDPGRunList16q
    TString list_lhc16q_1 = "265525 265521 265501 265500 265499 265427 265426 265425 265424 265421 265420 265419 265388 265387 265384 265383 265378 265344 265343 265342 265339 265338 265336 265335 265334 265332 265309";
    TString list_lhc16q_2 = "265435 265422";

    plugin->AddRunList ( list_lhc16q_1.Data() );
//           plugin->AddRunList ( list_lhc16q_2.Data() ); // present in train dataset LHC16q_pass1_wSDD but not in the list AliDPGRunList16q/RunList_LHC16q_pass1_CentralBarrelTracking_calo_20171129_v2.txt
    return kTRUE;
    }

// AOD LHC16r; p-Pb 8.16 TeV
// https://twiki.cern.ch/twiki/pub/ALICE/AliDPGRunList16r
// https://twiki.cern.ch/twiki/pub/ALICE/AliDPGRunList16r/RunList_LHC16r_pass1_CentralBarrelTracking_calo_20170202_v0.txt
else if ( datarun.EqualTo ( "pp_lhc16r_aod" ) ) {
    plugin->SetRunPrefix ( kGridRunPattern.Data() );

    // AliEn data production directory
    plugin->SetGridDataDir ( "/alice/data/2016/LHC16r" );

    // Can be like: *AliESDs.root, */pass1/*AliESDs.root, ...
    plugin->SetDataPattern ( "*pass1_CENT_wSDD/AOD190/*AliAOD.root" );

    TString list_lhc16r_1 = "266318 266317 266316 266208 266197 266196 266187 265744";

    plugin->AddRunList ( list_lhc16r_1.Data() );
    return kTRUE;
    }

// AOD LHC16s; Pb-p 8.16 TeV
// https://twiki.cern.ch/twiki/bin/view/ALICE/AliDPGRunList16s
// https://twiki.cern.ch/twiki/pub/ALICE/AliDPGRunList16s/RunList_LHC16s_pass1_CentralBarrelTracking_calo_20170202_v0.txt
else if ( datarun.EqualTo ( "pp_lhc16s_aod" ) ) {
    plugin->SetRunPrefix ( kGridRunPattern.Data() );

    // AliEn data production directory
    plugin->SetGridDataDir ( "/alice/data/2016/LHC16s" );

    // Can be like: *AliESDs.root, */pass1/*AliESDs.root, ...
    plugin->SetDataPattern ( "*pass1_CENT_wSDD/AOD190/*AliAOD.root" );

    TString list_lhc16s_1 = "267110 267081 267077 267072 267070 266998 266997 266994 266993 266944 266886 266885 266883 266882 266437";

    plugin->AddRunList ( list_lhc16s_1.Data() );
    return kTRUE;
    }

// AOD LHC16t; p-Pb 5.02 TeV
else if ( datarun.EqualTo ( "pp_lhc16t_aod" ) ) {
    plugin->SetRunPrefix ( kGridRunPattern.Data() );

    // AliEn data production directory
    plugin->SetGridDataDir ( "/alice/data/2016/LHC16t" );

    // Can be like: *AliESDs.root, */pass1/*AliESDs.root, ...
    plugin->SetDataPattern ( "*pass1_CENT_wSDD/AOD190/*AliAOD.root" );

    // https://twiki.cern.ch/twiki/bin/view/ALICE/AliDPGRunList16t
    // https://twiki.cern.ch/twiki/pub/ALICE/AliDPGRunList16t/RunList_LHC16t_pass1_CentralBarrelTracking_calo_20170202_v0.txt
    TString list_lhc16t_1 = "267166 267165 267164 267163";

    plugin->AddRunList ( list_lhc16t_1.Data() );
    return kTRUE;
    }

// LHC18f3b_cent_2	p-Pb, 8.16 TeV - DPMJET production anchored to LHC16r, CENT, ALIROOT-7792
else if ( datarun.EqualTo ( "lhc18f3bcent" ) ) {
    // AliEn data production directory
    plugin->SetGridDataDir ( "/alice/sim/2018/LHC18f3b_cent_2" );

    // Can be like: *AliESDs.root, */pass1/*AliESDs.root, ...
    plugin->SetDataPattern ( "*/*AliAOD.root" );

    TString list_lhc18f3bcent_1 = "265594 265596 265607 265697 265698 265700 265701 265705 265709 265713 265714 265741 265742 265744 265746";
    TString list_lhc18f3bcent_2 = "265754 265756 265788 265789 265795 265797 266034 266074 266076 266081 266083 266084 266085 266086 266117";
    TString list_lhc18f3bcent_3 = "266187 266189 266190 266193 266196 266197 266208 266296 266299 266300 266304 266305 266316 266317 266318";

    TString list_lhc18f3bcent_all = list_lhc18f3bcent_1 + list_lhc18f3bcent_2 + list_lhc18f3bcent_3;

    plugin->AddRunList ( list_lhc18f3bcent_all.Data() );
    return kTRUE;
    }

// ##################################################################################
else
  { Printf ( "InputData :: NO DEFINED INPUT DATA RECOGNIZED !!! = %s", datarun.Data() ); return kFALSE; }

}
Example #18
0
void
TestSPD(const TString& which, Double_t nVar=2)
{
  TFile* file = TFile::Open("forward.root", "READ");
  if (!file) return;

  Bool_t spd = which.EqualTo("spd", TString::kIgnoreCase);
  
  TList* l = 0;
  if (spd) l = static_cast<TList*>(file->Get("CentralSums"));
  else     l = static_cast<TList*>(file->Get("ForwardSums"));
  if (!l) { 
    Warning("", "%sSums not found", spd ? "Central" : "Forward");
    return;
  }

  TList* ei = static_cast<TList*>(l->FindObject("fmdEventInspector"));
  if (!l) { 
    Warning("", "fmdEventInspector not found");
    return;
  }
  
  TObject* run = ei->FindObject("runNo");
  if (!run) 
    Warning("", "No run number found");
  ULong_t runNo = run ? run->GetUniqueID() : 0;

  TH2* h = 0;
  if (spd) h = static_cast<TH2*>(l->FindObject("nClusterVsnTracklet"));
  else { 
    TList* den = static_cast<TList*>(l->FindObject("fmdDensityCalculator"));
    if (!den) { 
      Error("", "fmdDensityCalculator not found");
      return;
    }
    TList* rng = static_cast<TList*>(den->FindObject(which));
    if (!rng) { 
      Error("", "%s not found", which.Data());
      return;
    }
    h = static_cast<TH2*>(rng->FindObject("elossVsPoisson"));
  }
  if (!h) { 
    Warning("", "%s not found", spd ? nClusterVsnTracklet : "elossVsPoisson");
    return;
  }

  gStyle->SetOptFit(1111);
  gStyle->SetOptStat(0);
  TCanvas* c = new TCanvas("c", Form("Run %u", runNo));
  c->Divide(2,2);
  
  TVirtualPad* p = c->cd(1);
  if (spd) {
    p->SetLogx();
    p->SetLogy();
  }
  p->SetLogz();
  h->Draw("colz");

  TObjArray* fits = new TObjArray;
  h->FitSlicesY(0, 1, -1, 0, "QN", fits);

  TF1* mean = new TF1("mean", "pol1");
  TF1* var  = new TF1("var", "pol1");
  // mean->FixParameter(0, 0);
  // var->FixParameter(0, 0);
  for (Int_t i = 0; i < 3; i++) { 
    p = c->cd(2+i);
    if (spd) { 
      p->SetLogx();
      p->SetLogy();
    }
    TH1* hh = static_cast<TH1*>(fits->At(i));
    hh->Draw();

    if (i == 0) continue;
    
    hh->Fit((i == 1? mean : var), "+Q");
    
  }

  TGraphErrors* g1 = new TGraphErrors(h->GetNbinsX());
  g1->SetFillColor(kBlue-10);
  g1->SetFillStyle(3001);
  g1->SetLineStyle(1);
  TGraph* u1 = new TGraph(h->GetNbinsX());
  TGraph* l1 = new TGraph(h->GetNbinsX());
  u1->SetLineColor(kBlue+1);
  l1->SetLineColor(kBlue+1);
  u1->SetName("u1");
  l1->SetName("l1");
  TGraphErrors* g2 = new TGraphErrors(h->GetNbinsX());
  g2->SetFillColor(kRed-10);
  g2->SetFillStyle(3001);
  g2->SetLineStyle(2);
  TGraph* u2 = new TGraph(h->GetNbinsX());
  TGraph* l2 = new TGraph(h->GetNbinsX());
  u2->SetLineColor(kRed+1);
  l2->SetLineColor(kRed+1);
  u2->SetName("u2");
  l2->SetName("l2");
  for (Int_t i = 1; i <= h->GetNbinsX(); i++) {
    Double_t x  = hh->GetXaxis()->GetBinCenter(i);
    Double_t y  = mean->Eval(x);
    Double_t e  = var->Eval(y);
    Double_t e1 = nVar * e;
    if (spd) e1 *= TMath::Log10(e);
    // Printf("%10e -> %10e +/- %10e", x, y, ee);
    g1->SetPoint(i-1, x, y);
    g1->SetPointError(i-1, 0, e1);
    u1->SetPoint(i-1, x, y+e1);
    l1->SetPoint(i-1, x, y-e1);
    // Printf("%3d: %f -> %f +/- %f", i, x, y, ee);

    Double_t e2 = nVar*0.05*x;
    g2->SetPoint(i-1, x, x);
    g2->SetPointError(i-1, 0, e2);
    u2->SetPoint(i-1, x, x+e2);
    l2->SetPoint(i-1, x, x-e2);
  }

  p = c->cd(1);
  c->Clear();
  c->cd();
  c->SetLogz();
  h->Draw("colz");
  g1->Draw("3 same");
  u1->Draw("l same");
  l1->Draw("l same");
  g2->Draw("3 same");
  u2->Draw("l same");
  l2->Draw("l same");

  Double_t ly = 0.9;
  Double_t dy = 0.06;
  TLatex* ltx = new TLatex(0.15, ly, Form("#LTy#GT = %f + %f x",
					   mean->GetParameter(0),
					   mean->GetParameter(1)));
  ltx->SetNDC();
  ltx->SetTextSize(dy);
  ltx->SetTextAlign(13);
  ltx->Draw();

  ly -= dy + 0.01;
  ltx->DrawLatex(0.15, ly, Form("#sigma_{y} = %f + %f x", 
				var->GetParameter(0),
				var->GetParameter(1)));
  
  ly -= dy + 0.01;
  ltx->DrawLatex(0.15, ly, Form("#delta = %f #sigma %s", 
				nVar, (spd ? "log_{10}(#sigma" : "")));
	    
					   
}
Example #19
0
void fillHistoFromTreeVar(std::string& treedrawspec,
			  int  index,
			  wTH1 *&wth1)
{
  // Sample treedrawspec:
  // mytree:"TDCwinstart[%d]:runnum>>winstrt%d(70,202000,209000)","evtnum==1","prof P"
  //
  vector<string> v_tokens;
  string tid;
  TString drawspec;
  Tokenize(treedrawspec,v_tokens,":",true);
  if( (v_tokens.size() < 2) ||
      (!v_tokens[0].size())  ||
      (!v_tokens[2].size())    ) {
    cerr << "malformed root tree draw spec treeid:\"varexp\",\"selection\",option: " << treedrawspec << endl;
    return;
  }

  tid = v_tokens[0];
  for (size_t i=2; i<v_tokens.size(); i++) {
    drawspec += v_tokens[i];
  }
  int fmtcnt = drawspec.CountChar('%');

  if (fmtcnt) { // use index for tree array var
    switch(fmtcnt) {
    case 1: drawspec = Form(drawspec,index); break;
    case 2: drawspec = Form(drawspec,index,index); break;
    case 3: drawspec = Form(drawspec,index,index,index); break;
    case 4: drawspec = Form(drawspec,index,index,index,index); break;
    case 5: drawspec = Form(drawspec,index,index,index,index,index); break;
    case 6: drawspec = Form(drawspec,index,index,index,index,index,index); break;
    default:
      cerr << "More than six fmt specifiers in drawspec found, fix me! " << drawspec <<endl;
      exit(-1);
    }
  }
  if( gl_verbose)
    cout<<"drawspec="<<drawspec<<endl;

  TTree *tree = findTree(tid);
  assert (tree);

  // can't use comma as delimiter since histo with binning spec may be supplied
  TObjArray *tokens = drawspec.Tokenize("\"");
  TString hname;

  TString varexp = ((TObjString *)(*tokens)[0])->GetString();

  if (varexp.Contains(">>")) {
    TObjArray *rematches = TPRegexp(">>(\\w+)").MatchS(varexp); // get histo name
    assert(rematches->GetEntriesFast() ==2);
    hname = ((TObjString *)(*rematches)[1])->GetString();

    if (wth1 && !hname.EqualTo(wth1->histo()->GetName())) {
      cerr << "Error: histo name in treedraw spec "<<hname;
      cerr <<" doesn't match named histo "<<wth1->histo()->GetName()<<endl;
      exit(-1);
    }
  } else { // add histo name
    assert (wth1);
    hname = TString(wth1->histo()->GetName());
    varexp = varexp + ">>+" + hname; // append to pre-existing histo
  }

  if( gl_verbose)
    cout<<"varexp="<<varexp<<", hname="<<hname<<endl;
  switch(tokens->GetEntriesFast()) {
  case 1:
    tree->Draw(varexp,"","goff");
    break;
  case 3:
    {
      TString cut = ((TObjString *)(*tokens)[2])->GetString();
      tree->Draw(varexp,cut,"goff"); 
    }
    break;
  case 4: // assume the cut string is blank
    {
      TString gopt = ((TObjString *)(*tokens)[3])->GetString();
      gopt = gopt + " goff";
      tree->Draw(varexp,"",gopt);
    }
    break;
  case 5:
    {
      TString cut  = ((TObjString *)(*tokens)[2])->GetString();
      TString gopt = ((TObjString *)(*tokens)[4])->GetString();
      gopt = gopt + " goff";
      tree->Draw(varexp,cut,gopt);
    }
    break;
  default:
    cerr << "malformed root tree draw spec treeid:varexp,selection,option";
    for (int i=0; i<tokens->GetEntriesFast(); i++)
      cerr << i<<": "<< ((TObjString *)(*tokens)[i])->GetString() << " ";
    cerr << endl;
    break;
  }
  if (!wth1) {
    wth1 = new wTH1((TH1*)gDirectory->Get(hname));
    assert(wth1);
    wth1->histo()->UseCurrentStyle();
  }
}                                                // fillHistoFromTreeVar
Example #20
0
  /** 
   * Create our task, and return it.  This uses the interpreter to
   * make the object.  
   * 
   * @param mgr Analysis manager 
   * 
   * @return Pointer to the task 
   */
  AliAnalysisTaskSE* CreateTask(AliAnalysisManager* mgr)
  {
    // Enable these lines to load the code from PWGUD directory.
    // These do not seem to be up-to-speed with the latest
    // developments, so for now, we use private scripts - sigh!
    //
    // Note, PWGLF also has these scripts, but it is not clear that
    // they are anymore current than the ones in PWGUD.
    // 
    // gROOT->SetMacroPath(Form("%s:$ALICE_PHYSICS/PWGUD/multVScentPbPb",
    // gROOT->GetMacroPath()));
    // gSystem->AddIncludePath("-I$ALICE_PHYSICS/PWGUD/multVScentPbPb");
    Info("CreateTasks", "Loading code");
    fRailway->LoadSource("FixPaths.C");
    fRailway->LoadSource("AliTrackletdNdetaUtils.C");
    fRailway->LoadSource("AliTrackletdNdetaTask.C");

    // --- Create the task using interpreter -------------------------
    Bool_t             mc  = mgr->GetMCtruthEventHandler() != 0;
    const char*        nme = (mc ? "MidMCdNdeta" : "MiddNdeta");
    const char*        cls = (mc ?
			      "AliTrackletdNdetaMCTask" :
			      "AliTrackletdNdetaTask");
    Long_t             ret = gROOT->ProcessLine(Form("new %s(\"%s\")",cls,nme));
    AliAnalysisTaskSE* task =reinterpret_cast<AliAnalysisTaskSE*>(ret);
    if (!task) return 0;

    // --- Add task to train -----------------------------------------
    gROOT->ProcessLine(Form("((%s*)%p)->Connect()", cls, task));

    // --- Figure out the trigger options ----------------------------
    TString trg = fOptions.Get("trig");
    trg.ToUpper();
    UInt_t  sel = AliVEvent::kINT7;
    if      (trg.EqualTo("MB"))    sel = AliVEvent::kMB;
    else if (trg.EqualTo("V0AND")) sel = AliVEvent::kINT7;
    else if (trg.EqualTo("V0OR"))  sel = AliVEvent::kCINT5;
    else if (trg.EqualTo("ANY"))   sel = AliVEvent::kAny;

    
    // --- Set various options on task -------------------------------
    const char* defCent = "0-5-10-20-30-40-50-60-70-80-90";
    task->SelectCollisionCandidates(sel);
    FromOption(task, "ReconstructionMode",      "reconstruct",      "nor,inj");
    FromOption(task, "CentralityMethod", 	"cent", 	    "V0M");
    FromOption(task, "CentralityAxis",          "cent-bins",        defCent);
    FromOption(task, "EtaAxis",                 "eta-bins",         "r16:2");
    FromOption(task, "IPzAxis",                 "ipz-bins",         "u15");
    // FromOption(task, "CheckReconstructables",   "check-reco",    false);
    FromOption(task, "MaxDelta",		"max-delta",	    25.);
    FromOption(task, "TailDelta",		"tail-delta",	    5.);
    FromOption(task, "ScaleDTheta",	        "scale-dtheta",	    false);
    FromOption(task, "DPhiWindow",		"dphi-window",	    0.06);
    FromOption(task, "DThetaWindow",		"dtheta-window",    0.025);
    FromOption(task, "DPhiShift",		"dphi-shift",	    0.0045);
    FromOption(task, "PhiOverlapCut",		"phi-overlap-cut"  ,0.005);
    FromOption(task, "ZEtaOverlapCut",		"z-eta-overlap-cut",0.05);
    FromOption(task, "PhiRotation",		"phi-rotation",	TMath::Pi());
    // FromOption(task, "InjScale",		"inj-scale",	1.);
    FromOption(task, "ShiftedDPhiCut",		"shifted-dphi-cut",-1.);
    FromOption(task, "DeltaCut",		"delta-cut",	    1.5);
    if (fOptions.AsBool("cut-dtheta")) 
      FromOption(task, "ScaleDThetaCut",	"dtheta-window",    0.025);
    
    SetupReweighting(task);

    task->Print("");
    
    return task;
  }
Example #21
0
File: Analyze.C Project: XuQiao/HI
void
Analyze(const TString mode="CLOSED",
        UShort_t       maxH=6,
        Bool_t         /*doLoops*/=false,
        Int_t ifile=0   )
{
#ifdef __CINT__
  gROOT->LoadMacro("correlations/Types.hh++");
  gROOT->LoadMacro("correlations/Result.hh++");
  gROOT->LoadMacro("correlations/QVector.hh++");
  gROOT->LoadMacro("correlations/recursive/FromQVector.hh++");
  gROOT->LoadMacro("correlations/recurrence/FromQVector.hh++");
  gROOT->LoadMacro("correlations/closed/FromQVector.hh++");
  gROOT->LoadMacro("correlations/test/ReadData.hh++");
#endif
  // --- Setup of harmonics, etc -------------------------------------
  gRandom->SetSeed(54321);
  UShort_t emode = 0;
  if      (mode.EqualTo("closed",     TString::kIgnoreCase)) emode = 0;
  else if (mode.EqualTo("recurrence", TString::kIgnoreCase)) emode = 1;
  else if (mode.EqualTo("recursive",  TString::kIgnoreCase)) emode = 2;
  else
    Warning("Analyze", "Mode %s unknown, assuming CLOSED", mode.Data());

  correlations::QVector        q[nbin];
  correlations::FromQVector*   c[nbin];
  correlations::HarmonicVector h(maxH);
  for (UShort_t i = 0; i < maxH; i++) {
    // Generate random harmonicx
   // h[i] = -6 + gRandom->Integer(12);
   h[0] = 2;
   h[1] = -2;
   h[2] = 2;
   h[3] = -2;
   h[4] = 2;
   h[5] = -2;
   h[6] = -2;
   h[7] = 2;
   // Printf("h_%d:\t%d", i, h[i]);
  }

  // Resize the Q-vector to fit the harmonics
    for(int ibin=0;ibin<nbin;ibin++){
    q[ibin] = correlations::QVector(0,0,false);
    q[ibin].resize(h);
  switch (emode) {
  case 0: c[ibin] = new correlations::closed::FromQVector(q[ibin]); break;
  case 1: c[ibin] = new correlations::recurrence::FromQVector(q[ibin]); break;
  case 2: c[ibin] = new correlations::recursive::FromQVector(q[ibin]); break;
    }
  }
  //Printf("Correlator: %s", c->name());


  // --- Some histograms ---------------------------------------------
  TH1* sumreals[nbin];
  TH1* sumimags[nbin];
  TH1* weights[nbin];
  TVectorD tottrk;
  TVectorD Nevent;
  tottrk.ResizeTo(nbin);
  tottrk.Zero();
  Nevent.ResizeTo(nbin);
  Nevent.Zero();

  //TH1*      reals  = new TH1D("reals", "Re(C{n})", maxH-2+1, 2+.5, maxH+1+.5);
  //TH1*      imags  = static_cast<TH1*>(reals->Clone("imags"));
    for(int ibin=0;ibin<nbin;ibin++){
  sumreals[ibin]  = new TH1D(Form("sumreals_%d",ibin), "Re(C{n})", maxH-2+1, 2+.5, maxH+1+.5);
  sumimags[ibin]  = static_cast<TH1*>(sumreals[ibin]->Clone(Form("sumimags_%d",ibin)));
  weights[ibin]  = static_cast<TH1*>(sumreals[ibin]->Clone(Form("weights_%d",ibin)));
    }
  TProfile* timing = new TProfile("timing", "Timing", maxH-2+1, 2+.5,maxH+1+.5);
  TH1*      hs     = new TH1I("harmonics", "Harmonics", maxH, 1.5, maxH+1.5);
  /*reals->SetFillColor(kGreen+1);
  reals->SetFillStyle(3001);
  reals->SetStats(0);
  imags->SetTitle("Im(C{n})");
  imags->SetFillColor(kBlue+1);
  imags->SetFillStyle(3001);
  imags->SetStats(0);
  timing->SetFillColor(kRed+1);
  timing->SetFillStyle(3001);
  timing->SetStats(0);
  hs->SetFillColor(kMagenta+1);
  hs->SetFillStyle(3001);
  hs->SetStats(0);*/
  for (UShort_t i = 0; i < maxH-1; i++) {
    TString label = TString::Format("C{%d}", i+2);
//    reals->GetXaxis()->SetBinLabel(i+1, label);
//    imags->GetXaxis()->SetBinLabel(i+1, label);
    timing->GetXaxis()->SetBinLabel(i+1, label);
    hs->GetXaxis()->SetBinLabel(i+1,Form("h_{%d}", i+1));
    hs->SetBinContent(i+1, h[i]);
  }
  hs->GetXaxis()->SetBinLabel(maxH,Form("h_{%d}", maxH));
  hs->SetBinContent(maxH, h[maxH-1]);

  TStopwatch timer;
 
  // --- Setup input ------------------------------------------------
  TFile*   file = TFile::Open(Form("%s/vndata_50k_%d.root",dir.Data(),ifile), "READ");
  TTree*   tree = static_cast<TTree*>(file->Get("tree"));
//  TArrayD  phis(0);
  Int_t M;
  Float_t phi[10000],pt[10000],eta[10000];
//  TArrayD  weights(0);
//  Double_t phiR = 0;
//  TArrayD* pPhis = &phis;
//  TArrayD* pWeights = &weights;
  tree->SetBranchAddress("phig", phi);
  tree->SetBranchAddress("ptg",pt);
  tree->SetBranchAddress("etag",eta);
  tree->SetBranchAddress("n", &M);
//  tree->SetBranchAddress("weight", &pWeights);
//  tree->SetBranchAddress("event", &phiR);


  // --- The results -------------------------------------------------
  const UShort_t             nQ = maxH - 1;
  correlations::ResultVector qs[nbin];
    for(int ibin=0;ibin<nbin;ibin++)
        qs[ibin] = correlations::ResultVector(nQ);

  // --- Event loop --------------------------------------------------
  Int_t nEvents = tree->GetEntries();
  for (Int_t event = 0; event < nEvents; event++) {
    tree->GetEntry(event);
    int ntrk = M; int xbin=-1;
    for(int j=0;j<nbin;j++)
        if(ntrk<trkbin[j]&&ntrk>=trkbin[j+1])
            xbin=j;
        if(xbin<0 || xbin==nbin) continue;
    tottrk[xbin]+=ntrk;
    q[xbin].reset();
 //   printf("Event # %4u  %4d particles ", event++, phis.GetSize());
    for (UShort_t pa = 0; pa < M; pa++){
	if(fabs(eta[pa])>etamax) continue;
        if(pt[pa]<ptmin||pt[pa]>ptmax) continue; //event selection
  //  phis.Set(n,pPhis);
      q[xbin].fill(phi[pa], 1.);
    }
    for (UShort_t i = 0; i < nQ; i++) {
      UShort_t n = i + 2;
   //   printf("%s%d", i == 0 ? "" : "..", n);
      timer.Reset();
      timer.Start();
      qs[xbin][i] += c[xbin]->calculate(n, h);
      timer.Stop();
      timing->Fill(n+.5, timer.RealTime());
    }

  //  printf(" done\n");
  Nevent[xbin]++;
  }
  file->Close();

    for(int ibin=0;ibin<nbin;ibin++){
  for (UShort_t i = 0; i < nQ; i++) {
 //   UShort_t iq = i+2;
 //   Double_t              t  = timing->GetBinContent(i+1);
 //   correlations::Complex rc = qs[i].eval();
   // Printf("QC{%2d}: %12g + %12gi  <t>: %10gs",
//	   iq, rc.real(), rc.imag(), t);
   // if(i==0)Printf("v2{%2d}: %3g\n",2,sqrt(qs[0].eval().real()));
   // if(i==2)Printf("v2{%2d}: %3g\n",4,TMath::Power(fabs(qs[2].eval().real()),1./4));
   // if(i==4)Printf("v2{%2d}: %3g\n",6,TMath::Power(fabs(qs[4].eval().real()),1./6));
    sumreals[ibin]->SetBinContent(i+1,qs[ibin][i]._sum.real());
    sumimags[ibin]->SetBinContent(i+1,qs[ibin][i]._sum.imag());
    weights[ibin]->SetBinContent(i+1,qs[ibin][i]._weights);
    //reals->SetBinContent(i+1, rc.real());
    //imags->SetBinContent(i+1, rc.imag());
  }
    }

/*
  TCanvas* can = new TCanvas("C", "C");
  can->SetTopMargin(0.15);
  can->SetBottomMargin(0.15);
  can->SetRightMargin(0.03);
  can->Divide(1,3, 0, 0);

  DrawInPad(can, 3, timing, true);
  DrawInPad(can, 1, reals);
  DrawInPad(can, 2, imags);

  can->cd(0);
  TLatex* ltx = new TLatex(0.5,0.995,c->name());
  ltx->SetNDC(true);
  ltx->SetTextAlign(23);
  ltx->SetTextSize(0.04);
  ltx->Draw();

  can->Modified();
  can->Update();
  can->cd();
*/
  TString out(mode);
  out.ToLower();
  file = TFile::Open(Form("%s/%s_%d.root",outdir.Data(),out.Data(),ifile), "RECREATE");
    for(int ibin=0;ibin<nbin;ibin++){
  sumimags[ibin]->Write();
  sumreals[ibin]->Write();
  weights[ibin]->Write();
    }
  Nevent.Write("Nevent");
  tottrk.Write("tottrk");
  timing->Write();
  hs->Write();
  file->Write();
  file->Close();
    for(int ibin=0;ibin<nbin;ibin++){
  delete sumimags[ibin];
  delete sumreals[ibin];
  delete weights[ibin];
    }
  delete timing;
  delete hs;
}
Example #22
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// runPlotter
//
// option = "hist"         --> all distributions normalized to the luminosity
// option = "nostack,hist" --> signal and top distributions normalized to one
//
//   Draw(TString  hname,                  Name of the histogram.
//        TString  xtitle       = "",      Title of the x-axis.
//        Int_t    ngroup       = -1,      Number of bins to be merged into one bin.
//        Int_t    precision    = 0,       Number of decimal digits.
//        TString  units        = "NULL",  Units of the histogram.
//        Bool_t   setlogy      = false,   Set it to true (false) for logarithmic (linear) scale.
//        Bool_t   moveoverflow = true,    Set it to true to plot the events out of range.
//        Float_t  xmin         = -999,
//        Float_t  xmax         = -999,
//        Float_t  ymin         = -999,
//        Float_t  ymax         = -999);
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void runPlotter(TString level,
		TString option = "hist")
{
  gInterpreter->ExecuteMacro("PaperStyle.C");

  TString tok;

  Ssiz_t from = 0;

  TString analysis = (level.Tokenize(tok, from, "/")) ? tok : "NONE";

  if (analysis.EqualTo("NONE")) return;

  float lumi = lumi_fb_2016;

  if (analysis.EqualTo("Shape")) lumi = lumi_fb_Run2016B;

  Bool_t scale = linY;

  if (analysis.EqualTo("MonoH")) scale = logY;
  if (analysis.EqualTo("Stop"))  scale = logY;
  if (analysis.EqualTo("Top"))   scale = logY;

  int firstchannel = (analysis.EqualTo("WZ")) ? eee : ee;
  int lastchannel  = (analysis.EqualTo("WZ")) ? lll : ll;

  HistogramReader plotter(inputdir + analysis, outputdir);

  plotter.SetStackOption(option);
  plotter.SetPublicStyle(false);
  plotter.SetSavePdf    (false);

  if (option.Contains("nostack"))
    {
      plotter.SetDrawRatio(false);
    }
  else
    {
      plotter.SetLuminosity(lumi);
      plotter.SetDrawRatio (true);
    }


  // Get the data
  //----------------------------------------------------------------------------
  plotter.AddData("01_Data", "data", color_Data);


  // Add processes
  //----------------------------------------------------------------------------
  if (analysis.EqualTo("WZ"))
    {
      plotter.AddProcess("02_WZTo3LNu", "WZ",       color_WZTo3LNu);
      plotter.AddProcess("06_WW",       "WW",       color_WW);
      plotter.AddProcess("11_Wg",       "W#gamma",  color_Wg);
      plotter.AddProcess("15_WgStat",   "W#gamma*", color_WgStar);
      plotter.AddProcess("03_VZ",       "VZ",       color_VZ);
      plotter.AddProcess("09_TTV",      "ttV",      color_TTV);
      plotter.AddProcess("13_VVV",      "VVV",      color_VVV);

      if (datadriven)
	{
	  // -999 is needed to not scale by luminosity
	  plotter.AddProcess("00_Fakes", "non-prompt", color_Fakes, roc_background, -999);
	  plotter.AddProcess("12_Zg",    "Z#gamma",    color_Zg);
	}
      else
	{
	  plotter.AddProcess("07_ZJets",     "Z+jets", color_ZJets);
	  plotter.AddProcess("04_TTTo2L2Nu", "tt",     color_TTTo2L2Nu);
	  plotter.AddProcess("05_ST",        "tW",     color_ST);
	}
    }
  else
    {
      plotter.AddProcess("14_HZ",        "HZ",       color_HZ);
      plotter.AddProcess("10_HWW",       "HWW",      color_HWW);
      plotter.AddProcess("06_WW",        "WW",       color_WW, roc_signal);
      plotter.AddProcess("02_WZTo3LNu",  "WZ",       color_WZTo3LNu);
      plotter.AddProcess("03_VZ",        "VZ",       color_VZ);
      plotter.AddProcess("11_Wg",        "W#gamma",  color_Wg);
      plotter.AddProcess("15_WgStar",    "W#gamma*", color_WgStar);
      plotter.AddProcess("07_ZJets",     "Z+jets",   color_ZJets);
      plotter.AddProcess("09_TTV",       "ttV",      color_TTV);
      plotter.AddProcess("04_TTTo2L2Nu", "tt",       color_TTTo2L2Nu);
      plotter.AddProcess("05_ST",        "tW",       color_ST);

      if (datadriven)
	{
	  // -999 is needed to not scale by luminosity
	  plotter.AddProcess("00_Fakes", "non-prompt", color_Fakes, roc_background, -999);
	}
      else
	{
	  plotter.AddProcess("08_WJets", "W+jets", color_WJets);
	}
    }


  // Add signals
  //----------------------------------------------------------------------------
  if (analysis.EqualTo("MonoH"))
    {
      plotter.AddSignal("monoH_2HDM_MZp-600_MA0-400",  "m_{Z'} 600",  color_Signal-4);
      plotter.AddSignal("monoH_2HDM_MZp-800_MA0-400",  "m_{Z'} 800",  color_Signal-3);
      plotter.AddSignal("monoH_2HDM_MZp-1200_MA0-400", "m_{Z'} 1200", color_Signal-1);
      plotter.AddSignal("monoH_2HDM_MZp-1700_MA0-400", "m_{Z'} 1700", color_Signal+1);
      plotter.AddSignal("monoH_2HDM_MZp-2000_MA0-400", "m_{Z'} 2000", color_Signal+2);
      plotter.AddSignal("monoH_2HDM_MZp-2500_MA0-400", "m_{Z'} 2500", color_Signal+3);
    }


  if (analysis.EqualTo("TTDM"))
    {
      plotter.AddSignal("ttDM0001scalar00010", "m_{#chi}1 m_{S}10",  color_Signal);
      plotter.AddSignal("ttDM0001scalar00500", "m_{#chi}1 m_{S}500", color_Signal+2);
    }


  if (analysis.EqualTo("Stop"))
    {
      plotter.AddSignal("T2tt_mStop??", "m_{Stop}350-400",  color_Signal);  
      plotter.AddSignal("T2tt_mStop??", "m_{Stop}400-1200", color_Signal+2);  
    }


  // Draw events by cut
  //----------------------------------------------------------------------------
  plotter.SetDrawYield(false);

  gSystem->mkdir(outputdir + level, kTRUE);

  for (int i=firstchannel; i<=lastchannel; i++)
    {
      plotter.LoopEventsByCut(analysis, "h_counterLum_" + schannel[i]);

      TString title = (i < lastchannel) ? lchannel[i] : "inclusive";

      plotter.SetTitle(title);

      plotter.Draw(analysis + "/h_counterLum_" + schannel[i] + "_evolution", "", -1, 0, "NULL", logY, false);
    }


  // Draw events by channel
  //----------------------------------------------------------------------------
  plotter.SetDrawYield(false);

  for (int j=0; j<=njetbin; j++)
    {
      if (!analysis.EqualTo("Top")  &&
	  !analysis.EqualTo("Stop") &&
	  !analysis.EqualTo("WW")   &&
	  j != njetbin) continue;
      
      TString jetbin = (j < njetbin) ? Form("/%djet", j) : "";

      gSystem->mkdir(outputdir + level + jetbin, kTRUE);

      plotter.LoopEventsByChannel(level + jetbin);

      plotter.Draw(level + jetbin + "/h_counterLum_evolution", "", -1, 0, "NULL", scale, false);
    }


  // Draw distributions
  //----------------------------------------------------------------------------
  if (!option.Contains("nostack")) plotter.SetDrawYield(true);
  if (analysis.EqualTo("MonoH"))   plotter.SetDrawYield(false);

  float m2l_xmin   = (level.Contains("WZ")) ?  60 :   0;  // [GeV]
  float m2l_xmax   = (level.Contains("WZ")) ? 120 : 300;  // [GeV]
  int   m2l_ngroup = (level.Contains("WZ")) ?   2 :   5;
  
  for (int j=0; j<=njetbin; j++)
    {
      if (!analysis.EqualTo("Top")  &&
	  !analysis.EqualTo("Stop") &&
	  !analysis.EqualTo("WW")   &&
	  j != njetbin) continue;   
         
      TString jetbin = (j < njetbin) ? Form("/%djet", j) : "";

      gSystem->mkdir(outputdir + level + jetbin, kTRUE);

      TString prefix = level + jetbin + "/h_";

      for (int i=firstchannel; i<=lastchannel; i++)
	{
	  TString suffix = "_" + schannel[i];
	  
	  TString title = (i < lastchannel) ? lchannel[i] : "inclusive";

	  plotter.SetTitle(title);


	  // Common histograms
	  //--------------------------------------------------------------------
	  plotter.Draw(prefix + "m2l" + suffix, "m_{" + sll + "}", m2l_ngroup, 0, "GeV", logY, true, m2l_xmin, m2l_xmax);
	  plotter.Draw(prefix + "m2l" + suffix, "m_{" + sll + "}", m2l_ngroup, 0, "GeV", linY, true, m2l_xmin, m2l_xmax);

	  plotter.Draw(prefix + "njet"           + suffix, "number of 30 GeV jets",             -1, 0, "NULL", scale);
	  plotter.Draw(prefix + "nbjet20cmvav2l" + suffix, "number of 20 GeV cmvav2l b-jets",   -1, 0, "NULL", scale);
	  plotter.Draw(prefix + "nbjet30csvv2m"  + suffix, "number of 30 GeV csvv2m b-jets",    -1, 0, "NULL", scale);
	  plotter.Draw(prefix + "dphillmet"      + suffix, "#Delta#phi(" +sll + "," + sm + ")",  5, 2, "rad",  scale);
	  plotter.Draw(prefix + "metPfType1Phi"  + suffix, sm + " #phi",                         5, 2, "rad",  scale);
	  plotter.Draw(prefix + "metPfType1"     + suffix, sm,                                  10, 0, "GeV",  scale, true, 0,  200);
	  plotter.Draw(prefix + "nvtx"           + suffix, "number of vertices",                -1, 0, "NULL", scale, true, 0,   30);
	  plotter.Draw(prefix + "lep1pt"         + suffix, "leading lepton p_{T}",               5, 0, "GeV",  scale, true, 0,  150);
	  plotter.Draw(prefix + "lep2pt"         + suffix, "trailing lepton p_{T}",              5, 0, "GeV",  scale, true, 0,  150);
	  plotter.Draw(prefix + "lep1eta"        + suffix, "leading lepton #eta",               -1, 1, "NULL", scale);
	  plotter.Draw(prefix + "lep2eta"        + suffix, "trailing lepton #eta",              -1, 1, "NULL", scale);
	  plotter.Draw(prefix + "lep1phi"        + suffix, "leading lepton #phi",                5, 2, "rad",  scale);
	  plotter.Draw(prefix + "lep2phi"        + suffix, "trailing lepton #phi",               5, 2, "rad",  scale);
	  plotter.Draw(prefix + "jet1eta"        + suffix, "leading jet #eta",                  -1, 1, "NULL", scale, false);
	  plotter.Draw(prefix + "jet2eta"        + suffix, "trailing jet #eta",                 -1, 1, "NULL", scale, false);
	  plotter.Draw(prefix + "jet1phi"        + suffix, "leading jet #phi",                   5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "jet2phi"        + suffix, "trailing jet #phi",                  5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "jet1pt"         + suffix, "leading jet p_{T}",                  5, 0, "GeV",  scale, true, 0,  400);
	  plotter.Draw(prefix + "jet2pt"         + suffix, "trailing jet p_{T}",                 5, 0, "GeV",  scale, true, 0,  400);
	  plotter.Draw(prefix + "dphill"         + suffix, "#Delta#phi(lep1,lep2)",              5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "detall"         + suffix, "#Delta#eta(lep1,lep2)",              5, 2, "rad",  scale, true, 0, 5);
	  plotter.Draw(prefix + "topReco"        + suffix, "number of tt reco solutions",       -1, 0, "NULL", scale);


	  // ROC
	  //--------------------------------------------------------------------
	  plotter.Roc(prefix + "ht"    + suffix, "H_{T}",         1000, "GeV", 0, 1000);
	  plotter.Roc(prefix + "pt2l"  + suffix, "p_{T}^{ll}",    1000, "GeV", 0, 1000);
	  plotter.Roc(prefix + "mth"   + suffix, "m_{T}^{ll}",    1000, "GeV", 0, 1000);
	  plotter.Roc(prefix + "mtw1"  + suffix, "m_{T}^{W1}",    1000, "GeV", 0, 1000);
	  plotter.Roc(prefix + "mtw2"  + suffix, "m_{T}^{W2}",    1000, "GeV", 0, 1000);
	  plotter.Roc(prefix + "mt2ll" + suffix, "m_{T2}^{ll}",   1000, "GeV", 0, 1000);
	  plotter.Roc(prefix + "m2l"   + suffix, "m_{ll}",        1000, "GeV", 0, 1000);
	  plotter.Roc(prefix + "drll"  + suffix, "#Delta R_{ll}",   50, "rad", 0,    5);


	  if (!allplots) continue;


	  plotter.Draw(prefix + "dyll"         + suffix, "lepton #Delta#eta",                 -1, 3, "NULL", scale);
	  plotter.Draw(prefix + "dphimetjet"   + suffix, "min #Delta#phi(jet," + sm + ")",     5, 2, "rad",  scale);
	  plotter.Draw(prefix + "dphimetptbll" + suffix, "#Delta#phi(llmet," + sm + ")",       5, 2, "rad",  scale);
	  plotter.Draw(prefix + "mllbb"        + suffix, "m_{" + sll + "bb}",                 10, 0, "GeV",  scale, false, 0, 600);
	  plotter.Draw(prefix + "meff"         + suffix, "m_{eff}",                           10, 0, "GeV",  scale, false, 0, 600);
	  plotter.Draw(prefix + "ptbll"        + suffix, "p_{T}^{llmet}",                     10, 0, "GeV",  scale, false, 0, 600);
	  plotter.Draw(prefix + "mt2ll"        + suffix, "M_{T2}(" + sll + ")",               10, 0, "GeV",  scale, false, 0, 600);
	  plotter.Draw(prefix + "mt2bb"        + suffix, "M_{T2}(bb)" ,                       10, 0, "GeV",  scale, false, 0, 600);
	  plotter.Draw(prefix + "mt2lblb"      + suffix, "M_{T2}(" + sl + "b" + sl + "b)",    10, 0, "GeV",  scale, false, 0, 600);
	  plotter.Draw(prefix + "dphijet1met"  + suffix, "#Delta#phi(jet1,E_{T}^{miss})",      5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphijet2met"  + suffix, "#Delta#phi(jet2,E_{T}^{miss})",      5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphijj"       + suffix, "#Delta#phi(jet1,jet2)",              5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphijjmet"    + suffix, "#Delta#phi(jj,E_{T}^{miss})",        5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphilep1jet1" + suffix, "#Delta#phi(lep1,jet1)",              5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphilep1jet2" + suffix, "#Delta#phi(lep1,jet2)",              5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphilep2jet1" + suffix, "#Delta#phi(lep2,jet1)",              5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphilep2jet2" + suffix, "#Delta#phi(lep2,jet2)",              5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphillstar"   + suffix, "#Delta#phi*(lep1,lep2)",             5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphilmet1"    + suffix, "#Delta#phi(lep1,E_{T}^{miss})",      5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphilmet2"    + suffix, "#Delta#phi(lep2,E_{T}^{miss})",      5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "metTtrkPhi"   + suffix, "track E_{T}^{miss} #phi",            5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "drll"         + suffix, "#DeltaR(lep1,lep2)",                 5, 1, "NULL", scale, false);
	  plotter.Draw(prefix + "jet1mass"     + suffix, "leading jet mass",                  -1, 0, "GeV",  scale, true, 0,   50);
	  plotter.Draw(prefix + "jet2mass"     + suffix, "trailing jet mass",                 -1, 0, "GeV",  scale, true, 0,   50);
	  plotter.Draw(prefix + "mc"           + suffix, "m_{c}",                             10, 0, "GeV",  scale, true, 0,  400);
	  plotter.Draw(prefix + "metTtrk"      + suffix, "track E_{T}^{miss}",                10, 0, "GeV",  scale, true, 0,  400);
	  plotter.Draw(prefix + "mpmet"        + suffix, "min projected E_{T}^{miss}",        10, 0, "GeV",  logY,  true, 0,  200);
	  plotter.Draw(prefix + "mth"          + suffix, "m_{T}^{H}",                         10, 0, "GeV",  scale, true, 0,  400);
	  plotter.Draw(prefix + "mtw1"         + suffix, "m_{T}^{W,1}",                       10, 0, "GeV",  scale, true, 0,  400);
	  plotter.Draw(prefix + "mtw2"         + suffix, "m_{T}^{W,2}",                       10, 0, "GeV",  scale, true, 0,  400);
	  plotter.Draw(prefix + "ht"           + suffix, "H_{T}",                             20, 0, "GeV",  scale, true, 0, 1500);
	  plotter.Draw(prefix + "htjets"       + suffix, "#sum_{jet} p_{T}",                  20, 0, "GeV",  scale, true, 0, 1500);
	  plotter.Draw(prefix + "htnojets"     + suffix, "p_{T}^{lep1} + p_{T}^{lep2} + MET", 20, 0, "GeV",  scale, true, 0, 1500);
	  plotter.Draw(prefix + "pt2l"         + suffix, "p_{T}^{#font[12]{ll}}",             10, 0, "GeV",  scale, true, 0,  300);
	  plotter.Draw(prefix + "ptww"         + suffix, "p_{T}^{WW}",                        10, 0, "GeV",  scale, true, 0,  600);
	  plotter.Draw(prefix + "sumjpt12"     + suffix, "p_{T}^{jet1} + p_{T}^{jet2}",       10, 0, "GeV",  scale, true, 0,  600);
	  plotter.Draw(prefix + "sumpt12"      + suffix, "p_{T}^{lep1} + p_{T}^{lep2}",       10, 0, "GeV",  scale, true, 0,  600);


	  // WW and MonoH histograms
	  //--------------------------------------------------------------------
	  if (analysis.EqualTo("WW") || analysis.EqualTo("MonoH"))
	    {
	      plotter.Draw(prefix + "fullpmet" + suffix, "projected E_{T}^{miss}",       10, 0, "GeV", scale, false, 0, 100);
	      plotter.Draw(prefix + "trkpmet"  + suffix, "projected track E_{T}^{miss}",  2, 0, "GeV", scale, false, 0, 100);
	      plotter.Draw(prefix + "mllstar"  + suffix, "m2l^{*}",                      10, 0, "GeV", scale, false, 0, 300);
	      plotter.Draw(prefix + "metPuppi"     + suffix, "PUPPI E_{T}^{miss}",                10, 0, "GeV",  scale, true, 0,  400);
	    }

	  if (analysis.EqualTo("MonoH"))
	    {
	      plotter.Draw(prefix + "deltarl1met"    + suffix, "#DeltaR(lep1,E_{T}^{miss})", 2, 1, "NULL", scale, false, 0, 4);
	      plotter.Draw(prefix + "deltarl2met"    + suffix, "#DeltaR(lep2,E_{T}^{miss})", 2, 1, "NULL", scale, false, 0, 4);
	      plotter.Draw(prefix + "deltarllmet"    + suffix, "#DeltaR(ll,E_{T}^{miss})",   2, 1, "NULL", scale, false, 0, 4);
              plotter.Draw(prefix + "deltarjet1met"  + suffix, "#DeltaR(jet1,E_{T}^{miss})", 5, 2, "NULL", scale, false);
              plotter.Draw(prefix + "deltarjet2met"  + suffix, "#DeltaR(jet2,E_{T}^{miss})", 5, 2, "NULL", scale, false);
              plotter.Draw(prefix + "deltarjj"       + suffix, "#DeltaR(jet1,jet2)",         5, 2, "NULL", scale, false);
              plotter.Draw(prefix + "deltarjjmet"    + suffix, "#DeltaR(jj,E_{T}^{miss})",   5, 2, "NULL", scale, false);
              plotter.Draw(prefix + "deltarlep1jet1" + suffix, "#DeltaR(lep1,jet1)",         5, 2, "NULL", scale, false);
              plotter.Draw(prefix + "deltarlep1jet2" + suffix, "#DeltaR(lep1,jet2)",         5, 2, "NULL", scale, false);
              plotter.Draw(prefix + "deltarlep2jet1" + suffix, "#DeltaR(lep2,jet1)",         5, 2, "NULL", scale, false);
              plotter.Draw(prefix + "deltarlep2jet2" + suffix, "#DeltaR(lep2,jet2)",         5, 2, "NULL", scale, false);
	    }


	  // WZ histograms
	  //--------------------------------------------------------------------
	  if (analysis.EqualTo("WZ"))
	    {
	      plotter.Draw(prefix + "m3l"        + suffix, "m_{#font[12]{3l}}",                10, 0, "GeV",  scale, true, 60, 360);
	      plotter.Draw(prefix + "mtw"        + suffix, "W transverse mass",                10, 0, "GeV",  scale, true,  0, 150);
	      plotter.Draw(prefix + "zl1pt"      + suffix, "Z leading lepton p_{T}",           10, 0, "GeV",  scale, true,  0, 150);
	      plotter.Draw(prefix + "zl2pt"      + suffix, "Z trailing lepton p_{T}",          10, 0, "GeV",  scale, true,  0, 150);
	      plotter.Draw(prefix + "wlpt"       + suffix, "W lepton p_{T}",                   10, 0, "GeV",  scale, true,  0, 150);
	      plotter.Draw(prefix + "wlzldeltar" + suffix, "min #DeltaR(W lepton, Z leptons)",  5, 1, "NULL", scale);
	    }
	}
    }


  // Cross section
  //----------------------------------------------------------------------------
  //  root -l eos/cms/store/group/phys_higgs/cmshww/amassiro/HWW12fb_v2/07Jun2016_spring16_mAODv2_12pXfbm1/MCl2loose__hadd__bSFL2pTEff__l2tight/latino_WWTo2L2Nu.root as _file0...
  //  mcWeightPos->GetEntries() - mcWeightNeg->GetEntries()
  //  1.96718e+06
  //
  if (analysis.EqualTo("Control") && level.Contains("WW"))
    {
      printf("\n Cross section\n");
      printf("---------------\n\n");

      for (int i=firstchannel; i<=lastchannel; i++)
	plotter.CrossSection(level,
			     schannel[i],
			     "WW",
			     WW2lnu,
			     "WWTo2L2Nu",            12.1780, 1967180,
			     "GluGluWWTo2L2Nu_MCFM",  0.5905,  481600);
    }


  // Copy index.php in every directory
  //----------------------------------------------------------------------------
  gSystem->Exec("for dir in $(find ./ -type d); do cp -n ../index.php $dir/; done");
  gSystem->Exec("rm -f index.php");
}
Example #23
0
  /** 
   * Create our tasks.  This uses the interpreter to make the object.
   * 
   * @param mgr 
   */
  void CoupleTrackletCar(AliAnalysisManager* mgr)
  {
    AliAnalysisManager::SetCommonFileName("tracklet_dndeta.root");
    TString fwd(gSystem->Getenv("ANA_SRC"));
    if (fwd.IsNull()) fwd = "$ALICE_PHYSICS/PWGLF/FORWARD/analysis2";
    gROOT->SetMacroPath(Form("%s:%s/dndeta/tracklets3",
			     gROOT->GetMacroPath(), fwd.Data()));
    gSystem->AddIncludePath(Form("-I%s/dndeta/tracklets3", fwd.Data()));
    
    Info("CreateTasks", "Loading code");
    fRailway->LoadSource("FixPaths.C");
    fRailway->LoadSource("AliAODSimpleHeader.C");
    fRailway->LoadSource("AliAODTracklet.C");
    fRailway->LoadSource("AliTrackletWeights.C");
    fRailway->LoadSource("AliTrackletAODUtils.C");
    fRailway->LoadSource("AliTrackletAODdNdeta.C");

    // --- Create the task using interpreter -------------------------
    Bool_t   mc = fOptions.Has("mc");
    if (!mc) mc = fRailway->IsMC();     
    Long_t ret  =
      gROOT->ProcessLine(Form("AliTrackletAODdNdeta::Create(%d,\"%s\")",mc,
			      fOptions.AsString("reweigh")));
    AliAnalysisTaskSE* task = reinterpret_cast<AliAnalysisTaskSE*>(ret);
    if (!task) return;
    
    // --- Figure out the trigger options ----------------------------
    TString trg = fOptions.Get("trig"); trg.ToUpper();
    UInt_t  sel = AliVEvent::kINT7;
    UInt_t  mb  = AliVEvent::kINT1; // AliVEvent::kMB;
    if      (trg.EqualTo("MB"))      sel = mb;
    else if (trg.EqualTo("MBOR"))    sel = mb;
    else if (trg.EqualTo("INEL"))    sel = mb;
    else if (trg.EqualTo("INELGT0")) sel = mb;
    else if (trg.EqualTo("V0AND"))   sel = AliVEvent::kINT7;
    else if (trg.EqualTo("NSD"))     sel = AliVEvent::kINT7;
    else if (trg.EqualTo("V0OR"))    sel = AliVEvent::kCINT5;
    else if (trg.EqualTo("ANY"))     sel = AliVEvent::kAny;
    task->SelectCollisionCandidates(sel);
    Int_t minTrk = trg.EqualTo("INELGT0") ? 1 : 0;

    // --- Figure out calculation mode -------------------------------
    TString calc = fOptions.Get("reweigh-calc"); calc.ToUpper();
    UChar_t mcal = 0;
    if      (calc.BeginsWith("PROD")) mcal = 0;
    else if (calc.BeginsWith("SQ"))   mcal = 1;
    else if (calc.BeginsWith("SUM"))  mcal = 2;
    else if (calc.BeginsWith("AV"))   mcal = 3;
    
    // --- Set various options on task -------------------------------
    const char* defCent = "0-5-10-20-30-40-50-60-70-80-90";
    FromOption(task, "CentralityMethod","cent", 	    "V0M");
    FromOption(task, "CentralityAxis",  "cent-bins",        defCent);
    FromOption(task, "EtaAxis",         "eta-bins",         "r16:2");
    FromOption(task, "IPzAxis",         "ipz-bins",         "u15");
    FromOption(task, "DeltaCut",	"delta-cut",	    1.5);
    FromOption(task, "TailDelta",	"tail-delta",	    5.);
    FromOption(task, "TailMaximum",	"tail-max",	    -1);
    FromOption(task, "MaxDelta",	"max-delta",	    25.);
    FromOption(task, "DPhiShift",	"dphi-shift",	    0.0045);
    FromOption(task, "ShiftedDPhiCut",	"shifted-dphi-cut",-1.);
    FromOption(task, "AbsMinCent",      "abs-min-cent",    -1.);
    FromOption(task, "WeightMask",      "reweigh-mask",     0xFF);
    FromOption(task, "WeightVeto",      "reweigh-veto",     0x0);
    SetOnTask (task, "WeightCalc",                          mcal);
    FromOption(task, "WeightInverse",   "reweigh-inv",      false);
    FromOption(task, "TriggerEff",      "trigEff",          0.);
    SetOnTask (task, "MinEta1",                             minTrk);
    // if (mc && we) {
    //   TUrl wurl(fOptions.AsString("reweight"));
    //   TFile* wfile = TFile::Open(wurl.GetFile());
    //   if (!wfile) {
    // 	Warning("CreateTasks", "Failed to open weights file: %s",
    // 		wurl.GetUrl());
    // 	return;
    //   }
    //   TString wnam(wurl.GetAnchor());
    //   if (wnam.IsNull()) wnam = "weights";
    //   TObject* wobj = wfile->Get(wnam);
    //   if (!wobj) {
    // 	Warning("CreateTasks", "Failed to get weights %s from file %s",
    // 		wnam.Data(), wfile->GetName());
    // 	return;
    //   }
    //   if (!wobj->IsA()->InheritsFrom("AliTrackletWeights")) {
    // 	Warning("CreateTasks", "Object %s from file %s not an "
    // 		"AliTrackletWeights but a %s",
    // 		wnam.Data(), wfile->GetName(), wobj->ClassName());
    // 	return;
    //   }
    //   SetOnTaskGeneric(task, "Weights",
    // 		       Form("((AliTrackletWeights*)%p)", wobj));
    // }
    Printf("Print the generated task");
    task->Print("");    
  }
Example #24
0
void generalpTT::DoAnalysis(const TString filelist, const Int_t ntarget, const TString tag)
{
    
    TString GEN = TString("");
    TString gTrack = TString("");
    
    if(filelist.Contains("neut",TString::kIgnoreCase)){
        GEN.Append("NEUT");
        gTrack.Append("nRooTracker");
    }
    else if(filelist.Contains("genie",TString::kIgnoreCase)){
        GEN.Append("GENIE");
        gTrack.Append("gRooTracker");
    }
    else if(filelist.Contains("nuwro",TString::kIgnoreCase)){
        GEN.Append("NUWRO");
        gTrack.Append("nRooTracker");
    }
    else if(filelist.Contains("gibuu",TString::kIgnoreCase)){
        GEN.Append("GIBUU");
        gTrack.Append("giRooTracker");
    }
    else{
        printf("generalpTT::ERROR : Cannot determine generator, please check.\n");
        exit(1);
    }
    
    if(filelist.Contains("ccqe", TString::kIgnoreCase)){
        GEN.Append("CCQE");
        printf("NOTE: File is determined to contain CCQE interactions only.\n");
    }
    
    
    const TString gen = (const TString)GEN;

    gRooTrackerUtils::Ini();
    Init(gRooTrackerUtils::IniIO(filelist,gTrack));
    
    TList *lout = gRooTrackerUtils::GetHistList();
    TTree *tout = gRooTrackerUtils::GetTree();
    
    const Int_t nentries = fChain->GetEntries();
    Int_t nsel = 0;
    
    printf("********************************\n");
    printf("Analysing in %s mode\n", gen.Data());
    printf("********************************\n");
    
    #ifdef Verbosity
        std::cout << "WARNING RUNNING IN VERBOSE MODE" << std::endl;
    #endif
    
    Int_t ndpp = 0;
    double pmomcons = 0.;
    Int_t ncons = 0;
    for (Int_t jentry = 0; jentry<nentries; jentry++) {
        
        if(jentry%10000==0) printf("%d/%d nsel %d\n", jentry, nentries, nsel);
        if(!fChain->GetEntry(jentry)){
            printf("DoAnalysis GetEntry ends at jentry %d\n", jentry);
            break;
        }
    
        #ifdef Verbosity
            std:cout<<"Event "<<jentry+1;
        #endif
        
       /* if(fString){
            if(fString.Atoi() == 11){
                #ifdef Verbosity
                    std::cout<<" Delta++";
                #endif
                ndpp++;
                //continue;
            }
        }*/
        
        #ifdef Verbosity
            std::cout<<" "<<std::endl;
        #endif
        
        gRooTrackerUtils::FillCount(lout,0);

        const Int_t nfound = gRooTrackerUtils::FindParticles(StdHepN, StdHepPdg, StdHepStatus, StdHepP4, StdHepP4, gen);

        gRooTrackerUtils::SetCount(nfound);
        gRooTrackerUtils::SetpTT();
        gRooTrackerUtils::SetDeltapTT();
        gRooTrackerUtils::SetSigneddpTT();
        gRooTrackerUtils::SetdpT();
        //gRooTrackerUtils::SetConsSum();
        gRooTrackerUtils::SetAltdpTT();
        gRooTrackerUtils::SetAbsdpTT();
        
        if(gen.EqualTo("NEUT",TString::kIgnoreCase)){
            gRooTrackerUtils::GetMomCons();
            
            #ifdef Verbosity
                std::cout << "dp = "<< (*gRooTrackerUtils::fMomCons) << std::endl;
            #endif
            
            if((*gRooTrackerUtils::fMomCons) > 0.01){
                #ifdef Verbosity
                    std::cout<<"*** Mom. not conserved ***"<<std::endl;
                #endif
                
                ncons++;
            }
            pmomcons = ncons*100/ndpp;
        }
        
        gRooTrackerUtils::FillCount(lout,11);
        tout->Fill();
        nsel++;
        if(ntarget>=0 && nsel>=ntarget) break;
    }
    
    std::cout<<std::endl;
    std::cout<<"SELECTION SUMMARY"<<std::endl;
    std::cout<<"No. Delta++ Events (NeutMode==11): "<<ndpp<<std::endl;
    std::cout<<"Percentage of events where momentum is not conserved: "<< pmomcons << "%" <<std::endl;
    
    printf("generalpTT: nsel %d of ntarget %d for %d nentries\n", nsel, ntarget, nentries);
    
    Int_t nevents;
    if(nsel < ntarget){
        nevents = nsel;
    }
    else{
        nevents = ntarget;
    }
    
    TFile *fout= new TFile(Form("%s_%d_DeltapTT.root",tag.Data(), nevents),"recreate");
    tout->Write();
    //for further handling in plot
    lout->Write("lout",TObject::kSingleKey);
    fout->Save();
    fout->Close();
    printf("FILE SAVED AS %s_%d_DeltapTT.root\n", tag.Data(), nevents);
    delete fout;
    delete lout;
    delete tout;

}
void drawPtDependencePA(TString dirName, int prodDate, int jetPtCut, TString fNameSuffix, TString outNameSuffix){
  bool saveFigures=true;

  const int nPtBin = 4;
  double ptBin[nPtBin+1] = {40, 50,60,80,9999};
  double ptBinPaDraw[nPtBin+1] = { 40.5 ,49.5, 58.5,  76.5,  123. } ;
  // double AvePtBin[nPtBin+1] = { 45, 54.1479, 67.4204, 99.6956, 9999};

  const int nCentBinHI = 2;
  const int centBinHI[nCentBinHI +1] = {-1, 10030, 13099};

  TH1D* hxjg[7][10][6]; // [Collision][centrality][pt]
  TH1D* hJetPt[7][10][6]; // [Collision][centrality][pt]
  TH1D* hJetPtIaaBin[7][10][6]; // [Collision][centrality][pt]
  TH1D* hDphi[7][10][6]; // [Collision][centrality][pt]
  TH1D* meanXjg[7][10];      // [Collision][centrality]
  TH1D* meanJetPt[7][10];      // [Collisi on][centrality]

  TH1D* rjg[7][5];     //  [Collision][centrality]
  for (int icoll=0 ; icoll<6  ; icoll++) {
      for (int icent=1 ; icent<= 10 ; icent++) {
          meanXjg[icoll][icent] = new TH1D( Form("meanXjg_icoll%d_icent%d",icoll,icent), ";p_{T}^{#gamma} (GeV); <X_{J#gamma}>",nPtBin,ptBinPaDraw);
          meanJetPt[icoll][icent] = new TH1D( Form("meanJetPt_icoll%d_icent%d",icoll,icent), ";p_{T}^{#gamma} (GeV); <p_{T}^{Jet}>",nPtBin,ptBinPaDraw);
          rjg[icoll][icent] = new TH1D( Form("rjg_icoll%d_icent%d",icoll,icent), ";p_{T}^{#gamma} (GeV); R_{J#gamma}",nPtBin,ptBinPaDraw);

          for (int ipt=1 ; ipt<=nPtBin ; ipt++) {
              hxjg[icoll][icent][ipt] = NULL;
              hJetPt[icoll][icent][ipt] = NULL;
              hJetPtIaaBin[icoll][icent][ipt] = NULL;
              hDphi[icoll][icent][ipt] = NULL;
          }

      }
  }

  TFile* histFile[7][6];  // [Collision][pt]
  for (int ipt=1 ; ipt<=nPtBin ; ipt++) {
      for (int icoll=0 ; icoll<6 ; icoll++) {
          TString sampleName = getSampleName( icoll ) ;
          char* fname;
          if (fNameSuffix.EqualTo(""))  {  // if no explicit suffix for the input file name is specified
              fname =  Form("ffFiles/%s/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr%d_%d.root",dirName.Data(), sampleName.Data(), (int)ptBin[ipt-1], (int)ptBin[ipt], (int)jetPtCut, prodDate);
          }
          else {
              fname =  Form("ffFiles/%s/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr%d_%d_%s.root",dirName.Data(), sampleName.Data(), (int)ptBin[ipt-1], (int)ptBin[ipt], (int)jetPtCut, prodDate, fNameSuffix.Data());
          }

          histFile[icoll][ipt] = new TFile(fname) ;
          cout << " Reading file : " << fname << endl;

          if ( histFile[icoll][ipt]->IsZombie()  == false ) {
              cout << " Success." << endl;
              if ( (icoll == kPPDATA) || (icoll == kPPMC) )   {  //  PP
                  int icent = 7 ;
                  hxjg[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("xjg_icent%d_final", icent)) ;
                  cout << " Getting histogram : " << Form("xjg_icent%d_final", icent) << endl;
                  hJetPt[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPt_icent%d_final", icent)) ;
                  cout << " Getting histogram : " << Form("jetPt_icent%d_final", icent) << endl;
                  hJetPtIaaBin[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPtForIaa_icent%d_final", icent)) ;
                  cout << " Getting histogram : " << Form("jetPtForIaa_icent%d_final", icent) << endl;
                  hDphi[icoll][icent][ipt]  = (TH1D*)histFile[icoll][ipt]->Get(Form("jetDphi_icent%d_final", icent)) ;
                  cout << " Getting histogram : " << Form("jetDphi_icent%d_final", icent) << endl;
                  //hEta[icoll][icent][ipt]  = (TH1D*)histFile[icoll][ipt]->Get(Form("etaJg_icent%d_final", icent)) ;
                  //cout << " Getting histogram : " << Form("etaJg_icent%d_final", icent) << endl;

              }

              if ( (icoll == kPADATA) || (icoll == kPAMC) )   {  //  PA
                  int icent = 1 ;
                  hxjg[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("xjg_icent%d_final", icent)) ;
                  cout << " Getting histogram : " << Form("xjg_icent%d_final", icent) << endl;
                  hJetPt[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPt_icent%d_final", icent)) ;
                  cout << " Getting histogram : " << Form("jetPt_icent%d_final", icent) << endl;
                  hJetPtIaaBin[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPtForIaa_icent%d_final", icent ) ) ;
                  cout << " Getting histogram : " << Form("jetPtForIaa_icent%d_final", icent ) << endl;

                  hDphi[icoll][icent][ipt]  = (TH1D*)histFile[icoll][ipt]->Get(Form("jetDphi_icent%d_final", icent)) ;
                  cout << " Getting histogram : " << Form("jetDphi_icent%d_final", icent) << endl;
                  //hEta[icoll][icent][ipt]  = (TH1D*)histFile[icoll][ipt]->Get(Form("etaJg_icent%d_final", icent)) ;
                  //cout << " Getting histogram : " << Form("etaJg_icent%d_final", icent) << endl;

              }

              if ( ( icoll == kHIDATA) ||  (icoll == kHIMC) ) { // PbPb
                  for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
                      hxjg[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("xjg_icent%d_final", centBinHI[icent] )) ;
                      cout << " Getting histogram : " << Form("xjg_icent%d_final", centBinHI[icent] ) << endl;
                      hJetPt[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPt_icent%d_final", centBinHI[icent] ) );
                      cout << " Getting histogram : " << Form("jetPt_icent%d_final", centBinHI[icent] ) << endl;
                      hJetPtIaaBin[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPtForIaa_icent%d_final", centBinHI[icent] ) );
                      cout << " Getting histogram : " << Form("jetPtForIaa_icent%d_final", centBinHI[icent] ) << endl;
                      hDphi[icoll][icent][ipt]  = (TH1D*)histFile[icoll][ipt]->Get(Form("jetDphi_icent%d_final", centBinHI[icent] ) ) ;
                      cout << " Getting histogram : " << Form("jetDphi_icent%d_final", centBinHI[icent])<< endl;
                      //hEta[icoll][icent][ipt]  = (TH1D*)histFile[icoll][ipt]->Get(Form("etaJg_icent%d_final", centBinHI[icent] ) ) ;
                      //cout << " Getting histogram : " << Form("etaJg_icent%d_final", centBinHI[icent])<< endl;
                  }
              }
          }
          else
              cout << " no such file " << endl;
      }
  }

  for (int ipt=1 ; ipt<=nPtBin ; ipt++) {
      for (int icoll=0 ; icoll<6 ; icoll++) {
          for (int icent=1 ; icent<= 10 ; icent++ ) {

              if ( hxjg[icoll][icent][ipt] == NULL )  continue;   // emtpy histogram

              double rVal, rErr;
              rVal = hxjg[icoll][icent][ipt]->IntegralAndError(1, hxjg[icoll][icent][ipt]->GetNbinsX(), rErr, "width");
              rjg[icoll][icent]->SetBinContent( ipt, rVal );
              rjg[icoll][icent]->SetBinError  ( ipt, rErr );

              meanXjg[icoll][icent]->SetBinContent( ipt, hxjg[icoll][icent][ipt]->GetMean() );
              meanXjg[icoll][icent]->SetBinError  ( ipt, hxjg[icoll][icent][ipt]->GetMeanError() );

              meanJetPt[icoll][icent]->SetBinContent( ipt, hJetPt[icoll][icent][ipt]->GetMean() );
              meanJetPt[icoll][icent]->SetBinError  ( ipt, hJetPt[icoll][icent][ipt]->GetMeanError() );
          }
      }
  }

  TCanvas* c1 = new TCanvas("c1","",1200,350);
  makeMultiPanelCanvas(c1,nPtBin,1,0.0,0.0,0.2,0.15,0.02);
  for ( int ipt = 1 ; ipt<=nPtBin  ; ipt++) {

      c1->cd(ipt);

      handsomeTH1(hDphi[kPAMC][1][ipt], 1);
      hDphi[kPAMC][1][ipt]->SetXTitle("#Delta#phi_{J#gamma}");
      hDphi[kPAMC][1][ipt]->SetYTitle("Normalized entries");
      hDphi[kPAMC][1][ipt]->SetMarkerStyle(24);
      hDphi[kPAMC][1][ipt]->Scale(1./hDphi[kPAMC][1][ipt]->Integral("width"));
      hDphi[kPAMC][1][ipt]->SetAxisRange(0,3.141592,"X");
      hDphi[kPAMC][1][ipt]->SetAxisRange(0.01,30,"Y");
      hDphi[kPAMC][1][ipt]->Draw();

      handsomeTH1(hDphi[kPADATA][1][ipt], kRed);
      hDphi[kPADATA][1][ipt]->Scale(1./hDphi[kPADATA][1][ipt]->Integral("width"));
      hDphi[kPADATA][1][ipt]->Draw("same");

      gPad->SetLogy();

      double dx1=0.15;
      if ( ipt == nPtBin )
          drawText(Form("p_{T}^{#gamma} > %dGeV, ", (int)ptBin[ipt-1]), 0.12+dx1+0.25,0.85,1,15);//yeonju 130823
      else
          drawText(Form("%dGeV < p_{T}^{#gamma} < %dGeV, ", (int)ptBin[ipt-1], (int)ptBin[ipt]), 0.12+dx1,0.85,1,15);//yeonju 130823

  }
  c1->cd(1);

  TLegend *l1 = new TLegend(0.2199474,0.5971384,0.7283974,0.8119819,NULL,"brNDC");
  easyLeg(l1,"5.02TeV");
  l1->AddEntry(hDphi[kPAMC][1][1],"pA pythia+HIJING ","p");
  l1->AddEntry(hDphi[kPADATA][1][1],"pA Data","p");
  l1->Draw();

  if (saveFigures) {
      if(outNameSuffix.EqualTo("")){
          c1->SaveAs("figures/pT_dependence_dphi_pA_figure1.pdf");
          c1->SaveAs("figures/pT_dependence_dphi_pA_figure1.gif");
      }
      else {
          c1->SaveAs(Form("figures/pT_dependence_dphi_pA_figure1_%s.pdf", outNameSuffix.Data()));
          c1->SaveAs(Form("figures/pT_dependence_dphi_pA_figure1_%s.gif", outNameSuffix.Data()));
      }
  }


  TH1D* hTempPt = new TH1D("hTemp",";p_{T}^{#gamma} (GeV);",200,10,300);

  TCanvas* c2 = new TCanvas("c2","",1200,350);
  makeMultiPanelCanvas(c2,nPtBin,1,0.0,0.0,0.2,0.15,0.02);
  for ( int ipt = 1 ; ipt<=nPtBin  ; ipt++) {

      c2->cd(ipt);

      hTempPt->SetXTitle("p_{T}^{Jet} (GeV)");
      hTempPt->SetYTitle("#frac{dN}{dp_{T}} #frac{1}{N}");
      hTempPt->SetAxisRange(10,150,"X");
      //        hTempPt->SetAxisRange(0,0.025,"Y");
      hTempPt->SetAxisRange(0,0.08,"Y");
      handsomeTH1(hTempPt,0);
      hTempPt->DrawCopy();

      //	hJetPt[kPAMC][1][ipt]->Scale(1./rjg[kPAMC][1]->GetBinContent(ipt)); // rjg normalization

      handsomeTH1(hJetPt[kPAMC][1][ipt], 1);
      hJetPt[kPAMC][1][ipt]->SetMarkerStyle(24);
      hJetPt[kPAMC][1][ipt]->Draw("same");

      handsomeTH1(hJetPt[kPADATA][1][ipt],kRed);
      //	hJetPt[kPADATA][1][ipt]->Scale(1./rjg[kPADATA][1]->GetBinContent(ipt));

      hJetPt[kPADATA][1][ipt]->Draw("same");


      double dx1=0.15;
      if ( ipt == nPtBin )
          drawText(Form("p_{T}^{#gamma} > %dGeV, ", (int)ptBin[ipt-1]), 0.12+dx1+0.25,0.85,1,15);//yeonju 130823
      else
          drawText(Form("%dGeV < p_{T}^{#gamma} < %dGeV, ", (int)ptBin[ipt-1], (int)ptBin[ipt]), 0.12+dx1,0.85,1,15);//yeonju 130823

      onSun(30,0,200,0);
  }
  c2->cd(1);
  l1->Draw();

  if (saveFigures) {
      if(outNameSuffix.EqualTo("")){
          c2->SaveAs("figures/pT_dependence_jetPt_pA_figure1.pdf");
          c2->SaveAs("figures/pT_dependence_jetPt_pA_figure1.gif");
      }
      else {
          c2->SaveAs(Form("figures/pT_dependence_jetPt_pA_figure1_%s.pdf", outNameSuffix.Data()));
          c2->SaveAs(Form("figures/pT_dependence_jetPt_pA_figure1_%s.gif", outNameSuffix.Data()));
      }
  }

  TLegend *l2 = new TLegend(0.2116935,0.7012712,0.6149194,0.904661,NULL,"brNDC");
  easyLeg(l2,"5.02TeV");

  l2->AddEntry(hDphi[kPAMC][1][1],"pPb pythia+HIJING","p");
  l2->AddEntry(hDphi[kPADATA][1][1],"pPb Data","p");


  TCanvas* c21 = new TCanvas("c21","",500,500);
  handsomeTH1(meanJetPt[kPAMC][1], 1);
  meanJetPt[kPAMC][1]->SetYTitle("<p_{T}^{Jet}>  (>30GeV)");
  meanJetPt[kPAMC][1]->SetMarkerStyle(24);
  //  meanJetPt[kPAMC][1]->SetAxisRange(-2,2,"X");
  meanJetPt[kPAMC][1]->SetAxisRange(40,115,"Y");
  meanJetPt[kPAMC][1]->Draw();

  handsomeTH1(meanJetPt[kPADATA][1],kRed);
  meanJetPt[kPADATA][1]->Draw("same");

  l1 ->Draw();

  if (saveFigures) {
      if(outNameSuffix.EqualTo("")){
          c21->SaveAs("figures/pT_dependence_jetPt_pA_figure2.pdf");
          c21->SaveAs("figures/pT_dependence_jetPt_pA_figure2.gif");
      }
      else {
          c21->SaveAs(Form("figures/pT_dependence_jetPt_pA_figure2_%s.pdf", outNameSuffix.Data()));
          c21->SaveAs(Form("figures/pT_dependence_jetPt_pA_figure2_%s.gif", outNameSuffix.Data()));
      }
  }


  TCanvas* c3 = new TCanvas("c3","",1200,350);
  makeMultiPanelCanvas(c3,nPtBin,1,0.0,0.0,0.2,0.15,0.02);
  for ( int ipt = 1 ; ipt<=nPtBin  ; ipt++) {

      c3->cd(ipt);

      handsomeTH1(hxjg[kPAMC][1][ipt], 1);
      hxjg[kPAMC][1][ipt]->SetXTitle("x_{J#gamma}");
      hxjg[kPAMC][1][ipt]->SetYTitle("#frac{dN}{dp_{T}} #frac{1}{N}");
      hxjg[kPAMC][1][ipt]->SetMarkerStyle(24);

      //	hxjg[kPAMC][1][ipt]->Scale(1./rjg[kPAMC][1]->GetBinContent(ipt)); // rjg normalization


      hxjg[kPAMC][1][ipt]->SetAxisRange(0,2,"X");
      hxjg[kPAMC][1][ipt]->Draw();

      handsomeTH1(hxjg[kPADATA][1][ipt],kRed);
      //	hxjg[kPADATA][1][ipt]->Scale(1./rjg[kPADATA][1]->GetBinContent(ipt)); // rjg normalization


      hxjg[kPADATA][1][ipt]->Draw("same");

      double dx1=0.15;
      if ( ipt == nPtBin )
          drawText(Form("p_{T}^{#gamma} > %dGeV, ", (int)ptBin[ipt-1]), 0.12+dx1+0.25,0.85,1,15);//yeonju 130823
      else
          drawText(Form("%dGeV < p_{T}^{#gamma} < %dGeV, ", (int)ptBin[ipt-1], (int)ptBin[ipt]), 0.12+dx1,0.85,1,15);//yeonju 130823


      onSun(30,0,200,0);
  }
  c3->cd(1);
  l1->Draw();

  if (saveFigures) {
      if(outNameSuffix.EqualTo("")){
          c3->SaveAs("figures/pT_dependence_xjg_pA_figure1.pdf");
          c3->SaveAs("figures/pT_dependence_xjg_pA_figure1.gif");
      }
      else {
          c3->SaveAs(Form("figures/pT_dependence_xjg_pA_figure1_%s.pdf", outNameSuffix.Data()));
          c3->SaveAs(Form("figures/pT_dependence_xjg_pA_figure1_%s.gif", outNameSuffix.Data()));
      }
  }

  TCanvas* c31 = new TCanvas("c31","",500,500);
  handsomeTH1(meanXjg[kPAMC][1], 1);
  meanXjg[kPAMC][1]->SetYTitle("<x_{J#gamma}>  (>30GeV)");
  meanXjg[kPAMC][1]->SetMarkerStyle(24);
  //  meanXjg[kPAMC][1]->SetAxisRange(-2,2,"X");
  meanXjg[kPAMC][1]->SetAxisRange(0.6,1.2,"Y");
  meanXjg[kPAMC][1]->Draw();

  handsomeTH1(meanXjg[kPADATA][1],kRed);
  meanXjg[kPADATA][1]->Draw("same");

  l1->Draw();

  if (saveFigures) {
      if(outNameSuffix.EqualTo("")){
          c31->SaveAs("figures/pT_dependence_xjg_pA_figure2.pdf");
          c31->SaveAs("figures/pT_dependence_xjg_pA_figure2.gif");
      }
      else {
          c31->SaveAs(Form("figures/pT_dependence_xjg_pA_figure2_%s.pdf", outNameSuffix.Data()));
          c31->SaveAs(Form("figures/pT_dependence_xjg_pA_figure2_%s.gif", outNameSuffix.Data()));
      }
  }

  TCanvas* c_rjg = new TCanvas("c_rjg","",500,500);
  handsomeTH1(rjg[kPAMC][1], 1);
  rjg[kPAMC][1]->SetYTitle("R_{J#gamma}");
  rjg[kPAMC][1]->SetMarkerStyle(24);
  //  rjg[kPAMC][1]->SetAxisRange(-2,2,"X");
  rjg[kPAMC][1]->SetAxisRange(0.0,1.1,"Y");
  rjg[kPAMC][1]->Draw();

  handsomeTH1(rjg[kPADATA][1],kRed);
  rjg[kPADATA][1]->Draw("same");


  l1->Draw();

  if (saveFigures) {
      if(outNameSuffix.EqualTo("")){
          c_rjg->SaveAs("figures/pT_dependence_rjg_pA_figure1.pdf");
          c_rjg->SaveAs("figures/pT_dependence_rjg_pA_figure1.gif");
      }
      else {
          c_rjg->SaveAs(Form("figures/pT_dependence_rjg_pA_figure1_%s.pdf", outNameSuffix.Data()));
          c_rjg->SaveAs(Form("figures/pT_dependence_rjg_pA_figure1_%s.gif", outNameSuffix.Data()));
      }
  }

  // Save the final root histogram files
  TFile* fResults;
  if(outNameSuffix.EqualTo("")){
      fResults =  new TFile("resultHistograms.root", "update");
  }
  else   {
      fResults =  new TFile(Form("resultHistograms_%s.root", outNameSuffix.Data()), "update");
  }
  //    TFile * fResults =  new TFile("resultHistograms_ppb_photonEnergy_ScaledBy0.015.root","update");

  meanJetPt[kPADATA][1]->SetName(Form("meanJetPt_ppb"));
  meanJetPt[kPADATA][1]->Write();

  meanXjg[kPADATA][1]->SetName(Form("meanXjg_ppb"));
  meanXjg[kPADATA][1]->Write();

  rjg[kPADATA][1]->SetName(Form("meanRjg_ppb"));
  rjg[kPADATA][1]->Write();

  for ( int ipt = 1 ; ipt<=nPtBin  ; ipt++) {
      hJetPt[kPADATA][1][ipt]->SetName(Form("dNdJetPt_ppb_ptBin%d",ipt));
      hJetPt[kPADATA][1][ipt]->Write();

      hJetPtIaaBin[kPADATA][1][ipt]->SetName(Form("dNdJetPt_IaaBin_ppb_ptBin%d",ipt));
      hJetPtIaaBin[kPADATA][1][ipt]->Write();

      hxjg[kPADATA][1][ipt]->SetName(Form("dNdXjg_ppb_ptBin%d",ipt));
      hxjg[kPADATA][1][ipt]->Write();

      hDphi[kPADATA][1][ipt]->SetName(Form("dNdphi_ppb_ptBin%d",ipt));
      hDphi[kPADATA][1][ipt]->Write();
  }

  fResults->Close();
}
Example #26
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// drawFigures4and5
//
// Zpt
// LeadingJetPt
// Njets
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void drawFigures4and5(TString var = "Zpt") 
{
  gSystem->mkdir("pdf", kTRUE);
  gSystem->mkdir("png", kTRUE);

  gInterpreter->ExecuteMacro("WZPaperStyle.C");

  Bool_t drawMcfm = (var.EqualTo("Zpt")) ? true : false;

  TString variable;
  TString xtitle;
  TString ytitle;

  if (var.EqualTo("Zpt"))          variable = "Z";
  if (var.EqualTo("LeadingJetPt")) variable = "leading jet";
  if (var.EqualTo("Njets"))        variable = "N_{jets}";

  if (var.EqualTo("Njets"))
    {
      xtitle = variable;
      ytitle = "d#sigma(WZ#rightarrow3l#nu)/d" + variable + " (pb)";
    }
  else
    {
      xtitle = "p_{T}^{" + variable + "} (GeV)";
      ytitle = "d#sigma(WZ#rightarrow3l#nu)/dp_{T}^{" + variable + "} (pb/GeV)";
    }

  TFile* file = new TFile("rootfiles/all_unfolding_" + var + ".root", "read");

  TH1D* xsValue          = (TH1D*)file->Get("hComb_diff");
  TH1D* xsValue_Madgraph = (TH1D*)file->Get("hGenXs" + var + "_1");
  TH1D* xsValue_MCnlo;

  if (drawMcfm) xsValue_MCnlo = (TH1D*)file->Get("mcfm_tot");


  // Data cosmetics
  //----------------------------------------------------------------------------
  xsValue->SetFillColor  (     kWhite);
  xsValue->SetFillStyle  (       1001);
  xsValue->SetLineColor  (     kBlack);
  xsValue->SetLineWidth  (          1);
  xsValue->SetMarkerColor(     kBlack);
  xsValue->SetMarkerSize (     _msize);
  xsValue->SetMarkerStyle(kFullCircle);


  // Madgraph cosmetics
  //----------------------------------------------------------------------------
  xsValue_Madgraph->SetFillColor  (    kOrange);
  xsValue_Madgraph->SetFillStyle  (       1001);
  xsValue_Madgraph->SetLineColor  (  kOrange+7);
  xsValue_Madgraph->SetLineWidth  (          1);
  xsValue_Madgraph->SetMarkerColor(  kOrange+7);
  xsValue_Madgraph->SetMarkerSize (     _msize);
  xsValue_Madgraph->SetMarkerStyle(kFullSquare);


  // MCNLO cosmetics
  //----------------------------------------------------------------------------
  if (drawMcfm)
    {
      xsValue_MCnlo->SetFillColor  (   kAzure-9);
      xsValue_MCnlo->SetFillStyle  (       1001);
      xsValue_MCnlo->SetLineColor  (     kAzure);
      xsValue_MCnlo->SetLineWidth  (          1);
      xsValue_MCnlo->SetMarkerColor(     kAzure);
      xsValue_MCnlo->SetMarkerSize (     _msize);
      xsValue_MCnlo->SetMarkerStyle(kOpenCircle);
    }


  // Set the canvas and pads
  //----------------------------------------------------------------------------
  TCanvas* canvas = new TCanvas(var, var);

  TPad* pad1;
  TPad* pad2;
  TPad* pad3;

  if (drawMcfm)
    {
      pad1 = new TPad("pad1" + var, "pad1" + var, 0, 0.49, 1, 1.000);
      pad2 = new TPad("pad2" + var, "pad2" + var, 0, 0.33, 1, 0.492);
      pad3 = new TPad("pad3" + var, "pad3" + var, 0, 0.00, 1, 0.332);
  
      pad1->SetTopMargin(0.09);
      pad2->SetTopMargin(0);
      pad3->SetTopMargin(0);

      pad1->SetBottomMargin(0);
      pad2->SetBottomMargin(0);
      pad3->SetBottomMargin(0.45);

      pad1->SetLeftMargin(0.16);
      pad2->SetLeftMargin(0.16);
      pad3->SetLeftMargin(0.16);
      
      pad1->SetRightMargin(0.06);
      pad2->SetRightMargin(0.06);
      pad3->SetRightMargin(0.06);
    }
  else
    {
      pad1 = new TPad("pad1" + var, "pad1" + var, 0, 0.33, 1, 1.000);
      pad2 = new TPad("pad2" + var, "pad2" + var, 0, 0.00, 1, 0.332);
  
      pad1->SetTopMargin(0.09);
      pad2->SetTopMargin(0);

      pad1->SetBottomMargin(0);
      pad2->SetBottomMargin(0.45);

      pad1->SetLeftMargin(0.16);
      pad2->SetLeftMargin(0.16);

      pad1->SetRightMargin(0.06);
      pad2->SetRightMargin(0.06);
    }


  // Draw pad1
  //----------------------------------------------------------------------------
  pad1->Draw();
  pad1->cd();
  pad1->SetLogy();

  AxisFonts(xsValue->GetXaxis(), xtitle);
  AxisFonts(xsValue->GetYaxis(), ytitle);
  
  xsValue->SetTitle("");

  xsValue->Draw("pe");

  xsValue_Madgraph->Draw("p,same");

  if (drawMcfm) xsValue_MCnlo->Draw("p,same");

  xsValue->Draw("pe,same");

  if (var.EqualTo("Zpt"))          xsValue->SetMinimum(1.1e-4);
  if (var.EqualTo("LeadingJetPt")) xsValue->SetMinimum(5e-4);
  if (var.EqualTo("Njets"))        xsValue->SetMinimum(2e-2);

  DrawLatex(_cmsTextFont,   0.173, 0.935, 0.065, 11, "CMS");
  DrawLatex(_lumiTextFont,  0.940, 0.935, 0.050, 31, "19.6 fb^{-1} (8 TeV)");


  // Legend
  //----------------------------------------------------------------------------
  if (drawMcfm)
    {
      DrawLegend(0.72, 0.80, xsValue,          " Data",     "lp");
      DrawLegend(0.72, 0.73, xsValue_Madgraph, " MadGraph", "flp");
      DrawLegend(0.72, 0.66, xsValue_MCnlo,    " MCFM",     "flp");
    }
  else
    {
      DrawLegend(0.68, 0.81, xsValue,          " Data",     "lp");
      DrawLegend(0.68, 0.74, xsValue_Madgraph, " MadGraph", "flp");
    }


  // Prepare the ratios
  //----------------------------------------------------------------------------
  TH1D* ratio_mad  = (TH1D*)xsValue_Madgraph->Clone("ratio_mad");
  TH1D* hratio_mad = (TH1D*)xsValue_Madgraph->Clone("hratio_mad");

  TH1D* ratio_mcnlo;
  TH1D* hratio_mcnlo;

  if (drawMcfm)
    {
      ratio_mcnlo  = (TH1D*)xsValue_MCnlo->Clone("ratio_mcnlo");
      hratio_mcnlo = (TH1D*)xsValue_MCnlo->Clone("hratio_mcnlo");
    }


  // Set the bin content
  //----------------------------------------------------------------------------
  for (UInt_t ibin=1; ibin<=ratio_mad->GetNbinsX(); ibin++) {
   
    Double_t madValue   = xsValue_Madgraph->GetBinContent(ibin);
    Double_t dataValue  = xsValue->GetBinContent(ibin);
    Double_t dataError  = xsValue->GetBinError(ibin);
   
    Double_t ratioValue_mad = (madValue > 0) ? madValue / dataValue : 0.0;
    Double_t ratioError_mad = madValue / pow(dataValue,2)*dataError;
   
    ratio_mad->SetBinContent(ibin, ratioValue_mad);
    ratio_mad->SetBinError  (ibin, 1e-9);

    hratio_mad->SetBinContent(ibin, ratioValue_mad);
    hratio_mad->SetBinError  (ibin, ratioError_mad);
   

    if (drawMcfm)
      {
	Double_t mcnloValue       = xsValue_MCnlo->GetBinContent(ibin);
	Double_t ratioValue_mcnlo = (mcnloValue > 0) ? mcnloValue / dataValue : 0.0;
	Double_t ratioError_mcnlo = mcnloValue / pow(dataValue,2)*dataError;

	ratio_mcnlo->SetBinContent(ibin, ratioValue_mcnlo);
	ratio_mcnlo->SetBinError  (ibin, 1e-9);

	hratio_mcnlo->SetBinContent(ibin, ratioValue_mcnlo);
	hratio_mcnlo->SetBinError  (ibin, ratioError_mcnlo);
      }
  }


  // Draw pad2
  //----------------------------------------------------------------------------
  AxisFontsRatio(ratio_mad->GetYaxis(), "y", "#frac{Theory}{Data}");
  AxisFontsRatio(ratio_mad->GetXaxis(), "x", xtitle);

  canvas->cd();
  pad2->Draw();
  pad2->cd();

  ratio_mad->SetTitle("");
  
  ratio_mad ->Draw("ep");
  hratio_mad->Draw("e2,same");
  ratio_mad ->Draw("ep,same");

  TLine* line2 = new TLine(ratio_mad->GetXaxis()->GetXmin(), 1.0, ratio_mad->GetXaxis()->GetXmax(), 1.0);
  line2->SetLineStyle(3);
  line2->Draw("same");

  ratio_mad->GetYaxis()->SetRangeUser(0.01, 2.3);  

  if (drawMcfm) DrawLatex(43, 0.20, 0.785, 15.0, 11, "MadGraph+Pythia normalized to #sigma_{NLO}");
  else          DrawLatex(43, 0.19, 0.845, 15.0, 11, "MadGraph+Pythia normalized to #sigma_{NLO}");


  // Draw pad3
  //----------------------------------------------------------------------------
  if (drawMcfm)
    {
      AxisFontsRatio(ratio_mcnlo->GetYaxis(), "y", "#frac{Theory}{Data}");
      AxisFontsRatio(ratio_mcnlo->GetXaxis(), "x", xtitle);

      canvas->cd();
      pad3->Draw();
      pad3->cd();
  
      ratio_mcnlo->SetTitle("");

      ratio_mcnlo ->Draw("ep");
      hratio_mcnlo->Draw("e2,same");
      ratio_mcnlo ->Draw("ep,same");

      TLine* line3 = new TLine(ratio_mcnlo->GetXaxis()->GetXmin(), 1.0, ratio_mcnlo->GetXaxis()->GetXmax(), 1.0);
      line3->SetLineStyle(3);
      line3->Draw("same");

      ratio_mcnlo->GetYaxis()->SetRangeUser(0.1, 2.3);  

      pad3->Modified();

      DrawLatex(43, 0.2, 0.885, 15.0, 11, "MCFM");
    }


  // Save
  //----------------------------------------------------------------------------
  pad1->cd();
  pad1->RedrawAxis();
  pad1->GetFrame()->DrawClone();
  
  pad2->cd();
  pad2->RedrawAxis();
  pad2->GetFrame()->DrawClone();

  if (drawMcfm)
    {
      pad3->cd();
      pad3->RedrawAxis();
      pad3->GetFrame()->DrawClone();
    }

  canvas->cd();
  canvas->Update();

  canvas->SaveAs("pdf/unfolded_" + var + ".pdf");
  canvas->SaveAs("png/unfolded_" + var + ".png");
}
Example #27
0
Int_t DrawTrendingTOFQA(TString mergedTrendFile = "trending.root", // trending tree file 
			Bool_t displayAll = kFALSE) //set to kTRUE to display trending for expert plots
{
  //
  //reads merged trending.root file and draws trending plots from tree
  //
  if (!mergedTrendFile) {
    Printf("Cannot open merged trend file with TOF QA");
    return 1;
  }
  
  char  outfilename[200]= "ProductionQA.hist.root";
  TString plotDir(".");
  // TString plotDir(Form("PlotsTrending"));
  // gSystem->Exec(Form("mkdir %s",plotDir.Data()));

  Int_t runNumber=0;
  Double_t avTime=0., peakTime=0., spreadTime=0., peakTimeErr=0., spreadTimeErr=0.,negTimeRatio=0.,
    avRawTime=0., peakRawTime=0., spreadRawTime=0., peakRawTimeErr=0., spreadRawTimeErr=0., 
    avTot=0., peakTot=0.,spreadTot=0.,  peakTotErr=0.,spreadTotErr=0.,
    meanResTOF=0., spreadResTOF=0., meanResTOFerr=0., spreadResTOFerr=0.,
    orphansRatio=0., avL=0., negLratio=0.,
    matchEffIntegratedErr=-9999., matchEffIntegrated=-9999., matchEffLinFit1Gev=0.,matchEffLinFit1GevErr=0.;
  Double_t avDiffTime=0.,peakDiffTime=0., spreadDiffTime=0.,peakDiffTimeErr=0., spreadDiffTimeErr=0.,avT0fillRes=0.;
   
  Double_t avT0A=0.,peakT0A=0., spreadT0A=0.,peakT0AErr=0., spreadT0AErr=0.;
  Double_t avT0C=0.,peakT0C=0., spreadT0C=0.,peakT0CErr=0., spreadT0CErr=0.;
  Double_t avT0AC=0.,peakT0AC=0., spreadT0AC=0.,peakT0ACErr=0., spreadT0ACErr=0.;
  Double_t avT0res=0.,peakT0res=0., spreadT0res=0.,peakT0resErr=0., spreadT0resErr=0.;

  Double_t StartTime_pBestT0 = 0.0, StartTime_pBestT0Err = 0.0, StartTime_pFillT0 = 0.0, StartTime_pFillT0Err = 0.0, StartTime_pTOFT0 = 0.0, StartTime_pTOFT0Err = 0.0, StartTime_pT0ACT0 = 0.0, StartTime_pT0ACT0Err = 0.0, StartTime_pT0AT0 = 0.0, StartTime_pT0AT0Err = 0.0, StartTime_pT0CT0 = 0.0, StartTime_pT0CT0Err = 0.0;
  Double_t StartTime_pBestT0_Res = 0.0, StartTime_pFillT0_Res = 0.0, StartTime_pTOFT0_Res = 0.0, StartTime_pT0ACT0_Res = 0.0, StartTime_pT0AT0_Res = 0.0, StartTime_pT0CT0_Res = 0.0;

  Float_t avMulti=0;
  Float_t fractionEventsWHits=0.0;
  Double_t goodChannelRatio=0.0;
  Double_t goodChannelRatioInAcc=0.0;

  
  TFile * fin = TFile::Open(mergedTrendFile.Data());
  TTree * ttree = (TTree*) fin->Get("trending");
  if (!ttree){
    fin->ls();
    Printf("Invalid trending tree.");
    return 2;
  }
  ttree->SetBranchAddress("run",&runNumber);
  ttree->SetBranchAddress("avMulti",&avMulti);
  ttree->SetBranchAddress("goodChannelsRatio",&goodChannelRatio);   
  ttree->SetBranchAddress("goodChannelsRatioInAcc",&goodChannelRatioInAcc);   
  ttree->SetBranchAddress("avTime",&avTime); //mean time
  ttree->SetBranchAddress("peakTime",&peakTime); //main peak time after fit
  ttree->SetBranchAddress("spreadTime",&spreadTime); //spread of main peak of time after fit
  ttree->SetBranchAddress("peakTimeErr",&peakTimeErr); //main peak time after fit error
  ttree->SetBranchAddress("spreadTimeErr",&spreadTimeErr); //spread of main peak of time after fit error
  ttree->SetBranchAddress("negTimeRatio",&negTimeRatio); //negative time ratio
  ttree->SetBranchAddress("avRawTime",&avRawTime); //mean raw time
  ttree->SetBranchAddress("peakRawTime",&peakRawTime); //mean peak of raw time after fit
  ttree->SetBranchAddress("spreadRawTime",&spreadRawTime); //spread of main peak of raw time after fit
  ttree->SetBranchAddress("peakRawTimeErr",&peakRawTimeErr); //main peak raw  time after fit error
  ttree->SetBranchAddress("spreadRawTimeErr",&spreadRawTimeErr); //spread of  raw main peak of time after fit error
  ttree->SetBranchAddress("avTot",&avTot); //main peak tot
  ttree->SetBranchAddress("peakTot",&peakTot); // main peak of tot after fit
  ttree->SetBranchAddress("spreadTot",&spreadTot); //spread of main peak of tot after fit
  ttree->SetBranchAddress("peakTotErr",&peakTotErr); // main peak of tot after fit
  ttree->SetBranchAddress("spreadTotErr",&spreadTotErr); //spread of main peak of tot after fit
  ttree->SetBranchAddress("orphansRatio",&orphansRatio); //orphans ratio
  ttree->SetBranchAddress("avL",&avL); //mean track length
  ttree->SetBranchAddress("negLratio",&negLratio);//ratio of tracks with track length <350 cm
  if(0 != ttree->SetBranchAddress("matchEffIntegrated",&matchEffIntegrated)) //matching eff integrated in pt (1-10GeV/c)
    matchEffIntegrated = 0;
  if(0 != ttree->SetBranchAddress("matchEffIntegratedErr",&matchEffIntegratedErr)) //matching eff integrated in pt (1-10GeV/c)
    matchEffIntegratedErr = 0;
  ttree->SetBranchAddress("matchEffLinFit1Gev",&matchEffLinFit1Gev);//matching eff fit param 
  ttree->SetBranchAddress("matchEffLinFit1GevErr",&matchEffLinFit1GevErr);////matching eff fit param error
  ttree->SetBranchAddress("avPiDiffTime",&avDiffTime); //mean t-texp
  ttree->SetBranchAddress("peakPiDiffTime",&peakDiffTime); //main peak t-texp after fit
  ttree->SetBranchAddress("spreadPiDiffTime",&spreadDiffTime); //spread of main peak t-texp after fit
  ttree->SetBranchAddress("peakPiDiffTimeErr",&peakDiffTimeErr); //main peak t-texp after fit error
  ttree->SetBranchAddress("spreadPiDiffTimeErr",&spreadDiffTimeErr); //spread of main peak of t-texp after fit error
  ttree->SetBranchAddress("meanResTOF",&meanResTOF); //mean of t-texp_pi-t0_TOF
  ttree->SetBranchAddress("spreadResTOF",&spreadResTOF); //spread of t-texp_pi-t0_TOF, ie. resolution
  ttree->SetBranchAddress("meanResTOFerr",&meanResTOFerr); //error on mean of t-texp_pi-t0_TOF
  ttree->SetBranchAddress("spreadResTOFerr",&spreadResTOFerr); //error on the spread of t-texp_pi-t0_TOF
  ttree->SetBranchAddress("avT0A",&avT0A); //main peak t0A
  ttree->SetBranchAddress("peakT0A",&peakT0A); // main peak of t0A after fit
  ttree->SetBranchAddress("spreadT0A",&spreadT0A); //spread of main peak of t0A after fit
  ttree->SetBranchAddress("peakT0AErr",&peakT0AErr); // main peak of t0A after fit
  ttree->SetBranchAddress("spreadT0AErr",&spreadT0AErr); //spread of main peak of t0A after fit
  ttree->SetBranchAddress("avT0C",&avT0C); //main peak t0C
  ttree->SetBranchAddress("peakT0C",&peakT0C); // main peak of t0C after fit
  ttree->SetBranchAddress("spreadT0C",&spreadT0C); //spread of main peak of t0C after fit
  ttree->SetBranchAddress("peakT0CErr",&peakT0CErr); // main peak of t0C after fit
  ttree->SetBranchAddress("spreadT0CErr",&spreadT0CErr); //spread of main peak of t0C after fit
  ttree->SetBranchAddress("avT0AC",&avT0AC); //main peak t0AC
  ttree->SetBranchAddress("peakT0AC",&peakT0AC); // main peak of t0AC after fit
  ttree->SetBranchAddress("spreadT0AC",&spreadT0AC); //spread of main peak of t0AC after fit
  ttree->SetBranchAddress("peakT0ACErr",&peakT0ACErr); // main peak of t0AC after fit
  ttree->SetBranchAddress("spreadT0ACErr",&spreadT0ACErr); //spread of main peak of t0AC after fit
  ttree->SetBranchAddress("avT0res",&avT0res); //main peak t0AC
  ttree->SetBranchAddress("peakT0res",&peakT0res); // main peak of t0AC after fit
  ttree->SetBranchAddress("spreadT0res",&spreadT0res); //spread of main peak of t0AC after fit
  ttree->SetBranchAddress("peakT0resErr",&peakT0resErr); // main peak of t0AC after fit
  ttree->SetBranchAddress("spreadT0resErr",&spreadT0resErr); //spread of main peak of t0AC after fit
  ttree->SetBranchAddress("avT0fillRes",&avT0fillRes); //t0 fill res

  ttree->SetBranchAddress("StartTime_pBestT0",&StartTime_pBestT0); //T0Best                                  
  ttree->SetBranchAddress("StartTime_pFillT0",&StartTime_pFillT0); //T0Fill
  ttree->SetBranchAddress("StartTime_pTOFT0",&StartTime_pTOFT0); //T0TOF
  ttree->SetBranchAddress("StartTime_pT0ACT0",&StartTime_pT0ACT0); //T0AC
  ttree->SetBranchAddress("StartTime_pT0AT0",&StartTime_pT0AT0); //T0A
  ttree->SetBranchAddress("StartTime_pT0CT0",&StartTime_pT0CT0); //T0C
  ttree->SetBranchAddress("StartTime_pBestT0_Res",&StartTime_pBestT0_Res); //T0Best                      
  ttree->SetBranchAddress("StartTime_pFillT0_Res",&StartTime_pFillT0_Res); //T0Fill res
  ttree->SetBranchAddress("StartTime_pTOFT0_Res",&StartTime_pTOFT0_Res); //T0TOF res
  ttree->SetBranchAddress("StartTime_pT0ACT0_Res",&StartTime_pT0ACT0_Res); //T0AC res
  ttree->SetBranchAddress("StartTime_pT0AT0_Res",&StartTime_pT0AT0_Res); //T0A res
  ttree->SetBranchAddress("StartTime_pT0CT0_Res",&StartTime_pT0CT0_Res); //T0C res

  ttree->SetBranchAddress("StartTime_pBestT0Err",&StartTime_pBestT0Err); //T0Best                                  
  ttree->SetBranchAddress("StartTime_pFillT0Err",&StartTime_pFillT0Err); //T0Fill
  ttree->SetBranchAddress("StartTime_pTOFT0Err",&StartTime_pTOFT0Err); //T0TOF
  ttree->SetBranchAddress("StartTime_pT0ACT0Err",&StartTime_pT0ACT0Err); //T0AC
  ttree->SetBranchAddress("StartTime_pT0AT0Err",&StartTime_pT0AT0Err); //T0A
  ttree->SetBranchAddress("StartTime_pT0CT0Err",&StartTime_pT0CT0Err); //T0C

  //Fetch period-integrated PID plots
  //Pions
  TH2F * hDiffTimePi=(TH2F*)fin->Get("hExpTimePiVsP_all");  
  hDiffTimePi->SetTitle("PIONS t-t_{exp,#pi} (from tracking) vs. P");
  //Kaon
  TH2F * hDiffTimeKa=(TH2F*)fin->Get("hExpTimeKaVsP_all");  
  hDiffTimeKa->SetTitle("KAONS t-t_{exp,K} (from tracking) vs. P");
  //Protons
  TH2F * hDiffTimePro=(TH2F*)fin->Get("hExpTimeProVsP_all"); 
  hDiffTimePro->SetTitle("PROTONS t-t_{exp,p} (from tracking) vs. P");

  //Create trending plots
  Int_t nRuns=ttree->GetEntries();
  TList lista;
   
  TH1F * hAvMulti=new TH1F("hAvMulti","Average multiplicity of matched tracks <N_{TOF}>;; <N_{TOF}>", nRuns,0., nRuns);//, 600, 0. , 600.);
  hAvMulti->SetDrawOption("E1");
  hAvMulti->SetMarkerStyle(20);
  hAvMulti->SetMarkerColor(kBlue);
	
  TH1F * hAvDiffTimeVsRun=new TH1F("hAvDiffTimeVsRun","Mean t-t_{exp} (no fit);run;<t^{TOF}-t_{exp,#pi}> (ps)",nRuns,0., nRuns);//, 600, 0. , 600.);
  hAvDiffTimeVsRun->SetDrawOption("E1");
  hAvDiffTimeVsRun->SetMarkerStyle(20);
  hAvDiffTimeVsRun->SetMarkerColor(kBlue);
  //   hAvTimeVsRun->GetYaxis()->SetRangeUser(0.0, 50.0);

  TH1F * hPeakDiffTimeVsRun=new TH1F("hPeakDiffTimeVsRun","t-t_{exp} (gaussian fit) ;; <t^{TOF}-t_{exp,#pi}> (ps)",nRuns,0., nRuns);//,600, 0. , 600. );
  hPeakDiffTimeVsRun->SetDrawOption("E1");
  hPeakDiffTimeVsRun->SetMarkerStyle(20);
  hPeakDiffTimeVsRun->SetMarkerColor(kBlue);
   
  TH1F * hSpreadDiffTimeVsRun=new TH1F("hSpreadDiffTimeVsRun","#sigma(t-t_{exp}) (gaussian fit);; #sigma(t^{TOF}-t_{exp,#pi}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.);
  hSpreadDiffTimeVsRun->SetDrawOption("E1");
  hSpreadDiffTimeVsRun->SetMarkerStyle(20);
  hSpreadDiffTimeVsRun->SetMarkerColor(kBlue);

  TH1F * hMeanTOFResVsRun=new TH1F("hMeanTOFResVsRun","Mean value of t-t_{exp,#pi}-t0_{TOF} (ps);;<t^{TOF}-t_{exp,#pi}-t_{0,TOF}> (ps)",nRuns,0., nRuns);
  hMeanTOFResVsRun->SetDrawOption("E1");
  hMeanTOFResVsRun->SetMarkerStyle(20);
  hMeanTOFResVsRun->SetMarkerColor(kBlue);

  TH1F * hSigmaTOFResVsRun=new TH1F("hSigmaTOFResVsRun","Spread of t-t_{exp,#pi}-t0_{TOF} (ps);;#sigma(t^{TOF}-t_{exp,#pi}-t_{0,TOF}) (ps)",nRuns,0., nRuns);
  hSigmaTOFResVsRun->SetDrawOption("E1");
  hSigmaTOFResVsRun->SetMarkerStyle(20);
  hSigmaTOFResVsRun->SetMarkerColor(kBlue);

  TH1F * hAvTimeVsRun=new TH1F("hAvTimeVsRun","<t^{TOF}>;;<t^{TOF}> (ns)",nRuns,0., nRuns);//, 600, 0. , 600.);
  hAvTimeVsRun->SetDrawOption("E1");
  hAvTimeVsRun->SetMarkerStyle(20);
  hAvTimeVsRun->SetMarkerColor(kBlue);
  //   hAvTimeVsRun->GetYaxis()->SetRangeUser(0.0, 50.0);

  TH1F * hPeakTimeVsRun=new TH1F("hPeakTimeVsRun","Peak value of t^{TOF} (landau fit);;t_{peak}^{TOF} (ns)",nRuns,0., nRuns);//,600, 0. , 600. );
  hPeakTimeVsRun->SetDrawOption("E1");
  hPeakTimeVsRun->SetMarkerStyle(20);
  hPeakTimeVsRun->SetMarkerColor(kBlue);
   
  TH1F * hSpreadTimeVsRun=new TH1F("hSpreadTimeVsRun","Spread of t^{TOF} (landau fit);; #sigma(t^{TOF}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.);
  hSpreadTimeVsRun->SetDrawOption("E1");
  hSpreadTimeVsRun->SetMarkerStyle(20);
  hSpreadTimeVsRun->SetMarkerColor(kBlue);
  
  TH1F * hAvRawTimeVsRun=new TH1F("hAvRawTimeVsRun","Peak value of raw t^{TOF};;<t_{raw}^{TOF}> (ns)",nRuns,0., nRuns);//, 600, 0. , 600.);
  hAvRawTimeVsRun->SetDrawOption("E1");
  hAvRawTimeVsRun->SetMarkerStyle(21);
  hAvRawTimeVsRun->SetMarkerColor(kGreen);

  TH1F * hPeakRawTimeVsRun=new TH1F("hPeakRawTimeVsRun","Peak value of raw t^{TOF} (landau fit);;t_{peak,raw}^{TOF} (ns)",nRuns,0., nRuns);//, 600, 0. , 600.);
  hPeakRawTimeVsRun->SetDrawOption("E1");
  hPeakRawTimeVsRun->SetMarkerStyle(21);
  hPeakRawTimeVsRun->SetMarkerColor(kGreen);

  TH1F * hSpreadRawTimeVsRun=new TH1F("hSpreadRawTimeVsRun","Spread of raw t^{TOF} (landau fit);;#sigma(t_{raw}^{TOF}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.);
  hSpreadRawTimeVsRun->SetDrawOption("E1");
  hSpreadRawTimeVsRun->SetMarkerStyle(21);
  hSpreadRawTimeVsRun->SetMarkerColor(kGreen);
   
  TH1F * hAvTotVsRun=new TH1F("hAvTotVsRun","<ToT> (no fit);run;<ToT> (ns)",nRuns,0., nRuns);//, 50, 0. , 50.);
  hAvTotVsRun->SetDrawOption("E1");
  hAvTotVsRun->SetMarkerStyle(22);
   
  TH1F * hPeakTotVsRun=new TH1F("hPeakTotVsRun","<ToT> (gaussian fit);;ToT_{peak} (ns)",nRuns,0., nRuns);//, 50, 0. , 50.);
  hPeakTotVsRun->SetDrawOption("E1");
  hPeakTotVsRun->SetMarkerStyle(22);
   
  TH1F * hSpreadTotVsRun=new TH1F("hSpreadTotVsRun","#sigma(ToT) (gaussian fit);#sigma(ToT) (ns)",nRuns,0., nRuns);//, 50, 0. , 50.);
  hSpreadTotVsRun->SetDrawOption("E1");
  hSpreadTotVsRun->SetMarkerStyle(22);
   
  TH1F * hNegTimeRatioVsRun=new TH1F("hNegTimeRatioVsRun","Ratio of tracks with t^{TOF}<12.5 ns; ; ratio of tracks with t^{TOF}<12.5 ns (%)",nRuns, 0., nRuns);//, 100, 0. , 100.);
  hNegTimeRatioVsRun->SetDrawOption("E");

  TH1F * hOrphansRatioVsRun=new TH1F("hOrphansRatioVsRun","Ratio of orphans (hits with ToT=0); ; ratio of orphans (%)",nRuns, 0., nRuns);//, 1000, 0. , 100.);
  hOrphansRatioVsRun->SetDrawOption("E");

  TH1F * hMeanLVsRun=new TH1F("hMeanLVsRun","Average track length;; <L> (cm)",nRuns, 0., nRuns);//, 350, 350. , 700.);
  hMeanLVsRun->SetDrawOption("E");
  TH1F * hNegLRatioVsRun=new TH1F("hNegLRatioVsRun","Ratio of tracks with L<350 cm;; ratio of tracks with L<350 cm (%)",nRuns, 0., nRuns);//, 1000, 0. , 100.);
  hNegLRatioVsRun->SetDrawOption("E");
  TH1F * hMatchEffVsRun=new TH1F("hMatchEffVsRun","#epsilon_{match} (linear fit for p_{T}>1.0 GeV/c);;#epsilon_{match} (p_{T}>1.0 GeV/c)",nRuns, 0., nRuns);//, 100, 0. , 1.);
  hMatchEffVsRun->SetDrawOption("E");
  TH1F * hMatchEffVsRunNormToGoodCh=new TH1F("hMatchEffVsRunNormToGoodCh","#epsilon_{match} normalized to percentage of TOF good channels;;#epsilon_{match}(p_{T}>1.0 GeV/c,|#eta|<0.8)/f_{all good}",nRuns, 0., nRuns);//, 100, 0. , 1.);
  hMatchEffVsRunNormToGoodCh->SetDrawOption("E");
	
  TH1F * hMatchEffVsRunNormToGoodChInAcc=new TH1F("hMatchEffVsRunNormToGoodChInAcc","#epsilon_{match} normalized to TOF good channels in |#eta|<0.8;;#epsilon_{match}(p_{T}>1.0 GeV/c,|#eta|<0.8/f_{good}(|#eta|<0.8)",nRuns, 0., nRuns);//, 100, 0. , 1.);
  hMatchEffVsRunNormToGoodChInAcc->SetDrawOption("E");

  TH1F * hMatchEffIntegratedVsRun=new TH1F("hMatchEffVsRun1hMatchEffIntegratedVsRun","#it{p}_{T} integrated #epsilon_{match}; ; #epsilon_{match} (1 < p_{T} < 10 GeV/c)",nRuns, 0., nRuns);
  hMatchEffIntegratedVsRun->SetDrawOption("E");

  TH1F * hPeakT0AVsRun=new TH1F("hPeakT0AVsRun","Peak value of T0A (gaussian fit);;t0A (ps)",nRuns,0., nRuns);
  TH1F * hPeakT0CVsRun=new TH1F("hPeakT0CVsRun","Peak value of T0C (gaussian fit);;t0AC (ps)",nRuns,0., nRuns);
  TH1F * hPeakT0ACVsRun=new TH1F("hPeakT0ACVsRun","Peak value of T0AC (gaussian fit);;t0AC (ps)",nRuns,0., nRuns);
  TH1F * hT0fillResVsRun=new TH1F("hT0fillResVsRun","t0_fill spread;;t0_spread (ps)",nRuns,0., nRuns);

  TH1F * hT0BestVsRun=new TH1F("hT0BestVsRun","start time by best_t0;;t0 Best (ps)",nRuns,0., nRuns);
  hT0BestVsRun->SetDrawOption("E1");
  hT0BestVsRun->SetLineColor(kOrange);
  hT0BestVsRun->SetLineWidth(2);
  hT0BestVsRun->SetMarkerStyle(20);
  hT0BestVsRun->SetMarkerColor(kOrange);

  TH1F * hT0FillVsRun=new TH1F("hT0FillVsRun","start time by fill_t0;;t0 Fill (ps)",nRuns,0., nRuns);
  hT0FillVsRun->SetDrawOption("E1");
  hT0FillVsRun->SetLineColor(kBlue);
  hT0FillVsRun->SetLineWidth(2);
  hT0FillVsRun->SetMarkerStyle(20);
  hT0FillVsRun->SetMarkerColor(kBlue);

  TH1F * hT0TOFVsRun=new TH1F("hT0TOFVsRun","start time by TOF_t0;;t0 TOF (ps)",nRuns,0., nRuns);
  hT0TOFVsRun->SetDrawOption("E1");
  hT0TOFVsRun->SetLineColor(kBlue);
  hT0TOFVsRun->SetLineWidth(2);
  hT0TOFVsRun->SetMarkerStyle(20);
  hT0TOFVsRun->SetMarkerColor(kBlue);

  TH1F * hT0T0ACVsRun=new TH1F("hT0T0ACVsRun","start time by T0AC;;t0 T0AC (ps)",nRuns,0., nRuns);
  hT0T0ACVsRun->SetDrawOption("E1");
  hT0T0ACVsRun->SetLineColor(kRed);
  hT0T0ACVsRun->SetLineWidth(2);
  hT0T0ACVsRun->SetMarkerStyle(20);
  hT0T0ACVsRun->SetMarkerColor(kRed);

  TH1F * hT0T0AVsRun=new TH1F("hT0T0AtVsRun","start time by T0A;;t0 T0A (ps)",nRuns,0., nRuns);
  hT0T0AVsRun->SetDrawOption("E1");
  hT0T0AVsRun->SetLineColor(kGreen+2);
  hT0T0AVsRun->SetLineWidth(2);
  hT0T0AVsRun->SetMarkerStyle(20);
  hT0T0AVsRun->SetMarkerColor(kGreen+2);

  TH1F * hT0T0CVsRun=new TH1F("hT0T0CVsRun","start time by T0C;;t0 T0C (ps)",nRuns,0., nRuns);
  hT0T0CVsRun->SetDrawOption("E1");
  hT0T0CVsRun->SetLineColor(kMagenta);
  hT0T0CVsRun->SetLineWidth(2);
  hT0T0CVsRun->SetMarkerStyle(20);
  hT0T0CVsRun->SetMarkerColor(kMagenta);

  TH1F * hT0BestVsRunRes=new TH1F("hT0BestVsRunRes","#sigma of best_t0;; #sigma t0 Best (ps)",nRuns,0., nRuns);
  hT0BestVsRunRes->SetDrawOption("E1");
  hT0BestVsRunRes->SetLineColor(kOrange);
  hT0BestVsRunRes->SetLineWidth(2);
  hT0BestVsRunRes->SetMarkerStyle(20);
  hT0BestVsRunRes->SetMarkerColor(kOrange);

  TH1F * hT0FillVsRunRes=new TH1F("hT0FillVsRunRes","fill_t0;; #sigmat0 Fill (ps)",nRuns,0., nRuns);
  hT0FillVsRunRes->SetDrawOption("E1");
  hT0FillVsRunRes->SetLineColor(kBlue);
  hT0FillVsRunRes->SetLineWidth(2);
  hT0FillVsRunRes->SetMarkerStyle(20);
  hT0FillVsRunRes->SetMarkerColor(kBlue);
  
  TH1F * hT0TOFVsRunRes=new TH1F("hT0T0FVsRunRes","TOF_t0;; #sigma t0 TOF (ps)",nRuns,0., nRuns);
  hT0TOFVsRunRes->SetDrawOption("E1");
  hT0TOFVsRunRes->SetLineColor(kBlue);
  hT0TOFVsRunRes->SetLineWidth(2);
  hT0TOFVsRunRes->SetMarkerStyle(20);
  hT0TOFVsRunRes->SetMarkerColor(kBlue);
  
  TH1F * hT0T0ACVsRunRes=new TH1F("hT0T0ACVsRunRes","T0AC_t0;; #sigma t0 T0AC (ps)",nRuns,0., nRuns);
  hT0T0ACVsRunRes->SetDrawOption("E1");
  hT0T0ACVsRunRes->SetLineColor(kRed);
  hT0T0ACVsRunRes->SetLineWidth(2);
  hT0T0ACVsRunRes->SetMarkerStyle(20);
  hT0T0ACVsRunRes->SetMarkerColor(kRed);
  
  TH1F * hT0T0AVsRunRes=new TH1F("hT0T0AVsRunRes","T0A_t0;; #sigma t0 T0A (ps)",nRuns,0., nRuns);
  hT0T0AVsRunRes->SetDrawOption("E1");
  hT0T0AVsRunRes->SetLineColor(kGreen+2);
  hT0T0AVsRunRes->SetLineWidth(2);
  hT0T0AVsRunRes->SetMarkerStyle(20);
  hT0T0AVsRunRes->SetMarkerColor(kGreen+2);
  
  TH1F * hT0T0CVsRunRes=new TH1F("hT0T0CVsRunRes","T0C_t0;; #sigma t0 T0C (ps)",nRuns,0., nRuns);
  hT0T0CVsRunRes->SetDrawOption("E1");
  hT0T0CVsRunRes->SetLineColor(kMagenta);
  hT0T0CVsRunRes->SetLineWidth(2);
  hT0T0CVsRunRes->SetMarkerStyle(20);
  hT0T0CVsRunRes->SetMarkerColor(kMagenta);
	
  TH1F * hGoodChannelsRatio=new TH1F("hGoodChannelsRatio","Fraction of TOF good channels;;fraction of good channels",nRuns, 0., nRuns);//, 100, 0. , 1.);
  hGoodChannelsRatio->SetDrawOption("E");

  TH1F * hGoodChannelsRatioInAcc=new TH1F("hGoodChannelsRatioInAcc","Fraction of TOF good channels in |#eta|<0.8;;fraction of good channels in |#eta|<0.8",nRuns, 0., nRuns);//, 100, 0. , 1.);
  hGoodChannelsRatioInAcc->SetDrawOption("E");
	
  lista.Add(hAvMulti);
  lista.Add(hAvDiffTimeVsRun);
  lista.Add(hPeakDiffTimeVsRun);
  lista.Add(hSpreadDiffTimeVsRun);
  lista.Add(hAvTimeVsRun);
  lista.Add(hPeakTimeVsRun);
  lista.Add(hMeanTOFResVsRun);
  lista.Add(hSigmaTOFResVsRun);
  lista.Add(hSpreadTimeVsRun);
  lista.Add(hAvRawTimeVsRun);
  lista.Add(hPeakRawTimeVsRun);
  lista.Add(hSpreadRawTimeVsRun); 
  lista.Add(hAvTotVsRun);
  lista.Add(hPeakTotVsRun);
  lista.Add(hSpreadTotVsRun);
  lista.Add(hNegTimeRatioVsRun);
  lista.Add(hOrphansRatioVsRun);
  lista.Add(hMeanLVsRun);
  lista.Add(hNegLRatioVsRun);
  lista.Add(hMatchEffVsRun);
  lista.Add(hMatchEffVsRunNormToGoodCh);
  lista.Add(hMatchEffVsRunNormToGoodChInAcc);
  lista.Add(hPeakT0AVsRun);
  lista.Add(hPeakT0CVsRun);
  lista.Add(hPeakT0ACVsRun);
  lista.Add(hT0fillResVsRun);
  lista.Add(hGoodChannelsRatio);
  lista.Add(hGoodChannelsRatioInAcc);
  lista.Add(hT0BestVsRun);
  lista.Add(hT0FillVsRun);
  lista.Add(hT0TOFVsRun);
  lista.Add(hT0T0ACVsRun);
  lista.Add(hT0T0AVsRun);
  lista.Add(hT0T0CVsRun);
  lista.Add(hT0BestVsRunRes);
  lista.Add(hT0FillVsRunRes);
  lista.Add(hT0TOFVsRunRes);
  lista.Add(hT0T0ACVsRunRes);
  lista.Add(hT0T0AVsRunRes);
  lista.Add(hT0T0CVsRunRes);
 
  char runlabel[6];
   
  for (Int_t irun=0;irun<nRuns;irun++){
    ttree->GetEntry(irun);
    
    sprintf(runlabel,"%i",runNumber);
    
    hAvMulti->SetBinContent(irun+1, avMulti);
    hAvMulti->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hAvDiffTimeVsRun->SetBinContent(irun+1, avDiffTime);
    hAvDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hPeakDiffTimeVsRun->SetBinContent(irun+1,peakDiffTime);
    hPeakDiffTimeVsRun->SetBinError(irun+1,peakDiffTimeErr);
    hPeakDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hSpreadDiffTimeVsRun->SetBinContent(irun+1,spreadDiffTime);
    hSpreadDiffTimeVsRun->SetBinError(irun+1,spreadDiffTimeErr);
    hSpreadDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hMeanTOFResVsRun->SetBinContent(irun+1,meanResTOF);
    hMeanTOFResVsRun->SetBinError(irun+1,meanResTOFerr);
    hMeanTOFResVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hSigmaTOFResVsRun->SetBinContent(irun+1,spreadResTOF);
    hSigmaTOFResVsRun->SetBinError(irun+1,spreadResTOFerr);
    hSigmaTOFResVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);


    hAvTimeVsRun->SetBinContent(irun+1, avTime);
    hAvTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hPeakTimeVsRun->SetBinContent(irun+1,peakTime);
    hPeakTimeVsRun->SetBinError(irun+1,peakTimeErr);
    hPeakTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hSpreadTimeVsRun->SetBinContent(irun+1,spreadTime);
    hSpreadTimeVsRun->SetBinError(irun+1,spreadTimeErr);
    hSpreadTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hAvRawTimeVsRun->SetBinContent(irun+1, avRawTime);
    hAvRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
    
    hPeakRawTimeVsRun->SetBinContent(irun+1,peakRawTime);
    hPeakRawTimeVsRun->SetBinError(irun+1,peakRawTimeErr);
    hPeakRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hSpreadRawTimeVsRun->SetBinContent(irun+1,spreadRawTime);
    hSpreadRawTimeVsRun->SetBinError(irun+1,spreadRawTimeErr);
    hSpreadRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hAvTotVsRun->SetBinContent(irun+1,avTot);
    hAvTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hPeakTotVsRun->SetBinContent(irun+1,peakTot);
    hPeakTotVsRun->SetBinError(irun+1,peakTotErr);
    hPeakTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hSpreadTotVsRun->SetBinContent(irun+1,spreadTot);
    hSpreadTotVsRun->SetBinError(irun+1,spreadTotErr);
    hSpreadTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
    
    hNegTimeRatioVsRun->SetBinContent(irun+1,negTimeRatio);
    hNegTimeRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
    
    hOrphansRatioVsRun->SetBinContent(irun+1,orphansRatio);
    hOrphansRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
    
    hMeanLVsRun->SetBinContent(irun+1,avL);
    hMeanLVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
    
    hNegLRatioVsRun->SetBinContent(irun+1,negLratio);
    hNegLRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hMatchEffVsRun->SetBinContent(irun+1,matchEffLinFit1Gev);
    hMatchEffVsRun->SetBinError(irun+1,matchEffLinFit1GevErr);
    hMatchEffVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
    hMatchEffVsRun->SetLineColor(kRed);
    hMatchEffVsRun->SetLineWidth(2);

    hMatchEffIntegratedVsRun->SetBinContent(irun+1, matchEffIntegrated);
    hMatchEffIntegratedVsRun->SetBinError(irun+1, matchEffIntegratedErr);
    hMatchEffIntegratedVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
    hMatchEffIntegratedVsRun->SetLineColor(kOrange);
    hMatchEffIntegratedVsRun->SetLineStyle(7);
    hMatchEffIntegratedVsRun->SetLineWidth(2);
  
    if (goodChannelRatio>0)
      hMatchEffVsRunNormToGoodCh->SetBinContent(irun+1,matchEffLinFit1Gev/goodChannelRatio);
    else 
      hMatchEffVsRunNormToGoodCh->SetBinContent(irun+1, 0.0);
    hMatchEffVsRunNormToGoodCh->SetBinError(irun+1,matchEffLinFit1GevErr);
    hMatchEffVsRunNormToGoodCh->GetXaxis()->SetBinLabel(irun+1,runlabel);
    hMatchEffVsRunNormToGoodCh->SetLineColor(kCyan+2);
    hMatchEffVsRunNormToGoodCh->SetLineWidth(2);
     
    hGoodChannelsRatio->SetBinContent(irun+1, goodChannelRatio);
    hGoodChannelsRatio->SetLineColor(kCyan-1);
    hGoodChannelsRatio->SetLineWidth(2);
    hGoodChannelsRatio->GetXaxis()->SetBinLabel(irun+1,runlabel);

    if (goodChannelRatioInAcc>0)
      hMatchEffVsRunNormToGoodChInAcc->SetBinContent(irun+1,matchEffLinFit1Gev/goodChannelRatioInAcc);
    else 
      hMatchEffVsRunNormToGoodChInAcc->SetBinContent(irun+1, 0.0);
    hMatchEffVsRunNormToGoodChInAcc->SetBinError(irun+1,matchEffLinFit1GevErr);
    hMatchEffVsRunNormToGoodChInAcc->GetXaxis()->SetBinLabel(irun+1,runlabel);
    hMatchEffVsRunNormToGoodChInAcc->SetLineColor(kBlue);
    hMatchEffVsRunNormToGoodChInAcc->SetLineWidth(2);

    hGoodChannelsRatioInAcc->SetBinContent(irun+1, goodChannelRatioInAcc);
    hGoodChannelsRatioInAcc->SetLineColor(kBlue+2);
    hGoodChannelsRatioInAcc->SetLineWidth(2);
    hGoodChannelsRatioInAcc->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hPeakT0AVsRun->SetBinContent(irun+1,peakT0A);
    hPeakT0AVsRun->SetBinError(irun+1,spreadT0A);
    hPeakT0AVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hPeakT0CVsRun->SetBinContent(irun+1,peakT0C);
    hPeakT0CVsRun->SetBinError(irun+1,spreadT0C);
    hPeakT0CVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
    
    hPeakT0ACVsRun->SetBinContent(irun+1,peakT0AC);
    hPeakT0ACVsRun->SetBinError(irun+1,spreadT0AC);
    hPeakT0ACVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hT0fillResVsRun->SetBinContent(irun+1,avT0fillRes);
    hT0fillResVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hT0BestVsRun->SetBinContent(irun+1,StartTime_pBestT0);
    hT0BestVsRun->SetBinError(irun+1,StartTime_pBestT0Err);
    hT0BestVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hT0FillVsRun->SetBinContent(irun+1,StartTime_pFillT0);
    hT0FillVsRun->SetBinError(irun+1,StartTime_pFillT0Err);
    hT0FillVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hT0TOFVsRun->SetBinContent(irun+1,StartTime_pTOFT0);
    hT0TOFVsRun->SetBinError(irun+1,StartTime_pTOFT0Err);
    hT0TOFVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hT0T0ACVsRun->SetBinContent(irun+1,StartTime_pT0ACT0);
    hT0T0ACVsRun->SetBinError(irun+1,StartTime_pT0ACT0Err);
    hT0T0ACVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hT0T0AVsRun->SetBinContent(irun+1,StartTime_pT0AT0);
    hT0T0AVsRun->SetBinError(irun+1,StartTime_pT0AT0Err);
    hT0T0AVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hT0T0CVsRun->SetBinContent(irun+1,StartTime_pT0CT0);
    hT0T0CVsRun->SetBinError(irun+1,StartTime_pT0CT0Err);
    hT0T0CVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
    
    hT0BestVsRunRes->SetBinContent(irun+1,StartTime_pBestT0_Res);
    hT0BestVsRunRes->SetBinError(irun+1, 1.e-5);
    hT0BestVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hT0FillVsRunRes->SetBinContent(irun+1,StartTime_pFillT0_Res);
    hT0FillVsRunRes->SetBinError(irun+1, 1.e-5);   
    hT0FillVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hT0TOFVsRunRes->SetBinContent(irun+1,StartTime_pTOFT0_Res);
    hT0TOFVsRunRes->SetBinError(irun+1, 1.e-5);
    hT0TOFVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hT0T0ACVsRunRes->SetBinContent(irun+1,StartTime_pT0ACT0_Res);
    hT0T0ACVsRunRes->SetBinError(irun+1, 1.e-5);
    hT0T0ACVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hT0T0AVsRunRes->SetBinContent(irun+1,StartTime_pT0AT0_Res);
    hT0T0AVsRunRes->SetBinError(irun+1, 1.e-5);
    hT0T0AVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel);

    hT0T0CVsRunRes->SetBinContent(irun+1,StartTime_pT0CT0_Res);
    hT0T0CVsRunRes->SetBinError(irun+1, 1.e-5);
    hT0T0CVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel);

  }
  
  TFile * fout=new TFile(outfilename,"recreate");
  fout->cd();
  lista.Write();
  fout->Close();
    
  gStyle->SetOptStat(10);

  TString plotext = "png";
  const TString desiredext = gSystem->Getenv("TOFQAPLOTEXTENSION");
  if(desiredext.EqualTo("pdf") || desiredext.EqualTo("root")) plotext = desiredext; 
  else if(!desiredext.IsNull()) cout<<"Unrecognized extension: '"<<desiredext<<"'"<<endl;
  
  //Plot t-texp trend
  TCanvas* cPeakDiffTimeVsRun = new TCanvas("cPeakDiffTimeVsRun","cPeakDiffTimeVsRun", 50,50,1050, 550);
  hPeakDiffTimeVsRun->GetYaxis()->SetRangeUser(-50.,50.);
  hPeakDiffTimeVsRun->Draw();
  cPeakDiffTimeVsRun->Print(Form("%s/cPeakDiffTimeVsRun.%s", plotDir.Data(), plotext.Data()));
	
  TCanvas* cSpreadDiffTimeVsRun = new TCanvas("cSpreadDiffTimeVsRun","cSpreadDiffTimeVsRun", 50,50,1050, 550);
  hSpreadDiffTimeVsRun->GetYaxis()->SetRangeUser(0.,400.);
  hSpreadDiffTimeVsRun->Draw();
  cSpreadDiffTimeVsRun->Print(Form("%s/cSpreadDiffTimeVsRun.%s", plotDir.Data(), plotext.Data()));

  //Plot average of t-texp-t0tof and resolution trend
  TCanvas* cMeanTOFResVsRun = new TCanvas("cMeanTOFResVsRun","cMeanTOFResVsRun", 50,50,1050, 550);
  hMeanTOFResVsRun->GetYaxis()->SetRangeUser(-50.,50.);
  hMeanTOFResVsRun->Draw();
  cMeanTOFResVsRun->Print(Form("%s/cMeanTOFResVsRun.%s", plotDir.Data(), plotext.Data()));
       
  TCanvas* cSigmaTOFResVsRun = new TCanvas("cSigmaTOFResVsRun","cSigmaTOFResVsRun", 50,50,1050, 550);
  hSigmaTOFResVsRun->GetYaxis()->SetRangeUser(0.,200.);
  hSigmaTOFResVsRun->Draw();
  cSigmaTOFResVsRun->Print(Form("%s/cSigmaTOFResVsRun.%s", plotDir.Data(), plotext.Data()));

  //Plot matching efficiency trend
  TCanvas* cMatchEffVsRun = new TCanvas("cMatchEffVsRun","cMatchEffVsRun",50, 50, 1050, 550);
  hMatchEffVsRun->GetYaxis()->SetRangeUser(0.,1.);
  hMatchEffVsRun->Draw();
  hMatchEffIntegratedVsRun->Draw("same");
  cMatchEffVsRun->Print(Form("%s/cMatchEffVsRun.%s", plotDir.Data(), plotext.Data()));
  
  TCanvas* cMatchEffNormToGoodChInAcc = new TCanvas("cMatchEffNormToGoodChInAcc","cMatchEffNormToGoodChInAcc",50, 50,1050, 550);
  hMatchEffVsRunNormToGoodChInAcc->GetYaxis()->SetRangeUser(0.,1.);
  hMatchEffVsRunNormToGoodChInAcc->Draw();
  cMatchEffNormToGoodChInAcc->Print(Form("%s/cMatchEffNormToGoodChInAcc.%s", plotDir.Data(), plotext.Data()));

  TCanvas* cMatchEffNormToGoodCh = new TCanvas("cMatchEffNormToGoodCh","cMatchEffNormToGoodCh",50, 50,1050, 550);
  hMatchEffVsRunNormToGoodCh->GetYaxis()->SetRangeUser(0.,1.);
  hMatchEffVsRunNormToGoodCh->Draw();
  cMatchEffNormToGoodCh->Print(Form("%s/cMatchEffNormToGoodCh.%s", plotDir.Data(), plotext.Data()));

   TLegend *leg = new TLegend(0.5095602,0.1206897,0.8891013,0.3314176,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   
   TLegendEntry *entry=leg->AddEntry("hMatchEffVsRun","#epsilon_{match} (linear fit for p_{T}>1.0 GeV/c)","lpf");
   entry->SetFillStyle(1001);

   Int_t ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(2);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(1);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("hMatchEffVsRunNormToGoodCh","#epsilon_{match} norm. to fraction of TOF good channels","lpf");
   entry->SetFillStyle(1001);

   ci = TColor::GetColor("#009999");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(2);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(1);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("hMatchEffVsRunNormToGoodChInAcc","#epsilon_{match} norm. to fraction of TOF good channels in |#eta|<0.8","lpf");
   entry->SetFillStyle(1001);

   ci = TColor::GetColor("#0000ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(2);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(1);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);

  TCanvas* cMatchEffSummary = new TCanvas("cMatchEffSummary","cMatchEffSummary",50, 50,1050, 550);
  hMatchEffVsRun->GetYaxis()->SetRangeUser(0.4,0.8);
  hMatchEffVsRun->Draw();
  hMatchEffVsRunNormToGoodCh->Draw("same");
  hMatchEffVsRunNormToGoodChInAcc->Draw("same");
  leg->Draw("same");
  cMatchEffSummary->Print(Form("%s/cMatchEffSummary.%s", plotDir.Data(), plotext.Data()));
  
  //Plot start time trend
  TCanvas* cStartTimeSummary = new TCanvas("cStartTimeSummary","cStartTimeSummary",50, 50,1050, 550);
  hT0TOFVsRun->GetYaxis()->SetRangeUser(-100.,100.);
  hT0TOFVsRun->GetYaxis()->SetTitle("Start Time (ps)");
  hT0TOFVsRun->Draw();
  hT0T0ACVsRun->Draw("same");
  hT0T0AVsRun->Draw("same");
  hT0T0CVsRun->Draw("same");
  hT0BestVsRun->Draw("same");
  gPad->SetGridy();
  gPad->SetTitle("Start Time by different methods");
  TLegend * cLegSTS = new TLegend(0.6,0.7,0.9,0.9);
  cLegSTS->SetFillStyle(1001);
  cLegSTS->SetFillColor(kWhite);
  cLegSTS->SetNColumns(2);
  cLegSTS->SetBorderSize(1);
  cLegSTS->AddEntry(hT0TOFVsRun,"TOF_T0","lp");
  cLegSTS->AddEntry(hT0T0ACVsRun,"T0AC_T0","lp");
  cLegSTS->AddEntry(hT0T0AVsRun,"T0A_T0","lp");
  cLegSTS->AddEntry(hT0T0CVsRun,"T0C_T0","lp");
  cLegSTS->AddEntry(hT0BestVsRun, "Best_T0","lp");
  cLegSTS->Draw();
  cStartTimeSummary->Print(Form("%s/cStartTimeSummary.%s", plotDir.Data(), plotext.Data()));

  TCanvas* cStartTimeResolutionSummary = new TCanvas("cStartTimeResolutionSummary","cStartTimeResolutionSummary",50, 50,1050, 550);
  hT0TOFVsRunRes->GetYaxis()->SetRangeUser(0.,200.);
  hT0TOFVsRunRes->GetYaxis()->SetTitle("#sigma Start Time (ps)");
  hT0TOFVsRunRes->Draw();
  hT0T0ACVsRunRes->Draw("same");
  hT0T0AVsRunRes->Draw("same");
  hT0T0CVsRunRes->Draw("same");
  hT0BestVsRunRes->Draw("same");
  TLegend * cLegSTRS = new TLegend(0.6,0.7,0.9,0.9);
  cLegSTRS->SetFillStyle(1001);
  cLegSTRS->SetFillColor(kWhite);
  cLegSTRS->SetNColumns(2);
  cLegSTRS->SetBorderSize(1);
  cLegSTRS->AddEntry(hT0TOFVsRunRes,"TOF_T0 res.","lp");
  cLegSTRS->AddEntry(hT0T0ACVsRunRes,"T0AC_T0 res.","lp");
  cLegSTRS->AddEntry(hT0T0AVsRunRes,"T0A_T0 res.","lp");
  cLegSTRS->AddEntry(hT0T0CVsRunRes,"T0C_T0 res.","lp");
  cLegSTRS->AddEntry(hT0BestVsRunRes, "Best_T0 res.","lp");
    
  cLegSTRS->Draw();
  cStartTimeResolutionSummary->Print(Form("%s/cStartTimeResolutionSummary.%s", plotDir.Data(), plotext.Data()));

  TCanvas* cGoodCh = new TCanvas("cGoodCh","cGoodCh",50, 50,1050, 550);
  hGoodChannelsRatio->GetYaxis()->SetRangeUser(0.75,1.);
  hGoodChannelsRatio->Draw();
  cGoodCh->Print(Form("%s/cGoodCh.%s", plotDir.Data(), plotext.Data()));

  TCanvas* cGoodChInAcc = new TCanvas("cGoodChInAcc","cGoodChInAcc",50, 50,1050, 550);
  hGoodChannelsRatioInAcc->GetYaxis()->SetRangeUser(0.75,1.);
  hGoodChannelsRatioInAcc->Draw();
  cGoodChInAcc->Print(Form("%s/cGoodChInAcc.%s", plotDir.Data(), plotext.Data()));

  TCanvas* cPidPerformance= new TCanvas("cPidPerformance","summary of PID performance", 1200, 500);
  cPidPerformance->Divide(3,1);
  cPidPerformance->cd(1);
  gPad->SetLogz();
  hDiffTimePi->Draw("colz");
  cPidPerformance->cd(2);
  gPad->SetLogz();
  hDiffTimeKa->Draw("colz");
  cPidPerformance->cd(3);
  gPad->SetLogz();
  hDiffTimePro->Draw("colz");
  cPidPerformance->Print(Form("%s/cPIDExpTimes.%s", plotDir.Data(), plotext.Data()));
  
  if (displayAll) {	
    TCanvas* cPeakT0AVsRun = new TCanvas("cPeakT0AVsRun","cPeakT0AVsRun", 50,50,1050, 550);
    hPeakT0AVsRun->Draw();
    cPeakT0AVsRun->Print(Form("%s/cPeakT0AVsRun.png",plotDir.Data()));
  
    TCanvas* cPeakT0CVsRun = new TCanvas("cPeakT0CVsRun","cPeakT0CVsRun", 50,50,1050, 550);
    hPeakT0CVsRun->Draw();
    cPeakT0CVsRun->Print(Form("%s/cPeakT0CVsRun.png",plotDir.Data()));
  
    TCanvas* cPeakT0ACVsRun = new TCanvas("cPeakT0ACVsRun","cPeakT0ACVsRun", 50,50,1050, 550);
    hPeakT0ACVsRun->Draw();
    cPeakT0ACVsRun->Print(Form("%s/cPeakT0ACVsRun.png",plotDir.Data()));
  
    TCanvas* cT0fillResVsRun = new TCanvas("cT0fillResVsRun","cT0fillResVsRun", 50,50,1050, 550);
    hT0fillResVsRun->Draw();
    cT0fillResVsRun->Print(Form("%s/cT0fillResVsRun.png",plotDir.Data()));

    //Plot TOF signal trend
    TCanvas* cAvDiffTimeVsRun = new TCanvas("cAvDiffTimeVsRun","cAvDiffTimeVsRun",50,50,1050, 550);
    gPad->SetGridx();
    gPad->SetGridy();
    hAvDiffTimeVsRun->Draw();
    cAvDiffTimeVsRun->Print(Form("%s/cAvDiffTimeVsRun.png",plotDir.Data()));
	  
    TCanvas* cAvTimeVsRun = new TCanvas("cAvTimeVsRun","cAvTimeVsRun", 50,50,1050, 550);
    hAvTimeVsRun->Draw();
    cAvTimeVsRun->Print(Form("%s/cAvTimeVsRun.png",plotDir.Data()));
	  
    TCanvas* cPeakTimeVsRun = new TCanvas("cPeakTimeVsRun","cPeakTimeVsRun", 50,50,1050, 550);
    hPeakTimeVsRun->Draw();
    cPeakTimeVsRun->Print(Form("%s/cPeakTimeVsRun.png",plotDir.Data()));
	  
    TCanvas* cSpreadTimeVsRun = new TCanvas("cSpreadTimeVsRun","cSpreadTimeVsRun", 50,50,1050, 550);
    hSpreadTimeVsRun->Draw();
    cSpreadTimeVsRun->Print(Form("%s/cSpreadTimeVsRun.png",plotDir.Data()));
	  
    TCanvas* cAvRawTimeVsRun = new TCanvas("cAvRawTimeVsRun","cAvRawTimeVsRun", 50,50,1050, 550);
    hAvRawTimeVsRun->Draw();
    cAvRawTimeVsRun->Print(Form("%s/cAvRawTimeVsRun.png",plotDir.Data()));
	  
    TCanvas* cPeakRawTimeVsRun = new TCanvas("cPeakRawTimeVsRun","cPeakRawTimeVsRun", 50,50,1050, 550);
    hPeakRawTimeVsRun->Draw();
    cPeakRawTimeVsRun->Print(Form("%s/cPeakRawTimeVsRun.png",plotDir.Data()));
	  
    TCanvas* cSpreadRawTimeVsRun = new TCanvas("cSpreadRawTimeVsRun","cSpreadRawTimeVsRun", 50,50,1050, 550);
    hSpreadRawTimeVsRun->Draw();
    cSpreadRawTimeVsRun->Print(Form("%s/cSpreadRawTimeVsRun.png",plotDir.Data()));
	  
    TCanvas* cAvTotVsRun = new TCanvas("cAvTotVsRun","cAvTotVsRun", 50,50,1050, 550);
    hAvTotVsRun->Draw();
    cAvTotVsRun->Print(Form("%s/cAvTotVsRun.png",plotDir.Data()));
	  
    TCanvas* cPeakTotVsRun = new TCanvas("cPeakTotVsRun","cPeakTotVsRun", 50,50,1050, 550);
    hPeakTotVsRun->Draw();
    cPeakTotVsRun->Print(Form("%s/cPeakTotVsRun.png",plotDir.Data()));
	  
    TCanvas* cSpreadTotVsRun = new TCanvas("cSpreadTotVsRun","cSpreadTotVsRun", 50,50,1050, 550);
    hSpreadTotVsRun->Draw();
    cSpreadTotVsRun->Print(Form("%s/cSpreadTotVsRun.png",plotDir.Data()));
	  
    TCanvas* cNegTimeRatioVsRun = new TCanvas("cNegTimeRatioVsRun","cNegTimeRatioVsRun", 50,50,1050, 550);
    hNegTimeRatioVsRun->Draw();
    cNegTimeRatioVsRun->Print(Form("%s/cNegTimeRatioVsRun.png",plotDir.Data()));
	  
    TCanvas* cOrphansRatioVsRun = new TCanvas("cOrphansRatioVsRun","cOrphansRatioVsRun", 50,50,1050, 550);
    hOrphansRatioVsRun->Draw();
    cOrphansRatioVsRun->Print(Form("%s/cOrphansRatioVsRun.png",plotDir.Data()));
	  
    TCanvas* cMeanLVsRun = new TCanvas("cMeanLVsRun","cMeanLVsRun", 50,50,1050, 550);
    hMeanLVsRun->Draw();
    cMeanLVsRun->Print(Form("%s/cMeanLVsRun.png",plotDir.Data()));
	  
    TCanvas* cNegLRatioVsRun = new TCanvas("cNegLRatioVsRun","cNegLRatioVsRun", 50,50,1050, 550);
    hNegLRatioVsRun->Draw();
    cNegLRatioVsRun->Print(Form("%s/cNegLRatioVsRun.png",plotDir.Data()));
  }
	
  return 0;
}
void drawSpectra2D(const TString configFile, const TString inputFile, const TString outputFile, const TString outputFigureName)
{
    std::cout<<"running drawSpectra2D()"<<std::endl;
    std::cout<<"configFile  = "<< configFile.Data() <<std::endl;
    std::cout<<"inputFile   = "<< inputFile.Data()  <<std::endl;
    std::cout<<"outputFile  = "<< outputFile.Data() <<std::endl;

    InputConfiguration configInput = InputConfigurationParser::Parse(configFile.Data());
    CutConfiguration configCuts = CutConfigurationParser::Parse(configFile.Data());

    if (!configInput.isValid) {
        std::cout << "Input configuration is invalid." << std::endl;
        std::cout << "exiting" << std::endl;
        return;
    }
    if (!configCuts.isValid) {
        std::cout << "Cut configuration is invalid." << std::endl;
        std::cout << "exiting" << std::endl;
        return;
    }

    /*
     * drawing behavior :
     *      1. If N = # formulas and N = # selections, then N histograms will be drawn,
     *      2. If 1 = # formulas and N = # selections, then N histograms will be drawn with the same formula.
     *      3. If N = # formulas and 1 = # selections, then N histograms will be drawn with the same selection.
     *      4. else, exit.
     */
    // input for mode
    int mode = configInput.proc[INPUT::kPERFORMANCE].i[INPUT::k_mode];

    // input for TTree
    std::vector<std::string> treePaths = ConfigurationParser::ParseList(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_treePath]);
    std::vector<std::string> treeFriendsPath = ConfigurationParser::ParseList(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_treeFriendPath]);
    std::vector<std::string> treeFriendsPathIndividual = ConfigurationParser::ParseList(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_treeFriendPathIndividual]);
    std::vector<std::string> formulas = ConfigurationParser::ParseList(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_treeFormula]);
    std::string selectionBase = configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_treeSelectionBase];
    std::vector<std::string> selections = ConfigurationParser::ParseList(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_treeSelection]);
    std::vector<std::string> selectionSplitter = ConfigurationParser::ParseList(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_treeSelectionSplitter]);
    std::vector<std::string> weights = ConfigurationParser::ParseList(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_TH1_weight]);

    // input for TH1
    std::vector<std::string> titles = ConfigurationParser::ParseList(ConfigurationParser::ParseLatex(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_TH1_title]));
    std::vector<std::string> titlesX = ConfigurationParser::ParseList(ConfigurationParser::ParseLatex(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_TH1_titleX]));
    std::vector<std::string> titlesY = ConfigurationParser::ParseList(ConfigurationParser::ParseLatex(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_TH1_titleY]));
    // nBinsx, xLow, xUp, nBinsy, yLow, yUp for a TH2D histogram
    std::vector<std::vector<float>> TH2D_Bins_List = ConfigurationParser::ParseListTH2D_Bins(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_TH2D_Bins_List]);
    float titleOffsetX = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_titleOffsetX];
    float titleOffsetY = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_titleOffsetY];
    float markerSize = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_markerSize];
    int drawNormalized = configInput.proc[INPUT::kPERFORMANCE].i[INPUT::k_drawNormalized];
    std::vector<std::string> drawOptions = ConfigurationParser::ParseList(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_drawOption]);
    std::vector<std::string> markerStyles = ConfigurationParser::ParseList(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_markerStyle]);
    std::vector<std::string> lineStyles = ConfigurationParser::ParseList(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_lineStyle]);
    std::vector<std::string> fillStyles = ConfigurationParser::ParseList(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_fillStyle]);
    std::vector<std::string> colors = ConfigurationParser::ParseList(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_color]);
    std::vector<std::string> fillColors = ConfigurationParser::ParseList(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_fillColor]);
    std::vector<std::string> lineColors = ConfigurationParser::ParseList(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_lineColor]);
    int lineWidth = configInput.proc[INPUT::kPERFORMANCE].i[INPUT::k_lineWidth];

    // input for TLegend
    std::vector<std::string> legendEntryLabels = ConfigurationParser::ParseList(ConfigurationParser::ParseLatex(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_legendEntryLabel]));
    std::string legendPosition = configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_legendPosition];
    float legendOffsetX = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_legendOffsetX];
    float legendOffsetY = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_legendOffsetY];
    int legendBorderSize = configInput.proc[INPUT::kPERFORMANCE].i[INPUT::k_legendBorderSize];
    float legendWidth = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_legendWidth];
    float legendHeight = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_legendHeight];
    float legendTextSize = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_legendTextSize];

    // input for text objects
    std::string tmpText = ConfigurationParser::ParseLatex(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_text]);
    std::vector<std::string> textLines = ConfigurationParser::ParseList(tmpText);
    int textFont = configInput.proc[INPUT::kPERFORMANCE].i[INPUT::k_textFont];
    float textSize = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_textSize];
    std::string textPosition = configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_textPosition];
    float textOffsetX = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_textOffsetX];
    float textOffsetY = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_textOffsetY];

    std::string tmpTextOverPad = ConfigurationParser::ParseLatex(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_textAbovePad]);
    std::vector<std::string> textsOverPad = ConfigurationParser::ParseList(tmpTextOverPad);
    std::vector<std::string> textsOverPadAlignments = ConfigurationParser::ParseList(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_textAbovePadAlign]);
    int textAbovePadFont = configInput.proc[INPUT::kPERFORMANCE].i[INPUT::k_textAbovePadFont];
    float textAbovePadSize = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_textAbovePadSize];
    float textAbovePadOffsetX = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_textAbovePadOffsetX];
    float textAbovePadOffsetY = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_textAbovePadOffsetY];

    // input for TLine
    // y-axis positions of the horizontal lines to be drawn
    std::vector<float> TLines_horizontal = ConfigurationParser::ParseListFloat(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_TLine_horizontal]);
    std::vector<std::string> lineStyles_horizontal = ConfigurationParser::ParseList(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_LineStyle_horizontal]);
    // x-axis positions of the vertical lines to be drawn
    std::vector<float> TLines_vertical = ConfigurationParser::ParseListFloat(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_TLine_vertical]);
    std::vector<std::string> lineStyles_vertical = ConfigurationParser::ParseList(configInput.proc[INPUT::kPERFORMANCE].s[INPUT::k_LineStyle_vertical]);

    // input for TCanvas
    int windowWidth = configInput.proc[INPUT::kPERFORMANCE].i[INPUT::k_windowWidth];
    int windowHeight = configInput.proc[INPUT::kPERFORMANCE].i[INPUT::k_windowHeight];
    float leftMargin = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_leftMargin];
    float rightMargin = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_rightMargin];
    float bottomMargin = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_bottomMargin];
    float topMargin = configInput.proc[INPUT::kPERFORMANCE].f[INPUT::k_topMargin];
    int setLogx = configInput.proc[INPUT::kPERFORMANCE].i[INPUT::k_setLogx];
    int setLogy = configInput.proc[INPUT::kPERFORMANCE].i[INPUT::k_setLogy];
    int setLogz = configInput.proc[INPUT::kPERFORMANCE].i[INPUT::k_setLogz];

    // set default values
    if (selections.size() == 0) selections.push_back("1");
    if (weights.size() == 0)    weights.push_back(INPUT_DEFAULT::TH1_weight.c_str());   // default weight = 1.
    if (titleOffsetX == 0) titleOffsetX = INPUT_DEFAULT::titleOffsetX;
    if (titleOffsetY == 0) titleOffsetY = INPUT_DEFAULT::titleOffsetY;
    if (drawNormalized >= INPUT_TH1::kN_TYPE_NORM) drawNormalized = INPUT_DEFAULT::drawNormalized;
    if (lineWidth == 0)  lineWidth = INPUT_DEFAULT::lineWidth;

    if (markerSize == 0)  markerSize = INPUT_DEFAULT::markerSize;

    if (textFont == 0)  textFont = INPUT_DEFAULT::textFont;
    if (textSize == 0)  textSize = INPUT_DEFAULT::textSize;

    if (windowWidth  == 0)  windowWidth = INPUT_DEFAULT::windowWidth;
    if (windowHeight == 0)  windowHeight = INPUT_DEFAULT::windowHeight;
    if (leftMargin == 0) leftMargin = INPUT_DEFAULT::leftMargin;
    if (rightMargin == 0) rightMargin = INPUT_DEFAULT::rightMargin;
    if (bottomMargin == 0) bottomMargin = INPUT_DEFAULT::bottomMargin;
    if (topMargin == 0) topMargin = INPUT_DEFAULT::topMargin;

    int nTrees = treePaths.size();
    int nFriends = treeFriendsPath.size();
    int nFriendsIndividual = treeFriendsPathIndividual.size();
    int nFormulas = formulas.size();
    int nSelections = selections.size();
    int nSelectionSplitter = selectionSplitter.size();
    int nWeights = weights.size();
    int nTitles = titles.size();
    int nTitlesX = titlesX.size();
    int nTitlesY = titlesY.size();
    int nTH2D_Bins_List = TH2D_Bins_List[0].size();
    int nDrawOptions = drawOptions.size();
    int nMarkerStyles = markerStyles.size();
    int nLineStyles = lineStyles.size();
    int nFillStyles = fillStyles.size();
    int nColors = colors.size();
    int nFillColors = fillColors.size();
    int nLineColors = lineColors.size();
    int nLegendEntryLabels = legendEntryLabels.size();
    int nTextLines = textLines.size();
    int nTextsOverPad = textsOverPad.size();
    int nTextsOverPadAlignments = textsOverPadAlignments.size();
    int nTLines_horizontal = TLines_horizontal.size();
    int nLineStyles_horizontal = lineStyles_horizontal.size();
    int nTLines_vertical = TLines_vertical.size();
    int nLineStyles_vertical = lineStyles_vertical.size();

    // verbose about input configuration
    std::cout<<"Input Configuration :"<<std::endl;
    std::cout << "mode = " << mode << std::endl;
    if (mode == INPUT_MODE::k_comparison) {
        // in comparison mode "inputFile" should have the following format
        // inputFile = <inputFile1>,<inputFile2>,...
        // there should be no single space between <inputFile1> and <inputFile2>.
        // the idea is to feed the input samples as a single argument and split them in the macro.
        std::cout << "comparison mode : Spectra from two input samples are going to be compared." << std::endl;
    }
    std::cout << "nTrees = " << nTrees << std::endl;
    for (int i=0; i<nTrees; ++i) {
        std::cout << Form("treePaths[%d] = %s", i, treePaths.at(i).c_str()) << std::endl;
    }
    std::cout << "nFriends = " << nFriends << std::endl;
    for (int i=0; i<nFriends; ++i) {
        std::cout << Form("treeFriendsPath[%d] = %s", i, treeFriendsPath.at(i).c_str()) << std::endl;
    }
    std::cout << "nFriendsIndividual = " << nFriendsIndividual << std::endl;
    for (int i=0; i<nFriendsIndividual; ++i) {
        std::cout << Form("treeFriendsPathIndividual[%d] = %s", i, treeFriendsPathIndividual.at(i).c_str()) << std::endl;
    }
    std::cout << "nFormulas     = " << nFormulas << std::endl;
    for (int i=0; i<nFormulas; ++i) {
        std::cout << Form("formulas[%d]   = %s", i, formulas.at(i).c_str()) << std::endl;
    }
    std::cout << "selectionBase = " << selectionBase.c_str() << std::endl;
    std::cout << "nSelections   = " << nSelections << std::endl;
    for (int i=0; i<nSelections; ++i) {
        std::cout << Form("selections[%d] = %s", i, selections.at(i).c_str()) << std::endl;
    }
    std::cout << "nSelectionSplitter = " << nSelectionSplitter << std::endl;
    for (int i=0; i<nSelectionSplitter; ++i) {
        std::cout << Form("selectionSplitter[%d] = %s", i, selectionSplitter.at(i).c_str()) << std::endl;
    }
    std::cout << "nWeights   = " << nWeights << std::endl;
    for (int i=0; i<nWeights; ++i) {
        std::cout << Form("weights[%d] = %s", i, weights.at(i).c_str()) << std::endl;
    }

    std::cout << "nTitles   = " << nTitles << std::endl;
    for (int i=0; i<nTitles; ++i) {
        std::cout << Form("titles[%d] = %s", i, titles.at(i).c_str()) << std::endl;
    }
    std::cout << "nTitlesX   = " << nTitlesX << std::endl;
    for (int i=0; i<nTitlesX; ++i) {
        std::cout << Form("titlesX[%d] = %s", i, titlesX.at(i).c_str()) << std::endl;
    }
    std::cout << "nTitlesY   = " << nTitlesY << std::endl;
    for (int i=0; i<nTitlesY; ++i) {
        std::cout << Form("titlesY[%d] = %s", i, titlesY.at(i).c_str()) << std::endl;
    }
    std::cout << "nTH2D_Bins_List = " << nTH2D_Bins_List << std::endl;
    for (int i=0; i<nTH2D_Bins_List; ++i) {
        std::cout << Form("TH2D_Bins_List[%d] = { ", i);
        std::cout << Form("%.0f, ", TH2D_Bins_List[0].at(i));
        std::cout << Form("%f, ", TH2D_Bins_List[1].at(i));
        std::cout << Form("%f }", TH2D_Bins_List[2].at(i));
        std::cout << " { ";
        std::cout << Form("%.0f, ", TH2D_Bins_List[3].at(i));
        std::cout << Form("%f, ", TH2D_Bins_List[4].at(i));
        std::cout << Form("%f }", TH2D_Bins_List[5].at(i)) << std::endl;;
    }
    std::cout << "titleOffsetX = " << titleOffsetX << std::endl;
    std::cout << "titleOffsetY = " << titleOffsetY << std::endl;
    std::cout << "markerSize = " << markerSize << std::endl;
    std::cout << "drawNormalized = " << drawNormalized << std::endl;
    std::cout << "nDrawOptions   = " << nDrawOptions << std::endl;
    for (int i = 0; i<nDrawOptions; ++i) {
        std::cout << Form("drawOptions[%d] = %s", i, drawOptions.at(i).c_str()) << std::endl;
    }
    std::cout << "nMarkerStyles  = " << nMarkerStyles << std::endl;
    for (int i = 0; i<nMarkerStyles; ++i) {
        std::cout << Form("markerStyles[%d] = %s", i, markerStyles.at(i).c_str()) << std::endl;
    }
    std::cout << "nLineStyles   = " << nLineStyles << std::endl;
    for (int i = 0; i<nLineStyles; ++i) {
        std::cout << Form("lineStyles[%d] = %s", i, lineStyles.at(i).c_str()) << std::endl;
    }
    std::cout << "nFillStyles   = " << nFillStyles << std::endl;
    for (int i = 0; i<nFillStyles; ++i) {
        std::cout << Form("fillStyles[%d] = %s", i, fillStyles.at(i).c_str()) << std::endl;
    }
    std::cout << "nColors   = " << nColors << std::endl;
    for (int i = 0; i<nColors; ++i) {
        std::cout << Form("colors[%d] = %s", i, colors.at(i).c_str()) << std::endl;
    }
    std::cout << "nFillColors = " << nFillColors << std::endl;
    for (int i = 0; i<nFillColors; ++i) {
        std::cout << Form("fillColors[%d] = %s", i, fillColors.at(i).c_str()) << std::endl;
    }
    std::cout << "nLineColors = " << nLineColors << std::endl;
    for (int i = 0; i<nLineColors; ++i) {
        std::cout << Form("lineColors[%d] = %s", i, lineColors.at(i).c_str()) << std::endl;
    }
    std::cout << "lineWidth = " << lineWidth << std::endl;

    std::cout << "nLegendEntryLabels   = " << nLegendEntryLabels << std::endl;
    for (int i = 0; i<nLegendEntryLabels; ++i) {
        std::cout << Form("legendEntryLabels[%d] = %s", i, legendEntryLabels.at(i).c_str()) << std::endl;
    }
    if (nLegendEntryLabels > 0) {
        std::cout << "legendPosition   = " << legendPosition.c_str() << std::endl;
        if (legendPosition.size() == 0) std::cout<< "No position is provided, legend will not be drawn." <<std::endl;
        std::cout << "legendOffsetX    = " << legendOffsetX << std::endl;
        std::cout << "legendOffsetY    = " << legendOffsetY << std::endl;
        std::cout << "legendBorderSize = " << legendBorderSize << std::endl;
        std::cout << "legendWidth      = " << legendWidth << std::endl;
        std::cout << "legendHeight     = " << legendHeight << std::endl;
        std::cout << "legendTextSize   = " << legendTextSize << std::endl;
    }

    std::cout << "nTextLines   = " << nTextLines << std::endl;
    for (int i = 0; i<nTextLines; ++i) {
        std::cout << Form("textLines[%d] = %s", i, textLines.at(i).c_str()) << std::endl;
    }
    if (nTextLines > 0) {
        std::cout << "textFont = " << textFont << std::endl;
        std::cout << "textSize = " << textSize << std::endl;
        std::cout << "textPosition = " << textPosition << std::endl;
        std::cout << "textOffsetX  = " << textOffsetX << std::endl;
        std::cout << "textOffsetY  = " << textOffsetY << std::endl;
    }

    std::cout << "nTextsOverPad = " << nTextsOverPad << std::endl;
    for (int i = 0; i<nTextsOverPad; ++i) {
        std::cout << Form("textsOverPad[%d] = %s", i, textsOverPad.at(i).c_str()) << std::endl;
    }
    if (nTextsOverPad > 0) {
        std::cout << "nTextsOverPadAlignments = " << nTextsOverPadAlignments << std::endl;
        for (int i = 0; i<nTextsOverPadAlignments; ++i) {
            std::cout << Form("textsOverPadAlignments[%d] = %s", i, textsOverPadAlignments.at(i).c_str()) << std::endl;
        }
        std::cout << "textAbovePadFont = " << textAbovePadFont << std::endl;
        std::cout << "textAbovePadSize = " << textAbovePadSize << std::endl;
        std::cout << "textAbovePadOffsetX  = " << textAbovePadOffsetX << std::endl;
        std::cout << "textAbovePadOffsetY  = " << textAbovePadOffsetY << std::endl;
    }

    std::cout << "nTLines_horizontal = " << nTLines_horizontal << std::endl;
    for (int i = 0; i<nTLines_horizontal; ++i) {
        std::cout << Form("TLines_horizontal[%d] = %f", i, TLines_horizontal.at(i)) << std::endl;
    }
    if (nTLines_horizontal > 0) {
        std::cout << "nLineStyles_horizontal = " << nLineStyles_horizontal << std::endl;
        for (int i = 0; i<nLineStyles_horizontal; ++i) {
            std::cout << Form("lineStyles_horizontal[%d] = %s", i, lineStyles_horizontal.at(i).c_str()) << std::endl;
        }
    }
    std::cout << "nTLines_vertical = " << nTLines_vertical << std::endl;
    for (int i = 0; i<nTLines_vertical; ++i) {
        std::cout << Form("TLines_vertical[%d] = %f", i, TLines_vertical.at(i)) << std::endl;
    }
    if (nTLines_vertical > 0) {
        std::cout << "nLineStyles_vertical = " << nLineStyles_vertical << std::endl;
        for (int i = 0; i<nLineStyles_vertical; ++i) {
            std::cout << Form("lineStyles_vertical[%d] = %s", i, lineStyles_vertical.at(i).c_str()) << std::endl;
        }
    }

    std::cout << "windowWidth = " << windowWidth << std::endl;
    std::cout << "windowHeight = " << windowHeight << std::endl;
    std::cout << "leftMargin   = " << leftMargin << std::endl;
    std::cout << "rightMargin  = " << rightMargin << std::endl;
    std::cout << "bottomMargin = " << bottomMargin << std::endl;
    std::cout << "topMargin    = " << topMargin << std::endl;
    std::cout << "setLogx = " << setLogx << std::endl;
    std::cout << "setLogy = " << setLogy << std::endl;
    std::cout << "setLogz = " << setLogz << std::endl;

    // cut configuration

    // verbose about cut configuration
    std::cout<<"Cut Configuration :"<<std::endl;

    std::cout<<"Input handling :"<< std::endl;

    std::vector<std::string> inputFileArguments = InputConfigurationParser::ParseFileArgument(inputFile.Data());
    int nInputFileArguments = inputFileArguments.size();
    // if no mode is specified (which is what happens most of the time), then it is expected that nInputFileArguments = 1.
    std::cout<<"nInputFileArguments (number of input file arguments) = "<< nInputFileArguments << std::endl;
    for (int i = 0; i < nInputFileArguments; ++i) {
        std::cout << Form("inputFileArguments[%d] = %s", i, inputFileArguments.at(i).c_str()) << std::endl;
    }

    std::vector<std::vector<std::string>> inputFiles(nInputFileArguments);
    std::cout<<"#####"<< std::endl;
    for (int i = 0; i < nInputFileArguments; ++i) {

        if (nInputFileArguments > 1) {
            std::cout<<"###"<< std::endl;
            std::cout<<"inputFileArgument = " << inputFileArguments.at(i).c_str() << std::endl;
        }

        inputFiles[i] = InputConfigurationParser::ParseFiles(inputFileArguments.at(i));
        std::cout<<"input ROOT files : num = " << inputFiles[i].size() << std::endl;
        for (std::vector<std::string>::iterator it = inputFiles[i].begin() ; it != inputFiles[i].end(); ++it) {
            std::cout<<(*it).c_str()<< std::endl;
        }
    }
    std::cout<<"##### END #####"<< std::endl;

    // check consistency of the input file arguments with the mode
    if (mode == INPUT_MODE::k_noMode && nInputFileArguments > 1) {
        std::cout<<"no specific mode is chosen. more than one input samples are provided."<< std::endl;
        std::cout<<"exiting"<< std::endl;
        return;
    }
    if (mode == INPUT_MODE::k_comparison && nInputFileArguments == 1) {
        std::cout<<"comparison mode is chosen. But only one input sample is provided."<< std::endl;
        std::cout<<"exiting"<< std::endl;
        return;
    }

    if (nTrees == 1 && nFriendsIndividual > 0) {
        std::cout<<"nTrees = "<< nTrees <<", nFriendsIndividual = " << nFriendsIndividual << std::endl;
        std::cout<<"There is only one tree to be plotted, it does not make sense to use individual friend trees."<< std::endl;
        std::cout<<"exiting"<< std::endl;
        return;
    }
    else if (nTrees > 1 && nFriendsIndividual > 0 && nTrees != nFriendsIndividual) {
        std::cout<<"nTrees = "<< nTrees <<", nFriendsIndividual = " << nFriendsIndividual << std::endl;
        std::cout<<"exiting"<< std::endl;
        return;
    }

    if (nSelectionSplitter == 1) {
        std::cout << "nSelectionSplitter = "<< nSelectionSplitter << std::endl;
        std::cout << "selectionSplitter has been set to have exactly one selection"<< std::endl;
        std::cout << "selectionSplitter is allowed to be either empty or to have more than one selections"<< std::endl;
        std::cout << "exiting"<< std::endl;
        return;
    }
    int nSplits = 1;
    if (nSelectionSplitter > 1)  nSplits = nSelectionSplitter;

    int nSelectionsTot = nSelections * nSplits;
    int nFormulasTot = nFormulas * nSplits;

    TH1::SetDefaultSumw2();
    int nHistos = nFormulasTot;
    if (nFormulas == 1 && nSelections > nFormulas) nHistos = nSelectionsTot;
    else if (nFormulas == 1 && nSelections == 1 && nTrees > nFormulas) nHistos = nTrees * nSplits;
    else if (nFormulas > 1 && nSelections > 1 && nFormulas != nSelections) {
        std::cout << "mismatch of number of formulas and number of selections"<< std::endl;
        std::cout << "nHistos     = "<< nHistos << std::endl;
        std::cout << "nSelections = "<< nSelections << std::endl;
        std::cout << "exiting " << std::endl;
        return;
    }
    else if (nFormulas > 1 && nTrees > 1 && nFormulas != nTrees) {
        std::cout << "mismatch of number of formulas and number of trees"<< std::endl;
        std::cout << "nHistos = "<< nHistos << std::endl;
        std::cout << "nTrees  = "<< nTrees << std::endl;
        std::cout << "exiting " << std::endl;
        return;
    }
    else if (nSelections > 1 && nTrees > 1 && nSelections != nTrees) {
        std::cout << "mismatch of number of selections and number of trees"<< std::endl;
        std::cout << "nHistos     = "<< nHistos << std::endl;
        std::cout << "nSelections = "<< nSelections << std::endl;
        std::cout << "nTrees      = "<< nTrees << std::endl;
        std::cout << "exiting " << std::endl;
        return;
    }
    TFile* output = TFile::Open(outputFile.Data(),"RECREATE");
    output->cd();

    int nHistosInput = nHistos/nSplits;     // number of histograms without considering selectionSplitter
    std::cout << "nHistos = " << nHistos << std::endl;
    TH2D* h[nHistos];
    for (int i=0; i<nHistos; ++i) {
        int nBinsx  = (int)TH2D_Bins_List[0].at(0);
        float xLow = TH2D_Bins_List[1].at(0);
        float xUp  = TH2D_Bins_List[2].at(0);
        int nBinsy  = (int)TH2D_Bins_List[3].at(0);
        float yLow = TH2D_Bins_List[4].at(0);
        float yUp  = TH2D_Bins_List[5].at(0);
        if (nTH2D_Bins_List == nHistosInput) {
            nBinsx = (int)TH2D_Bins_List[0].at(i%nTH2D_Bins_List);
            xLow  = TH2D_Bins_List[1].at(i%nTH2D_Bins_List);
            xUp   = TH2D_Bins_List[2].at(i%nTH2D_Bins_List);
            nBinsy = (int)TH2D_Bins_List[3].at(i%nTH2D_Bins_List);
            yLow  = TH2D_Bins_List[4].at(i%nTH2D_Bins_List);
            yUp   = TH2D_Bins_List[5].at(i%nTH2D_Bins_List);
        }
        std::string title = "";
        if (nTitles == 1)  {
            if (titles.at(0).compare(CONFIGPARSER::nullInput) != 0)  title = titles.at(0).c_str();
        }
        else if (nTitles == nHistosInput)  {
            if (titles.at(i%nTitles).compare(CONFIGPARSER::nullInput) != 0)  title = titles.at(i%nTitles).c_str();
        }
        else if (nTitles == nHistos)  {
            if (titles.at(i).compare(CONFIGPARSER::nullInput) != 0)  title = titles.at(i).c_str();
        }

        std::string titleX = "";
        if (nTitlesX == 1) titleX = titlesX.at(0).c_str();
        else if (nTitlesX == nHistosInput) titleX = titlesX.at(i%nTitlesX).c_str();
        else if (nTitlesX == nHistos)      titleX = titlesX.at(i).c_str();

        std::string titleY = "";
        if (nTitlesY == 1) titleY = titlesY.at(0).c_str();
        else if (nTitlesY == nHistosInput) titleY = titlesY.at(i%nTitlesY).c_str();
        else if (nTitlesY == nHistos)      titleY = titlesY.at(i).c_str();

        h[i] = new TH2D(Form("h2D_%d", i),Form("%s;%s;%s", title.c_str(), titleX.c_str(), titleY.c_str()), nBinsx, xLow, xUp, nBinsy, yLow, yUp);
    }

    // if no mode is specified (which is what happens most of the time), then it is expected that nInputFileArguments = 1.
    // so in that case : 1.) the "TTree*" objects below are effectively 1D, not 2D. 2.) the loops below have effective depth 1, not 2.
    TTree* trees[nTrees][nInputFileArguments];
    TTree* treeFriends[nFriends][nInputFileArguments];
    TTree* treeFriendsIndividual[nFriendsIndividual][nInputFileArguments];
    TTree* treeHiForestInfo[nInputFileArguments];

    Long64_t entries[nInputFileArguments];
    Long64_t entriesSelected[nHistos];
    std::fill_n(entriesSelected, nHistos, 0);

    int nFiles[nInputFileArguments];
    TFile* fileTmp = 0;

    std::cout << "initial reading to get the number of entries (if there is only one input file) and HiForest info" << std::endl;
    for (int iInFileArg = 0; iInFileArg < nInputFileArguments; ++iInFileArg) {

        nFiles[iInFileArg] = inputFiles[iInFileArg].size();
        if (nInputFileArguments > 1) {
            std::cout <<"iInFileArg = " << iInFileArg << " , "<< std::endl;
        }

        // read the first file only to get the HiForest info
        std::string inputPath = inputFiles[iInFileArg].at(0).c_str();
        fileTmp = new TFile(inputPath.c_str(), "READ");

        bool treeExists = true;
        if (nFiles[iInFileArg] == 1) {
            // read one tree only to get the number of entries
            trees[0][iInFileArg] = (TTree*)fileTmp->Get(treePaths.at(0).c_str());
            if (!trees[0][iInFileArg]) {
                std::cout << "tree is not found in the path : "<< treePaths.at(0).c_str() <<". skipping file." << std::endl;
                treeExists = false;
            }
            if (treeExists) {
                entries[iInFileArg] = trees[0][iInFileArg]->GetEntries();
                std::cout << "entries = " << entries[iInFileArg] << std::endl;
            }
        }

        if (treeExists) {
            treeHiForestInfo[0] = (TTree*)fileTmp->Get("HiForest/HiForestInfo");
            if (!treeHiForestInfo[0]) {
                std::cout << "HiForest/HiForestInfo tree is not found." << std::endl;
                treeExists = false;
            }
            if (treeExists) {
                HiForestInfoController hfic(treeHiForestInfo[0]);
                if (iInFileArg == 0)  std::cout<<"### HiForestInfo Tree ###"<< std::endl;
                else                  std::cout<<"### HiForestInfo Tree, input "<< iInFileArg+1 << " ###" << std::endl;
                hfic.printHiForestInfo();
                std::cout<<"###"<< std::endl;
            }
        }

        fileTmp->Close();
    }

    std::cout << "TTree::Draw()" <<std::endl;
    for (int iInFileArg = 0; iInFileArg < nInputFileArguments; ++iInFileArg) {

        if (nInputFileArguments > 1) {
            std::cout <<"iInFileArg = " << iInFileArg << std::endl;
        }

        entries[iInFileArg] = 0;
        for (int iFile = 0; iFile < nFiles[iInFileArg]; ++iFile) {

            std::string inputPath = inputFiles[iInFileArg].at(iFile).c_str();
            std::cout <<"iFile = " << iFile << " , " ;
            std::cout <<"reading input file : " << inputPath.c_str() << std::endl;
            fileTmp = new TFile(inputPath.c_str(), "READ");

            // check if the file is usable, if not skip the file.
            if (isGoodFile(fileTmp) != 0) {
                std::cout << "File is not good. skipping file." << std::endl;
                continue;
            }

            bool treeExists = true;
            for (int i=0; i<nTrees; ++i) {
                trees[i][iInFileArg] = (TTree*)fileTmp->Get(treePaths.at(i).c_str());
                if (!trees[i][iInFileArg]) {
                    std::cout << "tree is not found in the path : "<< treePaths.at(i).c_str() <<". skipping file." << std::endl;
                    treeExists = false;
                }
            }
            for (int i=0; i<nFriends; ++i) {
                treeFriends[i][iInFileArg] = (TTree*)fileTmp->Get(treeFriendsPath.at(i).c_str());
                if (!treeFriends[i][iInFileArg]) {
                    std::cout << "tree is not found in the path : "<< treeFriendsPath.at(i).c_str() <<". skipping file." << std::endl;
                    treeExists = false;
                }
            }
            if (!treeExists)  continue;

            // add friends
            for (int i=0; i<nTrees; ++i) {
                for (int j=0; j<nFriends; ++j) {
                    trees[i][iInFileArg]->AddFriend(treeFriends[j][iInFileArg], Form("t%d", j));
                }
            }
            for (int i=0; i < nFriendsIndividual; ++i) {
                if (treeFriendsPathIndividual.at(i).compare(CONFIGPARSER::nullInput) != 0) {
                    treeFriendsIndividual[i][iInFileArg] = (TTree*)fileTmp->Get(treeFriendsPathIndividual.at(i).c_str());
                }
            }
            if (nFriendsIndividual > 0) {
                for (int i=0; i<nTrees; ++i) {
                    if (treeFriendsPathIndividual.at(i).compare(CONFIGPARSER::nullInput) != 0) {
                        trees[i][0]->AddFriend(treeFriendsIndividual[i][0], Form("tSelf%d", i));
                    }
                }
            }

            Long64_t entriesTmp = trees[0][iInFileArg]->GetEntries();      // assume all the trees have same number of entries
            entries[iInFileArg] += entriesTmp;

            if (nInputFileArguments == 1)  {
                std::cout << "entries in File = " << entriesTmp << std::endl;
            }
            else {
                std::cout << Form("entries[%d] = ", iInFileArg) << entriesTmp << std::endl;
            }

            output->cd();
            for (int i=0; i<nHistos; ++i) {

                int treeIndex = 0;
                if (nHistosInput == nTrees)  treeIndex = i%nTrees;
                // std::cout << "treePath = " << treePaths.at(treeIndex).c_str() << ", ";

                int iInFileArg = 0;
                if (mode == INPUT_MODE::k_comparison) {
                    iInFileArg = i%nInputFileArguments;
                    std::cout << "iInFileArg = " << iInFileArg << ", ";
                }

                std::string formula = formulas.at(0).c_str();
                std::string selection = selections.at(0).c_str();
                std::string weight = weights.at(0).c_str();
                if (nHistosInput == nFormulas)  formula = formulas.at(i%nFormulas).c_str();
                if (nHistosInput == nSelections)  selection = selections.at(i%nSelections).c_str();
                if (nHistosInput == nWeights)  weight = weights.at(i%nWeights).c_str();

                std::string selectionSplit = "";
                if (nSelectionSplitter > 1)  selectionSplit = selectionSplitter.at(i/ (nHistos/nSelectionSplitter)).c_str();

                // std::cout << "drawing histogram i = " << i << ", ";

                TCut selectionFinal = selectionBase.c_str();
                selectionFinal = selectionFinal && selection.c_str();
                if (selectionSplit.size() > 0)  selectionFinal = selectionFinal && selectionSplit.c_str();
                Long64_t entriesSelectedTmp = trees[treeIndex][iInFileArg]->GetEntries(selectionFinal.GetTitle());
                // std::cout << "entriesSelected in file = " << entriesSelectedTmp << std::endl;
                entriesSelected[i] += entriesSelectedTmp;

                TCut weight_AND_selection = Form("(%s)*(%s)", weight.c_str(), selectionFinal.GetTitle());
                trees[treeIndex][iInFileArg]->Draw(Form("%s >>+ %s", formula.c_str(), h[i]->GetName()), weight_AND_selection.GetTitle(), "goff");
            }
            fileTmp->Close();
        }
    }
    std::cout << "TTree::Draw() ENDED" <<std::endl;
    for (int i = 0; i < nInputFileArguments; ++i) {

        if (nInputFileArguments == 1)  {
            std::cout << "entries = " << entries[0] << std::endl;
        }
        else {
            std::cout << Form("entries[%d] = ", i) << entries[i] << std::endl;
        }
    }
    std::cout << "### selected entries" << std::endl;
    for (int i = 0; i < nHistos; ++i) {

        std::cout << "TH1D i = " << i << ", ";
        int treeIndex = 0;
        if (nHistosInput == nTrees)  treeIndex = i%nTrees;
        std::cout << "treePath = " << treePaths.at(treeIndex).c_str() << ", ";

        std::cout << "entriesSelected = " << entriesSelected[i] << std::endl;
    }
    std::cout << "###" << std::endl;

    // print info about histograms
    for (int i=0; i<nHistos; ++i) {
        std::cout << "#####" << std::endl;
        std::cout << Form("h[%d]", i) << std::endl;
        std::string summary = summaryTH1(h[i]);
        std::cout << summary.c_str() << std::endl;
    }

    output->cd();

    TH2D* h_normInt[nHistos];
    TH2D* h_normEvents[nHistos];
    for (int i=0; i<nHistos; ++i) {
        h[i]->Write();

        h_normInt[i] = (TH2D*)h[i]->Clone(Form("%s_normInt", h[i]->GetName()));
        h_normInt[i]->Scale(1./h[i]->Integral());
        h_normInt[i]->Write();

        h_normEvents[i] = (TH2D*)h[i]->Clone(Form("%s_normEvents", h[i]->GetName()));
        h_normEvents[i]->Scale(1./entriesSelected[i]);
        h_normEvents[i]->Write();
    }
    // histograms are written. After this point changes to the histograms will not be reflected in the output ROOT file.

    // set the style of the histograms for canvases to be written
    for (int i=0; i<nHistos; ++i) {
        h[i]->SetTitleOffset(titleOffsetX,"X");
        h[i]->SetTitleOffset(titleOffsetY,"Y");
        h_normInt[i]->SetTitleOffset(titleOffsetX,"X");
        h_normInt[i]->SetTitleOffset(titleOffsetY,"Y");
        h_normEvents[i]->SetTitleOffset(titleOffsetX,"X");
        h_normEvents[i]->SetTitleOffset(titleOffsetY,"Y");

        // default marker style and color
        h[i]->SetMarkerStyle(kFullCircle);
        h[i]->SetMarkerColor(kBlack);
        h_normInt[i]->SetMarkerStyle(kFullCircle);
        h_normInt[i]->SetMarkerColor(kBlack);
        h_normEvents[i]->SetMarkerStyle(kFullCircle);
        h_normEvents[i]->SetMarkerColor(kBlack);

        // no stats box in the final plots
        h[i]->SetStats(false);
        h_normInt[i]->SetStats(false);
        h_normEvents[i]->SetStats(false);
    }

    // write canvases
    TCanvas* c;
    for (int i=0; i<nHistos; ++i) {
        c = new TCanvas(Form("cnv_%d",i),"",windowWidth,windowHeight);
        c->SetTitle(h[i]->GetTitle());
        setCanvasMargin(c, leftMargin, rightMargin, bottomMargin, topMargin);
        setCanvasFinal(c, setLogx, setLogy, setLogz);
        c->cd();

        h[i]->SetTitleOffset(titleOffsetX,"X");
        h[i]->SetTitleOffset(titleOffsetY,"Y");
        h[i]->SetStats(false);
        h[i]->Draw("colz");
        c->Write();
        c->Close();         // do not use Delete() for TCanvas.

        // normalized to 1.
        c = new TCanvas(Form("cnv_%d_normInt",i),"",windowWidth,windowHeight);
        c->SetTitle(h_normInt[i]->GetTitle());
        setCanvasMargin(c, leftMargin, rightMargin, bottomMargin, topMargin);
        setCanvasFinal(c, setLogx, setLogy, setLogz);
        c->cd();

        h_normInt[i]->SetTitleOffset(titleOffsetX,"X");
        h_normInt[i]->SetTitleOffset(titleOffsetY,"Y");
        h_normInt[i]->SetStats(false);
        h_normInt[i]->Draw("colz");
        c->Write();
        c->Close();         // do not use Delete() for TCanvas.

        // normalized by number of events
        c = new TCanvas(Form("cnv_%d_normEvents",i),"",windowWidth,windowHeight);
        c->SetTitle(h_normEvents[i]->GetTitle());
        setCanvasMargin(c, leftMargin, rightMargin, bottomMargin, topMargin);
        setCanvasFinal(c, setLogx, setLogy, setLogz);
        c->cd();

        h_normEvents[i]->SetTitleOffset(titleOffsetX,"X");
        h_normEvents[i]->SetTitleOffset(titleOffsetY,"Y");
        h_normEvents[i]->SetStats(false);
        h_normEvents[i]->Draw("colz");
        c->Write();
        c->Close();         // do not use Delete() for TCanvas.
    }
    // canvases are written.

    // set style of the histograms for the canvases to be saved as picture
    for(int i=0; i<nHistos; ++i) {
        std::string drawOption = "colz";
        if (nDrawOptions == 1) {
            if (drawOptions.at(0).compare(CONFIGPARSER::nullInput) != 0)  drawOption = drawOptions.at(0).c_str();
        }
        else if (nDrawOptions == nHistosInput) {
            if (drawOptions.at(i).compare(CONFIGPARSER::nullInput) != 0)  drawOption = drawOptions.at(i%nDrawOptions).c_str();
        }
        // https://root.cern.ch/doc/master/classTObject.html#abe2a97d15738d5de00cd228e0dc21e56
        // TObject::SetDrawOption() is not suitable for the approach here.

        int markerStyle = GRAPHICS::markerStyle;
        if (nMarkerStyles == 1) markerStyle = GraphicsConfigurationParser::ParseMarkerStyle(markerStyles.at(0));
        else if (nMarkerStyles == nHistosInput) markerStyle = GraphicsConfigurationParser::ParseMarkerStyle(markerStyles.at(i%nMarkerStyles));
        h[i]->SetMarkerStyle(markerStyle);
        h_normInt[i]->SetMarkerStyle(markerStyle);
        h_normEvents[i]->SetMarkerStyle(markerStyle);

        int lineStyle = GRAPHICS::lineStyle;
        if (nLineStyles == 1)  lineStyle = GraphicsConfigurationParser::ParseLineStyle(lineStyles.at(0));
        else if (nLineStyles == nHistosInput)  lineStyle = GraphicsConfigurationParser::ParseLineStyle(lineStyles.at(i%nLineStyles));
        h[i]->SetLineStyle(lineStyle);
        h_normInt[i]->SetLineStyle(lineStyle);
        h_normEvents[i]->SetLineStyle(lineStyle);

        int fillStyle = GRAPHICS::fillStyle;
        if (nFillStyles == 1)  fillStyle = GraphicsConfigurationParser::ParseLineStyle(fillStyles.at(0));
        else if (nFillStyles == nHistosInput)  fillStyle = GraphicsConfigurationParser::ParseLineStyle(fillStyles.at(i%nFillStyles));
        h[i]->SetFillStyle(fillStyle);
        h_normInt[i]->SetFillStyle(fillStyle);
        h_normEvents[i]->SetFillStyle(fillStyle);

        int color = GRAPHICS::colors[i];
        if (nColors == 1) color = GraphicsConfigurationParser::ParseColor(colors.at(0));
        else if (nColors == nHistosInput) color = GraphicsConfigurationParser::ParseColor(colors.at(i%nColors));
        h[i]->SetMarkerColor(color);
        h[i]->SetLineColor(color);
        h_normInt[i]->SetMarkerColor(color);
        h_normInt[i]->SetLineColor(color);
        h_normEvents[i]->SetMarkerColor(color);
        h_normEvents[i]->SetLineColor(color);

        int fillColor = -1;
        if (nFillColors == 1) fillColor = GraphicsConfigurationParser::ParseColor(fillColors.at(0));
        else if (nFillColors == nHistosInput) fillColor = GraphicsConfigurationParser::ParseColor(fillColors.at(i%nFillColors));
        if (fillColor != -1)
        {
            h[i]->SetFillColor(fillColor);
            h_normInt[i]->SetFillColor(fillColor);
            h_normEvents[i]->SetFillColor(fillColor);
        }

        int lineColor = -1;
        if (nLineColors == 1) lineColor = GraphicsConfigurationParser::ParseColor(lineColors.at(0));
        else if (nLineColors == nHistosInput) lineColor = GraphicsConfigurationParser::ParseColor(lineColors.at(i%nLineColors));
        if (nLineColors != -1)
        {
            h[i]->SetLineColor(lineColor);
            h_normInt[i]->SetLineColor(lineColor);
            h_normEvents[i]->SetLineColor(lineColor);
        }

        if(lineWidth != INPUT_DEFAULT::lineWidth) {
            if (drawOption.find("hist") != std::string::npos) {
                h[i]->SetLineWidth(lineWidth);
                h_normInt[i]->SetLineWidth(lineWidth);
                h_normEvents[i]->SetLineWidth(lineWidth);
            }
        }

        h[i]->SetMarkerSize(markerSize);
        h_normInt[i]->SetMarkerSize(markerSize);
        h_normEvents[i]->SetMarkerSize(markerSize);
    }

    TH1D* h_draw[nHistos];
    for (int i=0; i<nHistos; ++i) {
        if (drawNormalized == INPUT_TH1::k_normInt) {
            h_draw[i] = (TH1D*)h_normInt[i]->Clone(Form("h_%d_draw", i));
        }
        else if (drawNormalized == INPUT_TH1::k_normEvents) {
            h_draw[i] = (TH1D*)h_normEvents[i]->Clone(Form("h_%d_draw", i));
        }
        else {  // no normalization
            h_draw[i] = (TH1D*)h[i]->Clone(Form("h_%d_draw", i));
        }
    }

    for (int i = 0; i<nHistos; ++i) {

        c = new TCanvas(Form("cnv_drawSpectra2D_%d", i),"",windowWidth,windowHeight);
        setCanvasMargin(c, leftMargin, rightMargin, bottomMargin, topMargin);
        setCanvasFinal(c, setLogx, setLogy, setLogz);
        c->cd();
        TLegend* leg = new TLegend();

        std::string drawOption = "";
        if (nDrawOptions == 1)  drawOption = drawOptions.at(0).c_str();
        else if (nDrawOptions == nHistosInput) drawOption = drawOptions.at(i%nDrawOptions).c_str();

        h_draw[i]->Draw(drawOption.c_str());

        if (nLegendEntryLabels == nHistosInput) {
            std::string label = legendEntryLabels.at(i%nLegendEntryLabels).c_str();
            std::string legendOption = "lpf";
            if (drawOption.find("hist") != std::string::npos)  legendOption = "lf";
            if (label.compare(CONFIGPARSER::nullInput) != 0)  leg->AddEntry(h_draw[i], label.c_str(), legendOption.c_str());
        }

        if (legendTextSize != 0)  leg->SetTextSize(legendTextSize);
        leg->SetBorderSize(legendBorderSize);
        double height = calcTLegendHeight(leg);
        double width = calcTLegendWidth(leg);
        if (legendHeight != 0)  height = legendHeight;
        if (legendWidth != 0)  width = legendWidth;
        if (legendPosition.size() > 0) {    // draw the legend if really a position is provided.
            setLegendPosition(leg, legendPosition, c, height, width, legendOffsetX, legendOffsetY);
            leg->Draw();
        }

        // add Text
        TLatex* latex = 0;
        if (nTextLines > 0) {
            latex = new TLatex();
            latex->SetTextFont(textFont);
            latex->SetTextSize(textSize);
            setTextAlignment(latex, textPosition);
            std::vector<std::pair<float,float>> textCoordinates = calcTextCoordinates(textLines, textPosition, c, textOffsetX, textOffsetY);
            for (int i = 0; i<nTextLines; ++i) {
                float x = textCoordinates.at(i).first;
                float y = textCoordinates.at(i).second;
                latex->DrawLatexNDC(x, y, textLines.at(i).c_str());
            }
        }

        // add Text above the pad
        TLatex* latexOverPad = 0;
        if (nTextsOverPad > 0) {
            latexOverPad = new TLatex();
            latexOverPad->SetTextFont(textAbovePadFont);
            latexOverPad->SetTextSize(textAbovePadSize);
            for (int i = 0; i < nTextsOverPad; ++i) {
                int textOverPadAlignment = GRAPHICS::textAlign;
                if (nTextsOverPadAlignments == 1) textOverPadAlignment = GraphicsConfigurationParser::ParseTextAlign(textsOverPadAlignments.at(0));
                else if (nTextsOverPadAlignments == nTextsOverPad) textOverPadAlignment = GraphicsConfigurationParser::ParseTextAlign(textsOverPadAlignments.at(i));

                latexOverPad->SetTextAlign(textOverPadAlignment);
                setTextAbovePad(latexOverPad, c, textAbovePadOffsetX, textAbovePadOffsetY);

                latexOverPad->DrawLatexNDC(latexOverPad->GetX(), latexOverPad->GetY(), textsOverPad.at(i).c_str());
            }
        }

        // add TLine
        TLine* line_horizontal[nTLines_horizontal];
        for (int iLine = 0; iLine<nTLines_horizontal; ++iLine) {
            // draw horizontal line
            double xmin = h[i]->GetXaxis()->GetBinLowEdge(h[i]->GetXaxis()->GetFirst());
            double xmax = h[i]->GetXaxis()->GetBinLowEdge(h[i]->GetXaxis()->GetLast()+1);

            int lineStyle_horizontal = GRAPHICS::lineStyle_horizontal;
            if (nLineStyles_horizontal == 1)
                lineStyle_horizontal = GraphicsConfigurationParser::ParseLineStyle(lineStyles_horizontal.at(0));
            else if (nLineStyles_horizontal == nTLines_horizontal)
                lineStyle_horizontal = GraphicsConfigurationParser::ParseLineStyle(lineStyles_horizontal.at(iLine));

            line_horizontal[iLine] = new TLine(xmin, TLines_horizontal.at(iLine), xmax, TLines_horizontal.at(iLine));
            line_horizontal[iLine]->SetLineStyle(lineStyle_horizontal);   // https://root.cern.ch/doc/master/TAttLine_8h.html#a7092c0c4616367016b70d54e5c680a69
            line_horizontal[iLine]->Draw();
        }
        // add TLine
        TLine* line_vertical[nTLines_vertical];
        for (int iLine = 0; iLine<nTLines_vertical; ++iLine) {
            // draw vertical line
            double ymin = h[i]->GetYaxis()->GetBinLowEdge(h[i]->GetYaxis()->GetFirst());
            double ymax = h[i]->GetYaxis()->GetBinLowEdge(h[i]->GetYaxis()->GetLast()+1);

            int lineStyle_vertical = GRAPHICS::lineStyle_vertical;
            if (nLineStyles_vertical == 1)
                lineStyle_vertical = GraphicsConfigurationParser::ParseLineStyle(lineStyles_vertical.at(0));
            else if (nLineStyles_vertical == nTLines_vertical)
                lineStyle_vertical = GraphicsConfigurationParser::ParseLineStyle(lineStyles_vertical.at(iLine));

            line_vertical[iLine] = new TLine(TLines_vertical.at(iLine), ymin, TLines_vertical.at(iLine), ymax);
            line_vertical[iLine]->SetLineStyle(lineStyle_vertical);   // https://root.cern.ch/doc/master/TAttLine_8h.html#a7092c0c4616367016b70d54e5c680a69
            line_vertical[iLine]->Draw();
        }
        c->Write();

        // save histograms as picture if a figure name is provided.
        // for now 2D canvases are not drawn on top, they are drawn separately.
        if (!outputFigureName.EqualTo("")) {
            std::string tmpOutputFigureName = outputFigureName.Data();
            if (tmpOutputFigureName.find(".") != std::string::npos) {     // file extension is specified
                if (nHistos > 1) {
                    // modify outputFile name
                    // if i=1, then "output.ext" becomes "output_2.ext"
                    size_t pos = tmpOutputFigureName.find_last_of(".");
                    tmpOutputFigureName.replace(pos,1, Form("_%d.", i+1));
                }
                c->SaveAs(tmpOutputFigureName.c_str());
            }
            else {  // file extension is NOT specified
                if (nHistos > 1) {
                    // modify outputFile name
                    // if i=1, then "output" becomes "output_2"
                    tmpOutputFigureName = Form("%s_%d", tmpOutputFigureName.c_str(), i+1);
                }

                c->SaveAs(Form("%s.C", tmpOutputFigureName.c_str()));
                c->SaveAs(Form("%s.png", tmpOutputFigureName.c_str()));
                c->SaveAs(Form("%s.pdf", tmpOutputFigureName.c_str()));
            }
        }

        leg->Delete();
        c->Close();
    }

    output->Close();
}
Example #29
0
void optimize_n_jets(const TString sigName = "reduced_trees/SMS-T1tttt_2J_mGl-1500_mLSP-100*v75*.root", const TString bgName = "all", const TString plotNote="T1tttt_1500_100_met_200_ht40_1000", const TCut cuts="") 
{
  set_plot_style();
  TH1::StatOverflows(true);
  TH1::SetDefaultSumw2(); //trick to turn on Sumw2 for all histos
  //TH1::SetStats(0);

  const unsigned int nbins = 16;

  TH1D* h_n30sig = new TH1D("h_n30sig",";n_{jets};Events after cut (#int L dt = 5 fb^{-1})",nbins,0.,16.);
  TH1D* h_n30bg = new TH1D("h_n30bg","",nbins,0.,16.);
  TH1D* h_n40sig = new TH1D("h_n40sig","",nbins,0.,16.);
  TH1D* h_n40bg = new TH1D("h_n40bg","",nbins,0.,16.);
  TH1D* h_n50sig = new TH1D("h_n50sig","",nbins,0.,16.);
  TH1D* h_n50bg = new TH1D("h_n50bg","",nbins,0.,16.);
  TH1D* h_n70sig = new TH1D("h_n70sig","",nbins,0.,16.);
  TH1D* h_n70bg = new TH1D("h_n70bg","",nbins,0.,16.);
  TH1D* h_n100sig = new TH1D("h_n100sig","",nbins,0.,16.);
  TH1D* h_n100bg = new TH1D("h_n100bg","",nbins,0.,16.);

  // TH1D* h_n30sig_pass = new TH1D("h_n30sig_pass",";n_{jets};EventsPassing cut",nbins,0.,16.);
  // TH1D* h_n40sig_pass = new TH1D("h_n40sig_pass","",nbins,0.,16.);
  // TH1D* h_n50sig_pass = new TH1D("h_n50sig_pass","",nbins,0.,16.);
  // TH1D* h_n70sig_pass = new TH1D("h_n70sig_pass","",nbins,0.,16.);
  // TH1D* h_n100sig_pass = new TH1D("h_n100sig_pass","",nbins,0.,16.);

  TH1D* h_n30s_over_sqrt_b = new TH1D("h_n30s_over_sqrt_b",";n_{jets} cut;S/#sqrt{B}",nbins,0.,16.);
  TH1D* h_n40s_over_sqrt_b = new TH1D("h_n40s_over_sqrt_b","",nbins,0.,16.);
  TH1D* h_n50s_over_sqrt_b = new TH1D("h_n50s_over_sqrt_b","",nbins,0.,16.);
  TH1D* h_n70s_over_sqrt_b = new TH1D("h_n70s_over_sqrt_b","",nbins,0.,16.);
  TH1D* h_n100s_over_sqrt_b = new TH1D("h_n100s_over_sqrt_b","",nbins,0.,16.);

  h_n30sig->SetStats(0);
  h_n30s_over_sqrt_b->SetStats(0);


  TCut start(cuts+"met>200&&ht40>500&&num_csvm_jets30>1&&min_delta_phi_met_N>4&&num_reco_veto_muons==0&&num_reco_veto_electrons==0");
  TCut weighted_selection(start*"(weightppb*5000.)");

  TChain * bg = new TChain("reduced_tree");
  TChain * sig = new TChain("reduced_tree");
  if (!bgName.EqualTo("all")) bg->Add(bgName);// treestring is passed as an argument
  else {
    bg->Add("reduced_trees/skimmed/TTJets*v75*.root");
    bg->Add("reduced_trees/skimmed/QCD*v75*.root");
    bg->Add("reduced_trees/skimmed/WJets*v75*.root");
    bg->Add("reduced_trees/skimmed/ZJets*v75*.root");
    bg->Add("reduced_trees/skimmed/TTo*v75*.root");
    bg->Add("reduced_trees/skimmed/TBarTo*v75*.root");
    bg->Add("reduced_trees/skimmed/*tW*v75*.root");
    bg->Add("reduced_trees/skimmed/*HToBB*v75*.root");
    bg->Add("reduced_trees/skimmed/TTbarH*v75*.root");
  }
  sig->Add(sigName);

  TCanvas * thecanvas= new TCanvas("thecanvas","the canvas",800,1600);
  TPad* pad1 = new TPad("pad1","This is pad1",0.,0.5,1,1);
  TPad* pad2 = new TPad("pad1","This is pad2",0.,0.,1,0.5);
  pad1->Draw();
  pad2->Draw();

  sig->Project("h_n30sig","num_jets_pt30",weighted_selection);
  bg->Project("h_n30bg","num_jets_pt30",weighted_selection);
  sig->Project("h_n40sig","num_jets_pt40",weighted_selection);
  bg->Project("h_n40bg","num_jets_pt40",weighted_selection);
  sig->Project("h_n50sig","num_jets_pt50",weighted_selection);
  bg->Project("h_n50bg","num_jets_pt50",weighted_selection);
  sig->Project("h_n70sig","num_jets_pt70",weighted_selection);
  bg->Project("h_n70bg","num_jets_pt70",weighted_selection);
  sig->Project("h_n100sig","num_jets_pt100",weighted_selection);
  bg->Project("h_n100bg","num_jets_pt100",weighted_selection);

  convert_to_int(h_n30sig);
  convert_to_int(h_n40sig);
  convert_to_int(h_n50sig);
  convert_to_int(h_n70sig);
  convert_to_int(h_n100sig);
  convert_to_int(h_n30bg);
  convert_to_int(h_n40bg);
  convert_to_int(h_n50bg);
  convert_to_int(h_n70bg);
  convert_to_int(h_n100bg);

  for (unsigned int bin(0); bin<nbins+1; bin++) {
    if (h_n30bg->GetBinContent(bin+1)>0) h_n30s_over_sqrt_b->SetBinContent(bin+1, h_n30sig->GetBinContent(bin+1)/sqrt(h_n30bg->GetBinContent(bin+1)));
    else h_n30s_over_sqrt_b->SetBinContent(bin+1,100.);
    if (h_n40bg->GetBinContent(bin+1)>0) h_n40s_over_sqrt_b->SetBinContent(bin+1, h_n40sig->GetBinContent(bin+1)/sqrt(h_n40bg->GetBinContent(bin+1)));
    else h_n40s_over_sqrt_b->SetBinContent(bin+1,100.);
    if (h_n50bg->GetBinContent(bin+1)>0) h_n50s_over_sqrt_b->SetBinContent(bin+1, h_n50sig->GetBinContent(bin+1)/sqrt(h_n50bg->GetBinContent(bin+1)));
    else h_n50s_over_sqrt_b->SetBinContent(bin+1,100.);
    if (h_n70bg->GetBinContent(bin+1)>0) h_n70s_over_sqrt_b->SetBinContent(bin+1, h_n70sig->GetBinContent(bin+1)/sqrt(h_n70bg->GetBinContent(bin+1)));
    else h_n70s_over_sqrt_b->SetBinContent(bin+1,100.);
    if (h_n100bg->GetBinContent(bin+1)>0) h_n100s_over_sqrt_b->SetBinContent(bin+1, h_n100sig->GetBinContent(bin+1)/sqrt(h_n100bg->GetBinContent(bin+1)));
    else h_n100s_over_sqrt_b->SetBinContent(bin+1,100.);
   
    // h_n30sig_pass->SetBinContent(bin+1, h_n30sig->Integral(bin+1,nbins+1));
    // h_n40sig_pass->SetBinContent(bin+1, h_n40sig->Integral(bin+1,nbins+1));
    // h_n50sig_pass->SetBinContent(bin+1, h_n50sig->Integral(bin+1,nbins+1));
    // h_n70sig_pass->SetBinContent(bin+1, h_n70sig->Integral(bin+1,nbins+1));
    // h_n100sig_pass->SetBinContent(bin+1, h_n100sig->Integral(bin+1,nbins+1));
  }

  h_n30s_over_sqrt_b->SetLineColor(1);
  h_n40s_over_sqrt_b->SetLineColor(2);
  h_n50s_over_sqrt_b->SetLineColor(3);
  h_n70s_over_sqrt_b->SetLineColor(kOrange);
  h_n100s_over_sqrt_b->SetLineColor(kCyan);
  h_n30s_over_sqrt_b->SetLineWidth(3);
  h_n40s_over_sqrt_b->SetLineWidth(3);
  h_n50s_over_sqrt_b->SetLineWidth(3);
  h_n70s_over_sqrt_b->SetLineWidth(3);
  h_n100s_over_sqrt_b->SetLineWidth(3);

  h_n30sig->SetLineColor(1);
  h_n40sig->SetLineColor(2);
  h_n50sig->SetLineColor(3);
  h_n70sig->SetLineColor(kOrange);
  h_n100sig->SetLineColor(kCyan);
  h_n30sig->SetLineWidth(3);
  h_n40sig->SetLineWidth(3);
  h_n50sig->SetLineWidth(3);
  h_n70sig->SetLineWidth(3);
  h_n100sig->SetLineWidth(3);
 
  pad1->cd();
  h_n30sig->Draw("hist");
  h_n40sig->Draw("hist,same");
  h_n50sig->Draw("hist,same");
  h_n70sig->Draw("hist,same");
  h_n100sig->Draw("hist,same");

  TLegend* leg = new TLegend(0.7,0.7,0.9,0.9);
  leg->SetFillStyle(0);
  leg->SetLineStyle(0);
  leg->SetTextFont(132);
  leg->AddEntry(h_n30s_over_sqrt_b,"p_{T} > 30 GeV","l");
  leg->AddEntry(h_n40s_over_sqrt_b,"p_{T} > 40 GeV","l");
  leg->AddEntry(h_n50s_over_sqrt_b,"p_{T} > 50 GeV","l");
  leg->AddEntry(h_n70s_over_sqrt_b,"p_{T} > 70 GeV","l");
  leg->AddEntry(h_n100s_over_sqrt_b,"p_{T} > 100 GeV","l");
  leg->Draw();

  pad2->cd();
  h_n30s_over_sqrt_b->SetMinimum(0);
  if (sigName.Contains("tttt")||sigName.Contains("1000")) h_n30s_over_sqrt_b->SetMaximum(5);
  else h_n30s_over_sqrt_b->SetMaximum(2.5);
  h_n30s_over_sqrt_b->Draw("hist");
  h_n40s_over_sqrt_b->Draw("hist,same");
  h_n50s_over_sqrt_b->Draw("hist,same");
  h_n70s_over_sqrt_b->Draw("hist,same");
  h_n100s_over_sqrt_b->Draw("hist,same");



  thecanvas->Print("macros/cutflow/plots/optimize_n_jets/n_jets_optimization_"+plotNote+".pdf");


}
Example #30
0
void visscan_init(const TString& cdburi = "",
                  const TString& path   = ".",
                  Bool_t showHLTESDTree=kFALSE,
                  Bool_t showMuon = kTRUE,
                  Bool_t showTrd = kFALSE)
{
    AliEveEventManager *man = new AliEveEventManager(AliEveEventManager::kSourceOffline);
    
    if (showMuon)
    {
        if (gSystem->Getenv("ALICE_ROOT") != 0)
        {
            gInterpreter->AddIncludePath(Form("%s/MUON", gSystem->Getenv("ALICE_ROOT")));
            gInterpreter->AddIncludePath(Form("%s/MUON/mapping", gSystem->Getenv("ALICE_ROOT")));
        }
    }
    else
    {
        gShowMuonRPhi = gShowMuonRhoZ = kFALSE;
    }
    
    if(cdburi.EqualTo(""))
    {
        cdburi = Form("%s/../src/OCDB/", gSystem->Getenv("ALICE_ROOT"));
        cout<<"\n\nsetting cdb uri:"<<cdburi<<endl;
    }
    if (cdburi.IsNull() && ! AliCDBManager::Instance()->IsDefaultStorageSet())
    {
        gEnv->SetValue("Root.Stacktrace", "no");
        Fatal("visscan_init.C", "OCDB path MUST be specified as the first argument.");
    }
    
    AliEveDataSourceOffline *dataSource = (AliEveDataSourceOffline*)man->GetDataSourceOffline();
    
    gInterpreter->AddIncludePath(Form("%s/../src/MONITOR/MONITOR", gSystem->Getenv("ALICE_ROOT")));
    gInterpreter->AddIncludePath(Form("%s/../src/STEER/", gSystem->Getenv("ALICE_ROOT")));
    gInterpreter->AddIncludePath(Form("%s/../src/", gSystem->Getenv("ALICE_ROOT")));
    gInterpreter->AddIncludePath(Form("%s/../src/ANALYSIS/ANALYSISalice", gSystem->Getenv("ALICE_ROOT")));
    gInterpreter->AddIncludePath(Form("%s/../src/STEER/STEERbase", gSystem->Getenv("ALICE_ROOT")));
    gInterpreter->AddIncludePath(Form("%s/../src/STEER/ESD", gSystem->Getenv("ALICE_ROOT")));
    gInterpreter->AddIncludePath(Form("%s/../src/EVE/EveBase", gSystem->Getenv("ALICE_ROOT")));
    gInterpreter->AddIncludePath(Form("%s/../src/STEER/STEER", gSystem->Getenv("ALICE_ROOT")));
    gInterpreter->AddIncludePath(Form("%s/../src/STEER/AOD", gSystem->Getenv("ALICE_ROOT")));
    gInterpreter->AddIncludePath(Form("%s/../src/RAW/RAWdatarec", gSystem->Getenv("ALICE_ROOT")));
    gInterpreter->AddIncludePath(Form("%s/../src/RAW/RAWDatabase", gSystem->Getenv("ALICE_ROOT")));
    gInterpreter->AddIncludePath(Form("%s/../src/STEER/CDB", gSystem->Getenv("ALICE_ROOT")));
    
    TEveUtil::LoadMacro("alieve_init.C+");
    alieve_init(cdburi, path, -1, showHLTESDTree);
    
    man->Open();
    
    // TEveLine::SetDefaultSmooth(1);
    
    TEveUtil::AssertMacro("VizDB_scan.C");
    
    AliEveMacroExecutor *exec    = man->GetExecutor();
    TEveBrowser         *browser = gEve->GetBrowser();
    browser->ShowCloseTab(kFALSE);
    
    
    //==============================================================================
    // Geometry, scenes, projections and viewers
    //==============================================================================
    
    AliEveMultiView *mv = new AliEveMultiView;
    
    mv->SetDepth(-10);
    
    TEveUtil::LoadMacro("geom_gentle.C");
    mv->InitGeomGentle(geom_gentle(), geom_gentle_rphi(), geom_gentle_rhoz(), 0);
    
    if (showTrd) {
        TEveUtil::LoadMacro("geom_gentle_trd.C+");
        mv->InitGeomGentleTrd(geom_gentle_trd());
    }
    
    if (gShowMuonRPhi || gShowMuonRhoZ) {
        TEveUtil::LoadMacro("geom_gentle_muon.C+");
        mv->InitGeomGentleMuon(geom_gentle_muon(kFALSE), gShowMuonRPhi, gShowMuonRhoZ, kFALSE);
    }
    
    mv->SetDepth(0);
    
    //==============================================================================
    // Registration of per-event macros
    //==============================================================================
    
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Track",   "kine_tracks.C", "kine_tracks", "", kTRUE));
    
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits ITS", "its_hits.C",    "its_hits",    "", kTRUE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits TPC", "tpc_hits.C",    "tpc_hits",    "", kTRUE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits T0",  "t0_hits.C",     "t0_hits",     "", kTRUE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits FMD", "fmd_hits.C",    "fmd_hits",    "", kTRUE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits ACORDE", "acorde_hits.C",    "acorde_hits",    "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits EMCAL", "emcal_hits.C",    "emcal_hits",    "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits TOF",  "tof_hits.C",     "tof_hits",     "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits TRD", "trd_hits.C",    "trd_hits",    "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hits VZERO", "vzero_hits.C",    "vzero_hits",    "", kFALSE));
    
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG ITS",     "its_digits.C",  "its_digits",  "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG TPC",     "tpc_digits.C",  "tpc_digits",  "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG TOF",     "tof_digits.C",  "tof_digits",  "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG HMPID",   "hmpid_digits.C","hmpid_digits","", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG FMD",     "fmd_digits.C",  "fmd_digits",  "", kFALSE));
    
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ITS",     "its_raw.C",     "its_raw",     "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TPC",     "tpc_raw.C",     "tpc_raw",     "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TOF",     "tof_raw.C",     "tof_raw",     "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW HMPID",   "hmpid_raw.C",   "hmpid_raw",   "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW T0",      "t0_raw.C",      "t0_raw",      "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW FMD",     "fmd_raw.C",     "fmd_raw",     "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW VZERO",   "vzero_raw.C",   "vzero_raw",   "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ACORDE",  "acorde_raw.C",  "acorde_raw",  "", kFALSE));
    /*
     exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX",             "primary_vertex.C", "primary_vertex",             "",                kTRUE));
     exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse",     "primary_vertex.C", "primary_vertex_ellipse",     "",                kTRUE));
     exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box",         "primary_vertex.C", "primary_vertex_box",         "kFALSE, 3, 3, 3", kFALSE));
     exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX SPD",         "primary_vertex.C", "primary_vertex_spd",         "",                kTRUE));
     exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse SPD", "primary_vertex.C", "primary_vertex_ellipse_spd", "",                kTRUE));
     exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box SPD",     "primary_vertex.C", "primary_vertex_box_spd",     "kFALSE, 3, 3, 3", kFALSE));
     exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX TPC",         "primary_vertex.C", "primary_vertex_tpc",         "",                kFALSE));
     exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse TPC", "primary_vertex.C", "primary_vertex_ellipse_tpc", "",                kFALSE));
     exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box TPC",     "primary_vertex.C", "primary_vertex_box_tpc",     "kFALSE, 3, 3, 3", kFALSE));
     */
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0",   "esd_V0_points.C",       "esd_V0_points_onfly"));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0",   "esd_V0_points.C",       "esd_V0_points_offline"));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0",   "esd_V0.C",              "esd_V0"));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC CSCD", "esd_cascade_points.C",  "esd_cascade_points"));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC CSCD", "esd_cascade.C",         "esd_cascade"));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC KINK", "esd_kink_points.C",     "esd_kink_points"));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC KINK", "esd_kink.C",            "esd_kink"));
    
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks",              "esd_tracks.C", "esd_tracks",              "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks ITS standalone",          "esd_tracks.C", "esd_tracks_ITS_standalone",              "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks ITS",          "esd_tracks.C", "esd_tracks_ITS",              "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks TPC",           "esd_tracks.C", "esd_tracks_TPC",              "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks MI",           "esd_tracks.C", "esd_tracks_MI",           "", kFALSE));
    
    // default appearance:
    //  exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks by category",  "esd_tracks.C", "esd_tracks_by_category",  "", kTRUE));
    
    // preset for cosmics:
    //  exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks by category",  "esd_tracks.C", "esd_tracks_by_category",  "kGreen,kGreen,kGreen,kGreen,kGreen,kGreen,kGreen,kGreen,kGreen,kFALSE", kTRUE));
    
    
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks by anal cuts", "esd_tracks.C", "esd_tracks_by_anal_cuts", "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks Lego", "lego.C", "lego", "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks Beams Info", "beams_info.C", "beams_info", "", kFALSE));
    
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracklets SPD", "esd_spd_tracklets.C", "esd_spd_tracklets", "", kTRUE));
    
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC ZDC",      "esd_zdc.C", "esd_zdc", "", kFALSE));
    
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters",     "clusters.C",     "clusters", "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters ITS", "its_clusters.C", "its_clusters"));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters TPC", "tpc_clusters.C", "tpc_clusters"));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters TRD", "trd_clusters.C", "trd_clusters"));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters TOF", "tof_clusters.C", "tof_clusters"));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters HMPID", "hmpid_clusters.C", "hmpid_clusters"));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters PHOS", "phos_clusters.C", "phos_clusters"));
    
    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters TPC", "vplot_tpc.C",    "vplot_tpc", "", kFALSE));
    
    exec->AddMacro(new AliEveMacro(AliEveMacro::kAOD, "ANA HF",   "aod_HF.C",   "aod_HF",   "", kFALSE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kAOD, "ANA Jets", "jetplane.C", "jetplane", "", kFALSE));
    
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "DUMP VZERO",   "vzero_dump.C",   "vzero_dump",   "", kFALSE));
    
    if (showMuon)
    {
        exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM TrackRef MUON", "muon_trackRefs.C", "muon_trackRefs", "kTRUE", kFALSE));
        exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW MUON", "muon_raw.C", "muon_raw", "", kFALSE));
        exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG MUON", "muon_digits.C", "muon_digits", "", kFALSE));
        exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clusters MUON", "muon_clusters.C", "muon_clusters", "", kTRUE));
        exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks MUON", "esd_muon_tracks.C", "esd_muon_tracks", "kTRUE,kFALSE", kTRUE));
    }
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "ESD AD", "ad_esd.C", "ad_esd", "", kTRUE));
    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "ESD EMCal", "emcal_esdclustercells.C", "emcal_esdclustercells", "", kTRUE));
    
    
    //==============================================================================
    // Additional GUI components
    //==============================================================================
    
    // Macro / data selection
    TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
    slot->StartEmbedding();
    AliEveMacroExecutorWindow* exewin = new AliEveMacroExecutorWindow(exec);
    slot->StopEmbedding("DataSelection");
    exewin->PopulateMacros();
    
    // Event selection tab
    slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
    slot->StartEmbedding();
    new AliEveEventSelectorWindow(gClient->GetRoot(), 600, 400, man->GetEventSelector());
    slot->StopEmbedding("Selections");
    
    // QA viewer
    /*
     slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
     slot->StartEmbedding();
     new AliQAHistViewer(gClient->GetRoot(), 600, 400, kTRUE);
     slot->StopEmbedding("QA histograms");
     
     browser->GetTabRight()->SetTab(1);
     */
    browser->StartEmbedding(TRootBrowser::kBottom);
    new AliEveEventManagerWindow(man);
    browser->StopEmbedding("EventCtrl");
    
    slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
    TEveWindowTab *store_tab = slot->MakeTab();
    store_tab->SetElementNameTitle("WindowStore",
                                   "Undocked windows whose previous container is not known\n"
                                   "are placed here when the main-frame is closed.");
    gEve->GetWindowManager()->SetDefaultContainer(store_tab);
    
    
    //==============================================================================
    // AliEve objects - global tools
    //==============================================================================
    
    AliEveTrackCounter* g_trkcnt = new AliEveTrackCounter("Primary Counter");
    gEve->AddToListTree(g_trkcnt, kFALSE);
    
    
    //==============================================================================
    // Final stuff
    //==============================================================================
    
    // A refresh to show proper window.
    //gEve->GetViewers()->SwitchColorSet();
    browser->MoveResize(0, 0, gClient->GetDisplayWidth(),gClient->GetDisplayHeight() - 32);
    gEve->Redraw3D(kTRUE);
    gSystem->ProcessEvents();
    
    // Register command to call on each event.
    man->AddNewEventCommand("on_new_event();");
    man->GotoEvent(0);
    
    gEve->EditElement(g_trkcnt);
    gEve->Redraw3D(kTRUE);
    
    //move multiview to the front
    browser->GetTabRight()->SetTab(1);
    TGLViewer *glv1 = mv->Get3DView()->GetGLViewer();
    glv1->CurrentCamera().RotateRad(-0.4, 0.6);
    gEve->FullRedraw3D();
    gSystem->ProcessEvents();
    gEve->Redraw3D(kTRUE);
    // set autoload by default
    
    
    
    Color_t colors[9] = {kCyan,kCyan,kCyan,kRed,kRed,kRed,kGreen,kGreen,kGreen};
    
    man->SetESDcolorsByCategory(colors);
    man->SetESDwidth(2);
    man->SetESDdashNoRefit(true);
    man->SetESDdrawNoRefit(true);
    
    man->SetESDtracksByCategory(false);
    man->SetESDtracksByType(true);
    
    man->SetAutoLoad(false);
}