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(const 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",
348 // centObj, centObj->GetQuality()));
350 cent = centObj->GetCentralityPercentileUnchecked("V0M");
352 // AliInfo(Form("Centrality is %f", cent));
355 // Check the FMD ESD data
356 if (!event->GetFMDData()) {
358 AliWarning("No FMD data found in ESD"); }
362 // Get the vertex information
364 Bool_t vzOk = ReadVertex(event, vz);
366 fHEventsTr->Fill(vz);
369 AliWarning("Failed to read vertex from ESD"); }
372 fHEventsTrVtx->Fill(vz);
374 // Get the vertex bin
375 ivz = fHEventsTr->GetXaxis()->FindBin(vz);
376 if (ivz <= 0 || ivz > fHEventsTr->GetXaxis()->GetNbins()) {
378 AliWarning(Form("Vertex @ %f outside of range [%f,%f]",
379 vz, fHEventsTr->GetXaxis()->GetXmin(),
380 fHEventsTr->GetXaxis()->GetXmax())); }
389 //____________________________________________________________________
391 AliFMDEventInspector::ReadTriggers(const AliESDEvent* esd, UInt_t& triggers)
394 // Read the trigger information from the ESD event
398 // triggers On return, contains the trigger bits
401 // @c true on success, @c false otherwise
405 // Get the analysis manager - should always be there
406 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
408 AliWarning("No analysis manager defined!");
412 // Get the input handler - should always be there
413 AliInputEventHandler* ih =
414 static_cast<AliInputEventHandler*>(am->GetInputEventHandler());
416 AliWarning("No input handler");
420 AliMCEventHandler* mcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
421 AliMCEvent* mcEvent = 0;
423 mcEvent = mcHandler->MCEvent();
426 //Assign MC only triggers : True NSD etc.
427 AliHeader* header = mcEvent->Header();
428 AliGenEventHeader* genHeader = header->GenEventHeader();
430 AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(genHeader);
431 AliGenDPMjetEventHeader* dpmHeader = dynamic_cast<AliGenDPMjetEventHeader*>(header->GenEventHeader());
433 if(pythiaGenHeader) {
434 Int_t pythiaType = pythiaGenHeader->ProcessType();
435 if(pythiaType==92 || pythiaType==93)
439 Int_t processType = dpmHeader->ProcessType();
440 if(processType == 5 || processType == 6)
445 triggers |= AliAODForwardMult::kMCNSD;
446 fHTriggers->Fill(kMCNSD+0.5);
451 // Check if this is a collision candidate (INEL)
452 // Note, that we should use the value cached in the input
453 // handler rather than calling IsCollisionCandiate directly
454 // on the AliPhysicsSelection obejct. If we called the latter
455 // then the AliPhysicsSelection object would overcount by a
457 Bool_t inel = ih->IsEventSelected();
459 triggers |= AliAODForwardMult::kInel;
460 fHTriggers->Fill(kInel+0.5);
463 // If this is inel, see if we have a tracklet
465 const AliMultiplicity* spdmult = esd->GetMultiplicity();
467 AliWarning("No SPD multiplicity");
470 // Check if we have one or more tracklets
471 // in the range -1 < eta < 1 to set the INEL>0
473 Int_t n = spdmult->GetNumberOfTracklets();
474 for (Int_t j = 0; j < n; j++) {
475 if(TMath::Abs(spdmult->GetEta(j)) < 1) {
476 triggers |= AliAODForwardMult::kInelGt0;
477 fHTriggers->Fill(kInelGt0+.5);
484 // Analyse some trigger stuff
485 AliTriggerAnalysis ta;
486 if (ta.IsOfflineTriggerFired(esd, AliTriggerAnalysis::kNSD1)) {
487 triggers |= AliAODForwardMult::kNSD;
488 fHTriggers->Fill(kNSD+.5);
491 Bool_t pileup = esd->IsPileupFromSPD(3,0.8);
493 triggers |= AliAODForwardMult::kPileUp;
494 fHTriggers->Fill(kPileUp+.5);
498 TString trigStr = esd->GetFiredTriggerClasses();
499 // AliWarning(Form("Fired trigger classes: %s", trigStr.Data()));
500 fHWords->Fill(trigStr.Data(), 1);
502 if (trigStr.Contains("MB1") || trigStr.Contains("MBBG3"))
503 triggers |= AliAOODForwardMult::kB;
504 if (trigStr.Contains("COTA"))
505 triggers |= AliAODForwardMult::kA;
506 if (trigStr.Contains("COTC"))
507 triggers |= AliAODForwardMult::kC;
509 if (trigStr.Contains("CBEAMB-ABCE-NOPF-ALL")) {
510 triggers |= AliAODForwardMult::kEmpty;
511 fHTriggers->Fill(kEmpty+.5);
514 if (trigStr.Contains("CINT1A-ABCE-NOPF-ALL")) {
515 triggers |= AliAODForwardMult::kA;
516 fHTriggers->Fill(kA+.5);
519 if (trigStr.Contains("CINT1B-ABCE-NOPF-ALL")) {
520 triggers |= AliAODForwardMult::kB;
521 fHTriggers->Fill(kB+.5);
525 if (trigStr.Contains("CINT1C-ABCE-NOPF-ALL")) {
526 triggers |= AliAODForwardMult::kC;
527 fHTriggers->Fill(kC+.5);
530 if (trigStr.Contains("CINT1-E-NOPF-ALL")) {
531 triggers |= AliAODForwardMult::kE;
532 fHTriggers->Fill(kE+.5);
537 //____________________________________________________________________
539 AliFMDEventInspector::ReadVertex(const AliESDEvent* esd, Double_t& vz)
542 // Read the vertex information from the ESD event
546 // vz On return, the vertex Z position
549 // @c true on success, @c false otherwise
553 const AliESDVertex* vertex = esd->GetPrimaryVertexSPD();
556 AliWarning("No SPD vertex found in ESD"); }
560 // Check that enough tracklets contributed
561 if(vertex->GetNContributors() <= 0) {
563 AliWarning(Form("Number of contributors to vertex is %d<=0",
564 vertex->GetNContributors())); }
569 // Check that the uncertainty isn't too large
570 if (vertex->GetZRes() > fMaxVzErr) {
572 AliWarning(Form("Uncertaintity in Z of vertex is too large %f > %f",
573 vertex->GetZRes(), fMaxVzErr)); }
579 if (vertex->IsFromVertexerZ()) {
582 if (TMath::Sqrt(TMath::Power(vertex->GetX(),2) + TMath::Power(vertex->GetY(),2)) > 3 ) {
587 // Get the z coordiante
592 //____________________________________________________________________
594 AliFMDEventInspector::ReadRunDetails(const AliESDEvent* esd)
597 // Read the collision system, collision energy, and L3 field setting
601 // esd ESD to get information from
604 // true on success, false
606 // AliInfo(Form("Parameters from 1st ESD event: cms=%s, sNN=%f, field=%f",
607 // esd->GetBeamType(), 2*esd->GetBeamEnergy(),
608 // esd->GetMagneticField()));
610 AliForwardUtil::ParseCollisionSystem(esd->GetBeamType());
612 AliForwardUtil::ParseCenterOfMassEnergy(fCollisionSystem,
613 2 * esd->GetBeamEnergy());
615 AliForwardUtil::ParseMagneticField(esd->GetMagneticField());
617 if (fCollisionSystem == AliForwardUtil::kUnknown ||
619 TMath::Abs(fField) > 10)
625 //____________________________________________________________________
627 AliFMDEventInspector::Print(Option_t*) const
634 char ind[gROOT->GetDirLevel()+1];
635 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
636 ind[gROOT->GetDirLevel()] = '\0';
637 TString sNN(AliForwardUtil::CenterOfMassEnergyString(fEnergy));
638 sNN.Strip(TString::kBoth, '0');
639 sNN.ReplaceAll("GeV", " GeV");
640 TString field(AliForwardUtil::MagneticFieldString(fField));
641 field.ReplaceAll("p", "+");
642 field.ReplaceAll("m", "-");
643 field.ReplaceAll("kG", " kG");
645 std::cout << ind << "AliFMDEventInspector: " << GetName() << '\n'
646 << ind << " Low flux cut: " << fLowFluxCut << '\n'
647 << ind << " Max(delta v_z): " << fMaxVzErr << " cm\n"
648 << ind << " System: "
649 << AliForwardUtil::CollisionSystemString(fCollisionSystem) << '\n'
650 << ind << " CMS energy per nucleon: " << sNN << '\n'
651 << ind << " Field: " << field << std::endl;