CMS 3D CMS Logo

CrossingFrame< T > Class Template Reference

CrossingFrame is the result of the Sim Mixing Module. More...

#include <SimDataFormats/CrossingFrame/interface/CrossingFrame.h>

List of all members.

Public Member Functions

template<>
void addPileups (const int bcr, const std::vector< edm::HepMCProduct > *mcps, unsigned int evtNr, int vertexoffset, bool checkTof, bool high)
template<>
void addPileups (const int bcr, const std::vector< PCaloHit > *calohits, unsigned int evtNr, int vertexoffset, bool checkTof, bool high)
template<>
void addPileups (const int bcr, const std::vector< SimVertex > *simvertices, unsigned int evtNr, int vertexoffset, bool checkTof, bool high)
template<>
void addPileups (const int bcr, const std::vector< SimTrack > *simtracks, unsigned int evtNr, int vertexoffset, bool checkTof, bool high)
void addPileups (const int bcr, const std::vector< T > *vec, unsigned int evtId, int vertexoffset=0, bool checkTof=false, bool high=false)
void addSignals (const std::vector< T > *vec, edm::EventID id)
 CrossingFrame (int minb, int maxb, int bunchsp, std::string subdet, unsigned int maxNbSources)
 CrossingFrame ()
int getBunchCrossing (unsigned int ip) const
std::pair< int, intgetBunchRange () const
int getBunchSpace () const
edm::EventID getEventID () const
unsigned int getNrPileups (int bcr) const
unsigned int getNrPileups () const
unsigned int getNrSignals () const
const T & getObject (unsigned int ip) const
void getPileups (typename std::vector< T >::const_iterator &first, typename std::vector< T >::const_iterator &last) const
void getSignal (typename std::vector< T >::const_iterator &first, typename std::vector< T >::const_iterator &last) const
int getSourceType (unsigned int ip) const
CrossingFrameoperator= (CrossingFrame const &rhs)
void print (int level=0) const
void setBcrOffset ()
void setSourceOffset (const unsigned int s)
void swap (CrossingFrame &other)
 ~CrossingFrame ()

Static Public Attributes

static const int highTrackTof
static const int limHighLowTof
static const int lowTrackTof
static const int minLowTof

Private Attributes

int bunchSpace_
int firstCrossing_
edm::EventID id_
edm::EventID idFirstPileup_
int lastCrossing_
unsigned int maxNbSources_
unsigned int pileupFileNr_
std::vector< unsigned intpileupOffsetsBcr_
std::vector< std::vector
< unsigned int > > 
pileupOffsetsSource_
std::vector< T > pileups_
std::vector< T > signals_
std::string subdet_


Detailed Description

template<class T>
class CrossingFrame< T >

CrossingFrame is the result of the Sim Mixing Module.

Author:
Ursula Berthon, Claude Charlot, LLR Palaiseau
Version:
1st Version July 2005

2nd Version Sep 2005

3rd Version Nov 2007

Definition at line 26 of file CrossingFrame.h.


Constructor & Destructor Documentation

template<class T>
CrossingFrame< T >::CrossingFrame (  )  [inline]

Definition at line 32 of file CrossingFrame.h.

template<class T>
CrossingFrame< T >::CrossingFrame ( int  minb,
int  maxb,
int  bunchsp,
std::string  subdet,
unsigned int  maxNbSources 
) [inline]

Definition at line 117 of file CrossingFrame.h.

References CrossingFrame< T >::firstCrossing_, i, CrossingFrame< T >::lastCrossing_, CrossingFrame< T >::maxNbSources_, CrossingFrame< T >::pileupOffsetsBcr_, and CrossingFrame< T >::pileupOffsetsSource_.

00117                                                                                                            :firstCrossing_(minb), lastCrossing_(maxb), bunchSpace_(bunchsp),subdet_(subdet),maxNbSources_(maxNbSources) {
00118  pileupOffsetsSource_.resize(maxNbSources_);
00119  for (unsigned int i=0;i<maxNbSources_;++i)
00120    pileupOffsetsSource_[i].reserve(-firstCrossing_+lastCrossing_+1);
00121 
00122 //FIXME: should we force around 0 or so??
00123   pileupOffsetsBcr_.reserve(-firstCrossing_+lastCrossing_+1);
00124 }

template<class T>
CrossingFrame< T >::~CrossingFrame (  )  [inline]

Definition at line 35 of file CrossingFrame.h.

00035 {;}


Member Function Documentation

template<>
void CrossingFrame< edm::HepMCProduct >::addPileups ( const int  bcr,
const std::vector< edm::HepMCProduct > *  mcps,
unsigned int  evtNr,
int  vertexoffset,
bool  checkTof,
bool  high 
) [inline]

Definition at line 91 of file CrossingFrame.cc.

References i, and CrossingFrame< T >::pileups_.

00091                                                                                                                                                                    { 
00092   for (unsigned int i=0;i<mcps->size();++i) {
00093     pileups_.push_back((*mcps)[i]);
00094   }
00095 }

template<>
void CrossingFrame< PCaloHit >::addPileups ( const int  bcr,
const std::vector< PCaloHit > *  calohits,
unsigned int  evtNr,
int  vertexoffset,
bool  checkTof,
bool  high 
) [inline]

Definition at line 80 of file CrossingFrame.cc.

References CrossingFrame< T >::bunchSpace_, i, id, CrossingFrame< T >::pileups_, and PCaloHit::setEventId().

00080                                                                                                                                                          { 
00081 
00082   EncodedEventId id(bcr,evtNr);
00083   for (unsigned int i=0;i<calohits->size();++i) {
00084     PCaloHit hit((*calohits)[i].id(),(*calohits)[i].energyEM(),(*calohits)[i].energyHad(),(*calohits)[i].time()+bcr*bunchSpace_,(*calohits)[i].geantTrackId());
00085     hit.setEventId(id);
00086     pileups_.push_back(hit);
00087   }
00088 }

template<>
void CrossingFrame< SimVertex >::addPileups ( const int  bcr,
const std::vector< SimVertex > *  simvertices,
unsigned int  evtNr,
int  vertexoffset,
bool  checkTof,
bool  high 
) [inline]

Definition at line 37 of file CrossingFrame.cc.

References CrossingFrame< T >::bunchSpace_, i, id, CrossingFrame< T >::pileups_, CoreSimVertex::setEventId(), t, x, y, and z.

00037                                                                                                                                                               { 
00038 
00039   EncodedEventId id(bcr,evtNr);
00040   for (unsigned int i=0;i<simvertices->size();++i) {
00041     SimVertex vertex(math::XYZVectorD( (*simvertices)[i].position().x(),
00042                                        (*simvertices)[i].position().y(),
00043                                        (*simvertices)[i].position().z() ),
00044                      ((*simvertices)[i].position()).t()+bcr*bunchSpace_,
00045                      (*simvertices)[i].parentIndex());
00046     
00047     //    SimVertex vertex((*simvertices)[i].position(),((*simvertices)[i].position())[3]+bcr*bunchSpace_,(*simvertices)[i].parentIndex());
00048     vertex.setEventId(EncodedEventId(bcr,evtNr));
00049     pileups_.push_back(vertex);
00050   }
00051 }

template<>
void CrossingFrame< SimTrack >::addPileups ( const int  bcr,
const std::vector< SimTrack > *  simtracks,
unsigned int  evtNr,
int  vertexoffset,
bool  checkTof,
bool  high 
) [inline]

Definition at line 19 of file CrossingFrame.cc.

References i, id, CrossingFrame< T >::pileups_, CoreSimTrack::setEventId(), CoreSimTrack::setTrackId(), and track.

00019                                                                                                                                                           { 
00020 
00021   EncodedEventId id(bcr,evtNr);
00022   for (unsigned int i=0;i<simtracks->size();++i)
00023     if ((*simtracks)[i].noVertex()) {
00024       SimTrack track((*simtracks)[i]);
00025       track.setEventId(id);
00026       pileups_.push_back(track);
00027     }
00028     else {
00029       SimTrack track((*simtracks)[i].type(),(*simtracks)[i].momentum(),(*simtracks)[i].vertIndex()+vertexoffset, (*simtracks)[i].genpartIndex());
00030       track.setEventId(id);
00031       track.setTrackId((*simtracks)[i].trackId());
00032       pileups_.push_back(track);
00033     }
00034 }

template<class T>
void CrossingFrame< T >::addPileups ( const int  bcr,
const std::vector< T > *  vec,
unsigned int  evtId,
int  vertexoffset = 0,
bool  checkTof = false,
bool  high = false 
)

template<class T>
void CrossingFrame< T >::addSignals ( const std::vector< T > *  vec,
edm::EventID  id 
) [inline]

Definition at line 163 of file CrossingFrame.h.

References CrossingFrame< T >::id_, and CrossingFrame< T >::signals_.

00163                                                                        {
00164   id_=id;
00165   signals_=*vec;
00166 }

template<class T>
int CrossingFrame< T >::getBunchCrossing ( unsigned int  ip  )  const [inline]

Definition at line 190 of file CrossingFrame.h.

References CrossingFrame< T >::firstCrossing_, CrossingFrame< T >::lastCrossing_, CrossingFrame< T >::pileupOffsetsBcr_, and CrossingFrame< T >::pileups_.

Referenced by CrossingFrame< T >::getSourceType().

00190                                                             {
00191   // return the bcr for a certain position in the pileup vector
00192     for (unsigned int ii=1;ii<pileupOffsetsBcr_.size();ii++){
00193       if (ip>=pileupOffsetsBcr_[ii-1] && ip<pileupOffsetsBcr_[ii]) return ii+firstCrossing_-1;
00194     }
00195     if (ip<pileups_.size()) return lastCrossing_;
00196     else return 999;
00197 }

template<class T>
std::pair<int,int> CrossingFrame< T >::getBunchRange (  )  const [inline]

Definition at line 55 of file CrossingFrame.h.

00055 {return std::pair<int,int>(firstCrossing_,lastCrossing_);}

template<class T>
int CrossingFrame< T >::getBunchSpace (  )  const [inline]

Definition at line 56 of file CrossingFrame.h.

00056 {return bunchSpace_;}

template<class T>
edm::EventID CrossingFrame< T >::getEventID (  )  const [inline]

Definition at line 54 of file CrossingFrame.h.

00054 {return id_;}

template<class T>
unsigned int CrossingFrame< T >::getNrPileups ( int  bcr  )  const [inline]

Definition at line 66 of file CrossingFrame.h.

template<class T>
unsigned int CrossingFrame< T >::getNrPileups (  )  const [inline]

Definition at line 65 of file CrossingFrame.h.

Referenced by CrossingFrame< PSimHit >::getObject().

00065 {return pileups_.size();} 

template<class T>
unsigned int CrossingFrame< T >::getNrSignals (  )  const [inline]

Definition at line 64 of file CrossingFrame.h.

Referenced by CrossingFrame< PSimHit >::getObject().

00064 {return signals_.size();} 

template<class T>
const T& CrossingFrame< T >::getObject ( unsigned int  ip  )  const [inline]

Definition at line 71 of file CrossingFrame.h.

00071                                              { 
00072     if (ip<0 || ip>getNrSignals()+getNrPileups()) throw cms::Exception("BadIndex")<<"CrossingFrame::getObject called with an invalid index!";
00073     if (ip<getNrSignals()) {
00074       return signals_[ip];
00075     }
00076     else  {
00077       return pileups_[ip-getNrSignals()];
00078     }
00079   }  

template<class T>
void CrossingFrame< T >::getPileups ( typename std::vector< T >::const_iterator &  first,
typename std::vector< T >::const_iterator &  last 
) const [inline]

Definition at line 169 of file CrossingFrame.h.

References CrossingFrame< T >::pileups_.

00169                                                                                                                              {
00170   first=pileups_.begin();
00171   last=pileups_.end();
00172 }

template<class T>
void CrossingFrame< T >::getSignal ( typename std::vector< T >::const_iterator &  first,
typename std::vector< T >::const_iterator &  last 
) const [inline]

Definition at line 59 of file CrossingFrame.h.

00059                                                                                                              {
00060     first=signals_.begin();
00061     last=signals_.end();
00062   }

template<class T>
int CrossingFrame< T >::getSourceType ( unsigned int  ip  )  const [inline]

Definition at line 179 of file CrossingFrame.h.

References CrossingFrame< T >::firstCrossing_, CrossingFrame< T >::getBunchCrossing(), i, and CrossingFrame< T >::pileupOffsetsSource_.

00179                                                           {
00180   // decide to which source belongs object with index ip in the pileup vector
00181   // pileup=0, cosmics=1, beam halo+ =2, beam halo- =3 forward =4
00182   unsigned int bcr= getBunchCrossing(ip)-firstCrossing_; //starts at 0
00183   for (unsigned int i=0;i<pileupOffsetsSource_.size()-1;++i) {
00184     if (ip>=(pileupOffsetsSource_[i])[bcr] && ip <(pileupOffsetsSource_[i+1])[bcr]) return i;
00185   }
00186   return pileupOffsetsSource_.size()-1;
00187 }

template<typename T>
CrossingFrame< T > & CrossingFrame< T >::operator= ( CrossingFrame< T > const &  rhs  )  [inline]

Definition at line 156 of file CrossingFrame.h.

References CrossingFrame< T >::swap(), and pyDBSRunClass::temp.

00156                                                        {
00157   CrossingFrame<T> temp(rhs);
00158   this->swap(temp);
00159   return *this;
00160 }

template<class T>
void CrossingFrame< T >::print ( int  level = 0  )  const [inline]

Definition at line 175 of file CrossingFrame.h.

00175                                             {
00176 }

template<class T>
void CrossingFrame< T >::setBcrOffset (  )  [inline]

Definition at line 46 of file CrossingFrame.h.

00046                       {
00047     pileupOffsetsBcr_.push_back(pileups_.size());
00048   }

template<class T>
void CrossingFrame< T >::setSourceOffset ( const unsigned int  s  )  [inline]

Definition at line 49 of file CrossingFrame.h.

00049                                              {
00050     pileupOffsetsSource_[s].push_back(pileups_.size());
00051   }

template<typename T>
void CrossingFrame< T >::swap ( CrossingFrame< T > &  other  )  [inline]

Definition at line 129 of file CrossingFrame.h.

References CrossingFrame< T >::bunchSpace_, CrossingFrame< T >::firstCrossing_, i, CrossingFrame< T >::id_, CrossingFrame< T >::idFirstPileup_, CrossingFrame< T >::lastCrossing_, CrossingFrame< T >::maxNbSources_, CrossingFrame< T >::pileupFileNr_, CrossingFrame< T >::pileupOffsetsBcr_, CrossingFrame< T >::pileupOffsetsSource_, CrossingFrame< T >::pileups_, CrossingFrame< T >::signals_, CrossingFrame< T >::subdet_, and std::swap().

Referenced by CrossingFrame< T >::operator=(), and swap().

00129                                               {
00130   std::swap(firstCrossing_, other.firstCrossing_);
00131   std::swap(lastCrossing_, other.lastCrossing_);
00132   std::swap(bunchSpace_, other.bunchSpace_);
00133   subdet_.swap(other.subdet_);
00134   std::swap(id_, other.id_);
00135   std::swap(idFirstPileup_, other.idFirstPileup_);
00136   std::swap(pileupFileNr_, other.pileupFileNr_);
00137   std::swap(maxNbSources_, other.maxNbSources_);
00138   signals_.swap(other.signals_);
00139   pileups_.swap(other.pileups_);
00140   pileupOffsetsBcr_.swap(other.pileupOffsetsBcr_);
00141   /*   for (std::vector<unsigned int> *p = pileupOffsetsSource_, */
00142   /*                             *po = other.pileupOffsetsSource_; */
00143   /*                             p < pileupOffsetsSource_ + maxNbSources_; */
00144   /*                             ++p, ++po) { */
00145   /*     p->swap(*po); */
00146   /*   } */
00147   pileupOffsetsSource_.resize(maxNbSources_);
00148   for (unsigned int i=0;i<pileupOffsetsSource_.size();++i) { 
00149     pileupOffsetsSource_[i].swap(other.pileupOffsetsSource_[i]);
00150   }
00151 }


Member Data Documentation

template<class T>
int CrossingFrame< T >::bunchSpace_ [private]

Definition at line 93 of file CrossingFrame.h.

Referenced by CrossingFrame< PSimHit >::addPileups(), CrossingFrame< T >::addPileups(), CrossingFrame< PSimHit >::getBunchSpace(), and CrossingFrame< T >::swap().

template<class T>
int CrossingFrame< T >::firstCrossing_ [private]

Definition at line 91 of file CrossingFrame.h.

Referenced by CrossingFrame< T >::CrossingFrame(), CrossingFrame< T >::getBunchCrossing(), CrossingFrame< PSimHit >::getBunchRange(), CrossingFrame< PSimHit >::getNrPileups(), CrossingFrame< T >::getSourceType(), and CrossingFrame< T >::swap().

template<class T>
const int CrossingFrame< T >::highTrackTof [static]

Definition at line 84 of file CrossingFrame.h.

template<class T>
edm::EventID CrossingFrame< T >::id_ [private]

Definition at line 95 of file CrossingFrame.h.

Referenced by CrossingFrame< T >::addSignals(), CrossingFrame< PSimHit >::getEventID(), and CrossingFrame< T >::swap().

template<class T>
edm::EventID CrossingFrame< T >::idFirstPileup_ [private]

Definition at line 98 of file CrossingFrame.h.

Referenced by CrossingFrame< T >::swap().

template<class T>
int CrossingFrame< T >::lastCrossing_ [private]

Definition at line 92 of file CrossingFrame.h.

Referenced by CrossingFrame< T >::CrossingFrame(), CrossingFrame< T >::getBunchCrossing(), CrossingFrame< PSimHit >::getBunchRange(), CrossingFrame< PSimHit >::getNrPileups(), and CrossingFrame< T >::swap().

template<class T>
const int CrossingFrame< T >::limHighLowTof [static]

Definition at line 86 of file CrossingFrame.h.

Referenced by CrossingFrame< PSimHit >::addPileups().

template<class T>
const int CrossingFrame< T >::lowTrackTof [static]

Definition at line 83 of file CrossingFrame.h.

template<class T>
unsigned int CrossingFrame< T >::maxNbSources_ [private]

Definition at line 101 of file CrossingFrame.h.

Referenced by CrossingFrame< T >::CrossingFrame(), and CrossingFrame< T >::swap().

template<class T>
const int CrossingFrame< T >::minLowTof [static]

Definition at line 85 of file CrossingFrame.h.

template<class T>
unsigned int CrossingFrame< T >::pileupFileNr_ [private]

Definition at line 99 of file CrossingFrame.h.

Referenced by CrossingFrame< T >::swap().

template<class T>
std::vector<unsigned int> CrossingFrame< T >::pileupOffsetsBcr_ [private]

Definition at line 108 of file CrossingFrame.h.

Referenced by CrossingFrame< T >::CrossingFrame(), CrossingFrame< T >::getBunchCrossing(), CrossingFrame< PSimHit >::getNrPileups(), CrossingFrame< PSimHit >::setBcrOffset(), and CrossingFrame< T >::swap().

template<class T>
std::vector< std::vector<unsigned int> > CrossingFrame< T >::pileupOffsetsSource_ [private]

Definition at line 109 of file CrossingFrame.h.

Referenced by CrossingFrame< T >::CrossingFrame(), CrossingFrame< T >::getSourceType(), CrossingFrame< PSimHit >::setSourceOffset(), and CrossingFrame< T >::swap().

template<class T>
std::vector<T> CrossingFrame< T >::pileups_ [private]

Definition at line 107 of file CrossingFrame.h.

Referenced by CrossingFrame< PSimHit >::addPileups(), CrossingFrame< T >::addPileups(), CrossingFrame< T >::getBunchCrossing(), CrossingFrame< PSimHit >::getNrPileups(), CrossingFrame< PSimHit >::getObject(), CrossingFrame< T >::getPileups(), CrossingFrame< PSimHit >::setBcrOffset(), CrossingFrame< PSimHit >::setSourceOffset(), and CrossingFrame< T >::swap().

template<class T>
std::vector<T> CrossingFrame< T >::signals_ [private]

Definition at line 104 of file CrossingFrame.h.

Referenced by CrossingFrame< T >::addSignals(), CrossingFrame< PSimHit >::getNrSignals(), CrossingFrame< PSimHit >::getObject(), CrossingFrame< PSimHit >::getSignal(), and CrossingFrame< T >::swap().

template<class T>
std::string CrossingFrame< T >::subdet_ [private]

Definition at line 94 of file CrossingFrame.h.

Referenced by CrossingFrame< T >::swap().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:17:00 2009 for CMSSW by  doxygen 1.5.4