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