1 /////////////////////////////////////////////////////////
2 // NumberOfEventsMCvsDATA.C //
4 // plots the ratio (# of MC events)/(# of DATA events) //
5 // against the run number //
7 // Written by John Groh //
8 /////////////////////////////////////////////////////////
14 // possible cuts to use - 0 1 2 3
15 Double_t CentCutMin[4] = {0, 30, 30, 30};
16 Double_t CentCutMax[4] = {5, 40, 40, 40};
17 Double_t QvecCutMin[4] = {0, 0, 0, 1.5};
18 Double_t QvecCutMax[4] = {100, 100, 0.4, 100};
19 Double_t EtaMin[4] = {-0.8,-0.8,-0.8,-0.8};
20 Double_t EtaMax[4] = {0.8, 0.8, 0.8, 0.8};
21 Double_t Nsigmapid = 3.;
24 //--------------------
25 // Start of function -
26 //--------------------
27 // icut selects which cut to use (2 and 3 have too low statistics and cause divide-by-zero errors, so don't use)
28 // nSigmaCut is the size of the deviation with which to determine outliers
29 void NumberOfEventsMCvsDATA(Int_t icut = 1, const Float_t nSigmaCut = 3)
31 // load libraries (I'm not sure I need all of these...)
32 gSystem->Load("libCore");
33 gSystem->Load("libPhysics");
34 gSystem->Load("libTree");
35 gSystem->Load("libMatrix");
36 gSystem->Load("libSTEERBase");
37 gSystem->Load("libESD");
38 gSystem->Load("libAOD");
39 gSystem->Load("libANALYSIS");
40 gSystem->Load("libOADB");
41 gSystem->Load("libANALYSISalice");
42 gSystem->Load("libTender");
43 gSystem->Load("libCORRFW");
44 gSystem->Load("libPWGTools");
45 gSystem->Load("libPWGLFspectra");
46 gSystem->Load("libProof");
47 gSystem->AddIncludePath("-I$ALICE_ROOT/include");
49 // get number of runs used
52 ifstream runList("output/AODQAChecks/RunList.txt");
53 while (!runList.eof())
60 // I know this is silly, but you need a const for array sizes.
61 // Also, it seems to want to read one more line than there is in the file
62 const Int_t nRuns = nRunsTemp - 1;
64 // fill an array with the run numbers and another two with the file names
65 runList.open("output/AODQAChecks/RunList.txt");
67 TString dataFilesDATA[nRuns];
68 TString dataFilesMC[nRuns];
70 for (Int_t irun=0; irun<nRuns; irun++)
72 runList >> runs[irun];
73 dataFilesDATA[irun] = Form("output/AODQAChecks/DATA/AnalysisResults%i.root",runs[irun]);
74 dataFilesMC[irun] = Form("output/AODQAChecks/MC/AnalysisResults%i.root",runs[irun]);
78 // choose which TDirectories in the .root files to use
81 snameDATA = Form("OutputAODSpectraTask_Data_Cent%.0fto%.0f_QVec%.1fto%.1f_Eta%.1fto%.1f_%.1fSigmaPID_TrBit%d",CentCutMin[icut],CentCutMax[icut],QvecCutMin[icut],QvecCutMax[icut],EtaMin[icut],EtaMax[icut],Nsigmapid,trkbit);
82 snameMC = Form("OutputAODSpectraTask_MC_Cent%.0fto%.0f_QVec%.1fto%.1f_Eta%.1fto%.1f_%.1fSigmaPID_TrBit%d",CentCutMin[icut],CentCutMax[icut],QvecCutMin[icut],QvecCutMax[icut],EtaMin[icut],EtaMax[icut],Nsigmapid,trkbit);
85 TDirectoryFile * DirDATA;
86 AliSpectraAODEventCuts * ecutsDATA;
88 TDirectoryFile * DirMC;
89 AliSpectraAODEventCuts * ecutsMC;
91 // histogram to be filled w/ the ratio (# of MC events)/(# of DATA events)
92 TH1F * hNEventsRatio = new TH1F("hNEventsRatio","",nRuns,0,nRuns);
95 for (Int_t irun=0; irun<nRuns; irun++)
97 Printf("\n--- Processing run %i ---",runs[irun]);
100 fileDATA = TFile::Open(dataFilesDATA[irun].Data());
103 Printf("\n!!! ERROR: Could not open DATA file %s !!!\n",dataFiles[irun].Data());
106 fileMC = TFile::Open(dataFilesMC[irun].Data());
109 Printf("\n!!! ERROR: Could not open MC file %s !!!\n",dataFiles[irun].Data());
113 // choose the right directory and event cut objects
114 DirDATA = (TDirectoryFile*)fileDATA->Get(Form("%s",snameDATA.Data()));
117 Printf("\n!!! ERROR: DirDATA is a null pointer. Skipping to next file !!!\n");
120 DirMC = (TDirectoryFile*)fileMC->Get(Form("%s",snameMC.Data()));
123 Printf("\n!!! ERROR: DirMC is a null pointer. Skipping to next file !!!\n");
126 ecutsDATA = (AliSpectraAODEventCuts*)DirDATA->Get("Event Cuts");
129 Printf("\n!!! ERROR: ecutsDATA is a null pointer. Skipping to next file !!!\n");
132 ecutsMC = (AliSpectraAODEventCuts*)DirMC->Get("Event Cuts");
135 Printf("\n!!! ERROR: ecutsMC is a null pointer. Skipping to next file !!!\n");
139 // calculate the ratio and fill the histogram
140 Int_t nEventsDATA = ecutsDATA->NumberOfEvents();
141 Int_t nEventsMC = ecutsMC->NumberOfEvents();
142 Float_t ratio = (Float_t)nEventsMC / (Float_t)nEventsDATA;
143 hNEventsRatio->SetBinContent(irun+1,ratio);
144 Printf("# of MC events: %i\n# of DATA events: %i\nRatio: %.2f",nEventsMC,nEventsDATA,ratio);
146 } // end loop over runs
149 TCanvas * cNEventsRatio = new TCanvas("cNEventsRatio","cNEventsRatio");
150 for (Int_t irun=0; irun<nRuns; irun++)
151 hNEventsRatio->GetXaxis()->SetBinLabel(irun+1,Form("%i",runs[irun]));
152 hNEventsRatio->GetYaxis()->SetTitle("(# of MC events)/(# of DATA events)");
153 hNEventsRatio->GetYaxis()->SetTitleOffset(1.2);
154 hNEventsRatio->SetMarkerStyle(21);
155 hNEventsRatio->SetMarkerColor(kBlue);
156 hNEventsRatio->SetStats(kFALSE);
157 hNEventsRatio->DrawCopy("P");