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

cond::DbConnectionconnection
 
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::DbSessionsession
 

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 36 of file L1RPCHwConfigSourceHandler.h.

Constructor & Destructor Documentation

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

Definition at line 6 of file L1RPCHwConfigSourceHandler.cc.

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

Definition at line 17 of file L1RPCHwConfigSourceHandler.cc.

18 {
19 }

Member Function Documentation

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

Definition at line 229 of file L1RPCHwConfigSourceHandler.cc.

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

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

Definition at line 80 of file L1RPCHwConfigSourceHandler.cc.

References gather_cfg::cout, and python.CommonUtils::session.

81 {
82  std::cout << "L1RPCHwConfigSourceHandler: connecting to " << connect << "..." << std::flush;
84 // session->configuration().setAuthenticationMethod(cond::XML);
88  session->open(connect,true) ;
89  std::cout << "Done." << std::endl;
90 }
void open(const std::string &connectionString, bool readOnly=false)
Definition: DbSession.cc:159
DbConnectionConfiguration & configuration()
Definition: DbConnection.cc:83
DbSession createSession() const
Definition: DbConnection.cc:66
void setAuthenticationPath(const std::string &p)
tuple cout
Definition: gather_cfg.py:121
void popcon::L1RPCHwConfigSourceHandler::DisconnectOnlineDB ( )

Definition at line 92 of file L1RPCHwConfigSourceHandler.cc.

References python.CommonUtils::session.

93 {
94  connection->close() ;
95  delete connection ;
96  session->close();
97  delete session ;
98 }
void popcon::L1RPCHwConfigSourceHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< L1RPCHwConfig >.

Definition at line 21 of file L1RPCHwConfigSourceHandler.cc.

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

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

Definition at line 100 of file L1RPCHwConfigSourceHandler.cc.

References gather_cfg::cout, first, prof2calltree::last, python.IdGenerator::schema, python.CommonUtils::session, and AlCaHLTBitMon_QueryRunRegistry::string.

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

Member Data Documentation

cond::DbConnection* popcon::L1RPCHwConfigSourceHandler::connection
private

Definition at line 52 of file L1RPCHwConfigSourceHandler.h.

L1RPCHwConfig* popcon::L1RPCHwConfigSourceHandler::disabledDevs
private

Definition at line 50 of file L1RPCHwConfigSourceHandler.h.

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

Definition at line 59 of file L1RPCHwConfigSourceHandler.h.

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

Definition at line 58 of file L1RPCHwConfigSourceHandler.h.

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

Definition at line 56 of file L1RPCHwConfigSourceHandler.h.

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

Definition at line 57 of file L1RPCHwConfigSourceHandler.h.

int popcon::L1RPCHwConfigSourceHandler::m_dummy
private

Definition at line 54 of file L1RPCHwConfigSourceHandler.h.

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

Definition at line 53 of file L1RPCHwConfigSourceHandler.h.

Referenced by id().

int popcon::L1RPCHwConfigSourceHandler::m_validate
private

Definition at line 55 of file L1RPCHwConfigSourceHandler.h.

cond::DbSession* popcon::L1RPCHwConfigSourceHandler::session
private

Definition at line 51 of file L1RPCHwConfigSourceHandler.h.