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 {
12  initialize();
13 }
14 
16 }
17 
18 // copy-ctor
21 
22 // copy assignment operator
25  temp.swap(*this);
26  return *this;
27 }
28 
29 // public swap function
31  std::swap(mPItems, other.mPItems);
33 }
34 
35 // move constructor
37  other.swap(*this);
38 }
39 
41 
42  const HcalSiPMCharacteristics::PrecisionItem* retItem = nullptr;
43 
44  for(unsigned int i = 0; i < getTypes(); i++){
45  auto iter = &mPItems.at(i);
46  if(type==iter->type_) retItem = iter;
47  }
48  return retItem;
49 
50  //NOT WORKING:
51  //PrecisionItem target(type, 0, 0, 0, 0, 0, 0, 0);
52  //return HcalObjectAddons::findByT<PrecisionItem,HcalSiPMCharacteristicsAddons::LessByType>(&target,mPItemsByType);
53 }
54 
56 
57 bool HcalSiPMCharacteristicsAddons::Helper::loadObject(int type, int pixels, float parLin1,
58  float parLin2, float parLin3,
59  float crossTalk, int auxi1,
60  float auxi2) {
62  parLin2,parLin3,crossTalk,
63  auxi1,auxi2);
64  auto iter = mPItems.find(target);
65  if (iter!=mPItems.end()) {
66  edm::LogWarning("HCAL") << "HcalSiPMCharacteristics::loadObject type "
67  << type << " already exists with pixels "
68  << iter->pixels_ << " NoLinearity parameters "
69  << iter->parLin1_ << ":" << iter->parLin2_ << ":"
70  << iter->parLin3_ << " CrossTalk parameter "
71  << iter->crossTalk_ << " new values " << pixels
72  << ", " << parLin1 << ", " << parLin2 << ", "
73  << parLin3 << ", " << crossTalk << ", " << auxi1
74  << " and " << auxi2 << " are ignored";
75  return false;
76  } else {
77  mPItems.insert(target);
78  return true;
79  }
80 }
81 
84  return (item ? item->pixels_ : 0);
85 }
86 
87 std::vector<float> HcalSiPMCharacteristics::getNonLinearities(int type) const {
89  std::vector<float> pars;
90  if (item) {
91  pars.push_back(item->parLin1_);
92  pars.push_back(item->parLin2_);
93  pars.push_back(item->parLin3_);
94  }
95  return pars;
96 }
97 
99  const PrecisionItem* item = findByType(type);
100  return (item ? item->crossTalk_ : 0);
101 }
102 
105  return (item ? item->auxi1_ : 0);
106 }
107 
110  return (item ? item->auxi2_ : 0);
111 }
112 
114  HcalObjectAddons::sortByT<PrecisionItem,HcalSiPMCharacteristicsAddons::LessByType>(mPItems,mPItemsByType);
115 }
116 
119 }
type
Definition: HCALResponse.h:21
Definition: helper.py:1
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
#define end
Definition: vmac.h:39
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
#define begin
Definition: vmac.h:32
float getAuxi2(int type) const
std::vector< const PrecisionItem * > mPItemsByType
int getPixels(int type) const
get # of pixels
std::vector< PrecisionItem > mPItems