AliPhysics  a76316e (a76316e)
AliAnalysisTaskEmcalTriggerMultiplicity.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2016, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 #include <array>
16 #include <iostream>
17 #include <map>
18 #include <vector>
19 
20 #include <THistManager.h>
21 #include <TMath.h>
22 #include <TString.h>
23 
24 #include "AliAnalysisDataContainer.h"
25 #include "AliAnalysisManager.h"
27 #include "AliClusterContainer.h"
29 #include "AliEmcalList.h"
30 #include "AliEmcalTrackSelection.h"
31 #include "AliLog.h"
32 #include "AliVCluster.h"
33 #include "AliVEvent.h"
34 #include "AliVEventHandler.h"
35 #include "AliVMultiplicity.h"
36 #include "AliVVZERO.h"
37 
41 
42 namespace EMCalTriggerPtAnalysis {
43 
44 AliAnalysisTaskEmcalTriggerMultiplicity::AliAnalysisTaskEmcalTriggerMultiplicity():
46  fTrackSel(nullptr),
47  fEnableSumw2(false)
48 {
49 }
50 
54  fEnableSumw2(false)
55 {
56 }
57 
58 
60  if(fTrackSel) delete fTrackSel;
61 }
62 
64  std::vector<float> ptthresh = {0.1, 0.5, 1., 2., 5., 10.};
65  TString optionstring = fEnableSumw2 ? "s" : "";
66  for(const auto &t : GetSupportedTriggers()){
67  // Event counters
68  fHistos->CreateTH1(Form("hEventCount%s", t.Data()), Form("Event count trigger class %s", t.Data()), 1, 0.5, 1.5, optionstring);
69  fHistos->CreateTH1(Form("hVertexZ%s", t.Data()), Form("z-distribution of the primary vertex for trigger class %s", t.Data()), 200, -40., 40., optionstring);
70 
71  // Multiplicity distributions
72  fHistos->CreateTH1(Form("VZEROAmult%s", t.Data()), Form("VZERO-A multiplicity distribution for trigger class %s", t.Data()), 1000, 0., 1000., optionstring);
73  fHistos->CreateTH1(Form("VZEROCmult%s", t.Data()), Form("VZERO-C multiplicity distribution for trigger class %s", t.Data()), 1000, 0., 1000., optionstring);
74  fHistos->CreateTH1(Form("TrackletMult%s", t.Data()), Form("SPD tracklet multiplcity for trigger class %s", t.Data()), 1000, 0., 1000., optionstring);
75  fHistos->CreateTH1(Form("EMCALClusterMult%s", t.Data()), Form("EMCAL cluster multiplcity for trigger class %s", t.Data()), 1000, 0., 1000., optionstring);
76  fHistos->CreateTH1(Form("EMCALEnergyMult%s", t.Data()), Form("EMCAL total energy for trigger class %s", t.Data()), 1000, 0., 1000., optionstring);
77  fHistos->CreateTH1(Form("EMCALMeanMult%s", t.Data()), Form("EMCAL total energy for trigger class %s", t.Data()), 1000, 0., 100., optionstring);
78  fHistos->CreateTH1(Form("EMCALMedianMult%s", t.Data()), Form("EMCAL total energy for trigger class %s", t.Data()), 1000, 0., 100., optionstring);
79  for(auto pt : ptthresh){
80  fHistos->CreateTH1(Form("TrackMult%d%s", static_cast<int>(pt * 10.), t.Data()), Form("Global track multiplicity for tracks with pt > %1.f GeV/c for trigger class %s", pt, t.Data()), 1000, 0., 1000., optionstring);
81  }
82  }
83 }
84 
86 
87 }
88 
90  for(const auto &t : fSelectedTriggers){
91  Double_t weight = GetTriggerWeight(t);
92  fHistos->FillTH1(Form("hEventCount%s", t.Data()), 1, weight);
93  fHistos->FillTH1(Form("hVertexZ%s", t.Data()), fVertex[2], weight);
94  }
95 }
96 
98  // Monitor
99  // - VZERO_A multiplicity
100  // - ITS tracklet multiplicity
101  // - global track multiplicity
102  // - EMCAL clusters
103  AliVVZERO *vzerodata = fInputEvent->GetVZEROData();
104 
105  // Track multiplicity
106  std::vector<float> ptthresh = {0.1, 0.5, 1., 2., 5., 10.};
107  std::map<float, int> trackmult;
108  for(auto t : ptthresh) trackmult[t] = 0;
109  for(int itrk = 0; itrk < fInputEvent->GetNumberOfTracks(); itrk++){
110  AliVTrack *trk = static_cast<AliVTrack *>(fInputEvent->GetTrack(itrk));
111  if(TMath::Abs(trk->Eta()) > 0.8) continue;
112  if(fTrackSel->IsTrackAccepted(trk)){
113  for(auto t : ptthresh){
114  if(TMath::Abs(trk->Pt()) > t) trackmult[t]++;
115  }
116  }
117  }
118 
119  // Tracklet multiplicity
120  int ntracklets(0);
121  AliVMultiplicity *mult = fInputEvent->GetMultiplicity();
122  for(int itl = 0; itl < mult->GetNumberOfTracklets(); itl++){
123  if(TMath::Abs(mult->GetEta(itl))) ntracklets++;
124  }
125 
126  // EMCAL cluster multiplicity
127  // cluster threshold 500 MeV
128  Int_t nclusters(0);
129  Double_t eTotalEMCAL(0);
130  std::vector<double> allClusterEnergies;
131  AliClusterContainer *clustercont = this->GetClusterContainer(0);
132  for(auto clust : clustercont->all()){
133  if(clust->GetIsExotic()) continue;
134  if(clust->GetNonLinCorrEnergy() > 0.5){
135  nclusters++;
136  allClusterEnergies.push_back(clust->GetNonLinCorrEnergy());
137  eTotalEMCAL += clust->GetNonLinCorrEnergy();
138  }
139  }
140  std::sort(allClusterEnergies.begin(), allClusterEnergies.end(), std::less<double>());
141  TArrayD sortedenergies(allClusterEnergies.size());
142  int entrycnt(0);
143  for(auto e : allClusterEnergies) sortedenergies[entrycnt++] = e;
144  Double_t emcalmean = TMath::Mean(allClusterEnergies.begin(), allClusterEnergies.end()),
145  emcalmedian = TMath::Median(sortedenergies.GetSize(), sortedenergies.GetArray());
146 
147  // all quantities available
148  // fill histograms
149  for(const auto &t : fSelectedTriggers){
150  Double_t weight = GetTriggerWeight(t);
151  fHistos->FillTH1(Form("VZEROAmult%s", t.Data()), vzerodata->GetMTotV0A(), weight);
152  fHistos->FillTH1(Form("VZEROCmult%s", t.Data()), vzerodata->GetMTotV0C(), weight);
153  fHistos->FillTH1(Form("TrackletMult%s", t.Data()), ntracklets, weight);
154  fHistos->FillTH1(Form("EMCALClusterMult%s", t.Data()), nclusters, weight);
155  fHistos->FillTH1(Form("EMCALEnergyMult%s", t.Data()), eTotalEMCAL, weight);
156  fHistos->FillTH1(Form("EMCALMeanMult%s", t.Data()), emcalmean, weight);
157  fHistos->FillTH1(Form("EMCALMedianMult%s", t.Data()), emcalmedian, weight);
158  for(auto tmult : trackmult) fHistos->FillTH1(Form("TrackMult%d%s", static_cast<int>(tmult.first *10.), t.Data()), tmult.second, weight);
159  }
160 
161  return true;
162 }
163 
166 }
167 
169  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
170  if(!mgr){
171  std::cout << "Analysis manager not provided - cannot initialize task" << std::endl;
172  return nullptr;
173  }
174 
175  TString taskname = "EmcalTriggerMultTask_";
176  taskname += suffix;
178  mgr->AddTask(task);
179 
180  // Configuring cluster container
181  AliClusterContainer *clustercont = task->AddClusterContainer(
182  nclusters == "usedefault" ? AliEmcalAnalysisFactory::ClusterContainerNameFactory(mgr->GetInputEventHandler()->InheritsFrom("AliAODInputHandler")) : nclusters
183  );
184  clustercont->SetClusECut(0.5);
185  clustercont->SetExoticCut(true);
186 
187  // Configuring input-/output-container
188  TString outputcont("TriggerMultiplicityHistos_"), outputfile(mgr->GetCommonFileName());
189  outputcont += suffix;
190  outputfile += TString::Format(":TriggerMultiplicity_") + suffix;
191  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
192  mgr->ConnectOutput(task, 1, mgr->CreateContainer(outputcont.Data(), AliEmcalList::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data()));
193 
194  return task;
195 }
196 
197 } /* namespace EMCalTriggerPtAnalysis */
std::vector< TString > fSelectedTriggers
! Triggers selected for given event
double Double_t
Definition: External.C:58
Study of multiplicity distrubtions in EMCAL triggered events.
AliClusterContainer * AddClusterContainer(const char *n)
Create new cluster container and attach it to the task.
static AliAnalysisTaskEmcalTriggerMultiplicity * AddTaskEmcalTriggerMultiplicity(const TString &nclusters="usedefault", const TString &suffix="")
static AliEmcalTrackSelection * TrackCutsFactory(TString name, Bool_t isAOD)
Fully-configure EMCAL track selection independent of the data type.
const AliClusterIterableContainer all() const
int Int_t
Definition: External.C:63
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
virtual PWG::EMCAL::AliEmcalTrackSelResultPtr IsTrackAccepted(AliVTrack *const trk)=0
Interface for track selection code.
Analysis of high- tracks in triggered events.
Double_t fVertex[3]
!event vertex
void SetClusECut(Double_t cut)
Container structure for EMCAL clusters.
std::vector< TString > GetSupportedTriggers(Bool_t useExclusiveTriggers=true) const
void SetExoticCut(Bool_t e)
static TString ClusterContainerNameFactory(Bool_t isAOD)
Get name of the default cluster container.