Main Page
Namespaces
Classes
Package Documentation
CalibFormats
CastorObjects
src
CastorCalibrationWidthsSet.cc
Go to the documentation of this file.
1
#include "
CalibFormats/CastorObjects/interface/CastorCalibrationWidthsSet.h
"
2
#include "
DataFormats/HcalDetId/interface/HcalGenericDetId.h
"
3
#include "
FWCore/Utilities/interface/Exception.h
"
4
#include <algorithm>
5
#include <iostream>
6
7
CastorCalibrationWidthsSet::CastorCalibrationWidthsSet
() : sorted_(
false
) {}
8
9
const
CastorCalibrationWidths
&
CastorCalibrationWidthsSet::getCalibrationWidths
(
const
DetId
fId)
const
{
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
}
22
23
void
CastorCalibrationWidthsSet::setCalibrationWidths
(
DetId
fId,
const
CastorCalibrationWidths
& ca) {
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
}
33
void
CastorCalibrationWidthsSet::sort
() {
34
if
(!
sorted_
) {
35
std::sort(
mItems
.begin(),
mItems
.end());
36
sorted_
=
true
;
37
}
38
}
39
void
CastorCalibrationWidthsSet::clear
() {
mItems
.clear(); }
CastorCalibrationWidthsSet::setCalibrationWidths
void setCalibrationWidths(const DetId id, const CastorCalibrationWidths &ca)
Definition:
CastorCalibrationWidthsSet.cc:23
funct::false
false
Definition:
Factorize.h:36
CastorCalibrationWidths
Definition:
CastorCalibrationWidths.h:9
CastorCalibrationWidthsSet::getCalibrationWidths
const CastorCalibrationWidths & getCalibrationWidths(const DetId id) const
Definition:
CastorCalibrationWidthsSet.cc:9
edmPickEvents.target
target
Definition:
edmPickEvents.py:310
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition:
FindCaloHit.cc:20
CastorCalibrationWidthsSet::sorted_
bool sorted_
Definition:
CastorCalibrationWidthsSet.h:32
HcalGenericDetId.h
CastorCalibrationWidthsSet::Item
CalibWidthSetObject Item
Definition:
CastorCalibrationWidthsSet.h:29
calib
Definition:
CalibElectron.h:14
CastorCalibrationWidthsSet::sort
void sort()
Definition:
CastorCalibrationWidthsSet.cc:33
CastorCalibrationWidthsSet::clear
void clear()
Definition:
CastorCalibrationWidthsSet.cc:39
HcalGenericDetId
Definition:
HcalGenericDetId.h:15
CastorCalibrationWidthsSet::mItems
std::vector< CalibWidthSetObject > mItems
Definition:
CastorCalibrationWidthsSet.h:31
DetId
Definition:
DetId.h:18
Exception.h
CastorCalibrationWidthsSet.h
cms::Exception
Definition:
Exception.h:68
CastorCalibrationWidthsSet::CastorCalibrationWidthsSet
CastorCalibrationWidthsSet()
Definition:
CastorCalibrationWidthsSet.cc:7
CastorCalibrationWidthsSet::CalibWidthSetObject
Definition:
CastorCalibrationWidthsSet.h:22
Generated for CMSSW Reference Manual by
1.8.11