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

◆ Item

Definition at line 29 of file CastorCalibrationWidthsSet.h.

Constructor & Destructor Documentation

◆ CastorCalibrationWidthsSet()

CastorCalibrationWidthsSet::CastorCalibrationWidthsSet ( )

Definition at line 7 of file CastorCalibrationWidthsSet.cc.

7 : sorted_(false) {}

Member Function Documentation

◆ clear()

void CastorCalibrationWidthsSet::clear ( )

Definition at line 39 of file CastorCalibrationWidthsSet.cc.

39 { mItems.clear(); }

References mItems.

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

◆ getCalibrationWidths()

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

Definition at line 9 of file CastorCalibrationWidthsSet.cc.

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 }

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

Referenced by CastorDbService::getCastorCalibrationWidths().

◆ setCalibrationWidths()

void CastorCalibrationWidthsSet::setCalibrationWidths ( const DetId  id,
const CastorCalibrationWidths ca 
)

Definition at line 23 of file CastorCalibrationWidthsSet.cc.

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 }

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

Referenced by CastorDbService::buildCalibWidths().

◆ sort()

void CastorCalibrationWidthsSet::sort ( )

Definition at line 33 of file CastorCalibrationWidthsSet.cc.

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

References mItems, and sorted_.

Referenced by CastorDbService::buildCalibWidths().

Member Data Documentation

◆ dummy

CastorCalibrationWidths CastorCalibrationWidthsSet::dummy
private

Definition at line 30 of file CastorCalibrationWidthsSet.h.

◆ mItems

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

◆ sorted_

bool CastorCalibrationWidthsSet::sorted_
private

Definition at line 32 of file CastorCalibrationWidthsSet.h.

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

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