CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FillInfo.cc
Go to the documentation of this file.
3 #include <algorithm>
4 #include <iterator>
5 #include <stdexcept>
6 
7 //helper function: returns the positions of the bits in the bitset that are set (i.e., have a value of 1).
8 static std::vector<unsigned short> bitsetToVector( std::bitset<FillInfo::bunchSlots+1> const & bs ) {
9  std::vector<unsigned short> vec;
10  //reserve space only for the bits in the bitset that are set
11  vec.reserve( bs.count() );
12  for( size_t i = 0; i < bs.size(); ++i ) {
13  if( bs.test( i ) )
14  vec.push_back( (unsigned short)i );
15  }
16  return vec;
17 }
18 
19 //helper function: returns the enum for fill types in string type
21  std::string s_fillType( "UNKNOWN" );
22  switch( fillType ) {
23  case FillInfo::UNKNOWN :
24  s_fillType = std::string( "UNKNOWN" );
25  break;
26  case FillInfo::PROTONS :
27  s_fillType = std::string( "PROTONS" );
28  break;
29  case FillInfo::IONS :
30  s_fillType = std::string( "IONS" );
31  break;
32  case FillInfo::COSMICS :
33  s_fillType = std::string( "COSMICS" );
34  break;
35  case FillInfo::GAP :
36  s_fillType = std::string( "GAP" );
37  break;
38  default :
39  s_fillType = std::string( "UNKNOWN" );
40  }
41  return s_fillType;
42 }
43 
44 //helper function: returns the enum for particle types in string type
46  std::string s_particleType( "NONE" );
47  switch( particleType ) {
48  case FillInfo::NONE :
49  s_particleType = std::string( "NONE" );
50  break;
51  case FillInfo::PROTON :
52  s_particleType = std::string( "PROTON" );
53  break;
54  case FillInfo::PB82 :
55  s_particleType = std::string( "PB82" );
56  break;
57  case FillInfo::AR18 :
58  s_particleType = std::string( "AR18" );
59  break;
60  case FillInfo::D :
61  s_particleType = std::string( "D" );
62  break;
63  case FillInfo::XE54 :
64  s_particleType = std::string( "XE54" );
65  break;
66  default :
67  s_particleType = std::string( "NONE" );
68  }
69  return s_particleType;
70 }
71 
72 FillInfo::FillInfo(): m_isData( false )
73  , m_lhcFill( 0 )
74  , m_bunches1( 0 )
75  , m_bunches2( 0 )
76  , m_collidingBunches( 0 )
77  , m_targetBunches( 0 )
78  , m_fillType( FillTypeId::UNKNOWN )
79  , m_particles1( ParticleTypeId::NONE )
80  , m_particles2( ParticleTypeId::NONE )
81  , m_crossingAngle( 0. )
82  , m_betastar( 0. )
83  , m_intensity1( 0. )
84  , m_intensity2( 0. )
85  , m_energy( 0. )
86  , m_createTime( 0 )
87  , m_beginTime( 0 )
88  , m_endTime( 0 )
89  , m_injectionScheme( "None" )
90 {}
91 
92 FillInfo::FillInfo( unsigned short const & lhcFill, bool const & fromData ): m_isData( fromData )
93  , m_lhcFill( lhcFill )
94  , m_bunches1( 0 )
95  , m_bunches2( 0 )
96  , m_collidingBunches( 0 )
97  , m_targetBunches( 0 )
98  , m_fillType( FillTypeId::UNKNOWN )
99  , m_particles1( ParticleTypeId::NONE )
100  , m_particles2( ParticleTypeId::NONE )
101  , m_crossingAngle( 0. )
102  , m_betastar( 0. )
103  , m_intensity1( 0. )
104  , m_intensity2( 0. )
105  , m_energy( 0. )
106  , m_createTime( 0 )
107  , m_beginTime( 0 )
108  , m_endTime( 0 )
109  , m_injectionScheme( "None" )
110 {}
111 
113 
114 //reset instance
115 void FillInfo::setFill( unsigned short const & lhcFill, bool const & fromData ) {
116  m_isData = fromData;
117  m_lhcFill = lhcFill;
118  m_bunches1 = 0;
119  m_bunches2 = 0;
120  m_collidingBunches = 0;
121  m_targetBunches = 0;
125  m_crossingAngle = 0.;
126  m_betastar = 0.;
127  m_intensity1 = 0;
128  m_intensity2 = 0;
129  m_energy = 0.;
130  m_createTime = 0;
131  m_beginTime = 0;
132  m_endTime = 0;
133  m_injectionScheme = "None";
134  m_bunchConfiguration1.reset();
135  m_bunchConfiguration2.reset();
136 }
137 
138 //getters
139 unsigned short const FillInfo::fillNumber() const {
140  return m_lhcFill;
141 }
142 
143 bool const FillInfo::isData() const {
144  return m_isData;
145 }
146 
147 unsigned short const FillInfo::bunchesInBeam1() const {
148  return m_bunches1;
149 }
150 
151 unsigned short const FillInfo::bunchesInBeam2() const {
152  return m_bunches2;
153 }
154 
155 unsigned short const FillInfo::collidingBunches() const {
156  return m_collidingBunches;
157 }
158 
159 unsigned short const FillInfo::targetBunches() const {
160  return m_targetBunches;
161 }
162 
164  return m_fillType;
165 }
166 
168  return m_particles1;
169 }
170 
172  return m_particles2;
173 }
174 
175 float const FillInfo::crossingAngle() const {
176  return m_crossingAngle;
177 }
178 
179 float const FillInfo::betaStar() const {
180  return m_betastar;
181 }
182 
183 float const FillInfo::intensityForBeam1() const {
184  return m_intensity1;
185 }
186 
187 float const FillInfo::intensityForBeam2() const {
188  return m_intensity2;
189 }
190 
191 float const FillInfo::energy() const {
192  return m_energy;
193 }
194 
196  return m_createTime;
197 }
198 
200  return m_beginTime;
201 }
202 
204  return m_endTime;
205 }
206 
208  return m_injectionScheme;
209 }
210 
211 //returns a boolean, true if the injection scheme has a leading 25ns
212 //TODO: parse the circulating bunch configuration, instead of the string.
214  const std::string prefix( "25ns" );
215  return std::equal( prefix.begin(), prefix.end(), m_injectionScheme.begin() );
216 }
217 
218 //returns a boolean, true if the bunch slot number is in the circulating bunch configuration
219 bool FillInfo::isBunchInBeam1( size_t const & bunch ) const {
220  if( bunch == 0 )
221  throw std::out_of_range( "0 not allowed" ); //CMS starts counting bunch crossing from 1!
222  return m_bunchConfiguration1.test( bunch );
223 }
224 
225 bool FillInfo::isBunchInBeam2( size_t const & bunch ) const {
226  if( bunch == 0 )
227  throw std::out_of_range( "0 not allowed" ); //CMS starts counting bunch crossing from 1!
228  return m_bunchConfiguration2.test( bunch );
229 }
230 
231 //member functions returning *by value* a vector with all filled bunch slots
232 std::vector<unsigned short> FillInfo::bunchConfigurationForBeam1() const {
234 }
235 
236 std::vector<unsigned short> FillInfo::bunchConfigurationForBeam2() const {
238 }
239 
240 //setters
241 void FillInfo::setBunchesInBeam1( unsigned short const & bunches ) {
242  m_bunches1 = bunches;
243 }
244 
245 void FillInfo::setBunchesInBeam2( unsigned short const & bunches ) {
246  m_bunches2 = bunches;
247 }
248 
249 void FillInfo::setCollidingBunches( unsigned short const & collidingBunches ) {
251 }
252 
253 void FillInfo::setTargetBunches( unsigned short const & targetBunches ) {
255 }
256 
257 void FillInfo::setFillType( FillInfo::FillTypeId const & fillType ) {
259 }
260 
263 }
264 
267 }
268 
269 void FillInfo::setCrossingAngle( float const & angle ) {
271 }
272 
273 void FillInfo::setBetaStar( float const & betaStar ) {
275 }
276 
277 void FillInfo::setIntensityForBeam1( float const & intensity ) {
278  m_intensity1 = intensity;
279 }
280 
281 void FillInfo::setIntensityForBeam2( float const & intensity ) {
282  m_intensity2 = intensity;
283 }
284 
285 void FillInfo::setEnergy( float const & energy ) {
286  m_energy = energy;
287 }
288 
289 void FillInfo::setCreationTime( cond::Time_t const & createTime ) {
291 }
292 
293 void FillInfo::setBeginTime( cond::Time_t const & beginTime ) {
295 }
296 
298  m_endTime = endTime;
299 }
300 
301 void FillInfo::setInjectionScheme( std::string const & injectionScheme ) {
303 }
304 
305 //sets all values in one go
306 void FillInfo::setBeamInfo( unsigned short const & bunches1
307  ,unsigned short const & bunches2
308  ,unsigned short const & collidingBunches
309  ,unsigned short const & targetBunches
310  ,FillTypeId const & fillType
311  ,ParticleTypeId const & particleType1
312  ,ParticleTypeId const & particleType2
313  ,float const & angle
314  ,float const & beta
315  ,float const & intensity1
316  ,float const & intensity2
317  ,float const & energy
318  ,cond::Time_t const & createTime
319  ,cond::Time_t const & beginTime
320  ,cond::Time_t const & endTime
321  ,std::string const & scheme
322  ,std::bitset<bunchSlots+1> const & bunchConf1
323  ,std::bitset<bunchSlots+1> const & bunchConf2 ) {
324  this->setBunchesInBeam1( bunches1 );
325  this->setBunchesInBeam2( bunches2 );
326  this->setCollidingBunches( collidingBunches );
327  this->setTargetBunches( targetBunches );
328  this->setFillType( fillType );
329  this->setParticleTypeForBeam1( particleType1 );
330  this->setParticleTypeForBeam2( particleType2 );
331  this->setCrossingAngle( angle );
332  this->setBetaStar( beta );
333  this->setIntensityForBeam1( intensity1 );
334  this->setIntensityForBeam2( intensity2 );
335  this->setEnergy( energy );
336  this->setCreationTime( createTime );
337  this->setBeginTime( beginTime );
338  this->setEndTime( endTime );
339  this->setInjectionScheme( scheme );
340  this->setBunchBitsetForBeam1( bunchConf1 );
341  this->setBunchBitsetForBeam2( bunchConf2 );
342 }
343 
344 void FillInfo::print( std::stringstream & ss ) const {
345  ss << "LHC fill: " << m_lhcFill << std::endl
346  << "Bunches in Beam 1: " << m_bunches1 << std::endl
347  << "Bunches in Beam 2: " << m_bunches2 << std::endl
348  << "Colliding bunches at IP5: " << m_collidingBunches << std::endl
349  << "Target bunches at IP5: " << m_targetBunches << std::endl
350  << "Fill type: " << fillTypeToString( m_fillType ) << std::endl
351  << "Particle type for Beam 1: " << particleTypeToString( m_particles1 ) << std::endl
352  << "Particle type for Beam 2: " << particleTypeToString( m_particles2 ) << std::endl
353  << "Crossing angle (urad): " << m_crossingAngle << std::endl
354  << "Beta star (cm): " << m_betastar << std::endl
355  << "Average Intensity for Beam 1 (number of charges): " << m_intensity1 << std::endl
356  << "Average Intensity for Beam 2 (number of charges): " << m_intensity2 << std::endl
357  << "Energy (GeV): " << m_energy << std::endl
358  << "Creation time of the fill: " << boost::posix_time::to_iso_extended_string( cond::time::to_boost( m_createTime ) ) << std::endl
359  << "Begin time of Stable Beam flag: " << boost::posix_time::to_iso_extended_string( cond::time::to_boost( m_beginTime ) ) << std::endl
360  << "End time of the fill: " << boost::posix_time::to_iso_extended_string( cond::time::to_boost( m_endTime ) ) << std::endl
361  << "Injection scheme as given by LPC: " << m_injectionScheme << std::endl;
362  std::vector<unsigned short> bunchVector1 = this->bunchConfigurationForBeam1();
363  std::vector<unsigned short> bunchVector2 = this->bunchConfigurationForBeam2();
364  ss << "Bunches filled for Beam 1 (total " << bunchVector1.size() << "): ";
365  std::copy( bunchVector1.begin(), bunchVector1.end(), std::ostream_iterator<unsigned short>( ss, ", " ) );
366  ss << std::endl;
367  ss << "Bunches filled for Beam 2 (total " << bunchVector2.size() << "): ";
368  std::copy( bunchVector2.begin(), bunchVector2.end(), std::ostream_iterator<unsigned short>( ss, ", " ) );
369  ss << std::endl;
370 }
371 
372 //protected getters
373 std::bitset<FillInfo::bunchSlots+1> const & FillInfo::bunchBitsetForBeam1() const {
374  return m_bunchConfiguration1;
375 }
376 
377 std::bitset<FillInfo::bunchSlots+1> const & FillInfo::bunchBitsetForBeam2() const {
378  return m_bunchConfiguration2;
379 }
380 
381 //protected setters
382 void FillInfo::setBunchBitsetForBeam1( std::bitset<FillInfo::bunchSlots+1> const & bunchConfiguration ) {
383  m_bunchConfiguration1 = bunchConfiguration;
384 }
385 
386 void FillInfo::setBunchBitsetForBeam2( std::bitset<FillInfo::bunchSlots+1> const & bunchConfiguration ) {
387  m_bunchConfiguration2 = bunchConfiguration;
388 }
389 
390 std::ostream & operator<<( std::ostream & os, FillInfo fillInfo ) {
391  std::stringstream ss;
392  fillInfo.print( ss );
393  os << ss.str();
394  return os;
395 }
ParticleTypeId m_particles1
Definition: FillInfo.h:150
const double beta
int i
Definition: DBlmapReader.cc:9
void setBetaStar(float const &betaStar)
Definition: FillInfo.cc:273
float const intensityForBeam1() const
Definition: FillInfo.cc:183
void setCrossingAngle(float const &angle)
Definition: FillInfo.cc:269
unsigned short m_bunches1
Definition: FillInfo.h:148
ParticleType
Definition: FillInfo.h:13
unsigned short m_bunches2
Definition: FillInfo.h:148
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)
Definition: FillInfo.cc:306
void setCollidingBunches(unsigned short const &collidingBunches)
Definition: FillInfo.cc:249
void setBunchBitsetForBeam2(std::bitset< bunchSlots+1 > const &bunchConfiguration)
Definition: FillInfo.cc:386
cond::Time_t m_beginTime
Definition: FillInfo.h:152
0: Unidentified isolated particle
Definition: ParticleCode.h:19
ParticleTypeId const particleTypeForBeam1() const
Definition: FillInfo.cc:167
std::bitset< bunchSlots+1 > m_bunchConfiguration2
Definition: FillInfo.h:157
void setIntensityForBeam2(float const &intensity)
Definition: FillInfo.cc:281
unsigned short m_lhcFill
Definition: FillInfo.h:147
void setBunchBitsetForBeam1(std::bitset< bunchSlots+1 > const &bunchConfiguration)
Definition: FillInfo.cc:382
cond::Time_t const beginTime() const
Definition: FillInfo.cc:199
std::bitset< bunchSlots+1 > const & bunchBitsetForBeam2() const
Definition: FillInfo.cc:377
void setFillType(FillTypeId const &fillType)
Definition: FillInfo.cc:257
float m_crossingAngle
Definition: FillInfo.h:151
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
std::bitset< bunchSlots+1 > const & bunchBitsetForBeam1() const
Definition: FillInfo.cc:373
float m_betastar
Definition: FillInfo.h:151
void setIntensityForBeam1(float const &intensity)
Definition: FillInfo.cc:277
std::string m_injectionScheme
Definition: FillInfo.h:153
void setBunchesInBeam1(unsigned short const &bunches)
Definition: FillInfo.cc:241
FillTypeId const fillType() const
Definition: FillInfo.cc:163
bool equal(const T &first, const T &second)
Definition: Equal.h:34
FillInfo()
Definition: FillInfo.cc:72
unsigned short const fillNumber() const
Definition: FillInfo.cc:139
unsigned long long Time_t
Definition: Time.h:16
static std::vector< unsigned short > bitsetToVector(std::bitset< FillInfo::bunchSlots+1 > const &bs)
Definition: FillInfo.cc:8
unsigned short const bunchesInBeam1() const
Definition: FillInfo.cc:147
void setParticleTypeForBeam2(ParticleTypeId const &particleType)
Definition: FillInfo.cc:265
void setEndTime(cond::Time_t const &endTime)
Definition: FillInfo.cc:297
cond::Time_t m_endTime
Definition: FillInfo.h:152
unsigned short m_targetBunches
Definition: FillInfo.h:148
float m_energy
Definition: FillInfo.h:151
void setTargetBunches(unsigned short const &targetBunches)
Definition: FillInfo.cc:253
std::string const & injectionScheme() const
Definition: FillInfo.cc:207
float const betaStar() const
Definition: FillInfo.cc:179
FillTypeId m_fillType
Definition: FillInfo.h:149
bool isBunchInBeam1(size_t const &bunch) const
Definition: FillInfo.cc:219
void setFill(unsigned short const &lhcFill, bool const &fromData=true)
Definition: FillInfo.cc:115
~FillInfo()
Definition: FillInfo.cc:112
cond::Time_t const createTime() const
Definition: FillInfo.cc:195
bool m_isData
Definition: FillInfo.h:146
unsigned short m_collidingBunches
Definition: FillInfo.h:148
float m_intensity1
Definition: FillInfo.h:151
void setParticleTypeForBeam1(ParticleTypeId const &particleType)
Definition: FillInfo.cc:261
bool isBunchInBeam2(size_t const &bunch) const
Definition: FillInfo.cc:225
cond::Time_t m_createTime
Definition: FillInfo.h:152
bool is25nsBunchSpacing() const
Definition: FillInfo.cc:213
static std::string fillTypeToString(FillInfo::FillTypeId const &fillType)
Definition: FillInfo.cc:20
std::bitset< bunchSlots+1 > m_bunchConfiguration1
Definition: FillInfo.h:157
cond::Time_t const endTime() const
Definition: FillInfo.cc:203
static std::string particleTypeToString(FillInfo::ParticleTypeId const &particleType)
Definition: FillInfo.cc:45
float const energy() const
Definition: FillInfo.cc:191
ParticleTypeId const particleTypeForBeam2() const
Definition: FillInfo.cc:171
void setBeginTime(cond::Time_t const &beginTime)
Definition: FillInfo.cc:293
bool const isData() const
Definition: FillInfo.cc:143
unsigned short const bunchesInBeam2() const
Definition: FillInfo.cc:151
float const intensityForBeam2() const
Definition: FillInfo.cc:187
volatile std::atomic< bool > shutdown_flag false
std::vector< unsigned short > bunchConfigurationForBeam1() const
Definition: FillInfo.cc:232
void setBunchesInBeam2(unsigned short const &bunches)
Definition: FillInfo.cc:245
ParticleTypeId m_particles2
Definition: FillInfo.h:150
void setEnergy(float const &energy)
Definition: FillInfo.cc:285
unsigned short const targetBunches() const
Definition: FillInfo.cc:159
float const crossingAngle() const
Definition: FillInfo.cc:175
boost::posix_time::ptime to_boost(Time_t iValue)
tuple particleType
unsigned short const collidingBunches() const
Definition: FillInfo.cc:155
void setCreationTime(cond::Time_t const &createTime)
Definition: FillInfo.cc:289
std::vector< unsigned short > bunchConfigurationForBeam2() const
Definition: FillInfo.cc:236
void setInjectionScheme(std::string const &injectionScheme)
Definition: FillInfo.cc:301
void print(std::stringstream &ss) const
Definition: FillInfo.cc:344
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
float m_intensity2
Definition: FillInfo.h:151