AliPhysics  b76e98e (b76e98e)
AliAnalysisTaskEGAMonitor.cxx
Go to the documentation of this file.
1 #include <array>
2 #include <bitset>
3 #include <string>
4 #include <vector>
5 
6 #include <TClonesArray.h>
7 #include <THistManager.h>
8 #include <TGrid.h>
9 #include <THashList.h>
10 #include <TObjArray.h>
11 #include <TParameter.h>
12 
13 #include "AliAnalysisUtils.h"
15 #include "AliEMCALGeometry.h"
16 #include "AliEMCALTriggerMapping.h"
17 #include "AliEMCALTriggerPatchInfo.h"
18 #include "AliEMCALTriggerTypes.h"
19 #include "AliInputEventHandler.h"
20 #include "AliLog.h"
21 #include "AliOADBContainer.h"
22 #include "AliVVertex.h"
23 #include "AliVCaloTrigger.h"
24 
28 
29 namespace EMCalTriggerPtAnalysis {
30 
31 AliAnalysisTaskEGAMonitor::AliAnalysisTaskEGAMonitor() :
33  fHistos(nullptr),
34  fUseRecalcPatches(false),
35  fRecalcLow(0.),
36  fRecalcHigh(0.),
37  fNameMaskedFastorOADB(""),
38  fMaskedFastorOADB(nullptr),
39  fMaskedFastors()
40 {
41  this->SetNeedEmcalGeom(true);
42  this->SetCaloTriggerPatchInfoName("EmcalTriggers");
43 }
44 
46  AliAnalysisTaskEmcal(name, true),
48  fUseRecalcPatches(false),
49  fRecalcLow(0.),
50  fRecalcHigh(0.),
54 {
55  this->SetNeedEmcalGeom(true);
56  this->SetCaloTriggerPatchInfoName("EmcalTriggers");
57 }
58 
60  if(fHistos) delete fHistos;
61  if(fGeom) delete fGeom;
62 }
63 
66 
67  fAliAnalysisUtils = new AliAnalysisUtils;
68 
69  fHistos = new THistManager("EGAhistos");
70  fHistos->CreateTH1("hEventCountEGA", "Number of EGA triggered events", 1, 0.5, 1.5);
71  fHistos->CreateTH1("hEventCountINT7", "Number of INT7 triggered events", 1, 0.5, 1.5);
72  std::array<std::string, 5> triggers = {"EG1", "EG2", "DG1", "DG2", "MB"};
73  for(const auto &t : triggers){
74  fHistos->CreateTH2(Form("hColRowG1%s", t.c_str()), Form("Col-Row distribution of online G1 patches for trigger %s", t.c_str()), 48, -0.5, 47.5, 104, -0.5, 103.5);
75  fHistos->CreateTH2(Form("hColRowG2%s", t.c_str()), Form("Col-Row distribution of online G2 patches for trigger %s", t.c_str()), 48, -0.5, 47.5, 104, -0.5, 103.5);
76  fHistos->CreateTH2(Form("hColRowGall%s", t.c_str()), Form("Col-Row distribution of online gamma patches for trigger %s", t.c_str()), 48, -0.5, 47.5, 104, -0.5, 103.5);
77  fHistos->CreateTH1(Form("hADCRecalcGall%s", t.c_str()), Form("ADC distribution of gamma recalc patches for trigger %s", t.c_str()), 2049, -0.5, 2048.5);
78  fHistos->CreateTH1(Form("hADCRecalcG1%s", t.c_str()), Form("ADC distribution of G1 recalc patches for trigger %s", t.c_str()), 2049, -0.5, 2048.5);
79  fHistos->CreateTH1(Form("hADCRecalcG2%s", t.c_str()), Form("ADC distribution of G2 recalc patches for trigger %s", t.c_str()), 2049, -0.5, 2048.5);
80  }
81  for(auto h : *(fHistos->GetListOfHistograms())) fOutput->Add(h);
82 
83  PostData(1, fOutput);
84 }
85 
87  if(!fAliAnalysisUtils->IsVertexSelected2013pA(InputEvent())) return false;
88  if(fAliAnalysisUtils->IsPileUpEvent(InputEvent())) return false;
89  if(!(fInputHandler->IsEventSelected() & (AliVEvent::kEMCEGA | AliVEvent::kINT7))) return false;
90  AliDebugStream(1) << GetName() << ": Event is selected" << std::endl;
91  return true;
92 }
93 
95  std::vector<std::string> triggers;
96  if(fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA){
97  if(InputEvent()->GetFiredTriggerClasses().Contains("EG1")) triggers.push_back("EG1");
98  if(InputEvent()->GetFiredTriggerClasses().Contains("EG2")) triggers.push_back("EG2");
99  if(InputEvent()->GetFiredTriggerClasses().Contains("DG1")) triggers.push_back("DG1");
100  if(InputEvent()->GetFiredTriggerClasses().Contains("DG2")) triggers.push_back("DG2");
101  fHistos->FillTH1("hEventCountEGA", 1);
102  } else if(fInputHandler->IsEventSelected() & AliVEvent::kINT7){
103  triggers.push_back("MB");
104  fHistos->FillTH1("hEventCountINT7", 1);
105  }
106  if(!triggers.size()) return false;
107 
108  AliDebugStream(1) << GetName() << ": Finding firing trigger patches" << std::endl;
109  if(fUseRecalcPatches){
110  for(auto p : *(this->fTriggerPatchInfo)){
111  AliEMCALTriggerPatchInfo *patch = static_cast<AliEMCALTriggerPatchInfo *>(p);
112  if(!patch->IsGammaLowRecalc()) continue;
113 
114  // reject patches having a masked fastor
115  if(IsPatchRejected(patch->GetColStart(), patch->GetRowStart())) continue;
116 
117  for(const auto &t : triggers){
118  fHistos->FillTH2(Form("hColRowGall%s", t.c_str()), patch->GetColStart(), patch->GetRowStart());
119  fHistos->FillTH1(Form("hADCRecalcGall%s", t.c_str()), patch->GetADCAmp());
120  }
121  if(patch->GetADCAmp() > fRecalcLow){
122  for(const auto &t : triggers){
123  fHistos->FillTH2(Form("hColRowG2%s", t.c_str()), patch->GetColStart(), patch->GetRowStart());
124  fHistos->FillTH1(Form("hADCRecalcG2%s", t.c_str()), patch->GetADCAmp());
125  }
126  }
127  if(patch->GetADCAmp() > fRecalcHigh){
128  for(const auto &t : triggers){
129  fHistos->FillTH2(Form("hColRowG1%s", t.c_str()), patch->GetColStart(), patch->GetRowStart());
130  fHistos->FillTH1(Form("hADCRecalcG1%s", t.c_str()), patch->GetADCAmp());
131  }
132  }
133  }
134  } else {
135  AliVCaloTrigger *emctrigraw = InputEvent()->GetCaloTrigger("EMCAL");
136 
137  emctrigraw->Reset();
138  Int_t col(-1), row(-1), triggerbits(0);
139  while(emctrigraw->Next()){
140  emctrigraw->GetTriggerBits(triggerbits);
141  if(triggerbits) AliDebugStream(2) << "Trigger bits: " << std::bitset<sizeof(Int_t) * 8>(triggerbits) << std::endl;
142  if(!((triggerbits & (BIT(kL1GammaHigh) | BIT(kL1GammaLow))) || (triggerbits & (BIT(kL1GammaHigh+kTriggerTypeEnd) | BIT(kL1GammaLow+kTriggerTypeEnd))))) continue;
143  AliDebugStream(2) << "Found gamma trigger bits" << std::endl;
144 
145  emctrigraw->GetPosition(col, row);
146  if(IsPatchRejected(col, row)) continue;
147  if((triggerbits & BIT(kL1GammaHigh)) || (triggerbits & BIT(kL1GammaHigh+kTriggerTypeEnd))){
148  for(const auto &t : triggers) fHistos->FillTH2(Form("hColRowG1%s", t.c_str()), col, row);
149  }
150  if((triggerbits & BIT(kL1GammaLow)) || (triggerbits & BIT(kL1GammaLow+kTriggerTypeEnd))){
151  for(const auto &t : triggers) fHistos->FillTH2(Form("hColRowG2%s", t.c_str()), col, row);
152  }
153  }
154  }
155 
156  return true;
157 }
158 
161 
162  if(!fLocalInitialized) return;
163 
164  if(fNameMaskedFastorOADB.Length()){
165  if(fNameMaskedFastorOADB.Contains("alien://") && ! gGrid) TGrid::Connect("alien://");
166  fMaskedFastorOADB = new AliOADBContainer("AliEmcalMaskedFastors");
167  fMaskedFastorOADB->InitFromFile(fNameMaskedFastorOADB.Data(), "AliEmcalMaskedFastors");
168  }
169 }
170 
172  if(fMaskedFastorOADB){
173  fMaskedFastors.clear();
174  for(auto p : *(static_cast<TObjArray *>(fMaskedFastorOADB->GetObject(runnumber)))){
175  fMaskedFastors.push_back(static_cast<TParameter<int> *>(p)->GetVal());
176  }
177  }
178 }
179 
181  bool rejected(false);
182  for(int icol = col; icol < col + 2; icol++){
183  for(int irow = row; irow < row + 2; irow++){
184  int fabsID;
185  fGeom->GetTriggerMapping()->GetAbsFastORIndexFromPositionInEMCAL(icol,irow, fabsID);
186  for(auto m : fMaskedFastors){
187  if(fabsID == m){
188  rejected = true;
189  break;
190  }
191  }
192  }
193  }
194  return rejected;
195 }
196 
197 } /* namespace EMCalTriggerPtAnalysis */
Double_t fRecalcHigh
High threshold for recalc gamma trigger.
Base task in the EMCAL framework.
Bool_t fLocalInitialized
whether or not the task has been already initialized
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
TString fNameMaskedFastorOADB
Name of the OADB container with the masked fastor information.
void SetCaloTriggerPatchInfoName(const char *n)
Bool_t fUseRecalcPatches
Defined whether to use recalc patches.
Simplistic class, checks distribution of the online EGA trigger patches.
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
AliEMCALGeometry * fGeom
!emcal geometry
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
AliAnalysisUtils * fAliAnalysisUtils
!vertex selection (optional)
virtual void RunChanged(Int_t newrun)
Process tasks relevant when a file with a different run number is processed.
virtual bool Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
AliOADBContainer * fMaskedFastorOADB
OADB container with masked fastor information.
AliEmcalList * fOutput
!output list
Analysis of high- tracks in triggered events.
Double_t fRecalcLow
Low threshold for recalc gamma trigger.
TClonesArray * fTriggerPatchInfo
!trigger patch info array
void SetNeedEmcalGeom(Bool_t n)
virtual void ExecOnce()
Perform steps needed to initialize the analysis.
std::vector< int > fMaskedFastors
List of masked fastors.
Container class for histograms.
Definition: THistManager.h:99
virtual void ExecOnce()
Perform steps needed to initialize the analysis.
void UserCreateOutputObjects()
Main initialization function on the worker.
virtual bool IsEventSelected()
Performing event selection.