Fix Coverity
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AliFMDEventInspector.cxx
CommitLineData
7984e5f7 1//
2// This class inspects the event
3//
4// Input:
5// - AliESDFMD object possibly corrected for sharing
6//
7// Output:
8// - A histogram of v_z of events with triggers.
9// - A histogram of v_z of events with vertex and triggers
10// - A histogram of trigger counters
11//
12// Note, that these are added to the master output list
13//
14// Corrections used:
15// - None
16//
8565b10b 17#include "AliFMDEventInspector.h"
18#include "AliLog.h"
19#include "AliESDEvent.h"
20#include "AliMultiplicity.h"
21#include "AliAnalysisManager.h"
11d40ecb 22#include "AliMCEventHandler.h"
8565b10b 23#include "AliInputEventHandler.h"
24#include "AliTriggerAnalysis.h"
25#include "AliPhysicsSelection.h"
26#include "AliAODForwardMult.h"
0bd4b00f 27#include "AliForwardUtil.h"
5e4d905e 28#include "AliCentrality.h"
8565b10b 29#include <TH1.h>
30#include <TList.h>
31#include <TDirectory.h>
0bd4b00f 32#include <TROOT.h>
33#include <iostream>
34#include <iomanip>
e1f47419 35
8565b10b 36//====================================================================
37AliFMDEventInspector::AliFMDEventInspector()
38 : TNamed(),
39 fHEventsTr(0),
40 fHEventsTrVtx(0),
5bb5d1f6 41 fHEventsAccepted(0),
96110c91 42 fHEventsAcceptedXY(0),
8565b10b 43 fHTriggers(0),
0bd4b00f 44 fHType(0),
fe52e455 45 fHWords(0),
5e4d905e 46 fHCent(0),
e308a636 47 fHCentVsQual(0),
8565b10b 48 fLowFluxCut(1000),
9d05ffeb 49 fMaxVzErr(0.2),
8565b10b 50 fList(0),
0bd4b00f 51 fEnergy(0),
52 fField(999),
53 fCollisionSystem(kUnknown),
e308a636 54 fDebug(0),
5bb5d1f6 55 fCentAxis(0),
e83d0620 56 fVtxAxis(10,-10,10),
31554871 57 fUseFirstPhysicsVertex(true),
58 fUseV0AND(false)
8565b10b 59{
7984e5f7 60 //
61 // Constructor
62 //
8565b10b 63}
64
65//____________________________________________________________________
66AliFMDEventInspector::AliFMDEventInspector(const char* name)
67 : TNamed("fmdEventInspector", name),
68 fHEventsTr(0),
69 fHEventsTrVtx(0),
5bb5d1f6 70 fHEventsAccepted(0),
96110c91 71 fHEventsAcceptedXY(0),
8565b10b 72 fHTriggers(0),
0bd4b00f 73 fHType(0),
fe52e455 74 fHWords(0),
5e4d905e 75 fHCent(0),
e308a636 76 fHCentVsQual(0),
8565b10b 77 fLowFluxCut(1000),
9d05ffeb 78 fMaxVzErr(0.2),
8565b10b 79 fList(0),
0bd4b00f 80 fEnergy(0),
81 fField(999),
82 fCollisionSystem(kUnknown),
e308a636 83 fDebug(0),
5bb5d1f6 84 fCentAxis(0),
e83d0620 85 fVtxAxis(10,-10,10),
31554871 86 fUseFirstPhysicsVertex(true),
87 fUseV0AND(false)
8565b10b 88{
7984e5f7 89 //
90 // Constructor
91 //
92 // Parameters:
93 // name Name of object
94 //
8565b10b 95}
96
97//____________________________________________________________________
98AliFMDEventInspector::AliFMDEventInspector(const AliFMDEventInspector& o)
99 : TNamed(o),
100 fHEventsTr(o.fHEventsTr),
101 fHEventsTrVtx(o.fHEventsTrVtx),
5bb5d1f6 102 fHEventsAccepted(o.fHEventsAccepted),
96110c91 103 fHEventsAcceptedXY(o.fHEventsAcceptedXY),
8565b10b 104 fHTriggers(o.fHTriggers),
0bd4b00f 105 fHType(o.fHType),
fe52e455 106 fHWords(o.fHWords),
5e4d905e 107 fHCent(o.fHCent),
e308a636 108 fHCentVsQual(o.fHCentVsQual),
6feacd76 109 fLowFluxCut(o.fLowFluxCut),
8565b10b 110 fMaxVzErr(o.fMaxVzErr),
111 fList(o.fList),
0bd4b00f 112 fEnergy(o.fEnergy),
113 fField(o.fField),
114 fCollisionSystem(o.fCollisionSystem),
e308a636 115 fDebug(0),
5bb5d1f6 116 fCentAxis(0),
e83d0620 117 fVtxAxis(o.fVtxAxis),
31554871 118 fUseFirstPhysicsVertex(o.fUseFirstPhysicsVertex),
119 fUseV0AND(o.fUseV0AND)
8565b10b 120{
7984e5f7 121 //
122 // Copy constructor
123 //
124 // Parameters:
125 // o Object to copy from
126 //
8565b10b 127}
128
129//____________________________________________________________________
130AliFMDEventInspector::~AliFMDEventInspector()
131{
7984e5f7 132 //
133 // Destructor
134 //
8565b10b 135 if (fList) delete fList;
136}
137//____________________________________________________________________
138AliFMDEventInspector&
139AliFMDEventInspector::operator=(const AliFMDEventInspector& o)
140{
7984e5f7 141 //
142 // Assignement operator
143 //
144 // Parameters:
145 // o Object to assign from
146 //
147 // Return:
148 // Reference to this object
149 //
d015ecfe 150 if (&o == this) return *this;
8565b10b 151 TNamed::operator=(o);
152 fHEventsTr = o.fHEventsTr;
153 fHEventsTrVtx = o.fHEventsTrVtx;
5bb5d1f6 154 fHEventsAccepted = o.fHEventsAccepted;
96110c91 155 fHEventsAcceptedXY = o.fHEventsAcceptedXY;
8565b10b 156 fHTriggers = o.fHTriggers;
0bd4b00f 157 fHType = o.fHType;
fe52e455 158 fHWords = o.fHWords;
5e4d905e 159 fHCent = o.fHCent;
e308a636 160 fHCentVsQual = o.fHCentVsQual;
8565b10b 161 fLowFluxCut = o.fLowFluxCut;
162 fMaxVzErr = o.fMaxVzErr;
163 fDebug = o.fDebug;
164 fList = (o.fList ? new TList : 0);
0bd4b00f 165 fEnergy = o.fEnergy;
166 fField = o.fField;
167 fCollisionSystem = o.fCollisionSystem;
5bb5d1f6 168 fVtxAxis.Set(o.fVtxAxis.GetNbins(), o.fVtxAxis.GetXmin(),
169 o.fVtxAxis.GetXmax());
e83d0620 170
171 fUseFirstPhysicsVertex = o.fUseFirstPhysicsVertex;
31554871 172 fUseV0AND = o.fUseV0AND;
e83d0620 173
8565b10b 174 if (fList) {
175 fList->SetName(GetName());
176 if (fHEventsTr) fList->Add(fHEventsTr);
177 if (fHEventsTrVtx) fList->Add(fHEventsTrVtx);
178 if (fHTriggers) fList->Add(fHTriggers);
0bd4b00f 179 if (fHType) fList->Add(fHType);
fe52e455 180 if (fHWords) fList->Add(fHWords);
5e4d905e 181 if (fHCent) fList->Add(fHCent);
e308a636 182 if (fHCentVsQual) fList->Add(fHCentVsQual);
8565b10b 183 }
184 return *this;
185}
186
187//____________________________________________________________________
188Bool_t
fb3430ac 189AliFMDEventInspector::FetchHistograms(const TList* d,
8565b10b 190 TH1I*& hEventsTr,
191 TH1I*& hEventsTrVtx,
192 TH1I*& hTriggers) const
193{
7984e5f7 194 //
195 // Fetch our histograms from the passed list
196 //
197 // Parameters:
198 // d Input
199 // hEventsTr On return, pointer to histogram, or null
200 // hEventsTrVtx On return, pointer to histogram, or null
201 // hTriggers On return, pointer to histogram, or null
202 //
203 // Return:
204 // true on success, false otherwise
205 //
8565b10b 206 hEventsTr = 0;
207 hEventsTrVtx = 0;
208 hTriggers = 0;
209 TList* dd = dynamic_cast<TList*>(d->FindObject(GetName()));
210 if (!dd) return kFALSE;
211
212 hEventsTr = dynamic_cast<TH1I*>(dd->FindObject("nEventsTr"));
213 hEventsTrVtx = dynamic_cast<TH1I*>(dd->FindObject("nEventsTrVtx"));
214 hTriggers = dynamic_cast<TH1I*>(dd->FindObject("triggers"));
215
216 if (!hEventsTr || !hEventsTrVtx || !hTriggers) return kFALSE;
217 return kTRUE;
218}
219//____________________________________________________________________
220void
221AliFMDEventInspector::Init(const TAxis& vtxAxis)
222{
7984e5f7 223 //
224 // Initialize the object
225 //
226 // Parameters:
227 // vtxAxis Vertex axis in use
228 //
e308a636 229
230 // -1.5 -0.5 0.5 1.5 ... 89.5 ... 100.5
231 // ----- 92 number --------- ---- 1 ---
232 TArrayD limits(93);
233 for (Int_t i = 0; i < 92; i++) limits[i] = -1.5 + i;
d8244e9e 234 limits[92] = 100.5;
5bb5d1f6 235
236 fVtxAxis.Set(vtxAxis.GetNbins(), vtxAxis.GetXmin(), vtxAxis.GetXmax());
e308a636 237
238 fCentAxis = new TAxis(limits.GetSize()-1, limits.GetArray());
8565b10b 239 fHEventsTr = new TH1I("nEventsTr", "Number of events w/trigger",
5bb5d1f6 240 4*vtxAxis.GetNbins(),
241 2*vtxAxis.GetXmin(),
242 2*vtxAxis.GetXmax());
8565b10b 243 fHEventsTr->SetXTitle("v_{z} [cm]");
244 fHEventsTr->SetYTitle("# of events");
245 fHEventsTr->SetFillColor(kRed+1);
246 fHEventsTr->SetFillStyle(3001);
247 fHEventsTr->SetDirectory(0);
248 // fHEventsTr->Sumw2();
249 fList->Add(fHEventsTr);
250
5bb5d1f6 251 fHEventsTrVtx = static_cast<TH1I*>(fHEventsTr->Clone("nEventsTrVtx"));
252 fHEventsTrVtx->SetTitle("Number of events w/trigger and vertex");
8565b10b 253 fHEventsTrVtx->SetFillColor(kBlue+1);
8565b10b 254 fHEventsTrVtx->SetDirectory(0);
255 // fHEventsTrVtx->Sumw2();
256 fList->Add(fHEventsTrVtx);
257
5bb5d1f6 258 fHEventsAccepted = new TH1I("nEventsAccepted",
259 "Number of events w/trigger and vertex in range",
260 2*vtxAxis.GetNbins(),
261 2*vtxAxis.GetXmin(),
262 2*vtxAxis.GetXmax());
263 fHEventsAccepted->SetXTitle("v_{z} [cm]");
264 fHEventsAccepted->SetYTitle("# of events");
265 fHEventsAccepted->SetFillColor(kGreen+1);
266 fHEventsAccepted->SetFillStyle(3001);
267 fHEventsAccepted->SetDirectory(0);
268 // fHEventsAccepted->Sumw2();
269 fList->Add(fHEventsAccepted);
270
96110c91 271 fHEventsAcceptedXY = new TH2D("nEventsAcceptedXY",
272 "XY vertex w/trigger and Z vertex in range",
273 1000,-1,1,1000,-1,1);
274
275 fHEventsAcceptedXY->SetXTitle("v_{x} [cm]");
276 fHEventsAcceptedXY->SetYTitle("v_{y} [cm]");
277 fHEventsAcceptedXY->SetDirectory(0);
278 // fHEventsAccepted->Sumw2();
279 fList->Add(fHEventsAcceptedXY);
280
281
0be6c8cd 282 fHTriggers = new TH1I("triggers", "Triggers", kOffline+1, 0, kOffline+1);
8565b10b 283 fHTriggers->SetFillColor(kRed+1);
284 fHTriggers->SetFillStyle(3001);
285 fHTriggers->SetStats(0);
286 fHTriggers->SetDirectory(0);
287 fHTriggers->GetXaxis()->SetBinLabel(kInel +1,"INEL");
288 fHTriggers->GetXaxis()->SetBinLabel(kInelGt0+1,"INEL>0");
289 fHTriggers->GetXaxis()->SetBinLabel(kNSD +1,"NSD");
290 fHTriggers->GetXaxis()->SetBinLabel(kEmpty +1,"Empty");
291 fHTriggers->GetXaxis()->SetBinLabel(kA +1,"A");
292 fHTriggers->GetXaxis()->SetBinLabel(kB +1,"B");
293 fHTriggers->GetXaxis()->SetBinLabel(kC +1,"C");
294 fHTriggers->GetXaxis()->SetBinLabel(kE +1,"E");
e58000b7 295 fHTriggers->GetXaxis()->SetBinLabel(kPileUp +1,"Pileup");
0be6c8cd 296 fHTriggers->GetXaxis()->SetBinLabel(kMCNSD +1,"NSD_{MC}");
297 fHTriggers->GetXaxis()->SetBinLabel(kOffline+1,"Offline");
8565b10b 298 fList->Add(fHTriggers);
0bd4b00f 299
300 fHType = new TH1I("type", Form("Event type (cut: SPD mult>%d)",
301 fLowFluxCut), 2, -.5, 1.5);
302 fHType->SetFillColor(kRed+1);
303 fHType->SetFillStyle(3001);
304 fHType->SetStats(0);
305 fHType->SetDirectory(0);
306 fHType->GetXaxis()->SetBinLabel(1,"Low-flux");
307 fHType->GetXaxis()->SetBinLabel(2,"High-flux");
308 fList->Add(fHType);
fe52e455 309
c56f8519 310#if 0
311 // This histogram disabled as it causes problems in the merge
fe52e455 312 fHWords = new TH1I("words", "Trigger words seen", 1, 0, 0);
313 fHWords->SetFillColor(kBlue+1);
314 fHWords->SetFillStyle(3001);
315 fHWords->SetStats(0);
316 fHWords->SetDirectory(0);
317 fHWords->SetBit(TH1::kCanRebin);
318 fList->Add(fHWords);
c56f8519 319#endif
5e4d905e 320
e308a636 321 fHCent = new TH1F("cent", "Centrality", limits.GetSize()-1,limits.GetArray());
5e4d905e 322 fHCent->SetFillColor(kBlue+1);
323 fHCent->SetFillStyle(3001);
324 fHCent->SetStats(0);
325 fHCent->SetDirectory(0);
326 fHCent->SetXTitle("Centrality [%]");
327 fHCent->SetYTitle("Events");
328 fList->Add(fHCent);
e308a636 329
330 fHCentVsQual = new TH2F("centVsQuality", "Quality vs Centrality",
331 5, 0, 5, limits.GetSize()-1, limits.GetArray());
332 fHCentVsQual->SetXTitle("Quality");
333 fHCentVsQual->SetYTitle("Centrality [%]");
334 fHCentVsQual->SetZTitle("Events");
335 fHCentVsQual->GetXaxis()->SetBinLabel(1, "OK");
336 fHCentVsQual->GetXaxis()->SetBinLabel(2, "Outside v_{z} cut");
337 fHCentVsQual->GetXaxis()->SetBinLabel(3, "V0 vs SPD outlier");
338 fHCentVsQual->GetXaxis()->SetBinLabel(4, "V0 vs TPC outlier");
339 fHCentVsQual->GetXaxis()->SetBinLabel(5, "V0 vs ZDC outlier");
340 fList->Add(fHCentVsQual);
8565b10b 341}
342
f7cfc454 343//____________________________________________________________________
344void
9b2f2e39 345AliFMDEventInspector::StoreInformation(Int_t runNo)
f7cfc454 346{
347 // Write TNamed objects to output list containing information about
348 // the running conditions
349 if (!fList) return;
350
351 TNamed* sys = new TNamed("sys", "");
352 TNamed* sNN = new TNamed("sNN", "");
353 TNamed* fld = new TNamed("field", "");
9b2f2e39 354 TNamed* run = new TNamed("runNo", Form("%d", runNo));
f7cfc454 355 sys->SetTitle(AliForwardUtil::CollisionSystemString(fCollisionSystem));
356 sNN->SetTitle(AliForwardUtil::CenterOfMassEnergyString(fEnergy));
357 fld->SetTitle(AliForwardUtil::MagneticFieldString(fField));
358 sys->SetUniqueID(fCollisionSystem);
359 sNN->SetUniqueID(fEnergy);
360 fld->SetUniqueID(fField);
9b2f2e39 361 run->SetUniqueID(runNo);
f7cfc454 362
363 fList->Add(sys);
364 fList->Add(sNN);
365 fList->Add(fld);
9b2f2e39 366 fList->Add(run);
f7cfc454 367}
368
8565b10b 369//____________________________________________________________________
370void
371AliFMDEventInspector::DefineOutput(TList* dir)
372{
7984e5f7 373 //
374 // Define the output histograms. These are put in a sub list of the
375 // passed list. The histograms are merged before the parent task calls
376 // AliAnalysisTaskSE::Terminate
377 //
378 // dir Directory to add to
379 //
8565b10b 380 fList = new TList;
381 fList->SetName(GetName());
382 dir->Add(fList);
383}
384
385//____________________________________________________________________
386UInt_t
387AliFMDEventInspector::Process(const AliESDEvent* event,
388 UInt_t& triggers,
389 Bool_t& lowFlux,
0bd4b00f 390 UShort_t& ivz,
5e4d905e 391 Double_t& vz,
5bb5d1f6 392 Double_t& cent,
393 UShort_t& nClusters)
8565b10b 394{
7984e5f7 395 //
396 // Process the event
397 //
398 // Parameters:
399 // event Input event
400 // triggers On return, the triggers fired
401 // lowFlux On return, true if the event is considered a low-flux
402 // event (according to the setting of fLowFluxCut)
403 // ivz On return, the found vertex bin (1-based). A zero
404 // means outside of the defined vertex range
405 // vz On return, the z position of the interaction
5e4d905e 406 // cent On return, the centrality - if not available < 0
7984e5f7 407 //
408 // Return:
409 // 0 (or kOk) on success, otherwise a bit mask of error codes
410 //
411
e1f47419 412 // --- Check that we have an event ---------------------------------
8565b10b 413 if (!event) {
414 AliWarning("No ESD event found for input event");
415 return kNoEvent;
416 }
417
e1f47419 418 // --- Read trigger information from the ESD and store in AOD object
5bb5d1f6 419 if (!ReadTriggers(event, triggers, nClusters)) {
0bd4b00f 420 if (fDebug > 2) {
421 AliWarning("Failed to read triggers from ESD"); }
8565b10b 422 return kNoTriggers;
423 }
424
e1f47419 425 // --- Check if this is a high-flux event --------------------------
8565b10b 426 const AliMultiplicity* testmult = event->GetMultiplicity();
427 if (!testmult) {
0bd4b00f 428 if (fDebug > 3) {
429 AliWarning("No central multiplicity object found"); }
8565b10b 430 }
e1f47419 431 else
432 lowFlux = testmult->GetNumberOfTracklets() < fLowFluxCut;
5e4d905e 433
0bd4b00f 434 fHType->Fill(lowFlux ? 0 : 1);
5e4d905e 435
e1f47419 436 // --- Read centrality information
e308a636 437 cent = -10;
438 UShort_t qual = 0;
439 if (!ReadCentrality(event, cent, qual)) {
e1f47419 440 if (fDebug > 3)
441 AliWarning("Failed to get centrality");
8565b10b 442 }
e308a636 443 fHCent->Fill(cent);
444 if (qual == 0) fHCentVsQual->Fill(0., cent);
445 else {
446 for (UShort_t i = 0; i < 4; i++)
447 if (qual & (1 << i)) fHCentVsQual->Fill(Double_t(i+1), cent);
448 }
8565b10b 449
e1f47419 450 // --- Get the vertex information ----------------------------------
96110c91 451
452 Double_t vx = 0;
453 Double_t vy = 0;
8565b10b 454 vz = 0;
96110c91 455
456 Bool_t vzOk = ReadVertex(event, vz,vx,vy);
8565b10b 457
458 fHEventsTr->Fill(vz);
459 if (!vzOk) {
0bd4b00f 460 if (fDebug > 3) {
461 AliWarning("Failed to read vertex from ESD"); }
8565b10b 462 return kNoVertex;
463 }
464 fHEventsTrVtx->Fill(vz);
96110c91 465
e1f47419 466 // --- Get the vertex bin ------------------------------------------
5bb5d1f6 467 ivz = fVtxAxis.FindBin(vz);
468 if (ivz <= 0 || ivz > fVtxAxis.GetNbins()) {
0bd4b00f 469 if (fDebug > 3) {
8565b10b 470 AliWarning(Form("Vertex @ %f outside of range [%f,%f]",
5bb5d1f6 471 vz, fVtxAxis.GetXmin(), fVtxAxis.GetXmax()));
472 }
0bd4b00f 473 ivz = 0;
8565b10b 474 return kBadVertex;
475 }
5bb5d1f6 476 fHEventsAccepted->Fill(vz);
96110c91 477 fHEventsAcceptedXY->Fill(vx,vy);
e58000b7 478
e1f47419 479 // --- Check the FMD ESD data --------------------------------------
480 if (!event->GetFMDData()) {
481 if (fDebug > 3) {
482 AliWarning("No FMD data found in ESD"); }
483 return kNoFMD;
484 }
485
e58000b7 486
8565b10b 487 return kOk;
488}
489
e1f47419 490//____________________________________________________________________
491Bool_t
e308a636 492AliFMDEventInspector::ReadCentrality(const AliESDEvent* esd,
493 Double_t& cent,
494 UShort_t& qual) const
e1f47419 495{
496 //
497 // Read centrality from event
498 //
499 // Parameters:
500 // esd Event
501 // cent On return, the centrality or negative if not found
502 //
503 // Return:
504 // False on error, true otherwise
505 //
e308a636 506 cent = -1;
507 qual = 0;
e1f47419 508 AliCentrality* centObj = const_cast<AliESDEvent*>(esd)->GetCentrality();
e308a636 509 if (!centObj) return true;
510
511 // AliInfo(Form("Got centrality object %p with quality %d",
512 // centObj, centObj->GetQuality()));
513 // centObj->Print();
514 cent = centObj->GetCentralityPercentile("V0M");
fd36b8a6 515 //cent = centObj->GetCentralityPercentile("ZEMvsZDC");
e308a636 516 qual = centObj->GetQuality();
e1f47419 517
518 return true;
519}
520
8565b10b 521//____________________________________________________________________
522Bool_t
5bb5d1f6 523AliFMDEventInspector::ReadTriggers(const AliESDEvent* esd, UInt_t& triggers,
524 UShort_t& nClusters)
8565b10b 525{
7984e5f7 526 //
527 // Read the trigger information from the ESD event
528 //
529 // Parameters:
530 // esd ESD event
531 // triggers On return, contains the trigger bits
532 //
533 // Return:
534 // @c true on success, @c false otherwise
535 //
8565b10b 536 triggers = 0;
537
538 // Get the analysis manager - should always be there
539 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
540 if (!am) {
541 AliWarning("No analysis manager defined!");
542 return kFALSE;
543 }
544
545 // Get the input handler - should always be there
546 AliInputEventHandler* ih =
547 static_cast<AliInputEventHandler*>(am->GetInputEventHandler());
548 if (!ih) {
549 AliWarning("No input handler");
550 return kFALSE;
551 }
11d40ecb 552
e1f47419 553 // Check if this is a collision candidate (MB)
e333578d 554 // Note, that we should use the value cached in the input
555 // handler rather than calling IsCollisionCandiate directly
556 // on the AliPhysicsSelection obejct. If we called the latter
557 // then the AliPhysicsSelection object would overcount by a
558 // factor of 2! :-(
11d40ecb 559 Bool_t offline = ih->IsEventSelected() ;
560 Bool_t fastonly = (ih->IsEventSelected() & AliVEvent::kFastOnly);
59acef00 561 TString trigStr = esd->GetFiredTriggerClasses();
11d40ecb 562
460a5c02 563 //If we have the MC input handler, this must be MC
564 Bool_t isMC = am->GetMCtruthEventHandler() != 0;
565
11d40ecb 566 // For the 2.76 TeV p+p run, the FMD ran in the slow partition
567 // so it received no triggers from the fast partition. Therefore
568 // the fast triggers are removed here but not for MC where all
569 // triggers are fast.
11d40ecb 570 if(TMath::Abs(fEnergy - 2750.) < 20 &&
571 fCollisionSystem == AliForwardUtil::kPP &&
572 !isMC)
573 if (fastonly) offline = false;
5bb5d1f6 574 nClusters = 0;
59acef00 575
576 // MUON triggers are not strictly minimum bias (MB) so they are removed (HHD)
577
578 if(offline && trigStr.Contains("CMUS1")) offline = false;
579
11d40ecb 580 if (offline ) {
0be6c8cd 581 triggers |= AliAODForwardMult::kOffline;
8565b10b 582 triggers |= AliAODForwardMult::kInel;
0be6c8cd 583 fHTriggers->Fill(kOffline+0.5);
8565b10b 584
0be6c8cd 585 // If this is inel, see if we have a tracklet
8565b10b 586 const AliMultiplicity* spdmult = esd->GetMultiplicity();
587 if (!spdmult) {
588 AliWarning("No SPD multiplicity");
589 }
590 else {
e333578d 591 // Check if we have one or more tracklets
592 // in the range -1 < eta < 1 to set the INEL>0
593 // trigger flag.
5bb5d1f6 594 //
595 // Also count tracklets as a single cluster
8565b10b 596 Int_t n = spdmult->GetNumberOfTracklets();
597 for (Int_t j = 0; j < n; j++) {
598 if(TMath::Abs(spdmult->GetEta(j)) < 1) {
599 triggers |= AliAODForwardMult::kInelGt0;
5bb5d1f6 600 nClusters++;
8565b10b 601 }
602 }
5bb5d1f6 603 n = spdmult->GetNumberOfSingleClusters();
604 for (Int_t j = 0; j < n; j++) {
605 Double_t eta = -TMath::Log(TMath::Tan(spdmult->GetThetaSingle(j)/2.));
606 if (TMath::Abs(eta) < 1) nClusters++;
607 }
8565b10b 608 }
5bb5d1f6 609 if (nClusters > 0) triggers |= AliAODForwardMult::kNClusterGt0;
8565b10b 610 }
11d40ecb 611
8565b10b 612 // Analyse some trigger stuff
613 AliTriggerAnalysis ta;
31554871 614 if(fUseV0AND) {
615 if (ta.IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0AND))
616 triggers |= AliAODForwardMult::kNSD;
617 }
618 else {
619 if (ta.IsOfflineTriggerFired(esd, AliTriggerAnalysis::kNSD1))
620 triggers |= AliAODForwardMult::kNSD;
621 }
622
5bb5d1f6 623 // Check for multiple vertices (pile-up) with at least 3
624 // contributors and at least 0.8cm from the primary vertex
10f6a070 625 Bool_t pileup = kFALSE;
626 if(fCollisionSystem == AliForwardUtil::kPP)
627 pileup = esd->IsPileupFromSPD(3,0.8);
e58000b7 628 if (pileup) {
629 triggers |= AliAODForwardMult::kPileUp;
630 fHTriggers->Fill(kPileUp+.5);
631 }
59acef00 632
8565b10b 633 // Get trigger stuff
59acef00 634
635 //TString trigStr = esd->GetFiredTriggerClasses();
fe52e455 636 // AliWarning(Form("Fired trigger classes: %s", trigStr.Data()));
c56f8519 637 if (fHWords) fHWords->Fill(trigStr.Data(), 1);
fe52e455 638#if 0
639 if (trigStr.Contains("MB1") || trigStr.Contains("MBBG3"))
0be6c8cd 640 triggers |= AliAOODForwardMult::kB;
fe52e455 641 if (trigStr.Contains("COTA"))
642 triggers |= AliAODForwardMult::kA;
643 if (trigStr.Contains("COTC"))
644 triggers |= AliAODForwardMult::kC;
645#endif
8565b10b 646 if (trigStr.Contains("CBEAMB-ABCE-NOPF-ALL")) {
647 triggers |= AliAODForwardMult::kEmpty;
648 fHTriggers->Fill(kEmpty+.5);
649 }
59acef00 650
d969d4af 651 // Check for B triggers
652 if (trigStr.Contains("CINT1B-ABCE-NOPF-ALL") || // Early pp
653 trigStr.Contains("CINT1-B-NOPF-ALLNOTRD") || // Late pp
59acef00 654 trigStr.Contains("CINT1-B-NOPF-FASTNOTRD") || // Late pp
655 //trigStr.Contains("CMUS1-B-NOPF-MUON") || // Late pp -- HHD 160811
d969d4af 656 trigStr.Contains("CSMBB-ABCE-NOPF-ALL") || // pp
657 trigStr.Contains("CMBACS2-B-NOPF-ALL") || // PbPb
658 // trigStr.Contains("C0SMH-B-NOPF-ALL") || // PbPb - high mult
659 trigStr.Contains("CMBS2A-B-NOPF-ALL") || // PbPb
660 trigStr.Contains("CMBS2C-B-NOPF-ALL") || // PbPb
661 trigStr.Contains("CMBAC-B-NOPF-ALL") || // PbPb
662 // trigStr.Contains("C0SMH-B-NOPF-ALL") || // PbPb - high mult
663 trigStr.Contains("CMBACS2-B-NOPF-ALLNOTRD") // PbPb
664 // trigStr.Contains("C0SMH-B-NOPF-ALLNOTRD") // PbPb - high mult
665 ) {
59acef00 666 Bool_t bTrigger = kTRUE;
667 if ( trigStr.Contains("CINT1-B-NOPF-FASTNOTRD") &&
668 !trigStr.Contains("CINT1-B-NOPF-ALLNOTRD") &&
669 TMath::Abs(fEnergy - 2750.) < 20 &&
670 fCollisionSystem == AliForwardUtil::kPP)
671 bTrigger = kFALSE;
672 if(bTrigger) {
673 triggers |= AliAODForwardMult::kB;
674 fHTriggers->Fill(kB+.5);
675 }
8565b10b 676 }
d969d4af 677
678 // Check for A triggers
8d847dd3 679 if (trigStr.Contains("CINT1A-ABCE-NOPF-ALL") || // Early pp
680 trigStr.Contains("CINT1-AC-NOPF-ALLNOTRD") || // Late pp
681 trigStr.Contains("CINT1-AC-NOPF-FASTNOTRD") || // Late pp
d969d4af 682 (trigStr.Contains("CSMBA-ABCE-NOPF-ALL") &&
8d847dd3 683 !(triggers & AliAODForwardMult::kB)) || // pp
684 trigStr.Contains("CMBACS2-A-NOPF-ALL") || // PbPb
685 // trigStr.Contains("C0SMH-A-NOPF-ALL") || // PbPb - high mult
686 trigStr.Contains("CMBS2A-A-NOPF-ALL") || // PbPb
687 trigStr.Contains("CMBS2C-A-NOPF-ALL") || // PbPb
688 trigStr.Contains("CMBAC-A-NOPF-ALL") || // PbPb
689 // trigStr.Contains("C0SMH-A-NOPF-ALL") || // PbPb - high mult
d969d4af 690 trigStr.Contains("CMBACS2-A-NOPF-ALLNOTRD") // PbPb
691 // trigStr.Contains("C0SMH-A-NOPF-ALLNOTRD") // PbPb - high mult
692 ) {
693 triggers |= AliAODForwardMult::kA;
694 fHTriggers->Fill(kA+.5);
695 }
8565b10b 696
d969d4af 697 // Check for C triggers
698 if (trigStr.Contains("CINT1C-ABCE-NOPF-ALL") || // Early pp
699 (trigStr.Contains("CSMBC-ABCE-NOPF-ALL") &&
700 !(triggers & AliAODForwardMult::kB)) || // pp
701 trigStr.Contains("CMBACS2-C-NOPF-ALL") || // PbPb
702 // trigStr.Contains("C0SMH-B-NOPF-ALL") || // PbPb - high mult
703 trigStr.Contains("CMBS2A-C-NOPF-ALL") || // PbPb
704 trigStr.Contains("CMBS2C-C-NOPF-ALL") || // PbPb
705 trigStr.Contains("CMBAC-C-NOPF-ALL") || // PbPb
706 // trigStr.Contains("C0SMH-B-NOPF-ALL") || // PbPb - high mult
707 trigStr.Contains("CMBACS2-C-NOPF-ALLNOTRD") // PbPb
708 // trigStr.Contains("C0SMH-B-NOPF-ALLNOTRD") // PbPb - high mult
709 ) {
8565b10b 710 triggers |= AliAODForwardMult::kC;
711 fHTriggers->Fill(kC+.5);
712 }
713
d969d4af 714 // Check for E triggers
715 if (trigStr.Contains("CINT1-E-NOPF-ALL") || // Early pp
716 trigStr.Contains("CINT1-E-NOPF-ALLNOTRD") || // Late pp
308e9175 717 trigStr.Contains("CINT1-E-NOPF-FASTNOTRD") || // Late pp
d969d4af 718 trigStr.Contains("CMBACS2-E-NOPF-ALL") || // PbPb
719 // trigStr.Contains("C0SMH-B-NOPF-ALL") || // PbPb - high mult
720 trigStr.Contains("CMBS2A-E-NOPF-ALL") || // PbPb
721 trigStr.Contains("CMBS2C-E-NOPF-ALL") || // PbPb
722 trigStr.Contains("CMBAC-E-NOPF-ALL") || // PbPb
723 // trigStr.Contains("C0SMH-B-NOPF-ALL") || // PbPb - high mult
724 trigStr.Contains("CMBACS2-E-NOPF-ALLNOTRD") // PbPb
725 // trigStr.Contains("C0SMH-B-NOPF-ALLNOTRD") // PbPb - high mult
726 ) {
8565b10b 727 triggers |= AliAODForwardMult::kE;
728 fHTriggers->Fill(kE+.5);
729 }
730
d969d4af 731 // Now check - if we have a collision - for offline triggers and
732 // fill histogram.
0be6c8cd 733 if (triggers & AliAODForwardMult::kB) {
734 if (triggers & AliAODForwardMult::kInel)
735 fHTriggers->Fill(kInel);
736
737 if (triggers & AliAODForwardMult::kInelGt0)
738 fHTriggers->Fill(kInelGt0+.5);
739
740 if (triggers & AliAODForwardMult::kNSD)
741 fHTriggers->Fill(kNSD+.5);
742 }
743
8565b10b 744 return kTRUE;
745}
746//____________________________________________________________________
747Bool_t
96110c91 748AliFMDEventInspector::ReadVertex(const AliESDEvent* esd,
749 Double_t& vz,
750 Double_t& vx,
751 Double_t& vy)
8565b10b 752{
7984e5f7 753 //
754 // Read the vertex information from the ESD event
755 //
756 // Parameters:
757 // esd ESD event
758 // vz On return, the vertex Z position
759 //
760 // Return:
761 // @c true on success, @c false otherwise
762 //
8565b10b 763 vz = 0;
96110c91 764 vx = 1024;
765 vy = 1024;
e83d0620 766 if(fUseFirstPhysicsVertex) {
767 // This is the code used by the 1st physics people
768 const AliESDVertex* vertex = esd->GetPrimaryVertex();
769 if (!vertex || !vertex->GetStatus()) {
770 if (fDebug > 2) {
771 AliWarning(Form("No primary vertex (%p) or bad status %d",
772 vertex, (vertex ? vertex->GetStatus() : -1)));
773 }
774 return false;
5bb5d1f6 775 }
e83d0620 776 const AliESDVertex* vertexSPD = esd->GetPrimaryVertexSPD();
777 if (!vertexSPD || !vertexSPD->GetStatus()) {
5bb5d1f6 778 if (fDebug > 2) {
e83d0620 779 AliWarning(Form("No primary SPD vertex (%p) or bad status %d",
780 vertexSPD, (vertexSPD ? vertexSPD->GetStatus() : -1)));
5bb5d1f6 781 }
782 return false;
783 }
e83d0620 784
785 // if vertex is from SPD vertexZ, require more stringent cuts
786 if (vertex->IsFromVertexerZ()) {
787 if (vertex->GetDispersion() > fMaxVzErr ||
788 vertex->GetZRes() > 1.25 * fMaxVzErr) {
789 if (fDebug > 2) {
790 AliWarning(Form("Dispersion %f > %f or resolution %f > %f",
791 vertex->GetDispersion(), fMaxVzErr,
792 vertex->GetZRes(), 1.25 * fMaxVzErr));
793 }
794 return false;
795 }
796 }
797 vz = vertex->GetZ();
96110c91 798
799 if(!vertex->IsFromVertexerZ()) {
800 vx = vertex->GetX();
801 vy = vertex->GetY();
802 }
e83d0620 803 return true;
96110c91 804 }
e83d0620 805 else { //Use standard SPD vertex (perhaps preferable for Pb+Pb)
806
807 // Get the vertex
808 const AliESDVertex* vertex = esd->GetPrimaryVertexSPD();
809 if (!vertex) {
810 if (fDebug > 2) {
811 AliWarning("No SPD vertex found in ESD"); }
812 return kFALSE;
813 }
814
815 // Check that enough tracklets contributed
816 if(vertex->GetNContributors() <= 0) {
817 if (fDebug > 2) {
818 AliWarning(Form("Number of contributors to vertex is %d<=0",
819 vertex->GetNContributors())); }
820 vz = 0;
821 return kFALSE;
822 }
823 // Check that the uncertainty isn't too large
824 if (vertex->GetZRes() > fMaxVzErr) {
825 if (fDebug > 2) {
826 AliWarning(Form("Uncertaintity in Z of vertex is too large %f > %f",
0bd4b00f 827 vertex->GetZRes(), fMaxVzErr)); }
e83d0620 828 return kFALSE;
829 }
830
831 // Get the z coordiante
832 vz = vertex->GetZ();
96110c91 833 const AliESDVertex* vertexXY = esd->GetPrimaryVertex();
834
835 if(!vertexXY->IsFromVertexerZ()) {
836 vx = vertexXY->GetX();
837 vy = vertexXY->GetY();
838 }
e83d0620 839 return kTRUE;
840 }
8565b10b 841}
0be6c8cd 842
0bd4b00f 843//____________________________________________________________________
844Bool_t
845AliFMDEventInspector::ReadRunDetails(const AliESDEvent* esd)
846{
7984e5f7 847 //
848 // Read the collision system, collision energy, and L3 field setting
849 // from the ESD
850 //
851 // Parameters:
852 // esd ESD to get information from
853 //
854 // Return:
855 // true on success, false
856 //
cc83fca2 857 // AliInfo(Form("Parameters from 1st ESD event: cms=%s, sNN=%f, field=%f",
858 // esd->GetBeamType(), 2*esd->GetBeamEnergy(),
859 // esd->GetMagneticField()));
0bd4b00f 860 fCollisionSystem =
861 AliForwardUtil::ParseCollisionSystem(esd->GetBeamType());
862 fEnergy =
863 AliForwardUtil::ParseCenterOfMassEnergy(fCollisionSystem,
0be6c8cd 864 2 * esd->GetBeamEnergy());
0bd4b00f 865 fField =
866 AliForwardUtil::ParseMagneticField(esd->GetMagneticField());
f7cfc454 867
9b2f2e39 868 StoreInformation(esd->GetRunNumber());
0bd4b00f 869 if (fCollisionSystem == AliForwardUtil::kUnknown ||
870 fEnergy <= 0 ||
871 TMath::Abs(fField) > 10)
872 return kFALSE;
873
874 return kTRUE;
875}
876
877//____________________________________________________________________
878void
879AliFMDEventInspector::Print(Option_t*) const
880{
7984e5f7 881 //
882 // Print information
883 //
884 // option Not used
885 //
0bd4b00f 886 char ind[gROOT->GetDirLevel()+1];
887 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
888 ind[gROOT->GetDirLevel()] = '\0';
889 TString sNN(AliForwardUtil::CenterOfMassEnergyString(fEnergy));
890 sNN.Strip(TString::kBoth, '0');
891 sNN.ReplaceAll("GeV", " GeV");
892 TString field(AliForwardUtil::MagneticFieldString(fField));
893 field.ReplaceAll("p", "+");
894 field.ReplaceAll("m", "-");
895 field.ReplaceAll("kG", " kG");
896
e1f47419 897 std::cout << ind << ClassName() << ": " << GetName() << '\n'
2a9e4c0b 898 << ind << " Vertex bins: " << fVtxAxis.GetNbins() << '\n'
899 << ind << " Vertex range: [" << fVtxAxis.GetXmin()
900 << "," << fVtxAxis.GetXmax() << "]\n"
0bd4b00f 901 << ind << " Low flux cut: " << fLowFluxCut << '\n'
902 << ind << " Max(delta v_z): " << fMaxVzErr << " cm\n"
903 << ind << " System: "
904 << AliForwardUtil::CollisionSystemString(fCollisionSystem) << '\n'
905 << ind << " CMS energy per nucleon: " << sNN << '\n'
d8244e9e 906 << ind << " Field: " << field << '\n';
907 if (!fCentAxis) { std::cout << std::flush; return; }
908 Int_t nBin = fCentAxis->GetNbins();
909 std::cout << ind << " Centrality axis: " << nBin << " bins"
910 << std::flush;
911 for (Int_t i = 0; i < nBin; i++) {
912 if ((i % 10) == 0) std::cout << '\n' << ind << " ";
913 std::cout << std::setw(5) << fCentAxis->GetBinLowEdge(i+1) << '-';
914 }
915 std::cout << std::setw(5) << fCentAxis->GetBinUpEdge(nBin) << std::endl;
0bd4b00f 916}
917
918
8565b10b 919//
920// EOF
921//
922