CMS 3D CMS Logo

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

#include <CSCCrosstalkDBConditions.h>

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

Public Types

typedef std::unique_ptr< CSCDBCrosstalkReturnType
 

Public Member Functions

 CSCCrosstalkDBConditions (const edm::ParameterSet &)
 
ReturnType produceDBCrosstalk (const CSCDBCrosstalkRcd &)
 
 ~CSCCrosstalkDBConditions () 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 CSCDBCrosstalkprefillDBCrosstalk ()
 
- 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
 

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 >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
template<typename TFunc >
auto setWhatProduced (TFunc &&func, const es::Label &iLabel={})
 
template<typename TReturn , typename TRecord , typename TFunc , typename TDecorator >
ESConsumesCollectorT< TRecord > setWhatProduced (TFunc &&func, TDecorator &&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 CSCCrosstalkDBConditions.h.

Member Typedef Documentation

◆ ReturnType

Definition at line 27 of file CSCCrosstalkDBConditions.h.

Constructor & Destructor Documentation

◆ CSCCrosstalkDBConditions()

CSCCrosstalkDBConditions::CSCCrosstalkDBConditions ( const edm::ParameterSet iConfig)

Definition at line 8 of file CSCCrosstalkDBConditions.cc.

References produceDBCrosstalk(), 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<CSCDBCrosstalkRcd>();
14  // now do what ever other initialization is needed
15 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
ReturnType produceDBCrosstalk(const CSCDBCrosstalkRcd &)

◆ ~CSCCrosstalkDBConditions()

CSCCrosstalkDBConditions::~CSCCrosstalkDBConditions ( )
override

Definition at line 17 of file CSCCrosstalkDBConditions.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

◆ prefillDBCrosstalk()

CSCDBCrosstalk * CSCCrosstalkDBConditions::prefillDBCrosstalk ( )
inlinestatic

Definition at line 43 of file CSCCrosstalkDBConditions.h.

References DMR_cfg::cerr, counter, CSCDBCrosstalk::crosstalk, beamvalidation::exit(), CSCDBCrosstalk::factor_intercept, CSCDBCrosstalk::factor_slope, mps_fire::i, recoMuon::in, createfilelist::int, dqmdumpme::k, and pixelgpudetails::MAX_SIZE.

Referenced by produceDBCrosstalk().

43  {
44  // const int MAX_SIZE = 273024; //for ME1a unganged
45  const int MAX_SIZE = 252288;
46  const int SLOPE_FACTOR = 10000000;
47  const int INTERCEPT_FACTOR = 100000;
48  const int MAX_SHORT = 32767;
49  CSCDBCrosstalk *cndbcrosstalk = new CSCDBCrosstalk();
50 
51  int db_index, new_index;
52  float db_slope_right, db_slope_left, db_intercept_right;
53  float db_intercept_left;
54  std::vector<int> db_index_id;
55  std::vector<float> db_slope_r;
56  std::vector<float> db_intercept_r;
57  std::vector<float> db_slope_l;
58  std::vector<float> db_intercept_l;
59  float new_slope_right, new_slope_left, new_intercept_right;
60  float new_intercept_left;
61  std::vector<int> new_index_id;
62  std::vector<float> new_slope_r;
63  std::vector<float> new_intercept_r;
64  std::vector<float> new_slope_l;
65  std::vector<float> new_intercept_l;
66 
67  int counter;
68  int db_nrlines = 0;
69  int new_nrlines = 0;
70 
71  std::ifstream dbdata;
72  dbdata.open("old_dbxtalk.dat", std::ios::in);
73  if (!dbdata) {
74  std::cerr << "Error: old_dbxtalk.dat -> no such file!" << std::endl;
75  exit(1);
76  }
77 
78  while (!dbdata.eof()) {
79  dbdata >> db_index >> db_slope_right >> db_intercept_right >> db_slope_left >> db_intercept_left;
80  db_index_id.push_back(db_index);
81  db_slope_r.push_back(db_slope_right);
82  db_slope_l.push_back(db_slope_left);
83  db_intercept_r.push_back(db_intercept_right);
84  db_intercept_l.push_back(db_intercept_left);
85  db_nrlines++;
86  }
87  dbdata.close();
88 
89  std::ifstream newdata;
90  newdata.open("xtalk.dat", std::ios::in);
91  if (!newdata) {
92  std::cerr << "Error: xtalk.dat -> no such file!" << std::endl;
93  exit(1);
94  }
95 
96  while (!newdata.eof()) {
97  newdata >> new_index >> new_slope_right >> new_intercept_right >> new_slope_left >> new_intercept_left;
98  new_index_id.push_back(new_index);
99  new_slope_r.push_back(new_slope_right);
100  new_slope_l.push_back(new_slope_left);
101  new_intercept_r.push_back(new_intercept_right);
102  new_intercept_l.push_back(new_intercept_left);
103  new_nrlines++;
104  }
105  newdata.close();
106 
107  CSCDBCrosstalk::CrosstalkContainer &itemvector = cndbcrosstalk->crosstalk;
108  itemvector.resize(MAX_SIZE);
109  cndbcrosstalk->factor_slope = int(SLOPE_FACTOR);
110  cndbcrosstalk->factor_intercept = int(INTERCEPT_FACTOR);
111 
112  for (int i = 0; i < MAX_SIZE; ++i) {
113  itemvector[i].xtalk_slope_right = (short int)(db_slope_r[i] * SLOPE_FACTOR + 0.5);
114  itemvector[i].xtalk_intercept_right = (short int)(db_intercept_r[i] * INTERCEPT_FACTOR + 0.5);
115  itemvector[i].xtalk_slope_left = (short int)(db_slope_l[i] * SLOPE_FACTOR + 0.5);
116  itemvector[i].xtalk_intercept_left = (short int)(db_intercept_l[i] * INTERCEPT_FACTOR + 0.5);
117  }
118 
119  for (int i = 0; i < MAX_SIZE; ++i) {
120  counter = db_index_id[i];
121  for (unsigned int k = 0; k < new_index_id.size() - 1; k++) {
122  if (counter == new_index_id[k]) {
123  if ((short int)(fabs(new_slope_r[k] * SLOPE_FACTOR + 0.5)) < MAX_SHORT)
124  itemvector[counter].xtalk_slope_right = int(new_slope_r[k] * SLOPE_FACTOR + 0.5);
125  if ((short int)(fabs(new_intercept_r[k] * INTERCEPT_FACTOR + 0.5)) < MAX_SHORT)
126  itemvector[counter].xtalk_intercept_right = int(new_intercept_r[k] * INTERCEPT_FACTOR + 0.5);
127  if ((short int)(fabs(new_slope_l[k] * SLOPE_FACTOR + 0.5)) < MAX_SHORT)
128  itemvector[counter].xtalk_slope_left = int(new_slope_l[k] * SLOPE_FACTOR + 0.5);
129  if ((short int)(fabs(new_intercept_l[k] * INTERCEPT_FACTOR + 0.5)) < MAX_SHORT)
130  itemvector[counter].xtalk_intercept_left = int(new_intercept_l[k] * INTERCEPT_FACTOR + 0.5);
131  itemvector[i] = itemvector[counter];
132  // std::cout<<" counter "<<counter <<" dbindex "<<new_index_id[k]<<"
133  // dbslope " <<db_slope_r[k]<<" new slope "<<new_slope_r[k]<<std::endl;
134  }
135  }
136 
137  if (counter > 223968) {
138  itemvector[counter].xtalk_slope_right = int(db_slope_r[i]);
139  itemvector[counter].xtalk_slope_left = int(db_slope_l[i]);
140  itemvector[counter].xtalk_intercept_right = int(db_intercept_r[i]);
141  itemvector[counter].xtalk_intercept_left = int(db_intercept_l[i]);
142  }
143  }
144 
145  return cndbcrosstalk;
146 }
std::vector< Item > CrosstalkContainer
static std::atomic< unsigned int > counter
constexpr unsigned int MAX_SIZE
CrosstalkContainer crosstalk
def exit(msg="")

◆ produceDBCrosstalk()

CSCCrosstalkDBConditions::ReturnType CSCCrosstalkDBConditions::produceDBCrosstalk ( const CSCDBCrosstalkRcd iRecord)

Definition at line 27 of file CSCCrosstalkDBConditions.cc.

References prefillDBCrosstalk().

Referenced by CSCCrosstalkDBConditions().

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

◆ setIntervalFor()

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

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 32 of file CSCCrosstalkDBConditions.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