ATLAS Offline Software
HLTPrescaleSetCollectionLoader.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "./DBHelper.h"
9 
12 
13 #include <CoralBase/Attribute.h>
14 #include <CoralBase/AttributeList.h>
15 
16 #include "RelationalAccess/SchemaException.h"
17 #include "RelationalAccess/ITransaction.h"
18 #include "RelationalAccess/ITable.h"
19 #include "RelationalAccess/ISchema.h"
20 #include "RelationalAccess/ICursor.h"
21 #include "RelationalAccess/IQuery.h"
22 
23 #include <algorithm>
24 #include <iostream>
25 #include <sstream>
26 #include <stdexcept>
27 
28 using namespace std;
29 
30 bool
32  unsigned int requestcounter,
33  const std::string& partition ) {
34  TRG_MSG_INFO("started loading data");
35 
36  vector< pair<unsigned int, unsigned int> > lb_psk;
37 
38  //Find if old or new schema is being used:
39  try {
40  startSession();
41 
42  unique_ptr< coral::IQuery > q( m_session.nominalSchema().newQuery() );
43 
44  //Set the tables that are used
45  q->addToTableList ( "HLT_PRESCALE_SET_COLL", "PSC" );
46 
47  //Bind list
48  coral::AttributeList bindings;
49  bindings.extend<uint>("req");
50  bindings.extend<string>("part");
51  bindings[0].data<uint>() = requestcounter;
52  bindings[1].data<string>() = partition;
53 
54  string theCondition = "HPSC_PARTITION=:part and :req>=0";
55 
56  q->setCondition( theCondition, bindings );
57 
58  //Output data and types
59  coral::AttributeList attList;
60  attList.extend<int>( "PSC.HPSC_LB" );
61  attList.extend<int>( "PSC.HPSC_HLTPSK" );
62  fillQuery(q.get(), attList);
63 
64  // the ordering
65  q->addToOrderList( "PSC.HPSC_LB" );
66 
67  // process the query
68  // query->setRowCacheSize(20);
69  q->setDistinct();
70 
71  coral::ICursor& cursor = q->execute();
72 
73  // fill chain info list
74  while (cursor.next()) {
75  const coral::AttributeList& row = cursor.currentRow();
76  int lb = row["PSC.HPSC_LB"].data<int>();
77  int psk = row["PSC.HPSC_HLTPSK"].data<int>();
78  lb_psk.push_back( make_pair(lb, psk) );
79  }
80 
81  TRG_MSG_INFO("LB_PSK map for partition " << partition);
82  for(uint i=0; i< lb_psk.size(); i++) {
83  TRG_MSG_INFO("For LB " << lb_psk[i].first << " onwards load psk " << lb_psk[i].second);
84  }
85  commitSession();
86  }
87  catch (const std::exception& e) {
88  TRG_MSG_ERROR("HLTPrescaleSetCollectionLoader: caught exception: " << e.what());
89  throw;
90  }
91 
92  pscoll.set_prescale_keys_to_load( lb_psk );
93 
94  return load(pscoll);
95 }
96 
97 
98 
99 bool
101 
102  IHLTPrescaleSetLoader& pssloader = m_storageMgr.hltPrescaleSetLoader();
103  pssloader.setLevel(outputLevel());
104 
105  bool loadsuccess = true;
106 
107  for(HLTPrescaleSetCollection::cont& psinfo: psc.sets()) {
108 
109  // already loaded?
110  if(psinfo.pss!=0) continue;
111 
112  // create new prescale set and load it
113  psinfo.pss = new HLTPrescaleSet();
114  psinfo.pss->setId(psinfo.psk);
115  bool loadpss = pssloader.load(*psinfo.pss);
116 
117  if(!loadpss) {
118  TRG_MSG_ERROR("HLTPrescaleSetCollectionLoader::load(): Could not load HLT Prescales for key " << psinfo.psk);
119  loadsuccess = false;
120  }
121  }
122 
123  return loadsuccess;
124 }
125 
TRG_MSG_ERROR
#define TRG_MSG_ERROR(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:29
query_example.row
row
Definition: query_example.py:24
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
TrigConf::IHLTPrescaleSetLoader::load
virtual bool load(HLTPrescaleSet &hltpss)=0
HLTPrescaleSetCollectionLoader.h
DBHelper.h
TrigConf::fillQuery
void fillQuery(coral::IQuery *q, coral::AttributeList &attList)
Definition: DBHelper.cxx:13
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
TrigConf::IHLTPrescaleSetLoader
Definition: IHLTPrescaleSetLoader.h:14
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
psc
Definition: Config.h:26
python.BunchSpacingUtils.lb
lb
Definition: BunchSpacingUtils.py:88
StorageMgr.h
lumiFormat.i
int i
Definition: lumiFormat.py:92
calibdata.exception
exception
Definition: calibdata.py:496
TrigConf::ILoader::setLevel
virtual void setLevel(MSGTC::Level lvl)=0
Load the configuration data from the configuration source.
HLTPrescaleSetLoader.h
TrigConf::HLTPrescaleSet
HLT chain configuration information.
Definition: HLTPrescaleSet.h:31
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
HLTPrescaleSetCollection.h
python.TrigPSCPythonDbSetup.outputLevel
outputLevel
Definition: TrigPSCPythonDbSetup.py:30
HLTPrescaleSet.h
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
query_example.cursor
cursor
Definition: query_example.py:21
TrigConf::HLTPrescaleSetCollectionLoader::load
virtual bool load(HLTPrescaleSetCollection &psc)
Definition: HLTPrescaleSetCollectionLoader.cxx:100
TrigConf::HLTPrescaleSetCollection
HLT chain configuration information.
Definition: HLTPrescaleSetCollection.h:25
DeMoScan.first
bool first
Definition: DeMoScan.py:534
StateLessPT_NewConfig.partition
partition
Definition: StateLessPT_NewConfig.py:49
TrigConf::HLTPrescaleSetCollection::set_prescale_keys_to_load
void set_prescale_keys_to_load(const std::vector< std::pair< unsigned int, unsigned int > > &)
Definition: HLTPrescaleSetCollection.cxx:141
extractSporadic.q
list q
Definition: extractSporadic.py:98
python.root_pickle.load
def load(f, use_proxy=1, key=None)
Definition: root_pickle.py:476
TrigConf::HLTPrescaleSetCollection::cont
Definition: HLTPrescaleSetCollection.h:28