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",
"."))
25 std::cout <<
"L1RPCHwConfigSourceHandler: L1RPCHwConfigSourceHandler::getNewObjects begins\n";
41 std::cout<<
" Validation was requested, so will check present contents"<<std::endl;
43 <<
", last object valid since " 47 std::cout <<
"L1RPCHwConfigSourceHandler: no validation requested"<<std::endl;
72 if (!difference)
std::cout<<
"No changes - will not write anything!!!"<<std::endl;
74 std::cout<<
"Will write new object to offline DB!!!"<<std::endl;
78 std::cout <<
"L1RPCHwConfigSourceHandler: L1RPCHwConfigSourceHandler::getNewObjects ends\n";
83 std::cout <<
"L1RPCHwConfigSourceHandler: connecting to " << connect <<
"..." << std::flush;
102 coral::AttributeList conditionData;
103 std::cout << std::endl <<
"L1RPCHwConfigSourceHandler: start to build L1RPC Hw Config..." << std::flush << std::endl << std::endl;
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() ) {
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++) {
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() ) {
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++) {
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() ) {
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;
217 for (
int jSegment=0; jSegment<12; jSegment++) {
228 const Ref& set1 = _set1;
229 std::cout<<
"Size of new object is : "<<std::flush;
231 std::cout<<
"Size of ref object is : "<<std::flush;
234 if (set1->size() != set2->
size()) {
235 std::cout<<
" Number of disabled devices changed "<<std::endl;
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;
void enableTower(int tower, bool enable)
edm::Ref< Container > Ref
void enableCrate(int logSector, bool enable)
void getNewObjects() override
void start(bool readOnly=true)
~L1RPCHwConfigSourceHandler() override
Transaction & transaction()
int Compare2Configs(const Ref &set1, L1RPCHwConfig *set2)
OldContainer m_to_transfer
std::vector< int > m_disableCrates
cond::ValidityInterval lastInterval
std::vector< int > m_disableTowers
bool isActive(int tower, int sector, int segment) const
unsigned long long Time_t
L1RPCHwConfig * disabledDevs
coral::ISchema & nominalSchema()
Session createSession(const std::string &connectionString, bool writeCapable=false)
void enablePAC(int tower, int sector, int segment, bool enable)
cond::persistency::Session session
cond::Time_t currentTime() const
void ConnectOnlineDB(std::string connect, std::string authPath)
void DisconnectOnlineDB()
void setAuthenticationPath(const std::string &p)
L1RPCHwConfigSourceHandler(const edm::ParameterSet &ps)
cond::TagInfo_t const & tagInfo() const