CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

CaloRecHitMetaCollectionFast Class Reference

#include <CaloRecHitMetaCollectionFast.h>

Inheritance diagram for CaloRecHitMetaCollectionFast:
CaloRecHitMetaCollectionV

List of all members.

Public Types

typedef
CaloRecHitMetaCollectionV::Iterator 
const_iterator

Public Member Functions

void add (const CaloRecHit *hit)
 add an item to the collection
virtual const CaloRecHitat (const_iterator::offset_type i) const
 get an item by index
 CaloRecHitMetaCollectionFast ()
 create an empty collection
 CaloRecHitMetaCollectionFast (const CaloRecHitMetaCollectionFast &c)
 copy constructor
virtual const_iterator find (const DetId &id) const
 find by id (default version is very slow unsorted find)
virtual ~CaloRecHitMetaCollectionFast ()
 destructor

Private Member Functions

void sort () const

Private Attributes

bool dirty_
std::vector< const CaloRecHit * > hits_

Detailed Description

Implementation of CaloRecHitMetaCollectionV which internally stores a vector of const CaloRecHit pointers. Fast for access and relatively fast to build, but uses more memory than CaloRecHitMetaCollectionCompact.

Appropriate class for subcollections produced by selection algorithms.

Date:
2006/01/17 15:57:11
Revision:
1.1
Author:
J. Mans - Minnesota

Definition at line 20 of file CaloRecHitMetaCollectionFast.h.


Member Typedef Documentation

Reimplemented from CaloRecHitMetaCollectionV.

Definition at line 22 of file CaloRecHitMetaCollectionFast.h.


Constructor & Destructor Documentation

CaloRecHitMetaCollectionFast::CaloRecHitMetaCollectionFast ( )

create an empty collection

Definition at line 4 of file CaloRecHitMetaCollectionFast.cc.

References dirty_.

                                                            {
  dirty_=false;
}
CaloRecHitMetaCollectionFast::CaloRecHitMetaCollectionFast ( const CaloRecHitMetaCollectionFast c)

copy constructor

virtual CaloRecHitMetaCollectionFast::~CaloRecHitMetaCollectionFast ( ) [inline, virtual]

destructor

Definition at line 29 of file CaloRecHitMetaCollectionFast.h.

{ }

Member Function Documentation

void CaloRecHitMetaCollectionFast::add ( const CaloRecHit hit)

add an item to the collection

Definition at line 8 of file CaloRecHitMetaCollectionFast.cc.

References dirty_, hits_, and CaloRecHitMetaCollectionV::size_.

Referenced by CaloConeSelector::select(), and CaloDualConeSelector::select().

                                                            {
  hits_.push_back(hit);
  dirty_=true;
  size_++;
}
const CaloRecHit * CaloRecHitMetaCollectionFast::at ( const_iterator::offset_type  i) const [virtual]

get an item by index

Implements CaloRecHitMetaCollectionV.

Definition at line 40 of file CaloRecHitMetaCollectionFast.cc.

References dirty_, hits_, CaloRecHitMetaCollectionV::size_, and sort().

                                                                                    {
  if (dirty_) sort();
  return ((i<0 || i>=(const_iterator::offset_type)size_)?(0):(hits_[i]));
}
CaloRecHitMetaCollectionV::const_iterator CaloRecHitMetaCollectionFast::find ( const DetId id) const [virtual]

find by id (default version is very slow unsorted find)

Reimplemented from CaloRecHitMetaCollectionV.

Definition at line 25 of file CaloRecHitMetaCollectionFast.cc.

References AlCaHLTBitMon_QueryRunRegistry::comp, dirty_, CaloRecHitMetaCollectionV::end(), first, hits_, prof2calltree::last, and sort().

                                                                                                {
  if (dirty_) sort();

  CRHMCVComp comp;

  std::vector<const CaloRecHit*>::const_iterator last=hits_.end();
  std::vector<const CaloRecHit*>::const_iterator first=hits_.begin();
  std::vector<const CaloRecHit*>::const_iterator loc =std::lower_bound(first,
                                                                       last,
                                                                       id,
                                                                       comp);
  return loc == last || comp(id, *loc) ? end() : const_iterator(this,loc - hits_.begin());   
}
void CaloRecHitMetaCollectionFast::sort ( ) const [private]

Definition at line 46 of file CaloRecHitMetaCollectionFast.cc.

References AlCaHLTBitMon_QueryRunRegistry::comp, dirty_, and hits_.

Referenced by at(), and find().

                                              {
  if (dirty_) {
    CRHMCVComp comp;
    std::sort(hits_.begin(),hits_.end(),comp);
    dirty_=false;
  }
}

Member Data Documentation

bool CaloRecHitMetaCollectionFast::dirty_ [mutable, private]

Definition at line 42 of file CaloRecHitMetaCollectionFast.h.

Referenced by add(), at(), CaloRecHitMetaCollectionFast(), find(), and sort().

std::vector<const CaloRecHit*> CaloRecHitMetaCollectionFast::hits_ [mutable, private]

Definition at line 41 of file CaloRecHitMetaCollectionFast.h.

Referenced by add(), at(), find(), and sort().