AliPhysics  9b6b435 (9b6b435)
PrintScaleFactors.C
Go to the documentation of this file.
1 
13 #if !defined(__CINT__) || defined(__MAKECINT__)
14 
15 #include <TH1F.h>
16 #include <TList.h>
17 #include <TString.h>
18 #include <TFile.h>
19 
20 #endif
21 
30 void ForBin
31 (
32  Int_t bin = -1,
33  TString prodName = "pp_7TeV_GJ",
34  TString fileName = "Merged",
35  TString listName = "CTC_EMCAL_Trig_default_ClV1_Ecell100_Eseed500_SPDPileUp"
36  )
37 {
38  //printf("Scale bin %d\n",bin);
39 
40  TFile * f= TFile::Open(Form("%s/%d/%s.root",prodName.Data(),bin,fileName.Data()),"read");
41 
42  if ( !f )
43  {
44  //printf("No file available for bin %d: \n",bin);
45  return;
46  }
47 
48  TList* list = (TList*) f->Get(listName);
49 
50  if ( !list )
51  {
52  //printf("No list available\n");
53  return;
54  }
55 
56  // Extract the cross section from the corresponding histograms in the file
57 
58  Float_t nEventsIn = ((TH1F*)list->FindObject("hNEventsIn"))->GetEntries();
59  Float_t nEvents = ((TH1F*)list->FindObject("hNEvents")) ->GetEntries();
60  Float_t entries = ((TH1F*)list->FindObject("hXsec")) ->GetEntries();
61  Float_t xsec = ((TH1F*)list->FindObject("hXsec")) ->GetBinContent(1) ;
62  Float_t trials = ((TH1F*)list->FindObject("hTrials")) ->GetBinContent(1) ;
63 
64 
65  Float_t xsecNorm = xsec / entries; // average per chunk
66  Float_t trialsNorm = trials/ entries; // trials per chunk
67 
68  Double_t scale = xsecNorm/trialsNorm/nEventsIn ;
69 
70  printf("Bin %d, nEvents Input %2.4e, nEvents selected %2.4e, Events accepted %2.2f, nXsec files %2.4e,"
71  "xsec %2.4e, xSecNorm=xsec/nFiles %2.4e trials %2.4e, trialsNorm=trials/nFiles %2.4e, "
72  "factor=xSecNorm/trialsNorm %2.4e, factor/nEventsInput = %2.4e \n",
73  bin, nEventsIn, nEvents, nEvents/nEventsIn, entries,
74  xsec, xsecNorm, trials, trialsNorm,
75  xsecNorm/trialsNorm,scale);
76 
77  f->Close();
78  delete f;
79 }
80 
90 (
91  TString prodName = "pp_7TeV_GJ",
92  TString fileName = "Merged",
93  TString listName = "CTC_EMCAL_Trig_default_ClV1_Ecell100_Eseed500_SPDPileUp",
94  Int_t bin = -1
95  )
96 {
97  printf("production %s, file %s, list %s\n",prodName.Data(),fileName.Data(),listName.Data());
98 
99  if ( bin < 0 )
100  for(Int_t i = 0; i < 20; i++) ForBin(i,prodName,fileName,listName);
101  else
102  ForBin(bin,prodName,fileName,listName);
103 }
void ForBin(Int_t bin=-1, TString prodName="pp_7TeV_GJ", TString fileName="Merged", TString listName="CTC_EMCAL_Trig_default_ClV1_Ecell100_Eseed500_SPDPileUp")
double Double_t
Definition: External.C:58
TString fileName
void PrintScaleFactors(TString prodName="pp_7TeV_GJ", TString fileName="Merged", TString listName="CTC_EMCAL_Trig_default_ClV1_Ecell100_Eseed500_SPDPileUp", Int_t bin=-1)
int Int_t
Definition: External.C:63
float Float_t
Definition: External.C:68
Double_t nEvents
plot quality messages