2 // This class inspects the event
5 // - AliESDFMD object possibly corrected for sharing
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
12 // Note, that these are added to the master output list
17 #include "AliFMDEventInspector.h"
19 #include "AliESDEvent.h"
20 #include "AliMultiplicity.h"
21 #include "AliAnalysisManager.h"
22 #include "AliInputEventHandler.h"
23 #include "AliTriggerAnalysis.h"
24 #include "AliPhysicsSelection.h"
25 #include "AliAODForwardMult.h"
26 #include "AliForwardUtil.h"
29 #include <TDirectory.h>
34 //====================================================================
35 AliFMDEventInspector::AliFMDEventInspector()
46 fCollisionSystem(kUnknown),
54 //____________________________________________________________________
55 AliFMDEventInspector::AliFMDEventInspector(const char* name)
56 : TNamed("fmdEventInspector", name),
66 fCollisionSystem(kUnknown),
73 // name Name of object
77 //____________________________________________________________________
78 AliFMDEventInspector::AliFMDEventInspector(const AliFMDEventInspector& o)
80 fHEventsTr(o.fHEventsTr),
81 fHEventsTrVtx(o.fHEventsTrVtx),
82 fHTriggers(o.fHTriggers),
84 fLowFluxCut(o.fMaxVzErr),
85 fMaxVzErr(o.fMaxVzErr),
89 fCollisionSystem(o.fCollisionSystem),
96 // o Object to copy from
100 //____________________________________________________________________
101 AliFMDEventInspector::~AliFMDEventInspector()
106 if (fHEventsTr) delete fHEventsTr;
107 if (fHEventsTrVtx) delete fHEventsTrVtx;
108 if (fHTriggers) delete fHTriggers;
109 if (fHType) delete fHType;
110 if (fList) delete fList;
112 //____________________________________________________________________
113 AliFMDEventInspector&
114 AliFMDEventInspector::operator=(const AliFMDEventInspector& o)
117 // Assignement operator
120 // o Object to assign from
123 // Reference to this object
125 TNamed::operator=(o);
126 fHEventsTr = o.fHEventsTr;
127 fHEventsTrVtx = o.fHEventsTrVtx;
128 fHTriggers = o.fHTriggers;
130 fLowFluxCut = o.fLowFluxCut;
131 fMaxVzErr = o.fMaxVzErr;
133 fList = (o.fList ? new TList : 0);
136 fCollisionSystem = o.fCollisionSystem;
138 fList->SetName(GetName());
139 if (fHEventsTr) fList->Add(fHEventsTr);
140 if (fHEventsTrVtx) fList->Add(fHEventsTrVtx);
141 if (fHTriggers) fList->Add(fHTriggers);
142 if (fHType) fList->Add(fHType);
147 //____________________________________________________________________
149 AliFMDEventInspector::FetchHistograms(TList* d,
152 TH1I*& hTriggers) const
155 // Fetch our histograms from the passed list
159 // hEventsTr On return, pointer to histogram, or null
160 // hEventsTrVtx On return, pointer to histogram, or null
161 // hTriggers On return, pointer to histogram, or null
164 // true on success, false otherwise
169 TList* dd = dynamic_cast<TList*>(d->FindObject(GetName()));
170 if (!dd) return kFALSE;
172 hEventsTr = dynamic_cast<TH1I*>(dd->FindObject("nEventsTr"));
173 hEventsTrVtx = dynamic_cast<TH1I*>(dd->FindObject("nEventsTrVtx"));
174 hTriggers = dynamic_cast<TH1I*>(dd->FindObject("triggers"));
176 if (!hEventsTr || !hEventsTrVtx || !hTriggers) return kFALSE;
179 //____________________________________________________________________
181 AliFMDEventInspector::Init(const TAxis& vtxAxis)
184 // Initialize the object
187 // vtxAxis Vertex axis in use
189 fHEventsTr = new TH1I("nEventsTr", "Number of events w/trigger",
193 fHEventsTr->SetXTitle("v_{z} [cm]");
194 fHEventsTr->SetYTitle("# of events");
195 fHEventsTr->SetFillColor(kRed+1);
196 fHEventsTr->SetFillStyle(3001);
197 fHEventsTr->SetDirectory(0);
198 // fHEventsTr->Sumw2();
199 fList->Add(fHEventsTr);
201 fHEventsTrVtx = new TH1I("nEventsTrVtx",
202 "Number of events w/trigger and vertex",
206 fHEventsTrVtx->SetXTitle("v_{z} [cm]");
207 fHEventsTrVtx->SetYTitle("# of events");
208 fHEventsTrVtx->SetFillColor(kBlue+1);
209 fHEventsTrVtx->SetFillStyle(3001);
210 fHEventsTrVtx->SetDirectory(0);
211 // fHEventsTrVtx->Sumw2();
212 fList->Add(fHEventsTrVtx);
215 fHTriggers = new TH1I("triggers", "Triggers", 10, 0, 10);
216 fHTriggers->SetFillColor(kRed+1);
217 fHTriggers->SetFillStyle(3001);
218 fHTriggers->SetStats(0);
219 fHTriggers->SetDirectory(0);
220 fHTriggers->GetXaxis()->SetBinLabel(kInel +1,"INEL");
221 fHTriggers->GetXaxis()->SetBinLabel(kInelGt0+1,"INEL>0");
222 fHTriggers->GetXaxis()->SetBinLabel(kNSD +1,"NSD");
223 fHTriggers->GetXaxis()->SetBinLabel(kEmpty +1,"Empty");
224 fHTriggers->GetXaxis()->SetBinLabel(kA +1,"A");
225 fHTriggers->GetXaxis()->SetBinLabel(kB +1,"B");
226 fHTriggers->GetXaxis()->SetBinLabel(kC +1,"C");
227 fHTriggers->GetXaxis()->SetBinLabel(kE +1,"E");
228 fHTriggers->GetXaxis()->SetBinLabel(9, "spare1");
229 fHTriggers->GetXaxis()->SetBinLabel(10, "spare2");
230 fList->Add(fHTriggers);
232 fHType = new TH1I("type", Form("Event type (cut: SPD mult>%d)",
233 fLowFluxCut), 2, -.5, 1.5);
234 fHType->SetFillColor(kRed+1);
235 fHType->SetFillStyle(3001);
237 fHType->SetDirectory(0);
238 fHType->GetXaxis()->SetBinLabel(1,"Low-flux");
239 fHType->GetXaxis()->SetBinLabel(2,"High-flux");
244 //____________________________________________________________________
246 AliFMDEventInspector::DefineOutput(TList* dir)
249 // Define the output histograms. These are put in a sub list of the
250 // passed list. The histograms are merged before the parent task calls
251 // AliAnalysisTaskSE::Terminate
253 // dir Directory to add to
256 fList->SetName(GetName());
260 //____________________________________________________________________
262 AliFMDEventInspector::Process(const AliESDEvent* event,
273 // triggers On return, the triggers fired
274 // lowFlux On return, true if the event is considered a low-flux
275 // event (according to the setting of fLowFluxCut)
276 // ivz On return, the found vertex bin (1-based). A zero
277 // means outside of the defined vertex range
278 // vz On return, the z position of the interaction
281 // 0 (or kOk) on success, otherwise a bit mask of error codes
284 // Check that we have an event
286 AliWarning("No ESD event found for input event");
290 // Read trigger information from the ESD and store in AOD object
291 if (!ReadTriggers(event, triggers)) {
293 AliWarning("Failed to read triggers from ESD"); }
297 // Check if this is a high-flux event
298 const AliMultiplicity* testmult = event->GetMultiplicity();
301 AliWarning("No central multiplicity object found"); }
304 lowFlux = testmult->GetNumberOfTracklets() < fLowFluxCut;
306 fHType->Fill(lowFlux ? 0 : 1);
308 // Check the FMD ESD data
309 if (!event->GetFMDData()) {
311 AliWarning("No FMD data found in ESD"); }
315 // Get the vertex information
317 Bool_t vzOk = ReadVertex(event, vz);
319 fHEventsTr->Fill(vz);
322 AliWarning("Failed to read vertex from ESD"); }
325 fHEventsTrVtx->Fill(vz);
327 // Get the vertex bin
328 ivz = fHEventsTr->GetXaxis()->FindBin(vz);
329 if (ivz <= 0 || ivz > fHEventsTr->GetXaxis()->GetNbins()) {
331 AliWarning(Form("Vertex @ %f outside of range [%f,%f]",
332 vz, fHEventsTr->GetXaxis()->GetXmin(),
333 fHEventsTr->GetXaxis()->GetXmax())); }
340 //____________________________________________________________________
342 AliFMDEventInspector::ReadTriggers(const AliESDEvent* esd, UInt_t& triggers)
345 // Read the trigger information from the ESD event
349 // triggers On return, contains the trigger bits
352 // @c true on success, @c false otherwise
356 // Get the analysis manager - should always be there
357 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
359 AliWarning("No analysis manager defined!");
363 // Get the input handler - should always be there
364 AliInputEventHandler* ih =
365 static_cast<AliInputEventHandler*>(am->GetInputEventHandler());
367 AliWarning("No input handler");
371 // Get the physics selection - add that by using the macro
372 // AddTaskPhysicsSelection.C
373 AliPhysicsSelection* ps =
374 static_cast<AliPhysicsSelection*>(ih->GetEventSelection());
376 AliWarning("No physics selection");
380 // Check if this is a collision candidate (INEL)
381 Bool_t inel = ps->IsCollisionCandidate(esd);
383 triggers |= AliAODForwardMult::kInel;
384 fHTriggers->Fill(kInel+0.5);
387 // IF this is inel, see if we have a tracklet
389 const AliMultiplicity* spdmult = esd->GetMultiplicity();
391 AliWarning("No SPD multiplicity");
394 Int_t n = spdmult->GetNumberOfTracklets();
395 for (Int_t j = 0; j < n; j++) {
396 if(TMath::Abs(spdmult->GetEta(j)) < 1) {
397 triggers |= AliAODForwardMult::kInelGt0;
398 fHTriggers->Fill(kInelGt0+.5);
405 // Analyse some trigger stuff
406 AliTriggerAnalysis ta;
407 if (ta.IsOfflineTriggerFired(esd, AliTriggerAnalysis::kNSD1)) {
408 triggers |= AliAODForwardMult::kNSD;
409 fHTriggers->Fill(kNSD+.5);
413 TString trigStr = esd->GetFiredTriggerClasses();
414 if (trigStr.Contains("CBEAMB-ABCE-NOPF-ALL")) {
415 triggers |= AliAODForwardMult::kEmpty;
416 fHTriggers->Fill(kEmpty+.5);
419 if (trigStr.Contains("CINT1A-ABCE-NOPF-ALL")) {
420 triggers |= AliAODForwardMult::kA;
421 fHTriggers->Fill(kA+.5);
424 if (trigStr.Contains("CINT1B-ABCE-NOPF-ALL")) {
425 triggers |= AliAODForwardMult::kB;
426 fHTriggers->Fill(kB+.5);
430 if (trigStr.Contains("CINT1C-ABCE-NOPF-ALL")) {
431 triggers |= AliAODForwardMult::kC;
432 fHTriggers->Fill(kC+.5);
435 if (trigStr.Contains("CINT1-E-NOPF-ALL")) {
436 triggers |= AliAODForwardMult::kE;
437 fHTriggers->Fill(kE+.5);
442 //____________________________________________________________________
444 AliFMDEventInspector::ReadVertex(const AliESDEvent* esd, Double_t& vz)
447 // Read the vertex information from the ESD event
451 // vz On return, the vertex Z position
454 // @c true on success, @c false otherwise
458 const AliESDVertex* vertex = esd->GetPrimaryVertexSPD();
461 AliWarning("No SPD vertex found in ESD"); }
465 // Check that enough tracklets contributed
466 if(vertex->GetNContributors() <= 0) {
468 AliWarning(Form("Number of contributors to vertex is %d<=0",
469 vertex->GetNContributors())); }
474 // Check that the uncertainty isn't too large
475 if (vertex->GetZRes() > fMaxVzErr) {
477 AliWarning(Form("Uncertaintity in Z of vertex is too large %f > %f",
478 vertex->GetZRes(), fMaxVzErr)); }
482 // Get the z coordiante
487 //____________________________________________________________________
489 AliFMDEventInspector::ReadRunDetails(const AliESDEvent* esd)
492 // Read the collision system, collision energy, and L3 field setting
496 // esd ESD to get information from
499 // true on success, false
502 AliForwardUtil::ParseCollisionSystem(esd->GetBeamType());
504 AliForwardUtil::ParseCenterOfMassEnergy(fCollisionSystem,
505 2 * esd->GetBeamEnergy());
507 AliForwardUtil::ParseMagneticField(esd->GetMagneticField());
509 if (fCollisionSystem == AliForwardUtil::kUnknown ||
511 TMath::Abs(fField) > 10)
517 //____________________________________________________________________
519 AliFMDEventInspector::Print(Option_t*) const
526 char ind[gROOT->GetDirLevel()+1];
527 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
528 ind[gROOT->GetDirLevel()] = '\0';
529 TString sNN(AliForwardUtil::CenterOfMassEnergyString(fEnergy));
530 sNN.Strip(TString::kBoth, '0');
531 sNN.ReplaceAll("GeV", " GeV");
532 TString field(AliForwardUtil::MagneticFieldString(fField));
533 field.ReplaceAll("p", "+");
534 field.ReplaceAll("m", "-");
535 field.ReplaceAll("kG", " kG");
537 std::cout << ind << "AliFMDEventInspector: " << GetName() << '\n'
538 << ind << " Low flux cut: " << fLowFluxCut << '\n'
539 << ind << " Max(delta v_z): " << fMaxVzErr << " cm\n"
540 << ind << " System: "
541 << AliForwardUtil::CollisionSystemString(fCollisionSystem) << '\n'
542 << ind << " CMS energy per nucleon: " << sNN << '\n'
543 << ind << " Field: " << field << std::endl;