CMS 3D CMS Logo

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

#include <CastorCalibrationsSet.h>

Classes

struct  CalibSetObject
 

Public Member Functions

 CastorCalibrationsSet ()
 
void clear ()
 
const CastorCalibrationsgetCalibrations (const DetId id) const
 
void setCalibrations (const DetId id, const CastorCalibrations &ca)
 
void sort ()
 

Private Types

typedef CalibSetObject Item
 

Private Attributes

CastorCalibrations dummy
 
std::vector< CalibSetObjectmItems
 
bool sorted_
 

Detailed Description

Definition at line 8 of file CastorCalibrationsSet.h.

Member Typedef Documentation

◆ Item

Definition at line 24 of file CastorCalibrationsSet.h.

Constructor & Destructor Documentation

◆ CastorCalibrationsSet()

CastorCalibrationsSet::CastorCalibrationsSet ( )

Definition at line 6 of file CastorCalibrationsSet.cc.

6 : sorted_(false) {}

Member Function Documentation

◆ clear()

void CastorCalibrationsSet::clear ( )

Definition at line 38 of file CastorCalibrationsSet.cc.

38 { mItems.clear(); }

References mItems.

Referenced by CastorDbService::buildCalibrations(), and BeautifulSoup.Tag::setString().

◆ getCalibrations()

const CastorCalibrations & CastorCalibrationsSet::getCalibrations ( const DetId  id) const

Definition at line 8 of file CastorCalibrationsSet.cc.

8  {
9  Item target(fId);
10  std::vector<Item>::const_iterator cell;
11  if (sorted_) {
12  cell = std::lower_bound(mItems.begin(), mItems.end(), target);
13  } else {
14  cell = std::find(mItems.begin(), mItems.end(), target);
15  }
16  if (cell == mItems.end() || cell->id != fId)
17  throw cms::Exception("Conditions not found") << "Unavailable CastorCalibrations for cell " << HcalGenericDetId(fId);
18  return cell->calib;
19 }

References spr::find(), pfDeepBoostedJetPreprocessParams_cfi::lower_bound, mItems, sorted_, and filterCSVwithJSON::target.

Referenced by CastorDbService::getCastorCalibrations().

◆ setCalibrations()

void CastorCalibrationsSet::setCalibrations ( const DetId  id,
const CastorCalibrations ca 
)

Definition at line 21 of file CastorCalibrationsSet.cc.

21  {
22  sorted_ = false;
23  std::vector<Item>::iterator cell = std::find(mItems.begin(), mItems.end(), Item(fId)); //slow, but guaranteed
24  if (cell == mItems.end()) {
25  mItems.push_back(Item(fId));
26  mItems.at(mItems.size() - 1).calib = ca;
27  return;
28  }
29 
30  cell->calib = ca;
31 }

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

Referenced by CastorDbService::buildCalibrations().

◆ sort()

void CastorCalibrationsSet::sort ( )

Definition at line 32 of file CastorCalibrationsSet.cc.

32  {
33  if (!sorted_) {
34  std::sort(mItems.begin(), mItems.end());
35  sorted_ = true;
36  }
37 }

References mItems, jetUpdater_cfi::sort, and sorted_.

Referenced by CastorDbService::buildCalibrations().

Member Data Documentation

◆ dummy

CastorCalibrations CastorCalibrationsSet::dummy
private

Definition at line 25 of file CastorCalibrationsSet.h.

◆ mItems

std::vector<CalibSetObject> CastorCalibrationsSet::mItems
private

Definition at line 26 of file CastorCalibrationsSet.h.

Referenced by clear(), getCalibrations(), setCalibrations(), and sort().

◆ sorted_

bool CastorCalibrationsSet::sorted_
private

Definition at line 27 of file CastorCalibrationsSet.h.

Referenced by getCalibrations(), setCalibrations(), and sort().

HcalGenericDetId
Definition: HcalGenericDetId.h:15
CastorCalibrationsSet::sorted_
bool sorted_
Definition: CastorCalibrationsSet.h:27
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
calib
Definition: CalibElectron.h:12
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
CastorCalibrationsSet::mItems
std::vector< CalibSetObject > mItems
Definition: CastorCalibrationsSet.h:26
CastorCalibrationsSet::Item
CalibSetObject Item
Definition: CastorCalibrationsSet.h:24
filterCSVwithJSON.target
target
Definition: filterCSVwithJSON.py:32
cms::Exception
Definition: Exception.h:70