AliPhysics  1168478 (1168478)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  fBackToBackJetPtFraction(0.6),
39  fMaxMomentumThridJet(12),
40  fHistB2BRhoVsCent(0),
41  fHistB2BRhoVsLeadJetPt(),
42  fHistB2BRhoVsLeadTrackPt(0),
43  fHistB2BRhoVsNtrack(0),
44  fHistB2BRhoVsLeadClusterE(0),
45  fHistB2BRhoVsNcluster(0),
46  fHistB2BRhoScaledVsCent(0),
47  fHistB2BRhoScaledVsNtrack(0),
48  fHistB2BRhoScaledVsNcluster(0)
49 {
50 }
51 
59  AliAnalysisTaskRhoBaseDev(name, histo),
60  fBackToBackJetPtFraction(0.6),
61  fMaxMomentumThridJet(12),
62  fHistB2BRhoVsCent(0),
63  fHistB2BRhoVsLeadJetPt(),
64  fHistB2BRhoVsLeadTrackPt(0),
65  fHistB2BRhoVsNtrack(0),
66  fHistB2BRhoVsLeadClusterE(0),
67  fHistB2BRhoVsNcluster(0),
68  fHistB2BRhoScaledVsCent(0),
69  fHistB2BRhoScaledVsNtrack(0),
70  fHistB2BRhoScaledVsNcluster(0)
71 {
72 }
73 
79 {
80  if (!fCreateHisto) return;
81 
83 
84  TString name;
85 
86  //ranges for PbPb
87  Float_t Ntrackrange[2] = {0, 6000};
88  //set multiplicity related axes to a smaller max value
89  if (fBeamType != kAA) Ntrackrange[1] = 200.;
90 
91  fHistB2BRhoVsCent = new TH2F("fHistB2BRhoVsCent", "fHistB2BRhoVsCent", 100, 0, 100, fNbins, fMinBinPt, fMaxBinPt);
92  fHistB2BRhoVsCent->GetXaxis()->SetTitle("Centrality (%)");
93  fHistB2BRhoVsCent->GetYaxis()->SetTitle("#rho (GeV/#it{c} #times rad^{-1})");
95 
96  if (fParticleCollArray.size() > 0) {
97  fHistB2BRhoVsNtrack = new TH2F("fHistB2BRhoVsNtrack", "fHistB2BRhoVsNtrack", 200, Ntrackrange[0], Ntrackrange[1], fNbins, fMinBinPt, fMaxBinPt);
98  fHistB2BRhoVsNtrack->GetXaxis()->SetTitle("No. of tracks");
99  fHistB2BRhoVsNtrack->GetYaxis()->SetTitle("#rho (GeV/#it{c} #times rad^{-1})");
101 
102  fHistB2BRhoVsLeadTrackPt = new TH2F("fHistB2BRhoVsLeadTrackPt", "fHistB2BRhoVsLeadTrackPt", fNbins, fMinBinPt, fMaxBinPt*2, fNbins, fMinBinPt, fMaxBinPt);
103  fHistB2BRhoVsLeadTrackPt->GetXaxis()->SetTitle("#it{p}_{T,track} (GeV/c)");
104  fHistB2BRhoVsLeadTrackPt->GetYaxis()->SetTitle("#rho (GeV/#it{c} #times rad^{-1})");
106  }
107 
108  if (fClusterCollArray.size()>0) {
109  fHistB2BRhoVsNcluster = new TH2F("fHistB2BRhoVsNcluster", "fHistB2BRhoVsNcluster", 50, Ntrackrange[0] / 4, Ntrackrange[1] / 4, fNbins, fMinBinPt, fMaxBinPt);
110  fHistB2BRhoVsNcluster->GetXaxis()->SetTitle("No. of clusters");
111  fHistB2BRhoVsNcluster->GetYaxis()->SetTitle("#rho (GeV/#it{c} #times rad^{-1})");
113 
114  fHistB2BRhoVsLeadClusterE = new TH2F("fHistB2BRhoVsLeadClusterE", "fHistB2BRhoVsLeadClusterE", fNbins, fMinBinPt, fMaxBinPt*2, fNbins, fMinBinPt, fMaxBinPt);
115  fHistB2BRhoVsLeadClusterE->GetXaxis()->SetTitle("#it{p}_{T,track} (GeV/c)");
116  fHistB2BRhoVsLeadClusterE->GetYaxis()->SetTitle("#rho (GeV/#it{c} #times rad^{-1})");
118  }
119 
120  for (auto jetCont : fJetCollArray) {
121  std::string jetName = jetCont.second->GetArrayName().Data();
122 
123  name = TString::Format("%s_fHistB2BRhoVsLeadJetPt", jetName.c_str());
124  fHistB2BRhoVsLeadJetPt[jetName] = new TH2F(name, name, fNbins, fMinBinPt, fMaxBinPt*2, fNbins, fMinBinPt, fMaxBinPt);
125  fHistB2BRhoVsLeadJetPt[jetName]->GetXaxis()->SetTitle("#it{p}_{T,jet} (GeV/c)");
126  fHistB2BRhoVsLeadJetPt[jetName]->GetYaxis()->SetTitle("#rho (GeV/#it{c} #times rad^{-1})");
127  fOutput->Add(fHistB2BRhoVsLeadJetPt[jetName]);
128  }
129 
130  if (fScaleFunction) {
131  fHistB2BRhoScaledVsCent = new TH2F("fHistB2BRhoScaledVsCent", "fHistB2BRhoScaledVsCent", 100, 0, 100, fNbins, fMinBinPt , fMaxBinPt);
132  fHistB2BRhoScaledVsCent->GetXaxis()->SetTitle("Centrality (%)");
133  fHistB2BRhoScaledVsCent->GetYaxis()->SetTitle("#rho_{scaled} (GeV/#it{c} #times rad^{-1})");
135 
136  if (fParticleCollArray.size() > 0) {
137  fHistB2BRhoScaledVsNtrack = new TH2F("fHistB2BRhoScaledVsNtrack", "fHistB2BRhoScaledVsNtrack", 200, Ntrackrange[0], Ntrackrange[1], fNbins, fMinBinPt, fMaxBinPt);
138  fHistB2BRhoScaledVsNtrack->GetXaxis()->SetTitle("No. of tracks");
139  fHistB2BRhoScaledVsNtrack->GetYaxis()->SetTitle("#rho (GeV/#it{c} #times rad^{-1})");
141  }
142 
143  if (fClusterCollArray.size() > 0) {
144  fHistB2BRhoScaledVsNcluster = new TH2F("fHistB2BRhoScaledVsNcluster", "fHistB2BRhoScaledVsNcluster", 50, Ntrackrange[0] / 4, Ntrackrange[1] / 4, fNbins, fMinBinPt, fMaxBinPt);
145  fHistB2BRhoScaledVsNcluster->GetXaxis()->SetTitle("No. of clusters");
146  fHistB2BRhoScaledVsNcluster->GetYaxis()->SetTitle("#rho_{scaled} (GeV/#it{c} #times rad^{-1})");
148  }
149  }
150 }
151 
163 Double_t AliAnalysisTaskRhoTransDev::GetPerpPtDensity(AliEmcalContainer* cont, AliVParticle* leadingJet)
164 {
165  static Float_t minPhi = (3.0/8.0) * TMath::Pi();
166  static Float_t maxPhi = (5.0/8.0) * TMath::Pi();
167 
168  Double_t perpPt = 0;
169 
170  for (auto mom : cont->accepted_momentum()) {
171  Double_t phi_diff = TMath::Abs(AliEmcalContainer::RelativePhi(mom.first.Phi(), leadingJet->Phi()));
172  if (phi_diff >= minPhi && phi_diff <= maxPhi) perpPt += mom.first.Pt();
173  }
174 
175  Double_t acc = cont->GetEtaSwing() * (maxPhi - minPhi) * 2;
176 
177  return acc > 0 ? perpPt / acc : 0;
178 }
179 
189 {
190  AliEmcalJet* leadingJet = fLeadingJet["Signal"];
191 
192  Double_t perpPtDensity = 0;
193 
194  for (auto partCont : fParticleCollArray) {
195  perpPtDensity += GetPerpPtDensity(partCont.second, leadingJet);
196  }
197 
198  for (auto clusCont : fClusterCollArray) {
199  perpPtDensity += GetPerpPtDensity(clusCont.second, leadingJet);
200  }
201 
202  fOutRho->SetVal(perpPtDensity);
203 }
204 
214 {
215  static Float_t minPhi = (5.0/6.0) * TMath::Pi();
216 
217  Bool_t b2bJet = kFALSE;
218  Bool_t thirdJetOverThreshold = kFALSE;
219 
220  auto itJet = fSortedJets["Signal"].begin();
221  if (itJet == fSortedJets["Signal"].end()) return kFALSE;
222  AliEmcalJet* leadingJet = *itJet;
223  Double_t minB2Bpt = leadingJet->Pt() * fBackToBackJetPtFraction;
224  itJet++;
225  while (itJet != fSortedJets["Signal"].end()) {
226  auto jet = *itJet;
227  Double_t phidiff = TMath::Abs(AliEmcalContainer::RelativePhi(jet->Phi(), leadingJet->Phi()));
228  if (phidiff > minPhi) {
229  if (jet->Pt() > minB2Bpt) b2bJet = kTRUE;
230  }
231  else if (jet->Pt() > fMaxMomentumThridJet) {
232  thirdJetOverThreshold = kTRUE;
233  break;
234  }
235  if (jet->Pt() < fMaxMomentumThridJet && (b2bJet || jet->Pt() < minB2Bpt)) break;
236  itJet++;
237  }
238 
239  return b2bJet && !thirdJetOverThreshold;
240 }
241 
246 {
248  if (!r) return kFALSE;
249 
250  if (IsB2BEvent()) {
251  fHistB2BRhoVsCent->Fill(fCent, fOutRho->GetVal());
252 
253  if (fLeadingParticle) {
254  fHistB2BRhoVsLeadTrackPt->Fill(fLeadingParticle->Pt(), fOutRho->GetVal());
255  }
256 
257  if (fLeadingCluster) {
258  fHistB2BRhoVsLeadClusterE->Fill(fLeadingCluster->E(), fOutRho->GetVal());
259  }
260 
261  if (fHistB2BRhoVsNtrack) fHistRhoVsNtrack->Fill(fNtracks, fOutRho->GetVal());
263 
264  for (auto jetCont : fJetCollArray) {
265  if (fLeadingJet[jetCont.first]) fHistB2BRhoVsLeadJetPt[jetCont.first]->Fill(fLeadingJet[jetCont.first]->Pt(), fOutRho->GetVal());
266  }
267 
268  if (fOutRhoScaled) {
269  fHistB2BRhoScaledVsCent->Fill(fCent, fOutRhoScaled->GetVal());
272  }
273  }
274 
275  return kTRUE;
276 }
277 
283 {
284  if (fJetCollArray.count("Signal") == 0) {
285  AliError("No signal jet collection found. Task will not run!");
286  return kFALSE;
287  }
288 
289  if (fParticleCollArray.size() + fClusterCollArray.size() == 0) {
290  AliError("No particle or cluster array was provided. Task will not run!");
291  return kFALSE;
292  }
293 
294  return kTRUE;
295 }
296 
313 {
314  // Get the pointer to the existing analysis manager via the static access method.
315  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
316  if (!mgr) {
317  ::Error("AliAnalysisTaskRhoTransDev::AddTaskRhoTransDev", "No analysis manager to connect to.");
318  return nullptr;
319  }
320 
321  // Check the analysis type using the event handlers connected to the analysis manager.
322  AliVEventHandler* handler = mgr->GetInputEventHandler();
323  if (!handler) {
324  ::Error("AliAnalysisTaskRhoTransDev::AddTaskRhoTransDev", "This task requires an input event handler");
325  return nullptr;
326  }
327 
328  EDataType_t dataType = kUnknownDataType;
329 
330  if (handler->InheritsFrom("AliESDInputHandler")) {
331  dataType = kESD;
332  }
333  else if (handler->InheritsFrom("AliAODInputHandler")) {
334  dataType = kAOD;
335  }
336 
337  // Init the task and do settings
338  if (trackName == "usedefault") {
339  if (dataType == kESD) {
340  trackName = "Tracks";
341  }
342  else if (dataType == kAOD) {
343  trackName = "tracks";
344  }
345  else {
346  trackName = "";
347  }
348  }
349 
350  if (clusName == "usedefault") {
351  if (dataType == kESD) {
352  clusName = "CaloClusters";
353  }
354  else if (dataType == kAOD) {
355  clusName = "caloClusters";
356  }
357  else {
358  clusName = "";
359  }
360  }
361 
362  TString name(TString::Format("AliAnalysisTaskRhoTransDev_%s", nRho.Data()));
363  if (!suffix.IsNull()) {
364  name += "_";
365  name += suffix;
366  }
367 
368  AliAnalysisTaskRhoTransDev* mgrTask = dynamic_cast<AliAnalysisTaskRhoTransDev*>(mgr->GetTask(name.Data()));
369  if (mgrTask) {
370  ::Warning("AliAnalysisTaskRhoTransDev::AddTaskRhoTransDev", "Not adding the task again, since a task with the same name '%s' already exists", name.Data());
371  return mgrTask;
372  }
373 
374  AliAnalysisTaskRhoTransDev* rhotask = new AliAnalysisTaskRhoTransDev(name, histo);
375  rhotask->SetOutRhoName(nRho);
376 
377  AliParticleContainer* partCont = rhotask->AddParticleContainer(trackName.Data());
378  partCont->SetMinPt(trackPtCut);
379  AliClusterContainer *clusterCont = rhotask->AddClusterContainer(clusName.Data());
380  if (clusterCont) {
381  clusterCont->SetClusECut(0.);
382  clusterCont->SetClusPtCut(0.);
383  clusterCont->SetClusHadCorrEnergyCut(clusECut);
384  clusterCont->SetDefaultClusterEnergy(AliVCluster::kHadCorr);
385  }
386 
387  AliJetContainer *jetCont = new AliJetContainer(jetType, AliJetContainer::antikt_algorithm, rscheme, jetradius, partCont, clusterCont);
388  if (jetCont) {
389  jetCont->SetJetPtCut(0);
390  jetCont->SetJetAcceptanceType(acceptance);
391  jetCont->SetName("Signal");
392  rhotask->AdoptJetContainer(jetCont);
393  }
394 
395  // Final settings, pass to manager and set the containers
396  mgr->AddTask(rhotask);
397 
398  // Create containers for input/output
399  mgr->ConnectInput(rhotask, 0, mgr->GetCommonInputContainer());
400  if (histo) {
401  TString contname(name);
402  contname += "_histos";
403  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname.Data(),
404  TList::Class(), AliAnalysisManager::kOutputContainer,
405  Form("%s", AliAnalysisManager::GetCommonFileName()));
406  mgr->ConnectOutput(rhotask, 1, coutput1);
407  }
408 
409  return rhotask;
410 }
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="")
EBeamType_t fBeamType
!event beam type
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
Double_t fMaxBinPt
max pt in histograms
Double_t Phi() const
Definition: AliEmcalJet.h:110
Base class for a task that calculates the UE.
Double_t GetPerpPtDensity(AliEmcalContainer *cont, AliVParticle *leadingJet)
Container for particles within the EMCAL framework.
Bool_t fCreateHisto
whether or not create histograms
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
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.
Double_t fMaxMomentumThridJet
Maximum pt of any additional jet in the event (other than the back-to-back fraction.
TH2 * fHistRhoVsNcluster
!rho vs. no. of clusters
Double_t fMinBinPt
min pt in histograms
Double_t Pt() const
Definition: AliEmcalJet.h:102
TH2 * fHistB2BRhoVsNcluster
!rho vs. no. of clusters
AliParticleContainer * AddParticleContainer(std::string branchName, std::string contName="")
TH2 * fHistB2BRhoVsLeadClusterE
!rho vs. leading cluster energy
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
TH2 * fHistB2BRhoVsCent
!rho vs. centrality
TH2 * fHistRhoVsNtrack
!rho vs. no. of tracks
std::map< std::string, AliEmcalJet * > fLeadingJet
std::map< std::string, std::list< AliEmcalJet * > > fSortedJets
!jets sorted by momentum
std::map< std::string, AliParticleContainer * > fParticleCollArray
particle/track collection array
Represent a jet reconstructed using the EMCal jet framework.
Definition: AliEmcalJet.h:44
TH2 * fHistRhoScaledVsNtrack
!rhoscaled vs. no. of tracks
void SetClusPtCut(Double_t cut)
std::map< std::string, TH2 * > fHistB2BRhoVsLeadJetPt
!rho vs. leading jet pt
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
Int_t fNtracks
!number of tracks
Double_t fBackToBackJetPtFraction
Minimum pt fraction of the back-to-back jet.
AliRhoParameter * fOutRho
!output rho object
Double_t fCent
!event centrality
Container for jet within the EMCAL jet framework.
void SetClusHadCorrEnergyCut(Double_t cut)
Int_t fNclusters
!number of clusters