CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
MixCollection< T > Class Template Reference

#include <MixCollection.h>

Classes

class  MixItr
 

Public Types

typedef MixItr iterator
 
typedef std::pair< int, int > range
 

Public Member Functions

iterator begin () const
 
range bunchrange () const
 
iterator end () const
 
const TgetObject (unsigned int ip) const
 
bool inRegistry () const
 
 MixCollection ()
 
 MixCollection (const CrossingFrame< T > *cf, const range bunchRange=range(-999, 999))
 
 MixCollection (const std::vector< const CrossingFrame< T > * > &cfs, const range bunchRange=range(-999, 999))
 
int size () const
 
int sizePileup () const
 
int sizeSignal () const
 

Private Member Functions

void init (const range bunchRange)
 

Private Attributes

range bunchRange_
 
std::vector< const CrossingFrame< T > * > crossingFrames_
 
bool inRegistry_
 
int nrDets_
 

Friends

class MixItr
 

Detailed Description

template<class T>
class MixCollection< T >

Definition at line 11 of file MixCollection.h.

Member Typedef Documentation

template<class T>
typedef MixItr MixCollection< T >::iterator

Definition at line 126 of file MixCollection.h.

template<class T>
typedef std::pair<int, int> MixCollection< T >::range

Definition at line 14 of file MixCollection.h.

Constructor & Destructor Documentation

template<class T >
MixCollection< T >::MixCollection ( )

Definition at line 146 of file MixCollection.h.

References MixCollection< T >::crossingFrames_, mps_fire::i, MixCollection< T >::init(), MixCollection< T >::inRegistry_, dataset::name, MixCollection< T >::nrDets_, and NULL.

146  : bunchRange_(0, 0), inRegistry_(false), nrDets_(0) {
147  crossingFrames_.push_back(NULL);
148 }
#define NULL
Definition: scimark2.h:8
std::vector< const CrossingFrame< T > * > crossingFrames_
template<class T>
MixCollection< T >::MixCollection ( const CrossingFrame< T > *  cf,
const range  bunchRange = range(-999, 999) 
)
template<class T>
MixCollection< T >::MixCollection ( const std::vector< const CrossingFrame< T > * > &  cfs,
const range  bunchRange = range(-999, 999) 
)

Member Function Documentation

template<class T >
MixCollection< T >::MixItr MixCollection< T >::begin ( void  ) const
template<class T>
range MixCollection< T >::bunchrange ( ) const
inline

Definition at line 19 of file MixCollection.h.

References MixCollection< T >::bunchRange_.

19 { return bunchRange_; }
template<class T >
MixCollection< T >::MixItr MixCollection< T >::end ( void  ) const
template<class T>
const T& MixCollection< T >::getObject ( unsigned int  ip) const
inline

Definition at line 27 of file MixCollection.h.

References MixCollection< T >::crossingFrames_, Exception, gen::n, AlCaHLTBitMon_ParallelJobs::p, alignCSCRings::s, and MixCollection< T >::size().

Referenced by GenParticleProducer::produce().

27  {
28  if (ip >= (unsigned int)size())
29  throw cms::Exception("BadIndex")
30  << "MixCollection::getObject called with an invalid index!"; // ip >= 0, since ip is unsigned
31  int n = ip;
32  /*
33 - int iframe=0;
34 - for (unsigned int ii=0;ii<crossingFrames_.size();++ii) {
35 - iframe=ii;
36 - int s=crossingFrames_[iframe]->getNrSignals()+crossingFrames_[iframe]->getNrPileups();
37 - if (n<s) break;
38 */
39  for (unsigned int iframe = 0; iframe < crossingFrames_.size(); ++iframe) {
40  int s = crossingFrames_[iframe]->getNrSignals();
41  if (n < s)
42  return crossingFrames_[iframe]->getObject(n);
43  n = n - s;
44  }
45  /*
46  return crossingFrames_[iframe]->getObject(n);
47 */
48  for (unsigned int iframe = 0; iframe < crossingFrames_.size(); ++iframe) {
49  int s = crossingFrames_[iframe]->getNrSignals();
50  int p = crossingFrames_[iframe]->getNrPileups();
51  if (n < p)
52  return crossingFrames_[iframe]->getObject(s + n);
53  n = n - p;
54  }
55  throw cms::Exception("InternalError") << "MixCollection::getObject reached impossible condition";
56  }
int size() const
Definition: MixCollection.h:20
std::vector< const CrossingFrame< T > * > crossingFrames_
template<class T>
void MixCollection< T >::init ( const range  bunchRange)
private

Definition at line 185 of file MixCollection.h.

References MixCollection< T >::bunchRange_, MixCollection< T >::crossingFrames_, Exception, plotBeamSpotDB::first, and plotBeamSpotDB::last.

Referenced by MixCollection< T >::MixCollection().

185  {
186  bunchRange_ = bunchRange;
187 
188  //verify whether bunchrange is ok
189  // in case of several crossingFrames, we have verified before that they have the same bunchrange
190  range defaultrange = crossingFrames_[0]->getBunchRange();
191  if (bunchRange_ == range(-999, 999))
192  bunchRange_ = defaultrange;
193  else if (bunchRange_ != defaultrange) {
194  int first = defaultrange.first;
195  int last = defaultrange.second;
196  if (bunchRange_.first < defaultrange.first || bunchRange_.second > defaultrange.second)
197  throw cms::Exception("BadRunRange")
198  << " You are asking for a runrange (" << bunchRange_.first << "," << bunchRange_.second
199  << "), outside of the existing runrange (" << defaultrange.first << ", " << defaultrange.second << ")\n";
200  bunchRange_ = range(first, last);
201  }
202 }
std::pair< int, int > range
Definition: MixCollection.h:14
std::vector< const CrossingFrame< T > * > crossingFrames_
template<class T>
bool MixCollection< T >::inRegistry ( ) const
inline

Definition at line 24 of file MixCollection.h.

References MixCollection< T >::inRegistry_.

24 { return inRegistry_; }
template<class T>
int MixCollection< T >::size ( void  ) const
inline
template<class T >
int MixCollection< T >::sizePileup ( ) const

Definition at line 205 of file MixCollection.h.

References MixCollection< T >::crossingFrames_, mps_fire::i, MixCollection< T >::nrDets_, and alignCSCRings::s.

Referenced by MixCollection< T >::size().

205  {
206  // get size cumulated for all subdetectors
207  int s = 0;
208  for (int i = 0; i < nrDets_; ++i) {
209  s += crossingFrames_[i]->getNrPileups();
210  }
211  return s;
212 }
std::vector< const CrossingFrame< T > * > crossingFrames_
template<class T >
int MixCollection< T >::sizeSignal ( ) const

Definition at line 215 of file MixCollection.h.

References MixCollection< T >::crossingFrames_, mps_fire::i, MixCollection< T >::nrDets_, and alignCSCRings::s.

Referenced by MixCollection< T >::size().

215  {
216  int s = 0;
217  for (int i = 0; i < nrDets_; ++i) {
218  s += crossingFrames_[i]->getNrSignals();
219  }
220  return s;
221 }
std::vector< const CrossingFrame< T > * > crossingFrames_

Friends And Related Function Documentation

template<class T>
friend class MixItr
friend

Definition at line 58 of file MixCollection.h.

Referenced by MixCollection< T >::begin(), and MixCollection< T >::end().

Member Data Documentation

template<class T>
range MixCollection< T >::bunchRange_
private

Definition at line 133 of file MixCollection.h.

Referenced by MixCollection< T >::bunchrange(), and MixCollection< T >::init().

template<class T>
std::vector<const CrossingFrame<T> *> MixCollection< T >::crossingFrames_
private
template<class T>
bool MixCollection< T >::inRegistry_
private
template<class T>
int MixCollection< T >::nrDets_
private