CMS 3D CMS Logo

L1RCTOmdsFedVectorProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1RCTOmdsFedVectorProducer
4 // Class: L1RCTOmdsFedVectorProducer
5 //
13 //
14 // Original Author: Jessica Lynn Leonard,32 4-C20,+41227674522,
15 // Created: Fri Sep 9 11:19:20 CEST 2011
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
25 
27 
28 // OMDS stuff
29 #include "RelationalAccess/ISessionProxy.h"
30 #include "RelationalAccess/ITransaction.h"
31 #include "RelationalAccess/IRelationalDomain.h"
32 #include "RelationalAccess/ISchema.h"
33 #include "RelationalAccess/IQuery.h"
34 #include "RelationalAccess/ICursor.h"
35 #include "RelationalAccess/IConnection.h"
36 #include "CoralBase/AttributeList.h"
37 #include "CoralBase/Attribute.h"
38 #include "CoralKernel/Context.h"
39 
41 // end OMDS stuff
42 
46 
48 
49 //
50 // class declaration
51 //
52 
54 public:
56  ~L1RCTOmdsFedVectorProducer() override;
57 
58  using ReturnType = std::unique_ptr<RunInfo>;
59 
61 
62 private:
63  // ----------member data ---------------------------
67 };
68 
69 //
70 // constants, enums and typedefs
71 //
72 
73 //
74 // static data member definitions
75 //
76 
77 //
78 // constructors and destructor
79 //
81  : connectionString(iConfig.getParameter<std::string>("connectionString")),
82  authpath(iConfig.getParameter<std::string>("authpath")),
83  tableToRead(iConfig.getParameter<std::string>("tableToRead")) {
84  //the following line is needed to tell the framework what
85  // data is being produced
86  setWhatProduced(this, "OmdsFedVector");
87 
88  //now do what ever other initialization is needed
89 }
90 
92  // do anything here that needs to be done at desctruction time
93  // (e.g. close files, deallocate resources etc.)
94 }
95 
96 //
97 // member functions
98 //
99 
100 // ------------ method called to produce the data ------------
102  // std::cout << "ENTERING L1RCTOmdsFedVectorProducer::produce()" << std::endl;
103 
104  // std::cout << "GETTING FED VECTOR FROM OMDS" << std::endl;
105 
106  // GETTING ALREADY-EXISTING RUNINFO OUT OF ES TO FIND OUT RUN NUMBER
108  iRecord.get(sum);
109  const RunInfo* summary = sum.product();
110  int runNumber = summary->m_run;
111 
112  // CREATING NEW RUNINFO WHICH WILL GET NEW FED VECTOR AND BE RETURNED
113  auto pRunInfo = std::make_unique<RunInfo>();
114 
115  // DO THE DATABASE STUFF
116 
117  //make connection object
119 
120  //set in configuration object authentication path
121  connection.setAuthenticationPath(authpath);
122  connection.configure();
123 
124  //create session object from connection
125  cond::persistency::Session session = connection.createSession(connectionString, true);
126 
127  session.transaction().start(true); // (true=readOnly)
128 
129  coral::ISchema& schema = session.coralSession().schema("CMS_RUNINFO");
130 
131  //condition
132  coral::AttributeList conditionData;
133  conditionData.extend<int>("n_run");
134  conditionData[0].data<int>() = runNumber;
135 
136  std::string columnToRead_val = "VALUE";
137 
138  std::string tableToRead_fed = "RUNSESSION_STRING";
139  coral::IQuery* queryV = schema.newQuery();
140  queryV->addToTableList(tableToRead);
141  queryV->addToTableList(tableToRead_fed);
142  queryV->addToOutputList(tableToRead_fed + "." + columnToRead_val, columnToRead_val);
143  //queryV->addToOutputList(tableToRead + "." + columnToRead, columnToRead);
144  //condition
146  tableToRead + ".RUNNUMBER=:n_run AND " + tableToRead +
147  ".NAME='CMS.LVL0:FED_ENABLE_MASK' AND RUNSESSION_PARAMETER.ID = RUNSESSION_STRING.RUNSESSION_PARAMETER_ID";
148  //std::string condition = tableToRead + ".runnumber=:n_run AND " + tableToRead + ".name='CMS.LVL0:FED_ENABLE_MASK'";
149  queryV->setCondition(condition, conditionData);
150  coral::ICursor& cursorV = queryV->execute();
151  std::string fed;
152  if (cursorV.next()) {
153  //cursorV.currentRow().toOutputStream(std::cout) << std::endl;
154  const coral::AttributeList& row = cursorV.currentRow();
155  fed = row[columnToRead_val].data<std::string>();
156  } else {
157  fed = "null";
158  }
159  //std::cout << "string fed emask == " << fed << std::endl;
160  delete queryV;
161 
162  std::replace(fed.begin(), fed.end(), '%', ' ');
163  std::stringstream stream(fed);
164  for (;;) {
166  if (!(stream >> word)) {
167  break;
168  }
169  std::replace(word.begin(), word.end(), '&', ' ');
170  std::stringstream ss(word);
171  int fedNumber;
172  int val;
173  ss >> fedNumber >> val;
174  //std::cout << "fed:: " << fed << "--> val:: " << val << std::endl;
175  //val bit 0 represents the status of the SLINK, but 5 and 7 means the SLINK/TTS is ON but NA or BROKEN (see mail of alex....)
176  if ((val & 0001) == 1 && (val != 5) && (val != 7))
177  pRunInfo->m_fed_in.push_back(fedNumber);
178  }
179  // std::cout << "feds in run:--> ";
180  // std::copy(pRunInfo->m_fed_in.begin(), pRunInfo->m_fed_in.end(), std::ostream_iterator<int>(std::cout, ", "));
181  // std::cout << std::endl;
182  /*
183  for (size_t i =0; i<pRunInfo->m_fed_in.size() ; ++i)
184  {
185  std::cout << "fed in run:--> " << pRunInfo->m_fed_in[i] << std::endl;
186  }
187  */
188 
189  return pRunInfo;
190 }
191 
192 //define this as a plug-in
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
L1RCTOmdsFedVectorProducer::produce
ReturnType produce(const RunInfoRcd &)
Definition: L1RCTOmdsFedVectorProducer.cc:101
ConnectionPool.h
RunSummaryRcd.h
ESHandle.h
LuminosityBlock.h
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
l1RCTOmdsFedVectorProducer_cfi.tableToRead
tableToRead
Definition: l1RCTOmdsFedVectorProducer_cfi.py:6
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
ESProducer.h
l1RCTOmdsFedVectorProducer_cfi.authpath
authpath
Definition: l1RCTOmdsFedVectorProducer_cfi.py:5
cond::persistency::ConnectionPool::createSession
Session createSession(const std::string &connectionString, bool writeCapable=false)
Definition: ConnectionPool.cc:172
convertSQLiteXML.runNumber
runNumber
Definition: convertSQLiteXML.py:91
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
RunInfo
Definition: RunInfo.h:18
cond::persistency::ConnectionPool
Definition: ConnectionPool.h:35
Run.h
edm::ESHandle
Definition: DTSurvey.h:22
L1RCTOmdsFedVectorProducer::authpath
std::string authpath
Definition: L1RCTOmdsFedVectorProducer.cc:65
RunInfoRcd
Definition: RunSummaryRcd.h:26
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1RCTOmdsFedVectorProducer
Definition: L1RCTOmdsFedVectorProducer.cc:53
L1RCTOmdsFedVectorProducer::ReturnType
std::unique_ptr< RunInfo > ReturnType
Definition: L1RCTOmdsFedVectorProducer.cc:58
edm::ParameterSet
Definition: ParameterSet.h:47
cond::persistency::Session
Definition: Session.h:63
L1RCTOmdsFedVectorProducer::L1RCTOmdsFedVectorProducer
L1RCTOmdsFedVectorProducer(const edm::ParameterSet &)
Definition: L1RCTOmdsFedVectorProducer.cc:80
cond::persistency::Session::coralSession
coral::ISessionProxy & coralSession()
Definition: Session.cc:218
L1RCTOmdsFedVectorProducer::connectionString
std::string connectionString
Definition: L1RCTOmdsFedVectorProducer.cc:64
cond::persistency::ConnectionPool::setAuthenticationPath
void setAuthenticationPath(const std::string &p)
Definition: ConnectionPool.cc:35
edmLumisInFiles.summary
summary
Definition: edmLumisInFiles.py:39
L1RCTOmdsFedVectorProducer::tableToRead
std::string tableToRead
Definition: L1RCTOmdsFedVectorProducer.cc:66
cond::persistency::ConnectionPool::configure
void configure()
Definition: ConnectionPool.cc:127
L1RCTOmdsFedVectorProducer::~L1RCTOmdsFedVectorProducer
~L1RCTOmdsFedVectorProducer() override
Definition: L1RCTOmdsFedVectorProducer.cc:91
goodZToMuMu_cfi.condition
condition
Definition: goodZToMuMu_cfi.py:37
cond::persistency::Session::transaction
Transaction & transaction()
Definition: Session.cc:52
cond::persistency::Transaction::start
void start(bool readOnly=true)
Definition: Session.cc:18
RunInfo.h
ModuleFactory.h
heppy_batch.val
val
Definition: heppy_batch.py:351
std
Definition: JetResolutionObject.h:76
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
edm::ESProducer
Definition: ESProducer.h:104
edm::eventsetup::EventSetupRecordImplementation::get
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
Definition: EventSetupRecordImplementation.h:74
l1RCTOmdsFedVectorProducer_cfi.connectionString
connectionString
Definition: l1RCTOmdsFedVectorProducer_cfi.py:4
python.rootplot.root2matplotlib.replace
def replace(string, replacements)
Definition: root2matplotlib.py:444