AliPhysics  9b6b435 (9b6b435)
AliAnalysisTaskEmcalResponseOutliers.cxx
Go to the documentation of this file.
1 /************************************************************************************
2  * Copyright (C) 2019, Copyright Holders of the ALICE Collaboration *
3  * All rights reserved. *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions are met: *
7  * * Redistributions of source code must retain the above copyright *
8  * notice, this list of conditions and the following disclaimer. *
9  * * Redistributions in binary form must reproduce the above copyright *
10  * notice, this list of conditions and the following disclaimer in the *
11  * documentation and/or other materials provided with the distribution. *
12  * * Neither the name of the <organization> nor the *
13  * names of its contributors may be used to endorse or promote products *
14  * derived from this software without specific prior written permission. *
15  * *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND *
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
19  * DISCLAIMED. IN NO EVENT SHALL ALICE COLLABORATION BE LIABLE FOR ANY *
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
26  ************************************************************************************/
27 #include <sstream>
28 #include <string>
29 
30 #include <TH2.h>
31 #include <TList.h>
32 #include <TNtuple.h>
33 
34 #include "AliAODInputHandler.h"
35 #include "AliAnalysisManager.h"
37 #include "AliClusterContainer.h"
39 #include "AliEmcalJet.h"
40 #include "AliJetContainer.h"
41 #include "AliTrackContainer.h"
42 
44 
45 using namespace PWGJE::EMCALJetTasks;
46 
49  fOutlierData(nullptr),
50  fHistNonOutliers(nullptr),
51  fHistOutliers(nullptr)
52 {
53 
54 }
55 
56 AliAnalysisTaskEmcalResponseOutliers::AliAnalysisTaskEmcalResponseOutliers(const char *name):
57  AliAnalysisTaskEmcalJet(name, true),
58  fOutlierData(nullptr),
59  fHistNonOutliers(nullptr),
60  fHistOutliers(nullptr)
61 {
62  SetIsPythia(true);
65  ResetMCFilter();
66 }
67 
69  if(fOutlierData) delete fOutlierData;
70 }
71 
74 
75  std::string varlist = "ptpart";
76  varlist += ":ptdet";
77  varlist += ":deltaR";
78  varlist += ":etapart";
79  varlist += ":phipart";
80  varlist += ":etadet";
81  varlist += ":phidet";
82  varlist += ":nefpart";
83  varlist += ":nefdet";
84  varlist += ":npart";
85  varlist += ":ncharged";
86  varlist += ":nneutral";
87  varlist += ":leadingpart";
88  varlist += ":leadingcharged";
89  varlist += ":leadingneutral";
90  varlist += ":pdgmaxpart";
91  fOutlierData = new TNtuple("fOutlierData", "Outlier information", varlist.data());
92 
93  fHistNonOutliers = new TH2D("fHistNonOutliers", "histogram for non-outlier jets; p_{t,det} (GeV/c); p_{t,part} (GeV/c)", 500, 0., 500., 500, 0., 500.);
94  fHistOutliers = new TH2D("fHistOutliers", "histogram for outlier jets; p_{t,det} (GeV/c); p_{t,part} (GeV/c)", 500, 0., 500., 500, 0., 500.);
95 
96  fOutput->Add(fOutlierData);
97  fOutput->Add(fHistNonOutliers);
98  fOutput->Add(fHistOutliers);
99 
100  PostData(1, fOutput);
101 }
102 
104  auto detjets = GetJetContainer("detjets");
105  auto partcont = GetParticleContainer("mcparticles");
106 
107  // Outlier selection based on pt-hard bin
108  const double detptmax[21] = {0., 10., 20., 20., 30., 40., 50., 60., 80., 100., 120., 140., 150., 300., 300., 300., 300., 300., 300., 300., 300.},
109  partptmin[21] = {0., 20., 25., 30., 40., 50., 70., 80., 100., 120., 140., 180., 200., 250., 270., 300., 350., 380., 420., 450., 600.};
110  AliDebugStream(1) << "Using outlier cuts for pt-hard bin " << fPtHardBinGlobal << ": pt max det: " << detptmax[fPtHardBinGlobal]
111  << ", pt min part: " << partptmin[fPtHardBinGlobal] << std::endl;
112 
113  AliDebugStream(1) << "Found " << detjets->GetNEntries() << " jets at detector level" << std::endl;
114 
115  for(auto detjet : detjets->accepted()) {
116  auto mcjet = detjet->ClosestJet();
117  if(!mcjet) continue;
118  if(!(detjet->Pt() < detptmax[fPtHardBinGlobal] && mcjet->Pt() > partptmin[fPtHardBinGlobal])){
119  fHistNonOutliers->Fill(detjet->Pt(), mcjet->Pt());
120  continue;
121  }
122  // jet identified as outlier
123  fHistOutliers->Fill(detjet->Pt(), mcjet->Pt());
124  auto truepart = mcjet->GetLeadingTrack(partcont->GetArray());
125  TVector3 detvec, mcvec;
126  detvec.SetPtEtaPhi(detjet->Pt(), detjet->Eta(), detjet->Phi());
127  mcvec.SetPtEtaPhi(mcjet->Pt(), mcjet->Eta(), mcjet->Phi());
128  Float_t outlierDataBlock[16];
129  outlierDataBlock[0] = mcjet->Pt();
130  outlierDataBlock[1] = detjet->Pt();
131  outlierDataBlock[2] = detvec.DeltaR(mcvec);
132  outlierDataBlock[3] = mcjet->Eta();
133  outlierDataBlock[4] = mcjet->Phi();
134  outlierDataBlock[5] = detjet->Eta();
135  outlierDataBlock[6] = detjet->Phi();
136  outlierDataBlock[7] = mcjet->NEF();
137  outlierDataBlock[8] = detjet->NEF();
138  outlierDataBlock[9] = mcjet->GetNumberOfTracks() + mcjet->GetNumberOfClusters();
139  outlierDataBlock[10] = detjet->GetNumberOfTracks();
140  outlierDataBlock[11] = detjet->GetNumberOfClusters();
141  outlierDataBlock[12] = mcjet->MaxPartPt();
142  outlierDataBlock[13] = detjet->MaxChargedPt();
143  outlierDataBlock[14] = detjet->MaxNeutralPt();
144  outlierDataBlock[15] = static_cast<Float_t>(truepart->PdgCode());
145  fOutlierData->Fill(outlierDataBlock);
146  }
147  return true;
148 }
149 
151  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
152  if(!mgr){
153  ::Error("EmcalTriggerJets::AliAnalysisTaskEmcalJetEnergyScale::AddTaskJetEnergyScale", "No analysis manager available");
154  return nullptr;
155  }
156 
157  auto inputhandler = mgr->GetInputEventHandler();
158  auto isAOD = inputhandler->IsA() == AliAODInputHandler::Class();
159 
160  auto responsetask = new AliAnalysisTaskEmcalResponseOutliers("ResponseOutlierTask");
161  mgr->AddTask(responsetask);
162 
163 
164  auto partcont = responsetask->AddMCParticleContainer("mcparticles");
165  partcont->SetMinPt(0.);
166  auto clusters = responsetask->AddClusterContainer(EMCalTriggerPtAnalysis::AliEmcalAnalysisFactory::ClusterContainerNameFactory(isAOD));
167  clusters->SetDefaultClusterEnergy(AliVCluster::kHadCorr);
168  clusters->SetClusHadCorrEnergyCut(0.3);
169  auto tracks = responsetask->AddTrackContainer(EMCalTriggerPtAnalysis::AliEmcalAnalysisFactory::TrackContainerNameFactory(isAOD));
170  auto contdetjet = responsetask->AddJetContainer(AliJetContainer::kFullJet, AliJetContainer::antikt_algorithm, AliJetContainer::E_scheme, 0.2,
171  AliJetContainer::kEMCALfid, tracks, clusters);
172  contdetjet->SetName("detjets");
173 
174  std::stringstream outnamebuilder;
175  outnamebuilder << mgr->GetCommonFileName() << ":OutlierResponse";
176 
177  mgr->ConnectInput(responsetask, 0, mgr->GetCommonInputContainer());
178  mgr->ConnectOutput(responsetask, 1, mgr->CreateContainer("OutlierResponseHists", TList::Class(), AliAnalysisManager::kOutputContainer, outnamebuilder.str().data()));
179 
180  return responsetask;
181 }
EMCal fiducial acceptance (each eta, phi edge narrowed by jet R)
AliJetContainer * GetJetContainer(Int_t i=0) const
Int_t fPtHardBinGlobal
!event -hard bin, detected from filename
void SetIsPythia(Bool_t i)
Define production as pythia pt-hard production.
AliParticleContainer * GetParticleContainer(Int_t i=0) const
Get particle container attached to this task.
float Float_t
Definition: External.C:68
TH2 * fHistNonOutliers
! Control histogram for jets not identified as outliers
Definition: External.C:228
void SetUsePtHardBinScaling(Bool_t b)
Switch on pt-hard bin scaling.
TH2 * fHistOutliers
! Control histogram for jets identified as outliers
void ResetMCFilter()
Switch off MC outlier rejection.
AliEmcalList * fOutput
!output list
static AliAnalysisTaskEmcalResponseOutliers * AddTaskEmcalResponseOutliers()
void SetMakeGeneralHistograms(Bool_t g)
Enable general histograms.
Base task in the EMCAL jet framework.
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 UserCreateOutputObjects()
Main initialization function on the worker.
static TString TrackContainerNameFactory(Bool_t isAOD)
Get name of the default track container.
static TString ClusterContainerNameFactory(Bool_t isAOD)
Get name of the default cluster container.