AliPhysics  e6c8d43 (e6c8d43)
AliAnalysisTaskEmcalPatchMultCorr.cxx
Go to the documentation of this file.
1 /************************************************************************************
2  * Copyright (C) 2018, 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 <iostream>
28 #include <sstream>
29 #include <string>
30 
31 #include <TClonesArray.h>
32 #include <THistManager.h>
33 #include <TList.h>
34 #include <TString.h>
35 
36 #include "AliAnalysisManager.h"
37 #include "AliEMCALTriggerPatchInfo.h"
38 #include "AliInputEventHandler.h"
40 
42 
43 using namespace EmcalTriggerJets;
44 
47  fHistos(nullptr)
48 {
49  SetCaloTriggerPatchInfoName("EmcalTriggers");
50  SetUseAliAnaUtils(true);
51  SetMakeGeneralHistograms(true);
52 }
53 
54 AliAnalysisTaskEmcalPatchMultCorr::AliAnalysisTaskEmcalPatchMultCorr(const char *name):
55  AliAnalysisTaskEmcal(name, true),
56  fHistos(nullptr)
57 {
58  SetCaloTriggerPatchInfoName("EmcalTriggers");
59  SetUseAliAnaUtils(true);
61 }
62 
64 
65 }
66 
69 
70  fHistos = new THistManager(Form("histos_%s", GetName()));
71  fHistos->CreateTH2("hMultCorrGAJE", "Multiplicity correlation firing gamma/jet patches; Mult JE; Mult GA", 100., 0., 100., 100., 0., 100.);
72  fHistos->CreateTH1("hCountIsolatedGA", "Number of GA patches not contained by a JE patch; Isolated GA patches; Number of events", 100, 0., 100.);
73  for(auto h : *(fHistos->GetListOfHistograms())) fOutput->Add(h);
74 }
75 
77  // Only study EJ1 events
78  if(!(fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)) return false;
79  if(!TString(fInputEvent->GetFiredTriggerClasses()).Contains("EJ1")) return false;
80  auto ejepatches = SelectPatches(fTriggerPatchInfo, 255, true),
81  egapatches = SelectPatches(fTriggerPatchInfo, 115, false),
82  isolatedGA = GetIsolatedGammaPatches(egapatches, ejepatches);
83  fHistos->FillTH2("hMultCorrGAJE", ejepatches.size(), egapatches.size());
84  fHistos->FillTH1("hCountIsolatedGA", isolatedGA.size());
85  return true;
86 }
87 
88 const std::vector<const AliEMCALTriggerPatchInfo *> AliAnalysisTaskEmcalPatchMultCorr::SelectPatches(const TClonesArray *patchcontainer, double threshold, bool isEJE) const{
89  std::vector<const AliEMCALTriggerPatchInfo *> selpatches;
90  for(auto p : *patchcontainer){
91  auto testpatch = static_cast<AliEMCALTriggerPatchInfo *>(p);
92  if((isEJE && !testpatch->IsJetHighRecalc()) || (!isEJE && !testpatch->IsGammaHighRecalc())) continue;
93  if(testpatch->GetADCAmp() < threshold) continue;
94  selpatches.emplace_back(testpatch);
95  }
96  return selpatches;
97 }
98 
99 const std::vector<const AliEMCALTriggerPatchInfo *> AliAnalysisTaskEmcalPatchMultCorr::GetIsolatedGammaPatches(const std::vector<const AliEMCALTriggerPatchInfo *> &gapaches, const std::vector<const AliEMCALTriggerPatchInfo *> &jepatches) const{
100  std::vector<const AliEMCALTriggerPatchInfo *> isolated;
101  for(auto ga : gapaches) {
102  bool hasOverlap = false;
103  for(auto je : jepatches){
104  if(CheckGAJEOverlap(ga, je)) {
105  hasOverlap = true;
106  break;
107  }
108  }
109  if(!hasOverlap) isolated.emplace_back(ga);
110  }
111  return isolated;
112 }
113 
114 bool AliAnalysisTaskEmcalPatchMultCorr::CheckGAJEOverlap(const AliEMCALTriggerPatchInfo *gapatch, const AliEMCALTriggerPatchInfo *jepatch) const{
115  int garowmin = gapatch->GetRowStart(), garowmax = gapatch->GetRowStart() + gapatch->GetPatchSize() - 1,
116  gacolmin = gapatch->GetColStart(), gacolmax = gapatch->GetColStart() + gapatch->GetPatchSize() - 1,
117  jerowmin = jepatch->GetRowStart(), jerowmax = jepatch->GetRowStart() + jepatch->GetPatchSize() - 1,
118  jecolmin = jepatch->GetColStart(), jecolmax = jepatch->GetColStart() + jepatch->GetPatchSize() - 1;
119  // Check whether any of the 4 edges of the GA patch is contianed within the square spanned by the jet patch
120  return InSquare(gacolmin, garowmin, jecolmin, jerowmin, jecolmax, jerowmax) ||
121  InSquare(gacolmax, garowmin, jecolmin, jerowmin, jecolmax, jerowmax) ||
122  InSquare(gacolmin, garowmax, jecolmin, jerowmin, jecolmax, jerowmax) ||
123  InSquare(gacolmax, garowmax, jecolmin, jerowmin, jecolmax, jerowmax);
124 }
125 
126 bool AliAnalysisTaskEmcalPatchMultCorr::InSquare(int px, int py, int sxlow, int sylow, int sxhigh, int syhigh) const {
127  // all edge coordinates are part of the square
128  return px >= sxlow && px <= sxhigh && py >= sylow && py <= syhigh;
129 }
130 
132  auto *mgr = AliAnalysisManager::GetAnalysisManager();
133  if(!mgr){
134  std::cerr << "No analysis manager found. Returning ..." << std::endl;
135  return nullptr;
136  }
137 
138  auto *patchtask = new AliAnalysisTaskEmcalPatchMultCorr(Form("PatchMultCorrTask_%s", name));
139  mgr->AddTask(patchtask);
140 
141  std::stringstream outfilename;
142  outfilename << mgr->GetCommonFileName() << ":PatchMultCorrResults_" << name;
143  mgr->ConnectInput(patchtask, 0, mgr->GetCommonInputContainer());
144  mgr->ConnectOutput(patchtask, 1, mgr->CreateContainer(Form("PatchMultCorrHists_%s", name), TList::Class(), AliAnalysisManager::kOutputContainer, outfilename.str().data()));
145 
146  return patchtask;
147 }
const std::vector< const AliEMCALTriggerPatchInfo * > SelectPatches(const TClonesArray *patchcontainer, double threshold, bool isEJE) const
Base task in the EMCAL framework.
void SetUseAliAnaUtils(Bool_t b, Bool_t bRejPilup=kTRUE)
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
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
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
const std::vector< const AliEMCALTriggerPatchInfo * > GetIsolatedGammaPatches(const std::vector< const AliEMCALTriggerPatchInfo * > &gapaches, const std::vector< const AliEMCALTriggerPatchInfo * > &jepatches) const
static AliAnalysisTaskEmcalPatchMultCorr * AddTaskEmcalPatchMultCorr(const char *name)
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
bool CheckGAJEOverlap(const AliEMCALTriggerPatchInfo *gapatch, const AliEMCALTriggerPatchInfo *jepatch) const
AliEmcalList * fOutput
!output list
void SetMakeGeneralHistograms(Bool_t g)
TClonesArray * fTriggerPatchInfo
!trigger patch info array
Container class for histograms.
Definition: THistManager.h:99
bool InSquare(int px, int py, int sxlow, int sylow, int sxhigh, int syhigh) const
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.