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",
"."))
24 std::cout <<
"L1RPCHwConfigSourceHandler: L1RPCHwConfigSourceHandler::getNewObjects begins\n";
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();
46 std::cout <<
"L1RPCHwConfigSourceHandler: no validation requested"<<std::endl;
52 std::vector<int>::iterator crIt = m_disableCrates.begin();
53 for (; crIt!=m_disableCrates.end(); ++crIt){
54 disabledDevs->enableCrate(*crIt,
false);
56 std::vector<int>::iterator twIt = m_disableTowers.begin();
57 for (; twIt!=m_disableTowers.end(); ++twIt){
58 disabledDevs->enableTower(*twIt,
false);
61 ConnectOnlineDB(m_connect,m_authpath);
70 if (m_validate==1) difference=Compare2Configs(payload,disabledDevs);
71 if (!difference)
std::cout<<
"No changes - will not write anything!!!"<<std::endl;
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));
77 std::cout <<
"L1RPCHwConfigSourceHandler: L1RPCHwConfigSourceHandler::getNewObjects ends\n";
82 std::cout <<
"L1RPCHwConfigSourceHandler: connecting to " << connect <<
"..." << std::flush;
85 connection->configuration().setAuthenticationPath( authPath ) ;
86 connection->configure();
102 session->transaction().start(
true );
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;
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() ) {
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);
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() ) {
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);
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() ) {
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;
220 for (
int jSegment=0; jSegment<12; jSegment++) {
221 disabledDevs->enablePAC(tower,sector,jSegment,
false);
231 std::cout<<
"Size of new object is : "<<std::flush;
233 std::cout<<
"Size of ref object is : "<<std::flush;
236 if (set1->size() != set2->
size()) {
237 std::cout<<
" Number of disabled devices changed "<<std::endl;
240 for (
int tower=-16; tower<17; tower++) {
241 for (
int sector=0; sector<12; sector++) {
242 for (
int segment=0; segment<12; segment++)
243 if (set1->isActive(tower,sector,segment) != set2->
isActive(tower,sector,segment)) {
244 std::cout<<
" Configuration changed for tower "<<tower<<
", sector "<<sector<<
", segment "<<segment<<std::endl;
edm::Ref< Container > Ref
~L1RPCHwConfigSourceHandler()
int Compare2Configs(Ref set1, L1RPCHwConfig *set2)
bool isActive(int tower, int sector, int segment) const
unsigned long long Time_t
cond::Time_t currentTime() const
void ConnectOnlineDB(std::string connect, std::string authPath)
void DisconnectOnlineDB()
L1RPCHwConfigSourceHandler(const edm::ParameterSet &ps)