AliPhysics  608b256 (608b256)
AliAnalysisTaskEmcalTriggerBackground.cxx
Go to the documentation of this file.
1 #include <algorithm>
2 #include <iostream>
3 #include <vector>
4 #include "THistManager.h"
5 #include <TList.h>
6 #include <TMath.h>
7 #include <TString.h>
8 #include "AliEMCALTriggerPatchInfo.h"
9 #include "AliAnalysisManager.h"
11 #include "AliVCaloTrigger.h"
12 
14 
15 using namespace EmcalTriggerJets;
16 
19  fHistos(nullptr)
20 {
21  SetCaloTriggerPatchInfoName("EmcalTriggers");
22  SetCaloTriggersName("EMCALTrigger");
23 }
24 
25 AliAnalysisTaskEmcalTriggerBackground::AliAnalysisTaskEmcalTriggerBackground(const char *name) :
26  AliAnalysisTaskEmcal(name, true),
27  fHistos(nullptr)
28 {
29  SetCaloTriggerPatchInfoName("EmcalTriggers");
30  SetCaloTriggersName("EMCALTrigger");
32 }
33 
35  if(fHistos) delete fHistos;
36 }
37 
40 
41  fHistos = new THistManager("backgroundtaskhists");
42  fHistos->CreateTH2("hRhoEMCAL", "Rho values in EMCAL", 1000, 0., 1000, 1000, 0., 1000.);
43  fHistos->CreateTH2("hRhoEMCALMedianDCAL", "Rho value in EMCAL vs Median DCAL", 1000, 0., 1000, 1000, 0., 1000.);
44  fHistos->CreateTH2("hRhoDCAL", "Rho values in DCAL", 1000, 0., 1000, 1000, 0., 1000.);
45  fHistos->CreateTH2("hRhoDCALMedianEMCAL", "Rho value in DCAL vs Median EMCAL", 1000, 0., 1000, 1000, 0., 1000.);
46 
47  for(auto h : *fHistos->GetListOfHistograms()) fOutput->Add(h);
48 }
49 
51  std::vector<double> bkgpatchesEMCAL, bkgpatchesDCAL;
52 
53  for(auto p : *fTriggerPatchInfo) {
54  AliEMCALTriggerPatchInfo *patch = static_cast<AliEMCALTriggerPatchInfo *>(p);
55  if(!patch->IsBkgRecalc()) continue;
56  if(patch->IsEMCal()) bkgpatchesEMCAL.push_back(patch->GetADCAmp());
57  else bkgpatchesDCAL.push_back(patch->GetADCAmp());
58  }
59 
60  std::sort(bkgpatchesEMCAL.begin(), bkgpatchesEMCAL.end(), std::greater<double>());
61  std::sort(bkgpatchesDCAL.begin(), bkgpatchesDCAL.end(), std::greater<double>());
62 
63  auto medEMCAL = TMath::Median<double>(bkgpatchesEMCAL.size(), bkgpatchesEMCAL.data()),
64  medDCAL = TMath::Median<double>(bkgpatchesDCAL.size(), bkgpatchesDCAL.data());
65 
66  fHistos->FillTH2("hRhoEMCAL", fCaloTriggers->GetMedian(0), medEMCAL);
67  fHistos->FillTH2("hRhoDCAL", fCaloTriggers->GetMedian(1), medDCAL);
68  fHistos->FillTH2("hRhoEMCALMedianDCAL", fCaloTriggers->GetMedian(0), medDCAL);
69  fHistos->FillTH2("hRhoDCALMedianEMCAL", fCaloTriggers->GetMedian(1), medEMCAL);
70  return true;
71 }
72 
74  auto mgr = AliAnalysisManager::GetAnalysisManager();
75  if(!mgr) {
76  std::cerr << "No Analysis manager available." << std::endl;
77  return nullptr;
78  }
79 
81  mgr->AddTask(task);
82 
83  TString outfilename(mgr->GetCommonFileName());
84  outfilename += Form(":EmcalTriggerBackground%s", name);
85  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
86  mgr->ConnectOutput(task, 1, mgr->CreateContainer(Form("EmcalTriggerBackground%s", name), TList::Class(), AliAnalysisManager::kOutputContainer, outfilename.Data()));
87  std::cout << "Done" << std::endl;
88  return task;
89 }
Base task in the EMCAL framework.
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
static AliAnalysisTaskEmcalTriggerBackground * AddTaskEmcalTriggerBackground(const char *nametag)
void SetCaloTriggerPatchInfoName(const char *n)
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.
THashList * GetListOfHistograms() const
Get the list of histograms.
Definition: THistManager.h:671
AliEmcalList * fOutput
!output list
void SetMakeGeneralHistograms(Bool_t g)
Enable general histograms.
TClonesArray * fTriggerPatchInfo
!trigger patch info array
Container class for histograms.
Definition: THistManager.h:99
void SetCaloTriggersName(const char *n)
AliVCaloTrigger * fCaloTriggers
!calo triggers
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.