AliPhysics  8630145 (8630145)
 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  fRequestCentrality(false),
50  fEventCentrality(0)
51 {
52  SetCaloTriggerPatchInfoName("EmcalTriggers");
53 }
54 
57  fCentralityRange(-999., 999.),
58  fRequestCentrality(false),
59  fEventCentrality(0)
60 {
61  SetCaloTriggerPatchInfoName("EmcalTriggers");
62 }
63 
65  AliInfoStream() << "Creating histograms for task " << GetName() << std::endl;
66 
67  EnergyBinning energybinning;
68  TLinearBinning etabinning(100, -0.7, 0.7);
69  std::array<TString, 10> patchtypes = {"EG1", "EG2", "EJ1", "EJ2", "EMC7", "DG1", "DG2", "DJ1", "DJ2", "DMC7"};
70  Double_t encuts[5] = {1., 2., 5., 10., 20.};
71  for(auto trg : GetSupportedTriggers()){
72  fHistos->CreateTH1(Form("hEventCount%s", trg.Data()), Form("Event count for trigger class %s", trg.Data()), 1, 0.5, 1.5);
73  fHistos->CreateTH1(Form("hEventCentrality%s", trg.Data()), Form("Event centrality for trigger class %s", trg.Data()), 103, -2., 101.);
74  fHistos->CreateTH1(Form("hVertexZ%s", trg.Data()), Form("z-position of the primary vertex for trigger class %s", trg.Data()), 200, -40., 40.);
75  for(auto patch : patchtypes){
76  fHistos->CreateTH1(Form("h%sPatchEnergy%s", patch.Data(), trg.Data()), Form("%s-patch energy for trigger class %s", patch.Data(), trg.Data()), energybinning);
77  fHistos->CreateTH1(Form("h%sPatchET%s", patch.Data(), trg.Data()), Form("%s-patch transverse energy for trigger class %s", patch.Data(), trg.Data()), energybinning);
78  fHistos->CreateTH2(Form("h%sPatchEnergyEta%s", patch.Data(), trg.Data()), Form("%s-patch energy for trigger class %s", patch.Data(), trg.Data()), energybinning, etabinning);
79  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);
80  for(int ien = 0; ien < 5; ien++){
81  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());
82  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);
83  }
84  }
85  }
86  AliDebugStream(1) << "Histograms done" << std::endl;
87 }
88 
90  fEventCentrality = -1;
92  AliMultSelection *mult = dynamic_cast<AliMultSelection *>(InputEvent()->FindListObject("MultSelection"));
93  if(!mult){
94  AliErrorStream() << GetName() << ": Centrality selection enabled but no centrality estimator found" << std::endl;
95  return false;
96  }
97  if(mult->IsEventSelected()) return false;
98  fEventCentrality = mult->GetEstimator("V0M")->GetPercentile();
99  AliDebugStream(1) << GetName() << ": Centrality " << fEventCentrality << std::endl;
101  AliDebugStream(1) << GetName() << ": reject centrality: " << fEventCentrality << std::endl;
102  return false;
103  } else {
104  AliDebugStream(1) << GetName() << ": select centrality " << fEventCentrality << std::endl;
105  }
106  } else {
107  AliDebugStream(1) << GetName() << ": No centrality selection applied" << std::endl;
108  }
109  return true;
110 }
111 
113  AliDebugStream(1) << GetName() << ": Start function" << std::endl;
114 
115  AliDebugStream(1) << GetName() << ": Number of trigger patches " << fTriggerPatchInfo->GetEntries() << std::endl;
116 
117  Double_t energy, eta, phi, et;
118  Int_t col, row;
119  for(auto patchIter : *fTriggerPatchInfo){
120  AliEMCALTriggerPatchInfo *patch = static_cast<AliEMCALTriggerPatchInfo *>(patchIter);
121  if(!patch->IsOfflineSimple()) continue;
122 
123  bool isDCAL = patch->IsDCalPHOS(),
124  isSingleShower = SelectSingleShowerPatch(patch),
125  isJetPatch = SelectJetPatch(patch);
126 
127  std::vector<TString> patchnames;
128  if(isJetPatch){
129  if(isDCAL){
130  patchnames.push_back("DJ1");
131  patchnames.push_back("DJ2");
132  } else {
133  patchnames.push_back("EJ1");
134  patchnames.push_back("EJ2");
135  }
136  }
137  if(isSingleShower){
138  if(isDCAL){
139  patchnames.push_back("DMC7");
140  patchnames.push_back("DG1");
141  patchnames.push_back("DG2");
142  } else {
143  patchnames.push_back("EMC7");
144  patchnames.push_back("EG1");
145  patchnames.push_back("EG2");
146  }
147  }
148  if(!patchnames.size()){
149  // Undefined patch type - ignore
150  continue;
151  }
152 
153  TLorentzVector posvec;
154  energy = patch->GetPatchE();
155  eta = patch->GetEtaGeo();
156  phi = patch->GetPhiGeo();
157  col = patch->GetColStart();
158  row = patch->GetRowStart();
159  et = patch->GetLorentzVectorCenterGeo().Et();
160 
161  // fill histograms allEta
162  for(const auto &nameit : patchnames){
163  for(const auto &trg : fSelectedTriggers){
164  FillPatchHistograms(trg.Data(), nameit, energy, et, eta, phi, col, row);
165  }
166  }
167  }
168 }
169 
170 void AliAnalysisTaskEmcalPatchesRef::FillPatchHistograms(TString triggerclass, TString patchname, double energy, double transverseenergy, double eta, double phi, int col, int row){
171  Double_t weight = GetTriggerWeight(triggerclass);
172  AliDebugStream(1) << GetName() << ": Using weight " << weight << " for trigger " << triggerclass << " in patch histograms." << std::endl;
173  fHistos->FillTH1(Form("h%sPatchEnergy%s", patchname.Data(), triggerclass.Data()), energy, weight);
174  fHistos->FillTH1(Form("h%sPatchET%s", patchname.Data(), triggerclass.Data()), transverseenergy, weight);
175  fHistos->FillTH2(Form("h%sPatchEnergyEta%s", patchname.Data(), triggerclass.Data()), energy, eta, weight);
176  fHistos->FillTH2(Form("h%sPatchETEta%s", patchname.Data(), triggerclass.Data()), transverseenergy, eta, weight);
177  Double_t encuts[5] = {1., 2., 5., 10., 20.};
178  for(int ien = 0; ien < 5; ien++){
179  if(energy > encuts[ien]){
180  fHistos->FillTH2(Form("h%sEtaPhi%dG%s", patchname.Data(), static_cast<int>(encuts[ien]), triggerclass.Data()), eta, phi, weight);
181  fHistos->FillTH2(Form("h%sColRow%dG%s", patchname.Data(), static_cast<int>(encuts[ien]), triggerclass.Data()), col, row, weight);
182  }
183  }
184 }
185 
187  // Fill Event counter and reference vertex distributions for the different trigger classes
188  for(const auto &trg : fSelectedTriggers){
189  Double_t weight = GetTriggerWeight(trg);
190  AliDebugStream(1) << GetName() << ": Using weight " << weight << " for trigger " << trg << " in event histograms." << std::endl;
191  fHistos->FillTH1(Form("hEventCount%s", trg.Data()), 1, weight);
192  fHistos->FillTH1(Form("hEventCentrality%s", trg.Data()), fEventCentrality, weight);
193  fHistos->FillTH1(Form("hVertexZ%s", trg.Data()), fVertex[2], weight);
194  }
195 
196 }
197 
198 void AliAnalysisTaskEmcalPatchesRef::GetPatchBoundaries(const AliEMCALTriggerPatchInfo *patch, Double_t *boundaries) const {
199  boundaries[0] = patch->GetEtaMin();
200  boundaries[1] = patch->GetEtaMax();
201  boundaries[2] = patch->GetPhiMin();
202  boundaries[3] = patch->GetPhiMax();
203 }
204 
205 bool AliAnalysisTaskEmcalPatchesRef::SelectSingleShowerPatch(const AliEMCALTriggerPatchInfo *patch) const{
206  if(!patch->IsOfflineSimple()) return false;
207  return patch->IsGammaLowSimple();
208 }
209 
210 bool AliAnalysisTaskEmcalPatchesRef::SelectJetPatch(const AliEMCALTriggerPatchInfo *patch) const{
211  if(!patch->IsOfflineSimple()) return false;
212  return patch->IsJetLowSimple();
213 }
214 
217 {
218  this->SetMinimum(0.);
219  this->AddStep(1., 0.05);
220  this->AddStep(2., 0.1);
221  this->AddStep(4, 0.2);
222  this->AddStep(7, 0.5);
223  this->AddStep(16, 1);
224  this->AddStep(32, 2);
225  this->AddStep(40, 4);
226  this->AddStep(50, 5);
227  this->AddStep(100, 10);
228  this->AddStep(200, 20);
229 }
230 
231 
232 } /* 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.
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)