ROOT logo
void processDrawUDQA(const char *infile="AnalysisResults.root", 
		     TString suffix = "eps", 
		     const char *outfile="DrawUDQA_outfile.root") {

TFile *f = TFile::Open(infile, "read");

if(!f) {
 Printf("FATAL: File doesn't exist");
 return;
}

TList *flistQA = (TList*)f->Get("UpcTree/ListHist");

if(!flistQA) {
 Printf("FATAL: TList - UpcTree/ListHist -  doesn't exist");
 return;
}



TH1D *fHistNeventsJPsi = dynamic_cast<TH1D*> (flistQA->At(0));
fHistNeventsJPsi->GetYaxis()->SetTitle("Counts (Events)");

TH2D *fHistTPCsignalJPsi = dynamic_cast<TH2D*> (flistQA->At(1));
fHistTPCsignalJPsi->GetXaxis()->SetTitle("d#it{E}/d#it{x}^{TPC} (#it{l}^{+}) (a.u.)");
fHistTPCsignalJPsi->GetYaxis()->SetTitle("d#it{E}/d#it{x}^{TPC} (#it{l}^{-}) (a.u.)");

TH2D *fHistDiLeptonPtJPsi = dynamic_cast<TH2D*> (flistQA->At(2));
fHistDiLeptonPtJPsi->GetXaxis()->SetTitle("#it{p}_{T} (#it{l}^{+}) (GeV/#it{c})");
fHistDiLeptonPtJPsi->GetYaxis()->SetTitle("#it{p}_{T} (#it{l}^{-}) (GeV/#it{c})");

TH1D *fHistDiElectronMass = dynamic_cast<TH1D*> (flistQA->At(3));
fHistDiElectronMass->GetYaxis()->SetTitle("dN/dM");

TH1D *fHistDiMuonMass = dynamic_cast<TH1D*> (flistQA->At(4));
fHistDiMuonMass->GetYaxis()->SetTitle("dN/dM");

//___________________________________
  // Added by sjena
TFile *fout = TFile::Open(outfile,"UPDATE");
  fout->ls();
  
  TDirectoryFile *cdd = NULL;
  cdd = (TDirectoryFile*)fout->Get("UD");
  if(!cdd) {
    Printf("Warning: UD <dir> doesn't exist, creating a new one");
    cdd = (TDirectoryFile*)fout->mkdir("UD");
  }
  cdd->cd();
  cdd->ls();

  fHistNeventsJPsi->Write();
  fHistTPCsignalJPsi->Write();
  fHistDiLeptonPtJPsi->Write();
  fHistDiElectronMass->Write();
  fHistDiMuonMass->Write();
  fout->Close();
//___________________________________




  myOptions();
  gROOT->ForceStyle();

  TDatime now;
  int iDate = now.GetDate();
  int iYear=iDate/10000;
  int iMonth=(iDate%10000)/100;
  int iDay=iDate%100;
  char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun",
		    "Jul","Aug","Sep","Oct","Nov","Dec"};
  char cStamp1[25],cStamp2[25];
  sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear);
  sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear);

myHistSetUp(fHistNeventsJPsi);
fHistNeventsJPsi->SetLineWidth(3.0);
myHistSetUp(fHistTPCsignalJPsi);
myHistSetUp(fHistDiLeptonPtJPsi);
myHistSetUp(fHistDiElectronMass);
fHistDiElectronMass->SetLineWidth(2.0);
myHistSetUp(fHistDiMuonMass);
fHistDiMuonMass->SetLineWidth(2.0);

TCanvas *c1 = new TCanvas("fig_ud_NeventsJPsi"," ",800,400);
c1->Draw();
c1->cd();
TPad *myPad1 = new TPad("myPad1", "The pad",0,0,1,1);
myPadSetUp(myPad1,0.15,0.1,0.04,0.15);
myPad1->SetLogy();
myPad1->Draw();
myPad1->cd();

fHistNeventsJPsi->Draw();
 c1->SaveAs(Form("fig_ud_NeventsJPsi.%s",suffix.Data()));


TCanvas *c21 = new TCanvas("fig_ud_TPCsignalJPsi"," ",500,500);
c21->Draw();
c21->cd();
TPad *myPad21 = new TPad("myPad21", "The pad",0,0,1,1);
myPadSetUp(myPad21,0.15,0.15,0.15,0.15);
myPad21->Draw();
myPad21->cd();
fHistTPCsignalJPsi->Draw("COLZ");
 c21->SaveAs(Form("fig_ud_TPCsignalJPsi.%s",suffix.Data()));


TCanvas *c22 = new TCanvas("fig_ud_DiLeptonPtJPsi"," ",500,500);
c22->Draw();
c22->cd();
TPad *myPad22 = new TPad("myPad22", "The pad",0,0,1,1);
myPadSetUp(myPad22,0.15,0.15,0.15,0.15);
myPad22->Draw();
myPad22->cd();
fHistDiLeptonPtJPsi->Draw("COLZ");
 c22->SaveAs(Form("fig_ud_DiLeptonPtJPsi.%s",suffix.Data()));
 

TCanvas *c31 = new TCanvas("fig_ud_DiElectronMassJPsi"," ",800,500);
c31->Draw();
c31->cd();
TPad *myPad31 = new TPad("myPad31", "The pad",0,0,1,1);
myPadSetUp(myPad31,0.15,0.1,0.04,0.15);
myPad31->Draw();
myPad31->cd();
fHistDiElectronMass->Draw();
 c31->SaveAs(Form("fig_ud_DiElectronMassJPsi.%s",suffix.Data()));
 

TCanvas *c32 = new TCanvas("fig_ud_DiMuonMassJPsi"," ",800,500);
c32->Draw();
c32->cd();
TPad *myPad32 = new TPad("myPad32", "The pad",0,0,1,1);
myPadSetUp(myPad32,0.15,0.1,0.04,0.15);
myPad32->Draw();
myPad32->cd();
fHistDiMuonMass->Draw();
 c32->SaveAs(Form("fig_ud_DiMuonMassJPsi.%s",suffix.Data()));
 

/*
   TFile* outfile = new TFile("fig_ud.root","recreate");
   c1->Write();
   c21->Write();
   c31->Write();
   c22->Write();
   c32->Write();
 */

}

void myPadSetUp(TPad *currentPad, float currentLeft=0.11, float currentTop=0.04, float currentRight=0.04, float currentBottom=0.15){
  currentPad->SetLeftMargin(currentLeft);
  currentPad->SetTopMargin(currentTop);
  currentPad->SetRightMargin(currentRight);
  currentPad->SetBottomMargin(currentBottom);
  return;
}


void myHistSetUp(TH1 *currentGraph=0){
 
  currentGraph->SetLabelSize(0.05,"xyz");
  currentGraph->SetLabelFont(42,"xyz"); 
  currentGraph->SetLabelOffset(0.01,"xyz");
  currentGraph->SetTitleFont(42,"xyz");   
  currentGraph->GetXaxis()->SetTitleOffset(1.1);
  currentGraph->GetYaxis()->SetTitleOffset(1.1);  
  currentGraph->SetTitleSize(0.06,"xyz");
  currentGraph->SetStats(kFALSE); 
  currentGraph->SetTitle("");
  return;
}
void myHistSetUp(TH2 *currentGraph=0){
 
  currentGraph->SetLabelSize(0.05,"xyz");
  currentGraph->SetLabelFont(42,"xyz"); 
  currentGraph->SetLabelOffset(0.01,"xyz");
  currentGraph->SetTitleFont(42,"xyz"); 
  currentGraph->GetXaxis()->SetTitleOffset(1.3);
  currentGraph->GetYaxis()->SetTitleOffset(1.3);  
  currentGraph->SetTitleSize(0.05,"xyz");
  currentGraph->SetStats(kFALSE);
  currentGraph->SetTitle(""); 
  return;
}

void myOptions(Int_t lStat=0){
  // Set gStyle
  int font = 42;
  // From plain
  gStyle->SetFrameBorderMode(0);
  gStyle->SetFrameFillColor(0);
  gStyle->SetCanvasBorderMode(0);
  gStyle->SetPadBorderMode(0);
  gStyle->SetPadColor(10);
  gStyle->SetCanvasColor(10);
  gStyle->SetTitleFillColor(10);
  gStyle->SetTitleBorderSize(1);
  gStyle->SetStatColor(10);
  gStyle->SetStatBorderSize(1);
  gStyle->SetLegendBorderSize(1);
  //
  gStyle->SetDrawBorder(0);
  gStyle->SetTextFont(font);
  gStyle->SetStatFont(font);
  gStyle->SetStatFontSize(0.05);
  gStyle->SetStatX(0.97);
  gStyle->SetStatY(0.98);
  gStyle->SetStatH(0.03);
  gStyle->SetStatW(0.3);
  gStyle->SetTickLength(0.02,"y");
  gStyle->SetEndErrorSize(3);
  gStyle->SetLabelSize(0.05,"xyz");
  gStyle->SetLabelFont(font,"xyz"); 
  gStyle->SetLabelOffset(0.01,"xyz");
  gStyle->SetTitleFont(font,"xyz");  
  gStyle->SetTitleOffset(1.0,"xyz");  
  gStyle->SetTitleSize(0.06,"xyz");  
  gStyle->SetMarkerSize(1); 
  gStyle->SetPalette(1,0); 
  if (lStat){
    gStyle->SetOptTitle(1);
    gStyle->SetOptStat(1111);
    gStyle->SetOptFit(1111);
    }
  else {
    gStyle->SetOptTitle(0);
    gStyle->SetOptStat(0);
    gStyle->SetOptFit(0);
  }
}

 processDrawUDQA.C:1
 processDrawUDQA.C:2
 processDrawUDQA.C:3
 processDrawUDQA.C:4
 processDrawUDQA.C:5
 processDrawUDQA.C:6
 processDrawUDQA.C:7
 processDrawUDQA.C:8
 processDrawUDQA.C:9
 processDrawUDQA.C:10
 processDrawUDQA.C:11
 processDrawUDQA.C:12
 processDrawUDQA.C:13
 processDrawUDQA.C:14
 processDrawUDQA.C:15
 processDrawUDQA.C:16
 processDrawUDQA.C:17
 processDrawUDQA.C:18
 processDrawUDQA.C:19
 processDrawUDQA.C:20
 processDrawUDQA.C:21
 processDrawUDQA.C:22
 processDrawUDQA.C:23
 processDrawUDQA.C:24
 processDrawUDQA.C:25
 processDrawUDQA.C:26
 processDrawUDQA.C:27
 processDrawUDQA.C:28
 processDrawUDQA.C:29
 processDrawUDQA.C:30
 processDrawUDQA.C:31
 processDrawUDQA.C:32
 processDrawUDQA.C:33
 processDrawUDQA.C:34
 processDrawUDQA.C:35
 processDrawUDQA.C:36
 processDrawUDQA.C:37
 processDrawUDQA.C:38
 processDrawUDQA.C:39
 processDrawUDQA.C:40
 processDrawUDQA.C:41
 processDrawUDQA.C:42
 processDrawUDQA.C:43
 processDrawUDQA.C:44
 processDrawUDQA.C:45
 processDrawUDQA.C:46
 processDrawUDQA.C:47
 processDrawUDQA.C:48
 processDrawUDQA.C:49
 processDrawUDQA.C:50
 processDrawUDQA.C:51
 processDrawUDQA.C:52
 processDrawUDQA.C:53
 processDrawUDQA.C:54
 processDrawUDQA.C:55
 processDrawUDQA.C:56
 processDrawUDQA.C:57
 processDrawUDQA.C:58
 processDrawUDQA.C:59
 processDrawUDQA.C:60
 processDrawUDQA.C:61
 processDrawUDQA.C:62
 processDrawUDQA.C:63
 processDrawUDQA.C:64
 processDrawUDQA.C:65
 processDrawUDQA.C:66
 processDrawUDQA.C:67
 processDrawUDQA.C:68
 processDrawUDQA.C:69
 processDrawUDQA.C:70
 processDrawUDQA.C:71
 processDrawUDQA.C:72
 processDrawUDQA.C:73
 processDrawUDQA.C:74
 processDrawUDQA.C:75
 processDrawUDQA.C:76
 processDrawUDQA.C:77
 processDrawUDQA.C:78
 processDrawUDQA.C:79
 processDrawUDQA.C:80
 processDrawUDQA.C:81
 processDrawUDQA.C:82
 processDrawUDQA.C:83
 processDrawUDQA.C:84
 processDrawUDQA.C:85
 processDrawUDQA.C:86
 processDrawUDQA.C:87
 processDrawUDQA.C:88
 processDrawUDQA.C:89
 processDrawUDQA.C:90
 processDrawUDQA.C:91
 processDrawUDQA.C:92
 processDrawUDQA.C:93
 processDrawUDQA.C:94
 processDrawUDQA.C:95
 processDrawUDQA.C:96
 processDrawUDQA.C:97
 processDrawUDQA.C:98
 processDrawUDQA.C:99
 processDrawUDQA.C:100
 processDrawUDQA.C:101
 processDrawUDQA.C:102
 processDrawUDQA.C:103
 processDrawUDQA.C:104
 processDrawUDQA.C:105
 processDrawUDQA.C:106
 processDrawUDQA.C:107
 processDrawUDQA.C:108
 processDrawUDQA.C:109
 processDrawUDQA.C:110
 processDrawUDQA.C:111
 processDrawUDQA.C:112
 processDrawUDQA.C:113
 processDrawUDQA.C:114
 processDrawUDQA.C:115
 processDrawUDQA.C:116
 processDrawUDQA.C:117
 processDrawUDQA.C:118
 processDrawUDQA.C:119
 processDrawUDQA.C:120
 processDrawUDQA.C:121
 processDrawUDQA.C:122
 processDrawUDQA.C:123
 processDrawUDQA.C:124
 processDrawUDQA.C:125
 processDrawUDQA.C:126
 processDrawUDQA.C:127
 processDrawUDQA.C:128
 processDrawUDQA.C:129
 processDrawUDQA.C:130
 processDrawUDQA.C:131
 processDrawUDQA.C:132
 processDrawUDQA.C:133
 processDrawUDQA.C:134
 processDrawUDQA.C:135
 processDrawUDQA.C:136
 processDrawUDQA.C:137
 processDrawUDQA.C:138
 processDrawUDQA.C:139
 processDrawUDQA.C:140
 processDrawUDQA.C:141
 processDrawUDQA.C:142
 processDrawUDQA.C:143
 processDrawUDQA.C:144
 processDrawUDQA.C:145
 processDrawUDQA.C:146
 processDrawUDQA.C:147
 processDrawUDQA.C:148
 processDrawUDQA.C:149
 processDrawUDQA.C:150
 processDrawUDQA.C:151
 processDrawUDQA.C:152
 processDrawUDQA.C:153
 processDrawUDQA.C:154
 processDrawUDQA.C:155
 processDrawUDQA.C:156
 processDrawUDQA.C:157
 processDrawUDQA.C:158
 processDrawUDQA.C:159
 processDrawUDQA.C:160
 processDrawUDQA.C:161
 processDrawUDQA.C:162
 processDrawUDQA.C:163
 processDrawUDQA.C:164
 processDrawUDQA.C:165
 processDrawUDQA.C:166
 processDrawUDQA.C:167
 processDrawUDQA.C:168
 processDrawUDQA.C:169
 processDrawUDQA.C:170
 processDrawUDQA.C:171
 processDrawUDQA.C:172
 processDrawUDQA.C:173
 processDrawUDQA.C:174
 processDrawUDQA.C:175
 processDrawUDQA.C:176
 processDrawUDQA.C:177
 processDrawUDQA.C:178
 processDrawUDQA.C:179
 processDrawUDQA.C:180
 processDrawUDQA.C:181
 processDrawUDQA.C:182
 processDrawUDQA.C:183
 processDrawUDQA.C:184
 processDrawUDQA.C:185
 processDrawUDQA.C:186
 processDrawUDQA.C:187
 processDrawUDQA.C:188
 processDrawUDQA.C:189
 processDrawUDQA.C:190
 processDrawUDQA.C:191
 processDrawUDQA.C:192
 processDrawUDQA.C:193
 processDrawUDQA.C:194
 processDrawUDQA.C:195
 processDrawUDQA.C:196
 processDrawUDQA.C:197
 processDrawUDQA.C:198
 processDrawUDQA.C:199
 processDrawUDQA.C:200
 processDrawUDQA.C:201
 processDrawUDQA.C:202
 processDrawUDQA.C:203
 processDrawUDQA.C:204
 processDrawUDQA.C:205
 processDrawUDQA.C:206
 processDrawUDQA.C:207
 processDrawUDQA.C:208
 processDrawUDQA.C:209
 processDrawUDQA.C:210
 processDrawUDQA.C:211
 processDrawUDQA.C:212
 processDrawUDQA.C:213
 processDrawUDQA.C:214
 processDrawUDQA.C:215
 processDrawUDQA.C:216
 processDrawUDQA.C:217
 processDrawUDQA.C:218
 processDrawUDQA.C:219
 processDrawUDQA.C:220
 processDrawUDQA.C:221
 processDrawUDQA.C:222
 processDrawUDQA.C:223
 processDrawUDQA.C:224
 processDrawUDQA.C:225
 processDrawUDQA.C:226
 processDrawUDQA.C:227
 processDrawUDQA.C:228
 processDrawUDQA.C:229
 processDrawUDQA.C:230
 processDrawUDQA.C:231
 processDrawUDQA.C:232
 processDrawUDQA.C:233
 processDrawUDQA.C:234
 processDrawUDQA.C:235
 processDrawUDQA.C:236