CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
CSCGainsDBConditions Class Reference

#include <CSCGainsDBConditions.h>

Inheritance diagram for CSCGainsDBConditions:
edm::ESProducer edm::EventSetupRecordIntervalFinder edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Types

typedef std::unique_ptr< CSCDBGainsReturnType
 

Public Member Functions

 CSCGainsDBConditions (const edm::ParameterSet &)
 
ReturnType produceDBGains (const CSCDBGainsRcd &)
 
 ~CSCGainsDBConditions () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ESProducer (const ESProducer &)=delete
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProducer const & operator= (const ESProducer &)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESProxyIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
 ESProxyFactoryProducer (const ESProxyFactoryProducer &)=delete
 
const ESProxyFactoryProduceroperator= (const ESProxyFactoryProducer &)=delete
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
void createKeyedProxies (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
 DataProxyProvider ()
 
 DataProxyProvider (const DataProxyProvider &)=delete
 
const ComponentDescriptiondescription () const
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const DataProxyProvideroperator= (const DataProxyProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () noexcept(false)
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
bool concurrentFinder () const
 
const eventsetup::ComponentDescriptiondescriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
 EventSetupRecordIntervalFinder (const EventSetupRecordIntervalFinder &)=delete
 
std::set< eventsetup::EventSetupRecordKeyfindingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
bool nonconcurrentAndIOVNeedsUpdate (const eventsetup::EventSetupRecordKey &key, const IOVSyncValue &syncValue) const
 
const EventSetupRecordIntervalFinderoperator= (const EventSetupRecordIntervalFinder &)=delete
 
void resetInterval (const eventsetup::EventSetupRecordKey &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder () noexcept(false)
 

Static Public Member Functions

static CSCDBGainsprefillDBGains ()
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 

Private Member Functions

void setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
 

Private Attributes

CSCDBGainscndbGains
 

Additional Inherited Members

- Protected Types inherited from edm::ESProxyFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::DataProxyProvider
using KeyedProxiesVector = std::vector< std::pair< DataKey, std::shared_ptr< DataProxy > >>
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
ESConsumesCollectorT< TRecord > setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
void usesResources (std::vector< std::string > const &)
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedProxiesVector registerProxies (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 
- Protected Member Functions inherited from edm::EventSetupRecordIntervalFinder
template<class T >
void findingRecord ()
 
void findingRecordWithKey (const eventsetup::EventSetupRecordKey &)
 

Detailed Description

Definition at line 20 of file CSCGainsDBConditions.h.

Member Typedef Documentation

◆ ReturnType

typedef std::unique_ptr<CSCDBGains> CSCGainsDBConditions::ReturnType

Definition at line 27 of file CSCGainsDBConditions.h.

Constructor & Destructor Documentation

◆ CSCGainsDBConditions()

CSCGainsDBConditions::CSCGainsDBConditions ( const edm::ParameterSet iConfig)

Definition at line 8 of file CSCGainsDBConditions.cc.

References produceDBGains(), and edm::ESProducer::setWhatProduced().

8  {
9  // the following line is needed to tell the framework what
10  // data is being produced
11  // added by Zhen (changed since 1_2_0)
13  findingRecord<CSCDBGainsRcd>();
14  // now do what ever other initialization is needed
15 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
ReturnType produceDBGains(const CSCDBGainsRcd &)

◆ ~CSCGainsDBConditions()

CSCGainsDBConditions::~CSCGainsDBConditions ( )
override

Definition at line 17 of file CSCGainsDBConditions.cc.

17  {
18  // do anything here that needs to be done at desctruction time
19  // (e.g. close files, deallocate resources etc.)
20 }

Member Function Documentation

◆ prefillDBGains()

CSCDBGains * CSCGainsDBConditions::prefillDBGains ( )
inlinestatic

Definition at line 44 of file CSCGainsDBConditions.h.

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, counter, gather_cfg::cout, beamvalidation::exit(), CSCDBGains::factor_gain, CSCDBGains::gains, mps_fire::i, recoMuon::in, createfilelist::int, dqmdumpme::k, and pixelgpudetails::MAX_SIZE.

Referenced by produceDBGains().

44  {
45  // const int MAX_SIZE = 273024;//for ME1a unganged
46  const int MAX_SIZE = 252288;
47  const int FACTOR = 1000;
48  const int MAX_SHORT = 32767;
49  CSCDBGains *cndbgains = new CSCDBGains();
50 
51  int db_index;
52  float db_gainslope; // db_intercpt, db_chisq;
53  std::vector<int> db_index_id;
54  std::vector<float> db_slope;
55  std::vector<float> db_intercept;
56  std::vector<float> db_chi2;
57  int new_index;
58  float new_gainslope, new_intercpt, new_chisq;
59  std::vector<int> new_cham_id;
60  std::vector<int> new_index_id;
61  std::vector<int> new_strips;
62  std::vector<float> new_slope;
63  std::vector<float> new_intercept;
64  std::vector<float> new_chi2;
65 
66  int counter;
67  int db_nrlines = 0;
68  int new_nrlines = 0;
69 
70  std::ifstream dbdata;
71  dbdata.open("old_dbgains.dat", std::ios::in);
72  if (!dbdata) {
73  std::cerr << "Error: old_dbgains.dat -> no such file!" << std::endl;
74  exit(1);
75  }
76 
77  while (!dbdata.eof()) {
78  dbdata >> db_index >> db_gainslope;
79  db_index_id.push_back(db_index);
80  db_slope.push_back(db_gainslope);
81  // db_intercept.push_back(db_intercpt);
82  // db_chi2.push_back(db_chisq);
83  db_nrlines++;
84  }
85  dbdata.close();
86 
87  std::ifstream newdata;
88  newdata.open("gains.dat", std::ios::in);
89  if (!newdata) {
90  std::cerr << "Error: gains.dat -> no such file!" << std::endl;
91  exit(1);
92  }
93 
94  while (!newdata.eof()) {
95  newdata >> new_index >> new_gainslope >> new_intercpt >> new_chisq;
96  new_index_id.push_back(new_index);
97  new_slope.push_back(new_gainslope);
98  new_intercept.push_back(new_intercpt);
99  new_chi2.push_back(new_chisq);
100  new_nrlines++;
101  }
102  newdata.close();
103 
104  CSCDBGains::GainContainer &itemvector = cndbgains->gains;
105  itemvector.resize(MAX_SIZE);
106  cndbgains->factor_gain = (short int)(FACTOR);
107  std::cout << " myfactor " << cndbgains->factor_gain << std::endl;
108 
109  for (int i = 0; i < MAX_SIZE; ++i) {
110  itemvector[i].gain_slope = int(db_slope[i] * FACTOR + 0.5);
111  }
112 
113  for (int i = 0; i < MAX_SIZE; ++i) {
114  counter = db_index_id[i];
115  itemvector[i] = itemvector[counter];
116  itemvector[i].gain_slope = int(db_slope[i]);
117 
118  for (unsigned int k = 0; k < new_index_id.size() - 1; k++) {
119  if (counter == new_index_id[k]) {
120  if ((short int)(fabs(new_slope[k] * FACTOR + 0.5)) < MAX_SHORT)
121  itemvector[counter].gain_slope = int(new_slope[k] * FACTOR + 0.5);
122  itemvector[i] = itemvector[counter];
123  }
124  }
125  if (counter > 223968) {
126  itemvector[counter].gain_slope = int(db_slope[i]);
127  itemvector[i] = itemvector[counter];
128  }
129  }
130  return cndbgains;
131 }
GainContainer gains
Definition: CSCDBGains.h:24
int factor_gain
Definition: CSCDBGains.h:19
std::vector< Item > GainContainer
Definition: CSCDBGains.h:23
static std::atomic< unsigned int > counter
constexpr unsigned int MAX_SIZE
def exit(msg="")

◆ produceDBGains()

CSCGainsDBConditions::ReturnType CSCGainsDBConditions::produceDBGains ( const CSCDBGainsRcd iRecord)

Definition at line 27 of file CSCGainsDBConditions.cc.

References prefillDBGains().

Referenced by CSCGainsDBConditions().

27  {
28  // need a new object so to not be deleted at exit
30 }
static CSCDBGains * prefillDBGains()
std::unique_ptr< CSCDBGains > ReturnType

◆ setIntervalFor()

void CSCGainsDBConditions::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey ,
const edm::IOVSyncValue ,
edm::ValidityInterval oValidity 
)
overrideprivatevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 32 of file CSCGainsDBConditions.cc.

References edm::IOVSyncValue::beginOfTime(), and edm::IOVSyncValue::endOfTime().

34  {
36 }
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88

Member Data Documentation

◆ cndbGains

CSCDBGains* CSCGainsDBConditions::cndbGains
private

Definition at line 36 of file CSCGainsDBConditions.h.