43 << boost::posix_time::to_iso_extended_string(
45 <<
" ); from " <<
m_name <<
"::getNewObjects";
52 << *previousFill <<
"from " <<
m_name <<
"::getNewObjects";
53 if (m_firstFill <= previousFill->fillNumber()) {
56 std::ostringstream es;
57 es <<
"Trying to insert fill number " <<
m_firstFill 58 << ((
m_firstFill < previousFill->fillNumber()) ?
", which is an older fill than " 59 :
", which is the same fill as ")
60 <<
"the last one in the destination tag " << previousFill->fillNumber()
61 <<
": the first fill to be looked for will become " << previousFill->fillNumber() + 1;
62 edm::LogWarning(m_name) << es.str() <<
"; from " << m_name <<
"::getNewObjects";
71 <<
" cannot be larger than the last one " <<
m_lastFill <<
" EXITING. from " << m_name
89 coral::ISchema &runTimeLoggerSchema = session.
nominalSchema();
93 std::unique_ptr<coral::IQuery> fillDataQuery(runTimeLoggerSchema.newQuery());
95 fillDataQuery->addToTableList(
std::string(
"RUNTIME_SUMMARY"));
97 fillDataQuery->addToOutputList(
std::string(
"LHCFILL"));
98 fillDataQuery->addToOutputList(
std::string(
"NBUNCHESBEAM1"));
99 fillDataQuery->addToOutputList(
std::string(
"NBUNCHESBEAM2"));
100 fillDataQuery->addToOutputList(
std::string(
"NCOLLIDINGBUNCHES"));
101 fillDataQuery->addToOutputList(
std::string(
"NTARGETBUNCHES"));
102 fillDataQuery->addToOutputList(
std::string(
"RUNTIME_TYPE_ID"));
103 fillDataQuery->addToOutputList(
std::string(
"PARTY1"));
104 fillDataQuery->addToOutputList(
std::string(
"PARTY2"));
105 fillDataQuery->addToOutputList(
std::string(
"CROSSINGANGLE"));
106 fillDataQuery->addToOutputList(
std::string(
"BETASTAR"));
107 fillDataQuery->addToOutputList(
std::string(
"INTENSITYBEAM1"));
108 fillDataQuery->addToOutputList(
std::string(
"INTENSITYBEAM2"));
109 fillDataQuery->addToOutputList(
std::string(
"ENERGY"));
110 fillDataQuery->addToOutputList(
std::string(
"CREATETIME"));
111 fillDataQuery->addToOutputList(
std::string(
"BEGINTIME"));
112 fillDataQuery->addToOutputList(
std::string(
"ENDTIME"));
113 fillDataQuery->addToOutputList(
std::string(
"INJECTIONSCHEME"));
115 coral::AttributeList fillDataBindVariables;
116 fillDataBindVariables.extend(
std::string(
"firstFillNumber"),
typeid(
unsigned short));
118 fillDataBindVariables.extend(
std::string(
"lastFillNumber"),
typeid(
unsigned short));
122 std::string conditionStr(
"BEGINTIME IS NOT NULL AND LHCFILL BETWEEN :firstFillNumber AND :lastFillNumber");
123 fillDataQuery->setCondition(conditionStr, fillDataBindVariables);
125 fillDataQuery->addToOrderList(
std::string(
"LHCFILL"));
127 coral::AttributeList fillDataOutput;
128 fillDataOutput.extend<
unsigned short>(
std::string(
"LHCFILL"));
129 fillDataOutput.extend<
unsigned short>(
std::string(
"NBUNCHESBEAM1"));
130 fillDataOutput.extend<
unsigned short>(
std::string(
"NBUNCHESBEAM2"));
131 fillDataOutput.extend<
unsigned short>(
std::string(
"NCOLLIDINGBUNCHES"));
132 fillDataOutput.extend<
unsigned short>(
std::string(
"NTARGETBUNCHES"));
133 fillDataOutput.extend<
int>(
std::string(
"RUNTIME_TYPE_ID"));
136 fillDataOutput.extend<
float>(
std::string(
"CROSSINGANGLE"));
137 fillDataOutput.extend<
float>(
std::string(
"BETASTAR"));
138 fillDataOutput.extend<
float>(
std::string(
"INTENSITYBEAM1"));
139 fillDataOutput.extend<
float>(
std::string(
"INTENSITYBEAM2"));
140 fillDataOutput.extend<
float>(
std::string(
"ENERGY"));
141 fillDataOutput.extend<coral::TimeStamp>(
std::string(
"CREATETIME"));
142 fillDataOutput.extend<coral::TimeStamp>(
std::string(
"BEGINTIME"));
143 fillDataOutput.extend<coral::TimeStamp>(
std::string(
"ENDTIME"));
145 fillDataQuery->defineOutput(fillDataOutput);
147 coral::ICursor &fillDataCursor = fillDataQuery->execute();
149 unsigned short previousFillNumber = 1, currentFill =
m_firstFill;
150 cond::Time_t previousFillEndTime = 0ULL, afterPreviousFillEndTime = 0ULL, beforeStableBeamStartTime = 0ULL;
152 previousFillNumber = previousFill->fillNumber();
153 previousFillEndTime = previousFill->endTime();
155 unsigned short bunches1 = 0, bunches2 = 0, collidingBunches = 0, targetBunches = 0;
158 float crossingAngle = 0., betastar = 0., intensityBeam1 = 0., intensityBeam2 = 0.,
energy = 0.;
159 coral::TimeStamp stableBeamStartTimeStamp, beamDumpTimeStamp;
160 cond::Time_t creationTime = 0ULL, stableBeamStartTime = 0ULL, beamDumpTime = 0ULL;
162 std::ostringstream
ss;
164 while (fillDataCursor.next()) {
166 std::ostringstream qs;
167 fillDataCursor.currentRow().toOutputStream(qs);
168 edm::LogInfo(m_name) << qs.str() <<
"\nfrom " << m_name <<
"::getNewObjects";
170 currentFill = fillDataCursor.currentRow()[
std::string(
"LHCFILL")].data<
unsigned short>();
171 coral::Attribute
const &bunches1Attribute = fillDataCursor.currentRow()[
std::string(
"NBUNCHESBEAM1")];
172 if (bunches1Attribute.isNull()) {
175 bunches1 = bunches1Attribute.data<
unsigned short>();
177 coral::Attribute
const &bunches2Attribute = fillDataCursor.currentRow()[
std::string(
"NBUNCHESBEAM2")];
178 if (bunches2Attribute.isNull()) {
181 bunches2 = bunches2Attribute.data<
unsigned short>();
183 coral::Attribute
const &collidingBunchesAttribute = fillDataCursor.currentRow()[
std::string(
"NCOLLIDINGBUNCHES")];
184 if (collidingBunchesAttribute.isNull()) {
185 collidingBunches = 0;
187 collidingBunches = collidingBunchesAttribute.data<
unsigned short>();
189 coral::Attribute
const &targetBunchesAttribute = fillDataCursor.currentRow()[
std::string(
"NTARGETBUNCHES")];
190 if (targetBunchesAttribute.isNull()) {
193 targetBunches = targetBunchesAttribute.data<
unsigned short>();
198 coral::Attribute
const &particleType1Attribute = fillDataCursor.currentRow()[
std::string(
"PARTY1")];
199 if (particleType1Attribute.isNull()) {
204 coral::Attribute
const &particleType2Attribute = fillDataCursor.currentRow()[
std::string(
"PARTY2")];
205 if (particleType2Attribute.isNull()) {
210 coral::Attribute
const &crossingAngleAttribute = fillDataCursor.currentRow()[
std::string(
"CROSSINGANGLE")];
211 if (crossingAngleAttribute.isNull()) {
214 crossingAngle = crossingAngleAttribute.data<
float>();
216 coral::Attribute
const &betastarAttribute = fillDataCursor.currentRow()[
std::string(
"BETASTAR")];
217 if (betastarAttribute.isNull()) {
220 betastar = betastarAttribute.data<
float>();
222 coral::Attribute
const &intensityBeam1Attribute = fillDataCursor.currentRow()[
std::string(
"INTENSITYBEAM1")];
223 if (intensityBeam1Attribute.isNull()) {
226 intensityBeam1 = intensityBeam1Attribute.data<
float>();
228 coral::Attribute
const &intensityBeam2Attribute = fillDataCursor.currentRow()[
std::string(
"INTENSITYBEAM2")];
229 if (intensityBeam2Attribute.isNull()) {
232 intensityBeam2 = intensityBeam2Attribute.data<
float>();
234 coral::Attribute
const &energyAttribute = fillDataCursor.currentRow()[
std::string(
"ENERGY")];
235 if (energyAttribute.isNull()) {
238 energy = energyAttribute.data<
float>();
244 stableBeamStartTimeStamp = fillDataCursor.currentRow()[
std::string(
"BEGINTIME")].data<coral::TimeStamp>();
246 coral::Attribute
const &beamDumpTimeAttribute = fillDataCursor.currentRow()[
std::string(
"ENDTIME")];
247 if (beamDumpTimeAttribute.isNull()) {
250 beamDumpTimeStamp = beamDumpTimeAttribute.data<coral::TimeStamp>();
253 coral::Attribute
const &injectionSchemeAttribute = fillDataCursor.currentRow()[
std::string(
"INJECTIONSCHEME")];
254 if (injectionSchemeAttribute.isNull()) {
257 injectionScheme = injectionSchemeAttribute.data<
std::string>();
277 if (beamDumpTime == 0) {
278 edm::LogWarning(m_name) <<
"NO TRANSFER NEEDED: the fill number " << currentFill <<
" is still ongoing" 279 <<
"; from " << m_name <<
"::getNewObjects";
287 coral::AttributeList bunchConfBindVariables;
288 bunchConfBindVariables.extend<coral::TimeStamp>(
std::string(
"stableBeamStartTimeStamp"));
289 bunchConfBindVariables[
std::string(
"stableBeamStartTimeStamp")].data<coral::TimeStamp>() = stableBeamStartTimeStamp;
290 conditionStr =
std::string(
"DIPTIME <= :stableBeamStartTimeStamp");
292 coral::AttributeList bunchConfOutput;
293 bunchConfOutput.extend<coral::TimeStamp>(
std::string(
"DIPTIME"));
294 bunchConfOutput.extend<
unsigned short>(
std::string(
"BUCKET"));
296 std::unique_ptr<coral::IQuery> bunchConf1Query(beamCondSchema.newQuery());
297 bunchConf1Query->addToTableList(
std::string(
"LHC_CIRCBUNCHCONFIG_BEAM1"),
298 std::string(
"BEAMCONF\", TABLE( BEAMCONF.VALUE ) \"BUCKETS"));
301 bunchConf1Query->setCondition(conditionStr, bunchConfBindVariables);
302 bunchConf1Query->addToOrderList(
std::string(
"DIPTIME DESC"));
304 bunchConf1Query->defineOutput(bunchConfOutput);
305 coral::ICursor &bunchConf1Cursor = bunchConf1Query->execute();
306 std::bitset<FillInfo::bunchSlots + 1> bunchConfiguration1(0ULL);
307 while (bunchConf1Cursor.next()) {
309 std::ostringstream b1s;
310 fillDataCursor.currentRow().toOutputStream(b1s);
311 edm::LogInfo(m_name) << b1s.str() <<
"\nfrom " << m_name <<
"::getNewObjects";
314 if (bunchConf1Cursor.currentRow()[
std::string(
"BUCKET")].data<
unsigned short>() != 0) {
315 unsigned short slot =
316 (bunchConf1Cursor.currentRow()[
std::string(
"BUCKET")].data<
unsigned short>() - 1) / 10 + 1;
317 bunchConfiguration1[slot] =
true;
321 std::unique_ptr<coral::IQuery> bunchConf2Query(beamCondSchema.newQuery());
322 bunchConf2Query->addToTableList(
std::string(
"LHC_CIRCBUNCHCONFIG_BEAM2"),
323 std::string(
"BEAMCONF\", TABLE( BEAMCONF.VALUE ) \"BUCKETS"));
326 bunchConf2Query->setCondition(conditionStr, bunchConfBindVariables);
327 bunchConf2Query->addToOrderList(
std::string(
"DIPTIME DESC"));
329 bunchConf2Query->defineOutput(bunchConfOutput);
330 coral::ICursor &bunchConf2Cursor = bunchConf2Query->execute();
331 std::bitset<FillInfo::bunchSlots + 1> bunchConfiguration2(0ULL);
332 while (bunchConf2Cursor.next()) {
334 std::ostringstream b2s;
335 fillDataCursor.currentRow().toOutputStream(b2s);
336 edm::LogInfo(m_name) << b2s.str() <<
"\nfrom " << m_name <<
"::getNewObjects";
338 if (bunchConf2Cursor.currentRow()[
std::string(
"BUCKET")].data<
unsigned short>() != 0) {
339 unsigned short slot =
340 (bunchConf2Cursor.currentRow()[
std::string(
"BUCKET")].data<
unsigned short>() - 1) / 10 + 1;
341 bunchConfiguration2[slot] =
true;
352 if (afterPreviousFillEndTime < stableBeamStartTime) {
353 edm::LogInfo(m_name) <<
"Entering fake fill between fill number " << previousFillNumber
354 <<
" and current fill number " << currentFill <<
", from " << afterPreviousFillEndTime
357 <<
" ) to " << beforeStableBeamStartTime <<
" ( " 359 <<
" ); from " << m_name <<
"::getNewObjects";
363 edm::LogError(m_name) <<
"WRONG DATA! In the previous fill number " << previousFillNumber
364 <<
" beams were dumped at timestamp " 366 <<
", which is not before the timestamp " 368 <<
" when current fill number " << currentFill <<
" entered stable beams. EXITING. from " 369 << m_name <<
"::getNewObjects";
374 fillInfo->
setBeamInfo(const_cast<unsigned short const &>(bunches1),
375 const_cast<unsigned short const &>(bunches2),
376 const_cast<unsigned short const &>(collidingBunches),
377 const_cast<unsigned short const &>(targetBunches),
378 const_cast<FillInfo::FillTypeId const &>(fillType),
379 const_cast<FillInfo::ParticleTypeId const &>(particleType1),
380 const_cast<FillInfo::ParticleTypeId const &>(particleType2),
381 const_cast<float const &>(crossingAngle),
382 const_cast<float const &>(betastar),
383 const_cast<float const &>(intensityBeam1),
384 const_cast<float const &>(intensityBeam2),
385 const_cast<float const &>(
energy),
386 const_cast<cond::Time_t const &>(creationTime),
387 const_cast<cond::Time_t const &>(stableBeamStartTime),
388 const_cast<cond::Time_t const &>(beamDumpTime),
389 const_cast<std::string const &>(injectionScheme),
390 const_cast<std::bitset<FillInfo::bunchSlots + 1>
const &
>(bunchConfiguration1),
391 const_cast<std::bitset<FillInfo::bunchSlots + 1>
const &
>(bunchConfiguration2));
395 << stableBeamStartTime <<
" ( " 397 <<
" ) has values:\n" 398 << *fillInfo <<
"from " << m_name <<
"::getNewObjects";
400 ss <<
" fill = " << currentFill <<
";\tinjection scheme: " << injectionScheme
401 <<
";\tstart time: " << boost::posix_time::to_iso_extended_string(stableBeamStartTimeStamp.time())
402 <<
";\tend time: " << boost::posix_time::to_iso_extended_string(beamDumpTimeStamp.time()) <<
"." << std::endl;
404 previousFillNumber = currentFill;
405 previousFillEndTime = beamDumpTime;
414 <<
"::getNewObjects";
edm::ErrorSummaryEntry Error
std::string m_userTextLog
edm::Ref< Container > Ref
void setBeamInfo(unsigned short const &bunches1, unsigned short const &bunches2, unsigned short const &collidingBunches, unsigned short const &targetBunches, FillTypeId const &fillType, ParticleTypeId const &particleType1, ParticleTypeId const &particleType2, float const &angle, float const &beta, float const &intensity1, float const &intensity2, float const &energy, cond::Time_t const &createTime, cond::Time_t const &beginTime, cond::Time_t const &endTime, std::string const &scheme, std::bitset< bunchSlots+1 > const &bunchConf1, std::bitset< bunchSlots+1 > const &bunchConf2)
void start(bool readOnly=true)
cond::Time_t pack(cond::UnpackedTime iValue)
static size_t const availableBunchSlots
Transaction & transaction()
OldContainer m_to_transfer
U second(std::pair< T, U > const &p)
cond::ValidityInterval lastInterval
unsigned long long Time_t
coral::ISchema & nominalSchema()
Session createSession(const std::string &connectionString, bool writeCapable=false)
void setMessageVerbosity(coral::MsgLevel level)
Time_t from_boost(boost::posix_time::ptime bt)
unsigned short m_lastFill
std::string lastPayloadToken
std::string m_connectionString
coral::ISessionProxy & coralSession()
unsigned short m_firstFill
void setAuthenticationPath(const std::string &p)
boost::posix_time::ptime to_boost(Time_t iValue)
cond::TagInfo_t const & tagInfo() const
cond::UnpackedTime unpack(cond::Time_t iValue)