AliPhysics  56f1704 (56f1704)
AliAnalysisTaskEmcalTriggerSelectionTest.cxx
Go to the documentation of this file.
1 /************************************************************************************
2  * Copyright (C) 2017, 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 <array>
28 #include <iostream>
29 
30 #include <THistManager.h>
31 #include <TString.h>
32 
33 #include "AliAnalysisManager.h"
34 #include "AliAODInputHandler.h"
36 #include "AliClusterContainer.h"
40 #include "AliInputEventHandler.h"
41 #include "AliLog.h"
42 #include "AliVCluster.h"
43 #include "AliVEvent.h"
44 
48 
49 namespace PWGJE {
50 namespace EMCALJetTasks {
51 namespace Test {
52 
53 AliAnalysisTaskEmcalTriggerSelectionTest::AliAnalysisTaskEmcalTriggerSelectionTest():
55  fTriggerDecision(nullptr),
56  fHistos(nullptr),
57  fSelectedTriggers()
58 {
59 }
60 
62  AliAnalysisTaskEmcal(name, true),
66 {
67  this->SetMakeGeneralHistograms(true);
68 }
69 
71 }
72 
75 
76  const std::array<TString, 9> EMCALL1TRIGGERS = {"INT7", "EG1", "EG2", "EJ1", "EJ2", "DG1", "DG2", "DJ1", "DJ2"};
77  fHistos = new THistManager("triggerselectiontest");
78 
79  for(auto t : EMCALL1TRIGGERS){
80  fHistos->CreateTH1(Form("hEventCount%s", t.Data()), Form("Event counter for trigger %s", t.Data()), 1, 0.5, 1.5);
81  fHistos->CreateTH1(Form("hVertexDist%s", t.Data()), Form("Vertex distribution for trigger %s", t.Data()), 160, -40., 40);
82  fHistos->CreateTH1(Form("hClusterEnergyNonLinCorr%s", t.Data()), Form("Cluster energy corrected for non-linearity for trigger %s", t.Data()), 1000, 0., 100);
83  }
84 
85  for(auto h : *fHistos->GetListOfHistograms()) fOutput->Add(h);
86 }
87 
89  fTriggerDecision = dynamic_cast<PWG::EMCAL::AliEmcalTriggerDecisionContainer *>(fInputEvent->FindListObject("EmcalTriggerDecision"));
90  if(!fTriggerDecision)
91  AliFatal("Trigger decision object not found in the event - task cannot run\n");
92 }
93 
95  // check if we have at least one trigger selected
96  fSelectedTriggers.clear();
97  if(fInputHandler->IsEventSelected() & AliVEvent::kINT7) fSelectedTriggers.push_back("INT7");
100  AliDebugStream(2) << "Processing decision " << sel->GetName() << std::endl;
101  if(sel->IsSelected()) {
102  AliDebugStream(2) << "Selected" << std::endl;
103  fSelectedTriggers.push_back(sel->GetName());
104  }
105  }
106  AliDebugStream(1) << "Found " << fSelectedTriggers.size() << " triggers\n";
107  return fSelectedTriggers.size() > 0;
108 }
109 
111  for(auto t : fSelectedTriggers) this->FillHistosForTrigger(t);
112  return true;
113 }
114 
116  fHistos->FillTH1(Form("hEventCount%s", trigger), 1);
117  fHistos->FillTH1(Form("hVertexDist%s", trigger), fVertex[2]);
118  for(auto c : this->GetClusterContainer(0)->accepted()){
119  fHistos->FillTH1(Form("hClusterEnergyNonLinCorr%s", trigger), c->GetNonLinCorrEnergy());
120  }
121 }
122 
124  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
125  if(!mgr) {
126  std::cerr << "AddTaskEmcalTriggerSelectionTest: Analysis manager not available" << std::endl;
127  return nullptr;
128  }
129 
130  TString taskname("TriggerSelectionTest"),outfilename(TString::Format("%s:TriggerSelectionTest", mgr->GetCommonFileName()));
131  if(suffix.Length()){
132  taskname += "_" + suffix;
133  outfilename += "_" + suffix;
134  }
135 
137  mgr->AddTask(testtask);
138 
139  AliClusterContainer *clusters = testtask->AddClusterContainer(EMCalTriggerPtAnalysis::AliEmcalAnalysisFactory::ClusterContainerNameFactory(mgr->GetInputEventHandler()->IsA() == AliAODInputHandler::Class()));
140  clusters->SetClusNonLinCorrEnergyCut(0.5);
141 
142  mgr->ConnectInput(testtask, 0, mgr->GetCommonInputContainer());
143  mgr->ConnectOutput(testtask, 1, mgr->CreateContainer(Form("Histos%s", taskname.Data()), AliEmcalList::Class(), AliAnalysisManager::kOutputContainer, outfilename));
144 
145  return testtask;
146 }
147 
148 
149 } /* namespace Test */
150 } /* namespace EMCALJetTasks */
151 } /* namespace PWGJE */
Container for trigger decision.
static AliAnalysisTaskEmcalTriggerSelectionTest * AddTaskEmcalTriggerSelectionTest(TString suffix)
Base task in the EMCAL framework.
TCanvas * c
Definition: TestFitELoss.C:172
AliClusterContainer * AddClusterContainer(const char *n)
Create new cluster container and attach it to the task.
const TList * GetListOfTriggerDecisions() const
Get container with trigger decision results.
THashList * GetListOfHistograms() const
Get the list of histograms.
Definition: THistManager.h:671
void SetClusNonLinCorrEnergyCut(Double_t cut)
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
AliEmcalList * fOutput
!output list
Double_t fVertex[3]
!event vertex
void SetMakeGeneralHistograms(Bool_t g)
Container class for histograms.
Definition: THistManager.h:99
PWG::EMCAL::AliEmcalTriggerDecisionContainer * fTriggerDecision
Trigger decision container (from event)
Bool_t IsSelected() const
Check whether event is selected under the given trigger.
void UserCreateOutputObjects()
Main initialization function on the worker.
Container structure for EMCAL clusters.
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.
static TString ClusterContainerNameFactory(Bool_t isAOD)
Get name of the default cluster container.