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