CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 const CSCDBGainsReturnType
 
- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair
< DataKey,
edm::propagate_const
< std::shared_ptr< DataProxy > > > > 
KeyedProxies
 
typedef std::vector
< EventSetupRecordKey
Keys
 
typedef std::map
< EventSetupRecordKey,
KeyedProxies
RecordProxies
 

Public Member Functions

 CSCGainsDBConditions (const edm::ParameterSet &)
 
ReturnType produceDBGains (const CSCDBGainsRcd &)
 
 ~CSCGainsDBConditions ()
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer ()
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider ()
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
const
eventsetup::ComponentDescription
descriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
std::set
< eventsetup::EventSetupRecordKey
findingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder ()
 

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 &)
 

Private Attributes

CSCDBGainscndbGains
 

Additional Inherited Members

- Protected Member Functions inherited from edm::ESProducer
template<typename T >
void setWhatProduced (T *iThis, const es::Label &iLabel=es::Label())
 
template<typename T >
void setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
void setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
void setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel=es::Label())
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::auto_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::auto_ptr< eventsetup::ProxyFactoryBase > &iFactory, const std::string &iLabel=std::string())
 
virtual void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList)
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 
- 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

Definition at line 28 of file CSCGainsDBConditions.h.

Constructor & Destructor Documentation

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

Definition at line 10 of file CSCGainsDBConditions.cc.

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

11 {
12  //the following line is needed to tell the framework what
13  // data is being produced
15  // added by Zhen (changed since 1_2_0)
17  findingRecord<CSCDBGainsRcd>();
18  //now do what ever other initialization is needed
19 }
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
ReturnType produceDBGains(const CSCDBGainsRcd &)
static CSCDBGains * prefillDBGains()
CSCGainsDBConditions::~CSCGainsDBConditions ( )

Definition at line 22 of file CSCGainsDBConditions.cc.

References cndbGains.

23 {
24 
25  // do anything here that needs to be done at desctruction time
26  // (e.g. close files, deallocate resources etc.)
27  delete cndbGains;
28 }

Member Function Documentation

CSCDBGains * CSCGainsDBConditions::prefillDBGains ( )
inlinestatic

Definition at line 44 of file CSCGainsDBConditions.h.

References ecal_dqm_sourceclient-live_cfg::cerr, counter, gather_cfg::cout, cmsRelvalreport::exit, CSCDBGains::factor_gain, CSCDBGains::gains, i, recoMuon::in, and relval_2017::k.

Referenced by CSCGainsDBConditions().

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

Definition at line 37 of file CSCGainsDBConditions.cc.

References cndbGains.

Referenced by CSCGainsDBConditions().

38 {
39  //need a new object so to not be deleted at exit
40  CSCDBGains* mydata=new CSCDBGains( *cndbGains );
41  return mydata;
42 
43 }
void CSCGainsDBConditions::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey ,
const edm::IOVSyncValue ,
edm::ValidityInterval oValidity 
)
privatevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 45 of file CSCGainsDBConditions.cc.

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

47  {
49 
50  }
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
static const IOVSyncValue & beginOfTime()

Member Data Documentation

CSCDBGains* CSCGainsDBConditions::cndbGains
private