coverity fix
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / UserTasks / AliAnalysisTaskTriggerRejection.cxx
CommitLineData
14e13ab8 1//
2// Jet trigger rejection analysis task.
3//
4// Author: M.Verweij
5
6#include <TClonesArray.h>
7#include <TH1F.h>
8#include <TH2F.h>
9#include <TH3F.h>
10#include <TProfile.h>
11#include <THnSparse.h>
12#include <TList.h>
13#include <TLorentzVector.h>
14
15#include "AliVVZERO.h"
16#include "AliEmcalJet.h"
17#include "AliRhoParameter.h"
18#include "AliLog.h"
19#include "AliJetContainer.h"
20#include "AliEmcalTriggerPatchInfo.h"
21#include "AliPicoTrack.h"
22
23#include "AliAnalysisTaskTriggerRejection.h"
24
25ClassImp(AliAnalysisTaskTriggerRejection)
26
27//________________________________________________________________________
28AliAnalysisTaskTriggerRejection::AliAnalysisTaskTriggerRejection() :
29 AliAnalysisTaskEmcalJet("AliAnalysisTaskTriggerRejection", kTRUE),
30 fContainerFull(0),
31 fContainerCharged(1),
32 fMaxPatch(0),
33 fhnTriggerInfo(0)
34{
35 // Default constructor.
36 SetMakeGeneralHistograms(kTRUE);
37}
38
39//________________________________________________________________________
40AliAnalysisTaskTriggerRejection::AliAnalysisTaskTriggerRejection(const char *name) :
41 AliAnalysisTaskEmcalJet(name, kTRUE),
42 fContainerFull(0),
43 fContainerCharged(1),
44 fMaxPatch(0),
45 fhnTriggerInfo(0)
46{
47 // Standard constructor.
48 SetMakeGeneralHistograms(kTRUE);
49}
50
51//________________________________________________________________________
52AliAnalysisTaskTriggerRejection::~AliAnalysisTaskTriggerRejection()
53{
54 // Destructor.
55}
56
57//________________________________________________________________________
58void AliAnalysisTaskTriggerRejection::UserCreateOutputObjects()
59{
60 // Create user output.
61
62 AliAnalysisTaskEmcalJet::UserCreateOutputObjects();
63
64 Bool_t oldStatus = TH1::AddDirectoryStatus();
65 TH1::AddDirectory(kFALSE);
66
67 Int_t fgkNCentBins = 21;
68 Float_t kMinCent = 0.;
69 Float_t kMaxCent = 105.;
70
71 Int_t fgkNPtBins = 170;
72 Float_t kMinPt = -50.;
73 Float_t kMaxPt = 120.;
74
75 Int_t fgkNVZEROBins = 100;
76 Float_t kMinVZERO = 0.;
77 Float_t kMaxVZERO = 25000;
78
79 const Int_t fgkNEPatch = 100;
80 Float_t kMinEPatch = 0.;
81 Float_t kMaxEPatch = 200.;
82
83 const Int_t fgkNADC = 100;
84 Float_t kMinADC = 0.;
85 Float_t kMaxADC = 1500.;
86
87 const Int_t fgkNEta = 10;
88 const Int_t fgkNPhi = 10;
89
90 const Int_t nDim = 8;//cent;V0mult;ptjet1;ptjet2;Epatch;ADCpatch;EtaPatch;PhiPatch
91 const Int_t nBins[nDim] = {fgkNCentBins,fgkNVZEROBins,fgkNPtBins,fgkNPtBins,fgkNEPatch,fgkNADC,fgkNEta,fgkNPhi};
92 const Double_t xmin0[nDim] = {kMinCent,kMinVZERO,kMinPt,kMinPt,kMinEPatch,kMinADC,-0.7,1.4};
93 const Double_t xmax0[nDim] = {kMaxCent,kMaxVZERO,kMaxPt,kMaxPt,kMaxEPatch,kMaxADC, 0.7,3.14};
94 fhnTriggerInfo = new THnSparseF("fhnTriggerInfo",
95 "hnTriggerInfo;cent;V0mult;ptjet1;ptjet2;Epatch;ADCpatch;EtaPatch;PhiPatch",nDim,nBins,xmin0,xmax0);
96 fOutput->Add(fhnTriggerInfo);
97
98 // =========== Switch on Sumw2 for all histos ===========
99 for (Int_t i=0; i<fOutput->GetEntries(); ++i) {
100 TH1 *h1 = dynamic_cast<TH1*>(fOutput->At(i));
101 if (h1){
102 h1->Sumw2();
103 continue;
104 }
105 TH2 *h2 = dynamic_cast<TH2*>(fOutput->At(i));
106 if (h2){
107 h2->Sumw2();
108 continue;
109 }
110 TH3 *h3 = dynamic_cast<TH3*>(fOutput->At(i));
111 if (h3){
112 h3->Sumw2();
113 continue;
114 }
115 THnSparse *hn = dynamic_cast<THnSparse*>(fOutput->At(i));
116 if(hn)hn->Sumw2();
117 }
118
119 TH1::AddDirectory(oldStatus);
120
121 PostData(1, fOutput); // Post data for ALL output slots > 0 here.
122}
123
124//________________________________________________________________________
125void AliAnalysisTaskTriggerRejection::ExtractMainPatch() {
126
127 //Find main trigger
128 if(!fTriggerPatchInfo)
129 return;
130
131 //number of patches in event
132 Int_t nPatch = fTriggerPatchInfo->GetEntriesFast();
133
134 //extract main trigger patch
135 Double_t emax = -1.;
136 for (Int_t iPatch = 0; iPatch < nPatch; iPatch++) {
137 AliEmcalTriggerPatchInfo *patch = (AliEmcalTriggerPatchInfo*)fTriggerPatchInfo->At( iPatch );
138 if(patch->GetPatchE()>emax) {
139 fMaxPatch = patch;
140 emax = patch->GetPatchE();
141 }
142 }
143}
144//________________________________________________________________________
145Bool_t AliAnalysisTaskTriggerRejection::FillHistograms()
146{
147 // Fill histograms.
148
149 if(!GetJetContainer(fContainerFull) || !GetJetContainer(fContainerCharged) || !fMaxPatch)
150 return kFALSE;
151
152 //Get leading jets
153 AliEmcalJet *leadJet1 = GetJetContainer(fContainerFull)->GetLeadingJet("rho");
154 AliEmcalJet *leadJet2 = GetJetContainer(fContainerCharged)->GetLeadingJet("rho");
155
156 Double_t ptLeadJet1 = -999;
157 Double_t ptLeadJet2 = -999;
158
159 if(leadJet1) ptLeadJet1 = leadJet1->Pt() - GetRhoVal(fContainerFull)*leadJet1->Area();
160 if(leadJet2) ptLeadJet2 = leadJet2->Pt() - GetRhoVal(fContainerCharged)*leadJet2->Area();
161
e870a903 162 Double_t VZEROAmp = (Double_t)(InputEvent()->GetVZEROData()->GetTriggerChargeA() + InputEvent()->GetVZEROData()->GetTriggerChargeC());
14e13ab8 163
164 //cent;V0mult;ptjet1;ptjet2;Epatch;ADCpatch;EtaPatch;PhiPatch
165 Double_t var[8] = {
166 fCent,
167 VZEROAmp,
168 ptLeadJet1,
169 ptLeadJet2,
170 fMaxPatch->GetPatchE(),
be184d52 171 (Double_t)fMaxPatch->GetADCAmp(),
14e13ab8 172 fMaxPatch->GetEtaGeo(),
173 fMaxPatch->GetPhiGeo()
174 };
175 fhnTriggerInfo->Fill(var);
176
177 return kTRUE;
178}
179
180//________________________________________________________________________
181Bool_t AliAnalysisTaskTriggerRejection::Run()
182{
183 // Run analysis code here, if needed. It will be executed before FillHistograms().
184
185 if(fTriggerPatchInfo)
186 ExtractMainPatch();
187
188 return kTRUE; // If return kFALSE FillHistogram() will NOT be executed.
189}
190
191//_______________________________________________________________________
192void AliAnalysisTaskTriggerRejection::Terminate(Option_t *)
193{
194 // Called once at the end of the analysis.
195}