AliPhysics  64f4410 (64f4410)
AliAnalysisTaskEmcalTriggerCorrelationMC.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 <array>
28 #include <bitset>
29 #include <iostream>
30 #include <sstream>
31 #include <string>
32 
33 #include <TH2.h>
34 
35 #include "AliAnalysisManager.h"
38 #include "AliInputEventHandler.h"
39 #include "AliLog.h"
40 #include "AliVEvent.h"
41 
42 using namespace EmcalTriggerJets;
43 
46  fTriggerCorrelationHist(nullptr),
47  fNameTriggerDecisionContainer("EmcalTriggerDecision")
48 {
49 
50 }
51 
53  AliAnalysisTaskEmcal(name, true),
55  fNameTriggerDecisionContainer("EmcalTriggerDecision")
56 {
57  SetUseAliAnaUtils(true);
58 }
59 
61 
62 }
63 
66 
67  const std::array<const std::string, 9> kTriggers = {{"INT7", "EG1", "EG2", "EJ1", "EJ2", "DG1", "DG2", "DJ1", "DJ2"}};
68  fTriggerCorrelationHist = new TH2F("hTriggerCorrelationMC", "Trigger correlation hist", kTriggers.size(), -0.5, kTriggers.size() - 0.5, kTriggers.size(), -0.5, kTriggers.size() - 0.5);
69 
70  for(decltype(kTriggers.size()) itrg = 0; itrg < kTriggers.size(); itrg++){
71  fTriggerCorrelationHist->GetXaxis()->SetBinLabel(itrg+1, kTriggers[itrg].data());
72  fTriggerCorrelationHist->GetYaxis()->SetBinLabel(itrg+1, kTriggers[itrg].data());
73  }
75 
76  PostData(1, fOutput);
77 }
78 
80  const std::array<const std::string, 9> kTriggers = {{"INT7", "EG1", "EG2", "EJ1", "EJ2", "DG1", "DG2", "DJ1", "DJ2"}};
81  if(!(fInputHandler->IsEventSelected() & AliVEvent::kINT7)) return false;
82 
83  auto emcaltriggers = static_cast<PWG::EMCAL::AliEmcalTriggerDecisionContainer *>(fInputEvent->FindListObject(fNameTriggerDecisionContainer.Data()));
84  if(!emcaltriggers){
85  AliErrorStream() << "EMCAL trigger decision container with name " << fNameTriggerDecisionContainer << " not found in the event. Exiting ..." << std::endl;
86  return false;
87  }
88 
89  // Get all triggers selected in the event
90  std::bitset<sizeof(Short_t) * 8> triggersSelected = 0;
91  for(decltype(kTriggers.size()) itrg = 0; itrg < kTriggers.size(); itrg++){
92  const auto &triggername = kTriggers[itrg];
93  if(triggername == "INT7") triggersSelected.set(itrg, true);
94  else if(emcaltriggers->IsEventSelected(triggername.data())) triggersSelected.set(itrg, true);
95  }
96 
97  for(decltype(kTriggers.size()) itrg = 0; itrg < kTriggers.size(); itrg++){
98  if(!triggersSelected.test(itrg)) continue;
99  const auto &xlabel = kTriggers[itrg];
100  for(decltype(kTriggers.size()) jtrg = 0; jtrg < kTriggers.size(); jtrg++){
101  if(!triggersSelected.test(jtrg)) continue;
102  const auto &ylabel = kTriggers[jtrg];
103  fTriggerCorrelationHist->Fill(xlabel.data(), ylabel.data(), 1.);
104  }
105  }
106  return true;
107 }
108 
110  auto mgr = AliAnalysisManager::GetAnalysisManager();
111  if(!mgr){
112  std::cerr << "No Analysis Manager found. Exiting ..." << std::endl;
113  return nullptr;
114  }
115 
116  std::stringstream tasknamebuilder;
117  tasknamebuilder << "EmcalTriggerCorrelationMC";
118  if(strlen(suffix)) {
119  tasknamebuilder << "_" << suffix;
120  }
121  auto correlationtask = new AliAnalysisTaskEmcalTriggerCorrelationMC(tasknamebuilder.str().data());
122  mgr->AddTask(correlationtask);
123 
124  std::stringstream outcontname, outfilename;
125  outcontname << "HistosTriggerCorrelationMC";
126  outfilename << mgr->GetCommonFileName() << ":EmcalTriggerCorrelationMC";
127  if(strlen(suffix)){
128  outcontname << "_" << suffix;
129  outfilename << "_" << suffix;
130  }
131  mgr->ConnectInput(correlationtask, 0, mgr->GetCommonInputContainer());
132  mgr->ConnectOutput(correlationtask, 1, mgr->CreateContainer(outcontname.str().data(), TList::Class(), AliAnalysisManager::kOutputContainer, outfilename.str().data()));
133 
134  return correlationtask;
135 }
Definition: External.C:236
Base task in the EMCAL framework.
void SetUseAliAnaUtils(Bool_t b, Bool_t bRejPilup=kTRUE)
AliEmcalList * fOutput
!output list
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 AliAnalysisTaskEmcalTriggerCorrelationMC * AddTaskEmcalTriggerCorrelationMC(const char *suffix)