AliPhysics  775474e (775474e)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskEmcalPatchesRef.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2015, 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 <TClonesArray.h>
21 #include <TGrid.h>
22 #include <THistManager.h>
23 #include <THashList.h>
24 #include <TLinearBinning.h>
25 #include <TObjArray.h>
26 #include <TParameter.h>
27 
28 #include "AliAnalysisUtils.h"
29 #include "AliESDEvent.h"
30 #include "AliEMCALTriggerPatchInfo.h"
32 #include "AliInputEventHandler.h"
33 #include "AliLog.h"
34 #include "AliMultSelection.h"
35 #include "AliMultEstimator.h"
36 #include "AliOADBContainer.h"
37 
39 
43 
44 namespace EMCalTriggerPtAnalysis {
45 
46 AliAnalysisTaskEmcalPatchesRef::AliAnalysisTaskEmcalPatchesRef() :
48  fCentralityRange(-999., 999.),
49  fEnableSumw2(false),
50  fRequestCentrality(false),
51  fEventCentrality(0)
52 {
53  SetCaloTriggerPatchInfoName("EmcalTriggers");
54 }
55 
58  fCentralityRange(-999., 999.),
59  fEnableSumw2(false),
60  fRequestCentrality(false),
61  fEventCentrality(0)
62 {
63  SetCaloTriggerPatchInfoName("EmcalTriggers");
64 }
65 
67  AliInfoStream() << "Creating histograms for task " << GetName() << std::endl;
68 
69  EnergyBinning energybinning;
70  TLinearBinning etabinning(100, -0.7, 0.7);
71  std::array<TString, 10> patchtypes = {"EG1", "EG2", "EJ1", "EJ2", "EMC7", "DG1", "DG2", "DJ1", "DJ2", "DMC7"};
72  Double_t encuts[5] = {1., 2., 5., 10., 20.};
73  TString optionstring = fEnableSumw2 ? "s" : "";
74  for(auto trg : GetSupportedTriggers()){
75  fHistos->CreateTH1(Form("hEventCount%s", trg.Data()), Form("Event count for trigger class %s", trg.Data()), 1, 0.5, 1.5, optionstring);
76  fHistos->CreateTH1(Form("hEventCentrality%s", trg.Data()), Form("Event centrality for trigger class %s", trg.Data()), 103, -2., 101., optionstring);
77  fHistos->CreateTH1(Form("hVertexZ%s", trg.Data()), Form("z-position of the primary vertex for trigger class %s", trg.Data()), 200, -40., 40., optionstring);
78  for(auto patch : patchtypes){
79  fHistos->CreateTH1(Form("h%sPatchEnergy%s", patch.Data(), trg.Data()), Form("%s-patch energy for trigger class %s", patch.Data(), trg.Data()), energybinning, optionstring);
80  fHistos->CreateTH1(Form("h%sPatchET%s", patch.Data(), trg.Data()), Form("%s-patch transverse energy for trigger class %s", patch.Data(), trg.Data()), energybinning, optionstring);
81  fHistos->CreateTH2(Form("h%sPatchEnergyEta%s", patch.Data(), trg.Data()), Form("%s-patch energy for trigger class %s", patch.Data(), trg.Data()), energybinning, etabinning, optionstring);
82  fHistos->CreateTH2(Form("h%sPatchETEta%s", patch.Data(), trg.Data()), Form("%s-patch transverse energy for trigger class %s", patch.Data(), trg.Data()), energybinning, etabinning, optionstring);
83  for(int ien = 0; ien < 5; ien++){
84  fHistos->CreateTH2(Form("h%sEtaPhi%dG%s", patch.Data(), static_cast<int>(encuts[ien]), trg.Data()), Form("%s-patch #eta-#phi map for patches with energy larger than %f GeV/c for trigger class %s", patch.Data(), encuts[ien], trg.Data()), 100, -0.7, 0.7, 200, 0, TMath::TwoPi(), optionstring);
85  fHistos->CreateTH2(Form("h%sColRow%dG%s", patch.Data(), static_cast<int>(encuts[ien]), trg.Data()), Form("%s-patch col-row map for patches with energy larger than %f GeV/c for trigger class %s", patch.Data(), encuts[ien], trg.Data()), 48, -0.5, 47.5, 104, -0.5, 103.5, optionstring);
86  }
87  }
88  }
89  AliDebugStream(1) << "Histograms done" << std::endl;
90 }
91 
93  fEventCentrality = -1;
95  AliMultSelection *mult = dynamic_cast<AliMultSelection *>(InputEvent()->FindListObject("MultSelection"));
96  if(!mult){
97  AliErrorStream() << GetName() << ": Centrality selection enabled but no centrality estimator found" << std::endl;
98  return false;
99  }
100  if(mult->IsEventSelected()) return false;
101  fEventCentrality = mult->GetEstimator("V0M")->GetPercentile();
102  AliDebugStream(1) << GetName() << ": Centrality " << fEventCentrality << std::endl;
104  AliDebugStream(1) << GetName() << ": reject centrality: " << fEventCentrality << std::endl;
105  return false;
106  } else {
107  AliDebugStream(1) << GetName() << ": select centrality " << fEventCentrality << std::endl;
108  }
109  } else {
110  AliDebugStream(1) << GetName() << ": No centrality selection applied" << std::endl;
111  }
112  return true;
113 }
114 
116  AliDebugStream(1) << GetName() << ": Start function" << std::endl;
117 
118  AliDebugStream(1) << GetName() << ": Number of trigger patches " << fTriggerPatchInfo->GetEntries() << std::endl;
119 
120  Double_t energy, eta, phi, et;
121  Int_t col, row;
122  for(auto patchIter : *fTriggerPatchInfo){
123  AliEMCALTriggerPatchInfo *patch = static_cast<AliEMCALTriggerPatchInfo *>(patchIter);
124  if(!patch->IsOfflineSimple()) continue;
125 
126  bool isDCAL = patch->IsDCalPHOS(),
127  isSingleShower = SelectSingleShowerPatch(patch),
128  isJetPatch = SelectJetPatch(patch);
129 
130  std::vector<TString> patchnames;
131  if(isJetPatch){
132  if(isDCAL){
133  patchnames.push_back("DJ1");
134  patchnames.push_back("DJ2");
135  } else {
136  patchnames.push_back("EJ1");
137  patchnames.push_back("EJ2");
138  }
139  }
140  if(isSingleShower){
141  if(isDCAL){
142  patchnames.push_back("DMC7");
143  patchnames.push_back("DG1");
144  patchnames.push_back("DG2");
145  } else {
146  patchnames.push_back("EMC7");
147  patchnames.push_back("EG1");
148  patchnames.push_back("EG2");
149  }
150  }
151  if(!patchnames.size()){
152  // Undefined patch type - ignore
153  continue;
154  }
155 
156  TLorentzVector posvec;
157  energy = patch->GetPatchE();
158  eta = patch->GetEtaGeo();
159  phi = patch->GetPhiGeo();
160  col = patch->GetColStart();
161  row = patch->GetRowStart();
162  et = patch->GetLorentzVectorCenterGeo().Et();
163 
164  // fill histograms allEta
165  for(const auto &nameit : patchnames){
166  for(const auto &trg : fSelectedTriggers){
167  FillPatchHistograms(trg.Data(), nameit, energy, et, eta, phi, col, row);
168  }
169  }
170  }
171  return true;
172 }
173 
174 void AliAnalysisTaskEmcalPatchesRef::FillPatchHistograms(TString triggerclass, TString patchname, double energy, double transverseenergy, double eta, double phi, int col, int row){
175  Double_t weight = GetTriggerWeight(triggerclass);
176  AliDebugStream(1) << GetName() << ": Using weight " << weight << " for trigger " << triggerclass << " in patch histograms." << std::endl;
177  fHistos->FillTH1(Form("h%sPatchEnergy%s", patchname.Data(), triggerclass.Data()), energy, weight);
178  fHistos->FillTH1(Form("h%sPatchET%s", patchname.Data(), triggerclass.Data()), transverseenergy, weight);
179  fHistos->FillTH2(Form("h%sPatchEnergyEta%s", patchname.Data(), triggerclass.Data()), energy, eta, weight);
180  fHistos->FillTH2(Form("h%sPatchETEta%s", patchname.Data(), triggerclass.Data()), transverseenergy, eta, weight);
181  Double_t encuts[5] = {1., 2., 5., 10., 20.};
182  for(int ien = 0; ien < 5; ien++){
183  if(energy > encuts[ien]){
184  fHistos->FillTH2(Form("h%sEtaPhi%dG%s", patchname.Data(), static_cast<int>(encuts[ien]), triggerclass.Data()), eta, phi, weight);
185  fHistos->FillTH2(Form("h%sColRow%dG%s", patchname.Data(), static_cast<int>(encuts[ien]), triggerclass.Data()), col, row, weight);
186  }
187  }
188 }
189 
191  // Fill Event counter and reference vertex distributions for the different trigger classes
192  for(const auto &trg : fSelectedTriggers){
193  Double_t weight = GetTriggerWeight(trg);
194  AliDebugStream(1) << GetName() << ": Using weight " << weight << " for trigger " << trg << " in event histograms." << std::endl;
195  fHistos->FillTH1(Form("hEventCount%s", trg.Data()), 1, weight);
196  fHistos->FillTH1(Form("hEventCentrality%s", trg.Data()), fEventCentrality, weight);
197  fHistos->FillTH1(Form("hVertexZ%s", trg.Data()), fVertex[2], weight);
198  }
199 
200 }
201 
202 void AliAnalysisTaskEmcalPatchesRef::GetPatchBoundaries(const AliEMCALTriggerPatchInfo *patch, Double_t *boundaries) const {
203  boundaries[0] = patch->GetEtaMin();
204  boundaries[1] = patch->GetEtaMax();
205  boundaries[2] = patch->GetPhiMin();
206  boundaries[3] = patch->GetPhiMax();
207 }
208 
209 bool AliAnalysisTaskEmcalPatchesRef::SelectSingleShowerPatch(const AliEMCALTriggerPatchInfo *patch) const{
210  if(!patch->IsOfflineSimple()) return false;
211  return patch->IsGammaLowSimple();
212 }
213 
214 bool AliAnalysisTaskEmcalPatchesRef::SelectJetPatch(const AliEMCALTriggerPatchInfo *patch) const{
215  if(!patch->IsOfflineSimple()) return false;
216  return patch->IsJetLowSimple();
217 }
218 
221 {
222  this->SetMinimum(0.);
223  this->AddStep(1., 0.05);
224  this->AddStep(2., 0.1);
225  this->AddStep(4, 0.2);
226  this->AddStep(7, 0.5);
227  this->AddStep(16, 1);
228  this->AddStep(32, 2);
229  this->AddStep(40, 4);
230  this->AddStep(50, 5);
231  this->AddStep(100, 10);
232  this->AddStep(200, 20);
233 }
234 
235 
236 } /* namespace EMCalTriggerPtAnalysis */
std::vector< TString > fSelectedTriggers
! Triggers selected for given event
void FillPatchHistograms(TString triggerclass, TString patchname, double energy, double transverseenergy, double eta, double phi, int col, int row)
double Double_t
Definition: External.C:58
Class creating a linear binning, used in the histogram manager.
Bool_t fEnableSumw2
Enable sumw2 during histogram creation.
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
void AddStep(Double_t max, Double_t binwidth)
void SetCaloTriggerPatchInfoName(const char *n)
Bool_t fRequestCentrality
Switch for request of centrality selection.
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
int Int_t
Definition: External.C:63
bool SelectSingleShowerPatch(const AliEMCALTriggerPatchInfo *patch) const
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Helper class creating user defined custom binning.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
bool SelectJetPatch(const AliEMCALTriggerPatchInfo *patch) const
energy
Analysis of trigger patches in min. bias and triggered events.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Double_t fVertex[3]
!event vertex
AliCutValueRange< double > fCentralityRange
Range of accepted event centralities.
TClonesArray * fTriggerPatchInfo
!trigger patch info array
void GetPatchBoundaries(const AliEMCALTriggerPatchInfo *patch, Double_t *boundaries) const
void SetMinimum(Double_t min)