CMS 3D CMS Logo

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