]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/AliFMDEventInspector.cxx
matching constituents within matched jets (from Redmer)
[u/mrichter/AliRoot.git] / PWGLF / 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"
e85a76b7 26#include "AliOADBPhysicsSelection.h"
8565b10b 27#include "AliAODForwardMult.h"
0bd4b00f 28#include "AliForwardUtil.h"
5e4d905e 29#include "AliCentrality.h"
8565b10b 30#include <TH1.h>
31#include <TList.h>
32#include <TDirectory.h>
0bd4b00f 33#include <TROOT.h>
e6463868 34#include <TParameter.h>
0bd4b00f 35#include <iostream>
36#include <iomanip>
65abd48b 37#include "AliMCEvent.h"
38#include "AliHeader.h"
39#include "AliGenEventHeader.h"
40#include "AliCollisionGeometry.h"
da70cd6a 41#include "AliVVZERO.h"
e1f47419 42
8565b10b 43//====================================================================
5ca83fee 44const char* AliFMDEventInspector::fgkFolderName = "fmdEventInspector";
45
46//____________________________________________________________________
8565b10b 47AliFMDEventInspector::AliFMDEventInspector()
48 : TNamed(),
49 fHEventsTr(0),
50 fHEventsTrVtx(0),
5bb5d1f6 51 fHEventsAccepted(0),
96110c91 52 fHEventsAcceptedXY(0),
8565b10b 53 fHTriggers(0),
66cf95f2 54 fHTriggerCorr(0),
0bd4b00f 55 fHType(0),
5ca83fee 56 fHWords(0),
57 fHCent(0),
58 fHCentVsQual(0),
59 fHStatus(0),
8449e3e0 60 fHVtxStatus(0),
61 fHTrgStatus(0),
5ca83fee 62 fLowFluxCut(1000),
63 fMaxVzErr(0.2),
64 fList(0),
65 fEnergy(0),
0bd4b00f 66 fField(999),
5ca83fee 67 fCollisionSystem(kUnknown),
e308a636 68 fDebug(0),
5bb5d1f6 69 fCentAxis(0),
e83d0620 70 fVtxAxis(10,-10,10),
5ca83fee 71 fUseFirstPhysicsVertex(false),
72 fUseV0AND(false),
73 fMinPileupContrib(3),
74 fMinPileupDistance(0.8),
5934a3e3 75 fUseDisplacedVertices(false),
241cca4d 76 fDisplacedVertex(),
77 fCollWords(),
5934a3e3 78 fBgWords(),
4f9319f3 79 fCentMethod("V0M"),
8449e3e0 80 fMinCent(-1.0),
81 fMaxCent(-1.0),
82 fUsepA2012Vertex(false),
83 fRunNumber(0)
8565b10b 84{
7984e5f7 85 //
86 // Constructor
87 //
241cca4d 88 DGUARD(fDebug,1,"Default CTOR of AliFMDEventInspector");
8565b10b 89}
90
91//____________________________________________________________________
92AliFMDEventInspector::AliFMDEventInspector(const char* name)
5ca83fee 93 : TNamed(fgkFolderName, name),
8565b10b 94 fHEventsTr(0),
95 fHEventsTrVtx(0),
5bb5d1f6 96 fHEventsAccepted(0),
96110c91 97 fHEventsAcceptedXY(0),
8565b10b 98 fHTriggers(0),
66cf95f2 99 fHTriggerCorr(0),
0bd4b00f 100 fHType(0),
fe52e455 101 fHWords(0),
5e4d905e 102 fHCent(0),
e308a636 103 fHCentVsQual(0),
241cca4d 104 fHStatus(0),
8449e3e0 105 fHVtxStatus(0),
106 fHTrgStatus(0),
8565b10b 107 fLowFluxCut(1000),
9d05ffeb 108 fMaxVzErr(0.2),
8565b10b 109 fList(0),
0bd4b00f 110 fEnergy(0),
111 fField(999),
112 fCollisionSystem(kUnknown),
e308a636 113 fDebug(0),
5bb5d1f6 114 fCentAxis(0),
e83d0620 115 fVtxAxis(10,-10,10),
5ca83fee 116 fUseFirstPhysicsVertex(false),
e6463868 117 fUseV0AND(false),
118 fMinPileupContrib(3),
65abd48b 119 fMinPileupDistance(0.8),
120 fUseDisplacedVertices(false),
241cca4d 121 fDisplacedVertex(),
122 fCollWords(),
5934a3e3 123 fBgWords(),
4f9319f3 124 fCentMethod("V0M"),
8449e3e0 125 fMinCent(-1.0),
126 fMaxCent(-1.0),
127 fUsepA2012Vertex(false),
128 fRunNumber(0)
8565b10b 129{
7984e5f7 130 //
131 // Constructor
132 //
133 // Parameters:
134 // name Name of object
135 //
241cca4d 136 DGUARD(fDebug,1,"Named CTOR of AliFMDEventInspector: %s", name);
8565b10b 137}
138
139//____________________________________________________________________
140AliFMDEventInspector::AliFMDEventInspector(const AliFMDEventInspector& o)
141 : TNamed(o),
142 fHEventsTr(o.fHEventsTr),
143 fHEventsTrVtx(o.fHEventsTrVtx),
5bb5d1f6 144 fHEventsAccepted(o.fHEventsAccepted),
96110c91 145 fHEventsAcceptedXY(o.fHEventsAcceptedXY),
8565b10b 146 fHTriggers(o.fHTriggers),
66cf95f2 147 fHTriggerCorr(o.fHTriggerCorr),
0bd4b00f 148 fHType(o.fHType),
fe52e455 149 fHWords(o.fHWords),
5e4d905e 150 fHCent(o.fHCent),
e308a636 151 fHCentVsQual(o.fHCentVsQual),
241cca4d 152 fHStatus(o.fHStatus),
8449e3e0 153 fHVtxStatus(o.fHVtxStatus),
154 fHTrgStatus(o.fHTrgStatus),
6feacd76 155 fLowFluxCut(o.fLowFluxCut),
8565b10b 156 fMaxVzErr(o.fMaxVzErr),
157 fList(o.fList),
0bd4b00f 158 fEnergy(o.fEnergy),
159 fField(o.fField),
160 fCollisionSystem(o.fCollisionSystem),
e308a636 161 fDebug(0),
5bb5d1f6 162 fCentAxis(0),
e83d0620 163 fVtxAxis(o.fVtxAxis),
31554871 164 fUseFirstPhysicsVertex(o.fUseFirstPhysicsVertex),
e6463868 165 fUseV0AND(o.fUseV0AND),
166 fMinPileupContrib(o.fMinPileupContrib),
65abd48b 167 fMinPileupDistance(o.fMinPileupDistance),
168 fUseDisplacedVertices(o.fUseDisplacedVertices),
241cca4d 169 fDisplacedVertex(o.fDisplacedVertex),
170 fCollWords(),
5934a3e3 171 fBgWords(),
4f9319f3 172 fCentMethod(o.fCentMethod),
8449e3e0 173 fMinCent(o.fMinCent),
174 fMaxCent(o.fMaxCent),
175 fUsepA2012Vertex(o.fUsepA2012Vertex),
176 fRunNumber(o.fRunNumber)
177
8565b10b 178{
7984e5f7 179 //
180 // Copy constructor
181 //
182 // Parameters:
183 // o Object to copy from
184 //
241cca4d 185 DGUARD(fDebug,1,"Copy CTOR of AliFMDEventInspector");
8565b10b 186}
187
188//____________________________________________________________________
189AliFMDEventInspector::~AliFMDEventInspector()
190{
7984e5f7 191 //
192 // Destructor
193 //
c929bc03 194 DGUARD(fDebug,1,"DTOR of AliFMDEventInspector");
195 // if (fList) delete fList;
8565b10b 196}
197//____________________________________________________________________
198AliFMDEventInspector&
199AliFMDEventInspector::operator=(const AliFMDEventInspector& o)
200{
7984e5f7 201 //
202 // Assignement operator
203 //
204 // Parameters:
205 // o Object to assign from
206 //
207 // Return:
208 // Reference to this object
209 //
6ab100ec 210 DGUARD(fDebug,3,"Assignment of AliFMDEventInspector");
d015ecfe 211 if (&o == this) return *this;
8565b10b 212 TNamed::operator=(o);
213 fHEventsTr = o.fHEventsTr;
214 fHEventsTrVtx = o.fHEventsTrVtx;
5bb5d1f6 215 fHEventsAccepted = o.fHEventsAccepted;
96110c91 216 fHEventsAcceptedXY = o.fHEventsAcceptedXY;
8565b10b 217 fHTriggers = o.fHTriggers;
66cf95f2 218 fHTriggerCorr = o.fHTriggerCorr;
0bd4b00f 219 fHType = o.fHType;
fe52e455 220 fHWords = o.fHWords;
5e4d905e 221 fHCent = o.fHCent;
e308a636 222 fHCentVsQual = o.fHCentVsQual;
241cca4d 223 fHStatus = o.fHStatus;
8449e3e0 224 fHVtxStatus = o.fHVtxStatus;
225 fHTrgStatus = o.fHTrgStatus;
8565b10b 226 fLowFluxCut = o.fLowFluxCut;
227 fMaxVzErr = o.fMaxVzErr;
228 fDebug = o.fDebug;
229 fList = (o.fList ? new TList : 0);
0bd4b00f 230 fEnergy = o.fEnergy;
231 fField = o.fField;
232 fCollisionSystem = o.fCollisionSystem;
5bb5d1f6 233 fVtxAxis.Set(o.fVtxAxis.GetNbins(), o.fVtxAxis.GetXmin(),
234 o.fVtxAxis.GetXmax());
e83d0620 235
236 fUseFirstPhysicsVertex = o.fUseFirstPhysicsVertex;
31554871 237 fUseV0AND = o.fUseV0AND;
e6463868 238 fMinPileupContrib = o.fMinPileupContrib;
239 fMinPileupDistance = o.fMinPileupDistance;
65abd48b 240 fUseDisplacedVertices = o.fUseDisplacedVertices;
241 fDisplacedVertex = o.fDisplacedVertex;
5934a3e3 242 fCentMethod = o.fCentMethod;
8449e3e0 243 fMinCent = o.fMinCent;
244 fMaxCent = o.fMaxCent;
245 fUsepA2012Vertex = o.fUsepA2012Vertex;
246 fRunNumber = o.fRunNumber;
4f9319f3 247
8565b10b 248 if (fList) {
249 fList->SetName(GetName());
250 if (fHEventsTr) fList->Add(fHEventsTr);
251 if (fHEventsTrVtx) fList->Add(fHEventsTrVtx);
252 if (fHTriggers) fList->Add(fHTriggers);
66cf95f2 253 if (fHTriggerCorr) fList->Add(fHTriggerCorr);
0bd4b00f 254 if (fHType) fList->Add(fHType);
fe52e455 255 if (fHWords) fList->Add(fHWords);
5e4d905e 256 if (fHCent) fList->Add(fHCent);
e308a636 257 if (fHCentVsQual) fList->Add(fHCentVsQual);
241cca4d 258 if (fHStatus) fList->Add(fHStatus);
8449e3e0 259 if (fHVtxStatus) fList->Add(fHVtxStatus);
260 if (fHTrgStatus) fList->Add(fHTrgStatus);
8565b10b 261 }
262 return *this;
263}
264
5934a3e3 265//____________________________________________________________________
266void
267AliFMDEventInspector::SetCentralityMethod(ECentMethod m)
268{
269 switch (m) {
270 case kV0Multiplicity: fCentMethod = "VOM"; break; // VZERO multiplicity
271 case kV0Amplitude: fCentMethod = "V0A"; break; // VZERO amplitude
272 case kV0Charge: fCentMethod = "V0C"; break; // VZERO charge
273 case kFMDRough: fCentMethod = "FMD"; break; // FMD scaled energy l
274 case kNTracks: fCentMethod = "TRK"; break; // Number of tracks
275 case kLTracks: fCentMethod = "TKL"; break; // Number of tracks
276 case kCL0: fCentMethod = "CL0"; break; //
277 case kCL1: fCentMethod = "CL1"; break; //
278 case kCND: fCentMethod = "CND"; break; //
279 case kNParticles: fCentMethod = "NPA"; break; // Neutral particles
280 case kNeutrons: fCentMethod = "ZNA"; break; // ZDC neutron amplitu
281 case kV0vsFMD: fCentMethod = "V0MvsFMD"; break; // VZERO versus FMD
282 case kV0vsNTracks: fCentMethod = "TKLvsVOM"; break; // Tracks versus VZERO
283 case kZEMvsZDC: fCentMethod = "ZEMvsZDC"; break; // ZDC
284 default: fCentMethod = "V0M"; break;
285 }
286}
287
8449e3e0 288//____________________________________________________________________
289void
290AliFMDEventInspector::SetMinCentrality(Double_t minCent)
291{
292 AliWarning("\n"
293 "*******************************************************\n"
294 "* Setting centrality cuts in this stage is deprecated *\n"
295 "*******************************************************");
296 fMinCent = minCent;
297}
298//____________________________________________________________________
299void
300AliFMDEventInspector::SetMaxCentrality(Double_t maxCent)
301{
302 AliWarning("\n"
303 "*******************************************************\n"
304 "* Setting centrality cuts in this stage is deprecated *\n"
305 "*******************************************************");
306 fMaxCent = maxCent;
307}
308
8565b10b 309//____________________________________________________________________
310Bool_t
fb3430ac 311AliFMDEventInspector::FetchHistograms(const TList* d,
8565b10b 312 TH1I*& hEventsTr,
313 TH1I*& hEventsTrVtx,
5ca83fee 314 TH1I*& hEventsAcc,
8565b10b 315 TH1I*& hTriggers) const
316{
7984e5f7 317 //
318 // Fetch our histograms from the passed list
319 //
320 // Parameters:
321 // d Input
322 // hEventsTr On return, pointer to histogram, or null
323 // hEventsTrVtx On return, pointer to histogram, or null
324 // hTriggers On return, pointer to histogram, or null
325 //
326 // Return:
327 // true on success, false otherwise
328 //
6ab100ec 329 DGUARD(fDebug,3,"Fetch histograms in AliFMDEventInspector");
8565b10b 330 hEventsTr = 0;
331 hEventsTrVtx = 0;
5ca83fee 332 hEventsAcc = 0;
333 hTriggers = 0;
8565b10b 334 TList* dd = dynamic_cast<TList*>(d->FindObject(GetName()));
335 if (!dd) return kFALSE;
336
337 hEventsTr = dynamic_cast<TH1I*>(dd->FindObject("nEventsTr"));
338 hEventsTrVtx = dynamic_cast<TH1I*>(dd->FindObject("nEventsTrVtx"));
5ca83fee 339 hEventsAcc = dynamic_cast<TH1I*>(dd->FindObject("nEventsAccepted"));
8565b10b 340 hTriggers = dynamic_cast<TH1I*>(dd->FindObject("triggers"));
341
5ca83fee 342 if (!hEventsTr ||
343 !hEventsTrVtx ||
344 !hEventsAcc ||
345 !hTriggers) return kFALSE;
8565b10b 346 return kTRUE;
347}
241cca4d 348//____________________________________________________________________
349void
350AliFMDEventInspector::CacheConfiguredTriggerClasses(TList& cache,
351 const TList* classes,
352 AliOADBPhysicsSelection* o)
353{
354 TIter nextClass(classes);
355 TObjString* trigClass = 0;
356 // Loop over all trigger classes. Trigger classes have the format
357 //
358 // class := positive_words SPACE(s) negative_words
359 // positive_words :=
360 // | '+' words
361 // negative_words :=
362 // | '-' words
363 // words := word
364 // | word ',' words
365 //
366 while ((trigClass = static_cast<TObjString*>(nextClass()))) {
367 // Tokenize on space to get positive and negative parts
368 TString side = o->GetBeamSide(trigClass->String());
369 TObjArray* parts = trigClass->String().Tokenize(" ");
370 TObjString* part = 0;
371 TIter nextPart(parts);
372 while ((part = static_cast<TObjString*>(nextPart()))) {
373 // We only care about the positive ones
374 if (part->GetName()[0] != '+') continue;
375 part->String().Remove(0,1);
376
377 // Tokenize on a comma to get the words
378 TObjArray* words = part->String().Tokenize(",");
379 TObjString* word = 0;
380 TIter nextWord(words);
381 while ((word = static_cast<TObjString*>(nextWord()))) {
382 TNamed* store = new TNamed(word->String(), side);
383 cache.Add(store);
384 DMSG(fDebug,3,"Caching %s trigger word %s",
385 store->GetTitle(), store->GetName());
386 } // while (word)
387 delete words;
388 }
389 delete parts;
390 }
391}
392
8565b10b 393//____________________________________________________________________
394void
5934a3e3 395AliFMDEventInspector::SetupForData(const TAxis& vtxAxis)
8565b10b 396{
7984e5f7 397 //
241cca4d 398 // Initialize the object - this is called on the first seen event.
7984e5f7 399 //
400 // Parameters:
401 // vtxAxis Vertex axis in use
402 //
6ab100ec 403 DGUARD(fDebug,1,"Initialize in AliFMDEventInspector");
241cca4d 404
405 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
406
407 // Get the input handler - should always be there
408 AliInputEventHandler* ih =
409 static_cast<AliInputEventHandler*>(am->GetInputEventHandler());
410 if (!ih) {
411 AliWarning("No input handler");
412 return;
413 }
414 // Get the physics selection - should always be there
415 AliPhysicsSelection* ps =
416 static_cast<AliPhysicsSelection*>(ih->GetEventSelection());
417 if (!ps) {
418 AliWarning("No physics selection");
419 return;
420 }
421 // Get the configured triggers
422 AliOADBPhysicsSelection* oadb =
423 const_cast<AliOADBPhysicsSelection*>(ps->GetOADBPhysicsSelection());
424 if (!oadb) {
425 AliWarning("No OADB physics selection object");
426 return;
427 }
428 // Get the configured trigger words from the physics selection
429 const TList* collTriggClasses = ps->GetCollisionTriggerClasses();
430 const TList* bgTriggClasses = ps->GetBGTriggerClasses();
431 if (!collTriggClasses) {
432 AliWarning("No configured collision trigger classes");
433 return;
434 }
435 if (!bgTriggClasses) {
436 AliWarning("No configured background trigger classes");
437 return;
438 }
439 CacheConfiguredTriggerClasses(fCollWords, collTriggClasses, oadb);
440 CacheConfiguredTriggerClasses(fBgWords, bgTriggClasses, oadb);
441 // fCollWords.ls();
442 // fBgWords.ls();
443
e308a636 444
8449e3e0 445 TArrayD limits;
446 if ((fMinCent < 0 && fMaxCent < 0) || fMaxCent <= fMinCent) {
447 // -1.5 -0.5 0.5 1.5 ... 89.5 ... 100.5
448 // ----- 92 number --------- ---- 1 ---
449 limits.Set(93);
450 for (Int_t i = 0; i < 92; i++) limits[i] = -1.5 + i;
451 limits[92] = 100.5;
452 }
453 else {
454 Int_t n = fMaxCent-fMinCent+2;
455 limits.Set(n);
456 for (Int_t i = 0; i < n; i++) {
457 limits[i] = fMinCent + i - .5;
458 }
459 }
460
5bb5d1f6 461 fVtxAxis.Set(vtxAxis.GetNbins(), vtxAxis.GetXmin(), vtxAxis.GetXmax());
e308a636 462
463 fCentAxis = new TAxis(limits.GetSize()-1, limits.GetArray());
8565b10b 464 fHEventsTr = new TH1I("nEventsTr", "Number of events w/trigger",
5bb5d1f6 465 4*vtxAxis.GetNbins(),
466 2*vtxAxis.GetXmin(),
467 2*vtxAxis.GetXmax());
8565b10b 468 fHEventsTr->SetXTitle("v_{z} [cm]");
469 fHEventsTr->SetYTitle("# of events");
470 fHEventsTr->SetFillColor(kRed+1);
471 fHEventsTr->SetFillStyle(3001);
472 fHEventsTr->SetDirectory(0);
473 // fHEventsTr->Sumw2();
474 fList->Add(fHEventsTr);
475
5bb5d1f6 476 fHEventsTrVtx = static_cast<TH1I*>(fHEventsTr->Clone("nEventsTrVtx"));
477 fHEventsTrVtx->SetTitle("Number of events w/trigger and vertex");
8565b10b 478 fHEventsTrVtx->SetFillColor(kBlue+1);
8565b10b 479 fHEventsTrVtx->SetDirectory(0);
480 // fHEventsTrVtx->Sumw2();
481 fList->Add(fHEventsTrVtx);
482
5bb5d1f6 483 fHEventsAccepted = new TH1I("nEventsAccepted",
484 "Number of events w/trigger and vertex in range",
485 2*vtxAxis.GetNbins(),
486 2*vtxAxis.GetXmin(),
487 2*vtxAxis.GetXmax());
488 fHEventsAccepted->SetXTitle("v_{z} [cm]");
489 fHEventsAccepted->SetYTitle("# of events");
490 fHEventsAccepted->SetFillColor(kGreen+1);
491 fHEventsAccepted->SetFillStyle(3001);
492 fHEventsAccepted->SetDirectory(0);
493 // fHEventsAccepted->Sumw2();
494 fList->Add(fHEventsAccepted);
495
96110c91 496 fHEventsAcceptedXY = new TH2D("nEventsAcceptedXY",
497 "XY vertex w/trigger and Z vertex in range",
498 1000,-1,1,1000,-1,1);
499
500 fHEventsAcceptedXY->SetXTitle("v_{x} [cm]");
501 fHEventsAcceptedXY->SetYTitle("v_{y} [cm]");
502 fHEventsAcceptedXY->SetDirectory(0);
503 // fHEventsAccepted->Sumw2();
504 fList->Add(fHEventsAcceptedXY);
505
506
0be6c8cd 507 fHTriggers = new TH1I("triggers", "Triggers", kOffline+1, 0, kOffline+1);
8565b10b 508 fHTriggers->SetFillColor(kRed+1);
509 fHTriggers->SetFillStyle(3001);
510 fHTriggers->SetStats(0);
511 fHTriggers->SetDirectory(0);
66cf95f2 512
513 fHTriggerCorr = new TH2I("triggerCorr", "Trigger correlation",
514 kOffline+1, 0, kOffline+1,
515 kOffline+1, 0, kOffline+1);
516 fHTriggerCorr->SetStats(0);
517 fHTriggerCorr->SetDirectory(0);
cd51b0dd 518 fHTriggerCorr->SetXTitle("Requirement");
519 fHTriggerCorr->SetYTitle("Companion");
520
66cf95f2 521 Int_t binNum[] = { kInel +1,
522 kInelGt0+1,
523 kNSD +1,
524 kV0AND +1,
525 kEmpty +1,
526 kA +1,
527 kB +1,
528 kC +1,
529 kE +1,
530 kPileUp +1,
531 kMCNSD +1,
8449e3e0 532 kSatellite+1,
66cf95f2 533 kOffline+1 };
534 const char* binLbl[] = { "INEL",
535 "INEL>0",
536 "NSD",
537 "VOAND",
538 "Empty",
539 "A",
540 "B",
541 "C",
542 "E",
543 "Pileup",
544 "NSD_{MC}",
8449e3e0 545 "Satellite",
66cf95f2 546 "Offline" };
cd51b0dd 547 for (Int_t i = 0; i < kOffline+1; i++) {
66cf95f2 548 fHTriggers->GetXaxis()->SetBinLabel(binNum[i], binLbl[i]);
549 fHTriggerCorr->GetXaxis()->SetBinLabel(binNum[i], binLbl[i]);
550 fHTriggerCorr->GetYaxis()->SetBinLabel(binNum[i], binLbl[i]);
551 }
8565b10b 552 fList->Add(fHTriggers);
66cf95f2 553 fList->Add(fHTriggerCorr);
554
0bd4b00f 555
556 fHType = new TH1I("type", Form("Event type (cut: SPD mult>%d)",
557 fLowFluxCut), 2, -.5, 1.5);
558 fHType->SetFillColor(kRed+1);
559 fHType->SetFillStyle(3001);
560 fHType->SetStats(0);
561 fHType->SetDirectory(0);
562 fHType->GetXaxis()->SetBinLabel(1,"Low-flux");
563 fHType->GetXaxis()->SetBinLabel(2,"High-flux");
564 fList->Add(fHType);
fe52e455 565
c56f8519 566#if 0
567 // This histogram disabled as it causes problems in the merge
fe52e455 568 fHWords = new TH1I("words", "Trigger words seen", 1, 0, 0);
569 fHWords->SetFillColor(kBlue+1);
570 fHWords->SetFillStyle(3001);
571 fHWords->SetStats(0);
572 fHWords->SetDirectory(0);
573 fHWords->SetBit(TH1::kCanRebin);
574 fList->Add(fHWords);
c56f8519 575#endif
5e4d905e 576
e308a636 577 fHCent = new TH1F("cent", "Centrality", limits.GetSize()-1,limits.GetArray());
5e4d905e 578 fHCent->SetFillColor(kBlue+1);
579 fHCent->SetFillStyle(3001);
580 fHCent->SetStats(0);
581 fHCent->SetDirectory(0);
582 fHCent->SetXTitle("Centrality [%]");
583 fHCent->SetYTitle("Events");
584 fList->Add(fHCent);
e308a636 585
586 fHCentVsQual = new TH2F("centVsQuality", "Quality vs Centrality",
587 5, 0, 5, limits.GetSize()-1, limits.GetArray());
588 fHCentVsQual->SetXTitle("Quality");
589 fHCentVsQual->SetYTitle("Centrality [%]");
590 fHCentVsQual->SetZTitle("Events");
591 fHCentVsQual->GetXaxis()->SetBinLabel(1, "OK");
592 fHCentVsQual->GetXaxis()->SetBinLabel(2, "Outside v_{z} cut");
593 fHCentVsQual->GetXaxis()->SetBinLabel(3, "V0 vs SPD outlier");
594 fHCentVsQual->GetXaxis()->SetBinLabel(4, "V0 vs TPC outlier");
595 fHCentVsQual->GetXaxis()->SetBinLabel(5, "V0 vs ZDC outlier");
b7ab8a2c 596 fHCentVsQual->SetDirectory(0);
e308a636 597 fList->Add(fHCentVsQual);
241cca4d 598
599 fHStatus = new TH1I("status", "Status", 7, 1, 8);
8449e3e0 600 fHStatus->SetFillColor(kBlue+1);
241cca4d 601 fHStatus->SetFillStyle(3001);
602 fHStatus->SetStats(0);
603 fHStatus->SetDirectory(0);
8449e3e0 604 TAxis* xAxis = fHStatus->GetXaxis();
605 xAxis->SetBinLabel(1, "OK");
606 xAxis->SetBinLabel(2, "No event");
607 xAxis->SetBinLabel(3, "No triggers");
608 xAxis->SetBinLabel(4, "No SPD");
609 xAxis->SetBinLabel(5, "No FMD");
610 xAxis->SetBinLabel(6, "No vertex");
611 xAxis->SetBinLabel(7, "Bad vertex");
241cca4d 612 fList->Add(fHStatus);
8449e3e0 613
614 fHVtxStatus = new TH1I("vtxStatus","Vertex Status",
615 kNotVtxZ,kVtxOK,kNotVtxZ+1);
616 fHVtxStatus->SetFillColor(kGreen+1);
617 fHVtxStatus->SetFillStyle(3001);
618 fHVtxStatus->SetStats(0);
619 fHVtxStatus->SetDirectory(0);
620 xAxis = fHVtxStatus->GetXaxis();
621 xAxis->SetBinLabel(kVtxOK, "OK");
622 xAxis->SetBinLabel(kNoVtx, "None/bad status");
623 xAxis->SetBinLabel(kNoSPDVtx, "No SPD/bad status");
624 xAxis->SetBinLabel(kFewContrib, "N_{contrib} <= 0");
625 xAxis->SetBinLabel(kUncertain, Form("#delta z > %4.2f", fMaxVzErr));
626 xAxis->SetBinLabel(kNotVtxZ, "Not Z vertexer");
627 fList->Add(fHVtxStatus);
628
629 fHTrgStatus = new TH1I("trgStatus", "Trigger Status",
630 kOther, kNoTrgWords, kOther+1);
631 fHTrgStatus->SetFillColor(kMagenta+1);
632 fHTrgStatus->SetFillStyle(3001);
633 fHTrgStatus->SetStats(0);
634 fHTrgStatus->SetDirectory(0);
635 xAxis = fHTrgStatus->GetXaxis();
636 xAxis->SetBinLabel(kNoTrgWords, "No words");
637 xAxis->SetBinLabel(kPP2760Fast, "FAST in pp@#sqrt{s}=2.76TeV");
638 xAxis->SetBinLabel(kMUON, "Muon trigger");
639 xAxis->SetBinLabel(kTriggered, "Triggered");
640 xAxis->SetBinLabel(kMinBias, "CINT1 (V0A||V0C||FASTOR)");
641 xAxis->SetBinLabel(kMinBiasNoSPD, "CINT5 (V0A||V0C)");
642 xAxis->SetBinLabel(kV0AndTrg, "CINT7 (V0A&&V0C)");
643 xAxis->SetBinLabel(kHighMult, "N>>0");
644 xAxis->SetBinLabel(kCentral, "Central");
645 xAxis->SetBinLabel(kSemiCentral, "Semi-central");
646 xAxis->SetBinLabel(kDiffractive, "Diffractive");
647 xAxis->SetBinLabel(kUser, "User");
648 xAxis->SetBinLabel(kOther, "Other");
649 fList->Add(fHTrgStatus);
650
bfab35d9 651 if (fUseDisplacedVertices) fDisplacedVertex.SetupForData(fList, "", false);
8565b10b 652}
653
f7cfc454 654//____________________________________________________________________
655void
8449e3e0 656AliFMDEventInspector::StoreInformation()
f7cfc454 657{
658 // Write TNamed objects to output list containing information about
659 // the running conditions
6ab100ec 660 DGUARD(fDebug,2,"Store information from AliFMDEventInspector");
f7cfc454 661 if (!fList) return;
662
241cca4d 663
664 fList->Add(AliForwardUtil::MakeParameter("sys", fCollisionSystem));
665 fList->Add(AliForwardUtil::MakeParameter("sNN", fEnergy));
666 fList->Add(AliForwardUtil::MakeParameter("field", fField));
8449e3e0 667 fList->Add(AliForwardUtil::MakeParameter("runNo", fRunNumber));
241cca4d 668 fList->Add(AliForwardUtil::MakeParameter("lowFlux", fLowFluxCut));
669 fList->Add(AliForwardUtil::MakeParameter("fpVtx",fUseFirstPhysicsVertex));
670 fList->Add(AliForwardUtil::MakeParameter("v0and",fUseV0AND));
671 fList->Add(AliForwardUtil::MakeParameter("nPileUp", fMinPileupContrib));
672 fList->Add(AliForwardUtil::MakeParameter("dPileup", fMinPileupDistance));
8449e3e0 673 fList->Add(AliForwardUtil::MakeParameter("satellite", fUseDisplacedVertices));
1ff25622 674 fList->Add(AliForwardUtil::MakeParameter("alirootRev",
675 AliForwardUtil::AliROOTRevision()));
676 fList->Add(AliForwardUtil::MakeParameter("alirootBranch",
677 AliForwardUtil::AliROOTBranch()));
678
f7cfc454 679}
680
8565b10b 681//____________________________________________________________________
682void
5934a3e3 683AliFMDEventInspector::CreateOutputObjects(TList* dir)
8565b10b 684{
7984e5f7 685 //
686 // Define the output histograms. These are put in a sub list of the
687 // passed list. The histograms are merged before the parent task calls
688 // AliAnalysisTaskSE::Terminate
689 //
690 // dir Directory to add to
691 //
6ab100ec 692 DGUARD(fDebug,1,"Define output from AliFMDEventInspector");
8565b10b 693 fList = new TList;
694 fList->SetName(GetName());
c929bc03 695 fList->SetOwner();
8565b10b 696 dir->Add(fList);
697}
698
699//____________________________________________________________________
700UInt_t
701AliFMDEventInspector::Process(const AliESDEvent* event,
702 UInt_t& triggers,
703 Bool_t& lowFlux,
0bd4b00f 704 UShort_t& ivz,
5ca83fee 705 TVector3& ip,
5bb5d1f6 706 Double_t& cent,
707 UShort_t& nClusters)
8565b10b 708{
7984e5f7 709 //
710 // Process the event
711 //
712 // Parameters:
713 // event Input event
714 // triggers On return, the triggers fired
715 // lowFlux On return, true if the event is considered a low-flux
716 // event (according to the setting of fLowFluxCut)
717 // ivz On return, the found vertex bin (1-based). A zero
718 // means outside of the defined vertex range
719 // vz On return, the z position of the interaction
5e4d905e 720 // cent On return, the centrality - if not available < 0
7984e5f7 721 //
722 // Return:
723 // 0 (or kOk) on success, otherwise a bit mask of error codes
724 //
4f9319f3 725 DGUARD(fDebug,1,"Process event in AliFMDEventInspector");
e1f47419 726 // --- Check that we have an event ---------------------------------
8565b10b 727 if (!event) {
728 AliWarning("No ESD event found for input event");
241cca4d 729 fHStatus->Fill(2);
8565b10b 730 return kNoEvent;
731 }
732
bfab35d9 733 // --- Process satellite event information is requested ------------
734 if (fUseDisplacedVertices) {
735 if (!fDisplacedVertex.Process(event))
736 AliWarning("Failed to process satellite event");
737 }
738
e1f47419 739 // --- Read trigger information from the ESD and store in AOD object
241cca4d 740 if (!ReadTriggers(*event, triggers, nClusters)) {
0bd4b00f 741 if (fDebug > 2) {
742 AliWarning("Failed to read triggers from ESD"); }
241cca4d 743 fHStatus->Fill(3);
8565b10b 744 return kNoTriggers;
745 }
746
e1f47419 747 // --- Check if this is a high-flux event --------------------------
8565b10b 748 const AliMultiplicity* testmult = event->GetMultiplicity();
749 if (!testmult) {
0bd4b00f 750 if (fDebug > 3) {
751 AliWarning("No central multiplicity object found"); }
8565b10b 752 }
e1f47419 753 else
754 lowFlux = testmult->GetNumberOfTracklets() < fLowFluxCut;
5e4d905e 755
0bd4b00f 756 fHType->Fill(lowFlux ? 0 : 1);
314f6077 757
758 // --- Get the interaction point -----------------------------------
759 Bool_t vzOk = ReadVertex(*event, ip);
760 fHEventsTr->Fill(ip.Z());
761 if (!vzOk) {
762 if (fDebug > 3) {
763 AliWarning("Failed to read vertex from ESD"); }
764 fHStatus->Fill(6);
765 return kNoVertex;
766 }
767
768 // --- Read centrality information
e308a636 769 cent = -10;
770 UShort_t qual = 0;
241cca4d 771 if (!ReadCentrality(*event, cent, qual)) {
e1f47419 772 if (fDebug > 3)
773 AliWarning("Failed to get centrality");
8565b10b 774 }
314f6077 775 // --- check centrality cut
4f9319f3 776
8449e3e0 777 if(fMinCent > -0.0001 && cent < fMinCent) return kNoEvent;
778 if(fMaxCent > -0.0001 && cent > fMaxCent) return kNoEvent;
e308a636 779 fHCent->Fill(cent);
780 if (qual == 0) fHCentVsQual->Fill(0., cent);
781 else {
782 for (UShort_t i = 0; i < 4; i++)
783 if (qual & (1 << i)) fHCentVsQual->Fill(Double_t(i+1), cent);
784 }
314f6077 785
8565b10b 786
5ca83fee 787 fHEventsTrVtx->Fill(ip.Z());
96110c91 788
e1f47419 789 // --- Get the vertex bin ------------------------------------------
5ca83fee 790 ivz = fVtxAxis.FindBin(ip.Z());
5bb5d1f6 791 if (ivz <= 0 || ivz > fVtxAxis.GetNbins()) {
0bd4b00f 792 if (fDebug > 3) {
8565b10b 793 AliWarning(Form("Vertex @ %f outside of range [%f,%f]",
5ca83fee 794 ip.Z(), fVtxAxis.GetXmin(), fVtxAxis.GetXmax()));
5bb5d1f6 795 }
0bd4b00f 796 ivz = 0;
241cca4d 797 fHStatus->Fill(7);
8565b10b 798 return kBadVertex;
799 }
5ca83fee 800 fHEventsAccepted->Fill(ip.Z());
801 fHEventsAcceptedXY->Fill(ip.X(),ip.Y());
e58000b7 802
e1f47419 803 // --- Check the FMD ESD data --------------------------------------
804 if (!event->GetFMDData()) {
805 if (fDebug > 3) {
806 AliWarning("No FMD data found in ESD"); }
241cca4d 807 fHStatus->Fill(5);
e1f47419 808 return kNoFMD;
809 }
810
241cca4d 811 fHStatus->Fill(1);
8565b10b 812 return kOk;
813}
814
e1f47419 815//____________________________________________________________________
816Bool_t
241cca4d 817AliFMDEventInspector::ReadCentrality(const AliESDEvent& esd,
e308a636 818 Double_t& cent,
819 UShort_t& qual) const
e1f47419 820{
821 //
822 // Read centrality from event
823 //
824 // Parameters:
825 // esd Event
826 // cent On return, the centrality or negative if not found
827 //
828 // Return:
829 // False on error, true otherwise
830 //
6ab100ec 831 DGUARD(fDebug,2,"Read the centrality in AliFMDEventInspector");
241cca4d 832
241cca4d 833 cent = -1;
8449e3e0 834 qual = 1;
241cca4d 835 AliCentrality* centObj = const_cast<AliESDEvent&>(esd).GetCentrality();
8449e3e0 836 if (centObj) {
837 cent = centObj->GetCentralityPercentile(fCentMethod);
838 qual = centObj->GetQuality();
839 }
241cca4d 840
bc31b177 841 // We overwrite with satellite events, so we can be sure to get the
842 // centrality determination from the satellite vertex selection
843 if (fUseDisplacedVertices && fDisplacedVertex.IsSatellite()) {
8449e3e0 844 cent = fDisplacedVertex.GetCentralityPercentile();
845 qual = 0;
846 }
e1f47419 847
848 return true;
849}
850
da70cd6a 851//____________________________________________________________________
852Bool_t
853AliFMDEventInspector::CheckpAExtraV0(const AliESDEvent& esd) const
854{
855 if (fCollisionSystem != AliForwardUtil::kPPb) return true;
856
857 AliVVZERO* esdV0 = esd.GetVZEROData();
858 if ((esdV0->GetV0ADecision()!=1) || (esdV0->GetV0CDecision()!=1))
859 return false;
860 return true;
861}
862
8565b10b 863//____________________________________________________________________
864Bool_t
241cca4d 865AliFMDEventInspector::ReadTriggers(const AliESDEvent& esd, UInt_t& triggers,
5bb5d1f6 866 UShort_t& nClusters)
8565b10b 867{
7984e5f7 868 //
869 // Read the trigger information from the ESD event
870 //
871 // Parameters:
872 // esd ESD event
873 // triggers On return, contains the trigger bits
874 //
875 // Return:
876 // @c true on success, @c false otherwise
877 //
6ab100ec 878 DGUARD(fDebug,2,"Read the triggers in AliFMDEventInspector");
8565b10b 879 triggers = 0;
880
881 // Get the analysis manager - should always be there
882 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
241cca4d 883 DMSG(fDebug,10,"Got analysis manager %p", am);
8565b10b 884 if (!am) {
885 AliWarning("No analysis manager defined!");
886 return kFALSE;
887 }
888
889 // Get the input handler - should always be there
890 AliInputEventHandler* ih =
891 static_cast<AliInputEventHandler*>(am->GetInputEventHandler());
241cca4d 892 DMSG(fDebug,10,"Got input handler %p", ih);
8565b10b 893 if (!ih) {
894 AliWarning("No input handler");
895 return kFALSE;
896 }
e85a76b7 897
e1f47419 898 // Check if this is a collision candidate (MB)
8449e3e0 899 ///
900 // Historic remark: Note, that we should use the value cached in the
901 // input handler rather than calling IsCollisionCandiate directly
902 // on the AliPhysicsSelection obejct. If we called the latter
903 // then the AliPhysicsSelection object would overcount by a factor
904 // of 2! :-(
905 UInt_t trgMask = ih->IsEventSelected();
906 Bool_t offline = trgMask;
907 Bool_t fastonly = (trgMask & AliVEvent::kFastOnly);
241cca4d 908 TString trigStr = esd.GetFiredTriggerClasses();
909
8449e3e0 910 if (trigStr.IsNull()) fHTrgStatus->Fill(kNoTrgWords);
241cca4d 911 if (fHWords) fHWords->Fill(trigStr.Data(), 1);
11d40ecb 912
241cca4d 913 if(fUseDisplacedVertices) {
914 DMSG(fDebug,3,"Using displaced vertex stuff");
8449e3e0 915 // if (TMath::Abs(fDisplacedVertex.GetVertexZ()) >= 999) offline = false;
916 if (fDisplacedVertex.IsSatellite())
917 triggers |= AliAODForwardMult::kSatellite;
918 }
919
920 if (CheckFastPartition(fastonly)) {
921 fHTrgStatus->Fill(kPP2760Fast);
922 offline = false;
241cca4d 923 }
65abd48b 924
8449e3e0 925 if (offline && CheckCosmics(trigStr)) {
926 fHTrgStatus->Fill(kMUON);
927 offline = false;
928 }
929 if (offline) fHTrgStatus->Fill(kTriggered);
930 Int_t f = 0;
931 if (trgMask & AliVEvent::kMB) f += fHTrgStatus->Fill(kMinBias);
932 if (trgMask & AliVEvent::kCINT5) f += fHTrgStatus->Fill(kMinBiasNoSPD);
933 if (trgMask & AliVEvent::kINT7) f += fHTrgStatus->Fill(kV0AndTrg);
934 if (trgMask & AliVEvent::kHighMult) f += fHTrgStatus->Fill(kHighMult);
935 if (trgMask & AliVEvent::kCentral) f += fHTrgStatus->Fill(kCentral);
936 if (trgMask & AliVEvent::kSemiCentral) f += fHTrgStatus->Fill(kSemiCentral);
937 if (trgMask & AliVEvent::kDG5) f += fHTrgStatus->Fill(kDiffractive);
938 if (trgMask & AliVEvent::kUserDefined) f += fHTrgStatus->Fill(kUser);
939 if (f <= 0) fHTrgStatus->Fill(kOther);
940
c929bc03 941 // if (!CheckpAExtraV0(esd)) offline = false;
241cca4d 942
943 DMSG(fDebug,2,"Event is %striggered by off-line", offline ? "" : "NOT ");
944
945 if (offline) {
946 triggers |= AliAODForwardMult::kOffline;
947 triggers |= AliAODForwardMult::kInel;
241cca4d 948 CheckINELGT0(esd, nClusters, triggers);
65abd48b 949 }
950
241cca4d 951 CheckNSD(esd,triggers);
cd51b0dd 952 CheckPileup(esd, triggers);
953 CheckEmpty(trigStr, triggers);
954 // if (CheckPileup(esd, triggers)) fHTriggers->Fill(kPileUp+.5);
955 // if (CheckEmpty(trigStr, triggers)) fHTriggers->Fill(kEmpty+.5);
241cca4d 956
8449e3e0 957 CheckWords(esd, triggers);
241cca4d 958
66cf95f2 959#define TEST_TRIG_BIN(RET,BIN,TRIGGERS) \
960 do { switch (BIN) { \
8449e3e0 961 case kInel: RET = triggers & AliAODForwardMult::kInel; break; \
962 case kInelGt0: RET = triggers & AliAODForwardMult::kInelGt0; break; \
963 case kNSD: RET = triggers & AliAODForwardMult::kNSD; break; \
964 case kV0AND: RET = triggers & AliAODForwardMult::kV0AND; break; \
965 case kEmpty: RET = triggers & AliAODForwardMult::kEmpty; break; \
966 case kA: RET = triggers & AliAODForwardMult::kA; break; \
967 case kB: RET = triggers & AliAODForwardMult::kB; break; \
968 case kC: RET = triggers & AliAODForwardMult::kC; break; \
969 case kE: RET = triggers & AliAODForwardMult::kE; break; \
970 case kPileUp: RET = triggers & AliAODForwardMult::kPileUp; break; \
971 case kMCNSD: RET = triggers & AliAODForwardMult::kMCNSD; break; \
972 case kSatellite:RET = triggers & AliAODForwardMult::kSatellite; break; \
973 case kOffline: RET = triggers & AliAODForwardMult::kOffline; break; \
974 default: RET = false; } } while(false)
66cf95f2 975
8449e3e0 976 if (!fHTriggers) {
977 AliWarning("Histogram of triggers not defined - has init been called");
978 return false;
979 }
241cca4d 980
66cf95f2 981 for (Int_t i = 0; i < kOffline+1; i++) {
982 Bool_t hasX = false;
983 TEST_TRIG_BIN(hasX, i, triggers);
984 if (!hasX) continue;
cd51b0dd 985 fHTriggers->Fill(i+.5);
986 for (Int_t j = 0; j < kOffline+1; j++) {
66cf95f2 987 Bool_t hasY = false;
988 TEST_TRIG_BIN(hasY, j, triggers);
989 if (!hasY) continue;
990
991 fHTriggerCorr->Fill(i+.5, j+.5);
992 }
993 }
241cca4d 994 return kTRUE;
995}
996
997//____________________________________________________________________
998Bool_t
999AliFMDEventInspector::CheckFastPartition(bool fastonly) const
1000{
11d40ecb 1001 // For the 2.76 TeV p+p run, the FMD ran in the slow partition
1002 // so it received no triggers from the fast partition. Therefore
1003 // the fast triggers are removed here but not for MC where all
1004 // triggers are fast.
241cca4d 1005 if (TMath::Abs(fEnergy - 2750.) > 20) return false;
1006 if (fCollisionSystem != AliForwardUtil::kPP) return false;
1007 if (fastonly)
1008 DMSG(fDebug,1,"Fast trigger in pp @ sqrt(s)=2.76TeV removed");
1009
1010 return fastonly;
1011}
1012
1013//____________________________________________________________________
1014Bool_t
1015AliFMDEventInspector::CheckCosmics(const TString& trigStr) const
1016{
1017 // MUON triggers are not strictly minimum bias (MB) so they are
1018 // removed (HHD)
1019 if(trigStr.Contains("CMUS1")) {
1020 DMSG(fDebug,1,"Cosmic trigger ins't min-bias, removed");
1021 return true;
1022 }
1023 return false;
1024}
1025
1026//____________________________________________________________________
1027Bool_t
1028AliFMDEventInspector::CheckINELGT0(const AliESDEvent& esd,
1029 UShort_t& nClusters,
1030 UInt_t& triggers) const
1031{
5bb5d1f6 1032 nClusters = 0;
8565b10b 1033
241cca4d 1034 // If this is inel, see if we have a tracklet
1035 const AliMultiplicity* spdmult = esd.GetMultiplicity();
1036 if (!spdmult) {
1037 AliWarning("No SPD multiplicity");
1038 return false;
1039 }
1040
1041 // Check if we have one or more tracklets
1042 // in the range -1 < eta < 1 to set the INEL>0
1043 // trigger flag.
1044 //
1045 // Also count tracklets as a single cluster
1046 Int_t n = spdmult->GetNumberOfTracklets();
1047 for (Int_t j = 0; j < n; j++) {
1048 if(TMath::Abs(spdmult->GetEta(j)) < 1) {
1049 triggers |= AliAODForwardMult::kInelGt0;
1050 nClusters++;
8565b10b 1051 }
1052 }
241cca4d 1053 n = spdmult->GetNumberOfSingleClusters();
1054 for (Int_t j = 0; j < n; j++) {
1055 Double_t eta = -TMath::Log(TMath::Tan(spdmult->GetThetaSingle(j)/2.));
1056 if (TMath::Abs(eta) < 1) nClusters++;
1057 }
1058 if (nClusters > 0) triggers |= AliAODForwardMult::kNClusterGt0;
1059
1060 return triggers & AliAODForwardMult::kNClusterGt0;
1061}
1062
1063//____________________________________________________________________
1064Bool_t
1065AliFMDEventInspector::CheckNSD(const AliESDEvent& esd, UInt_t& triggers) const
1066{
8565b10b 1067 // Analyse some trigger stuff
1068 AliTriggerAnalysis ta;
241cca4d 1069 if (ta.IsOfflineTriggerFired(&esd, AliTriggerAnalysis::kV0AND)) {
e6463868 1070 triggers |= AliAODForwardMult::kV0AND;
1071 if (fUseV0AND)
31554871 1072 triggers |= AliAODForwardMult::kNSD;
1073 }
241cca4d 1074 if (ta.IsOfflineTriggerFired(&esd, AliTriggerAnalysis::kNSD1))
e6463868 1075 triggers |= AliAODForwardMult::kNSD;
241cca4d 1076 return triggers & AliAODForwardMult::kNSD;
1077}
1078//____________________________________________________________________
1079Bool_t
1080AliFMDEventInspector::CheckPileup(const AliESDEvent& esd,
1081 UInt_t& triggers) const
1082{
5bb5d1f6 1083 // Check for multiple vertices (pile-up) with at least 3
1084 // contributors and at least 0.8cm from the primary vertex
241cca4d 1085 if(fCollisionSystem != AliForwardUtil::kPP) return false;
1086
1087 Bool_t pileup = esd.IsPileupFromSPD(fMinPileupContrib,fMinPileupDistance);
1088 if (pileup) triggers |= AliAODForwardMult::kPileUp;
1089 return pileup;
1090}
1091
1092//____________________________________________________________________
1093Bool_t
1094AliFMDEventInspector::CheckEmpty(const TString& trigStr, UInt_t& triggers) const
1095{
8565b10b 1096 if (trigStr.Contains("CBEAMB-ABCE-NOPF-ALL")) {
1097 triggers |= AliAODForwardMult::kEmpty;
241cca4d 1098 return true;
8565b10b 1099 }
241cca4d 1100 return false;
1101}
1102//____________________________________________________________________
1103Bool_t
1104AliFMDEventInspector::CheckWords(const AliESDEvent& esd, UInt_t& triggers) const
1105{
1106 TObject* word = 0;
1107 TIter nextColl(&fCollWords);
1108 while ((word = nextColl())) {
1109 DMSG(fDebug,10,"Checking if %s trigger %s is fired",
1110 word->GetTitle(), word->GetName());
1111 if (!esd.IsTriggerClassFired(word->GetName())) continue;
8565b10b 1112
241cca4d 1113 TString beamSide = word->GetTitle();
1114 DMSG(fDebug,10,"Found it - this is a %s trigger", beamSide.Data());
e85a76b7 1115
241cca4d 1116 if (!beamSide.EqualTo("B")) continue;
1117 triggers |= AliAODForwardMult::kB;
1118 break; // No more to do here
e85a76b7 1119 }
241cca4d 1120 TIter nextBg(&fBgWords);
1121 UInt_t all = (AliAODForwardMult::kA |
1122 AliAODForwardMult::kC |
1123 AliAODForwardMult::kE);
1124 while ((word = nextBg())) {
1125 DMSG(fDebug,10,"Checking if %s trigger %s is fired",
1126 word->GetTitle(), word->GetName());
1127 if (!esd.IsTriggerClassFired(word->GetName())) continue;
0be6c8cd 1128
241cca4d 1129 TString beamSide = word->GetTitle();
1130 DMSG(fDebug,10,"Found it - this is a %s trigger", beamSide.Data());
e6463868 1131
241cca4d 1132 if (beamSide.Contains("A")) triggers |= AliAODForwardMult::kA;
1133 if (beamSide.Contains("C")) triggers |= AliAODForwardMult::kC;
1134 if (beamSide.Contains("E")) triggers |= AliAODForwardMult::kE;
1135
1136 if ((triggers & all) == all) break; // No more to do
0be6c8cd 1137 }
241cca4d 1138 return true;
8565b10b 1139}
241cca4d 1140
1141
8565b10b 1142//____________________________________________________________________
1143Bool_t
5ca83fee 1144AliFMDEventInspector::ReadVertex(const AliESDEvent& esd, TVector3& ip)
8565b10b 1145{
7984e5f7 1146 //
1147 // Read the vertex information from the ESD event
1148 //
1149 // Parameters:
1150 // esd ESD event
1151 // vz On return, the vertex Z position
1152 //
1153 // Return:
1154 // @c true on success, @c false otherwise
1155 //
6ab100ec 1156 DGUARD(fDebug,2,"Read the vertex in AliFMDEventInspector");
5ca83fee 1157 ip.SetXYZ(1024, 1024, 0);
65abd48b 1158
8449e3e0 1159 EVtxStatus s = kNoVtx;
bfab35d9 1160 if (fUseDisplacedVertices && fDisplacedVertex.IsSatellite()) {
1161 s = kVtxOK;
1162 ip.SetZ(fDisplacedVertex.GetVertexZ());
1163 }
1164 else if (fUseFirstPhysicsVertex)
8449e3e0 1165 s = CheckPWGUDVertex(esd, ip);
1166 else if (fUsepA2012Vertex)
1167 s = CheckpA2012Vertex(esd,ip);
1168 else
1169 s = CheckVertex(esd, ip);
1170
8449e3e0 1171 fHVtxStatus->Fill(s);
1172
1173 return s == kVtxOK;
241cca4d 1174}
1175
1176//____________________________________________________________________
8449e3e0 1177AliFMDEventInspector::EVtxStatus
241cca4d 1178AliFMDEventInspector::CheckPWGUDVertex(const AliESDEvent& esd,
5ca83fee 1179 TVector3& ip) const
241cca4d 1180{
1181 // This is the code used by the 1st physics people
1182 const AliESDVertex* vertex = esd.GetPrimaryVertex();
1183 if (!vertex || !vertex->GetStatus()) {
1184 DMSG(fDebug,2,"No primary vertex (%p) or bad status %d",
1185 vertex, (vertex ? vertex->GetStatus() : -1));
8449e3e0 1186 return kNoVtx;
241cca4d 1187 }
1188 const AliESDVertex* vertexSPD = esd.GetPrimaryVertexSPD();
1189 if (!vertexSPD || !vertexSPD->GetStatus()) {
1190 DMSG(fDebug,2,"No primary SPD vertex (%p) or bad status %d",
1191 vertexSPD, (vertexSPD ? vertexSPD->GetStatus() : -1));
8449e3e0 1192 return kNoSPDVtx;
241cca4d 1193 }
96110c91 1194
241cca4d 1195 // if vertex is from SPD vertexZ, require more stringent cuts
1196 if (vertex->IsFromVertexerZ()) {
1197 if (vertex->GetDispersion() > fMaxVzErr ||
1198 vertex->GetZRes() > 1.25 * fMaxVzErr) {
1199 DMSG(fDebug,2,"Dispersion %f > %f or resolution %f > %f",
1200 vertex->GetDispersion(), fMaxVzErr,
1201 vertex->GetZRes(), 1.25 * fMaxVzErr);
8449e3e0 1202 return kUncertain;
96110c91 1203 }
96110c91 1204 }
5ca83fee 1205 ip.SetZ(vertex->GetZ());
241cca4d 1206
1207 if(!vertex->IsFromVertexerZ()) {
5ca83fee 1208 ip.SetX(vertex->GetX());
1209 ip.SetY(vertex->GetY());
241cca4d 1210 }
8449e3e0 1211 return kVtxOK;
241cca4d 1212}
8449e3e0 1213//____________________________________________________________________
1214AliFMDEventInspector::EVtxStatus
1215AliFMDEventInspector::CheckpA2012Vertex(const AliESDEvent& esd,
1216 TVector3& ip) const
ffd35d33 1217{
8449e3e0 1218 const AliESDVertex *vertex = esd.GetPrimaryVertexSPD();
1219 if (!vertex) return kNoSPDVtx;
1220 if (vertex->GetNContributors() <= 0) return kFewContrib;
1221
1222 TString vtxTyp = vertex->GetTitle();
1223 if (vtxTyp.Contains("vertexer: Z")) return kNotVtxZ;
1224
1225 if (vertex->GetDispersion() >= 0.04 || vertex->GetZRes()>=0.25)
1226 return kUncertain;
1227
1228 ip.SetX(vertex->GetX());
1229 ip.SetY(vertex->GetY());
1230 ip.SetZ(vertex->GetZ());
1231
1232 return kVtxOK;
ffd35d33 1233}
1234
241cca4d 1235//____________________________________________________________________
8449e3e0 1236AliFMDEventInspector::EVtxStatus
241cca4d 1237AliFMDEventInspector::CheckVertex(const AliESDEvent& esd,
5ca83fee 1238 TVector3& ip) const
241cca4d 1239{
1240 // Use standard SPD vertex (perhaps preferable for Pb+Pb)
1241 // Get the vertex
1242 const AliESDVertex* vertex = esd.GetPrimaryVertexSPD();
1243 if (!vertex) {
1244 if (fDebug > 2) {
1245 AliWarning("No SPD vertex found in ESD"); }
8449e3e0 1246 return kNoSPDVtx;
241cca4d 1247 }
e83d0620 1248
8449e3e0 1249 // #if 0 // Check disabled - seem to kill a lot of PbPb events
241cca4d 1250 // Check that enough tracklets contributed
1251 if(vertex->GetNContributors() <= 0) {
1252 DMSG(fDebug,2,"Number of contributors to vertex is %d<=0",
1253 vertex->GetNContributors());
5ca83fee 1254 ip.SetZ(0);
8449e3e0 1255 return kFewContrib;
241cca4d 1256 }
8449e3e0 1257 // #endif
1258
241cca4d 1259 // Check that the uncertainty isn't too large
1260 if (vertex->GetZRes() > fMaxVzErr) {
1261 DMSG(fDebug,2,"Uncertaintity in Z of vertex is too large %f > %f",
1262 vertex->GetZRes(), fMaxVzErr);
8449e3e0 1263 return kUncertain;
241cca4d 1264 }
e83d0620 1265
241cca4d 1266 // Get the z coordiante
5ca83fee 1267 ip.SetZ(vertex->GetZ());
241cca4d 1268 const AliESDVertex* vertexXY = esd.GetPrimaryVertex();
96110c91 1269
5ca83fee 1270
241cca4d 1271 if(!vertexXY->IsFromVertexerZ()) {
5ca83fee 1272 ip.SetX(vertexXY->GetX());
1273 ip.SetY(vertexXY->GetY());
241cca4d 1274 }
8449e3e0 1275 return kVtxOK;
8565b10b 1276}
241cca4d 1277
0bd4b00f 1278//____________________________________________________________________
1279Bool_t
1280AliFMDEventInspector::ReadRunDetails(const AliESDEvent* esd)
1281{
7984e5f7 1282 //
1283 // Read the collision system, collision energy, and L3 field setting
1284 // from the ESD
1285 //
1286 // Parameters:
1287 // esd ESD to get information from
1288 //
1289 // Return:
1290 // true on success, false
1291 //
cc83fca2 1292 // AliInfo(Form("Parameters from 1st ESD event: cms=%s, sNN=%f, field=%f",
1293 // esd->GetBeamType(), 2*esd->GetBeamEnergy(),
1294 // esd->GetMagneticField()));
6ab100ec 1295 DGUARD(fDebug,2,"Read the run details in AliFMDEventInspector");
d4d486f8 1296 const char* sys = esd->GetBeamType();
1297 Float_t cms = 2 * esd->GetBeamEnergy();
1298 Float_t fld = esd->GetMagneticField();
1299 fCollisionSystem = AliForwardUtil::ParseCollisionSystem(sys);
1300 fEnergy = AliForwardUtil::ParseCenterOfMassEnergy(fCollisionSystem,
1301 cms);
1302 fField = AliForwardUtil::ParseMagneticField(fld);
8449e3e0 1303 fRunNumber = esd->GetRunNumber();
1304 StoreInformation();
d4d486f8 1305 if (fCollisionSystem == AliForwardUtil::kUnknown) {
1306 AliWarningF("Unknown collision system: %s - please check", sys);
1307 return false;
1308 }
1309 if (fEnergy <= 0) {
1310 AliWarningF("Unknown CMS energy: %f (%d) - please check", cms, fEnergy);
1311 return false;
1312 }
1313 if (TMath::Abs(fField) > 10) {
1314 AliWarningF("Unknown L3 field setting: %f (%d) - please check", fld,fField);
1315 return false;
1316 }
0bd4b00f 1317
d4d486f8 1318 return true;
0bd4b00f 1319}
1320
241cca4d 1321
1322//____________________________________________________________________
1323const Char_t*
1324AliFMDEventInspector::CodeString(UInt_t code)
1325{
1326 static TString s;
1327 s = "";
1328 if (code & kNoEvent) s.Append("NOEVENT ");
1329 if (code & kNoTriggers) s.Append("NOTRIGGERS ");
1330 if (code & kNoSPD) s.Append("NOSPD ");
1331 if (code & kNoFMD) s.Append("NOFMD ");
1332 if (code & kNoVertex) s.Append("NOVERTEX ");
1333 if (code & kBadVertex) s.Append("BADVERTEX ");
1334 return s.Data();
1335}
0bd4b00f 1336//____________________________________________________________________
1337void
1338AliFMDEventInspector::Print(Option_t*) const
1339{
7984e5f7 1340 //
1341 // Print information
1342 //
1343 // option Not used
1344 //
0bd4b00f 1345 char ind[gROOT->GetDirLevel()+1];
1346 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
1347 ind[gROOT->GetDirLevel()] = '\0';
1348 TString sNN(AliForwardUtil::CenterOfMassEnergyString(fEnergy));
1349 sNN.Strip(TString::kBoth, '0');
1350 sNN.ReplaceAll("GeV", " GeV");
1351 TString field(AliForwardUtil::MagneticFieldString(fField));
1352 field.ReplaceAll("p", "+");
1353 field.ReplaceAll("m", "-");
1354 field.ReplaceAll("kG", " kG");
1355
241cca4d 1356 std::cout << std::boolalpha
1357 << ind << ClassName() << ": " << GetName() << '\n'
2a9e4c0b 1358 << ind << " Vertex bins: " << fVtxAxis.GetNbins() << '\n'
1359 << ind << " Vertex range: [" << fVtxAxis.GetXmin()
1360 << "," << fVtxAxis.GetXmax() << "]\n"
0bd4b00f 1361 << ind << " Low flux cut: " << fLowFluxCut << '\n'
1362 << ind << " Max(delta v_z): " << fMaxVzErr << " cm\n"
e6463868 1363 << ind << " Min(nContrib_pileup): " << fMinPileupContrib << '\n'
1364 << ind << " Min(v-pileup): " << fMinPileupDistance << '\n'
0bd4b00f 1365 << ind << " System: "
1366 << AliForwardUtil::CollisionSystemString(fCollisionSystem) << '\n'
1367 << ind << " CMS energy per nucleon: " << sNN << '\n'
241cca4d 1368 << ind << " Field: " << field << '\n'
5934a3e3 1369 << ind << " Satellite events: " << fUseDisplacedVertices<<'\n'
1370 << ind << " Centrality method: " << fCentMethod << '\n'
1371 << std::noboolalpha;
d8244e9e 1372 if (!fCentAxis) { std::cout << std::flush; return; }
1373 Int_t nBin = fCentAxis->GetNbins();
1374 std::cout << ind << " Centrality axis: " << nBin << " bins"
1375 << std::flush;
1376 for (Int_t i = 0; i < nBin; i++) {
1377 if ((i % 10) == 0) std::cout << '\n' << ind << " ";
1378 std::cout << std::setw(5) << fCentAxis->GetBinLowEdge(i+1) << '-';
1379 }
1380 std::cout << std::setw(5) << fCentAxis->GetBinUpEdge(nBin) << std::endl;
0bd4b00f 1381}
1382
1383
8565b10b 1384//
1385// EOF
1386//
1387