CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
L1RCTOmdsFedVectorProducer Class Reference
Inheritance diagram for L1RCTOmdsFedVectorProducer:
edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Types

using ReturnType = std::unique_ptr< RunInfo >
 
- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
 
typedef std::vector< EventSetupRecordKeyKeys
 
typedef std::map< EventSetupRecordKey, KeyedProxiesRecordProxies
 

Public Member Functions

 L1RCTOmdsFedVectorProducer (const edm::ParameterSet &)
 
ReturnType produce (const RunInfoRcd &)
 
 ~L1RCTOmdsFedVectorProducer () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ~ESProducer ()(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval) override
 overrides DataProxyProvider method More...
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () noexcept(false)
 

Private Attributes

std::string authpath
 
std::string connectionString
 
std::string tableToRead
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::ESProducer
 ESProducer (const ESProducer &)=delete
 
ESProducer const & operator= (const ESProducer &)=delete
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
ESConsumesCollector setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList) override
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 55 of file L1RCTOmdsFedVectorProducer.cc.

Member Typedef Documentation

Definition at line 60 of file L1RCTOmdsFedVectorProducer.cc.

Constructor & Destructor Documentation

L1RCTOmdsFedVectorProducer::L1RCTOmdsFedVectorProducer ( const edm::ParameterSet iConfig)

Definition at line 82 of file L1RCTOmdsFedVectorProducer.cc.

References edm::ESProducer::setWhatProduced().

82  :
83  connectionString(iConfig.getParameter<std::string>("connectionString")),
84  authpath(iConfig.getParameter<std::string>("authpath")),
85  tableToRead(iConfig.getParameter<std::string>("tableToRead"))
86 {
87  //the following line is needed to tell the framework what
88  // data is being produced
89  setWhatProduced(this,"OmdsFedVector");
90 
91  //now do what ever other initialization is needed
92 }
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:116
L1RCTOmdsFedVectorProducer::~L1RCTOmdsFedVectorProducer ( )
override

Definition at line 95 of file L1RCTOmdsFedVectorProducer.cc.

96 {
97 
98  // do anything here that needs to be done at desctruction time
99  // (e.g. close files, deallocate resources etc.)
100 
101 }

Member Function Documentation

L1RCTOmdsFedVectorProducer::ReturnType L1RCTOmdsFedVectorProducer::produce ( const RunInfoRcd iRecord)

Definition at line 110 of file L1RCTOmdsFedVectorProducer.cc.

References authpath, connectionString, cond::persistency::Session::coralSession(), DEFINE_FWK_EVENTSETUP_MODULE, edm::eventsetup::EventSetupRecord::get(), RunInfo::m_run, edm::ESHandle< T >::product(), python.rootplot.root2matplotlib::replace(), convertSQLiteXML::runNumber, dataDML::schema, dataDML::session, cond::persistency::ConnectionPool::setAuthenticationPath(), cond::persistency::Transaction::start(), AlCaHLTBitMon_QueryRunRegistry::string, heppy_report::summary, tableToRead, cond::persistency::Session::transaction(), and heppy_batch::val.

111 {
112  // std::cout << "ENTERING L1RCTOmdsFedVectorProducer::produce()" << std::endl;
113 
114  // std::cout << "GETTING FED VECTOR FROM OMDS" << std::endl;
115 
116  // GETTING ALREADY-EXISTING RUNINFO OUT OF ES TO FIND OUT RUN NUMBER
118  iRecord.get(sum);
119  const RunInfo* summary=sum.product();
120  int runNumber = summary->m_run;
121 
122  // CREATING NEW RUNINFO WHICH WILL GET NEW FED VECTOR AND BE RETURNED
123  auto pRunInfo = std::make_unique<RunInfo>();
124 
125 
126  // DO THE DATABASE STUFF
127 
128  //make connection object
130 
131  //set in configuration object authentication path
132  connection.setAuthenticationPath(authpath);
133  connection.configure();
134 
135  //create session object from connection
136  cond::persistency::Session session = connection.createSession(connectionString,true );
137 
138  session.transaction().start(true); // (true=readOnly)
139 
140  coral::ISchema& schema = session.coralSession().schema("CMS_RUNINFO");
141 
142  //condition
143  coral::AttributeList conditionData;
144  conditionData.extend<int>( "n_run" );
145  conditionData[0].data<int>() = runNumber;
146 
147  std::string columnToRead_val = "VALUE";
148 
149  std::string tableToRead_fed = "RUNSESSION_STRING";
150  coral::IQuery* queryV = schema.newQuery();
151  queryV->addToTableList(tableToRead);
152  queryV->addToTableList(tableToRead_fed);
153  queryV->addToOutputList(tableToRead_fed + "." + columnToRead_val, columnToRead_val);
154  //queryV->addToOutputList(tableToRead + "." + columnToRead, columnToRead);
155  //condition
156  std::string condition = tableToRead + ".RUNNUMBER=:n_run AND " + tableToRead + ".NAME='CMS.LVL0:FED_ENABLE_MASK' AND RUNSESSION_PARAMETER.ID = RUNSESSION_STRING.RUNSESSION_PARAMETER_ID";
157  //std::string condition = tableToRead + ".runnumber=:n_run AND " + tableToRead + ".name='CMS.LVL0:FED_ENABLE_MASK'";
158  queryV->setCondition(condition, conditionData);
159  coral::ICursor& cursorV = queryV->execute();
160  std::string fed;
161  if ( cursorV.next() ) {
162  //cursorV.currentRow().toOutputStream(std::cout) << std::endl;
163  const coral::AttributeList& row = cursorV.currentRow();
164  fed = row[columnToRead_val].data<std::string>();
165  }
166  else {
167  fed="null";
168  }
169  //std::cout << "string fed emask == " << fed << std::endl;
170  delete queryV;
171 
172  std::replace(fed.begin(), fed.end(), '%', ' ');
173  std::stringstream stream(fed);
174  for(;;)
175  {
176  std::string word;
177  if ( !(stream >> word) ){break;}
178  std::replace(word.begin(), word.end(), '&', ' ');
179  std::stringstream ss(word);
180  int fedNumber;
181  int val;
182  ss >> fedNumber >> val;
183  //std::cout << "fed:: " << fed << "--> val:: " << val << std::endl;
184  //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....)
185  if( (val & 0001) == 1 && (val != 5) && (val != 7) )
186  pRunInfo->m_fed_in.push_back(fedNumber);
187  }
188  // std::cout << "feds in run:--> ";
189  // std::copy(pRunInfo->m_fed_in.begin(), pRunInfo->m_fed_in.end(), std::ostream_iterator<int>(std::cout, ", "));
190  // std::cout << std::endl;
191  /*
192  for (size_t i =0; i<pRunInfo->m_fed_in.size() ; ++i)
193  {
194  std::cout << "fed in run:--> " << pRunInfo->m_fed_in[i] << std::endl;
195  }
196  */
197 
198  return pRunInfo ;
199 }
void start(bool readOnly=true)
Definition: Session.cc:22
def replace(string, replacements)
Transaction & transaction()
Definition: Session.cc:66
coral::ISessionProxy & coralSession()
Definition: Session.cc:228
int m_run
Definition: RunInfo.h:21
void setAuthenticationPath(const std::string &p)
T const * product() const
Definition: ESHandle.h:84
bool get(HolderT &iHolder) const

Member Data Documentation

std::string L1RCTOmdsFedVectorProducer::authpath
private

Definition at line 66 of file L1RCTOmdsFedVectorProducer.cc.

Referenced by produce().

std::string L1RCTOmdsFedVectorProducer::connectionString
private

Definition at line 65 of file L1RCTOmdsFedVectorProducer.cc.

Referenced by produce().

std::string L1RCTOmdsFedVectorProducer::tableToRead
private

Definition at line 67 of file L1RCTOmdsFedVectorProducer.cc.

Referenced by produce().