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
8
CastorCalibrationWidthsSet::CastorCalibrationWidthsSet
()
9
: sorted_ (
false
) {}
10
11
const
CastorCalibrationWidths
&
CastorCalibrationWidthsSet::getCalibrationWidths
(
const
DetId
fId)
const
{
12
Item
target
(fId);
13
std::vector<Item>::const_iterator cell;
14
if
(
sorted_
) {
15
cell = std::lower_bound (
mItems
.begin(),
mItems
.end(),
target
);
16
}
17
else
{
18
cell =
std::find
(
mItems
.begin(),
mItems
.end(),
target
);
19
}
20
if
(cell ==
mItems
.end() || cell->id != fId)
21
throw
cms::Exception
(
"Conditions not found"
) <<
"Unavailable CastorCalibrationWidths for cell "
<<
HcalGenericDetId
(fId);
22
return
cell->calib;
23
}
24
25
void
CastorCalibrationWidthsSet::setCalibrationWidths
(
DetId
fId,
const
CastorCalibrationWidths
& ca) {
26
sorted_
=
false
;
27
std::vector<Item>::iterator cell=
std::find
(
mItems
.begin(),
mItems
.end(),
Item
(fId));
//slow, but guaranteed
28
if
(cell==
mItems
.end())
29
{
30
mItems
.push_back(
Item
(fId));
31
mItems
.at(
mItems
.size()-1).
calib
=ca;
32
return
;
33
}
34
cell->calib=ca;
35
}
36
void
CastorCalibrationWidthsSet::sort
() {
37
if
(!
sorted_
) {
38
std::sort (
mItems
.begin(),
mItems
.end());
39
sorted_
=
true
;
40
}
41
}
42
void
CastorCalibrationWidthsSet::clear
() {
43
mItems
.clear();
44
}
CastorCalibrationWidthsSet::setCalibrationWidths
void setCalibrationWidths(const DetId id, const CastorCalibrationWidths &ca)
Definition:
CastorCalibrationWidthsSet.cc:25
funct::false
false
Definition:
Factorize.h:34
CastorCalibrationWidths
Definition:
CastorCalibrationWidths.h:9
CastorCalibrationWidthsSet::getCalibrationWidths
const CastorCalibrationWidths & getCalibrationWidths(const DetId id) const
Definition:
CastorCalibrationWidthsSet.cc:11
edmPickEvents.target
target
Definition:
edmPickEvents.py:275
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:31
HcalGenericDetId.h
CastorCalibrationWidthsSet::Item
CalibWidthSetObject Item
Definition:
CastorCalibrationWidthsSet.h:28
calib
Definition:
CalibElectron.h:14
CastorCalibrationWidthsSet::sort
void sort()
Definition:
CastorCalibrationWidthsSet.cc:36
CastorCalibrationWidthsSet::clear
void clear()
Definition:
CastorCalibrationWidthsSet.cc:42
HcalGenericDetId
Definition:
HcalGenericDetId.h:15
CastorCalibrationWidthsSet::mItems
std::vector< CalibWidthSetObject > mItems
Definition:
CastorCalibrationWidthsSet.h:30
DetId
Definition:
DetId.h:18
Exception.h
CastorCalibrationWidthsSet.h
cms::Exception
Definition:
Exception.h:68
CastorCalibrationWidthsSet::CastorCalibrationWidthsSet
CastorCalibrationWidthsSet()
Definition:
CastorCalibrationWidthsSet.cc:8
CastorCalibrationWidthsSet::CalibWidthSetObject
Definition:
CastorCalibrationWidthsSet.h:21
Generated for CMSSW Reference Manual by
1.8.11