AliPhysics  bdbde52 (bdbde52)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 <iostream>
28 
29 #include <THistManager.h>
30 #include <TString.h>
31 
32 #include "AliAnalysisManager.h"
33 #include "AliAODInputHandler.h"
35 #include "AliClusterContainer.h"
39 #include "AliInputEventHandler.h"
40 #include "AliLog.h"
41 #include "AliVCluster.h"
42 #include "AliVEvent.h"
43 
47 
48 namespace PWGJE {
49 namespace EMCALJetTasks {
50 namespace Test {
51 
52 AliAnalysisTaskEmcalTriggerSelectionTest::AliAnalysisTaskEmcalTriggerSelectionTest():
54  fTriggerDecision(nullptr),
55  fHistos(nullptr),
56  fSelectedTriggers()
57 {
58 }
59 
61  AliAnalysisTaskEmcal(name, true),
62  fTriggerDecision(nullptr),
63  fHistos(nullptr),
64  fSelectedTriggers()
65 {
66  this->SetMakeGeneralHistograms(true);
67 }
68 
70 }
71 
74 
75  const std::array<TString, 9> EMCALL1TRIGGERS = {"INT7", "EG1", "EG2", "EJ1", "EJ2", "DG1", "DG2", "DJ1", "DJ2"};
76  fHistos = new THistManager("triggerselectiontest");
77 
78  for(auto t : EMCALL1TRIGGERS){
79  fHistos->CreateTH1(Form("hEventCount%s", t.Data()), Form("Event counter for trigger %s", t.Data()), 1, 0.5, 1.5);
80  fHistos->CreateTH1(Form("hVertexDist%s", t.Data()), Form("Vertex distribution for trigger %s", t.Data()), 160, -40., 40);
81  fHistos->CreateTH1(Form("hClusterEnergyNonLinCorr%s", t.Data()), Form("Cluster energy corrected for non-linearity for trigger %s", t.Data()), 1000, 0., 100);
82  }
83 
84  for(auto h : *fHistos->GetListOfHistograms()) fOutput->Add(h);
85 }
86 
88  fTriggerDecision = dynamic_cast<PWG::EMCAL::AliEmcalTriggerDecisionContainer *>(fInputEvent->FindListObject("EmcalTriggerDecision"));
89  if(!fTriggerDecision)
90  AliFatal("Trigger decision object not found in the event - task cannot run\n");
91 }
92 
94  // check if we have at least one trigger selected
95  fSelectedTriggers.clear();
96  if(fInputHandler->IsEventSelected() & AliVEvent::kINT7) fSelectedTriggers.push_back("INT7");
99  AliDebugStream(2) << "Processing decision " << sel->GetName() << std::endl;
100  if(sel->IsSelected()) {
101  AliDebugStream(2) << "Selected" << std::endl;
102  fSelectedTriggers.push_back(sel->GetName());
103  }
104  }
105  AliDebugStream(1) << "Found " << fSelectedTriggers.size() << " triggers\n";
106  return fSelectedTriggers.size() > 0;
107 }
108 
110  for(auto t : fSelectedTriggers) this->FillHistosForTrigger(t);
111  return true;
112 }
113 
115  fHistos->FillTH1(Form("hEventCount%s", trigger), 1);
116  fHistos->FillTH1(Form("hVertexDist%s", trigger), fVertex[2]);
117  for(auto c : this->GetClusterContainer(0)->accepted()){
118  fHistos->FillTH1(Form("hClusterEnergyNonLinCorr%s", trigger), c->GetNonLinCorrEnergy());
119  }
120 }
121 
123  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
124  if(!mgr) {
125  std::cerr << "AddTaskEmcalTriggerSelectionTest: Analysis manager not available" << std::endl;
126  return nullptr;
127  }
128 
129  TString taskname("TriggerSelectionTest"),outfilename(TString::Format("%s:TriggerSelectionTest", mgr->GetCommonFileName()));
130  if(suffix.Length()){
131  taskname += "_" + suffix;
132  outfilename += "_" + suffix;
133  }
134 
136  mgr->AddTask(testtask);
137 
138  AliClusterContainer *clusters = testtask->AddClusterContainer(EMCalTriggerPtAnalysis::AliEmcalAnalysisFactory::ClusterContainerNameFactory(mgr->GetInputEventHandler()->IsA() == AliAODInputHandler::Class()));
139  clusters->SetClusNonLinCorrEnergyCut(0.5);
140 
141  mgr->ConnectInput(testtask, 0, mgr->GetCommonInputContainer());
142  mgr->ConnectOutput(testtask, 1, mgr->CreateContainer(Form("Histos%s", taskname.Data()), AliEmcalList::Class(), AliAnalysisManager::kOutputContainer, outfilename));
143 
144  return testtask;
145 }
146 
147 
148 } /* namespace Test */
149 } /* namespace EMCALJetTasks */
150 } /* 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.