CMS 3D CMS Logo

HcalSiPMCharacteristics.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <iostream>
3 #include <set>
4 
8 
10  : mPItems(helper.mPItems.begin(), helper.mPItems.end()) {
11  initialize();
12 }
13 
15 
16 // copy-ctor
18  : mPItems(src.mPItems), mPItemsByType(src.mPItemsByType) {}
19 
20 // copy assignment operator
23  temp.swap(*this);
24  return *this;
25 }
26 
27 // public swap function
29  std::swap(mPItems, other.mPItems);
30  std::swap(mPItemsByType, other.mPItemsByType);
31 }
32 
33 // move constructor
35  other.swap(*this);
36 }
37 
39  const HcalSiPMCharacteristics::PrecisionItem* retItem = nullptr;
40 
41  for (unsigned int i = 0; i < getTypes(); i++) {
42  auto iter = &mPItems.at(i);
43  if (type == iter->type_)
44  retItem = iter;
45  }
46  return retItem;
47 
48  //NOT WORKING:
49  //PrecisionItem target(type, 0, 0, 0, 0, 0, 0, 0);
50  //return HcalObjectAddons::findByT<PrecisionItem,HcalSiPMCharacteristicsAddons::LessByType>(&target,mPItemsByType);
51 }
52 
54 
56  int type, int pixels, float parLin1, float parLin2, float parLin3, float crossTalk, int auxi1, float auxi2) {
57  HcalSiPMCharacteristics::PrecisionItem target(type, pixels, parLin1, parLin2, parLin3, crossTalk, auxi1, auxi2);
58  auto iter = mPItems.find(target);
59  if (iter != mPItems.end()) {
60  edm::LogWarning("HCAL") << "HcalSiPMCharacteristics::loadObject type " << type << " already exists with pixels "
61  << iter->pixels_ << " NoLinearity parameters " << iter->parLin1_ << ":" << iter->parLin2_
62  << ":" << iter->parLin3_ << " CrossTalk parameter " << iter->crossTalk_ << " new values "
63  << pixels << ", " << parLin1 << ", " << parLin2 << ", " << parLin3 << ", " << crossTalk
64  << ", " << auxi1 << " and " << auxi2 << " are ignored";
65  return false;
66  } else {
67  mPItems.insert(target);
68  return true;
69  }
70 }
71 
74  return (item ? item->pixels_ : 0);
75 }
76 
77 std::vector<float> HcalSiPMCharacteristics::getNonLinearities(int type) const {
79  std::vector<float> pars;
80  pars.reserve(3);
81  if (item) {
82  pars.push_back(item->parLin1_);
83  pars.push_back(item->parLin2_);
84  pars.push_back(item->parLin3_);
85  }
86  return pars;
87 }
88 
90  const PrecisionItem* item = findByType(type);
91  return (item ? item->crossTalk_ : 0);
92 }
93 
96  return (item ? item->auxi1_ : 0);
97 }
98 
100  const HcalSiPMCharacteristics::PrecisionItem* item = findByType(type);
101  return (item ? item->auxi2_ : 0);
102 }
103 
105  HcalObjectAddons::sortByT<PrecisionItem, HcalSiPMCharacteristicsAddons::LessByType>(mPItems, mPItemsByType);
106 }
107 
Definition: helper.py:1
int getAuxi1(int type) const
get auxiliary words
const PrecisionItem * findByType(int type) const
std::vector< float > getNonLinearities(int type) const
get nonlinearity constants
float getAuxi2(int type) const
void swap(HcalSiPMCharacteristics &other)
HcalSiPMCharacteristics & operator=(const HcalSiPMCharacteristics &rhs)
float getCrossTalk(int type) const
get cross talk
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
bool loadObject(int type, int pixels, float parLin1, float parLin2, float parLin3, float crossTalk, int auxi1=0, float auxi2=0)
int getPixels(int type) const
get # of pixels
Log< level::Warning, false > LogWarning
std::vector< const PrecisionItem * > mPItemsByType
unsigned int getTypes() const
get # of types
std::vector< PrecisionItem > mPItems