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 bunch slot number is in the circulating bunch configuration
212 bool FillInfo::isBunchInBeam1( size_t const & bunch ) const {
213  if( bunch == 0 )
214  throw std::out_of_range( "0 not allowed" ); //CMS starts counting bunch crossing from 1!
215  return m_bunchConfiguration1.test( bunch );
216 }
217 
218 bool FillInfo::isBunchInBeam2( size_t const & bunch ) const {
219  if( bunch == 0 )
220  throw std::out_of_range( "0 not allowed" ); //CMS starts counting bunch crossing from 1!
221  return m_bunchConfiguration2.test( bunch );
222 }
223 
224 //member functions returning *by value* a vector with all filled bunch slots
225 std::vector<unsigned short> FillInfo::bunchConfigurationForBeam1() const {
227 }
228 
229 std::vector<unsigned short> FillInfo::bunchConfigurationForBeam2() const {
231 }
232 
233 //setters
234 void FillInfo::setBunchesInBeam1( unsigned short const & bunches ) {
235  m_bunches1 = bunches;
236 }
237 
238 void FillInfo::setBunchesInBeam2( unsigned short const & bunches ) {
239  m_bunches2 = bunches;
240 }
241 
242 void FillInfo::setCollidingBunches( unsigned short const & collidingBunches ) {
244 }
245 
246 void FillInfo::setTargetBunches( unsigned short const & targetBunches ) {
248 }
249 
250 void FillInfo::setFillType( FillInfo::FillTypeId const & fillType ) {
252 }
253 
256 }
257 
260 }
261 
262 void FillInfo::setCrossingAngle( float const & angle ) {
264 }
265 
266 void FillInfo::setBetaStar( float const & betaStar ) {
268 }
269 
270 void FillInfo::setIntensityForBeam1( float const & intensity ) {
271  m_intensity1 = intensity;
272 }
273 
274 void FillInfo::setIntensityForBeam2( float const & intensity ) {
275  m_intensity2 = intensity;
276 }
277 
278 void FillInfo::setEnergy( float const & energy ) {
279  m_energy = energy;
280 }
281 
282 void FillInfo::setCreationTime( cond::Time_t const & createTime ) {
284 }
285 
286 void FillInfo::setBeginTime( cond::Time_t const & beginTime ) {
288 }
289 
290 void FillInfo::setEndTime( cond::Time_t const & endTime ) {
291  m_endTime = endTime;
292 }
293 
294 void FillInfo::setInjectionScheme( std::string const & injectionScheme ) {
296 }
297 
298 //sets all values in one go
299 void FillInfo::setBeamInfo( unsigned short const & bunches1
300  ,unsigned short const & bunches2
301  ,unsigned short const & collidingBunches
302  ,unsigned short const & targetBunches
303  ,FillTypeId const & fillType
304  ,ParticleTypeId const & particleType1
305  ,ParticleTypeId const & particleType2
306  ,float const & angle
307  ,float const & beta
308  ,float const & intensity1
309  ,float const & intensity2
310  ,float const & energy
311  ,cond::Time_t const & createTime
312  ,cond::Time_t const & beginTime
313  ,cond::Time_t const & endTime
314  ,std::string const & scheme
315  ,std::bitset<bunchSlots+1> const & bunchConf1
316  ,std::bitset<bunchSlots+1> const & bunchConf2 ) {
317  this->setBunchesInBeam1( bunches1 );
318  this->setBunchesInBeam2( bunches2 );
319  this->setCollidingBunches( collidingBunches );
320  this->setTargetBunches( targetBunches );
321  this->setFillType( fillType );
322  this->setParticleTypeForBeam1( particleType1 );
323  this->setParticleTypeForBeam2( particleType2 );
324  this->setCrossingAngle( angle );
325  this->setBetaStar( beta );
326  this->setIntensityForBeam1( intensity1 );
327  this->setIntensityForBeam2( intensity2 );
328  this->setEnergy( energy );
329  this->setCreationTime( createTime );
330  this->setBeginTime( beginTime );
331  this->setEndTime( endTime );
332  this->setInjectionScheme( scheme );
333  this->setBunchBitsetForBeam1( bunchConf1 );
334  this->setBunchBitsetForBeam2( bunchConf2 );
335 }
336 
337 void FillInfo::print( std::stringstream & ss ) const {
338  ss << "LHC fill: " << m_lhcFill << std::endl
339  << "Bunches in Beam 1: " << m_bunches1 << std::endl
340  << "Bunches in Beam 2: " << m_bunches2 << std::endl
341  << "Colliding bunches at IP5: " << m_collidingBunches << std::endl
342  << "Target bunches at IP5: " << m_targetBunches << std::endl
343  << "Fill type: " << fillTypeToString( m_fillType ) << std::endl
344  << "Particle type for Beam 1: " << particleTypeToString( m_particles1 ) << std::endl
345  << "Particle type for Beam 2: " << particleTypeToString( m_particles2 ) << std::endl
346  << "Crossing angle (urad): " << m_crossingAngle << std::endl
347  << "Beta star (cm): " << m_betastar << std::endl
348  << "Average Intensity for Beam 1 (number of charges): " << m_intensity1 << std::endl
349  << "Average Intensity for Beam 2 (number of charges): " << m_intensity2 << std::endl
350  << "Energy (GeV): " << m_energy << std::endl
351  << "Creation time of the fill: " << boost::posix_time::to_iso_extended_string( cond::time::to_boost( m_createTime ) ) << std::endl
352  << "Begin time of Stable Beam flag: " << boost::posix_time::to_iso_extended_string( cond::time::to_boost( m_beginTime ) ) << std::endl
353  << "End time of the fill: " << boost::posix_time::to_iso_extended_string( cond::time::to_boost( m_endTime ) ) << std::endl
354  << "Injection scheme as given by LPC: " << m_injectionScheme << std::endl;
355  std::vector<unsigned short> bunchVector1 = this->bunchConfigurationForBeam1();
356  std::vector<unsigned short> bunchVector2 = this->bunchConfigurationForBeam2();
357  ss << "Bunches filled for Beam 1 (total " << bunchVector1.size() << "): ";
358  std::copy( bunchVector1.begin(), bunchVector1.end(), std::ostream_iterator<unsigned short>( ss, ", " ) );
359  ss << std::endl;
360  ss << "Bunches filled for Beam 2 (total " << bunchVector2.size() << "): ";
361  std::copy( bunchVector2.begin(), bunchVector2.end(), std::ostream_iterator<unsigned short>( ss, ", " ) );
362  ss << std::endl;
363 }
364 
365 //protected getters
366 std::bitset<FillInfo::bunchSlots+1> const & FillInfo::bunchBitsetForBeam1() const {
367  return m_bunchConfiguration1;
368 }
369 
370 std::bitset<FillInfo::bunchSlots+1> const & FillInfo::bunchBitsetForBeam2() const {
371  return m_bunchConfiguration2;
372 }
373 
374 //protected setters
375 void FillInfo::setBunchBitsetForBeam1( std::bitset<FillInfo::bunchSlots+1> const & bunchConfiguration ) {
376  m_bunchConfiguration1 = bunchConfiguration;
377 }
378 
379 void FillInfo::setBunchBitsetForBeam2( std::bitset<FillInfo::bunchSlots+1> const & bunchConfiguration ) {
380  m_bunchConfiguration2 = bunchConfiguration;
381 }
382 
383 std::ostream & operator<<( std::ostream & os, FillInfo fillInfo ) {
384  std::stringstream ss;
385  fillInfo.print( ss );
386  os << ss.str();
387  return os;
388 }
ParticleTypeId m_particles1
Definition: FillInfo.h:146
const double beta
int i
Definition: DBlmapReader.cc:9
void setBetaStar(float const &betaStar)
Definition: FillInfo.cc:266
float const intensityForBeam1() const
Definition: FillInfo.cc:183
void setCrossingAngle(float const &angle)
Definition: FillInfo.cc:262
unsigned short m_bunches1
Definition: FillInfo.h:144
ParticleType
Definition: FillInfo.h:13
unsigned short m_bunches2
Definition: FillInfo.h:144
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:299
void setCollidingBunches(unsigned short const &collidingBunches)
Definition: FillInfo.cc:242
void setBunchBitsetForBeam2(std::bitset< bunchSlots+1 > const &bunchConfiguration)
Definition: FillInfo.cc:379
cond::Time_t m_beginTime
Definition: FillInfo.h:148
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:153
void setIntensityForBeam2(float const &intensity)
Definition: FillInfo.cc:274
unsigned short m_lhcFill
Definition: FillInfo.h:143
void setBunchBitsetForBeam1(std::bitset< bunchSlots+1 > const &bunchConfiguration)
Definition: FillInfo.cc:375
cond::Time_t const beginTime() const
Definition: FillInfo.cc:199
std::bitset< bunchSlots+1 > const & bunchBitsetForBeam2() const
Definition: FillInfo.cc:370
void setFillType(FillTypeId const &fillType)
Definition: FillInfo.cc:250
float m_crossingAngle
Definition: FillInfo.h:147
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
std::bitset< bunchSlots+1 > const & bunchBitsetForBeam1() const
Definition: FillInfo.cc:366
float m_betastar
Definition: FillInfo.h:147
void setIntensityForBeam1(float const &intensity)
Definition: FillInfo.cc:270
std::string m_injectionScheme
Definition: FillInfo.h:149
void setBunchesInBeam1(unsigned short const &bunches)
Definition: FillInfo.cc:234
FillTypeId const fillType() const
Definition: FillInfo.cc:163
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
tuple particleType
Definition: autophobj.py:28
void setParticleTypeForBeam2(ParticleTypeId const &particleType)
Definition: FillInfo.cc:258
void setEndTime(cond::Time_t const &endTime)
Definition: FillInfo.cc:290
cond::Time_t m_endTime
Definition: FillInfo.h:148
unsigned short m_targetBunches
Definition: FillInfo.h:144
float m_energy
Definition: FillInfo.h:147
void setTargetBunches(unsigned short const &targetBunches)
Definition: FillInfo.cc:246
std::string const & injectionScheme() const
Definition: FillInfo.cc:207
float const betaStar() const
Definition: FillInfo.cc:179
FillTypeId m_fillType
Definition: FillInfo.h:145
bool isBunchInBeam1(size_t const &bunch) const
Definition: FillInfo.cc:212
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:142
unsigned short m_collidingBunches
Definition: FillInfo.h:144
float m_intensity1
Definition: FillInfo.h:147
void setParticleTypeForBeam1(ParticleTypeId const &particleType)
Definition: FillInfo.cc:254
bool isBunchInBeam2(size_t const &bunch) const
Definition: FillInfo.cc:218
cond::Time_t m_createTime
Definition: FillInfo.h:148
static std::string fillTypeToString(FillInfo::FillTypeId const &fillType)
Definition: FillInfo.cc:20
std::bitset< bunchSlots+1 > m_bunchConfiguration1
Definition: FillInfo.h:153
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:286
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:225
void setBunchesInBeam2(unsigned short const &bunches)
Definition: FillInfo.cc:238
ParticleTypeId m_particles2
Definition: FillInfo.h:146
void setEnergy(float const &energy)
Definition: FillInfo.cc:278
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)
unsigned short const collidingBunches() const
Definition: FillInfo.cc:155
void setCreationTime(cond::Time_t const &createTime)
Definition: FillInfo.cc:282
std::vector< unsigned short > bunchConfigurationForBeam2() const
Definition: FillInfo.cc:229
void setInjectionScheme(std::string const &injectionScheme)
Definition: FillInfo.cc:294
void print(std::stringstream &ss) const
Definition: FillInfo.cc:337
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
float m_intensity2
Definition: FillInfo.h:147