CMS 3D CMS Logo

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 std::unique_ptr< CSCDBGasGainCorrectionReturnType
 
- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
 
typedef std::vector< EventSetupRecordKeyKeys
 
typedef std::map< EventSetupRecordKey, KeyedProxiesRecordProxies
 

Public Member Functions

 CSCGasGainCorrectionDBConditions (const edm::ParameterSet &)
 
ReturnType produceDBGasGainCorrection (const CSCDBGasGainCorrectionRcd &)
 
 ~CSCGasGainCorrectionDBConditions () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer ()(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval) override
 overrides DataProxyProvider method More...
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- 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 () noexcept(false)
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
const eventsetup::ComponentDescriptiondescriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
std::set< eventsetup::EventSetupRecordKeyfindingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder () noexcept(false)
 

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

Private Attributes

std::string dataCorrFileName
 
bool isForMC
 

Additional Inherited Members

- Protected Member Functions inherited from edm::ESProducer
 ESProducer (const ESProducer &)=delete
 
ESProducer const & operator= (const ESProducer &)=delete
 
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={})
 
- 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 eventsetup::EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList) override
 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 8 of file CSCGasGainCorrectionDBConditions.cc.

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

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

Definition at line 19 of file CSCGasGainCorrectionDBConditions.cc.

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

Member Function Documentation

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

Definition at line 53 of file CSCGasGainCorrectionDBConditions.h.

References relativeConstraints::chamber, trackerTree::check(), gather_cfg::cout, makeMuonMisalignmentScenario::endcap, groupFilesInBlocks::fin, CSCDBGasGainCorrection::gasGainCorr, mps_fire::i, SiStripPI::mean, relativeConstraints::ring, and relativeConstraints::station.

Referenced by produceDBGasGainCorrection().

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

Definition at line 29 of file CSCGasGainCorrectionDBConditions.cc.

References dataCorrFileName, isForMC, and prefillDBGasGainCorrection().

Referenced by CSCGasGainCorrectionDBConditions().

30  {
31  // need a new object so to not be deleted at exit
33 }
std::unique_ptr< CSCDBGasGainCorrection > ReturnType
static CSCDBGasGainCorrection * prefillDBGasGainCorrection(bool isForMC, std::string dataCorrFileName)
void CSCGasGainCorrectionDBConditions::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey ,
const edm::IOVSyncValue ,
edm::ValidityInterval oValidity 
)
overrideprivatevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 35 of file CSCGasGainCorrectionDBConditions.cc.

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

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

Member Data Documentation

std::string CSCGasGainCorrectionDBConditions::dataCorrFileName
private
bool CSCGasGainCorrectionDBConditions::isForMC
private