AliPhysics  f05a842 (f05a842)
 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 <iostream>
3 #include <map>
4 #include <vector>
5 #include <TArrayD.h>
6 #include <TClonesArray.h>
7 #include <TGrid.h>
8 #include <THashList.h>
9 #include <THistManager.h>
10 #include <TLinearBinning.h>
11 #include <TObjArray.h>
12 #include <TParameter.h>
13 
14 #include "AliEMCALGeometry.h"
16 #include "AliInputEventHandler.h"
17 #include "AliLog.h"
18 #include "AliOADBContainer.h"
19 #include "AliVCaloCells.h"
20 #include "AliVEvent.h"
21 
25 
28  fInitialized(kTRUE),
29  fHistManager(nullptr),
30  fGeometry(nullptr),
31  fMinCellAmplitude(0),
32  fRequestTrigger(AliVEvent::kAnyINT),
33  fBadChannelContainer(""),
34  fTriggerString(""),
35  fNumberOfCells(12288),
36  fOldRun(-1),
37  fMaskedCells()
38 {
39 
40 }
41 
43  AliAnalysisTaskSE(name),
44  fInitialized(kTRUE),
45  fHistManager(nullptr),
46  fGeometry(nullptr),
47  fMinCellAmplitude(0),
48  fRequestTrigger(AliVEvent::kAnyINT),
49  fBadChannelContainer(""),
50  fTriggerString(""),
51  fNumberOfCells(12288),
52  fOldRun(-1),
53  fMaskedCells()
54 {
55  DefineOutput(1, TList::Class());
56 }
57 
59  if(fGeometry) delete fGeometry;
60 }
61 
63  fHistManager = new THistManager("EMCALCellMonitor");
64 
65 
66  PostData(1, fHistManager->GetListOfHistograms());
67 }
68 
70  if(!fGeometry)
71  fGeometry = AliEMCALGeometry::GetInstanceFromRunNumber(fInputEvent->GetRunNumber());
72  fNumberOfCells = fGeometry->GetNCells();
74 }
75 
78  for(auto cellID : fMaskedCells) fHistManager->FillTH1("cellMasking", cellID);
79 }
80 
82  if(!fInitialized) {
83  ExecOnce();
84  fInitialized = kTRUE;
85  }
86 
87  // Run change
88  if(InputEvent()->GetRunNumber() != fOldRun){
89  RunChanged();
90  fOldRun = InputEvent()->GetRunNumber();
91  }
92 
93  // Check trigger
94  if(!(fInputHandler->IsEventSelected() & fRequestTrigger)) return;
95  if(fTriggerString.Length()){
96  if(!TString(InputEvent()->GetFiredTriggerClasses()).Contains(fTriggerString)) return;
97  }
98 
99  fHistManager->FillTH1("events", 1);
100 
101  AliVCaloCells *emcalcells = fInputEvent->GetEMCALCells();
102 
103  // input data
104  Short_t cellNumber;
105  Double_t amplitude, celltime, efrac;
106  Int_t mclabel;
107 
108  Int_t sm, mod, meta, mphi, ieta, iphi;
109  for(int icell = 0; icell < emcalcells->GetNumberOfCells(); icell++){
110  emcalcells->GetCell(icell, cellNumber, amplitude, celltime, mclabel, efrac);
111  if(IsCellMasked(cellNumber)) continue;
112  fHistManager->FillTH2("cellAmplitude", amplitude, cellNumber);
113  if(amplitude < fMinCellAmplitude) continue;
114  fHistManager->FillTH1("cellAmplitudeCut", amplitude, cellNumber);
115  fHistManager->FillTH1("cellFrequency", cellNumber);
116  fHistManager->FillTH2("cellTime", celltime, cellNumber);
117  if(celltime >= 1e-6) fHistManager->FillTH2("cellTimeOutlier", celltime, cellNumber);
118  if(celltime > -5e-8 && celltime < 1e-7) fHistManager->FillTH2("cellTimeMain", celltime, cellNumber);
119 
120  // Get Cell index in eta-phi of sm
121  fGeometry->GetCellIndex(cellNumber, sm, mod, mphi, meta);
122  fGeometry->GetCellPhiEtaIndexInSModule(sm, mod, mphi, meta, iphi, ieta);
123 
124  fHistManager->FillTH2(Form("cellCountSM%d", sm), ieta, iphi);
125  fHistManager->FillTH2(Form("cellAmpSM%d", sm), ieta, iphi, amplitude);
126  fHistManager->FillTH2(Form("cellAmpTimeCorrSM%d", sm), celltime, amplitude);
127  }
128 
129  // Cluster loop
130  if(fNameClusters.Length()){
131  TClonesArray *clustercont = dynamic_cast<TClonesArray *>(InputEvent()->FindListObject(fNameClusters.Data()));
132  if(clustercont){
133  const AliVCluster *myclust = nullptr;
134  for(TIter clusteriter = TIter(clustercont).Begin(); clusteriter != TIter::End(); ++clusteriter){
135  myclust = dynamic_cast<const AliVCluster *>(*clusteriter);
136  if(!myclust) continue;
137  for(int icell = 0; icell < myclust->GetNCells(); icell++){
138  fHistManager->FillTH1("cellClusterOccurrency", myclust->GetCellAbsId(icell));
139  fHistManager->FillTH2("cellAmplitudeFractionCluster", myclust->GetCellAbsId(icell), myclust->GetCellAmplitudeFraction(icell));
140  }
141  }
142  } else {
143  AliErrorStream() << GetName() << ": cluster container " << fNameClusters << " not found in the input event" << std::endl;
144  }
145  }
146  PostData(1, fHistManager->GetListOfHistograms());
147 }
148 
150  fHistManager->CreateTH1("events", "Number of events", 1, 0.5, 1.5);
151  fHistManager->CreateTH1("cellMasking", "Monitoring for masked cells", TLinearBinning(fNumberOfCells, -0.5, fNumberOfCells - 0.5));
152  fHistManager->CreateTH1("cellFrequency", "Frequency of cell firing", TLinearBinning(fNumberOfCells, -0.5, fNumberOfCells - 0.5));
153  fHistManager->CreateTH2("cellAmplitude", "Energy distribution per cell", AliEmcalCellMonitorAmplitudeBinning(), TLinearBinning(fNumberOfCells, -0.5, fNumberOfCells - 0.5));
154  fHistManager->CreateTH2("cellAmplitudeCut", "Energy distribution per cell (after energy cut)", AliEmcalCellMonitorAmplitudeBinning(), TLinearBinning(fNumberOfCells, -0.5, fNumberOfCells - 0.5));
155  fHistManager->CreateTH2("cellTime", "Time distribution per cell", 300, -3e-7, 1e-6, fNumberOfCells, -0.5, fNumberOfCells - 0.5);
156  fHistManager->CreateTH2("cellTimeOutlier", "Outlier time distribution per cell", 100, 1e-6, 5e-5, fNumberOfCells, -0.5, fNumberOfCells - 0.5);
157  fHistManager->CreateTH2("cellTimeMain", "Time distribution per cell for the main bunch", 150, -50e-9, 100e-9, fNumberOfCells, -0.5, fNumberOfCells - 0.5);
158  fHistManager->CreateTH1("cellClusterOccurrency", "Occurrency of a cell in clusters", fNumberOfCells, -0.5, fNumberOfCells - 0.5);
159  fHistManager->CreateTH2("cellAmplitudeFractionCluster", "Summed cell amplitude fraction in a cluster", fNumberOfCells, -0.5, fNumberOfCells - 0.5, 200, 0., 200.);
160  for(int ism = 0; ism < 20; ++ism){
161  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);
162  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);
163  }
164 
165  for(int ism = 0; ism < 20; ++ism){
166  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.);
167  }
168 }
169 
171  if(!fBadChannelContainer.Length()) return;
172  AliInfoStream() << GetName() << ": Loading bad channel map from " <<fBadChannelContainer << std::endl;
173  fMaskedCells.clear();
174  if(fBadChannelContainer.Contains("alien://") && ! gGrid) TGrid::Connect("alien://"); // Make sure alien connection is available as the AliOADBContainer doesn't handle it
175  AliOADBContainer contreader("EmcalBadChannelsAdditional");
176  contreader.InitFromFile(fBadChannelContainer.Data(), "EmcalBadChannelsAdditional");
177  TObjArray *rundata = dynamic_cast<TObjArray *>(contreader.GetObject(InputEvent()->GetRunNumber()));
178  if(!rundata) return;
179  for(TIter channeliter = TIter(rundata).Begin(); channeliter != TIter::End(); ++channeliter){
180  TParameter<int> *cellID = static_cast<TParameter<int> *>(*channeliter);
181  if(cellID) SetBadCell(cellID->GetVal());
182  }
183 }
184 
186  if(std::find(fMaskedCells.begin(), fMaskedCells.end(), cellId) != fMaskedCells.end()) return;
187  fMaskedCells.push_back(cellId);
188 }
189 
191  return (std::find(fMaskedCells.begin(), fMaskedCells.end(), cellId) != fMaskedCells.end());
192 }
193 
196 {
197  SetMinimum(0);
198  AddStep(2., 0.1);
199  AddStep(5., 0.2);
200  AddStep(10., 0.5);
201  AddStep(20., 1.);
202  AddStep(50., 2.);
203  AddStep(100., 5.);
204  AddStep(200., 10.);
205 }
double Double_t
Definition: External.C:58
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="")
int Int_t
Definition: External.C:63
THashList * GetListOfHistograms() const
Definition: THistManager.h:504
TString fNameClusters
Name of the cluster container (as TClonesArray)
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="")
Bool_t fInitialized
Check whether task is initialized (for ExecOnce)
short Short_t
Definition: External.C:23
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
const char Option_t
Definition: External.C:48
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.