AliPhysics  2c6b7ad (2c6b7ad)
MakeCorrSecMap.C
Go to the documentation of this file.
1 //____________________________________________________________________
14 Bool_t
15 MakeSecMap(TList* list, Double_t low, Double_t high,
17 {
18  // --- Get the list ------------------------------------------------
20  TList* vl = static_cast<TList*>(list->FindObject(lName));
21  if (!vl) {
22  Error("MakeSecMap", "List %s not found in %s",
23  lName.Data(), list->GetName());
24  return false;
25  }
26 
27  // --- Get primary distribution ------------------------------------
28  const char* primaryName = "primary";
29  TH2D* primary = static_cast<TH2D*>(vl->FindObject(primaryName));
30  if (!primary) {
31  Error("MakeSecMap", "Couldn't not find histogram %s in %s",
32  primaryName, lName.Data());
33  return false;
34  }
35  TH2D* primaryI = static_cast<TH2D*>(primary->Clone("primaryI"));
36  TH2D* primaryO = static_cast<TH2D*>(primary->Clone("primaryO"));
37  primaryI->SetDirectory(0);
38  primaryO->SetDirectory(0);
39  primaryI->RebinY(2);
40 
41 
42  // --- Calculate vertex --------------------------------------------
43  Double_t vz = (high+low) / 2;
44 
45  // --- Loop over rings ---------------------------------------------
46  for (UShort_t d = 1; d <= 3; d++) {
47  UShort_t nr = (d == 1 ? 1 : 2);
48  for (UShort_t q = 0; q < nr; q++) {
49  Char_t r = (q == 0 ? 'I' : 'O');
50 
51  const char* ringName = Form("FMD%d%c_cache", d, r);
52  TH2D* ring = static_cast<TH2D*>(vl->FindObject(ringName));
53  if (!ring) {
54  Error("MakeSecMap", "Didn't find histogram %s in %s",
55  ringName, vl->GetName());
56  vl->ls();
57  continue;
58  }
59 
60  TH2D* tmp = static_cast<TH2D*>(ring->Clone("tmp"));
61  TString tmpName = tmp->GetName();
62  tmpName.ReplaceAll("_cache", "");
63  tmp->SetName(tmpName);
64  tmp->SetDirectory(0);
65  tmp->Divide(q == 0 ? primaryI : primaryO);
66 
67 
68  m->SetCorrection(d, r, vz, tmp);
69  }
70  }
71  return true;
72 }
73 
74 //____________________________________________________________________
85 void
86 MakeCorrSecMap(const char* filename,
87  const char* sys="pp",
88  UShort_t cms=900,
89  Short_t field=+5)
90 {
91  // --- Load code ---------------------------------------------------
92  // gROOT->Macro("$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C");
93 
94 
95  // --- Get the file ------------------------------------------------
96  TFile* file = TFile::Open(filename, "READ");
97  if (!file) {
98  Error("MakeCorrSecMap", "Couldn't open file %s", filename);
99  return;
100  }
101 
102  // --- Get the parent list -----------------------------------------
103  const char* forwardName = "ForwardSums";
104  TList* forward = static_cast<TList*>(file->Get(forwardName));
105  if (!forward) {
106  Error("MakeCorrSecMap", "Couldn't get list %s from %s",
107  forwardName, filename);
108  return;
109  }
110 
111  // --- Get the vertex axis -----------------------------------------
112  const char* vtxName = "vtxAxis";
113  TH1* vtxHist = static_cast<TH1*>(forward->FindObject(vtxName));
114  if (!vtxHist) {
115  Error("MakeCorrSecMap", "Couldn't get histogram %s from %s",
116  vtxName, forwardName);
117  return;
118  }
119  const TAxis& vtxAxis = *(vtxHist->GetXaxis());
120 
121  // --- Get the vertex axis -----------------------------------------
122  const char* etaName = "etaAxis";
123  TH1* etaHist = static_cast<TH1*>(forward->FindObject(etaName));
124  if (!etaHist) {
125  Error("MakeCorrSecMap", "Couldn't get histogram %s from %s",
126  etaName, forwardName);
127  return;
128  }
129  const TAxis& etaAxis = *(etaHist->GetXaxis());
130 
131  // --- Fill correction object --------------------------------------
133  corr->SetVertexAxis(vtxAxis);
134  corr->SetEtaAxis(etaAxis);
135 
136  for (Int_t i = 1; i <= vtxAxis.GetNbins(); i++) {
137  Double_t low = vtxAxis.GetBinLowEdge(i);
138  Double_t high = vtxAxis.GetBinUpEdge(i);
139 
140  MakeSecMap(forward, low, high, corr);
141  }
142 
143  // --- Get output filename and open --------------------------------
147  isys, cms, field, false));
148  TFile* output = TFile::Open(fname.Data(), "RECREATE");
149  if (!output) {
150  Warning("Run", "Failed to open output file %s", fname.Data());
151  return kFALSE;
152  }
153 
154  // --- Write to output ---------------------------------------------
156  output->Write();
157  output->Close();
158  Info("Run", "File %s created. It should be copied to %s and stored in SVN",
159  fname.Data(),mgr.GetFileDir(AliForwardCorrectionManager::kSecondaryMap));
160 
161 }
162 //____________________________________________________________________
163 //
164 // EOF
165 //
166 
Bool_t SetCorrection(UShort_t d, Char_t r, Double_t v, TH2D *h)
const char * filename
Definition: TestFCM.C:1
double Double_t
Definition: External.C:58
char Char_t
Definition: External.C:18
Bool_t MakeSecMap(TList *list, Double_t low, Double_t high, AliFMDCorrSecondaryMap *m)
int Int_t
Definition: External.C:63
static const char * BinName(Double_t low, Double_t high)
void SetVertexAxis(const TAxis &axis)
Definition: External.C:228
void MakeCorrSecMap(const char *filename, const char *sys="pp", UShort_t cms=900, Short_t field=+5)
const char * GetObjectName(Int_t what) const
short Short_t
Definition: External.C:23
static UShort_t ParseCollisionSystem(const char *sys)
TFile * file
TList with histograms for a given trigger.
unsigned short UShort_t
Definition: External.C:28
void SetEtaAxis(const TAxis &axis)
bool Bool_t
Definition: External.C:53
Definition: External.C:196
static AliForwardCorrectionManager & Instance()