ATLAS Offline Software
Loading...
Searching...
No Matches
TriggerThresholdValueLoader.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6//
7//NAME: TriggerThresholdValueLoader.cpp
8//PACKAGE: TrigConfStorage
9//
10//AUTHOR: J.Haller (CERN) Johannes.Haller@cern.ch
11//CREATED: 31. Oct. 2005
12//
13//PURPOSE:
14//
15//UPDATED: 8 Dec 2008 Paul Bell for sqlite access
16// (use of defineOutput method to set data type)
17//
19
21
22#include <CoralBase/Attribute.h>
23#include <CoralBase/AttributeList.h>
24
25#include "RelationalAccess/SchemaException.h"
26#include "RelationalAccess/ITransaction.h"
27#include "RelationalAccess/ITable.h"
28#include "RelationalAccess/ISchema.h"
29#include "RelationalAccess/ICursor.h"
30#include "RelationalAccess/IQuery.h"
31
38
39#include <iostream>
40#include <stdexcept>
41#include <typeinfo>
42
43using namespace std;
44
45bool
47 TRG_MSG_DEBUG("TriggerThresholdValueLoader loading thresholdvalue with ID = " << ttvTarget.id());
48 L1DataDef def;
49
50 string name = "";
51 string type = "";
52 int version = 0;
53 float ptcut = 0;
54 float priority=0;
55 int phimin = 0;
56 int phimax = 0;
57 int etamin = 0;
58 int etamax = 0;
59 string emisolation = "";
60 string hadisolation = "";
61 string hadveto = "";
62 int window = 0;
63
64 try {
65 //unsigned int schema = triggerDBSchemaVersion();
66
68
69 coral::ITable& table = m_session.nominalSchema().tableHandle( "L1_TRIGGER_THRESHOLD_VALUE");
70 coral::IQuery* query = table.newQuery();
71 query->setRowCacheSize( 5 );
72
73 //Bind list
74 coral::AttributeList bindList;
75 bindList.extend<long>("ttvId");
76 std::string cond= "L1TTV_ID = :ttvId";
77 bindList[0].data<long>() = ttvTarget.id();
78 query->setCondition( cond, bindList );
79
80 //Define the data types
81 coral::AttributeList attList;
82 attList.extend<std::string>( "L1TTV_NAME" );
83 attList.extend<int>( "L1TTV_VERSION" );
84 attList.extend<std::string>( "L1TTV_TYPE" );
85 attList.extend<std::string>( "L1TTV_PT_CUT" );
86 attList.extend<int>( "L1TTV_ETA_MIN" );
87 attList.extend<int>( "L1TTV_ETA_MAX" );
88 attList.extend<int>( "L1TTV_PHI_MIN" );
89 attList.extend<int>( "L1TTV_PHI_MAX" );
90 attList.extend<std::string>( "L1TTV_EM_ISOLATION" );
91 attList.extend<std::string>( "L1TTV_HAD_ISOLATION" );
92 attList.extend<std::string>( "L1TTV_HAD_VETO" );
93 attList.extend<int>( "L1TTV_WINDOW" );
94 attList.extend<std::string>( "L1TTV_PRIORITY" );
95 query->defineOutput(attList);
96 query->addToOutputList( "L1TTV_NAME" );
97 query->addToOutputList( "L1TTV_VERSION" );
98 query->addToOutputList( "L1TTV_TYPE" );
99 query->addToOutputList( "L1TTV_PT_CUT" );
100 query->addToOutputList( "L1TTV_ETA_MIN" );
101 query->addToOutputList( "L1TTV_ETA_MAX" );
102 query->addToOutputList( "L1TTV_PHI_MIN" );
103 query->addToOutputList( "L1TTV_PHI_MAX" );
104 query->addToOutputList( "L1TTV_EM_ISOLATION" );
105 query->addToOutputList( "L1TTV_HAD_ISOLATION" );
106 query->addToOutputList( "L1TTV_HAD_VETO" );
107 query->addToOutputList( "L1TTV_WINDOW" );
108 query->addToOutputList( "L1TTV_PRIORITY" );
109
110 coral::ICursor& cursor = query->execute();
111 if ( !cursor.next()) {
112 msg() << "TriggerThresholdValueLoader >> No such TriggerThresholdValue exists "
113 << ttvTarget.id() << std::endl;
114 delete query;
116 throw std::runtime_error( "TriggerThresholdValueLoader >> TriggerThresholdValue not available" );
117 }
118
119 const coral::AttributeList& row = cursor.currentRow();
120
121 name = row["L1TTV_NAME"].data<std::string>();
122 version = row["L1TTV_VERSION"].data<int>();
123 type = row["L1TTV_TYPE"].data<std::string>();
124 ptcut = std::stof(row["L1TTV_PT_CUT"].data<std::string>());
125 etamin = row["L1TTV_ETA_MIN"].data<int>();
126 etamax = row["L1TTV_ETA_MAX"].data<int>();
127 phimin = row["L1TTV_PHI_MIN"].data<int>();
128 phimax = row["L1TTV_PHI_MAX"].data<int>();
129 window = row["L1TTV_WINDOW"].data<int>();
130 priority = std::stof(row["L1TTV_PRIORITY"].data<std::string>());
131 emisolation = row["L1TTV_EM_ISOLATION"].data<std::string>();
132 hadisolation = row["L1TTV_HAD_ISOLATION"].data<std::string>();
133 hadveto = row["L1TTV_HAD_VETO"].data<std::string>();
134
135
136 if (cursor.next()) {
137 msg() << "TriggerThresholdValueLoader >> More than one TriggerThresholdValue exists "
138 << ttvTarget.id() << std::endl;
139 delete query;
141 throw std::runtime_error( "TriggerThresholdValueLoader >> TriggerThresholdValue not available" );
142 }
143
144 // Fill the value common for all threshold_value
145 ttvTarget.setName( name );
146 ttvTarget.setVersion( version );
147 ttvTarget.setType( type );
148 ttvTarget.setPtcut( ptcut );
149 ttvTarget.setPriority(priority);
150 delete query;
152 //msg() << name << std::endl;
153
154 }
155 catch( const coral::Exception& e ) {
156 TRG_MSG_ERROR("Caught coral exception: " << e.what() );
157 throw;
158 }
159 catch( const std::exception& e ) {
160 TRG_MSG_ERROR("Caught standard exception: " << e.what() );
161 throw;
162 }
163
164 try {
165 ClusterThresholdValue& ctvTarget = dynamic_cast<ClusterThresholdValue&>(ttvTarget);
167 msg() << "TriggerThresholdValueLoader >> No type match for ttv_id = "
168 << ctvTarget.id() << " " << type << std::endl;
169 throw std::runtime_error( "TriggerThresholdValueLoader >> ClusterThresholdValue not available" );
170 }
171
172 cout << "ISO " << emisolation << " " << hadisolation << " " << hadveto << endl;
173
174 if(hadveto=="USEISOBITS" || std::stoi(hadveto)==99 ) {
175 ctvTarget.setIsolationMask( TrigConf::bin2uint(emisolation) );
176 ctvTarget.setUseIsolationMask();
177 } else {
178 ctvTarget.setEmIsolation( std::stof(emisolation) );
179 ctvTarget.setHadIsolation( std::stof(hadisolation) );
180 ctvTarget.setHadVeto( std::stof(hadveto) );
181 ctvTarget.setUseIsolationMask( false );
182 }
183
184
185 ctvTarget.setPhiMin( phimin);
186 ctvTarget.setPhiMax( phimax);
187 ctvTarget.setEtaMin( etamin );
188 ctvTarget.setEtaMax( etamax );
189 } catch (std::bad_cast& ex) { }
190
191 //is it a jet_threshold_value?
192 try {
193 JetThresholdValue& jtvTarget = dynamic_cast<JetThresholdValue&>(ttvTarget);
194
195 if (type!=def.typeAsString(L1DataDef::JET) &&
198 msg() << "TriggerThresholdValueLoader >> No type match for ttv_id = "
199 << jtvTarget.id() << type << std::endl;
200 throw std::runtime_error( "TriggerThresholdValueLoader >> TriggerThresholdValue not available" );
201 }
202 jtvTarget.setPhiMin( phimin );
203 jtvTarget.setPhiMax( phimax );
204 jtvTarget.setEtaMin( etamin );
205 jtvTarget.setEtaMax( etamax );
206 jtvTarget.setWindow( window );
207 } catch (std::bad_cast& ex) {}
208
209 return true;
210}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
void commitSession()
commit session if not already done
Definition DBLoader.cxx:45
coral::ISessionProxy & m_session
CORAL interface to database session.
Definition DBLoader.h:68
void startSession()
start session if not already active
Definition DBLoader.cxx:35
static std::string & typeAsString(TriggerType tt)
Definition L1DataDef.h:53
unsigned int id() const
void setName(const std::string &name)
void setVersion(unsigned int version)
MsgStreamTC & msg() const
The standard message stream.
virtual bool load(TriggerThresholdValue &data) override
void setType(const std::string &type)
Definition query.py:1
STL namespace.