2 // Class that contains the forward multiplicity data per event
4 // This class contains a histogram of
6 // \frac{d^2N_{ch}}{d\eta d\phi}\quad,
8 // as well as a trigger mask for each analysed event.
10 // The eta acceptance of the event is stored in the underflow bins of
11 // the histogram. So to build the final histogram, one needs to
12 // correct for this acceptance (properly weighted by the events), and
13 // the vertex efficiency. This simply boils down to defining a 2D
14 // histogram and summing the event histograms in that histogram. One
15 // should of course also do proper book-keeping of the accepted event.
17 #include "AliAODForwardMult.h"
21 #include <TObjString.h>
22 #include <TObjArray.h>
24 ClassImp(AliAODForwardMult)
29 //____________________________________________________________________
30 const Float_t AliAODForwardMult::fgkInvalidIpZ = 1e6;
32 //____________________________________________________________________
33 AliAODForwardMult::AliAODForwardMult()
45 //____________________________________________________________________
46 AliAODForwardMult::AliAODForwardMult(Bool_t isMC)
48 fHist("forwardMult", "d^{2}N_{ch}/d#etad#varphi in the forward regions",
49 200, -4, 6, 20, 0, 2*TMath::Pi()),
58 // isMC If set to true this is for MC data (effects branch name)
60 fHist.SetXTitle("#eta");
61 fHist.SetYTitle("#varphi [radians]");
62 fHist.SetZTitle("#frac{d^{2}N_{ch}}{d#etad#varphi}");
63 fHist.SetDirectory(0);
67 //____________________________________________________________________
69 AliAODForwardMult::Init(const TAxis& etaAxis)
71 // Initialize the histogram with an eta axis
74 // etaAxis Eta axis to use
76 fHist.SetBins(etaAxis.GetNbins(), etaAxis.GetXmin(), etaAxis.GetXmax(),
77 20, 0, 2*TMath::Pi());
80 //____________________________________________________________________
82 AliAODForwardMult::Clear(Option_t* option)
84 // Clear (or reset) internal values
87 // option Passed to TH1::Reset
93 //____________________________________________________________________
95 AliAODForwardMult::SetSNN(UShort_t snn)
97 // set the center of mass energy per nucleon pair (GeV).
98 // This is stored in bin (0,0) of the histogram
101 // sNN Center of mass energy per nuclean
102 fHist.SetBinContent(0,0,snn);
104 //____________________________________________________________________
106 AliAODForwardMult::SetSystem(UShort_t sys)
108 // set the center of mass energy per nucleon pair (GeV).
109 // This is stored in bin (N+1,0) of the histogram
112 // sys Collision system number
113 fHist.SetBinContent(fHist.GetNbinsX()+1,0,sys);
116 //____________________________________________________________________
118 AliAODForwardMult::HasIpZ() const
120 // Check if we have valid z coordinate of the interaction point
123 // true if the z coordinate of the interaction point is valid
125 return TMath::Abs(fIpZ - fgkInvalidIpZ) > 1;
128 //____________________________________________________________________
130 AliAODForwardMult::GetSNN() const
132 // set the center of mass energy per nucleon pair (GeV).
133 // This is stored in bin (0,0) of the histogram
136 // sNN Center of mass energy per nuclean
137 return UShort_t(fHist.GetBinContent(0,0));
140 //____________________________________________________________________
142 AliAODForwardMult::GetSystem() const
144 // set the center of mass energy per nucleon pair (GeV).
145 // This is stored in bin (N+1,0) of the histogram
148 // sNN Center of mass energy per nuclean
149 return UShort_t(fHist.GetBinContent(fHist.GetNbinsX()+1,0));
152 //____________________________________________________________________
154 AliAODForwardMult::Browse(TBrowser* b)
156 // Browse this object
160 static TObjString ipz;
161 static TObjString trg;
162 static TObjString cnt;
163 ipz = Form("ip_z=%fcm", fIpZ);
164 trg = GetTriggerString(fTriggers);
165 cnt = Form("%+6.1f%%", fCentrality);
172 //____________________________________________________________________
174 AliAODForwardMult::GetTriggerString(UInt_t mask)
176 // Get a string that describes the triggers
179 // mask Bit pattern of triggers
181 // Character string representation of mask
184 if ((mask & kInel) != 0x0) trg.Append("INEL ");
185 if ((mask & kInelGt0) != 0x0) trg.Append("INEL>0 ");
186 if ((mask & kNSD) != 0x0) trg.Append("NSD ");
187 if ((mask & kA) != 0x0) trg.Append("A ");
188 if ((mask & kB) != 0x0) trg.Append("B ");
189 if ((mask & kC) != 0x0) trg.Append("C ");
190 if ((mask & kE) != 0x0) trg.Append("E ");
191 if ((mask & kMCNSD) != 0x0) trg.Append("MCNSD ");
195 //____________________________________________________________________
197 AliAODForwardMult::MakeTriggerHistogram(const char* name)
200 // Make a histogram to record triggers in.
202 // The bins defined by the trigger enumeration in this class. One
203 // can use this enumeration to retrieve the number of triggers for
207 // name Name of the histogram
210 // Newly allocated histogram
212 TH1I* ret = new TH1I(name, "Triggers", kAccepted+1, -.5, kAccepted+.5);
213 ret->SetYTitle("Events");
214 ret->SetFillColor(kRed+1);
215 ret->SetFillStyle(3001);
216 ret->GetXaxis()->SetBinLabel(kBinAll, "All events");
217 ret->GetXaxis()->SetBinLabel(kBinB, "w/B trigger");
218 ret->GetXaxis()->SetBinLabel(kBinA, "w/A trigger");
219 ret->GetXaxis()->SetBinLabel(kBinC, "w/C trigger");
220 ret->GetXaxis()->SetBinLabel(kBinE, "w/E trigger");
221 ret->GetXaxis()->SetBinLabel(kBinInel, "Minimum Bias");
222 ret->GetXaxis()->SetBinLabel(kBinInelGt0, "INEL>0");
223 ret->GetXaxis()->SetBinLabel(kBinNSD, "NSD");
224 ret->GetXaxis()->SetBinLabel(kBinMCNSD, "NSD (MC truth)");
225 ret->GetXaxis()->SetBinLabel(kBinPileUp, "w/Pileup");
226 ret->GetXaxis()->SetBinLabel(kBinOffline, "w/Offline");
227 ret->GetXaxis()->SetBinLabel(kWithVertex, "w/Vertex");
228 ret->GetXaxis()->SetBinLabel(kWithTrigger, "w/Selected trigger");
229 ret->GetXaxis()->SetBinLabel(kAccepted, "Accepted by cut");
230 ret->GetXaxis()->SetNdivisions(kAccepted, false);
235 //____________________________________________________________________
237 AliAODForwardMult::MakeTriggerMask(const char* what)
239 UShort_t trgMask = 0;
243 TIter next(trgs.Tokenize(" ,|"));
244 while ((trg = static_cast<TObjString*>(next()))) {
245 TString s(trg->GetString());
246 if (s.IsNull()) continue;
247 if (s.CompareTo("INEL") == 0) trgMask |= AliAODForwardMult::kInel;
248 else if (s.CompareTo("INEL>0")== 0) trgMask |= AliAODForwardMult::kInelGt0;
249 else if (s.CompareTo("NSD") == 0) trgMask |= AliAODForwardMult::kNSD;
251 AliWarningGeneral("MakeTriggerMask",
252 Form("Unknown trigger %s", s.Data()));
257 //____________________________________________________________________
259 AliAODForwardMult::CheckEvent(Int_t triggerMask,
260 Double_t vzMin, Double_t vzMax,
261 UShort_t cMin, UShort_t cMax,
265 // Check if event meets the passses requirements.
267 // It returns true if @e all of the following is true
269 // - The trigger is within the bit mask passed.
270 // - The vertex is within the specified limits.
271 // - The centrality is within the specified limits, or if lower
272 // limit is equal to or larger than the upper limit.
274 // If a histogram is passed in the last parameter, then that
275 // histogram is filled with the trigger bits.
278 // triggerMask Trigger mask
279 // vzMin Minimum @f$ v_z@f$ (in centimeters)
280 // vzMax Maximum @f$ v_z@f$ (in centimeters)
281 // cMin Minimum centrality (in percent)
282 // cMax Maximum centrality (in percent)
283 // hist Histogram to fill
286 // @c true if the event meets the requirements
288 if (cMin < cMax && (cMin > fCentrality || cMax <= fCentrality)) return false;
291 hist->AddBinContent(kBinAll);
292 if (IsTriggerBits(kB|triggerMask)) hist->AddBinContent(kBinB);
293 if (IsTriggerBits(kA|triggerMask)) hist->AddBinContent(kBinA);
294 if (IsTriggerBits(kC|triggerMask)) hist->AddBinContent(kBinC);
295 if (IsTriggerBits(kE|triggerMask)) hist->AddBinContent(kBinE);
296 if (IsTriggerBits(kB|kInel)) hist->AddBinContent(kBinInel);
297 if (IsTriggerBits(kB|kInelGt0)) hist->AddBinContent(kBinInelGt0);
298 if (IsTriggerBits(kB|kNSD)) hist->AddBinContent(kBinNSD);
299 if (IsTriggerBits(kPileUp)) hist->AddBinContent(kBinPileUp);
300 if (IsTriggerBits(kMCNSD)) hist->AddBinContent(kBinMCNSD);
301 if (IsTriggerBits(kOffline)) hist->AddBinContent(kBinOffline);
303 // Check if we have an event of interest.
304 if (!IsTriggerBits(triggerMask|kB)) return false;
307 if (IsTriggerBits(kPileUp)) return false;
308 if (hist) hist->AddBinContent(kWithTrigger);
310 // Check that we have a valid vertex
311 if (!HasIpZ()) return false;
312 if (hist) hist->AddBinContent(kWithVertex);
314 // Check that vertex is within cuts
315 if (!InRange(vzMin, vzMax)) return false;
316 if (hist) hist->AddBinContent(kAccepted);
321 //____________________________________________________________________
323 AliAODForwardMult::Print(Option_t* option) const
328 // option Passed to TH1::Print
330 UShort_t sys = GetSystem();
331 TString str = "unknown";
333 case 1: str = "pp"; break;
334 case 2: str = "PbPb"; break;
336 std::cout << "Ipz: " << fIpZ << "cm " << (HasIpZ() ? "" : "in")
338 << "Triggers: " << GetTriggerString(fTriggers)
339 << "sNN: " << GetSNN() << "GeV\n"
341 << "Centrality: " << fCentrality << "%"
345 //____________________________________________________________________