AliPhysics  2aaea23 (2aaea23)
AliAnalysisTaskEmcalPatchesRef.cxx
Go to the documentation of this file.
1 /************************************************************************************
2  * Copyright (C) 2015, 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 
28 #include <array>
29 #include <iostream>
30 #include <map>
31 #include <vector>
32 
33 #include <TClonesArray.h>
34 #include <TGrid.h>
35 #include <THistManager.h>
36 #include <THashList.h>
37 #include <TLinearBinning.h>
38 #include <TObjArray.h>
39 #include <TParameter.h>
40 
41 #include "AliAnalysisUtils.h"
42 #include "AliESDEvent.h"
43 #include "AliEMCALTriggerPatchInfo.h"
45 #include "AliInputEventHandler.h"
46 #include "AliLog.h"
47 #include "AliMultSelection.h"
48 #include "AliMultEstimator.h"
49 #include "AliOADBContainer.h"
50 
52 
56 
57 namespace EMCalTriggerPtAnalysis {
58 
59 AliAnalysisTaskEmcalPatchesRef::AliAnalysisTaskEmcalPatchesRef() :
61  fCentralityRange(-999., 999.),
62  fEnableSumw2(false),
63  fUseRecalcPatches(false),
64  fRequestCentrality(false),
65  fEventCentrality(0)
66 {
67  SetCaloTriggerPatchInfoName("EmcalTriggers");
68 }
69 
72  fCentralityRange(-999., 999.),
73  fEnableSumw2(false),
74  fUseRecalcPatches(false),
75  fRequestCentrality(false),
77 {
78  SetCaloTriggerPatchInfoName("EmcalTriggers");
79 }
80 
82  AliInfoStream() << "Creating histograms for task " << GetName() << std::endl;
83 
84  EnergyBinning energybinning;
85  TLinearBinning etabinning(100, -0.7, 0.7);
86  const std::array<const TString, 10> patchtypes = {"EG1", "EG2", "EJ1", "EJ2", "EMC7", "DG1", "DG2", "DJ1", "DJ2", "DMC7"};
87  const std::array<double, 5> encuts = {1., 2., 5., 10., 20.};
88  TString optionstring = fEnableSumw2 ? "s" : "";
89  for(const auto &trg : GetSupportedTriggers()){
90  fHistos->CreateTH1("EventCount" + trg, "Event count for trigger class " + trg, 1, 0.5, 1.5, optionstring);
91  fHistos->CreateTH1("EventCentrality" + trg, "Event centrality for trigger class " + trg, 103, -2., 101., optionstring);
92  fHistos->CreateTH1("VertexZ" + trg, "z-position of the primary vertex for trigger class " + trg, 200, -40., 40., optionstring);
93  for(const auto &patch : patchtypes){
94  fHistos->CreateTH1(patch + "PatchEnergy" + trg, patch + "-patch energy for trigger class " + trg, energybinning, optionstring);
95  fHistos->CreateTH1(patch + "PatchET" + trg, patch +"-patch transverse energy for trigger class "+ trg, energybinning, optionstring);
96  fHistos->CreateTH2(patch + "PatchEnergyEsmear" + trg, patch + "-patch energy vs. smeared energy for trigger class " + trg, energybinning, energybinning);
97  fHistos->CreateTH2(patch + "PatchEnergyEta" + trg, patch + "%s-patch energy for trigger class " + trg, energybinning, etabinning, optionstring);
98  fHistos->CreateTH2(patch + "PatchETEta" +trg, patch + "-patch transverse energy for trigger class " + trg, energybinning, etabinning, optionstring);
99  for(auto energy : encuts){
100  fHistos->CreateTH2(Form("%sEtaPhi%dG%s", patch.Data(), static_cast<int>(energy), trg.Data()), Form("%s-patch #eta-#phi map for patches with energy larger than %f GeV/c for trigger class %s", patch.Data(), energy, trg.Data()), 100, -0.7, 0.7, 200, 0, TMath::TwoPi(), optionstring);
101  fHistos->CreateTH2(Form("%sColRow%dG%s", patch.Data(), static_cast<int>(energy), trg.Data()), Form("%s-patch col-row map for patches with energy larger than %f GeV/c for trigger class %s", patch.Data(), energy, trg.Data()), 48, -0.5, 47.5, 104, -0.5, 103.5, optionstring);
102  }
103  }
104  }
105  AliDebugStream(1) << "Histograms done" << std::endl;
106 }
107 
109  fEventCentrality = -1;
110  if(fRequestCentrality){
111  AliMultSelection *mult = dynamic_cast<AliMultSelection *>(InputEvent()->FindListObject("MultSelection"));
112  if(!mult){
113  AliErrorStream() << GetName() << ": Centrality selection enabled but no centrality estimator found" << std::endl;
114  return false;
115  }
116  if(mult->IsEventSelected()) return false;
117  fEventCentrality = mult->GetEstimator("V0M")->GetPercentile();
118  AliDebugStream(1) << GetName() << ": Centrality " << fEventCentrality << std::endl;
120  AliDebugStream(1) << GetName() << ": reject centrality: " << fEventCentrality << std::endl;
121  return false;
122  } else {
123  AliDebugStream(1) << GetName() << ": select centrality " << fEventCentrality << std::endl;
124  }
125  } else {
126  AliDebugStream(1) << GetName() << ": No centrality selection applied" << std::endl;
127  }
128  return true;
129 }
130 
132  AliDebugStream(1) << GetName() << ": Start function" << std::endl;
133 
134  AliDebugStream(1) << GetName() << ": Number of trigger patches " << fTriggerPatchInfo->GetEntries() << std::endl;
135 
136  Double_t energy, eta, phi, et, smearedenergy;
137  Int_t col, row;
138  for(auto patchIter : *fTriggerPatchInfo){
139  AliEMCALTriggerPatchInfo *patch = static_cast<AliEMCALTriggerPatchInfo *>(patchIter);
140  if(!patch->IsOfflineSimple()) continue;
141 
142  bool isDCAL = patch->IsDCalPHOS(),
143  isSingleShower = SelectSingleShowerPatch(patch),
144  isJetPatch = SelectJetPatch(patch);
145 
146  std::vector<TString> patchnames;
147  if(isJetPatch){
148  if(isDCAL){
149  patchnames.push_back("DJ1");
150  patchnames.push_back("DJ2");
151  } else {
152  patchnames.push_back("EJ1");
153  patchnames.push_back("EJ2");
154  }
155  }
156  if(isSingleShower){
157  if(isDCAL){
158  patchnames.push_back("DMC7");
159  patchnames.push_back("DG1");
160  patchnames.push_back("DG2");
161  } else {
162  patchnames.push_back("EMC7");
163  patchnames.push_back("EG1");
164  patchnames.push_back("EG2");
165  }
166  }
167  if(!patchnames.size()){
168  // Undefined patch type - ignore
169  continue;
170  }
171 
172  TLorentzVector posvec;
173  energy = fUseRecalcPatches ? patch->GetADCAmpGeVRough() : patch->GetPatchE();
174  smearedenergy = patch->GetSmearedEnergy();
175  eta = patch->GetEtaGeo();
176  phi = patch->GetPhiGeo();
177  col = patch->GetColStart();
178  row = patch->GetRowStart();
179  et = patch->GetLorentzVectorCenterGeo().Et();
180 
181  // fill histograms allEta
182  for(const auto &nameit : patchnames){
183  for(const auto &trg : fSelectedTriggers){
184  FillPatchHistograms(trg.Data(), nameit, energy, et, smearedenergy, eta, phi, col, row);
185  }
186  }
187  }
188  return true;
189 }
190 
191 void AliAnalysisTaskEmcalPatchesRef::FillPatchHistograms(TString triggerclass, TString patchname, double energy, double transverseenergy, double smearedenergy, double eta, double phi, int col, int row){
192  Double_t weight = GetTriggerWeight(triggerclass);
193  AliDebugStream(1) << GetName() << ": Using weight " << weight << " for trigger " << triggerclass << " in patch histograms." << std::endl;
194  fHistos->FillTH1(patchname + "PatchEnergy" + triggerclass, energy, weight);
195  fHistos->FillTH1(patchname + "PatchET" + triggerclass, transverseenergy, weight);
196  fHistos->FillTH2(patchname + "PatchEnergyEta" + triggerclass, energy, eta, weight);
197  fHistos->FillTH2(patchname + "PatchETEta" + triggerclass, transverseenergy, eta, weight);
198  fHistos->FillTH2(patchname + "PatchEnergyEsmear" + triggerclass, energy, smearedenergy, weight);
199  const std::array<double, 5> encuts = {1., 2., 5., 10., 20.};
200  for(auto etest : encuts){
201  if(energy > etest){
202  fHistos->FillTH2(Form("%sEtaPhi%dG%s", patchname.Data(), static_cast<int>(etest), triggerclass.Data()), eta, phi, weight);
203  fHistos->FillTH2(Form("%sColRow%dG%s", patchname.Data(), static_cast<int>(etest), triggerclass.Data()), col, row, weight);
204  }
205  }
206 }
207 
209  // Fill Event counter and reference vertex distributions for the different trigger classes
210  for(const auto &trg : fSelectedTriggers){
211  Double_t weight = GetTriggerWeight(trg);
212  AliDebugStream(1) << GetName() << ": Using weight " << weight << " for trigger " << trg << " in event histograms." << std::endl;
213  fHistos->FillTH1("EventCount" + trg, 1, weight);
214  fHistos->FillTH1("EventCentrality" + trg, fEventCentrality, weight);
215  fHistos->FillTH1("VertexZ" + trg, fVertex[2], weight);
216  }
217 
218 }
219 
220 void AliAnalysisTaskEmcalPatchesRef::GetPatchBoundaries(const AliEMCALTriggerPatchInfo *patch, Double_t *boundaries) const {
221  boundaries[0] = patch->GetEtaMin();
222  boundaries[1] = patch->GetEtaMax();
223  boundaries[2] = patch->GetPhiMin();
224  boundaries[3] = patch->GetPhiMax();
225 }
226 
227 bool AliAnalysisTaskEmcalPatchesRef::SelectSingleShowerPatch(const AliEMCALTriggerPatchInfo *patch) const{
228  if(fUseRecalcPatches){
229  if(!patch->IsRecalc()) return false;
230  return patch->IsGammaLowRecalc();
231  } else {
232  if(!patch->IsOfflineSimple()) return false;
233  return patch->IsGammaLowSimple();
234  }
235 }
236 
237 bool AliAnalysisTaskEmcalPatchesRef::SelectJetPatch(const AliEMCALTriggerPatchInfo *patch) const{
238  if(fUseRecalcPatches){
239  if(!patch->IsRecalc()) return false;
240  return patch->IsJetLowRecalc();
241  } else {
242  if(!patch->IsOfflineSimple()) return false;
243  return patch->IsJetLowSimple();
244  }
245 }
246 
249 {
250  this->SetMinimum(0.);
251  this->AddStep(1., 0.05);
252  this->AddStep(2., 0.1);
253  this->AddStep(4, 0.2);
254  this->AddStep(7, 0.5);
255  this->AddStep(16, 1);
256  this->AddStep(32, 2);
257  this->AddStep(40, 4);
258  this->AddStep(50, 5);
259  this->AddStep(100, 10);
260  this->AddStep(200, 20);
261 }
262 
263 
264 } /* namespace EMCalTriggerPtAnalysis */
std::vector< TString > fSelectedTriggers
! Triggers selected for given event
virtual bool IsUserEventSelected()
Apply additional event selection requested by the user.
double Double_t
Definition: External.C:58
Class creating a linear binning, used in the histogram manager.
void FillPatchHistograms(TString triggerclass, TString patchname, double energy, double transverseenergy, double smearedenergy, double eta, double phi, int col, int row)
Filling patch related histogram.
Bool_t fEnableSumw2
Enable sumw2 during histogram creation.
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 AddStep(Double_t max, Double_t binwidth)
virtual void UserFillHistosAfterEventSelection()
Fill event-based histograms.
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="")
Create a new TH2 within the container.
int Int_t
Definition: External.C:63
bool SelectSingleShowerPatch(const AliEMCALTriggerPatchInfo *patch) const
Selecting offline/recalc simple single shower (gamma or L0) patches.
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
Helper class creating user defined custom binning.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
bool SelectJetPatch(const AliEMCALTriggerPatchInfo *patch) const
Selecting offline/recalc simple jet patches.
Analysis of trigger patches in min. bias and triggered events.
Analysis of high- tracks in triggered events.
Double_t fVertex[3]
!event vertex
AliCutValueRange< double > fCentralityRange
Range of accepted event centralities.
TClonesArray * fTriggerPatchInfo
!trigger patch info array
std::vector< TString > GetSupportedTriggers(Bool_t useExclusiveTriggers=true) const
Bool_t fUseRecalcPatches
Switch between offline (FEE) and recalc (L1) patches.
void GetPatchBoundaries(const AliEMCALTriggerPatchInfo *patch, Double_t *boundaries) const
void SetMinimum(Double_t min)