ATLAS Offline Software
ItemMap.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // local includes
6 #include "./ItemMap.h"
7 
8 // TrigT1 configuration includes
11 
12 
13 // random number generator
14 #include "CLHEP/Random/RandomEngine.h"
15 #include "CLHEP/Random/RandFlat.h"
16 
17 #include "boost/algorithm/string.hpp"
18 #include <boost/tokenizer.hpp>
19 #include <boost/lexical_cast.hpp>
20 
22 {
23  for( const TrigConf::L1Item & item : *l1menu ) {
24  const std::string & itemName( item.name() );
25 
26  // get postion from ctp id
27  unsigned int ctpId = item.ctpId();
28 
29  CTPTriggerItem * ctpItem = new CTPTriggerItem();
30  ctpItem->setPrescale( 1 );
31  ctpItem->setCtpId( ctpId );
32  ctpItem->setName(itemName);
33  ctpItem->setLogic(item.definition());
34  ctpItem->setTriggerType(item.triggerTypeAsUChar());
35  ctpItem->setBunchGroups(item.bunchgroups());
36 
37  m_map[ itemName ] = ctpItem;
38  m_itemNames.insert( itemName );
39 
40  }
41 }
42 
43 
45  for( auto entry : m_map ) {
46  delete entry.second;
47  }
48 }
49 
50 
53 {
54  for( const TrigConf::TriggerItem * item : item_vector ) {
55 
56  std::string definition = getDefinition(item);
57 
58  const std::string & itemName( item->name() );
59 
60  // get postion from ctp id
61  unsigned int ctpId = item->ctpId();
62 
63  CTPTriggerItem * ctpItem = new CTPTriggerItem();
64  ctpItem->setPrescale( prescales.prescales_float()[ ctpId ] );
65  ctpItem->setCtpId( ctpId );
66  ctpItem->setName(itemName);
67  ctpItem->setLogic(definition);
68  ctpItem->setTriggerType(item->triggerType());
69 
70  m_map[ itemName ] = ctpItem;
71  m_itemNames.insert( itemName );
72  }
73 }
74 
75 
76 /*
77  e.g for the item L1_EM15VHI_2TAU12IM_J25_3J12
78  the definition that is stored in COOL is (1&2&3&4&5&6)
79  and the list of thresholds is 1,EM15VHI_x1,EM15VHI 2,HA12IM_x2,HA12IM 1,J25_x1,J25 3,J12_x3,J12 BGRP0 BGRP1
80 
81  In this function this information is used to create a definition string
82  "(EM15VHI[x1]&HA12IM[x2]&J25[x1]&J12[x3]&BGRP0&BGRP1)"
83 */
84 std::string
86 
87 
88  std::vector<std::string> thresholdlist;
89  std::string logic, conditions;
90  item->buildLogic(logic, thresholdlist); // get's the list of thresholds, e.g. 1,EM15VHI_x1,EM15VHI 2,HA12IM_x2,HA12IM 1,J25_x1,J25 3,J12_x3,J12 BGRP0 BGRP1
91 
92  std::map<unsigned int, std::string> thrNames;
93  size_t idx = 1;
94  for(const std::string & thrmult : thresholdlist) {
95  std::vector<std::string> res;
96  boost::split(res, thrmult, boost::is_any_of(",")); // split 1,EM15VHI_x1,EM15VHI into multiplicity,name_mult, and name
97 
98  std::string name_mult("");
99  if(res.size() == 1) {
100  name_mult=res[0]; // for thresholds without multiplicity requirement like RNDM0 or BGRP0,...
101  } else {
102  name_mult = res[2]+"[x"+res[0]+"]"; // build "EM15VHI[x1]"
103  }
104  thrNames[idx++] = name_mult;
105  }
106 
107  // now take the logic (1&2&3&4&5&6) apart and replace the numbers with names "thr[xmult]"
108  std::string def = item->definition();
109  std::vector<std::string> tokens;
110  // build tokens with separators ()&|! and <space>. Keeps all separators except <space> in the list of tokens
111  for ( auto & tok : boost::tokenizer<boost::char_separator<char> > (item->definition(), boost::char_separator<char>(" ", "()&|!")) ) {
112  try {
113  int n = boost::lexical_cast<int,std::string>(tok);
114  tokens.emplace_back(thrNames[n]);
115  }
116  catch(const boost::bad_lexical_cast &) {
117  tokens.emplace_back(tok);
118  }
119  }
120 
121  // and reassemble the logic definition string
122  std::string definition("");
123  for( auto & tok : tokens ) {
124  definition += tok;
125  }
126 
127  return definition;
128 }
LVL1CTP::CTPTriggerItem
Class storing information helping to make the CTP decision.
Definition: CTPTriggerItem.h:23
TriggerItem.h
PrescaleSet.h
LVL1CTP::ItemMap::m_itemNames
std::set< std::string > m_itemNames
Definition: ItemMap.h:65
TrigConf::PrescaleSet
Definition: PrescaleSet.h:22
LVL1CTP::ItemMap::~ItemMap
~ItemMap()
default destructor
Definition: ItemMap.cxx:44
LVL1CTP::CTPTriggerItem::setLogic
void setLogic(const std::string &logicExpr)
Definition: CTPTriggerItem.cxx:60
TrigConf::L1Menu
L1 menu configuration.
Definition: L1Menu.h:28
LVL1CTP::CTPTriggerItem::setName
void setName(const std::string &name)
Definition: CTPTriggerItem.cxx:29
beamspotman.tokens
tokens
Definition: beamspotman.py:1284
RatesAnalysisFullMenu.prescales
prescales
Definition: RatesAnalysisFullMenu.py:119
ItemMap.h
LVL1CTP::CTPTriggerItem::setBunchGroups
void setBunchGroups(const std::vector< std::string > &bunchGroups)
Definition: CTPTriggerItem.cxx:72
beamspotman.n
n
Definition: beamspotman.py:731
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
TrigConf::L1Item
L1 threshold configuration.
Definition: L1Item.h:18
LVL1CTP::CTPTriggerItem::setTriggerType
void setTriggerType(unsigned char triggerType)
Definition: CTPTriggerItem.cxx:50
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
LVL1CTP::ItemMap::m_map
std::map< std::string, const CTPTriggerItem * > m_map
map from item name to CTPTriggerItem
Definition: ItemMap.h:63
LVL1CTP::CTPTriggerItem::setPrescale
void setPrescale(int prescale)
Definition: CTPTriggerItem.cxx:18
item
Definition: ItemListSvc.h:43
TrigConf::ItemContainer
boost::multi_index::multi_index_container< TriggerItem *, boost::multi_index::indexed_by< boost::multi_index::random_access<>, boost::multi_index::ordered_unique< boost::multi_index::identity< TriggerItem > >, boost::multi_index::ordered_unique< boost::multi_index::tag< tag_ctpid >, boost::multi_index::const_mem_fun< TriggerItem, int, &TriggerItem::ctpId > >, boost::multi_index::hashed_unique< boost::multi_index::tag< tag_name_hash >, boost::multi_index::const_mem_fun< TrigConfData, const std::string &, &TrigConfData::name > > > > ItemContainer
Definition: Menu.h:39
LVL1CTP::ItemMap::ItemMap
ItemMap(const TrigConf::L1Menu *l1menu)
Definition: ItemMap.cxx:21
LVL1CTP::CTPTriggerItem::setCtpId
void setCtpId(unsigned int ctpid)
Definition: CTPTriggerItem.cxx:45
python.XMLReader.l1menu
l1menu
Definition: XMLReader.py:73
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
LVL1CTP::ItemMap::getDefinition
std::string getDefinition(const TrigConf::TriggerItem *item) const
Definition: ItemMap.cxx:85
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
TrigConf::TriggerItem
Definition: TriggerItem.h:25