CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Friends
HcalSiPMCharacteristics Class Reference

#include <HcalSiPMCharacteristics.h>

Classes

class  PrecisionItem
 

Public Member Functions

int getAuxi1 (int type) const
 get auxiliary words More...
 
float getAuxi2 (int type) const
 
float getCrossTalk (int type) const
 get cross talk More...
 
std::vector< float > getNonLinearities (int type) const
 get nonlinearity constants More...
 
int getPixels (int type) const
 get # of pixels More...
 
int getType (unsigned int k) const
 
unsigned int getTypes () const
 get # of types More...
 
 HcalSiPMCharacteristics ()
 
 HcalSiPMCharacteristics (const HcalSiPMCharacteristics &src)
 
 HcalSiPMCharacteristics (HcalSiPMCharacteristics &&other)
 
bool loadObject (int type, int pixels, float parLin1, float parLin2, float parLin3, float crossTalk, int auxi1=0, float auxi2=0)
 
HcalSiPMCharacteristicsoperator= (const HcalSiPMCharacteristics &rhs)
 
void sort ()
 
void sortByType () const
 
void swap (HcalSiPMCharacteristics &other)
 
 ~HcalSiPMCharacteristics ()
 

Protected Member Functions

const PrecisionItemfindByType (int type) const
 

Protected Attributes

std::vector< PrecisionItemmPItems
 
std::atomic< std::vector
< const PrecisionItem * > * > 
mPItemsByType
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 

Detailed Description

Definition at line 13 of file HcalSiPMCharacteristics.h.

Constructor & Destructor Documentation

HcalSiPMCharacteristics::HcalSiPMCharacteristics ( )

Definition at line 8 of file HcalSiPMCharacteristics.cc.

8 : mPItemsByType(nullptr) {}
std::atomic< std::vector< const PrecisionItem * > * > mPItemsByType
HcalSiPMCharacteristics::~HcalSiPMCharacteristics ( )

Definition at line 14 of file HcalSiPMCharacteristics.cc.

References mPItemsByType.

14  {
15  delete mPItemsByType.load();
16 }
std::atomic< std::vector< const PrecisionItem * > * > mPItemsByType
HcalSiPMCharacteristics::HcalSiPMCharacteristics ( const HcalSiPMCharacteristics src)

Definition at line 19 of file HcalSiPMCharacteristics.cc.

20  : mPItems(src.mPItems), mPItemsByType(nullptr) {}
std::atomic< std::vector< const PrecisionItem * > * > mPItemsByType
std::vector< PrecisionItem > mPItems
HcalSiPMCharacteristics::HcalSiPMCharacteristics ( HcalSiPMCharacteristics &&  other)

Definition at line 38 of file HcalSiPMCharacteristics.cc.

References swap().

39  other.swap(*this);
40 }
void swap(HcalSiPMCharacteristics &other)

Member Function Documentation

const HcalSiPMCharacteristics::PrecisionItem * HcalSiPMCharacteristics::findByType ( int  type) const
protected

Definition at line 42 of file HcalSiPMCharacteristics.cc.

References mPItemsByType, sortByType(), and filterCSVwithJSON::target.

Referenced by getAuxi1(), getAuxi2(), getCrossTalk(), getNonLinearities(), getPixels(), and loadObject().

42  {
44  std::vector<const HcalSiPMCharacteristics::PrecisionItem*>::const_iterator item;
45 
46  sortByType();
47  auto const& ptr = (*mPItemsByType.load(std::memory_order_acquire));
48  item = std::lower_bound (ptr.begin(), ptr.end(), &target, hcal_impl::LessByType());
49  if (item == ptr.end() || (*item)->type_ != type)
50  // throw cms::Exception ("Conditions not found") << "Unavailable SiPMCharacteristics for type " << type;
51  return 0;
52  return *item;
53 }
type
Definition: HCALResponse.h:21
std::atomic< std::vector< const PrecisionItem * > * > mPItemsByType
int HcalSiPMCharacteristics::getAuxi1 ( int  type) const

get auxiliary words

Definition at line 105 of file HcalSiPMCharacteristics.cc.

References HcalSiPMCharacteristics::PrecisionItem::auxi1_, and findByType().

105  {
107  return (item ? item->auxi1_ : 0);
108 }
type
Definition: HCALResponse.h:21
const PrecisionItem * findByType(int type) const
float HcalSiPMCharacteristics::getAuxi2 ( int  type) const
float HcalSiPMCharacteristics::getCrossTalk ( int  type) const

get cross talk

Definition at line 100 of file HcalSiPMCharacteristics.cc.

References HcalSiPMCharacteristics::PrecisionItem::crossTalk_, and findByType().

Referenced by HBHEPhase1Reconstructor::processData(), and HcalSimParameters::sipmCrossTalk().

100  {
101  const PrecisionItem* item = findByType(type);
102  return (item ? item->crossTalk_ : 0);
103 }
type
Definition: HCALResponse.h:21
const PrecisionItem * findByType(int type) const
std::vector< float > HcalSiPMCharacteristics::getNonLinearities ( int  type) const

get nonlinearity constants

Definition at line 89 of file HcalSiPMCharacteristics.cc.

References findByType(), HcalSiPMCharacteristics::PrecisionItem::parLin1_, HcalSiPMCharacteristics::PrecisionItem::parLin2_, and HcalSiPMCharacteristics::PrecisionItem::parLin3_.

Referenced by HcalSimParameters::sipmNonlinearity().

89  {
91  std::vector<float> pars;
92  if (item) {
93  pars.push_back(item->parLin1_);
94  pars.push_back(item->parLin2_);
95  pars.push_back(item->parLin3_);
96  }
97  return pars;
98 }
type
Definition: HCALResponse.h:21
const PrecisionItem * findByType(int type) const
int HcalSiPMCharacteristics::getPixels ( int  type) const

get # of pixels

Definition at line 84 of file HcalSiPMCharacteristics.cc.

References findByType(), and HcalSiPMCharacteristics::PrecisionItem::pixels_.

Referenced by HcalSimParameters::pixels().

int HcalSiPMCharacteristics::getType ( unsigned int  k) const
inline
unsigned int HcalSiPMCharacteristics::getTypes ( ) const
inline

get # of types

Definition at line 36 of file HcalSiPMCharacteristics.h.

References mPItems.

36 {return mPItems.size();}
std::vector< PrecisionItem > mPItems
bool HcalSiPMCharacteristics::loadObject ( int  type,
int  pixels,
float  parLin1,
float  parLin2,
float  parLin3,
float  crossTalk,
int  auxi1 = 0,
float  auxi2 = 0 
)

Definition at line 55 of file HcalSiPMCharacteristics.cc.

References HcalSiPMCharacteristics::PrecisionItem::crossTalk_, findByType(), mPItems, mPItemsByType, HcalSiPMCharacteristics::PrecisionItem::parLin1_, HcalSiPMCharacteristics::PrecisionItem::parLin2_, HcalSiPMCharacteristics::PrecisionItem::parLin3_, HcalSiPMCharacteristics::PrecisionItem::pixels_, and filterCSVwithJSON::target.

58  {
60  if (item) {
61  edm::LogWarning("HCAL") << "HcalSiPMCharacteristics::loadObject type "
62  << type << " already exists with pixels "
63  << item->pixels_ << " NoLinearity parameters "
64  << item->parLin1_ << ":" << item->parLin2_ << ":"
65  << item->parLin3_ << " CrossTalk parameter "
66  << item->crossTalk_ << " new values " << pixels
67  << ", " << parLin1 << ", " << parLin2 << ", "
68  << parLin3 << ", " << crossTalk << ", " << auxi1
69  << " and " << auxi2 << " are ignored";
70  return false;
71  } else {
73  parLin2,parLin3,crossTalk,
74  auxi1,auxi2);
75  mPItems.push_back(target);
76  if (mPItemsByType) {
77  delete mPItemsByType.load();
78  mPItemsByType = nullptr;
79  }
80  return true;
81  }
82 }
type
Definition: HCALResponse.h:21
std::atomic< std::vector< const PrecisionItem * > * > mPItemsByType
const PrecisionItem * findByType(int type) const
std::vector< PrecisionItem > mPItems
HcalSiPMCharacteristics & HcalSiPMCharacteristics::operator= ( const HcalSiPMCharacteristics rhs)

Definition at line 23 of file HcalSiPMCharacteristics.cc.

References swap(), and groupFilesInBlocks::temp.

23  {
25  temp.swap(*this);
26  return *this;
27 }
template<class Archive >
void HcalSiPMCharacteristics::serialize ( Archive &  ar,
const unsigned int  version 
)
private
void HcalSiPMCharacteristics::sort ( )
inline

Definition at line 50 of file HcalSiPMCharacteristics.h.

50 {}
void HcalSiPMCharacteristics::sortByType ( ) const

Definition at line 115 of file HcalSiPMCharacteristics.cc.

References i, mPItems, and mPItemsByType.

Referenced by findByType().

115  {
116  if (!mPItemsByType.load(std::memory_order_acquire)) {
117  auto ptr = new std::vector<const PrecisionItem*>;
118  for (auto i=mPItems.begin(); i!=mPItems.end(); ++i) {
119  if (i->type_) (*ptr).push_back(&(*i));
120  }
121 
122  std::sort ((*ptr).begin(), (*ptr).end(), hcal_impl::LessByType());
123  //atomically try to swap this to become mPItemsByType
124  std::vector<const PrecisionItem*>* expect = nullptr;
125  bool exchanged = mPItemsByType.compare_exchange_strong(expect, ptr, std::memory_order_acq_rel);
126  if(!exchanged) {
127  delete ptr;
128  }
129  }
130 }
int i
Definition: DBlmapReader.cc:9
std::atomic< std::vector< const PrecisionItem * > * > mPItemsByType
std::vector< PrecisionItem > mPItems
void HcalSiPMCharacteristics::swap ( HcalSiPMCharacteristics other)

Definition at line 30 of file HcalSiPMCharacteristics.cc.

References mPItems, mPItemsByType, and std::swap().

Referenced by HcalSiPMCharacteristics(), and operator=().

30  {
31  std::swap(mPItems, other.mPItems);
32  other.mPItemsByType.exchange(mPItemsByType.exchange(other.mPItemsByType.load(std::memory_order_acquire),
33  std::memory_order_acq_rel),
34  std::memory_order_acq_rel);
35 }
std::atomic< std::vector< const PrecisionItem * > * > mPItemsByType
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::vector< PrecisionItem > mPItems

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 84 of file HcalSiPMCharacteristics.h.

template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 84 of file HcalSiPMCharacteristics.h.

Member Data Documentation

std::vector<PrecisionItem> HcalSiPMCharacteristics::mPItems
protected

Definition at line 77 of file HcalSiPMCharacteristics.h.

Referenced by getType(), getTypes(), loadObject(), sortByType(), and swap().

std::atomic<std::vector<const PrecisionItem*>*> HcalSiPMCharacteristics::mPItemsByType
mutableprotected