46 <<
" ); from " <<
m_name <<
"::getNewObjects";
53 <<
" and values:\n" << *previousFill
54 <<
"from " <<
m_name <<
"::getNewObjects";
55 if( m_firstFill <= previousFill->fillNumber() ) {
58 std::ostringstream es;
59 es <<
"Trying to insert fill number " <<
m_firstFill
60 << ( (
m_firstFill < previousFill->fillNumber() ) ?
", which is an older fill than " :
", which is the same fill as " )
61 <<
"the last one in the destination tag " << previousFill->fillNumber()
62 <<
": the first fill to be looked for will become " << previousFill->fillNumber() + 1;
63 edm::LogWarning( m_name ) << es.str() <<
"; from " << m_name <<
"::getNewObjects";
72 <<
" cannot be larger than the last one " <<
m_lastFill
73 <<
" EXITING. from " << m_name <<
"::getNewObjects";
93 coral::ISchema& runTimeLoggerSchema = session.
nominalSchema();
97 std::unique_ptr<coral::IQuery> fillDataQuery( runTimeLoggerSchema.newQuery() );
99 fillDataQuery->addToTableList( std::string(
"RUNTIME_SUMMARY" ) );
101 fillDataQuery->addToOutputList( std::string(
"LHCFILL" ) );
102 fillDataQuery->addToOutputList( std::string(
"NBUNCHESBEAM1" ) );
103 fillDataQuery->addToOutputList( std::string(
"NBUNCHESBEAM2" ) );
104 fillDataQuery->addToOutputList( std::string(
"NCOLLIDINGBUNCHES" ) );
105 fillDataQuery->addToOutputList( std::string(
"NTARGETBUNCHES" ) );
106 fillDataQuery->addToOutputList( std::string(
"RUNTIME_TYPE_ID" ) );
107 fillDataQuery->addToOutputList( std::string(
"PARTY1" ) );
108 fillDataQuery->addToOutputList( std::string(
"PARTY2" ) );
109 fillDataQuery->addToOutputList( std::string(
"CROSSINGANGLE" ) );
110 fillDataQuery->addToOutputList( std::string(
"BETASTAR" ) );
111 fillDataQuery->addToOutputList( std::string(
"INTENSITYBEAM1" ) );
112 fillDataQuery->addToOutputList( std::string(
"INTENSITYBEAM2" ) );
113 fillDataQuery->addToOutputList( std::string(
"ENERGY" ) );
114 fillDataQuery->addToOutputList( std::string(
"CREATETIME" ) );
115 fillDataQuery->addToOutputList( std::string(
"BEGINTIME" ) );
116 fillDataQuery->addToOutputList( std::string(
"ENDTIME" ) );
117 fillDataQuery->addToOutputList( std::string(
"INJECTIONSCHEME" ) );
119 coral::AttributeList fillDataBindVariables;
120 fillDataBindVariables.extend( std::string(
"firstFillNumber" ),
typeid(
unsigned short ) );
121 fillDataBindVariables[ std::string(
"firstFillNumber" ) ].data<
unsigned short>() =
m_firstFill;
122 fillDataBindVariables.extend( std::string(
"lastFillNumber" ),
typeid(
unsigned short ) );
123 fillDataBindVariables[ std::string(
"lastFillNumber" ) ].data<
unsigned short>() =
m_lastFill;
126 std::string conditionStr(
"BEGINTIME IS NOT NULL AND LHCFILL BETWEEN :firstFillNumber AND :lastFillNumber" );
127 fillDataQuery->setCondition( conditionStr, fillDataBindVariables );
129 fillDataQuery->addToOrderList( std::string(
"LHCFILL" ) );
131 coral::AttributeList fillDataOutput;
132 fillDataOutput.extend<
unsigned short>( std::string(
"LHCFILL" ) );
133 fillDataOutput.extend<
unsigned short>( std::string(
"NBUNCHESBEAM1" ) );
134 fillDataOutput.extend<
unsigned short>( std::string(
"NBUNCHESBEAM2" ) );
135 fillDataOutput.extend<
unsigned short>( std::string(
"NCOLLIDINGBUNCHES" ) );
136 fillDataOutput.extend<
unsigned short>( std::string(
"NTARGETBUNCHES" ) );
137 fillDataOutput.extend<
int>( std::string(
"RUNTIME_TYPE_ID" ) );
138 fillDataOutput.extend<
int>( std::string(
"PARTY1" ) );
139 fillDataOutput.extend<
int>( std::string(
"PARTY2" ) );
140 fillDataOutput.extend<
float>( std::string(
"CROSSINGANGLE" ) );
141 fillDataOutput.extend<
float>( std::string(
"BETASTAR" ) );
142 fillDataOutput.extend<
float>( std::string(
"INTENSITYBEAM1" ) );
143 fillDataOutput.extend<
float>( std::string(
"INTENSITYBEAM2" ) );
144 fillDataOutput.extend<
float>( std::string(
"ENERGY" ) );
145 fillDataOutput.extend<coral::TimeStamp>( std::string(
"CREATETIME" ) );
146 fillDataOutput.extend<coral::TimeStamp>( std::string(
"BEGINTIME" ) );
147 fillDataOutput.extend<coral::TimeStamp>( std::string(
"ENDTIME" ) );
148 fillDataOutput.extend<std::string>( std::string(
"INJECTIONSCHEME" ) );
149 fillDataQuery->defineOutput( fillDataOutput );
151 coral::ICursor& fillDataCursor = fillDataQuery->execute();
153 unsigned short previousFillNumber = 1, currentFill =
m_firstFill;
154 cond::Time_t previousFillEndTime = 0ULL, afterPreviousFillEndTime = 0ULL, beforeStableBeamStartTime = 0ULL;
156 previousFillNumber = previousFill->fillNumber();
157 previousFillEndTime = previousFill->endTime();
159 unsigned short bunches1 = 0, bunches2 = 0, collidingBunches = 0, targetBunches = 0;
162 float crossingAngle = 0., betastar = 0., intensityBeam1 = 0., intensityBeam2 = 0.,
energy = 0.;
163 coral::TimeStamp stableBeamStartTimeStamp, beamDumpTimeStamp;
164 cond::Time_t creationTime = 0ULL, stableBeamStartTime = 0ULL, beamDumpTime = 0ULL;
165 std::string injectionScheme(
"None" );
166 std::ostringstream ss;
168 while( fillDataCursor.next() ) {
170 std::ostringstream qs;
171 fillDataCursor.currentRow().toOutputStream( qs );
172 edm::LogInfo( m_name ) << qs.str() <<
"\nfrom " << m_name <<
"::getNewObjects";
174 currentFill = fillDataCursor.currentRow()[ std::string(
"LHCFILL" ) ].data<
unsigned short>();
175 coral::Attribute
const & bunches1Attribute = fillDataCursor.currentRow()[ std::string(
"NBUNCHESBEAM1" ) ];
176 if( bunches1Attribute.isNull() ) {
179 bunches1 = bunches1Attribute.data<
unsigned short>();
181 coral::Attribute
const & bunches2Attribute = fillDataCursor.currentRow()[ std::string(
"NBUNCHESBEAM2" ) ];
182 if( bunches2Attribute.isNull() ) {
185 bunches2 = bunches2Attribute.data<
unsigned short>();
187 coral::Attribute
const & collidingBunchesAttribute = fillDataCursor.currentRow()[ std::string(
"NCOLLIDINGBUNCHES" ) ];
188 if( collidingBunchesAttribute.isNull() ) {
189 collidingBunches = 0;
191 collidingBunches = collidingBunchesAttribute.data<
unsigned short>();
193 coral::Attribute
const & targetBunchesAttribute = fillDataCursor.currentRow()[ std::string(
"NTARGETBUNCHES" ) ];
194 if( targetBunchesAttribute.isNull() ) {
197 targetBunches = targetBunchesAttribute.data<
unsigned short>();
200 fillType =
static_cast<FillInfo::FillTypeId>( fillDataCursor.currentRow()[ std::string(
"RUNTIME_TYPE_ID" ) ].data<
int>() );
201 coral::Attribute
const & particleType1Attribute = fillDataCursor.currentRow()[ std::string(
"PARTY1" ) ];
202 if( particleType1Attribute.isNull() ) {
207 coral::Attribute
const & particleType2Attribute = fillDataCursor.currentRow()[ std::string(
"PARTY2" ) ];
208 if( particleType2Attribute.isNull() ) {
213 coral::Attribute
const & crossingAngleAttribute = fillDataCursor.currentRow()[ std::string(
"CROSSINGANGLE" ) ];
214 if( crossingAngleAttribute.isNull() ) {
217 crossingAngle = crossingAngleAttribute.data<
float>();
219 coral::Attribute
const & betastarAttribute = fillDataCursor.currentRow()[ std::string(
"BETASTAR" ) ];
220 if( betastarAttribute.isNull() ) {
223 betastar = betastarAttribute.data<
float>();
225 coral::Attribute
const & intensityBeam1Attribute = fillDataCursor.currentRow()[ std::string(
"INTENSITYBEAM1" ) ];
226 if( intensityBeam1Attribute.isNull() ) {
229 intensityBeam1 = intensityBeam1Attribute.data<
float>();
231 coral::Attribute
const & intensityBeam2Attribute = fillDataCursor.currentRow()[ std::string(
"INTENSITYBEAM2" ) ];
232 if( intensityBeam2Attribute.isNull() ) {
235 intensityBeam2 = intensityBeam2Attribute.data<
float>();
237 coral::Attribute
const & energyAttribute = fillDataCursor.currentRow()[ std::string(
"ENERGY" ) ];
238 if( energyAttribute.isNull() ){
241 energy = energyAttribute.data<
float>();
244 creationTime =
cond::time::from_boost( fillDataCursor.currentRow()[ std::string(
"CREATETIME" ) ].data<coral::TimeStamp>().
time() );
246 stableBeamStartTimeStamp = fillDataCursor.currentRow()[ std::string(
"BEGINTIME" ) ].data<coral::TimeStamp>();
248 coral::Attribute
const & beamDumpTimeAttribute = fillDataCursor.currentRow()[ std::string(
"ENDTIME" ) ];
249 if( beamDumpTimeAttribute.isNull() ) {
252 beamDumpTimeStamp = beamDumpTimeAttribute.data<coral::TimeStamp>();
255 coral::Attribute
const & injectionSchemeAttribute = fillDataCursor.currentRow()[ std::string(
"INJECTIONSCHEME" ) ];
256 if( injectionSchemeAttribute.isNull() ) {
257 injectionScheme = std::string(
"None" );
259 injectionScheme = injectionSchemeAttribute.data<std::string>();
279 if( beamDumpTime == 0 ) {
280 edm::LogWarning( m_name ) <<
"NO TRANSFER NEEDED: the fill number " << currentFill
281 <<
" is still ongoing"
282 <<
"; from " << m_name <<
"::getNewObjects";
290 coral::AttributeList bunchConfBindVariables;
291 bunchConfBindVariables.extend<coral::TimeStamp>( std::string(
"stableBeamStartTimeStamp" ) );
292 bunchConfBindVariables[ std::string(
"stableBeamStartTimeStamp" ) ].data<coral::TimeStamp>() = stableBeamStartTimeStamp;
293 conditionStr = std::string(
"DIPTIME <= :stableBeamStartTimeStamp" );
295 coral::AttributeList bunchConfOutput;
296 bunchConfOutput.extend<coral::TimeStamp>( std::string(
"DIPTIME" ) );
297 bunchConfOutput.extend<
unsigned short>( std::string(
"BUCKET" ) );
299 std::unique_ptr<coral::IQuery> bunchConf1Query(beamCondSchema.newQuery());
300 bunchConf1Query->addToTableList( std::string(
"LHC_CIRCBUNCHCONFIG_BEAM1" ), std::string(
"BEAMCONF\", TABLE( BEAMCONF.VALUE ) \"BUCKETS" ) );
301 bunchConf1Query->addToOutputList( std::string(
"BEAMCONF.DIPTIME" ), std::string(
"DIPTIME" ) );
302 bunchConf1Query->addToOutputList( std::string(
"BUCKETS.COLUMN_VALUE" ), std::string(
"BUCKET" ) );
303 bunchConf1Query->setCondition( conditionStr, bunchConfBindVariables );
304 bunchConf1Query->addToOrderList( std::string(
"DIPTIME DESC" ) );
306 bunchConf1Query->defineOutput( bunchConfOutput );
307 coral::ICursor& bunchConf1Cursor = bunchConf1Query->execute();
308 std::bitset<FillInfo::bunchSlots+1> bunchConfiguration1( 0ULL );
309 while( bunchConf1Cursor.next() ) {
311 std::ostringstream b1s;
312 fillDataCursor.currentRow().toOutputStream( b1s );
313 edm::LogInfo( m_name ) << b1s.str() <<
"\nfrom " << m_name <<
"::getNewObjects";
316 if( bunchConf1Cursor.currentRow()[ std::string(
"BUCKET" ) ].data<
unsigned short>() != 0 ) {
317 unsigned short slot = ( bunchConf1Cursor.currentRow()[ std::string(
"BUCKET" ) ].data<
unsigned short>() - 1 ) / 10 + 1;
318 bunchConfiguration1[ slot ] =
true;
322 std::unique_ptr<coral::IQuery> bunchConf2Query(beamCondSchema.newQuery());
323 bunchConf2Query->addToTableList( std::string(
"LHC_CIRCBUNCHCONFIG_BEAM2" ), std::string(
"BEAMCONF\", TABLE( BEAMCONF.VALUE ) \"BUCKETS" ) );
324 bunchConf2Query->addToOutputList( std::string(
"BEAMCONF.DIPTIME" ), std::string(
"DIPTIME" ) );
325 bunchConf2Query->addToOutputList( std::string(
"BUCKETS.COLUMN_VALUE" ), std::string(
"BUCKET" ) );
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 = ( bunchConf2Cursor.currentRow()[ std::string(
"BUCKET" ) ].data<
unsigned short>() - 1 ) / 10 + 1;
340 bunchConfiguration2[ slot ] =
true;
349 if( afterPreviousFillEndTime < stableBeamStartTime ) {
350 edm::LogInfo( m_name ) <<
"Entering fake fill between fill number " << previousFillNumber
351 <<
" and current fill number " << currentFill
352 <<
", from " << afterPreviousFillEndTime
353 <<
" ( " << boost::posix_time::to_iso_extended_string(
cond::time::to_boost( afterPreviousFillEndTime ) )
354 <<
" ) to " << beforeStableBeamStartTime
355 <<
" ( " << boost::posix_time::to_iso_extended_string(
cond::time::to_boost( beforeStableBeamStartTime ) )
356 <<
" ); from " << m_name <<
"::getNewObjects";
360 edm::LogError( m_name ) <<
"WRONG DATA! In the previous fill number " << previousFillNumber
361 <<
" beams were dumped at timestamp " << boost::posix_time::to_iso_extended_string(
cond::time::to_boost( previousFillEndTime ) )
362 <<
", which is not before the timestamp " << boost::posix_time::to_iso_extended_string(
cond::time::to_boost( stableBeamStartTime ) )
363 <<
" when current fill number " << currentFill
364 <<
" entered stable beams. EXITING. from " << m_name <<
"::getNewObjects";
369 fillInfo->
setBeamInfo( const_cast<unsigned short const &>( bunches1 )
370 , const_cast<unsigned short const &>( bunches2 )
371 , const_cast<unsigned short const &>( collidingBunches )
372 , const_cast<unsigned short const &>( targetBunches )
373 , const_cast<FillInfo::FillTypeId const &>( fillType )
374 , const_cast<FillInfo::ParticleTypeId const &>( particleType1 )
375 , const_cast<FillInfo::ParticleTypeId const &>( particleType2 )
376 , const_cast<float const &>( crossingAngle )
377 , const_cast<float const &>( betastar )
378 , const_cast<float const &>( intensityBeam1 )
379 , const_cast<float const &>( intensityBeam2 )
380 , const_cast<float const &>(
energy )
381 , const_cast<cond::Time_t const &>( creationTime )
382 , const_cast<cond::Time_t const &>( stableBeamStartTime )
383 , const_cast<cond::Time_t const &>( beamDumpTime )
384 , const_cast<std::string const &>( injectionScheme )
385 ,
const_cast<std::bitset<FillInfo::bunchSlots+1>
const &
>( bunchConfiguration1 )
386 ,
const_cast<std::bitset<FillInfo::bunchSlots+1>
const &
>( bunchConfiguration2 )
391 <<
" with validity " << stableBeamStartTime
392 <<
" ( " << boost::posix_time::to_iso_extended_string(
cond::time::to_boost( stableBeamStartTime ) )
393 <<
" ) has values:\n" << *fillInfo
394 <<
"from " << m_name <<
"::getNewObjects";
396 ss <<
" fill = " << currentFill
397 <<
";\tinjection scheme: " << injectionScheme
399 << boost::posix_time::to_iso_extended_string( stableBeamStartTimeStamp.time() )
401 << boost::posix_time::to_iso_extended_string( beamDumpTimeStamp.time() )
404 previousFillNumber = currentFill;
405 previousFillEndTime = beamDumpTime;
412 dbConnection.
close();
415 edm::LogInfo( m_name ) <<
"Transferring " <<
m_to_transfer.size() <<
" payload(s); from " << m_name <<
"::getNewObjects";
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)
DbTransaction & transaction()
void open(const std::string &connectionString, bool readOnly=false)
int commit()
commit transaction.
DbConnectionConfiguration & configuration()
cond::Time_t pack(cond::UnpackedTime iValue)
coral::ISchema & schema(const std::string &schemaName)
static size_t const availableBunchSlots
std::string lastPayloadToken
OldContainer m_to_transfer
cond::TagInfo const & tagInfo() const
U second(std::pair< T, U > const &p)
int start(bool readOnly=false)
start transaction
void setPoolAutomaticCleanUp(bool flag)
void setMessageLevel(coral::MsgLevel l)
unsigned long long Time_t
Time_t from_boost(boost::posix_time::ptime bt)
unsigned short m_lastFill
DbSession createSession() const
coral::ISchema & nominalSchema()
std::string m_connectionString
void setConnectionTimeOut(int timeOut)
void setAuthenticationPath(const std::string &p)
cond::ValidityInterval lastInterval
unsigned short m_firstFill
tuple size
Write out results.
boost::posix_time::ptime to_boost(Time_t iValue)
cond::UnpackedTime unpack(cond::Time_t iValue)