AliPhysics  41af4b0 (41af4b0)
AliAnalysisTaskRhoTransDev.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2017, 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 
17 
18 #include <TClonesArray.h>
19 #include <TMath.h>
20 
21 #include <AliLog.h>
22 #include <AliVEventHandler.h>
23 #include <AliAnalysisManager.h>
24 
25 #include "AliEmcalJet.h"
26 #include "AliRhoParameter.h"
27 #include "AliJetContainer.h"
28 
32 
38  fHistB2BRhoVsCent(0),
39  fHistB2BRhoVsLeadJetPt(),
40  fHistB2BRhoVsLeadTrackPt(0),
41  fHistB2BRhoVsNtrack(0),
42  fHistB2BRhoVsLeadClusterE(0),
43  fHistB2BRhoVsNcluster(0),
44  fHistB2BRhoScaledVsCent(0),
45  fHistB2BRhoScaledVsNtrack(0),
46  fHistB2BRhoScaledVsNcluster(0)
47 {
48 }
49 
57  AliAnalysisTaskRhoBaseDev(name, histo),
67 {
68 }
69 
75 {
76  if (!fCreateHisto) return;
77 
79 
80  TString name;
81 
82  Int_t maxTracks = 6000;
83  Double_t maxRho = 500;
84  Int_t nRhoBins = 500;
85 
86  if (fForceBeamType == kpp) {
87  maxRho = 50;
88  maxTracks = 200;
89  }
90  else if (fForceBeamType == kpA) {
91  maxRho = 200;
92  maxTracks = 500;
93  }
94 
95  Int_t nPtBins = TMath::CeilNint(fMaxPt / fPtBinWidth);
96 
97  fHistB2BRhoVsCent = new TH2F("fHistB2BRhoVsCent", "fHistB2BRhoVsCent", 100, 0, 100, nRhoBins, 0, maxRho);
98  fHistB2BRhoVsCent->GetXaxis()->SetTitle("Centrality (%)");
99  fHistB2BRhoVsCent->GetYaxis()->SetTitle("#rho (GeV/#it{c} #times rad^{-1})");
101 
102  if (fParticleCollArray.size() > 0) {
103  fHistB2BRhoVsNtrack = new TH2F("fHistB2BRhoVsNtrack", "fHistB2BRhoVsNtrack", 200, 0, maxTracks, nRhoBins, 0, maxRho);
104  fHistB2BRhoVsNtrack->GetXaxis()->SetTitle("No. of tracks");
105  fHistB2BRhoVsNtrack->GetYaxis()->SetTitle("#rho (GeV/#it{c} #times rad^{-1})");
107 
108  fHistB2BRhoVsLeadTrackPt = new TH2F("fHistB2BRhoVsLeadTrackPt", "fHistB2BRhoVsLeadTrackPt", nPtBins, 0, fMaxPt, nRhoBins, 0, maxRho);
109  fHistB2BRhoVsLeadTrackPt->GetXaxis()->SetTitle("#it{p}_{T,track} (GeV/c)");
110  fHistB2BRhoVsLeadTrackPt->GetYaxis()->SetTitle("#rho (GeV/#it{c} #times rad^{-1})");
112  }
113 
114  if (fClusterCollArray.size()>0) {
115  fHistB2BRhoVsNcluster = new TH2F("fHistB2BRhoVsNcluster", "fHistB2BRhoVsNcluster", 50, 0, maxTracks / 4, nRhoBins, 0, maxRho);
116  fHistB2BRhoVsNcluster->GetXaxis()->SetTitle("No. of clusters");
117  fHistB2BRhoVsNcluster->GetYaxis()->SetTitle("#rho (GeV/#it{c} #times rad^{-1})");
119 
120  fHistB2BRhoVsLeadClusterE = new TH2F("fHistB2BRhoVsLeadClusterE", "fHistB2BRhoVsLeadClusterE", nPtBins, 0, fMaxPt, nRhoBins, 0, maxRho);
121  fHistB2BRhoVsLeadClusterE->GetXaxis()->SetTitle("#it{p}_{T,track} (GeV/c)");
122  fHistB2BRhoVsLeadClusterE->GetYaxis()->SetTitle("#rho (GeV/#it{c} #times rad^{-1})");
124  }
125 
126  for (auto jetCont : fJetCollArray) {
127  name = TString::Format("%s_fHistB2BRhoVsLeadJetPt", jetCont.first.c_str());
128  fHistB2BRhoVsLeadJetPt[jetCont.first] = new TH2F(name, name, nPtBins, 0, fMaxPt, nRhoBins, 0, maxRho);
129  fHistB2BRhoVsLeadJetPt[jetCont.first]->GetXaxis()->SetTitle("#it{p}_{T,jet} (GeV/c)");
130  fHistB2BRhoVsLeadJetPt[jetCont.first]->GetYaxis()->SetTitle("#rho (GeV/#it{c} #times rad^{-1})");
131  fOutput->Add(fHistB2BRhoVsLeadJetPt[jetCont.first]);
132  }
133 
134  if (fScaleFunction) {
135  fHistB2BRhoScaledVsCent = new TH2F("fHistB2BRhoScaledVsCent", "fHistB2BRhoScaledVsCent", 100, 0, 100, nRhoBins, 0, maxRho);
136  fHistB2BRhoScaledVsCent->GetXaxis()->SetTitle("Centrality (%)");
137  fHistB2BRhoScaledVsCent->GetYaxis()->SetTitle("#rho_{scaled} (GeV/#it{c} #times rad^{-1})");
139 
140  if (fParticleCollArray.size() > 0) {
141  fHistB2BRhoScaledVsNtrack = new TH2F("fHistB2BRhoScaledVsNtrack", "fHistB2BRhoScaledVsNtrack", 200, 0, maxTracks, nRhoBins, 0, maxRho);
142  fHistB2BRhoScaledVsNtrack->GetXaxis()->SetTitle("No. of tracks");
143  fHistB2BRhoScaledVsNtrack->GetYaxis()->SetTitle("#rho (GeV/#it{c} #times rad^{-1})");
145  }
146 
147  if (fClusterCollArray.size() > 0) {
148  fHistB2BRhoScaledVsNcluster = new TH2F("fHistB2BRhoScaledVsNcluster", "fHistB2BRhoScaledVsNcluster", 50, 0, maxTracks / 4, nRhoBins, 0, maxRho);
149  fHistB2BRhoScaledVsNcluster->GetXaxis()->SetTitle("No. of clusters");
150  fHistB2BRhoScaledVsNcluster->GetYaxis()->SetTitle("#rho_{scaled} (GeV/#it{c} #times rad^{-1})");
152  }
153  }
154 }
155 
167 Double_t AliAnalysisTaskRhoTransDev::GetPerpPtDensity(AliEmcalContainer* cont, AliVParticle* leadingJet)
168 {
169  static Float_t minPhi = (3.0/8.0) * TMath::Pi();
170  static Float_t maxPhi = (5.0/8.0) * TMath::Pi();
171 
172  Double_t perpPt = 0;
173 
174  for (auto mom : cont->accepted_momentum()) {
175  Double_t phi_diff = TMath::Abs(AliEmcalContainer::RelativePhi(mom.first.Phi(), leadingJet->Phi()));
176  if (phi_diff >= minPhi && phi_diff <= maxPhi) perpPt += mom.first.Pt();
177  }
178 
179  Double_t acc = cont->GetEtaSwing() * (maxPhi - minPhi) * 2;
180 
181  return acc > 0 ? perpPt / acc : 0;
182 }
183 
193 {
194  AliEmcalJet* leadingJet = fLeadingJet["Signal"];
195  if (!leadingJet) return;
196 
197  Double_t perpPtDensity = 0;
198 
199  for (auto partCont : fParticleCollArray) {
200  perpPtDensity += GetPerpPtDensity(partCont.second, leadingJet);
201  }
202 
203  for (auto clusCont : fClusterCollArray) {
204  perpPtDensity += GetPerpPtDensity(clusCont.second, leadingJet);
205  }
206 
207  fOutRho->SetVal(perpPtDensity);
208 }
209 
214 {
216  if (!r) return kFALSE;
217 
218  if (IsB2BEvent()) {
219  fHistB2BRhoVsCent->Fill(fCent, fOutRho->GetVal());
220 
221  if (fLeadingParticle) {
222  fHistB2BRhoVsLeadTrackPt->Fill(fLeadingParticle->Pt(), fOutRho->GetVal());
223  }
224 
225  if (fLeadingCluster) {
226  fHistB2BRhoVsLeadClusterE->Fill(fLeadingCluster->E(), fOutRho->GetVal());
227  }
228 
231 
232  for (auto jetCont : fJetCollArray) {
233  if (fLeadingJet[jetCont.first]) fHistB2BRhoVsLeadJetPt[jetCont.first]->Fill(fLeadingJet[jetCont.first]->Pt(), fOutRho->GetVal());
234  }
235 
236  if (fOutRhoScaled) {
237  fHistB2BRhoScaledVsCent->Fill(fCent, fOutRhoScaled->GetVal());
240  }
241  }
242  return kTRUE;
243 }
244 
250 {
251  if (fJetCollArray.count("Signal") == 0) {
252  AliError("No signal jet collection found. Task will not run!");
253  return kFALSE;
254  }
255 
256  if (fParticleCollArray.size() + fClusterCollArray.size() == 0) {
257  AliError("No particle or cluster array was provided. Task will not run!");
258  return kFALSE;
259  }
260 
261  return kTRUE;
262 }
263 
280 {
281  // Get the pointer to the existing analysis manager via the static access method.
282  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
283  if (!mgr) {
284  ::Error("AliAnalysisTaskRhoTransDev::AddTaskRhoTransDev", "No analysis manager to connect to.");
285  return nullptr;
286  }
287 
288  // Check the analysis type using the event handlers connected to the analysis manager.
289  AliVEventHandler* handler = mgr->GetInputEventHandler();
290  if (!handler) {
291  ::Error("AliAnalysisTaskRhoTransDev::AddTaskRhoTransDev", "This task requires an input event handler");
292  return nullptr;
293  }
294 
296 
297  if (handler->InheritsFrom("AliESDInputHandler")) {
298  dataType = kESD;
299  }
300  else if (handler->InheritsFrom("AliAODInputHandler")) {
301  dataType = kAOD;
302  }
303 
304  // Init the task and do settings
305  if (trackName == "usedefault") {
306  if (dataType == kESD) {
307  trackName = "Tracks";
308  }
309  else if (dataType == kAOD) {
310  trackName = "tracks";
311  }
312  else {
313  trackName = "";
314  }
315  }
316 
317  if (clusName == "usedefault") {
318  if (dataType == kESD) {
319  clusName = "CaloClusters";
320  }
321  else if (dataType == kAOD) {
322  clusName = "caloClusters";
323  }
324  else {
325  clusName = "";
326  }
327  }
328 
329  TString name(TString::Format("AliAnalysisTaskRhoTransDev_%s", nRho.Data()));
330  if (!suffix.IsNull()) {
331  name += "_";
332  name += suffix;
333  }
334 
335  AliAnalysisTaskRhoTransDev* mgrTask = dynamic_cast<AliAnalysisTaskRhoTransDev*>(mgr->GetTask(name.Data()));
336  if (mgrTask) {
337  ::Warning("AliAnalysisTaskRhoTransDev::AddTaskRhoTransDev", "Not adding the task again, since a task with the same name '%s' already exists", name.Data());
338  return mgrTask;
339  }
340 
341  AliAnalysisTaskRhoTransDev* rhotask = new AliAnalysisTaskRhoTransDev(name, histo);
342  rhotask->SetOutRhoName(nRho);
343 
344  AliParticleContainer* partCont = rhotask->AddParticleContainer(trackName.Data());
345  partCont->SetMinPt(trackPtCut);
346  AliClusterContainer *clusterCont = rhotask->AddClusterContainer(clusName.Data());
347  if (clusterCont) {
348  clusterCont->SetClusECut(0.);
349  clusterCont->SetClusPtCut(0.);
350  clusterCont->SetClusHadCorrEnergyCut(clusECut);
351  clusterCont->SetDefaultClusterEnergy(AliVCluster::kHadCorr);
352  }
353 
354  AliJetContainer *jetCont = new AliJetContainer(jetType, AliJetContainer::antikt_algorithm, rscheme, jetradius, partCont, clusterCont);
355  if (jetCont) {
356  jetCont->SetJetPtCut(1);
357  jetCont->SetJetAcceptanceType(acceptance);
358  jetCont->SetName("Signal");
359  rhotask->AdoptJetContainer(jetCont);
360  }
361 
362  // Final settings, pass to manager and set the containers
363  mgr->AddTask(rhotask);
364 
365  // Create containers for input/output
366  mgr->ConnectInput(rhotask, 0, mgr->GetCommonInputContainer());
367  if (histo) {
368  TString contname(name);
369  contname += "_histos";
370  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname.Data(),
371  TList::Class(), AliAnalysisManager::kOutputContainer,
372  Form("%s", AliAnalysisManager::GetCommonFileName()));
373  mgr->ConnectOutput(rhotask, 1, coutput1);
374  }
375 
376  return rhotask;
377 }
TH2 * fHistB2BRhoVsLeadTrackPt
!rho vs. leading track pt
static AliAnalysisTaskRhoTransDev * AddTaskRhoTransDev(TString nTracks="usedefault", Double_t trackPtCut=0.15, TString nClusters="usedefault", Double_t clusECut=0.30, TString nRho="Rho", Double_t jetradius=0.2, UInt_t acceptance=AliEmcalJet::kTPCfid, AliJetContainer::EJetType_t jetType=AliJetContainer::kChargedJet, AliJetContainer::ERecoScheme_t rscheme=AliJetContainer::pt_scheme, Bool_t histo=kTRUE, TString suffix="")
AliClusterContainer * AddClusterContainer(std::string branchName, std::string contName="")
double Double_t
Definition: External.C:58
EDataType_t
Switch for the data type.
Definition: External.C:236
TH2 * fHistB2BRhoScaledVsNtrack
!rhoscaled vs. no. of tracks
TF1 * fScaleFunction
pre-computed scale factor as a function of centrality
AliVCluster * fLeadingCluster
!leading cluster
Int_t fNtracks
!number of tracks
Base class for a task that calculates the UE.
Double_t GetPerpPtDensity(AliEmcalContainer *cont, AliVParticle *leadingJet)
Bool_t IsB2BEvent(std::string jetCollName="Signal")
Container for particles within the EMCAL framework.
EBeamType_t fForceBeamType
forced beam type
const Int_t nPtBins
Bool_t fCreateHisto
whether or not create histograms
int Int_t
Definition: External.C:63
void SetJetPtCut(Float_t cut)
void SetOutRhoName(const char *name)
TH2 * fHistB2BRhoScaledVsCent
!rhoscaled vs. centrality
unsigned int UInt_t
Definition: External.C:33
float Float_t
Definition: External.C:68
Float_t fMaxPt
Histogram pt limit.
TH2 * fHistB2BRhoVsNtrack
!rho vs. no. of tracks
TH2 * fHistRhoScaledVsNcluster
!rhoscaled vs. no. of clusters
Declaration of class AliAnalysisTaskRhoTransDev.
Class for a task that calculates the UE.
TH2 * fHistRhoVsNcluster
!rho vs. no. of clusters
Float_t fPtBinWidth
Histogram pt bin width.
Int_t fNclusters
!number of clusters
TH2 * fHistB2BRhoVsNcluster
!rho vs. no. of clusters
AliParticleContainer * AddParticleContainer(std::string branchName, std::string contName="")
AliVParticle * fLeadingParticle
!leading particle
TH2 * fHistB2BRhoVsLeadClusterE
!rho vs. leading cluster energy
TH2 * fHistB2BRhoVsCent
!rho vs. centrality
std::map< std::string, AliParticleContainer * > fParticleCollArray
particle/track collection array
Represent a jet reconstructed using the EMCal jet framework.
Definition: AliEmcalJet.h:51
TH2 * fHistRhoScaledVsNtrack
!rhoscaled vs. no. of tracks
void SetClusPtCut(Double_t cut)
std::map< std::string, TH2 * > fHistB2BRhoVsLeadJetPt
!rho vs. leading jet pt
std::map< std::string, AliEmcalJet * > fLeadingJet
!leading jet
void AdoptJetContainer(AliJetContainer *cont)
std::map< std::string, AliJetContainer * > fJetCollArray
jet collection array
void SetJetAcceptanceType(UInt_t type)
bool Bool_t
Definition: External.C:53
AliRhoParameter * fOutRhoScaled
!output scaled rho object
void SetClusECut(Double_t cut)
void SetDefaultClusterEnergy(Int_t d)
std::map< std::string, AliClusterContainer * > fClusterCollArray
cluster collection array
Container structure for EMCAL clusters.
TH2 * fHistB2BRhoScaledVsNcluster
!rhoscaled vs. no. of clusters
AliRhoParameter * fOutRho
!output rho object
Double_t fCent
!event centrality
Container for jet within the EMCAL jet framework.
void SetClusHadCorrEnergyCut(Double_t cut)