CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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);
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 
73  const HcalSiPMCharacteristics::PrecisionItem* item = findByType(type);
74  return (item ? item->pixels_ : 0);
75 }
76 
77 std::vector<float> HcalSiPMCharacteristics::getNonLinearities(int type) const {
78  const HcalSiPMCharacteristics::PrecisionItem* item = findByType(type);
79  std::vector<float> pars;
80  if (item) {
81  pars.push_back(item->parLin1_);
82  pars.push_back(item->parLin2_);
83  pars.push_back(item->parLin3_);
84  }
85  return pars;
86 }
87 
89  const PrecisionItem* item = findByType(type);
90  return (item ? item->crossTalk_ : 0);
91 }
92 
94  const HcalSiPMCharacteristics::PrecisionItem* item = findByType(type);
95  return (item ? item->auxi1_ : 0);
96 }
97 
99  const HcalSiPMCharacteristics::PrecisionItem* item = findByType(type);
100  return (item ? item->auxi2_ : 0);
101 }
102 
104  HcalObjectAddons::sortByT<PrecisionItem, HcalSiPMCharacteristicsAddons::LessByType>(mPItems, mPItemsByType);
105 }
106 
void swap(HcalSiPMCharacteristics &other)
float getCrossTalk(int type) const
get cross talk
HcalSiPMCharacteristics & operator=(const HcalSiPMCharacteristics &rhs)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
const PrecisionItem * findByType(int type) const
unsigned int getTypes() const
get # of types
int getAuxi1(int type) const
get auxiliary words
bool loadObject(int type, int pixels, float parLin1, float parLin2, float parLin3, float crossTalk, int auxi1=0, float auxi2=0)
std::vector< float > getNonLinearities(int type) const
get nonlinearity constants
string end
Definition: dataset.py:937
float getAuxi2(int type) const
Log< level::Warning, false > LogWarning
std::vector< const PrecisionItem * > mPItemsByType
int getPixels(int type) const
get # of pixels
std::vector< PrecisionItem > mPItems