AliPhysics  master (3d17d9d)
AliAnalysisEmcalTriggerSelectionHelper.cxx
Go to the documentation of this file.
1 /************************************************************************************
2  * Copyright (C) 2019, 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 <algorithm>
29 #include <iostream>
30 
33 #include "AliLog.h"
34 
36 ClassImp(PWGJE::EMCALJetTasks::AliAnalysisEmcalTriggerSelectionHelper)
37 
38 using namespace PWGJE::EMCALJetTasks;
39 
40 bool AliAnalysisEmcalTriggerSelectionHelperImpl::IsSelectEmcalTriggers(EMCAL_STRINGVIEW triggerstring) const {
41  const std::array<std::string, 8> kEMCALTriggers = {
42  "EJ1", "EJ2", "DJ1", "DJ2", "EG1", "EG2", "DG1", "DG2"
43  };
44  bool isEMCAL = false;
45  for(auto emcaltrg : kEMCALTriggers) {
46  if(triggerstring.find(emcaltrg) != std::string::npos) {
47  isEMCAL = true;
48  break;
49  }
50  }
51  return isEMCAL;
52 }
53 
54 std::string AliAnalysisEmcalTriggerSelectionHelperImpl::MatchTrigger(EMCAL_STRINGVIEW triggerstring, EMCAL_STRINGVIEW triggerselectionstring, bool useMuonCalo) const{
55  auto triggerclasses = PWG::EMCAL::Triggerinfo::DecodeTriggerString(triggerstring.data());
56  std::string result;
57  for(const auto &t : triggerclasses) {
58  // Use CENT cluster for downscaling
59  if(t.BunchCrossing() != "B") continue;
60  if(useMuonCalo){
61  if(t.Triggercluster() != "CALO") continue;
62  } else {
63  if(t.Triggercluster() != "CENT") continue;
64  }
65  if(t.Triggerclass().find(triggerselectionstring.data()) == std::string::npos) continue;
66  result = t.ExpandClassName();
67  break;
68  }
69  return result;
70 }
71 
72 std::vector<AliAnalysisEmcalTriggerSelectionHelper::TriggerCluster_t> AliAnalysisEmcalTriggerSelectionHelperImpl::GetTriggerClusterIndices(EMCAL_STRINGVIEW triggerstring) const {
73  // decode trigger string in order to determine the trigger clusters
74  AliDebugGeneralStream("AliAnalysisEmcalTriggerSelectionHelperImpl::GetTriggerClusterIndices", 4) << "Triggerstring: " << triggerstring.data() << std::endl;
75  std::vector<TriggerCluster_t> result;
76  result.emplace_back(kTrgClusterANY); // cluster ANY always included
77 
78  // Data - separate trigger clusters
79  std::vector<std::string> clusternames;
80  auto triggerinfos = PWG::EMCAL::Triggerinfo::DecodeTriggerString(triggerstring.data());
81  for(auto t : triggerinfos) {
82  if(std::find(clusternames.begin(), clusternames.end(), t.Triggercluster()) == clusternames.end()) clusternames.emplace_back(t.Triggercluster());
83  }
84  bool isCENT = (std::find(clusternames.begin(), clusternames.end(), "CENT") != clusternames.end()),
85  isCENTNOTRD = (std::find(clusternames.begin(), clusternames.end(), "CENTNOTRD") != clusternames.end()),
86  isCALO = (std::find(clusternames.begin(), clusternames.end(), "CALO") != clusternames.end()),
87  isCALOFAST = (std::find(clusternames.begin(), clusternames.end(), "CALOFAST") != clusternames.end());
88  AliDebugGeneralStream("AliAnalysisEmcalTriggerSelectionHelperImpl::GetTriggerClusterIndices", 4) << "Selected trigger clusters: CENT: " << (isCENT ? "yes" : "no") << ", CENTNOTRD: " << (isCENTNOTRD ? "yes" : "no") << ", CALO: " << (isCALO ? "yes" : "no") << ", CALOFAST: " << (isCALOFAST ? "yes" : "no") << std::endl;
89  if(isCENT || isCENTNOTRD) {
90  if(isCENT) {
91  result.emplace_back(kTrgClusterCENT);
92  if(isCENTNOTRD) {
93  result.emplace_back(kTrgClusterCENTNOTRD);
94  result.emplace_back(kTrgClusterCENTBOTH);
95  } else result.emplace_back(kTrgClusterOnlyCENT);
96  } else {
97  result.emplace_back(kTrgClusterCENTNOTRD);
98  result.emplace_back(kTrgClusterOnlyCENTNOTRD);
99  }
100  }
101  if(isCALO || isCALOFAST) {
102  if(isCALO) {
103  result.emplace_back(kTrgClusterCALO);
104  if(isCALOFAST) {
105  result.emplace_back(kTrgClusterCALOFAST);
106  result.emplace_back(kTrgClusterCALOBOTH);
107  } else result.emplace_back(kTrgClusterOnlyCALO);
108  } else {
109  result.emplace_back(kTrgClusterCALOFAST);
110  result.emplace_back(kTrgClusterOnlyCALOFAST);
111  }
112  }
113  return result;
114 }
115 
117  const std::array<std::string, kTrgClusterN> kNamesTriggerCluster = {{"ANY", "CENT", "CENTNOTRD", "CALO", "CALOFAST",
118  "CENTBOTH", "OnlyCENT", "OnlyCENTNOTRD", "CALOBOTH",
119  "OnluCALO", "OnlyCALOFAST"}};
120  return kNamesTriggerCluster[clust];
121 }
static std::vector< PWG::EMCAL::Triggerinfo > DecodeTriggerString(EMCAL_STRINGVIEW triggerstring)
Decoding trigger string.
std::vector< TriggerCluster_t > GetTriggerClusterIndices(EMCAL_STRINGVIEW triggerstring) const
#define EMCAL_STRINGVIEW