AliPhysics  cdeda5a (cdeda5a)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskEmcalNoiseTriggers.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 <memory>
16 #include "THistManager.h"
17 
19 #include "AliEMCALGeometry.h"
20 #include "AliEMCALTriggerMapping.h"
21 #include "AliEMCALTriggerPatchInfo.h"
23 #include "AliInputEventHandler.h"
24 #include "AliLog.h"
25 #include "AliVCaloTrigger.h"
26 #include "AliVEvent.h"
27 
31 
32 namespace EMCalTriggerPtAnalysis {
33 
34 const TString AliAnalysisTaskEmcalNoiseTriggers::fgkPatchNames[2] = {"Online", "Recalc"};
35 
36 AliAnalysisTaskEmcalNoiseTriggers::AliAnalysisTaskEmcalNoiseTriggers():
38  fTriggerBits(0),
39  fTriggerString("")
40 {
42 }
43 
46  fTriggerBits(0),
47  fTriggerString("")
48 {
50 }
51 
53  const int kMaxCol = 48, kMaxRow = 104, kMaxFastOr = kMaxRow * kMaxCol;
54  const TString kMaxTypes[2] = {"All", "Max"};
55 
56  // Event level histograms
57  fHistos->CreateTH1("hEventCount", "EventCounter", 1, 0.5, 1.5);
58  fHistos->CreateTH1("hVertexZ","", 100, -40, 40);
59 
60  // Histograms at fastor level
61  fHistos->CreateTH2("hFastorL1TimeSums", "FastOR L1 time sum distribution", kMaxFastOr, -0.5, kMaxFastOr - 0.5, 2049, -0.5, 2048.5);
62 
63  // Histograms at trigger patch level
64  for(int itype = 0; itype < 2; itype++){
65  const TString &mypatchtype = fgkPatchNames[itype];
66  fHistos->CreateTH1(Form("hEventSelPatch%s", mypatchtype.Data()), Form("Number of firing %s patches", mypatchtype.Data()), 1001, -0.5, 1000.5);
67  for(int imax = 0; imax < 2; imax++){
68  fHistos->CreateTH2(Form("hPatchMaxFastorADCvsSumADC%s%s", kMaxTypes[imax].Data(), mypatchtype.Data()), Form("Max FastOR ADC vs. ADC sum for %s %s patches; Sum ADC; Max FastOR ADC", kMaxTypes[imax].Data(), mypatchtype.Data()), 2048, 0., 2048, 2500, 0., 2500);
69  fHistos->CreateTH2(Form("hSumADCvsPatchADC%s%s", kMaxTypes[imax].Data(), mypatchtype.Data()), Form("Sum all ADC vs. Patch ADC for %s %s patches; sum ADC; patch ADC", kMaxTypes[imax].Data(), mypatchtype.Data()), 2048, 0., 2048, 2500, 0., 2500);
70  fHistos->CreateTH2(Form("hNfastorVsFracMaxFastor%s%s", kMaxTypes[imax].Data(), mypatchtype.Data()), Form("Number of non-zero FastORs vs. ADC fraction of the highest FastOR for %s %s patches; Number of FastORs; Fraction ADC highest Fastor", kMaxTypes[imax].Data(), mypatchtype.Data()), 257, -0.5, 256.5, 100, 0., 1);
71  }
72  }
73 }
74 
76  if(!(fInputHandler->IsEventSelected() & fTriggerBits)) return false;
77  if(fTriggerString.Length()){
78  return fInputEvent->GetFiredTriggerClasses().Contains(fTriggerString);
79  }
80  return true;
81 }
82 
84  if(!fL1ADC.IsAllocated()){
85  int nrows = 64;
86  if(fGeom->GetTriggerMappingVersion() == 2) nrows = 104;
87  fL1ADC.Allocate(48, nrows);
88  }
90 
91  // Look at fastors inside masked events
93 
94  // Loop patches
95  // In addition mark max patches for the case online and recalc - these
96  // patches will be processed later to investigate max patch distributions
97  AliEMCALTriggerPatchInfo *maxonline(nullptr), *maxrecalc(nullptr);
98  Int_t nselOnline(0), nselRecalc(0), ngoodOnline(0), ngoodRecalc(0);
99  for(auto patchit : *(this->fTriggerPatchInfo)){
100  AliEMCALTriggerPatchInfo *recpatch = static_cast<AliEMCALTriggerPatchInfo *>(patchit);
101  if(fTriggerBits & AliVEvent::kEMCEGA){
102  if(fTriggerString.Contains("EG1")){
103  if(recpatch->IsGammaHigh()){
104  if(AnalyseTriggerPatch(*recpatch, kOnline, false)) nselOnline++;
105  if(SelectFiredPatch("EG1", recpatch->GetADCAmp())) ngoodOnline++;
106  if(!maxonline || recpatch->GetADCAmp() > maxonline->GetADCAmp()) maxonline = recpatch;
107  }
108  if(recpatch->IsGammaLowRecalc()){
109  if(AnalyseTriggerPatch(*recpatch, kRecalc, false)) nselRecalc++;
110  if(SelectFiredPatch("EG1", recpatch->GetADCAmp())) ngoodRecalc++;
111  if(!maxrecalc || recpatch->GetADCAmp() > maxrecalc->GetADCAmp()) maxrecalc = recpatch;
112  }
113  }
114  if(fTriggerString.Contains("EG2")){
115  if(recpatch->IsGammaLow()){
116  if(AnalyseTriggerPatch(*recpatch, kOnline, false)) nselOnline++;
117  if(SelectFiredPatch("EG2", recpatch->GetADCAmp())) ngoodOnline++;
118  if(!maxonline || recpatch->GetADCAmp() > maxonline->GetADCAmp()) maxonline = recpatch;
119  }
120  if(recpatch->IsGammaLowRecalc()){
121  if(AnalyseTriggerPatch(*recpatch, kRecalc, false)) nselRecalc++;
122  if(SelectFiredPatch("EG2", recpatch->GetADCAmp())) ngoodRecalc++;
123  if(!maxrecalc || recpatch->GetADCAmp() > maxrecalc->GetADCAmp()) maxrecalc = recpatch;
124  }
125  }
126  } else if(fTriggerBits & AliVEvent::kEMCEJE){
127  if(fTriggerString.Contains("EJ1")){
128  if(recpatch->IsJetHigh()){
129  if(AnalyseTriggerPatch(*recpatch, kOnline, false)) nselOnline++;
130  if(SelectFiredPatch("EJ1", recpatch->GetADCAmp())) ngoodOnline++;
131  if(!maxonline || recpatch->GetADCAmp() > maxonline->GetADCAmp()) maxonline = recpatch;
132  }
133  if(recpatch->IsJetLowRecalc()){
134  if(AnalyseTriggerPatch(*recpatch, kRecalc, false)) nselRecalc++;
135  if(SelectFiredPatch("EJ1", recpatch->GetADCAmp())) ngoodRecalc++;
136  if(!maxrecalc || recpatch->GetADCAmp() > maxrecalc->GetADCAmp()) maxrecalc = recpatch;
137  }
138  }
139  if(fTriggerString.Contains("EJ2")){
140  if(recpatch->IsJetLow()){
141  if(AnalyseTriggerPatch(*recpatch, kOnline, false)) nselOnline++;
142  if(SelectFiredPatch("EJ2", recpatch->GetADCAmp())) ngoodOnline++;
143  if(!maxonline || recpatch->GetADCAmp() > maxonline->GetADCAmp()) maxonline = recpatch;
144  }
145  if(recpatch->IsJetLowRecalc()){
146  if(AnalyseTriggerPatch(*recpatch, kRecalc, false)) nselRecalc++;
147  if(SelectFiredPatch("EJ2", recpatch->GetADCAmp())) ngoodRecalc++;
148  if(!maxrecalc || recpatch->GetADCAmp() > maxrecalc->GetADCAmp()) maxrecalc = recpatch;
149  }
150  }
151  }
152  }
153 
154  // Fill event statistics
155  fHistos->FillTH1("hEventSelPatchOnline", nselOnline);
156  fHistos->FillTH1("hEventSelPatchRecalc", nselRecalc);
157  fHistos->FillTH1("hEventGoodPatchOnline", ngoodOnline);
158  fHistos->FillTH1("hEventGoodPatchRecalc", ngoodRecalc);
159 
160  if(maxonline) AnalyseTriggerPatch(*maxonline, kOnline, true);
161  if(maxrecalc) AnalyseTriggerPatch(*maxrecalc, kRecalc, true);
162 
163  return true;
164 }
165 
167  fL1ADC.Reset();
168  AliVCaloTrigger *emctrigger = fInputEvent->GetCaloTrigger("EMCAL");
169  emctrigger->Reset();
170 
171  Int_t globCol=-1, globRow=-1, adcAmp=-1;
172  while(emctrigger->Next()){
173  // get position in global 2x2 tower coordinates
174  // A0 left bottom (0,0)
175  emctrigger->GetPosition(globCol, globRow);
176  emctrigger->GetL1TimeSum(adcAmp);
177  AliDebugStream(1) << GetName() << "Fastor at (" << globCol << "," << globRow << ") with ADC " << adcAmp << std::endl;
178  if (adcAmp < 0) adcAmp = 0;
179 
180  try {
181  (fL1ADC)(globCol,globRow) = adcAmp;
182  }
184  std::string dirstring = e.GetDirection() == AliEMCALTriggerDataGrid<Int_t>::OutOfBoundsException::kColDir ? "Col" : "Row";
185  AliErrorStream() << "Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring << ": " << e.GetIndex() << std::endl;
186  }
187  }
188 }
189 
191  AliEMCALTriggerPatchADCInfoAP *adcpatch = new AliEMCALTriggerPatchADCInfoAP(patch.GetPatchSize());
192  for(unsigned char icol = 0; icol < patch.GetPatchSize(); icol++){
193  for(unsigned char irow = 0; irow < patch.GetPatchSize(); irow++){
194  Int_t adc = 0;
195  try{
196  adc = fL1ADC(icol + patch.GetColStart(), irow + patch.GetRowStart());
198  adc = 0;
199  }
200  adcpatch->SetADC(adc, icol, irow);
201  }
202  }
203  return adcpatch;
204 }
205 
207  fHistos->FillTH1("hEventCount", 1);
208  fHistos->FillTH1("hVertexZ", fVertex[2]);
209 }
210 
212  AliVCaloTrigger *emctrigger = fInputEvent->GetCaloTrigger("EMCAL");
213  emctrigger->Reset();
214 
215  Int_t globCol=-1, globRow=-1, adcAmp=-1, absFastor = -1;
216  while(emctrigger->Next()){
217  emctrigger->GetPosition(globCol, globRow);
218  emctrigger->GetL1TimeSum(adcAmp);
219  if(adcAmp < 0) adcAmp = 0;
220  fGeom->GetTriggerMapping()->GetAbsFastORIndexFromPositionInEMCAL(globCol, globRow, absFastor);
221  fHistos->FillTH2("hFastorL1TimeSums", absFastor, adcAmp);
222  }
223 }
224 
225 Bool_t AliAnalysisTaskEmcalNoiseTriggers::AnalyseTriggerPatch(const AliEMCALTriggerPatchInfo &recpatch, SelectPatchType_t pt, Bool_t maxpatch){
226  std::unique_ptr<AliEMCALTriggerPatchADCInfoAP> adcvalues(MakeFastorADCValuesForPatch(recpatch));
227 
228  // cut patch according to ADC sum without masking (select also patches with noise)
229  Int_t sumADC = adcvalues->GetSumADC();
230  if(pt == kRecalc) {
231  if(!SelectFiredPatch(fTriggerString, sumADC)) return kFALSE;
232  }
233 
234  const TString &mypatchtype = fgkPatchNames[pt], maxname = maxpatch ? "Max" : "All";
235  Int_t maxADC = adcvalues->GetMaxADC(), ncontrib = adcvalues->GetNFastorsContrib();
236  Float_t fracMaxFastor = static_cast<Float_t>(maxADC)/static_cast<Float_t>(sumADC);
237  fHistos->FillTH2(Form("hPatchMaxFastorADCvsSumADC%s%s", maxname.Data(), mypatchtype.Data()), sumADC, maxADC);
238  fHistos->FillTH2(Form("hSumADCvsPatchADC%s%s", maxname.Data(), mypatchtype.Data()), sumADC, recpatch.GetADCAmp());
239  fHistos->FillTH2(Form("hNfastorVsFracMaxFastor%s%s", maxname.Data(), mypatchtype.Data()), ncontrib, fracMaxFastor);
240  return kTRUE;
241 }
242 
243 } /* namespace EMCalTriggerPtAnalysis */
Analysis of trigger quantities in rejected (noise) events.
AliEMCALTriggerPatchADCInfoAP * MakeFastorADCValuesForPatch(const AliEMCALTriggerPatchInfo &patch) const
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
AliEMCALTriggerDataGrid< Int_t > fL1ADC
! Level1 fastor ADCs
void SetADC(Int_t adc, UChar_t col, UChar_t row)
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
float Float_t
Definition: External.C:68
AliEMCALGeometry * fGeom
!emcal geometry
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Bool_t AnalyseTriggerPatch(const AliEMCALTriggerPatchInfo &recpatch, SelectPatchType_t pt, Bool_t maxpatch)
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
static const TString fgkPatchNames[2]
Names of the trigger patch types (for histograms)
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Double_t fVertex[3]
!event vertex
TClonesArray * fTriggerPatchInfo
!trigger patch info array
bool Bool_t
Definition: External.C:53
Bool_t SelectFiredPatch(const TString &triggerclass, Int_t adc) const