AliPhysics  c7b8e89 (c7b8e89)
AliAnalysisTaskEmcalClusterMatched.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 <THashList.h>
16 #include <THistManager.h>
17 #include <TLinearBinning.h>
18 
20 #include "AliAnalysisDataContainer.h"
21 #include "AliAnalysisManager.h"
22 #include "AliAODInputHandler.h"
23 #include "AliAODTrack.h"
26 #include "AliEMCALGeometry.h"
27 #include "AliESDtrackCuts.h"
28 #include "AliLog.h"
29 #include "AliTrackContainer.h"
30 #include "AliVCluster.h"
31 #include "AliVEvent.h"
32 #include "AliVEventHandler.h"
33 #include "AliVTrack.h"
34 
35 #include <iostream>
36 
40 
41 namespace EMCalTriggerPtAnalysis {
42 
43 AliAnalysisTaskEmcalClusterMatched::AliAnalysisTaskEmcalClusterMatched():
45  fTrackSelectionGlobal(nullptr),
46  fTrackSelectionTPConly(nullptr),
47  fTimeCut(-50e6, 50e6),
48  fEnableSumw2(false)
49 {
50 
51 }
52 
57  fTimeCut(-50e6, 50e6),
58  fEnableSumw2(false)
59 {
60 
61 }
62 
66 }
67 
69  Bool_t isAOD = fInputHandler->IsA() == AliAODInputHandler::Class();
72 }
73 
75  EnergyBinning enbinning;
76  TLinearBinning smbinning(20, -0.5, 19.5), timebinning(1000, -0.5e-6, 0.5e-6);
77 
78  TString optionstring = fEnableSumw2 ? "s" : "";
79 
80  for(const auto &t :GetSupportedTriggers()){
81  fHistos->CreateTH1("hEventCount" + t, "Event count for trigger " + t, 1, 0.5, 1.5, optionstring);
82  fHistos->CreateTH1("hVertexZ" + t, "Position of the z-vertex for trigger" + t, 500, -50., 50., optionstring);
83  fHistos->CreateTH2("hClusterEnergyTime" + t, "Cluster energy vs time for trigger " + t, enbinning, timebinning, optionstring);
84  fHistos->CreateTH2("hClusterEnergyAllSM" + t, "Cluster energy vs supermodule for all clusters for trigger " + t, smbinning, enbinning, optionstring);
85  fHistos->CreateTH2("hClusterEnergyMatchGlobalSM" + t, "Cluster energy vs supermodule for matched clusters (gl) for trigger " + t, smbinning, enbinning, optionstring);
86  fHistos->CreateTH2("hClusterEnergyTimeMatchGlobal" + t, "Cluster energy vs time for matched clusters (gl) for trigger" + t, enbinning, timebinning, optionstring);
87  fHistos->CreateTH2("hClusterEnergyMatchTPConlySM" + t, "Cluster energy vs supermodule for matched clusters (tpc) for trigger " + t, smbinning, enbinning, optionstring);
88  fHistos->CreateTH2("hClusterEnergyTimeMatchTPConly" + t, "Cluster energy vs time for matched clusters (tpc) for trigger" + t, enbinning, timebinning, optionstring);
89  fHistos->CreateTH2("hClusterEnergyMatchTPCexclSM" + t, "Cluster energy vs supermodule for matched clusters (tpc excl) for trigger " + t, smbinning, enbinning, optionstring);
90  fHistos->CreateTH2("hClusterEnergyTimeMatchTPCexcl" + t, "Cluster energy vs time for matched clusters (tpc excl) for trigger " + t, enbinning, timebinning, optionstring);
91  fHistos->CreateTH2("hClusterEnergyUnmatchSM" + t, "Cluster energy vs supermodule for unmatched clusters for trigger " + t, smbinning, enbinning, optionstring);
92  fHistos->CreateTH2("hClusterEnergyTimeUnmatch" + t, "Cluster energy vs time for unmatched clusters for trigger " + t, enbinning, timebinning, optionstring);
93  }
94 }
95 
97  for(const auto &t : fSelectedTriggers) {
98  double weight = GetTriggerWeight(t);
99  fHistos->FillTH1("hEventCount" + t, 1, weight);
100  fHistos->FillTH1("hVertexZ" + t, fVertex[2], weight);
101  }
102 }
103 
105  for(auto clust : GetClusterContainer(fNameClusterContainer)->all()){
106  if(!clust->IsEMCAL()) continue;
107  if(clust->GetIsExotic()) continue;
108  if(!fTimeCut.IsInRange(clust->GetTOF())) continue;
109 
110  double energy = clust->GetNonLinCorrEnergy();
111  TLorentzVector clustervec;
112  clust->GetMomentum(clustervec,fVertex);
113  int supermoduleID;
114  fGeom->SuperModuleNumberFromEtaPhi(clustervec.Eta(), clustervec.Phi(), supermoduleID);
115  for(const auto &t : fSelectedTriggers){
116  double weight = GetTriggerWeight(t);
117  fHistos->FillTH2("hClusterEnergyAllSM" + t, supermoduleID, energy, weight);
118  fHistos->FillTH2("hClusterEnergyTime" + t, energy, clust->GetTOF(), weight);
119  }
120 
121  // check whether cluster was matched to global or TPC-only track
122  // attention: tpc tracks always subset of global tracks, exclusive TPC tracks
123  // handled separately
124  int nglobal(0), ntpc(0);
125  if(clust->GetNTracksMatched()){
126  AliDebugStream(1) << "Cluster matched to " << clust->GetNTracksMatched() << " Tracks" << std::endl;
127  }
128  for(int itrk = 0; itrk < clust->GetNTracksMatched(); itrk++){
129  AliVTrack *matched = static_cast<AliVTrack *>(clust->GetTrackMatched(itrk));
130  if(!matched) {
131  AliDebugStream(2) << "Track is null" << std::endl;
132  continue;
133  }
134  if(fTrackSelectionGlobal->IsTrackAccepted(matched)) nglobal++;
135  if(fTrackSelectionTPConly->IsTrackAccepted(matched)) ntpc++;
136  }
137 
138  if(nglobal || ntpc){
139  for(const auto &t : fSelectedTriggers){
140  double weight = GetTriggerWeight(t);
141  if(nglobal){
142  fHistos->FillTH2("hClusterEnergyMatchGlobalSM" + t, supermoduleID, energy, weight);
143  fHistos->FillTH2("hClusterEnergyTimeMatchGlobal" + t, energy, clust->GetTOF(), weight);
144  }
145  if(ntpc){
146  fHistos->FillTH2("hClusterEnergyMatchTPConlySM" + t, supermoduleID, energy, weight);
147  fHistos->FillTH2("hClusterEnergyTimeMatchTPConly" + t, energy, clust->GetTOF(), weight);
148  }
149  if(ntpc && !nglobal){
150  fHistos->FillTH2("hClusterEnergyMatchTPCexclSM" + t, supermoduleID, energy, weight);
151  fHistos->FillTH2("hClusterEnergyTimeMatchTPCexcl" + t, energy, clust->GetTOF(), weight);
152  }
153  }
154  } else {
155  // Unmatched cluster
156  for(const auto &t : fSelectedTriggers){
157  double weight = GetTriggerWeight(t);
158  fHistos->FillTH2("hClusterEnergyUnmatchSM" + t, supermoduleID, energy, weight);
159  fHistos->FillTH2("hClusterEnergyTimeUnmatch" + t, energy, clust->GetTOF(), weight);
160  }
161  }
162  }
163  return true;
164 }
165 
167  if(isAOD){
169  globalAOD->AddFilterBit(AliAODTrack::kTrkGlobal);
170  fTrackSelectionGlobal = globalAOD;
171 
173  tpcOnlyAOD->AddFilterBit(AliAODTrack::kTrkTPCOnly);
174  fTrackSelectionTPConly = tpcOnlyAOD;
175  } else {
177  globalESD->AddTrackCuts(AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(true, 1));
178  fTrackSelectionGlobal = globalESD;
179 
181  tpcOnlyESD->AddTrackCuts(AliESDtrackCuts::GetStandardTPCOnlyTrackCuts());
182  fTrackSelectionTPConly = tpcOnlyESD;
183  }
184 }
185 
187  TString suffixstring = suffix;
188  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
189  AliAnalysisTaskEmcalClusterMatched *clustertask = new AliAnalysisTaskEmcalClusterMatched("EmcalMatchedClusterAnalysis" + suffixstring);
190  mgr->AddTask(clustertask);
191 
192  TString outputfile = mgr->GetCommonFileName();
193  outputfile += (":MatchedClusterResults" + suffixstring);
194  mgr->ConnectInput(clustertask, 0, mgr->GetCommonInputContainer());
195  mgr->ConnectOutput(clustertask, 1, mgr->CreateContainer("MatchedClusterResultHistos" + suffixstring, AliEmcalList::Class(), AliAnalysisManager::kOutputContainer, outputfile));
196  return clustertask;
197 }
198 
204 {
205  this->SetMinimum(0.);
206  this->AddStep(1, 0.05);
207  this->AddStep(2, 0.1);
208  this->AddStep(4, 0.2);
209  this->AddStep(7, 0.5);
210  this->AddStep(16, 1);
211  this->AddStep(32, 2);
212  this->AddStep(40, 4);
213  this->AddStep(50, 5);
214  this->AddStep(100, 10);
215  this->AddStep(200, 20);
216 }
217 } /* namespace EMCalTriggerPtAnalysis */
std::vector< TString > fSelectedTriggers
! Triggers selected for given event
Class creating a linear binning, used in the histogram manager.
static AliAnalysisTaskEmcalClusterMatched * AddTaskEmcalClusterMatched(const char *suffix)
energy
Definition: HFPtSpectrum.C:44
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
void AddFilterBit(UInt_t filterbits)
Add a new filter bit to the track selection.
void AddStep(Double_t max, Double_t binwidth)
AliClusterContainer * AddClusterContainer(const char *n)
Create new cluster container and attach it to the task.
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
Create a new TH2 within the container.
TString fNameClusterContainer
Name of the cluster container in the event.
AliEMCALGeometry * fGeom
!emcal geometry
AliEmcalTrackSelection * fTrackSelectionGlobal
Global track cuts (strong condition)
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.
Helper class creating user defined custom binning.
void AddTrackCuts(AliVCuts *cuts)
Add new track cuts to the list of cuts.
Implement virtual track selection for AOD analysis.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
Simple task checking energy spectra of clusters matched to tracks.
AliEmcalTrackSelection * fTrackSelectionTPConly
TPC-only track cuts (weak condition)
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
bool Bool_t
Definition: External.C:53
Implementation of virtual track selection for ESDs.
std::vector< TString > GetSupportedTriggers(Bool_t useExclusiveTriggers=true) const
void SetMinimum(Double_t min)