CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Attributes
CastorCalibrationWidthsSet Class Reference

#include <CastorCalibrationWidthsSet.h>

Classes

struct  CalibWidthSetObject
 

Public Member Functions

 CastorCalibrationWidthsSet ()
 
void clear ()
 
const CastorCalibrationWidthsgetCalibrationWidths (const DetId id) const
 
void setCalibrationWidths (const DetId id, const CastorCalibrationWidths &ca)
 
void sort ()
 

Private Types

typedef CalibWidthSetObject Item
 

Private Attributes

CastorCalibrationWidths dummy
 
std::vector< CalibWidthSetObjectmItems
 
bool sorted_
 

Detailed Description

Author
R.Ofierzynski Adapted for CASTOR by L. Mundim

Definition at line 13 of file CastorCalibrationWidthsSet.h.

Member Typedef Documentation

Definition at line 29 of file CastorCalibrationWidthsSet.h.

Constructor & Destructor Documentation

CastorCalibrationWidthsSet::CastorCalibrationWidthsSet ( )

Definition at line 7 of file CastorCalibrationWidthsSet.cc.

Member Function Documentation

void CastorCalibrationWidthsSet::clear ( )
const CastorCalibrationWidths & CastorCalibrationWidthsSet::getCalibrationWidths ( const DetId  id) const

Definition at line 9 of file CastorCalibrationWidthsSet.cc.

References spr::find(), mItems, sorted_, and edmPickEvents::target.

Referenced by CastorDbService::getCastorCalibrationWidths().

9  {
10  Item target(fId);
11  std::vector<Item>::const_iterator cell;
12  if (sorted_) {
13  cell = std::lower_bound(mItems.begin(), mItems.end(), target);
14  } else {
15  cell = std::find(mItems.begin(), mItems.end(), target);
16  }
17  if (cell == mItems.end() || cell->id != fId)
18  throw cms::Exception("Conditions not found")
19  << "Unavailable CastorCalibrationWidths for cell " << HcalGenericDetId(fId);
20  return cell->calib;
21 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< CalibWidthSetObject > mItems
void CastorCalibrationWidthsSet::setCalibrationWidths ( const DetId  id,
const CastorCalibrationWidths ca 
)

Definition at line 23 of file CastorCalibrationWidthsSet.cc.

References spr::find(), mItems, and sorted_.

Referenced by CastorDbService::buildCalibWidths().

23  {
24  sorted_ = false;
25  std::vector<Item>::iterator cell = std::find(mItems.begin(), mItems.end(), Item(fId)); //slow, but guaranteed
26  if (cell == mItems.end()) {
27  mItems.push_back(Item(fId));
28  mItems.at(mItems.size() - 1).calib = ca;
29  return;
30  }
31  cell->calib = ca;
32 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< CalibWidthSetObject > mItems
void CastorCalibrationWidthsSet::sort ( )

Definition at line 33 of file CastorCalibrationWidthsSet.cc.

References mItems, and sorted_.

Referenced by CastorDbService::buildCalibWidths().

33  {
34  if (!sorted_) {
35  std::sort(mItems.begin(), mItems.end());
36  sorted_ = true;
37  }
38 }
std::vector< CalibWidthSetObject > mItems

Member Data Documentation

CastorCalibrationWidths CastorCalibrationWidthsSet::dummy
private

Definition at line 30 of file CastorCalibrationWidthsSet.h.

std::vector<CalibWidthSetObject> CastorCalibrationWidthsSet::mItems
private
bool CastorCalibrationWidthsSet::sorted_
private

Definition at line 32 of file CastorCalibrationWidthsSet.h.

Referenced by getCalibrationWidths(), setCalibrationWidths(), and sort().