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
CSCGasGainCorrectionDBConditions Class Reference

#include <CSCGasGainCorrectionDBConditions.h>

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

Public Types

typedef const
CSCDBGasGainCorrection
ReturnType
 
- 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

 CSCGasGainCorrectionDBConditions (const edm::ParameterSet &)
 
ReturnType produceDBGasGainCorrection (const CSCDBGasGainCorrectionRcd &)
 
 ~CSCGasGainCorrectionDBConditions ()
 
- 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 CSCDBGasGainCorrectionprefillDBGasGainCorrection (bool isForMC, std::string dataCorrFileName)
 
- 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

CSCDBGasGainCorrectioncndbGasGainCorr
 
std::string dataCorrFileName
 
bool isForMC
 

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 21 of file CSCGasGainCorrectionDBConditions.h.

Member Typedef Documentation

Definition at line 28 of file CSCGasGainCorrectionDBConditions.h.

Constructor & Destructor Documentation

CSCGasGainCorrectionDBConditions::CSCGasGainCorrectionDBConditions ( const edm::ParameterSet iConfig)

Definition at line 10 of file CSCGasGainCorrectionDBConditions.cc.

References cndbGasGainCorr, dataCorrFileName, edm::ParameterSet::getUntrackedParameter(), isForMC, prefillDBGasGainCorrection(), produceDBGasGainCorrection(), edm::ESProducer::setWhatProduced(), and AlCaHLTBitMon_QueryRunRegistry::string.

11 {
12  //the following line is needed to tell the framework what
13  // data is being produced
14  isForMC = iConfig.getUntrackedParameter<bool>("isForMC",true);
15  dataCorrFileName= iConfig.getUntrackedParameter<std::string>("dataCorrFileName","empty.txt");
17  // added by Zhen (changed since 1_2_0)
19  findingRecord<CSCDBGasGainCorrectionRcd>();
20  //now do what ever other initialization is needed
21 
22 }
T getUntrackedParameter(std::string const &, T const &) const
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
static CSCDBGasGainCorrection * prefillDBGasGainCorrection(bool isForMC, std::string dataCorrFileName)
ReturnType produceDBGasGainCorrection(const CSCDBGasGainCorrectionRcd &)
CSCGasGainCorrectionDBConditions::~CSCGasGainCorrectionDBConditions ( )

Definition at line 25 of file CSCGasGainCorrectionDBConditions.cc.

References cndbGasGainCorr.

26 {
27 
28  // do anything here that needs to be done at desctruction time
29  // (e.g. close files, deallocate resources etc.)
30  delete cndbGasGainCorr;
31 }

Member Function Documentation

CSCDBGasGainCorrection * CSCGasGainCorrectionDBConditions::prefillDBGasGainCorrection ( bool  isForMC,
std::string  dataCorrFileName 
)
inlinestatic

Definition at line 55 of file CSCGasGainCorrectionDBConditions.h.

References assert(), trackerTree::check(), cndbGasGainCorr, gather_cfg::cout, Reference_intrackfit_cff::endcap, groupFilesInBlocks::fin, CSCDBGasGainCorrection::gasGainCorr, i, j, timingPdfMaker::mean, relativeConstraints::ring, and relativeConstraints::station.

Referenced by CSCGasGainCorrectionDBConditions().

56 {
57  if (isMC)
58  printf("\n Generating fake DB constants for MC\n");
59  else {
60  printf("\n Reading gas gain corrections from file %s \n",filename.data());
61  }
62 
63  CSCIndexer indexer;
64 
65  const int MAX_SIZE = 55944;
66 
68 
69  CSCDBGasGainCorrection::GasGainContainer & itemvector = cndbGasGainCorr->gasGainCorr;
70  itemvector.resize(MAX_SIZE);
71 
72  //Filling corrections for MC is very simple
73  if (isMC){
74  for (int i=0;i<MAX_SIZE;i++){
75  itemvector[i].gainCorr = 1.;
76  }
77  return cndbGasGainCorr;
78  }
79 
80  struct gain_info {
81  int gas_gain_index ;
82  int endcap ;
83  int station ;
84  int ring ;
85  int chamber ;
86  int layer ;
87  int hvsegment ;
88  int cfeb ;
89  int nentries ;
90  float mean ;
91  float truncated_mean ;
92  float gas_gain_correction;
93  } gains[MAX_SIZE];
94 
95 
96  for (int j=0; j<MAX_SIZE; j++) {
97  gains[j].gas_gain_index = -999;
98  gains[j].endcap = -999;
99  gains[j].station = -999;
100  gains[j].ring = -999;
101  gains[j].chamber = -999;
102  gains[j].layer = -999;
103  gains[j].hvsegment = -999;
104  gains[j].cfeb = -999;
105  gains[j].nentries = -999;
106  gains[j].mean = -999.;
107  gains[j].truncated_mean = -999.;
108  gains[j].gas_gain_correction= -999.;
109  }
110 
111  FILE *fin = fopen(filename.data(),"r");
112 
113  int linecounter = 0; // set the line counter to the first serial number in the file....
114 
115  while (!feof(fin)){
116  //note space at end of format string to convert last \n
117  int check = fscanf(fin,"%d %d %d %d %d %d %d %d %d %f %f %f \n",
118  &gains[linecounter].gas_gain_index ,
119  &gains[linecounter].endcap ,
120  &gains[linecounter].station ,
121  &gains[linecounter].ring ,
122  &gains[linecounter].chamber ,
123  &gains[linecounter].layer ,
124  &gains[linecounter].hvsegment ,
125  &gains[linecounter].cfeb ,
126  &gains[linecounter].nentries ,
127  &gains[linecounter].mean ,
128  &gains[linecounter].truncated_mean ,
129  &gains[linecounter].gas_gain_correction);
130 
131  if (check != 12){
132  printf("The input file format is not as expected\n");
133  assert(0);
134  }
135 
136  linecounter++;
137 
138  }
139 
140  fclose(fin);
141 
142  if (linecounter == MAX_SIZE) {
143  std::cout << "Total number of gas gains read in = " << linecounter << std::endl;
144  } else {
145  std::cout << "ERROR: Total number of gas-gains read in = " << linecounter
146  << " while total number expected = " << MAX_SIZE << std::endl;
147  }
148 
149  // Fill the chip corrections with values from the file
150  for (int i=0;i<MAX_SIZE;i++){
151 
152  itemvector[i].gainCorr = 0.;
153 
154  if (gains[i].gas_gain_correction > 0.) {
155  itemvector[i].gainCorr = gains[i].gas_gain_correction;
156  } else {
157  // if there is no value, this should be fixed...
158  std::cout << "ERROR: gas_gain_correction < 0 for index " << gains[i].gas_gain_index << std::endl;
159  }
160  }
161 
162  return cndbGasGainCorr;
163 }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
int j
Definition: DBlmapReader.cc:9
std::vector< Item > GasGainContainer
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:145
CSCGasGainCorrectionDBConditions::ReturnType CSCGasGainCorrectionDBConditions::produceDBGasGainCorrection ( const CSCDBGasGainCorrectionRcd iRecord)

Definition at line 40 of file CSCGasGainCorrectionDBConditions.cc.

References cndbGasGainCorr.

Referenced by CSCGasGainCorrectionDBConditions().

41 {
42  //need a new object so to not be deleted at exit
44  return mydata;
45 
46 }
void CSCGasGainCorrectionDBConditions::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey ,
const edm::IOVSyncValue ,
edm::ValidityInterval oValidity 
)
privatevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 48 of file CSCGasGainCorrectionDBConditions.cc.

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

50 {
52 
53 }
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

CSCDBGasGainCorrection* CSCGasGainCorrectionDBConditions::cndbGasGainCorr
private
std::string CSCGasGainCorrectionDBConditions::dataCorrFileName
private

Definition at line 40 of file CSCGasGainCorrectionDBConditions.h.

Referenced by CSCGasGainCorrectionDBConditions().

bool CSCGasGainCorrectionDBConditions::isForMC
private

Definition at line 38 of file CSCGasGainCorrectionDBConditions.h.

Referenced by CSCGasGainCorrectionDBConditions().