AliPhysics  7273240 (7273240)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskEmcalClustersRef.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 <bitset>
17 #include <iostream>
18 #include <map>
19 #include <vector>
20 
21 #include <TArrayD.h>
22 #include <TClonesArray.h>
23 #include <TGrid.h>
24 #include <THashList.h>
25 #include <THistManager.h>
26 #include <TLinearBinning.h>
27 #include <TLorentzVector.h>
28 #include <TObjArray.h>
29 #include <TParameter.h>
30 #include <TMath.h>
31 
32 #include "AliAnalysisUtils.h"
33 #include "AliCentrality.h"
34 #include "AliClusterContainer.h"
35 #include "AliEMCALGeometry.h"
36 #include "AliEMCALTriggerPatchInfo.h"
38 #include "AliESDEvent.h"
39 #include "AliInputEventHandler.h"
40 #include "AliLog.h"
41 #include "AliOADBContainer.h"
42 #include "AliVCluster.h"
43 #include "AliVVertex.h"
44 #include "AliMultSelection.h"
45 #include "AliMultEstimator.h"
46 
48 
52 
53 namespace EMCalTriggerPtAnalysis {
54 
58 AliAnalysisTaskEmcalClustersRef::AliAnalysisTaskEmcalClustersRef() :
60  fNameClusterContainer(""),
61  fCentralityRange(-999., 999.),
62  fRequestCentrality(false),
63  fEventCentrality(-1)
64 {
65 }
66 
73  fNameClusterContainer(""),
74  fCentralityRange(-999., 999.),
75  fRequestCentrality(false),
76  fEventCentrality(-1)
77 {
78 }
79 
84 }
85 
90 
91  EnergyBinning energybinning;
92  TLinearBinning smbinning(21, -0.5, 20.5), etabinning(100, -0.7, 0.7);
93 
94  /*
95  * Exclusive classes are defined as triggered events
96  * in a class without lower threshold classes firing.
97  * This is needed to make the triggers statistically
98  * independent.
99  */
100  std::array<Double_t, 5> encuts = {1., 2., 5., 10., 20.};
101  Int_t sectorsWithEMCAL[10] = {4, 5, 6, 7, 8, 9, 13, 14, 15, 16};
102  for(auto trg : GetSupportedTriggers()){
103  fHistos->CreateTH1(Form("hEventCount%s", trg.Data()), Form("Event count for trigger class %s", trg.Data()), 1, 0.5, 1.5);
104  fHistos->CreateTH1(Form("hEventCentrality%s", trg.Data()), Form("Event centrality for trigger class %s", trg.Data()), 103, -2., 101.);
105  fHistos->CreateTH1(Form("hVertexZ%s", trg.Data()), Form("z-position of the primary vertex for trigger class %s", trg.Data()), 200, -40., 40.);
106  fHistos->CreateTH1(Form("hClusterEnergy%s", trg.Data()), Form("Cluster energy for trigger class %s", trg.Data()), energybinning);
107  fHistos->CreateTH1(Form("hClusterET%s", trg.Data()), Form("Cluster transverse energy for trigger class %s", trg.Data()), energybinning);
108  fHistos->CreateTH1(Form("hClusterEnergyFired%s", trg.Data()), Form("Cluster energy for trigger class %s, firing the trigger", trg.Data()), energybinning);
109  fHistos->CreateTH1(Form("hClusterETFired%s", trg.Data()), Form("Cluster transverse energy for trigger class %s, firing the trigger", trg.Data()), energybinning);
110  fHistos->CreateTH2(Form("hClusterEnergySM%s", trg.Data()), Form("Cluster energy versus supermodule for trigger class %s", trg.Data()), smbinning, energybinning);
111  fHistos->CreateTH2(Form("hClusterETSM%s", trg.Data()), Form("Cluster transverse energy versus supermodule for trigger class %s", trg.Data()), smbinning, energybinning);
112  fHistos->CreateTH2(Form("hClusterEnergyFiredSM%s", trg.Data()), Form("Cluster energy versus supermodule for trigger class %s, firing the trigger", trg.Data()), smbinning, energybinning);
113  fHistos->CreateTH2(Form("hClusterETFiredSM%s", trg.Data()), Form("Cluster transverse energy versus supermodule for trigger class %s, firing the trigger", trg.Data()), smbinning, energybinning);
114  fHistos->CreateTH2(Form("hEtaEnergy%s", trg.Data()), Form("Cluster energy vs. eta for trigger class %s", trg.Data()), etabinning, energybinning);
115  fHistos->CreateTH2(Form("hEtaET%s", trg.Data()), Form("Cluster transverse energy vs. eta for trigger class %s", trg.Data()), etabinning, energybinning);
116  fHistos->CreateTH2(Form("hEtaEnergyFired%s", trg.Data()), Form("Cluster energy vs. eta for trigger class %s, firing the trigger", trg.Data()), etabinning, energybinning);
117  fHistos->CreateTH2(Form("hEtaETFired%s", trg.Data()), Form("Cluster transverse energy vs. eta for trigger class %s, firing the trigger", trg.Data()), etabinning, energybinning);
118  for(int ism = 0; ism < 20; ism++){
119  fHistos->CreateTH2(Form("hEtaEnergySM%d%s", ism, trg.Data()), Form("Cluster energy vs. eta in Supermodule %d for trigger %s", ism, trg.Data()), etabinning, energybinning);
120  fHistos->CreateTH2(Form("hEtaETSM%d%s", ism, trg.Data()), Form("Cluster transverse energy vs. eta in Supermodule %d for trigger %s", ism, trg.Data()), etabinning, energybinning);
121  fHistos->CreateTH2(Form("hEtaEnergyFiredSM%d%s", ism, trg.Data()), Form("Cluster energy vs. eta in Supermodule %d for trigger %s, firing the trigger", ism, trg.Data()), etabinning, energybinning);
122  fHistos->CreateTH2(Form("hEtaETFiredSM%d%s", ism, trg.Data()), Form("Cluster transverse energy vs. eta in Supermodule %d for trigger %s, firing the trigger", ism, trg.Data()), etabinning, energybinning);
123  }
124  for(int isec = 0; isec < 10; isec++){
125  fHistos->CreateTH2(Form("hEtaEnergySec%d%s", sectorsWithEMCAL[isec], trg.Data()), Form("Cluster energy vs.eta in tracking sector %d for trigger %s", sectorsWithEMCAL[isec], trg.Data()), etabinning, energybinning);
126  fHistos->CreateTH2(Form("hEtaETSec%d%s", sectorsWithEMCAL[isec], trg.Data()), Form("Cluster transverse energy vs.eta in tracking sector %d for trigger %s", sectorsWithEMCAL[isec], trg.Data()), etabinning, energybinning);
127  fHistos->CreateTH2(Form("hEtaEnergyFiredSec%d%s", sectorsWithEMCAL[isec], trg.Data()), Form("Cluster energy vs.eta in tracking sector %d for trigger %s, firing the trigger", sectorsWithEMCAL[isec], trg.Data()), etabinning, energybinning);
128  fHistos->CreateTH2(Form("hEtaETFiredSec%d%s", sectorsWithEMCAL[isec], trg.Data()), Form("Cluster transverse energy vs.eta in tracking sector %d for trigger %s, firing the trigger", sectorsWithEMCAL[isec], trg.Data()), etabinning, energybinning);
129  }
130  for(auto ien : encuts){
131  fHistos->CreateTH2(Form("hEtaPhi%dG%s", static_cast<int>(ien), trg.Data()), Form("cluster #eta-#phi map for clusters with energy larger than %f GeV/c for trigger class %s", ien, trg.Data()), 100, -0.7, 0.7, 200, 0, 2*TMath::Pi());
132  fHistos->CreateTH2(Form("hEtaPhiFired%dG%s", static_cast<int>(ien), trg.Data()), Form("cluster #eta-#phi map for clusters fired the trigger with energy larger than %f GeV/c for trigger class %s", ien, trg.Data()), 200, -0.7, 0.7, 200, 0, 2*TMath::Pi());
133  }
134  }
135 }
136 
138  fEventCentrality = -1;
139  if(fRequestCentrality){
140  AliMultSelection *mult = dynamic_cast<AliMultSelection *>(InputEvent()->FindListObject("MultSelection"));
141  if(!mult){
142  AliErrorStream() << GetName() << ": Centrality selection enabled but no centrality estimator found" << std::endl;
143  return false;
144  }
145  if(mult->IsEventSelected()) return false;
146  fEventCentrality = mult->GetEstimator("V0M")->GetPercentile();
147  AliDebugStream(1) << GetName() << ": Centrality " << fEventCentrality << std::endl;
149  AliDebugStream(1) << GetName() << ": reject centrality: " << fEventCentrality << std::endl;
150  return false;
151  } else {
152  AliDebugStream(1) << GetName() << ": select centrality " << fEventCentrality << std::endl;
153  }
154  } else {
155  AliDebugStream(1) << GetName() << ": No centrality selection applied" << std::endl;
156  }
157  return true;
158 }
159 
160 
166  AliDebugStream(1) << GetName() << ": UserExec start" << std::endl;
167 
168  TList ej1patches, dj1patches, ej2patches, dj2patches, eg1patches, dg1patches, eg2patches, dg2patches;
169  FindPatchesForTrigger("EJ2", fTriggerPatchInfo, ej2patches);
170  FindPatchesForTrigger("DJ2", fTriggerPatchInfo, dj2patches);
171  FindPatchesForTrigger("EJ1", fTriggerPatchInfo, ej1patches);
172  FindPatchesForTrigger("DJ1", fTriggerPatchInfo, dj1patches);
173  FindPatchesForTrigger("EG2", fTriggerPatchInfo, eg2patches);
174  FindPatchesForTrigger("DG2", fTriggerPatchInfo, dg2patches);
175  FindPatchesForTrigger("EG1", fTriggerPatchInfo, eg1patches);
176  FindPatchesForTrigger("DG1", fTriggerPatchInfo, dg1patches);
177 
178  Double_t energy, et, eta, phi;
179  TList *selpatches(nullptr);
180  for(auto clust : GetClusterContainer(fNameClusterContainer.Data())->all()){
181  //AliVCluster *clust = static_cast<AliVCluster *>(*clustIter);
182  if(!clust->IsEMCAL()) continue;
183  if(clust->GetIsExotic()) continue;
184 
185  TLorentzVector posvec;
186  energy = clust->GetNonLinCorrEnergy();
187  et = posvec.Et();
188  clust->GetMomentum(posvec, fVertex);
189  eta = posvec.Eta();
190  phi = posvec.Phi();
191 
192  // fill histograms allEta
193  for(const auto & trg : fSelectedTriggers){
194  selpatches = nullptr;
195  if(trg.Contains("EJ2")) selpatches = &ej2patches;
196  if(trg.Contains("DJ2")) selpatches = &dj2patches;
197  if(trg.Contains("EJ1")) selpatches = &ej1patches;
198  if(trg.Contains("DJ1")) selpatches = &dj1patches;
199  if(trg.Contains("EG2")) selpatches = &eg2patches;
200  if(trg.Contains("DG2")) selpatches = &dg2patches;
201  if(trg.Contains("EG1")) selpatches = &eg1patches;
202  if(trg.Contains("DG1")) selpatches = &dg1patches;
203  FillClusterHistograms(trg.Data(), energy, et, eta, phi, nullptr);
204  }
205  }
206  return true;
207 }
208 
209 void AliAnalysisTaskEmcalClustersRef::FillClusterHistograms(const TString &triggerclass, double energy, double transverseenergy, double eta, double phi, TList *fTriggerPatches){
210  Bool_t hasTriggerPatch = fTriggerPatches ? CorrelateToTrigger(eta, phi, fTriggerPatches) : kFALSE;
211  Int_t supermoduleID = -1, sector = -1;
212  Double_t weight = GetTriggerWeight(triggerclass);
213  AliDebugStream(1) << GetName() << ": Using weight " << weight << " for trigger " << triggerclass << std::endl;
214 
215  fGeom->SuperModuleNumberFromEtaPhi(eta, phi, supermoduleID);
216  fHistos->FillTH1(Form("hClusterEnergy%s", triggerclass.Data()), energy, weight);
217  fHistos->FillTH1(Form("hClusterET%s", triggerclass.Data()), transverseenergy, weight);
218  fHistos->FillTH2(Form("hEtaEnergy%s", triggerclass.Data()), eta, energy, weight);
219  fHistos->FillTH2(Form("hEtaET%s", triggerclass.Data()), eta, transverseenergy, weight);
220  if(supermoduleID >= 0){
221  fHistos->FillTH2(Form("hClusterEnergySM%s", triggerclass.Data()), supermoduleID, energy, weight);
222  fHistos->FillTH2(Form("hClusterETSM%s", triggerclass.Data()), supermoduleID, transverseenergy, weight);
223  fHistos->FillTH2(Form("hEtaEnergySM%d%s", supermoduleID, triggerclass.Data()), eta, energy, weight);
224  fHistos->FillTH2(Form("hEtaETSM%d%s", supermoduleID, triggerclass.Data()), eta, transverseenergy, weight);
225  if(supermoduleID < 12)
226  sector = 4 + int(supermoduleID/2); // EMCAL
227  else
228  sector = 13 + int((supermoduleID-12)/2); // DCAL
229  fHistos->FillTH2(Form("hEtaEnergySec%d%s", sector, triggerclass.Data()), eta, energy, weight);
230  fHistos->FillTH2(Form("hEtaETSec%d%s", sector, triggerclass.Data()), eta, transverseenergy, weight);
231  }
232  if(hasTriggerPatch){
233  fHistos->FillTH1(Form("hClusterEnergyFired%s", triggerclass.Data()), energy, weight);
234  fHistos->FillTH1(Form("hClusterETFired%s", triggerclass.Data()), energy, weight);
235  fHistos->FillTH2(Form("hEtaEnergyFired%s", triggerclass.Data()), eta, energy, weight);
236  fHistos->FillTH2(Form("hEtaETFired%s", triggerclass.Data()), eta, energy, weight);
237  if(supermoduleID >= 0){
238  fHistos->FillTH2(Form("hClusterEnergyFiredSM%s", triggerclass.Data()), supermoduleID, energy, weight);
239  fHistos->FillTH2(Form("hClusterETFiredSM%s", triggerclass.Data()), supermoduleID, transverseenergy, weight);
240  fHistos->FillTH2(Form("hEtaEnergyFiredSM%d%s", supermoduleID, triggerclass.Data()), eta, energy,weight);
241  fHistos->FillTH2(Form("hEtaETFiredSM%d%s", supermoduleID, triggerclass.Data()), eta, transverseenergy, weight);
242  fHistos->FillTH2(Form("hEtaEnergyFiredSec%d%s", sector, triggerclass.Data()), eta, energy, weight);
243  fHistos->FillTH2(Form("hEtaETFiredSec%d%s", sector, triggerclass.Data()), eta, transverseenergy, weight);
244  }
245  }
246  Double_t encuts[5] = {1., 2., 5., 10., 20.};
247  for(int ien = 0; ien < 5; ien++){
248  if(energy > encuts[ien]){
249  fHistos->FillTH2(Form("hEtaPhi%dG%s", static_cast<int>(encuts[ien]), triggerclass.Data()), eta, phi, weight);
250  if(hasTriggerPatch){
251  fHistos->FillTH2(Form("hEtaPhiFired%dG%s", static_cast<int>(encuts[ien]), triggerclass.Data()), eta, phi, weight);
252  }
253  }
254  }
255 }
256 
266  for(const auto &t : fSelectedTriggers){
267  Double_t weight = GetTriggerWeight(t);
268  fHistos->FillTH1(Form("hEventCount%s", t.Data()), 1, weight);
269  fHistos->FillTH1(Form("hEventCentrality%s", t.Data()), fEventCentrality, weight);
270  fHistos->FillTH1(Form("hVertexZ%s", t.Data()), fVertex[2], weight);
271  }
272 }
273 
282  Bool_t hasfound = kFALSE;
283  for(TIter patchIter = TIter(fTriggerPatches).Begin(); patchIter != TIter::End(); ++patchIter){
284  Double_t boundaries[4];
285  GetPatchBoundaries(*patchIter, boundaries);
286  Double_t etamin = TMath::Min(boundaries[0], boundaries[1]),
287  etamax = TMath::Max(boundaries[0], boundaries[1]),
288  phimin = TMath::Min(boundaries[2], boundaries[3]),
289  phimax = TMath::Max(boundaries[2], boundaries[3]);
290  if(etaclust > etamin && etaclust < etamax && phiclust > phimin && phiclust < phimax){
291  hasfound = kTRUE;
292  break;
293  }
294  }
295  return hasfound;
296 }
297 
306 void AliAnalysisTaskEmcalClustersRef::FindPatchesForTrigger(TString triggerclass, const TClonesArray * fTriggerPatches, TList &foundtriggers) const {
307  foundtriggers.Clear();
308  if(!fTriggerPatches) return;
310  if(triggerclass == "EG1") myclass = AliEmcalTriggerOfflineSelection::kTrgEG1;
311  if(triggerclass == "EG2") myclass = AliEmcalTriggerOfflineSelection::kTrgEG2;
312  if(triggerclass == "EJ1") myclass = AliEmcalTriggerOfflineSelection::kTrgEJ1;
313  if(triggerclass == "EJ2") myclass = AliEmcalTriggerOfflineSelection::kTrgEJ2;
314  if(triggerclass == "DMC7") myclass = AliEmcalTriggerOfflineSelection::kTrgDL0;
315  if(triggerclass == "DG1") myclass = AliEmcalTriggerOfflineSelection::kTrgDG1;
316  if(triggerclass == "DG2") myclass = AliEmcalTriggerOfflineSelection::kTrgDG2;
317  if(triggerclass == "DJ1") myclass = AliEmcalTriggerOfflineSelection::kTrgDJ1;
318  if(triggerclass == "DJ2") myclass = AliEmcalTriggerOfflineSelection::kTrgDJ2;
319  for(TIter patchiter = TIter(fTriggerPatches).Begin(); patchiter != TIter::End(); ++patchiter){
320  if(!IsOfflineSimplePatch(*patchiter)) continue;
322  if(!SelectDCALPatch(*patchiter)) continue;
323  } else {
324  if(SelectDCALPatch(*patchiter)) continue;
325  }
327  if(!SelectSingleShowerPatch(*patchiter)) continue;
328  } else {
329  if(!SelectJetPatch(*patchiter)) continue;
330  }
331  double threshold = fTriggerSelection ? fTriggerSelection->GetThresholdForTrigger(myclass) : -1;
332  if(GetPatchEnergy(*patchiter) > threshold) foundtriggers.Add(*patchiter);
333  }
334 }
335 
337  AliEMCALTriggerPatchInfo *patch= dynamic_cast<AliEMCALTriggerPatchInfo *>(o);
338  boundaries[0] = patch->GetEtaMin();
339  boundaries[1] = patch->GetEtaMax();
340  boundaries[2] = patch->GetPhiMin();
341  boundaries[3] = patch->GetPhiMax();
342 }
343 
345  AliEMCALTriggerPatchInfo *patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(o);
346  return patch->IsOfflineSimple();
347 }
348 
350  AliEMCALTriggerPatchInfo *patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(o);
351  return patch->GetRowStart() >= 64;
352 }
353 
355  AliEMCALTriggerPatchInfo *patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(o);
356  return patch->IsGammaLowSimple();
357 }
358 
360  AliEMCALTriggerPatchInfo *patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(o);
361  if(!patch->IsOfflineSimple()) return false;
362  return patch->IsJetLowSimple();
363 }
364 
366  double energy = 0.;
367  AliEMCALTriggerPatchInfo *patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(o);
368  energy = patch->GetPatchE();
369  return energy;
370 }
371 
377 {
378  this->SetMinimum(0.);
379  this->AddStep(1, 0.05);
380  this->AddStep(2, 0.1);
381  this->AddStep(4, 0.2);
382  this->AddStep(7, 0.5);
383  this->AddStep(16, 1);
384  this->AddStep(32, 2);
385  this->AddStep(40, 4);
386  this->AddStep(50, 5);
387  this->AddStep(100, 10);
388  this->AddStep(200, 20);
389 }
390 
391 
392 } /* namespace EMCalTriggerPtAnalysis */
void GetPatchBoundaries(TObject *o, Double_t *boundaries) const
std::vector< TString > fSelectedTriggers
! Triggers selected for given event
double Double_t
Definition: External.C:58
Class creating a linear binning, used in the histogram manager.
Bool_t CorrelateToTrigger(Double_t etaclust, Double_t phiclust, TList *triggerpatches) const
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
AliEmcalTriggerOfflineSelection * fTriggerSelection
Offline trigger selection.
Bool_t fRequestCentrality
Switch on request for centrality range.
void AddStep(Double_t max, Double_t binwidth)
void FillClusterHistograms(const TString &triggerclass, double energy, double transversenergy, double eta, double phi, TList *triggerpatches)
const Double_t etamin
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
TString fNameClusterContainer
Name of the cluster container in the event.
AliEMCALGeometry * fGeom
!emcal geometry
EmcalTriggerClass
Definition of the various supported trigger types.
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Helper class creating user defined custom binning.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
energy
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Double_t fVertex[3]
!event vertex
AliCutValueRange< double > fCentralityRange
Selected centrality range.
const Double_t etamax
TClonesArray * fTriggerPatchInfo
!trigger patch info array
bool Bool_t
Definition: External.C:53
const Double_t phimin
void FindPatchesForTrigger(TString triggerclass, const TClonesArray *triggerpatches, TList &foundpatches) const
void SetMinimum(Double_t min)