AliPhysics  3b4a69f (3b4a69f)
AliAnalysisTaskEmcalClustersInJets.cxx
Go to the documentation of this file.
1 /************************************************************************************
2  * Copyright (C) 2018, Copyright Holders of the ALICE Collaboration *
3  * All rights reserved. *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions are met: *
7  * * Redistributions of source code must retain the above copyright *
8  * notice, this list of conditions and the following disclaimer. *
9  * * Redistributions in binary form must reproduce the above copyright *
10  * notice, this list of conditions and the following disclaimer in the *
11  * documentation and/or other materials provided with the distribution. *
12  * * Neither the name of the <organization> nor the *
13  * names of its contributors may be used to endorse or promote products *
14  * derived from this software without specific prior written permission. *
15  * *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND *
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
19  * DISCLAIMED. IN NO EVENT SHALL ALICE COLLABORATION BE LIABLE FOR ANY *
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
26  ************************************************************************************/
27 #include <algorithm>
28 #include <array>
29 #include <iostream>
30 #include <sstream>
31 #include <string>
32 #include <vector>
33 
34 #include <THistManager.h>
35 #include <TLinearBinning.h>
36 #include <TLorentzVector.h>
37 #include <TMath.h>
38 #include <TObjString.h>
39 
40 #include "AliAnalysisManager.h"
41 #include "AliAODInputHandler.h"
43 #include "AliClusterContainer.h"
45 #include "AliEmcalJet.h"
46 #include "AliInputEventHandler.h"
47 #include "AliJetContainer.h"
48 #include "AliTrackContainer.h"
49 #include "AliVEvent.h"
50 
52 
53 using namespace EmcalTriggerJets;
54 
57  fHistos(nullptr),
58  fNamesJetContainers(),
59  fNameClusterContainer(),
60  fNameTriggerClass()
61 {
62  this->SetUseAliAnaUtils(true);
63 }
64 
65 AliAnalysisTaskEmcalClustersInJets::AliAnalysisTaskEmcalClustersInJets(const char *name):
66  AliAnalysisTaskEmcalJet(name, true),
67  fHistos(nullptr),
68  fNamesJetContainers(),
69  fNameClusterContainer(),
70  fNameTriggerClass()
71 {
72  this->SetUseAliAnaUtils(true);
73 }
74 
76  if(fHistos) delete fHistos;
77 }
78 
81  fHistos = new THistManager(Form("histos_%s", GetName()));
82 
83  TLinearBinning energybinning(200, 0., 100.), etabinning(100, -0.8, 0.8), phibinning(100, 0., TMath::TwoPi());
84  fHistos->CreateTH1("hEventCounter", "Event counter", 1, 0.5, 1.5);
85  for(auto c : fNamesJetContainers){
86  auto contname = static_cast<TObjString *>(c)->String();
87  fHistos->CreateTH3(Form("hClustersAttached%s", contname.Data()), Form("Clusters attached to jets %s", contname.Data()), energybinning, etabinning, phibinning);
88  fHistos->CreateTH3(Form("hClustersNotAttached%s", contname.Data()), Form("Clusters attached to jets %s", contname.Data()), energybinning, etabinning, phibinning);
89  }
90  for(auto h : *(fHistos->GetListOfHistograms())) fOutput->Add(h);
91 
92  PostData(1, fOutput);
93 }
94 
96  UInt_t triggersel = AliVEvent::kAny;
97  if(fNameTriggerClass == "INT7") triggersel = AliVEvent::kINT7;
98  else if(fNameTriggerClass.Contains("EG") || fNameTriggerClass.Contains("DG")) triggersel = AliVEvent::kEMCEGA;
99  else if(fNameTriggerClass.Contains("EJ") || fNameTriggerClass.Contains("DJ")) triggersel = AliVEvent::kEMCEJE;
100 
101  bool isEMCALAcceptance = fNameTriggerClass == "INT7" || fNameTriggerClass.Contains("E");
102 
103  if(!(fInputHandler->IsEventSelected() && triggersel)) return false;
104  if(fNameTriggerClass.Length() && !fInputEvent->GetFiredTriggerClasses().Contains(fNameTriggerClass)) return false;
105 
106  auto clusters = this->GetClusterContainer();
107 
108  for(auto c : fNamesJetContainers){
109  auto contname = static_cast<TObjString *>(c)->String();
110  auto jetcontainer = this->GetJetContainer(contname.Data());
111  std::vector<AliVCluster *> attachedclusters;
112  for(auto j : jetcontainer->accepted()){
113  for(decltype(j->GetNumberOfClusters()) iclust = 0; iclust < j->GetNumberOfClusters(); iclust++){
114  auto clust = j->ClusterAt(iclust, clusters->GetArray());
115  attachedclusters.emplace_back(clust);
116  TLorentzVector pvec;
117  clust->GetMomentum(pvec, fVertex);
118  fHistos->FillTH3(Form("hClustersAttached%s", contname.Data()), clust->GetNonLinCorrEnergy(), pvec.Eta(), pvec.Phi());
119  }
120  }
121 
122  // Find all clusters not associtated to a jet
123  for(auto c : clusters->accepted()){
124  if(c->GetIsExotic()) continue;
125  if(std::find(attachedclusters.begin(), attachedclusters.end(), c) != attachedclusters.end()) continue;
126  TLorentzVector pvec;
127  c->GetMomentum(pvec, fVertex);
128  bool isEMCAL = (pvec.Phi() > 0. && pvec.Phi() < 3.5);
129  if((isEMCALAcceptance && !isEMCAL) || (!isEMCAL && isEMCALAcceptance)) continue;
130  fHistos->FillTH3(Form("hClustersNotAttached%s", contname.Data()), c->GetNonLinCorrEnergy(), pvec.Eta(), pvec.Phi());
131  }
132  }
133 
134  return true;
135 }
136 
138  if(!fNamesJetContainers.FindObject(name)) fNamesJetContainers.Add(new TObjString(name));
139 }
140 
142  auto mgr = AliAnalysisManager::GetAnalysisManager();
143  if(!mgr){
144  std::cerr << "No analysis manager available. Exiting ..." << std::endl;
145  return nullptr;
146  }
147  bool isAOD = mgr->GetInputEventHandler()->IsA() == AliAODInputHandler::Class();
148 
149  std::string jetname;
150  switch(jettype){
151  case AliJetContainer::kFullJet: jetname = "fulljets"; break;
152  case AliJetContainer::kNeutralJet: jetname = "neutraljets"; break;
153  };
154 
155  if(!jetname.length()){
156  std::cerr << "Unsuported jet type. Exiting ..." << std::endl;
157  return nullptr;
158  }
159 
160  std::stringstream taskname;
161  taskname << jetname << "_" << trigger;
162 
163  auto task = new AliAnalysisTaskEmcalClustersInJets(taskname.str().data());
164  mgr->AddTask(task);
165 
166 
167  // adding cluster container
169  auto clusters = task->AddClusterContainer(nameclusters);
170  task->SetNameClusterContainer(nameclusters);
171  clusters->SetClusTimeCut(-20e-9, 15e-9);
172  if(jettype == AliJetContainer::kNeutralJet){
173  clusters->SetDefaultClusterEnergy(AliVCluster:: kNonLinCorr);
174  clusters->SetClusNonLinCorrEnergyCut(0.3);
175  clusters->SetClusHadCorrEnergyCut(0.);
176  } else {
177  clusters->SetClusHadCorrEnergyCut(0.3);
178  }
179 
180  AliTrackContainer *tracks = nullptr;
181  if(jettype == AliJetContainer::kFullJet){
183  tracks->SetMinPt(0.15);
184  }
185 
186  // Adding jet containers
187  const std::array<double, 4> kJetRadii = {{0.2, 0.3, 0.4, 0.5}};
188  for(auto r : kJetRadii){
189  std::stringstream namejetcont;
190  namejetcont << jetname << "_R" << std::setw(2) << std::setfill('0') << int(r*10.);
191  auto jcont = task->AddJetContainer(jettype, AliJetContainer::antikt_algorithm, AliJetContainer::E_scheme, r, AliJetContainer::kEMCALfid, tracks, clusters);
192  jcont->SetName(namejetcont.str().data());
193  task->AddNameJetContainer(namejetcont.str().data());
194  jcont->SetMinPt(5.);
195  }
196 
197  // Connect output containers
198  std::stringstream outfilename;
199  outfilename << mgr->GetCommonFileName() << ":ClustersInJets_" << taskname.str();
200  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
201  mgr->ConnectOutput(task, 1 , mgr->CreateContainer(Form("Histos_%s", taskname.str().data()), TList::Class(), AliAnalysisManager::kOutputContainer, outfilename.str().data()));
202 
203  return task;
204 }
static AliAnalysisTaskEmcalClustersInJets * AddTaskEmcalClustersInJets(AliJetContainer::EJetType_t jettype, const char *trigger)
EMCal fiducial acceptance (each eta, phi edge narrowed by jet R)
Class creating a linear binning, used in the histogram manager.
AliJetContainer * GetJetContainer(Int_t i=0) const
Container with name, TClonesArray and cuts for particles.
void SetUseAliAnaUtils(Bool_t b, Bool_t bRejPilup=kTRUE)
virtual bool Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.
void FillTH3(const char *hname, double x, double y, double z, double weight=1., Option_t *opt="")
Fill a 3D histogram within the container.
TCanvas * c
Definition: TestFitELoss.C:172
Bool_t GetMomentum(TLorentzVector &mom, Int_t i) const
unsigned int UInt_t
Definition: External.C:33
THashList * GetListOfHistograms() const
Get the list of histograms.
Definition: THistManager.h:671
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
TString fNameTriggerClass
Name of the trigger class to be selected.
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
AliEmcalList * fOutput
!output list
Double_t fVertex[3]
!event vertex
Base task in the EMCAL jet framework.
Container class for histograms.
Definition: THistManager.h:99
void UserCreateOutputObjects()
Main initialization function on the worker.
TH3 * CreateTH3(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, int nbinsz, double zmin, double zmax, Option_t *opt="")
Create a new TH2 within the container.
static TString TrackContainerNameFactory(Bool_t isAOD)
Get name of the default track container.
static TString ClusterContainerNameFactory(Bool_t isAOD)
Get name of the default cluster container.