AliPhysics  c0d7b22 (c0d7b22)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalCellMonitorTask.cxx
Go to the documentation of this file.
1 #include <algorithm>
2 #include <map>
3 #include <vector>
4 #include <TArrayD.h>
5 #include <TGrid.h>
6 #include <THashList.h>
7 #include <THistManager.h>
8 #include <TLinearBinning.h>
9 #include <TObjArray.h>
10 #include <TParameter.h>
11 
12 #include "AliEMCALGeometry.h"
14 #include "AliInputEventHandler.h"
15 #include "AliLog.h"
16 #include "AliOADBContainer.h"
17 #include "AliVCaloCells.h"
18 #include "AliVEvent.h"
19 
23 
25  AliAnalysisTaskSE(),
26  fHistManager(nullptr),
27  fGeometry(nullptr),
28  fMinCellAmplitude(0),
29  fRequestTrigger(AliVEvent::kAnyINT),
30  fBadChannelContainer(""),
31  fTriggerString(""),
32  fNumberOfCells(12288),
33  fOldRun(-1),
34  fMaskedCells()
35 {
36 
37 }
38 
40  AliAnalysisTaskSE(name),
41  fHistManager(nullptr),
42  fGeometry(nullptr),
43  fMinCellAmplitude(0),
44  fRequestTrigger(AliVEvent::kAnyINT),
45  fBadChannelContainer(""),
46  fTriggerString(""),
47  fNumberOfCells(12288),
48  fOldRun(-1),
49  fMaskedCells()
50 {
51  DefineOutput(1, TList::Class());
52 }
53 
55  if(fGeometry) delete fGeometry;
56 }
57 
59  fHistManager = new THistManager("EMCALCellMonitor");
60 
61  fHistManager->CreateTH1("events", "Number of events", 1, 0.5, 1.5);
62  fHistManager->CreateTH1("cellMasking", "Monitoring for masked cells", TLinearBinning(fNumberOfCells, -0.5, fNumberOfCells - 0.5));
63  fHistManager->CreateTH1("cellFrequency", "Frequency of cell firing", TLinearBinning(fNumberOfCells, -0.5, fNumberOfCells - 0.5));
64  fHistManager->CreateTH2("cellAmplitude", "Energy distribution per cell", TLinearBinning(fNumberOfCells, -0.5, fNumberOfCells - 0.5), AliEmcalCellMonitorAmplitudeBinning());
65  fHistManager->CreateTH2("cellAmplitudeCut", "Energy distribution per cell (after energy cut)", TLinearBinning(fNumberOfCells, -0.5, fNumberOfCells - 0.5), AliEmcalCellMonitorAmplitudeBinning());
66  fHistManager->CreateTH2("cellTime", "Time distribution per cell", fNumberOfCells, -0.5, fNumberOfCells - 0.5, 200, -1e-6, 1e-6);
67  fHistManager->CreateTH2("cellTimeOutlier", "Outlier time distribution per cell", fNumberOfCells, -0.5, fNumberOfCells - 0.5, 100, 1e-6, 5e-5);
68  fHistManager->CreateTH2("cellTimeMain", "Time distribution per cell for the main bunch", fNumberOfCells, -0.5, fNumberOfCells - 0.5, 150, -50e-9, 100e-9);
69  for(int ism = 0; ism < 20; ++ism){
70  fHistManager->CreateTH2(Form("cellAmpSM%d", ism), Form("Integrated cell amplitudes for SM %d; col; row", ism), 48, -0.5, 47.5, 24, -0.5, 23.5);
71  fHistManager->CreateTH2(Form("cellCountSM%d", ism), Form("Count rate per cell for SM %d; col; row", ism), 48, -0.5, 47.5, 24, -0.5, 23.5);
72  }
73 
74  for(int ism = 0; ism < 20; ++ism){
75  fHistManager->CreateTH2(Form("cellAmpTimeCorrSM%d", ism), Form("Correlation between cell amplitude and time in Supermodule %d", ism), 1000, -5e-7, 5e-7, 1000, 0., 100.);
76  }
77 
78  PostData(1, fHistManager->GetListOfHistograms());
79 }
80 
82  if(!fGeometry) fGeometry = AliEMCALGeometry::GetInstanceFromRunNumber(fInputEvent->GetRunNumber());
83 
84  // Run change
85  if(InputEvent()->GetRunNumber() != fOldRun){
87 
88  for(auto cellID : fMaskedCells) fHistManager->FillTH1("cellMasking", cellID);
89  fOldRun = InputEvent()->GetRunNumber();
90  }
91 
92  // Check trigger
93  if(!(fInputHandler->IsEventSelected() & fRequestTrigger)) return;
94  if(fTriggerString.Length()){
95  if(!TString(InputEvent()->GetFiredTriggerClasses()).Contains(fTriggerString)) return;
96  }
97 
98  fHistManager->FillTH1("events", 1);
99 
100  AliVCaloCells *emcalcells = fInputEvent->GetEMCALCells();
101 
102  // input data
103  Short_t cellNumber;
104  Double_t amplitude, celltime, efrac;
105  Int_t mclabel;
106 
107  Int_t sm, mod, meta, mphi, ieta, iphi;
108  for(int icell = 0; icell < emcalcells->GetNumberOfCells(); icell++){
109  emcalcells->GetCell(icell, cellNumber, amplitude, celltime, mclabel, efrac);
110  if(IsCellMasked(cellNumber)) continue;
111  fHistManager->FillTH2("cellAmplitude", cellNumber, amplitude);
112  if(amplitude < fMinCellAmplitude) continue;
113  fHistManager->FillTH1("cellAmplitudeCut", cellNumber, amplitude);
114  fHistManager->FillTH1("cellFrequency", cellNumber);
115  fHistManager->FillTH2("cellTime", cellNumber, celltime);
116  if(celltime >= 1e-6) fHistManager->FillTH2("cellTimeOutlier", cellNumber, celltime);
117  if(celltime > -5e-8 && celltime < 1e-7) fHistManager->FillTH2("cellTimeMain", cellNumber, celltime);
118 
119  // Get Cell index in eta-phi of sm
120  fGeometry->GetCellIndex(cellNumber, sm, mod, mphi, meta);
121  fGeometry->GetCellPhiEtaIndexInSModule(sm, mod, mphi, meta, iphi, ieta);
122 
123  fHistManager->FillTH2(Form("cellCountSM%d", sm), ieta, iphi);
124  fHistManager->FillTH2(Form("cellAmpSM%d", sm), ieta, iphi, amplitude);
125  fHistManager->FillTH2(Form("cellAmpTimeCorrSM%d", sm), celltime, amplitude);
126  }
127  PostData(1, fHistManager->GetListOfHistograms());
128 }
129 
131  if(!fBadChannelContainer.Length()) return;
132  AliInfo(Form("Loading bad channel map from %s", fBadChannelContainer.Data()));
133  fMaskedCells.clear();
134  if(fBadChannelContainer.Contains("alien://") && ! gGrid) TGrid::Connect("alien://"); // Make sure alien connection is available as the AliOADBContainer doesn't handle it
135  AliOADBContainer contreader("EmcalBadChannelsAdditional");
136  contreader.InitFromFile(fBadChannelContainer.Data(), "EmcalBadChannelsAdditional");
137  TObjArray *rundata = dynamic_cast<TObjArray *>(contreader.GetObject(InputEvent()->GetRunNumber()));
138  if(!rundata) return;
139  for(TIter channeliter = TIter(rundata).Begin(); channeliter != TIter::End(); ++channeliter){
140  TParameter<int> *cellID = static_cast<TParameter<int> *>(*channeliter);
141  if(cellID) SetBadCell(cellID->GetVal());
142  }
143 }
144 
146  if(std::find(fMaskedCells.begin(), fMaskedCells.end(), cellId) != fMaskedCells.end()) return;
147  fMaskedCells.push_back(cellId);
148 }
149 
150 bool AliEmcalCellMonitorTask::IsCellMasked(Int_t cellId) const {
151  return (std::find(fMaskedCells.begin(), fMaskedCells.end(), cellId) != fMaskedCells.end());
152 }
153 
156 {
157  SetMinimum(0);
158  AddStep(1., 0.1);
159  AddStep(10., 0.5);
160  AddStep(20., 1.);
161  AddStep(50., 2.);
162  AddStep(100., 5.);
163  AddStep(200., 10.);
164 }
Class creating a linear binning, used in the histogram manager.
std::vector< Int_t > fMaskedCells
Vector of masked cells.
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
ULong_t fRequestTrigger
Trigger selection.
void AddStep(Double_t max, Double_t binwidth)
bool IsCellMasked(Int_t cellId) const
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
THashList * GetListOfHistograms() const
Definition: THistManager.h:504
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Helper class creating user defined custom binning.
Int_t fNumberOfCells
Number of cells.
virtual void UserExec(Option_t *)
TString fTriggerString
Trigger string in addition to trigger selection.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Double_t fMinCellAmplitude
Min. cell amplitude requested for cell time and frequency.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Int_t fOldRun
! Old Run number (for run change check)
Container class for histograms for the high- charged particle analysis.
Definition: THistManager.h:43
Int_t GetRunNumber(TString)
Definition: PlotMuonQA.C:2235
AliEMCALGeometry * fGeometry
! EMCAL geometry
TString fBadChannelContainer
Bad channel container name.
THistManager * fHistManager
! Histogram handler
void SetMinimum(Double_t min)
Simple monitoring task for cell related quantities.