CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
popcon::L1RPCHwConfigSourceHandler Class Reference

#include <L1RPCHwConfigSourceHandler.h>

Inheritance diagram for popcon::L1RPCHwConfigSourceHandler:
popcon::PopConSourceHandler< L1RPCHwConfig >

Public Member Functions

int Compare2Configs (const Ref &set1, L1RPCHwConfig *set2)
 
void ConnectOnlineDB (std::string connect, std::string authPath)
 
void DisconnectOnlineDB ()
 
void getNewObjects ()
 
std::string id () const
 
 L1RPCHwConfigSourceHandler (const edm::ParameterSet &ps)
 
void readHwConfig1 ()
 
 ~L1RPCHwConfigSourceHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< L1RPCHwConfig >
void convertFromOld ()
 
SummarydummySummary (typename OldContainer::value_type const &) const
 
void initialize (const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry_t const & logDBEntry () const
 
std::pair< Container const
*, std::string const > 
operator() (const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry) const
 
 PopConSourceHandler ()
 
Container const & returnData ()
 
void sort ()
 
cond::TagInfo_t const & tagInfo () const
 
std::string const & userTextLog () const
 
virtual ~PopConSourceHandler ()
 

Private Attributes

L1RPCHwConfigdisabledDevs
 
std::string m_authpath
 
std::string m_connect
 
std::vector< int > m_disableCrates
 
std::vector< int > m_disableTowers
 
int m_dummy
 
std::string m_name
 
int m_validate
 
cond::persistency::Session session
 

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< L1RPCHwConfig >
typedef std::vector< TripletContainer
 
typedef std::vector< std::pair
< L1RPCHwConfig
*, cond::Time_t > > 
OldContainer
 
typedef PopConSourceHandler
< L1RPCHwConfig
self
 
typedef cond::Summary Summary
 
typedef cond::Time_t Time_t
 
typedef L1RPCHwConfig value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< L1RPCHwConfig >
int add (value_type *payload, Summary *summary, Time_t time)
 
- Protected Attributes inherited from popcon::PopConSourceHandler< L1RPCHwConfig >
OldContainer m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 34 of file L1RPCHwConfigSourceHandler.h.

Constructor & Destructor Documentation

popcon::L1RPCHwConfigSourceHandler::L1RPCHwConfigSourceHandler ( const edm::ParameterSet ps)

Definition at line 7 of file L1RPCHwConfigSourceHandler.cc.

7  :
8  m_name(ps.getUntrackedParameter<std::string>("name","L1RPCHwConfigSourceHandler")),
9  m_dummy(ps.getUntrackedParameter<int>("WriteDummy",0)),
10  m_validate(ps.getUntrackedParameter<int>("Validate",0)),
11  m_disableCrates(ps.getUntrackedParameter<std::vector<int> >("DisabledCrates")),
12  m_disableTowers(ps.getUntrackedParameter<std::vector<int> >("DisabledTowers")),
13  m_connect(ps.getUntrackedParameter<std::string>("OnlineConn","")),
14  m_authpath(ps.getUntrackedParameter<std::string>("OnlineAuthPath","."))
15 {
16 }
T getUntrackedParameter(std::string const &, T const &) const
popcon::L1RPCHwConfigSourceHandler::~L1RPCHwConfigSourceHandler ( )

Definition at line 18 of file L1RPCHwConfigSourceHandler.cc.

19 {
20 }

Member Function Documentation

int popcon::L1RPCHwConfigSourceHandler::Compare2Configs ( const Ref &  set1,
L1RPCHwConfig set2 
)

Definition at line 226 of file L1RPCHwConfigSourceHandler.cc.

References gather_cfg::cout, L1RPCHwConfig::isActive(), and L1RPCHwConfig::size().

227 {
228  Ref set1 = _set1;
229  std::cout<<"Size of new object is : "<<std::flush;
230  std::cout<<set2->size()<<std::endl;
231  std::cout<<"Size of ref object is : "<<std::flush;
232  std::cout<<set1->size()<<std::endl;
233 
234  if (set1->size() != set2->size()) {
235  std::cout<<" Number of disabled devices changed "<<std::endl;
236  return 1;
237  }
238  for (int tower=-16; tower<17; tower++) {
239  for (int sector=0; sector<12; sector++) {
240  for (int segment=0; segment<12; segment++)
241  if (set1->isActive(tower,sector,segment) != set2->isActive(tower,sector,segment)) {
242  std::cout<<" Configuration changed for tower "<<tower<<", sector "<<sector<<", segment "<<segment<<std::endl;
243  return 1;
244  }
245  }
246  }
247  return 0;
248 }
bool isActive(int tower, int sector, int segment) const
Definition: L1RPCHwConfig.h:79
int size() const
Definition: L1RPCHwConfig.h:99
tuple cout
Definition: gather_cfg.py:145
void popcon::L1RPCHwConfigSourceHandler::ConnectOnlineDB ( std::string  connect,
std::string  authPath 
)

Definition at line 81 of file L1RPCHwConfigSourceHandler.cc.

References cond::persistency::ConnectionPool::configure(), gather_cfg::cout, cond::persistency::ConnectionPool::createSession(), models::session, and cond::persistency::ConnectionPool::setAuthenticationPath().

82 {
83  std::cout << "L1RPCHwConfigSourceHandler: connecting to " << connect << "..." << std::flush;
85 // session->configuration().setAuthenticationMethod(cond::XML);
86  connection.setAuthenticationPath( authPath ) ;
87  connection.configure();
88  session = connection.createSession( connect,true );
89  std::cout << "Done." << std::endl;
90 }
Session createSession(const std::string &connectionString, bool writeCapable=false)
tuple cout
Definition: gather_cfg.py:145
void setAuthenticationPath(const std::string &p)
void popcon::L1RPCHwConfigSourceHandler::DisconnectOnlineDB ( )

Definition at line 92 of file L1RPCHwConfigSourceHandler.cc.

References models::session.

93 {
94  session.close();
95 }
void popcon::L1RPCHwConfigSourceHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< L1RPCHwConfig >.

Definition at line 22 of file L1RPCHwConfigSourceHandler.cc.

References gather_cfg::cout, cond::service::PoolDBOutputService::currentTime(), and dumpRecoGeometry_cfg::tagInfo.

23 {
24 
25  std::cout << "L1RPCHwConfigSourceHandler: L1RPCHwConfigSourceHandler::getNewObjects begins\n";
27 
28 // std::cerr << "------- " << m_name
29 // << " - > getNewObjects" << std::endl;
30 // std::cerr<<"Got offlineInfo, tag: "<<std::endl;
31 // std::cerr << tagInfo().name << " , last object valid from "
32 // << tagInfo().lastInterval.first << " to "
33 // << tagInfo().lastInterval.second << " , token is "
34 // << tagInfo().token << " and this is the payload "
35 // << tagInfo().lastPayloadToken << std::endl;
36 
37 // first check what is already there in offline DB
38  Ref payload;
39 
40  if(m_validate==1) {
41  std::cout<<" Validation was requested, so will check present contents"<<std::endl;
42  std::cout<<"Name of tag : "<<tagInfo().name << ", tag size : " << tagInfo().size
43  << ", last object valid since "
44  << tagInfo().lastInterval.first << std::endl;
45  payload = lastPayload();
46  } else {
47  std::cout << "L1RPCHwConfigSourceHandler: no validation requested"<<std::endl;
48  }
49 
50 // now construct new object from online DB
52  if (m_dummy==1) {
53  std::vector<int>::iterator crIt = m_disableCrates.begin();
54  for (; crIt!=m_disableCrates.end(); ++crIt){
55  disabledDevs->enableCrate(*crIt,false);
56  }
57  std::vector<int>::iterator twIt = m_disableTowers.begin();
58  for (; twIt!=m_disableTowers.end(); ++twIt){
59  disabledDevs->enableTower(*twIt,false);
60  }
61  } else {
63  readHwConfig1();
65  }
66 
67  cond::Time_t snc=mydbservice->currentTime();
68 
69 // look for recent changes
70  int difference=1;
71  if (m_validate==1) difference=Compare2Configs(payload,disabledDevs);
72  if (!difference) std::cout<<"No changes - will not write anything!!!"<<std::endl;
73  if (difference==1) {
74  std::cout<<"Will write new object to offline DB!!!"<<std::endl;
75  m_to_transfer.push_back(std::make_pair((L1RPCHwConfig*)disabledDevs,snc+1));
76  }
77 
78  std::cout << "L1RPCHwConfigSourceHandler: L1RPCHwConfigSourceHandler::getNewObjects ends\n";
79 }
void enableTower(int tower, bool enable)
void enableCrate(int logSector, bool enable)
size_t size
Definition: Types.h:75
int Compare2Configs(const Ref &set1, L1RPCHwConfig *set2)
std::string name
Definition: Types.h:71
cond::ValidityInterval lastInterval
Definition: Types.h:73
unsigned long long Time_t
Definition: Time.h:16
void ConnectOnlineDB(std::string connect, std::string authPath)
tuple cout
Definition: gather_cfg.py:145
std::string popcon::L1RPCHwConfigSourceHandler::id ( ) const
inlinevirtual
void popcon::L1RPCHwConfigSourceHandler::readHwConfig1 ( )

Definition at line 97 of file L1RPCHwConfigSourceHandler.cc.

References gather_cfg::cout, plotBeamSpotDB::first, plotBeamSpotDB::last, dataDML::schema, models::session, and AlCaHLTBitMon_QueryRunRegistry::string.

98 {
99  session.transaction().start( true );
100  coral::ISchema& schema = session.nominalSchema();
101  std::string condition="";
102  coral::AttributeList conditionData;
103  std::cout << std::endl <<"L1RPCHwConfigSourceHandler: start to build L1RPC Hw Config..." << std::flush << std::endl << std::endl;
104 
105 // get disabled crates and translate into towers/sectors/segments
106  coral::IQuery* query1 = schema.newQuery();
107  query1->addToTableList( "CRATEDISABLED" );
108  query1->addToTableList( "CRATE" );
109  query1->addToTableList( "BOARD" );
110  query1->addToTableList( "TRIGGERBOARD" );
111  query1->addToOutputList("TRIGGERBOARD.TOWERTO","TOWERTO");
112  query1->addToOutputList("TRIGGERBOARD.TOWERFROM","TOWERFROM");
113  query1->addToOutputList("TRIGGERBOARD.SECTOR","SECTOR");
114  query1->addToOrderList( "TOWERTO" );
115  query1->addToOrderList( "SECTOR" );
116  condition = "CRATE.CRATEID=CRATEDISABLED.CRATE_CRATEID AND BOARD.CRATE_CRATEID=CRATE.CRATEID AND BOARD.BOARDID=TRIGGERBOARD.TRIGGERBOARDID AND CRATE.TYPE='TRIGGERCRATE'";
117  query1->setCondition( condition, conditionData );
118  coral::ICursor& cursor1 = query1->execute();
119  while ( cursor1.next() ) {
120 // cursor1.currentRow().toOutputStream( std::cout ) << std::endl;
121  const coral::AttributeList& row = cursor1.currentRow();
122  int sector = atoi((row["SECTOR"].data<std::string>()).c_str());
123  int first = atoi((row["TOWERTO"].data<std::string>()).c_str());
124  int last = atoi((row["TOWERFROM"].data<std::string>()).c_str());
125  for (int iTower=first; iTower<=last; iTower++) {
126  for (int jSegment=0; jSegment<12; jSegment++) {
127  disabledDevs->enablePAC(iTower,sector,jSegment,false);
128  }
129  }
130  }
131  delete query1;
132 
133 // get disabled triggerboards and translate into towers/sectors/segments
134  coral::IQuery* query2 = schema.newQuery();
135  query2->addToTableList( "BOARDDISABLED" );
136  query2->addToTableList( "BOARD" );
137  query2->addToTableList( "TRIGGERBOARD" );
138  query2->addToOutputList("TRIGGERBOARD.TOWERTO","TOWERTO");
139  query2->addToOutputList("TRIGGERBOARD.TOWERFROM","TOWERFROM");
140  query2->addToOutputList("TRIGGERBOARD.SECTOR","SECTOR");
141  query2->addToOrderList( "TOWERTO" );
142  query2->addToOrderList( "SECTOR" );
143  condition = "BOARD.BOARDID=BOARDDISABLED.BOARD_BOARDID AND BOARD.BOARDID=TRIGGERBOARD.TRIGGERBOARDID";
144  query2->setCondition( condition, conditionData );
145  coral::ICursor& cursor2 = query2->execute();
146  while ( cursor2.next() ) {
147 // cursor2.currentRow().toOutputStream( std::cout ) << std::endl;
148  const coral::AttributeList& row = cursor2.currentRow();
149  int sector = atoi((row["SECTOR"].data<std::string>()).c_str());
150  int first = atoi((row["TOWERTO"].data<std::string>()).c_str());
151  int last = atoi((row["TOWERFROM"].data<std::string>()).c_str());
152  for (int iTower=first; iTower<=last; iTower++) {
153  for (int jSegment=0; jSegment<12; jSegment++) {
154  disabledDevs->enablePAC(iTower,sector,jSegment,false);
155  }
156  }
157  }
158  delete query2;
159 
160 // get disabled links - this is not usable here
161 /*
162  coral::IQuery* query3 = schema.newQuery();
163  query3->addToTableList( "LINKDISABLED" );
164  query3->addToTableList( "LINKCONN" );
165  query3->addToTableList( "TRIGGERBOARD" );
166  query3->addToOutputList("TRIGGERBOARD.TOWERTO","TOWERTO");
167  query3->addToOutputList("TRIGGERBOARD.TOWERFROM","TOWERFROM");
168  query3->addToOutputList("TRIGGERBOARD.SECTOR","SECTOR");
169  query3->addToOutputList("LINKCONN.TRIGGERBOARDINPUTNUM","TBINPUTNUM");
170  query3->addToOrderList( "TOWERTO" );
171  query3->addToOrderList( "SECTOR" );
172  query3->addToOrderList( "TBINPUTNUM" );
173  condition = "LINKCONN.LINKCONNID=LINKDISABLED.LINK_LINKCONNID AND LINKCONN.TB_TRIGGERBOARDID=TRIGGERBOARD.TRIGGERBOARDID";
174  query3->setCondition( condition, conditionData );
175  coral::ICursor& cursor3 = query3->execute();
176  while ( cursor3.next() ) {
177 // cursor3.currentRow().toOutputStream( std::cout ) << std::endl;
178  const coral::AttributeList& row = cursor3.currentRow();
179  int sector = atoi((row["SECTOR"].data<std::string>()).c_str());
180  int first = atoi((row["TOWERTO"].data<std::string>()).c_str());
181  int last = atoi((row["TOWERFROM"].data<std::string>()).c_str());
182  for (int iTower=first; iTower<=last; iTower++) {
183  for (int jSegment=0; jSegment<12; jSegment++) {
184  disabledDevs->enablePAC(iTower,sector,jSegment,false);
185  }
186  }
187  }
188  delete query3;*/
189 
190 // get disabled chips and translate into towers/sectors
191 // for the moment assume that chip position 8 corresponds to lowest tower number
192 // and so on, ignoring bogus chip at position 11 if given TB operates 3 towers.
193  coral::IQuery* query4 = schema.newQuery();
194  query4->addToTableList( "CHIPDISABLED" );
195  query4->addToTableList( "CHIP" );
196  query4->addToTableList( "BOARD" );
197  query4->addToTableList( "TRIGGERBOARD" );
198  query4->addToOutputList("TRIGGERBOARD.TOWERTO","TOWERTO");
199  query4->addToOutputList("TRIGGERBOARD.TOWERFROM","TOWERFROM");
200  query4->addToOutputList("TRIGGERBOARD.SECTOR","SECTOR");
201  query4->addToOutputList("CHIP.POSITION","POSITION");
202  query4->addToOrderList( "TOWERTO" );
203  query4->addToOrderList( "SECTOR" );
204  query4->addToOrderList( "POSITION" );
205  condition = "CHIP.CHIPID=CHIPDISABLED.CHIP_CHIPID AND CHIP.BOARD_BOARDID=BOARD.BOARDID AND BOARD.BOARDID=TRIGGERBOARD.TRIGGERBOARDID AND CHIP.TYPE='PAC'";
206  query4->setCondition( condition, conditionData );
207  coral::ICursor& cursor4 = query4->execute();
208  while ( cursor4.next() ) {
209 // cursor4.currentRow().toOutputStream( std::cout ) << std::endl;
210  const coral::AttributeList& row = cursor4.currentRow();
211  int sector = atoi((row["SECTOR"].data<std::string>()).c_str());
212  int first = atoi((row["TOWERTO"].data<std::string>()).c_str());
213  int last = atoi((row["TOWERFROM"].data<std::string>()).c_str());
214  int chipPos=row["POSITION"].data<short>();
215  int tower=first+chipPos-8;
216  if (tower<=last) {
217  for (int jSegment=0; jSegment<12; jSegment++) {
218  disabledDevs->enablePAC(tower,sector,jSegment,false);
219  }
220  }
221  }
222  delete query4;
223 
224 }
tuple schema
Definition: dataDML.py:2334
void start(bool readOnly=true)
Definition: Session.cc:22
Transaction & transaction()
Definition: Session.cc:66
coral::ISchema & nominalSchema()
Definition: Session.cc:212
void enablePAC(int tower, int sector, int segment, bool enable)
tuple cout
Definition: gather_cfg.py:145

Member Data Documentation

L1RPCHwConfig* popcon::L1RPCHwConfigSourceHandler::disabledDevs
private

Definition at line 48 of file L1RPCHwConfigSourceHandler.h.

std::string popcon::L1RPCHwConfigSourceHandler::m_authpath
private

Definition at line 56 of file L1RPCHwConfigSourceHandler.h.

std::string popcon::L1RPCHwConfigSourceHandler::m_connect
private

Definition at line 55 of file L1RPCHwConfigSourceHandler.h.

std::vector<int> popcon::L1RPCHwConfigSourceHandler::m_disableCrates
private

Definition at line 53 of file L1RPCHwConfigSourceHandler.h.

std::vector<int> popcon::L1RPCHwConfigSourceHandler::m_disableTowers
private

Definition at line 54 of file L1RPCHwConfigSourceHandler.h.

int popcon::L1RPCHwConfigSourceHandler::m_dummy
private

Definition at line 51 of file L1RPCHwConfigSourceHandler.h.

std::string popcon::L1RPCHwConfigSourceHandler::m_name
private

Definition at line 50 of file L1RPCHwConfigSourceHandler.h.

Referenced by id().

int popcon::L1RPCHwConfigSourceHandler::m_validate
private

Definition at line 52 of file L1RPCHwConfigSourceHandler.h.

cond::persistency::Session popcon::L1RPCHwConfigSourceHandler::session
private

Definition at line 49 of file L1RPCHwConfigSourceHandler.h.