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"
27 #include "AliCentrality.h"
30 #include <TDirectory.h>
34 #include "AliMCEvent.h"
35 #include "AliGenPythiaEventHeader.h"
36 #include "AliGenDPMjetEventHeader.h"
37 #include "AliHeader.h"
38 #include "AliMCEventHandler.h"
39 //====================================================================
40 AliFMDEventInspector::AliFMDEventInspector()
53 fCollisionSystem(kUnknown),
61 //____________________________________________________________________
62 AliFMDEventInspector::AliFMDEventInspector(const char* name)
63 : TNamed("fmdEventInspector", name),
75 fCollisionSystem(kUnknown),
82 // name Name of object
86 //____________________________________________________________________
87 AliFMDEventInspector::AliFMDEventInspector(const AliFMDEventInspector& o)
89 fHEventsTr(o.fHEventsTr),
90 fHEventsTrVtx(o.fHEventsTrVtx),
91 fHTriggers(o.fHTriggers),
95 fLowFluxCut(o.fLowFluxCut),
96 fMaxVzErr(o.fMaxVzErr),
100 fCollisionSystem(o.fCollisionSystem),
107 // o Object to copy from
111 //____________________________________________________________________
112 AliFMDEventInspector::~AliFMDEventInspector()
117 if (fHEventsTr) delete fHEventsTr;
118 if (fHEventsTrVtx) delete fHEventsTrVtx;
119 if (fHTriggers) delete fHTriggers;
120 if (fHType) delete fHType;
121 if (fHWords) delete fHWords;
122 if (fHCent) delete fHCent;
123 if (fList) delete fList;
125 //____________________________________________________________________
126 AliFMDEventInspector&
127 AliFMDEventInspector::operator=(const AliFMDEventInspector& o)
130 // Assignement operator
133 // o Object to assign from
136 // Reference to this object
138 TNamed::operator=(o);
139 fHEventsTr = o.fHEventsTr;
140 fHEventsTrVtx = o.fHEventsTrVtx;
141 fHTriggers = o.fHTriggers;
145 fLowFluxCut = o.fLowFluxCut;
146 fMaxVzErr = o.fMaxVzErr;
148 fList = (o.fList ? new TList : 0);
151 fCollisionSystem = o.fCollisionSystem;
153 fList->SetName(GetName());
154 if (fHEventsTr) fList->Add(fHEventsTr);
155 if (fHEventsTrVtx) fList->Add(fHEventsTrVtx);
156 if (fHTriggers) fList->Add(fHTriggers);
157 if (fHType) fList->Add(fHType);
158 if (fHWords) fList->Add(fHWords);
159 if (fHCent) fList->Add(fHCent);
164 //____________________________________________________________________
166 AliFMDEventInspector::FetchHistograms(TList* d,
169 TH1I*& hTriggers) const
172 // Fetch our histograms from the passed list
176 // hEventsTr On return, pointer to histogram, or null
177 // hEventsTrVtx On return, pointer to histogram, or null
178 // hTriggers On return, pointer to histogram, or null
181 // true on success, false otherwise
186 TList* dd = dynamic_cast<TList*>(d->FindObject(GetName()));
187 if (!dd) return kFALSE;
189 hEventsTr = dynamic_cast<TH1I*>(dd->FindObject("nEventsTr"));
190 hEventsTrVtx = dynamic_cast<TH1I*>(dd->FindObject("nEventsTrVtx"));
191 hTriggers = dynamic_cast<TH1I*>(dd->FindObject("triggers"));
193 if (!hEventsTr || !hEventsTrVtx || !hTriggers) return kFALSE;
196 //____________________________________________________________________
198 AliFMDEventInspector::Init(const TAxis& vtxAxis)
201 // Initialize the object
204 // vtxAxis Vertex axis in use
206 fHEventsTr = new TH1I("nEventsTr", "Number of events w/trigger",
210 fHEventsTr->SetXTitle("v_{z} [cm]");
211 fHEventsTr->SetYTitle("# of events");
212 fHEventsTr->SetFillColor(kRed+1);
213 fHEventsTr->SetFillStyle(3001);
214 fHEventsTr->SetDirectory(0);
215 // fHEventsTr->Sumw2();
216 fList->Add(fHEventsTr);
218 fHEventsTrVtx = new TH1I("nEventsTrVtx",
219 "Number of events w/trigger and vertex",
223 fHEventsTrVtx->SetXTitle("v_{z} [cm]");
224 fHEventsTrVtx->SetYTitle("# of events");
225 fHEventsTrVtx->SetFillColor(kBlue+1);
226 fHEventsTrVtx->SetFillStyle(3001);
227 fHEventsTrVtx->SetDirectory(0);
228 // fHEventsTrVtx->Sumw2();
229 fList->Add(fHEventsTrVtx);
232 fHTriggers = new TH1I("triggers", "Triggers", 10, 0, 10);
233 fHTriggers->SetFillColor(kRed+1);
234 fHTriggers->SetFillStyle(3001);
235 fHTriggers->SetStats(0);
236 fHTriggers->SetDirectory(0);
237 fHTriggers->GetXaxis()->SetBinLabel(kInel +1,"INEL");
238 fHTriggers->GetXaxis()->SetBinLabel(kInelGt0+1,"INEL>0");
239 fHTriggers->GetXaxis()->SetBinLabel(kNSD +1,"NSD");
240 fHTriggers->GetXaxis()->SetBinLabel(kEmpty +1,"Empty");
241 fHTriggers->GetXaxis()->SetBinLabel(kA +1,"A");
242 fHTriggers->GetXaxis()->SetBinLabel(kB +1,"B");
243 fHTriggers->GetXaxis()->SetBinLabel(kC +1,"C");
244 fHTriggers->GetXaxis()->SetBinLabel(kE +1,"E");
245 fHTriggers->GetXaxis()->SetBinLabel(kPileUp +1,"Pileup");
246 fHTriggers->GetXaxis()->SetBinLabel(kMCNSD +1,"nsd");
247 fList->Add(fHTriggers);
249 fHType = new TH1I("type", Form("Event type (cut: SPD mult>%d)",
250 fLowFluxCut), 2, -.5, 1.5);
251 fHType->SetFillColor(kRed+1);
252 fHType->SetFillStyle(3001);
254 fHType->SetDirectory(0);
255 fHType->GetXaxis()->SetBinLabel(1,"Low-flux");
256 fHType->GetXaxis()->SetBinLabel(2,"High-flux");
260 fHWords = new TH1I("words", "Trigger words seen", 1, 0, 0);
261 fHWords->SetFillColor(kBlue+1);
262 fHWords->SetFillStyle(3001);
263 fHWords->SetStats(0);
264 fHWords->SetDirectory(0);
265 fHWords->SetBit(TH1::kCanRebin);
268 fHCent = new TH1F("cent", "Centrality", 101, -1.5, 100.5);
269 fHCent->SetFillColor(kBlue+1);
270 fHCent->SetFillStyle(3001);
272 fHCent->SetDirectory(0);
273 fHCent->SetXTitle("Centrality [%]");
274 fHCent->SetYTitle("Events");
278 //____________________________________________________________________
280 AliFMDEventInspector::DefineOutput(TList* dir)
283 // Define the output histograms. These are put in a sub list of the
284 // passed list. The histograms are merged before the parent task calls
285 // AliAnalysisTaskSE::Terminate
287 // dir Directory to add to
290 fList->SetName(GetName());
294 //____________________________________________________________________
296 AliFMDEventInspector::Process(const AliESDEvent* event,
308 // triggers On return, the triggers fired
309 // lowFlux On return, true if the event is considered a low-flux
310 // event (according to the setting of fLowFluxCut)
311 // ivz On return, the found vertex bin (1-based). A zero
312 // means outside of the defined vertex range
313 // vz On return, the z position of the interaction
314 // cent On return, the centrality - if not available < 0
317 // 0 (or kOk) on success, otherwise a bit mask of error codes
320 // Check that we have an event
322 AliWarning("No ESD event found for input event");
326 // Read trigger information from the ESD and store in AOD object
327 if (!ReadTriggers(event, triggers)) {
329 AliWarning("Failed to read triggers from ESD"); }
333 // Check if this is a high-flux event
334 const AliMultiplicity* testmult = event->GetMultiplicity();
337 AliWarning("No central multiplicity object found"); }
340 lowFlux = testmult->GetNumberOfTracklets() < fLowFluxCut;
342 fHType->Fill(lowFlux ? 0 : 1);
345 AliCentrality* centObj = const_cast<AliESDEvent*>(event)->GetCentrality();
347 AliInfo(Form("Got centrality object %p with quality %d", centObj, centObj->GetQuality()));
349 cent = centObj->GetCentralityPercentileUnchecked("V0M");
351 AliInfo(Form("Centrality is %f", cent));
354 // Check the FMD ESD data
355 if (!event->GetFMDData()) {
357 AliWarning("No FMD data found in ESD"); }
361 // Get the vertex information
363 Bool_t vzOk = ReadVertex(event, vz);
365 fHEventsTr->Fill(vz);
368 AliWarning("Failed to read vertex from ESD"); }
371 fHEventsTrVtx->Fill(vz);
373 // Get the vertex bin
374 ivz = fHEventsTr->GetXaxis()->FindBin(vz);
375 if (ivz <= 0 || ivz > fHEventsTr->GetXaxis()->GetNbins()) {
377 AliWarning(Form("Vertex @ %f outside of range [%f,%f]",
378 vz, fHEventsTr->GetXaxis()->GetXmin(),
379 fHEventsTr->GetXaxis()->GetXmax())); }
388 //____________________________________________________________________
390 AliFMDEventInspector::ReadTriggers(const AliESDEvent* esd, UInt_t& triggers)
393 // Read the trigger information from the ESD event
397 // triggers On return, contains the trigger bits
400 // @c true on success, @c false otherwise
404 // Get the analysis manager - should always be there
405 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
407 AliWarning("No analysis manager defined!");
411 // Get the input handler - should always be there
412 AliInputEventHandler* ih =
413 static_cast<AliInputEventHandler*>(am->GetInputEventHandler());
415 AliWarning("No input handler");
419 AliMCEventHandler* mcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
420 AliMCEvent* mcEvent = 0;
422 mcEvent = mcHandler->MCEvent();
425 //Assign MC only triggers : True NSD etc.
426 AliHeader* header = mcEvent->Header();
427 AliGenEventHeader* genHeader = header->GenEventHeader();
429 AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(genHeader);
430 AliGenDPMjetEventHeader* dpmHeader = dynamic_cast<AliGenDPMjetEventHeader*>(header->GenEventHeader());
432 if(pythiaGenHeader) {
433 Int_t pythiaType = pythiaGenHeader->ProcessType();
434 if(pythiaType==92 || pythiaType==93)
438 Int_t processType = dpmHeader->ProcessType();
439 if(processType == 5 || processType == 6)
444 triggers |= AliAODForwardMult::kMCNSD;
445 fHTriggers->Fill(kMCNSD+0.5);
450 // Check if this is a collision candidate (INEL)
451 // Note, that we should use the value cached in the input
452 // handler rather than calling IsCollisionCandiate directly
453 // on the AliPhysicsSelection obejct. If we called the latter
454 // then the AliPhysicsSelection object would overcount by a
456 Bool_t inel = ih->IsEventSelected();
458 triggers |= AliAODForwardMult::kInel;
459 fHTriggers->Fill(kInel+0.5);
462 // If this is inel, see if we have a tracklet
464 const AliMultiplicity* spdmult = esd->GetMultiplicity();
466 AliWarning("No SPD multiplicity");
469 // Check if we have one or more tracklets
470 // in the range -1 < eta < 1 to set the INEL>0
472 Int_t n = spdmult->GetNumberOfTracklets();
473 for (Int_t j = 0; j < n; j++) {
474 if(TMath::Abs(spdmult->GetEta(j)) < 1) {
475 triggers |= AliAODForwardMult::kInelGt0;
476 fHTriggers->Fill(kInelGt0+.5);
483 // Analyse some trigger stuff
484 AliTriggerAnalysis ta;
485 if (ta.IsOfflineTriggerFired(esd, AliTriggerAnalysis::kNSD1)) {
486 triggers |= AliAODForwardMult::kNSD;
487 fHTriggers->Fill(kNSD+.5);
490 Bool_t pileup = esd->IsPileupFromSPD(3,0.8);
492 triggers |= AliAODForwardMult::kPileUp;
493 fHTriggers->Fill(kPileUp+.5);
497 TString trigStr = esd->GetFiredTriggerClasses();
498 // AliWarning(Form("Fired trigger classes: %s", trigStr.Data()));
499 fHWords->Fill(trigStr.Data(), 1);
501 if (trigStr.Contains("MB1") || trigStr.Contains("MBBG3"))
502 triggers |= AliAOODForwardMult::kB;
503 if (trigStr.Contains("COTA"))
504 triggers |= AliAODForwardMult::kA;
505 if (trigStr.Contains("COTC"))
506 triggers |= AliAODForwardMult::kC;
508 if (trigStr.Contains("CBEAMB-ABCE-NOPF-ALL")) {
509 triggers |= AliAODForwardMult::kEmpty;
510 fHTriggers->Fill(kEmpty+.5);
513 if (trigStr.Contains("CINT1A-ABCE-NOPF-ALL")) {
514 triggers |= AliAODForwardMult::kA;
515 fHTriggers->Fill(kA+.5);
518 if (trigStr.Contains("CINT1B-ABCE-NOPF-ALL")) {
519 triggers |= AliAODForwardMult::kB;
520 fHTriggers->Fill(kB+.5);
524 if (trigStr.Contains("CINT1C-ABCE-NOPF-ALL")) {
525 triggers |= AliAODForwardMult::kC;
526 fHTriggers->Fill(kC+.5);
529 if (trigStr.Contains("CINT1-E-NOPF-ALL")) {
530 triggers |= AliAODForwardMult::kE;
531 fHTriggers->Fill(kE+.5);
536 //____________________________________________________________________
538 AliFMDEventInspector::ReadVertex(const AliESDEvent* esd, Double_t& vz)
541 // Read the vertex information from the ESD event
545 // vz On return, the vertex Z position
548 // @c true on success, @c false otherwise
552 const AliESDVertex* vertex = esd->GetPrimaryVertexSPD();
555 AliWarning("No SPD vertex found in ESD"); }
559 // Check that enough tracklets contributed
560 if(vertex->GetNContributors() <= 0) {
562 AliWarning(Form("Number of contributors to vertex is %d<=0",
563 vertex->GetNContributors())); }
568 // Check that the uncertainty isn't too large
569 if (vertex->GetZRes() > fMaxVzErr) {
571 AliWarning(Form("Uncertaintity in Z of vertex is too large %f > %f",
572 vertex->GetZRes(), fMaxVzErr)); }
578 if (vertex->IsFromVertexerZ()) {
581 if (TMath::Sqrt(TMath::Power(vertex->GetX(),2) + TMath::Power(vertex->GetY(),2)) > 3 ) {
586 // Get the z coordiante
591 //____________________________________________________________________
593 AliFMDEventInspector::ReadRunDetails(const AliESDEvent* esd)
596 // Read the collision system, collision energy, and L3 field setting
600 // esd ESD to get information from
603 // true on success, false
605 // AliInfo(Form("Parameters from 1st ESD event: cms=%s, sNN=%f, field=%f",
606 // esd->GetBeamType(), 2*esd->GetBeamEnergy(),
607 // esd->GetMagneticField()));
609 AliForwardUtil::ParseCollisionSystem(esd->GetBeamType());
611 AliForwardUtil::ParseCenterOfMassEnergy(fCollisionSystem,
612 2 * esd->GetBeamEnergy());
614 AliForwardUtil::ParseMagneticField(esd->GetMagneticField());
616 if (fCollisionSystem == AliForwardUtil::kUnknown ||
618 TMath::Abs(fField) > 10)
624 //____________________________________________________________________
626 AliFMDEventInspector::Print(Option_t*) const
633 char ind[gROOT->GetDirLevel()+1];
634 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
635 ind[gROOT->GetDirLevel()] = '\0';
636 TString sNN(AliForwardUtil::CenterOfMassEnergyString(fEnergy));
637 sNN.Strip(TString::kBoth, '0');
638 sNN.ReplaceAll("GeV", " GeV");
639 TString field(AliForwardUtil::MagneticFieldString(fField));
640 field.ReplaceAll("p", "+");
641 field.ReplaceAll("m", "-");
642 field.ReplaceAll("kG", " kG");
644 std::cout << ind << "AliFMDEventInspector: " << GetName() << '\n'
645 << ind << " Low flux cut: " << fLowFluxCut << '\n'
646 << ind << " Max(delta v_z): " << fMaxVzErr << " cm\n"
647 << ind << " System: "
648 << AliForwardUtil::CollisionSystemString(fCollisionSystem) << '\n'
649 << ind << " CMS energy per nucleon: " << sNN << '\n'
650 << ind << " Field: " << field << std::endl;