CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends

MixCollection< T > Class Template Reference

#include <MixCollection.h>

List of all members.

Classes

class  MixItr

Public Types

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

Public Member Functions

iterator begin ()
range bunchrange () const
iterator end ()
const TgetObject (unsigned int ip) const
bool inRegistry () const
 MixCollection (const CrossingFrame< T > *cf, const range bunchRange=range(-999, 999))
 MixCollection ()
 MixCollection (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 10 of file MixCollection.h.


Member Typedef Documentation

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

Definition at line 114 of file MixCollection.h.

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

Definition at line 15 of file MixCollection.h.


Constructor & Destructor Documentation

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

Definition at line 135 of file MixCollection.h.

References MixCollection< T >::crossingFrames_, and NULL.

                                : 
  bunchRange_(0,0), inRegistry_(false), nrDets_(0)
{
  crossingFrames_.push_back(NULL);
}
template<class T>
MixCollection< T >::MixCollection ( const CrossingFrame< T > *  cf,
const range  bunchRange = range(-999,999) 
)

Definition at line 142 of file MixCollection.h.

References gather_cfg::cout, MixCollection< T >::crossingFrames_, MixCollection< T >::init(), MixCollection< T >::inRegistry_, mergeVDriftHistosByStation::name, and MixCollection< T >::nrDets_.

                                                                                            : 
  inRegistry_(false),nrDets_(0) 
{
  nrDets_=1;
  inRegistry_=true;
  if (cf) {
    crossingFrames_.push_back(cf);
    init(bunchRange);
  }
  else std::cout <<"Could not construct MixCollection for "<<typeid(T).name() <<", pointer to CrossingFrame invalid!"<<std::endl;
} 
template<class T>
MixCollection< T >::MixCollection ( std::vector< const CrossingFrame< T > * >  cfs,
const range  bunchRange = range(-999,999) 
)

Definition at line 155 of file MixCollection.h.

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

                                                                                                          :  inRegistry_(false) , nrDets_(0)
{
  // first, verify that all CrossingFrames have the same bunchrange
  range bR=cfs[0]->getBunchRange();
  for (unsigned int i=1;i<cfs.size();++i) {
    if (bR!= cfs[i]->getBunchRange()) throw cms::Exception("Incompatible CrossingFrames")<<"You gave as input CrossingFrames with different bunchRanges!";
  }

  //set necessary variables
  for (unsigned int i=0;i<cfs.size();++i) {
    nrDets_++;
    crossingFrames_.push_back(cfs[i]);
    inRegistry_=true;  // true if at least one is present
  }

  init(bunchRange);
}

Member Function Documentation

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

Definition at line 22 of file MixCollection.h.

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

Definition at line 30 of file MixCollection.h.

Referenced by TrackerHitAssociator::associateHit(), TrackerHitAssociator::associateSimpleRecHitCluster(), and GenParticleProducer::produce().

                                              { 
     if (ip>=(unsigned int)size()) throw cms::Exception("BadIndex")<<"MixCollection::getObject called with an invalid index!"; // ip >= 0, since ip is unsigned
     int n=ip;
/*
-    int iframe=0;
-    for (unsigned int ii=0;ii<crossingFrames_.size();++ii) {
-      iframe=ii;
-      int s=crossingFrames_[iframe]->getNrSignals()+crossingFrames_[iframe]->getNrPileups();
-      if (n<s) break;
*/
    for (unsigned int iframe=0;iframe<crossingFrames_.size();++iframe) {
      int s=crossingFrames_[iframe]->getNrSignals();
      if (n<s) return crossingFrames_[iframe]->getObject(n);
       n=n-s;
     }
/*
    return crossingFrames_[iframe]->getObject(n);
*/
    for (unsigned int iframe=0;iframe<crossingFrames_.size();++iframe) {
      int s=crossingFrames_[iframe]->getNrSignals();
      int p=crossingFrames_[iframe]->getNrPileups();
      if (n<p) return crossingFrames_[iframe]->getObject(s+n);
      n=n-p;
    }
    throw cms::Exception("InternalError")<<"MixCollection::getObject reached impossible condition"; 
   }
template<class T >
void MixCollection< T >::init ( const range  bunchRange) [private]

Definition at line 174 of file MixCollection.h.

References Exception, first, and prof2calltree::last.

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

                                                              {

  bunchRange_=bunchRange;

  //verify whether bunchrange is ok
  // in case of several crossingFrames, we have verified before that they have the same bunchrange
  range defaultrange=crossingFrames_[0]->getBunchRange();
  if (bunchRange_==range(-999,999)) bunchRange_=defaultrange;
  else if (bunchRange_!=defaultrange ) {
    int first=defaultrange.first;
    int last = defaultrange.second;
    if (bunchRange_.first<defaultrange.first || bunchRange_.second>defaultrange.second )  throw cms::Exception("BadRunRange")<<" You are asking for a runrange ("<<bunchRange_.first<<","<<bunchRange_.second<<"), outside of the existing runrange ("<<defaultrange.first<<", "<<defaultrange.second<<")\n";
    bunchRange_=range(first,last);
  }
}
template<class T>
bool MixCollection< T >::inRegistry ( ) const [inline]

Definition at line 27 of file MixCollection.h.

Referenced by EcalDigiProducer::produce().

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

Definition at line 190 of file MixCollection.h.

References i, and asciidump::s.

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

                                                            {
  // get size cumulated for all subdetectors
  int s=0;
  for (int i=0;i<nrDets_;++i) {
    s+=crossingFrames_[i]->getNrPileups();
  }  return s;
}
template<class T >
int MixCollection< T >::sizeSignal ( ) const

Definition at line 198 of file MixCollection.h.

References i, and asciidump::s.

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

                                                            {
  int s=0;
  for (int i=0;i<nrDets_;++i) {
    s+=crossingFrames_[i]->getNrSignals();
  }
  return s;
}

Friends And Related Function Documentation

template<class T>
friend class MixItr [friend]

Definition at line 57 of file MixCollection.h.

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


Member Data Documentation

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

Definition at line 121 of file MixCollection.h.

Referenced by MixCollection< PSimHit >::bunchrange().

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]