AliPhysics  4a7363b (4a7363b)
AliAnalysisTaskEmcalPatchMasking.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 <memory>
18 
19 #include <TClonesArray.h>
20 #include <TGrid.h>
21 #include <THashList.h>
22 #include <THistManager.h>
23 #include <TMath.h>
24 #include <TParameter.h>
25 
26 #include "AliAnalysisUtils.h"
27 #include "AliOADBContainer.h"
29 #include "AliEMCALGeometry.h"
30 #include "AliEMCALTriggerMapping.h"
31 #include "AliEMCALTriggerPatchInfo.h"
33 #include "AliESDEvent.h"
34 #include "AliInputEventHandler.h"
35 #include "AliLog.h"
36 #include "AliVCaloTrigger.h"
37 #include "AliVEvent.h"
38 
42 
43 namespace EMCalTriggerPtAnalysis {
44 
45 AliAnalysisTaskEmcalPatchMasking::AliAnalysisTaskEmcalPatchMasking() :
47  fHistos(nullptr),
48  fL1ADC(),
49  fTriggerBits(0),
50  fTriggerPattern(""),
51  fNameMaskedFastorOADB(""),
52  fMaskedFastorOADB(nullptr),
53  fListMaskedFastors()
54 {
55  SetNeedEmcalGeom(true);
56  SetCaloTriggerPatchInfoName("EmcalTriggers");
57 }
58 
60  AliAnalysisTaskEmcal(name, true),
62  fL1ADC(),
63  fTriggerBits(0),
64  fTriggerPattern(""),
68 {
69  SetNeedEmcalGeom(true);
70  SetCaloTriggerPatchInfoName("EmcalTriggers");
71 }
72 
73 
76  if(fHistos) delete fHistos;
77 }
78 
81 
82  fAliAnalysisUtils = new AliAnalysisUtils;
83 
84  std::vector<TString> patchtypes = {"EG1", "EG2", "EJ1", "EJ2", "REGA", "REJE"};
85  fHistos = new THistManager(Form("Task%s", GetName()));
86  for(const auto &pt : patchtypes){
87  fHistos->CreateTH1(Form("hFracMaxFastorTotalAll%s", pt.Data()), Form("Contribution of max fastor to patch ADC for all %s patches", pt.Data()), 100, 0., 1.);
88  fHistos->CreateTH1(Form("hFracMaxFastorMeanAll%s", pt.Data()), Form("Ratio max ADC to the mean for all %s patches", pt.Data()), 500, 0., 50.);
89  fHistos->CreateTH2(Form("hPatchADCvsADCgoodAll%s", pt.Data()), Form("Patch ADC vs patch good ADC for all %s patches", pt.Data()), 500, 0., 2500., 500, 0., 2500.);
90  fHistos->CreateTH1(Form("hFracMaxMaskedFastorAll%s", pt.Data()), Form("Contribution of the max masked fastor to the patch ADC for all %s patches", pt.Data()), 100, 0., 1.);
91  fHistos->CreateTH1(Form("hFracMaxGoodFastorAll%s", pt.Data()), Form("Contribution of the max good fastor to the patch ADC for all %s patches", pt.Data()), 100, 0., 1.);
92  fHistos->CreateTH1(Form("hFracGoodADCAll%s", pt.Data()), Form("Contribution of the good adc sum to the patch ADC for all %s patches", pt.Data()), 100, 0., 1.);
93  fHistos->CreateTH1(Form("hFracMaskedADCAll%s", pt.Data()), Form("Contribution of the masked adc sum to the patch ADC for all %s patches", pt.Data()), 100, 0., 1.);
94  fHistos->CreateTH2(Form("hFracMaxMaskedvsNmaskedcontribAll%s", pt.Data()), Form("Number of non-zero masked fastors vs. fraction of max. masked for all %s patches", pt.Data()), 1000, 0., 1000, 100., 0., 1.);
95  fHistos->CreateTH1(Form("hFracMaxFastorTotalBad%s", pt.Data()), Form("Contribution of max fastor to patch ADC for bad %s patches", pt.Data()), 100, 0., 1.);
96  fHistos->CreateTH1(Form("hFracMaxFastorMeanBad%s", pt.Data()), Form("Ratio max ADC to the mean for bad %s patches", pt.Data()), 500, 0., 50.);
97  fHistos->CreateTH2(Form("hPatchADCvsADCgoodBad%s", pt.Data()), Form("Patch ADC vs patch good ADC for bad %s patches", pt.Data()), 500, 0., 2500., 500, 0., 2500.);
98  fHistos->CreateTH1(Form("hFracMaxMaskedFastorBad%s", pt.Data()), Form("Contribution of the max masked fastor to the patch ADC for bad %s patches", pt.Data()), 100, 0., 1.);
99  fHistos->CreateTH1(Form("hFracMaxGoodFastorBad%s", pt.Data()), Form("Contribution of the max good fastor to the patch ADC for bad %s patches", pt.Data()), 100, 0., 1.);
100  fHistos->CreateTH1(Form("hFracGoodADCBad%s", pt.Data()), Form("Contribution of the good adc sum to the patch ADC for bad %s patches", pt.Data()), 100, 0., 1.);
101  fHistos->CreateTH1(Form("hFracMaskedADCBad%s", pt.Data()), Form("Contribution of the masked adc sum to the patch ADC bad all %s patches", pt.Data()), 100, 0., 1.);
102  fHistos->CreateTH2(Form("hFracMaxMaskedvsNmaskedcontribBad%s", pt.Data()), Form("Number of non-zero masked fastors vs. fraction of max. masked for bad %s patches", pt.Data()), 1000, 0., 1000, 100., 0., 1.);
103  fHistos->CreateTH1(Form("hFracMaxMaskedSumMaskedBad%s", pt.Data()), Form("Contibution of the max. masked fastor to the ADC sum of masked fastors for bad %s patches", pt.Data()), 100, 0., 1.);
104  fHistos->CreateTH1(Form("hFracMaxFastorTotalGood%s", pt.Data()), Form("Contribution of max fastor to patch ADC for good %s patches", pt.Data()), 100, 0., 1.);
105  fHistos->CreateTH1(Form("hFracMaxFastorMeanGood%s", pt.Data()), Form("Ratio max ADC to the mean for good %s patches", pt.Data()), 500, 0., 10.);
106  }
107 
108  std::vector<TString> maxtypes = {"Online", "Recalc"};
109  for(const auto &mt : maxtypes){
110  fHistos->CreateTH1(Form("hFracMaxFastorTotalAllMax%s", mt.Data()), Form("Contribution of max fastor to patch ADC for all max %s patches", mt.Data()), 100, 0., 1.);
111  fHistos->CreateTH1(Form("hFracMaxFastorMeanAllMax%s", mt.Data()), Form("Ratio max ADC to the mean for all max %s patches", mt.Data()), 500, 0., 50.);
112  fHistos->CreateTH2(Form("hPatchADCvsADCgoodAllMax%s", mt.Data()), Form("Patch ADC vs patch good ADC for all max %s patches", mt.Data()), 500, 0., 2500., 500, 0., 2500.);
113  fHistos->CreateTH1(Form("hFracMaxMaskedFastorAllMax%s", mt.Data()), Form("Contribution of the max masked fastor to the patch ADC for all max %s patches", mt.Data()), 100, 0., 1.);
114  fHistos->CreateTH1(Form("hFracMaxGoodFastorAllMax%s", mt.Data()), Form("Contribution of the max good fastor to the patch ADC for all max %s patches", mt.Data()), 100, 0., 1.);
115  fHistos->CreateTH1(Form("hFracGoodADCAllMax%s", mt.Data()), Form("Contribution of the good adc sum to the patch ADC for all max %s patches", mt.Data()), 100, 0., 1.);
116  fHistos->CreateTH1(Form("hFracMaskedADCAllMax%s", mt.Data()), Form("Contribution of the masked adc sum to the patch ADC for all max %s patches", mt.Data()), 100, 0., 1.);
117  fHistos->CreateTH2(Form("hFracMaxMaskedvsNmaskedcontribAllMax%s", mt.Data()), Form("Number of non-zero masked fastors vs. fraction of max. masked for all max %s patches", mt.Data()), 1000, 0., 1000, 100., 0., 1.);
118  fHistos->CreateTH1(Form("hFracMaxFastorTotalBadMax%s", mt.Data()), Form("Contribution of max fastor to patch ADC for bad max %s patches", mt.Data()), 100, 0., 1.);
119  fHistos->CreateTH1(Form("hFracMaxFastorMeanBadMax%s", mt.Data()), Form("Ratio max ADC to the mean for bad max %s patches", mt.Data()), 500, 0., 50.);
120  fHistos->CreateTH2(Form("hPatchADCvsADCgoodBadMax%s", mt.Data()), Form("Patch ADC vs patch good ADC for bad max %s patches", mt.Data()), 500, 0., 2500., 500, 0., 2500.);
121  fHistos->CreateTH1(Form("hFracMaxMaskedFastorBadMax%s", mt.Data()), Form("Contribution of the max masked fastor to the patch ADC for bad max %s patches", mt.Data()), 100, 0., 1.);
122  fHistos->CreateTH1(Form("hFracMaxGoodFastorBadMax%s", mt.Data()), Form("Contribution of the max good fastor to the patch ADC for bad max %s patches", mt.Data()), 100, 0., 1.);
123  fHistos->CreateTH1(Form("hFracGoodADCBadMax%s", mt.Data()), Form("Contribution of the good adc sum to the patch ADC for bad max %s patches", mt.Data()), 100, 0., 1.);
124  fHistos->CreateTH1(Form("hFracMaskedADCBadMax%s", mt.Data()), Form("Contribution of the masked adc sum to the patch ADC bad all max %s patches", mt.Data()), 100, 0., 1.);
125  fHistos->CreateTH2(Form("hFracMaxMaskedvsNmaskedcontribBadMax%s", mt.Data()), Form("Number of non-zero masked fastors vs. fraction of max. masked for bad max %s patches", mt.Data()), 1000, 0., 1000, 100., 0., 1.);
126  fHistos->CreateTH1(Form("hFracMaxMaskedSumMaskedBadMax%s", mt.Data()), Form("Contibution of the max. masked fastor to the ADC sum of masked fastors for bad max %s patches", mt.Data()), 100, 0., 1.);
127  fHistos->CreateTH1(Form("hFracMaxFastorTotalGoodMax%s", mt.Data()), Form("Contribution of max fastor to patch ADC for good max %s patches", mt.Data()), 100, 0., 1.);
128  fHistos->CreateTH1(Form("hFracMaxFastorMeanGoodMax%s", mt.Data()), Form("Ratio max ADC to the mean for good max %s patches", mt.Data()), 500, 0., 50.);
129  }
130 
131  for(auto h : *(fHistos->GetListOfHistograms())) fOutput->Add(h);
132 
133  PostData(1, fOutput);
134 }
135 
137  if(fTriggerBits){
138  if(!(fInputHandler->IsEventSelected() & fTriggerBits)) return false;
139  }
140  if(fTriggerPattern.Length()){
141  if(!fInputEvent->GetFiredTriggerClasses().Contains(fTriggerPattern)) return false;
142  }
143 
144  if(fAliAnalysisUtils){
145  if(fInputEvent->IsA() == AliESDEvent::Class() && ! fAliAnalysisUtils->IsFirstEventInChunk(fInputEvent)) return false;
146  if(fAliAnalysisUtils->IsPileUpEvent(fInputEvent)) return false;
147  if(fAliAnalysisUtils->IsVertexSelected2013pA(fInputEvent)) return false;
148  }
149 
150  AliDebugStream(1) << GetName() << ": Event is selected" << std::endl;
151 
152  return true;
153 }
154 
157 
158  // Loop over trigger patches
159  AliEMCALTriggerPatchInfo *recpatch(nullptr), *maxOnline(nullptr), *maxRecalc(nullptr);
160  for(auto p : *(fTriggerPatchInfo)){
161  recpatch = static_cast<AliEMCALTriggerPatchInfo *>(p);
162 
163  // select only online and recalc patches
164  if(!(recpatch->IsGammaHigh() || recpatch->IsGammaLow() ||
165  recpatch->IsJetHigh() || recpatch->IsJetLow() ||
166  recpatch->IsGammaLowRecalc() || recpatch->IsJetLowRecalc())) continue;
167 
168  // Select only firing patches (patches - unmasked - above threshold for the given trigger)
169  // find the highest energetic online and recalc patch at the same step
170  if(fTriggerBits & AliVEvent::kEMCEGA){
171  if(recpatch->IsJetLow() || recpatch->IsJetHigh() || recpatch->IsJetLowRecalc()) continue;
172  if(fTriggerPattern.Contains("EG1")){
173  if(!(recpatch->IsGammaHigh() || recpatch->GetADCAmp() > 140)) continue;
174  if(recpatch->IsGammaHigh()){
175  if(!maxOnline) maxOnline = recpatch;
176  else {
177  if(recpatch->GetADCAmp() > maxOnline->GetADCAmp()) maxOnline = recpatch;
178  }
179  }
180  if(recpatch->IsGammaLowRecalc()){
181  if(!maxRecalc) maxRecalc = recpatch;
182  else {
183  if(recpatch->GetADCAmp() > maxRecalc->GetADCAmp()) maxRecalc = recpatch;
184  }
185  }
186  }
187  if(fTriggerPattern.Contains("EG2")){
188  if(!(recpatch->IsGammaLow() || recpatch->GetADCAmp() > 89)) continue;
189  if(recpatch->IsGammaLow()){
190  if(!maxOnline) maxOnline = recpatch;
191  else {
192  if(recpatch->GetADCAmp() > maxOnline->GetADCAmp()) maxOnline = recpatch;
193  }
194  }
195  if(recpatch->IsGammaLowRecalc()){
196  if(!maxRecalc) maxRecalc = recpatch;
197  else {
198  if(recpatch->GetADCAmp() > maxRecalc->GetADCAmp()) maxRecalc = recpatch;
199  }
200  }
201  }
202  }
203  if(fTriggerBits & AliVEvent::kEMCEJE){
204  if(recpatch->IsGammaLow() || recpatch->IsGammaHigh() || recpatch->IsGammaLowRecalc()) continue;
205  if(fTriggerPattern.Contains("EJ1")){
206  if(!(recpatch->IsJetHigh() || recpatch->GetADCAmp() > 260)) continue;
207  if(recpatch->IsJetHigh()){
208  if(!maxOnline) maxOnline = recpatch;
209  else {
210  if(recpatch->GetADCAmp() > maxOnline->GetADCAmp()) maxOnline = recpatch;
211  }
212  }
213  if(recpatch->IsJetLowRecalc()){
214  if(!maxRecalc) maxRecalc = recpatch;
215  else {
216  if(recpatch->GetADCAmp() > maxRecalc->GetADCAmp()) maxRecalc = recpatch;
217  }
218  }
219  }
220  if(fTriggerPattern.Contains("EJ2")){
221  if(!(recpatch->IsJetLow() || recpatch->GetADCAmp() > 127)) continue;
222  if(recpatch->IsJetLow()){
223  if(!maxOnline) maxOnline = recpatch;
224  else {
225  if(recpatch->GetADCAmp() > maxOnline->GetADCAmp()) maxOnline = recpatch;
226  }
227  }
228  if(recpatch->IsJetLowRecalc()){
229  if(!maxRecalc) maxRecalc = recpatch;
230  else {
231  if(recpatch->GetADCAmp() > maxRecalc->GetADCAmp()) maxRecalc = recpatch;
232  }
233  }
234  }
235  }
236 
237  AliDebugStream(2) << GetName() << ": Found firing patch" << std::endl;
238  ProcessPatch(*recpatch);
239  }
240 
241  if(maxOnline) ProcessMaxPatch(*maxOnline, "Online");
242  if(maxRecalc) ProcessMaxPatch(*maxRecalc, "Recalc");
243 
244  return true;
245 }
246 
249  if(!fLocalInitialized) return;
250 
251  if(fNameMaskedFastorOADB.Length()){
252  AliInfoStream() << "Initializing masked fastors from OADB container " << fNameMaskedFastorOADB.Data() << std::endl;
253  if(fNameMaskedFastorOADB.Contains("alien://") && !gGrid) TGrid::Connect("alien://");
254  fMaskedFastorOADB = new AliOADBContainer("AliEmcalMaskedFastors");
255  fMaskedFastorOADB->InitFromFile(fNameMaskedFastorOADB.Data(), "AliEmcalMaskedFastors");
256  }
257 
258  UChar_t nrow(64);
259  if(fGeom->GetTriggerMappingVersion() == 2) nrow = 104;
260  fL1ADC.Allocate(48, nrow);
261 }
262 
264  if(fMaskedFastorOADB){
265  fListMaskedFastors.clear();
266  TObjArray *badchannelmap = static_cast<TObjArray *>(fMaskedFastorOADB->GetObject(newrun));
267  if(!badchannelmap || !badchannelmap->GetEntries()) return;
268  for(TIter citer = TIter(badchannelmap).Begin(); citer != TIter::End(); ++citer){
269  TParameter<int> *channelID = static_cast<TParameter<int> *>(*citer);
270  AliDebugStream(3) << GetName() << ": Found masked fastor channel " << channelID->GetVal() << std::endl;
271  fListMaskedFastors.push_back(channelID->GetVal());
272  }
273  }
274 }
275 
277  fL1ADC.Reset();
278  AliVCaloTrigger *emctrigger = fInputEvent->GetCaloTrigger("EMCAL");
279  emctrigger->Reset();
280 
281  Int_t globCol=-1, globRow=-1, adcAmp=-1;
282  while(emctrigger->Next()){
283  // get position in global 2x2 tower coordinates
284  // A0 left bottom (0,0)
285  emctrigger->GetPosition(globCol, globRow);
286  emctrigger->GetL1TimeSum(adcAmp);
287  AliDebugStream(1) << GetName() << "Fastor at (" << globCol << "," << globRow << ") with ADC " << adcAmp << std::endl;
288  if (adcAmp < 0) adcAmp = 0;
289 
290  try {
291  (fL1ADC)(globCol,globRow) = adcAmp;
292  }
294  std::string dirstring = e.GetDirection() == AliEMCALTriggerDataGrid<Int_t>::OutOfBoundsException::kColDir ? "Col" : "Row";
295  AliErrorStream() << "Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring << ": " << e.GetIndex() << std::endl;
296  }
297  }
298 }
299 
301  AliEMCALTriggerPatchADCInfoAP *adcpatch = new AliEMCALTriggerPatchADCInfoAP(patch.GetPatchSize());
302  for(unsigned char icol = 0; icol < patch.GetPatchSize(); icol++){
303  for(unsigned char irow = 0; irow < patch.GetPatchSize(); irow++){
304  Int_t adc = 0;
305  try{
306  adc = fL1ADC(icol + patch.GetColStart(), irow + patch.GetRowStart());
308  adc = 0;
309  }
310  adcpatch->SetADC(adc, icol, irow);
311  }
312  }
313  return adcpatch;
314 }
315 
316 void AliAnalysisTaskEmcalPatchMasking::ProcessPatch(const AliEMCALTriggerPatchInfo &patch){
317  std::vector<TString> patchtypes;
318  if(patch.IsGammaHigh()) patchtypes.push_back("EG1");
319  if(patch.IsGammaLow()) patchtypes.push_back("EG2");
320  if(patch.IsGammaLowRecalc()) patchtypes.push_back("REGA");
321  if(patch.IsJetHigh()) patchtypes.push_back("EJ1");
322  if(patch.IsJetLow()) patchtypes.push_back("EJ2");
323  if(patch.IsJetLowRecalc()) patchtypes.push_back("REJE");
324 
325  std::unique_ptr<AliEMCALTriggerPatchADCInfoAP> patchADC(MakeFastorADCValuesForPatch(patch));
326 
327  // Find the max fastor ADC in the patch
328  Int_t maxFastorADC = 0, maxFastorADCmasked = 0, maxFastorADCgood = 0, tmp = 0;
329  Int_t nFastorNonZero = 0, nfastorMasked = 0, nMaskedFastorsNonZero = 0;
330  Int_t sumADCgood = 0, sumADCbad = 0, absFastorIndex = 0;
331  std::vector<Int_t> adcs;
332  for(UChar_t icol = 0; icol < patchADC->GetPatchSize(); icol++){
333  for(UChar_t irow = 0; irow < patchADC->GetPatchSize(); irow++){
334  tmp = patchADC->GetADC(icol, irow);
335  adcs.push_back(tmp);
336  if(tmp > 0) nFastorNonZero++;
337  if(tmp > maxFastorADC) maxFastorADC = tmp;
338 
339  // Get masked fastors in the patch
340  fGeom->GetTriggerMapping()->GetAbsFastORIndexFromPositionInEMCAL(icol + patch.GetColStart(), irow + patch.GetRowStart(), absFastorIndex);
341  if(std::find(fListMaskedFastors.begin(), fListMaskedFastors.end(), absFastorIndex) != fListMaskedFastors.end()){
342  // Fastor is masked
343  nfastorMasked++;
344  if(tmp > 0) nMaskedFastorsNonZero++;
345  sumADCbad += tmp;
346  if(tmp > maxFastorADCmasked) maxFastorADCmasked = tmp;
347  } else {
348  // Fastor is not masked
349  sumADCgood += tmp;
350  if(tmp > maxFastorADCgood) maxFastorADCgood = tmp;
351  }
352  }
353  }
354  AliDebugStream(2) << GetName() << ": Max Fastor: " << maxFastorADC << ", Sum: " << patch.GetADCAmp() << std::endl;
355  AliDebugStream(2) << GetName() << ": Mean ADC: " << TMath::Mean(adcs.begin(), adcs.end()) << std::endl;
356  AliDebugStream(2) << GetName() << ": Sum good " << sumADCgood << ", bad " << sumADCbad << std::endl;
357 
358  Float_t fracMaxFastorPatchADC = static_cast<Float_t>(maxFastorADC)/static_cast<Float_t>(patch.GetADCAmp()),
359  fracMaxFastorMaskedPatchADC = static_cast<Float_t>(maxFastorADCmasked)/static_cast<Float_t>(patch.GetADCAmp()),
360  fracMaxFastorGoodPatchADC = static_cast<Float_t>(maxFastorADCgood)/static_cast<Float_t>(patch.GetADCAmp()),
361  fracMaxFastorMeanADC = static_cast<Float_t>(maxFastorADC)/TMath::Mean(adcs.begin(), adcs.end()),
362  fracGoodADC = static_cast<Float_t>(sumADCgood)/static_cast<Float_t>(patch.GetADCAmp()),
363  fracMaskedADC = static_cast<Float_t>(sumADCbad)/static_cast<Float_t>(patch.GetADCAmp());
364 
365  // Fill histograms
366  for(const auto &pt : patchtypes){
367  fHistos->FillTH1(Form("hFracMaxFastorTotalAll%s", pt.Data()), fracMaxFastorPatchADC);
368  fHistos->FillTH1(Form("hFracMaxFastorMeanAll%s", pt.Data()), fracMaxFastorMeanADC);
369  fHistos->FillTH2(Form("hPatchADCvsADCgoodAll%s", pt.Data()), patch.GetADCAmp(), sumADCgood);
370  fHistos->FillTH1(Form("hFracMaxMaskedFastorAll%s", pt.Data()), fracMaxFastorMaskedPatchADC);
371  fHistos->FillTH1(Form("hFracMaxGoodFastorAll%s", pt.Data()), fracMaxFastorGoodPatchADC);
372  fHistos->FillTH1(Form("hFracGoodADCAll%s", pt.Data()), fracGoodADC);
373  fHistos->FillTH1(Form("hFracMaskedADCAll%s", pt.Data()), fracMaskedADC);
374  fHistos->FillTH2(Form("hFracMaxMaskedvsNmaskedcontribAll%s", pt.Data()), nMaskedFastorsNonZero, fracMaxFastorMaskedPatchADC);
375 
376  if(nfastorMasked){
377  Float_t fracMaxMaskedSumMasked = 0;
378  if(sumADCbad) fracMaxMaskedSumMasked = static_cast<Float_t>(maxFastorADCmasked)/static_cast<Float_t>(sumADCbad);
379  fHistos->FillTH1(Form("hFracMaxFastorTotalBad%s", pt.Data()), fracMaxFastorPatchADC);
380  fHistos->FillTH1(Form("hFracMaxFastorMeanBad%s", pt.Data()), fracMaxFastorMeanADC);
381  fHistos->FillTH2(Form("hPatchADCvsADCgoodBad%s", pt.Data()), patch.GetADCAmp(), sumADCgood);
382  fHistos->FillTH1(Form("hFracMaxMaskedFastorBad%s", pt.Data()), fracMaxFastorMaskedPatchADC);
383  fHistos->FillTH1(Form("hFracMaxGoodFastorBad%s", pt.Data()), fracMaxFastorGoodPatchADC);
384  fHistos->FillTH1(Form("hFracGoodADCBad%s", pt.Data()), fracGoodADC);
385  fHistos->FillTH1(Form("hFracMaskedADCBad%s", pt.Data()), fracMaskedADC);
386  fHistos->FillTH2(Form("hFracMaxMaskedvsNmaskedcontribBad%s", pt.Data()), nMaskedFastorsNonZero, fracMaxFastorMaskedPatchADC);
387  fHistos->FillTH1(Form("hFracMaxMaskedSumMaskedBad%s", pt.Data()), fracMaxMaskedSumMasked);
388  } else {
389  // For jet patches can almost never happen
390  fHistos->FillTH1(Form("hFracMaxFastorTotalGood%s", pt.Data()), fracMaxFastorPatchADC);
391  fHistos->FillTH1(Form("hFracMaxFastorMeanGood%s", pt.Data()), fracMaxFastorMeanADC);
392  }
393  }
394 }
395 
396 void AliAnalysisTaskEmcalPatchMasking::ProcessMaxPatch(const AliEMCALTriggerPatchInfo &patch, const TString &patchtype){
397  std::unique_ptr<AliEMCALTriggerPatchADCInfoAP> patchADC(MakeFastorADCValuesForPatch(patch));
398 
399  // Find the max fastor ADC in the patch
400  UShort_t maxFastorADC = 0, maxFastorADCmasked = 0, maxFastorADCgood = 0, tmp = 0;
401  UShort_t nFastorNonZero = 0, nfastorMasked = 0, nMaskedFastorsNonZero = 0;
402  Int_t sumADCgood = 0, sumADCbad = 0, absFastorIndex = 0;
403  std::vector<UShort_t> adcs;
404  for(UChar_t icol = 0; icol < patchADC->GetPatchSize(); icol++){
405  for(UChar_t irow = 0; irow < patchADC->GetPatchSize(); irow++){
406  tmp = patchADC->GetADC(icol, irow);
407  adcs.push_back(tmp);
408  if(tmp > 0) nFastorNonZero++;
409  if(tmp > maxFastorADC) maxFastorADC = tmp;
410 
411  // Get masked fastors in the patch
412  fGeom->GetTriggerMapping()->GetAbsFastORIndexFromPositionInEMCAL(icol + patch.GetColStart(), irow + patch.GetRowStart(), absFastorIndex);
413  if(std::find(fListMaskedFastors.begin(), fListMaskedFastors.end(), absFastorIndex) != fListMaskedFastors.end()){
414  // Fastor is masked
415  nfastorMasked++;
416  if(tmp > 0) nMaskedFastorsNonZero++;
417  sumADCbad += tmp;
418  if(tmp > maxFastorADCmasked) maxFastorADCmasked = tmp;
419  } else {
420  // Fastor is not masked
421  sumADCgood += tmp;
422  if(tmp > maxFastorADCgood) maxFastorADCgood = tmp;
423  }
424  }
425  }
426  Float_t fracMaxFastorPatchADC = static_cast<Float_t>(maxFastorADC)/static_cast<Float_t>(patch.GetADCAmp()),
427  fracMaxFastorMaskedPatchADC = static_cast<Float_t>(maxFastorADCmasked)/static_cast<Float_t>(patch.GetADCAmp()),
428  fracMaxFastorGoodPatchADC = static_cast<Float_t>(maxFastorADCgood)/static_cast<Float_t>(patch.GetADCAmp()),
429  fracMaxFastorMeanADC = static_cast<Float_t>(maxFastorADC)/TMath::Mean(adcs.begin(), adcs.end()),
430  fracGoodADC = static_cast<Float_t>(sumADCgood)/static_cast<Float_t>(patch.GetADCAmp()),
431  fracMaskedADC = static_cast<Float_t>(sumADCbad)/static_cast<Float_t>(patch.GetADCAmp());
432 
433  fHistos->FillTH1(Form("hFracMaxFastorTotalAllMax%s", patchtype.Data()), fracMaxFastorPatchADC);
434  fHistos->FillTH1(Form("hFracMaxFastorMeanAllMax%s", patchtype.Data()), fracMaxFastorMeanADC);
435  fHistos->FillTH2(Form("hPatchADCvsADCgoodAllMax%s", patchtype.Data()), patch.GetADCAmp(), sumADCgood);
436  fHistos->FillTH1(Form("hFracMaxMaskedFastorAllMax%s", patchtype.Data()), fracMaxFastorMaskedPatchADC);
437  fHistos->FillTH1(Form("hFracMaxGoodFastorAllMax%s", patchtype.Data()), fracMaxFastorGoodPatchADC);
438  fHistos->FillTH1(Form("hFracGoodADCAllMax%s", patchtype.Data()), fracGoodADC);
439  fHistos->FillTH1(Form("hFracMaskedADCAllMax%s", patchtype.Data()), fracMaskedADC);
440  fHistos->FillTH2(Form("hFracMaxMaskedvsNmaskedcontribAllMax%s", patchtype.Data()), nMaskedFastorsNonZero, fracMaxFastorMaskedPatchADC);
441 
442  if(nfastorMasked){
443  Float_t fracMaxMaskedSumMasked = 0;
444  if(sumADCbad) fracMaxMaskedSumMasked = static_cast<Float_t>(maxFastorADCmasked)/static_cast<Float_t>(sumADCbad);
445  fHistos->FillTH1(Form("hFracMaxFastorTotalBadMax%s", patchtype.Data()), fracMaxFastorPatchADC);
446  fHistos->FillTH1(Form("hFracMaxFastorMeanBadMax%s", patchtype.Data()), fracMaxFastorMeanADC);
447  fHistos->FillTH2(Form("hPatchADCvsADCgoodBadMax%s", patchtype.Data()), patch.GetADCAmp(), sumADCgood);
448  fHistos->FillTH1(Form("hFracMaxMaskedFastorBadMax%s", patchtype.Data()), fracMaxFastorMaskedPatchADC);
449  fHistos->FillTH1(Form("hFracMaxGoodFastorBadMax%s", patchtype.Data()), fracMaxFastorGoodPatchADC);
450  fHistos->FillTH1(Form("hFracGoodADCBadMax%s", patchtype.Data()), fracGoodADC);
451  fHistos->FillTH1(Form("hFracMaskedADCBadMax%s", patchtype.Data()), fracMaskedADC);
452  fHistos->FillTH2(Form("hFracMaxMaskedvsNmaskedcontribBadMax%s", patchtype.Data()), nMaskedFastorsNonZero, fracMaxFastorMaskedPatchADC);
453  fHistos->FillTH1(Form("hFracMaxMaskedSumMaskedBadMax%s", patchtype.Data()), fracMaxMaskedSumMasked);
454  } else {
455  // For jet patches can almost never happen
456  fHistos->FillTH1(Form("hFracMaxFastorTotalGoodMax%s", patchtype.Data()), fracMaxFastorPatchADC);
457  fHistos->FillTH1(Form("hFracMaxFastorMeanGoodMax%s", patchtype.Data()), fracMaxFastorMeanADC);
458  }
459 
460 }
461 
462 } /* namespace EMCalTriggerPtAnalysis */
TString fNameMaskedFastorOADB
Name of the masked fastor OADB container.
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.
void SetADC(Int_t adc, UChar_t col, UChar_t row)
std::vector< UShort_t > fListMaskedFastors
List of masked fastors.
void SetCaloTriggerPatchInfoName(const char *n)
Investigation of observables related to masked fastors within 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.
AliEMCALTriggerPatchADCInfoAP * MakeFastorADCValuesForPatch(const AliEMCALTriggerPatchInfo &patch) const
int Int_t
Definition: External.C:63
THashList * GetListOfHistograms() const
Get the list of histograms.
Definition: THistManager.h:671
float Float_t
Definition: External.C:68
AliEMCALGeometry * fGeom
!emcal geometry
void ProcessMaxPatch(const AliEMCALTriggerPatchInfo &patch, const TString &maxtype)
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)
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
AliOADBContainer * fMaskedFastorOADB
! OADB container of the masked fastors
AliEmcalList * fOutput
!output list
Analysis of high- tracks in triggered events.
TClonesArray * fTriggerPatchInfo
!trigger patch info array
void SetNeedEmcalGeom(Bool_t n)
Container class for histograms.
Definition: THistManager.h:99
unsigned short UShort_t
Definition: External.C:28
virtual void ExecOnce()
Perform steps needed to initialize the analysis.
void UserCreateOutputObjects()
Main initialization function on the worker.
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.