AliPhysics  4c9ecbb (4c9ecbb)
AliAnalysisTaskEmcalOccupancy.cxx
Go to the documentation of this file.
1 #include <algorithm>
2 #include <cfloat>
3 #include <cstdlib>
4 #include <cstring>
5 #include <iostream>
6 
7 #include <TLinearBinning.h>
8 #include <THistManager.h>
9 
10 #include "AliAnalysisManager.h"
12 #include "AliClusterContainer.h"
13 #include "AliEMCALGeometry.h"
14 #include "AliMultSelection.h"
15 #include "AliVCaloCells.h"
16 
18 
21  fNameClusters(),
22  fHistos(nullptr),
23  fUseCentrality(false),
24  fCellCounter(nullptr)
25 {
26 
27 }
28 
30  AliAnalysisTaskEmcalLight(name, true),
31  fNameClusters(),
32  fHistos(nullptr),
33  fUseCentrality(false),
34  fCellCounter(nullptr)
35 {
36  SetNeedEmcalGeom(true);
37  this->SetMakeGeneralHistograms(true);
38 }
39 
41  if(fCellCounter) delete fCellCounter;
42  if(fHistos) delete fHistos;
43 }
44 
47  fHistos = new THistManager("histos");
48 
49  TLinearBinning multbinning(101, -0.5, 100.5),
50  cellbinning(20001, -0.5, 20000.5),
51  clusterbinning(2001, -0.5, 2000.5);
52  const TBinning *histbinning[5] = {&multbinning, &cellbinning, &cellbinning, &clusterbinning, &clusterbinning};
53  fHistos->CreateTHnSparse("EMCALOccupancy", "EMCAL occupancy", 5, histbinning);
54 
55  for(auto h : *fHistos) fOutput->Add(h);
56  PostData(1, fOutput);
57 }
58 
61  if(!fLocalInitialized) return;
62 
63  // Create buffer for cells (would normally be done with a std::unique_ptr
64  fCellCounter = new UChar_t[fGeom->GetNCells()];
65 }
66 
68  // Reset cell counter
69  memset(fCellCounter, 0, sizeof(UChar_t) * fGeom->GetNCells());
70 
71  // Get the centrality percentile - steered by AliAnalysisTaskEmcalLight
72  double centralityPercentile = (this->fForceBeamType == AliAnalysisTaskEmcalOccupancy::kAA) ? fCent : 0.;
73 
74  AliVCaloCells *emccells = InputEvent()->GetEMCALCells();
75  int cellcounterRaw(0), cellcounterCorr(0);
76  for(int icell = 0; icell < emccells->GetNumberOfCells(); icell++) {
77  Short_t absID = emccells->GetCellNumber(icell);
78  Double_t amplitude = emccells->GetAmplitude(icell);
79  if(amplitude > DBL_EPSILON) {
80  cellcounterRaw++;
81  fCellCounter[absID]++;
82  }
83  }
84 
85  // Filter out all non-0 cells
86  cellcounterCorr = std::count_if(fCellCounter, fCellCounter + fGeom->GetNCells(), [] (UChar_t count) -> bool { return count > 0; } );
87 
88  // check on cluster level - with and without exotics
89  int clustercounterRaw(0), clustercounterCorr(0);
91  clustercounterRaw = clusters->GetNClusters();
92  const AliClusterIterableContainer &clusteriter = clusters->all();
93  clustercounterCorr = std::count_if(clusteriter.begin(), clusteriter.end(), [](const AliVCluster *c) -> bool { return !c->GetIsExotic(); } );
94 
95  Double_t datapoint[5] = {centralityPercentile, static_cast<double>(cellcounterRaw), static_cast<double>(cellcounterCorr), static_cast<double>(clustercounterRaw), static_cast<double>(clustercounterCorr)};
96 
97  fHistos->FillTHnSparse("EMCALOccupancy", datapoint);
98 
99  return true;
100 }
101 
103  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
104  if(!mgr) {
105  std::cout << "AddOccupancyTask: Analysis Manager not available - exiting ..." << std::endl;
106  return nullptr;
107  }
108 
110  mgr->AddTask(occupancyTask);
111 
112  TString outname = mgr->GetCommonFileName();
113  outname += TString::Format(":EMCALOccupancy");
114 
115  mgr->ConnectInput(occupancyTask, 0, mgr->GetCommonInputContainer());
116  mgr->ConnectOutput(occupancyTask, 1, mgr->CreateContainer("EMCALOccupancyHists", TList::Class(), AliAnalysisManager::kOutputContainer, outname));
117 
118  return occupancyTask;
119 }
THistManager * fHistos
Histogram container;.
AliEMCALGeometry * fGeom
!emcal geometry
double Double_t
Definition: External.C:58
Class creating a linear binning, used in the histogram manager.
TCanvas * c
Definition: TestFitELoss.C:172
Interface for binnings used by the histogram handler.
Definition: TBinning.h:21
const AliClusterIterableContainer all() const
EBeamType_t fForceBeamType
forced beam type
TString fNameClusters
Name of the cluster container.
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
Base task in the EMCAL framework (lighter version of AliAnalysisTaskEmcal)
static AliAnalysisTaskEmcalOccupancy * AddOccupancyTask(const char *name)
AliClusterContainer * GetClusterContainer(std::string name) const
Int_t GetNClusters() const
short Short_t
Definition: External.C:23
Bool_t fLocalInitialized
!whether or not the task has been already initialized
Container class for histograms.
Definition: THistManager.h:99
bool Bool_t
Definition: External.C:53
THnSparse * CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
Create a new THnSparse within the container.
Task monitoring the occupancy on cluster and cell level.
Container structure for EMCAL clusters.
Double_t fCent
!event centrality
UChar_t * fCellCounter
! Counting how often a cell is fired per event