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