1 #include "AliFMDEventInspector.h"
3 #include "AliESDEvent.h"
4 #include "AliMultiplicity.h"
5 #include "AliAnalysisManager.h"
6 #include "AliInputEventHandler.h"
7 #include "AliTriggerAnalysis.h"
8 #include "AliPhysicsSelection.h"
9 #include "AliAODForwardMult.h"
10 #include "AliForwardUtil.h"
13 #include <TDirectory.h>
18 //====================================================================
19 AliFMDEventInspector::AliFMDEventInspector()
30 fCollisionSystem(kUnknown),
35 //____________________________________________________________________
36 AliFMDEventInspector::AliFMDEventInspector(const char* name)
37 : TNamed("fmdEventInspector", name),
47 fCollisionSystem(kUnknown),
52 //____________________________________________________________________
53 AliFMDEventInspector::AliFMDEventInspector(const AliFMDEventInspector& o)
55 fHEventsTr(o.fHEventsTr),
56 fHEventsTrVtx(o.fHEventsTrVtx),
57 fHTriggers(o.fHTriggers),
59 fLowFluxCut(o.fMaxVzErr),
60 fMaxVzErr(o.fMaxVzErr),
64 fCollisionSystem(o.fCollisionSystem),
69 //____________________________________________________________________
70 AliFMDEventInspector::~AliFMDEventInspector()
72 if (fHEventsTr) delete fHEventsTr;
73 if (fHEventsTrVtx) delete fHEventsTrVtx;
74 if (fHTriggers) delete fHTriggers;
75 if (fHType) delete fHType;
76 if (fList) delete fList;
78 //____________________________________________________________________
80 AliFMDEventInspector::operator=(const AliFMDEventInspector& o)
83 fHEventsTr = o.fHEventsTr;
84 fHEventsTrVtx = o.fHEventsTrVtx;
85 fHTriggers = o.fHTriggers;
87 fLowFluxCut = o.fLowFluxCut;
88 fMaxVzErr = o.fMaxVzErr;
90 fList = (o.fList ? new TList : 0);
93 fCollisionSystem = o.fCollisionSystem;
95 fList->SetName(GetName());
96 if (fHEventsTr) fList->Add(fHEventsTr);
97 if (fHEventsTrVtx) fList->Add(fHEventsTrVtx);
98 if (fHTriggers) fList->Add(fHTriggers);
99 if (fHType) fList->Add(fHType);
104 //____________________________________________________________________
106 AliFMDEventInspector::FetchHistograms(TList* d,
109 TH1I*& hTriggers) const
114 TList* dd = dynamic_cast<TList*>(d->FindObject(GetName()));
115 if (!dd) return kFALSE;
117 hEventsTr = dynamic_cast<TH1I*>(dd->FindObject("nEventsTr"));
118 hEventsTrVtx = dynamic_cast<TH1I*>(dd->FindObject("nEventsTrVtx"));
119 hTriggers = dynamic_cast<TH1I*>(dd->FindObject("triggers"));
121 if (!hEventsTr || !hEventsTrVtx || !hTriggers) return kFALSE;
124 //____________________________________________________________________
126 AliFMDEventInspector::Init(const TAxis& vtxAxis)
128 fHEventsTr = new TH1I("nEventsTr", "Number of events w/trigger",
132 fHEventsTr->SetXTitle("v_{z} [cm]");
133 fHEventsTr->SetYTitle("# of events");
134 fHEventsTr->SetFillColor(kRed+1);
135 fHEventsTr->SetFillStyle(3001);
136 fHEventsTr->SetDirectory(0);
137 // fHEventsTr->Sumw2();
138 fList->Add(fHEventsTr);
140 fHEventsTrVtx = new TH1I("nEventsTrVtx",
141 "Number of events w/trigger and vertex",
145 fHEventsTrVtx->SetXTitle("v_{z} [cm]");
146 fHEventsTrVtx->SetYTitle("# of events");
147 fHEventsTrVtx->SetFillColor(kBlue+1);
148 fHEventsTrVtx->SetFillStyle(3001);
149 fHEventsTrVtx->SetDirectory(0);
150 // fHEventsTrVtx->Sumw2();
151 fList->Add(fHEventsTrVtx);
154 fHTriggers = new TH1I("triggers", "Triggers", 10, 0, 10);
155 fHTriggers->SetFillColor(kRed+1);
156 fHTriggers->SetFillStyle(3001);
157 fHTriggers->SetStats(0);
158 fHTriggers->SetDirectory(0);
159 fHTriggers->GetXaxis()->SetBinLabel(kInel +1,"INEL");
160 fHTriggers->GetXaxis()->SetBinLabel(kInelGt0+1,"INEL>0");
161 fHTriggers->GetXaxis()->SetBinLabel(kNSD +1,"NSD");
162 fHTriggers->GetXaxis()->SetBinLabel(kEmpty +1,"Empty");
163 fHTriggers->GetXaxis()->SetBinLabel(kA +1,"A");
164 fHTriggers->GetXaxis()->SetBinLabel(kB +1,"B");
165 fHTriggers->GetXaxis()->SetBinLabel(kC +1,"C");
166 fHTriggers->GetXaxis()->SetBinLabel(kE +1,"E");
167 fHTriggers->GetXaxis()->SetBinLabel(9, "spare1");
168 fHTriggers->GetXaxis()->SetBinLabel(10, "spare2");
169 fList->Add(fHTriggers);
171 fHType = new TH1I("type", Form("Event type (cut: SPD mult>%d)",
172 fLowFluxCut), 2, -.5, 1.5);
173 fHType->SetFillColor(kRed+1);
174 fHType->SetFillStyle(3001);
176 fHType->SetDirectory(0);
177 fHType->GetXaxis()->SetBinLabel(1,"Low-flux");
178 fHType->GetXaxis()->SetBinLabel(2,"High-flux");
183 //____________________________________________________________________
185 AliFMDEventInspector::DefineOutput(TList* dir)
188 fList->SetName(GetName());
192 //____________________________________________________________________
194 AliFMDEventInspector::Process(const AliESDEvent* event,
200 // Check that we have an event
202 AliWarning("No ESD event found for input event");
206 // Read trigger information from the ESD and store in AOD object
207 if (!ReadTriggers(event, triggers)) {
209 AliWarning("Failed to read triggers from ESD"); }
213 // Check if this is a high-flux event
214 const AliMultiplicity* testmult = event->GetMultiplicity();
217 AliWarning("No central multiplicity object found"); }
220 lowFlux = testmult->GetNumberOfTracklets() < fLowFluxCut;
222 fHType->Fill(lowFlux ? 0 : 1);
224 // Check the FMD ESD data
225 if (!event->GetFMDData()) {
227 AliWarning("No FMD data found in ESD"); }
231 // Get the vertex information
233 Bool_t vzOk = ReadVertex(event, vz);
235 fHEventsTr->Fill(vz);
238 AliWarning("Failed to read vertex from ESD"); }
241 fHEventsTrVtx->Fill(vz);
243 // Get the vertex bin
244 ivz = fHEventsTr->GetXaxis()->FindBin(vz);
245 if (ivz <= 0 || ivz > fHEventsTr->GetXaxis()->GetNbins()) {
247 AliWarning(Form("Vertex @ %f outside of range [%f,%f]",
248 vz, fHEventsTr->GetXaxis()->GetXmin(),
249 fHEventsTr->GetXaxis()->GetXmax())); }
256 //____________________________________________________________________
258 AliFMDEventInspector::ReadTriggers(const AliESDEvent* esd, UInt_t& triggers)
262 // Get the analysis manager - should always be there
263 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
265 AliWarning("No analysis manager defined!");
269 // Get the input handler - should always be there
270 AliInputEventHandler* ih =
271 static_cast<AliInputEventHandler*>(am->GetInputEventHandler());
273 AliWarning("No input handler");
277 // Get the physics selection - add that by using the macro
278 // AddTaskPhysicsSelection.C
279 AliPhysicsSelection* ps =
280 static_cast<AliPhysicsSelection*>(ih->GetEventSelection());
282 AliWarning("No physics selection");
286 // Check if this is a collision candidate (INEL)
287 Bool_t inel = ps->IsCollisionCandidate(esd);
289 triggers |= AliAODForwardMult::kInel;
290 fHTriggers->Fill(kInel+0.5);
293 // IF this is inel, see if we have a tracklet
295 const AliMultiplicity* spdmult = esd->GetMultiplicity();
297 AliWarning("No SPD multiplicity");
300 Int_t n = spdmult->GetNumberOfTracklets();
301 for (Int_t j = 0; j < n; j++) {
302 if(TMath::Abs(spdmult->GetEta(j)) < 1) {
303 triggers |= AliAODForwardMult::kInelGt0;
304 fHTriggers->Fill(kInelGt0+.5);
311 // Analyse some trigger stuff
312 AliTriggerAnalysis ta;
313 if (ta.IsOfflineTriggerFired(esd, AliTriggerAnalysis::kNSD1)) {
314 triggers |= AliAODForwardMult::kNSD;
315 fHTriggers->Fill(kNSD+.5);
319 TString trigStr = esd->GetFiredTriggerClasses();
320 if (trigStr.Contains("CBEAMB-ABCE-NOPF-ALL")) {
321 triggers |= AliAODForwardMult::kEmpty;
322 fHTriggers->Fill(kEmpty+.5);
325 if (trigStr.Contains("CINT1A-ABCE-NOPF-ALL")) {
326 triggers |= AliAODForwardMult::kA;
327 fHTriggers->Fill(kA+.5);
330 if (trigStr.Contains("CINT1B-ABCE-NOPF-ALL")) {
331 triggers |= AliAODForwardMult::kB;
332 fHTriggers->Fill(kB+.5);
336 if (trigStr.Contains("CINT1C-ABCE-NOPF-ALL")) {
337 triggers |= AliAODForwardMult::kC;
338 fHTriggers->Fill(kC+.5);
341 if (trigStr.Contains("CINT1-E-NOPF-ALL")) {
342 triggers |= AliAODForwardMult::kE;
343 fHTriggers->Fill(kE+.5);
348 //____________________________________________________________________
350 AliFMDEventInspector::ReadVertex(const AliESDEvent* esd, Double_t& vz)
354 const AliESDVertex* vertex = esd->GetPrimaryVertexSPD();
357 AliWarning("No SPD vertex found in ESD"); }
361 // Check that enough tracklets contributed
362 if(vertex->GetNContributors() <= 0) {
364 AliWarning(Form("Number of contributors to vertex is %d<=0",
365 vertex->GetNContributors())); }
370 // Check that the uncertainty isn't too large
371 if (vertex->GetZRes() > fMaxVzErr) {
373 AliWarning(Form("Uncertaintity in Z of vertex is too large %f > %f",
374 vertex->GetZRes(), fMaxVzErr)); }
378 // Get the z coordiante
383 //____________________________________________________________________
385 AliFMDEventInspector::ReadRunDetails(const AliESDEvent* esd)
388 AliForwardUtil::ParseCollisionSystem(esd->GetBeamType());
390 AliForwardUtil::ParseCenterOfMassEnergy(fCollisionSystem,
391 2 * esd->GetBeamEnergy());
393 AliForwardUtil::ParseMagneticField(esd->GetMagneticField());
395 if (fCollisionSystem == AliForwardUtil::kUnknown ||
397 TMath::Abs(fField) > 10)
403 //____________________________________________________________________
405 AliFMDEventInspector::Print(Option_t*) const
407 char ind[gROOT->GetDirLevel()+1];
408 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
409 ind[gROOT->GetDirLevel()] = '\0';
410 TString sNN(AliForwardUtil::CenterOfMassEnergyString(fEnergy));
411 sNN.Strip(TString::kBoth, '0');
412 sNN.ReplaceAll("GeV", " GeV");
413 TString field(AliForwardUtil::MagneticFieldString(fField));
414 field.ReplaceAll("p", "+");
415 field.ReplaceAll("m", "-");
416 field.ReplaceAll("kG", " kG");
418 std::cout << ind << "AliFMDEventInspector: " << GetName() << '\n'
419 << ind << " Low flux cut: " << fLowFluxCut << '\n'
420 << ind << " Max(delta v_z): " << fMaxVzErr << " cm\n"
421 << ind << " System: "
422 << AliForwardUtil::CollisionSystemString(fCollisionSystem) << '\n'
423 << ind << " CMS energy per nucleon: " << sNN << '\n'
424 << ind << " Field: " << field << std::endl;