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  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 
95  return (item ? item->auxi1_ : 0);
96 }
97 
100  return (item ? item->auxi2_ : 0);
101 }
102 
104  HcalObjectAddons::sortByT<PrecisionItem, HcalSiPMCharacteristicsAddons::LessByType>(mPItems, mPItemsByType);
105 }
106 
HcalSiPMCharacteristics::mPItems
std::vector< PrecisionItem > mPItems
Definition: HcalSiPMCharacteristics.h:84
HcalSiPMCharacteristics::sortByType
void sortByType()
Definition: HcalSiPMCharacteristics.cc:103
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
HcalSiPMCharacteristicsAddons::Helper::Helper
Helper()
Definition: HcalSiPMCharacteristics.cc:53
HcalSiPMCharacteristics::getAuxi2
float getAuxi2(int type) const
Definition: HcalSiPMCharacteristics.cc:98
HcalSiPMCharacteristics.h
HcalSiPMCharacteristics::PrecisionItem
Definition: HcalSiPMCharacteristics.h:20
HcalObjectAddons.h
HcalSiPMCharacteristics::~HcalSiPMCharacteristics
~HcalSiPMCharacteristics()
Definition: HcalSiPMCharacteristics.cc:14
HcalSiPMCharacteristics::getNonLinearities
std::vector< float > getNonLinearities(int type) const
get nonlinearity constants
Definition: HcalSiPMCharacteristics.cc:77
HcalSiPMCharacteristics::getAuxi1
int getAuxi1(int type) const
get auxiliary words
Definition: HcalSiPMCharacteristics.cc:93
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
HcalSiPMCharacteristics::getCrossTalk
float getCrossTalk(int type) const
get cross talk
Definition: HcalSiPMCharacteristics.cc:88
HcalSiPMCharacteristics::initialize
void initialize()
Definition: HcalSiPMCharacteristics.cc:107
end
#define end
Definition: vmac.h:39
HcalSiPMCharacteristics::HcalSiPMCharacteristics
HcalSiPMCharacteristics()
Definition: HcalSiPMCharacteristics.h:49
HcalSiPMCharacteristics::findByType
const PrecisionItem * findByType(int type) const
Definition: HcalSiPMCharacteristics.cc:38
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
HcalSiPMCharacteristics::operator=
HcalSiPMCharacteristics & operator=(const HcalSiPMCharacteristics &rhs)
Definition: HcalSiPMCharacteristics.cc:21
trackingPlots.other
other
Definition: trackingPlots.py:1465
HcalSiPMCharacteristics::swap
void swap(HcalSiPMCharacteristics &other)
Definition: HcalSiPMCharacteristics.cc:28
edm::LogWarning
Definition: MessageLogger.h:141
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
helper
Definition: helper.py:1
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
HcalSiPMCharacteristicsAddons::Helper::loadObject
bool loadObject(int type, int pixels, float parLin1, float parLin2, float parLin3, float crossTalk, int auxi1=0, float auxi2=0)
Definition: HcalSiPMCharacteristics.cc:55
type
type
Definition: HCALResponse.h:21
HcalSiPMCharacteristics::mPItemsByType
std::vector< const PrecisionItem * > mPItemsByType
Definition: HcalSiPMCharacteristics.h:85
filterCSVwithJSON.target
target
Definition: filterCSVwithJSON.py:32
HcalSiPMCharacteristicsAddons::Helper
Definition: HcalSiPMCharacteristics.h:106
HcalSiPMCharacteristics::getPixels
int getPixels(int type) const
get # of pixels
Definition: HcalSiPMCharacteristics.cc:72
begin
#define begin
Definition: vmac.h:32
HcalSiPMCharacteristics::getTypes
unsigned int getTypes() const
get # of types
Definition: HcalSiPMCharacteristics.h:65
HcalSiPMCharacteristics
Definition: HcalSiPMCharacteristics.h:18