AliPhysics  55b2ab8 (55b2ab8)
AliAnalysisTaskEmcalEG1Correlation.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 <bitset>
28 #include <iostream>
29 #include <sstream>
30 
31 #include <TH2.h>
32 #include <TList.h>
33 
34 #include "AliAnalysisManager.h"
37 #include "AliInputEventHandler.h"
38 #include "AliVEvent.h"
39 
41 
42 using namespace EmcalTriggerJets;
43 
46  fOutput(nullptr),
47  fCorrelationHistNoPhysSel(nullptr),
48  fCorrelationHistWithPhysSel(nullptr)
49 {
50 }
51 
52 AliAnalysisTaskEmcalEG1Correlation::AliAnalysisTaskEmcalEG1Correlation(const char *taskname):
53  AliAnalysisTaskSE(taskname),
54  fOutput(nullptr),
55  fCorrelationHistNoPhysSel(nullptr),
56  fCorrelationHistWithPhysSel(nullptr)
57 {
58  DefineOutput(1, TList::Class());
59 }
60 
62  if(fOutput) delete fOutput;
63 }
64 
66  fOutput = new TList;
67  fOutput->SetOwner(true);
68 
69  auto triggers = GetSupportedTriggers();
70  fCorrelationHistNoPhysSel = new TH2D("fCorrelationHistNoPhysSel", "Trigger Correlation without physics selection", triggers.size(), -0.5, triggers.size() - 0.5, triggers.size(), -0.5, triggers.size() - 0.5);
71  fCorrelationHistWithPhysSel = new TH2D("fCorrelationHistWithPhysSel", "Trigger Correlation without physics selection", triggers.size(), -0.5, triggers.size() - 0.5, triggers.size(), -0.5, triggers.size() - 0.5);
72 
73  for(decltype(triggers.size()) itrg = 0; itrg < triggers.size(); itrg++){
74  fCorrelationHistNoPhysSel->GetXaxis()->SetBinLabel(itrg+1, triggers[itrg].data());
75  fCorrelationHistNoPhysSel->GetYaxis()->SetBinLabel(itrg+1, triggers[itrg].data());
76  fCorrelationHistWithPhysSel->GetXaxis()->SetBinLabel(itrg+1, triggers[itrg].data());
77  fCorrelationHistWithPhysSel->GetYaxis()->SetBinLabel(itrg+1, triggers[itrg].data());
78  }
79 
82 
83  PostData(1, fOutput);
84 }
85 
86 
87 
89  auto triggers = PWG::EMCAL::Triggerinfo::DecodeTriggerString(fInputEvent->GetFiredTriggerClasses().Data());
90  auto supported = GetSupportedTriggers();
91  std::bitset<8> firedTS(0), firedPS(0);
92  for(decltype(supported.size()) itrg = 0; itrg < supported.size(); itrg++){
93  if(IsTriggerSelectedTS("C" + supported[itrg], triggers)) firedTS.set(itrg);
94  if(IsTriggerSelectedPS(supported[itrg], triggers)) firedPS.set(itrg);
95  }
96 
97  // From trigger string
98  for(decltype(supported.size()) itrg = 0; itrg < supported.size(); itrg++){
99  if(!firedTS.test(itrg)) continue;
100  const auto &xlabel = supported[itrg];
101  for(decltype(supported.size()) jtrg = 0; jtrg < supported.size(); jtrg++){
102  if(!firedTS.test(jtrg)) continue;
103  const auto &ylabel = supported[jtrg];
104  fCorrelationHistNoPhysSel->Fill(xlabel.data(), ylabel.data(), 1.);
105  }
106  }
107 
108  // From physics selection
109  for(decltype(supported.size()) itrg = 0; itrg < supported.size(); itrg++){
110  if(!firedPS.test(itrg)) continue;
111  const auto &xlabel = supported[itrg];
112  for(decltype(supported.size()) jtrg = 0; jtrg < supported.size(); jtrg++){
113  if(!firedPS.test(jtrg)) continue;
114  const auto &ylabel = supported[jtrg];
115  fCorrelationHistWithPhysSel->Fill(xlabel.data(), ylabel.data(), 1.);
116  }
117  }
118 }
119 
120 bool AliAnalysisTaskEmcalEG1Correlation::IsTriggerSelectedTS(const std::string &trigger, const std::vector<PWG::EMCAL::Triggerinfo> &decoded) const {
121  bool found(false);
122  for(auto d : decoded){
123  if(d.Triggerclass() == trigger) {
124  found = true;
125  break;
126  }
127  }
128  return found;
129 }
130 
131 bool AliAnalysisTaskEmcalEG1Correlation::IsTriggerSelectedPS(const std::string &trigger, const std::vector<PWG::EMCAL::Triggerinfo> &decoded) const {
132  bool isPhysSel = false;
133  if(trigger.find("EG") != std::string::npos){
134  isPhysSel = fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA;
135  } else if(trigger.find("EJ") != std::string::npos){
136  isPhysSel = fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE;
137  } else if(trigger == "EMC7") {
138  isPhysSel = fInputHandler->IsEventSelected() & AliVEvent::kEMC7;
139  } else if(trigger == "EMC8") {
140  isPhysSel = fInputHandler->IsEventSelected() & AliVEvent::kEMC8;
141  }
142  if(!isPhysSel) return false;
143  return IsTriggerSelectedTS("C"+trigger, decoded);
144 }
145 
147  return {
148  "EMC7EG1", "EMC8EG1", "EMC7EG2", "EMC7EJ1", "EMC7EJ2", "EMC7", "EMC8"
149  };
150 }
151 
153  auto mgr = AliAnalysisManager::GetAnalysisManager();
154  if(!mgr){
155  std::cerr << "No analysis manager found ..." << std::endl;
156  return nullptr;
157  }
158 
159  auto task = new AliAnalysisTaskEmcalEG1Correlation(taskname);
160  task->SelectCollisionCandidates(AliVEvent::kAny);
161  mgr->AddTask(task);
162 
163  std::stringstream outfilename, outcontname;
164  outfilename << mgr->GetCommonFileName() << ":EG1Correlation" << taskname;
165  outcontname << "HistosEG1Correlation" << taskname;
166 
167  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
168  mgr->ConnectOutput(task, 1, mgr->CreateContainer(outcontname.str().data(), TList::Class(), AliAnalysisManager::kOutputContainer, outfilename.str().data()));
169 
170  return task;
171 }
TH2 * fCorrelationHistWithPhysSel
! Correlation histogram with physics selection applied
static std::vector< PWG::EMCAL::Triggerinfo > DecodeTriggerString(const std::string &triggerstring)
Decoding trigger string.
static AliAnalysisTaskEmcalEG1Correlation * AddTaskEmcalEG1Correlation(const char *taskname)
bool IsTriggerSelectedPS(const std::string &trigger, const std::vector< PWG::EMCAL::Triggerinfo > &triggers) const
Definition: External.C:228
TH2 * fCorrelationHistNoPhysSel
! Correlation histogram without physics selection applied
const char Option_t
Definition: External.C:48
bool IsTriggerSelectedTS(const std::string &trigger, const std::vector< PWG::EMCAL::Triggerinfo > &triggers) const