CondFormats
CastorObjects
src
CastorRawGains.cc
Go to the documentation of this file.
1
7
#include <iostream>
8
9
#include "
FWCore/Utilities/interface/Exception.h
"
10
#include "
CondFormats/CastorObjects/interface/CastorRawGains.h
"
11
#include "
DataFormats/HcalDetId/interface/HcalGenericDetId.h
"
12
13
namespace
{
14
class
compareItems {
15
public
:
16
bool
operator()(
const
CastorRawGains::Item
&
first
,
const
CastorRawGains::Item
&
second
)
const
{
17
return
first
.rawId() <
second
.rawId();
18
}
19
};
20
21
CastorRawGains::Container::const_iterator
find
(
const
CastorRawGains::Container
& container,
unsigned
long
id
) {
22
CastorRawGains::Container::const_iterator
result
= container.begin();
23
for
(;
result
!= container.end();
result
++) {
24
if
(
result
->rawId() ==
id
)
25
break
;
// found
26
}
27
return
result
;
28
}
29
}
// namespace
30
31
CastorRawGains::CastorRawGains
() : mSorted(
false
) {}
32
33
CastorRawGains::~CastorRawGains
() {}
34
35
const
CastorRawGain
*
CastorRawGains::getValues
(
DetId
fId)
const
{
36
Item
target
(fId.
rawId
(), 0, 0, 0,
CastorRawGain::BAD
);
37
std::vector<Item>::const_iterator cell;
38
if
(
sorted
()) {
39
cell =
std::lower_bound
(
mItems
.begin(),
mItems
.end(),
target
, compareItems());
40
}
else
{
41
std::cerr
<<
"CastorRawGains::getValues-> container is not sorted. Please sort it to search effectively"
42
<< std::endl;
43
cell =
find
(
mItems
, fId.
rawId
());
44
}
45
if
(cell ==
mItems
.end() || cell->rawId() !=
target
.rawId())
46
throw
cms::Exception
(
"Conditions not found"
)
47
<<
"Unavailable Raw Gains for cell "
<<
HcalGenericDetId
(
target
.rawId());
48
return
&(*cell);
49
}
50
51
std::vector<DetId>
CastorRawGains::getAllChannels
()
const
{
52
std::vector<DetId>
result
;
53
for
(std::vector<Item>::const_iterator
item
=
mItems
.begin();
item
!=
mItems
.end();
item
++) {
54
result
.push_back(
DetId
(
item
->rawId()));
55
}
56
return
result
;
57
}
58
59
CastorRawGain
*
CastorRawGains::addItem
(
DetId
fId) {
60
CastorRawGain
item
(fId.
rawId
());
61
mItems
.push_back(
item
);
62
mSorted
=
false
;
63
return
&(
mItems
.back());
64
}
65
66
void
CastorRawGains::addValues
(
DetId
fId,
const
CastorRawGain
& fValues) {
67
Item
item
(fId.
rawId
(), fValues.
getValue
(), fValues.
getError
(), fValues.
getVoltage
(), fValues.
getStatus
());
68
mItems
.push_back(
item
);
69
mSorted
=
false
;
70
}
71
72
void
CastorRawGains::sort
() {
73
if
(!
mSorted
) {
74
std::sort
(
mItems
.begin(),
mItems
.end(), compareItems());
75
mSorted
=
true
;
76
}
77
}
funct::false
false
Definition:
Factorize.h:29
CastorRawGains::CastorRawGains
CastorRawGains()
Definition:
CastorRawGains.cc:31
HcalGenericDetId
Definition:
HcalGenericDetId.h:15
CastorRawGain::getValue
float getValue() const
Definition:
CastorRawGain.h:15
CastorRawGain::getVoltage
float getVoltage() const
Definition:
CastorRawGain.h:17
CastorRawGain::BAD
Definition:
CastorRawGain.h:14
CastorRawGains::addItem
CastorRawGain * addItem(DetId fId)
add new (empty) item
Definition:
CastorRawGains.cc:59
edm::second
U second(std::pair< T, U > const &p)
Definition:
ParameterSet.cc:222
HcalGenericDetId.h
CastorRawGain::getError
float getError() const
Definition:
CastorRawGain.h:16
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition:
FindCaloHit.cc:19
CastorRawGains::mItems
Container mItems
Definition:
CastorRawGains.h:38
DetId
Definition:
DetId.h:17
CastorRawGain::getStatus
Status getStatus() const
Definition:
CastorRawGain.h:18
CastorRawGains::sort
void sort()
sort values by channelId
Definition:
CastorRawGains.cc:72
CastorRawGains::~CastorRawGains
~CastorRawGains()
Definition:
CastorRawGains.cc:33
CastorRawGain
Definition:
CastorRawGain.h:12
first
auto first
Definition:
CAHitNtupletGeneratorKernelsImpl.h:112
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition:
pfDeepBoostedJetPreprocessParams_cfi.py:15
jetUpdater_cfi.sort
sort
Definition:
jetUpdater_cfi.py:29
CastorRawGains::getValues
const CastorRawGain * getValues(DetId fId) const
get value
Definition:
CastorRawGains.cc:35
CastorRawGains::addValues
void addValues(DetId fId, const CastorRawGain &fValues)
fill values
Definition:
CastorRawGains.cc:66
CastorRawGains.h
B2GTnPMonitor_cfi.item
item
Definition:
B2GTnPMonitor_cfi.py:147
CastorRawGains::Container
std::vector< Item > Container
Definition:
CastorRawGains.h:35
CastorRawGains::mSorted
bool mSorted
Definition:
CastorRawGains.h:39
CastorRawGains::getAllChannels
std::vector< DetId > getAllChannels() const
get list of all available channels
Definition:
CastorRawGains.cc:51
CastorRawGains::sorted
bool sorted() const
check if data are sorted
Definition:
CastorRawGains.h:26
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition:
DetId.h:57
triggerObjects_cff.id
id
Definition:
triggerObjects_cff.py:29
Exception.h
filterCSVwithJSON.target
target
Definition:
filterCSVwithJSON.py:32
mps_fire.result
result
Definition:
mps_fire.py:311
cms::Exception
Definition:
Exception.h:70
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition:
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
Generated for CMSSW Reference Manual by
1.8.16