CMS 3D CMS Logo

L1RPCHwConfigSourceHandler.cc
Go to the documentation of this file.
6 
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 
17 
19  std::cout << "L1RPCHwConfigSourceHandler: L1RPCHwConfigSourceHandler::getNewObjects begins\n";
21 
22  // std::cerr << "------- " << m_name
23  // << " - > getNewObjects" << std::endl;
24  // std::cerr<<"Got offlineInfo, tag: "<<std::endl;
25  // std::cerr << tagInfo().name << " , last object valid from "
26  // << tagInfo().lastInterval.first << " to "
27  // << tagInfo().lastInterval.second << " , token is "
28  // << tagInfo().token << " and this is the payload "
29  // << tagInfo().lastPayloadToken << std::endl;
30 
31  // first check what is already there in offline DB
32  Ref payload;
33 
34  if (m_validate == 1) {
35  std::cout << " Validation was requested, so will check present contents" << std::endl;
36  std::cout << "Name of tag : " << tagInfo().name << ", tag size : " << tagInfo().size << ", last object valid since "
37  << tagInfo().lastInterval.since << std::endl;
38  payload = lastPayload();
39  } else {
40  std::cout << "L1RPCHwConfigSourceHandler: no validation requested" << std::endl;
41  }
42 
43  // now construct new object from online DB
44  disabledDevs = new L1RPCHwConfig();
45  if (m_dummy == 1) {
46  std::vector<int>::iterator crIt = m_disableCrates.begin();
47  for (; crIt != m_disableCrates.end(); ++crIt) {
48  disabledDevs->enableCrate(*crIt, false);
49  }
50  std::vector<int>::iterator twIt = m_disableTowers.begin();
51  for (; twIt != m_disableTowers.end(); ++twIt) {
52  disabledDevs->enableTower(*twIt, false);
53  }
54  } else {
55  ConnectOnlineDB(m_connect, m_authpath);
56  readHwConfig1();
57  DisconnectOnlineDB();
58  }
59 
60  cond::Time_t snc = mydbservice->currentTime();
61 
62  // look for recent changes
63  int difference = 1;
64  if (m_validate == 1)
65  difference = Compare2Configs(payload, disabledDevs);
66  if (!difference)
67  std::cout << "No changes - will not write anything!!!" << std::endl;
68  if (difference == 1) {
69  std::cout << "Will write new object to offline DB!!!" << std::endl;
70  m_to_transfer.push_back(std::make_pair((L1RPCHwConfig*)disabledDevs, snc + 1));
71  }
72 
73  std::cout << "L1RPCHwConfigSourceHandler: L1RPCHwConfigSourceHandler::getNewObjects ends\n";
74 }
75 
77  std::cout << "L1RPCHwConfigSourceHandler: connecting to " << connect << "..." << std::flush;
79  // session->configuration().setAuthenticationMethod(cond::XML);
80  connection.setAuthenticationPath(authPath);
81  connection.configure();
82  session = connection.createSession(connect, true);
83  std::cout << "Done." << std::endl;
84 }
85 
87 
89  session.transaction().start(true);
90  coral::ISchema& schema = session.nominalSchema();
92  coral::AttributeList conditionData;
93  std::cout << std::endl
94  << "L1RPCHwConfigSourceHandler: start to build L1RPC Hw Config..." << std::flush << std::endl
95  << std::endl;
96 
97  // get disabled crates and translate into towers/sectors/segments
98  coral::IQuery* query1 = schema.newQuery();
99  query1->addToTableList("CRATEDISABLED");
100  query1->addToTableList("CRATE");
101  query1->addToTableList("BOARD");
102  query1->addToTableList("TRIGGERBOARD");
103  query1->addToOutputList("TRIGGERBOARD.TOWERTO", "TOWERTO");
104  query1->addToOutputList("TRIGGERBOARD.TOWERFROM", "TOWERFROM");
105  query1->addToOutputList("TRIGGERBOARD.SECTOR", "SECTOR");
106  query1->addToOrderList("TOWERTO");
107  query1->addToOrderList("SECTOR");
108  condition =
109  "CRATE.CRATEID=CRATEDISABLED.CRATE_CRATEID AND BOARD.CRATE_CRATEID=CRATE.CRATEID AND "
110  "BOARD.BOARDID=TRIGGERBOARD.TRIGGERBOARDID AND CRATE.TYPE='TRIGGERCRATE'";
111  query1->setCondition(condition, conditionData);
112  coral::ICursor& cursor1 = query1->execute();
113  while (cursor1.next()) {
114  // cursor1.currentRow().toOutputStream( std::cout ) << std::endl;
115  const coral::AttributeList& row = cursor1.currentRow();
116  int sector = atoi((row["SECTOR"].data<std::string>()).c_str());
117  int first = atoi((row["TOWERTO"].data<std::string>()).c_str());
118  int last = atoi((row["TOWERFROM"].data<std::string>()).c_str());
119  for (int iTower = first; iTower <= last; iTower++) {
120  for (int jSegment = 0; jSegment < 12; jSegment++) {
121  disabledDevs->enablePAC(iTower, sector, jSegment, false);
122  }
123  }
124  }
125  delete query1;
126 
127  // get disabled triggerboards and translate into towers/sectors/segments
128  coral::IQuery* query2 = schema.newQuery();
129  query2->addToTableList("BOARDDISABLED");
130  query2->addToTableList("BOARD");
131  query2->addToTableList("TRIGGERBOARD");
132  query2->addToOutputList("TRIGGERBOARD.TOWERTO", "TOWERTO");
133  query2->addToOutputList("TRIGGERBOARD.TOWERFROM", "TOWERFROM");
134  query2->addToOutputList("TRIGGERBOARD.SECTOR", "SECTOR");
135  query2->addToOrderList("TOWERTO");
136  query2->addToOrderList("SECTOR");
137  condition = "BOARD.BOARDID=BOARDDISABLED.BOARD_BOARDID AND BOARD.BOARDID=TRIGGERBOARD.TRIGGERBOARDID";
138  query2->setCondition(condition, conditionData);
139  coral::ICursor& cursor2 = query2->execute();
140  while (cursor2.next()) {
141  // cursor2.currentRow().toOutputStream( std::cout ) << std::endl;
142  const coral::AttributeList& row = cursor2.currentRow();
143  int sector = atoi((row["SECTOR"].data<std::string>()).c_str());
144  int first = atoi((row["TOWERTO"].data<std::string>()).c_str());
145  int last = atoi((row["TOWERFROM"].data<std::string>()).c_str());
146  for (int iTower = first; iTower <= last; iTower++) {
147  for (int jSegment = 0; jSegment < 12; jSegment++) {
148  disabledDevs->enablePAC(iTower, sector, jSegment, false);
149  }
150  }
151  }
152  delete query2;
153 
154  // get disabled links - this is not usable here
155  /*
156  coral::IQuery* query3 = schema.newQuery();
157  query3->addToTableList( "LINKDISABLED" );
158  query3->addToTableList( "LINKCONN" );
159  query3->addToTableList( "TRIGGERBOARD" );
160  query3->addToOutputList("TRIGGERBOARD.TOWERTO","TOWERTO");
161  query3->addToOutputList("TRIGGERBOARD.TOWERFROM","TOWERFROM");
162  query3->addToOutputList("TRIGGERBOARD.SECTOR","SECTOR");
163  query3->addToOutputList("LINKCONN.TRIGGERBOARDINPUTNUM","TBINPUTNUM");
164  query3->addToOrderList( "TOWERTO" );
165  query3->addToOrderList( "SECTOR" );
166  query3->addToOrderList( "TBINPUTNUM" );
167  condition = "LINKCONN.LINKCONNID=LINKDISABLED.LINK_LINKCONNID AND LINKCONN.TB_TRIGGERBOARDID=TRIGGERBOARD.TRIGGERBOARDID";
168  query3->setCondition( condition, conditionData );
169  coral::ICursor& cursor3 = query3->execute();
170  while ( cursor3.next() ) {
171 // cursor3.currentRow().toOutputStream( std::cout ) << std::endl;
172  const coral::AttributeList& row = cursor3.currentRow();
173  int sector = atoi((row["SECTOR"].data<std::string>()).c_str());
174  int first = atoi((row["TOWERTO"].data<std::string>()).c_str());
175  int last = atoi((row["TOWERFROM"].data<std::string>()).c_str());
176  for (int iTower=first; iTower<=last; iTower++) {
177  for (int jSegment=0; jSegment<12; jSegment++) {
178  disabledDevs->enablePAC(iTower,sector,jSegment,false);
179  }
180  }
181  }
182  delete query3;*/
183 
184  // get disabled chips and translate into towers/sectors
185  // for the moment assume that chip position 8 corresponds to lowest tower number
186  // and so on, ignoring bogus chip at position 11 if given TB operates 3 towers.
187  coral::IQuery* query4 = schema.newQuery();
188  query4->addToTableList("CHIPDISABLED");
189  query4->addToTableList("CHIP");
190  query4->addToTableList("BOARD");
191  query4->addToTableList("TRIGGERBOARD");
192  query4->addToOutputList("TRIGGERBOARD.TOWERTO", "TOWERTO");
193  query4->addToOutputList("TRIGGERBOARD.TOWERFROM", "TOWERFROM");
194  query4->addToOutputList("TRIGGERBOARD.SECTOR", "SECTOR");
195  query4->addToOutputList("CHIP.POSITION", "POSITION");
196  query4->addToOrderList("TOWERTO");
197  query4->addToOrderList("SECTOR");
198  query4->addToOrderList("POSITION");
199  condition =
200  "CHIP.CHIPID=CHIPDISABLED.CHIP_CHIPID AND CHIP.BOARD_BOARDID=BOARD.BOARDID AND "
201  "BOARD.BOARDID=TRIGGERBOARD.TRIGGERBOARDID AND CHIP.TYPE='PAC'";
202  query4->setCondition(condition, conditionData);
203  coral::ICursor& cursor4 = query4->execute();
204  while (cursor4.next()) {
205  // cursor4.currentRow().toOutputStream( std::cout ) << std::endl;
206  const coral::AttributeList& row = cursor4.currentRow();
207  int sector = atoi((row["SECTOR"].data<std::string>()).c_str());
208  int first = atoi((row["TOWERTO"].data<std::string>()).c_str());
209  int last = atoi((row["TOWERFROM"].data<std::string>()).c_str());
210  int chipPos = row["POSITION"].data<short>();
211  int tower = first + chipPos - 8;
212  if (tower <= last) {
213  for (int jSegment = 0; jSegment < 12; jSegment++) {
214  disabledDevs->enablePAC(tower, sector, jSegment, false);
215  }
216  }
217  }
218  delete query4;
219 }
220 
222  const Ref& set1 = _set1;
223  std::cout << "Size of new object is : " << std::flush;
224  std::cout << set2->size() << std::endl;
225  std::cout << "Size of ref object is : " << std::flush;
226  std::cout << set1->size() << std::endl;
227 
228  if (set1->size() != set2->size()) {
229  std::cout << " Number of disabled devices changed " << std::endl;
230  return 1;
231  }
232  for (int tower = -16; tower < 17; tower++) {
233  for (int sector = 0; sector < 12; sector++) {
234  for (int segment = 0; segment < 12; segment++)
235  if (set1->isActive(tower, sector, segment) != set2->isActive(tower, sector, segment)) {
236  std::cout << " Configuration changed for tower " << tower << ", sector " << sector << ", segment " << segment
237  << std::endl;
238  return 1;
239  }
240  }
241  }
242  return 0;
243 }
lumi_dqm_sourceclient-live_cfg.authPath
authPath
Definition: lumi_dqm_sourceclient-live_cfg.py:33
ConnectionPool.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
hgcalTowerProducer_cfi.tower
tower
Definition: hgcalTowerProducer_cfi.py:4
popcon::L1RPCHwConfigSourceHandler::L1RPCHwConfigSourceHandler
L1RPCHwConfigSourceHandler(const edm::ParameterSet &ps)
Definition: L1RPCHwConfigSourceHandler.cc:7
L1RPCHwConfig::isActive
bool isActive(int tower, int sector, int segment) const
Definition: L1RPCHwConfig.h:70
popcon::L1RPCHwConfigSourceHandler::~L1RPCHwConfigSourceHandler
~L1RPCHwConfigSourceHandler() override
Definition: L1RPCHwConfigSourceHandler.cc:16
cond::persistency::ConnectionPool::createSession
Session createSession(const std::string &connectionString, bool writeCapable=false)
Definition: ConnectionPool.cc:172
dqmdumpme.first
first
Definition: dqmdumpme.py:55
popcon::L1RPCHwConfigSourceHandler::readHwConfig1
void readHwConfig1()
Definition: L1RPCHwConfigSourceHandler.cc:88
dqmdumpme.last
last
Definition: dqmdumpme.py:56
PoolDBOutputService.h
Service.h
cond::persistency::ConnectionPool
Definition: ConnectionPool.h:35
jets_cff.payload
payload
Definition: jets_cff.py:32
L1RPCHwConfigSourceHandler.h
popcon::L1RPCHwConfigSourceHandler::ConnectOnlineDB
void ConnectOnlineDB(std::string connect, std::string authPath)
Definition: L1RPCHwConfigSourceHandler.cc:76
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
L1RPCHwConfig
Definition: L1RPCHwConfig.h:65
popcon::L1RPCHwConfigSourceHandler::DisconnectOnlineDB
void DisconnectOnlineDB()
Definition: L1RPCHwConfigSourceHandler.cc:86
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
L1RPCHwConfig::size
int size() const
Definition: L1RPCHwConfig.h:88
edm::Service< cond::service::PoolDBOutputService >
createfilelist.int
int
Definition: createfilelist.py:10
cond::persistency::ConnectionPool::setAuthenticationPath
void setAuthenticationPath(const std::string &p)
Definition: ConnectionPool.cc:35
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
DBConfiguration_cff.connect
connect
Definition: DBConfiguration_cff.py:18
popcon::L1RPCHwConfigSourceHandler::Compare2Configs
int Compare2Configs(const Ref &set1, L1RPCHwConfig *set2)
Definition: L1RPCHwConfigSourceHandler.cc:221
cond::persistency::ConnectionPool::configure
void configure()
Definition: ConnectionPool.cc:127
goodZToMuMu_cfi.condition
condition
Definition: goodZToMuMu_cfi.py:37
popcon::L1RPCHwConfigSourceHandler::getNewObjects
void getNewObjects() override
Definition: L1RPCHwConfigSourceHandler.cc:18
std
Definition: JetResolutionObject.h:76
reco::JetExtendedAssociation::Ref
edm::Ref< Container > Ref
Definition: JetExtendedAssociation.h:32
ParameterSetfwd.h
dumpRecoGeometry_cfg.tagInfo
tagInfo
Definition: dumpRecoGeometry_cfg.py:194
cond::service::PoolDBOutputService::currentTime
cond::Time_t currentTime() const
Definition: PoolDBOutputService.cc:217