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