CMS 3D CMS Logo

Classes | Functions | Variables
LHCInfoImpl Namespace Reference

Classes

struct  IOVComp
 
struct  LumiSectionFilter
 

Functions

template<typename T >
TaccessParams (std::vector< T > &params, size_t index)
 
bool comparePayloads (const LHCInfo &rhs, const LHCInfo &lhs)
 
template<typename T >
const TgetOneParam (const std::vector< std::vector< T > > &params, size_t index)
 
template<typename T >
const TgetParams (const std::vector< T > &params, size_t index)
 
bool makeFillDataQuery (cond::persistency::Session &session, const std::string &conditionString, const coral::AttributeList &fillDataBindVariables, std::unique_ptr< LHCInfo > &targetPayload, bool debug)
 
std::vector< std::pair< cond::Time_t, std::shared_ptr< LHCInfo > > >::const_iterator search (const cond::Time_t &val, const std::vector< std::pair< cond::Time_t, std::shared_ptr< LHCInfo > >> &container)
 
void setElementData (cond::Time_t since, const std::string &dipVal, unsigned int elementNr, float value, LHCInfo &payload, std::set< cond::Time_t > &initList)
 
template<typename T >
void setOneParam (std::vector< std::vector< T > > &params, size_t index, const T &value)
 
template<typename T >
void setParams (std::vector< T > &params, size_t index, const T &value)
 
size_t transferPayloads (const std::vector< std::pair< cond::Time_t, std::shared_ptr< LHCInfo > > > &buffer, std::vector< std::shared_ptr< LHCInfo > > &payloadBuffer, std::vector< std::pair< LHCInfo *, cond::Time_t > > &vecToTransfer, std::shared_ptr< LHCInfo > &prevPayload)
 

Variables

static const std::map< std::string, int > vecMap = {{"Beam1/beamPhaseMean",1},{"Beam2/beamPhaseMean",2},{"Beam1/cavPhaseMean",3},{"Beam2/cavPhaseMean",4}}
 

Function Documentation

template<typename T >
T& LHCInfoImpl::accessParams ( std::vector< T > &  params,
size_t  index 
)

Definition at line 119 of file LHCInfo.cc.

Referenced by LHCInfo::beam1RF(), LHCInfo::beam1VC(), LHCInfo::beam2RF(), and LHCInfo::beam2VC().

119  {
120  if( index >= params.size() ) throw std::out_of_range("Parameter with index "+std::to_string(index)+" is out of range.");
121  return params[index];
122  }
bool LHCInfoImpl::comparePayloads ( const LHCInfo rhs,
const LHCInfo lhs 
)

Definition at line 773 of file LHCInfoPopConSourceHandler.cc.

References LHCInfo::betaStar(), LHCInfo::crossingAngle(), LHCInfo::ctppsStatus(), LHCInfo::delivLumi(), LHCInfo::fillNumber(), LHCInfo::instLumi(), LHCInfo::instLumiError(), LHCInfo::lhcComment(), LHCInfo::lhcState(), and LHCInfo::recLumi().

Referenced by transferPayloads().

773  {
774  if( rhs.fillNumber() != lhs.fillNumber() ) return false;
775  if( rhs.delivLumi() != lhs.delivLumi() ) return false;
776  if( rhs.recLumi() != lhs.recLumi() ) return false;
777  if( rhs.instLumi() != lhs.instLumi() ) return false;
778  if( rhs.instLumiError() != lhs.instLumiError() ) return false;
779  if( rhs.crossingAngle() != rhs.crossingAngle() ) return false;
780  if( rhs.betaStar() != rhs.betaStar() ) return false;
781  if( rhs.lhcState() != rhs.lhcState() ) return false;
782  if( rhs.lhcComment() != rhs.lhcComment() ) return false;
783  if( rhs.ctppsStatus() != rhs.ctppsStatus() ) return false;
784  return true;
785  }
std::string const & lhcState() const
Definition: LHCInfo.cc:232
std::string const & ctppsStatus() const
Definition: LHCInfo.cc:240
float const delivLumi() const
Definition: LHCInfo.cc:196
float const crossingAngle() const
Definition: LHCInfo.cc:176
float const instLumiError() const
Definition: LHCInfo.cc:208
std::string const & lhcComment() const
Definition: LHCInfo.cc:236
float const instLumi() const
Definition: LHCInfo.cc:204
float const recLumi() const
Definition: LHCInfo.cc:200
float const betaStar() const
Definition: LHCInfo.cc:180
unsigned short const fillNumber() const
Definition: LHCInfo.cc:144
template<typename T >
const T& LHCInfoImpl::getOneParam ( const std::vector< std::vector< T > > &  params,
size_t  index 
)

Definition at line 124 of file LHCInfo.cc.

References SurfaceOrientation::inner, and dataset::name.

Referenced by LHCInfo::beginTime(), LHCInfo::betaStar(), LHCInfo::bunchesInBeam1(), LHCInfo::bunchesInBeam2(), LHCInfo::collidingBunches(), LHCInfo::createTime(), LHCInfo::crossingAngle(), LHCInfo::ctppsStatus(), LHCInfo::delivLumi(), LHCInfo::endTime(), LHCInfo::energy(), LHCInfo::fillNumber(), LHCInfo::fillType(), LHCInfo::injectionScheme(), LHCInfo::instLumi(), LHCInfo::instLumiError(), LHCInfo::intensityForBeam1(), LHCInfo::intensityForBeam2(), LHCInfo::lhcComment(), LHCInfo::lhcState(), LHCInfo::lumiSection(), LHCInfo::particleTypeForBeam1(), LHCInfo::particleTypeForBeam2(), LHCInfo::recLumi(), and LHCInfo::targetBunches().

124  {
125  if( index >= params.size() ) throw std::out_of_range("Parameter with index "+std::to_string(index)+" is out of range.");
126  const std::vector<T>& inner = params[index];
127  if( inner.empty() ) throw std::out_of_range("Parameter with index "+std::to_string(index)+" type="+typeid(T).name()+" has no value stored.");
128  return inner[ 0 ];
129  }
long double T
template<typename T >
const T& LHCInfoImpl::getParams ( const std::vector< T > &  params,
size_t  index 
)

Definition at line 114 of file LHCInfo.cc.

Referenced by LHCInfo::beam1RF(), LHCInfo::beam1VC(), LHCInfo::beam2RF(), LHCInfo::beam2VC(), LHCInfo::lumiPerBX(), and QTestConfigurationParser::qtestsConfig().

114  {
115  if( index >= params.size() ) throw std::out_of_range("Parameter with index "+std::to_string(index)+" is out of range.");
116  return params[index];
117  }
bool LHCInfoImpl::makeFillDataQuery ( cond::persistency::Session session,
const std::string &  conditionString,
const coral::AttributeList &  fillDataBindVariables,
std::unique_ptr< LHCInfo > &  targetPayload,
bool  debug 
)

Definition at line 64 of file LHCInfoPopConSourceHandler.cc.

References LHCInfo::COSMICS, cond::time::from_boost(), LHCInfo::GAP, LHCInfo::IONS, cond::persistency::Session::nominalSchema(), LHCInfo::NONE, LHCInfo::PB82, LHCInfo::PROTON, LHCInfo::PROTONS, AlCaHLTBitMon_QueryRunRegistry::string, ntuplemaker::time, and LHCInfo::UNKNOWN.

Referenced by LHCInfoPopConSourceHandler::getFillData(), and LHCInfoPopConSourceHandler::getNextFillData().

68  {
69  coral::ISchema& runTimeLoggerSchema = session.nominalSchema();
70  //prepare the query for table 1:
71  std::unique_ptr<coral::IQuery> fillDataQuery( runTimeLoggerSchema.newQuery() );
72  //FROM clause
73  fillDataQuery->addToTableList( std::string( "RUNTIME_SUMMARY" ) );
74  //SELECT clause
75  fillDataQuery->addToOutputList( std::string( "LHCFILL" ) );
76  fillDataQuery->addToOutputList( std::string( "NBUNCHESBEAM1" ) );
77  fillDataQuery->addToOutputList( std::string( "NBUNCHESBEAM2" ) );
78  fillDataQuery->addToOutputList( std::string( "NCOLLIDINGBUNCHES" ) );
79  fillDataQuery->addToOutputList( std::string( "NTARGETBUNCHES" ) );
80  fillDataQuery->addToOutputList( std::string( "RUNTIME_TYPE_ID" ) );
81  fillDataQuery->addToOutputList( std::string( "PARTY1" ) );
82  fillDataQuery->addToOutputList( std::string( "PARTY2" ) );
83  fillDataQuery->addToOutputList( std::string( "INTENSITYBEAM1" ) );
84  fillDataQuery->addToOutputList( std::string( "INTENSITYBEAM2" ) );
85  fillDataQuery->addToOutputList( std::string( "ENERGY" ) );
86  fillDataQuery->addToOutputList( std::string( "CREATETIME" ) );
87  fillDataQuery->addToOutputList( std::string( "BEGINTIME" ) );
88  fillDataQuery->addToOutputList( std::string( "ENDTIME" ) );
89  fillDataQuery->addToOutputList( std::string( "INJECTIONSCHEME" ) );
90  //WHERE clause
91  fillDataQuery->setCondition( conditionString, fillDataBindVariables );
92  //ORDER BY clause
93  std::string orderStr("BEGINTIME");
94  //define query output
95  coral::AttributeList fillDataOutput;
96  fillDataOutput.extend<unsigned short>( std::string( "LHCFILL" ) );
97  fillDataOutput.extend<unsigned short>( std::string( "NBUNCHESBEAM1" ) );
98  fillDataOutput.extend<unsigned short>( std::string( "NBUNCHESBEAM2" ) );
99  fillDataOutput.extend<unsigned short>( std::string( "NCOLLIDINGBUNCHES" ) );
100  fillDataOutput.extend<unsigned short>( std::string( "NTARGETBUNCHES" ) );
101  fillDataOutput.extend<int>( std::string( "RUNTIME_TYPE_ID" ) );
102  fillDataOutput.extend<int>( std::string( "PARTY1" ) );
103  fillDataOutput.extend<int>( std::string( "PARTY2" ) );
104  fillDataOutput.extend<float>( std::string( "INTENSITYBEAM1" ) );
105  fillDataOutput.extend<float>( std::string( "INTENSITYBEAM2" ) );
106  fillDataOutput.extend<float>( std::string( "ENERGY" ) );
107  fillDataOutput.extend<coral::TimeStamp>( std::string( "CREATETIME" ) );
108  fillDataOutput.extend<coral::TimeStamp>( std::string( "BEGINTIME" ) );
109  fillDataOutput.extend<coral::TimeStamp>( std::string( "ENDTIME" ) );
110  fillDataOutput.extend<std::string>( std::string( "INJECTIONSCHEME" ) );
111  fillDataQuery->defineOutput( fillDataOutput );
112  fillDataQuery->limitReturnedRows( 1 );
113  //execute the query
114  coral::ICursor& fillDataCursor = fillDataQuery->execute();
115  //
116  unsigned short currentFill = 0;
117  unsigned short bunches1 = 0, bunches2 = 0, collidingBunches = 0, targetBunches = 0;
119  LHCInfo::ParticleTypeId particleType1 = LHCInfo::NONE, particleType2 = LHCInfo::NONE;
120  float intensityBeam1 = 0., intensityBeam2 = 0., energy = 0.;
121  coral::TimeStamp stableBeamStartTimeStamp, beamDumpTimeStamp;
122  cond::Time_t creationTime = 0ULL, stableBeamStartTime = 0ULL, beamDumpTime = 0ULL;
123  std::string injectionScheme( "None" );
124  std::ostringstream ss;
125  bool ret = false;
126  if( fillDataCursor.next() ) {
127  ret = true;
128  if( debug ) {
129  std::ostringstream qs;
130  fillDataCursor.currentRow().toOutputStream( qs );
131  }
132  coral::Attribute const & fillAttribute = fillDataCursor.currentRow()[ std::string( "LHCFILL" ) ];
133  if( !fillAttribute.isNull() ){
134  currentFill = fillAttribute.data<unsigned short>();
135  }
136  coral::Attribute const & bunches1Attribute = fillDataCursor.currentRow()[ std::string( "NBUNCHESBEAM1" ) ];
137  if( !bunches1Attribute.isNull() ) {
138  bunches1 = bunches1Attribute.data<unsigned short>();
139  }
140  coral::Attribute const & bunches2Attribute = fillDataCursor.currentRow()[ std::string( "NBUNCHESBEAM2" ) ];
141  if( !bunches2Attribute.isNull() ) {
142  bunches2 = bunches2Attribute.data<unsigned short>();
143  }
144  coral::Attribute const & collidingBunchesAttribute = fillDataCursor.currentRow()[ std::string( "NCOLLIDINGBUNCHES" ) ];
145  if( !collidingBunchesAttribute.isNull() ) {
146  collidingBunches = collidingBunchesAttribute.data<unsigned short>();
147  }
148  coral::Attribute const & targetBunchesAttribute = fillDataCursor.currentRow()[ std::string( "NTARGETBUNCHES" ) ];
149  if( !targetBunchesAttribute.isNull() ) {
150  targetBunches = targetBunchesAttribute.data<unsigned short>();
151  }
152  //RUNTIME_TYPE_ID IS NOT NULL
153  fillType = static_cast<LHCInfo::FillTypeId>( fillDataCursor.currentRow()[ std::string( "RUNTIME_TYPE_ID" ) ].data<int>() );
154  coral::Attribute const & particleType1Attribute = fillDataCursor.currentRow()[ std::string( "PARTY1" ) ];
155  if( !particleType1Attribute.isNull() ) {
156  particleType1 = static_cast<LHCInfo::ParticleTypeId>( particleType1Attribute.data<int>() );
157  }
158  coral::Attribute const & particleType2Attribute = fillDataCursor.currentRow()[ std::string( "PARTY2" ) ];
159  if( !particleType2Attribute.isNull() ) {
160  particleType2 = static_cast<LHCInfo::ParticleTypeId>( particleType2Attribute.data<int>() );
161  }
162  coral::Attribute const & intensityBeam1Attribute = fillDataCursor.currentRow()[ std::string( "INTENSITYBEAM1" ) ];
163  if( !intensityBeam1Attribute.isNull() ) {
164  intensityBeam1 = intensityBeam1Attribute.data<float>();
165  }
166  coral::Attribute const & intensityBeam2Attribute = fillDataCursor.currentRow()[ std::string( "INTENSITYBEAM2" ) ];
167  if( !intensityBeam2Attribute.isNull() ) {
168  intensityBeam2 = intensityBeam2Attribute.data<float>();
169  }
170  coral::Attribute const & energyAttribute = fillDataCursor.currentRow()[ std::string( "ENERGY" ) ];
171  if( !energyAttribute.isNull() ){
172  energy = energyAttribute.data<float>();
173  }
174  }
175  if( ret ){
176  //CREATETIME IS NOT NULL
177  creationTime = cond::time::from_boost( fillDataCursor.currentRow()[ std::string( "CREATETIME" ) ].data<coral::TimeStamp>().time() );
178  //BEGINTIME is imposed to be NOT NULL in the WHERE clause
179  stableBeamStartTimeStamp = fillDataCursor.currentRow()[ std::string( "BEGINTIME" ) ].data<coral::TimeStamp>();
180  stableBeamStartTime = cond::time::from_boost( stableBeamStartTimeStamp.time() );
181  coral::Attribute const & beamDumpTimeAttribute = fillDataCursor.currentRow()[ std::string( "ENDTIME" ) ];
182  if( !beamDumpTimeAttribute.isNull() ) {
183  beamDumpTimeStamp = beamDumpTimeAttribute.data<coral::TimeStamp>();
184  beamDumpTime = cond::time::from_boost( beamDumpTimeStamp.time() );
185  }
186  coral::Attribute const & injectionSchemeAttribute = fillDataCursor.currentRow()[ std::string( "INJECTIONSCHEME" ) ];
187  if( !injectionSchemeAttribute.isNull() ) {
188  injectionScheme = injectionSchemeAttribute.data<std::string>();
189  }
190  //fix an inconsistency in RunTimeLogger: if the fill type is defined, the particle type should reflect it!
191  if( fillType != LHCInfo::UNKNOWN && ( particleType1 == LHCInfo::NONE || particleType2 == LHCInfo::NONE ) ) {
192  switch( fillType ) {
193  case LHCInfo::PROTONS :
194  particleType1 = LHCInfo::PROTON;
195  particleType2 = LHCInfo::PROTON;
196  break;
197  case LHCInfo::IONS :
198  particleType1 = LHCInfo::PB82;
199  particleType2 = LHCInfo::PB82;
200  break;
201  case LHCInfo::UNKNOWN :
202  case LHCInfo::COSMICS :
203  case LHCInfo::GAP :
204  break;
205  }
206  }
207  targetPayload.reset( new LHCInfo() );
208  targetPayload->setFillNumber( currentFill );
209  targetPayload->setBunchesInBeam1( bunches1 );
210  targetPayload->setBunchesInBeam2( bunches2 );
211  targetPayload->setCollidingBunches( collidingBunches );
212  targetPayload->setTargetBunches( targetBunches );
213  targetPayload->setFillType( fillType );
214  targetPayload->setParticleTypeForBeam1( particleType1 );
215  targetPayload->setParticleTypeForBeam2( particleType2 );
216  targetPayload->setIntensityForBeam1( intensityBeam1 );
217  targetPayload->setIntensityForBeam2( intensityBeam2 );
218  targetPayload->setEnergy( energy );
219  targetPayload->setCreationTime( creationTime );
220  targetPayload->setBeginTime( stableBeamStartTime );
221  targetPayload->setEndTime( beamDumpTime );
222  targetPayload->setInjectionScheme( injectionScheme );
223  }
224  return ret;
225  }
unsigned long long Time_t
Definition: Time.h:16
coral::ISchema & nominalSchema()
Definition: Session.cc:241
Time_t from_boost(boost::posix_time::ptime bt)
ParticleType
Definition: LHCInfo.h:15
#define debug
Definition: HDRShower.cc:19
FillType
Definition: LHCInfo.h:14
std::vector<std::pair<cond::Time_t,std::shared_ptr<LHCInfo> > >::const_iterator LHCInfoImpl::search ( const cond::Time_t val,
const std::vector< std::pair< cond::Time_t, std::shared_ptr< LHCInfo > >> &  container 
)

Definition at line 57 of file LHCInfoPopConSourceHandler.cc.

References AlCaHLTBitMon_ParallelJobs::p, pfDeepBoostedJetPreprocessParams_cfi::upper_bound, and heppy_batch::val.

Referenced by LHCInfoImpl::LumiSectionFilter::process().

58  {
59  if( container.empty() ) return container.end();
60  auto p = std::upper_bound( container.begin(), container.end(), val, IOVComp() );
61  return (p!= container.begin()) ? p-1 : container.end();
62  }
void LHCInfoImpl::setElementData ( cond::Time_t  since,
const std::string &  dipVal,
unsigned int  elementNr,
float  value,
LHCInfo payload,
std::set< cond::Time_t > &  initList 
)

Definition at line 619 of file LHCInfoPopConSourceHandler.cc.

References LHCInfo::beam1RF(), LHCInfo::beam1VC(), LHCInfo::beam2RF(), LHCInfo::beam2VC(), LHCInfo::bunchSlots, and relativeConstraints::value.

Referenced by LHCInfoPopConSourceHandler::getEcalData().

621  {
622  if( initList.find(since)==initList.end() ){
623  payload.beam1VC().resize( LHCInfo::bunchSlots ,0.);
624  payload.beam2VC().resize( LHCInfo::bunchSlots ,0.);
625  payload.beam1RF().resize( LHCInfo::bunchSlots,0.);
626  payload.beam2RF().resize( LHCInfo::bunchSlots,0.);
627  initList.insert(since);
628  }
629  // set the current values to all of the payloads of the lumi section samples after the current since
630  if( elementNr < LHCInfo::bunchSlots ){
631  switch( vecMap.at(dipVal) ){
632  case 1:
633  payload.beam1VC()[elementNr]=value;
634  break;
635  case 2:
636  payload.beam2VC()[elementNr]=value;
637  break;
638  case 3:
639  payload.beam1RF()[elementNr]=value;
640  break;
641  case 4:
642  payload.beam2RF()[elementNr]=value;
643  break;
644  default:
645  break;
646  }
647  }
648  }
static const std::map< std::string, int > vecMap
std::vector< float > const & beam1VC() const
Definition: LHCInfo.cc:248
std::vector< float > const & beam2RF() const
Definition: LHCInfo.cc:260
std::vector< float > const & beam1RF() const
Definition: LHCInfo.cc:256
std::vector< float > const & beam2VC() const
Definition: LHCInfo.cc:252
static size_t const bunchSlots
Definition: LHCInfo.h:31
template<typename T >
void LHCInfoImpl::setOneParam ( std::vector< std::vector< T > > &  params,
size_t  index,
const T value 
)
template<typename T >
void LHCInfoImpl::setParams ( std::vector< T > &  params,
size_t  index,
const T value 
)

Definition at line 136 of file LHCInfo.cc.

References relativeConstraints::value.

Referenced by LHCInfo::setBeam1RF(), LHCInfo::setBeam1VC(), LHCInfo::setBeam2RF(), LHCInfo::setBeam2VC(), and LHCInfo::setLumiPerBX().

136  {
137  if( index >= params.size() ) throw std::out_of_range("Parameter with index "+std::to_string(index)+" is out of range.");
138  params[ index ] = value;
139  }
size_t LHCInfoImpl::transferPayloads ( const std::vector< std::pair< cond::Time_t, std::shared_ptr< LHCInfo > > > &  buffer,
std::vector< std::shared_ptr< LHCInfo > > &  payloadBuffer,
std::vector< std::pair< LHCInfo *, cond::Time_t > > &  vecToTransfer,
std::shared_ptr< LHCInfo > &  prevPayload 
)

Definition at line 787 of file LHCInfoPopConSourceHandler.cc.

References popcon::PopConSourceHandler< LHCInfo >::add(), edmScanValgrind::buffer, comparePayloads(), jets_cff::payload, and ntuplemaker::since.

Referenced by LHCInfoPopConSourceHandler::getNewObjects().

790  {
791  size_t niovs = 0;
792  for( auto& iov: buffer ){
793  bool add = false;
794  LHCInfo& payload = *iov.second;
795  cond::Time_t since = iov.first;
796  if( vecToTransfer.empty() ){
797  add = true;
798  } else {
799  LHCInfo& lastAdded = *vecToTransfer.back().first;
800  if( !comparePayloads( lastAdded,payload ) ) {
801  add = true;
802  }
803  }
804  if( add ) {
805  niovs++;
806  vecToTransfer.push_back( std::make_pair( &payload, since ) );
807  payloadBuffer.push_back( iov.second );
808  prevPayload = iov.second;
809  }
810  }
811  return niovs;
812  }
bool comparePayloads(const LHCInfo &rhs, const LHCInfo &lhs)
unsigned long long Time_t
Definition: Time.h:16
void add(std::map< std::string, TH1 * > &h, TH1 *hist)

Variable Documentation

const std::map<std::string, int> LHCInfoImpl::vecMap = {{"Beam1/beamPhaseMean",1},{"Beam2/beamPhaseMean",2},{"Beam1/cavPhaseMean",3},{"Beam2/cavPhaseMean",4}}
static

Definition at line 618 of file LHCInfoPopConSourceHandler.cc.