]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/AliCentralCorrSecondaryMap.cxx
Fix histogram names in central corrections task.
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliCentralCorrSecondaryMap.cxx
1 //
2 // This class contains the secondary correction 
3 // for the central region
4 //
5 #include "AliCentralCorrSecondaryMap.h"
6 #include <TBrowser.h>
7 #include <TH2D.h>
8 #include <AliLog.h>
9 #include <iostream>
10
11 //____________________________________________________________________
12 AliCentralCorrSecondaryMap::AliCentralCorrSecondaryMap()
13   : fArray(), 
14     fVertexAxis(0,0,0)
15 {
16   // 
17   // Default constructor 
18   //
19   fArray.SetOwner(kTRUE);
20   fArray.SetName("rings");
21   fVertexAxis.SetName("vtxAxis");
22   fVertexAxis.SetTitle("v_{z} [cm]");
23   
24 }
25 //____________________________________________________________________
26 AliCentralCorrSecondaryMap::AliCentralCorrSecondaryMap(const 
27                                                AliCentralCorrSecondaryMap& o)
28   : TObject(o), 
29     fArray(o.fArray), 
30     fVertexAxis(o.fVertexAxis.GetNbins(), o.fVertexAxis.GetXmin(), 
31                 o.fVertexAxis.GetXmax())
32 {
33   // 
34   // Copy constructor 
35   // 
36   // Parameters:
37   //    o Object to copy from 
38   //
39   fVertexAxis.SetName("vtxAxis");
40   fVertexAxis.SetTitle("v_{z} [cm]");
41 }
42 //____________________________________________________________________
43 AliCentralCorrSecondaryMap::~AliCentralCorrSecondaryMap()
44 {
45   //
46   // Destructor 
47   // 
48   //
49   fArray.Clear();
50 }
51 //____________________________________________________________________
52 AliCentralCorrSecondaryMap&
53 AliCentralCorrSecondaryMap::operator=(const AliCentralCorrSecondaryMap& o)
54 {
55   // 
56   // Assignment operator 
57   // 
58   // Parameters:
59   //    o Object to assign from 
60   // 
61   // Return:
62   //    Reference to this object 
63   //
64   fArray        = o.fArray;
65   SetVertexAxis(o.fVertexAxis);
66
67   return *this;
68 }
69 //____________________________________________________________________
70 TH2D*
71 AliCentralCorrSecondaryMap::GetCorrection(Double_t v) const
72 {
73   // 
74   // Get the acceptance correction @f$ a_{r,v}@f$ 
75   // 
76   // Parameters:
77   //    d  Detector number (1-3)
78   //    r  Ring identifier (I or O)
79   //    v  Primary interaction point @f$z@f$ coordinate
80   // 
81   // Return:
82   //    The correction @f$ a_{r,v}@f$ 
83   //
84   Int_t b = FindVertexBin(v);
85   if (b <= 0) return 0;
86   return GetCorrection(UShort_t(b));
87 }
88 //____________________________________________________________________
89 TH2D*
90 AliCentralCorrSecondaryMap::GetCorrection(UShort_t b) const
91 {
92   // 
93   // Get the acceptance correction @f$ a_{r,v}@f$ 
94   // 
95   // Parameters:
96   //    d  Detector number (1-3)
97   //    r  Ring identifier (I or O)
98   //    b  Bin corresponding to the primary interaction point 
99   //           @f$z@f$ coordinate (1 based)
100   // 
101   // Return:
102   //    The correction @f$ a_{r,v}@f$ 
103   //
104   
105   TObject* o = fArray.At(b-1);
106   if (!o) { 
107     AliWarning(Form("No dead channels map found for SPD in vertex bin %d",
108                     b));
109     return 0;
110   }
111   return static_cast<TH2D*>(o);
112 }
113   
114 //____________________________________________________________________
115 Int_t
116 AliCentralCorrSecondaryMap::FindVertexBin(Double_t v) const
117 {
118   // 
119   // Find the vertex bin that corresponds to the passed vertex 
120   // 
121   // Parameters:
122   //    vertex The interaction points @f$z@f$-coordinate 
123   // 
124   // Return:
125   //    Vertex bin in @f$[1,N_{\mbox{vertex}}]@f$ or negative if 
126   // out of range 
127   //
128   if (fVertexAxis.GetNbins() <= 0) { 
129     AliWarning("No vertex array defined");
130     return 0;
131   }
132   Int_t bin = const_cast<TAxis&>(fVertexAxis).FindBin(v);
133   if (bin <= 0 || bin > fVertexAxis.GetNbins()) { 
134     AliWarning(Form("vertex %+8.4f out of range [%+8.4f,%+8.4f]",
135                     v, fVertexAxis.GetXmin(), fVertexAxis.GetXmax()));
136     return 0;
137   }
138   return bin;
139 }
140
141 //____________________________________________________________________
142 Bool_t
143 AliCentralCorrSecondaryMap::SetCorrection(UShort_t b, TH2D*  h) 
144 {
145   // 
146   // Set the acceptance correction @f$ a_{r,v}(\eta)@f$ 
147   // Note, that the object takes ownership of the passed pointer.
148   // 
149   // Parameters:
150   //    d    Detector number (1-3)
151   //    r    Ring identifier (I or O)
152   //    b    Bin corresponding to the primary interaction point 
153   //             @f$z@f$ coordinate  (1 based)
154   //    h    @f$ a_{r,v}(\eta)@f$ 
155   // 
156   // Return:
157   //    true if operation succeeded 
158   //
159   
160   if (b <= 0 || b > fVertexAxis.GetNbins()) { 
161     AliWarning(Form("Vertex bin %3d out of range [1,%3d]", 
162                     b, fVertexAxis.GetNbins()));
163     return false;
164   }
165   h->SetName(Form("sec_vtxbin%03d", b));
166   h->SetTitle(Form("Secondary correction [%+5.1f<v_{z}<%+5.1f]", 
167                    fVertexAxis.GetBinLowEdge(b), 
168                    fVertexAxis.GetBinUpEdge(b)));
169   h->SetXTitle("#eta");
170   h->SetYTitle("#varphi [radians]");
171   h->SetZTitle("dN_{ch}/d#eta / #sum_{i} N_{ch,i}");
172   h->SetFillStyle(3001);
173   h->SetFillColor(kRed+1);
174   h->SetMarkerStyle(20);
175   h->SetMarkerColor(kRed+1);
176   h->SetDirectory(0);
177   h->SetStats(0);
178   fArray.AddAtAndExpand(h, b-1);
179   return kTRUE;
180 }
181 //____________________________________________________________________
182 Bool_t
183 AliCentralCorrSecondaryMap::SetCorrection(Double_t v, TH2D*  h) 
184 {
185   // 
186   // Set the acceptance correction @f$ a_{r,v}(\eta)@f$.
187   // Note, that the object takes ownership of the passed pointer.
188   // 
189   // Parameters:
190   //    d    Detector number (1-3)
191   //    r    Ring identifier (I or O)
192   //    v    Primary interaction point @f$z@f$ coordinate  
193   //    h    @f$ a_{r,v}(\eta)@f$ 
194   // 
195   // Return:
196   //    true if operation succeeded 
197   //
198   Int_t b = FindVertexBin(v);
199   if (b <= 0 || b > fVertexAxis.GetNbins()) { 
200     AliWarning(Form("Vertex %+8.4f out of range [%+8.4f,%+8.4f]", 
201                     v, fVertexAxis.GetXmin(), fVertexAxis.GetXmax()));
202     return false;
203   }
204   return SetCorrection( UShort_t(b), h);
205 }
206 //____________________________________________________________________
207 void
208 AliCentralCorrSecondaryMap::Browse(TBrowser* b)
209 {
210   // 
211   // Browse this object in the browser
212   // 
213   // Parameters:
214   //    b 
215   //
216   b->Add(&fArray);
217   b->Add(&fVertexAxis);
218 }
219 //____________________________________________________________________
220 void
221 AliCentralCorrSecondaryMap::Print(Option_t* /* option */) const
222 {
223   // 
224   // Print this object 
225   // 
226   // Parameters:
227   //    option 
228   //  
229   std::cout << "  SecondaryMap correction\n" 
230             << "   # of vertex bins: "  << fVertexAxis.GetNbins() << "\n"
231             << "   Vertex range:     [" << fVertexAxis.GetXmin() 
232             << "," << fVertexAxis.GetXmax() << "]\n" 
233             << "   Histograms:\n"
234             << "    ";
235   TIter next(&fArray);
236   TObject* o = 0;
237   while ((o = next())) std::cout << o->GetName() << " ";
238   std::cout << std::endl;
239 }
240     
241 //____________________________________________________________________
242 //
243 // EOF
244 //